KDGantt::GraphicsScene Class Reference

#include <kdganttgraphicsscene.h>

Inheritance diagram for KDGantt::GraphicsScene:

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

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 48 of file kdganttgraphicsscene.h.


Public Slots

void setConstraintModel (ConstraintModel *)
void setModel (QAbstractItemModel *)
void setReadOnly (bool)
void setRootIndex (const QModelIndex &idx)
void setSelectionModel (QItemSelectionModel *selectionmodel)
void setSummaryHandlingModel (QAbstractProxyModel *)

Signals

void clicked (const QModelIndex &index)
void doubleClicked (const QModelIndex &index)
void entered (const QModelIndex &index)
void gridChanged ()
void pressed (const QModelIndex &index)

Public Member Functions

void clearConstraintItems ()
void clearItems ()
ConstraintModelconstraintModel () const
GraphicsItemcreateItem (ItemType type) const
void deleteSubtree (const QModelIndex &)
GraphicsItemdragSource () const
ConstraintGraphicsItemfindConstraintItem (const Constraint &) const
QList< ConstraintGraphicsItem * > findConstraintItems (const QModelIndex &idx) const
GraphicsItemfindItem (const QPersistentModelIndex &) const
GraphicsItemfindItem (const QModelIndex &) const
 GraphicsScene (QObject *parent=0)
AbstractGridgrid () const
void insertItem (const QPersistentModelIndex &, GraphicsItem *)
bool isReadOnly () const
void itemClicked (const QModelIndex &)
ItemDelegateitemDelegate () const
void itemDoubleClicked (const QModelIndex &)
void itemEntered (const QModelIndex &)
void itemPressed (const QModelIndex &)
QAbstractItemModel * model () const
void print (QPainter *painter, qreal start, qreal end, const QRectF &target=QRectF(), bool drawRowLabels=true)
void print (QPainter *painter, const QRectF &target=QRectF(), bool drawRowLabels=true)
void print (QPrinter *printer, qreal start, qreal end, bool drawRowLabels=true)
void print (QPrinter *printer, bool drawRowLabels=true)
void removeItem (const QModelIndex &)
QModelIndex rootIndex () const
AbstractRowControllerrowController () const
QItemSelectionModel * selectionModel () const
void setDragSource (GraphicsItem *item)
void setGrid (AbstractGrid *grid)
void setItemDelegate (ItemDelegate *)
void setRowController (AbstractRowController *rc)
QAbstractProxyModelsummaryHandlingModel () const
void updateItems ()
void updateRow (const QModelIndex &idx)
virtual ~GraphicsScene ()

Static Public Member Functions

static QModelIndex dataIndex (const QModelIndex &idx)
static QModelIndex mainIndex (const QModelIndex &idx)

Protected Member Functions

void drawBackground (QPainter *painter, const QRectF &rect)
void helpEvent (QGraphicsSceneHelpEvent *helpEvent)

Constructor & Destructor Documentation

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

Definition at line 160 of file kdganttgraphicsscene.cpp.

References StockDiagram::init().

00161     : QGraphicsScene( parent ), _d( new Private( this ) )
00162 {
00163     init();
00164 }

GraphicsScene::~GraphicsScene (  )  [virtual]

Definition at line 166 of file kdganttgraphicsscene.cpp.

References clearConstraintItems(), and clearItems().

00167 {
00168     clearConstraintItems();
00169     clearItems();
00170 }


Member Function Documentation

void GraphicsScene::clearConstraintItems (  ) 

Definition at line 529 of file kdganttgraphicsscene.cpp.

Referenced by ~GraphicsScene().

00530 {
00531     // TODO
00532     // d->constraintItems.clearConstraintItems();
00533 }

void GraphicsScene::clearItems (  ) 

Definition at line 490 of file kdganttgraphicsscene.cpp.

References d.

Referenced by ~GraphicsScene().

00491 {
00492     // TODO constraints
00493     qDeleteAll( items() );
00494     d->items.clear();
00495 }

void KDGantt::GraphicsScene::clicked ( const QModelIndex &  index  )  [signal]

Referenced by itemClicked().

