00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "KDGanttView.h"
00037 #include "KDGanttViewSubwidgets.h"
00038 #include "KDGanttMinimizeSplitter.h"
00039 #include "KDGanttViewItem.h"
00040 #include "KDGanttXMLTools.h"
00041 #include "itemAttributeDialog.h"
00042 #include <qprinter.h>
00043 #include <qpainter.h>
00044 #include <qlayout.h>
00045 #include <qpaintdevicemetrics.h>
00046 #include <qfile.h>
00047 #include <qheader.h>
00048 #include <qscrollview.h>
00049 #include <qapplication.h>
00050 #include <qevent.h>
00051 #include <qiconview.h>
00052
00053 #include <qmessagebox.h>
00054 #include <qfileinfo.h>
00055
00056 #ifndef KDGANTT_MASTER_CVS
00057 #include "KDGanttView.moc"
00058 #endif
00059
00060 #if defined KDAB_EVAL
00061 #include "../evaldialog/evaldialog.h"
00062 #endif
00063
00083 KDGanttView::KDGanttView( QWidget* parent, const char* name ) : KDGanttMinimizeSplitter( Qt::Vertical, parent, name )
00084 {
00085 #if defined KDAB_EVAL
00086 EvalDialog::checkEvalLicense( "KD Gantt" );
00087 #endif
00088 myCurrentItem = 0;
00089 setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
00090 mySplitter = new KDGanttMinimizeSplitter( this );
00091 mySplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
00092 leftWidget = new QVBox( mySplitter );
00093 rightWidget = new QVBox( mySplitter );
00094
00095 myLegend = new KDLegendWidget( leftWidget, this );
00096 spacerLeft = new QHBox( leftWidget );
00097 myListView = new KDListView(leftWidget, this);
00098 myListView->setVScrollBarMode (QScrollView::AlwaysOff );
00099 connect( myListView, SIGNAL( selectionChanged( QListViewItem* ) ),
00100 this, SLOT( slotSelectionChanged( QListViewItem* ) ) );
00101
00102 connect( myListView, SIGNAL( mouseButtonClicked ( int, QListViewItem * , const QPoint &, int ) ), this, SLOT( slotmouseButtonClicked ( int , QListViewItem * , const QPoint &, int ) ) );
00103 connect( myListView, SIGNAL( contextMenuRequested ( QListViewItem * , const QPoint &, int ) ), this, SLOT( slotcontextMenuRequested ( QListViewItem * , const QPoint & , int ) ) );
00104 connect( myListView, SIGNAL(doubleClicked ( QListViewItem * ) ), this, SLOT(slotdoubleClicked ( QListViewItem * ) ) );
00105
00106 connect( myListView, SIGNAL(currentChanged( QListViewItem * ) ), this, SLOT(slotCurrentChanged ( QListViewItem * ) ) );
00107 connect( myListView, SIGNAL(itemRenamed ( QListViewItem * , int , const QString & ) ), this, SLOT(slotItemRenamed ( QListViewItem *, int , const QString & ) ) );
00108 connect( myListView, SIGNAL(mouseButtonPressed( int, QListViewItem * , const QPoint &, int ) ), this, SLOT(slotMouseButtonPressed ( int , QListViewItem * , const QPoint & , int ) ) );
00109
00110
00111 myTimeTable = new KDTimeTableWidget (rightWidget,this);
00112
00113 spacerRight = new QWidget( rightWidget );
00114
00115 myTimeHeaderContainer = new QHBox( rightWidget );
00116 myTimeHeaderContainer->setFrameStyle( QFrame::NoFrame );
00117 myTimeHeaderContainer->setMargin( 0 );
00118 myTimeHeaderScroll = new QScrollView ( myTimeHeaderContainer );
00119 myTimeHeaderScroll->setHScrollBarMode( QScrollView::AlwaysOff );
00120 myTimeHeaderScroll->setVScrollBarMode( QScrollView::AlwaysOff );
00121 timeHeaderSpacerWidget = new QWidget( myTimeHeaderContainer );
00122
00123
00124
00125
00126
00127
00128
00129
00130 myTimeHeader = new KDTimeHeaderWidget (myTimeHeaderScroll->viewport(),this);
00131 myTimeHeaderScroll->addChild( myTimeHeader );
00132 myTimeHeaderScroll->viewport()->setBackgroundColor( myTimeHeader->backgroundColor() );
00133 timeHeaderSpacerWidget->setBackgroundColor( myTimeHeader->backgroundColor() );
00134 myCanvasView = new KDGanttCanvasView (this,myTimeTable,rightWidget);
00135 myTimeHeaderScroll->setFrameStyle( QFrame::NoFrame );
00136
00137 myCanvasView->setFrameStyle( QFrame::NoFrame );
00138 myCanvasView->setMargin( 0 );
00139
00140 myTimeHeaderScroll->setMargin( 0 );
00141 setFrameStyle(myListView->frameStyle());
00142 setLineWidth( 2 );
00143 myListView->setFrameStyle( QFrame::NoFrame );
00144 myListView->setMargin( 0 );
00145 QObject::connect(myListView, SIGNAL ( expanded ( QListViewItem * ) ) , myTimeTable , SLOT( expandItem(QListViewItem * ))) ;
00146 QObject::connect(myListView, SIGNAL (collapsed ( QListViewItem * ) ) , myTimeTable , SLOT(collapseItem(QListViewItem * ))) ;
00147
00148 timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
00149 listViewIsVisible = true;
00150 chartIsEditable = true;
00151 editorIsEnabled = true;
00152 _displaySubitemsAsGroup = false;
00153 initDefaults();
00154 _showHeader = false;
00155
00156 myTextColor = Qt::black;
00157 myLegendItems = new QPtrList<legendItem>;
00158
00159 myItemAttributeDialog = new itemAttributeDialog();
00160 setRepaintMode( KDGanttView::Medium );
00161
00162 setShowLegendButton( true );
00163 setHeaderVisible( false );
00164
00165
00166 connect(myCanvasView->horizontalScrollBar(), SIGNAL ( valueChanged ( int )) ,myTimeHeaderScroll->horizontalScrollBar(), SLOT( setValue ( int))) ;
00167 connect(myCanvasView, SIGNAL ( heightResized( int )) ,myTimeTable, SLOT( checkHeight ( int))) ;
00168 connect(myCanvasView, SIGNAL ( widthResized( int )) ,myTimeHeader, SLOT( checkWidth ( int))) ;
00169
00170 QObject::connect(myCanvasView->verticalScrollBar(), SIGNAL ( valueChanged ( int ) ) ,myListView->verticalScrollBar(), SLOT( setValue ( int ))) ;
00171 connect(myTimeHeader, SIGNAL ( sizeChanged( int ) ) ,this, SLOT(slotHeaderSizeChanged() )) ;
00172 connect(myTimeHeader, SIGNAL ( sizeChanged( int ) ) ,myTimeTable, SLOT(resetWidth( int ) )) ;
00173 connect(myListView, SIGNAL ( contentsMoving ( int, int ) ) ,myCanvasView, SLOT( moveMyContent( int, int ))) ;
00174 connect(myTimeTable, SIGNAL ( heightComputed ( int ) ) ,myCanvasView, SLOT( setMyContentsHeight( int ))) ;
00175
00176 connect( myCanvasView->horizontalScrollBar(), SIGNAL (prevLine () ) ,this, SLOT(addTickLeft()));
00177 connect( myCanvasView->horizontalScrollBar(), SIGNAL (nextLine () ) ,this, SLOT(addTickRight()));
00178 connect( myCanvasView->horizontalScrollBar(), SIGNAL (valueChanged ( int ) ) ,this, SLOT( enableAdding( int )));
00179
00180
00181 fCenterTimeLineAfterShow = false;
00182 fDragEnabled = false;
00183 fDropEnabled = false;
00184 closingBlocked = false;
00185 myTimeHeader->computeTicks();
00186 centerTimelineAfterShow( QDateTime::currentDateTime () );
00187 setDisplayEmptyTasksAsLine( false );
00188 QValueList<int> list;
00189 list.append(240);
00190 list.append(530);
00191 mySplitter->setSizes( list );
00192 myTimeTable->setBlockUpdating();
00193 }
00194
00195
00196
00197 KDGanttView::~KDGanttView()
00198 {
00199 setUpdateEnabled(false);
00200
00201 myCanvasView->resetCutPaste( 0 );
00202 myTimeTable->clearTaskLinks();
00203 }
00227 void KDGanttView::setUpdateEnabled( bool enable )
00228 {
00229 myTimeTable->setBlockUpdating( !enable );
00230 if ( enable ) {
00231 myTimeTable->updateMyContent();
00232 myCanvasView->setMyContentsHeight( 0 );
00233 }
00234 }
00235
00243 bool KDGanttView::getUpdateEnabled() const
00244 {
00245 return !myTimeTable->blockUpdating();
00246 }
00247
00248
00249
00250
00257 void KDGanttView::setGanttMaximumWidth( int w )
00258 {
00259 myTimeHeader->setMaximumWidth ( w );
00260 }
00268 int KDGanttView::ganttMaximumWidth() const
00269 {
00270 return myTimeHeader->maximumWidth();
00271 }
00272
00279 void KDGanttView::show()
00280 {
00281 myTimeTable->setBlockUpdating( false );
00282 if (myCanvasView->horizontalScrollBar()->value() > 0 )
00283 myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->value()-1 );
00284 else
00285 myCanvasView->horizontalScrollBar()->setValue(1 );
00286 myTimeTable->updateMyContent();
00287 QWidget::show();
00288 myCanvasView->setMyContentsHeight( 0 );
00289 if ( fCenterTimeLineAfterShow ) {
00290 fCenterTimeLineAfterShow = false;
00291 centerTimeline (dtCenterTimeLineAfterShow);
00292 }
00293 }
00301 bool KDGanttView::close ( bool alsoDelete )
00302 {
00303
00304 if ( closingBlocked )
00305 return false;
00306 return QWidget::close ( alsoDelete );
00307 }
00308
00309
00318 QSize KDGanttView::sizeHint()
00319 {
00320 bool block = myTimeTable->blockUpdating();
00321 myTimeTable->setBlockUpdating( false );
00322 myTimeTable->updateMyContent();
00323 qApp->processEvents();
00324 int hintHeight = myTimeHeader->height();
00325 int legendHeight = 0;
00326 if ( showLegendButton() )
00327 legendHeight = myLegend->height();
00328 int listViewHeaderHeight = 0;
00329 if ( headerVisible() )
00330 listViewHeaderHeight = myListView->header()->height();
00331 if ( hintHeight < legendHeight+listViewHeaderHeight )
00332 hintHeight = legendHeight + listViewHeaderHeight;
00333 hintHeight += myListView->horizontalScrollBar()->height();
00334 if ( myLegend->isShown() )
00335 hintHeight += myLegend->legendSizeHint().height() +10;
00336 hintHeight += myTimeTable->minimumHeight+myListView->frameWidth()*2+2;
00337 int hintWid = myListView->sizeHint().width();
00338
00339 hintWid += myCanvasView->sizeHint().width();
00340
00341
00342 myTimeTable->setBlockUpdating( block );
00343 return QSize( hintWid+10, hintHeight );
00344 }
00345
00346
00354 void KDGanttView::setShowLegendButton( bool show )
00355 {
00356 _showLegendButton = show;
00357 if ( show )
00358 myLegend->show();
00359 else
00360 myLegend->hide();
00361 slotHeaderSizeChanged();
00362 }
00363
00364
00371 bool KDGanttView::showLegendButton() const
00372 {
00373 return _showLegendButton;
00374 }
00375
00376
00383 void KDGanttView::setHeaderVisible( bool visible )
00384 {
00385 if( visible )
00386 myListView->header()->show();
00387 else
00388 myListView->header()->hide();
00389 _showHeader = visible;
00390 slotHeaderSizeChanged();
00391 }
00392
00393
00399 bool KDGanttView::headerVisible() const
00400 {
00401 return _showHeader;
00402 }
00403
00404
00413 QDateTime KDGanttView::getDateTimeForCoordX(int coordX, bool global ) const
00414 {
00415
00416 return myTimeHeader->getDateTimeForIndex(coordX, !global );
00417 }
00418
00419
00423 void KDGanttView::slotSelectionChanged( QListViewItem* item )
00424 {
00425 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00426 Q_ASSERT( gItem );
00427 emit lvSelectionChanged( gItem );
00428 }
00429
00430
00431
00432
00433
00434
00435 void KDGanttView::slotmouseButtonClicked ( int button, QListViewItem * item,
00436 const QPoint & pos, int c )
00437 {
00438 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00439 emit lvMouseButtonClicked ( button , gItem, pos, c );
00440 if (gItem == 0 && myCurrentItem != 0 ) {
00441 myCurrentItem = 0;
00442 emit lvCurrentChanged( gItem );
00443 }
00444 if (gItem != 0 && myCurrentItem == 0 ) {
00445 myCurrentItem = gItem;
00446 emit lvCurrentChanged( gItem );
00447 }
00448
00449
00450
00451 {
00452 switch ( button ) {
00453 case LeftButton:
00454 emit lvItemLeftClicked( gItem );
00455 emit itemLeftClicked( gItem );
00456 break;
00457 case MidButton:
00458 emit lvItemMidClicked( gItem );
00459 emit itemMidClicked( gItem );
00460 break;
00461 }
00462 }
00463 }
00464
00465
00466
00467
00468
00469
00470
00471 void KDGanttView::slotcontextMenuRequested ( QListViewItem * item, const QPoint & pos, int col )
00472 {
00473 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00474 emit lvContextMenuRequested ( gItem, pos, col );
00475 emit lvItemRightClicked( gItem );
00476 emit itemRightClicked( gItem );
00477 }
00478
00479
00480
00481
00482
00483 void KDGanttView::slotdoubleClicked ( QListViewItem * item )
00484 {
00485 {
00486 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00487 emit lvItemDoubleClicked( gItem );
00488 emit itemDoubleClicked( gItem );
00489 }
00490 }
00491
00492
00493
00494
00495
00496 void KDGanttView::slotCurrentChanged ( QListViewItem * item )
00497 {
00498 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00499 myCurrentItem = gItem;
00500 emit lvCurrentChanged( gItem );
00501 }
00502
00503
00504
00505
00506
00507 void KDGanttView::slotItemRenamed ( QListViewItem * item , int col,
00508 const QString & text )
00509 {
00510 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00511 emit lvItemRenamed( gItem, col, text );
00512 }
00513
00514
00515
00516
00517
00518 void KDGanttView::slotMouseButtonPressed ( int button, QListViewItem * item,
00519 const QPoint & pos, int c )
00520 {
00521 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00522 emit lvMouseButtonPressed( button, gItem, pos, c );
00523 }
00524
00525
00540 void KDGanttView::setRepaintMode( RepaintMode mode )
00541 {
00542
00543 QScrollBar *cvh, *cvv;
00544 cvh = myCanvasView->horizontalScrollBar();
00545 cvv = myCanvasView->verticalScrollBar();
00546
00547 cvh->disconnect( this );
00548 cvv->disconnect( this );
00549
00550 switch ( mode ) {
00551 case No:
00552
00553 break;
00554 case Medium:
00555 connect( cvv, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00556 connect( cvh, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00557 connect( cvv, SIGNAL (nextLine () ) ,this, SLOT(forceRepaint()));
00558 connect( cvh, SIGNAL (nextLine () ) ,this, SLOT(forceRepaint()));
00559 connect( cvv, SIGNAL (prevLine () ) ,this, SLOT(forceRepaint()));
00560 connect( cvh, SIGNAL (prevLine () ) ,this, SLOT(forceRepaint()));
00561 break;
00562 case Always:
00563 connect( cvv, SIGNAL (valueChanged ( int ) ) ,this, SLOT(forceRepaint( int )));
00564 connect( cvh, SIGNAL (valueChanged ( int ) ) ,this, SLOT(forceRepaint( int )));
00565 connect( cvv, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00566 connect( cvh, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00567 break;
00568 }
00569 }
00570
00571
00572 void KDGanttView::forceRepaint( int )
00573 {
00574 if ( myTimeTable->blockUpdating() )
00575 return;
00576
00577 myTimeTable->setAllChanged();
00578 myTimeTable->update();
00579 }
00580
00581
00582 void KDGanttView::slotHeaderSizeChanged()
00583 {
00584 int legendHeight = 0;
00585 if ( showLegendButton() )
00586 legendHeight = 24;
00587 int listViewHeaderHeight = 0;
00588 if ( headerVisible() )
00589 listViewHeaderHeight = myListView->header()->height();
00590 int timeHeaderHeight = myTimeHeader->height()+myTimeHeaderScroll->frameWidth()*2;;
00591 int diffY = timeHeaderHeight-legendHeight-listViewHeaderHeight;
00592 if ( diffY < 0 ) {
00593 spacerLeft->setFixedHeight( 0 );
00594 spacerRight->setFixedHeight(-diffY);
00595 } else {
00596 spacerRight->setFixedHeight( 0 );
00597 spacerLeft->setFixedHeight( diffY );
00598 }
00599 myLegend->setFixedHeight( legendHeight );
00600 myTimeHeaderContainer->setFixedHeight( timeHeaderHeight );
00601 }
00602
00603 void KDGanttView::setLegendIsDockwindow( bool show )
00610 {
00611 bool isdock = myLegend->asDockwindow();
00612 if ( show != isdock ) {
00613 myLegend->setAsDockwindow(show);
00614
00615 legendItem* li;
00616 for ( li = myLegendItems->first(); li; li = myLegendItems->next() ) {
00617 myLegend->addLegendItem(li->shape, li->color, li->text );
00618 }
00619 }
00620 }
00621
00622 bool KDGanttView::legendIsDockwindow() const
00629 {
00630 return myLegend->asDockwindow();
00631 }
00632
00633
00646 QDockWindow* KDGanttView::legendDockwindow() const
00647 {
00648 return myLegend->dockwindow();
00649 }
00650
00651
00660 void KDGanttView::setShowLegend( bool show )
00661 {
00662 myLegend->showMe(show);
00663 }
00664
00665
00674 bool KDGanttView::showLegend() const
00675 {
00676 return myLegend->isShown();
00677 }
00678
00679
00688 void KDGanttView::setShowListView( bool show )
00689 {
00690 if(listViewIsVisible == show) return;
00691 listViewIsVisible = show;
00692 if (listViewIsVisible)
00693 myListView->parentWidget()->show();
00694 else
00695 myListView->parentWidget()->hide();
00696 }
00697
00698
00705 bool KDGanttView::showListView() const
00706 {
00707 return listViewIsVisible;
00708 }
00709
00710
00720 void KDGanttView::setEditorEnabled( bool enable )
00721 {
00722 editorIsEnabled = enable;
00723 }
00724
00725
00734 bool KDGanttView::editorEnabled() const
00735 {
00736 return editorIsEnabled;
00737 }
00738
00739
00748 void KDGanttView::setEditable( bool editable )
00749 {
00750 chartIsEditable = editable;
00751 }
00752
00753
00761 bool KDGanttView::editable() const
00762 {
00763 return chartIsEditable;
00764 }
00765
00766
00778 bool KDGanttView::saveProject( QIODevice* device )
00779 {
00780 Q_ASSERT( device );
00781
00782 QDomDocument doc = saveXML();
00783 if( device->isOpen() )
00784 device->close();
00785 if( device->open( IO_WriteOnly ) ) {
00786 QTextStream ts( device );
00787 ts << doc.toString();
00788 return true;
00789 } else
00790 return false;
00791 }
00792
00793
00805 bool KDGanttView::loadProject( QIODevice* device )
00806 {
00807 Q_ASSERT( device );
00808
00809 if( device->isOpen() )
00810 device->close();
00811 if( device->open( IO_ReadOnly ) ) {
00812 QDomDocument doc( "GanttView" );
00813 QString err;
00814 int errline, errcol;
00815 if ( !doc.setContent( device, &err, &errline, &errcol ) ) {
00816 qDebug("KDGantt::Error parsing XML data at line %d. Message is:", errline );
00817 qDebug("%s ", err.latin1());
00818 device->close();
00819 return false;
00820 }
00821 device->close();
00822 return loadXML( doc );
00823 } else
00824 return false;
00825 }
00826
00827
00846 void KDGanttView::print( QPrinter* printer ,
00847 bool printListView, bool printTimeLine,
00848 bool printLegend )
00849 {
00850 bool deletePrinter = false;
00851 if (! printer ) {
00852 printer = new QPrinter();
00853 deletePrinter = true;
00854 if ( !printer->setup()) {
00855 delete printer;
00856 return;
00857 }
00858 }
00859
00860 QPainter p( printer );
00861
00862 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
00863 float dx, dy;
00864
00865
00866
00867 QSize size = drawContents( 0, printListView, printTimeLine, printLegend );
00868
00869
00870 QString date = "Printing Time: " + QDateTime::currentDateTime().toString();
00871 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
00872 p.drawText( 0, 0, date );
00873
00874
00875 dx = (float) m.width() / (float)size.width();
00876 dy = (float)(m.height() - ( 2 * hei )) / (float)size.height();
00877 float scale;
00878
00879 if ( dx < dy )
00880 scale = dx;
00881 else
00882 scale = dy;
00883
00884 p.scale( scale, scale );
00885
00886 p.translate( 0, 2*hei );
00887 drawContents( &p, printListView, printTimeLine, printLegend );
00888
00889
00890
00891
00892
00893 p.end();
00894 if ( deletePrinter )
00895 delete printer;
00896 }
00897
00898
00938 QSize KDGanttView::drawContents( QPainter* p,
00939 bool drawListView , bool drawTimeLine, bool drawLegend )
00940 {
00941 QSize size;
00942 int lvX, lvY, thX, thY, tlX, tlY, lwX, lwY, allX, allY;
00943 lvX = myListView->contentsWidth();
00944 lvY = myCanvasView->canvas()->height() + 20;
00945 thX = myTimeHeader->width();
00946 thY = myTimeHeader->height();
00947 tlX = myCanvasView->canvas()->width();
00948 tlY = lvY;
00949 lwX = myLegend->legendSize().width();
00950 lwY = myLegend->legendSize().height();
00951 allX = 0;
00952 allY = 0;
00953 if ( drawListView ) {
00954 allX += lvX;
00955 allY += tlY;
00956 }
00957 if ( drawTimeLine ) {
00958 allX += thX;
00959 allY += thY;
00960 }
00961 if ( drawLegend ) {
00962 allY += lwY;
00963 if ( allX < lwX )
00964 allX = lwX ;
00965 }
00966 size = QSize( allX, allY );
00967 int temp = 0;
00968 if ( p ) {
00969 if ( drawListView ) {
00970 if ( drawTimeLine )
00971 temp = thY;
00972 p->translate( 0, temp );
00973 myListView->drawToPainter( p );
00974 p->translate( lvX, -temp);
00975 }
00976 if ( drawTimeLine ) {
00977 p->translate( myCanvasView->frameWidth(), 0);
00978 myTimeHeader->repaintMe( 0, myTimeHeader->width(), p );
00979 p->translate( -myCanvasView->frameWidth(), thY);
00980 myCanvasView->drawToPainter( p );
00981 if ( drawListView )
00982 p->translate( -lvX, tlY);
00983 else
00984 p->translate( 0, tlY);
00985 } else {
00986 if ( drawListView )
00987 p->translate( -lvX, 0 );
00988 }
00989 if ( drawLegend ) {
00990 myLegend->drawToPainter( p );
00991 p->translate( 0, lwY );
00992 }
00993 }
00994 return size;
00995 }
00996
01010 void KDGanttView::setZoomFactor( double factor, bool absolute )
01011 {
01012 myTimeHeader->zoom(factor,absolute);
01013 }
01014
01015
01023 double KDGanttView::zoomFactor() const
01024 {
01025 return myTimeHeader->zoomFactor();
01026 }
01027
01028
01037 void KDGanttView::zoomToFit()
01038 {
01039 myTimeHeader->zoomToFit();
01040 }
01041
01042
01054 void KDGanttView::zoomToSelection( const QDateTime& start, const QDateTime& end )
01055 {
01056
01057 myTimeHeader->zoomToSelection( start, end);
01058
01059 }
01060
01061
01068 void KDGanttView::ensureVisible( KDGanttViewItem* item )
01069 {
01070 myListView->ensureItemVisible (item);
01071 }
01072
01073
01082 void KDGanttView::centerTimeline( const QDateTime& center )
01083 {
01084 myTimeHeader->centerDateTime( center );
01085 }
01086
01087
01101 void KDGanttView::centerTimelineAfterShow( const QDateTime& center )
01102 {
01103 myTimeHeader->centerDateTime( center );
01104 if ( ! isVisible() ) {
01105 dtCenterTimeLineAfterShow = center;
01106 fCenterTimeLineAfterShow = true;
01107 }
01108 }
01109
01114 void KDGanttView::setTimelineToStart()
01115 {
01116 myCanvasView->horizontalScrollBar()->setValue( 0 );
01117 }
01118
01119
01123 void KDGanttView::setTimelineToEnd()
01124 {
01125 myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->maxValue());
01126 }
01127
01128
01139 void KDGanttView::addTicksLeft( int num )
01140 {
01141 myTimeHeader->addTickLeft( num );
01142 }
01143
01144
01154 void KDGanttView::addTicksRight( int num )
01155 {
01156 myTimeHeader->addTickRight( num );
01157 }
01158
01159
01164 void KDGanttView::center( KDGanttViewItem* item )
01165 {
01166 ensureVisible(item);
01167 int x = myListView->contentsWidth()/2;
01168 int y = myListView->itemPos (item );
01169 myListView->center(x,y);
01170 }
01171
01172
01179 void KDGanttView::setShowTaskLinks( bool show )
01180 {
01181 myTimeTable->setShowTaskLinks(show);
01182
01183 }
01184
01185
01192 bool KDGanttView::showTaskLinks() const
01193 {
01194 return myTimeTable->showTaskLinks();
01195 }
01196
01197
01205 void KDGanttView::setFont(const QFont& font)
01206 {
01207 myListView->setFont(font);
01208 myListView->repaint();
01209 myTimeHeader->setFont(font);
01210 myLegend->setFont( font );
01211 QWidget::setFont( font );
01212 setScale(scale());
01213 }
01214
01215
01240 void KDGanttView::setShowHeaderPopupMenu( bool show,
01241 bool showZoom,
01242 bool showScale,
01243 bool showTime,
01244 bool showYear,
01245 bool showGrid,
01246 bool showPrint)
01247 {
01248 myTimeHeader->setShowPopupMenu( show,showZoom,showScale,showTime,
01249 showYear,showGrid,showPrint );
01250 }
01251
01252
01259 bool KDGanttView::showHeaderPopupMenu() const
01260 {
01261 return myTimeHeader->showPopupMenu();
01262 }
01263
01264
01265
01279 void KDGanttView::setShowTimeTablePopupMenu( bool show )
01280 {
01281 myCanvasView->setShowPopupMenu( show );
01282 }
01283
01284
01291 bool KDGanttView::showTimeTablePopupMenu() const
01292 {
01293 return myCanvasView->showPopupMenu();
01294 }
01295
01296
01314 void KDGanttView::setShapes( KDGanttViewItem::Type type,
01315 KDGanttViewItem::Shape start,
01316 KDGanttViewItem::Shape middle,
01317 KDGanttViewItem::Shape end,
01318 bool overwriteExisting )
01319 {
01320 if ( overwriteExisting ) {
01321 QListViewItemIterator it(myListView);
01322 for ( ; it.current(); ++it ) {
01323 if ( ((KDGanttViewItem*)it.current())->type() == type)
01324 ((KDGanttViewItem*)it.current())->setShapes(start,middle, end );
01325 }
01326 }
01327 int index = getIndex( type );
01328 myDefaultShape [index*3] = start;
01329 myDefaultShape [index*3+1] = middle;
01330 myDefaultShape [index*3+2] = end;
01331 undefinedShape[index] = false;
01332 }
01333
01334
01347 bool KDGanttView::shapes( KDGanttViewItem::Type type,
01348 KDGanttViewItem::Shape& start,
01349 KDGanttViewItem::Shape& middle,
01350 KDGanttViewItem::Shape& end ) const
01351 {
01352 int index = getIndex( type );
01353 start = myDefaultShape [index*3];
01354 middle = myDefaultShape [index*3+1];
01355 end = myDefaultShape [index*3+2];
01356 return !undefinedShape[index];
01357 }
01358
01359
01377 void KDGanttView::setColors( KDGanttViewItem::Type type,
01378 const QColor& start, const QColor& middle,
01379 const QColor& end,
01380 bool overwriteExisting )
01381 {
01382 if ( overwriteExisting ) {
01383 QListViewItemIterator it(myListView);
01384 for ( ; it.current(); ++it ) {
01385 if ( ((KDGanttViewItem*)it.current())->type() == type)
01386 ((KDGanttViewItem*)it.current())->setColors(start,middle, end );
01387 }
01388 }
01389 int index = getIndex( type );
01390 myColor [index*3] = start;
01391 myColor [index*3+1] = middle;
01392 myColor [index*3+2] = end;
01393 undefinedColor[index] = false;
01394 }
01395
01396
01409 bool KDGanttView::colors( KDGanttViewItem::Type type,
01410 QColor& start, QColor& middle, QColor& end ) const
01411 {
01412 int index = getIndex( type );
01413 start = myColor [index*3];
01414 middle = myColor [index*3+1];
01415 end = myColor [index*3+2];
01416 return !undefinedColor[index];
01417 }
01418
01419
01439 void KDGanttView::setHighlightColors( KDGanttViewItem::Type type,
01440 const QColor& start,
01441 const QColor& middle,
01442 const QColor& end,
01443 bool overwriteExisting )
01444 {
01445 if ( overwriteExisting ) {
01446 QListViewItemIterator it(myListView);
01447 for ( ; it.current(); ++it ) {
01448 if ( ((KDGanttViewItem*)it.current())->type() == type)
01449 ((KDGanttViewItem*)it.current())->setHighlightColors(start,middle, end );
01450 }
01451 }
01452 int index = getIndex( type );
01453 myColorHL [index*3] = start;
01454 myColorHL [index*3+1] = middle;
01455 myColorHL [index*3+2] = end;
01456 undefinedColorHL[index] = false;
01457
01458 }
01459
01460
01475 bool KDGanttView::highlightColors( KDGanttViewItem::Type type,
01476 QColor& start, QColor& middle,
01477 QColor& end ) const
01478 {
01479 int index = getIndex( type );
01480 start = myColorHL [index*3];
01481 middle = myColorHL [index*3+1];
01482 end = myColorHL [index*3+2];
01483 return !undefinedColorHL[index];
01484 }
01485
01486
01494 void KDGanttView::setTextColor( const QColor& color )
01495 {
01496 QListViewItemIterator it(myListView);
01497 for ( ; it.current(); ++it ) {
01498 ((KDGanttViewItem*)it.current())->setTextColor(color);
01499 }
01500 myTextColor = color;
01501 }
01502
01503
01510 QColor KDGanttView::textColor() const
01511 {
01512 return myTextColor;
01513 }
01514
01515
01526 void KDGanttView::setNoInformationBrush( const QBrush& brush )
01527 {
01528 myTimeTable->setNoInformationBrush( brush );
01529 }
01530
01531
01538 QBrush KDGanttView::noInformationBrush() const
01539 {
01540 return myTimeTable->noInformationBrush();
01541 }
01542
01543
01549 void KDGanttView::clearLegend( )
01550 {
01551 myLegend->clearLegend();
01552 myLegendItems->setAutoDelete( true );
01553 delete myLegendItems;
01554 myLegendItems = new QPtrList<legendItem>;
01555 }
01556
01557
01566 void KDGanttView::addLegendItem( KDGanttViewItem::Shape shape,
01567 const QColor& shapeColor,
01568 const QString& text )
01569 {
01570 myLegend->addLegendItem( shape,shapeColor,text );
01571 legendItem* item = new legendItem;
01572 item->shape = shape;
01573 item->color = shapeColor;
01574 item->text = text;
01575 myLegendItems->append( item );
01576 }
01577
01578
01586 void KDGanttView::setHorizonStart( const QDateTime& start )
01587 {
01588 myTimeHeader->setHorizonStart(start);
01589 }
01590
01591
01598 QDateTime KDGanttView::horizonStart() const
01599 {
01600 return myTimeHeader->horizonStart();
01601 }
01602
01603
01611 void KDGanttView::setHorizonEnd( const QDateTime& end )
01612 {
01613 myTimeHeader->setHorizonEnd(end);
01614 }
01615
01616
01624 QDateTime KDGanttView::horizonEnd() const
01625 {
01626 return myTimeHeader->horizonEnd();
01627 }
01628
01629
01637 void KDGanttView::setScale( Scale unit )
01638 {
01639 myTimeHeader->setScale( unit );
01640 }
01641
01642
01649 KDGanttView::Scale KDGanttView::scale() const
01650 {
01651 return myTimeHeader->scale();
01652 }
01653
01654
01661 void KDGanttView::setMaximumScale( Scale unit )
01662 {
01663 myTimeHeader->setMaximumScale( unit );
01664 }
01665
01666
01673 KDGanttView::Scale KDGanttView::maximumScale() const
01674 {
01675 return myTimeHeader->maximumScale();
01676 }
01677
01678
01685 void KDGanttView::setMinimumScale( Scale unit )
01686 {
01687 myTimeHeader->setMinimumScale( unit );
01688 }
01689
01690
01697 KDGanttView::Scale KDGanttView::minimumScale() const
01698 {
01699 return myTimeHeader->minimumScale();
01700 }
01701
01702
01712 void KDGanttView::setAutoScaleMinorTickCount( int count )
01713 {
01714 myTimeHeader->setAutoScaleMinorTickCount( count );
01715 }
01716
01717
01724 int KDGanttView::autoScaleMinorTickCount() const
01725 {
01726 return myTimeHeader->autoScaleMinorTickCount();
01727 }
01728
01729
01738 void KDGanttView::setMinimumColumnWidth( int width )
01739 {
01740 myTimeHeader->setMinimumColumnWidth( width );
01741 }
01742
01743
01750 int KDGanttView::minimumColumnWidth() const
01751 {
01752 return myTimeHeader->minimumColumnWidth();
01753 }
01754
01755
01763 void KDGanttView::setYearFormat( YearFormat format )
01764 {
01765 myTimeHeader->setYearFormat(format );
01766 }
01767
01768
01775 KDGanttView::YearFormat KDGanttView::yearFormat() const
01776 {
01777 return myTimeHeader->yearFormat();
01778 }
01779
01780
01789 void KDGanttView::setHourFormat( HourFormat format )
01790 {
01791 myTimeHeader->setHourFormat( format );
01792 }
01793
01794
01802 KDGanttView::HourFormat KDGanttView::hourFormat() const
01803 {
01804 return myTimeHeader->hourFormat();
01805 }
01806
01807
01818 void KDGanttView::setShowMajorTicks( bool show )
01819 {
01820 myTimeHeader->setShowMajorTicks(show );
01821 }
01822
01823
01830 bool KDGanttView::showMajorTicks() const
01831 {
01832 return myTimeHeader->showMajorTicks();
01833 }
01834
01835
01848 void KDGanttView::setShowMinorTicks( bool show)
01849 {
01850 myTimeHeader->setShowMinorTicks( show );
01851 }
01852
01853
01860 bool KDGanttView::showMinorTicks() const
01861 {
01862 return myTimeHeader->showMinorTicks();
01863 }
01864
01865
01883 void KDGanttView::setColumnBackgroundColor( const QDateTime& column,
01884 const QColor& color ,
01885 Scale mini, Scale maxi )
01886 {
01887 myTimeHeader->setColumnBackgroundColor( column, color,mini,maxi );
01888 }
01889
01890
01917 void KDGanttView::setIntervalBackgroundColor( const QDateTime& start,
01918 const QDateTime& end,
01919 const QColor& color ,
01920 Scale mini, Scale maxi )
01921 {
01922 myTimeHeader->setIntervalBackgroundColor( start, end, color,mini,maxi );
01923 }
01924
01925
01944 bool KDGanttView::changeBackgroundInterval( const QDateTime& oldstart,
01945 const QDateTime& oldend,
01946 const QDateTime& newstart,
01947 const QDateTime& newend )
01948 {
01949 return myTimeHeader->changeBackgroundInterval( oldstart, oldend,
01950 newstart, newend );
01951 }
01952
01962 bool KDGanttView::deleteBackgroundInterval( const QDateTime& start,
01963 const QDateTime& end)
01964 {
01965 return myTimeHeader->deleteBackgroundInterval( start, end );
01966 }
01967
01968
01977 void KDGanttView::clearBackgroundColor()
01978 {
01979 myTimeHeader->clearBackgroundColor();
01980 }
01981
01982
01991 QColor KDGanttView::columnBackgroundColor( const QDateTime& column ) const
01992 {
01993 return myTimeHeader->columnBackgroundColor( column ) ;
01994 }
01995
01996
02005 void KDGanttView::setWeekendBackgroundColor( const QColor& color )
02006 {
02007 myTimeHeader->setWeekendBackgroundColor( color );
02008 }
02009
02010
02017 QColor KDGanttView::weekendBackgroundColor() const
02018 {
02019 return myTimeHeader->weekendBackgroundColor();
02020 }
02021
02022
02033 void KDGanttView::setWeekdayBackgroundColor( const QColor& color, int weekday )
02034 {
02035 myTimeHeader->setWeekdayBackgroundColor( color, weekday );
02036 }
02037
02038
02046 QColor KDGanttView::weekdayBackgroundColor(int weekday) const
02047 {
02048 return myTimeHeader->weekdayBackgroundColor( weekday);
02049 }
02050
02051
02052
02063 void KDGanttView::setWeekendDays( int start, int end )
02064 {
02065 myTimeHeader->setWeekendDays( start, end );
02066 }
02067
02068
02076 void KDGanttView::weekendDays( int& start, int& end ) const
02077 {
02078 myTimeHeader->weekendDays( start, end );
02079 }
02080
02081
02182 void KDGanttView::setMajorScaleCount( int count )
02183 {
02184 myTimeHeader->setMajorScaleCount(count );
02185 }
02186
02187
02194 int KDGanttView::majorScaleCount() const
02195 {
02196 return myTimeHeader->majorScaleCount();
02197 }
02198
02199
02206 void KDGanttView::setMinorScaleCount( int count )
02207 {
02208 myTimeHeader->setMinorScaleCount(count );
02209 }
02210
02211
02218 int KDGanttView::minorScaleCount() const
02219 {
02220 return myTimeHeader->minorScaleCount();
02221
02222 }
02223
02224
02237 void KDGanttView::setDefaultColor( KDGanttViewItem::Type type,
02238 const QColor& color,
02239 bool overwriteExisting )
02240 {
02241 if ( overwriteExisting ) {
02242 QListViewItemIterator it(myListView);
02243 for ( ; it.current(); ++it ) {
02244 if ( ((KDGanttViewItem*)it.current())->type() == type)
02245 ((KDGanttViewItem*)it.current())->setDefaultColor(color );
02246 }
02247 }
02248 int index = getIndex( type );
02249 myDefaultColor [index] = color;
02250 }
02251
02252
02253
02264 QColor KDGanttView::defaultColor( KDGanttViewItem::Type type ) const
02265 {
02266 int index = getIndex( type );
02267 return myDefaultColor [index];
02268 }
02269
02270
02283 void KDGanttView::setDefaultHighlightColor( KDGanttViewItem::Type type,
02284 const QColor& color,
02285 bool overwriteExisting )
02286 {
02287 if ( overwriteExisting ) {
02288 QListViewItemIterator it(myListView);
02289 for ( ; it.current(); ++it ) {
02290 if ( ((KDGanttViewItem*)it.current())->type() == type)
02291 ((KDGanttViewItem*)it.current())->setDefaultHighlightColor(color );
02292 }
02293 }
02294 int index = getIndex( type );
02295 myDefaultColorHL [index] = color;
02296 }
02297
02298
02299
02310 QColor KDGanttView::defaultHighlightColor( KDGanttViewItem::Type type ) const
02311 {
02312 int index = getIndex( type );
02313 return myDefaultColorHL [index];
02314 }
02315
02316
02322 KDGanttViewItem* KDGanttView::firstChild() const
02323 {
02324 return (KDGanttViewItem*)myListView->firstChild();
02325
02326 }
02344 void KDGanttView::setCalendarMode( bool mode )
02345 {
02346 myListView->setCalendarMode( mode );
02347 }
02348
02349
02357 bool KDGanttView::calendarMode() const
02358 {
02359 return myListView->calendarMode();
02360 }
02361
02362
02363
02373 void KDGanttView::setDisplaySubitemsAsGroup( bool show )
02374 {
02375 QListViewItemIterator it( myListView );
02376 for ( ; it.current(); ++it ) {
02377 KDGanttViewItem* currentItem = ( KDGanttViewItem* )it.current();
02378 currentItem->setDisplaySubitemsAsGroup( show );
02379 }
02380 _displaySubitemsAsGroup = show;
02381 }
02382
02383
02392 bool KDGanttView::displaySubitemsAsGroup() const
02393 {
02394 return _displaySubitemsAsGroup;
02395 }
02396
02397
02405 void KDGanttView::setDisplayEmptyTasksAsLine( bool show )
02406 {
02407 _displayEmptyTasksAsLine = show;
02408 }
02409
02410
02417 bool KDGanttView::displayEmptyTasksAsLine() const
02418 {
02419 return _displayEmptyTasksAsLine;
02420 }
02421
02422
02437 void KDGanttView::setHorBackgroundLines( int count, QBrush brush )
02438 {
02439 myTimeTable->setHorBackgroundLines( count, brush );
02440 }
02441
02442
02452 int KDGanttView::horBackgroundLines( QBrush& brush )
02453 {
02454 return myTimeTable->horBackgroundLines( brush );
02455 }
02456
02457
02463 KDGanttViewItem* KDGanttView::lastItem() const
02464 {
02465 return (KDGanttViewItem*)myListView->lastItem ();
02466 }
02467
02468
02474 QPtrList<KDGanttViewTaskLink> KDGanttView::taskLinks() const
02475 {
02476
02477 return myTimeTable->taskLinks();
02478 }
02479
02480
02486 QPtrList<KDGanttViewTaskLinkGroup> KDGanttView::taskLinkGroups() const
02487 {
02488 return myTaskLinkGroupList;
02489 }
02490
02491
02499 bool KDGanttView::loadXML( const QDomDocument& doc )
02500 {
02501 QDomElement docRoot = doc.documentElement();
02502 QDomNode node = docRoot.firstChild();
02503 while( !node.isNull() ) {
02504 QDomElement element = node.toElement();
02505 if( !element.isNull() ) {
02506 QString tagName = element.tagName();
02507 if( tagName == "ShowLegend" ) {
02508 bool value;
02509 if( KDGanttXML::readBoolNode( element, value ) )
02510 setShowLegend( value );
02511 } else if( tagName == "ShowLegendButton" ) {
02512 bool value;
02513 if( KDGanttXML::readBoolNode( element, value ) )
02514 setShowLegendButton( value );
02515 } else if( tagName == "LegendIsDockWindow" ) {
02516 bool value;
02517 if( KDGanttXML::readBoolNode( element, value ) )
02518 setLegendIsDockwindow( value );
02519 } else if( tagName == "ShowListView" ) {
02520 bool value;
02521 if( KDGanttXML::readBoolNode( element, value ) )
02522 setShowListView( value );
02523 } else if( tagName == "ShowHeader" ) {
02524 bool value;
02525 if( KDGanttXML::readBoolNode( element, value ) )
02526 setHeaderVisible( value );
02527 } else if( tagName == "ShowTaskLinks" ) {
02528 bool value;
02529 if( KDGanttXML::readBoolNode( element, value ) )
02530 setShowTaskLinks( value );
02531 } else if( tagName == "EditorEnabled" ) {
02532 bool value;
02533 if( KDGanttXML::readBoolNode( element, value ) )
02534 setEditorEnabled( value );
02535 } else if( tagName == "DisplayEmptyTasksAsLine" ) {
02536 bool value;
02537 if( KDGanttXML::readBoolNode( element, value ) )
02538 setDisplayEmptyTasksAsLine( value );
02539 } else if( tagName == "GlobalFont" ) {
02540 QFont font;
02541 if( KDGanttXML::readFontNode( element, font ) )
02542 setFont( font );
02543 } else if( tagName == "HorizonStart" ) {
02544 QDateTime value;
02545 if( KDGanttXML::readDateTimeNode( element, value ) )
02546 setHorizonStart( value );
02547 } else if( tagName == "HorizonEnd" ) {
02548 QDateTime value;
02549 if( KDGanttXML::readDateTimeNode( element, value ) )
02550 setHorizonEnd( value );
02551 } else if( tagName == "Scale" ) {
02552 QString value;
02553 if( KDGanttXML::readStringNode( element, value ) )
02554 setScale( stringToScale( value ) );
02555 } else if( tagName == "MinimumScale" ) {
02556 QString value;
02557 if( KDGanttXML::readStringNode( element, value ) )
02558 setMinimumScale( stringToScale( value ) );
02559 } else if( tagName == "MaximumScale" ) {
02560 QString value;
02561 if( KDGanttXML::readStringNode( element, value ) )
02562 setMaximumScale( stringToScale( value ) );
02563 } else if( tagName == "YearFormat" ) {
02564 QString value;
02565 if( KDGanttXML::readStringNode( element, value ) )
02566 setYearFormat( stringToYearFormat( value ) );
02567 } else if( tagName == "HourFormat" ) {
02568 QString value;
02569 if( KDGanttXML::readStringNode( element, value ) )
02570 setHourFormat( stringToHourFormat( value ) );
02571 } else if( tagName == "ShowMinorTicks" ) {
02572 bool value;
02573 if( KDGanttXML::readBoolNode( element, value ) )
02574 setShowMinorTicks( value );
02575 } else if( tagName == "ShowMajorTicks" ) {
02576 bool value;
02577 if( KDGanttXML::readBoolNode( element, value ) )
02578 setShowMajorTicks( value );
02579 } else if( tagName == "DragEnabled" ) {
02580 bool value;
02581 if( KDGanttXML::readBoolNode( element, value ) )
02582 setDragEnabled( value );
02583 } else if( tagName == "DropEnabled" ) {
02584 bool value;
02585 if( KDGanttXML::readBoolNode( element, value ) )
02586 setDropEnabled( value );
02587 } else if( tagName == "CalendarMode" ) {
02588 bool value;
02589 if( KDGanttXML::readBoolNode( element, value ) )
02590 setCalendarMode( value );
02591 } else if( tagName == "Editable" ) {
02592 bool value;
02593 if( KDGanttXML::readBoolNode( element, value ) )
02594 setEditable( value );
02595 } else if( tagName == "TextColor" ) {
02596 QColor value;
02597 if( KDGanttXML::readColorNode( element, value ) )
02598 setTextColor( value );
02599 } else if( tagName == "MajorScaleCount" ) {
02600 int value;
02601 if( KDGanttXML::readIntNode( element, value ) )
02602 setMajorScaleCount( value );
02603 } else if( tagName == "MinorScaleCount" ) {
02604 int value;
02605 if( KDGanttXML::readIntNode( element, value ) )
02606 setMinorScaleCount( value );
02607 } else if( tagName == "AutoScaleMinorTickCount" ) {
02608 int value;
02609 if( KDGanttXML::readIntNode( element, value ) )
02610 setAutoScaleMinorTickCount( value );
02611 } else if( tagName == "MinimumColumnWidth" ) {
02612 int value;
02613 if( KDGanttXML::readIntNode( element, value ) )
02614 setMinimumColumnWidth( value );
02615 } else if( tagName == "GanttMaximumWidth" ) {
02616 int value;
02617 if( KDGanttXML::readIntNode( element, value ) )
02618 setGanttMaximumWidth( value );
02619 } else if( tagName == "NoInformationBrush" ) {
02620 QBrush value;
02621 if( KDGanttXML::readBrushNode( element, value ) )
02622 setNoInformationBrush( value );
02623 } else if( tagName == "GanttViewBackgroundColor" ) {
02624 QColor value;
02625 if( KDGanttXML::readColorNode( element, value ) )
02626 setGvBackgroundColor( value );
02627 } else if( tagName == "ListViewBackgroundColor" ) {
02628 QColor value;
02629 if( KDGanttXML::readColorNode( element, value ) )
02630 setLvBackgroundColor( value );
02631 } else if( tagName == "TimeHeaderBackgroundColor" ) {
02632 QColor value;
02633 if( KDGanttXML::readColorNode( element, value ) )
02634 setTimeHeaderBackgroundColor( value );
02635 } else if( tagName == "LegendHeaderBackgroundColor" ) {
02636 QColor value;
02637 if( KDGanttXML::readColorNode( element, value ) )
02638 setLegendHeaderBackgroundColor( value );
02639 } else if( tagName == "WeekendBackgroundColor" ) {
02640 QColor value;
02641 if( KDGanttXML::readColorNode( element, value ) )
02642 setWeekendBackgroundColor( value );
02643 } else if( tagName == "WeekdayBackgroundColor" ) {
02644 QDomNode node = element.firstChild();
02645 int day = 0;
02646 QColor color;
02647 while( !node.isNull() ) {
02648 QDomElement element = node.toElement();
02649 if( !element.isNull() ) {
02650 QString tagName = element.tagName();
02651 if( tagName == "Day" ) {
02652 int value;
02653 if( KDGanttXML::readIntNode( element, value ) )
02654 day = value;
02655 } else if( tagName == "Color" ) {
02656 QColor value;
02657 if( KDGanttXML::readColorNode( element, value ) )
02658 color = value;
02659 } else {
02660 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02661 Q_ASSERT( false );
02662 }
02663 }
02664 node = node.nextSibling();
02665 }
02666
02667 if( day && color.isValid() )
02668 setWeekdayBackgroundColor( color, day );
02669 } else if( tagName == "WeekendDays" ) {
02670 QString startString = element.attribute( "Start" );
02671 QString endString = element.attribute( "End" );
02672 bool startOk = false, endOk = false;
02673 int start = startString.toInt( &startOk );
02674 int end = startString.toInt( &endOk );
02675 if( startOk && endOk )
02676 setWeekendDays( start, end );
02677 } else if( tagName == "ZoomFactor" ) {
02678 double value;
02679 if( KDGanttXML::readDoubleNode( element, value ) )
02680 setZoomFactor( value, true );
02681 } else if( tagName == "ShowHeaderPopupMenu" ) {
02682 bool value;
02683 if( KDGanttXML::readBoolNode( element, value ) )
02684 setShowHeaderPopupMenu( value );
02685 } else if( tagName == "ShowTimeTablePopupMenu" ) {
02686 bool value;
02687 if( KDGanttXML::readBoolNode( element, value ) )
02688 setShowTimeTablePopupMenu( value );
02689 } else if( tagName == "Shapes" ) {
02690 QDomNode node = element.firstChild();
02691 bool undefinedShape = false;
02692 while( !node.isNull() ) {
02693 QDomElement element = node.toElement();
02694 if( !element.isNull() ) {
02695 QString tagName = element.tagName();
02696 if( tagName == "Event" ) {
02697 KDGanttViewItem::Shape startShape, middleShape, endShape;
02698 startShape = KDGanttViewItem::TriangleDown;
02699 middleShape = KDGanttViewItem::TriangleDown;
02700 endShape = KDGanttViewItem::TriangleDown;
02701 QDomNode node = element.firstChild();
02702 while( !node.isNull() ) {
02703 QDomElement element = node.toElement();
02704 if( !element.isNull() ) {
02705 QString tagName = element.tagName();
02706 if( tagName == "Start" ) {
02707 QString value;
02708 if( KDGanttXML::readStringNode( element, value ) )
02709 startShape = KDGanttViewItem::stringToShape( value );
02710 if ( value == "Undefined" )
02711 undefinedShape = true;
02712 } else if( tagName == "Middle" ) {
02713 QString value;
02714 if( KDGanttXML::readStringNode( element, value ) )
02715 middleShape = KDGanttViewItem::stringToShape( value );
02716 if ( value == "Undefined" )
02717 undefinedShape = true;
02718 } else if( tagName == "End" ) {
02719 QString value;
02720 if( KDGanttXML::readStringNode( element, value ) )
02721 endShape = KDGanttViewItem::stringToShape( value );
02722 if ( value == "Undefined" )
02723 undefinedShape = true;
02724 } else {
02725 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02726 Q_ASSERT( false );
02727 }
02728 }
02729 node = node.nextSibling();
02730 }
02731 if ( ! undefinedShape )
02732 setShapes( KDGanttViewItem::Event, startShape,
02733 middleShape, endShape, false );
02734 undefinedShape = false;
02735 } else if( tagName == "Task" ) {
02736 KDGanttViewItem::Shape startShape, middleShape, endShape;
02737 startShape = KDGanttViewItem::TriangleDown;
02738 middleShape = KDGanttViewItem::TriangleDown;
02739 endShape = KDGanttViewItem::TriangleDown;
02740 QDomNode node = element.firstChild();
02741 while( !node.isNull()) {
02742 QDomElement element = node.toElement();
02743 if( !element.isNull() ) {
02744 QString tagName = element.tagName();
02745 if( tagName == "Start" ) {
02746 QString value;
02747 if( KDGanttXML::readStringNode( element, value ) )
02748 startShape = KDGanttViewItem::stringToShape( value );
02749 if ( value == "Undefined" )
02750 undefinedShape = true;
02751 } else if( tagName == "Middle" ) {
02752 QString value;
02753 if( KDGanttXML::readStringNode( element, value ) )
02754 middleShape = KDGanttViewItem::stringToShape( value );
02755 if ( value == "Undefined" )
02756 undefinedShape = true;
02757 } else if( tagName == "End" ) {
02758 QString value;
02759 if( KDGanttXML::readStringNode( element, value ) )
02760 endShape = KDGanttViewItem::stringToShape( value );
02761 if ( value == "Undefined" )
02762 undefinedShape = true;
02763 } else {
02764 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02765 Q_ASSERT( false );
02766 }
02767 }
02768 node = node.nextSibling();
02769 }
02770 if ( ! undefinedShape )
02771 setShapes( KDGanttViewItem::Task, startShape, middleShape, endShape, false );
02772 undefinedShape = false;
02773 } else if( tagName == "Summary" ) {
02774 KDGanttViewItem::Shape startShape, middleShape, endShape;
02775 startShape = KDGanttViewItem::TriangleDown;
02776 middleShape = KDGanttViewItem::TriangleDown;
02777 endShape = KDGanttViewItem::TriangleDown;
02778 QDomNode node = element.firstChild();
02779 while( !node.isNull() ) {
02780 QDomElement element = node.toElement();
02781 if( !element.isNull() ) {
02782 QString tagName = element.tagName();
02783 if( tagName == "Start" ) {
02784 QString value;
02785 if( KDGanttXML::readStringNode( element, value ) )
02786 startShape = KDGanttViewItem::stringToShape( value );
02787 if ( value == "Undefined" )
02788 undefinedShape = true;
02789 } else if( tagName == "Middle" ) {
02790 QString value;
02791 if( KDGanttXML::readStringNode( element, value ) )
02792 middleShape = KDGanttViewItem::stringToShape( value );
02793 if ( value == "Undefined" )
02794 undefinedShape = true;
02795 } else if( tagName == "End" ) {
02796 QString value;
02797 if( KDGanttXML::readStringNode( element, value ) )
02798 endShape = KDGanttViewItem::stringToShape( value );
02799 if ( value == "Undefined" )
02800 undefinedShape = true;
02801 } else {
02802 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02803 Q_ASSERT( false );
02804 }
02805 }
02806 node = node.nextSibling();
02807 }
02808 if ( ! undefinedShape )
02809 setShapes( KDGanttViewItem::Summary, startShape,
02810 middleShape, endShape, false );
02811 undefinedShape = false;
02812 } else {
02813 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02814 Q_ASSERT( false );
02815 }
02816 }
02817 node = node.nextSibling();
02818 }
02819 } else if( tagName == "Colors" ) {
02820 QDomNode node = element.firstChild();
02821 while( !node.isNull()) {
02822 QDomElement element = node.toElement();
02823 if( !element.isNull() ) {
02824 QString tagName = element.tagName();
02825 if( tagName == "Event" ) {
02826 QColor startColor, middleColor, endColor;
02827 QDomNode node = element.firstChild();
02828 while( !node.isNull() ) {
02829 QDomElement element = node.toElement();
02830 if( !element.isNull() ) {
02831 QString tagName = element.tagName();
02832 if( tagName == "Start" ) {
02833 QColor value;
02834 if( KDGanttXML::readColorNode( element, value ) )
02835 startColor = value;
02836 } else if( tagName == "Middle" ) {
02837 QColor value;
02838 if( KDGanttXML::readColorNode( element, value ) )
02839 middleColor = value;
02840 } else if( tagName == "End" ) {
02841 QColor value;
02842 if( KDGanttXML::readColorNode( element, value ) )
02843 endColor = value;
02844 } else {
02845 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02846 Q_ASSERT( false );
02847 }
02848 }
02849 node = node.nextSibling();
02850 }
02851 setColors( KDGanttViewItem::Event, startColor,
02852 middleColor, endColor, false );
02853 } else if( tagName == "Task" ) {
02854 QColor startColor, middleColor, endColor;
02855 QDomNode node = element.firstChild();
02856 while( !node.isNull() ) {
02857 QDomElement element = node.toElement();
02858 if( !element.isNull() ) {
02859 QString tagName = element.tagName();
02860 if( tagName == "Start" ) {
02861 QColor value;
02862 if( KDGanttXML::readColorNode( element, value ) )
02863 startColor = value;
02864 } else if( tagName == "Middle" ) {
02865 QColor value;
02866 if( KDGanttXML::readColorNode( element, value ) )
02867 middleColor = value;
02868 } else if( tagName == "End" ) {
02869 QColor value;
02870 if( KDGanttXML::readColorNode( element, value ) )
02871 endColor = value;
02872 } else {
02873 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02874 Q_ASSERT( false );
02875 }
02876 }
02877 node = node.nextSibling();
02878 }
02879 setColors( KDGanttViewItem::Task, startColor,
02880 middleColor, endColor, false );
02881 } else if( tagName == "Summary" ) {
02882 QColor startColor, middleColor, endColor;
02883 QDomNode node = element.firstChild();
02884 while( !node.isNull() ) {
02885 QDomElement element = node.toElement();
02886 if( !element.isNull() ) {
02887 QString tagName = element.tagName();
02888 if( tagName == "Start" ) {
02889 QColor value;
02890 if( KDGanttXML::readColorNode( element, value ) )
02891 startColor = value;
02892 } else if( tagName == "Middle" ) {
02893 QColor value;
02894 if( KDGanttXML::readColorNode( element, value ) )
02895 middleColor = value;
02896 } else if( tagName == "End" ) {
02897 QColor value;
02898 if( KDGanttXML::readColorNode( element, value ) )
02899 endColor = value;
02900 } else {
02901 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02902 Q_ASSERT( false );
02903 }
02904 }
02905 node = node.nextSibling();
02906 }
02907 setColors( KDGanttViewItem::Summary, startColor,
02908 middleColor, endColor , false);
02909 } else {
02910 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02911 Q_ASSERT( false );
02912 }
02913 }
02914 node = node.nextSibling();
02915 }
02916 } else if( tagName == "DefaultColors" ) {
02917 QDomNode node = element.firstChild();
02918 while( !node.isNull() ) {
02919 QDomElement element = node.toElement();
02920 if( !element.isNull() ) {
02921 QString tagName = element.tagName();
02922 if( tagName == "Event" ) {
02923 QColor value;
02924 if( KDGanttXML::readColorNode( element, value ) )
02925 setDefaultColor( KDGanttViewItem::Event,
02926 value, false );
02927 } else if( tagName == "Task" ) {
02928 QColor value;
02929 if( KDGanttXML::readColorNode( element, value ) )
02930 setDefaultColor( KDGanttViewItem::Task,
02931 value, false );
02932 } else if( tagName == "Summary" ) {
02933 QColor value;
02934 if( KDGanttXML::readColorNode( element, value ) )
02935 setDefaultColor( KDGanttViewItem::Summary,
02936 value , false);
02937 } else {
02938 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02939 Q_ASSERT( false );
02940 }
02941 }
02942
02943 node = node.nextSibling();
02944 }
02945 } else if( tagName == "HighlightColors" ) {
02946 QDomNode node = element.firstChild();
02947 while( !node.isNull() ) {
02948 QDomElement element = node.toElement();
02949 if( !element.isNull() ) {
02950 QString tagName = element.tagName();
02951 if( tagName == "Event" ) {
02952 QColor startColor, middleColor, endColor;
02953 QDomNode node = element.firstChild();
02954 while( !node.isNull() ) {
02955 QDomElement element = node.toElement();
02956 if( !element.isNull() ) {
02957 QString tagName = element.tagName();
02958 if( tagName == "Start" ) {
02959 QColor value;
02960 if( KDGanttXML::readColorNode( element, value ) )
02961 startColor = value;
02962 } else if( tagName == "Middle" ) {
02963 QColor value;
02964 if( KDGanttXML::readColorNode( element, value ) )
02965 middleColor = value;
02966 } else if( tagName == "End" ) {
02967 QColor value;
02968 if( KDGanttXML::readColorNode( element, value ) )
02969 endColor = value;
02970 } else {
02971 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02972 Q_ASSERT( false );
02973 }
02974 }
02975 node = node.nextSibling();
02976 }
02977 setHighlightColors( KDGanttViewItem::Event,
02978 startColor,
02979 middleColor, endColor, false );
02980 } else if( tagName == "Task" ) {
02981 QColor startColor, middleColor, endColor;
02982 QDomNode node = element.firstChild();
02983 while( !node.isNull() ) {
02984 QDomElement element = node.toElement();
02985 if( !element.isNull() ) {
02986 QString tagName = element.tagName();
02987 if( tagName == "Start" ) {
02988 QColor value;
02989 if( KDGanttXML::readColorNode( element, value ) )
02990 startColor = value;
02991 } else if( tagName == "Middle" ) {
02992 QColor value;
02993 if( KDGanttXML::readColorNode( element, value ) )
02994 middleColor = value;
02995 } else if( tagName == "End" ) {
02996 QColor value;
02997 if( KDGanttXML::readColorNode( element, value ) )
02998 endColor = value;
02999 } else {
03000 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03001 Q_ASSERT( false );
03002 }
03003 }
03004 node = node.nextSibling();
03005 }
03006 setHighlightColors( KDGanttViewItem::Task,
03007 startColor,
03008 middleColor, endColor , false);
03009 } else if( tagName == "Summary" ) {
03010 QColor startColor, middleColor, endColor;
03011 QDomNode node = element.firstChild();
03012 while( !node.isNull() ) {
03013 QDomElement element = node.toElement();
03014 if( !element.isNull() ) {
03015 QString tagName = element.tagName();
03016 if( tagName == "Start" ) {
03017 QColor value;
03018 if( KDGanttXML::readColorNode( element, value ) )
03019 startColor = value;
03020 } else if( tagName == "Middle" ) {
03021 QColor value;
03022 if( KDGanttXML::readColorNode( element, value ) )
03023 middleColor = value;
03024 } else if( tagName == "End" ) {
03025 QColor value;
03026 if( KDGanttXML::readColorNode( element, value ) )
03027 endColor = value;
03028 } else {
03029 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03030 Q_ASSERT( false );
03031 }
03032 }
03033 node = node.nextSibling();
03034 }
03035 setHighlightColors( KDGanttViewItem::Summary,
03036 startColor,
03037 middleColor, endColor, false );
03038 } else {
03039 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03040 Q_ASSERT( false );
03041 }
03042 }
03043 node = node.nextSibling();
03044 }
03045 } else if( tagName == "DefaultHighlightColors" ) {
03046 QDomNode node = element.firstChild();
03047 while( !node.isNull() ) {
03048 QDomElement element = node.toElement();
03049 if( !element.isNull() ) {
03050 QString tagName = element.tagName();
03051 if( tagName == "Event" ) {
03052 QColor value;
03053 if( KDGanttXML::readColorNode( element, value ) )
03054 setDefaultHighlightColor( KDGanttViewItem::Event,
03055 value , false);
03056 } else if( tagName == "Task" ) {
03057 QColor value;
03058 if( KDGanttXML::readColorNode( element, value ) )
03059 setDefaultHighlightColor( KDGanttViewItem::Task,
03060 value, false );
03061 } else if( tagName == "Summary" ) {
03062 QColor value;
03063 if( KDGanttXML::readColorNode( element, value ) )
03064 setDefaultHighlightColor( KDGanttViewItem::Summary,
03065 value, false );
03066 } else {
03067 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03068 Q_ASSERT( false );
03069 }
03070 }
03071
03072 node = node.nextSibling();
03073 }
03074 } else if( tagName == "Items" ) {
03075 QDomNode node = element.firstChild();
03076 KDGanttViewItem* previous = 0;
03077 while( !node.isNull() ) {
03078 QDomElement element = node.toElement();
03079 if( !element.isNull() ) {
03080 QString tagName = element.tagName();
03081 if( tagName == "Item" ) {
03082 KDGanttViewItem* newItem;
03083 if( previous )
03084 newItem =
03085 KDGanttViewItem::createFromDomElement( this,
03086 previous,
03087 element );
03088 else
03089 newItem =
03090 KDGanttViewItem::createFromDomElement( this,
03091 element );
03092 previous = newItem;
03093 } else {
03094 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03095 Q_ASSERT( false );
03096 }
03097 }
03098
03099 node = node.nextSibling();
03100 }
03101 } else if( tagName == "TaskLinks" ) {
03102 QDomNode node = element.firstChild();
03103 while( !node.isNull() ) {
03104 QDomElement element = node.toElement();
03105 if( !element.isNull() ) {
03106 QString tagName = element.tagName();
03107 if( tagName == "TaskLink" )
03108 KDGanttViewTaskLink::createFromDomElement( element );
03109 else {
03110 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03111 Q_ASSERT( false );
03112 }
03113 }
03114
03115 node = node.nextSibling();
03116 }
03117 } else if( tagName == "TaskLinkGroups" ) {
03118 QDomNode node = element.firstChild();
03119 while( !node.isNull() ) {
03120 QDomElement element = node.toElement();
03121 if( !element.isNull() ) {
03122 QString tagName = element.tagName();
03123 if( tagName == "TaskLink" )
03124 KDGanttViewTaskLinkGroup::createFromDomElement( element );
03125 } else {
03126 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03127 Q_ASSERT( false );
03128 }
03129
03130 node = node.nextSibling();
03131 }
03132 } else if( tagName == "ColumnBackgroundColors" ) {
03133 QDomNode node = element.firstChild();
03134 while( !node.isNull() ) {
03135 QDomElement element = node.toElement();
03136 if( !element.isNull() ) {
03137 QString tagName = element.tagName();
03138 if( tagName == "ColumnBackgroundColor" ) {
03139 QDomNode node = element.firstChild();
03140 QDateTime dateTime;
03141 QColor color;
03142 while( !node.isNull() ) {
03143 QDomElement element = node.toElement();
03144 if( !element.isNull() ) {
03145
03146
03147 QString tagName = element.tagName();
03148 if( tagName == "DateTime" ) {
03149 QDateTime value;
03150 if( KDGanttXML::readDateTimeNode( element, value ) )
03151 dateTime = value;
03152 } else if( tagName == "Color" ) {
03153 QColor value;
03154 if( KDGanttXML::readColorNode( element, value ) )
03155 color = value;
03156 } else {
03157 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03158 Q_ASSERT( false );
03159 }
03160 }
03161
03162 node = node.nextSibling();
03163 }
03164 setColumnBackgroundColor( dateTime, color );
03165 } else {
03166 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03167 Q_ASSERT( false );
03168 }
03169 }
03170 node = node.nextSibling();
03171 }
03172 } else if( tagName == "LegendItems" ) {
03173 clearLegend();
03174 QDomNode node = element.firstChild();
03175 while( !node.isNull() ) {
03176 QDomElement element = node.toElement();
03177 if( !element.isNull() ) {
03178 QString tagName = element.tagName();
03179 if( tagName == "LegendItem" ) {
03180 KDGanttViewItem::Shape tempLegendShape;
03181 tempLegendShape = KDGanttViewItem::TriangleDown;
03182 QColor tempLegendColor;
03183 QString tempLegendString;
03184 bool ok = true;
03185 QDomNode node = element.firstChild();
03186 while( !node.isNull() ) {
03187 QDomElement element = node.toElement();
03188 if( !element.isNull() ) {
03189 QString tagName = element.tagName();
03190 if( tagName == "Shape" ) {
03191 QString value;
03192 if( KDGanttXML::readStringNode( element, value ) )
03193 tempLegendShape = KDGanttViewItem::stringToShape( value );
03194 else
03195 ok = false;
03196 } else if( tagName == "Color" ) {
03197 QColor value;
03198 if( KDGanttXML::readColorNode( element, value ) )
03199 tempLegendColor = value;
03200 else
03201 ok = false;
03202 } else if( tagName == "Text" ) {
03203 QString value;
03204 if( KDGanttXML::readStringNode( element, value ) )
03205 tempLegendString = value;
03206 else
03207 ok = false;
03208 } else {
03209 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03210 Q_ASSERT( false );
03211 }
03212 }
03213 node = node.nextSibling();
03214 }
03215 if( ok ) {
03216 addLegendItem( tempLegendShape,
03217 tempLegendColor,
03218 tempLegendString );
03219 qDebug( "Adding legend item %s", tempLegendString.latin1() );
03220 }
03221 } else {
03222 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03223 Q_ASSERT( false );
03224 }
03225 }
03226 node = node.nextSibling();
03227 }
03228 } else {
03229 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03230 Q_ASSERT( false );
03231 }
03232 }
03233
03234 node = node.nextSibling();
03235 }
03236 return true;
03237 }
03238
03239
03248 QDomDocument KDGanttView::saveXML( bool withPI ) const
03249 {
03250
03251 QString docstart = "<GanttView/>";
03252
03253 QDomDocument doc( "GanttView" );
03254 doc.setContent( docstart );
03255 if( withPI ) {
03256 QDomProcessingInstruction pin = doc.createProcessingInstruction( "kdgantt", "version=\"1.0\" encoding=\"UTF-8\"" ) ;
03257 doc.appendChild ( pin );
03258 }
03259
03260 QDomElement docRoot = doc.documentElement();
03261 docRoot.setAttribute( "xmlns", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
03262 docRoot.setAttribute( "xmlns:xsi", "http://www.w3.org/2000/10/XMLSchema-instance" );
03263 docRoot.setAttribute( "xsi:schemaLocation", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
03264
03265
03266 KDGanttXML::createBoolNode( doc, docRoot, "ShowLegend", showLegend() );
03267
03268
03269 KDGanttXML::createBoolNode( doc, docRoot, "ShowLegendButton",
03270 showLegendButton() );
03271
03272
03273 KDGanttXML::createBoolNode( doc, docRoot, "LegendIsDockWindow",
03274 legendIsDockwindow() );
03275
03276
03277 KDGanttXML::createBoolNode( doc, docRoot, "ShowListView", showListView() );
03278
03279
03280 KDGanttXML::createBoolNode( doc, docRoot, "ShowHeader", headerVisible() );
03281
03282
03283 KDGanttXML::createBoolNode( doc, docRoot, "ShowTaskLinks", showTaskLinks() );
03284
03285
03286 KDGanttXML::createBoolNode( doc, docRoot, "EditorEnabled", editorEnabled() );
03287
03288
03289 KDGanttXML::createFontNode( doc, docRoot, "GlobalFont", font() );
03290
03291
03292 KDGanttXML::createBoolNode( doc, docRoot, "DisplayEmptyTasksAsLine",
03293 displayEmptyTasksAsLine() );
03294
03295
03296 KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonStart", horizonStart() );
03297
03298
03299 KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonEnd", horizonEnd() );
03300
03301
03302 KDGanttXML::createStringNode( doc, docRoot, "Scale", scaleToString( scale() ) );
03303 KDGanttXML::createStringNode( doc, docRoot, "MinimumScale",
03304 scaleToString( minimumScale() ) );
03305 KDGanttXML::createStringNode( doc, docRoot, "MaximumScale",
03306 scaleToString( maximumScale() ) );
03307
03308
03309 KDGanttXML::createStringNode( doc, docRoot, "YearFormat",
03310 yearFormatToString( yearFormat() ) );
03311
03312
03313 KDGanttXML::createStringNode( doc, docRoot, "HourFormat",
03314 hourFormatToString( hourFormat() ) );
03315
03316
03317 KDGanttXML::createBoolNode( doc, docRoot, "ShowMinorTicks", showMinorTicks() );
03318
03319
03320 KDGanttXML::createBoolNode( doc, docRoot, "ShowMajorTicks", showMajorTicks() );
03321
03322
03323 KDGanttXML::createBoolNode( doc, docRoot, "Editable", editable() );
03324
03325
03326 KDGanttXML::createColorNode( doc, docRoot, "TextColor", textColor() );
03327
03328
03329 KDGanttXML::createIntNode( doc, docRoot, "MajorScaleCount", majorScaleCount() );
03330
03331
03332 KDGanttXML::createIntNode( doc, docRoot, "MinorScaleCount", minorScaleCount() );
03333
03334
03335 KDGanttXML::createIntNode( doc, docRoot, "AutoScaleMinorTickCount",
03336 autoScaleMinorTickCount() );
03337
03338
03339 KDGanttXML::createIntNode( doc, docRoot, "MinimumColumnWidth",
03340 minimumColumnWidth() );
03341
03342
03343 KDGanttXML::createIntNode( doc, docRoot, "GanttMaximumWidth",
03344 ganttMaximumWidth() );
03345
03346
03347 KDGanttXML::createBrushNode( doc, docRoot, "NoInformationBrush",
03348 noInformationBrush() );
03349
03350
03351 KDGanttXML::createColorNode( doc, docRoot, "GanttViewBackgroundColor",
03352 gvBackgroundColor() );
03353
03354
03355 KDGanttXML::createColorNode( doc, docRoot, "ListViewBackgroundColor",
03356 lvBackgroundColor() );
03357
03358
03359 KDGanttXML::createColorNode( doc, docRoot, "TimeHeaderBackgroundColor",
03360 timeHeaderBackgroundColor() );
03361
03362
03363 KDGanttXML::createColorNode( doc, docRoot, "LegendHeaderBackgroundColor",
03364 legendHeaderBackgroundColor() );
03365
03366
03367 KDGanttXML::createColorNode( doc, docRoot, "WeekendBackgroundColor",
03368 weekendBackgroundColor() );
03369
03370
03371 for( int weekday = 1; weekday <= 7; weekday++ ) {
03372 QColor color = weekdayBackgroundColor( weekday );
03373 if( color.isValid() ) {
03374 QDomElement weekendBackgroundColorElement = doc.createElement( "WeekdayBackgroundColor" );
03375 docRoot.appendChild( weekendBackgroundColorElement );
03376 KDGanttXML::createIntNode( doc, weekendBackgroundColorElement,
03377 "Day", weekday );
03378 KDGanttXML::createColorNode( doc, weekendBackgroundColorElement,
03379 "Color", color );
03380 }
03381 }
03382
03383
03384 QDomElement weekendDaysElement = doc.createElement( "WeekendDays" );
03385 docRoot.appendChild( weekendDaysElement );
03386 int weekendStart, weekendEnd;
03387 weekendDays( weekendStart, weekendEnd );
03388 weekendDaysElement.setAttribute( "Start", weekendStart );
03389 weekendDaysElement.setAttribute( "End", weekendStart );
03390
03391
03392 KDGanttXML::createDoubleNode( doc, docRoot, "ZoomFactor",
03393 zoomFactor() );
03394
03395
03396 KDGanttXML::createBoolNode( doc, docRoot, "ShowHeaderPopupMenu",
03397 showHeaderPopupMenu() );
03398
03399
03400 KDGanttXML::createBoolNode( doc, docRoot, "ShowTimeTablePopupMenu",
03401 showTimeTablePopupMenu() );
03402
03403
03404 QDomElement shapesElement = doc.createElement( "Shapes" );
03405 docRoot.appendChild( shapesElement );
03406 QDomElement shapesEventElement = doc.createElement( "Event" );
03407 shapesElement.appendChild( shapesEventElement );
03408 KDGanttViewItem::Shape start, middle, end;
03409 if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
03410 KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
03411 KDGanttViewItem::shapeToString( start ) );
03412 KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
03413 KDGanttViewItem::shapeToString( middle ) );
03414 KDGanttXML::createStringNode( doc, shapesEventElement, "End",
03415 KDGanttViewItem::shapeToString( end ) );
03416 } else {
03417 KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
03418 "Undefined" );
03419 KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
03420 "Undefined" );
03421 KDGanttXML::createStringNode( doc, shapesEventElement, "End",
03422 "Undefined" );
03423 }
03424 QDomElement shapesTaskElement = doc.createElement( "Task" );
03425 shapesElement.appendChild( shapesTaskElement );
03426 if( shapes( KDGanttViewItem::Task, start, middle, end ) ) {
03427 KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
03428 KDGanttViewItem::shapeToString( start ) );
03429 KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
03430 KDGanttViewItem::shapeToString( middle ) );
03431 KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
03432 KDGanttViewItem::shapeToString( end ) );
03433 } else {
03434 KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
03435 "Undefined" );
03436 KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
03437 "Undefined" );
03438 KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
03439 "Undefined" );
03440 }
03441 QDomElement shapesSummaryElement = doc.createElement( "Summary" );
03442 shapesElement.appendChild( shapesSummaryElement );
03443 if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
03444 KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
03445 KDGanttViewItem::shapeToString( start ) );
03446 KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
03447 KDGanttViewItem::shapeToString( middle ) );
03448 KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
03449 KDGanttViewItem::shapeToString( end ) );
03450 } else {
03451 KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
03452 "Undefined" );
03453 KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
03454 "Undefined" );
03455 KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
03456 "Undefined" );
03457 }
03458
03459
03460 QDomElement colorsElement = doc.createElement( "Colors" );
03461 docRoot.appendChild( colorsElement );
03462 QDomElement colorsEventElement = doc.createElement( "Event" );
03463 colorsElement.appendChild( colorsEventElement );
03464 QColor startColor, middleColor, endColor;
03465 colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03466 KDGanttXML::createColorNode( doc, colorsEventElement, "Start", startColor );
03467 KDGanttXML::createColorNode( doc, colorsEventElement, "Middle", middleColor );
03468 KDGanttXML::createColorNode( doc, colorsEventElement, "End", endColor );
03469 QDomElement colorsTaskElement = doc.createElement( "Task" );
03470 colorsElement.appendChild( colorsTaskElement );
03471 colors( KDGanttViewItem::Task, startColor, middleColor, endColor );
03472 KDGanttXML::createColorNode( doc, colorsTaskElement, "Start", startColor );
03473 KDGanttXML::createColorNode( doc, colorsTaskElement, "Middle", middleColor );
03474 KDGanttXML::createColorNode( doc, colorsTaskElement, "End", endColor );
03475 QDomElement colorsSummaryElement = doc.createElement( "Summary" );
03476 colorsElement.appendChild( colorsSummaryElement );
03477 colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03478 KDGanttXML::createColorNode( doc, colorsSummaryElement, "Start", startColor );
03479 KDGanttXML::createColorNode( doc, colorsSummaryElement, "Middle", middleColor );
03480 KDGanttXML::createColorNode( doc, colorsSummaryElement, "End", endColor );
03481
03482
03483 QDomElement defaultColorsElement = doc.createElement( "DefaultColors" );
03484 docRoot.appendChild( defaultColorsElement );
03485 KDGanttXML::createColorNode( doc, defaultColorsElement, "Event",
03486 defaultColor( KDGanttViewItem::Event ) );
03487 KDGanttXML::createColorNode( doc, defaultColorsElement, "Task",
03488 defaultColor( KDGanttViewItem::Task ) );
03489 KDGanttXML::createColorNode( doc, defaultColorsElement, "Summary",
03490 defaultColor( KDGanttViewItem::Summary ) );
03491
03492
03493
03494 QDomElement highlightColorsElement = doc.createElement( "HighlightColors" );
03495 docRoot.appendChild( highlightColorsElement );
03496 QDomElement highlightColorsEventElement = doc.createElement( "Event" );
03497 highlightColorsElement.appendChild( highlightColorsEventElement );
03498 highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03499 KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Start", startColor );
03500 KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Middle", middleColor );
03501 KDGanttXML::createColorNode( doc, highlightColorsEventElement, "End", endColor );
03502 QDomElement highlightColorsTaskElement = doc.createElement( "Task" );
03503 highlightColorsElement.appendChild( highlightColorsTaskElement );
03504 highlightColors( KDGanttViewItem::Task, startColor, middleColor, endColor );
03505 KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Start", startColor );
03506 KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Middle", middleColor );
03507 KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "End", endColor );
03508 QDomElement highlightColorsSummaryElement = doc.createElement( "Summary" );
03509 highlightColorsElement.appendChild( highlightColorsSummaryElement );
03510 highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03511 KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
03512 KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
03513 KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );
03514
03515
03516
03517
03518
03519
03520
03521
03522
03523
03524
03525
03526
03527
03528 QDomElement defaultHighlightColorsElement = doc.createElement( "DefaultHighlightColors" );
03529 docRoot.appendChild( defaultHighlightColorsElement );
03530 KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Event",
03531 defaultHighlightColor( KDGanttViewItem::Event ) );
03532 KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Task",
03533 defaultHighlightColor( KDGanttViewItem::Task ) );
03534 KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Summary",
03535 defaultHighlightColor( KDGanttViewItem::Summary ) );
03536
03537
03538
03539 QDomElement itemsElement = doc.createElement( "Items" );
03540 docRoot.appendChild( itemsElement );
03541 KDGanttViewItem* currentItem = firstChild();
03542 while( currentItem ) {
03543 currentItem->createNode( doc, itemsElement );
03544 currentItem = currentItem->nextSibling();
03545 }
03546
03547
03548 QDomElement taskLinksElement = doc.createElement( "TaskLinks" );
03549 docRoot.appendChild( taskLinksElement );
03550 QPtrList<KDGanttViewTaskLink> taskLinkList = taskLinks();
03551 KDGanttViewTaskLink* currentTL = 0;
03552 for( currentTL = taskLinkList.first(); currentTL;
03553 currentTL = taskLinkList.next() )
03554 currentTL->createNode( doc, taskLinksElement );
03555
03556
03557 QDomElement taskLinkGroupsElement = doc.createElement( "TaskLinkGroups" );
03558 docRoot.appendChild( taskLinkGroupsElement );
03559 QPtrList<KDGanttViewTaskLinkGroup> taskLinkGroupList = taskLinkGroups();
03560 KDGanttViewTaskLinkGroup* currentTLG = 0;
03561 for( currentTLG = taskLinkGroupList.first(); currentTLG;
03562 currentTLG = taskLinkGroupList.next() )
03563 currentTLG->createNode( doc, taskLinkGroupsElement );
03564
03565
03566 QDomElement columnBackgroundColorsElement =
03567 doc.createElement( "ColumnBackgroundColors" );
03568 docRoot.appendChild( columnBackgroundColorsElement );
03569 KDTimeHeaderWidget::ColumnColorList ccList =
03570 myTimeHeader->columnBackgroundColorList();
03571 for( KDTimeHeaderWidget::ColumnColorList::iterator it = ccList.begin();
03572 it != ccList.end(); ++it ) {
03573 QDomElement columnBackgroundColorElement =
03574 doc.createElement( "ColumnBackgroundColor" );
03575 columnBackgroundColorsElement.appendChild( columnBackgroundColorElement );
03576 KDGanttXML::createDateTimeNode( doc, columnBackgroundColorElement,
03577 "DateTime", (*it).datetime );
03578 KDGanttXML::createColorNode( doc, columnBackgroundColorElement,
03579 "Color", (*it).color );
03580 }
03581
03582
03583 QDomElement legendItemsElement =
03584 doc.createElement( "LegendItems" );
03585 docRoot.appendChild( legendItemsElement );
03586 legendItem* current;
03587 QPtrListIterator<legendItem> lit( *myLegendItems );
03588 while( ( current = lit.current() ) ) {
03589 ++lit;
03590 QDomElement legendItemElement = doc.createElement( "LegendItem" );
03591 legendItemsElement.appendChild( legendItemElement );
03592 KDGanttXML::createStringNode( doc, legendItemElement, "Shape",
03593 KDGanttViewItem::shapeToString( current->shape ) );
03594 KDGanttXML::createColorNode( doc, legendItemElement, "Color",
03595 current->color );
03596 KDGanttXML::createStringNode( doc, legendItemElement, "Text",
03597 current->text );
03598 }
03599
03600
03601 KDGanttXML::createBoolNode( doc, docRoot, "DragEnabled", isDragEnabled() );
03602
03603
03604 KDGanttXML::createBoolNode( doc, docRoot, "DropEnabled", isDropEnabled() );
03605
03606
03607 KDGanttXML::createBoolNode( doc, docRoot, "CalendarMode", calendarMode() );
03608
03609 return doc;
03610 }
03611
03612
03613
03614 QString KDGanttView::scaleToString( Scale scale )
03615 {
03616 switch( scale ) {
03617 case Minute:
03618 return "Minute";
03619 case Hour:
03620 return "Hour";
03621 case Day:
03622 return "Day";
03623 case Week:
03624 return "Week";
03625 case Month:
03626 return "Month";
03627 case Auto:
03628 return "Auto";
03629 }
03630 return "";
03631 }
03632
03633
03634 KDGanttView::Scale KDGanttView::stringToScale( const QString& string )
03635 {
03636 if( string == "Minute" )
03637 return Minute;
03638 else if( string == "Hour" )
03639 return Hour;
03640 else if( string == "Day" )
03641 return Day;
03642 else if( string == "Week" )
03643 return Week;
03644 else if( string == "Month" )
03645 return Month;
03646 else if( string == "Auto" )
03647 return Auto;
03648
03649 return Auto;
03650 }
03651
03652
03653 QString KDGanttView::yearFormatToString( YearFormat format )
03654 {
03655 switch( format ) {
03656 case FourDigit:
03657 return "FourDigit";
03658 case TwoDigit:
03659 return "TwoDigit";
03660 case TwoDigitApostrophe:
03661 return "TwoDigitApostrophe";
03662 case NoDate:
03663 return "NoDate";
03664 }
03665 return "";
03666 }
03667
03668
03669 KDGanttView::YearFormat KDGanttView::stringToYearFormat( const QString& string )
03670 {
03671 if( string == "FourDigit" )
03672 return FourDigit;
03673 else if( string == "TwoDigit" )
03674 return TwoDigit;
03675 else if( string == "TwoDigitApostrophe" )
03676 return TwoDigitApostrophe;
03677 else if( string == "NoDate" )
03678 return NoDate;
03679 else
03680 return FourDigit;
03681 }
03682
03683
03684 QString KDGanttView::hourFormatToString( HourFormat format )
03685 {
03686 switch( format ) {
03687 case Hour_12:
03688 return "Hour_12";
03689 case Hour_24:
03690 return "Hour_24";
03691 case Hour_24_FourDigit:
03692 return "Hour_24_FourDigit";
03693 }
03694 return "";
03695 }
03696
03697
03698 KDGanttView::HourFormat KDGanttView::stringToHourFormat( const QString& string )
03699 {
03700 if( string == "Hour_12" )
03701 return Hour_12;
03702 else if( string == "Hour_24" )
03703 return Hour_24;
03704 else
03705 return Hour_24;
03706 }
03707
03708
03709 void KDGanttView::addTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
03710 {
03711
03712 if (myTaskLinkGroupList.isEmpty()) {
03713 myTaskLinkGroupList.append(group);
03714 return;
03715 }
03716 if (myTaskLinkGroupList.find(group) == -1)
03717 myTaskLinkGroupList.append(group);
03718 }
03719
03720
03721 void KDGanttView::removeTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
03722 {
03723 myTaskLinkGroupList.remove(group);
03724 }
03725
03726
03732 void KDGanttView::editItem( KDGanttViewItem* item)
03733 {
03734 if ( ! item )
03735 return;
03736 if ( editorEnabled() ) {
03737 if ( item->editable() ) {
03738 myItemAttributeDialog->reset( item );
03739 myItemAttributeDialog->show();
03740 }
03741 }
03742 }
03743
03744
03755 QPixmap KDGanttView::getPixmap( KDGanttViewItem::Shape shape,
03756 const QColor& shapeColor,
03757 const QColor& backgroundColor, int itemSize)
03758 {
03759
03760 int size = itemSize+2;
03761 int hei = ( itemSize/3 ) / 2;
03762 QPixmap p = QPixmap( size+4, size+4 );
03763 p.fill( backgroundColor );
03764 QPainter paint (&p);
03765 QBrush b = QBrush ( Qt::SolidPattern );
03766 b.setColor( shapeColor );
03767 paint.setBrush( b );
03768 QPen pen( Qt::black, 1 ) ;
03769 paint.setPen( pen );
03770 switch (shape) {
03771 case KDGanttViewItem::TriangleDown:{
03772 QPointArray arr = QPointArray(3);
03773 arr.setPoint(0,-size/2,-hei);
03774 arr.setPoint(1,size/2,-hei);
03775 arr.setPoint(2,0,((size/2)-hei));
03776 arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03777 paint.drawPolygon( arr );
03778 break;
03779 }
03780 case KDGanttViewItem::TriangleUp :{
03781 QPointArray arr = QPointArray(3);
03782 arr.setPoint(0,-size/2,hei);
03783 arr.setPoint(1,size/2,hei);
03784 arr.setPoint(2,0,(-size/2)+hei);
03785 arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03786 paint.drawPolygon( arr );
03787 break;
03788 }
03789 case KDGanttViewItem::Diamond :{
03790 QPointArray arr = QPointArray(4);
03791 arr.setPoint(0,0,-size/2);
03792 arr.setPoint(1,size/2,0);
03793 arr.setPoint(2,0,size/2);
03794 arr.setPoint(3,-size/2,0);
03795 arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03796 paint.drawPolygon( arr );
03797 break;
03798 }
03799 case KDGanttViewItem::Square :{
03800 QPointArray arr = QPointArray(4);
03801 arr.setPoint(0,-size/2,-size/2);
03802 arr.setPoint(1,size/2,-size/2);
03803 arr.setPoint(2,size/2,size/2);
03804 arr.setPoint(3,-size/2,size/2);
03805 arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03806 paint.drawPolygon( arr );
03807 break;
03808 }
03809 case KDGanttViewItem::Circle :{
03810 paint.drawEllipse( 2, 2, size, size);
03811 break;
03812 }
03813 }
03814 paint.end();
03815 return p;
03816 }
03817
03818 int KDGanttView::getIndex( KDGanttViewItem::Type type) const
03819 {
03820 int index = -1;
03821 switch (type) {
03822 case (KDGanttViewItem::Event):
03823 index = 0;
03824 break;
03825 case (KDGanttViewItem::Task):
03826 index = 1;
03827 break;
03828 case (KDGanttViewItem::Summary):
03829 index = 2;
03830 break;
03831 }
03832 return index;
03833 }
03834
03835
03836 void KDGanttView::initDefaults()
03837 {
03838 int i;
03839
03840 for (i = 0;i<3;++i) {
03841 undefinedShape[i] = true;
03842 undefinedColor[i] = true;
03843 undefinedColorHL[i] = true;
03844 }
03845
03846 myDefaultColor [ getIndex( KDGanttViewItem::Event ) ] = Qt::blue;
03847 myDefaultColorHL [ getIndex( KDGanttViewItem::Event ) ] = Qt::red;
03848 myDefaultColor [ getIndex( KDGanttViewItem::Task ) ] = Qt::green;
03849 myDefaultColorHL [ getIndex( KDGanttViewItem::Task ) ] = Qt::red;
03850 myDefaultColor [ getIndex( KDGanttViewItem::Summary ) ] = Qt::cyan;
03851 myDefaultColorHL [ getIndex( KDGanttViewItem::Summary ) ] = Qt::red;
03852
03853
03854
03855 for (i = 0;i<3;++i) {
03856 myDefaultShape [3*getIndex( KDGanttViewItem::Event )+ i] = KDGanttViewItem::Diamond;
03857 myDefaultShape [3*getIndex( KDGanttViewItem::Task ) +i] = KDGanttViewItem::Square;
03858 myDefaultShape [3*getIndex( KDGanttViewItem::Summary ) +i] = KDGanttViewItem::TriangleDown;
03859
03860 }
03861 }
03862
03863
03864
03868 int KDGanttView::addColumn( const QString& label, int width )
03869 {
03870 return myListView->addColumn( label, width );
03871 }
03872
03873
03878 int KDGanttView::addColumn( const QIconSet& iconset, const QString& label,
03879 int width )
03880 {
03881 return myListView->addColumn( iconset, label, width );
03882 }
03883
03884
03888 void KDGanttView::removeColumn( int index )
03889 {
03890 myListView->removeColumn( index );
03891 }
03892
03893
03897 KDGanttViewItem* KDGanttView::selectedItem() const
03898 {
03899 return static_cast<KDGanttViewItem*>( myListView->selectedItem() );
03900 }
03901
03902
03906 void KDGanttView::setSelected( KDGanttViewItem* item, bool selected )
03907 {
03908 myListView->setSelected( item, selected );
03909 }
03910
03911
03924 KDGanttViewItem* KDGanttView::getItemByName( const QString& name ) const
03925 {
03926 KDGanttViewItem* temp = firstChild(),* ret;
03927 while (temp != 0) {
03928 if ( (ret = temp->getChildByName( name ) ) )
03929 return ret;
03930 temp = temp->nextSibling();
03931 }
03932 return 0;
03933 }
03934
03935
03947 KDGanttViewItem* KDGanttView::getItemByListViewPos( const QPoint& pos ) const
03948 {
03949 return static_cast<KDGanttViewItem*>( myListView->itemAt(myListView->mapFromGlobal(pos) ));
03950 }
03951
03952
03967 KDGanttViewItem* KDGanttView::getItemByGanttViewPos( const QPoint& pos ) const
03968 {
03969 KDGanttViewItem* item;
03970 QPoint local = myCanvasView->mapFromGlobal(pos);
03971
03972 QCanvasItemList il = myTimeTable->collisions( myCanvasView->viewportToContents( local ));
03973 QCanvasItemList::Iterator it;
03974 for ( it = il.begin(); it != il.end(); ++it ) {
03975 if ( myCanvasView->getType(*it) == Type_is_KDGanttViewItem) {
03976 item = myCanvasView->getItem(*it);
03977 if ( item->enabled() )
03978 return item;
03979 }
03980 }
03981 return 0;
03982 }
03983
03984
03999 KDGanttViewItem* KDGanttView::getItemAt( const QPoint& pos, bool global ) const
04000 {
04001
04002
04003
04004
04005
04006
04007
04008
04009
04010 KDGanttViewItem* item;
04011 KDGanttViewItem* retItem = 0;
04012 int y;
04013 if ( global )
04014 y = myCanvasView->mapFromGlobal(pos).y();
04015 else
04016 y = pos.y();
04017 item = firstChild();
04018 while ( item != 0 ) {
04019 int yc = item->itemPos();
04020 if ( yc <= y && y < yc + item->height()) {
04021 retItem = item;
04022 break;
04023 }
04024 item = item->itemBelow();
04025 }
04026 return retItem;
04027
04028 }
04029
04030
04031 void KDGanttView::addTickRight()
04032 {
04033 if ( _enableAdding && myCanvasView->horizontalScrollBar()->value() == myCanvasView->horizontalScrollBar()->maxValue()) {
04034 myCanvasView->horizontalScrollBar()->blockSignals( true );
04035 myTimeHeader->addTickRight();
04036 myCanvasView->horizontalScrollBar()->blockSignals( false );
04037 setTimelineToEnd();
04038 }
04039 }
04040
04041
04042 void KDGanttView::addTickLeft()
04043 {
04044 if ( _enableAdding && myCanvasView->horizontalScrollBar()->value() == 0 ) {
04045 myCanvasView->horizontalScrollBar()->blockSignals( true );
04046 myTimeHeader->addTickLeft();
04047 myCanvasView->horizontalScrollBar()->blockSignals( false );
04048 setTimelineToStart();
04049 }
04050 }
04051
04052
04053 void KDGanttView::enableAdding( int val )
04054 {
04055 _enableAdding = ( val == 0 || val == myCanvasView->horizontalScrollBar()->maxValue());
04056 }
04057
04058
04064 int KDGanttView::childCount() const
04065 {
04066 return myListView->childCount();
04067 }
04068
04069
04073 void KDGanttView::clear()
04074 {
04075 bool block = myTimeTable->blockUpdating();
04076 myTimeTable->setBlockUpdating( true );
04077 myListView->clear();
04078 myTimeTable->setBlockUpdating( false );
04079 myTimeTable->updateMyContent();
04080 myTimeTable->setBlockUpdating( block );
04081 }
04082
04083
04087 void KDGanttView::slot_lvDropped(QDropEvent* e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse )
04088 {
04089 emit dropped( e, droppedItem, itemBelowMouse);
04090 }
04091
04095 QDragObject * KDGanttView::dragObject ()
04096 {
04097 return myListView->dragObject ();
04098 }
04099
04100
04104 void KDGanttView::startDrag ()
04105 {
04106
04107 }
04108
04109
04113 void KDGanttView::setPaletteBackgroundColor( const QColor& col)
04114 {
04115 QWidget::setPaletteBackgroundColor( col );
04116 timeHeaderSpacerWidget->setPaletteBackgroundColor( col );
04117 }
04118
04119
04126 void KDGanttView::setGvBackgroundColor ( const QColor & c )
04127 {
04128 myTimeTable->setBackgroundColor( c );
04129 }
04130
04131
04138 void KDGanttView::setTimeHeaderBackgroundColor ( const QColor & c )
04139 {
04140 myTimeHeader->setPaletteBackgroundColor( c );
04141
04142 timeHeaderSpacerWidget->setPaletteBackgroundColor( c );
04143 }
04144
04145
04152 void KDGanttView::setLegendHeaderBackgroundColor ( const QColor & c )
04153 {
04154 myLegend->setPaletteBackgroundColor( c );
04155 leftWidget->setPaletteBackgroundColor( c );
04156 }
04157
04158
04165 void KDGanttView::setLvBackgroundColor ( const QColor & c )
04166 {
04167 myListView->viewport()->setPaletteBackgroundColor( c );
04168 }
04169
04170
04177 QColor KDGanttView::lvBackgroundColor ( )const
04178 {
04179 return myListView->viewport()->paletteBackgroundColor( );
04180 }
04181
04182
04189 QColor KDGanttView::gvBackgroundColor () const
04190 {
04191 return myTimeTable->backgroundColor( );
04192 }
04193
04194
04201 QColor KDGanttView::timeHeaderBackgroundColor () const
04202 {
04203 return myTimeHeader->paletteBackgroundColor( );
04204 }
04205
04206
04213 QColor KDGanttView::legendHeaderBackgroundColor () const
04214 {
04215 return myLegend->paletteBackgroundColor( );
04216 }
04217
04218
04233 void KDGanttView::addUserdefinedLegendHeaderWidget( QWidget * w )
04234 {
04235 if ( w ) {
04236 w->reparent ( spacerLeft, 0, QPoint(0,0) );
04237 }
04238 }
04239
04240
04249 void KDGanttView::setDragEnabled( bool b )
04250 {
04251 fDragEnabled = b;
04252 QListViewItemIterator it( myListView );
04253 for ( ; it.current(); ++it ) {
04254 (( KDGanttViewItem* )it.current())->setDragEnabled(b);
04255 }
04256
04257 }
04258
04259
04268 void KDGanttView::setDropEnabled( bool b )
04269 {
04270 fDropEnabled = b;
04271
04272
04273 QListViewItemIterator it( myListView );
04274 for ( ; it.current(); ++it ) {
04275 (( KDGanttViewItem* )it.current())->setDropEnabled(b);
04276 }
04277 }
04278
04279
04288 void KDGanttView::setDragDropEnabled( bool b )
04289 {
04290 setDropEnabled( b );
04291 setDragEnabled( b );
04292 }
04293
04294
04301 bool KDGanttView::isDragEnabled() const
04302 {
04303 return fDragEnabled;
04304 }
04305
04306
04313 bool KDGanttView::isDropEnabled() const
04314 {
04315 return fDropEnabled;
04316 }
04317
04318
04322 bool KDGanttView::dragEnabled() const
04323 {
04324 return isDragEnabled();
04325 }
04326
04327
04331 bool KDGanttView::dropEnabled() const
04332 {
04333 return isDropEnabled();
04334 }
04335
04336
04363 bool KDGanttView::lvDropEvent ( QDropEvent* e,
04364 KDGanttViewItem* droppedItem,
04365 KDGanttViewItem* itemBelowMouse )
04366 {
04367 Q_UNUSED( e );
04368 Q_UNUSED( droppedItem );
04369 Q_UNUSED( itemBelowMouse );
04370
04371
04372
04373
04374
04375
04376
04377
04378
04379
04380
04381
04382
04383
04384
04385
04386
04387
04388
04389
04390
04391
04392
04393
04394
04395
04396
04397
04398
04399
04400
04401
04402
04403
04404
04405
04406
04407 return false;
04408 }
04409
04410
04427 void KDGanttView::lvDragEnterEvent ( QDragEnterEvent * e)
04428 {
04429
04430
04431
04432
04433 if ( KDGanttViewItemDrag::canDecode(e) ) {
04434 e->accept( true);
04435 return;
04436 }
04437
04438
04439
04440
04441
04442
04443
04444
04445
04446
04447
04448
04449 e->accept( false );
04450 }
04451
04452
04481 bool KDGanttView::lvDragMoveEvent ( QDragMoveEvent* ,
04482 KDGanttViewItem* ,
04483 KDGanttViewItem* )
04484 {
04485
04486
04487
04488
04489
04490
04491
04492
04493
04494
04495
04496
04497
04498
04499
04500
04501
04502
04503
04504
04505
04506
04507
04508 return false;
04509 }
04510
04511
04521 void KDGanttView::lvStartDrag (KDGanttViewItem* item)
04522 {
04523 QDragObject* d = new KDGanttViewItemDrag(item, this, "itemdrag" );
04524
04525
04526
04527
04528
04529
04530
04531
04532
04533 if ( d->drag() ) {
04534 delete item;
04535 }
04536 }
04537
04538
04546 void KDGanttView::setListViewWidth( int w )
04547 {
04548 int sw = mySplitter->width();
04549 QValueList<int> list;
04550 list.append(w);
04551 list.append(sw-w);
04552 mySplitter->setSizes( list );
04553 }
04554
04555
04562 int KDGanttView::listViewWidth( )
04563 {
04564 return leftWidget->width();
04565 }
04566
04567
04577 void KDGanttView::setLvVScrollBarMode( QScrollView::ScrollBarMode m )
04578 {
04579 myListView->setVScrollBarMode ( m );
04580 }
04581
04582
04592 void KDGanttView::setGvVScrollBarMode( QScrollView::ScrollBarMode m )
04593 {
04594 if ( m == QScrollView::Auto )
04595 qDebug("KDGanttView::setListViewVScrollBarMode: QScrollView::Auto not supported. Nothing changed. ");
04596 else
04597 {
04598 myCanvasView->setVScrollBarMode ( m );
04599 if ( m == QScrollView::AlwaysOn )
04600 timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
04601 else
04602 timeHeaderSpacerWidget->setFixedWidth( 0 );
04603 }
04604 }
04605
04606
04607 void KDGanttView::notifyEditdialog( KDGanttViewItem * item)
04608 {
04609 if (myItemAttributeDialog->getItem() == item ) {
04610 myItemAttributeDialog->reset( 0 );
04611 }
04612 }
04613
04621 void KDGanttView::setLinkItemsEnabled(bool on)
04622 {
04623 myCanvasView->linkItemsEnabled = on;
04624 myCanvasView->autoScrollEnabled = true;
04625 }
04626
04632 bool KDGanttView::isLinkItemsEnabled() const
04633 {
04634 return myCanvasView->linkItemsEnabled;
04635 }
04636