KDGantt::ItemDelegate Class Reference

#include <KDGanttItemDelegate>

Inheritance diagram for KDGantt::ItemDelegate:

Inheritance graph
[legend]
Collaboration diagram for KDGantt::ItemDelegate:

Collaboration graph
[legend]

List of all members.


Detailed Description

Class used to render gantt items in a KDGantt::GraphicsView.

Definition at line 40 of file kdganttitemdelegate.h.


Public Types

enum  InteractionState {
  State_None = 0,
  State_Move,
  State_ExtendLeft,
  State_ExtendRight,
  State_DragConstraint
}

Public Member Functions

virtual QRectF constraintBoundingRect (const QPointF &start, const QPointF &end, const Constraint &constraint) const
QBrush defaultBrush (ItemType type) const
QPen defaultPen (ItemType type) const
virtual InteractionState interactionStateFor (const QPointF &pos, const StyleOptionGanttItem &opt, const QModelIndex &idx) const
virtual Span itemBoundingSpan (const StyleOptionGanttItem &opt, const QModelIndex &idx) const
 ItemDelegate (QObject *parent=0)
virtual void paintConstraintItem (QPainter *p, const QStyleOptionGraphicsItem &opt, const QPointF &start, const QPointF &end, const Constraint &constraint)
virtual void paintGanttItem (QPainter *p, const StyleOptionGanttItem &opt, const QModelIndex &idx)
void setDefaultBrush (ItemType type, const QBrush &brush)
void setDefaultPen (ItemType type, const QPen &pen)
virtual ~ItemDelegate ()

Protected Member Functions

QPolygonF finishFinishArrow (const QPointF &start, const QPointF &end) const
QPolygonF finishFinishLine (const QPointF &start, const QPointF &end) const
QPolygonF finishStartArrow (const QPointF &start, const QPointF &end) const
QPolygonF finishStartLine (const QPointF &start, const QPointF &end) const
void paintFinishFinishConstraint (QPainter *p, const QStyleOptionGraphicsItem &opt, const QPointF &start, const QPointF &end, const Constraint &constraint)
void paintFinishStartConstraint (QPainter *p, const QStyleOptionGraphicsItem &opt, const QPointF &start, const QPointF &end, const Constraint &constraint)
void paintStartFinishConstraint (QPainter *p, const QStyleOptionGraphicsItem &opt, const QPointF &start, const QPointF &end, const Constraint &constraint)
void paintStartStartConstraint (QPainter *p, const QStyleOptionGraphicsItem &opt, const QPointF &start, const QPointF &end, const Constraint &constraint)
QPolygonF startFinishArrow (const QPointF &start, const QPointF &end) const
QPolygonF startFinishLine (const QPointF &start, const QPointF &end) const
QPolygonF startStartArrow (const QPointF &start, const QPointF &end) const
QPolygonF startStartLine (const QPointF &start, const QPointF &end) const

Member Enumeration Documentation

enum KDGantt::ItemDelegate::InteractionState

This enum is used for communication between the view and the delegate about user interaction with gantt items.

See also:
KDGantt::ItemDelegate::interactionStateFor
Enumerator:
State_None 
State_Move 
State_ExtendLeft 
State_ExtendRight 
State_DragConstraint 

Definition at line 44 of file kdganttitemdelegate.h.

00044                               { State_None = 0,
00045                                 State_Move,
00046                                 State_ExtendLeft,
00047                                 State_ExtendRight,
00048                                 State_DragConstraint
00049         };


Constructor & Destructor Documentation

ItemDelegate::ItemDelegate ( QObject parent = 0  )  [explicit]

Constructor. Creates an ItemDelegate with parent parent

Definition at line 124 of file kdganttitemdelegate.cpp.

00125     : QItemDelegate( parent ), _d( new Private )
00126 {
00127 }

ItemDelegate::~ItemDelegate (  )  [virtual]

Destructor

Definition at line 130 of file kdganttitemdelegate.cpp.

00131 {
00132     delete _d;
00133 }


Member Function Documentation

QRectF ItemDelegate::constraintBoundingRect ( const QPointF &  start,
const QPointF &  end,
const Constraint constraint 
) const [virtual]