ConstraintModel * GraphicsScene::constraintModel (  )  const

Definition at line 232 of file kdganttgraphicsscene.cpp.

References d.

00233 {
00234     return d->constraintModel;
00235 }

GraphicsItem * GraphicsScene::createItem ( ItemType  type  )  const

Creates a new item of type type. TODO: If the user should be allowed to override this in any way, it needs to be in View!

Definition at line 336 of file kdganttgraphicsscene.cpp.

References KDGantt::TypeEvent, KDGantt::TypeSummary, and KDGantt::TypeTask.

Referenced by updateRow().

00337 {
00338 #if 0
00339     switch( type ) {
00340     case TypeEvent:   return 0;
00341     case TypeTask:    return new TaskItem;
00342     case TypeSummary: return new SummaryItem;
00343     default:          return 0;
00344     }
00345 #endif
00346     //qDebug() << "GraphicsScene::createItem("<<type<<")";
00347     Q_UNUSED( type );
00348     return new GraphicsItem;
00349 }

QModelIndex GraphicsScene::dataIndex ( const QModelIndex &  idx  )  [static]

Returns the index pointing to the last column in the same row as idx. This can be thought of as in "inverse" of mainIndex()

Definition at line 318 of file kdganttgraphicsscene.cpp.

References model().

Referenced by deleteSubtree().

00319 {
00320 #if 0
00321     if ( idx.isValid() ) {
00322         const QAbstractItemModel* model = idx.model();
00323         return model->index( idx.row(), model->columnCount( idx.parent() )-1,idx.parent() );
00324     } else {
00325         return QModelIndex();
00326     }
00327 #else
00328     return idx;
00329 #endif
00330 }

void GraphicsScene::deleteSubtree ( const QModelIndex &  _idx  ) 

Definition at line 508 of file kdganttgraphicsscene.cpp.

References dataIndex(), removeItem(), and summaryHandlingModel().

00509 {
00510     QModelIndex idx = dataIndex( _idx );
00511     if ( !idx.model() ) return;
00512     const QModelIndex parent( idx.parent() );
00513     const int colcount = idx.model()->columnCount( parent );
00514     {for ( int i = 0; i < colcount; ++i ) {
00515         removeItem( parent.child( idx.row(), i ) );
00516     }}
00517     const int rowcount = summaryHandlingModel()->rowCount( _idx );
00518     {for ( int i = 0; i < rowcount; ++i ) {
00519         deleteSubtree( summaryHandlingModel()->index( i, summaryHandlingModel()->columnCount(_idx)-1, _idx ) );
00520     }}
00521 }

void KDGantt::GraphicsScene::doubleClicked ( const QModelIndex &  index  )  [signal]

Referenced by itemDoubleClicked().

GraphicsItem * GraphicsScene::dragSource (  )  const

Definition at line 621 of file kdganttgraphicsscene.cpp.

References d.

00622 {
00623     return d->dragSource;
00624 }

void GraphicsScene::drawBackground ( QPainter *  painter,
const QRectF &  rect 
) [protected]

Definition at line 566 of file kdganttgraphicsscene.cpp.

References d.

00567 {
00568     QRectF scn( sceneRect() );
00569     QRectF rect( _rect );
00570     if ( d->isPrinting ) {
00571         QRectF headerRect( scn.topLeft()+QPointF( d->labelsWidth, 0 ),
00572                            QSizeF( scn.width()-d->labelsWidth, d->rowController->headerHeight() ));
00573         d->grid->paintHeader( painter, headerRect, rect, 0, 0 );
00574 
00575         /* We have to blank out the part of the header that is invisible during
00576      * normal rendering when we are printing.
00577      */
00578         QRectF labelsTabRect( scn.topLeft(), QSizeF( d->labelsWidth, headerRect.height() ) );
00579 
00580         QStyleOptionHeader opt;
00581         opt.rect = labelsTabRect.toRect();
00582         opt.text = tr( "" );
00583         opt.textAlignment = Qt::AlignCenter;
00584 #if QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)
00585         style()->drawControl(QStyle::CE_Header, &opt, painter, 0);
00586 #else
00587         QApplication::style()->drawControl(QStyle::CE_Header, &opt, painter, 0);
00588 #endif
00589         scn.setTop( headerRect.bottom() );
00590         scn.setLeft( headerRect.left() );
00591         rect = rect.intersected( scn );
00592     }
00593     d->grid->paintGrid( painter, scn, rect, d->rowController );
00594 }

