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 <tqprinter.h>
00043 #include <tqpainter.h>
00044 #include <tqlayout.h>
00045 #include <tqpaintdevicemetrics.h>
00046 #include <tqfile.h>
00047 #include <tqheader.h>
00048 #include <tqscrollview.h>
00049 #include <tqapplication.h>
00050 #include <tqevent.h>
00051 #include <tqiconview.h>
00052
00053 #include <tqmessagebox.h>
00054 #include <tqfileinfo.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( TQWidget* parent, const char* name )
00084 : KDGanttMinimizeSplitter( Qt::Vertical, parent, name ),
00085 myCanvasView(0),
00086 myTimeHeaderScroll(0),
00087 mFixedHorizon( false )
00088 {
00089 #if defined KDAB_EVAL
00090 EvalDialog::checkEvalLicense( "KD Gantt" );
00091 #endif
00092 myCurrentItem = 0;
00093 setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
00094 mySplitter = new KDGanttMinimizeSplitter( this );
00095 mySplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
00096 leftWidget = new TQVBox( mySplitter );
00097 rightWidget = new TQVBox( mySplitter );
00098
00099 myLegend = new KDLegendWidget( leftWidget, this );
00100 spacerLeft = new TQHBox( leftWidget );
00101 myListView = new KDListView(leftWidget, this);
00102 myListView->setVScrollBarMode (TQScrollView::AlwaysOff );
00103 connect( myListView, TQT_SIGNAL( selectionChanged( TQListViewItem* ) ),
00104 this, TQT_SLOT( slotSelectionChanged( TQListViewItem* ) ) );
00105
00106 connect( myListView, TQT_SIGNAL( mouseButtonClicked ( int, TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT( slotmouseButtonClicked ( int , TQListViewItem * , const TQPoint &, int ) ) );
00107 connect( myListView, TQT_SIGNAL( contextMenuRequested ( TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT( slotcontextMenuRequested ( TQListViewItem * , const TQPoint & , int ) ) );
00108
00109 connect( myListView, TQT_SIGNAL(currentChanged( TQListViewItem * ) ), this, TQT_SLOT(slotCurrentChanged ( TQListViewItem * ) ) );
00110 connect( myListView, TQT_SIGNAL(itemRenamed ( TQListViewItem * , int , const TQString & ) ), this, TQT_SLOT(slotItemRenamed ( TQListViewItem *, int , const TQString & ) ) );
00111 connect( myListView, TQT_SIGNAL(mouseButtonPressed( int, TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT(slotMouseButtonPressed ( int , TQListViewItem * , const TQPoint & , int ) ) );
00112
00113
00114 myTimeTable = new KDTimeTableWidget (rightWidget,this);
00115
00116 spacerRight = new TQWidget( rightWidget );
00117
00118 myTimeHeaderContainer = new TQHBox( rightWidget );
00119 myTimeHeaderContainer->setFrameStyle( TQFrame::NoFrame );
00120 myTimeHeaderContainer->setMargin( 0 );
00121 myTimeHeaderScroll = new TQScrollView ( myTimeHeaderContainer );
00122 myTimeHeaderScroll->setHScrollBarMode( TQScrollView::AlwaysOff );
00123 myTimeHeaderScroll->setVScrollBarMode( TQScrollView::AlwaysOff );
00124 timeHeaderSpacerWidget = new TQWidget( myTimeHeaderContainer );
00125
00126
00127
00128
00129
00130
00131
00132
00133 myTimeHeader = new KDTimeHeaderWidget (myTimeHeaderScroll->viewport(),this);
00134 myTimeHeaderScroll->addChild( myTimeHeader );
00135 myTimeHeaderScroll->viewport()->setBackgroundColor( myTimeHeader->backgroundColor() );
00136 timeHeaderSpacerWidget->setBackgroundColor( myTimeHeader->backgroundColor() );
00137 myCanvasView = new KDGanttCanvasView (this,myTimeTable,rightWidget);
00138 myTimeHeaderScroll->setFrameStyle( TQFrame::NoFrame );
00139
00140 myCanvasView->setFrameStyle( TQFrame::NoFrame );
00141 myCanvasView->setMargin( 0 );
00142
00143 myTimeHeaderScroll->setMargin( 0 );
00144 setFrameStyle(myListView->frameStyle());
00145 setLineWidth( 2 );
00146 myListView->setFrameStyle( TQFrame::NoFrame );
00147 myListView->setMargin( 0 );
00148 TQObject::connect(myListView, TQT_SIGNAL ( expanded ( TQListViewItem * ) ) , myTimeTable , TQT_SLOT( expandItem(TQListViewItem * ))) ;
00149 TQObject::connect(myListView, TQT_SIGNAL (collapsed ( TQListViewItem * ) ) , myTimeTable , TQT_SLOT(collapseItem(TQListViewItem * ))) ;
00150
00151 timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
00152 listViewIsVisible = true;
00153 chartIsEditable = true;
00154 editorIsEnabled = true;
00155 _displaySubitemsAsGroup = false;
00156 initDefaults();
00157 _showHeader = false;
00158
00159 myTextColor = TQt::black;
00160 myLegendItems = new TQPtrList<legendItem>;
00161
00162 myItemAttributeDialog = new itemAttributeDialog();
00163 setRepaintMode( KDGanttView::Medium );
00164
00165 setShowLegendButton( true );
00166 setHeaderVisible( false );
00167
00168
00169 connect(myCanvasView->horizontalScrollBar(), TQT_SIGNAL ( valueChanged ( int )) ,myTimeHeaderScroll->horizontalScrollBar(), TQT_SLOT( setValue ( int))) ;
00170 connect(myCanvasView, TQT_SIGNAL ( heightResized( int )) ,myTimeTable, TQT_SLOT( checkHeight ( int))) ;
00171 connect(myCanvasView, TQT_SIGNAL ( widthResized( int )) ,myTimeHeader, TQT_SLOT( checkWidth ( int))) ;
00172
00173 TQObject::connect(myCanvasView->verticalScrollBar(), TQT_SIGNAL ( valueChanged ( int ) ) ,myListView->verticalScrollBar(), TQT_SLOT( setValue ( int ))) ;
00174 connect(myTimeHeader, TQT_SIGNAL ( sizeChanged( int ) ) ,this, TQT_SLOT(slotHeaderSizeChanged() )) ;
00175 connect(myTimeHeader, TQT_SIGNAL ( sizeChanged( int ) ) ,myTimeTable, TQT_SLOT(resetWidth( int ) )) ;
00176 connect(myListView, TQT_SIGNAL ( contentsMoving ( int, int ) ) ,myCanvasView, TQT_SLOT( moveMyContent( int, int ))) ;
00177 connect(myTimeTable, TQT_SIGNAL ( heightComputed ( int ) ) ,myCanvasView, TQT_SLOT( setMyContentsHeight( int ))) ;
00178
00179 connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(addTickLeft()));
00180 connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(addTickRight()));
00181 connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT( enableAdding( int )));
00182
00183
00184 fCenterTimeLineAfterShow = false;
00185 fDragEnabled = false;
00186 fDropEnabled = false;
00187 closingBlocked = false;
00188 myTimeHeader->computeTicks();
00189 centerTimelineAfterShow( TQDateTime::currentDateTime () );
00190 setDisplayEmptyTasksAsLine( false );
00191 TQValueList<int> list;
00192 list.append(240);
00193 list.append(530);
00194 mySplitter->setSizes( list );
00195 myTimeTable->setBlockUpdating();
00196 }
00197
00198
00199
00200 KDGanttView::~KDGanttView()
00201 {
00202 setUpdateEnabled(false);
00203
00204 myCanvasView->resetCutPaste( 0 );
00205 myTimeTable->clearTaskLinks();
00206 }
00230 void KDGanttView::setUpdateEnabled( bool enable )
00231 {
00232 myTimeTable->setBlockUpdating( !enable );
00233 if ( enable ) {
00234 myTimeTable->updateMyContent();
00235 myCanvasView->setMyContentsHeight( 0 );
00236 }
00237 }
00238
00246 bool KDGanttView::getUpdateEnabled() const
00247 {
00248 return !myTimeTable->blockUpdating();
00249 }
00250
00251
00252
00253
00260 void KDGanttView::setGanttMaximumWidth( int w )
00261 {
00262 myTimeHeader->setMaximumWidth ( w );
00263 }
00271 int KDGanttView::ganttMaximumWidth() const
00272 {
00273 return myTimeHeader->maximumWidth();
00274 }
00275
00282 void KDGanttView::show()
00283 {
00284 myTimeTable->setBlockUpdating( false );
00285 if (myCanvasView->horizontalScrollBar()->value() > 0 )
00286 myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->value()-1 );
00287 else
00288 myCanvasView->horizontalScrollBar()->setValue(1 );
00289 myTimeTable->updateMyContent();
00290 TQWidget::show();
00291 myCanvasView->setMyContentsHeight( 0 );
00292 if ( fCenterTimeLineAfterShow ) {
00293 fCenterTimeLineAfterShow = false;
00294 centerTimeline (dtCenterTimeLineAfterShow);
00295 }
00296 }
00304 bool KDGanttView::close ( bool alsoDelete )
00305 {
00306
00307 if ( closingBlocked )
00308 return false;
00309 return TQWidget::close ( alsoDelete );
00310 }
00311
00312
00321 TQSize KDGanttView::sizeHint() const
00322 {
00323 bool block = myTimeTable->blockUpdating();
00324 myTimeTable->setBlockUpdating( false );
00325 myTimeTable->updateMyContent();
00326
00327
00328
00329
00330
00331
00332 int hintHeight = myTimeHeader->height();
00333 int legendHeight = 0;
00334 if ( showLegendButton() )
00335 legendHeight = myLegend->height();
00336 int listViewHeaderHeight = 0;
00337 if ( headerVisible() )
00338 listViewHeaderHeight = myListView->header()->height();
00339 if ( hintHeight < legendHeight+listViewHeaderHeight )
00340 hintHeight = legendHeight + listViewHeaderHeight;
00341 hintHeight += myListView->horizontalScrollBar()->height();
00342 if ( myLegend->isShown() )
00343 hintHeight += myLegend->legendSizeHint().height() +10;
00344 hintHeight += myTimeTable->minimumHeight+myListView->frameWidth()*2+2;
00345 int hintWid = myListView->sizeHint().width();
00346
00347 hintWid += myCanvasView->sizeHint().width();
00348
00349
00350 myTimeTable->setBlockUpdating( block );
00351 return TQSize( hintWid+10, hintHeight );
00352 }
00353
00354
00362 void KDGanttView::setShowLegendButton( bool show )
00363 {
00364 _showLegendButton = show;
00365 if ( show )
00366 myLegend->show();
00367 else
00368 myLegend->hide();
00369 slotHeaderSizeChanged();
00370 }
00371
00372
00379 bool KDGanttView::showLegendButton() const
00380 {
00381 return _showLegendButton;
00382 }
00383
00384
00391 void KDGanttView::setHeaderVisible( bool visible )
00392 {
00393 if( visible )
00394 myListView->header()->show();
00395 else
00396 myListView->header()->hide();
00397 _showHeader = visible;
00398 slotHeaderSizeChanged();
00399 }
00400
00401
00407 bool KDGanttView::headerVisible() const
00408 {
00409 return _showHeader;
00410 }
00411
00412
00421 TQDateTime KDGanttView::getDateTimeForCoordX(int coordX, bool global ) const
00422 {
00423
00424 return myTimeHeader->getDateTimeForIndex(coordX, !global );
00425 }
00426
00427
00431 void KDGanttView::slotSelectionChanged( TQListViewItem* item )
00432 {
00433 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00434 Q_ASSERT( gItem );
00435 emit lvSelectionChanged( gItem );
00436 }
00437
00438
00439
00440
00441
00442
00443 void KDGanttView::slotmouseButtonClicked ( int button, TQListViewItem * item,
00444 const TQPoint & pos, int c )
00445 {
00446 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00447 emit lvMouseButtonClicked ( button , gItem, pos, c );
00448 if (gItem == 0 && myCurrentItem != 0 ) {
00449 myCurrentItem = 0;
00450 emit lvCurrentChanged( gItem );
00451 }
00452 if (gItem != 0 && myCurrentItem == 0 ) {
00453 myCurrentItem = gItem;
00454 emit lvCurrentChanged( gItem );
00455 }
00456
00457
00458
00459 {
00460 switch ( button ) {
00461 case Qt::LeftButton:
00462 emit lvItemLeftClicked( gItem );
00463 emit itemLeftClicked( gItem );
00464 break;
00465 case Qt::MidButton:
00466 emit lvItemMidClicked( gItem );
00467 emit itemMidClicked( gItem );
00468 break;
00469 }
00470 }
00471 }
00472
00473
00474
00475
00476
00477
00478
00479 void KDGanttView::slotcontextMenuRequested ( TQListViewItem * item, const TQPoint & pos, int col )
00480 {
00481 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00482 emit lvContextMenuRequested ( gItem, pos, col );
00483 emit lvItemRightClicked( gItem );
00484 emit itemRightClicked( gItem );
00485 }
00486
00487
00488 void KDGanttView::emptySpaceDoubleClicked( TQMouseEvent * e )
00489 {
00490 emit dateTimeDoubleClicked( getDateTimeForCoordX( e->x(), false ) );
00491 }
00492
00493
00494
00495
00496
00497 void KDGanttView::slotCurrentChanged ( TQListViewItem * item )
00498 {
00499 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00500 myCurrentItem = gItem;
00501 emit lvCurrentChanged( gItem );
00502 }
00503
00504
00505
00506
00507
00508 void KDGanttView::slotItemRenamed ( TQListViewItem * item , int col,
00509 const TQString & text )
00510 {
00511 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00512 emit lvItemRenamed( gItem, col, text );
00513 }
00514
00515
00516
00517
00518
00519 void KDGanttView::slotMouseButtonPressed ( int button, TQListViewItem * item,
00520 const TQPoint & pos, int c )
00521 {
00522 KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00523 emit lvMouseButtonPressed( button, gItem, pos, c );
00524 }
00525
00526
00541 void KDGanttView::setRepaintMode( RepaintMode mode )
00542 {
00543
00544 TQScrollBar *cvh, *cvv;
00545 cvh = myCanvasView->horizontalScrollBar();
00546 cvv = myCanvasView->verticalScrollBar();
00547
00548 cvh->disconnect( this );
00549 cvv->disconnect( this );
00550
00551 switch ( mode ) {
00552 case No:
00553
00554 break;
00555 case Medium:
00556 connect( cvv, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
00557 connect( cvh, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
00558 connect( cvv, TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(forceRepaint()));
00559 connect( cvh, TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(forceRepaint()));
00560 connect( cvv, TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(forceRepaint()));
00561 connect( cvh, TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(forceRepaint()));
00562 break;
00563 case Always:
00564 connect( cvv, TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT(forceRepaint( int )));
00565 connect( cvh, TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT(forceRepaint( int )));
00566 connect( cvv, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
00567 connect( cvh, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
00568 break;
00569 }
00570 }
00571
00572
00573 void KDGanttView::forceRepaint( int )
00574 {
00575 if ( myTimeTable->blockUpdating() )
00576 return;
00577
00578 myTimeTable->setAllChanged();
00579 myTimeTable->update();
00580 }
00581
00582
00583 void KDGanttView::slotHeaderSizeChanged()
00584 {
00585 int legendHeight = 0;
00586 if ( showLegendButton() )
00587 legendHeight = 24;
00588 int listViewHeaderHeight = 0;
00589 if ( headerVisible() )
00590 listViewHeaderHeight = myListView->header()->height();
00591 int timeHeaderHeight = myTimeHeader->height()+myTimeHeaderScroll->frameWidth()*2;;
00592 int diffY = timeHeaderHeight-legendHeight-listViewHeaderHeight;
00593 if ( diffY < 0 ) {
00594 spacerLeft->setFixedHeight( 0 );
00595 spacerRight->setFixedHeight(-diffY);
00596 } else {
00597 spacerRight->setFixedHeight( 0 );
00598 spacerLeft->setFixedHeight( diffY );
00599 }
00600 myLegend->setFixedHeight( legendHeight );
00601 myTimeHeaderContainer->setFixedHeight( timeHeaderHeight );
00602 }
00603
00604 void KDGanttView::setLegendIsDoctwindow( bool show )
00611 {
00612 bool isdock = myLegend->asDoctwindow();
00613 if ( show != isdock ) {
00614 myLegend->setAsDoctwindow(show);
00615
00616 legendItem* li;
00617 for ( li = myLegendItems->first(); li; li = myLegendItems->next() ) {
00618 myLegend->addLegendItem(li->shape, li->color, li->text );
00619 }
00620 }
00621 }
00622
00623 bool KDGanttView::legendIsDoctwindow() const
00630 {
00631 return myLegend->asDoctwindow();
00632 }
00633
00634
00647 TQDockWindow* KDGanttView::legendDoctwindow() const
00648 {
00649 return myLegend->dockwindow();
00650 }
00651
00652
00661 void KDGanttView::setShowLegend( bool show )
00662 {
00663 myLegend->showMe(show);
00664 }
00665
00666
00675 bool KDGanttView::showLegend() const
00676 {
00677 return myLegend->isShown();
00678 }
00679
00680
00689 void KDGanttView::setShowListView( bool show )
00690 {
00691 if(listViewIsVisible == show) return;
00692 listViewIsVisible = show;
00693 if (listViewIsVisible)
00694 myListView->parentWidget()->show();
00695 else
00696 myListView->parentWidget()->hide();
00697 }
00698
00699
00706 bool KDGanttView::showListView() const
00707 {
00708 return listViewIsVisible;
00709 }
00710
00711
00721 void KDGanttView::setEditorEnabled( bool enable )
00722 {
00723 editorIsEnabled = enable;
00724 }
00725
00726
00735 bool KDGanttView::editorEnabled() const
00736 {
00737 return editorIsEnabled;
00738 }
00739
00740
00749 void KDGanttView::setEditable( bool editable )
00750 {
00751 chartIsEditable = editable;
00752 }
00753
00754
00762 bool KDGanttView::editable() const
00763 {
00764 return chartIsEditable;
00765 }
00766
00767
00779 bool KDGanttView::saveProject( TQIODevice* device )
00780 {
00781 Q_ASSERT( device );
00782
00783 TQDomDocument doc = saveXML();
00784 if( device->isOpen() )
00785 device->close();
00786 if( device->open( IO_WriteOnly ) ) {
00787 TQTextStream ts( device );
00788 ts << doc.toString();
00789 return true;
00790 } else
00791 return false;
00792 }
00793
00794
00806 bool KDGanttView::loadProject( TQIODevice* device )
00807 {
00808 Q_ASSERT( device );
00809
00810 if( device->isOpen() )
00811 device->close();
00812 if( device->open( IO_ReadOnly ) ) {
00813 TQDomDocument doc( "GanttView" );
00814 TQString err;
00815 int errline, errcol;
00816 if ( !doc.setContent( device, &err, &errline, &errcol ) ) {
00817 tqDebug("KDGantt::Error parsing XML data at line %d. Message is:", errline );
00818 tqDebug("%s ", err.latin1());
00819 device->close();
00820 return false;
00821 }
00822 device->close();
00823 return loadXML( doc );
00824 } else
00825 return false;
00826 }
00827
00828
00847 void KDGanttView::print( TQPrinter* printer ,
00848 bool printListView, bool printTimeLine,
00849 bool printLegend )
00850 {
00851 bool deletePrinter = false;
00852 if (! printer ) {
00853 printer = new TQPrinter();
00854 deletePrinter = true;
00855 if ( !printer->setup()) {
00856 delete printer;
00857 return;
00858 }
00859 }
00860
00861 TQPainter p( printer );
00862
00863 TQPaintDeviceMetrics m = TQPaintDeviceMetrics ( printer );
00864 float dx, dy;
00865
00866
00867
00868 TQSize size = drawContents( 0, printListView, printTimeLine, printLegend );
00869
00870
00871 TQString date = "Printing Time: " + TQDateTime::currentDateTime().toString();
00872 int hei = p.boundingRect(0,0, 5, 5, TQt::AlignLeft, date ).height();
00873 p.drawText( 0, 0, date );
00874
00875
00876 dx = (float) m.width() / (float)size.width();
00877 dy = (float)(m.height() - ( 2 * hei )) / (float)size.height();
00878 float scale;
00879
00880 if ( dx < dy )
00881 scale = dx;
00882 else
00883 scale = dy;
00884
00885 p.scale( scale, scale );
00886
00887 p.translate( 0, 2*hei );
00888 drawContents( &p, printListView, printTimeLine, printLegend );
00889
00890
00891
00892
00893
00894 p.end();
00895 if ( deletePrinter )
00896 delete printer;
00897 }
00898
00899
00939 TQSize KDGanttView::drawContents( TQPainter* p,
00940 bool drawListView , bool drawTimeLine, bool drawLegend )
00941 {
00942 TQSize size;
00943 int lvX, lvY, thX, thY, tlX, tlY, lwX, lwY, allX, allY;
00944 lvX = myListView->contentsWidth();
00945 lvY = myCanvasView->canvas()->height() + 20;
00946 thX = myTimeHeader->width();
00947 thY = myTimeHeader->height();
00948 tlX = myCanvasView->canvas()->width();
00949 tlY = lvY;
00950 lwX = myLegend->legendSize().width();
00951 lwY = myLegend->legendSize().height();
00952 allX = 0;
00953 allY = 0;
00954 if ( drawListView ) {
00955 allX += lvX;
00956 allY += tlY;
00957 }
00958 if ( drawTimeLine ) {
00959 allX += thX;
00960 allY += thY;
00961 }
00962 if ( drawLegend ) {
00963 allY += lwY;
00964 if ( allX < lwX )
00965 allX = lwX ;
00966 }
00967 size = TQSize( allX, allY );
00968 int temp = 0;
00969 if ( p ) {
00970 if ( drawListView ) {
00971 if ( drawTimeLine )
00972 temp = thY;
00973 p->translate( 0, temp );
00974
00975
00976
00977 myListView->drawToPainter( p, drawTimeLine );
00978 p->translate( lvX, -temp);
00979 }
00980 if ( drawTimeLine ) {
00981 p->translate( myCanvasView->frameWidth(), 0);
00982 myTimeHeader->repaintMe( 0, myTimeHeader->width(), p );
00983 p->translate( -myCanvasView->frameWidth(), thY);
00984 myCanvasView->drawToPainter( p );
00985 if ( drawListView )
00986 p->translate( -lvX, tlY);
00987 else
00988 p->translate( 0, tlY);
00989 } else {
00990 if ( drawListView )
00991 p->translate( -lvX, 0 );
00992 }
00993 if ( drawLegend ) {
00994 myLegend->drawToPainter( p );
00995 p->translate( 0, lwY );
00996 }
00997 }
00998 return size;
00999 }
01000
01014 void KDGanttView::setZoomFactor( double factor, bool absolute )
01015 {
01016 myTimeHeader->zoom(factor,absolute);
01017 }
01018
01019
01027 double KDGanttView::zoomFactor() const
01028 {
01029 return myTimeHeader->zoomFactor();
01030 }
01031
01032
01041 void KDGanttView::zoomToFit()
01042 {
01043 myTimeHeader->zoomToFit();
01044 }
01045
01046
01058 void KDGanttView::zoomToSelection( const TQDateTime& start, const TQDateTime& end )
01059 {
01060
01061 myTimeHeader->zoomToSelection( start, end);
01062
01063 }
01064
01065
01072 void KDGanttView::ensureVisible( KDGanttViewItem* item )
01073 {
01074 myListView->ensureItemVisible (item);
01075 }
01076
01077
01086 void KDGanttView::centerTimeline( const TQDateTime& center )
01087 {
01088 myTimeHeader->centerDateTime( center );
01089 }
01090
01091
01105 void KDGanttView::centerTimelineAfterShow( const TQDateTime& center )
01106 {
01107 myTimeHeader->centerDateTime( center );
01108 if ( ! isVisible() ) {
01109 dtCenterTimeLineAfterShow = center;
01110 fCenterTimeLineAfterShow = true;
01111 }
01112 }
01113
01118 void KDGanttView::setTimelineToStart()
01119 {
01120 myCanvasView->horizontalScrollBar()->setValue( 0 );
01121 }
01122
01123
01127 void KDGanttView::setTimelineToEnd()
01128 {
01129 myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->maxValue());
01130 }
01131
01132
01143 void KDGanttView::addTicksLeft( int num )
01144 {
01145 myTimeHeader->addTickLeft( num );
01146 }
01147
01148
01158 void KDGanttView::addTicksRight( int num )
01159 {
01160 myTimeHeader->addTickRight( num );
01161 }
01162
01163
01168 void KDGanttView::center( KDGanttViewItem* item )
01169 {
01170 ensureVisible(item);
01171 int x = myListView->contentsWidth()/2;
01172 int y = myListView->itemPos (item );
01173 myListView->center(x,y);
01174 }
01175
01176
01183 void KDGanttView::setShowTaskLinks( bool show )
01184 {
01185 myTimeTable->setShowTaskLinks(show);
01186
01187 }
01188
01189
01196 bool KDGanttView::showTaskLinks() const
01197 {
01198 return myTimeTable->showTaskLinks();
01199 }
01200
01201
01209 void KDGanttView::setFont(const TQFont& font)
01210 {
01211 myListView->setFont(font);
01212 myListView->repaint();
01213 myTimeHeader->setFont(font);
01214 myLegend->setFont( font );
01215 TQWidget::setFont( font );
01216 setScale(scale());
01217 }
01218
01219
01244 void KDGanttView::setShowHeaderPopupMenu( bool show,
01245 bool showZoom,
01246 bool showScale,
01247 bool showTime,
01248 bool showYear,
01249 bool showGrid,
01250 bool showPrint)
01251 {
01252 myTimeHeader->setShowPopupMenu( show,showZoom,showScale,showTime,
01253 showYear,showGrid,showPrint );
01254 }
01255
01256
01263 bool KDGanttView::showHeaderPopupMenu() const
01264 {
01265 return myTimeHeader->showPopupMenu();
01266 }
01267
01268
01269
01283 void KDGanttView::setShowTimeTablePopupMenu( bool show )
01284 {
01285 myCanvasView->setShowPopupMenu( show );
01286 }
01287
01288
01295 bool KDGanttView::showTimeTablePopupMenu() const
01296 {
01297 return myCanvasView->showPopupMenu();
01298 }
01299
01300
01318 void KDGanttView::setShapes( KDGanttViewItem::Type type,
01319 KDGanttViewItem::Shape start,
01320 KDGanttViewItem::Shape middle,
01321 KDGanttViewItem::Shape end,
01322 bool overwriteExisting )
01323 {
01324 if ( overwriteExisting ) {
01325 TQListViewItemIterator it(myListView);
01326 for ( ; it.current(); ++it ) {
01327 if ( ((KDGanttViewItem*)it.current())->type() == type)
01328 ((KDGanttViewItem*)it.current())->setShapes(start,middle, end );
01329 }
01330 }
01331 int index = getIndex( type );
01332 myDefaultShape [index*3] = start;
01333 myDefaultShape [index*3+1] = middle;
01334 myDefaultShape [index*3+2] = end;
01335 undefinedShape[index] = false;
01336 }
01337
01338
01351 bool KDGanttView::shapes( KDGanttViewItem::Type type,
01352 KDGanttViewItem::Shape& start,
01353 KDGanttViewItem::Shape& middle,
01354 KDGanttViewItem::Shape& end ) const
01355 {
01356 int index = getIndex( type );
01357 start = myDefaultShape [index*3];
01358 middle = myDefaultShape [index*3+1];
01359 end = myDefaultShape [index*3+2];
01360 return !undefinedShape[index];
01361 }
01362
01363
01381 void KDGanttView::setColors( KDGanttViewItem::Type type,
01382 const TQColor& start, const TQColor& middle,
01383 const TQColor& end,
01384 bool overwriteExisting )
01385 {
01386 if ( overwriteExisting ) {
01387 TQListViewItemIterator it(myListView);
01388 for ( ; it.current(); ++it ) {
01389 if ( ((KDGanttViewItem*)it.current())->type() == type)
01390 ((KDGanttViewItem*)it.current())->setColors(start,middle, end );
01391 }
01392 }
01393 int index = getIndex( type );
01394 myColor [index*3] = start;
01395 myColor [index*3+1] = middle;
01396 myColor [index*3+2] = end;
01397 undefinedColor[index] = false;
01398 }
01399
01400
01413 bool KDGanttView::colors( KDGanttViewItem::Type type,
01414 TQColor& start, TQColor& middle, TQColor& end ) const
01415 {
01416 int index = getIndex( type );
01417 start = myColor [index*3];
01418 middle = myColor [index*3+1];
01419 end = myColor [index*3+2];
01420 return !undefinedColor[index];
01421 }
01422
01423
01443 void KDGanttView::setHighlightColors( KDGanttViewItem::Type type,
01444 const TQColor& start,
01445 const TQColor& middle,
01446 const TQColor& end,
01447 bool overwriteExisting )
01448 {
01449 if ( overwriteExisting ) {
01450 TQListViewItemIterator it(myListView);
01451 for ( ; it.current(); ++it ) {
01452 if ( ((KDGanttViewItem*)it.current())->type() == type)
01453 ((KDGanttViewItem*)it.current())->setHighlightColors(start,middle, end );
01454 }
01455 }
01456 int index = getIndex( type );
01457 myColorHL [index*3] = start;
01458 myColorHL [index*3+1] = middle;
01459 myColorHL [index*3+2] = end;
01460 undefinedColorHL[index] = false;
01461
01462 }
01463
01464
01479 bool KDGanttView::highlightColors( KDGanttViewItem::Type type,
01480 TQColor& start, TQColor& middle,
01481 TQColor& end ) const
01482 {
01483 int index = getIndex( type );
01484 start = myColorHL [index*3];
01485 middle = myColorHL [index*3+1];
01486 end = myColorHL [index*3+2];
01487 return !undefinedColorHL[index];
01488 }
01489
01490
01498 void KDGanttView::setTextColor( const TQColor& color )
01499 {
01500 TQListViewItemIterator it(myListView);
01501 for ( ; it.current(); ++it ) {
01502 ((KDGanttViewItem*)it.current())->setTextColor(color);
01503 }
01504 myTextColor = color;
01505 }
01506
01507
01514 TQColor KDGanttView::textColor() const
01515 {
01516 return myTextColor;
01517 }
01518
01519
01530 void KDGanttView::setNoInformationBrush( const TQBrush& brush )
01531 {
01532 myTimeTable->setNoInformationBrush( brush );
01533 }
01534
01535
01542 TQBrush KDGanttView::noInformationBrush() const
01543 {
01544 return myTimeTable->noInformationBrush();
01545 }
01546
01547
01553 void KDGanttView::clearLegend( )
01554 {
01555 myLegend->clearLegend();
01556 myLegendItems->setAutoDelete( true );
01557 delete myLegendItems;
01558 myLegendItems = new TQPtrList<legendItem>;
01559 }
01560
01561
01570 void KDGanttView::addLegendItem( KDGanttViewItem::Shape shape,
01571 const TQColor& shapeColor,
01572 const TQString& text )
01573 {
01574 myLegend->addLegendItem( shape,shapeColor,text );
01575 legendItem* item = new legendItem;
01576 item->shape = shape;
01577 item->color = shapeColor;
01578 item->text = text;
01579 myLegendItems->append( item );
01580 }
01581
01582
01590 void KDGanttView::setHorizonStart( const TQDateTime& start )
01591 {
01592 myTimeHeader->setHorizonStart(start);
01593 }
01594
01595
01602 TQDateTime KDGanttView::horizonStart() const
01603 {
01604 return myTimeHeader->horizonStart();
01605 }
01606
01607
01615 void KDGanttView::setHorizonEnd( const TQDateTime& end )
01616 {
01617 myTimeHeader->setHorizonEnd(end);
01618 }
01619
01620
01628 TQDateTime KDGanttView::horizonEnd() const
01629 {
01630 return myTimeHeader->horizonEnd();
01631 }
01632
01633
01641 void KDGanttView::setScale( Scale unit )
01642 {
01643 myTimeHeader->setScale( unit );
01644 }
01645
01646
01653 KDGanttView::Scale KDGanttView::scale() const
01654 {
01655 return myTimeHeader->scale();
01656 }
01657
01658
01665 void KDGanttView::setMaximumScale( Scale unit )
01666 {
01667 myTimeHeader->setMaximumScale( unit );
01668 }
01669
01670
01677 KDGanttView::Scale KDGanttView::maximumScale() const
01678 {
01679 return myTimeHeader->maximumScale();
01680 }
01681
01682
01689 void KDGanttView::setMinimumScale( Scale unit )
01690 {
01691 myTimeHeader->setMinimumScale( unit );
01692 }
01693
01694
01701 KDGanttView::Scale KDGanttView::minimumScale() const
01702 {
01703 return myTimeHeader->minimumScale();
01704 }
01705
01706
01716 void KDGanttView::setAutoScaleMinorTickCount( int count )
01717 {
01718 myTimeHeader->setAutoScaleMinorTickCount( count );
01719 }
01720
01721
01728 int KDGanttView::autoScaleMinorTickCount() const
01729 {
01730 return myTimeHeader->autoScaleMinorTickCount();
01731 }
01732
01733
01742 void KDGanttView::setMinimumColumnWidth( int width )
01743 {
01744 myTimeHeader->setMinimumColumnWidth( width );
01745 }
01746
01747
01754 int KDGanttView::minimumColumnWidth() const
01755 {
01756 return myTimeHeader->minimumColumnWidth();
01757 }
01758
01759
01767 void KDGanttView::setYearFormat( YearFormat format )
01768 {
01769 myTimeHeader->setYearFormat(format );
01770 }
01771
01772
01779 KDGanttView::YearFormat KDGanttView::yearFormat() const
01780 {
01781 return myTimeHeader->yearFormat();
01782 }
01783
01784
01793 void KDGanttView::setHourFormat( HourFormat format )
01794 {
01795 myTimeHeader->setHourFormat( format );
01796 }
01797
01798
01806 KDGanttView::HourFormat KDGanttView::hourFormat() const
01807 {
01808 return myTimeHeader->hourFormat();
01809 }
01810
01811
01822 void KDGanttView::setShowMajorTicks( bool show )
01823 {
01824 myTimeHeader->setShowMajorTicks(show );
01825 }
01826
01827
01834 bool KDGanttView::showMajorTicks() const
01835 {
01836 return myTimeHeader->showMajorTicks();
01837 }
01838
01839
01852 void KDGanttView::setShowMinorTicks( bool show)
01853 {
01854 myTimeHeader->setShowMinorTicks( show );
01855 }
01856
01857
01864 bool KDGanttView::showMinorTicks() const
01865 {
01866 return myTimeHeader->showMinorTicks();
01867 }
01868
01869
01887 void KDGanttView::setColumnBackgroundColor( const TQDateTime& column,
01888 const TQColor& color ,
01889 Scale mini, Scale maxi )
01890 {
01891 myTimeHeader->setColumnBackgroundColor( column, color,mini,maxi );
01892 }
01893
01894 #if 0
01895
01921 void KDGanttView::setIntervalBackgroundColor( const TQDateTime& start,
01922 const TQDateTime& end,
01923 const TQColor& color ,
01924 Scale mini, Scale maxi )
01925 {
01926 myTimeHeader->setIntervalBackgroundColor( start, end, color,mini,maxi );
01927 }
01928
01929
01948 bool KDGanttView::changeBackgroundInterval( const TQDateTime& oldstart,
01949 const TQDateTime& oldend,
01950 const TQDateTime& newstart,
01951 const TQDateTime& newend )
01952 {
01953 return myTimeHeader->changeBackgroundInterval( oldstart, oldend,
01954 newstart, newend );
01955 }
01956
01966 bool KDGanttView::deleteBackgroundInterval( const TQDateTime& start,
01967 const TQDateTime& end)
01968 {
01969 return myTimeHeader->deleteBackgroundInterval( start, end );
01970 }
01971 #endif
01972
01978 void KDGanttView::addIntervalBackgroundColor( KDIntervalColorRectangle* newItem )
01979 {
01980 myTimeHeader->addIntervalBackgroundColor( newItem );
01981 }
01982
01991 void KDGanttView::clearBackgroundColor()
01992 {
01993 myTimeHeader->clearBackgroundColor();
01994 }
01995
01996
02005 TQColor KDGanttView::columnBackgroundColor( const TQDateTime& column ) const
02006 {
02007 return myTimeHeader->columnBackgroundColor( column ) ;
02008 }
02009
02010
02019 void KDGanttView::setWeekendBackgroundColor( const TQColor& color )
02020 {
02021 myTimeHeader->setWeekendBackgroundColor( color );
02022 }
02023
02024
02031 TQColor KDGanttView::weekendBackgroundColor() const
02032 {
02033 return myTimeHeader->weekendBackgroundColor();
02034 }
02035
02036
02047 void KDGanttView::setWeekdayBackgroundColor( const TQColor& color, int weekday )
02048 {
02049 myTimeHeader->setWeekdayBackgroundColor( color, weekday );
02050 }
02051
02052
02060 TQColor KDGanttView::weekdayBackgroundColor(int weekday) const
02061 {
02062 return myTimeHeader->weekdayBackgroundColor( weekday);
02063 }
02064
02065
02066
02077 void KDGanttView::setWeekendDays( int start, int end )
02078 {
02079 myTimeHeader->setWeekendDays( start, end );
02080 }
02081
02082
02090 void KDGanttView::weekendDays( int& start, int& end ) const
02091 {
02092 myTimeHeader->weekendDays( start, end );
02093 }
02094
02095
02196 void KDGanttView::setMajorScaleCount( int count )
02197 {
02198 myTimeHeader->setMajorScaleCount(count );
02199 }
02200
02201
02208 int KDGanttView::majorScaleCount() const
02209 {
02210 return myTimeHeader->majorScaleCount();
02211 }
02212
02213
02220 void KDGanttView::setMinorScaleCount( int count )
02221 {
02222 myTimeHeader->setMinorScaleCount(count );
02223 }
02224
02225
02232 int KDGanttView::minorScaleCount() const
02233 {
02234 return myTimeHeader->minorScaleCount();
02235
02236 }
02237
02238
02251 void KDGanttView::setDefaultColor( KDGanttViewItem::Type type,
02252 const TQColor& color,
02253 bool overwriteExisting )
02254 {
02255 if ( overwriteExisting ) {
02256 TQListViewItemIterator it(myListView);
02257 for ( ; it.current(); ++it ) {
02258 if ( ((KDGanttViewItem*)it.current())->type() == type)
02259 ((KDGanttViewItem*)it.current())->setDefaultColor(color );
02260 }
02261 }
02262 int index = getIndex( type );
02263 myDefaultColor [index] = color;
02264 }
02265
02266
02267
02278 TQColor KDGanttView::defaultColor( KDGanttViewItem::Type type ) const
02279 {
02280 int index = getIndex( type );
02281 return myDefaultColor [index];
02282 }
02283
02284
02297 void KDGanttView::setDefaultHighlightColor( KDGanttViewItem::Type type,
02298 const TQColor& color,
02299 bool overwriteExisting )
02300 {
02301 if ( overwriteExisting ) {
02302 TQListViewItemIterator it(myListView);
02303 for ( ; it.current(); ++it ) {
02304 if ( ((KDGanttViewItem*)it.current())->type() == type)
02305 ((KDGanttViewItem*)it.current())->setDefaultHighlightColor(color );
02306 }
02307 }
02308 int index = getIndex( type );
02309 myDefaultColorHL [index] = color;
02310 }
02311
02312
02313
02324 TQColor KDGanttView::defaultHighlightColor( KDGanttViewItem::Type type ) const
02325 {
02326 int index = getIndex( type );
02327 return myDefaultColorHL [index];
02328 }
02329
02330
02336 KDGanttViewItem* KDGanttView::firstChild() const
02337 {
02338 return (KDGanttViewItem*)myListView->firstChild();
02339
02340 }
02358 void KDGanttView::setCalendarMode( bool mode )
02359 {
02360 myListView->setCalendarMode( mode );
02361 }
02362
02363
02371 bool KDGanttView::calendarMode() const
02372 {
02373 return myListView->calendarMode();
02374 }
02375
02376
02377
02387 void KDGanttView::setDisplaySubitemsAsGroup( bool show )
02388 {
02389 TQListViewItemIterator it( myListView );
02390 for ( ; it.current(); ++it ) {
02391 KDGanttViewItem* currentItem = ( KDGanttViewItem* )it.current();
02392 currentItem->setDisplaySubitemsAsGroup( show );
02393 }
02394 _displaySubitemsAsGroup = show;
02395 }
02396
02397
02406 bool KDGanttView::displaySubitemsAsGroup() const
02407 {
02408 return _displaySubitemsAsGroup;
02409 }
02410
02411
02419 void KDGanttView::setDisplayEmptyTasksAsLine( bool show )
02420 {
02421 _displayEmptyTasksAsLine = show;
02422 }
02423
02424
02431 bool KDGanttView::displayEmptyTasksAsLine() const
02432 {
02433 return _displayEmptyTasksAsLine;
02434 }
02435
02436
02451 void KDGanttView::setHorBackgroundLines( int count, TQBrush brush )
02452 {
02453 myTimeTable->setHorBackgroundLines( count, brush );
02454 }
02455
02456
02466 int KDGanttView::horBackgroundLines( TQBrush& brush )
02467 {
02468 return myTimeTable->horBackgroundLines( brush );
02469 }
02470
02471
02477 KDGanttViewItem* KDGanttView::lastItem() const
02478 {
02479 return (KDGanttViewItem*)myListView->lastItem ();
02480 }
02481
02482
02488 TQPtrList<KDGanttViewTaskLink> KDGanttView::taskLinks() const
02489 {
02490
02491 return myTimeTable->taskLinks();
02492 }
02493
02494
02500 TQPtrList<KDGanttViewTaskLinkGroup> KDGanttView::taskLinkGroups() const
02501 {
02502 return myTaskLinkGroupList;
02503 }
02504
02505
02513 bool KDGanttView::loadXML( const TQDomDocument& doc )
02514 {
02515 TQDomElement docRoot = doc.documentElement();
02516 TQDomNode node = docRoot.firstChild();
02517 while( !node.isNull() ) {
02518 TQDomElement element = node.toElement();
02519 if( !element.isNull() ) {
02520 TQString tagName = element.tagName();
02521 if( tagName == "ShowLegend" ) {
02522 bool value;
02523 if( KDGanttXML::readBoolNode( element, value ) )
02524 setShowLegend( value );
02525 } else if( tagName == "ShowLegendButton" ) {
02526 bool value;
02527 if( KDGanttXML::readBoolNode( element, value ) )
02528 setShowLegendButton( value );
02529 } else if( tagName == "LegendIsDockWindow" ) {
02530 bool value;
02531 if( KDGanttXML::readBoolNode( element, value ) )
02532 setLegendIsDoctwindow( value );
02533 } else if( tagName == "ShowListView" ) {
02534 bool value;
02535 if( KDGanttXML::readBoolNode( element, value ) )
02536 setShowListView( value );
02537 } else if( tagName == "ShowHeader" ) {
02538 bool value;
02539 if( KDGanttXML::readBoolNode( element, value ) )
02540 setHeaderVisible( value );
02541 } else if( tagName == "ShowTaskLinks" ) {
02542 bool value;
02543 if( KDGanttXML::readBoolNode( element, value ) )
02544 setShowTaskLinks( value );
02545 } else if( tagName == "EditorEnabled" ) {
02546 bool value;
02547 if( KDGanttXML::readBoolNode( element, value ) )
02548 setEditorEnabled( value );
02549 } else if( tagName == "DisplayEmptyTasksAsLine" ) {
02550 bool value;
02551 if( KDGanttXML::readBoolNode( element, value ) )
02552 setDisplayEmptyTasksAsLine( value );
02553 } else if( tagName == "GlobalFont" ) {
02554 TQFont font;
02555 if( KDGanttXML::readFontNode( element, font ) )
02556 setFont( font );
02557 } else if( tagName == "HorizonStart" ) {
02558 TQDateTime value;
02559 if( KDGanttXML::readDateTimeNode( element, value ) )
02560 setHorizonStart( value );
02561 } else if( tagName == "HorizonEnd" ) {
02562 TQDateTime value;
02563 if( KDGanttXML::readDateTimeNode( element, value ) )
02564 setHorizonEnd( value );
02565 } else if( tagName == "Scale" ) {
02566 TQString value;
02567 if( KDGanttXML::readStringNode( element, value ) )
02568 setScale( stringToScale( value ) );
02569 } else if( tagName == "MinimumScale" ) {
02570 TQString value;
02571 if( KDGanttXML::readStringNode( element, value ) )
02572 setMinimumScale( stringToScale( value ) );
02573 } else if( tagName == "MaximumScale" ) {
02574 TQString value;
02575 if( KDGanttXML::readStringNode( element, value ) )
02576 setMaximumScale( stringToScale( value ) );
02577 } else if( tagName == "YearFormat" ) {
02578 TQString value;
02579 if( KDGanttXML::readStringNode( element, value ) )
02580 setYearFormat( stringToYearFormat( value ) );
02581 } else if( tagName == "HourFormat" ) {
02582 TQString value;
02583 if( KDGanttXML::readStringNode( element, value ) )
02584 setHourFormat( stringToHourFormat( value ) );
02585 } else if( tagName == "ShowMinorTicks" ) {
02586 bool value;
02587 if( KDGanttXML::readBoolNode( element, value ) )
02588 setShowMinorTicks( value );
02589 } else if( tagName == "ShowMajorTicks" ) {
02590 bool value;
02591 if( KDGanttXML::readBoolNode( element, value ) )
02592 setShowMajorTicks( value );
02593 } else if( tagName == "DragEnabled" ) {
02594 bool value;
02595 if( KDGanttXML::readBoolNode( element, value ) )
02596 setDragEnabled( value );
02597 } else if( tagName == "DropEnabled" ) {
02598 bool value;
02599 if( KDGanttXML::readBoolNode( element, value ) )
02600 setDropEnabled( value );
02601 } else if( tagName == "CalendarMode" ) {
02602 bool value;
02603 if( KDGanttXML::readBoolNode( element, value ) )
02604 setCalendarMode( value );
02605 } else if( tagName == "Editable" ) {
02606 bool value;
02607 if( KDGanttXML::readBoolNode( element, value ) )
02608 setEditable( value );
02609 } else if( tagName == "TextColor" ) {
02610 TQColor value;
02611 if( KDGanttXML::readColorNode( element, value ) )
02612 setTextColor( value );
02613 } else if( tagName == "MajorScaleCount" ) {
02614 int value;
02615 if( KDGanttXML::readIntNode( element, value ) )
02616 setMajorScaleCount( value );
02617 } else if( tagName == "MinorScaleCount" ) {
02618 int value;
02619 if( KDGanttXML::readIntNode( element, value ) )
02620 setMinorScaleCount( value );
02621 } else if( tagName == "AutoScaleMinorTickCount" ) {
02622 int value;
02623 if( KDGanttXML::readIntNode( element, value ) )
02624 setAutoScaleMinorTickCount( value );
02625 } else if( tagName == "MinimumColumnWidth" ) {
02626 int value;
02627 if( KDGanttXML::readIntNode( element, value ) )
02628 setMinimumColumnWidth( value );
02629 } else if( tagName == "GanttMaximumWidth" ) {
02630 int value;
02631 if( KDGanttXML::readIntNode( element, value ) )
02632 setGanttMaximumWidth( value );
02633 } else if( tagName == "NoInformationBrush" ) {
02634 TQBrush value;
02635 if( KDGanttXML::readBrushNode( element, value ) )
02636 setNoInformationBrush( value );
02637 } else if( tagName == "GanttViewBackgroundColor" ) {
02638 TQColor value;
02639 if( KDGanttXML::readColorNode( element, value ) )
02640 setGvBackgroundColor( value );
02641 } else if( tagName == "ListViewBackgroundColor" ) {
02642 TQColor value;
02643 if( KDGanttXML::readColorNode( element, value ) )
02644 setLvBackgroundColor( value );
02645 } else if( tagName == "TimeHeaderBackgroundColor" ) {
02646 TQColor value;
02647 if( KDGanttXML::readColorNode( element, value ) )
02648 setTimeHeaderBackgroundColor( value );
02649 } else if( tagName == "LegendHeaderBackgroundColor" ) {
02650 TQColor value;
02651 if( KDGanttXML::readColorNode( element, value ) )
02652 setLegendHeaderBackgroundColor( value );
02653 } else if( tagName == "WeekendBackgroundColor" ) {
02654 TQColor value;
02655 if( KDGanttXML::readColorNode( element, value ) )
02656 setWeekendBackgroundColor( value );
02657 } else if( tagName == "WeekdayBackgroundColor" ) {
02658 TQDomNode node = element.firstChild();
02659 int day = 0;
02660 TQColor color;
02661 while( !node.isNull() ) {
02662 TQDomElement element = node.toElement();
02663 if( !element.isNull() ) {
02664 TQString tagName = element.tagName();
02665 if( tagName == "Day" ) {
02666 int value;
02667 if( KDGanttXML::readIntNode( element, value ) )
02668 day = value;
02669 } else if( tagName == "Color" ) {
02670 TQColor value;
02671 if( KDGanttXML::readColorNode( element, value ) )
02672 color = value;
02673 } else {
02674 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02675 Q_ASSERT( false );
02676 }
02677 }
02678 node = node.nextSibling();
02679 }
02680
02681 if( day && color.isValid() )
02682 setWeekdayBackgroundColor( color, day );
02683 } else if( tagName == "WeekendDays" ) {
02684 TQString startString = element.attribute( "Start" );
02685 TQString endString = element.attribute( "End" );
02686 bool startOk = false, endOk = false;
02687 int start = startString.toInt( &startOk );
02688 int end = startString.toInt( &endOk );
02689 if( startOk && endOk )
02690 setWeekendDays( start, end );
02691 } else if( tagName == "ZoomFactor" ) {
02692 double value;
02693 if( KDGanttXML::readDoubleNode( element, value ) )
02694 setZoomFactor( value, true );
02695 } else if( tagName == "ShowHeaderPopupMenu" ) {
02696 bool value;
02697 if( KDGanttXML::readBoolNode( element, value ) )
02698 setShowHeaderPopupMenu( value );
02699 } else if( tagName == "ShowTimeTablePopupMenu" ) {
02700 bool value;
02701 if( KDGanttXML::readBoolNode( element, value ) )
02702 setShowTimeTablePopupMenu( value );
02703 } else if( tagName == "Shapes" ) {
02704 TQDomNode node = element.firstChild();
02705 bool undefinedShape = false;
02706 while( !node.isNull() ) {
02707 TQDomElement element = node.toElement();
02708 if( !element.isNull() ) {
02709 TQString tagName = element.tagName();
02710 if( tagName == "Event" ) {
02711 KDGanttViewItem::Shape startShape, middleShape, endShape;
02712 startShape = KDGanttViewItem::TriangleDown;
02713 middleShape = KDGanttViewItem::TriangleDown;
02714 endShape = KDGanttViewItem::TriangleDown;
02715 TQDomNode node = element.firstChild();
02716 while( !node.isNull() ) {
02717 TQDomElement element = node.toElement();
02718 if( !element.isNull() ) {
02719 TQString tagName = element.tagName();
02720 if( tagName == "Start" ) {
02721 TQString value;
02722 if( KDGanttXML::readStringNode( element, value ) )
02723 startShape = KDGanttViewItem::stringToShape( value );
02724 if ( value == "Undefined" )
02725 undefinedShape = true;
02726 } else if( tagName == "Middle" ) {
02727 TQString value;
02728 if( KDGanttXML::readStringNode( element, value ) )
02729 middleShape = KDGanttViewItem::stringToShape( value );
02730 if ( value == "Undefined" )
02731 undefinedShape = true;
02732 } else if( tagName == "End" ) {
02733 TQString value;
02734 if( KDGanttXML::readStringNode( element, value ) )
02735 endShape = KDGanttViewItem::stringToShape( value );
02736 if ( value == "Undefined" )
02737 undefinedShape = true;
02738 } else {
02739 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02740 Q_ASSERT( false );
02741 }
02742 }
02743 node = node.nextSibling();
02744 }
02745 if ( ! undefinedShape )
02746 setShapes( KDGanttViewItem::Event, startShape,
02747 middleShape, endShape, false );
02748 undefinedShape = false;
02749 } else if( tagName == "Task" ) {
02750 KDGanttViewItem::Shape startShape, middleShape, endShape;
02751 startShape = KDGanttViewItem::TriangleDown;
02752 middleShape = KDGanttViewItem::TriangleDown;
02753 endShape = KDGanttViewItem::TriangleDown;
02754 TQDomNode node = element.firstChild();
02755 while( !node.isNull()) {
02756 TQDomElement element = node.toElement();
02757 if( !element.isNull() ) {
02758 TQString tagName = element.tagName();
02759 if( tagName == "Start" ) {
02760 TQString value;
02761 if( KDGanttXML::readStringNode( element, value ) )
02762 startShape = KDGanttViewItem::stringToShape( value );
02763 if ( value == "Undefined" )
02764 undefinedShape = true;
02765 } else if( tagName == "Middle" ) {
02766 TQString value;
02767 if( KDGanttXML::readStringNode( element, value ) )
02768 middleShape = KDGanttViewItem::stringToShape( value );
02769 if ( value == "Undefined" )
02770 undefinedShape = true;
02771 } else if( tagName == "End" ) {
02772 TQString value;
02773 if( KDGanttXML::readStringNode( element, value ) )
02774 endShape = KDGanttViewItem::stringToShape( value );
02775 if ( value == "Undefined" )
02776 undefinedShape = true;
02777 } else {
02778 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02779 Q_ASSERT( false );
02780 }
02781 }
02782 node = node.nextSibling();
02783 }
02784 if ( ! undefinedShape )
02785 setShapes( KDGanttViewItem::Task, startShape, middleShape, endShape, false );
02786 undefinedShape = false;
02787 } else if( tagName == "Summary" ) {
02788 KDGanttViewItem::Shape startShape, middleShape, endShape;
02789 startShape = KDGanttViewItem::TriangleDown;
02790 middleShape = KDGanttViewItem::TriangleDown;
02791 endShape = KDGanttViewItem::TriangleDown;
02792 TQDomNode node = element.firstChild();
02793 while( !node.isNull() ) {
02794 TQDomElement element = node.toElement();
02795 if( !element.isNull() ) {
02796 TQString tagName = element.tagName();
02797 if( tagName == "Start" ) {
02798 TQString value;
02799 if( KDGanttXML::readStringNode( element, value ) )
02800 startShape = KDGanttViewItem::stringToShape( value );
02801 if ( value == "Undefined" )
02802 undefinedShape = true;
02803 } else if( tagName == "Middle" ) {
02804 TQString value;
02805 if( KDGanttXML::readStringNode( element, value ) )
02806 middleShape = KDGanttViewItem::stringToShape( value );
02807 if ( value == "Undefined" )
02808 undefinedShape = true;
02809 } else if( tagName == "End" ) {
02810 TQString value;
02811 if( KDGanttXML::readStringNode( element, value ) )
02812 endShape = KDGanttViewItem::stringToShape( value );
02813 if ( value == "Undefined" )
02814 undefinedShape = true;
02815 } else {
02816 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02817 Q_ASSERT( false );
02818 }
02819 }
02820 node = node.nextSibling();
02821 }
02822 if ( ! undefinedShape )
02823 setShapes( KDGanttViewItem::Summary, startShape,
02824 middleShape, endShape, false );
02825 undefinedShape = false;
02826 } else {
02827 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02828 Q_ASSERT( false );
02829 }
02830 }
02831 node = node.nextSibling();
02832 }
02833 } else if( tagName == "Colors" ) {
02834 TQDomNode node = element.firstChild();
02835 while( !node.isNull()) {
02836 TQDomElement element = node.toElement();
02837 if( !element.isNull() ) {
02838 TQString tagName = element.tagName();
02839 if( tagName == "Event" ) {
02840 TQColor startColor, middleColor, endColor;
02841 TQDomNode node = element.firstChild();
02842 while( !node.isNull() ) {
02843 TQDomElement element = node.toElement();
02844 if( !element.isNull() ) {
02845 TQString tagName = element.tagName();
02846 if( tagName == "Start" ) {
02847 TQColor value;
02848 if( KDGanttXML::readColorNode( element, value ) )
02849 startColor = value;
02850 } else if( tagName == "Middle" ) {
02851 TQColor value;
02852 if( KDGanttXML::readColorNode( element, value ) )
02853 middleColor = value;
02854 } else if( tagName == "End" ) {
02855 TQColor value;
02856 if( KDGanttXML::readColorNode( element, value ) )
02857 endColor = value;
02858 } else {
02859 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02860 Q_ASSERT( false );
02861 }
02862 }
02863 node = node.nextSibling();
02864 }
02865 setColors( KDGanttViewItem::Event, startColor,
02866 middleColor, endColor, false );
02867 } else if( tagName == "Task" ) {
02868 TQColor startColor, middleColor, endColor;
02869 TQDomNode node = element.firstChild();
02870 while( !node.isNull() ) {
02871 TQDomElement element = node.toElement();
02872 if( !element.isNull() ) {
02873 TQString tagName = element.tagName();
02874 if( tagName == "Start" ) {
02875 TQColor value;
02876 if( KDGanttXML::readColorNode( element, value ) )
02877 startColor = value;
02878 } else if( tagName == "Middle" ) {
02879 TQColor value;
02880 if( KDGanttXML::readColorNode( element, value ) )
02881 middleColor = value;
02882 } else if( tagName == "End" ) {
02883 TQColor value;
02884 if( KDGanttXML::readColorNode( element, value ) )
02885 endColor = value;
02886 } else {
02887 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02888 Q_ASSERT( false );
02889 }
02890 }
02891 node = node.nextSibling();
02892 }
02893 setColors( KDGanttViewItem::Task, startColor,
02894 middleColor, endColor, false );
02895 } else if( tagName == "Summary" ) {
02896 TQColor startColor, middleColor, endColor;
02897 TQDomNode node = element.firstChild();
02898 while( !node.isNull() ) {
02899 TQDomElement element = node.toElement();
02900 if( !element.isNull() ) {
02901 TQString tagName = element.tagName();
02902 if( tagName == "Start" ) {
02903 TQColor value;
02904 if( KDGanttXML::readColorNode( element, value ) )
02905 startColor = value;
02906 } else if( tagName == "Middle" ) {
02907 TQColor value;
02908 if( KDGanttXML::readColorNode( element, value ) )
02909 middleColor = value;
02910 } else if( tagName == "End" ) {
02911 TQColor value;
02912 if( KDGanttXML::readColorNode( element, value ) )
02913 endColor = value;
02914 } else {
02915 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02916 Q_ASSERT( false );
02917 }
02918 }
02919 node = node.nextSibling();
02920 }
02921 setColors( KDGanttViewItem::Summary, startColor,
02922 middleColor, endColor , false);
02923 } else {
02924 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02925 Q_ASSERT( false );
02926 }
02927 }
02928 node = node.nextSibling();
02929 }
02930 } else if( tagName == "DefaultColors" ) {
02931 TQDomNode node = element.firstChild();
02932 while( !node.isNull() ) {
02933 TQDomElement element = node.toElement();
02934 if( !element.isNull() ) {
02935 TQString tagName = element.tagName();
02936 if( tagName == "Event" ) {
02937 TQColor value;
02938 if( KDGanttXML::readColorNode( element, value ) )
02939 setDefaultColor( KDGanttViewItem::Event,
02940 value, false );
02941 } else if( tagName == "Task" ) {
02942 TQColor value;
02943 if( KDGanttXML::readColorNode( element, value ) )
02944 setDefaultColor( KDGanttViewItem::Task,
02945 value, false );
02946 } else if( tagName == "Summary" ) {
02947 TQColor value;
02948 if( KDGanttXML::readColorNode( element, value ) )
02949 setDefaultColor( KDGanttViewItem::Summary,
02950 value , false);
02951 } else {
02952 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02953 Q_ASSERT( false );
02954 }
02955 }
02956
02957 node = node.nextSibling();
02958 }
02959 } else if( tagName == "HighlightColors" ) {
02960 TQDomNode node = element.firstChild();
02961 while( !node.isNull() ) {
02962 TQDomElement element = node.toElement();
02963 if( !element.isNull() ) {
02964 TQString tagName = element.tagName();
02965 if( tagName == "Event" ) {
02966 TQColor startColor, middleColor, endColor;
02967 TQDomNode node = element.firstChild();
02968 while( !node.isNull() ) {
02969 TQDomElement element = node.toElement();
02970 if( !element.isNull() ) {
02971 TQString tagName = element.tagName();
02972 if( tagName == "Start" ) {
02973 TQColor value;
02974 if( KDGanttXML::readColorNode( element, value ) )
02975 startColor = value;
02976 } else if( tagName == "Middle" ) {
02977 TQColor value;
02978 if( KDGanttXML::readColorNode( element, value ) )
02979 middleColor = value;
02980 } else if( tagName == "End" ) {
02981 TQColor value;
02982 if( KDGanttXML::readColorNode( element, value ) )
02983 endColor = value;
02984 } else {
02985 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
02986 Q_ASSERT( false );
02987 }
02988 }
02989 node = node.nextSibling();
02990 }
02991 setHighlightColors( KDGanttViewItem::Event,
02992 startColor,
02993 middleColor, endColor, false );
02994 } else if( tagName == "Task" ) {
02995 TQColor startColor, middleColor, endColor;
02996 TQDomNode node = element.firstChild();
02997 while( !node.isNull() ) {
02998 TQDomElement element = node.toElement();
02999 if( !element.isNull() ) {
03000 TQString tagName = element.tagName();
03001 if( tagName == "Start" ) {
03002 TQColor value;
03003 if( KDGanttXML::readColorNode( element, value ) )
03004 startColor = value;
03005 } else if( tagName == "Middle" ) {
03006 TQColor value;
03007 if( KDGanttXML::readColorNode( element, value ) )
03008 middleColor = value;
03009 } else if( tagName == "End" ) {
03010 TQColor value;
03011 if( KDGanttXML::readColorNode( element, value ) )
03012 endColor = value;
03013 } else {
03014 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03015 Q_ASSERT( false );
03016 }
03017 }
03018 node = node.nextSibling();
03019 }
03020 setHighlightColors( KDGanttViewItem::Task,
03021 startColor,
03022 middleColor, endColor , false);
03023 } else if( tagName == "Summary" ) {
03024 TQColor startColor, middleColor, endColor;
03025 TQDomNode node = element.firstChild();
03026 while( !node.isNull() ) {
03027 TQDomElement element = node.toElement();
03028 if( !element.isNull() ) {
03029 TQString tagName = element.tagName();
03030 if( tagName == "Start" ) {
03031 TQColor value;
03032 if( KDGanttXML::readColorNode( element, value ) )
03033 startColor = value;
03034 } else if( tagName == "Middle" ) {
03035 TQColor value;
03036 if( KDGanttXML::readColorNode( element, value ) )
03037 middleColor = value;
03038 } else if( tagName == "End" ) {
03039 TQColor value;
03040 if( KDGanttXML::readColorNode( element, value ) )
03041 endColor = value;
03042 } else {
03043 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03044 Q_ASSERT( false );
03045 }
03046 }
03047 node = node.nextSibling();
03048 }
03049 setHighlightColors( KDGanttViewItem::Summary,
03050 startColor,
03051 middleColor, endColor, false );
03052 } else {
03053 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03054 Q_ASSERT( false );
03055 }
03056 }
03057 node = node.nextSibling();
03058 }
03059 } else if( tagName == "DefaultHighlightColors" ) {
03060 TQDomNode node = element.firstChild();
03061 while( !node.isNull() ) {
03062 TQDomElement element = node.toElement();
03063 if( !element.isNull() ) {
03064 TQString tagName = element.tagName();
03065 if( tagName == "Event" ) {
03066 TQColor value;
03067 if( KDGanttXML::readColorNode( element, value ) )
03068 setDefaultHighlightColor( KDGanttViewItem::Event,
03069 value , false);
03070 } else if( tagName == "Task" ) {
03071 TQColor value;
03072 if( KDGanttXML::readColorNode( element, value ) )
03073 setDefaultHighlightColor( KDGanttViewItem::Task,
03074 value, false );
03075 } else if( tagName == "Summary" ) {
03076 TQColor value;
03077 if( KDGanttXML::readColorNode( element, value ) )
03078 setDefaultHighlightColor( KDGanttViewItem::Summary,
03079 value, false );
03080 } else {
03081 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03082 Q_ASSERT( false );
03083 }
03084 }
03085
03086 node = node.nextSibling();
03087 }
03088 } else if( tagName == "Items" ) {
03089 TQDomNode node = element.firstChild();
03090 KDGanttViewItem* previous = 0;
03091 while( !node.isNull() ) {
03092 TQDomElement element = node.toElement();
03093 if( !element.isNull() ) {
03094 TQString tagName = element.tagName();
03095 if( tagName == "Item" ) {
03096 KDGanttViewItem* newItem;
03097 if( previous )
03098 newItem =
03099 KDGanttViewItem::createFromDomElement( this,
03100 previous,
03101 element );
03102 else
03103 newItem =
03104 KDGanttViewItem::createFromDomElement( this,
03105 element );
03106 previous = newItem;
03107 } else {
03108 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03109 Q_ASSERT( false );
03110 }
03111 }
03112
03113 node = node.nextSibling();
03114 }
03115 } else if( tagName == "TaskLinks" ) {
03116 TQDomNode node = element.firstChild();
03117 while( !node.isNull() ) {
03118 TQDomElement element = node.toElement();
03119 if( !element.isNull() ) {
03120 TQString tagName = element.tagName();
03121 if( tagName == "TaskLink" )
03122 KDGanttViewTaskLink::createFromDomElement( element );
03123 else {
03124 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03125 Q_ASSERT( false );
03126 }
03127 }
03128
03129 node = node.nextSibling();
03130 }
03131 } else if( tagName == "TaskLinkGroups" ) {
03132 TQDomNode node = element.firstChild();
03133 while( !node.isNull() ) {
03134 TQDomElement element = node.toElement();
03135 if( !element.isNull() ) {
03136 TQString tagName = element.tagName();
03137 if( tagName == "TaskLink" )
03138 KDGanttViewTaskLinkGroup::createFromDomElement( element );
03139 } else {
03140 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03141 Q_ASSERT( false );
03142 }
03143
03144 node = node.nextSibling();
03145 }
03146 } else if( tagName == "ColumnBackgroundColors" ) {
03147 TQDomNode node = element.firstChild();
03148 while( !node.isNull() ) {
03149 TQDomElement element = node.toElement();
03150 if( !element.isNull() ) {
03151 TQString tagName = element.tagName();
03152 if( tagName == "ColumnBackgroundColor" ) {
03153 TQDomNode node = element.firstChild();
03154 TQDateTime dateTime;
03155 TQColor color;
03156 while( !node.isNull() ) {
03157 TQDomElement element = node.toElement();
03158 if( !element.isNull() ) {
03159
03160
03161 TQString tagName = element.tagName();
03162 if( tagName == "DateTime" ) {
03163 TQDateTime value;
03164 if( KDGanttXML::readDateTimeNode( element, value ) )
03165 dateTime = value;
03166 } else if( tagName == "Color" ) {
03167 TQColor value;
03168 if( KDGanttXML::readColorNode( element, value ) )
03169 color = value;
03170 } else {
03171 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03172 Q_ASSERT( false );
03173 }
03174 }
03175
03176 node = node.nextSibling();
03177 }
03178 setColumnBackgroundColor( dateTime, color );
03179 } else {
03180 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03181 Q_ASSERT( false );
03182 }
03183 }
03184 node = node.nextSibling();
03185 }
03186 } else if( tagName == "LegendItems" ) {
03187 clearLegend();
03188 TQDomNode node = element.firstChild();
03189 while( !node.isNull() ) {
03190 TQDomElement element = node.toElement();
03191 if( !element.isNull() ) {
03192 TQString tagName = element.tagName();
03193 if( tagName == "LegendItem" ) {
03194 KDGanttViewItem::Shape tempLegendShape;
03195 tempLegendShape = KDGanttViewItem::TriangleDown;
03196 TQColor tempLegendColor;
03197 TQString tempLegendString;
03198 bool ok = true;
03199 TQDomNode node = element.firstChild();
03200 while( !node.isNull() ) {
03201 TQDomElement element = node.toElement();
03202 if( !element.isNull() ) {
03203 TQString tagName = element.tagName();
03204 if( tagName == "Shape" ) {
03205 TQString value;
03206 if( KDGanttXML::readStringNode( element, value ) )
03207 tempLegendShape = KDGanttViewItem::stringToShape( value );
03208 else
03209 ok = false;
03210 } else if( tagName == "Color" ) {
03211 TQColor value;
03212 if( KDGanttXML::readColorNode( element, value ) )
03213 tempLegendColor = value;
03214 else
03215 ok = false;
03216 } else if( tagName == "Text" ) {
03217 TQString value;
03218 if( KDGanttXML::readStringNode( element, value ) )
03219 tempLegendString = value;
03220 else
03221 ok = false;
03222 } else {
03223 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03224 Q_ASSERT( false );
03225 }
03226 }
03227 node = node.nextSibling();
03228 }
03229 if( ok ) {
03230 addLegendItem( tempLegendShape,
03231 tempLegendColor,
03232 tempLegendString );
03233 tqDebug( "Adding legend item %s", tempLegendString.latin1() );
03234 }
03235 } else {
03236 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03237 Q_ASSERT( false );
03238 }
03239 }
03240 node = node.nextSibling();
03241 }
03242 } else {
03243 tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
03244 Q_ASSERT( false );
03245 }
03246 }
03247
03248 node = node.nextSibling();
03249 }
03250 return true;
03251 }
03252
03253
03262 TQDomDocument KDGanttView::saveXML( bool withPI ) const
03263 {
03264
03265 TQString docstart = "<GanttView/>";
03266
03267 TQDomDocument doc( "GanttView" );
03268 doc.setContent( docstart );
03269 if( withPI ) {
03270 TQDomProcessingInstruction pin = doc.createProcessingInstruction( "kdgantt", "version=\"1.0\" encoding=\"UTF-8\"" ) ;
03271 doc.appendChild ( pin );
03272 }
03273
03274 TQDomElement docRoot = doc.documentElement();
03275 docRoot.setAttribute( "xmlns", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
03276 docRoot.setAttribute( "xmlns:xsi", "http://www.w3.org/2000/10/XMLSchema-instance" );
03277 docRoot.setAttribute( "xsi:schemaLocation", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
03278
03279
03280 KDGanttXML::createBoolNode( doc, docRoot, "ShowLegend", showLegend() );
03281
03282
03283 KDGanttXML::createBoolNode( doc, docRoot, "ShowLegendButton",
03284 showLegendButton() );
03285
03286
03287 KDGanttXML::createBoolNode( doc, docRoot, "LegendIsDockWindow",
03288 legendIsDoctwindow() );
03289
03290
03291 KDGanttXML::createBoolNode( doc, docRoot, "ShowListView", showListView() );
03292
03293
03294 KDGanttXML::createBoolNode( doc, docRoot, "ShowHeader", headerVisible() );
03295
03296
03297 KDGanttXML::createBoolNode( doc, docRoot, "ShowTaskLinks", showTaskLinks() );
03298
03299
03300 KDGanttXML::createBoolNode( doc, docRoot, "EditorEnabled", editorEnabled() );
03301
03302
03303 KDGanttXML::createFontNode( doc, docRoot, "GlobalFont", font() );
03304
03305
03306 KDGanttXML::createBoolNode( doc, docRoot, "DisplayEmptyTasksAsLine",
03307 displayEmptyTasksAsLine() );
03308
03309
03310 KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonStart", horizonStart() );
03311
03312
03313 KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonEnd", horizonEnd() );
03314
03315
03316 KDGanttXML::createStringNode( doc, docRoot, "Scale", scaleToString( scale() ) );
03317 KDGanttXML::createStringNode( doc, docRoot, "MinimumScale",
03318 scaleToString( minimumScale() ) );
03319 KDGanttXML::createStringNode( doc, docRoot, "MaximumScale",
03320 scaleToString( maximumScale() ) );
03321
03322
03323 KDGanttXML::createStringNode( doc, docRoot, "YearFormat",
03324 yearFormatToString( yearFormat() ) );
03325
03326
03327 KDGanttXML::createStringNode( doc, docRoot, "HourFormat",
03328 hourFormatToString( hourFormat() ) );
03329
03330
03331 KDGanttXML::createBoolNode( doc, docRoot, "ShowMinorTicks", showMinorTicks() );
03332
03333
03334 KDGanttXML::createBoolNode( doc, docRoot, "ShowMajorTicks", showMajorTicks() );
03335
03336
03337 KDGanttXML::createBoolNode( doc, docRoot, "Editable", editable() );
03338
03339
03340 KDGanttXML::createColorNode( doc, docRoot, "TextColor", textColor() );
03341
03342
03343 KDGanttXML::createIntNode( doc, docRoot, "MajorScaleCount", majorScaleCount() );
03344
03345
03346 KDGanttXML::createIntNode( doc, docRoot, "MinorScaleCount", minorScaleCount() );
03347
03348
03349 KDGanttXML::createIntNode( doc, docRoot, "AutoScaleMinorTickCount",
03350 autoScaleMinorTickCount() );
03351
03352
03353 KDGanttXML::createIntNode( doc, docRoot, "MinimumColumnWidth",
03354 minimumColumnWidth() );
03355
03356
03357 KDGanttXML::createIntNode( doc, docRoot, "GanttMaximumWidth",
03358 ganttMaximumWidth() );
03359
03360
03361 KDGanttXML::createBrushNode( doc, docRoot, "NoInformationBrush",
03362 noInformationBrush() );
03363
03364
03365 KDGanttXML::createColorNode( doc, docRoot, "GanttViewBackgroundColor",
03366 gvBackgroundColor() );
03367
03368
03369 KDGanttXML::createColorNode( doc, docRoot, "ListViewBackgroundColor",
03370 lvBackgroundColor() );
03371
03372
03373 KDGanttXML::createColorNode( doc, docRoot, "TimeHeaderBackgroundColor",
03374 timeHeaderBackgroundColor() );
03375
03376
03377 KDGanttXML::createColorNode( doc, docRoot, "LegendHeaderBackgroundColor",
03378 legendHeaderBackgroundColor() );
03379
03380
03381 KDGanttXML::createColorNode( doc, docRoot, "WeekendBackgroundColor",
03382 weekendBackgroundColor() );
03383
03384
03385 for( int weekday = 1; weekday <= 7; weekday++ ) {
03386 TQColor color = weekdayBackgroundColor( weekday );
03387 if( color.isValid() ) {
03388 TQDomElement weekendBackgroundColorElement = doc.createElement( "WeekdayBackgroundColor" );
03389 docRoot.appendChild( weekendBackgroundColorElement );
03390 KDGanttXML::createIntNode( doc, weekendBackgroundColorElement,
03391 "Day", weekday );
03392 KDGanttXML::createColorNode( doc, weekendBackgroundColorElement,
03393 "Color", color );
03394 }
03395 }
03396
03397
03398 TQDomElement weekendDaysElement = doc.createElement( "WeekendDays" );
03399 docRoot.appendChild( weekendDaysElement );
03400 int weekendStart, weekendEnd;
03401 weekendDays( weekendStart, weekendEnd );
03402 weekendDaysElement.setAttribute( "Start", weekendStart );
03403 weekendDaysElement.setAttribute( "End", weekendStart );
03404
03405
03406 KDGanttXML::createDoubleNode( doc, docRoot, "ZoomFactor",
03407 zoomFactor() );
03408
03409
03410 KDGanttXML::createBoolNode( doc, docRoot, "ShowHeaderPopupMenu",
03411 showHeaderPopupMenu() );
03412
03413
03414 KDGanttXML::createBoolNode( doc, docRoot, "ShowTimeTablePopupMenu",
03415 showTimeTablePopupMenu() );
03416
03417
03418 TQDomElement shapesElement = doc.createElement( "Shapes" );
03419 docRoot.appendChild( shapesElement );
03420 TQDomElement shapesEventElement = doc.createElement( "Event" );
03421 shapesElement.appendChild( shapesEventElement );
03422 KDGanttViewItem::Shape start, middle, end;
03423 if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
03424 KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
03425 KDGanttViewItem::shapeToString( start ) );
03426 KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
03427 KDGanttViewItem::shapeToString( middle ) );
03428 KDGanttXML::createStringNode( doc, shapesEventElement, "End",
03429 KDGanttViewItem::shapeToString( end ) );
03430 } else {
03431 KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
03432 "Undefined" );
03433 KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
03434 "Undefined" );
03435 KDGanttXML::createStringNode( doc, shapesEventElement, "End",
03436 "Undefined" );
03437 }
03438 TQDomElement shapesTaskElement = doc.createElement( "Task" );
03439 shapesElement.appendChild( shapesTaskElement );
03440 if( shapes( KDGanttViewItem::Task, start, middle, end ) ) {
03441 KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
03442 KDGanttViewItem::shapeToString( start ) );
03443 KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
03444 KDGanttViewItem::shapeToString( middle ) );
03445 KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
03446 KDGanttViewItem::shapeToString( end ) );
03447 } else {
03448 KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
03449 "Undefined" );
03450 KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
03451 "Undefined" );
03452 KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
03453 "Undefined" );
03454 }
03455 TQDomElement shapesSummaryElement = doc.createElement( "Summary" );
03456 shapesElement.appendChild( shapesSummaryElement );
03457 if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
03458 KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
03459 KDGanttViewItem::shapeToString( start ) );
03460 KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
03461 KDGanttViewItem::shapeToString( middle ) );
03462 KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
03463 KDGanttViewItem::shapeToString( end ) );
03464 } else {
03465 KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
03466 "Undefined" );
03467 KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
03468 "Undefined" );
03469 KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
03470 "Undefined" );
03471 }
03472
03473
03474 TQDomElement colorsElement = doc.createElement( "Colors" );
03475 docRoot.appendChild( colorsElement );
03476 TQDomElement colorsEventElement = doc.createElement( "Event" );
03477 colorsElement.appendChild( colorsEventElement );
03478 TQColor startColor, middleColor, endColor;
03479 colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03480 KDGanttXML::createColorNode( doc, colorsEventElement, "Start", startColor );
03481 KDGanttXML::createColorNode( doc, colorsEventElement, "Middle", middleColor );
03482 KDGanttXML::createColorNode( doc, colorsEventElement, "End", endColor );
03483 TQDomElement colorsTaskElement = doc.createElement( "Task" );
03484 colorsElement.appendChild( colorsTaskElement );
03485 colors( KDGanttViewItem::Task, startColor, middleColor, endColor );
03486 KDGanttXML::createColorNode( doc, colorsTaskElement, "Start", startColor );
03487 KDGanttXML::createColorNode( doc, colorsTaskElement, "Middle", middleColor );
03488 KDGanttXML::createColorNode( doc, colorsTaskElement, "End", endColor );
03489 TQDomElement colorsSummaryElement = doc.createElement( "Summary" );
03490 colorsElement.appendChild( colorsSummaryElement );
03491 colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03492 KDGanttXML::createColorNode( doc, colorsSummaryElement, "Start", startColor );
03493 KDGanttXML::createColorNode( doc, colorsSummaryElement, "Middle", middleColor );
03494 KDGanttXML::createColorNode( doc, colorsSummaryElement, "End", endColor );
03495
03496
03497 TQDomElement defaultColorsElement = doc.createElement( "DefaultColors" );
03498 docRoot.appendChild( defaultColorsElement );
03499 KDGanttXML::createColorNode( doc, defaultColorsElement, "Event",
03500 defaultColor( KDGanttViewItem::Event ) );
03501 KDGanttXML::createColorNode( doc, defaultColorsElement, "Task",
03502 defaultColor( KDGanttViewItem::Task ) );
03503 KDGanttXML::createColorNode( doc, defaultColorsElement, "Summary",
03504 defaultColor( KDGanttViewItem::Summary ) );
03505
03506
03507
03508 TQDomElement highlightColorsElement = doc.createElement( "HighlightColors" );
03509 docRoot.appendChild( highlightColorsElement );
03510 TQDomElement highlightColorsEventElement = doc.createElement( "Event" );
03511 highlightColorsElement.appendChild( highlightColorsEventElement );
03512 highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03513 KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Start", startColor );
03514 KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Middle", middleColor );
03515 KDGanttXML::createColorNode( doc, highlightColorsEventElement, "End", endColor );
03516 TQDomElement highlightColorsTaskElement = doc.createElement( "Task" );
03517 highlightColorsElement.appendChild( highlightColorsTaskElement );
03518 highlightColors( KDGanttViewItem::Task, startColor, middleColor, endColor );
03519 KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Start", startColor );
03520 KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Middle", middleColor );
03521 KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "End", endColor );
03522 TQDomElement highlightColorsSummaryElement = doc.createElement( "Summary" );
03523 highlightColorsElement.appendChild( highlightColorsSummaryElement );
03524 highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03525 KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
03526 KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
03527 KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );
03528
03529
03530
03531
03532
03533
03534
03535
03536
03537
03538
03539
03540
03541
03542 TQDomElement defaultHighlightColorsElement = doc.createElement( "DefaultHighlightColors" );
03543 docRoot.appendChild( defaultHighlightColorsElement );
03544 KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Event",
03545 defaultHighlightColor( KDGanttViewItem::Event ) );
03546 KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Task",
03547 defaultHighlightColor( KDGanttViewItem::Task ) );
03548 KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Summary",
03549 defaultHighlightColor( KDGanttViewItem::Summary ) );
03550
03551
03552
03553 TQDomElement itemsElement = doc.createElement( "Items" );
03554 docRoot.appendChild( itemsElement );
03555 KDGanttViewItem* currentItem = firstChild();
03556 while( currentItem ) {
03557 currentItem->createNode( doc, itemsElement );
03558 currentItem = currentItem->nextSibling();
03559 }
03560
03561
03562 TQDomElement taskLinksElement = doc.createElement( "TaskLinks" );
03563 docRoot.appendChild( taskLinksElement );
03564 TQPtrList<KDGanttViewTaskLink> taskLinkList = taskLinks();
03565 KDGanttViewTaskLink* currentTL = 0;
03566 for( currentTL = taskLinkList.first(); currentTL;
03567 currentTL = taskLinkList.next() )
03568 currentTL->createNode( doc, taskLinksElement );
03569
03570
03571 TQDomElement taskLinkGroupsElement = doc.createElement( "TaskLinkGroups" );
03572 docRoot.appendChild( taskLinkGroupsElement );
03573 TQPtrList<KDGanttViewTaskLinkGroup> taskLinkGroupList = taskLinkGroups();
03574 KDGanttViewTaskLinkGroup* currentTLG = 0;
03575 for( currentTLG = taskLinkGroupList.first(); currentTLG;
03576 currentTLG = taskLinkGroupList.next() )
03577 currentTLG->createNode( doc, taskLinkGroupsElement );
03578
03579
03580 TQDomElement columnBackgroundColorsElement =
03581 doc.createElement( "ColumnBackgroundColors" );
03582 docRoot.appendChild( columnBackgroundColorsElement );
03583 KDTimeHeaderWidget::ColumnColorList ccList =
03584 myTimeHeader->columnBackgroundColorList();
03585 for( KDTimeHeaderWidget::ColumnColorList::iterator it = ccList.begin();
03586 it != ccList.end(); ++it ) {
03587 TQDomElement columnBackgroundColorElement =
03588 doc.createElement( "ColumnBackgroundColor" );
03589 columnBackgroundColorsElement.appendChild( columnBackgroundColorElement );
03590 KDGanttXML::createDateTimeNode( doc, columnBackgroundColorElement,
03591 "DateTime", (*it).datetime );
03592 KDGanttXML::createColorNode( doc, columnBackgroundColorElement,
03593 "Color", (*it).color );
03594 }
03595
03596
03597 TQDomElement legendItemsElement =
03598 doc.createElement( "LegendItems" );
03599 docRoot.appendChild( legendItemsElement );
03600 legendItem* current;
03601 TQPtrListIterator<legendItem> lit( *myLegendItems );
03602 while( ( current = lit.current() ) ) {
03603 ++lit;
03604 TQDomElement legendItemElement = doc.createElement( "LegendItem" );
03605 legendItemsElement.appendChild( legendItemElement );
03606 KDGanttXML::createStringNode( doc, legendItemElement, "Shape",
03607 KDGanttViewItem::shapeToString( current->shape ) );
03608 KDGanttXML::createColorNode( doc, legendItemElement, "Color",
03609 current->color );
03610 KDGanttXML::createStringNode( doc, legendItemElement, "Text",
03611 current->text );
03612 }
03613
03614
03615 KDGanttXML::createBoolNode( doc, docRoot, "DragEnabled", isDragEnabled() );
03616
03617
03618 KDGanttXML::createBoolNode( doc, docRoot, "DropEnabled", isDropEnabled() );
03619
03620
03621 KDGanttXML::createBoolNode( doc, docRoot, "CalendarMode", calendarMode() );
03622
03623 return doc;
03624 }
03625
03626
03627
03628 TQString KDGanttView::scaleToString( Scale scale )
03629 {
03630 switch( scale ) {
03631 case Minute:
03632 return "Minute";
03633 case Hour:
03634 return "Hour";
03635 case Day:
03636 return "Day";
03637 case Week:
03638 return "Week";
03639 case Month:
03640 return "Month";
03641 case Auto:
03642 return "Auto";
03643 }
03644 return "";
03645 }
03646
03647
03648 KDGanttView::Scale KDGanttView::stringToScale( const TQString& string )
03649 {
03650 if( string == "Minute" )
03651 return Minute;
03652 else if( string == "Hour" )
03653 return Hour;
03654 else if( string == "Day" )
03655 return Day;
03656 else if( string == "Week" )
03657 return Week;
03658 else if( string == "Month" )
03659 return Month;
03660 else if( string == "Auto" )
03661 return Auto;
03662
03663 return Auto;
03664 }
03665
03666
03667 TQString KDGanttView::yearFormatToString( YearFormat format )
03668 {
03669 switch( format ) {
03670 case FourDigit:
03671 return "FourDigit";
03672 case TwoDigit:
03673 return "TwoDigit";
03674 case TwoDigitApostrophe:
03675 return "TwoDigitApostrophe";
03676 case NoDate:
03677 return "NoDate";
03678 }
03679 return "";
03680 }
03681
03682
03683 KDGanttView::YearFormat KDGanttView::stringToYearFormat( const TQString& string )
03684 {
03685 if( string == "FourDigit" )
03686 return FourDigit;
03687 else if( string == "TwoDigit" )
03688 return TwoDigit;
03689 else if( string == "TwoDigitApostrophe" )
03690 return TwoDigitApostrophe;
03691 else if( string == "NoDate" )
03692 return NoDate;
03693 else
03694 return FourDigit;
03695 }
03696
03697
03698 TQString KDGanttView::hourFormatToString( HourFormat format )
03699 {
03700 switch( format ) {
03701 case Hour_12:
03702 return "Hour_12";
03703 case Hour_24:
03704 return "Hour_24";
03705 case Hour_24_FourDigit:
03706 return "Hour_24_FourDigit";
03707 }
03708 return "";
03709 }
03710
03711
03712 KDGanttView::HourFormat KDGanttView::stringToHourFormat( const TQString& string )
03713 {
03714 if( string == "Hour_12" )
03715 return Hour_12;
03716 else if( string == "Hour_24" )
03717 return Hour_24;
03718 else
03719 return Hour_24;
03720 }
03721
03722
03723 void KDGanttView::addTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
03724 {
03725
03726 if (myTaskLinkGroupList.isEmpty()) {
03727 myTaskLinkGroupList.append(group);
03728 return;
03729 }
03730 if (myTaskLinkGroupList.find(group) == -1)
03731 myTaskLinkGroupList.append(group);
03732 }
03733
03734
03735 void KDGanttView::removeTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
03736 {
03737 myTaskLinkGroupList.remove(group);
03738 }
03739
03740
03746 void KDGanttView::editItem( KDGanttViewItem* item)
03747 {
03748 if ( ! item )
03749 return;
03750 if ( editorEnabled() ) {
03751 if ( item->editable() ) {
03752 myItemAttributeDialog->reset( item );
03753 myItemAttributeDialog->show();
03754 }
03755 }
03756 }
03757
03758
03769 TQPixmap KDGanttView::getPixmap( KDGanttViewItem::Shape shape,
03770 const TQColor& shapeColor,
03771 const TQColor& backgroundColor, int itemSize)
03772 {
03773
03774 int size = itemSize+2;
03775 int hei = ( itemSize/3 ) / 2;
03776 TQPixmap p = TQPixmap( size+4, size+4 );
03777 p.fill( backgroundColor );
03778 TQPainter paint (&p);
03779 TQBrush b = TQBrush ( TQt::SolidPattern );
03780 b.setColor( shapeColor );
03781 paint.setBrush( b );
03782 TQPen pen( TQt::black, 1 ) ;
03783 paint.setPen( pen );
03784 switch (shape) {
03785 case KDGanttViewItem::TriangleDown:{
03786 TQPointArray arr = TQPointArray(3);
03787 arr.setPoint(0,-size/2,-hei);
03788 arr.setPoint(1,size/2,-hei);
03789 arr.setPoint(2,0,((size/2)-hei));
03790 arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03791 paint.drawPolygon( arr );
03792 break;
03793 }
03794 case KDGanttViewItem::TriangleUp :{
03795 TQPointArray arr = TQPointArray(3);
03796 arr.setPoint(0,-size/2,hei);
03797 arr.setPoint(1,size/2,hei);
03798 arr.setPoint(2,0,(-size/2)+hei);
03799 arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03800 paint.drawPolygon( arr );
03801 break;
03802 }
03803 case KDGanttViewItem::Diamond :{
03804 TQPointArray arr = TQPointArray(4);
03805 arr.setPoint(0,0,-size/2);
03806 arr.setPoint(1,size/2,0);
03807 arr.setPoint(2,0,size/2);
03808 arr.setPoint(3,-size/2,0);
03809 arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03810 paint.drawPolygon( arr );
03811 break;
03812 }
03813 case KDGanttViewItem::Square :{
03814 TQPointArray arr = TQPointArray(4);
03815 arr.setPoint(0,-size/2,-size/2);
03816 arr.setPoint(1,size/2,-size/2);
03817 arr.setPoint(2,size/2,size/2);
03818 arr.setPoint(3,-size/2,size/2);
03819 arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03820 paint.drawPolygon( arr );
03821 break;
03822 }
03823 case KDGanttViewItem::Circle :{
03824 paint.drawEllipse( 2, 2, size, size);
03825 break;
03826 }
03827 }
03828 paint.end();
03829 return p;
03830 }
03831
03832 int KDGanttView::getIndex( KDGanttViewItem::Type type) const
03833 {
03834 int index = -1;
03835 switch (type) {
03836 case (KDGanttViewItem::Event):
03837 index = 0;
03838 break;
03839 case (KDGanttViewItem::Task):
03840 index = 1;
03841 break;
03842 case (KDGanttViewItem::Summary):
03843 index = 2;
03844 break;
03845 }
03846 return index;
03847 }
03848
03849
03850 void KDGanttView::initDefaults()
03851 {
03852 int i;
03853
03854 for (i = 0;i<3;++i) {
03855 undefinedShape[i] = true;
03856 undefinedColor[i] = true;
03857 undefinedColorHL[i] = true;
03858 }
03859
03860 myDefaultColor [ getIndex( KDGanttViewItem::Event ) ] = TQt::blue;
03861 myDefaultColorHL [ getIndex( KDGanttViewItem::Event ) ] = TQt::red;
03862 myDefaultColor [ getIndex( KDGanttViewItem::Task ) ] = TQt::green;
03863 myDefaultColorHL [ getIndex( KDGanttViewItem::Task ) ] = TQt::red;
03864 myDefaultColor [ getIndex( KDGanttViewItem::Summary ) ] = TQt::cyan;
03865 myDefaultColorHL [ getIndex( KDGanttViewItem::Summary ) ] = TQt::red;
03866
03867
03868
03869 for (i = 0;i<3;++i) {
03870 myDefaultShape [3*getIndex( KDGanttViewItem::Event )+ i] = KDGanttViewItem::Diamond;
03871 myDefaultShape [3*getIndex( KDGanttViewItem::Task ) +i] = KDGanttViewItem::Square;
03872 myDefaultShape [3*getIndex( KDGanttViewItem::Summary ) +i] = KDGanttViewItem::TriangleDown;
03873
03874 }
03875 }
03876
03877
03878
03882 int KDGanttView::addColumn( const TQString& label, int width )
03883 {
03884 return myListView->addColumn( label, width );
03885 }
03886
03887
03892 int KDGanttView::addColumn( const TQIconSet& iconset, const TQString& label,
03893 int width )
03894 {
03895 return myListView->addColumn( iconset, label, width );
03896 }
03897
03898
03902 void KDGanttView::removeColumn( int index )
03903 {
03904 myListView->removeColumn( index );
03905 }
03906
03907
03911 KDGanttViewItem* KDGanttView::selectedItem() const
03912 {
03913 return static_cast<KDGanttViewItem*>( myListView->selectedItem() );
03914 }
03915
03916
03920 void KDGanttView::setSelected( KDGanttViewItem* item, bool selected )
03921 {
03922 myListView->setSelected( item, selected );
03923 }
03924
03925
03938 KDGanttViewItem* KDGanttView::getItemByName( const TQString& name ) const
03939 {
03940 KDGanttViewItem* temp = firstChild(),* ret;
03941 while (temp != 0) {
03942 if ( (ret = temp->getChildByName( name ) ) )
03943 return ret;
03944 temp = temp->nextSibling();
03945 }
03946 return 0;
03947 }
03948
03949
03961 KDGanttViewItem* KDGanttView::getItemByListViewPos( const TQPoint& pos ) const
03962 {
03963 return static_cast<KDGanttViewItem*>( myListView->itemAt(myListView->mapFromGlobal(pos) ));
03964 }
03965
03966
03981 KDGanttViewItem* KDGanttView::getItemByGanttViewPos( const TQPoint& pos ) const
03982 {
03983 KDGanttViewItem* item;
03984 TQPoint local = myCanvasView->mapFromGlobal(pos);
03985
03986 TQCanvasItemList il = myTimeTable->collisions( myCanvasView->viewportToContents( local ));
03987 TQCanvasItemList::Iterator it;
03988 for ( it = il.begin(); it != il.end(); ++it ) {
03989 if ( myCanvasView->getType(*it) == Type_is_KDGanttViewItem) {
03990 item = myCanvasView->getItem(*it);
03991 if ( item->enabled() )
03992 return item;
03993 }
03994 }
03995 return 0;
03996 }
03997
03998
04013 KDGanttViewItem* KDGanttView::getItemAt( const TQPoint& pos, bool global ) const
04014 {
04015
04016
04017
04018
04019
04020
04021
04022
04023
04024 KDGanttViewItem* item;
04025 KDGanttViewItem* retItem = 0;
04026 int y;
04027 if ( global )
04028 y = myCanvasView->mapFromGlobal(pos).y();
04029 else
04030 y = pos.y();
04031 item = firstChild();
04032 while ( item != 0 ) {
04033 int yc = item->itemPos();
04034 if ( yc <= y && y < yc + item->height()) {
04035 retItem = item;
04036 break;
04037 }
04038 item = item->itemBelow();
04039 }
04040 return retItem;
04041
04042 }
04043
04044
04045 void KDGanttView::addTickRight()
04046 {
04047 if ( !mFixedHorizon && _enableAdding && myCanvasView->horizontalScrollBar()->value() == myCanvasView->horizontalScrollBar()->maxValue()) {
04048
04049 myTimeHeader->addTickRight();
04050
04051 myCanvasView->updateHorScrollBar();
04052 setTimelineToEnd();
04053 }
04054 }
04055
04056
04057 void KDGanttView::addTickLeft()
04058 {
04059 if ( !mFixedHorizon && _enableAdding && myCanvasView->horizontalScrollBar()->value() == 0 ) {
04060 myCanvasView->horizontalScrollBar()->blockSignals( true );
04061 myTimeHeader->addTickLeft();
04062 myCanvasView->horizontalScrollBar()->blockSignals( false );
04063 setTimelineToStart();
04064 }
04065 }
04066
04067
04068 void KDGanttView::enableAdding( int val )
04069 {
04070 _enableAdding = ( val == 0 || val == myCanvasView->horizontalScrollBar()->maxValue());
04071 }
04072
04073
04079 int KDGanttView::childCount() const
04080 {
04081 return myListView->childCount();
04082 }
04083
04084
04088 void KDGanttView::clear()
04089 {
04090 bool block = myTimeTable->blockUpdating();
04091 myTimeTable->setBlockUpdating( true );
04092 myListView->clear();
04093 myTimeTable->setBlockUpdating( false );
04094 myTimeTable->updateMyContent();
04095 myTimeTable->setBlockUpdating( block );
04096 }
04097
04098
04102 void KDGanttView::slot_lvDropped(TQDropEvent* e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse )
04103 {
04104 emit dropped( e, droppedItem, itemBelowMouse);
04105 }
04106
04110 TQDragObject * KDGanttView::dragObject ()
04111 {
04112 return myListView->dragObject ();
04113 }
04114
04115
04119 void KDGanttView::startDrag ()
04120 {
04121
04122 }
04123
04124
04128 void KDGanttView::setPaletteBackgroundColor( const TQColor& col)
04129 {
04130 TQWidget::setPaletteBackgroundColor( col );
04131 timeHeaderSpacerWidget->setPaletteBackgroundColor( col );
04132 }
04133
04134
04141 void KDGanttView::setGvBackgroundColor ( const TQColor & c )
04142 {
04143 myTimeTable->setBackgroundColor( c );
04144 }
04145
04146
04153 void KDGanttView::setTimeHeaderBackgroundColor ( const TQColor & c )
04154 {
04155 myTimeHeader->setPaletteBackgroundColor( c );
04156
04157 timeHeaderSpacerWidget->setPaletteBackgroundColor( c );
04158 }
04159
04160
04167 void KDGanttView::setLegendHeaderBackgroundColor ( const TQColor & c )
04168 {
04169 myLegend->setPaletteBackgroundColor( c );
04170 leftWidget->setPaletteBackgroundColor( c );
04171 }
04172
04173
04180 void KDGanttView::setLvBackgroundColor ( const TQColor & c )
04181 {
04182 myListView->viewport()->setPaletteBackgroundColor( c );
04183 }
04184
04185
04192 TQColor KDGanttView::lvBackgroundColor ( )const
04193 {
04194 return myListView->viewport()->paletteBackgroundColor( );
04195 }
04196
04197
04204 TQColor KDGanttView::gvBackgroundColor () const
04205 {
04206 return myTimeTable->backgroundColor( );
04207 }
04208
04209
04216 TQColor KDGanttView::timeHeaderBackgroundColor () const
04217 {
04218 return myTimeHeader->paletteBackgroundColor( );
04219 }
04220
04221
04228 TQColor KDGanttView::legendHeaderBackgroundColor () const
04229 {
04230 return myLegend->paletteBackgroundColor( );
04231 }
04232
04233
04248 void KDGanttView::addUserdefinedLegendHeaderWidget( TQWidget * w )
04249 {
04250 if ( w ) {
04251 w->reparent ( spacerLeft, 0, TQPoint(0,0) );
04252 }
04253 }
04254
04255
04264 void KDGanttView::setDragEnabled( bool b )
04265 {
04266 fDragEnabled = b;
04267 TQListViewItemIterator it( myListView );
04268 for ( ; it.current(); ++it ) {
04269 (( KDGanttViewItem* )it.current())->setDragEnabled(b);
04270 }
04271
04272 }
04273
04274
04283 void KDGanttView::setDropEnabled( bool b )
04284 {
04285 fDropEnabled = b;
04286
04287
04288 TQListViewItemIterator it( myListView );
04289 for ( ; it.current(); ++it ) {
04290 (( KDGanttViewItem* )it.current())->setDropEnabled(b);
04291 }
04292 }
04293
04294
04303 void KDGanttView::setDragDropEnabled( bool b )
04304 {
04305 setDropEnabled( b );
04306 setDragEnabled( b );
04307 }
04308
04309
04316 bool KDGanttView::isDragEnabled() const
04317 {
04318 return fDragEnabled;
04319 }
04320
04321
04328 bool KDGanttView::isDropEnabled() const
04329 {
04330 return fDropEnabled;
04331 }
04332
04333
04337 bool KDGanttView::dragEnabled() const
04338 {
04339 return isDragEnabled();
04340 }
04341
04342
04346 bool KDGanttView::dropEnabled() const
04347 {
04348 return isDropEnabled();
04349 }
04350
04351
04378 bool KDGanttView::lvDropEvent ( TQDropEvent* e,
04379 KDGanttViewItem* droppedItem,
04380 KDGanttViewItem* itemBelowMouse )
04381 {
04382 Q_UNUSED( e );
04383 Q_UNUSED( droppedItem );
04384 Q_UNUSED( itemBelowMouse );
04385
04386
04387
04388
04389
04390
04391
04392
04393
04394
04395
04396
04397
04398
04399
04400
04401
04402
04403
04404
04405
04406
04407
04408
04409
04410
04411
04412
04413
04414
04415
04416
04417
04418
04419
04420
04421
04422 return false;
04423 }
04424
04425
04442 void KDGanttView::lvDragEnterEvent ( TQDragEnterEvent * e)
04443 {
04444
04445
04446
04447
04448 if ( KDGanttViewItemDrag::canDecode(e) ) {
04449 e->accept( true);
04450 return;
04451 }
04452
04453
04454
04455
04456
04457
04458
04459
04460
04461
04462
04463
04464 e->accept( false );
04465 }
04466
04467
04496 bool KDGanttView::lvDragMoveEvent ( TQDragMoveEvent* ,
04497 KDGanttViewItem* ,
04498 KDGanttViewItem* )
04499 {
04500
04501
04502
04503
04504
04505
04506
04507
04508
04509
04510
04511
04512
04513
04514
04515
04516
04517
04518
04519
04520
04521
04522
04523 return false;
04524 }
04525
04526
04536 void KDGanttView::lvStartDrag (KDGanttViewItem* item)
04537 {
04538 TQDragObject* d = new KDGanttViewItemDrag(item, this, "itemdrag" );
04539
04540
04541
04542
04543
04544
04545
04546
04547
04548 if ( d->drag() ) {
04549 delete item;
04550 }
04551 }
04552
04553
04561 void KDGanttView::setListViewWidth( int w )
04562 {
04563 int sw = mySplitter->width();
04564 TQValueList<int> list;
04565 list.append(w);
04566 list.append(sw-w);
04567 mySplitter->setSizes( list );
04568 }
04569
04570
04577 int KDGanttView::listViewWidth( )
04578 {
04579 return leftWidget->width();
04580 }
04581
04582
04592 void KDGanttView::setLvVScrollBarMode( TQScrollView::ScrollBarMode m )
04593 {
04594 myListView->setVScrollBarMode ( m );
04595 }
04596
04597
04607 void KDGanttView::setGvVScrollBarMode( TQScrollView::ScrollBarMode m )
04608 {
04609 if ( m == TQScrollView::Auto )
04610 tqDebug("KDGanttView::setListViewVScrollBarMode: TQScrollView::Auto not supported. Nothing changed. ");
04611 else
04612 {
04613 myCanvasView->setVScrollBarMode ( m );
04614 if ( m == TQScrollView::AlwaysOn )
04615 timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
04616 else
04617 timeHeaderSpacerWidget->setFixedWidth( 0 );
04618 }
04619 }
04620
04621
04622 void KDGanttView::notifyEditdialog( KDGanttViewItem * item)
04623 {
04624 if (myItemAttributeDialog->getItem() == item ) {
04625 myItemAttributeDialog->reset( 0 );
04626 }
04627 }
04628
04636 void KDGanttView::setLinkItemsEnabled(bool on)
04637 {
04638 myCanvasView->linkItemsEnabled = on;
04639 myCanvasView->autoScrollEnabled = true;
04640 }
04641
04647 bool KDGanttView::isLinkItemsEnabled() const
04648 {
04649 return myCanvasView->linkItemsEnabled;
04650 }
04651