Returns:
The bounding rectangle for the graphics used to represent a constraint between points start and end (typically an arrow)

Definition at line 389 of file kdganttitemdelegate.cpp.

References KDGantt::Constraint::FinishFinish, finishFinishArrow(), finishFinishLine(), KDGantt::Constraint::FinishStart, finishStartArrow(), finishStartLine(), KDGantt::Constraint::relationType(), KDGantt::Constraint::StartFinish, startFinishArrow(), startFinishLine(), KDGantt::Constraint::StartStart, startStartArrow(), and startStartLine().

Referenced by KDGantt::ConstraintGraphicsItem::boundingRect().

00390 {
00391     QPolygonF poly;
00392     switch ( constraint.relationType() ) {
00393         case Constraint::FinishStart:
00394             poly = finishStartLine( start, end ) + finishStartArrow( start, end );
00395             break;
00396         case Constraint::FinishFinish:
00397             poly = finishFinishLine( start, end ) + finishFinishArrow( start, end );
00398             break;
00399         case Constraint::StartStart:
00400             poly = startStartLine( start, end ) + startStartArrow( start, end );
00401             break;
00402         case Constraint::StartFinish:
00403             poly = startFinishLine( start, end ) + startFinishArrow( start, end );
00404             break;
00405         default:
00406             break;
00407     }
00408     return poly.boundingRect().adjusted( -PW, -PW, PW, PW );
00409 }

QBrush ItemDelegate::defaultBrush ( ItemType  type  )  const

Returns:
The default brush for item type type
Todo:
Move this to GraphicsView to make delegate stateless.

Definition at line 152 of file kdganttitemdelegate.cpp.

References d.

Referenced by paintGanttItem().

00153 {
00154     return d->defaultbrush[type];
00155 }

QPen ItemDelegate::defaultPen ( ItemType  type  )  const

Returns:
The default pen for item type type
Todo:
Move this to GraphicsView to make delegate stateless.

Definition at line 172 of file kdganttitemdelegate.cpp.

References d.

Referenced by paintGanttItem().

00173 {
00174     return d->defaultpen[type];
00175 }

QPolygonF ItemDelegate::finishFinishArrow ( const QPointF &  start,
const QPointF &  end 
) const [protected]

Definition at line 518 of file kdganttitemdelegate.cpp.

Referenced by constraintBoundingRect(), and paintFinishFinishConstraint().

00519 {
00520     QPolygonF poly;
00521     poly << end
00522             << QPointF( end.x()+TURN/2., end.y()-TURN/2. )
00523             << QPointF( end.x()+TURN/2., end.y()+TURN/2. );
00524     return poly;
00525 }

QPolygonF ItemDelegate::finishFinishLine ( const QPointF &  start,
const QPointF &  end 
) const [protected]

Definition at line 496 of file kdganttitemdelegate.cpp.

Referenced by constraintBoundingRect(), and paintFinishFinishConstraint().

00497 {
00498     QPolygonF poly;
00499     qreal midx = end.x() + TURN;
00500     qreal midy = ( end.y()-start.y() )/2. + start.y();
00501 
00502     if ( start.x() > end.x()+TURN ) {
00503         poly << start
00504                 << QPointF( start.x()+TURN, start.y() )
00505                 << QPointF( start.x()+TURN, end.y() )
00506                 << end;
00507     } else {
00508         poly << start
00509                 << QPointF( midx, start.y() )
00510                 << QPointF( midx, midy )
00511                 << QPointF( end.x()+TURN, midy )
00512                 << QPointF( end.x()+TURN, end.y() )
00513                 << end;
00514     }
00515     return poly;
00516 }

QPolygonF ItemDelegate::finishStartArrow ( const QPointF &  start,
const QPointF &  end 
) const [protected]

Definition at line 474 of file kdganttitemdelegate.cpp.

Referenced by constraintBoundingRect(), and paintFinishStartConstraint().

00475 {
00476     QPolygonF poly;
00477     poly << end
00478             << QPointF( end.x()-TURN/2., end.y()-TURN/2. )
00479             << QPointF( end.x()-TURN/2., end.y()+TURN/2. );
00480     return poly;
00481 }

QPolygonF ItemDelegate::finishStartLine ( const QPointF &  start,
const QPointF &  end 
) const [protected]