void KDGantt::GraphicsScene::entered ( const QModelIndex &  index  )  [signal]

Referenced by itemEntered().

ConstraintGraphicsItem * GraphicsScene::findConstraintItem ( const Constraint c  )  const

Definition at line 524 of file kdganttgraphicsscene.cpp.

References d.

00525 {
00526     return d->findConstraintItem( c );
00527 }

QList<ConstraintGraphicsItem*> KDGantt::GraphicsScene::findConstraintItems ( const QModelIndex &  idx  )  const

GraphicsItem * GraphicsScene::findItem ( const QPersistentModelIndex &  idx  )  const

Definition at line 482 of file kdganttgraphicsscene.cpp.

References d, and summaryHandlingModel().

00483 {
00484     if ( !idx.isValid() ) return 0;
00485     assert( idx.model() == summaryHandlingModel() );
00486     QHash<QPersistentModelIndex,GraphicsItem*>::const_iterator it = d->items.find( idx );
00487     return ( it != d->items.end() )?*it:0;
00488 }

GraphicsItem * GraphicsScene::findItem ( const QModelIndex &  idx  )  const

Definition at line 474 of file kdganttgraphicsscene.cpp.

References d, and summaryHandlingModel().

Referenced by updateRow().

00475 {
00476     if ( !idx.isValid() ) return 0;
00477     assert( idx.model() == summaryHandlingModel() );
00478     QHash<QPersistentModelIndex,GraphicsItem*>::const_iterator it = d->items.find( idx );
00479     return ( it != d->items.end() )?*it:0;
00480 }

AbstractGrid * GraphicsScene::grid (  )  const

Definition at line 281 of file kdganttgraphicsscene.cpp.

References d.

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

00282 {
00283     return d->grid;
00284 }

void KDGantt::GraphicsScene::gridChanged (  )  [signal]

Referenced by setGrid().

void GraphicsScene::helpEvent ( QGraphicsSceneHelpEvent *  helpEvent  )  [protected]

Definition at line 552 of file kdganttgraphicsscene.cpp.

References KDGantt::ConstraintGraphicsItem::ganttToolTip().

00553 {
00554 #ifndef QT_NO_TOOLTIP
00555     QGraphicsItem *item = itemAt( helpEvent->scenePos() );
00556     if ( GraphicsItem* gitem = qgraphicsitem_cast<GraphicsItem*>( item ) ) {
00557         QToolTip::showText(helpEvent->screenPos(), gitem->ganttToolTip());
00558     } else if ( ConstraintGraphicsItem* citem = qgraphicsitem_cast<ConstraintGraphicsItem*>( item ) ) {
00559         QToolTip::showText(helpEvent->screenPos(), citem->ganttToolTip());
00560     } else {
00561         QGraphicsScene::helpEvent( helpEvent );
00562     }
00563 #endif /* QT_NO_TOOLTIP */
00564 }

void GraphicsScene::insertItem ( const QPersistentModelIndex &  idx,
GraphicsItem item 
)

Definition at line 418 of file kdganttgraphicsscene.cpp.

References KDGantt::GraphicsItem::addEndConstraint(), KDGantt::GraphicsItem::addStartConstraint(), d, KDGantt::Constraint::endIndex(), KDGantt::Constraint::startIndex(), and summaryHandlingModel().

Referenced by updateRow().

