KD Chart 2
[rev.2.5]
|
00001 /**************************************************************************** 00002 ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 00003 ** 00004 ** This file is part of the KD Chart library. 00005 ** 00006 ** Licensees holding valid commercial KD Chart licenses may use this file in 00007 ** accordance with the KD Chart Commercial License Agreement provided with 00008 ** the Software. 00009 ** 00010 ** 00011 ** This file may be distributed and/or modified under the terms of the 00012 ** GNU General Public License version 2 and version 3 as published by the 00013 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** Contact info@kdab.com if any conditions of this licensing are not 00019 ** clear to you. 00020 ** 00021 **********************************************************************/ 00022 00023 #include "kdganttgraphicsview.h" 00024 #include "kdganttgraphicsview_p.h" 00025 #include "kdganttabstractrowcontroller.h" 00026 #include "kdganttgraphicsitem.h" 00027 #include "kdganttconstraintmodel.h" 00028 00029 #include <QMenu> 00030 #include <QPainter> 00031 #include <QPaintEvent> 00032 #include <QResizeEvent> 00033 #include <QScrollBar> 00034 #include <QAbstractProxyModel> 00035 #include <QPrinter> 00036 00037 #include <cassert> 00038 00039 #if defined KDAB_EVAL 00040 #include "../evaldialog/evaldialog.h" 00041 #endif 00042 00047 using namespace KDGantt; 00048 00049 HeaderWidget::HeaderWidget( GraphicsView* parent ) 00050 : QWidget( parent ), m_offset( 0. ) 00051 { 00052 assert( parent ); // Parent must be set 00053 } 00054 00055 HeaderWidget::~HeaderWidget() 00056 { 00057 } 00058 00059 void HeaderWidget::scrollTo( int v ) 00060 { 00061 m_offset = v; 00062 // QWidget::scroll() wont work properly for me on Mac 00063 //scroll( static_cast<int>( old-v ), 0 ); 00064 update(); 00065 } 00066 00067 void HeaderWidget::paintEvent( QPaintEvent* ev ) 00068 { 00069 QPainter p( this ); 00070 view()->grid()->paintHeader( &p, rect(), ev->rect(), m_offset, this ); 00071 } 00072 00073 bool HeaderWidget::event( QEvent* event ) 00074 { 00075 if ( event->type() == QEvent::ToolTip ) { 00076 DateTimeGrid* const grid = qobject_cast< DateTimeGrid* >( view()->grid() ); 00077 if ( grid ) { 00078 QHelpEvent *e = static_cast<QHelpEvent*>( event ); 00079 QDateTime dt = grid->mapFromChart( view()->mapToScene( e->x(), 0 ).x() ).toDateTime(); 00080 setToolTip( dt.toString() ); 00081 } 00082 } 00083 return QWidget::event( event ); 00084 } 00085 00086 void HeaderWidget::contextMenuEvent( QContextMenuEvent* event ) 00087 { 00088 QMenu contextMenu; 00089 00090 DateTimeGrid* const grid = qobject_cast< DateTimeGrid* >( view()->grid() ); 00091 QAction* actionScaleAuto = 0; 00092 QAction* actionScaleMonth = 0; 00093 QAction* actionScaleWeek = 0; 00094 QAction* actionScaleDay = 0; 00095 QAction* actionScaleHour = 0; 00096 QAction* actionZoomIn = 0; 00097 QAction* actionZoomOut = 0; 00098 if( grid != 0 ) 00099 { 00100 QMenu* menuScale = new QMenu( tr( "Scale" ), &contextMenu ); 00101 QActionGroup* scaleGroup = new QActionGroup( &contextMenu ); 00102 scaleGroup->setExclusive( true ); 00103 00104 actionScaleAuto = new QAction( tr( "Auto" ), menuScale ); 00105 actionScaleAuto->setCheckable( true ); 00106 actionScaleAuto->setChecked( grid->scale() == DateTimeGrid::ScaleAuto ); 00107 actionScaleMonth = new QAction( tr( "Month" ), menuScale ); 00108 actionScaleMonth->setCheckable( true ); 00109 actionScaleMonth->setChecked( grid->scale() == DateTimeGrid::ScaleMonth ); 00110 actionScaleWeek = new QAction( tr( "Week" ), menuScale ); 00111 actionScaleWeek->setCheckable( true ); 00112 actionScaleWeek->setChecked( grid->scale() == DateTimeGrid::ScaleWeek ); 00113 actionScaleDay = new QAction( tr( "Day" ), menuScale ); 00114 actionScaleDay->setCheckable( true ); 00115 actionScaleDay->setChecked( grid->scale() == DateTimeGrid::ScaleDay ); 00116 actionScaleHour = new QAction( tr( "Hour" ), menuScale ); 00117 actionScaleHour->setCheckable( true ); 00118 actionScaleHour->setChecked( grid->scale() == DateTimeGrid::ScaleHour ); 00119 00120 scaleGroup->addAction( actionScaleAuto ); 00121 menuScale->addAction( actionScaleAuto ); 00122 00123 scaleGroup->addAction( actionScaleMonth ); 00124 menuScale->addAction( actionScaleMonth ); 00125 00126 scaleGroup->addAction( actionScaleWeek ); 00127 menuScale->addAction( actionScaleWeek ); 00128 00129 scaleGroup->addAction( actionScaleDay ); 00130 menuScale->addAction( actionScaleDay ); 00131 00132 scaleGroup->addAction( actionScaleHour ); 00133 menuScale->addAction( actionScaleHour ); 00134 00135 contextMenu.addMenu( menuScale ); 00136 00137 contextMenu.addSeparator(); 00138 00139 actionZoomIn = new QAction( tr( "Zoom In" ), &contextMenu ); 00140 contextMenu.addAction( actionZoomIn ); 00141 actionZoomOut = new QAction( tr( "Zoom Out" ), &contextMenu ); 00142 contextMenu.addAction( actionZoomOut ); 00143 } 00144 00145 if( contextMenu.isEmpty() ) 00146 { 00147 event->ignore(); 00148 return; 00149 } 00150 00151 const QAction* const action = contextMenu.exec( event->globalPos() ); 00152 if( action == 0 ) {} 00153 else if( action == actionScaleAuto ) 00154 { 00155 assert( grid != 0 ); 00156 grid->setScale( DateTimeGrid::ScaleAuto ); 00157 } 00158 else if( action == actionScaleMonth ) 00159 { 00160 assert( grid != 0 ); 00161 grid->setScale( DateTimeGrid::ScaleMonth ); 00162 } 00163 else if( action == actionScaleWeek ) 00164 { 00165 assert( grid != 0 ); 00166 grid->setScale( DateTimeGrid::ScaleWeek ); 00167 } 00168 else if( action == actionScaleDay ) 00169 { 00170 assert( grid != 0 ); 00171 grid->setScale( DateTimeGrid::ScaleDay ); 00172 } 00173 else if( action == actionScaleHour ) 00174 { 00175 assert( grid != 0 ); 00176 grid->setScale( DateTimeGrid::ScaleHour ); 00177 } 00178 else if( action == actionZoomIn ) 00179 { 00180 assert( grid != 0 ); 00181 grid->setDayWidth( grid->dayWidth() + 10.0 ); 00182 } 00183 else if( action == actionZoomOut ) 00184 { 00185 assert( grid != 0 ); 00186 grid->setDayWidth( grid->dayWidth() - 10.0 ); 00187 } 00188 00189 event->accept(); 00190 } 00191 00192 GraphicsView::Private::Private( GraphicsView* _q ) 00193 : q( _q ), rowcontroller(0), headerwidget( _q ) 00194 { 00195 } 00196 00197 void GraphicsView::Private::updateHeaderGeometry() 00198 { 00199 q->setViewportMargins(0,rowcontroller->headerHeight(),0,0); 00200 headerwidget.setGeometry( q->viewport()->x(), 00201 q->viewport()->y() - rowcontroller->headerHeight(), 00202 q->viewport()->width(), 00203 rowcontroller->headerHeight() ); 00204 } 00205 00206 void GraphicsView::Private::slotGridChanged() 00207 { 00208 updateHeaderGeometry(); 00209 headerwidget.update(); 00210 q->updateSceneRect(); 00211 q->update(); 00212 } 00213 00214 void GraphicsView::Private::slotHorizontalScrollValueChanged( int val ) 00215 { 00216 #if QT_VERSION >= 0x040300 00217 const QRectF viewRect = q->transform().mapRect( q->sceneRect() ); 00218 #else 00219 const QRectF viewRect = q->sceneRect(); 00220 #endif 00221 headerwidget.scrollTo( val-q->horizontalScrollBar()->minimum()+static_cast<int>( viewRect.left() ) ); 00222 } 00223 00224 void GraphicsView::Private::slotColumnsInserted( const QModelIndex& parent, int start, int end ) 00225 { 00226 Q_UNUSED( start ); 00227 Q_UNUSED( end ); 00228 QModelIndex idx = scene.model()->index( 0, 0, scene.summaryHandlingModel()->mapToSource( parent ) ); 00229 do { 00230 scene.updateRow( scene.summaryHandlingModel()->mapFromSource( idx ) ); 00231 } while ( ( idx = rowcontroller->indexBelow( idx ) ) != QModelIndex() && rowcontroller->isRowVisible( idx ) ); 00232 //} while ( ( idx = d->treeview.indexBelow( idx ) ) != QModelIndex() && d->treeview.visualRect(idx).isValid() ); 00233 q->updateSceneRect(); 00234 } 00235 00236 void GraphicsView::Private::slotColumnsRemoved( const QModelIndex& parent, int start, int end ) 00237 { 00238 // TODO 00239 Q_UNUSED( start ); 00240 Q_UNUSED( end ); 00241 Q_UNUSED( parent ); 00242 q->updateScene(); 00243 } 00244 00245 void GraphicsView::Private::slotDataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight ) 00246 { 00247 //qDebug() << "GraphicsView::slotDataChanged("<<topLeft<<bottomRight<<")"; 00248 const QModelIndex parent = topLeft.parent(); 00249 for ( int row = topLeft.row(); row <= bottomRight.row(); ++row ) { 00250 scene.updateRow( scene.summaryHandlingModel()->index( row, 0, parent ) ); 00251 } 00252 } 00253 00254 void GraphicsView::Private::slotLayoutChanged() 00255 { 00256 //qDebug() << "slotLayoutChanged()"; 00257 q->updateScene(); 00258 } 00259 00260 void GraphicsView::Private::slotModelReset() 00261 { 00262 //qDebug() << "slotModelReset()"; 00263 q->updateScene(); 00264 } 00265 00266 void GraphicsView::Private::slotRowsInserted( const QModelIndex& parent, int start, int end ) 00267 { 00268 Q_UNUSED( parent ); 00269 Q_UNUSED( start ); 00270 Q_UNUSED( end ); 00271 q->updateScene(); // TODO: This might be optimised 00272 } 00273 00274 void GraphicsView::Private::slotRowsAboutToBeRemoved( const QModelIndex& parent, int start, int end ) 00275 { 00276 //qDebug() << "GraphicsView::Private::slotRowsAboutToBeRemoved("<<parent<<start<<end<<")"; 00277 for ( int row = start; row <= end; ++row ) { 00278 for ( int col = 0; col < scene.summaryHandlingModel()->columnCount( parent ); ++col ) { 00279 //qDebug() << "removing "<<scene.summaryHandlingModel()->index( row, col, parent ); 00280 scene.removeItem( scene.summaryHandlingModel()->index( row, col, parent ) ); 00281 } 00282 } 00283 } 00284 00285 void GraphicsView::Private::slotRowsRemoved( const QModelIndex& parent, int start, int end ) 00286 { 00287 //qDebug() << "GraphicsView::Private::slotRowsRemoved("<<parent<<start<<end<<")"; 00288 // TODO 00289 Q_UNUSED( parent ); 00290 Q_UNUSED( start ); 00291 Q_UNUSED( end ); 00292 00293 q->updateScene(); 00294 } 00295 00296 void GraphicsView::Private::slotItemClicked( const QModelIndex& idx ) 00297 { 00298 QModelIndex sidx = idx;//scene.summaryHandlingModel()->mapToSource( idx ); 00299 emit q->clicked( sidx ); 00300 if (q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, q)) 00301 emit q->activated( sidx ); 00302 } 00303 00304 void GraphicsView::Private::slotItemDoubleClicked( const QModelIndex& idx ) 00305 { 00306 QModelIndex sidx = idx;//scene.summaryHandlingModel()->mapToSource( idx ); 00307 emit q->qrealClicked( sidx ); 00308 if (!q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, q)) 00309 emit q->activated( sidx ); 00310 } 00311 00312 void GraphicsView::Private::slotHeaderContextMenuRequested( const QPoint& pt ) 00313 { 00314 emit q->headerContextMenuRequested( headerwidget.mapToGlobal( pt ) ); 00315 } 00316 00338 GraphicsView::GraphicsView( QWidget* parent ) 00339 : QGraphicsView( parent ), _d( new Private( this ) ) 00340 { 00341 00342 #if defined KDAB_EVAL 00343 EvalDialog::checkEvalLicense( "KD Gantt" ); 00344 #endif 00345 connect( horizontalScrollBar(), SIGNAL( valueChanged( int ) ), 00346 this, SLOT( slotHorizontalScrollValueChanged( int ) ) ); 00347 connect( &_d->scene, SIGNAL( gridChanged() ), 00348 this, SLOT( slotGridChanged() ) ); 00349 connect( &_d->scene, SIGNAL( entered( const QModelIndex& ) ), 00350 this, SIGNAL( entered( const QModelIndex& ) ) ); 00351 connect( &_d->scene, SIGNAL( pressed( const QModelIndex& ) ), 00352 this, SIGNAL( pressed( const QModelIndex& ) ) ); 00353 connect( &_d->scene, SIGNAL( clicked( const QModelIndex& ) ), 00354 this, SLOT( slotItemClicked( const QModelIndex& ) ) ); 00355 connect( &_d->scene, SIGNAL( qrealClicked( const QModelIndex& ) ), 00356 this, SLOT( slotItemDoubleClicked( const QModelIndex& ) ) ); 00357 connect( &_d->scene, SIGNAL( sceneRectChanged( const QRectF& ) ), 00358 this, SLOT( updateSceneRect() ) ); 00359 connect( &_d->headerwidget, SIGNAL( customContextMenuRequested( const QPoint& ) ), 00360 this, SLOT( slotHeaderContextMenuRequested( const QPoint& ) ) ); 00361 setScene( &_d->scene ); 00362 00363 // HACK! 00364 setSummaryHandlingModel( _d->scene.summaryHandlingModel() ); 00365 00366 // So that AbstractGrid::drawBackground() and AbstractGrid::drawForeground() 00367 // works properly 00368 setViewportUpdateMode(QGraphicsView::FullViewportUpdate); 00369 00370 //setCacheMode( CacheBackground ); 00371 } 00372 00374 GraphicsView::~GraphicsView() 00375 { 00376 delete _d; 00377 } 00378 00379 #define d d_func() 00380 00394 void GraphicsView::setModel( QAbstractItemModel* model ) 00395 { 00396 if ( d->scene.model() ) { 00397 disconnect( d->scene.model() ); 00398 } 00399 00400 d->scene.setModel( model ); 00401 connect( model, SIGNAL( dataChanged( const QModelIndex&, const QModelIndex& ) ), 00402 this, SLOT( updateSceneRect() ) ); 00403 updateScene(); 00404 } 00405 00408 QAbstractItemModel* GraphicsView::model() const 00409 { 00410 return d->scene.model(); 00411 } 00412 00413 void GraphicsView::setSummaryHandlingModel( QAbstractProxyModel* proxyModel ) 00414 { 00415 disconnect( d->scene.summaryHandlingModel() ); 00416 d->scene.setSummaryHandlingModel( proxyModel ); 00417 00418 /* Connections. We have to rely on the treeview 00419 * to receive the signals before we do(!) 00420 */ 00421 connect( proxyModel, SIGNAL( columnsInserted( const QModelIndex&, int, int ) ), 00422 this, SLOT( slotColumnsInserted( const QModelIndex&, int, int ) ) ); 00423 connect( proxyModel, SIGNAL( columnsRemoved( const QModelIndex&, int, int ) ), 00424 this, SLOT( slotColumnsRemoved( const QModelIndex&, int, int ) ) ); 00425 connect( proxyModel, SIGNAL( dataChanged( const QModelIndex&, const QModelIndex& ) ), 00426 this, SLOT( slotDataChanged( const QModelIndex&, const QModelIndex& ) ) ); 00427 connect( proxyModel, SIGNAL( layoutChanged() ), 00428 this, SLOT( slotLayoutChanged() ) ); 00429 connect( proxyModel, SIGNAL( modelReset() ), 00430 this, SLOT( slotModelReset() ) ); 00431 connect( proxyModel, SIGNAL( rowsInserted( const QModelIndex&, int, int ) ), 00432 this, SLOT( slotRowsInserted( const QModelIndex&, int, int ) ) ); 00433 connect( proxyModel, SIGNAL( rowsAboutToBeRemoved( const QModelIndex&, int, int ) ), 00434 this, SLOT( slotRowsAboutToBeRemoved( const QModelIndex&, int, int ) ) ); 00435 connect( proxyModel, SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ), 00436 this, SLOT( slotRowsRemoved( const QModelIndex&, int, int ) ) ); 00437 00438 updateScene(); 00439 } 00440 00444 void GraphicsView::setConstraintModel( ConstraintModel* cmodel ) 00445 { 00446 d->scene.setConstraintModel( cmodel ); 00447 } 00448 00451 ConstraintModel* GraphicsView::constraintModel() const 00452 { 00453 return d->scene.constraintModel(); 00454 } 00455 00458 QAbstractProxyModel* GraphicsView::summaryHandlingModel() const 00459 { 00460 return d->scene.summaryHandlingModel(); 00461 } 00462 00466 void GraphicsView::setRootIndex( const QModelIndex& idx ) 00467 { 00468 d->scene.setRootIndex( idx ); 00469 } 00470 00473 QModelIndex GraphicsView::rootIndex() const 00474 { 00475 return d->scene.rootIndex(); 00476 } 00477 00481 void GraphicsView::setSelectionModel( QItemSelectionModel* model ) 00482 { 00483 d->scene.setSelectionModel( model ); 00484 } 00485 00488 QItemSelectionModel* GraphicsView::selectionModel() const 00489 { 00490 return d->scene.selectionModel(); 00491 } 00492 00496 void GraphicsView::setItemDelegate( ItemDelegate* delegate ) 00497 { 00498 d->scene.setItemDelegate( delegate ); 00499 } 00500 00503 ItemDelegate* GraphicsView::itemDelegate() const 00504 { 00505 return d->scene.itemDelegate(); 00506 } 00507 00513 void GraphicsView::setRowController( AbstractRowController* rowcontroller ) 00514 { 00515 d->rowcontroller = rowcontroller; 00516 d->scene.setRowController( rowcontroller ); 00517 updateScene(); 00518 } 00519 00523 AbstractRowController* GraphicsView::rowController() const 00524 { 00525 return d->rowcontroller; 00526 } 00527 00533 void GraphicsView::setGrid( AbstractGrid* grid ) 00534 { 00535 d->scene.setGrid( grid ); 00536 d->slotGridChanged(); 00537 } 00538 00541 AbstractGrid* GraphicsView::grid() const 00542 { 00543 return d->scene.grid(); 00544 } 00545 00549 void GraphicsView::setReadOnly( bool ro ) 00550 { 00551 d->scene.setReadOnly( ro ); 00552 } 00553 00556 bool GraphicsView::isReadOnly() const 00557 { 00558 return d->scene.isReadOnly(); 00559 } 00560 00570 void GraphicsView::setHeaderContextMenuPolicy( Qt::ContextMenuPolicy p ) 00571 { 00572 d->headerwidget.setContextMenuPolicy( p ); 00573 } 00574 00577 Qt::ContextMenuPolicy GraphicsView::headerContextMenuPolicy() const 00578 { 00579 return d->headerwidget.contextMenuPolicy(); 00580 } 00581 00590 void GraphicsView::addConstraint( const QModelIndex& from, 00591 const QModelIndex& to, 00592 Qt::KeyboardModifiers modifiers ) 00593 { 00594 if ( isReadOnly() ) return; 00595 ConstraintModel* cmodel = constraintModel(); 00596 assert( cmodel ); 00597 Constraint c( from, to, ( modifiers&Qt::ShiftModifier )?Constraint::TypeHard:Constraint::TypeSoft ); 00598 if ( cmodel->hasConstraint( c ) ) cmodel->removeConstraint( c ); 00599 else cmodel->addConstraint( c ); 00600 } 00601 00602 void GraphicsView::resizeEvent( QResizeEvent* ev ) 00603 { 00604 d->updateHeaderGeometry(); 00605 QRectF r = scene()->itemsBoundingRect(); 00606 // To scroll more to the left than the actual item start, bug #4516 00607 r.setLeft( qMin<qreal>( 0.0, r.left() ) ); 00608 // TODO: take scrollbars into account (if not always on) 00609 // The scene should be at least the size of the viewport 00610 QSizeF size = viewport()->size(); 00611 //TODO: why -2 below? size should be ex. frames etc? 00612 if ( size.width() > r.width() ) { 00613 r.setWidth( size.width() - 2 ); 00614 } 00615 if ( size.height() > r.height() ) { 00616 r.setHeight( size.height() - 2 ); 00617 } 00618 const int totalh = rowController()->totalHeight(); 00619 if ( r.height() < totalh ) { 00620 r.setHeight( totalh ); 00621 } 00622 00623 scene()->setSceneRect( r ); 00624 00625 QGraphicsView::resizeEvent( ev ); 00626 } 00627 00634 QModelIndex GraphicsView::indexAt( const QPoint& pos ) const 00635 { 00636 QGraphicsItem* item = itemAt( pos ); 00637 if ( GraphicsItem* gitem = qgraphicsitem_cast<GraphicsItem*>( item ) ) { 00638 return d->scene.summaryHandlingModel()->mapToSource( gitem->index() ); 00639 } else { 00640 return QModelIndex(); 00641 } 00642 } 00643 00645 void GraphicsView::clearItems() 00646 { 00647 d->scene.clearItems(); 00648 } 00649 00651 void GraphicsView::updateRow( const QModelIndex& idx ) 00652 { 00653 d->scene.updateRow( d->scene.summaryHandlingModel()->mapFromSource( idx ) ); 00654 } 00655 00659 void GraphicsView::updateSceneRect() 00660 { 00661 /* What to do with this? We need to shrink the view to 00662 * make collapsing items work 00663 */ 00664 qreal range = horizontalScrollBar()->maximum()-horizontalScrollBar()->minimum(); 00665 const qreal hscroll = horizontalScrollBar()->value()/( range>0?range:1 ); 00666 QRectF r = d->scene.itemsBoundingRect(); 00667 // To scroll more to the left than the actual item start, bug #4516 00668 r.setTop( 0. ); 00669 r.setLeft( qMin<qreal>( 0.0, r.left() ) ); 00670 r.setSize( r.size().expandedTo( viewport()->size() ) ); 00671 const int totalh = rowController()->totalHeight(); 00672 if ( r.height() < totalh ) r.setHeight( totalh ); 00673 d->scene.setSceneRect( r ); 00674 00675 /* set scrollbar to keep the same time in view */ 00676 range = horizontalScrollBar()->maximum()-horizontalScrollBar()->minimum(); 00677 if ( range>0 ) horizontalScrollBar()->setValue( qRound( hscroll*range ) ); 00678 00679 /* We have to update here to adjust for any rows with no 00680 * information because they are painted with a different 00681 * background brush 00682 */ 00683 d->scene.invalidate( QRectF(), QGraphicsScene::BackgroundLayer ); 00684 } 00685 00689 void GraphicsView::updateScene() 00690 { 00691 clearItems(); 00692 if( !model()) return; 00693 if( !rowController()) return; 00694 QModelIndex idx = model()->index( 0, 0, rootIndex() ); 00695 do { 00696 updateRow( idx ); 00697 } while ( ( idx = rowController()->indexBelow( idx ) ) != QModelIndex() && rowController()->isRowVisible(idx) ); 00698 //constraintModel()->cleanup(); 00699 //qDebug() << constraintModel(); 00700 updateSceneRect(); 00701 if ( scene() ) scene()->invalidate( QRectF(), QGraphicsScene::BackgroundLayer ); 00702 } 00703 00705 GraphicsItem* GraphicsView::createItem( ItemType type ) const 00706 { 00707 return d->scene.createItem( type ); 00708 } 00709 00711 void GraphicsView::deleteSubtree( const QModelIndex& idx ) 00712 { 00713 d->scene.deleteSubtree( d->scene.summaryHandlingModel()->mapFromSource( idx ) ); 00714 } 00715 00724 void GraphicsView::print( QPrinter* printer, bool drawRowLabels, bool drawColumnLabels ) 00725 { 00726 d->scene.print( printer, drawRowLabels, drawColumnLabels ); 00727 } 00728 00741 void GraphicsView::print( QPrinter* printer, qreal start, qreal end, bool drawRowLabels, bool drawColumnLabels ) 00742 { 00743 d->scene.print( printer, start, end, drawRowLabels, drawColumnLabels ); 00744 } 00745 00752 void GraphicsView::print( QPainter* painter, const QRectF& targetRect, bool drawRowLabels, bool drawColumnLabels ) 00753 { 00754 d->scene.print(painter, targetRect, drawRowLabels, drawColumnLabels); 00755 } 00756 00767 void GraphicsView::print( QPainter* painter, qreal start, qreal end, 00768 const QRectF& targetRect, bool drawRowLabels, bool drawColumnLabels ) 00769 { 00770 d->scene.print(painter, start, end, targetRect, drawRowLabels, drawColumnLabels); 00771 } 00772 00773 00774 #include "moc_kdganttgraphicsview.cpp"