Definition at line 452 of file kdganttitemdelegate.cpp.

Referenced by constraintBoundingRect(), and paintFinishStartConstraint().

00453 {
00454     QPolygonF poly;
00455     qreal midx = end.x() - TURN;
00456     qreal midy = ( end.y()-start.y() )/2. + start.y();
00457 
00458     if ( start.x() > end.x()-TURN ) {
00459         poly << start
00460                 << QPointF( start.x()+TURN, start.y() )
00461                 << QPointF( start.x()+TURN, midy )
00462                 << QPointF( end.x()-TURN, midy )
00463                 << QPointF( end.x()-TURN, end.y() )
00464                 << end;
00465     } else {
00466         poly << start
00467                 << QPointF( midx, start.y() )
00468                 << QPointF( midx, end.y() )
00469                 << end;
00470     }
00471     return poly;
00472 }

ItemDelegate::InteractionState ItemDelegate::interactionStateFor ( const QPointF &  pos,
const StyleOptionGanttItem opt,
const QModelIndex &  idx 
) const [virtual]

Returns:
The interaction state for position pos on item idx when rendered with options opt. This is used to tell the view about how the item should react to mouse click/drag.
Override to implement new items or interactions.

Definition at line 222 of file kdganttitemdelegate.cpp.

References KDGantt::StyleOptionGanttItem::itemRect, KDGantt::ItemTypeRole, State_ExtendLeft, State_ExtendRight, State_Move, State_None, KDGantt::TypeEvent, KDGantt::TypeNone, and KDGantt::TypeSummary.

Referenced by KDGantt::GraphicsItem::hoverMoveEvent(), KDGantt::GraphicsItem::mouseDoubleClickEvent(), and KDGantt::GraphicsItem::mousePressEvent().

00225 {
00226     if ( !idx.isValid() ) return State_None;
00227     if ( !( idx.model()->flags( idx ) & Qt::ItemIsEditable ) ) return State_None;
00228 
00229     const int typ = static_cast<ItemType>( idx.model()->data( idx, ItemTypeRole ).toInt() );
00230 
00231     QRectF itemRect( opt.itemRect );
00232 
00233     // An event item is infinitely thin, basically just a line, because it has only one date instead of two.
00234     // It is painted with an offset of -height/2, which is taken into account here.
00235     if ( typ == TypeEvent )
00236         itemRect = QRectF( itemRect.topLeft() - QPointF( itemRect.height() / 2.0, 0 ), QSizeF( itemRect.height(),
00237                                                                                                itemRect.height() ) );
00238 
00239     if ( typ == TypeNone || typ == TypeSummary ) return State_None;
00240     if ( !itemRect.contains(pos) ) return State_None;
00241     if ( typ == TypeEvent )
00242         return State_Move;
00243 
00244     qreal delta = 5.;
00245     if ( itemRect.width() < 15 ) delta = 1.;
00246     if( pos.x() >= itemRect.left() && pos.x() < itemRect.left()+delta ) {
00247         return State_ExtendLeft;
00248     } else   if( pos.x() <= itemRect.right() && pos.x() > itemRect.right()-delta ) {
00249         return State_ExtendRight;
00250     } else {
00251         return State_Move;
00252     }
00253 }

Span ItemDelegate::itemBoundingSpan ( const StyleOptionGanttItem opt,
const QModelIndex &  idx 
) const [virtual]

Returns:
The bounding Span for the item identified by idx when rendered with options opt. This is often the same as the span given by the AbstractGrid for idx, but it might be larger in case there are additional texts or decorations on the item.
Override this to implement new itemtypes or to change the look of the existing ones.

Definition at line 185 of file kdganttitemdelegate.cpp.

References KDGantt::StyleOptionGanttItem::Center, KDGantt::StyleOptionGanttItem::displayPosition, KDGantt::StyleOptionGanttItem::itemRect, KDGantt::ItemTypeRole, KDGantt::StyleOptionGanttItem::Left, KDGantt::StyleOptionGanttItem::Right, and KDGantt::TypeEvent.

Referenced by KDGantt::GraphicsItem::updateItem().