00419 {
00420     if ( !d->constraintModel.isNull() ) {
00421         // Create items for constraints
00422         const QModelIndex sidx = summaryHandlingModel()->mapToSource( idx );
00423         const QList<Constraint> clst = d->constraintModel->constraintsForIndex( sidx );
00424         Q_FOREACH( Constraint c,  clst ) {
00425             QModelIndex other_idx;
00426             if ( c.startIndex() == sidx ) {
00427                 other_idx = c.endIndex();
00428                 GraphicsItem* other_item = d->items.value(summaryHandlingModel()->mapFromSource( other_idx ),0);
00429                 if ( !other_item ) continue;
00430                 ConstraintGraphicsItem* citem = new ConstraintGraphicsItem( c );
00431                 item->addStartConstraint( citem );
00432                 other_item->addEndConstraint( citem );
00433                 addItem( citem );
00434             } else if ( c.endIndex() == sidx ) {
00435                 other_idx = c.startIndex();
00436                 GraphicsItem* other_item = d->items.value(summaryHandlingModel()->mapFromSource( other_idx ),0);
00437                 if ( !other_item ) continue;
00438                 ConstraintGraphicsItem* citem = new ConstraintGraphicsItem( c );
00439                 other_item->addStartConstraint( citem );
00440                 item->addEndConstraint( citem );
00441                 addItem( citem );
00442             } else {
00443                 assert( 0 ); // Impossible
00444             }
00445         }
00446     }
00447     d->items.insert( idx, item );
00448     addItem( item );
00449 }

bool GraphicsScene::isReadOnly (  )  const

Definition at line 291 of file kdganttgraphicsscene.cpp.

References d.

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

00292 {
00293     return d->readOnly;
00294 }

void GraphicsScene::itemClicked ( const QModelIndex &  idx  ) 

Definition at line 606 of file kdganttgraphicsscene.cpp.

References clicked().

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

00607 {
00608     emit clicked( idx );
00609 }

ItemDelegate * GraphicsScene::itemDelegate (  )  const

Definition at line 192 of file kdganttgraphicsscene.cpp.

References d.

Referenced by KDGantt::ConstraintGraphicsItem::boundingRect(), KDGantt::GraphicsItem::hoverMoveEvent(), KDGantt::GraphicsItem::mouseDoubleClickEvent(), KDGantt::GraphicsItem::mousePressEvent(), KDGantt::GraphicsItem::paint(), KDGantt::ConstraintGraphicsItem::paint(), and KDGantt::GraphicsItem::updateItem().

00193 {
00194     return d->itemDelegate;
00195 }

void GraphicsScene::itemDoubleClicked ( const QModelIndex &  idx  ) 

Definition at line 611 of file kdganttgraphicsscene.cpp.

References doubleClicked().

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

00612 {
00613     emit doubleClicked( idx );
00614 }

void GraphicsScene::itemEntered ( const QModelIndex &  idx  ) 

Definition at line 596 of file kdganttgraphicsscene.cpp.

References entered().

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

00597 {
00598     emit entered( idx );
00599 }

void GraphicsScene::itemPressed ( const QModelIndex &  idx  ) 

Definition at line 601 of file kdganttgraphicsscene.cpp.

References pressed().

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

00602 {
00603     emit pressed( idx );
00604 }

QModelIndex GraphicsScene::mainIndex ( const QModelIndex &  idx  )  [static]

Definition at line 301 of file kdganttgraphicsscene.cpp.

00302 {
00303 #if 0
00304     if ( idx.isValid() ) {
00305         return idx.model()->index( idx.row(), 0,idx.parent() );
00306     } else {
00307         return QModelIndex();
00308     }
00309 #else
00310     return idx;
00311 #endif
00312 }

QAbstractItemModel * GraphicsScene::model (  )  const

Definition at line 197 of file kdganttgraphicsscene.cpp.

References d.

Referenced by dataIndex(), setGrid(), setSummaryHandlingModel(), and updateRow().

00198 {
00199     assert(!d->summaryHandlingModel.isNull());
00200     return d->summaryHandlingModel->sourceModel();
00201 }

void KDGantt::GraphicsScene::pressed ( const QModelIndex &  index  )  [signal]

Referenced by itemPressed().

void GraphicsScene::print ( QPainter *  painter,
qreal  start,
qreal  end,
const QRectF &  _targetRect = QRectF(),
bool  drawRowLabels = true 
)

Render the GanttView inside the rectangle target using the painter painter. If drawRowLabels is true (the default), each row will have it's label printed on the left side.

