kdgantt

KDGanttView.cpp

00001 /* -*- Mode: C++ -*-
00002    $Id: KDGanttView.cpp 523435 2006-03-28 08:01:15Z mlaurent $
00003    KDGantt - a multi-platform charting engine
00004 */
00005 
00006 /****************************************************************************
00007  ** Copyright (C)  2002-2004 Klarälvdalens Datakonsult AB.  All rights reserved.
00008  **
00009  ** This file is part of the KDGantt library.
00010  **
00011  ** This file may be distributed and/or modified under the terms of the
00012  ** GNU General Public License version 2 as published by the Free Software
00013  ** Foundation and appearing in the file LICENSE.GPL included in the
00014  ** packaging of this file.
00015  **
00016  ** Licensees holding valid commercial KDGantt licenses may use this file in
00017  ** accordance with the KDGantt Commercial License Agreement provided with
00018  ** the Software.
00019  **
00020  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00021  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00022  **
00023  ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
00024  **   information about KDGantt Commercial License Agreements.
00025  **
00026  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
00027  ** licensing are not clear to you.
00028  **
00029  ** As a special exception, permission is given to link this program
00030  ** with any edition of Qt, and distribute the resulting executable,
00031  ** without including the source code for Qt in the source distribution.
00032  **
00033  **********************************************************************/
00034 
00035 
00036 #include "KDGanttView.h"
00037 #include "KDGanttViewSubwidgets.h"
00038 #include "KDGanttMinimizeSplitter.h"
00039 #include "KDGanttViewItem.h"
00040 #include "KDGanttXMLTools.h"
00041 #include "itemAttributeDialog.h"
00042 #include <qprinter.h>
00043 #include <qpainter.h>
00044 #include <qlayout.h>
00045 #include <qpaintdevicemetrics.h>
00046 #include <qfile.h>
00047 #include <qheader.h>
00048 #include <qscrollview.h>
00049 #include <qapplication.h>
00050 #include <qevent.h>
00051 #include <qiconview.h>
00052 
00053 #include <qmessagebox.h>
00054 #include <qfileinfo.h>
00055 
00056 #ifndef KDGANTT_MASTER_CVS
00057 #include "KDGanttView.moc"
00058 #endif
00059 
00060 #if defined KDAB_EVAL
00061 #include "../evaldialog/evaldialog.h"
00062 #endif
00063 
00083 KDGanttView::KDGanttView( QWidget* parent, const char* name  )
00084     : KDGanttMinimizeSplitter( Qt::Vertical, parent, name ),
00085       myCanvasView(0),
00086       myTimeHeaderScroll(0)
00087 {
00088 #if defined KDAB_EVAL
00089     EvalDialog::checkEvalLicense( "KD Gantt" );
00090 #endif
00091   myCurrentItem = 0;
00092     setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
00093     mySplitter = new KDGanttMinimizeSplitter( this );
00094     mySplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
00095     leftWidget = new QVBox( mySplitter );
00096     rightWidget = new QVBox( mySplitter );
00097 
00098     myLegend = new KDLegendWidget( leftWidget, this );
00099     spacerLeft = new QHBox( leftWidget );
00100     myListView = new KDListView(leftWidget, this);
00101     myListView->setVScrollBarMode (QScrollView::AlwaysOff );
00102     connect( myListView, SIGNAL( selectionChanged( QListViewItem* ) ),
00103              this, SLOT( slotSelectionChanged( QListViewItem* ) ) );
00104 
00105     connect( myListView, SIGNAL( mouseButtonClicked ( int, QListViewItem * , const QPoint &, int ) ), this, SLOT( slotmouseButtonClicked ( int , QListViewItem * , const QPoint &, int ) ) );
00106     connect( myListView, SIGNAL( contextMenuRequested ( QListViewItem * , const QPoint &, int  ) ), this, SLOT( slotcontextMenuRequested ( QListViewItem * , const QPoint & , int ) ) );
00107     connect( myListView, SIGNAL(doubleClicked ( QListViewItem *  ) ), this, SLOT(slotdoubleClicked ( QListViewItem * ) ) );
00108 
00109   connect( myListView, SIGNAL(currentChanged( QListViewItem *  ) ), this, SLOT(slotCurrentChanged ( QListViewItem * ) ) );
00110   connect( myListView, SIGNAL(itemRenamed ( QListViewItem * , int , const QString &  ) ), this, SLOT(slotItemRenamed ( QListViewItem *, int , const QString &  ) ) );
00111   connect( myListView, SIGNAL(mouseButtonPressed(  int, QListViewItem * , const QPoint &, int ) ), this, SLOT(slotMouseButtonPressed (  int , QListViewItem * , const QPoint & , int ) ) );
00112 
00113     //connect( myListView, SIGNAL( ), this, SLOT( ) );
00114     myTimeTable = new KDTimeTableWidget (rightWidget,this);
00115 
00116     spacerRight = new QWidget(  rightWidget );
00117 
00118     myTimeHeaderContainer = new QHBox( rightWidget );
00119     myTimeHeaderContainer->setFrameStyle( QFrame::NoFrame  );
00120     myTimeHeaderContainer->setMargin( 0 );
00121     myTimeHeaderScroll = new QScrollView ( myTimeHeaderContainer );
00122     myTimeHeaderScroll->setHScrollBarMode( QScrollView::AlwaysOff );
00123     myTimeHeaderScroll->setVScrollBarMode( QScrollView::AlwaysOff );
00124     timeHeaderSpacerWidget = new QWidget( myTimeHeaderContainer );
00125 
00126 
00127     /*
00128     myTimeHeaderScroll = new QScrollView ( rightWidget );
00129     myTimeHeaderScroll->setHScrollBarMode( QScrollView::AlwaysOff );
00130     myTimeHeaderScroll->setVScrollBarMode( QScrollView::AlwaysOn );
00131     */
00132     //myTimeHeader = new KDTimeHeaderWidget (rightWidget,this);
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( QFrame::NoFrame  );
00139     //
00140     myCanvasView->setFrameStyle( QFrame::NoFrame  );
00141     myCanvasView->setMargin( 0 );
00142     //
00143     myTimeHeaderScroll->setMargin( 0 );//myCanvasView->frameWidth() );
00144     setFrameStyle(myListView->frameStyle());
00145     setLineWidth( 2 );
00146     myListView->setFrameStyle( QFrame::NoFrame  );
00147     myListView->setMargin( 0 );
00148     QObject::connect(myListView, SIGNAL (  expanded ( QListViewItem * ) ) , myTimeTable , SLOT( expandItem(QListViewItem * ))) ;
00149     QObject::connect(myListView, SIGNAL (collapsed ( QListViewItem * ) ) , myTimeTable , SLOT(collapseItem(QListViewItem * ))) ;
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 = Qt::black;
00160     myLegendItems = new QPtrList<legendItem>;
00161     //QObject::connect( this, SIGNAL (itemDoubleClicked( KDGanttViewItem* ) ) , this, SLOT( editItem( KDGanttViewItem*  ))) ;
00162     myItemAttributeDialog = new itemAttributeDialog();
00163     setRepaintMode( KDGanttView::Medium );
00164     //setRepaintMode( KDGanttView::Always );
00165     setShowLegendButton( true );
00166     setHeaderVisible( false );
00167 
00168     // now connecting the widgets
00169     connect(myCanvasView->horizontalScrollBar(), SIGNAL (  valueChanged ( int )) ,myTimeHeaderScroll->horizontalScrollBar(), SLOT( setValue ( int))) ;
00170     connect(myCanvasView, SIGNAL (  heightResized( int )) ,myTimeTable, SLOT( checkHeight ( int))) ;
00171     connect(myCanvasView, SIGNAL (  widthResized( int )) ,myTimeHeader, SLOT( checkWidth ( int))) ;
00172 
00173     QObject::connect(myCanvasView->verticalScrollBar(), SIGNAL ( valueChanged ( int ) ) ,myListView->verticalScrollBar(), SLOT( setValue ( int ))) ;
00174     connect(myTimeHeader, SIGNAL ( sizeChanged( int ) ) ,this, SLOT(slotHeaderSizeChanged()  )) ;
00175     connect(myTimeHeader, SIGNAL ( sizeChanged( int ) ) ,myTimeTable, SLOT(resetWidth( int ) )) ;
00176     connect(myListView, SIGNAL ( contentsMoving ( int, int ) ) ,myCanvasView, SLOT(  moveMyContent( int, int ))) ;
00177    connect(myTimeTable, SIGNAL ( heightComputed ( int ) ) ,myCanvasView, SLOT(  setMyContentsHeight( int ))) ;
00178    // the next three are for adding new ticks at left/right
00179     connect( myCanvasView->horizontalScrollBar(), SIGNAL (prevLine () ) ,this, SLOT(addTickLeft()));
00180     connect( myCanvasView->horizontalScrollBar(), SIGNAL (nextLine () ) ,this, SLOT(addTickRight()));
00181     connect( myCanvasView->horizontalScrollBar(), SIGNAL (valueChanged ( int ) ) ,this, SLOT( enableAdding( int )));
00182 
00183    // now initing
00184     fCenterTimeLineAfterShow = false;
00185     fDragEnabled = false;
00186     fDropEnabled = false;
00187     closingBlocked = false;
00188    myTimeHeader->computeTicks();
00189    centerTimelineAfterShow( QDateTime::currentDateTime () );
00190    setDisplayEmptyTasksAsLine( false );
00191    QValueList<int> list;
00192    list.append(240);
00193    list.append(530);
00194    mySplitter->setSizes( list );
00195    myTimeTable->setBlockUpdating();// block updating until this->show() is called
00196 }
00197 
00198 
00199 
00200 KDGanttView::~KDGanttView()
00201 {
00202   setUpdateEnabled(false);
00203   // delete cut item, if there is any
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   QWidget::show();
00291   myCanvasView->setMyContentsHeight( 0 );
00292   if ( fCenterTimeLineAfterShow ) {
00293     fCenterTimeLineAfterShow = false;
00294     centerTimeline (dtCenterTimeLineAfterShow);
00295   }
00296 }
00304 bool KDGanttView::close ( bool alsoDelete )
00305 {
00306   //qDebug("close ");
00307   if ( closingBlocked )
00308     return false;
00309   return QWidget::close ( alsoDelete );
00310 }
00311 
00312 
00321 QSize KDGanttView::sizeHint() const
00322 {
00323   bool block = myTimeTable->blockUpdating();
00324   myTimeTable->setBlockUpdating( false );
00325   myTimeTable->updateMyContent();
00326   qApp->processEvents();
00327   int hintHeight = myTimeHeader->height();
00328   int legendHeight = 0;
00329   if ( showLegendButton() )
00330     legendHeight = myLegend->height();
00331   int listViewHeaderHeight = 0;
00332   if ( headerVisible() )
00333     listViewHeaderHeight = myListView->header()->height();
00334   if ( hintHeight < legendHeight+listViewHeaderHeight )
00335     hintHeight = legendHeight + listViewHeaderHeight;
00336   hintHeight += myListView->horizontalScrollBar()->height();
00337   if ( myLegend->isShown() )
00338     hintHeight += myLegend->legendSizeHint().height() +10;
00339   hintHeight += myTimeTable->minimumHeight+myListView->frameWidth()*2+2;
00340   int hintWid = myListView->sizeHint().width();
00341   //hintWid += myTimeHeader->mySizeHint+myCanvasView->verticalScrollBar()->width();
00342   hintWid += myCanvasView->sizeHint().width();
00343   // add 10 for the splitter-bars
00344   // qDebug("sizehint %d %d ",hintWid+10, hintHeight );
00345   myTimeTable->setBlockUpdating( block );
00346   return QSize( hintWid+10, hintHeight );
00347 }
00348 
00349 
00357 void KDGanttView::setShowLegendButton( bool show )
00358 {
00359   _showLegendButton = show;
00360      if ( show )
00361          myLegend->show();
00362     else
00363          myLegend->hide();
00364      slotHeaderSizeChanged();
00365 }
00366 
00367 
00374 bool KDGanttView::showLegendButton() const
00375 {
00376     return _showLegendButton;
00377 }
00378 
00379 
00386 void KDGanttView::setHeaderVisible( bool visible )
00387 {
00388     if( visible )
00389         myListView->header()->show();
00390     else
00391         myListView->header()->hide();
00392     _showHeader = visible;
00393     slotHeaderSizeChanged();
00394 }
00395 
00396 
00402 bool KDGanttView::headerVisible() const
00403 {
00404   return _showHeader;
00405 }
00406 
00407 
00416 QDateTime KDGanttView::getDateTimeForCoordX(int coordX, bool global ) const
00417 {
00418   // default for myTimeHeader->getDateTimeForIndex() is local
00419    return myTimeHeader->getDateTimeForIndex(coordX, !global );
00420 }
00421 
00422 
00426 void KDGanttView::slotSelectionChanged( QListViewItem* item )
00427 {
00428     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00429     Q_ASSERT( gItem );
00430     emit lvSelectionChanged( gItem );
00431 }
00432 
00433 
00434 /*
00435   Implements a casted pass-through of the mouseButtonClicked() signal.
00436   Signals itemLeftClicked() , itemMidClicked() are emitted as well.
00437 */
00438 void KDGanttView::slotmouseButtonClicked ( int button, QListViewItem * item,
00439                                            const QPoint & pos, int c )
00440 {
00441   KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00442   emit lvMouseButtonClicked ( button , gItem,  pos,  c );
00443   if (gItem == 0 && myCurrentItem != 0 ) {
00444     myCurrentItem = 0;
00445     emit lvCurrentChanged( gItem );
00446   }
00447   if (gItem != 0 && myCurrentItem == 0 ) {
00448     myCurrentItem = gItem;
00449     emit lvCurrentChanged( gItem );
00450   }
00451 
00452   // removed - makes no sense!
00453   //emit mouseButtonClicked ( button , gItem,  pos,  c );
00454    {
00455     switch ( button ) {
00456     case  LeftButton:
00457       emit lvItemLeftClicked( gItem );
00458       emit itemLeftClicked( gItem );
00459       break;
00460     case  MidButton:
00461       emit lvItemMidClicked( gItem );
00462       emit itemMidClicked( gItem );
00463       break;
00464     }
00465   }
00466 }
00467 
00468 
00469 /*
00470   Implements a casted pass-through of the contextMenuRequested() signal.
00471   The signal itemRightClicked() is emitted as well;
00472   the position is the global position.
00473 */
00474 void KDGanttView::slotcontextMenuRequested ( QListViewItem * item, const QPoint & pos, int col )
00475 {
00476     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00477     emit lvContextMenuRequested ( gItem,  pos,  col );
00478     emit lvItemRightClicked( gItem );
00479     emit itemRightClicked( gItem );
00480 }
00481 
00482 
00483 /*
00484   Implements a casted pass-through of the doubleClicked() signal.
00485 */
00486 void KDGanttView::slotdoubleClicked ( QListViewItem * item )
00487 {
00488    {
00489     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00490     emit lvItemDoubleClicked( gItem );
00491     emit itemDoubleClicked( gItem );
00492   }
00493 }
00494 
00495 
00496 /*
00497   Implements a casted pass-through of the currentChanged() signal.
00498 */
00499 void KDGanttView::slotCurrentChanged ( QListViewItem * item )
00500 {
00501     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00502     myCurrentItem = gItem;
00503     emit lvCurrentChanged( gItem );
00504 }
00505 
00506 
00507 /*
00508   Implements a casted pass-through of the itemRenamed() signal.
00509 */
00510 void KDGanttView::slotItemRenamed ( QListViewItem * item , int col,
00511                                     const QString & text )
00512 {
00513     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00514     emit lvItemRenamed( gItem,  col, text );
00515 }
00516 
00517 
00518 /*
00519   Implements a casted pass-through of the mouseButtonPressed() signal.
00520 */
00521 void KDGanttView::slotMouseButtonPressed ( int button, QListViewItem * item,
00522                                            const QPoint & pos, int c )
00523 {
00524     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00525     emit lvMouseButtonPressed( button, gItem,  pos,  c  );
00526 }
00527 
00528 
00543 void KDGanttView::setRepaintMode( RepaintMode mode )
00544 {
00545 
00546   QScrollBar  *cvh, *cvv;
00547   cvh = myCanvasView->horizontalScrollBar();
00548   cvv = myCanvasView->verticalScrollBar();
00549   // first disconnect
00550   cvh->disconnect( this );
00551   cvv->disconnect( this );
00552 
00553   switch ( mode ) {
00554   case  No:
00555 
00556     break;
00557   case Medium:
00558     connect( cvv, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00559     connect( cvh, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00560     connect( cvv, SIGNAL (nextLine () ) ,this, SLOT(forceRepaint()));
00561     connect( cvh, SIGNAL (nextLine () ) ,this, SLOT(forceRepaint()));
00562     connect( cvv, SIGNAL (prevLine () ) ,this, SLOT(forceRepaint()));
00563     connect( cvh, SIGNAL (prevLine () ) ,this, SLOT(forceRepaint()));
00564     break;
00565   case Always:
00566     connect( cvv, SIGNAL (valueChanged ( int ) ) ,this, SLOT(forceRepaint( int )));
00567     connect( cvh, SIGNAL (valueChanged ( int ) ) ,this, SLOT(forceRepaint( int )));
00568     connect( cvv, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00569     connect( cvh, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00570     break;
00571   }
00572 }
00573 
00574 
00575 void KDGanttView::forceRepaint( int )
00576 {
00577   if ( myTimeTable->blockUpdating() )
00578     return;
00579   // qDebug("forceRepaint( int ) ");
00580   myTimeTable->setAllChanged();
00581   myTimeTable->update();
00582 }
00583 
00584 
00585 void KDGanttView::slotHeaderSizeChanged()
00586 {
00587   int legendHeight = 0;
00588   if ( showLegendButton() )
00589     legendHeight = 24;
00590   int listViewHeaderHeight = 0;
00591   if ( headerVisible() )
00592     listViewHeaderHeight = myListView->header()->height();
00593   int timeHeaderHeight = myTimeHeader->height()+myTimeHeaderScroll->frameWidth()*2;;
00594   int diffY = timeHeaderHeight-legendHeight-listViewHeaderHeight;
00595   if ( diffY < 0 ) {
00596     spacerLeft->setFixedHeight( 0 );
00597     spacerRight->setFixedHeight(-diffY);
00598   } else {
00599     spacerRight->setFixedHeight( 0 );
00600     spacerLeft->setFixedHeight( diffY );
00601   }
00602   myLegend->setFixedHeight( legendHeight );
00603   myTimeHeaderContainer->setFixedHeight( timeHeaderHeight );
00604 }
00605 
00606 void KDGanttView::setLegendIsDockwindow( bool show )
00613 {
00614   bool isdock = myLegend->asDockwindow();
00615   if ( show != isdock ) {
00616     myLegend->setAsDockwindow(show);
00617     // legend is cleared - reinit legend with list
00618     legendItem* li;
00619     for ( li = myLegendItems->first(); li; li = myLegendItems->next() ) {
00620       myLegend->addLegendItem(li->shape, li->color, li->text );
00621     }
00622   }
00623 }
00624 
00625 bool KDGanttView::legendIsDockwindow() const
00632 {
00633     return myLegend->asDockwindow();
00634 }
00635 
00636 
00649 QDockWindow* KDGanttView::legendDockwindow() const
00650 {
00651   return myLegend->dockwindow();
00652 }
00653 
00654 
00663 void KDGanttView::setShowLegend( bool show )
00664 {
00665     myLegend->showMe(show);
00666 }
00667 
00668 
00677 bool KDGanttView::showLegend() const
00678 {
00679     return myLegend->isShown();
00680 }
00681 
00682 
00691 void KDGanttView::setShowListView( bool show )
00692 {
00693     if(listViewIsVisible == show) return;
00694     listViewIsVisible = show;
00695     if (listViewIsVisible)
00696         myListView->parentWidget()->show();
00697     else
00698         myListView->parentWidget()->hide();
00699 }
00700 
00701 
00708 bool KDGanttView::showListView() const
00709 {
00710     return listViewIsVisible;
00711 }
00712 
00713 
00723 void KDGanttView::setEditorEnabled( bool enable )
00724 {
00725   editorIsEnabled =  enable;
00726 }
00727 
00728 
00737 bool KDGanttView::editorEnabled() const
00738 {
00739     return editorIsEnabled;
00740 }
00741 
00742 
00751 void KDGanttView::setEditable( bool editable )
00752 {
00753   chartIsEditable =  editable;
00754 }
00755 
00756 
00764 bool KDGanttView::editable() const
00765 {
00766     return chartIsEditable;
00767 }
00768 
00769 
00781 bool KDGanttView::saveProject( QIODevice* device )
00782 {
00783     Q_ASSERT( device );
00784 
00785     QDomDocument doc = saveXML();
00786     if( device->isOpen() )
00787         device->close();
00788     if( device->open( IO_WriteOnly ) ) {
00789         QTextStream ts( device );
00790         ts << doc.toString();
00791         return true;
00792     } else
00793         return false;
00794 }
00795 
00796 
00808 bool KDGanttView::loadProject( QIODevice* device )
00809 {
00810     Q_ASSERT( device );
00811 
00812     if( device->isOpen() )
00813         device->close();
00814     if( device->open( IO_ReadOnly ) ) {
00815         QDomDocument doc( "GanttView" );
00816         QString err;
00817         int errline, errcol;
00818         if ( !doc.setContent( device, &err, &errline, &errcol ) ) {
00819           qDebug("KDGantt::Error parsing XML data at line %d. Message is:", errline );
00820           qDebug("%s ", err.latin1());
00821           device->close();
00822           return false;
00823         }
00824         device->close();
00825         return loadXML( doc );
00826     } else
00827         return false;
00828 }
00829 
00830 
00849 void KDGanttView::print( QPrinter* printer ,
00850                          bool printListView, bool printTimeLine,
00851                          bool printLegend )
00852 {
00853   bool deletePrinter = false;
00854   if (! printer ) {
00855     printer = new QPrinter();
00856     deletePrinter = true;
00857     if ( !printer->setup()) {
00858       delete printer;
00859       return;
00860     }
00861   }
00862   // now we have a printer to print on
00863   QPainter p( printer );
00864   // get the paper metrics
00865   QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
00866   float dx, dy;
00867   // get the size of the desired output for scaling.
00868   // here we want to print all: ListView, TimeLine, and Legend
00869   // for this purpose, we call drawContents() with a 0 pointer as painter
00870   QSize size = drawContents( 0, printListView, printTimeLine, printLegend );
00871 
00872   // at the top, we want to print current time/date
00873   QString date = "Printing Time: " + QDateTime::currentDateTime().toString();
00874   int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
00875   p.drawText( 0, 0, date );
00876 
00877   // compute the scale
00878   dx = (float) m.width()  / (float)size.width();
00879   dy  = (float)(m.height() - ( 2 * hei )) / (float)size.height();
00880   float scale;
00881   // scale to fit the width or height of the paper
00882   if ( dx < dy )
00883     scale = dx;
00884   else
00885     scale = dy;
00886   // set the scale
00887   p.scale( scale, scale );
00888   // now printing with y offset:  2 hei
00889   p.translate( 0, 2*hei );
00890   drawContents( &p, printListView, printTimeLine, printLegend );
00891   // the drawContents() has the side effect, that the painter translation is
00892   // after drawContents() set to the bottom of the painted stuff
00893   // for instance a
00894   // p.drawText(0, 0, "printend");
00895   // would be painted directly below the paintout of drawContents()
00896   p.end();
00897   if ( deletePrinter )
00898     delete printer;
00899 }
00900 
00901 
00941 QSize KDGanttView::drawContents( QPainter* p,
00942                       bool drawListView , bool drawTimeLine, bool drawLegend )
00943 {
00944   QSize size;
00945   int lvX, lvY, thX, thY, tlX, tlY, lwX, lwY, allX, allY;
00946   lvX = myListView->contentsWidth();
00947   lvY = myCanvasView->canvas()->height() + 20;
00948   thX = myTimeHeader->width();
00949   thY = myTimeHeader->height();
00950   tlX = myCanvasView->canvas()->width();
00951   tlY = lvY;
00952   lwX = myLegend->legendSize().width();
00953   lwY = myLegend->legendSize().height();
00954   allX = 0;
00955   allY = 0;
00956   if ( drawListView ) {
00957     allX += lvX;
00958     allY += tlY;
00959   }
00960   if ( drawTimeLine ) {
00961     allX += thX;
00962     allY += thY;
00963   }
00964   if ( drawLegend ) {
00965     allY += lwY;
00966     if ( allX < lwX )
00967       allX = lwX ;
00968   }
00969   size = QSize( allX, allY );
00970   int temp = 0;
00971   if ( p ) {
00972     if ( drawListView ) {
00973       if ( drawTimeLine )
00974         temp =  thY;
00975       p->translate( 0, temp );
00976       //HACK: Only draw list headers if we draw timeline, else
00977       // there is no room for it. This will most probably be changed
00978       // with qt4 anyway, so I think we can live with it atm.
00979       myListView->drawToPainter( p, drawTimeLine ); 
00980       p->translate( lvX, -temp);
00981     }
00982     if ( drawTimeLine ) {
00983       p->translate( myCanvasView->frameWidth(), 0);
00984       myTimeHeader->repaintMe( 0, myTimeHeader->width(), p );
00985       p->translate( -myCanvasView->frameWidth(), thY);
00986       myCanvasView->drawToPainter( p );
00987       if ( drawListView )
00988         p->translate( -lvX, tlY);
00989       else
00990         p->translate( 0, tlY);
00991     } else {
00992       if ( drawListView )
00993         p->translate( -lvX, 0 );
00994     }
00995     if ( drawLegend ) {
00996        myLegend->drawToPainter( p );
00997        p->translate( 0, lwY );
00998     }
00999   }
01000   return size;
01001 }
01002 
01016 void KDGanttView::setZoomFactor( double factor, bool absolute )
01017 {
01018     myTimeHeader->zoom(factor,absolute);
01019 }
01020 
01021 
01029 double KDGanttView::zoomFactor() const
01030 {
01031     return myTimeHeader->zoomFactor();
01032 }
01033 
01034 
01043 void KDGanttView::zoomToFit()
01044 {
01045   myTimeHeader->zoomToFit();
01046 }
01047 
01048 
01060 void KDGanttView::zoomToSelection( const QDateTime& start,  const QDateTime&  end )
01061 {
01062 
01063   myTimeHeader->zoomToSelection( start, end);
01064 
01065 }
01066 
01067 
01074 void KDGanttView::ensureVisible( KDGanttViewItem* item )
01075 {
01076     myListView->ensureItemVisible (item);
01077 }
01078 
01079 
01088 void KDGanttView::centerTimeline( const QDateTime& center )
01089 {
01090   myTimeHeader->centerDateTime( center );
01091 }
01092 
01093 
01107 void KDGanttView::centerTimelineAfterShow( const QDateTime& center )
01108 {
01109   myTimeHeader->centerDateTime( center );
01110   if ( ! isVisible() ) {
01111     dtCenterTimeLineAfterShow = center;
01112     fCenterTimeLineAfterShow = true;
01113   }
01114 }
01115 
01120 void KDGanttView::setTimelineToStart()
01121 {
01122   myCanvasView->horizontalScrollBar()->setValue( 0 );
01123 }
01124 
01125 
01129 void KDGanttView::setTimelineToEnd()
01130 {
01131  myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->maxValue());
01132 }
01133 
01134 
01145 void KDGanttView::addTicksLeft( int num )
01146 {
01147   myTimeHeader->addTickLeft( num  );
01148 }
01149 
01150 
01160 void KDGanttView::addTicksRight( int num )
01161 {
01162   myTimeHeader->addTickRight( num );
01163 }
01164 
01165 
01170 void KDGanttView::center( KDGanttViewItem* item )
01171 {
01172     ensureVisible(item);
01173     int x =  myListView->contentsWidth()/2;
01174     int y = myListView->itemPos (item );
01175     myListView->center(x,y);
01176 }
01177 
01178 
01185 void KDGanttView::setShowTaskLinks( bool show )
01186 {
01187     myTimeTable->setShowTaskLinks(show);
01188 
01189 }
01190 
01191 
01198 bool KDGanttView::showTaskLinks() const
01199 {
01200     return  myTimeTable->showTaskLinks();
01201 }
01202 
01203 
01211 void KDGanttView::setFont(const QFont& font)
01212 {
01213     myListView->setFont(font);
01214     myListView->repaint();
01215     myTimeHeader->setFont(font);
01216     myLegend->setFont( font );
01217     QWidget::setFont( font );
01218     setScale(scale());
01219 }
01220 
01221 
01246 void KDGanttView::setShowHeaderPopupMenu( bool show,
01247                                           bool showZoom,
01248                                           bool showScale,
01249                                           bool showTime,
01250                                           bool showYear,
01251                                           bool showGrid,
01252                                           bool showPrint)
01253 {
01254     myTimeHeader->setShowPopupMenu( show,showZoom,showScale,showTime,
01255                                     showYear,showGrid,showPrint );
01256 }
01257 
01258 
01265 bool KDGanttView::showHeaderPopupMenu() const
01266 {
01267     return myTimeHeader->showPopupMenu();
01268 }
01269 //****************************************************
01270 
01271 
01285 void KDGanttView::setShowTimeTablePopupMenu( bool show )
01286 {
01287     myCanvasView->setShowPopupMenu( show );
01288 }
01289 
01290 
01297 bool KDGanttView::showTimeTablePopupMenu() const
01298 {
01299     return myCanvasView->showPopupMenu();
01300 }
01301 
01302 
01320 void KDGanttView::setShapes( KDGanttViewItem::Type type,
01321                              KDGanttViewItem::Shape start,
01322                              KDGanttViewItem::Shape middle,
01323                              KDGanttViewItem::Shape end,
01324                              bool overwriteExisting )
01325 {
01326     if ( overwriteExisting ) {
01327       QListViewItemIterator it(myListView);
01328       for ( ; it.current(); ++it ) {
01329         if ( ((KDGanttViewItem*)it.current())->type() == type)
01330           ((KDGanttViewItem*)it.current())->setShapes(start,middle, end );
01331       }
01332     }
01333     int index = getIndex( type );
01334     myDefaultShape [index*3] = start;
01335     myDefaultShape [index*3+1] = middle;
01336     myDefaultShape [index*3+2] = end;
01337     undefinedShape[index] = false;
01338 }
01339 
01340 
01353 bool KDGanttView::shapes( KDGanttViewItem::Type type,
01354                           KDGanttViewItem::Shape& start,
01355                           KDGanttViewItem::Shape& middle,
01356                           KDGanttViewItem::Shape& end ) const
01357 {
01358     int index = getIndex( type );
01359     start = myDefaultShape [index*3];
01360     middle = myDefaultShape [index*3+1];
01361     end = myDefaultShape [index*3+2];
01362     return !undefinedShape[index];
01363 }
01364 
01365 
01383 void KDGanttView::setColors( KDGanttViewItem::Type type,
01384                              const QColor& start, const QColor& middle,
01385                              const QColor& end,
01386                              bool overwriteExisting )
01387 {
01388     if ( overwriteExisting ) {
01389       QListViewItemIterator it(myListView);
01390       for ( ; it.current(); ++it ) {
01391         if ( ((KDGanttViewItem*)it.current())->type() == type)
01392           ((KDGanttViewItem*)it.current())->setColors(start,middle, end );
01393       }
01394     }
01395     int index = getIndex( type );
01396     myColor [index*3] = start;
01397     myColor [index*3+1] = middle;
01398     myColor [index*3+2] = end;
01399     undefinedColor[index] = false;
01400 }
01401 
01402 
01415 bool KDGanttView::colors( KDGanttViewItem::Type type,
01416                           QColor& start, QColor& middle, QColor& end ) const
01417 {
01418   int index = getIndex( type );
01419   start = myColor [index*3];
01420     middle = myColor [index*3+1];
01421     end = myColor [index*3+2];
01422     return !undefinedColor[index];
01423 }
01424 
01425 
01445 void KDGanttView::setHighlightColors( KDGanttViewItem::Type type,
01446                                       const QColor& start,
01447                                       const QColor& middle,
01448                                       const QColor& end,
01449                                       bool overwriteExisting )
01450 {
01451     if ( overwriteExisting ) {
01452       QListViewItemIterator it(myListView);
01453       for ( ; it.current(); ++it ) {
01454         if ( ((KDGanttViewItem*)it.current())->type() == type)
01455           ((KDGanttViewItem*)it.current())->setHighlightColors(start,middle, end );
01456       }
01457     }
01458     int index = getIndex( type );
01459     myColorHL [index*3] = start;
01460     myColorHL [index*3+1] = middle;
01461     myColorHL [index*3+2] = end;
01462     undefinedColorHL[index] = false;
01463 
01464 }
01465 
01466 
01481 bool KDGanttView::highlightColors( KDGanttViewItem::Type type,
01482                                    QColor& start, QColor& middle,
01483                                    QColor& end ) const
01484 {
01485   int index = getIndex( type );
01486   start = myColorHL [index*3];
01487     middle = myColorHL [index*3+1];
01488     end = myColorHL [index*3+2];
01489     return !undefinedColorHL[index];
01490 }
01491 
01492 
01500 void KDGanttView::setTextColor( const QColor& color )
01501 {
01502     QListViewItemIterator it(myListView);
01503     for ( ; it.current(); ++it ) {
01504         ((KDGanttViewItem*)it.current())->setTextColor(color);
01505     }
01506     myTextColor = color;
01507 }
01508 
01509 
01516 QColor KDGanttView::textColor() const
01517 {
01518     return myTextColor;
01519 }
01520 
01521 
01532 void KDGanttView::setNoInformationBrush( const QBrush& brush )
01533 {
01534   myTimeTable->setNoInformationBrush( brush );
01535 }
01536 
01537 
01544 QBrush KDGanttView::noInformationBrush() const
01545 {
01546   return myTimeTable->noInformationBrush();
01547 }
01548 
01549 
01555 void KDGanttView::clearLegend( )
01556 {
01557     myLegend->clearLegend();
01558     myLegendItems->setAutoDelete( true );
01559     delete myLegendItems;
01560     myLegendItems = new QPtrList<legendItem>;
01561 }
01562 
01563 
01572 void KDGanttView::addLegendItem( KDGanttViewItem::Shape shape,
01573                                  const QColor& shapeColor,
01574                                  const QString& text )
01575 {
01576     myLegend->addLegendItem( shape,shapeColor,text );
01577     legendItem* item = new legendItem;
01578     item->shape = shape;
01579     item->color = shapeColor;
01580     item->text = text;
01581     myLegendItems->append( item );
01582 }
01583 
01584 
01592 void KDGanttView::setHorizonStart( const QDateTime& start )
01593 {
01594     myTimeHeader->setHorizonStart(start);
01595 }
01596 
01597 
01604 QDateTime KDGanttView::horizonStart() const
01605 {
01606     return myTimeHeader->horizonStart();
01607 }
01608 
01609 
01617 void KDGanttView::setHorizonEnd( const QDateTime& end )
01618 {
01619     myTimeHeader->setHorizonEnd(end);
01620 }
01621 
01622 
01630 QDateTime KDGanttView::horizonEnd() const
01631 {
01632     return myTimeHeader->horizonEnd();
01633 }
01634 
01635 
01643 void KDGanttView::setScale( Scale unit )
01644 {
01645     myTimeHeader->setScale( unit );
01646 }
01647 
01648 
01655 KDGanttView::Scale KDGanttView::scale() const
01656 {
01657     return myTimeHeader->scale();
01658 }
01659 
01660 
01667 void KDGanttView::setMaximumScale( Scale unit )
01668 {
01669     myTimeHeader->setMaximumScale( unit );
01670 }
01671 
01672 
01679 KDGanttView::Scale KDGanttView::maximumScale() const
01680 {
01681     return myTimeHeader->maximumScale();
01682 }
01683 
01684 
01691 void KDGanttView::setMinimumScale( Scale unit )
01692 {
01693     myTimeHeader->setMinimumScale( unit );
01694 }
01695 
01696 
01703 KDGanttView::Scale KDGanttView::minimumScale() const
01704 {
01705     return myTimeHeader->minimumScale();
01706 }
01707 
01708 
01718 void KDGanttView::setAutoScaleMinorTickCount( int count )
01719 {
01720   myTimeHeader->setAutoScaleMinorTickCount( count );
01721 }
01722 
01723 
01730 int KDGanttView::autoScaleMinorTickCount() const
01731 {
01732   return myTimeHeader->autoScaleMinorTickCount();
01733 }
01734 
01735 
01744 void KDGanttView::setMinimumColumnWidth( int width )
01745 {
01746     myTimeHeader->setMinimumColumnWidth( width );
01747 }
01748 
01749 
01756 int KDGanttView::minimumColumnWidth() const
01757 {
01758     return myTimeHeader->minimumColumnWidth();
01759 }
01760 
01761 
01769 void KDGanttView::setYearFormat( YearFormat format )
01770 {
01771     myTimeHeader->setYearFormat(format );
01772 }
01773 
01774 
01781 KDGanttView::YearFormat KDGanttView::yearFormat() const
01782 {
01783     return myTimeHeader->yearFormat();
01784 }
01785 
01786 
01795 void KDGanttView::setHourFormat( HourFormat format )
01796 {
01797     myTimeHeader->setHourFormat( format );
01798 }
01799 
01800 
01808 KDGanttView::HourFormat KDGanttView::hourFormat() const
01809 {
01810     return myTimeHeader->hourFormat();
01811 }
01812 
01813 
01824 void KDGanttView::setShowMajorTicks( bool show )
01825 {
01826     myTimeHeader->setShowMajorTicks(show );
01827 }
01828 
01829 
01836 bool KDGanttView::showMajorTicks() const
01837 {
01838     return myTimeHeader->showMajorTicks();
01839 }
01840 
01841 
01854 void KDGanttView::setShowMinorTicks( bool show)
01855 {
01856     myTimeHeader->setShowMinorTicks( show );
01857 }
01858 
01859 
01866 bool KDGanttView::showMinorTicks() const
01867 {
01868     return myTimeHeader->showMinorTicks();
01869 }
01870 
01871 
01889 void KDGanttView::setColumnBackgroundColor( const QDateTime& column,
01890                                             const QColor& color ,
01891                                             Scale mini, Scale maxi )
01892 {
01893   myTimeHeader->setColumnBackgroundColor( column, color,mini,maxi );
01894 }
01895 
01896 
01923 void KDGanttView::setIntervalBackgroundColor( const QDateTime& start,
01924                                               const QDateTime& end,
01925                                               const QColor& color ,
01926                                               Scale mini, Scale maxi )
01927 {
01928   myTimeHeader->setIntervalBackgroundColor( start, end, color,mini,maxi );
01929 }
01930 
01931 
01950 bool KDGanttView::changeBackgroundInterval( const QDateTime& oldstart,
01951                                    const QDateTime& oldend,
01952                                    const QDateTime& newstart,
01953                                    const QDateTime& newend )
01954 {
01955   return myTimeHeader->changeBackgroundInterval( oldstart, oldend,
01956                                                  newstart, newend );
01957 }
01958 
01968 bool KDGanttView::deleteBackgroundInterval( const QDateTime& start,
01969                                             const QDateTime& end)
01970 {
01971   return myTimeHeader->deleteBackgroundInterval( start, end );
01972 }
01973 
01974 
01983 void KDGanttView::clearBackgroundColor()
01984 {
01985   myTimeHeader->clearBackgroundColor();
01986 }
01987 
01988 
01997 QColor KDGanttView::columnBackgroundColor( const QDateTime& column ) const
01998 {
01999     return myTimeHeader->columnBackgroundColor( column ) ;
02000 }
02001 
02002 
02011 void KDGanttView::setWeekendBackgroundColor( const QColor& color )
02012 {
02013     myTimeHeader->setWeekendBackgroundColor( color );
02014 }
02015 
02016 
02023 QColor KDGanttView::weekendBackgroundColor() const
02024 {
02025     return myTimeHeader->weekendBackgroundColor();
02026 }
02027 
02028 
02039 void KDGanttView::setWeekdayBackgroundColor( const QColor& color, int  weekday )
02040 {
02041   myTimeHeader->setWeekdayBackgroundColor( color,  weekday );
02042 }
02043 
02044 
02052 QColor KDGanttView::weekdayBackgroundColor(int weekday) const
02053 {
02054   return myTimeHeader->weekdayBackgroundColor( weekday);
02055 }
02056 
02057 
02058 
02069 void KDGanttView::setWeekendDays( int start, int end )
02070 {
02071     myTimeHeader->setWeekendDays( start,  end );
02072 }
02073 
02074 
02082 void KDGanttView::weekendDays( int& start, int& end ) const
02083 {
02084     myTimeHeader->weekendDays( start,  end );
02085 }
02086 
02087 
02188 void KDGanttView::setMajorScaleCount( int count )
02189 {
02190     myTimeHeader->setMajorScaleCount(count );
02191 }
02192 
02193 
02200 int KDGanttView::majorScaleCount() const
02201 {
02202     return myTimeHeader->majorScaleCount();
02203 }
02204 
02205 
02212 void KDGanttView::setMinorScaleCount( int count )
02213 {
02214     myTimeHeader->setMinorScaleCount(count );
02215 }
02216 
02217 
02224 int KDGanttView::minorScaleCount() const
02225 {
02226     return myTimeHeader->minorScaleCount();
02227 
02228 }
02229 
02230 
02243 void KDGanttView::setDefaultColor( KDGanttViewItem::Type type,
02244                                    const QColor& color,
02245                                    bool overwriteExisting )
02246 {
02247     if ( overwriteExisting ) {
02248       QListViewItemIterator it(myListView);
02249       for ( ; it.current(); ++it ) {
02250         if ( ((KDGanttViewItem*)it.current())->type() == type)
02251           ((KDGanttViewItem*)it.current())->setDefaultColor(color );
02252       }
02253     }
02254     int index = getIndex( type );
02255     myDefaultColor [index] = color;
02256 }
02257 
02258 
02259 
02270 QColor KDGanttView::defaultColor( KDGanttViewItem::Type type ) const
02271 {
02272   int index = getIndex( type );
02273   return myDefaultColor [index];
02274 }
02275 
02276 
02289 void KDGanttView::setDefaultHighlightColor( KDGanttViewItem::Type type,
02290                                             const QColor& color,
02291                                             bool overwriteExisting )
02292 {
02293     if ( overwriteExisting ) {
02294       QListViewItemIterator it(myListView);
02295       for ( ; it.current(); ++it ) {
02296         if ( ((KDGanttViewItem*)it.current())->type() == type)
02297           ((KDGanttViewItem*)it.current())->setDefaultHighlightColor(color );
02298       }
02299     }
02300     int index = getIndex( type );
02301     myDefaultColorHL [index] = color;
02302 }
02303 
02304 
02305 
02316 QColor KDGanttView::defaultHighlightColor( KDGanttViewItem::Type type ) const
02317 {
02318   int index = getIndex( type );
02319   return myDefaultColorHL [index];
02320 }
02321 
02322 
02328 KDGanttViewItem* KDGanttView::firstChild() const
02329 {
02330     return (KDGanttViewItem*)myListView->firstChild();
02331 
02332 }
02350 void KDGanttView::setCalendarMode( bool mode )
02351 {
02352   myListView->setCalendarMode( mode );
02353 }
02354 
02355 
02363 bool  KDGanttView::calendarMode() const
02364 {
02365   return  myListView->calendarMode();
02366 }
02367 
02368 
02369 
02379 void KDGanttView::setDisplaySubitemsAsGroup( bool show )
02380 {
02381  QListViewItemIterator it( myListView );
02382  for ( ; it.current(); ++it ) {
02383    KDGanttViewItem* currentItem = ( KDGanttViewItem* )it.current();
02384    currentItem->setDisplaySubitemsAsGroup( show );
02385  }
02386  _displaySubitemsAsGroup = show;
02387 }
02388 
02389 
02398 bool KDGanttView::displaySubitemsAsGroup() const
02399 {
02400   return _displaySubitemsAsGroup;
02401 }
02402 
02403 
02411 void KDGanttView::setDisplayEmptyTasksAsLine( bool show )
02412 {
02413   _displayEmptyTasksAsLine = show;
02414 }
02415 
02416 
02423 bool KDGanttView::displayEmptyTasksAsLine() const
02424 {
02425   return _displayEmptyTasksAsLine;
02426 }
02427 
02428 
02443 void KDGanttView::setHorBackgroundLines( int count, QBrush brush )
02444 {
02445   myTimeTable->setHorBackgroundLines(  count, brush );
02446 }
02447 
02448 
02458 int KDGanttView::horBackgroundLines( QBrush& brush )
02459 {
02460   return myTimeTable->horBackgroundLines( brush );
02461 }
02462 
02463 
02469 KDGanttViewItem* KDGanttView::lastItem() const
02470 {
02471     return (KDGanttViewItem*)myListView->lastItem ();
02472 }
02473 
02474 
02480 QPtrList<KDGanttViewTaskLink> KDGanttView::taskLinks() const
02481 {
02482 
02483     return myTimeTable->taskLinks();
02484 }
02485 
02486 
02492 QPtrList<KDGanttViewTaskLinkGroup> KDGanttView::taskLinkGroups() const
02493 {
02494     return myTaskLinkGroupList;
02495 }
02496 
02497 
02505 bool KDGanttView::loadXML( const QDomDocument& doc )
02506 {
02507     QDomElement docRoot = doc.documentElement(); // ChartParams element
02508     QDomNode node = docRoot.firstChild();
02509     while( !node.isNull() ) {
02510         QDomElement element = node.toElement();
02511         if( !element.isNull() ) { // was really an element
02512             QString tagName = element.tagName();
02513             if( tagName == "ShowLegend" ) {
02514                 bool value;
02515                 if( KDGanttXML::readBoolNode( element, value ) )
02516                     setShowLegend( value );
02517             } else if( tagName == "ShowLegendButton" ) {
02518                 bool value;
02519                 if( KDGanttXML::readBoolNode( element, value ) )
02520                     setShowLegendButton( value );
02521             } else if( tagName == "LegendIsDockWindow" ) {
02522                 bool value;
02523                 if( KDGanttXML::readBoolNode( element, value ) )
02524                     setLegendIsDockwindow( value );
02525             } else if( tagName == "ShowListView" ) {
02526                 bool value;
02527                 if( KDGanttXML::readBoolNode( element, value ) )
02528                     setShowListView( value );
02529             } else if( tagName == "ShowHeader" ) {
02530               bool value;
02531               if( KDGanttXML::readBoolNode( element, value ) )
02532                 setHeaderVisible( value );
02533             } else if( tagName == "ShowTaskLinks" ) {
02534                 bool value;
02535                 if( KDGanttXML::readBoolNode( element, value ) )
02536                     setShowTaskLinks( value );
02537             } else if( tagName == "EditorEnabled" ) {
02538                 bool value;
02539                 if( KDGanttXML::readBoolNode( element, value ) )
02540                     setEditorEnabled( value );
02541             } else if( tagName == "DisplayEmptyTasksAsLine" ) {
02542               bool value;
02543               if( KDGanttXML::readBoolNode( element, value ) )
02544                 setDisplayEmptyTasksAsLine( value );
02545             } else if( tagName == "GlobalFont" ) {
02546                 QFont font;
02547                 if( KDGanttXML::readFontNode( element, font ) )
02548                     setFont( font );
02549             } else if( tagName == "HorizonStart" ) {
02550                 QDateTime value;
02551                 if( KDGanttXML::readDateTimeNode( element, value ) )
02552                     setHorizonStart( value );
02553             } else if( tagName == "HorizonEnd" ) {
02554                 QDateTime value;
02555                 if( KDGanttXML::readDateTimeNode( element, value ) )
02556                     setHorizonEnd( value );
02557             } else if( tagName == "Scale" ) {
02558                 QString value;
02559                 if( KDGanttXML::readStringNode( element, value ) )
02560                     setScale( stringToScale( value ) );
02561             } else if( tagName == "MinimumScale" ) {
02562                 QString value;
02563                 if( KDGanttXML::readStringNode( element, value ) )
02564                     setMinimumScale( stringToScale( value ) );
02565             } else if( tagName == "MaximumScale" ) {
02566                 QString value;
02567                 if( KDGanttXML::readStringNode( element, value ) )
02568                     setMaximumScale( stringToScale( value ) );
02569             } else if( tagName == "YearFormat" ) {
02570                 QString value;
02571                 if( KDGanttXML::readStringNode( element, value ) )
02572                     setYearFormat( stringToYearFormat( value ) );
02573             } else if( tagName == "HourFormat" ) {
02574                 QString value;
02575                 if( KDGanttXML::readStringNode( element, value ) )
02576                     setHourFormat( stringToHourFormat( value ) );
02577             } else if( tagName == "ShowMinorTicks" ) {
02578                 bool value;
02579                 if( KDGanttXML::readBoolNode( element, value ) )
02580                     setShowMinorTicks( value );
02581             } else if( tagName == "ShowMajorTicks" ) {
02582                 bool value;
02583                 if( KDGanttXML::readBoolNode( element, value ) )
02584                     setShowMajorTicks( value );
02585             } else if( tagName == "DragEnabled" ) {
02586                 bool value;
02587                 if( KDGanttXML::readBoolNode( element, value ) )
02588                     setDragEnabled( value );
02589             } else if( tagName == "DropEnabled" ) {
02590                 bool value;
02591                 if( KDGanttXML::readBoolNode( element, value ) )
02592                     setDropEnabled( value );
02593             } else if( tagName == "CalendarMode" ) {
02594                 bool value;
02595                 if( KDGanttXML::readBoolNode( element, value ) )
02596                     setCalendarMode( value );
02597             } else if( tagName == "Editable" ) {
02598                 bool value;
02599                 if( KDGanttXML::readBoolNode( element, value ) )
02600                     setEditable( value );
02601             } else if( tagName == "TextColor" ) {
02602                 QColor value;
02603                 if( KDGanttXML::readColorNode( element, value ) )
02604                     setTextColor( value );
02605             } else if( tagName == "MajorScaleCount" ) {
02606                 int value;
02607                 if( KDGanttXML::readIntNode( element, value ) )
02608                     setMajorScaleCount( value );
02609             } else if( tagName == "MinorScaleCount" ) {
02610                 int value;
02611                 if( KDGanttXML::readIntNode( element, value ) )
02612                     setMinorScaleCount( value );
02613             } else if( tagName == "AutoScaleMinorTickCount" ) {
02614                 int value;
02615                 if( KDGanttXML::readIntNode( element, value ) )
02616                     setAutoScaleMinorTickCount( value );
02617             } else if( tagName == "MinimumColumnWidth" ) {
02618                 int value;
02619                 if( KDGanttXML::readIntNode( element, value ) )
02620                     setMinimumColumnWidth( value );
02621             } else if( tagName == "GanttMaximumWidth" ) {
02622                 int value;
02623                 if( KDGanttXML::readIntNode( element, value ) )
02624                     setGanttMaximumWidth( value );
02625             } else if( tagName == "NoInformationBrush" ) {
02626               QBrush value;
02627               if( KDGanttXML::readBrushNode( element, value ) )
02628                 setNoInformationBrush( value );
02629             } else if( tagName == "GanttViewBackgroundColor" ) {
02630                 QColor value;
02631                 if( KDGanttXML::readColorNode( element, value ) )
02632                     setGvBackgroundColor( value );
02633             } else if( tagName == "ListViewBackgroundColor" ) {
02634                 QColor value;
02635                 if( KDGanttXML::readColorNode( element, value ) )
02636                     setLvBackgroundColor( value );
02637             } else if( tagName == "TimeHeaderBackgroundColor" ) {
02638                 QColor value;
02639                 if( KDGanttXML::readColorNode( element, value ) )
02640                     setTimeHeaderBackgroundColor( value );
02641             } else if( tagName == "LegendHeaderBackgroundColor" ) {
02642                 QColor value;
02643                 if( KDGanttXML::readColorNode( element, value ) )
02644                     setLegendHeaderBackgroundColor( value );
02645             } else if( tagName == "WeekendBackgroundColor" ) {
02646                 QColor value;
02647                 if( KDGanttXML::readColorNode( element, value ) )
02648                     setWeekendBackgroundColor( value );
02649             } else if( tagName == "WeekdayBackgroundColor" ) {
02650                 QDomNode node = element.firstChild();
02651                 int day = 0;
02652                 QColor color;
02653                 while( !node.isNull() ) {
02654                     QDomElement element = node.toElement();
02655                     if( !element.isNull() ) { // was really an elemente
02656                         QString tagName = element.tagName();
02657                         if( tagName == "Day" ) {
02658                             int value;
02659                             if( KDGanttXML::readIntNode( element, value ) )
02660                                 day = value;
02661                         } else if( tagName == "Color" ) {
02662                             QColor value;
02663                             if( KDGanttXML::readColorNode( element, value ) )
02664                                 color = value;
02665                         } else {
02666                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02667                             Q_ASSERT( false );
02668                         }
02669                     }
02670                     node = node.nextSibling();
02671                 }
02672 
02673                 if( day && color.isValid() )
02674                     setWeekdayBackgroundColor( color, day );
02675             } else if( tagName == "WeekendDays" ) {
02676                 QString startString = element.attribute( "Start" );
02677                 QString endString = element.attribute( "End" );
02678                 bool startOk = false, endOk = false;
02679                 int start = startString.toInt( &startOk );
02680                 int end = startString.toInt( &endOk );
02681                 if( startOk && endOk )
02682                     setWeekendDays( start, end );
02683             } else if( tagName == "ZoomFactor" ) {
02684                 double value;
02685                 if( KDGanttXML::readDoubleNode( element, value ) )
02686                     setZoomFactor( value, true );
02687             } else if( tagName == "ShowHeaderPopupMenu" ) {
02688                 bool value;
02689                 if( KDGanttXML::readBoolNode( element, value ) )
02690                     setShowHeaderPopupMenu( value );
02691             } else if( tagName == "ShowTimeTablePopupMenu" ) {
02692                 bool value;
02693                 if( KDGanttXML::readBoolNode( element, value ) )
02694                     setShowTimeTablePopupMenu( value );
02695             } else if( tagName == "Shapes" ) {
02696                 QDomNode node = element.firstChild();
02697                 bool undefinedShape = false;
02698                 while( !node.isNull() ) {
02699                     QDomElement element = node.toElement();
02700                     if( !element.isNull() ) { // was really an elemente
02701                         QString tagName = element.tagName();
02702                         if( tagName == "Event" ) {
02703                             KDGanttViewItem::Shape startShape, middleShape, endShape;
02704                             startShape = KDGanttViewItem::TriangleDown;
02705                             middleShape = KDGanttViewItem::TriangleDown;
02706                             endShape = KDGanttViewItem::TriangleDown;
02707                             QDomNode node = element.firstChild();
02708                             while( !node.isNull() ) {
02709                                 QDomElement element = node.toElement();
02710                                 if( !element.isNull() ) { // was really an elemente
02711                                     QString tagName = element.tagName();
02712                                     if( tagName == "Start" ) {
02713                                         QString value;
02714                                         if( KDGanttXML::readStringNode( element, value ) )
02715                                             startShape = KDGanttViewItem::stringToShape( value );
02716                                         if ( value == "Undefined" )
02717                                           undefinedShape = true;
02718                                     } else if( tagName == "Middle" ) {
02719                                         QString value;
02720                                         if( KDGanttXML::readStringNode( element, value ) )
02721                                             middleShape = KDGanttViewItem::stringToShape( value );
02722                                         if ( value == "Undefined" )
02723                                           undefinedShape = true;
02724                                     } else if( tagName == "End" ) {
02725                                         QString value;
02726                                         if( KDGanttXML::readStringNode( element, value ) )
02727                                             endShape = KDGanttViewItem::stringToShape( value );
02728                                         if ( value == "Undefined" )
02729                                           undefinedShape = true;
02730                                     } else {
02731                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02732                                         Q_ASSERT( false );
02733                                     }
02734                                 }
02735                                 node = node.nextSibling();
02736                             }
02737                             if ( ! undefinedShape )
02738                               setShapes( KDGanttViewItem::Event, startShape,
02739                                        middleShape, endShape, false );
02740                             undefinedShape = false;
02741                         } else if( tagName == "Task" ) {
02742                             KDGanttViewItem::Shape startShape, middleShape, endShape;
02743                             startShape = KDGanttViewItem::TriangleDown;
02744                             middleShape = KDGanttViewItem::TriangleDown;
02745                             endShape = KDGanttViewItem::TriangleDown;
02746                             QDomNode node = element.firstChild();
02747                             while( !node.isNull()) {
02748                                 QDomElement element = node.toElement();
02749                                 if( !element.isNull() ) { // was really an elemente
02750                                     QString tagName = element.tagName();
02751                                     if( tagName == "Start" ) {
02752                                         QString value;
02753                                         if( KDGanttXML::readStringNode( element, value ) )
02754                                             startShape = KDGanttViewItem::stringToShape( value );
02755                                         if ( value == "Undefined" )
02756                                           undefinedShape = true;
02757                                     } else if( tagName == "Middle" ) {
02758                                         QString value;
02759                                         if( KDGanttXML::readStringNode( element, value ) )
02760                                             middleShape = KDGanttViewItem::stringToShape( value );
02761                                         if ( value == "Undefined" )
02762                                           undefinedShape = true;
02763                                     } else if( tagName == "End" ) {
02764                                         QString value;
02765                                         if( KDGanttXML::readStringNode( element, value ) )
02766                                             endShape = KDGanttViewItem::stringToShape( value );
02767                                         if ( value == "Undefined" )
02768                                           undefinedShape = true;
02769                                     } else {
02770                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02771                                         Q_ASSERT( false );
02772                                     }
02773                                 }
02774                                 node = node.nextSibling();
02775                             }
02776                             if ( ! undefinedShape )
02777                               setShapes( KDGanttViewItem::Task, startShape, middleShape, endShape, false );
02778                             undefinedShape = false;
02779                         } else if( tagName == "Summary" ) {
02780                             KDGanttViewItem::Shape startShape, middleShape, endShape;
02781                             startShape = KDGanttViewItem::TriangleDown;
02782                             middleShape = KDGanttViewItem::TriangleDown;
02783                             endShape = KDGanttViewItem::TriangleDown;
02784                             QDomNode node = element.firstChild();
02785                             while( !node.isNull() ) {
02786                                 QDomElement element = node.toElement();
02787                                 if( !element.isNull() ) { // was really an elemente
02788                                     QString tagName = element.tagName();
02789                                     if( tagName == "Start" ) {
02790                                         QString value;
02791                                         if( KDGanttXML::readStringNode( element, value ) )
02792                                             startShape = KDGanttViewItem::stringToShape( value );
02793                                         if ( value == "Undefined" )
02794                                           undefinedShape = true;
02795                                     } else if( tagName == "Middle" ) {
02796                                         QString value;
02797                                         if( KDGanttXML::readStringNode( element, value ) )
02798                                             middleShape = KDGanttViewItem::stringToShape( value );
02799                                         if ( value == "Undefined" )
02800                                           undefinedShape = true;
02801                                     } else if( tagName == "End" ) {
02802                                         QString value;
02803                                         if( KDGanttXML::readStringNode( element, value ) )
02804                                             endShape = KDGanttViewItem::stringToShape( value );
02805                                         if ( value == "Undefined" )
02806                                           undefinedShape = true;
02807                                     } else {
02808                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02809                                         Q_ASSERT( false );
02810                                     }
02811                                 }
02812                                 node = node.nextSibling();
02813                             }
02814                             if ( ! undefinedShape )
02815                               setShapes( KDGanttViewItem::Summary, startShape,
02816                                        middleShape, endShape, false );
02817                             undefinedShape = false;
02818                         } else {
02819                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02820                             Q_ASSERT( false );
02821                         }
02822                     }
02823                     node = node.nextSibling();
02824                 }
02825             } else if( tagName == "Colors" ) {
02826                 QDomNode node = element.firstChild();
02827                 while( !node.isNull()) {
02828                     QDomElement element = node.toElement();
02829                     if( !element.isNull() ) { // was really an elemente
02830                         QString tagName = element.tagName();
02831                         if( tagName == "Event" ) {
02832                             QColor startColor, middleColor, endColor;
02833                             QDomNode node = element.firstChild();
02834                             while( !node.isNull() ) {
02835                                 QDomElement element = node.toElement();
02836                                 if( !element.isNull() ) { // was really an elemente
02837                                     QString tagName = element.tagName();
02838                                     if( tagName == "Start" ) {
02839                                         QColor value;
02840                                         if( KDGanttXML::readColorNode( element, value ) )
02841                                             startColor = value;
02842                                     } else if( tagName == "Middle" ) {
02843                                         QColor value;
02844                                         if( KDGanttXML::readColorNode( element, value ) )
02845                                             middleColor = value;
02846                                     } else if( tagName == "End" ) {
02847                                         QColor value;
02848                                         if( KDGanttXML::readColorNode( element, value ) )
02849                                             endColor = value;
02850                                     } else {
02851                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02852                                         Q_ASSERT( false );
02853                                     }
02854                                 }
02855                                 node = node.nextSibling();
02856                             }
02857                             setColors( KDGanttViewItem::Event, startColor,
02858                                        middleColor, endColor, false );
02859                         } else if( tagName == "Task" ) {
02860                             QColor startColor, middleColor, endColor;
02861                             QDomNode node = element.firstChild();
02862                             while( !node.isNull() ) {
02863                                 QDomElement element = node.toElement();
02864                                 if( !element.isNull() ) { // was really an elemente
02865                                     QString tagName = element.tagName();
02866                                     if( tagName == "Start" ) {
02867                                         QColor value;
02868                                         if( KDGanttXML::readColorNode( element, value ) )
02869                                             startColor = value;
02870                                     } else if( tagName == "Middle" ) {
02871                                         QColor value;
02872                                         if( KDGanttXML::readColorNode( element, value ) )
02873                                             middleColor = value;
02874                                     } else if( tagName == "End" ) {
02875                                         QColor value;
02876                                         if( KDGanttXML::readColorNode( element, value ) )
02877                                             endColor = value;
02878                                     } else {
02879                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02880                                         Q_ASSERT( false );
02881                                     }
02882                                 }
02883                                 node = node.nextSibling();
02884                             }
02885                             setColors( KDGanttViewItem::Task, startColor,
02886                                        middleColor, endColor, false );
02887                         } else if( tagName == "Summary" ) {
02888                             QColor startColor, middleColor, endColor;
02889                             QDomNode node = element.firstChild();
02890                             while( !node.isNull() ) {
02891                                 QDomElement element = node.toElement();
02892                                 if( !element.isNull() ) { // was really an elemente
02893                                     QString tagName = element.tagName();
02894                                     if( tagName == "Start" ) {
02895                                         QColor value;
02896                                         if( KDGanttXML::readColorNode( element, value ) )
02897                                             startColor = value;
02898                                     } else if( tagName == "Middle" ) {
02899                                         QColor value;
02900                                         if( KDGanttXML::readColorNode( element, value ) )
02901                                             middleColor = value;
02902                                     } else if( tagName == "End" ) {
02903                                         QColor value;
02904                                         if( KDGanttXML::readColorNode( element, value ) )
02905                                             endColor = value;
02906                                     } else {
02907                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02908                                         Q_ASSERT( false );
02909                                     }
02910                                 }
02911                                 node = node.nextSibling();
02912                             }
02913                             setColors( KDGanttViewItem::Summary, startColor,
02914                                        middleColor, endColor , false);
02915                         } else {
02916                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02917                             Q_ASSERT( false );
02918                         }
02919                     }
02920                     node = node.nextSibling();
02921                 }
02922             } else if( tagName == "DefaultColors" ) {
02923                 QDomNode node = element.firstChild();
02924                 while( !node.isNull() ) {
02925                     QDomElement element = node.toElement();
02926                     if( !element.isNull() ) { // was really an element
02927                         QString tagName = element.tagName();
02928                         if( tagName == "Event" ) {
02929                             QColor value;
02930                             if( KDGanttXML::readColorNode( element, value ) )
02931                                 setDefaultColor( KDGanttViewItem::Event,
02932                                                  value, false );
02933                         } else if( tagName == "Task" ) {
02934                             QColor value;
02935                             if( KDGanttXML::readColorNode( element, value ) )
02936                                 setDefaultColor( KDGanttViewItem::Task,
02937                                                  value, false );
02938                         } else if( tagName == "Summary" ) {
02939                             QColor value;
02940                             if( KDGanttXML::readColorNode( element, value ) )
02941                                 setDefaultColor( KDGanttViewItem::Summary,
02942                                                  value , false);
02943                         } else {
02944                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02945                             Q_ASSERT( false );
02946                         }
02947                     }
02948 
02949                     node = node.nextSibling();
02950                 }
02951             } else if( tagName == "HighlightColors" ) {
02952                 QDomNode node = element.firstChild();
02953                 while( !node.isNull() ) {
02954                     QDomElement element = node.toElement();
02955                     if( !element.isNull() ) { // was really an elemente
02956                         QString tagName = element.tagName();
02957                         if( tagName == "Event" ) {
02958                             QColor startColor, middleColor, endColor;
02959                             QDomNode node = element.firstChild();
02960                             while( !node.isNull() ) {
02961                                 QDomElement element = node.toElement();
02962                                 if( !element.isNull() ) { // was really an elemente
02963                                     QString tagName = element.tagName();
02964                                     if( tagName == "Start" ) {
02965                                         QColor value;
02966                                         if( KDGanttXML::readColorNode( element, value ) )
02967                                             startColor = value;
02968                                     } else if( tagName == "Middle" ) {
02969                                         QColor value;
02970                                         if( KDGanttXML::readColorNode( element, value ) )
02971                                             middleColor = value;
02972                                     } else if( tagName == "End" ) {
02973                                         QColor value;
02974                                         if( KDGanttXML::readColorNode( element, value ) )
02975                                             endColor = value;
02976                                     } else {
02977                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02978                                         Q_ASSERT( false );
02979                                     }
02980                                 }
02981                                 node = node.nextSibling();
02982                             }
02983                             setHighlightColors( KDGanttViewItem::Event,
02984                                                 startColor,
02985                                                 middleColor, endColor, false );
02986                         } else if( tagName == "Task" ) {
02987                             QColor startColor, middleColor, endColor;
02988                             QDomNode node = element.firstChild();
02989                             while( !node.isNull() ) {
02990                                 QDomElement element = node.toElement();
02991                                 if( !element.isNull() ) { // was really an elemente
02992                                     QString tagName = element.tagName();
02993                                     if( tagName == "Start" ) {
02994                                         QColor value;
02995                                         if( KDGanttXML::readColorNode( element, value ) )
02996                                             startColor = value;
02997                                     } else if( tagName == "Middle" ) {
02998                                         QColor value;
02999                                         if( KDGanttXML::readColorNode( element, value ) )
03000                                             middleColor = value;
03001                                     } else if( tagName == "End" ) {
03002                                         QColor value;
03003                                         if( KDGanttXML::readColorNode( element, value ) )
03004                                             endColor = value;
03005                                     } else {
03006                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03007                                         Q_ASSERT( false );
03008                                     }
03009                                 }
03010                                 node = node.nextSibling();
03011                             }
03012                             setHighlightColors( KDGanttViewItem::Task,
03013                                                 startColor,
03014                                                 middleColor, endColor , false);
03015                         } else if( tagName == "Summary" ) {
03016                             QColor startColor, middleColor, endColor;
03017                             QDomNode node = element.firstChild();
03018                             while( !node.isNull() ) {
03019                                 QDomElement element = node.toElement();
03020                                 if( !element.isNull() ) { // was really an elemente
03021                                     QString tagName = element.tagName();
03022                                     if( tagName == "Start" ) {
03023                                         QColor value;
03024                                         if( KDGanttXML::readColorNode( element, value ) )
03025                                             startColor = value;
03026                                     } else if( tagName == "Middle" ) {
03027                                         QColor value;
03028                                         if( KDGanttXML::readColorNode( element, value ) )
03029                                             middleColor = value;
03030                                     } else if( tagName == "End" ) {
03031                                         QColor value;
03032                                         if( KDGanttXML::readColorNode( element, value ) )
03033                                             endColor = value;
03034                                     } else {
03035                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03036                                         Q_ASSERT( false );
03037                                     }
03038                                 }
03039                                 node = node.nextSibling();
03040                             }
03041                             setHighlightColors( KDGanttViewItem::Summary,
03042                                                 startColor,
03043                                                 middleColor, endColor, false );
03044                         } else {
03045                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03046                             Q_ASSERT( false );
03047                         }
03048                     }
03049                     node = node.nextSibling();
03050                 }
03051             } else if( tagName == "DefaultHighlightColors" ) {
03052                 QDomNode node = element.firstChild();
03053                 while( !node.isNull() ) {
03054                     QDomElement element = node.toElement();
03055                     if( !element.isNull() ) { // was really an element
03056                         QString tagName = element.tagName();
03057                         if( tagName == "Event" ) {
03058                             QColor value;
03059                             if( KDGanttXML::readColorNode( element, value ) )
03060                                 setDefaultHighlightColor( KDGanttViewItem::Event,
03061                                                  value , false);
03062                         } else if( tagName == "Task" ) {
03063                             QColor value;
03064                             if( KDGanttXML::readColorNode( element, value ) )
03065                                 setDefaultHighlightColor( KDGanttViewItem::Task,
03066                                                  value, false );
03067                         } else if( tagName == "Summary" ) {
03068                             QColor value;
03069                             if( KDGanttXML::readColorNode( element, value ) )
03070                                 setDefaultHighlightColor( KDGanttViewItem::Summary,
03071                                                  value, false );
03072                         } else {
03073                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03074                             Q_ASSERT( false );
03075                         }
03076                     }
03077 
03078                     node = node.nextSibling();
03079                 }
03080             } else if( tagName == "Items" ) {
03081                 QDomNode node = element.firstChild();
03082                 KDGanttViewItem* previous = 0;
03083                 while( !node.isNull() ) {
03084                     QDomElement element = node.toElement();
03085                     if( !element.isNull() ) { // was really an element
03086                         QString tagName = element.tagName();
03087                         if( tagName == "Item" ) {
03088                             KDGanttViewItem* newItem;
03089                             if( previous )
03090                                 newItem =
03091                                     KDGanttViewItem::createFromDomElement( this,
03092                                                                            previous,
03093                                                                            element );
03094                             else
03095                                 newItem =
03096                                     KDGanttViewItem::createFromDomElement( this,
03097                                                                            element );
03098                             previous = newItem;
03099                         } else {
03100                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03101                             Q_ASSERT( false );
03102                         }
03103                     }
03104 
03105                     node = node.nextSibling();
03106                 }
03107             } else if( tagName == "TaskLinks" ) {
03108                 QDomNode node = element.firstChild();
03109                 while( !node.isNull() ) {
03110                     QDomElement element = node.toElement();
03111                     if( !element.isNull() ) { // was really an element
03112                         QString tagName = element.tagName();
03113                         if( tagName == "TaskLink" )
03114                             KDGanttViewTaskLink::createFromDomElement( element );
03115                         else {
03116                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03117                             Q_ASSERT( false );
03118                         }
03119                     }
03120 
03121                     node = node.nextSibling();
03122                 }
03123             } else if( tagName == "TaskLinkGroups" ) {
03124                 QDomNode node = element.firstChild();
03125                 while( !node.isNull() ) {
03126                     QDomElement element = node.toElement();
03127                     if( !element.isNull() ) { // was really an element
03128                         QString tagName = element.tagName();
03129                         if( tagName == "TaskLink" )
03130                             KDGanttViewTaskLinkGroup::createFromDomElement( element );
03131                     } else {
03132                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03133                         Q_ASSERT( false );
03134                     }
03135 
03136                     node = node.nextSibling();
03137                 }
03138             } else if( tagName == "ColumnBackgroundColors" ) {
03139                 QDomNode node = element.firstChild();
03140                 while( !node.isNull() ) {
03141                     QDomElement element = node.toElement();
03142                     if( !element.isNull() ) { // was really an element
03143                         QString tagName = element.tagName();
03144                         if( tagName == "ColumnBackgroundColor" ) {
03145                             QDomNode node = element.firstChild();
03146                             QDateTime dateTime;
03147                             QColor color;
03148                             while( !node.isNull() ) {
03149                                 QDomElement element = node.toElement();
03150                                 if( !element.isNull() ) { // was
03151                                                           // really an
03152                                                           // element
03153                                     QString tagName = element.tagName();
03154                                     if( tagName == "DateTime" ) {
03155                                         QDateTime value;
03156                                         if( KDGanttXML::readDateTimeNode( element, value ) )
03157                                             dateTime = value;
03158                                     } else if( tagName == "Color" ) {
03159                                         QColor value;
03160                                         if( KDGanttXML::readColorNode( element, value ) )
03161                                             color = value;
03162                                     } else {
03163                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03164                                         Q_ASSERT( false );
03165                                     }
03166                                 }
03167 
03168                                 node = node.nextSibling();
03169                             }
03170                             setColumnBackgroundColor( dateTime, color );
03171                         } else {
03172                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03173                             Q_ASSERT( false );
03174                         }
03175                     }
03176                     node = node.nextSibling();
03177                 }
03178             } else if( tagName == "LegendItems" ) {
03179                 clearLegend();
03180                 QDomNode node = element.firstChild();
03181                 while( !node.isNull() ) {
03182                     QDomElement element = node.toElement();
03183                     if( !element.isNull() ) { // was really an element
03184                         QString tagName = element.tagName();
03185                         if( tagName == "LegendItem" ) {
03186                             KDGanttViewItem::Shape tempLegendShape;
03187                             tempLegendShape = KDGanttViewItem::TriangleDown;
03188                             QColor tempLegendColor;
03189                             QString tempLegendString;
03190                             bool ok = true;
03191                             QDomNode node = element.firstChild();
03192                             while( !node.isNull() ) {
03193                                 QDomElement element = node.toElement();
03194                                 if( !element.isNull() ) { // was really an element
03195                                     QString tagName = element.tagName();
03196                                     if( tagName == "Shape" ) {
03197                                         QString value;
03198                                         if( KDGanttXML::readStringNode( element, value ) )
03199                                             tempLegendShape = KDGanttViewItem::stringToShape( value );
03200                                         else
03201                                             ok = false;
03202                                     } else if( tagName == "Color" ) {
03203                                         QColor value;
03204                                         if( KDGanttXML::readColorNode( element, value ) )
03205                                             tempLegendColor = value;
03206                                         else
03207                                             ok = false;
03208                                     } else if( tagName == "Text" ) {
03209                                         QString value;
03210                                         if( KDGanttXML::readStringNode( element, value ) )
03211                                             tempLegendString = value;
03212                                         else
03213                                             ok = false;
03214                                     } else {
03215                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03216                                         Q_ASSERT( false );
03217                                     }
03218                                 }
03219                                 node = node.nextSibling();
03220                             }
03221                             if( ok ) {
03222                                 addLegendItem( tempLegendShape,
03223                                                tempLegendColor,
03224                                                tempLegendString );
03225                                 qDebug( "Adding legend item %s", tempLegendString.latin1() );
03226                             }
03227                         } else {
03228                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03229                             Q_ASSERT( false );
03230                         }
03231                     }
03232                     node = node.nextSibling();
03233                 }
03234             } else {
03235                 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03236                 Q_ASSERT( false );
03237             }
03238         }
03239 
03240         node = node.nextSibling();
03241     } // while
03242         return true; /* FIXME: Do real error-reporting. The ASSERT's should be "return false" stmnts */
03243 } // method
03244 
03245 
03254 QDomDocument KDGanttView::saveXML( bool withPI ) const
03255 {
03256     // Create an inital DOM document
03257     QString docstart = "<GanttView/>";
03258 
03259     QDomDocument doc( "GanttView" );
03260     doc.setContent( docstart );
03261     if( withPI ) {
03262       QDomProcessingInstruction pin = doc.createProcessingInstruction( "kdgantt", "version=\"1.0\" encoding=\"UTF-8\""  ) ;
03263        doc.appendChild ( pin );
03264     }
03265 
03266     QDomElement docRoot = doc.documentElement();
03267     docRoot.setAttribute( "xmlns", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
03268     docRoot.setAttribute( "xmlns:xsi", "http://www.w3.org/2000/10/XMLSchema-instance" );
03269     docRoot.setAttribute( "xsi:schemaLocation", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
03270 
03271     // the ShowLegend element
03272     KDGanttXML::createBoolNode( doc, docRoot, "ShowLegend", showLegend() );
03273 
03274     // the ShowLegendButton element
03275     KDGanttXML::createBoolNode( doc, docRoot, "ShowLegendButton",
03276                            showLegendButton() );
03277 
03278     // the LegendIsDockWindow element
03279     KDGanttXML::createBoolNode( doc, docRoot, "LegendIsDockWindow",
03280                            legendIsDockwindow() );
03281 
03282     // the ShowListView element
03283     KDGanttXML::createBoolNode( doc, docRoot, "ShowListView", showListView() );
03284 
03285     // the ShowHeader element
03286     KDGanttXML::createBoolNode( doc, docRoot, "ShowHeader", headerVisible() );
03287 
03288     // the ShowTaskLinks element
03289     KDGanttXML::createBoolNode( doc, docRoot, "ShowTaskLinks", showTaskLinks() );
03290 
03291     // the EditorEnabled element
03292     KDGanttXML::createBoolNode( doc, docRoot, "EditorEnabled", editorEnabled() );
03293 
03294     // the global font element
03295     KDGanttXML::createFontNode( doc, docRoot, "GlobalFont", font() );
03296 
03297     // the DisplayEmptyTasksAsLine element
03298     KDGanttXML::createBoolNode( doc, docRoot, "DisplayEmptyTasksAsLine",
03299                            displayEmptyTasksAsLine() );
03300 
03301     // the HorizonStart element
03302     KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonStart", horizonStart() );
03303 
03304     // the HorizonEnd element
03305     KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonEnd", horizonEnd() );
03306 
03307     // the Scale, MinimumScale, MaximumScale elements
03308     KDGanttXML::createStringNode( doc, docRoot, "Scale", scaleToString( scale() ) );
03309     KDGanttXML::createStringNode( doc, docRoot, "MinimumScale",
03310                              scaleToString( minimumScale() ) );
03311     KDGanttXML::createStringNode( doc, docRoot, "MaximumScale",
03312                              scaleToString( maximumScale() ) );
03313 
03314     // the YearFormat element
03315     KDGanttXML::createStringNode( doc, docRoot, "YearFormat",
03316                              yearFormatToString( yearFormat() ) );
03317 
03318     // the HourFormat element
03319     KDGanttXML::createStringNode( doc, docRoot, "HourFormat",
03320                              hourFormatToString( hourFormat() ) );
03321 
03322     // the ShowMinorTicks element
03323     KDGanttXML::createBoolNode( doc, docRoot, "ShowMinorTicks", showMinorTicks() );
03324 
03325     // the ShowMajorTicks element
03326     KDGanttXML::createBoolNode( doc, docRoot, "ShowMajorTicks", showMajorTicks() );
03327 
03328     // the Editable element
03329     KDGanttXML::createBoolNode( doc, docRoot, "Editable", editable() );
03330 
03331     // the TextColor element
03332     KDGanttXML::createColorNode( doc, docRoot, "TextColor", textColor() );
03333 
03334     // the MajorScaleCount element
03335     KDGanttXML::createIntNode( doc, docRoot, "MajorScaleCount", majorScaleCount() );
03336 
03337     // the MinorScaleCount element
03338     KDGanttXML::createIntNode( doc, docRoot, "MinorScaleCount", minorScaleCount() );
03339 
03340     // the AutoScaleMinorTickCount element
03341     KDGanttXML::createIntNode( doc, docRoot, "AutoScaleMinorTickCount",
03342                           autoScaleMinorTickCount() );
03343 
03344     // the MinimumColumnWidth element
03345     KDGanttXML::createIntNode( doc, docRoot, "MinimumColumnWidth",
03346                           minimumColumnWidth() );
03347 
03348     // the GanttMaximumWidth element
03349     KDGanttXML::createIntNode( doc, docRoot, "GanttMaximumWidth",
03350                           ganttMaximumWidth() );
03351 
03352     // the NoInformationBrush element
03353     KDGanttXML::createBrushNode( doc, docRoot, "NoInformationBrush",
03354                             noInformationBrush() );
03355 
03356     // the GanttViewBackgroundColor element
03357     KDGanttXML::createColorNode( doc, docRoot, "GanttViewBackgroundColor",
03358                             gvBackgroundColor() );
03359 
03360     // the ListViewBackgroundColor element
03361     KDGanttXML::createColorNode( doc, docRoot, "ListViewBackgroundColor",
03362                             lvBackgroundColor() );
03363 
03364     // the TimeHeaderBackgroundColor element
03365     KDGanttXML::createColorNode( doc, docRoot, "TimeHeaderBackgroundColor",
03366                             timeHeaderBackgroundColor() );
03367 
03368     // the LegendHeaderBackgroundColor element
03369     KDGanttXML::createColorNode( doc, docRoot, "LegendHeaderBackgroundColor",
03370                             legendHeaderBackgroundColor() );
03371 
03372     // the WeekendBackgroundColor element
03373     KDGanttXML::createColorNode( doc, docRoot, "WeekendBackgroundColor",
03374                             weekendBackgroundColor() );
03375 
03376     // the WeekdayBackgroundColor elements
03377     for( int weekday = 1; weekday <= 7; weekday++ ) {
03378         QColor color = weekdayBackgroundColor( weekday );
03379         if( color.isValid() ) {
03380             QDomElement weekendBackgroundColorElement = doc.createElement( "WeekdayBackgroundColor" );
03381             docRoot.appendChild( weekendBackgroundColorElement );
03382             KDGanttXML::createIntNode( doc, weekendBackgroundColorElement,
03383                                   "Day", weekday );
03384             KDGanttXML::createColorNode( doc, weekendBackgroundColorElement,
03385                                     "Color", color );
03386         }
03387     }
03388 
03389     // the WeekendDays element
03390     QDomElement weekendDaysElement = doc.createElement( "WeekendDays" );
03391     docRoot.appendChild( weekendDaysElement );
03392     int weekendStart, weekendEnd;
03393     weekendDays( weekendStart, weekendEnd );
03394     weekendDaysElement.setAttribute( "Start", weekendStart );
03395     weekendDaysElement.setAttribute( "End", weekendStart );
03396 
03397     // the ZoomFactor element
03398     KDGanttXML::createDoubleNode( doc, docRoot, "ZoomFactor",
03399                              zoomFactor() );
03400 
03401     // the ShowHeaderPopupMenu element
03402     KDGanttXML::createBoolNode( doc, docRoot, "ShowHeaderPopupMenu",
03403                            showHeaderPopupMenu() );
03404 
03405     // the ShowTimeTablePopupMenu element
03406     KDGanttXML::createBoolNode( doc, docRoot, "ShowTimeTablePopupMenu",
03407                            showTimeTablePopupMenu() );
03408 
03409     // the Shapes element
03410     QDomElement shapesElement = doc.createElement( "Shapes" );
03411     docRoot.appendChild( shapesElement );
03412     QDomElement shapesEventElement = doc.createElement( "Event" );
03413     shapesElement.appendChild( shapesEventElement );
03414     KDGanttViewItem::Shape start, middle, end;
03415     if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
03416         KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
03417                                  KDGanttViewItem::shapeToString( start ) );
03418         KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
03419                                  KDGanttViewItem::shapeToString( middle ) );
03420         KDGanttXML::createStringNode( doc, shapesEventElement, "End",
03421                                  KDGanttViewItem::shapeToString( end ) );
03422     } else {
03423         KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
03424                                  "Undefined" );
03425         KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
03426                                  "Undefined" );
03427         KDGanttXML::createStringNode( doc, shapesEventElement, "End",
03428                                  "Undefined" );
03429     }
03430     QDomElement shapesTaskElement = doc.createElement( "Task" );
03431     shapesElement.appendChild( shapesTaskElement );
03432     if( shapes( KDGanttViewItem::Task, start, middle, end ) ) {
03433         KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
03434                                  KDGanttViewItem::shapeToString( start ) );
03435         KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
03436                                  KDGanttViewItem::shapeToString( middle ) );
03437         KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
03438                                  KDGanttViewItem::shapeToString( end ) );
03439     } else {
03440         KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
03441                                  "Undefined" );
03442         KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
03443                                  "Undefined" );
03444         KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
03445                                  "Undefined" );
03446     }
03447     QDomElement shapesSummaryElement = doc.createElement( "Summary" );
03448     shapesElement.appendChild( shapesSummaryElement );
03449     if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
03450         KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
03451                                  KDGanttViewItem::shapeToString( start ) );
03452         KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
03453                                  KDGanttViewItem::shapeToString( middle ) );
03454         KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
03455                                  KDGanttViewItem::shapeToString( end ) );
03456     } else {
03457         KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
03458                                  "Undefined" );
03459         KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
03460                                  "Undefined" );
03461         KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
03462                                  "Undefined" );
03463     }
03464 
03465     // the Colors element
03466     QDomElement colorsElement = doc.createElement( "Colors" );
03467     docRoot.appendChild( colorsElement );
03468     QDomElement colorsEventElement = doc.createElement( "Event" );
03469     colorsElement.appendChild( colorsEventElement );
03470     QColor startColor, middleColor, endColor;
03471     colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03472     KDGanttXML::createColorNode( doc, colorsEventElement, "Start", startColor );
03473     KDGanttXML::createColorNode( doc, colorsEventElement, "Middle", middleColor );
03474     KDGanttXML::createColorNode( doc, colorsEventElement, "End", endColor );
03475     QDomElement colorsTaskElement = doc.createElement( "Task" );
03476     colorsElement.appendChild( colorsTaskElement );
03477     colors( KDGanttViewItem::Task, startColor, middleColor, endColor );
03478     KDGanttXML::createColorNode( doc, colorsTaskElement, "Start", startColor );
03479     KDGanttXML::createColorNode( doc, colorsTaskElement, "Middle", middleColor );
03480     KDGanttXML::createColorNode( doc, colorsTaskElement, "End", endColor );
03481     QDomElement colorsSummaryElement = doc.createElement( "Summary" );
03482     colorsElement.appendChild( colorsSummaryElement );
03483     colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03484     KDGanttXML::createColorNode( doc, colorsSummaryElement, "Start", startColor );
03485     KDGanttXML::createColorNode( doc, colorsSummaryElement, "Middle", middleColor );
03486     KDGanttXML::createColorNode( doc, colorsSummaryElement, "End", endColor );
03487 
03488     // the DefaultColor element
03489     QDomElement defaultColorsElement = doc.createElement( "DefaultColors" );
03490     docRoot.appendChild( defaultColorsElement );
03491     KDGanttXML::createColorNode( doc, defaultColorsElement, "Event",
03492                             defaultColor( KDGanttViewItem::Event ) );
03493     KDGanttXML::createColorNode( doc, defaultColorsElement, "Task",
03494                             defaultColor( KDGanttViewItem::Task ) );
03495     KDGanttXML::createColorNode( doc, defaultColorsElement, "Summary",
03496                             defaultColor( KDGanttViewItem::Summary ) );
03497 
03498 
03499     // the HighlightColors element
03500     QDomElement highlightColorsElement = doc.createElement( "HighlightColors" );
03501     docRoot.appendChild( highlightColorsElement );
03502     QDomElement highlightColorsEventElement = doc.createElement( "Event" );
03503     highlightColorsElement.appendChild( highlightColorsEventElement );
03504     highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03505     KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Start", startColor );
03506     KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Middle", middleColor );
03507     KDGanttXML::createColorNode( doc, highlightColorsEventElement, "End", endColor );
03508     QDomElement highlightColorsTaskElement = doc.createElement( "Task" );
03509     highlightColorsElement.appendChild( highlightColorsTaskElement );
03510     highlightColors( KDGanttViewItem::Task, startColor, middleColor, endColor );
03511     KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Start", startColor );
03512     KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Middle", middleColor );
03513     KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "End", endColor );
03514     QDomElement highlightColorsSummaryElement = doc.createElement( "Summary" );
03515     highlightColorsElement.appendChild( highlightColorsSummaryElement );
03516     highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03517     KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
03518     KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
03519     KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );
03520 
03521 
03522     /*
03523     if( highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor ) ) {
03524         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
03525         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
03526         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );
03527     } else {
03528         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", QColor() );
03529         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", QColor() );
03530         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", QColor() );
03531     }
03532     */
03533     // the DefaultHighlightColor element
03534     QDomElement defaultHighlightColorsElement = doc.createElement( "DefaultHighlightColors" );
03535     docRoot.appendChild( defaultHighlightColorsElement );
03536     KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Event",
03537                             defaultHighlightColor( KDGanttViewItem::Event ) );
03538     KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Task",
03539                             defaultHighlightColor( KDGanttViewItem::Task ) );
03540     KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Summary",
03541                             defaultHighlightColor( KDGanttViewItem::Summary ) );
03542 
03543 
03544     // the Items element
03545     QDomElement itemsElement = doc.createElement( "Items" );
03546     docRoot.appendChild( itemsElement );
03547     KDGanttViewItem* currentItem = firstChild();
03548     while( currentItem ) {
03549         currentItem->createNode( doc, itemsElement );
03550         currentItem = currentItem->nextSibling();
03551     }
03552 
03553     // the TaskLinks element
03554     QDomElement taskLinksElement = doc.createElement( "TaskLinks" );
03555     docRoot.appendChild( taskLinksElement );
03556     QPtrList<KDGanttViewTaskLink> taskLinkList = taskLinks();
03557     KDGanttViewTaskLink* currentTL = 0;
03558     for( currentTL = taskLinkList.first(); currentTL;
03559          currentTL = taskLinkList.next() )
03560         currentTL->createNode( doc, taskLinksElement );
03561 
03562     // the TaskLinkGroups element
03563     QDomElement taskLinkGroupsElement = doc.createElement( "TaskLinkGroups" );
03564     docRoot.appendChild( taskLinkGroupsElement );
03565     QPtrList<KDGanttViewTaskLinkGroup> taskLinkGroupList = taskLinkGroups();
03566     KDGanttViewTaskLinkGroup* currentTLG = 0;
03567     for( currentTLG = taskLinkGroupList.first(); currentTLG;
03568          currentTLG = taskLinkGroupList.next() )
03569         currentTLG->createNode( doc, taskLinkGroupsElement );
03570 
03571     // the ColumnBackgroundColors element
03572     QDomElement columnBackgroundColorsElement =
03573         doc.createElement( "ColumnBackgroundColors" );
03574     docRoot.appendChild( columnBackgroundColorsElement );
03575     KDTimeHeaderWidget::ColumnColorList ccList =
03576         myTimeHeader->columnBackgroundColorList();
03577     for( KDTimeHeaderWidget::ColumnColorList::iterator it = ccList.begin();
03578          it != ccList.end(); ++it ) {
03579         QDomElement columnBackgroundColorElement =
03580             doc.createElement( "ColumnBackgroundColor" );
03581         columnBackgroundColorsElement.appendChild( columnBackgroundColorElement );
03582         KDGanttXML::createDateTimeNode( doc, columnBackgroundColorElement,
03583                                    "DateTime", (*it).datetime );
03584         KDGanttXML::createColorNode( doc, columnBackgroundColorElement,
03585                                 "Color", (*it).color );
03586     }
03587 
03588     // the LegendItems element
03589     QDomElement legendItemsElement =
03590         doc.createElement( "LegendItems" );
03591     docRoot.appendChild( legendItemsElement );
03592     legendItem* current;
03593     QPtrListIterator<legendItem> lit( *myLegendItems );
03594     while( ( current = lit.current() ) ) {
03595         ++lit;
03596         QDomElement legendItemElement = doc.createElement( "LegendItem" );
03597         legendItemsElement.appendChild( legendItemElement );
03598         KDGanttXML::createStringNode( doc, legendItemElement, "Shape",
03599                                  KDGanttViewItem::shapeToString( current->shape ) );
03600         KDGanttXML::createColorNode( doc, legendItemElement, "Color",
03601                                 current->color );
03602         KDGanttXML::createStringNode( doc, legendItemElement, "Text",
03603                                  current->text );
03604     }
03605 
03606     // the DragEnabled element
03607     KDGanttXML::createBoolNode( doc, docRoot, "DragEnabled", isDragEnabled() );
03608 
03609     // the DropEnabled element
03610     KDGanttXML::createBoolNode( doc, docRoot, "DropEnabled", isDropEnabled() );
03611 
03612     // the CalendarMode element
03613     KDGanttXML::createBoolNode( doc, docRoot, "CalendarMode", calendarMode() );
03614 
03615     return doc;
03616 }
03617 
03618 
03619 
03620 QString KDGanttView::scaleToString( Scale scale )
03621 {
03622     switch( scale ) {
03623     case Minute:
03624         return "Minute";
03625     case Hour:
03626         return "Hour";
03627     case Day:
03628         return "Day";
03629     case Week:
03630         return "Week";
03631     case Month:
03632         return "Month";
03633     case Auto:
03634         return "Auto";
03635     }
03636     return "";
03637 }
03638 
03639 
03640 KDGanttView::Scale KDGanttView::stringToScale( const QString& string )
03641 {
03642     if( string == "Minute" )
03643         return Minute;
03644     else if( string == "Hour" )
03645         return Hour;
03646     else if( string == "Day" )
03647         return Day;
03648     else if( string == "Week" )
03649         return Week;
03650     else if( string == "Month" )
03651         return Month;
03652     else if( string == "Auto" )
03653         return Auto;
03654 
03655     return Auto;
03656 }
03657 
03658 
03659 QString KDGanttView::yearFormatToString( YearFormat format )
03660 {
03661     switch( format ) {
03662     case FourDigit:
03663         return "FourDigit";
03664     case TwoDigit:
03665         return "TwoDigit";
03666     case TwoDigitApostrophe:
03667         return "TwoDigitApostrophe";
03668     case NoDate:
03669         return "NoDate";
03670     }
03671     return "";
03672 }
03673 
03674 
03675 KDGanttView::YearFormat KDGanttView::stringToYearFormat( const QString& string )
03676 {
03677     if( string == "FourDigit" )
03678         return FourDigit;
03679     else if( string == "TwoDigit" )
03680         return TwoDigit;
03681     else if( string == "TwoDigitApostrophe" )
03682         return TwoDigitApostrophe;
03683     else if( string == "NoDate" )
03684         return NoDate;
03685     else
03686         return FourDigit;
03687 }
03688 
03689 
03690 QString KDGanttView::hourFormatToString( HourFormat format )
03691 {
03692     switch( format ) {
03693     case Hour_12:
03694         return "Hour_12";
03695     case Hour_24:
03696         return "Hour_24";
03697     case Hour_24_FourDigit:
03698         return "Hour_24_FourDigit";
03699     }
03700     return "";
03701 }
03702 
03703 
03704 KDGanttView::HourFormat KDGanttView::stringToHourFormat( const QString& string )
03705 {
03706     if( string == "Hour_12" )
03707         return Hour_12;
03708     else if( string == "Hour_24" )
03709         return Hour_24;
03710     else
03711         return Hour_24;
03712 }
03713 
03714 
03715 void KDGanttView::addTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
03716 {
03717 
03718   if (myTaskLinkGroupList.isEmpty()) {
03719     myTaskLinkGroupList.append(group);
03720     return;
03721   }
03722     if (myTaskLinkGroupList.find(group) == -1)
03723         myTaskLinkGroupList.append(group);
03724 }
03725 
03726 
03727 void KDGanttView::removeTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
03728 {
03729     myTaskLinkGroupList.remove(group);
03730 }
03731 
03732 
03738 void KDGanttView::editItem( KDGanttViewItem*  item)
03739 {
03740   if ( ! item )
03741     return;
03742   if ( editorEnabled() ) {
03743     if ( item->editable() ) {
03744       myItemAttributeDialog->reset( item );
03745       myItemAttributeDialog->show();
03746     }
03747   }
03748 }
03749 
03750 
03761 QPixmap KDGanttView::getPixmap( KDGanttViewItem::Shape shape,
03762                                 const QColor& shapeColor,
03763                                 const QColor& backgroundColor, int itemSize)
03764 {
03765   // 10 is a good value as size
03766   int size = itemSize+2;
03767   int hei = ( itemSize/3 ) / 2;
03768   QPixmap p = QPixmap( size+4, size+4 );
03769   p.fill( backgroundColor );
03770   QPainter paint (&p);
03771   QBrush b = QBrush ( Qt::SolidPattern );
03772   b.setColor( shapeColor );
03773   paint.setBrush( b );
03774   QPen pen( Qt::black, 1 ) ;
03775   paint.setPen( pen );
03776   switch (shape) {
03777   case KDGanttViewItem::TriangleDown:{
03778     QPointArray arr = QPointArray(3);
03779     arr.setPoint(0,-size/2,-hei);
03780     arr.setPoint(1,size/2,-hei);
03781     arr.setPoint(2,0,((size/2)-hei));
03782     arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03783     paint.drawPolygon( arr );
03784     break;
03785   }
03786   case KDGanttViewItem::TriangleUp :{
03787     QPointArray arr = QPointArray(3);
03788     arr.setPoint(0,-size/2,hei);
03789     arr.setPoint(1,size/2,hei);
03790     arr.setPoint(2,0,(-size/2)+hei);
03791     arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03792     paint.drawPolygon( arr );
03793     break;
03794   }
03795   case  KDGanttViewItem::Diamond :{
03796     QPointArray arr = QPointArray(4);
03797     arr.setPoint(0,0,-size/2);
03798     arr.setPoint(1,size/2,0);
03799     arr.setPoint(2,0,size/2);
03800     arr.setPoint(3,-size/2,0);
03801     arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03802     paint.drawPolygon( arr );
03803     break;
03804   }
03805   case KDGanttViewItem::Square :{
03806     QPointArray arr = QPointArray(4);
03807     arr.setPoint(0,-size/2,-size/2);
03808     arr.setPoint(1,size/2,-size/2);
03809     arr.setPoint(2,size/2,size/2);
03810     arr.setPoint(3,-size/2,size/2);
03811     arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03812     paint.drawPolygon( arr );
03813     break;
03814   }
03815   case  KDGanttViewItem::Circle  :{
03816     paint.drawEllipse( 2, 2, size, size);
03817     break;
03818   }
03819   }
03820   paint.end();
03821   return p;
03822 }
03823 
03824 int KDGanttView::getIndex( KDGanttViewItem::Type type) const
03825 {
03826     int index = -1;
03827     switch (type) {
03828     case (KDGanttViewItem::Event):
03829         index = 0;
03830         break;
03831     case (KDGanttViewItem::Task):
03832         index = 1;
03833         break;
03834     case (KDGanttViewItem::Summary):
03835         index = 2;
03836         break;
03837     }
03838     return index;
03839 }
03840 
03841 
03842 void KDGanttView::initDefaults()
03843 {
03844   int i;
03845   // We have 3 item types. Set all undefined to true.
03846     for (i = 0;i<3;++i) {
03847         undefinedShape[i] = true;
03848         undefinedColor[i] = true;
03849         undefinedColorHL[i] = true;
03850     }
03851     // setting the default colors
03852     myDefaultColor [ getIndex( KDGanttViewItem::Event ) ] =  Qt::blue; //event
03853     myDefaultColorHL [ getIndex( KDGanttViewItem::Event ) ] =  Qt::red;
03854     myDefaultColor [ getIndex( KDGanttViewItem::Task ) ] =  Qt::green;//task
03855     myDefaultColorHL [ getIndex( KDGanttViewItem::Task ) ] =  Qt::red;
03856     myDefaultColor [ getIndex( KDGanttViewItem::Summary ) ] =  Qt::cyan;//summary
03857     myDefaultColorHL [ getIndex( KDGanttViewItem::Summary ) ] =  Qt::red;
03858 
03859     // setting the default shape types
03860     // currently, we take for each item for all three shapes (start, middle, end) the same default shape
03861     for (i = 0;i<3;++i) {
03862       myDefaultShape [3*getIndex( KDGanttViewItem::Event )+ i] =  KDGanttViewItem::Diamond; //event
03863       myDefaultShape [3*getIndex( KDGanttViewItem::Task ) +i] =  KDGanttViewItem::Square; //task
03864       myDefaultShape [3*getIndex( KDGanttViewItem::Summary ) +i] =  KDGanttViewItem::TriangleDown; //summary
03865 
03866     }
03867 }
03868 
03869 
03870 
03874 int KDGanttView::addColumn( const QString& label, int width )
03875 {
03876     return myListView->addColumn( label, width );
03877 }
03878 
03879 
03884 int KDGanttView::addColumn( const QIconSet& iconset, const QString& label,
03885                             int width )
03886 {
03887     return myListView->addColumn( iconset, label, width );
03888 }
03889 
03890 
03894 void KDGanttView::removeColumn( int index )
03895 {
03896     myListView->removeColumn( index );
03897 }
03898 
03899 
03903 KDGanttViewItem* KDGanttView::selectedItem() const
03904 {
03905     return static_cast<KDGanttViewItem*>( myListView->selectedItem() );
03906 }
03907 
03908 
03912 void KDGanttView::setSelected( KDGanttViewItem* item, bool selected )
03913 {
03914     myListView->setSelected( item, selected );
03915 }
03916 
03917 
03930 KDGanttViewItem* KDGanttView::getItemByName( const QString& name ) const
03931 {
03932     KDGanttViewItem* temp =  firstChild(),* ret;
03933     while (temp != 0) {
03934       if ( (ret = temp->getChildByName( name ) ) )
03935         return ret;
03936       temp = temp->nextSibling();
03937     }
03938     return 0;
03939 }
03940 
03941 
03953 KDGanttViewItem* KDGanttView::getItemByListViewPos( const QPoint& pos ) const
03954 {
03955     return static_cast<KDGanttViewItem*>( myListView->itemAt(myListView->mapFromGlobal(pos) ));
03956 }
03957 
03958 
03973 KDGanttViewItem* KDGanttView::getItemByGanttViewPos( const QPoint& pos ) const
03974 {
03975   KDGanttViewItem* item;
03976   QPoint local = myCanvasView->mapFromGlobal(pos);
03977 
03978     QCanvasItemList il = myTimeTable->collisions( myCanvasView->viewportToContents( local ));
03979     QCanvasItemList::Iterator it;
03980     for ( it = il.begin(); it != il.end(); ++it ) {
03981       if ( myCanvasView->getType(*it) == Type_is_KDGanttViewItem) {
03982         item = myCanvasView->getItem(*it);
03983         if ( item->enabled() )
03984           return item;
03985       }
03986     }
03987     return 0;
03988 }
03989 
03990 
04005 KDGanttViewItem* KDGanttView::getItemAt( const QPoint& pos, bool global ) const
04006 {
04007   /* buggy code - commented out
04008   QPoint myPos;
04009   if (  global )
04010     myPos = myListView->contentsToViewport( myListView->mapFromGlobal(pos) );
04011   else
04012      myPos = myListView->contentsToViewport( pos );
04013   return (KDGanttViewItem*) myListView->itemAt( myPos );
04014   */
04015 
04016   KDGanttViewItem* item;
04017   KDGanttViewItem* retItem = 0;
04018   int y;
04019   if ( global )
04020     y = myCanvasView->mapFromGlobal(pos).y();
04021   else
04022     y = pos.y();
04023   item = firstChild();
04024   while ( item != 0 ) {
04025     int yc = item->itemPos();
04026     if ( yc <= y && y < yc + item->height()) {
04027       retItem = item;
04028       break;
04029     }
04030     item = item->itemBelow();
04031   }
04032   return retItem;
04033 
04034 }
04035 
04036 
04037 void KDGanttView::addTickRight()
04038 {
04039   if ( _enableAdding && myCanvasView->horizontalScrollBar()->value() ==  myCanvasView->horizontalScrollBar()->maxValue()) {
04040     //myCanvasView->horizontalScrollBar()->blockSignals( true );
04041     myTimeHeader->addTickRight();
04042     //myCanvasView->horizontalScrollBar()->blockSignals( false );
04043     myCanvasView->updateHorScrollBar();
04044     setTimelineToEnd();
04045   }
04046 }
04047 
04048 
04049 void KDGanttView::addTickLeft()
04050 {
04051   if ( _enableAdding && myCanvasView->horizontalScrollBar()->value() == 0 ) {
04052     myCanvasView->horizontalScrollBar()->blockSignals( true );
04053     myTimeHeader->addTickLeft();
04054     myCanvasView->horizontalScrollBar()->blockSignals( false );
04055     setTimelineToStart();
04056   }
04057 }
04058 
04059 
04060 void KDGanttView::enableAdding( int val )
04061 {
04062   _enableAdding = ( val == 0 || val == myCanvasView->horizontalScrollBar()->maxValue());
04063 }
04064 
04065 
04071 int KDGanttView::childCount() const
04072 {
04073     return myListView->childCount();
04074 }
04075 
04076 
04080 void KDGanttView::clear()
04081 {
04082   bool block = myTimeTable->blockUpdating();
04083   myTimeTable->setBlockUpdating( true );
04084   myListView->clear();
04085   myTimeTable->setBlockUpdating( false );
04086   myTimeTable->updateMyContent();
04087   myTimeTable->setBlockUpdating( block );
04088 }
04089 
04090 
04094 void KDGanttView::slot_lvDropped(QDropEvent* e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse  )
04095 {
04096   emit dropped( e, droppedItem, itemBelowMouse);
04097 }
04098 
04102 QDragObject * KDGanttView::dragObject ()
04103 {
04104   return myListView->dragObject ();
04105 }
04106 
04107 
04111 void KDGanttView::startDrag ()
04112 {
04113   //myListView->pt_startDrag ();
04114 }
04115 
04116 
04120 void KDGanttView::setPaletteBackgroundColor( const QColor& col)
04121 {
04122   QWidget::setPaletteBackgroundColor( col );
04123   timeHeaderSpacerWidget->setPaletteBackgroundColor( col );
04124 }
04125 
04126 
04133 void KDGanttView::setGvBackgroundColor ( const QColor & c )
04134 {
04135   myTimeTable->setBackgroundColor( c );
04136 }
04137 
04138 
04145 void KDGanttView::setTimeHeaderBackgroundColor ( const QColor & c )
04146 {
04147   myTimeHeader->setPaletteBackgroundColor( c );
04148   //rightWidget->setPaletteBackgroundColor( c );
04149   timeHeaderSpacerWidget->setPaletteBackgroundColor( c );
04150 }
04151 
04152 
04159 void KDGanttView::setLegendHeaderBackgroundColor ( const QColor & c )
04160 {
04161   myLegend->setPaletteBackgroundColor( c );
04162   leftWidget->setPaletteBackgroundColor( c );
04163 }
04164 
04165 
04172 void KDGanttView::setLvBackgroundColor ( const QColor & c )
04173 {
04174  myListView->viewport()->setPaletteBackgroundColor( c );
04175 }
04176 
04177 
04184 QColor KDGanttView::lvBackgroundColor ( )const
04185 {
04186  return myListView->viewport()->paletteBackgroundColor( );
04187 }
04188 
04189 
04196 QColor KDGanttView::gvBackgroundColor () const
04197 {
04198  return myTimeTable->backgroundColor( );
04199 }
04200 
04201 
04208 QColor KDGanttView::timeHeaderBackgroundColor () const
04209 {
04210  return myTimeHeader->paletteBackgroundColor( );
04211 }
04212 
04213 
04220 QColor KDGanttView::legendHeaderBackgroundColor () const
04221 {
04222  return myLegend->paletteBackgroundColor( );
04223 }
04224 
04225 
04240 void KDGanttView::addUserdefinedLegendHeaderWidget( QWidget * w )
04241 {
04242   if ( w ) {
04243     w->reparent ( spacerLeft, 0, QPoint(0,0) );
04244   }
04245 }
04246 
04247 
04256 void KDGanttView::setDragEnabled( bool b )
04257 {
04258   fDragEnabled = b;
04259  QListViewItemIterator it( myListView );
04260  for ( ; it.current(); ++it ) {
04261    (( KDGanttViewItem* )it.current())->setDragEnabled(b);
04262  }
04263 
04264 }
04265 
04266 
04275 void KDGanttView::setDropEnabled( bool b )
04276 {
04277   fDropEnabled = b;
04278 
04279   //myListView->setAcceptDrops( b );
04280  QListViewItemIterator it( myListView );
04281  for ( ; it.current(); ++it ) {
04282    (( KDGanttViewItem* )it.current())->setDropEnabled(b);
04283  }
04284 }
04285 
04286 
04295 void KDGanttView::setDragDropEnabled( bool b )
04296 {
04297   setDropEnabled( b );
04298   setDragEnabled( b );
04299 }
04300 
04301 
04308 bool KDGanttView::isDragEnabled() const
04309 {
04310   return fDragEnabled;
04311 }
04312 
04313 
04320 bool KDGanttView::isDropEnabled() const
04321 {
04322  return fDropEnabled;
04323 }
04324 
04325 
04329 bool KDGanttView::dragEnabled() const
04330 {
04331   return isDragEnabled();
04332 }
04333 
04334 
04338 bool KDGanttView::dropEnabled() const
04339 {
04340  return isDropEnabled();
04341 }
04342 
04343 
04370 bool  KDGanttView::lvDropEvent ( QDropEvent* e,
04371                                  KDGanttViewItem* droppedItem,
04372                                  KDGanttViewItem* itemBelowMouse )
04373 {
04374     Q_UNUSED( e );
04375     Q_UNUSED( droppedItem );
04376     Q_UNUSED( itemBelowMouse );
04377 
04378   // Example code for user defined behaviour:
04379   // we want to accept the usual drags and the drags of files, which may be
04380   // a saved Gantt file.
04381   // Please uncomment the following lines for this behaviour
04382   // You have to uncomment lines in lvDragMoveEvent() and llvDragEnterEvent() as well
04383 
04384   // ************** begin example ************
04385   /*
04386   if ( QUriDrag::canDecode( e ) ) {
04387     QStrList lst;
04388     QUriDrag::decode( e, lst );
04389     // we try the first file of icon-url-list
04390     QString str = lst.at ( 0 );
04391     // remove file: at beginning of string
04392     str = str.right( str.length() - 5  );
04393     QFileInfo info;
04394     info.setFile( str ) ;
04395     if ( info.isFile() ) {
04396       if (!QMessageBox::information( this, "KDGantt Drag&Drop test",
04397                                      "Try to insert file: "+ str + " ?",
04398                                      "&Okay", "&Cancel",0,1  ) ) {
04399         QFile file( str );
04400         // store current updating status
04401         bool uen = myTimeTable->blockUpdating();
04402         // block updating while insertion of items
04403         myTimeTable->setBlockUpdating();
04404         loadProject( &file ) ;
04405         // restore updating status and execute an update via setUpdateEnabled( true );
04406         if ( !uen )
04407           setUpdateEnabled( true );
04408       }
04409     }
04410     return true;
04411   }
04412   */
04413   // *********** end example ****************
04414   return false;
04415 }
04416 
04417 
04434 void  KDGanttView::lvDragEnterEvent ( QDragEnterEvent * e)
04435 {
04436   // the standard behaviour:
04437   // accept drag enter events, if KDGanttViewItemDrag can decode the event
04438   // e->accept(KDGanttViewItemDrag::canDecode(e) );
04439 
04440   if ( KDGanttViewItemDrag::canDecode(e) ) {
04441     e->accept( true);
04442     return;
04443   }
04444 
04445   // example code for user defined behaviour:
04446   // we want to accecpt the usual drags and the drags of files, which may be
04447   // a saved Gantt file
04448   // Please uncomment the following lines for this behaviour
04449   // You have to uncomment lines in lvDragMoveEvent() and lvDropEvent () as well
04450 
04451   //  if ( QUriDrag::canDecode( e ) ) {
04452   // e->accept(true);
04453   //  return;
04454   // }
04455 
04456   e->accept( false );
04457 }
04458 
04459 
04488 bool  KDGanttView::lvDragMoveEvent ( QDragMoveEvent* /*e*/,
04489                                      KDGanttViewItem* /* draggedItem*/,
04490                                      KDGanttViewItem* /*itemBelowMouse*/)
04491 {
04492 
04493   // Example code 1:
04494   // To generally block items to be inserted as root items, subclass KDGanttView
04495   // and reimplement this method with to following code uncommented:
04496 
04497   // if ( !itemBelowMouse ) {
04498   //  e->accept( false );
04499   //  return true;
04500   //}
04501   //return false;
04502 
04503   // Example code 2:
04504   // To allow the drags of files, which may be
04505   // a saved Gantt file, subclass KDGanttView
04506   // and reimplement this method with to following code uncommented:
04507 
04508   // if ( QUriDrag::canDecode( e ) ) {
04509   //   e->accept(true);
04510   //   return true;
04511   //  }
04512 
04513 
04514  // normal behaviour - the internal drag move event handling should be executed
04515   return false;
04516 }
04517 
04518 
04528 void  KDGanttView::lvStartDrag (KDGanttViewItem* item)
04529 {
04530   QDragObject* d = new KDGanttViewItemDrag(item, this, "itemdrag" );
04531   // call d->drag() to start the dragging
04532   // d->drag() returns true, if a move was requested as a drag
04533   // if a copy (by pressing the <Ctrl>-key) was performed, d->drag() returns false
04534   // In order to avoid starting drags for particular items, subclass KDGanttView
04535   // an reimplement this method.
04536   // insert here some code like
04537   // if ( item->parent() )
04538   // return;
04539   // This particular code will make it impossible to drag other items but root items.
04540   if ( d->drag()  ) {
04541       delete item;
04542   }
04543 }
04544 
04545 
04553 void  KDGanttView::setListViewWidth( int w )
04554 {
04555   int sw = mySplitter->width();
04556   QValueList<int> list;
04557   list.append(w);
04558   list.append(sw-w);
04559   mySplitter->setSizes( list );
04560 }
04561 
04562 
04569 int  KDGanttView::listViewWidth( )
04570 {
04571   return leftWidget->width();
04572 }
04573 
04574 
04584 void  KDGanttView::setLvVScrollBarMode( QScrollView::ScrollBarMode m )
04585 {
04586   myListView->setVScrollBarMode ( m );
04587 }
04588 
04589 
04599 void  KDGanttView::setGvVScrollBarMode( QScrollView::ScrollBarMode m )
04600 {
04601   if ( m == QScrollView::Auto )
04602     qDebug("KDGanttView::setListViewVScrollBarMode: QScrollView::Auto not supported. Nothing changed. ");
04603   else
04604     {
04605       myCanvasView->setVScrollBarMode ( m );
04606       if ( m == QScrollView::AlwaysOn )
04607         timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
04608       else
04609         timeHeaderSpacerWidget->setFixedWidth( 0 );
04610     }
04611 }
04612 
04613 
04614 void  KDGanttView::notifyEditdialog( KDGanttViewItem * item)
04615 {
04616   if (myItemAttributeDialog->getItem() == item ) {
04617     myItemAttributeDialog->reset( 0 );
04618   }
04619 }
04620 
04628 void KDGanttView::setLinkItemsEnabled(bool on)
04629 {
04630     myCanvasView->linkItemsEnabled = on;
04631     myCanvasView->autoScrollEnabled = true;    
04632 }
04633 
04639 bool KDGanttView::isLinkItemsEnabled() const 
04640 {
04641     return myCanvasView->linkItemsEnabled;
04642 }
04643 
KDE Home | KDE Accessibility Home | Description of Access Keys