00187 {
00188     if ( !idx.isValid() ) return Span();
00189 
00190     const QString txt = idx.model()->data( idx, Qt::DisplayRole ).toString();
00191     const int typ = idx.model()->data( idx, ItemTypeRole ).toInt();
00192     QRectF itemRect = opt.itemRect;
00193 
00194 
00195     if (  typ == TypeEvent ) {
00196         itemRect = QRectF( itemRect.left()-itemRect.height()/2.,
00197                            itemRect.top(),
00198                            itemRect.height(),
00199                            itemRect.height() );
00200     }
00201 
00202     int tw = opt.fontMetrics.width( txt );
00203     tw += static_cast<int>( itemRect.height()/2. );
00204     Span s;
00205     switch ( opt.displayPosition ) {
00206     case StyleOptionGanttItem::Left:
00207         s = Span( itemRect.left()-tw, itemRect.width()+tw ); break;
00208     case StyleOptionGanttItem::Right:
00209         s = Span( itemRect.left(), itemRect.width()+tw ); break;
00210     case StyleOptionGanttItem::Center:
00211         s = Span( itemRect.left(), itemRect.width() ); break;
00212     }
00213     return s;
00214 }

void ItemDelegate::paintConstraintItem ( QPainter *  painter,
const QStyleOptionGraphicsItem &  opt,
const QPointF &  start,
const QPointF &  end,
const Constraint constraint 
) [virtual]

Paints the constraint between points start and end using painter and opt.

Todo:
Review opt's type

Definition at line 417 of file kdganttitemdelegate.cpp.

References KDGantt::Constraint::FinishFinish, KDGantt::Constraint::FinishStart, paintFinishFinishConstraint(), paintFinishStartConstraint(), paintStartFinishConstraint(), paintStartStartConstraint(), KDGantt::Constraint::relationType(), KDGantt::Constraint::StartFinish, and KDGantt::Constraint::StartStart.

Referenced by KDGantt::ConstraintGraphicsItem::paint().

00419 {
00420     //qDebug()<<"ItemDelegate::paintConstraintItem"<<start<<end<<constraint;
00421     switch ( constraint.relationType() ) {
00422         case Constraint::FinishStart: 
00423             paintFinishStartConstraint( painter, opt, start, end, constraint );
00424             break;
00425         case Constraint::FinishFinish: 
00426             paintFinishFinishConstraint( painter, opt, start, end, constraint );
00427             break;
00428         case Constraint::StartStart: 
00429             paintStartStartConstraint( painter, opt, start, end, constraint );
00430             break;
00431         case Constraint::StartFinish: 
00432             paintStartFinishConstraint( painter, opt, start, end, constraint );
00433             break;
00434         default:
00435             break;
00436     }
00437 }

void ItemDelegate::paintFinishFinishConstraint ( QPainter *  p,
const QStyleOptionGraphicsItem &  opt,
const QPointF &  start,
const QPointF &  end,
const Constraint constraint 
) [protected]

Definition at line 483 of file kdganttitemdelegate.cpp.

References d, finishFinishArrow(), and finishFinishLine().

Referenced by paintConstraintItem().

00484 {
00485     Q_UNUSED( opt );
00486 
00487     QPen pen = d->constraintPen( start, end, constraint );
00488     
00489     painter->setPen( pen );
00490     painter->setBrush( pen.color() );
00491     
00492     painter->drawPolyline( finishFinishLine( start, end ) );
00493     painter->drawPolygon( finishFinishArrow( start, end ) );
00494 }

void ItemDelegate::paintFinishStartConstraint ( QPainter *  p,
const QStyleOptionGraphicsItem &  opt,
const QPointF &  start,
const QPointF &  end,
const Constraint constraint 
) [protected]

Definition at line 439 of file kdganttitemdelegate.cpp.

References d, finishStartArrow(), and finishStartLine().

Referenced by paintConstraintItem().

00440 {
00441     Q_UNUSED( opt );
00442 
00443     QPen pen = d->constraintPen( start, end, constraint );
00444 
00445     painter->setPen( pen );
00446     painter->setBrush( pen.color() );
00447     
00448     painter->drawPolyline( finishStartLine( start, end ) );
00449     painter->drawPolygon( finishStartArrow( start, end ) );
00450 }