To print a certain range of a chart with a DateTimeGrid, use qreal DateTimeGrid::mapFromDateTime( const QDateTime& dt) const to figure out the values for start and end.

Definition at line 676 of file kdganttgraphicsscene.cpp.

00678 {
00679     QRectF targetRect( _targetRect );
00680     if ( targetRect.isNull() ) {
00681         targetRect = sceneRect();
00682     }
00683 
00684     doPrint( painter, targetRect, start, end, 0, drawRowLabels );
00685 }

void GraphicsScene::print ( QPainter *  painter,
const QRectF &  _targetRect = QRectF(),
bool  drawRowLabels = true 
)

Render the GanttView inside the rectangle target using the painter painter. If drawRowLabels is true (the default), each row will have it's label printed on the left side.

Definition at line 658 of file kdganttgraphicsscene.cpp.

00659 {
00660     QRectF targetRect( _targetRect );
00661     if ( targetRect.isNull() ) {
00662         targetRect = sceneRect();
00663     }
00664 
00665     doPrint( painter, targetRect, sceneRect().left(), sceneRect().right(), 0, drawRowLabels );
00666 }

void GraphicsScene::print ( QPrinter *  printer,
qreal  start,
qreal  end,
bool  drawRowLabels = true 
)

Print part of the Gantt chart from start to end using printer. If drawRowLabels is true (the default), each row will have it's label printed on the left side.

This version of print() will print multiple pages.

To print a certain range of a chart with a DateTimeGrid, use qreal DateTimeGrid::mapFromDateTime( const QDateTime& dt) const to figure out the values for start and end.

Definition at line 648 of file kdganttgraphicsscene.cpp.

00649 {
00650     QPainter painter( printer );
00651     doPrint( &painter, printer->pageRect(), start, end, printer, drawRowLabels );
00652 }

void GraphicsScene::print ( QPrinter *  printer,
bool  drawRowLabels = true 
)

Print the Gantt chart using printer. If drawRowLabels is true (the default), each row will have it's label printed on the left side.

This version of print() will print multiple pages.

Definition at line 632 of file kdganttgraphicsscene.cpp.

00633 {
00634     QPainter painter( printer );
00635     doPrint( &painter, printer->pageRect(), sceneRect().left(), sceneRect().right(), printer, drawRowLabels );
00636 }

void GraphicsScene::removeItem ( const QModelIndex &  idx  ) 

Definition at line 451 of file kdganttgraphicsscene.cpp.

References d, KDGantt::GraphicsItem::endConstraints(), and KDGantt::GraphicsItem::startConstraints().

Referenced by deleteSubtree(), and updateRow().

00452 {
00453     //qDebug() << "GraphicsScene::removeItem("<<idx<<")";
00454     QHash<QPersistentModelIndex,GraphicsItem*>::iterator it = d->items.find( idx );
00455     if ( it != d->items.end() ) {
00456         GraphicsItem* item = *it;
00457         assert( item );
00458         // We have to remove the item from the list first because
00459         // there is a good chance there will be reentrant calls
00460         d->items.erase( it );
00461         {
00462             // Remove any constraintitems attached
00463             const QSet<ConstraintGraphicsItem*> clst = QSet<ConstraintGraphicsItem*>::fromList( item->startConstraints() ) +
00464                                                        QSet<ConstraintGraphicsItem*>::fromList( item->endConstraints() );
00465             Q_FOREACH( ConstraintGraphicsItem* citem, clst ) {
00466                 d->deleteConstraintItem( citem );
00467             }
00468         }
00469         // Get rid of the item
00470         delete item;
00471     }
00472 }

QModelIndex GraphicsScene::rootIndex (  )  const

Definition at line 227 of file kdganttgraphicsscene.cpp.

References d.

00228 {
00229     return d->grid->rootIndex();
00230 }

AbstractRowController * GraphicsScene::rowController (  )  const

Definition at line 265 of file kdganttgraphicsscene.cpp.

References d.

Referenced by KDGantt::GraphicsItem::updateItem(), and updateRow().

00266 {
00267     return d->rowController;
00268 }

QItemSelectionModel * GraphicsScene::selectionModel (  )  const

