// Implementation of QTreeToolTip.
#include <clientapi.h>
#include <qcanvas.h>
#include <qtooltip.h>
#include "qtreeitem.h"
#include "clientchangeuser.h"
#include "clientjobdescuser.h"
#include "qtreerevball.h"
#include "qtreefiletext.h"
#include "qtreechangenum.h"
#include "qtreejobtext.h"
#include "qtreetooltip.h"
QTreeToolTip::QTreeToolTip( QCanvasView* parent )
: QToolTip( parent->viewport() ), view( parent )
{
}
QTreeToolTip::~QTreeToolTip()
{
}
void QTreeToolTip::maybeTip( const QPoint& p )
{
QPoint pos = view->viewportToContents( p );
QCanvasItemList items = view->canvas()->collisions( pos );
QCanvasItem* item = NULL;
int rtti = 0;
while ( !items.empty() )
{
item = items.front();
rtti = item ? item->rtti() : 0;
if ( rtti == RTTI_REV ||
rtti == RTTI_FILE ||
rtti == RTTI_JOB ||
rtti == RTTI_CHANGE ) break;
items.pop_front();
}
if ( rtti != RTTI_REV &&
rtti != RTTI_FILE &&
rtti != RTTI_JOB &&
rtti != RTTI_CHANGE )
return;
QString tiptext;
switch ( rtti )
{
case RTTI_REV:
tiptext = ( (QTreeRevBall*)item )->Tip();
break;
case RTTI_JOB:
tiptext = ( (QTreeJobText*)item )->Tip();
break;
case RTTI_FILE:
tiptext = ( (QTreeFileText*)item )->Tip();
break;
case RTTI_CHANGE:
tiptext = ( (QTreeChangeNum*)item )->Tip();
break;
}
QRect crect = item->boundingRect();
QRect vrect = QRect
( view->contentsToViewport( crect.topLeft() ), crect.size() );
tip( vrect, tiptext );
}