void ItemDelegate::paintGanttItem ( QPainter *  painter,
const StyleOptionGanttItem opt,
const QModelIndex &  idx 
) [virtual]

Paints the gantt item idx using painter and opt

Definition at line 257 of file kdganttitemdelegate.cpp.

References KDGantt::StyleOptionGanttItem::boundingRect, KDGantt::StyleOptionGanttItem::Center, defaultBrush(), defaultPen(), KDGantt::StyleOptionGanttItem::displayPosition, KDGantt::StyleOptionGanttItem::itemRect, KDGantt::ItemTypeRole, KDGantt::StyleOptionGanttItem::Left, r, KDGantt::StyleOptionGanttItem::Right, KDGantt::TaskCompletionRole, KDGantt::StyleOptionGanttItem::text, KDGantt::TypeEvent, KDGantt::TypeSummary, and KDGantt::TypeTask.

Referenced by KDGantt::Legend::drawItem(), and KDGantt::GraphicsItem::paint().

00260 {
00261     if ( !idx.isValid() ) return;
00262     const ItemType typ = static_cast<ItemType>( idx.model()->data( idx, ItemTypeRole ).toInt() );
00263     const QString& txt = opt.text;
00264     QRectF itemRect = opt.itemRect;
00265     QRectF boundingRect = opt.boundingRect;
00266     boundingRect.setY( itemRect.y() );
00267     boundingRect.setHeight( itemRect.height() );
00268 
00269     //qDebug() << "itemRect="<<itemRect<<", boundingRect="<<boundingRect;
00270     //qDebug() << painter->font() << opt.fontMetrics.height() << painter->device()->width() << painter->device()->height();
00271 
00272     painter->save();
00273 
00274     QPen pen = defaultPen( typ );
00275     if ( opt.state & QStyle::State_Selected ) pen.setWidth( 2*pen.width() );
00276     painter->setPen( pen );
00277     painter->setBrush( defaultBrush( typ ) );
00278 
00279     qreal pw = painter->pen().width()/2.;
00280     switch( typ ) {
00281     case TypeTask:
00282         if ( itemRect.isValid() ) {
00283             // TODO
00284             qreal pw = painter->pen().width()/2.;
00285             pw-=1;
00286             QRectF r = itemRect;
00287             r.translate( 0., r.height()/6. );
00288             r.setHeight( 2.*r.height()/3. );
00289             painter->setBrushOrigin( itemRect.topLeft() );
00290             painter->save();
00291             painter->translate( 0.5, 0.5 );
00292             painter->drawRect( r );
00293             bool ok;
00294             qreal completion = idx.model()->data( idx, KDGantt::TaskCompletionRole ).toDouble( &ok );
00295             if ( ok ) {
00296                 qreal h = r.height();
00297                 QRectF cr( r.x(), r.y()+h/4.,
00298                            r.width()*completion/100., h/2.+1 /*??*/ );
00299                 QColor compcolor( painter->pen().color() );
00300                 compcolor.setAlpha( 150 );
00301                 painter->fillRect( cr, compcolor );
00302             }
00303             painter->restore();
00304             Qt::Alignment ta;
00305             switch( opt.displayPosition ) {
00306             case StyleOptionGanttItem::Left: ta = Qt::AlignLeft; break;
00307             case StyleOptionGanttItem::Right: ta = Qt::AlignRight; break;
00308             case StyleOptionGanttItem::Center: ta = Qt::AlignCenter; break;
00309             }
00310             painter->drawText( boundingRect, ta | Qt::AlignVCenter, txt );
00311         }
00312         break;
00313     case TypeSummary:
00314         if ( opt.itemRect.isValid() ) {
00315             // TODO
00316             pw-=1;
00317             const QRectF r = QRectF( opt.itemRect ).adjusted( -pw, -pw, pw, pw );
00318             QPainterPath path;
00319             const qreal delta = r.height()/2.;
00320             path.moveTo( r.topLeft() );
00321             path.lineTo( r.topRight() );
00322             path.lineTo( QPointF( r.right(), r.top() + 2.*delta ) );
00323             //path.lineTo( QPointF( r.right()-3./2.*delta, r.top() + delta ) );
00324             path.quadTo( QPointF( r.right()-.5*delta, r.top() + delta ), QPointF( r.right()-2.*delta, r.top() + delta ) );
00325             //path.lineTo( QPointF( r.left()+3./2.*delta, r.top() + delta ) );
00326             path.lineTo( QPointF( r.left() + 2.*delta, r.top() + delta ) );
00327             path.quadTo( QPointF( r.left()+.5*delta, r.top() + delta ), QPointF( r.left(), r.top() + 2.*delta ) );
00328             path.closeSubpath();
00329             painter->setBrushOrigin( itemRect.topLeft() );
00330             painter->save();
00331             painter->translate( 0.5, 0.5 );
00332             painter->drawPath( path );
00333             painter->restore();
00334             Qt::Alignment ta;
00335             switch( opt.displayPosition ) {
00336             case StyleOptionGanttItem::Left: ta = Qt::AlignLeft; break;
00337             case StyleOptionGanttItem::Right: ta = Qt::AlignRight; break;
00338             case StyleOptionGanttItem::Center: ta = Qt::AlignCenter; break;
00339             }
00340             painter->drawText( boundingRect, ta | Qt::AlignVCenter, txt );
00341         }
00342         break;
00343     case TypeEvent: /* TODO */
00344         //qDebug() << opt.boundingRect << opt.itemRect;
00345         if ( opt.boundingRect.isValid() ) {
00346             const qreal pw = painter->pen().width() / 2. - 1;
00347             const QRectF r = QRectF( opt.itemRect ).adjusted( -pw, -pw, pw, pw ).translated( -opt.itemRect.height()/2, 0 );
00348             QPainterPath path;
00349             const qreal delta = static_cast< int >( r.height() / 2 );
00350             path.moveTo( delta, 0. );
00351             path.lineTo( 2.*delta, delta );
00352             path.lineTo( delta, 2.*delta );
00353             path.lineTo( 0., delta );
00354             path.closeSubpath();
00355             painter->save();
00356             painter->translate( r.topLeft() );
00357             painter->translate( 0, 0.5 );
00358             painter->drawPath( path );
00359             painter->restore();
00360             Qt::Alignment ta;
00361             switch( opt.displayPosition ) {
00362             case StyleOptionGanttItem::Left: ta = Qt::AlignLeft; break;
00363             case StyleOptionGanttItem::Right: ta = Qt::AlignRight; break;
00364             case StyleOptionGanttItem::Center: ta = Qt::AlignCenter; break;
00365             }
00366             painter->drawText( boundingRect, ta | Qt::AlignVCenter, txt );
00367 #if 0
00368             painter->setBrush( Qt::NoBrush );
00369             painter->setPen( Qt::black );
00370             painter->drawRect( opt.boundingRect );
00371             painter->setPen( Qt::red );
00372             painter->drawRect( r );
00373 #endif
00374         }
00375         break;
00376     default:
00377         break;
00378     }
00379     painter->restore();
00380 }