Definition at line 255 of file kdganttgraphicsscene.cpp.

References d.

Referenced by KDGantt::GraphicsItem::focusInEvent(), KDGantt::GraphicsItem::itemChange(), and KDGantt::GraphicsItem::mouseMoveEvent().

00256 {
00257     return d->selectionModel;
00258 }

void GraphicsScene::setConstraintModel ( ConstraintModel cm  )  [slot]

Definition at line 237 of file kdganttgraphicsscene.cpp.

References d.

00238 {
00239     if ( !d->constraintModel.isNull() ) {
00240         disconnect( d->constraintModel );
00241     }
00242     d->constraintModel = cm;
00243 
00244     connect( cm, SIGNAL( constraintAdded( const KDGantt::Constraint& ) ), this, SLOT( slotConstraintAdded( const KDGantt::Constraint& ) ) );
00245     connect( cm, SIGNAL( constraintRemoved( const KDGantt::Constraint& ) ), this, SLOT( slotConstraintRemoved( const KDGantt::Constraint& ) ) );
00246     d->resetConstraintItems();
00247 }

void GraphicsScene::setDragSource ( GraphicsItem item  ) 

Definition at line 616 of file kdganttgraphicsscene.cpp.

References d.

Referenced by KDGantt::GraphicsItem::mouseMoveEvent(), and KDGantt::GraphicsItem::mouseReleaseEvent().

00617 {
00618     d->dragSource = item;
00619 }

void GraphicsScene::setGrid ( AbstractGrid grid  ) 

Definition at line 270 of file kdganttgraphicsscene.cpp.

References d, gridChanged(), and model().

00271 {
00272     QAbstractItemModel* model = d->grid->model();
00273     if ( grid == 0 ) grid = &d->default_grid;
00274     if ( d->grid ) disconnect( d->grid );
00275     d->grid = grid;
00276     connect( d->grid, SIGNAL( gridChanged() ), this, SLOT( slotGridChanged() ) );
00277     d->grid->setModel( model );
00278     slotGridChanged();
00279 }

void GraphicsScene::setItemDelegate ( ItemDelegate delegate  ) 

Definition at line 185 of file kdganttgraphicsscene.cpp.

References d.

00186 {
00187     if ( !d->itemDelegate.isNull() && d->itemDelegate->parent()==this ) delete d->itemDelegate;
00188     d->itemDelegate = delegate;
00189     update();
00190 }

void GraphicsScene::setModel ( QAbstractItemModel *  model  )  [slot]

Definition at line 203 of file kdganttgraphicsscene.cpp.

References d, and setSelectionModel().

00204 {
00205     assert(!d->summaryHandlingModel.isNull());
00206     d->summaryHandlingModel->setSourceModel(model);
00207     d->grid->setModel( d->summaryHandlingModel );
00208     setSelectionModel( new QItemSelectionModel( model, this ) );
00209 }

void GraphicsScene::setReadOnly ( bool  ro  )  [slot]

Definition at line 286 of file kdganttgraphicsscene.cpp.

References d.

00287 {
00288     d->readOnly = ro;
00289 }

void GraphicsScene::setRootIndex ( const QModelIndex &  idx  )  [slot]

Definition at line 222 of file kdganttgraphicsscene.cpp.

References d.

00223 {
00224     d->grid->setRootIndex( idx );
00225 }

void GraphicsScene::setRowController ( AbstractRowController rc  ) 

Definition at line 260 of file kdganttgraphicsscene.cpp.

References d.

00261 {
00262     d->rowController = rc;
00263 }

void GraphicsScene::setSelectionModel ( QItemSelectionModel *  selectionmodel  )  [slot]

Definition at line 249 of file kdganttgraphicsscene.cpp.

References d.

Referenced by setModel().

00250 {
00251     d->selectionModel = smodel;
00252     // TODO: update selection from model and connect signals
00253 }

void GraphicsScene::setSummaryHandlingModel ( QAbstractProxyModel proxyModel  )  [slot]

Definition at line 216 of file kdganttgraphicsscene.cpp.

References d, and model().

