kdgantt

KDGanttView.cpp

00001 /* -*- Mode: C++ -*-
00002    $Id: KDGanttView.cpp 694771 2007-07-31 16:36:48Z ahartmetz $
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       mFixedHorizon( false )
00088 {
00089 #if defined KDAB_EVAL
00090     EvalDialog::checkEvalLicense( "KD Gantt" );
00091 #endif
00092   myCurrentItem = 0;
00093     setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
00094     mySplitter = new KDGanttMinimizeSplitter( this );
00095     mySplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
00096     leftWidget = new QVBox( mySplitter );
00097     rightWidget = new QVBox( mySplitter );
00098 
00099     myLegend = new KDLegendWidget( leftWidget, this );
00100     spacerLeft = new QHBox( leftWidget );
00101     myListView = new KDListView(leftWidget, this);
00102     myListView->setVScrollBarMode (QScrollView::AlwaysOff );
00103     connect( myListView, SIGNAL( selectionChanged( QListViewItem* ) ),
00104              this, SLOT( slotSelectionChanged( QListViewItem* ) ) );
00105 
00106     connect( myListView, SIGNAL( mouseButtonClicked ( int, QListViewItem * , const QPoint &, int ) ), this, SLOT( slotmouseButtonClicked ( int , QListViewItem * , const QPoint &, int ) ) );
00107     connect( myListView, SIGNAL( contextMenuRequested ( QListViewItem * , const QPoint &, int  ) ), this, SLOT( slotcontextMenuRequested ( QListViewItem * , const QPoint & , int ) ) );
00108     connect( myListView, SIGNAL(doubleClicked ( QListViewItem *  ) ), this, SLOT(slotdoubleClicked ( QListViewItem * ) ) );
00109 
00110   connect( myListView, SIGNAL(currentChanged( QListViewItem *  ) ), this, SLOT(slotCurrentChanged ( QListViewItem * ) ) );
00111   connect( myListView, SIGNAL(itemRenamed ( QListViewItem * , int , const QString &  ) ), this, SLOT(slotItemRenamed ( QListViewItem *, int , const QString &  ) ) );
00112   connect( myListView, SIGNAL(mouseButtonPressed(  int, QListViewItem * , const QPoint &, int ) ), this, SLOT(slotMouseButtonPressed (  int , QListViewItem * , const QPoint & , int ) ) );
00113 
00114     //connect( myListView, SIGNAL( ), this, SLOT( ) );
00115     myTimeTable = new KDTimeTableWidget (rightWidget,this);
00116 
00117     spacerRight = new QWidget(  rightWidget );
00118 
00119     myTimeHeaderContainer = new QHBox( rightWidget );
00120     myTimeHeaderContainer->setFrameStyle( QFrame::NoFrame  );
00121     myTimeHeaderContainer->setMargin( 0 );
00122     myTimeHeaderScroll = new QScrollView ( myTimeHeaderContainer );
00123     myTimeHeaderScroll->setHScrollBarMode( QScrollView::AlwaysOff );
00124     myTimeHeaderScroll->setVScrollBarMode( QScrollView::AlwaysOff );
00125     timeHeaderSpacerWidget = new QWidget( myTimeHeaderContainer );
00126 
00127 
00128     /*
00129     myTimeHeaderScroll = new QScrollView ( rightWidget );
00130     myTimeHeaderScroll->setHScrollBarMode( QScrollView::AlwaysOff );
00131     myTimeHeaderScroll->setVScrollBarMode( QScrollView::AlwaysOn );
00132     */
00133     //myTimeHeader = new KDTimeHeaderWidget (rightWidget,this);
00134     myTimeHeader = new KDTimeHeaderWidget (myTimeHeaderScroll->viewport(),this);
00135     myTimeHeaderScroll->addChild( myTimeHeader );
00136     myTimeHeaderScroll->viewport()->setBackgroundColor( myTimeHeader->backgroundColor() );
00137     timeHeaderSpacerWidget->setBackgroundColor( myTimeHeader->backgroundColor() );
00138     myCanvasView = new KDGanttCanvasView (this,myTimeTable,rightWidget);
00139     myTimeHeaderScroll->setFrameStyle( QFrame::NoFrame  );
00140     //
00141     myCanvasView->setFrameStyle( QFrame::NoFrame  );
00142     myCanvasView->setMargin( 0 );
00143     //
00144     myTimeHeaderScroll->setMargin( 0 );//myCanvasView->frameWidth() );
00145     setFrameStyle(myListView->frameStyle());
00146     setLineWidth( 2 );
00147     myListView->setFrameStyle( QFrame::NoFrame  );
00148     myListView->setMargin( 0 );
00149     QObject::connect(myListView, SIGNAL (  expanded ( QListViewItem * ) ) , myTimeTable , SLOT( expandItem(QListViewItem * ))) ;
00150     QObject::connect(myListView, SIGNAL (collapsed ( QListViewItem * ) ) , myTimeTable , SLOT(collapseItem(QListViewItem * ))) ;
00151 
00152     timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
00153     listViewIsVisible = true;
00154     chartIsEditable = true;
00155     editorIsEnabled = true;
00156     _displaySubitemsAsGroup = false;
00157     initDefaults();
00158     _showHeader = false;
00159 
00160     myTextColor = Qt::black;
00161     myLegendItems = new QPtrList<legendItem>;
00162     //QObject::connect( this, SIGNAL (itemDoubleClicked( KDGanttViewItem* ) ) , this, SLOT( editItem( KDGanttViewItem*  ))) ;
00163     myItemAttributeDialog = new itemAttributeDialog();
00164     setRepaintMode( KDGanttView::Medium );
00165     //setRepaintMode( KDGanttView::Always );
00166     setShowLegendButton( true );
00167     setHeaderVisible( false );
00168 
00169     // now connecting the widgets
00170     connect(myCanvasView->horizontalScrollBar(), SIGNAL (  valueChanged ( int )) ,myTimeHeaderScroll->horizontalScrollBar(), SLOT( setValue ( int))) ;
00171     connect(myCanvasView, SIGNAL (  heightResized( int )) ,myTimeTable, SLOT( checkHeight ( int))) ;
00172     connect(myCanvasView, SIGNAL (  widthResized( int )) ,myTimeHeader, SLOT( checkWidth ( int))) ;
00173 
00174     QObject::connect(myCanvasView->verticalScrollBar(), SIGNAL ( valueChanged ( int ) ) ,myListView->verticalScrollBar(), SLOT( setValue ( int ))) ;
00175     connect(myTimeHeader, SIGNAL ( sizeChanged( int ) ) ,this, SLOT(slotHeaderSizeChanged()  )) ;
00176     connect(myTimeHeader, SIGNAL ( sizeChanged( int ) ) ,myTimeTable, SLOT(resetWidth( int ) )) ;
00177     connect(myListView, SIGNAL ( contentsMoving ( int, int ) ) ,myCanvasView, SLOT(  moveMyContent( int, int ))) ;
00178    connect(myTimeTable, SIGNAL ( heightComputed ( int ) ) ,myCanvasView, SLOT(  setMyContentsHeight( int ))) ;
00179    // the next three are for adding new ticks at left/right
00180     connect( myCanvasView->horizontalScrollBar(), SIGNAL (prevLine () ) ,this, SLOT(addTickLeft()));
00181     connect( myCanvasView->horizontalScrollBar(), SIGNAL (nextLine () ) ,this, SLOT(addTickRight()));
00182     connect( myCanvasView->horizontalScrollBar(), SIGNAL (valueChanged ( int ) ) ,this, SLOT( enableAdding( int )));
00183 
00184    // now initing
00185     fCenterTimeLineAfterShow = false;
00186     fDragEnabled = false;
00187     fDropEnabled = false;
00188     closingBlocked = false;
00189    myTimeHeader->computeTicks();
00190    centerTimelineAfterShow( QDateTime::currentDateTime () );
00191    setDisplayEmptyTasksAsLine( false );
00192    QValueList<int> list;
00193    list.append(240);
00194    list.append(530);
00195    mySplitter->setSizes( list );
00196    myTimeTable->setBlockUpdating();// block updating until this->show() is called
00197 }
00198 
00199 
00200 
00201 KDGanttView::~KDGanttView()
00202 {
00203   setUpdateEnabled(false);
00204   // delete cut item, if there is any
00205   myCanvasView->resetCutPaste( 0 );
00206   myTimeTable->clearTaskLinks();
00207 }
00231 void KDGanttView::setUpdateEnabled( bool enable )
00232 {
00233   myTimeTable->setBlockUpdating( !enable );
00234   if ( enable ) {
00235     myTimeTable->updateMyContent();
00236     myCanvasView->setMyContentsHeight( 0 );
00237   }
00238 }
00239 
00247 bool KDGanttView::getUpdateEnabled() const
00248 {
00249   return !myTimeTable->blockUpdating();
00250 }
00251 
00252 
00253 
00254 
00261 void KDGanttView::setGanttMaximumWidth( int w )
00262 {
00263   myTimeHeader->setMaximumWidth ( w );
00264 }
00272 int  KDGanttView::ganttMaximumWidth() const
00273 {
00274   return myTimeHeader->maximumWidth();
00275 }
00276 
00283 void KDGanttView::show()
00284 {
00285   myTimeTable->setBlockUpdating( false );
00286   if (myCanvasView->horizontalScrollBar()->value() > 0 )
00287     myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->value()-1  );
00288   else
00289     myCanvasView->horizontalScrollBar()->setValue(1 );
00290   myTimeTable->updateMyContent();
00291   QWidget::show();
00292   myCanvasView->setMyContentsHeight( 0 );
00293   if ( fCenterTimeLineAfterShow ) {
00294     fCenterTimeLineAfterShow = false;
00295     centerTimeline (dtCenterTimeLineAfterShow);
00296   }
00297 }
00305 bool KDGanttView::close ( bool alsoDelete )
00306 {
00307   //qDebug("close ");
00308   if ( closingBlocked )
00309     return false;
00310   return QWidget::close ( alsoDelete );
00311 }
00312 
00313 
00322 QSize KDGanttView::sizeHint() const
00323 {
00324   bool block = myTimeTable->blockUpdating();
00325   myTimeTable->setBlockUpdating( false );
00326   myTimeTable->updateMyContent();
00327   /* The below causes recursive calls to various size updating methods, which
00328    * cause QCanvas to hide and show items like mad, which is very slow. If
00329    * there is a legitimate gui updating issue here somewhere, it will need
00330    * to be solved differently.
00331    */
00332   //qApp->processEvents();
00333   int hintHeight = myTimeHeader->height();
00334   int legendHeight = 0;
00335   if ( showLegendButton() )
00336     legendHeight = myLegend->height();
00337   int listViewHeaderHeight = 0;
00338   if ( headerVisible() )
00339     listViewHeaderHeight = myListView->header()->height();
00340   if ( hintHeight < legendHeight+listViewHeaderHeight )
00341     hintHeight = legendHeight + listViewHeaderHeight;
00342   hintHeight += myListView->horizontalScrollBar()->height();
00343   if ( myLegend->isShown() )
00344     hintHeight += myLegend->legendSizeHint().height() +10;
00345   hintHeight += myTimeTable->minimumHeight+myListView->frameWidth()*2+2;
00346   int hintWid = myListView->sizeHint().width();
00347   //hintWid += myTimeHeader->mySizeHint+myCanvasView->verticalScrollBar()->width();
00348   hintWid += myCanvasView->sizeHint().width();
00349   // add 10 for the splitter-bars
00350   // qDebug("sizehint %d %d ",hintWid+10, hintHeight );
00351   myTimeTable->setBlockUpdating( block );
00352   return QSize( hintWid+10, hintHeight );
00353 }
00354 
00355 
00363 void KDGanttView::setShowLegendButton( bool show )
00364 {
00365   _showLegendButton = show;
00366      if ( show )
00367          myLegend->show();
00368     else
00369          myLegend->hide();
00370      slotHeaderSizeChanged();
00371 }
00372 
00373 
00380 bool KDGanttView::showLegendButton() const
00381 {
00382     return _showLegendButton;
00383 }
00384 
00385 
00392 void KDGanttView::setHeaderVisible( bool visible )
00393 {
00394     if( visible )
00395         myListView->header()->show();
00396     else
00397         myListView->header()->hide();
00398     _showHeader = visible;
00399     slotHeaderSizeChanged();
00400 }
00401 
00402 
00408 bool KDGanttView::headerVisible() const
00409 {
00410   return _showHeader;
00411 }
00412 
00413 
00422 QDateTime KDGanttView::getDateTimeForCoordX(int coordX, bool global ) const
00423 {
00424   // default for myTimeHeader->getDateTimeForIndex() is local
00425    return myTimeHeader->getDateTimeForIndex(coordX, !global );
00426 }
00427 
00428 
00432 void KDGanttView::slotSelectionChanged( QListViewItem* item )
00433 {
00434     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00435     Q_ASSERT( gItem );
00436     emit lvSelectionChanged( gItem );
00437 }
00438 
00439 
00440 /*
00441   Implements a casted pass-through of the mouseButtonClicked() signal.
00442   Signals itemLeftClicked() , itemMidClicked() are emitted as well.
00443 */
00444 void KDGanttView::slotmouseButtonClicked ( int button, QListViewItem * item,
00445                                            const QPoint & pos, int c )
00446 {
00447   KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00448   emit lvMouseButtonClicked ( button , gItem,  pos,  c );
00449   if (gItem == 0 && myCurrentItem != 0 ) {
00450     myCurrentItem = 0;
00451     emit lvCurrentChanged( gItem );
00452   }
00453   if (gItem != 0 && myCurrentItem == 0 ) {
00454     myCurrentItem = gItem;
00455     emit lvCurrentChanged( gItem );
00456   }
00457 
00458   // removed - makes no sense!
00459   //emit mouseButtonClicked ( button , gItem,  pos,  c );
00460    {
00461     switch ( button ) {
00462     case  LeftButton:
00463       emit lvItemLeftClicked( gItem );
00464       emit itemLeftClicked( gItem );
00465       break;
00466     case  MidButton:
00467       emit lvItemMidClicked( gItem );
00468       emit itemMidClicked( gItem );
00469       break;
00470     }
00471   }
00472 }
00473 
00474 
00475 /*
00476   Implements a casted pass-through of the contextMenuRequested() signal.
00477   The signal itemRightClicked() is emitted as well;
00478   the position is the global position.
00479 */
00480 void KDGanttView::slotcontextMenuRequested ( QListViewItem * item, const QPoint & pos, int col )
00481 {
00482     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00483     emit lvContextMenuRequested ( gItem,  pos,  col );
00484     emit lvItemRightClicked( gItem );
00485     emit itemRightClicked( gItem );
00486 }
00487 
00488 
00489 /*
00490   Implements a casted pass-through of the doubleClicked() signal.
00491 */
00492 void KDGanttView::slotdoubleClicked ( QListViewItem * item )
00493 {
00494    {
00495     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00496     emit lvItemDoubleClicked( gItem );
00497     emit itemDoubleClicked( gItem );
00498   }
00499 }
00500 
00501 
00502 void KDGanttView::emptySpaceDoubleClicked( QMouseEvent * e )
00503 {
00504     emit dateTimeDoubleClicked( getDateTimeForCoordX( e->x(), false ) );
00505 }
00506 
00507 
00508 /*
00509   Implements a casted pass-through of the currentChanged() signal.
00510 */
00511 void KDGanttView::slotCurrentChanged ( QListViewItem * item )
00512 {
00513     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00514     myCurrentItem = gItem;
00515     emit lvCurrentChanged( gItem );
00516 }
00517 
00518 
00519 /*
00520   Implements a casted pass-through of the itemRenamed() signal.
00521 */
00522 void KDGanttView::slotItemRenamed ( QListViewItem * item , int col,
00523                                     const QString & text )
00524 {
00525     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00526     emit lvItemRenamed( gItem,  col, text );
00527 }
00528 
00529 
00530 /*
00531   Implements a casted pass-through of the mouseButtonPressed() signal.
00532 */
00533 void KDGanttView::slotMouseButtonPressed ( int button, QListViewItem * item,
00534                                            const QPoint & pos, int c )
00535 {
00536     KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
00537     emit lvMouseButtonPressed( button, gItem,  pos,  c  );
00538 }
00539 
00540 
00555 void KDGanttView::setRepaintMode( RepaintMode mode )
00556 {
00557 
00558   QScrollBar  *cvh, *cvv;
00559   cvh = myCanvasView->horizontalScrollBar();
00560   cvv = myCanvasView->verticalScrollBar();
00561   // first disconnect
00562   cvh->disconnect( this );
00563   cvv->disconnect( this );
00564 
00565   switch ( mode ) {
00566   case  No:
00567 
00568     break;
00569   case Medium:
00570     connect( cvv, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00571     connect( cvh, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00572     connect( cvv, SIGNAL (nextLine () ) ,this, SLOT(forceRepaint()));
00573     connect( cvh, SIGNAL (nextLine () ) ,this, SLOT(forceRepaint()));
00574     connect( cvv, SIGNAL (prevLine () ) ,this, SLOT(forceRepaint()));
00575     connect( cvh, SIGNAL (prevLine () ) ,this, SLOT(forceRepaint()));
00576     break;
00577   case Always:
00578     connect( cvv, SIGNAL (valueChanged ( int ) ) ,this, SLOT(forceRepaint( int )));
00579     connect( cvh, SIGNAL (valueChanged ( int ) ) ,this, SLOT(forceRepaint( int )));
00580     connect( cvv, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00581     connect( cvh, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
00582     break;
00583   }
00584 }
00585 
00586 
00587 void KDGanttView::forceRepaint( int )
00588 {
00589   if ( myTimeTable->blockUpdating() )
00590     return;
00591   // qDebug("forceRepaint( int ) ");
00592   myTimeTable->setAllChanged();
00593   myTimeTable->update();
00594 }
00595 
00596 
00597 void KDGanttView::slotHeaderSizeChanged()
00598 {
00599   int legendHeight = 0;
00600   if ( showLegendButton() )
00601     legendHeight = 24;
00602   int listViewHeaderHeight = 0;
00603   if ( headerVisible() )
00604     listViewHeaderHeight = myListView->header()->height();
00605   int timeHeaderHeight = myTimeHeader->height()+myTimeHeaderScroll->frameWidth()*2;;
00606   int diffY = timeHeaderHeight-legendHeight-listViewHeaderHeight;
00607   if ( diffY < 0 ) {
00608     spacerLeft->setFixedHeight( 0 );
00609     spacerRight->setFixedHeight(-diffY);
00610   } else {
00611     spacerRight->setFixedHeight( 0 );
00612     spacerLeft->setFixedHeight( diffY );
00613   }
00614   myLegend->setFixedHeight( legendHeight );
00615   myTimeHeaderContainer->setFixedHeight( timeHeaderHeight );
00616 }
00617 
00618 void KDGanttView::setLegendIsDockwindow( bool show )
00625 {
00626   bool isdock = myLegend->asDockwindow();
00627   if ( show != isdock ) {
00628     myLegend->setAsDockwindow(show);
00629     // legend is cleared - reinit legend with list
00630     legendItem* li;
00631     for ( li = myLegendItems->first(); li; li = myLegendItems->next() ) {
00632       myLegend->addLegendItem(li->shape, li->color, li->text );
00633     }
00634   }
00635 }
00636 
00637 bool KDGanttView::legendIsDockwindow() const
00644 {
00645     return myLegend->asDockwindow();
00646 }
00647 
00648 
00661 QDockWindow* KDGanttView::legendDockwindow() const
00662 {
00663   return myLegend->dockwindow();
00664 }
00665 
00666 
00675 void KDGanttView::setShowLegend( bool show )
00676 {
00677     myLegend->showMe(show);
00678 }
00679 
00680 
00689 bool KDGanttView::showLegend() const
00690 {
00691     return myLegend->isShown();
00692 }
00693 
00694 
00703 void KDGanttView::setShowListView( bool show )
00704 {
00705     if(listViewIsVisible == show) return;
00706     listViewIsVisible = show;
00707     if (listViewIsVisible)
00708         myListView->parentWidget()->show();
00709     else
00710         myListView->parentWidget()->hide();
00711 }
00712 
00713 
00720 bool KDGanttView::showListView() const
00721 {
00722     return listViewIsVisible;
00723 }
00724 
00725 
00735 void KDGanttView::setEditorEnabled( bool enable )
00736 {
00737   editorIsEnabled =  enable;
00738 }
00739 
00740 
00749 bool KDGanttView::editorEnabled() const
00750 {
00751     return editorIsEnabled;
00752 }
00753 
00754 
00763 void KDGanttView::setEditable( bool editable )
00764 {
00765   chartIsEditable =  editable;
00766 }
00767 
00768 
00776 bool KDGanttView::editable() const
00777 {
00778     return chartIsEditable;
00779 }
00780 
00781 
00793 bool KDGanttView::saveProject( QIODevice* device )
00794 {
00795     Q_ASSERT( device );
00796 
00797     QDomDocument doc = saveXML();
00798     if( device->isOpen() )
00799         device->close();
00800     if( device->open( IO_WriteOnly ) ) {
00801         QTextStream ts( device );
00802         ts << doc.toString();
00803         return true;
00804     } else
00805         return false;
00806 }
00807 
00808 
00820 bool KDGanttView::loadProject( QIODevice* device )
00821 {
00822     Q_ASSERT( device );
00823 
00824     if( device->isOpen() )
00825         device->close();
00826     if( device->open( IO_ReadOnly ) ) {
00827         QDomDocument doc( "GanttView" );
00828         QString err;
00829         int errline, errcol;
00830         if ( !doc.setContent( device, &err, &errline, &errcol ) ) {
00831           qDebug("KDGantt::Error parsing XML data at line %d. Message is:", errline );
00832           qDebug("%s ", err.latin1());
00833           device->close();
00834           return false;
00835         }
00836         device->close();
00837         return loadXML( doc );
00838     } else
00839         return false;
00840 }
00841 
00842 
00861 void KDGanttView::print( QPrinter* printer ,
00862                          bool printListView, bool printTimeLine,
00863                          bool printLegend )
00864 {
00865   bool deletePrinter = false;
00866   if (! printer ) {
00867     printer = new QPrinter();
00868     deletePrinter = true;
00869     if ( !printer->setup()) {
00870       delete printer;
00871       return;
00872     }
00873   }
00874   // now we have a printer to print on
00875   QPainter p( printer );
00876   // get the paper metrics
00877   QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
00878   float dx, dy;
00879   // get the size of the desired output for scaling.
00880   // here we want to print all: ListView, TimeLine, and Legend
00881   // for this purpose, we call drawContents() with a 0 pointer as painter
00882   QSize size = drawContents( 0, printListView, printTimeLine, printLegend );
00883 
00884   // at the top, we want to print current time/date
00885   QString date = "Printing Time: " + QDateTime::currentDateTime().toString();
00886   int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
00887   p.drawText( 0, 0, date );
00888 
00889   // compute the scale
00890   dx = (float) m.width()  / (float)size.width();
00891   dy  = (float)(m.height() - ( 2 * hei )) / (float)size.height();
00892   float scale;
00893   // scale to fit the width or height of the paper
00894   if ( dx < dy )
00895     scale = dx;
00896   else
00897     scale = dy;
00898   // set the scale
00899   p.scale( scale, scale );
00900   // now printing with y offset:  2 hei
00901   p.translate( 0, 2*hei );
00902   drawContents( &p, printListView, printTimeLine, printLegend );
00903   // the drawContents() has the side effect, that the painter translation is
00904   // after drawContents() set to the bottom of the painted stuff
00905   // for instance a
00906   // p.drawText(0, 0, "printend");
00907   // would be painted directly below the paintout of drawContents()
00908   p.end();
00909   if ( deletePrinter )
00910     delete printer;
00911 }
00912 
00913 
00953 QSize KDGanttView::drawContents( QPainter* p,
00954                       bool drawListView , bool drawTimeLine, bool drawLegend )
00955 {
00956   QSize size;
00957   int lvX, lvY, thX, thY, tlX, tlY, lwX, lwY, allX, allY;
00958   lvX = myListView->contentsWidth();
00959   lvY = myCanvasView->canvas()->height() + 20;
00960   thX = myTimeHeader->width();
00961   thY = myTimeHeader->height();
00962   tlX = myCanvasView->canvas()->width();
00963   tlY = lvY;
00964   lwX = myLegend->legendSize().width();
00965   lwY = myLegend->legendSize().height();
00966   allX = 0;
00967   allY = 0;
00968   if ( drawListView ) {
00969     allX += lvX;
00970     allY += tlY;
00971   }
00972   if ( drawTimeLine ) {
00973     allX += thX;
00974     allY += thY;
00975   }
00976   if ( drawLegend ) {
00977     allY += lwY;
00978     if ( allX < lwX )
00979       allX = lwX ;
00980   }
00981   size = QSize( allX, allY );
00982   int temp = 0;
00983   if ( p ) {
00984     if ( drawListView ) {
00985       if ( drawTimeLine )
00986         temp =  thY;
00987       p->translate( 0, temp );
00988       //HACK: Only draw list headers if we draw timeline, else
00989       // there is no room for it. This will most probably be changed
00990       // with qt4 anyway, so I think we can live with it atm.
00991       myListView->drawToPainter( p, drawTimeLine );
00992       p->translate( lvX, -temp);
00993     }
00994     if ( drawTimeLine ) {
00995       p->translate( myCanvasView->frameWidth(), 0);
00996       myTimeHeader->repaintMe( 0, myTimeHeader->width(), p );
00997       p->translate( -myCanvasView->frameWidth(), thY);
00998       myCanvasView->drawToPainter( p );
00999       if ( drawListView )
01000         p->translate( -lvX, tlY);
01001       else
01002         p->translate( 0, tlY);
01003     } else {
01004       if ( drawListView )
01005         p->translate( -lvX, 0 );
01006     }
01007     if ( drawLegend ) {
01008        myLegend->drawToPainter( p );
01009        p->translate( 0, lwY );
01010     }
01011   }
01012   return size;
01013 }
01014 
01028 void KDGanttView::setZoomFactor( double factor, bool absolute )
01029 {
01030     myTimeHeader->zoom(factor,absolute);
01031 }
01032 
01033 
01041 double KDGanttView::zoomFactor() const
01042 {
01043     return myTimeHeader->zoomFactor();
01044 }
01045 
01046 
01055 void KDGanttView::zoomToFit()
01056 {
01057   myTimeHeader->zoomToFit();
01058 }
01059 
01060 
01072 void KDGanttView::zoomToSelection( const QDateTime& start,  const QDateTime&  end )
01073 {
01074 
01075   myTimeHeader->zoomToSelection( start, end);
01076 
01077 }
01078 
01079 
01086 void KDGanttView::ensureVisible( KDGanttViewItem* item )
01087 {
01088     myListView->ensureItemVisible (item);
01089 }
01090 
01091 
01100 void KDGanttView::centerTimeline( const QDateTime& center )
01101 {
01102   myTimeHeader->centerDateTime( center );
01103 }
01104 
01105 
01119 void KDGanttView::centerTimelineAfterShow( const QDateTime& center )
01120 {
01121   myTimeHeader->centerDateTime( center );
01122   if ( ! isVisible() ) {
01123     dtCenterTimeLineAfterShow = center;
01124     fCenterTimeLineAfterShow = true;
01125   }
01126 }
01127 
01132 void KDGanttView::setTimelineToStart()
01133 {
01134   myCanvasView->horizontalScrollBar()->setValue( 0 );
01135 }
01136 
01137 
01141 void KDGanttView::setTimelineToEnd()
01142 {
01143  myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->maxValue());
01144 }
01145 
01146 
01157 void KDGanttView::addTicksLeft( int num )
01158 {
01159   myTimeHeader->addTickLeft( num  );
01160 }
01161 
01162 
01172 void KDGanttView::addTicksRight( int num )
01173 {
01174   myTimeHeader->addTickRight( num );
01175 }
01176 
01177 
01182 void KDGanttView::center( KDGanttViewItem* item )
01183 {
01184     ensureVisible(item);
01185     int x =  myListView->contentsWidth()/2;
01186     int y = myListView->itemPos (item );
01187     myListView->center(x,y);
01188 }
01189 
01190 
01197 void KDGanttView::setShowTaskLinks( bool show )
01198 {
01199     myTimeTable->setShowTaskLinks(show);
01200 
01201 }
01202 
01203 
01210 bool KDGanttView::showTaskLinks() const
01211 {
01212     return  myTimeTable->showTaskLinks();
01213 }
01214 
01215 
01223 void KDGanttView::setFont(const QFont& font)
01224 {
01225     myListView->setFont(font);
01226     myListView->repaint();
01227     myTimeHeader->setFont(font);
01228     myLegend->setFont( font );
01229     QWidget::setFont( font );
01230     setScale(scale());
01231 }
01232 
01233 
01258 void KDGanttView::setShowHeaderPopupMenu( bool show,
01259                                           bool showZoom,
01260                                           bool showScale,
01261                                           bool showTime,
01262                                           bool showYear,
01263                                           bool showGrid,
01264                                           bool showPrint)
01265 {
01266     myTimeHeader->setShowPopupMenu( show,showZoom,showScale,showTime,
01267                                     showYear,showGrid,showPrint );
01268 }
01269 
01270 
01277 bool KDGanttView::showHeaderPopupMenu() const
01278 {
01279     return myTimeHeader->showPopupMenu();
01280 }
01281 //****************************************************
01282 
01283 
01297 void KDGanttView::setShowTimeTablePopupMenu( bool show )
01298 {
01299     myCanvasView->setShowPopupMenu( show );
01300 }
01301 
01302 
01309 bool KDGanttView::showTimeTablePopupMenu() const
01310 {
01311     return myCanvasView->showPopupMenu();
01312 }
01313 
01314 
01332 void KDGanttView::setShapes( KDGanttViewItem::Type type,
01333                              KDGanttViewItem::Shape start,
01334                              KDGanttViewItem::Shape middle,
01335                              KDGanttViewItem::Shape end,
01336                              bool overwriteExisting )
01337 {
01338     if ( overwriteExisting ) {
01339       QListViewItemIterator it(myListView);
01340       for ( ; it.current(); ++it ) {
01341         if ( ((KDGanttViewItem*)it.current())->type() == type)
01342           ((KDGanttViewItem*)it.current())->setShapes(start,middle, end );
01343       }
01344     }
01345     int index = getIndex( type );
01346     myDefaultShape [index*3] = start;
01347     myDefaultShape [index*3+1] = middle;
01348     myDefaultShape [index*3+2] = end;
01349     undefinedShape[index] = false;
01350 }
01351 
01352 
01365 bool KDGanttView::shapes( KDGanttViewItem::Type type,
01366                           KDGanttViewItem::Shape& start,
01367                           KDGanttViewItem::Shape& middle,
01368                           KDGanttViewItem::Shape& end ) const
01369 {
01370     int index = getIndex( type );
01371     start = myDefaultShape [index*3];
01372     middle = myDefaultShape [index*3+1];
01373     end = myDefaultShape [index*3+2];
01374     return !undefinedShape[index];
01375 }
01376 
01377 
01395 void KDGanttView::setColors( KDGanttViewItem::Type type,
01396                              const QColor& start, const QColor& middle,
01397                              const QColor& end,
01398                              bool overwriteExisting )
01399 {
01400     if ( overwriteExisting ) {
01401       QListViewItemIterator it(myListView);
01402       for ( ; it.current(); ++it ) {
01403         if ( ((KDGanttViewItem*)it.current())->type() == type)
01404           ((KDGanttViewItem*)it.current())->setColors(start,middle, end );
01405       }
01406     }
01407     int index = getIndex( type );
01408     myColor [index*3] = start;
01409     myColor [index*3+1] = middle;
01410     myColor [index*3+2] = end;
01411     undefinedColor[index] = false;
01412 }
01413 
01414 
01427 bool KDGanttView::colors( KDGanttViewItem::Type type,
01428                           QColor& start, QColor& middle, QColor& end ) const
01429 {
01430   int index = getIndex( type );
01431   start = myColor [index*3];
01432     middle = myColor [index*3+1];
01433     end = myColor [index*3+2];
01434     return !undefinedColor[index];
01435 }
01436 
01437 
01457 void KDGanttView::setHighlightColors( KDGanttViewItem::Type type,
01458                                       const QColor& start,
01459                                       const QColor& middle,
01460                                       const QColor& end,
01461                                       bool overwriteExisting )
01462 {
01463     if ( overwriteExisting ) {
01464       QListViewItemIterator it(myListView);
01465       for ( ; it.current(); ++it ) {
01466         if ( ((KDGanttViewItem*)it.current())->type() == type)
01467           ((KDGanttViewItem*)it.current())->setHighlightColors(start,middle, end );
01468       }
01469     }
01470     int index = getIndex( type );
01471     myColorHL [index*3] = start;
01472     myColorHL [index*3+1] = middle;
01473     myColorHL [index*3+2] = end;
01474     undefinedColorHL[index] = false;
01475 
01476 }
01477 
01478 
01493 bool KDGanttView::highlightColors( KDGanttViewItem::Type type,
01494                                    QColor& start, QColor& middle,
01495                                    QColor& end ) const
01496 {
01497   int index = getIndex( type );
01498   start = myColorHL [index*3];
01499     middle = myColorHL [index*3+1];
01500     end = myColorHL [index*3+2];
01501     return !undefinedColorHL[index];
01502 }
01503 
01504 
01512 void KDGanttView::setTextColor( const QColor& color )
01513 {
01514     QListViewItemIterator it(myListView);
01515     for ( ; it.current(); ++it ) {
01516         ((KDGanttViewItem*)it.current())->setTextColor(color);
01517     }
01518     myTextColor = color;
01519 }
01520 
01521 
01528 QColor KDGanttView::textColor() const
01529 {
01530     return myTextColor;
01531 }
01532 
01533 
01544 void KDGanttView::setNoInformationBrush( const QBrush& brush )
01545 {
01546   myTimeTable->setNoInformationBrush( brush );
01547 }
01548 
01549 
01556 QBrush KDGanttView::noInformationBrush() const
01557 {
01558   return myTimeTable->noInformationBrush();
01559 }
01560 
01561 
01567 void KDGanttView::clearLegend( )
01568 {
01569     myLegend->clearLegend();
01570     myLegendItems->setAutoDelete( true );
01571     delete myLegendItems;
01572     myLegendItems = new QPtrList<legendItem>;
01573 }
01574 
01575 
01584 void KDGanttView::addLegendItem( KDGanttViewItem::Shape shape,
01585                                  const QColor& shapeColor,
01586                                  const QString& text )
01587 {
01588     myLegend->addLegendItem( shape,shapeColor,text );
01589     legendItem* item = new legendItem;
01590     item->shape = shape;
01591     item->color = shapeColor;
01592     item->text = text;
01593     myLegendItems->append( item );
01594 }
01595 
01596 
01604 void KDGanttView::setHorizonStart( const QDateTime& start )
01605 {
01606     myTimeHeader->setHorizonStart(start);
01607 }
01608 
01609 
01616 QDateTime KDGanttView::horizonStart() const
01617 {
01618     return myTimeHeader->horizonStart();
01619 }
01620 
01621 
01629 void KDGanttView::setHorizonEnd( const QDateTime& end )
01630 {
01631     myTimeHeader->setHorizonEnd(end);
01632 }
01633 
01634 
01642 QDateTime KDGanttView::horizonEnd() const
01643 {
01644     return myTimeHeader->horizonEnd();
01645 }
01646 
01647 
01655 void KDGanttView::setScale( Scale unit )
01656 {
01657     myTimeHeader->setScale( unit );
01658 }
01659 
01660 
01667 KDGanttView::Scale KDGanttView::scale() const
01668 {
01669     return myTimeHeader->scale();
01670 }
01671 
01672 
01679 void KDGanttView::setMaximumScale( Scale unit )
01680 {
01681     myTimeHeader->setMaximumScale( unit );
01682 }
01683 
01684 
01691 KDGanttView::Scale KDGanttView::maximumScale() const
01692 {
01693     return myTimeHeader->maximumScale();
01694 }
01695 
01696 
01703 void KDGanttView::setMinimumScale( Scale unit )
01704 {
01705     myTimeHeader->setMinimumScale( unit );
01706 }
01707 
01708 
01715 KDGanttView::Scale KDGanttView::minimumScale() const
01716 {
01717     return myTimeHeader->minimumScale();
01718 }
01719 
01720 
01730 void KDGanttView::setAutoScaleMinorTickCount( int count )
01731 {
01732   myTimeHeader->setAutoScaleMinorTickCount( count );
01733 }
01734 
01735 
01742 int KDGanttView::autoScaleMinorTickCount() const
01743 {
01744   return myTimeHeader->autoScaleMinorTickCount();
01745 }
01746 
01747 
01756 void KDGanttView::setMinimumColumnWidth( int width )
01757 {
01758     myTimeHeader->setMinimumColumnWidth( width );
01759 }
01760 
01761 
01768 int KDGanttView::minimumColumnWidth() const
01769 {
01770     return myTimeHeader->minimumColumnWidth();
01771 }
01772 
01773 
01781 void KDGanttView::setYearFormat( YearFormat format )
01782 {
01783     myTimeHeader->setYearFormat(format );
01784 }
01785 
01786 
01793 KDGanttView::YearFormat KDGanttView::yearFormat() const
01794 {
01795     return myTimeHeader->yearFormat();
01796 }
01797 
01798 
01807 void KDGanttView::setHourFormat( HourFormat format )
01808 {
01809     myTimeHeader->setHourFormat( format );
01810 }
01811 
01812 
01820 KDGanttView::HourFormat KDGanttView::hourFormat() const
01821 {
01822     return myTimeHeader->hourFormat();
01823 }
01824 
01825 
01836 void KDGanttView::setShowMajorTicks( bool show )
01837 {
01838     myTimeHeader->setShowMajorTicks(show );
01839 }
01840 
01841 
01848 bool KDGanttView::showMajorTicks() const
01849 {
01850     return myTimeHeader->showMajorTicks();
01851 }
01852 
01853 
01866 void KDGanttView::setShowMinorTicks( bool show)
01867 {
01868     myTimeHeader->setShowMinorTicks( show );
01869 }
01870 
01871 
01878 bool KDGanttView::showMinorTicks() const
01879 {
01880     return myTimeHeader->showMinorTicks();
01881 }
01882 
01883 
01901 void KDGanttView::setColumnBackgroundColor( const QDateTime& column,
01902                                             const QColor& color ,
01903                                             Scale mini, Scale maxi )
01904 {
01905   myTimeHeader->setColumnBackgroundColor( column, color,mini,maxi );
01906 }
01907 
01908 #if 0
01909 
01935 void KDGanttView::setIntervalBackgroundColor( const QDateTime& start,
01936                                               const QDateTime& end,
01937                                               const QColor& color ,
01938                                               Scale mini, Scale maxi )
01939 {
01940   myTimeHeader->setIntervalBackgroundColor( start, end, color,mini,maxi );
01941 }
01942 
01943 
01962 bool KDGanttView::changeBackgroundInterval( const QDateTime& oldstart,
01963                                    const QDateTime& oldend,
01964                                    const QDateTime& newstart,
01965                                    const QDateTime& newend )
01966 {
01967   return myTimeHeader->changeBackgroundInterval( oldstart, oldend,
01968                                                  newstart, newend );
01969 }
01970 
01980 bool KDGanttView::deleteBackgroundInterval( const QDateTime& start,
01981                                             const QDateTime& end)
01982 {
01983   return myTimeHeader->deleteBackgroundInterval( start, end );
01984 }
01985 #endif
01986 
01992 void KDGanttView::addIntervalBackgroundColor( KDIntervalColorRectangle* newItem )
01993 {
01994   myTimeHeader->addIntervalBackgroundColor( newItem );
01995 }
01996 
02005 void KDGanttView::clearBackgroundColor()
02006 {
02007   myTimeHeader->clearBackgroundColor();
02008 }
02009 
02010 
02019 QColor KDGanttView::columnBackgroundColor( const QDateTime& column ) const
02020 {
02021     return myTimeHeader->columnBackgroundColor( column ) ;
02022 }
02023 
02024 
02033 void KDGanttView::setWeekendBackgroundColor( const QColor& color )
02034 {
02035     myTimeHeader->setWeekendBackgroundColor( color );
02036 }
02037 
02038 
02045 QColor KDGanttView::weekendBackgroundColor() const
02046 {
02047     return myTimeHeader->weekendBackgroundColor();
02048 }
02049 
02050 
02061 void KDGanttView::setWeekdayBackgroundColor( const QColor& color, int  weekday )
02062 {
02063   myTimeHeader->setWeekdayBackgroundColor( color,  weekday );
02064 }
02065 
02066 
02074 QColor KDGanttView::weekdayBackgroundColor(int weekday) const
02075 {
02076   return myTimeHeader->weekdayBackgroundColor( weekday);
02077 }
02078 
02079 
02080 
02091 void KDGanttView::setWeekendDays( int start, int end )
02092 {
02093     myTimeHeader->setWeekendDays( start,  end );
02094 }
02095 
02096 
02104 void KDGanttView::weekendDays( int& start, int& end ) const
02105 {
02106     myTimeHeader->weekendDays( start,  end );
02107 }
02108 
02109 
02210 void KDGanttView::setMajorScaleCount( int count )
02211 {
02212     myTimeHeader->setMajorScaleCount(count );
02213 }
02214 
02215 
02222 int KDGanttView::majorScaleCount() const
02223 {
02224     return myTimeHeader->majorScaleCount();
02225 }
02226 
02227 
02234 void KDGanttView::setMinorScaleCount( int count )
02235 {
02236     myTimeHeader->setMinorScaleCount(count );
02237 }
02238 
02239 
02246 int KDGanttView::minorScaleCount() const
02247 {
02248     return myTimeHeader->minorScaleCount();
02249 
02250 }
02251 
02252 
02265 void KDGanttView::setDefaultColor( KDGanttViewItem::Type type,
02266                                    const QColor& color,
02267                                    bool overwriteExisting )
02268 {
02269     if ( overwriteExisting ) {
02270       QListViewItemIterator it(myListView);
02271       for ( ; it.current(); ++it ) {
02272         if ( ((KDGanttViewItem*)it.current())->type() == type)
02273           ((KDGanttViewItem*)it.current())->setDefaultColor(color );
02274       }
02275     }
02276     int index = getIndex( type );
02277     myDefaultColor [index] = color;
02278 }
02279 
02280 
02281 
02292 QColor KDGanttView::defaultColor( KDGanttViewItem::Type type ) const
02293 {
02294   int index = getIndex( type );
02295   return myDefaultColor [index];
02296 }
02297 
02298 
02311 void KDGanttView::setDefaultHighlightColor( KDGanttViewItem::Type type,
02312                                             const QColor& color,
02313                                             bool overwriteExisting )
02314 {
02315     if ( overwriteExisting ) {
02316       QListViewItemIterator it(myListView);
02317       for ( ; it.current(); ++it ) {
02318         if ( ((KDGanttViewItem*)it.current())->type() == type)
02319           ((KDGanttViewItem*)it.current())->setDefaultHighlightColor(color );
02320       }
02321     }
02322     int index = getIndex( type );
02323     myDefaultColorHL [index] = color;
02324 }
02325 
02326 
02327 
02338 QColor KDGanttView::defaultHighlightColor( KDGanttViewItem::Type type ) const
02339 {
02340   int index = getIndex( type );
02341   return myDefaultColorHL [index];
02342 }
02343 
02344 
02350 KDGanttViewItem* KDGanttView::firstChild() const
02351 {
02352     return (KDGanttViewItem*)myListView->firstChild();
02353 
02354 }
02372 void KDGanttView::setCalendarMode( bool mode )
02373 {
02374   myListView->setCalendarMode( mode );
02375 }
02376 
02377 
02385 bool  KDGanttView::calendarMode() const
02386 {
02387   return  myListView->calendarMode();
02388 }
02389 
02390 
02391 
02401 void KDGanttView::setDisplaySubitemsAsGroup( bool show )
02402 {
02403  QListViewItemIterator it( myListView );
02404  for ( ; it.current(); ++it ) {
02405    KDGanttViewItem* currentItem = ( KDGanttViewItem* )it.current();
02406    currentItem->setDisplaySubitemsAsGroup( show );
02407  }
02408  _displaySubitemsAsGroup = show;
02409 }
02410 
02411 
02420 bool KDGanttView::displaySubitemsAsGroup() const
02421 {
02422   return _displaySubitemsAsGroup;
02423 }
02424 
02425 
02433 void KDGanttView::setDisplayEmptyTasksAsLine( bool show )
02434 {
02435   _displayEmptyTasksAsLine = show;
02436 }
02437 
02438 
02445 bool KDGanttView::displayEmptyTasksAsLine() const
02446 {
02447   return _displayEmptyTasksAsLine;
02448 }
02449 
02450 
02465 void KDGanttView::setHorBackgroundLines( int count, QBrush brush )
02466 {
02467   myTimeTable->setHorBackgroundLines(  count, brush );
02468 }
02469 
02470 
02480 int KDGanttView::horBackgroundLines( QBrush& brush )
02481 {
02482   return myTimeTable->horBackgroundLines( brush );
02483 }
02484 
02485 
02491 KDGanttViewItem* KDGanttView::lastItem() const
02492 {
02493     return (KDGanttViewItem*)myListView->lastItem ();
02494 }
02495 
02496 
02502 QPtrList<KDGanttViewTaskLink> KDGanttView::taskLinks() const
02503 {
02504 
02505     return myTimeTable->taskLinks();
02506 }
02507 
02508 
02514 QPtrList<KDGanttViewTaskLinkGroup> KDGanttView::taskLinkGroups() const
02515 {
02516     return myTaskLinkGroupList;
02517 }
02518 
02519 
02527 bool KDGanttView::loadXML( const QDomDocument& doc )
02528 {
02529     QDomElement docRoot = doc.documentElement(); // ChartParams element
02530     QDomNode node = docRoot.firstChild();
02531     while( !node.isNull() ) {
02532         QDomElement element = node.toElement();
02533         if( !element.isNull() ) { // was really an element
02534             QString tagName = element.tagName();
02535             if( tagName == "ShowLegend" ) {
02536                 bool value;
02537                 if( KDGanttXML::readBoolNode( element, value ) )
02538                     setShowLegend( value );
02539             } else if( tagName == "ShowLegendButton" ) {
02540                 bool value;
02541                 if( KDGanttXML::readBoolNode( element, value ) )
02542                     setShowLegendButton( value );
02543             } else if( tagName == "LegendIsDockWindow" ) {
02544                 bool value;
02545                 if( KDGanttXML::readBoolNode( element, value ) )
02546                     setLegendIsDockwindow( value );
02547             } else if( tagName == "ShowListView" ) {
02548                 bool value;
02549                 if( KDGanttXML::readBoolNode( element, value ) )
02550                     setShowListView( value );
02551             } else if( tagName == "ShowHeader" ) {
02552               bool value;
02553               if( KDGanttXML::readBoolNode( element, value ) )
02554                 setHeaderVisible( value );
02555             } else if( tagName == "ShowTaskLinks" ) {
02556                 bool value;
02557                 if( KDGanttXML::readBoolNode( element, value ) )
02558                     setShowTaskLinks( value );
02559             } else if( tagName == "EditorEnabled" ) {
02560                 bool value;
02561                 if( KDGanttXML::readBoolNode( element, value ) )
02562                     setEditorEnabled( value );
02563             } else if( tagName == "DisplayEmptyTasksAsLine" ) {
02564               bool value;
02565               if( KDGanttXML::readBoolNode( element, value ) )
02566                 setDisplayEmptyTasksAsLine( value );
02567             } else if( tagName == "GlobalFont" ) {
02568                 QFont font;
02569                 if( KDGanttXML::readFontNode( element, font ) )
02570                     setFont( font );
02571             } else if( tagName == "HorizonStart" ) {
02572                 QDateTime value;
02573                 if( KDGanttXML::readDateTimeNode( element, value ) )
02574                     setHorizonStart( value );
02575             } else if( tagName == "HorizonEnd" ) {
02576                 QDateTime value;
02577                 if( KDGanttXML::readDateTimeNode( element, value ) )
02578                     setHorizonEnd( value );
02579             } else if( tagName == "Scale" ) {
02580                 QString value;
02581                 if( KDGanttXML::readStringNode( element, value ) )
02582                     setScale( stringToScale( value ) );
02583             } else if( tagName == "MinimumScale" ) {
02584                 QString value;
02585                 if( KDGanttXML::readStringNode( element, value ) )
02586                     setMinimumScale( stringToScale( value ) );
02587             } else if( tagName == "MaximumScale" ) {
02588                 QString value;
02589                 if( KDGanttXML::readStringNode( element, value ) )
02590                     setMaximumScale( stringToScale( value ) );
02591             } else if( tagName == "YearFormat" ) {
02592                 QString value;
02593                 if( KDGanttXML::readStringNode( element, value ) )
02594                     setYearFormat( stringToYearFormat( value ) );
02595             } else if( tagName == "HourFormat" ) {
02596                 QString value;
02597                 if( KDGanttXML::readStringNode( element, value ) )
02598                     setHourFormat( stringToHourFormat( value ) );
02599             } else if( tagName == "ShowMinorTicks" ) {
02600                 bool value;
02601                 if( KDGanttXML::readBoolNode( element, value ) )
02602                     setShowMinorTicks( value );
02603             } else if( tagName == "ShowMajorTicks" ) {
02604                 bool value;
02605                 if( KDGanttXML::readBoolNode( element, value ) )
02606                     setShowMajorTicks( value );
02607             } else if( tagName == "DragEnabled" ) {
02608                 bool value;
02609                 if( KDGanttXML::readBoolNode( element, value ) )
02610                     setDragEnabled( value );
02611             } else if( tagName == "DropEnabled" ) {
02612                 bool value;
02613                 if( KDGanttXML::readBoolNode( element, value ) )
02614                     setDropEnabled( value );
02615             } else if( tagName == "CalendarMode" ) {
02616                 bool value;
02617                 if( KDGanttXML::readBoolNode( element, value ) )
02618                     setCalendarMode( value );
02619             } else if( tagName == "Editable" ) {
02620                 bool value;
02621                 if( KDGanttXML::readBoolNode( element, value ) )
02622                     setEditable( value );
02623             } else if( tagName == "TextColor" ) {
02624                 QColor value;
02625                 if( KDGanttXML::readColorNode( element, value ) )
02626                     setTextColor( value );
02627             } else if( tagName == "MajorScaleCount" ) {
02628                 int value;
02629                 if( KDGanttXML::readIntNode( element, value ) )
02630                     setMajorScaleCount( value );
02631             } else if( tagName == "MinorScaleCount" ) {
02632                 int value;
02633                 if( KDGanttXML::readIntNode( element, value ) )
02634                     setMinorScaleCount( value );
02635             } else if( tagName == "AutoScaleMinorTickCount" ) {
02636                 int value;
02637                 if( KDGanttXML::readIntNode( element, value ) )
02638                     setAutoScaleMinorTickCount( value );
02639             } else if( tagName == "MinimumColumnWidth" ) {
02640                 int value;
02641                 if( KDGanttXML::readIntNode( element, value ) )
02642                     setMinimumColumnWidth( value );
02643             } else if( tagName == "GanttMaximumWidth" ) {
02644                 int value;
02645                 if( KDGanttXML::readIntNode( element, value ) )
02646                     setGanttMaximumWidth( value );
02647             } else if( tagName == "NoInformationBrush" ) {
02648               QBrush value;
02649               if( KDGanttXML::readBrushNode( element, value ) )
02650                 setNoInformationBrush( value );
02651             } else if( tagName == "GanttViewBackgroundColor" ) {
02652                 QColor value;
02653                 if( KDGanttXML::readColorNode( element, value ) )
02654                     setGvBackgroundColor( value );
02655             } else if( tagName == "ListViewBackgroundColor" ) {
02656                 QColor value;
02657                 if( KDGanttXML::readColorNode( element, value ) )
02658                     setLvBackgroundColor( value );
02659             } else if( tagName == "TimeHeaderBackgroundColor" ) {
02660                 QColor value;
02661                 if( KDGanttXML::readColorNode( element, value ) )
02662                     setTimeHeaderBackgroundColor( value );
02663             } else if( tagName == "LegendHeaderBackgroundColor" ) {
02664                 QColor value;
02665                 if( KDGanttXML::readColorNode( element, value ) )
02666                     setLegendHeaderBackgroundColor( value );
02667             } else if( tagName == "WeekendBackgroundColor" ) {
02668                 QColor value;
02669                 if( KDGanttXML::readColorNode( element, value ) )
02670                     setWeekendBackgroundColor( value );
02671             } else if( tagName == "WeekdayBackgroundColor" ) {
02672                 QDomNode node = element.firstChild();
02673                 int day = 0;
02674                 QColor color;
02675                 while( !node.isNull() ) {
02676                     QDomElement element = node.toElement();
02677                     if( !element.isNull() ) { // was really an elemente
02678                         QString tagName = element.tagName();
02679                         if( tagName == "Day" ) {
02680                             int value;
02681                             if( KDGanttXML::readIntNode( element, value ) )
02682                                 day = value;
02683                         } else if( tagName == "Color" ) {
02684                             QColor value;
02685                             if( KDGanttXML::readColorNode( element, value ) )
02686                                 color = value;
02687                         } else {
02688                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02689                             Q_ASSERT( false );
02690                         }
02691                     }
02692                     node = node.nextSibling();
02693                 }
02694 
02695                 if( day && color.isValid() )
02696                     setWeekdayBackgroundColor( color, day );
02697             } else if( tagName == "WeekendDays" ) {
02698                 QString startString = element.attribute( "Start" );
02699                 QString endString = element.attribute( "End" );
02700                 bool startOk = false, endOk = false;
02701                 int start = startString.toInt( &startOk );
02702                 int end = startString.toInt( &endOk );
02703                 if( startOk && endOk )
02704                     setWeekendDays( start, end );
02705             } else if( tagName == "ZoomFactor" ) {
02706                 double value;
02707                 if( KDGanttXML::readDoubleNode( element, value ) )
02708                     setZoomFactor( value, true );
02709             } else if( tagName == "ShowHeaderPopupMenu" ) {
02710                 bool value;
02711                 if( KDGanttXML::readBoolNode( element, value ) )
02712                     setShowHeaderPopupMenu( value );
02713             } else if( tagName == "ShowTimeTablePopupMenu" ) {
02714                 bool value;
02715                 if( KDGanttXML::readBoolNode( element, value ) )
02716                     setShowTimeTablePopupMenu( value );
02717             } else if( tagName == "Shapes" ) {
02718                 QDomNode node = element.firstChild();
02719                 bool undefinedShape = false;
02720                 while( !node.isNull() ) {
02721                     QDomElement element = node.toElement();
02722                     if( !element.isNull() ) { // was really an elemente
02723                         QString tagName = element.tagName();
02724                         if( tagName == "Event" ) {
02725                             KDGanttViewItem::Shape startShape, middleShape, endShape;
02726                             startShape = KDGanttViewItem::TriangleDown;
02727                             middleShape = KDGanttViewItem::TriangleDown;
02728                             endShape = KDGanttViewItem::TriangleDown;
02729                             QDomNode node = element.firstChild();
02730                             while( !node.isNull() ) {
02731                                 QDomElement element = node.toElement();
02732                                 if( !element.isNull() ) { // was really an elemente
02733                                     QString tagName = element.tagName();
02734                                     if( tagName == "Start" ) {
02735                                         QString value;
02736                                         if( KDGanttXML::readStringNode( element, value ) )
02737                                             startShape = KDGanttViewItem::stringToShape( value );
02738                                         if ( value == "Undefined" )
02739                                           undefinedShape = true;
02740                                     } else if( tagName == "Middle" ) {
02741                                         QString value;
02742                                         if( KDGanttXML::readStringNode( element, value ) )
02743                                             middleShape = KDGanttViewItem::stringToShape( value );
02744                                         if ( value == "Undefined" )
02745                                           undefinedShape = true;
02746                                     } else if( tagName == "End" ) {
02747                                         QString value;
02748                                         if( KDGanttXML::readStringNode( element, value ) )
02749                                             endShape = KDGanttViewItem::stringToShape( value );
02750                                         if ( value == "Undefined" )
02751                                           undefinedShape = true;
02752                                     } else {
02753                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02754                                         Q_ASSERT( false );
02755                                     }
02756                                 }
02757                                 node = node.nextSibling();
02758                             }
02759                             if ( ! undefinedShape )
02760                               setShapes( KDGanttViewItem::Event, startShape,
02761                                        middleShape, endShape, false );
02762                             undefinedShape = false;
02763                         } else if( tagName == "Task" ) {
02764                             KDGanttViewItem::Shape startShape, middleShape, endShape;
02765                             startShape = KDGanttViewItem::TriangleDown;
02766                             middleShape = KDGanttViewItem::TriangleDown;
02767                             endShape = KDGanttViewItem::TriangleDown;
02768                             QDomNode node = element.firstChild();
02769                             while( !node.isNull()) {
02770                                 QDomElement element = node.toElement();
02771                                 if( !element.isNull() ) { // was really an elemente
02772                                     QString tagName = element.tagName();
02773                                     if( tagName == "Start" ) {
02774                                         QString value;
02775                                         if( KDGanttXML::readStringNode( element, value ) )
02776                                             startShape = KDGanttViewItem::stringToShape( value );
02777                                         if ( value == "Undefined" )
02778                                           undefinedShape = true;
02779                                     } else if( tagName == "Middle" ) {
02780                                         QString value;
02781                                         if( KDGanttXML::readStringNode( element, value ) )
02782                                             middleShape = KDGanttViewItem::stringToShape( value );
02783                                         if ( value == "Undefined" )
02784                                           undefinedShape = true;
02785                                     } else if( tagName == "End" ) {
02786                                         QString value;
02787                                         if( KDGanttXML::readStringNode( element, value ) )
02788                                             endShape = KDGanttViewItem::stringToShape( value );
02789                                         if ( value == "Undefined" )
02790                                           undefinedShape = true;
02791                                     } else {
02792                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02793                                         Q_ASSERT( false );
02794                                     }
02795                                 }
02796                                 node = node.nextSibling();
02797                             }
02798                             if ( ! undefinedShape )
02799                               setShapes( KDGanttViewItem::Task, startShape, middleShape, endShape, false );
02800                             undefinedShape = false;
02801                         } else if( tagName == "Summary" ) {
02802                             KDGanttViewItem::Shape startShape, middleShape, endShape;
02803                             startShape = KDGanttViewItem::TriangleDown;
02804                             middleShape = KDGanttViewItem::TriangleDown;
02805                             endShape = KDGanttViewItem::TriangleDown;
02806                             QDomNode node = element.firstChild();
02807                             while( !node.isNull() ) {
02808                                 QDomElement element = node.toElement();
02809                                 if( !element.isNull() ) { // was really an elemente
02810                                     QString tagName = element.tagName();
02811                                     if( tagName == "Start" ) {
02812                                         QString value;
02813                                         if( KDGanttXML::readStringNode( element, value ) )
02814                                             startShape = KDGanttViewItem::stringToShape( value );
02815                                         if ( value == "Undefined" )
02816                                           undefinedShape = true;
02817                                     } else if( tagName == "Middle" ) {
02818                                         QString value;
02819                                         if( KDGanttXML::readStringNode( element, value ) )
02820                                             middleShape = KDGanttViewItem::stringToShape( value );
02821                                         if ( value == "Undefined" )
02822                                           undefinedShape = true;
02823                                     } else if( tagName == "End" ) {
02824                                         QString value;
02825                                         if( KDGanttXML::readStringNode( element, value ) )
02826                                             endShape = KDGanttViewItem::stringToShape( value );
02827                                         if ( value == "Undefined" )
02828                                           undefinedShape = true;
02829                                     } else {
02830                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02831                                         Q_ASSERT( false );
02832                                     }
02833                                 }
02834                                 node = node.nextSibling();
02835                             }
02836                             if ( ! undefinedShape )
02837                               setShapes( KDGanttViewItem::Summary, startShape,
02838                                        middleShape, endShape, false );
02839                             undefinedShape = false;
02840                         } else {
02841                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02842                             Q_ASSERT( false );
02843                         }
02844                     }
02845                     node = node.nextSibling();
02846                 }
02847             } else if( tagName == "Colors" ) {
02848                 QDomNode node = element.firstChild();
02849                 while( !node.isNull()) {
02850                     QDomElement element = node.toElement();
02851                     if( !element.isNull() ) { // was really an elemente
02852                         QString tagName = element.tagName();
02853                         if( tagName == "Event" ) {
02854                             QColor startColor, middleColor, endColor;
02855                             QDomNode node = element.firstChild();
02856                             while( !node.isNull() ) {
02857                                 QDomElement element = node.toElement();
02858                                 if( !element.isNull() ) { // was really an elemente
02859                                     QString tagName = element.tagName();
02860                                     if( tagName == "Start" ) {
02861                                         QColor value;
02862                                         if( KDGanttXML::readColorNode( element, value ) )
02863                                             startColor = value;
02864                                     } else if( tagName == "Middle" ) {
02865                                         QColor value;
02866                                         if( KDGanttXML::readColorNode( element, value ) )
02867                                             middleColor = value;
02868                                     } else if( tagName == "End" ) {
02869                                         QColor value;
02870                                         if( KDGanttXML::readColorNode( element, value ) )
02871                                             endColor = value;
02872                                     } else {
02873                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02874                                         Q_ASSERT( false );
02875                                     }
02876                                 }
02877                                 node = node.nextSibling();
02878                             }
02879                             setColors( KDGanttViewItem::Event, startColor,
02880                                        middleColor, endColor, false );
02881                         } else if( tagName == "Task" ) {
02882                             QColor startColor, middleColor, endColor;
02883                             QDomNode node = element.firstChild();
02884                             while( !node.isNull() ) {
02885                                 QDomElement element = node.toElement();
02886                                 if( !element.isNull() ) { // was really an elemente
02887                                     QString tagName = element.tagName();
02888                                     if( tagName == "Start" ) {
02889                                         QColor value;
02890                                         if( KDGanttXML::readColorNode( element, value ) )
02891                                             startColor = value;
02892                                     } else if( tagName == "Middle" ) {
02893                                         QColor value;
02894                                         if( KDGanttXML::readColorNode( element, value ) )
02895                                             middleColor = value;
02896                                     } else if( tagName == "End" ) {
02897                                         QColor value;
02898                                         if( KDGanttXML::readColorNode( element, value ) )
02899                                             endColor = value;
02900                                     } else {
02901                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02902                                         Q_ASSERT( false );
02903                                     }
02904                                 }
02905                                 node = node.nextSibling();
02906                             }
02907                             setColors( KDGanttViewItem::Task, startColor,
02908                                        middleColor, endColor, false );
02909                         } else if( tagName == "Summary" ) {
02910                             QColor startColor, middleColor, endColor;
02911                             QDomNode node = element.firstChild();
02912                             while( !node.isNull() ) {
02913                                 QDomElement element = node.toElement();
02914                                 if( !element.isNull() ) { // was really an elemente
02915                                     QString tagName = element.tagName();
02916                                     if( tagName == "Start" ) {
02917                                         QColor value;
02918                                         if( KDGanttXML::readColorNode( element, value ) )
02919                                             startColor = value;
02920                                     } else if( tagName == "Middle" ) {
02921                                         QColor value;
02922                                         if( KDGanttXML::readColorNode( element, value ) )
02923                                             middleColor = value;
02924                                     } else if( tagName == "End" ) {
02925                                         QColor value;
02926                                         if( KDGanttXML::readColorNode( element, value ) )
02927                                             endColor = value;
02928                                     } else {
02929                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02930                                         Q_ASSERT( false );
02931                                     }
02932                                 }
02933                                 node = node.nextSibling();
02934                             }
02935                             setColors( KDGanttViewItem::Summary, startColor,
02936                                        middleColor, endColor , false);
02937                         } else {
02938                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02939                             Q_ASSERT( false );
02940                         }
02941                     }
02942                     node = node.nextSibling();
02943                 }
02944             } else if( tagName == "DefaultColors" ) {
02945                 QDomNode node = element.firstChild();
02946                 while( !node.isNull() ) {
02947                     QDomElement element = node.toElement();
02948                     if( !element.isNull() ) { // was really an element
02949                         QString tagName = element.tagName();
02950                         if( tagName == "Event" ) {
02951                             QColor value;
02952                             if( KDGanttXML::readColorNode( element, value ) )
02953                                 setDefaultColor( KDGanttViewItem::Event,
02954                                                  value, false );
02955                         } else if( tagName == "Task" ) {
02956                             QColor value;
02957                             if( KDGanttXML::readColorNode( element, value ) )
02958                                 setDefaultColor( KDGanttViewItem::Task,
02959                                                  value, false );
02960                         } else if( tagName == "Summary" ) {
02961                             QColor value;
02962                             if( KDGanttXML::readColorNode( element, value ) )
02963                                 setDefaultColor( KDGanttViewItem::Summary,
02964                                                  value , false);
02965                         } else {
02966                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
02967                             Q_ASSERT( false );
02968                         }
02969                     }
02970 
02971                     node = node.nextSibling();
02972                 }
02973             } else if( tagName == "HighlightColors" ) {
02974                 QDomNode node = element.firstChild();
02975                 while( !node.isNull() ) {
02976                     QDomElement element = node.toElement();
02977                     if( !element.isNull() ) { // was really an elemente
02978                         QString tagName = element.tagName();
02979                         if( tagName == "Event" ) {
02980                             QColor startColor, middleColor, endColor;
02981                             QDomNode node = element.firstChild();
02982                             while( !node.isNull() ) {
02983                                 QDomElement element = node.toElement();
02984                                 if( !element.isNull() ) { // was really an elemente
02985                                     QString tagName = element.tagName();
02986                                     if( tagName == "Start" ) {
02987                                         QColor value;
02988                                         if( KDGanttXML::readColorNode( element, value ) )
02989                                             startColor = value;
02990                                     } else if( tagName == "Middle" ) {
02991                                         QColor value;
02992                                         if( KDGanttXML::readColorNode( element, value ) )
02993                                             middleColor = value;
02994                                     } else if( tagName == "End" ) {
02995                                         QColor value;
02996                                         if( KDGanttXML::readColorNode( element, value ) )
02997                                             endColor = value;
02998                                     } else {
02999                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03000                                         Q_ASSERT( false );
03001                                     }
03002                                 }
03003                                 node = node.nextSibling();
03004                             }
03005                             setHighlightColors( KDGanttViewItem::Event,
03006                                                 startColor,
03007                                                 middleColor, endColor, false );
03008                         } else if( tagName == "Task" ) {
03009                             QColor startColor, middleColor, endColor;
03010                             QDomNode node = element.firstChild();
03011                             while( !node.isNull() ) {
03012                                 QDomElement element = node.toElement();
03013                                 if( !element.isNull() ) { // was really an elemente
03014                                     QString tagName = element.tagName();
03015                                     if( tagName == "Start" ) {
03016                                         QColor value;
03017                                         if( KDGanttXML::readColorNode( element, value ) )
03018                                             startColor = value;
03019                                     } else if( tagName == "Middle" ) {
03020                                         QColor value;
03021                                         if( KDGanttXML::readColorNode( element, value ) )
03022                                             middleColor = value;
03023                                     } else if( tagName == "End" ) {
03024                                         QColor value;
03025                                         if( KDGanttXML::readColorNode( element, value ) )
03026                                             endColor = value;
03027                                     } else {
03028                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03029                                         Q_ASSERT( false );
03030                                     }
03031                                 }
03032                                 node = node.nextSibling();
03033                             }
03034                             setHighlightColors( KDGanttViewItem::Task,
03035                                                 startColor,
03036                                                 middleColor, endColor , false);
03037                         } else if( tagName == "Summary" ) {
03038                             QColor startColor, middleColor, endColor;
03039                             QDomNode node = element.firstChild();
03040                             while( !node.isNull() ) {
03041                                 QDomElement element = node.toElement();
03042                                 if( !element.isNull() ) { // was really an elemente
03043                                     QString tagName = element.tagName();
03044                                     if( tagName == "Start" ) {
03045                                         QColor value;
03046                                         if( KDGanttXML::readColorNode( element, value ) )
03047                                             startColor = value;
03048                                     } else if( tagName == "Middle" ) {
03049                                         QColor value;
03050                                         if( KDGanttXML::readColorNode( element, value ) )
03051                                             middleColor = value;
03052                                     } else if( tagName == "End" ) {
03053                                         QColor value;
03054                                         if( KDGanttXML::readColorNode( element, value ) )
03055                                             endColor = value;
03056                                     } else {
03057                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03058                                         Q_ASSERT( false );
03059                                     }
03060                                 }
03061                                 node = node.nextSibling();
03062                             }
03063                             setHighlightColors( KDGanttViewItem::Summary,
03064                                                 startColor,
03065                                                 middleColor, endColor, false );
03066                         } else {
03067                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03068                             Q_ASSERT( false );
03069                         }
03070                     }
03071                     node = node.nextSibling();
03072                 }
03073             } else if( tagName == "DefaultHighlightColors" ) {
03074                 QDomNode node = element.firstChild();
03075                 while( !node.isNull() ) {
03076                     QDomElement element = node.toElement();
03077                     if( !element.isNull() ) { // was really an element
03078                         QString tagName = element.tagName();
03079                         if( tagName == "Event" ) {
03080                             QColor value;
03081                             if( KDGanttXML::readColorNode( element, value ) )
03082                                 setDefaultHighlightColor( KDGanttViewItem::Event,
03083                                                  value , false);
03084                         } else if( tagName == "Task" ) {
03085                             QColor value;
03086                             if( KDGanttXML::readColorNode( element, value ) )
03087                                 setDefaultHighlightColor( KDGanttViewItem::Task,
03088                                                  value, false );
03089                         } else if( tagName == "Summary" ) {
03090                             QColor value;
03091                             if( KDGanttXML::readColorNode( element, value ) )
03092                                 setDefaultHighlightColor( KDGanttViewItem::Summary,
03093                                                  value, false );
03094                         } else {
03095                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03096                             Q_ASSERT( false );
03097                         }
03098                     }
03099 
03100                     node = node.nextSibling();
03101                 }
03102             } else if( tagName == "Items" ) {
03103                 QDomNode node = element.firstChild();
03104                 KDGanttViewItem* previous = 0;
03105                 while( !node.isNull() ) {
03106                     QDomElement element = node.toElement();
03107                     if( !element.isNull() ) { // was really an element
03108                         QString tagName = element.tagName();
03109                         if( tagName == "Item" ) {
03110                             KDGanttViewItem* newItem;
03111                             if( previous )
03112                                 newItem =
03113                                     KDGanttViewItem::createFromDomElement( this,
03114                                                                            previous,
03115                                                                            element );
03116                             else
03117                                 newItem =
03118                                     KDGanttViewItem::createFromDomElement( this,
03119                                                                            element );
03120                             previous = newItem;
03121                         } else {
03122                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03123                             Q_ASSERT( false );
03124                         }
03125                     }
03126 
03127                     node = node.nextSibling();
03128                 }
03129             } else if( tagName == "TaskLinks" ) {
03130                 QDomNode node = element.firstChild();
03131                 while( !node.isNull() ) {
03132                     QDomElement element = node.toElement();
03133                     if( !element.isNull() ) { // was really an element
03134                         QString tagName = element.tagName();
03135                         if( tagName == "TaskLink" )
03136                             KDGanttViewTaskLink::createFromDomElement( element );
03137                         else {
03138                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03139                             Q_ASSERT( false );
03140                         }
03141                     }
03142 
03143                     node = node.nextSibling();
03144                 }
03145             } else if( tagName == "TaskLinkGroups" ) {
03146                 QDomNode node = element.firstChild();
03147                 while( !node.isNull() ) {
03148                     QDomElement element = node.toElement();
03149                     if( !element.isNull() ) { // was really an element
03150                         QString tagName = element.tagName();
03151                         if( tagName == "TaskLink" )
03152                             KDGanttViewTaskLinkGroup::createFromDomElement( element );
03153                     } else {
03154                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03155                         Q_ASSERT( false );
03156                     }
03157 
03158                     node = node.nextSibling();
03159                 }
03160             } else if( tagName == "ColumnBackgroundColors" ) {
03161                 QDomNode node = element.firstChild();
03162                 while( !node.isNull() ) {
03163                     QDomElement element = node.toElement();
03164                     if( !element.isNull() ) { // was really an element
03165                         QString tagName = element.tagName();
03166                         if( tagName == "ColumnBackgroundColor" ) {
03167                             QDomNode node = element.firstChild();
03168                             QDateTime dateTime;
03169                             QColor color;
03170                             while( !node.isNull() ) {
03171                                 QDomElement element = node.toElement();
03172                                 if( !element.isNull() ) { // was
03173                                                           // really an
03174                                                           // element
03175                                     QString tagName = element.tagName();
03176                                     if( tagName == "DateTime" ) {
03177                                         QDateTime value;
03178                                         if( KDGanttXML::readDateTimeNode( element, value ) )
03179                                             dateTime = value;
03180                                     } else if( tagName == "Color" ) {
03181                                         QColor value;
03182                                         if( KDGanttXML::readColorNode( element, value ) )
03183                                             color = value;
03184                                     } else {
03185                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03186                                         Q_ASSERT( false );
03187                                     }
03188                                 }
03189 
03190                                 node = node.nextSibling();
03191                             }
03192                             setColumnBackgroundColor( dateTime, color );
03193                         } else {
03194                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03195                             Q_ASSERT( false );
03196                         }
03197                     }
03198                     node = node.nextSibling();
03199                 }
03200             } else if( tagName == "LegendItems" ) {
03201                 clearLegend();
03202                 QDomNode node = element.firstChild();
03203                 while( !node.isNull() ) {
03204                     QDomElement element = node.toElement();
03205                     if( !element.isNull() ) { // was really an element
03206                         QString tagName = element.tagName();
03207                         if( tagName == "LegendItem" ) {
03208                             KDGanttViewItem::Shape tempLegendShape;
03209                             tempLegendShape = KDGanttViewItem::TriangleDown;
03210                             QColor tempLegendColor;
03211                             QString tempLegendString;
03212                             bool ok = true;
03213                             QDomNode node = element.firstChild();
03214                             while( !node.isNull() ) {
03215                                 QDomElement element = node.toElement();
03216                                 if( !element.isNull() ) { // was really an element
03217                                     QString tagName = element.tagName();
03218                                     if( tagName == "Shape" ) {
03219                                         QString value;
03220                                         if( KDGanttXML::readStringNode( element, value ) )
03221                                             tempLegendShape = KDGanttViewItem::stringToShape( value );
03222                                         else
03223                                             ok = false;
03224                                     } else if( tagName == "Color" ) {
03225                                         QColor value;
03226                                         if( KDGanttXML::readColorNode( element, value ) )
03227                                             tempLegendColor = value;
03228                                         else
03229                                             ok = false;
03230                                     } else if( tagName == "Text" ) {
03231                                         QString value;
03232                                         if( KDGanttXML::readStringNode( element, value ) )
03233                                             tempLegendString = value;
03234                                         else
03235                                             ok = false;
03236                                     } else {
03237                                         qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03238                                         Q_ASSERT( false );
03239                                     }
03240                                 }
03241                                 node = node.nextSibling();
03242                             }
03243                             if( ok ) {
03244                                 addLegendItem( tempLegendShape,
03245                                                tempLegendColor,
03246                                                tempLegendString );
03247                                 qDebug( "Adding legend item %s", tempLegendString.latin1() );
03248                             }
03249                         } else {
03250                             qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03251                             Q_ASSERT( false );
03252                         }
03253                     }
03254                     node = node.nextSibling();
03255                 }
03256             } else {
03257                 qDebug( "Unrecognized tag name: %s", tagName.latin1() );
03258                 Q_ASSERT( false );
03259             }
03260         }
03261 
03262         node = node.nextSibling();
03263     } // while
03264         return true; /* FIXME: Do real error-reporting. The ASSERT's should be "return false" stmnts */
03265 } // method
03266 
03267 
03276 QDomDocument KDGanttView::saveXML( bool withPI ) const
03277 {
03278     // Create an inital DOM document
03279     QString docstart = "<GanttView/>";
03280 
03281     QDomDocument doc( "GanttView" );
03282     doc.setContent( docstart );
03283     if( withPI ) {
03284       QDomProcessingInstruction pin = doc.createProcessingInstruction( "kdgantt", "version=\"1.0\" encoding=\"UTF-8\""  ) ;
03285        doc.appendChild ( pin );
03286     }
03287 
03288     QDomElement docRoot = doc.documentElement();
03289     docRoot.setAttribute( "xmlns", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
03290     docRoot.setAttribute( "xmlns:xsi", "http://www.w3.org/2000/10/XMLSchema-instance" );
03291     docRoot.setAttribute( "xsi:schemaLocation", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
03292 
03293     // the ShowLegend element
03294     KDGanttXML::createBoolNode( doc, docRoot, "ShowLegend", showLegend() );
03295 
03296     // the ShowLegendButton element
03297     KDGanttXML::createBoolNode( doc, docRoot, "ShowLegendButton",
03298                            showLegendButton() );
03299 
03300     // the LegendIsDockWindow element
03301     KDGanttXML::createBoolNode( doc, docRoot, "LegendIsDockWindow",
03302                            legendIsDockwindow() );
03303 
03304     // the ShowListView element
03305     KDGanttXML::createBoolNode( doc, docRoot, "ShowListView", showListView() );
03306 
03307     // the ShowHeader element
03308     KDGanttXML::createBoolNode( doc, docRoot, "ShowHeader", headerVisible() );
03309 
03310     // the ShowTaskLinks element
03311     KDGanttXML::createBoolNode( doc, docRoot, "ShowTaskLinks", showTaskLinks() );
03312 
03313     // the EditorEnabled element
03314     KDGanttXML::createBoolNode( doc, docRoot, "EditorEnabled", editorEnabled() );
03315 
03316     // the global font element
03317     KDGanttXML::createFontNode( doc, docRoot, "GlobalFont", font() );
03318 
03319     // the DisplayEmptyTasksAsLine element
03320     KDGanttXML::createBoolNode( doc, docRoot, "DisplayEmptyTasksAsLine",
03321                            displayEmptyTasksAsLine() );
03322 
03323     // the HorizonStart element
03324     KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonStart", horizonStart() );
03325 
03326     // the HorizonEnd element
03327     KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonEnd", horizonEnd() );
03328 
03329     // the Scale, MinimumScale, MaximumScale elements
03330     KDGanttXML::createStringNode( doc, docRoot, "Scale", scaleToString( scale() ) );
03331     KDGanttXML::createStringNode( doc, docRoot, "MinimumScale",
03332                              scaleToString( minimumScale() ) );
03333     KDGanttXML::createStringNode( doc, docRoot, "MaximumScale",
03334                              scaleToString( maximumScale() ) );
03335 
03336     // the YearFormat element
03337     KDGanttXML::createStringNode( doc, docRoot, "YearFormat",
03338                              yearFormatToString( yearFormat() ) );
03339 
03340     // the HourFormat element
03341     KDGanttXML::createStringNode( doc, docRoot, "HourFormat",
03342                              hourFormatToString( hourFormat() ) );
03343 
03344     // the ShowMinorTicks element
03345     KDGanttXML::createBoolNode( doc, docRoot, "ShowMinorTicks", showMinorTicks() );
03346 
03347     // the ShowMajorTicks element
03348     KDGanttXML::createBoolNode( doc, docRoot, "ShowMajorTicks", showMajorTicks() );
03349 
03350     // the Editable element
03351     KDGanttXML::createBoolNode( doc, docRoot, "Editable", editable() );
03352 
03353     // the TextColor element
03354     KDGanttXML::createColorNode( doc, docRoot, "TextColor", textColor() );
03355 
03356     // the MajorScaleCount element
03357     KDGanttXML::createIntNode( doc, docRoot, "MajorScaleCount", majorScaleCount() );
03358 
03359     // the MinorScaleCount element
03360     KDGanttXML::createIntNode( doc, docRoot, "MinorScaleCount", minorScaleCount() );
03361 
03362     // the AutoScaleMinorTickCount element
03363     KDGanttXML::createIntNode( doc, docRoot, "AutoScaleMinorTickCount",
03364                           autoScaleMinorTickCount() );
03365 
03366     // the MinimumColumnWidth element
03367     KDGanttXML::createIntNode( doc, docRoot, "MinimumColumnWidth",
03368                           minimumColumnWidth() );
03369 
03370     // the GanttMaximumWidth element
03371     KDGanttXML::createIntNode( doc, docRoot, "GanttMaximumWidth",
03372                           ganttMaximumWidth() );
03373 
03374     // the NoInformationBrush element
03375     KDGanttXML::createBrushNode( doc, docRoot, "NoInformationBrush",
03376                             noInformationBrush() );
03377 
03378     // the GanttViewBackgroundColor element
03379     KDGanttXML::createColorNode( doc, docRoot, "GanttViewBackgroundColor",
03380                             gvBackgroundColor() );
03381 
03382     // the ListViewBackgroundColor element
03383     KDGanttXML::createColorNode( doc, docRoot, "ListViewBackgroundColor",
03384                             lvBackgroundColor() );
03385 
03386     // the TimeHeaderBackgroundColor element
03387     KDGanttXML::createColorNode( doc, docRoot, "TimeHeaderBackgroundColor",
03388                             timeHeaderBackgroundColor() );
03389 
03390     // the LegendHeaderBackgroundColor element
03391     KDGanttXML::createColorNode( doc, docRoot, "LegendHeaderBackgroundColor",
03392                             legendHeaderBackgroundColor() );
03393 
03394     // the WeekendBackgroundColor element
03395     KDGanttXML::createColorNode( doc, docRoot, "WeekendBackgroundColor",
03396                             weekendBackgroundColor() );
03397 
03398     // the WeekdayBackgroundColor elements
03399     for( int weekday = 1; weekday <= 7; weekday++ ) {
03400         QColor color = weekdayBackgroundColor( weekday );
03401         if( color.isValid() ) {
03402             QDomElement weekendBackgroundColorElement = doc.createElement( "WeekdayBackgroundColor" );
03403             docRoot.appendChild( weekendBackgroundColorElement );
03404             KDGanttXML::createIntNode( doc, weekendBackgroundColorElement,
03405                                   "Day", weekday );
03406             KDGanttXML::createColorNode( doc, weekendBackgroundColorElement,
03407                                     "Color", color );
03408         }
03409     }
03410 
03411     // the WeekendDays element
03412     QDomElement weekendDaysElement = doc.createElement( "WeekendDays" );
03413     docRoot.appendChild( weekendDaysElement );
03414     int weekendStart, weekendEnd;
03415     weekendDays( weekendStart, weekendEnd );
03416     weekendDaysElement.setAttribute( "Start", weekendStart );
03417     weekendDaysElement.setAttribute( "End", weekendStart );
03418 
03419     // the ZoomFactor element
03420     KDGanttXML::createDoubleNode( doc, docRoot, "ZoomFactor",
03421                              zoomFactor() );
03422 
03423     // the ShowHeaderPopupMenu element
03424     KDGanttXML::createBoolNode( doc, docRoot, "ShowHeaderPopupMenu",
03425                            showHeaderPopupMenu() );
03426 
03427     // the ShowTimeTablePopupMenu element
03428     KDGanttXML::createBoolNode( doc, docRoot, "ShowTimeTablePopupMenu",
03429                            showTimeTablePopupMenu() );
03430 
03431     // the Shapes element
03432     QDomElement shapesElement = doc.createElement( "Shapes" );
03433     docRoot.appendChild( shapesElement );
03434     QDomElement shapesEventElement = doc.createElement( "Event" );
03435     shapesElement.appendChild( shapesEventElement );
03436     KDGanttViewItem::Shape start, middle, end;
03437     if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
03438         KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
03439                                  KDGanttViewItem::shapeToString( start ) );
03440         KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
03441                                  KDGanttViewItem::shapeToString( middle ) );
03442         KDGanttXML::createStringNode( doc, shapesEventElement, "End",
03443                                  KDGanttViewItem::shapeToString( end ) );
03444     } else {
03445         KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
03446                                  "Undefined" );
03447         KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
03448                                  "Undefined" );
03449         KDGanttXML::createStringNode( doc, shapesEventElement, "End",
03450                                  "Undefined" );
03451     }
03452     QDomElement shapesTaskElement = doc.createElement( "Task" );
03453     shapesElement.appendChild( shapesTaskElement );
03454     if( shapes( KDGanttViewItem::Task, start, middle, end ) ) {
03455         KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
03456                                  KDGanttViewItem::shapeToString( start ) );
03457         KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
03458                                  KDGanttViewItem::shapeToString( middle ) );
03459         KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
03460                                  KDGanttViewItem::shapeToString( end ) );
03461     } else {
03462         KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
03463                                  "Undefined" );
03464         KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
03465                                  "Undefined" );
03466         KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
03467                                  "Undefined" );
03468     }
03469     QDomElement shapesSummaryElement = doc.createElement( "Summary" );
03470     shapesElement.appendChild( shapesSummaryElement );
03471     if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
03472         KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
03473                                  KDGanttViewItem::shapeToString( start ) );
03474         KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
03475                                  KDGanttViewItem::shapeToString( middle ) );
03476         KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
03477                                  KDGanttViewItem::shapeToString( end ) );
03478     } else {
03479         KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
03480                                  "Undefined" );
03481         KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
03482                                  "Undefined" );
03483         KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
03484                                  "Undefined" );
03485     }
03486 
03487     // the Colors element
03488     QDomElement colorsElement = doc.createElement( "Colors" );
03489     docRoot.appendChild( colorsElement );
03490     QDomElement colorsEventElement = doc.createElement( "Event" );
03491     colorsElement.appendChild( colorsEventElement );
03492     QColor startColor, middleColor, endColor;
03493     colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03494     KDGanttXML::createColorNode( doc, colorsEventElement, "Start", startColor );
03495     KDGanttXML::createColorNode( doc, colorsEventElement, "Middle", middleColor );
03496     KDGanttXML::createColorNode( doc, colorsEventElement, "End", endColor );
03497     QDomElement colorsTaskElement = doc.createElement( "Task" );
03498     colorsElement.appendChild( colorsTaskElement );
03499     colors( KDGanttViewItem::Task, startColor, middleColor, endColor );
03500     KDGanttXML::createColorNode( doc, colorsTaskElement, "Start", startColor );
03501     KDGanttXML::createColorNode( doc, colorsTaskElement, "Middle", middleColor );
03502     KDGanttXML::createColorNode( doc, colorsTaskElement, "End", endColor );
03503     QDomElement colorsSummaryElement = doc.createElement( "Summary" );
03504     colorsElement.appendChild( colorsSummaryElement );
03505     colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03506     KDGanttXML::createColorNode( doc, colorsSummaryElement, "Start", startColor );
03507     KDGanttXML::createColorNode( doc, colorsSummaryElement, "Middle", middleColor );
03508     KDGanttXML::createColorNode( doc, colorsSummaryElement, "End", endColor );
03509 
03510     // the DefaultColor element
03511     QDomElement defaultColorsElement = doc.createElement( "DefaultColors" );
03512     docRoot.appendChild( defaultColorsElement );
03513     KDGanttXML::createColorNode( doc, defaultColorsElement, "Event",
03514                             defaultColor( KDGanttViewItem::Event ) );
03515     KDGanttXML::createColorNode( doc, defaultColorsElement, "Task",
03516                             defaultColor( KDGanttViewItem::Task ) );
03517     KDGanttXML::createColorNode( doc, defaultColorsElement, "Summary",
03518                             defaultColor( KDGanttViewItem::Summary ) );
03519 
03520 
03521     // the HighlightColors element
03522     QDomElement highlightColorsElement = doc.createElement( "HighlightColors" );
03523     docRoot.appendChild( highlightColorsElement );
03524     QDomElement highlightColorsEventElement = doc.createElement( "Event" );
03525     highlightColorsElement.appendChild( highlightColorsEventElement );
03526     highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03527     KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Start", startColor );
03528     KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Middle", middleColor );
03529     KDGanttXML::createColorNode( doc, highlightColorsEventElement, "End", endColor );
03530     QDomElement highlightColorsTaskElement = doc.createElement( "Task" );
03531     highlightColorsElement.appendChild( highlightColorsTaskElement );
03532     highlightColors( KDGanttViewItem::Task, startColor, middleColor, endColor );
03533     KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Start", startColor );
03534     KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Middle", middleColor );
03535     KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "End", endColor );
03536     QDomElement highlightColorsSummaryElement = doc.createElement( "Summary" );
03537     highlightColorsElement.appendChild( highlightColorsSummaryElement );
03538     highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
03539     KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
03540     KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
03541     KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );
03542 
03543 
03544     /*
03545     if( highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor ) ) {
03546         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
03547         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
03548         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );
03549     } else {
03550         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", QColor() );
03551         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", QColor() );
03552         KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", QColor() );
03553     }
03554     */
03555     // the DefaultHighlightColor element
03556     QDomElement defaultHighlightColorsElement = doc.createElement( "DefaultHighlightColors" );
03557     docRoot.appendChild( defaultHighlightColorsElement );
03558     KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Event",
03559                             defaultHighlightColor( KDGanttViewItem::Event ) );
03560     KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Task",
03561                             defaultHighlightColor( KDGanttViewItem::Task ) );
03562     KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Summary",
03563                             defaultHighlightColor( KDGanttViewItem::Summary ) );
03564 
03565 
03566     // the Items element
03567     QDomElement itemsElement = doc.createElement( "Items" );
03568     docRoot.appendChild( itemsElement );
03569     KDGanttViewItem* currentItem = firstChild();
03570     while( currentItem ) {
03571         currentItem->createNode( doc, itemsElement );
03572         currentItem = currentItem->nextSibling();
03573     }
03574 
03575     // the TaskLinks element
03576     QDomElement taskLinksElement = doc.createElement( "TaskLinks" );
03577     docRoot.appendChild( taskLinksElement );
03578     QPtrList<KDGanttViewTaskLink> taskLinkList = taskLinks();
03579     KDGanttViewTaskLink* currentTL = 0;
03580     for( currentTL = taskLinkList.first(); currentTL;
03581          currentTL = taskLinkList.next() )
03582         currentTL->createNode( doc, taskLinksElement );
03583 
03584     // the TaskLinkGroups element
03585     QDomElement taskLinkGroupsElement = doc.createElement( "TaskLinkGroups" );
03586     docRoot.appendChild( taskLinkGroupsElement );
03587     QPtrList<KDGanttViewTaskLinkGroup> taskLinkGroupList = taskLinkGroups();
03588     KDGanttViewTaskLinkGroup* currentTLG = 0;
03589     for( currentTLG = taskLinkGroupList.first(); currentTLG;
03590          currentTLG = taskLinkGroupList.next() )
03591         currentTLG->createNode( doc, taskLinkGroupsElement );
03592 
03593     // the ColumnBackgroundColors element
03594     QDomElement columnBackgroundColorsElement =
03595         doc.createElement( "ColumnBackgroundColors" );
03596     docRoot.appendChild( columnBackgroundColorsElement );
03597     KDTimeHeaderWidget::ColumnColorList ccList =
03598         myTimeHeader->columnBackgroundColorList();
03599     for( KDTimeHeaderWidget::ColumnColorList::iterator it = ccList.begin();
03600          it != ccList.end(); ++it ) {
03601         QDomElement columnBackgroundColorElement =
03602             doc.createElement( "ColumnBackgroundColor" );
03603         columnBackgroundColorsElement.appendChild( columnBackgroundColorElement );
03604         KDGanttXML::createDateTimeNode( doc, columnBackgroundColorElement,
03605                                    "DateTime", (*it).datetime );
03606         KDGanttXML::createColorNode( doc, columnBackgroundColorElement,
03607                                 "Color", (*it).color );
03608     }
03609 
03610     // the LegendItems element
03611     QDomElement legendItemsElement =
03612         doc.createElement( "LegendItems" );
03613     docRoot.appendChild( legendItemsElement );
03614     legendItem* current;
03615     QPtrListIterator<legendItem> lit( *myLegendItems );
03616     while( ( current = lit.current() ) ) {
03617         ++lit;
03618         QDomElement legendItemElement = doc.createElement( "LegendItem" );
03619         legendItemsElement.appendChild( legendItemElement );
03620         KDGanttXML::createStringNode( doc, legendItemElement, "Shape",
03621                                  KDGanttViewItem::shapeToString( current->shape ) );
03622         KDGanttXML::createColorNode( doc, legendItemElement, "Color",
03623                                 current->color );
03624         KDGanttXML::createStringNode( doc, legendItemElement, "Text",
03625                                  current->text );
03626     }
03627 
03628     // the DragEnabled element
03629     KDGanttXML::createBoolNode( doc, docRoot, "DragEnabled", isDragEnabled() );
03630 
03631     // the DropEnabled element
03632     KDGanttXML::createBoolNode( doc, docRoot, "DropEnabled", isDropEnabled() );
03633 
03634     // the CalendarMode element
03635     KDGanttXML::createBoolNode( doc, docRoot, "CalendarMode", calendarMode() );
03636 
03637     return doc;
03638 }
03639 
03640 
03641 
03642 QString KDGanttView::scaleToString( Scale scale )
03643 {
03644     switch( scale ) {
03645     case Minute:
03646         return "Minute";
03647     case Hour:
03648         return "Hour";
03649     case Day:
03650         return "Day";
03651     case Week:
03652         return "Week";
03653     case Month:
03654         return "Month";
03655     case Auto:
03656         return "Auto";
03657     }
03658     return "";
03659 }
03660 
03661 
03662 KDGanttView::Scale KDGanttView::stringToScale( const QString& string )
03663 {
03664     if( string == "Minute" )
03665         return Minute;
03666     else if( string == "Hour" )
03667         return Hour;
03668     else if( string == "Day" )
03669         return Day;
03670     else if( string == "Week" )
03671         return Week;
03672     else if( string == "Month" )
03673         return Month;
03674     else if( string == "Auto" )
03675         return Auto;
03676 
03677     return Auto;
03678 }
03679 
03680 
03681 QString KDGanttView::yearFormatToString( YearFormat format )
03682 {
03683     switch( format ) {
03684     case FourDigit:
03685         return "FourDigit";
03686     case TwoDigit:
03687         return "TwoDigit";
03688     case TwoDigitApostrophe:
03689         return "TwoDigitApostrophe";
03690     case NoDate:
03691         return "NoDate";
03692     }
03693     return "";
03694 }
03695 
03696 
03697 KDGanttView::YearFormat KDGanttView::stringToYearFormat( const QString& string )
03698 {
03699     if( string == "FourDigit" )
03700         return FourDigit;
03701     else if( string == "TwoDigit" )
03702         return TwoDigit;
03703     else if( string == "TwoDigitApostrophe" )
03704         return TwoDigitApostrophe;
03705     else if( string == "NoDate" )
03706         return NoDate;
03707     else
03708         return FourDigit;
03709 }
03710 
03711 
03712 QString KDGanttView::hourFormatToString( HourFormat format )
03713 {
03714     switch( format ) {
03715     case Hour_12:
03716         return "Hour_12";
03717     case Hour_24:
03718         return "Hour_24";
03719     case Hour_24_FourDigit:
03720         return "Hour_24_FourDigit";
03721     }
03722     return "";
03723 }
03724 
03725 
03726 KDGanttView::HourFormat KDGanttView::stringToHourFormat( const QString& string )
03727 {
03728     if( string == "Hour_12" )
03729         return Hour_12;
03730     else if( string == "Hour_24" )
03731         return Hour_24;
03732     else
03733         return Hour_24;
03734 }
03735 
03736 
03737 void KDGanttView::addTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
03738 {
03739 
03740   if (myTaskLinkGroupList.isEmpty()) {
03741     myTaskLinkGroupList.append(group);
03742     return;
03743   }
03744     if (myTaskLinkGroupList.find(group) == -1)
03745         myTaskLinkGroupList.append(group);
03746 }
03747 
03748 
03749 void KDGanttView::removeTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
03750 {
03751     myTaskLinkGroupList.remove(group);
03752 }
03753 
03754 
03760 void KDGanttView::editItem( KDGanttViewItem*  item)
03761 {
03762   if ( ! item )
03763     return;
03764   if ( editorEnabled() ) {
03765     if ( item->editable() ) {
03766       myItemAttributeDialog->reset( item );
03767       myItemAttributeDialog->show();
03768     }
03769   }
03770 }
03771 
03772 
03783 QPixmap KDGanttView::getPixmap( KDGanttViewItem::Shape shape,
03784                                 const QColor& shapeColor,
03785                                 const QColor& backgroundColor, int itemSize)
03786 {
03787   // 10 is a good value as size
03788   int size = itemSize+2;
03789   int hei = ( itemSize/3 ) / 2;
03790   QPixmap p = QPixmap( size+4, size+4 );
03791   p.fill( backgroundColor );
03792   QPainter paint (&p);
03793   QBrush b = QBrush ( Qt::SolidPattern );
03794   b.setColor( shapeColor );
03795   paint.setBrush( b );
03796   QPen pen( Qt::black, 1 ) ;
03797   paint.setPen( pen );
03798   switch (shape) {
03799   case KDGanttViewItem::TriangleDown:{
03800     QPointArray arr = QPointArray(3);
03801     arr.setPoint(0,-size/2,-hei);
03802     arr.setPoint(1,size/2,-hei);
03803     arr.setPoint(2,0,((size/2)-hei));
03804     arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03805     paint.drawPolygon( arr );
03806     break;
03807   }
03808   case KDGanttViewItem::TriangleUp :{
03809     QPointArray arr = QPointArray(3);
03810     arr.setPoint(0,-size/2,hei);
03811     arr.setPoint(1,size/2,hei);
03812     arr.setPoint(2,0,(-size/2)+hei);
03813     arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03814     paint.drawPolygon( arr );
03815     break;
03816   }
03817   case  KDGanttViewItem::Diamond :{
03818     QPointArray arr = QPointArray(4);
03819     arr.setPoint(0,0,-size/2);
03820     arr.setPoint(1,size/2,0);
03821     arr.setPoint(2,0,size/2);
03822     arr.setPoint(3,-size/2,0);
03823     arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03824     paint.drawPolygon( arr );
03825     break;
03826   }
03827   case KDGanttViewItem::Square :{
03828     QPointArray arr = QPointArray(4);
03829     arr.setPoint(0,-size/2,-size/2);
03830     arr.setPoint(1,size/2,-size/2);
03831     arr.setPoint(2,size/2,size/2);
03832     arr.setPoint(3,-size/2,size/2);
03833     arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
03834     paint.drawPolygon( arr );
03835     break;
03836   }
03837   case  KDGanttViewItem::Circle  :{
03838     paint.drawEllipse( 2, 2, size, size);
03839     break;
03840   }
03841   }
03842   paint.end();
03843   return p;
03844 }
03845 
03846 int KDGanttView::getIndex( KDGanttViewItem::Type type) const
03847 {
03848     int index = -1;
03849     switch (type) {
03850     case (KDGanttViewItem::Event):
03851         index = 0;
03852         break;
03853     case (KDGanttViewItem::Task):
03854         index = 1;
03855         break;
03856     case (KDGanttViewItem::Summary):
03857         index = 2;
03858         break;
03859     }
03860     return index;
03861 }
03862 
03863 
03864 void KDGanttView::initDefaults()
03865 {
03866   int i;
03867   // We have 3 item types. Set all undefined to true.
03868     for (i = 0;i<3;++i) {
03869         undefinedShape[i] = true;
03870         undefinedColor[i] = true;
03871         undefinedColorHL[i] = true;
03872     }
03873     // setting the default colors
03874     myDefaultColor [ getIndex( KDGanttViewItem::Event ) ] =  Qt::blue; //event
03875     myDefaultColorHL [ getIndex( KDGanttViewItem::Event ) ] =  Qt::red;
03876     myDefaultColor [ getIndex( KDGanttViewItem::Task ) ] =  Qt::green;//task
03877     myDefaultColorHL [ getIndex( KDGanttViewItem::Task ) ] =  Qt::red;
03878     myDefaultColor [ getIndex( KDGanttViewItem::Summary ) ] =  Qt::cyan;//summary
03879     myDefaultColorHL [ getIndex( KDGanttViewItem::Summary ) ] =  Qt::red;
03880 
03881     // setting the default shape types
03882     // currently, we take for each item for all three shapes (start, middle, end) the same default shape
03883     for (i = 0;i<3;++i) {
03884       myDefaultShape [3*getIndex( KDGanttViewItem::Event )+ i] =  KDGanttViewItem::Diamond; //event
03885       myDefaultShape [3*getIndex( KDGanttViewItem::Task ) +i] =  KDGanttViewItem::Square; //task
03886       myDefaultShape [3*getIndex( KDGanttViewItem::Summary ) +i] =  KDGanttViewItem::TriangleDown; //summary
03887 
03888     }
03889 }
03890 
03891 
03892 
03896 int KDGanttView::addColumn( const QString& label, int width )
03897 {
03898     return myListView->addColumn( label, width );
03899 }
03900 
03901 
03906 int KDGanttView::addColumn( const QIconSet& iconset, const QString& label,
03907                             int width )
03908 {
03909     return myListView->addColumn( iconset, label, width );
03910 }
03911 
03912 
03916 void KDGanttView::removeColumn( int index )
03917 {
03918     myListView->removeColumn( index );
03919 }
03920 
03921 
03925 KDGanttViewItem* KDGanttView::selectedItem() const
03926 {
03927     return static_cast<KDGanttViewItem*>( myListView->selectedItem() );
03928 }
03929 
03930 
03934 void KDGanttView::setSelected( KDGanttViewItem* item, bool selected )
03935 {
03936     myListView->setSelected( item, selected );
03937 }
03938 
03939 
03952 KDGanttViewItem* KDGanttView::getItemByName( const QString& name ) const
03953 {
03954     KDGanttViewItem* temp =  firstChild(),* ret;
03955     while (temp != 0) {
03956       if ( (ret = temp->getChildByName( name ) ) )
03957         return ret;
03958       temp = temp->nextSibling();
03959     }
03960     return 0;
03961 }
03962 
03963 
03975 KDGanttViewItem* KDGanttView::getItemByListViewPos( const QPoint& pos ) const
03976 {
03977     return static_cast<KDGanttViewItem*>( myListView->itemAt(myListView->mapFromGlobal(pos) ));
03978 }
03979 
03980 
03995 KDGanttViewItem* KDGanttView::getItemByGanttViewPos( const QPoint& pos ) const
03996 {
03997   KDGanttViewItem* item;
03998   QPoint local = myCanvasView->mapFromGlobal(pos);
03999 
04000     QCanvasItemList il = myTimeTable->collisions( myCanvasView->viewportToContents( local ));
04001     QCanvasItemList::Iterator it;
04002     for ( it = il.begin(); it != il.end(); ++it ) {
04003       if ( myCanvasView->getType(*it) == Type_is_KDGanttViewItem) {
04004         item = myCanvasView->getItem(*it);
04005         if ( item->enabled() )
04006           return item;
04007       }
04008     }
04009     return 0;
04010 }
04011 
04012 
04027 KDGanttViewItem* KDGanttView::getItemAt( const QPoint& pos, bool global ) const
04028 {
04029   /* buggy code - commented out
04030   QPoint myPos;
04031   if (  global )
04032     myPos = myListView->contentsToViewport( myListView->mapFromGlobal(pos) );
04033   else
04034      myPos = myListView->contentsToViewport( pos );
04035   return (KDGanttViewItem*) myListView->itemAt( myPos );
04036   */
04037 
04038   KDGanttViewItem* item;
04039   KDGanttViewItem* retItem = 0;
04040   int y;
04041   if ( global )
04042     y = myCanvasView->mapFromGlobal(pos).y();
04043   else
04044     y = pos.y();
04045   item = firstChild();
04046   while ( item != 0 ) {
04047     int yc = item->itemPos();
04048     if ( yc <= y && y < yc + item->height()) {
04049       retItem = item;
04050       break;
04051     }
04052     item = item->itemBelow();
04053   }
04054   return retItem;
04055 
04056 }
04057 
04058 
04059 void KDGanttView::addTickRight()
04060 {
04061   if ( !mFixedHorizon && _enableAdding && myCanvasView->horizontalScrollBar()->value() ==  myCanvasView->horizontalScrollBar()->maxValue()) {
04062     //myCanvasView->horizontalScrollBar()->blockSignals( true );
04063     myTimeHeader->addTickRight();
04064     //myCanvasView->horizontalScrollBar()->blockSignals( false );
04065     myCanvasView->updateHorScrollBar();
04066     setTimelineToEnd();
04067   }
04068 }
04069 
04070 
04071 void KDGanttView::addTickLeft()
04072 {
04073   if ( !mFixedHorizon && _enableAdding && myCanvasView->horizontalScrollBar()->value() == 0 ) {
04074     myCanvasView->horizontalScrollBar()->blockSignals( true );
04075     myTimeHeader->addTickLeft();
04076     myCanvasView->horizontalScrollBar()->blockSignals( false );
04077     setTimelineToStart();
04078   }
04079 }
04080 
04081 
04082 void KDGanttView::enableAdding( int val )
04083 {
04084   _enableAdding = ( val == 0 || val == myCanvasView->horizontalScrollBar()->maxValue());
04085 }
04086 
04087 
04093 int KDGanttView::childCount() const
04094 {
04095     return myListView->childCount();
04096 }
04097 
04098 
04102 void KDGanttView::clear()
04103 {
04104   bool block = myTimeTable->blockUpdating();
04105   myTimeTable->setBlockUpdating( true );
04106   myListView->clear();
04107   myTimeTable->setBlockUpdating( false );
04108   myTimeTable->updateMyContent();
04109   myTimeTable->setBlockUpdating( block );
04110 }
04111 
04112 
04116 void KDGanttView::slot_lvDropped(QDropEvent* e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse  )
04117 {
04118   emit dropped( e, droppedItem, itemBelowMouse);
04119 }
04120 
04124 QDragObject * KDGanttView::dragObject ()
04125 {
04126   return myListView->dragObject ();
04127 }
04128 
04129 
04133 void KDGanttView::startDrag ()
04134 {
04135   //myListView->pt_startDrag ();
04136 }
04137 
04138 
04142 void KDGanttView::setPaletteBackgroundColor( const QColor& col)
04143 {
04144   QWidget::setPaletteBackgroundColor( col );
04145   timeHeaderSpacerWidget->setPaletteBackgroundColor( col );
04146 }
04147 
04148 
04155 void KDGanttView::setGvBackgroundColor ( const QColor & c )
04156 {
04157   myTimeTable->setBackgroundColor( c );
04158 }
04159 
04160 
04167 void KDGanttView::setTimeHeaderBackgroundColor ( const QColor & c )
04168 {
04169   myTimeHeader->setPaletteBackgroundColor( c );
04170   //rightWidget->setPaletteBackgroundColor( c );
04171   timeHeaderSpacerWidget->setPaletteBackgroundColor( c );
04172 }
04173 
04174 
04181 void KDGanttView::setLegendHeaderBackgroundColor ( const QColor & c )
04182 {
04183   myLegend->setPaletteBackgroundColor( c );
04184   leftWidget->setPaletteBackgroundColor( c );
04185 }
04186 
04187 
04194 void KDGanttView::setLvBackgroundColor ( const QColor & c )
04195 {
04196  myListView->viewport()->setPaletteBackgroundColor( c );
04197 }
04198 
04199 
04206 QColor KDGanttView::lvBackgroundColor ( )const
04207 {
04208  return myListView->viewport()->paletteBackgroundColor( );
04209 }
04210 
04211 
04218 QColor KDGanttView::gvBackgroundColor () const
04219 {
04220  return myTimeTable->backgroundColor( );
04221 }
04222 
04223 
04230 QColor KDGanttView::timeHeaderBackgroundColor () const
04231 {
04232  return myTimeHeader->paletteBackgroundColor( );
04233 }
04234 
04235 
04242 QColor KDGanttView::legendHeaderBackgroundColor () const
04243 {
04244  return myLegend->paletteBackgroundColor( );
04245 }
04246 
04247 
04262 void KDGanttView::addUserdefinedLegendHeaderWidget( QWidget * w )
04263 {
04264   if ( w ) {
04265     w->reparent ( spacerLeft, 0, QPoint(0,0) );
04266   }
04267 }
04268 
04269 
04278 void KDGanttView::setDragEnabled( bool b )
04279 {
04280   fDragEnabled = b;
04281  QListViewItemIterator it( myListView );
04282  for ( ; it.current(); ++it ) {
04283    (( KDGanttViewItem* )it.current())->setDragEnabled(b);
04284  }
04285 
04286 }
04287 
04288 
04297 void KDGanttView::setDropEnabled( bool b )
04298 {
04299   fDropEnabled = b;
04300 
04301   //myListView->setAcceptDrops( b );
04302  QListViewItemIterator it( myListView );
04303  for ( ; it.current(); ++it ) {
04304    (( KDGanttViewItem* )it.current())->setDropEnabled(b);
04305  }
04306 }
04307 
04308 
04317 void KDGanttView::setDragDropEnabled( bool b )
04318 {
04319   setDropEnabled( b );
04320   setDragEnabled( b );
04321 }
04322 
04323 
04330 bool KDGanttView::isDragEnabled() const
04331 {
04332   return fDragEnabled;
04333 }
04334 
04335 
04342 bool KDGanttView::isDropEnabled() const
04343 {
04344  return fDropEnabled;
04345 }
04346 
04347 
04351 bool KDGanttView::dragEnabled() const
04352 {
04353   return isDragEnabled();
04354 }
04355 
04356 
04360 bool KDGanttView::dropEnabled() const
04361 {
04362  return isDropEnabled();
04363 }
04364 
04365 
04392 bool  KDGanttView::lvDropEvent ( QDropEvent* e,
04393                                  KDGanttViewItem* droppedItem,
04394                                  KDGanttViewItem* itemBelowMouse )
04395 {
04396     Q_UNUSED( e );
04397     Q_UNUSED( droppedItem );
04398     Q_UNUSED( itemBelowMouse );
04399 
04400   // Example code for user defined behaviour:
04401   // we want to accept the usual drags and the drags of files, which may be
04402   // a saved Gantt file.
04403   // Please uncomment the following lines for this behaviour
04404   // You have to uncomment lines in lvDragMoveEvent() and llvDragEnterEvent() as well
04405 
04406   // ************** begin example ************
04407   /*
04408   if ( QUriDrag::canDecode( e ) ) {
04409     QStrList lst;
04410     QUriDrag::decode( e, lst );
04411     // we try the first file of icon-url-list
04412     QString str = lst.at ( 0 );
04413     // remove file: at beginning of string
04414     str = str.right( str.length() - 5  );
04415     QFileInfo info;
04416     info.setFile( str ) ;
04417     if ( info.isFile() ) {
04418       if (!QMessageBox::information( this, "KDGantt Drag&Drop test",
04419                                      "Try to insert file: "+ str + " ?",
04420                                      "&Okay", "&Cancel",0,1  ) ) {
04421         QFile file( str );
04422         // store current updating status
04423         bool uen = myTimeTable->blockUpdating();
04424         // block updating while insertion of items
04425         myTimeTable->setBlockUpdating();
04426         loadProject( &file ) ;
04427         // restore updating status and execute an update via setUpdateEnabled( true );
04428         if ( !uen )
04429           setUpdateEnabled( true );
04430       }
04431     }
04432     return true;
04433   }
04434   */
04435   // *********** end example ****************
04436   return false;
04437 }
04438 
04439 
04456 void  KDGanttView::lvDragEnterEvent ( QDragEnterEvent * e)
04457 {
04458   // the standard behaviour:
04459   // accept drag enter events, if KDGanttViewItemDrag can decode the event
04460   // e->accept(KDGanttViewItemDrag::canDecode(e) );
04461 
04462   if ( KDGanttViewItemDrag::canDecode(e) ) {
04463     e->accept( true);
04464     return;
04465   }
04466 
04467   // example code for user defined behaviour:
04468   // we want to accecpt the usual drags and the drags of files, which may be
04469   // a saved Gantt file
04470   // Please uncomment the following lines for this behaviour
04471   // You have to uncomment lines in lvDragMoveEvent() and lvDropEvent () as well
04472 
04473   //  if ( QUriDrag::canDecode( e ) ) {
04474   // e->accept(true);
04475   //  return;
04476   // }
04477 
04478   e->accept( false );
04479 }
04480 
04481 
04510 bool  KDGanttView::lvDragMoveEvent ( QDragMoveEvent* /*e*/,
04511                                      KDGanttViewItem* /* draggedItem*/,
04512                                      KDGanttViewItem* /*itemBelowMouse*/)
04513 {
04514 
04515   // Example code 1:
04516   // To generally block items to be inserted as root items, subclass KDGanttView
04517   // and reimplement this method with to following code uncommented:
04518 
04519   // if ( !itemBelowMouse ) {
04520   //  e->accept( false );
04521   //  return true;
04522   //}
04523   //return false;
04524 
04525   // Example code 2:
04526   // To allow the drags of files, which may be
04527   // a saved Gantt file, subclass KDGanttView
04528   // and reimplement this method with to following code uncommented:
04529 
04530   // if ( QUriDrag::canDecode( e ) ) {
04531   //   e->accept(true);
04532   //   return true;
04533   //  }
04534 
04535 
04536  // normal behaviour - the internal drag move event handling should be executed
04537   return false;
04538 }
04539 
04540 
04550 void  KDGanttView::lvStartDrag (KDGanttViewItem* item)
04551 {
04552   QDragObject* d = new KDGanttViewItemDrag(item, this, "itemdrag" );
04553   // call d->drag() to start the dragging
04554   // d->drag() returns true, if a move was requested as a drag
04555   // if a copy (by pressing the <Ctrl>-key) was performed, d->drag() returns false
04556   // In order to avoid starting drags for particular items, subclass KDGanttView
04557   // an reimplement this method.
04558   // insert here some code like
04559   // if ( item->parent() )
04560   // return;
04561   // This particular code will make it impossible to drag other items but root items.
04562   if ( d->drag()  ) {
04563       delete item;
04564   }
04565 }
04566 
04567 
04575 void  KDGanttView::setListViewWidth( int w )
04576 {
04577   int sw = mySplitter->width();
04578   QValueList<int> list;
04579   list.append(w);
04580   list.append(sw-w);
04581   mySplitter->setSizes( list );
04582 }
04583 
04584 
04591 int  KDGanttView::listViewWidth( )
04592 {
04593   return leftWidget->width();
04594 }
04595 
04596 
04606 void  KDGanttView::setLvVScrollBarMode( QScrollView::ScrollBarMode m )
04607 {
04608   myListView->setVScrollBarMode ( m );
04609 }
04610 
04611 
04621 void  KDGanttView::setGvVScrollBarMode( QScrollView::ScrollBarMode m )
04622 {
04623   if ( m == QScrollView::Auto )
04624     qDebug("KDGanttView::setListViewVScrollBarMode: QScrollView::Auto not supported. Nothing changed. ");
04625   else
04626     {
04627       myCanvasView->setVScrollBarMode ( m );
04628       if ( m == QScrollView::AlwaysOn )
04629         timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
04630       else
04631         timeHeaderSpacerWidget->setFixedWidth( 0 );
04632     }
04633 }
04634 
04635 
04636 void  KDGanttView::notifyEditdialog( KDGanttViewItem * item)
04637 {
04638   if (myItemAttributeDialog->getItem() == item ) {
04639     myItemAttributeDialog->reset( 0 );
04640   }
04641 }
04642 
04650 void KDGanttView::setLinkItemsEnabled(bool on)
04651 {
04652     myCanvasView->linkItemsEnabled = on;
04653     myCanvasView->autoScrollEnabled = true;
04654 }
04655 
04661 bool KDGanttView::isLinkItemsEnabled() const
04662 {
04663     return myCanvasView->linkItemsEnabled;
04664 }
04665 
KDE Home | KDE Accessibility Home | Description of Access Keys