void ItemDelegate::paintStartFinishConstraint ( QPainter *  p,
const QStyleOptionGraphicsItem &  opt,
const QPointF &  start,
const QPointF &  end,
const Constraint constraint 
) [protected]

Definition at line 571 of file kdganttitemdelegate.cpp.

References d, startFinishArrow(), and startFinishLine().

Referenced by paintConstraintItem().

00572 {
00573     Q_UNUSED( opt );
00574         
00575     QPen pen = d->constraintPen( start, end, constraint );
00576 
00577     painter->setPen( pen );
00578     painter->setBrush( pen.color() );
00579     
00580     painter->drawPolyline( startFinishLine( start, end ) );
00581     painter->drawPolygon( startFinishArrow( start, end ) );
00582 }

void ItemDelegate::paintStartStartConstraint ( QPainter *  p,
const QStyleOptionGraphicsItem &  opt,
const QPointF &  start,
const QPointF &  end,
const Constraint constraint 
) [protected]

Definition at line 527 of file kdganttitemdelegate.cpp.

References d, startStartArrow(), and startStartLine().

Referenced by paintConstraintItem().

00528 {
00529     Q_UNUSED( opt );
00530 
00531     QPen pen = d->constraintPen( start, end, constraint );
00532 
00533     painter->setPen( pen );
00534     painter->setBrush( pen.color() );
00535     
00536     painter->drawPolyline( startStartLine( start, end ) );
00537     painter->drawPolygon( startStartArrow( start, end ) );
00538 
00539 }