00217 {
00218     proxyModel->setSourceModel( model() );
00219     d->summaryHandlingModel = proxyModel;
00220 }

QAbstractProxyModel * GraphicsScene::summaryHandlingModel (  )  const

Definition at line 211 of file kdganttgraphicsscene.cpp.

References d.

Referenced by deleteSubtree(), findItem(), insertItem(), KDGantt::ConstraintGraphicsItem::proxyConstraint(), and updateRow().

00212 {
00213     return d->summaryHandlingModel;
00214 }

void GraphicsScene::updateItems (  ) 

Definition at line 497 of file kdganttgraphicsscene.cpp.

References d, KDGantt::GraphicsItem::rect(), and KDGantt::GraphicsItem::updateItem().

00498 {
00499     for ( QHash<QPersistentModelIndex,GraphicsItem*>::iterator it = d->items.begin();
00500           it != d->items.end(); ++it ) {
00501         GraphicsItem* const item = it.value();
00502         const QPersistentModelIndex& idx = it.key();
00503         item->updateItem( Span( item->pos().y(), item->rect().height() ), idx );
00504     }
00505     invalidate( QRectF(), QGraphicsScene::BackgroundLayer );
00506 }

void GraphicsScene::updateRow ( const QModelIndex &  idx  ) 

Definition at line 370 of file kdganttgraphicsscene.cpp.

References createItem(), d, findItem(), insertItem(), KDGantt::AbstractRowController::isRowExpanded(), KDGantt::ItemTypeRole, model(), removeItem(), rowController(), KDGantt::AbstractRowController::rowGeometry(), KDGantt::GraphicsItem::setIndex(), summaryHandlingModel(), KDGantt::TypeMulti, KDGantt::TypeNone, and KDGantt::GraphicsItem::updateItem().

00371 {
00372     //qDebug() << "GraphicsScene::updateRow("<<rowidx<<")" << rowidx.data( Qt::DisplayRole );
00373     if ( !rowidx.isValid() ) return;
00374     const QAbstractItemModel* model = rowidx.model(); // why const?
00375     assert( model );
00376     assert( rowController() );
00377     assert( model == summaryHandlingModel() );
00378 
00379     const QModelIndex sidx = summaryHandlingModel()->mapToSource( rowidx );
00380     Span rg = rowController()->rowGeometry( sidx );
00381     for ( QModelIndex treewalkidx = sidx; treewalkidx.isValid(); treewalkidx = treewalkidx.parent() ) {
00382         if ( treewalkidx.data( ItemTypeRole ).toInt() == TypeMulti
00383              && !rowController()->isRowExpanded( treewalkidx )) {
00384             rg = rowController()->rowGeometry( treewalkidx );
00385         }
00386     }
00387 
00388     bool blocked = blockSignals( true );
00389     for ( int col = 0; col < summaryHandlingModel()->columnCount( rowidx.parent() ); ++col ) {
00390         const QModelIndex idx = summaryHandlingModel()->index( rowidx.row(), col, rowidx.parent() );
00391         const QModelIndex sidx = summaryHandlingModel()->mapToSource( idx );
00392         const int itemtype = summaryHandlingModel()->data( idx, ItemTypeRole ).toInt();
00393         const bool isExpanded = rowController()->isRowExpanded( sidx );
00394         if ( itemtype == TypeNone ) {
00395             removeItem( idx );
00396             continue;
00397         }
00398         if ( itemtype == TypeMulti && !isExpanded ) {
00399             d->recursiveUpdateMultiItem( rg, idx );
00400         } else {
00401             if ( summaryHandlingModel()->data( rowidx.parent(), ItemTypeRole ).toInt() == TypeMulti && !isExpanded ) {
00402                 //continue;
00403             }
00404 
00405             GraphicsItem* item = findItem( idx );
00406             if (!item) {
00407                 item = createItem( static_cast<ItemType>( itemtype ) );
00408                 item->setIndex( idx );
00409                 insertItem(idx, item);
00410             }
00411             const Span span = rowController()->rowGeometry( sidx );
00412             item->updateItem( span, idx );
00413         }
00414     }
00415     blockSignals( blocked );
00416 }


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