// Implementation of QTreeChangeBar
#include <clientapi.h>
#include <qcanvas.h>
#include "qtreeitem.h"
#include "changesorter.h"
#include "filehead.h"
#include "clientchangeuser.h"
#include "qtreechangenum.h"
#include "qtreechangebar.h"
// Create a changebar based on the given ChangeSorter.
QTreeChangeBar::QTreeChangeBar( QCanvas* can, ChangeSorter* chgs, bool trunc )
: QCanvasRectangle( can ), changes( chgs )
{
int numchanges;
if ( trunc )
numchanges = changes->ArrSize();
else
numchanges = changes->Size();
// Set geometry.
int mywidth = numchanges*TREE_BALLSPACE;
if ( mywidth < TREE_BARWIDTH ) mywidth = TREE_BARWIDTH;
setSize( mywidth, TREE_BARHEIGHT );
setZ( 1 );
setPen( QPen::NoPen );
// Put down numbers.
nums = new QTreeChangeNum*[numchanges];
QString cnum, tip;
FileRev* frev;
for ( int a = 0 ; a < numchanges ; a++ )
{
if ( trunc )
{
cnum = changes->GetArrChange( a + 1 ).Text();
frev = changes->GetArrRev( a + 1 );
}
else
{
cnum = changes->GetChange( a + 1 ).Text();
frev = changes->GetRev( a + 1 );
}
tip = QString( "Change ");
tip += cnum;
tip += " on ";
tip += frev->date.Text();
tip += " by ";
tip += frev->user.Text();
nums[a] = new QTreeChangeNum( can, cnum, tip );
// Move into place and center.
nums[a]->move( a*TREE_BALLSPACE +
TREE_BALLSPACE/2 - nums[a]->boundingRect().width()/2,
TREE_BARHEIGHT/2 - nums[a]->boundingRect().height()/2 );
nums[a]->show();
}
// black line at bottom of bar
bline = new QCanvasLine( can );
QRect r = rect();
bline->setPoints( r.left(), r.bottom(), r.right(), r.bottom() );
bline->setZ( 10 );
bline->show();
}
QTreeChangeBar::~QTreeChangeBar()
{
}
// Called on construction or when changing color scheme.
void QTreeChangeBar::UpdateBrush()
{
setBrush( QBrush( QColor( TREE_COLCBAR ) ) );
}