void ItemDelegate::setDefaultBrush ( ItemType  type,
const QBrush &  brush 
)

Sets the default brush used for items of type type to brush. The default brush is used in the case when the model does not provide an explicit brush.

Todo:
Move this to GraphicsView to make delegate stateless.

Definition at line 143 of file kdganttitemdelegate.cpp.

References d.

00144 {
00145     d->defaultbrush[type] = brush;
00146 }

void ItemDelegate::setDefaultPen ( ItemType  type,
const QPen &  pen 
)

Sets the default pen used for items of type type to pen. The default pen is used in the case when the model does not provide an explicit pen.

Todo:
Move this to GraphicsView to make delegate stateless.

Definition at line 163 of file kdganttitemdelegate.cpp.

References d.

00164 {
00165     d->defaultpen[type]=pen;
00166 }

QPolygonF ItemDelegate::startFinishArrow ( const QPointF &  start,
const QPointF &  end 
) const [protected]

Definition at line 606 of file kdganttitemdelegate.cpp.

Referenced by constraintBoundingRect(), and paintStartFinishConstraint().

00607 {
00608     QPolygonF poly;
00609     poly << end
00610             << QPointF( end.x()+TURN/2., end.y()-TURN/2. )
00611             << QPointF( end.x()+TURN/2., end.y()+TURN/2. );
00612     return poly;
00613 }

QPolygonF ItemDelegate::startFinishLine ( const QPointF &  start,
const QPointF &  end 
) const [protected]

Definition at line 584 of file kdganttitemdelegate.cpp.

Referenced by constraintBoundingRect(), and paintStartFinishConstraint().

00585 {
00586     QPolygonF poly;
00587     qreal midx = end.x() + TURN;
00588     qreal midy = ( end.y()-start.y() )/2. + start.y();
00589 
00590     if ( start.x()-TURN > end.x()+TURN ) {
00591         poly << start
00592                 << QPointF( midx, start.y() )
00593                 << QPointF( midx, end.y() )
00594                 << end;
00595     } else {
00596         poly << start
00597                 << QPointF( start.x()-TURN, start.y() )
00598                 << QPointF( start.x()-TURN, midy )
00599                 << QPointF( midx, midy )
00600                 << QPointF( end.x()+TURN, end.y() )
00601                 << end;
00602     }
00603     return poly;
00604 }

QPolygonF ItemDelegate::startStartArrow ( const QPointF &  start,
const QPointF &  end 
) const [protected]

Definition at line 562 of file kdganttitemdelegate.cpp.

Referenced by constraintBoundingRect(), and paintStartStartConstraint().

00563 {
00564     QPolygonF poly;
00565     poly << end
00566             << QPointF( end.x()-TURN/2., end.y()-TURN/2. )
00567             << QPointF( end.x()-TURN/2., end.y()+TURN/2. );
00568     return poly;
00569 }

QPolygonF ItemDelegate::startStartLine ( const QPointF &  start,
const QPointF &  end 
) const [protected]

Definition at line 541 of file kdganttitemdelegate.cpp.

Referenced by constraintBoundingRect(), and paintStartStartConstraint().

00542 {
00543     QPolygonF poly;
00544     qreal midx = start.x() - TURN;
00545     qreal midy = ( end.y()-start.y() )/2. + start.y();
00546 
00547     if ( start.x() > end.x() ) {
00548         poly << start
00549                 << QPointF( end.x()-TURN, start.y() )
00550                 << QPointF( end.x()-TURN, end.y() )
00551                 << end;
00552     } else {
00553         poly << start
00554                 << QPointF( start.x()-TURN, start.y() )
00555                 << QPointF( start.x()-TURN, end.y() )
00556                 << QPointF( end.x()-TURN, end.y() )
00557                 << end;
00558     }
00559     return poly;
00560 }


The documentation for this class was generated from the following files:
Generated on Thu Mar 4 23:27:12 2010 for KD Chart 2 by  doxygen 1.5.4