~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to kdgantt1/KDGanttView.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C++ -*-
2
 
   $Id: KDGanttView.cpp 937849 2009-03-10 15:15:48Z winterz $
3
 
   KDGantt - a multi-platform charting engine
4
 
*/
5
 
 
6
 
/****************************************************************************
7
 
 ** Copyright (C)  2002-2004 Klarälvdalens Datakonsult AB.  All rights reserved.
8
 
 **
9
 
 ** This file is part of the KDGantt library.
10
 
 **
11
 
 ** This file may be used under the terms of the GNU General Public
12
 
 ** License versions 2.0 or 3.0 as published by the Free Software
13
 
 ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
14
 
 ** included in the packaging of this file.  Alternatively you may (at
15
 
 ** your option) use any later version of the GNU General Public
16
 
 ** License if such license has been publicly approved by
17
 
 ** Klarälvdalens Datakonsult AB (or its successors, if any).
18
 
 **
19
 
 ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
20
 
 ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
21
 
 ** A PARTICULAR PURPOSE. Klarälvdalens Datakonsult AB reserves all rights
22
 
 ** not expressly granted herein.
23
 
 **
24
 
 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
 
 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26
 
 **
27
 
 ** As a special exception, permission is given to link this program
28
 
 ** with any edition of Qt, and distribute the resulting executable,
29
 
 ** without including the source code for Qt in the source distribution.
30
 
 **
31
 
 **********************************************************************/
32
 
 
33
 
// we need the protected QHeader method
34
 
// QHeader::paintSection ( QPainter * p, int index, const QRect & fr )
35
 
// in order to print the header of the list view
36
 
// because we cannot reimplement QHeader to access this method we
37
 
// have to get access to the protected QHeader methods
38
 
 
39
 
#include "KDGanttView.h"
40
 
#include "KDGanttViewSubwidgets.h"
41
 
#include "KDGanttMinimizeSplitter.h"
42
 
#include "KDGanttViewItem.h"
43
 
#include "KDGanttViewTaskItem.h"
44
 
#include "KDGanttViewEventItem.h"
45
 
#include "KDGanttViewSummaryItem.h"
46
 
#include "KDGanttXMLTools.h"
47
 
#if QT_VERSION < 0x040000
48
 
#include "itemAttributeDialog.h"
49
 
#endif
50
 
#include <QPrinter>
51
 
#include <QPainter>
52
 
#include <QLayout>
53
 
#include <QFile>
54
 
#include <QApplication>
55
 
#include <QtDebug>
56
 
#include <QPrintDialog>
57
 
#include <QDragEnterEvent>
58
 
 
59
 
#include <QMessageBox>
60
 
#include <QFileInfo>
61
 
#include <QTextStream>
62
 
 
63
 
 
64
 
 
65
 
#if defined KDAB_EVAL
66
 
#include "../evaldialog/evaldialog.h"
67
 
#endif
68
 
 
69
 
/*!
70
 
  \class KDGanttView KDGanttView.h
71
 
  This class represents a Gantt view with the Gantt chart, the header,
72
 
  an optional listview and an optional legend.
73
 
 
74
 
  In order to set up a Gantt view, create an object of this class, and
75
 
  populate it with a number of \a KDGanttViewItem objects.
76
 
 
77
 
  If you experience problems with the repainting of the content of the
78
 
  Gantt View after scrolling, call \a setRepaintMode().
79
 
*/
80
 
 
81
 
/*!
82
 
  Constructs an empty KDGanttView.
83
 
 
84
 
  \param parent the widget parent
85
 
  \param name the internal debugging name
86
 
*/
87
 
 
88
 
 
89
 
KDGanttView::KDGanttView( QWidget* parent, const char* name  )
90
 
    : KDGanttMinimizeSplitter( Qt::Vertical, parent ),
91
 
      myCanvasView(0),
92
 
      myTimeHeaderScroll(0),
93
 
      mFixedHorizon( false )
94
 
{
95
 
  setObjectName( name );
96
 
 
97
 
#if defined KDAB_EVAL
98
 
    EvalDialog::checkEvalLicense( "KD Gantt" );
99
 
#endif
100
 
  myCurrentItem = 0;
101
 
  mUserHorizonChangeEnabled = true;
102
 
#if QT_VERSION < 0x040000
103
 
    setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
104
 
#endif
105
 
    mySplitter = new KDGanttMinimizeSplitter( this );
106
 
#if QT_VERSION < 0x040000
107
 
    mySplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
108
 
#endif
109
 
    leftWidget = new QVBox( mySplitter );
110
 
    rightWidget = new QVBox( mySplitter );
111
 
    //leftWidget->setMinimumSize( 20, 20 );
112
 
    //rightWidget->setMinimumSize( 20, 20 );
113
 
    myLegend = new KDLegendWidget( leftWidget, this );
114
 
    spacerLeft = new QWidget( leftWidget );
115
 
    spacerLeftLayout = new QHBoxLayout( spacerLeft );
116
 
    spacerLeftLayout->setMargin( 0 );
117
 
    spacerLeftLayout->setSpacing( 0 );
118
 
 
119
 
    myListView = new KDListView(leftWidget, this);
120
 
    myListView->setVScrollBarMode (QScrollView::AlwaysOff );
121
 
#if QT_VERSION < 0x040000
122
 
    connect( myListView, SIGNAL( selectionChanged( QListViewItem* ) ),
123
 
             this, SLOT( slotSelectionChanged( QListViewItem* ) ) );
124
 
    connect( myListView, SIGNAL( mouseButtonClicked ( int, QListViewItem * , const QPoint &, int ) ),
125
 
             this, SLOT( slotmouseButtonClicked ( int , QListViewItem * , const QPoint &, int ) ) );
126
 
    connect( myListView, SIGNAL( contextMenuRequested ( QListViewItem * , const QPoint &, int  ) ),
127
 
             this, SLOT( slotcontextMenuRequested ( QListViewItem * , const QPoint & , int ) ) );
128
 
    connect( myListView, SIGNAL(expanded ( QListViewItem *  ) ),
129
 
             this, SLOT(slotItemExpanded ( QListViewItem * ) ) );
130
 
    connect( myListView, SIGNAL(collapsed ( QListViewItem *  ) ),
131
 
             this, SLOT(slotItemCollapsed( QListViewItem * ) ) );
132
 
    connect( myListView, SIGNAL(currentChanged( QListViewItem *  ) ),
133
 
             this, SLOT(slotCurrentChanged ( QListViewItem * ) ) );
134
 
    connect( myListView, SIGNAL(itemRenamed ( QListViewItem * , int , const QString &  ) ),
135
 
             this, SLOT(slotItemRenamed ( QListViewItem *, int , const QString &  ) ) );
136
 
    connect( myListView, SIGNAL(mouseButtonPressed(  int, QListViewItem * , const QPoint &, int ) ),
137
 
             this, SLOT(slotMouseButtonPressed (  int , QListViewItem * , const QPoint & , int ) ) );
138
 
#else
139
 
    connect( myListView, SIGNAL( selectionChanged( Q3ListViewItem* ) ),
140
 
             this, SLOT( slotSelectionChanged( Q3ListViewItem* ) ) );
141
 
    connect( myListView, SIGNAL( mouseButtonClicked ( int, Q3ListViewItem * , const QPoint &, int ) ),
142
 
             this, SLOT( slotmouseButtonClicked ( int , Q3ListViewItem * , const QPoint &, int ) ) );
143
 
    connect( myListView, SIGNAL( contextMenuRequested ( Q3ListViewItem * , const QPoint &, int  ) ),
144
 
             this, SLOT( slotcontextMenuRequested ( Q3ListViewItem * , const QPoint & , int ) ) );
145
 
    connect( myListView, SIGNAL(expanded ( Q3ListViewItem *  ) ),
146
 
             this, SLOT(slotItemExpanded ( Q3ListViewItem * ) ) );
147
 
    connect( myListView, SIGNAL(collapsed ( Q3ListViewItem *  ) ),
148
 
             this, SLOT(slotItemCollapsed( Q3ListViewItem * ) ) );
149
 
    connect( myListView, SIGNAL(currentChanged( Q3ListViewItem *  ) ),
150
 
             this, SLOT(slotCurrentChanged ( Q3ListViewItem * ) ) );
151
 
    connect( myListView, SIGNAL(itemRenamed ( Q3ListViewItem * , int , const QString &  ) ),
152
 
             this, SLOT(slotItemRenamed ( Q3ListViewItem *, int , const QString &  ) ) );
153
 
    connect( myListView, SIGNAL(mouseButtonPressed(  int, Q3ListViewItem * , const QPoint &, int ) ),
154
 
             this, SLOT(slotMouseButtonPressed (  int , Q3ListViewItem * , const QPoint & , int ) ) );
155
 
#endif
156
 
    //connect( myListView, SIGNAL( ), this, SLOT( ) );
157
 
    myTimeTable = new KDTimeTableWidget (0,this);
158
 
 
159
 
    spacerRight = new QWidget(  rightWidget );
160
 
 
161
 
    myTimeHeaderContainer = new QHBox( rightWidget );
162
 
    myTimeHeaderContainer->setFrameStyle( QFrame::NoFrame  );
163
 
    myTimeHeaderContainer->setMargin( 0 );
164
 
    myTimeHeaderScroll = new QScrollView ( myTimeHeaderContainer );
165
 
    myTimeHeaderScroll->setHScrollBarMode( QScrollView::AlwaysOff );
166
 
    myTimeHeaderScroll->setVScrollBarMode( QScrollView::AlwaysOff );
167
 
    timeHeaderSpacerWidget = new QWidget( myTimeHeaderContainer );
168
 
 
169
 
 
170
 
    /*
171
 
    myTimeHeaderScroll = new QScrollView ( rightWidget );
172
 
    myTimeHeaderScroll->setHScrollBarMode( QScrollView::AlwaysOff );
173
 
    myTimeHeaderScroll->setVScrollBarMode( QScrollView::AlwaysOn );
174
 
    */
175
 
    //myTimeHeader = new KDTimeHeaderWidget (rightWidget,this);
176
 
    myTimeHeader = new KDTimeHeaderWidget (myTimeHeaderScroll->viewport(),this);
177
 
    myTimeHeaderScroll->addChild( myTimeHeader );
178
 
    QPalette pal = myTimeHeader->palette();
179
 
    myTimeHeaderScroll->viewport()->setPalette( pal );
180
 
    timeHeaderSpacerWidget->setPalette( pal );
181
 
    myCanvasView = new KDGanttCanvasView( this, myTimeTable, rightWidget);
182
 
    myTimeHeaderScroll->setFrameStyle( QFrame::NoFrame  );
183
 
    //
184
 
    myCanvasView->setFrameStyle( QFrame::NoFrame  );
185
 
    myCanvasView->setMargin( 0 );
186
 
    //
187
 
    myTimeHeaderScroll->setMargin( 0 );//myCanvasView->frameWidth() );
188
 
    setFrameStyle(myListView->frameStyle());
189
 
    setLineWidth( 2 );
190
 
    myListView->setFrameStyle( QFrame::NoFrame  );
191
 
    myListView->setMargin( 0 );
192
 
#if QT_VERSION < 0x040000
193
 
    QObject::connect(myListView, SIGNAL (  expanded ( QListViewItem * ) ) ,
194
 
                     myTimeTable , SLOT( expandItem(QListViewItem * ))) ;
195
 
    QObject::connect(myListView, SIGNAL (collapsed ( QListViewItem * ) ) ,
196
 
                     myTimeTable , SLOT(collapseItem(QListViewItem * ))) ;
197
 
#else
198
 
    QObject::connect(myListView, SIGNAL (  expanded ( Q3ListViewItem * ) ) ,
199
 
                     myTimeTable , SLOT( expandItem(Q3ListViewItem * ))) ;
200
 
    QObject::connect(myListView, SIGNAL (collapsed ( Q3ListViewItem * ) ) ,
201
 
                     myTimeTable , SLOT(collapseItem(Q3ListViewItem * ))) ;
202
 
#endif
203
 
    timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
204
 
    listViewIsVisible = true;
205
 
    chartIsEditable = true;
206
 
    editorIsEnabled = true;
207
 
    _displaySubitemsAsGroup = false;
208
 
    initDefaults();
209
 
    _showHeader = false;
210
 
 
211
 
    myTextColor = Qt::black;
212
 
    //QObject::connect( this, SIGNAL (itemDoubleClicked( KDGanttViewItem* ) ) , this, SLOT( editItem( KDGanttViewItem*  ))) ;
213
 
#if QT_VERSION < 0x040000
214
 
    myItemAttributeDialog = 0;
215
 
#endif
216
 
    setRepaintMode( KDGanttView::Medium );
217
 
    setShowLegendButton( true );
218
 
    setHeaderVisible( false );
219
 
 
220
 
    // now connecting the widgets
221
 
    connect(myCanvasView->horizontalScrollBar(), SIGNAL (  valueChanged ( int )) ,myTimeHeaderScroll->horizontalScrollBar(), SLOT( setValue ( int))) ;
222
 
    connect(myCanvasView, SIGNAL (  heightResized( int )) ,myTimeTable, SLOT( checkHeight ( int))) ;
223
 
    connect(myCanvasView, SIGNAL (  widthResized( int )) ,myTimeHeader, SLOT( checkWidth ( int))) ;
224
 
 
225
 
    QObject::connect(myCanvasView->verticalScrollBar(), SIGNAL ( valueChanged ( int ) ) ,myListView->verticalScrollBar(), SLOT( setValue ( int ))) ;
226
 
    connect(myTimeHeader, SIGNAL ( sizeChanged( int ) ) ,this, SLOT(slotHeaderSizeChanged()  )) ;
227
 
    connect(myTimeHeader, SIGNAL ( sizeChanged( int ) ) ,myTimeTable, SLOT(resetWidth( int ) )) ;
228
 
    connect(myListView, SIGNAL ( contentsMoving ( int, int ) ) ,myCanvasView, SLOT(  moveMyContent( int, int ))) ;
229
 
    connect(myTimeTable, SIGNAL ( heightComputed ( int ) ) ,myCanvasView, SLOT(  setMyContentsHeight( int ))) ;
230
 
   // the next three are for adding new ticks at left/right
231
 
#if QT_VERSION < 0x040000
232
 
    //connect( myCanvasView->horizontalScrollBar(), SIGNAL( prevLine () ) ,this, SLOT( addTickLeft()));
233
 
    //connect( myCanvasView->horizontalScrollBar(), SIGNAL( nextLine () ) ,this, SLOT( addTickRight()));
234
 
#else
235
 
    connect( myCanvasView->horizontalScrollBar(), SIGNAL( actionTriggered ( int ) ) ,this, SLOT( hScrollBarAction( int )));
236
 
    connect( myCanvasView->verticalScrollBar(), SIGNAL( actionTriggered ( int ) ) ,this, SLOT( vScrollBarAction( int )));
237
 
#endif
238
 
   // now initing
239
 
    fCenterTimeLineAfterShow = false;
240
 
    fDragEnabled = false;
241
 
    fDropEnabled = false;
242
 
    closingBlocked = false;
243
 
   myTimeHeader->computeTicks();
244
 
   centerTimelineAfterShow( QDateTime::currentDateTime () );
245
 
   setDisplayEmptyTasksAsLine( false );
246
 
   //QValueList<int> list;
247
 
   //list.append(240);
248
 
   //list.append(530);
249
 
   //mySplitter->setSizes( list );
250
 
   myTimeTable->setBlockUpdating();// block updating until this->show() is called
251
 
   mAddTickcountForTimeline = 1;
252
 
   myListView->setDefaultRenameAction( QListView::Reject );
253
 
}
254
 
 
255
 
KDGanttView::~KDGanttView()
256
 
{
257
 
    // Don't call clearAll, it recreates widgets inside KDLegendWidget
258
 
  QPtrList<KDGanttViewTaskLink>  tll = taskLinks();
259
 
  tll.setAutoDelete( true );
260
 
  tll.clear();
261
 
  QPtrList<KDGanttViewTaskLinkGroup> tlg = myTaskLinkGroupList;
262
 
  tlg.setAutoDelete( true );
263
 
  tlg.clear();
264
 
  clear();
265
 
 
266
 
  // delete cut item, if there is any
267
 
    myCanvasView->resetCutPaste( 0 );
268
 
    delete myTimeTable;
269
 
}
270
 
/*!
271
 
  This virtual method returns 0.
272
 
  Reimplement this virtual method to create your own subclassed items
273
 
  on a Drag&Drop operation or on save/load of data.
274
 
  Please read KDGanttView::createNewItem() for details.
275
 
 
276
 
  \param KDGanttViewItemTypeAsString the type of the new item as string.
277
 
         Is not Task, Summary or Event but another name for subclassed items.
278
 
         Usually the value is used what KDGanttViewItem::typeString() returns for that subclass.
279
 
  \param parent item of the new item. May be 0. If 0 the new item becomes a root item in this KDGantt view.
280
 
  \param previous the item behind the new one should appear. May be 0.
281
 
  \param lvtext the text to show in the list view
282
 
  \param name the name by which the item can be identified. If no name
283
 
              is specified, a unique name will be generated
284
 
  \return the newly created item
285
 
  \sa createNewItem()
286
 
*/
287
 
 
288
 
void KDGanttView::vScrollBarAction( int action )
289
 
{
290
 
    //qDebug() << "vScrollBarAction " << action ;
291
 
    switch ( mRepaintMode ) {
292
 
    case  No:
293
 
 
294
 
        break;
295
 
    case Medium:
296
 
        if ( action == 2 || action == 1 )
297
 
            forceRepaint();
298
 
        break;
299
 
    case Always:
300
 
        if ( action != 0 )
301
 
            forceRepaint();
302
 
        break;
303
 
    }
304
 
 
305
 
}
306
 
void KDGanttView::hScrollBarAction( int action )
307
 
{
308
 
    //qDebug() << "hScrollBarAction " << action;
309
 
    if (  action == 2 ) { // left
310
 
        addTickLeft();
311
 
    } else if ( action == 1 ) {
312
 
        addTickRight();
313
 
    }
314
 
    switch ( mRepaintMode ) {
315
 
    case  No:
316
 
 
317
 
        break;
318
 
    case Medium:
319
 
        if ( action == 2 || action == 1 )
320
 
            forceRepaint();
321
 
        break;
322
 
    case Always:
323
 
        if ( action != 0 )
324
 
            forceRepaint();
325
 
        break;
326
 
    }
327
 
}
328
 
 
329
 
KDGanttViewItem* KDGanttView::createUserDefinedItem( QString kdGanttViewItemTypeAsString,
330
 
                                                     KDGanttViewItem* parent,
331
 
                                                     KDGanttViewItem* after,
332
 
                                                     const QString& lvtext,
333
 
                                                     const QString& name )
334
 
{
335
 
    Q_UNUSED( kdGanttViewItemTypeAsString )
336
 
    Q_UNUSED( parent )
337
 
    Q_UNUSED( after )
338
 
    Q_UNUSED( lvtext )
339
 
    Q_UNUSED( name )
340
 
    qDebug() << "KDGanttView::createUserDefinedItem: Unknown type " << kdGanttViewItemTypeAsString;
341
 
    return 0;
342
 
}
343
 
/*!
344
 
  Creates a KDGanttViewItem according to the specification in the parameters.
345
 
  Calls KDGanttView::createUserDefinedItem() for a user defined item type.
346
 
  Reimplement this virtual method in a subclass of KDGanttView to define specific behaviour when adding new
347
 
  standard items and user defined (subclassed) items.
348
 
  In general it is not needed to reimplement this virtual method and it is sufficient to reimplement
349
 
  KDGanttView::createUserDefinedItem() only.
350
 
  You can find details about subclassing and needed reimplementation of methods in the manual chapter
351
 
  "Subclassing of KDGanttView and KDGanttViewItem" and there is a detailed real world
352
 
  example program "timerTrackerApp" provided which demonstrates all reimplementations needed for
353
 
  a proper implementation of subclassing.
354
 
  We give here a short overview of the problems and solutions.
355
 
  Well, there is in general no problem if you subclass KDGanttView.
356
 
  But if you subclass a KDGanttViewItem
357
 
  (to be more precise: A KDGanttViewTaskItem,  KDGanttViewSummaryItem or KDGanttViewEventItem)
358
 
  and you enable Drag&Drop (DnD) or you want to save/load configuration data via
359
 
  KDGanttView::loadProject() or KDGanttView::saveProject() there is a problem:
360
 
  When DnD is performed or load/save is called there are items created automatically in KDGantt and added
361
 
  to KDGanttView. But if you drag a subclassed item you want to create an instance of that
362
 
  subclass on a drop event, of course.
363
 
  For that reason this method KDGanttView::createUserDefinedItem() is called every time a new item is created
364
 
  internally in KDGantt.
365
 
  Such that if you subclass a KDGanttViewItem you should subclass KDGanttView as well and reimplement
366
 
  KDGanttView::createUserDefinedItem() and
367
 
  KDGanttViewItem::typeString().
368
 
  It is a good idea to reimplement
369
 
  KDGanttViewItem::userWriteToElement() and
370
 
  KDGanttViewItem::userReadFromElement()
371
 
  as well to preserve item subclass specific properties during DnD or save/load.
372
 
  If you want some specific behaviour on dropping standard types you have to reimplement this method
373
 
  KDGanttView::createNewItem() as well.
374
 
 
375
 
  \param KDGanttViewItemTypeAsString the type of the new item as string.
376
 
         May be Task, Summary or Event for standard KDGanttViewItems. Should be another name for subclassed items.
377
 
         Usually the value is used what KDGanttViewItem::typeString() returns for that subclass.
378
 
         Calls createUserDefinedItem() if such a non standard type name is passed.
379
 
  \param parent item of the new item. May be 0. If 0 the new item becomes a root item in this KDGantt view.
380
 
  \param previous the item behind the new one should appear. May be 0.
381
 
  \param lvtext the text to show in the list view
382
 
  \param name the name by which the item can be identified. If no name
383
 
              is specified, a unique name will be generated
384
 
  \return the newly created item
385
 
  \sa createUserDefinedItem()
386
 
*/
387
 
KDGanttViewItem* KDGanttView::createNewItem( QString KDGanttViewItemTypeAsString,
388
 
                                             KDGanttViewItem* parent,
389
 
                                             KDGanttViewItem* after,
390
 
                                             const QString& lvtext,
391
 
                                             const QString& name )
392
 
{
393
 
    KDGanttViewItem* retItem = 0;
394
 
    KDGanttViewItem::Type type = KDGanttViewItem::stringToType( KDGanttViewItemTypeAsString );
395
 
   switch( type ) {
396
 
    case KDGanttViewItem::Event:
397
 
        if ( parent ) {
398
 
            if ( after )
399
 
                retItem = new KDGanttViewEventItem( parent, after, lvtext, name);
400
 
            else
401
 
                retItem = new KDGanttViewEventItem( parent, lvtext, name);
402
 
        } else {
403
 
            if ( after )
404
 
                retItem = new KDGanttViewEventItem( this, after, lvtext, name);
405
 
            else
406
 
                retItem = new KDGanttViewEventItem( this, lvtext, name);
407
 
        }
408
 
        break;
409
 
    case KDGanttViewItem::Summary:
410
 
        if ( parent ) {
411
 
            if ( after )
412
 
                retItem = new KDGanttViewSummaryItem( parent, after, lvtext, name);
413
 
            else
414
 
                retItem = new KDGanttViewSummaryItem( parent, lvtext, name);
415
 
        } else {
416
 
            if ( after )
417
 
                retItem = new KDGanttViewSummaryItem( this, after, lvtext, name);
418
 
            else
419
 
                retItem = new KDGanttViewSummaryItem( this, lvtext, name);
420
 
        }
421
 
        break;
422
 
    case KDGanttViewItem::Task:
423
 
        if ( parent ) {
424
 
            if ( after )
425
 
                retItem = new KDGanttViewTaskItem( parent, after, lvtext, name);
426
 
            else
427
 
                retItem = new KDGanttViewTaskItem( parent, lvtext, name);
428
 
        } else {
429
 
            if ( after )
430
 
                retItem = new KDGanttViewTaskItem( this, after, lvtext, name);
431
 
            else
432
 
                retItem = new KDGanttViewTaskItem( this, lvtext, name);
433
 
        }
434
 
        break;
435
 
    case KDGanttViewItem::UnknownType:
436
 
        retItem = createUserDefinedItem( KDGanttViewItemTypeAsString,parent,after,lvtext,name );
437
 
        break;
438
 
    default:
439
 
        qDebug() << "Unknown type in KDGanttView::createNewItem()";
440
 
    }
441
 
   return retItem;
442
 
}
443
 
/*!
444
 
  Sets the column col of the list view to the width w .
445
 
  \param col column number of list view. col number 0 is the first column.
446
 
  \param w the width of the column
447
 
 
448
 
*/
449
 
void KDGanttView::setListViewColumnWidth ( int col, int w )
450
 
{
451
 
    myListView->setColumnWidth ( col, w );
452
 
}
453
 
 
454
 
/*!
455
 
  Returns a pointer to the header of the list view.
456
 
  The header is not visible per default.
457
 
  To show/hide the header you have to call setHeaderVisible()
458
 
  in order to get the internal layout properly updated.
459
 
 
460
 
  \return a pointer to the header of the list view.
461
 
  \sa setHeaderVisible(), headerVisible()
462
 
*/
463
 
QHeader * KDGanttView::listViewHeader () const
464
 
{
465
 
    return myListView->header();
466
 
}
467
 
 
468
 
/*!
469
 
  Sets all list view items with subitems which may be expanded recursively to expanded state.
470
 
  It makes sure that the item which was currently visible
471
 
  at the top of the list view before the operation is visible after the operation.
472
 
  \sa setAllClose()
473
 
*/
474
 
void KDGanttView::setAllOpen()
475
 
{
476
 
 
477
 
    KDGanttViewItem* curItem = (KDGanttViewItem*) myListView->itemAt( QPoint (  myListView->width() - 10 , 5 ));
478
 
    bool block = myTimeTable->blockUpdating();
479
 
    myTimeTable->setBlockUpdating( true );
480
 
    KDGanttViewItem* temp = firstChild();
481
 
    while (temp != 0) {
482
 
      temp->setAllSubitemsExpanded( true );
483
 
      temp = temp->nextSibling();
484
 
    }
485
 
    myTimeTable->setBlockUpdating( block );
486
 
    myTimeTable->updateMyContent();
487
 
    if ( curItem && ! block ) {
488
 
        myListView->ensureItemVisible( curItem );
489
 
    }
490
 
 
491
 
}
492
 
/*!
493
 
  Sets all list view items with subitems recursively to closed state.
494
 
  It makes sure that the item which was currently visible
495
 
  at the top of the list view before the operation is visible after the operation.
496
 
  \sa setAllOpen()
497
 
*/
498
 
void KDGanttView::setAllClose()
499
 
{
500
 
    KDGanttViewItem* curItem = (KDGanttViewItem*) myListView->itemAt( QPoint (  myListView->width() - 10 , 5 ));
501
 
    bool block = myTimeTable->blockUpdating();
502
 
    myTimeTable->setBlockUpdating( true );
503
 
    KDGanttViewItem* temp = firstChild();
504
 
    while (temp != 0) {
505
 
        temp->setAllSubitemsExpanded( false );
506
 
        temp = temp->nextSibling();
507
 
    }
508
 
    myTimeTable->setBlockUpdating( block );
509
 
    myTimeTable->updateMyContent();
510
 
    if ( curItem && !block ) {
511
 
        myListView->ensureItemVisible( curItem );
512
 
    }
513
 
}
514
 
 
515
 
 
516
 
/*!
517
 
  Enables or disables updating of the content of the Gantt view.
518
 
  To avoid flickering in the Gantt view while inserting large amounts
519
 
  of Gantt items, you should call
520
 
 
521
 
  bool upd = KDGanttView::getUpdateEnabled();
522
 
  KDGanttView::settUpdateEnabled( false );
523
 
    ...  insert items here  ...
524
 
  KDGanttView::settUpdateEnabled( upd );
525
 
 
526
 
  With this code, you avoid unwanted side effects with other parts in
527
 
  your code, where you disable (and re-enable) the update.
528
 
 
529
 
  When calling setUpdateEnabled( true ),
530
 
  all the content is recomputed, resized, and updated.
531
 
 
532
 
  Before calling show() for the first time, updating is disabled.
533
 
  When calling show(), updating is automatically enabled.
534
 
 
535
 
  \param enable if true, the content of the Gantt view is updated after
536
 
  every insertion of a new item.
537
 
  \sa getUpdateEnabled()
538
 
*/
539
 
void KDGanttView::setUpdateEnabled( bool enable )
540
 
{
541
 
  myTimeTable->setBlockUpdating( !enable );
542
 
  if ( enable ) {
543
 
      QTimer::singleShot( 0, this, SLOT ( updateGanttContent() ) );
544
 
      //updateGanttContent();
545
 
  }
546
 
}
547
 
void KDGanttView::updateGanttContent()
548
 
{
549
 
    myTimeTable->updateMyContent();
550
 
    myCanvasView->setMyContentsHeight( 0 );
551
 
}
552
 
 
553
 
/*!
554
 
  Returns whether updating is enabled or not.
555
 
 
556
 
  \return true, if updating is enabled
557
 
  \sa setUpdateEnabled()
558
 
*/
559
 
 
560
 
bool KDGanttView::getUpdateEnabled() const
561
 
{
562
 
  return !myTimeTable->blockUpdating();
563
 
}
564
 
 
565
 
/*!
566
 
  Sets the maximum width of the Gantt view part widget in pixels.
567
 
  The largest allowed width is 32767.
568
 
  Note that this does not set the maximum width of the Gantt view content,
569
 
  it sets the maximum width of the Gantt view widget itself.
570
 
  \param w the maximum width
571
 
*/
572
 
 
573
 
void KDGanttView::setGanttMaximumWidth( int w )
574
 
{
575
 
  myTimeHeader->setMaximumWidth ( w );
576
 
}
577
 
/*!
578
 
  Returns the maximum width of the Gantt view part widget in pixels.
579
 
  The default maximum width is 32767 pixels.
580
 
 
581
 
  \return the maximum width of the Gantt view part widget in pixels.
582
 
*/
583
 
 
584
 
int  KDGanttView::ganttMaximumWidth() const
585
 
{
586
 
  return myTimeHeader->maximumWidth();
587
 
}
588
 
 
589
 
/*!
590
 
  Updates the content of the GanttView and shows it.
591
 
  Automatically sets setUpdateEnabled( true ).
592
 
  \sa setUpdateEnabled()
593
 
*/
594
 
 
595
 
void KDGanttView::showEvent( QShowEvent * event )
596
 
{
597
 
  if ( event->spontaneous() ) {
598
 
    KDGanttMinimizeSplitter::showEvent( event );
599
 
    return;
600
 
  }
601
 
 
602
 
  myTimeTable->setBlockUpdating( false );
603
 
  if (myCanvasView->horizontalScrollBar()->value() > 0 )
604
 
    myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->value()-1  );
605
 
  else
606
 
    myCanvasView->horizontalScrollBar()->setValue(1 );
607
 
  myTimeTable->updateMyContent();
608
 
 
609
 
  KDGanttMinimizeSplitter::showEvent( event );
610
 
 
611
 
  myCanvasView->setMyContentsHeight( 0 );
612
 
  if ( fCenterTimeLineAfterShow ) {
613
 
    fCenterTimeLineAfterShow = false;
614
 
    centerTimeline (dtCenterTimeLineAfterShow);
615
 
  }
616
 
}
617
 
/*!
618
 
  Closes the widget.
619
 
  The closing is rejected, if a repainting is currently being done.
620
 
  \param alsoDelete if true, the widget is deleted
621
 
  \return true, if the widget was closed
622
 
*/
623
 
 
624
 
void KDGanttView::closeEvent( QCloseEvent * event )
625
 
{
626
 
  //qDebug() << "close ";
627
 
  if ( closingBlocked ) {
628
 
    event->ignore();
629
 
    return;
630
 
  }
631
 
  KDGanttMinimizeSplitter::closeEvent( event );
632
 
}
633
 
 
634
 
 
635
 
/*!
636
 
  Returns a useful size for the view.
637
 
  Returned width:
638
 
  sizeHint().width() of the list view + width of TimeTable
639
 
  Returned height:
640
 
  height() of TimeHeader + height() of TimeTable + height() of Legend (if shown)
641
 
*/
642
 
 
643
 
QSize KDGanttView::sizeHint() const
644
 
{
645
 
  bool block = myTimeTable->blockUpdating();
646
 
  myTimeTable->setBlockUpdating( false );
647
 
  myTimeTable->updateMyContent();
648
 
  /* The below causes recursive calls to various size updating methods, which
649
 
   * cause QCanvas to hide and show items like mad, which is very slow. If
650
 
   * there is a legitimate gui updating issue here somewhere, it will need
651
 
   * to be solved differently.
652
 
   */
653
 
  //qApp->processEvents();
654
 
  int hintHeight = myTimeHeader->height();
655
 
  int legendHeight = 0;
656
 
  if ( showLegendButton() )
657
 
    legendHeight = myLegend->height();
658
 
  int listViewHeaderHeight = 0;
659
 
  if ( headerVisible() )
660
 
    listViewHeaderHeight = myListView->header()->height();
661
 
  if ( hintHeight < legendHeight+listViewHeaderHeight )
662
 
    hintHeight = legendHeight + listViewHeaderHeight;
663
 
  hintHeight += myListView->horizontalScrollBar()->height();
664
 
  if ( myLegend->isShown() )
665
 
    hintHeight += myLegend->legendSizeHint().height() +10;
666
 
  hintHeight += myTimeTable->minimumHeight()+myListView->frameWidth()*2+2;
667
 
  int hintWid = myListView->sizeHint().width();
668
 
  //hintWid += myTimeHeader->mySizeHint+myCanvasView->verticalScrollBar()->width();
669
 
  hintWid += myCanvasView->sizeHint().width();
670
 
  // add 10 for the splitter-bars
671
 
  // qDebug() << "sizehint " << hintWid+10 << " " << hintHeight;
672
 
  myTimeTable->setBlockUpdating( block );
673
 
  return QSize( hintWid+10, hintHeight );
674
 
}
675
 
 
676
 
 
677
 
/*!
678
 
  Specifies whether the legend button should be visible. By default,
679
 
  it is visible.
680
 
 
681
 
  \param show true to show the legend button, false to hide it
682
 
  \sa showLegendButton()
683
 
*/
684
 
void KDGanttView::setShowLegendButton( bool show )
685
 
{
686
 
  _showLegendButton = show;
687
 
     if ( show )
688
 
         myLegend->show();
689
 
    else
690
 
         myLegend->hide();
691
 
     slotHeaderSizeChanged();
692
 
}
693
 
 
694
 
 
695
 
/*!
696
 
  Returns whether the legend button is visible.
697
 
 
698
 
  \return whether the legend button is visible
699
 
  \sa setShowLegendButton()
700
 
*/
701
 
bool KDGanttView::showLegendButton() const
702
 
{
703
 
    return _showLegendButton;
704
 
}
705
 
 
706
 
 
707
 
/*!
708
 
  Specifies whether the listview header should be visible. By default,
709
 
  it is not visible.
710
 
 
711
 
  \param visible true to make the header visible, false to make it invisible
712
 
  \sa listViewHeader ()
713
 
*/
714
 
void KDGanttView::setHeaderVisible( bool visible )
715
 
{
716
 
    if( visible )
717
 
        myListView->header()->show();
718
 
    else
719
 
        myListView->header()->hide();
720
 
    _showHeader = visible;
721
 
    slotHeaderSizeChanged();
722
 
}
723
 
 
724
 
 
725
 
/*!
726
 
  Returns whether the listview header is visible.
727
 
 
728
 
  \return whether the header is visible
729
 
  \sa listViewHeader ()
730
 
*/
731
 
bool KDGanttView::headerVisible() const
732
 
{
733
 
  return _showHeader;
734
 
}
735
 
 
736
 
 
737
 
/*!
738
 
  Returns the corresponding date and time of the coordinate X in the
739
 
  Gantt view.
740
 
 
741
 
  \param coordX the coordinate to search for
742
 
  \param global true if coordX is a global position, false otherwise
743
 
  \return the date and time at coordinate X in the Gantt view.
744
 
*/
745
 
QDateTime KDGanttView::getDateTimeForCoordX(int coordX, bool global ) const
746
 
{
747
 
  // default for myTimeHeader->getDateTimeForIndex() is local
748
 
   return myTimeHeader->getDateTimeForIndex(coordX, !global );
749
 
}
750
 
 
751
 
 
752
 
/*!
753
 
  Implements a casted pass-through of the selectionChanged() signal.
754
 
*/
755
 
void KDGanttView::slotSelectionChanged( QListViewItem* item )
756
 
{
757
 
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
758
 
    Q_ASSERT( gItem );
759
 
    emit lvSelectionChanged( gItem );
760
 
}
761
 
 
762
 
 
763
 
/*
764
 
  Implements a casted pass-through of the mouseButtonClicked() signal.
765
 
  Signals itemLeftClicked() , itemMidClicked() are emitted as well.
766
 
*/
767
 
void KDGanttView::slotmouseButtonClicked ( int button, QListViewItem * item,
768
 
                                           const QPoint & pos, int c )
769
 
{
770
 
  KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
771
 
  emit lvMouseButtonClicked ( button , gItem,  pos,  c );
772
 
  if (gItem == 0 && myCurrentItem != 0 ) {
773
 
    myCurrentItem = 0;
774
 
    emit lvCurrentChanged( gItem );
775
 
  }
776
 
  if (gItem != 0 && myCurrentItem == 0 ) {
777
 
    myCurrentItem = gItem;
778
 
    emit lvCurrentChanged( gItem );
779
 
  }
780
 
 
781
 
  // removed - makes no sense!
782
 
  //emit mouseButtonClicked ( button , gItem,  pos,  c );
783
 
   {
784
 
    switch ( button ) {
785
 
    case  Qt::LeftButton:
786
 
      emit lvItemLeftClicked( gItem );
787
 
      emit itemLeftClicked( gItem );
788
 
      break;
789
 
    case  Qt::MidButton:
790
 
      emit lvItemMidClicked( gItem );
791
 
      emit itemMidClicked( gItem );
792
 
      break;
793
 
    }
794
 
  }
795
 
}
796
 
 
797
 
 
798
 
/*
799
 
  Implements a casted pass-through of the contextMenuRequested() signal.
800
 
  The signal itemRightClicked() is emitted as well;
801
 
  the position is the global position.
802
 
*/
803
 
void KDGanttView::slotcontextMenuRequested ( QListViewItem * item, const QPoint & pos, int col )
804
 
{
805
 
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
806
 
    emit lvContextMenuRequested ( gItem,  pos,  col );
807
 
    emit lvItemRightClicked( gItem );
808
 
    emit itemRightClicked( gItem );
809
 
}
810
 
 
811
 
/*
812
 
  Implements a casted pass-through of the collapsed() signal.
813
 
*/
814
 
void KDGanttView::slotItemCollapsed ( QListViewItem * item )
815
 
{
816
 
   {
817
 
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
818
 
    emit itemCollapsed ( gItem );
819
 
  }
820
 
}
821
 
 
822
 
 
823
 
/*
824
 
  Implements a casted pass-through of the  expanded() signal.
825
 
*/
826
 
void KDGanttView::slotItemExpanded ( QListViewItem * item )
827
 
{
828
 
   {
829
 
       KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
830
 
       emit itemExpanded( gItem );
831
 
   }
832
 
}
833
 
 
834
 
 
835
 
 
836
 
 
837
 
void KDGanttView::emptySpaceDoubleClicked( QMouseEvent * e )
838
 
{
839
 
    emit dateTimeDoubleClicked( getDateTimeForCoordX( e->x(), false ) );
840
 
}
841
 
 
842
 
 
843
 
/*
844
 
  Implements a casted pass-through of the currentChanged() signal.
845
 
*/
846
 
void KDGanttView::slotCurrentChanged ( QListViewItem * item )
847
 
{
848
 
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
849
 
    myCurrentItem = gItem;
850
 
    emit lvCurrentChanged( gItem );
851
 
}
852
 
 
853
 
 
854
 
/*
855
 
  Implements a casted pass-through of the itemRenamed() signal.
856
 
*/
857
 
void KDGanttView::slotItemRenamed ( QListViewItem * item , int col,
858
 
                                    const QString & text )
859
 
{
860
 
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
861
 
    emit lvItemRenamed( gItem,  col, text );
862
 
}
863
 
 
864
 
 
865
 
/*
866
 
  Implements a casted pass-through of the mouseButtonPressed() signal.
867
 
*/
868
 
void KDGanttView::slotMouseButtonPressed ( int button, QListViewItem * item,
869
 
                                           const QPoint & pos, int c )
870
 
{
871
 
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
872
 
    emit lvMouseButtonPressed( button, gItem,  pos,  c  );
873
 
}
874
 
 
875
 
 
876
 
/*!
877
 
  Specifies whether the content should be repainted after scrolling or
878
 
  not.
879
 
 
880
 
  \param mode If No, there is no repainting after scrolling. This is
881
 
                 the fastest mode.
882
 
              If Medium, there is extra repainting after releasing the
883
 
                 scrollbar. This provides fast scrolling with updated content
884
 
                 after scrolling. Recommended, when repaint problems occur.
885
 
                 This is the default value after startup.
886
 
              If Always, there is an extra update after every move of the
887
 
                 scrollbar. This entails slow scrolling with updated
888
 
                 content at all time.
889
 
*/
890
 
void KDGanttView::setRepaintMode( RepaintMode mode )
891
 
{
892
 
 
893
 
  QScrollBar  *cvh, *cvv;
894
 
  cvh = myCanvasView->horizontalScrollBar();
895
 
  cvv = myCanvasView->verticalScrollBar();
896
 
  // first disconnect
897
 
  mRepaintMode = mode;
898
 
  cvh->disconnect( this );
899
 
  cvv->disconnect( this );
900
 
 
901
 
#if QT_VERSION < 0x040000
902
 
  connect( myCanvasView->horizontalScrollBar(), SIGNAL( prevLine () ) ,this, SLOT( addTickLeft()));
903
 
  connect( myCanvasView->horizontalScrollBar(), SIGNAL( nextLine () ) ,this, SLOT( addTickRight()));
904
 
#endif
905
 
  switch ( mode ) {
906
 
  case  No:
907
 
 
908
 
    break;
909
 
  case Medium:
910
 
    connect( cvv, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
911
 
    connect( cvh, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
912
 
#if QT_VERSION < 0x040000
913
 
    connect( cvv, SIGNAL (nextLine () ) ,this, SLOT(forceRepaint()));
914
 
    connect( cvh, SIGNAL (nextLine () ) ,this, SLOT(forceRepaint()));
915
 
    connect( cvv, SIGNAL (prevLine () ) ,this, SLOT(forceRepaint()));
916
 
    connect( cvh, SIGNAL (prevLine () ) ,this, SLOT(forceRepaint()));
917
 
#endif
918
 
    break;
919
 
  case Always:
920
 
#if QT_VERSION < 0x040000
921
 
    connect( cvv, SIGNAL (valueChanged ( int ) ) ,this, SLOT(forceRepaint( int )));
922
 
    connect( cvh, SIGNAL (valueChanged ( int ) ) ,this, SLOT(forceRepaint( int )));
923
 
#endif
924
 
    connect( cvv, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
925
 
    connect( cvh, SIGNAL (sliderReleased () ) ,this, SLOT(forceRepaint()));
926
 
    break;
927
 
  }
928
 
}
929
 
 
930
 
 
931
 
void KDGanttView::forceRepaint( int )
932
 
{
933
 
  if ( myTimeTable->blockUpdating() )
934
 
    return;
935
 
  // qDebug() << "forceRepaint( int ) ";
936
 
  myTimeTable->setAllChanged();
937
 
  myTimeTable->update();
938
 
}
939
 
 
940
 
 
941
 
void KDGanttView::slotHeaderSizeChanged()
942
 
{
943
 
  int legendHeight = 0;
944
 
  if ( showLegendButton() )
945
 
    legendHeight = 24;
946
 
  int listViewHeaderHeight = 0;
947
 
  if ( headerVisible() )
948
 
    listViewHeaderHeight = myListView->header()->height();
949
 
  int timeHeaderHeight = myTimeHeader->height()+myTimeHeaderScroll->frameWidth()*2;;
950
 
  int diffY = timeHeaderHeight-legendHeight-listViewHeaderHeight;
951
 
  if ( diffY < 0 ) {
952
 
    spacerLeft->setFixedHeight( 0 );
953
 
    spacerRight->setFixedHeight(-diffY);
954
 
  } else {
955
 
    spacerRight->setFixedHeight( 0 );
956
 
    spacerLeft->setFixedHeight( diffY );
957
 
  }
958
 
  myLegend->setFixedHeight( legendHeight );
959
 
  myTimeHeaderContainer->setFixedHeight( timeHeaderHeight );
960
 
}
961
 
 
962
 
 
963
 
/*!
964
 
  Specifies whether the legend should be shown as a dock window or not.
965
 
 
966
 
  \param show if true, show legend as a dock window
967
 
  \sa showLegend(), legendIsDockwindow(), legendDockwindow()
968
 
*/void KDGanttView::setLegendIsDockwindow( bool show )
969
 
{
970
 
  bool isdock = myLegend->asDockwindow();
971
 
  if ( show != isdock ) {
972
 
    myLegend->setAsDockwindow(show);
973
 
    // legend is cleared - reinit legend with list
974
 
    legendItem* li;
975
 
    for ( li = myLegendItems.first(); li; li = myLegendItems.next() ) {
976
 
        if ( li->has2 )
977
 
            myLegend->addLegendItem(li->shape, li->color, li->text,li->shape2, li->color2, li->text2 );
978
 
        else
979
 
            myLegend->addLegendItem(li->shape, li->color, li->text );
980
 
    }
981
 
  }
982
 
}
983
 
 
984
 
 
985
 
/*!
986
 
  Returns whether the legend is shown as a dock window
987
 
 
988
 
  \return true if the legend is shown as a dock window
989
 
  \sa setShowLegend(), setLegendIsDockwindow(), legendDockwindow()
990
 
*/bool KDGanttView::legendIsDockwindow() const
991
 
{
992
 
    return myLegend->asDockwindow();
993
 
}
994
 
 
995
 
 
996
 
/*!
997
 
  Returns the pointer to the legend dock window.
998
 
  DO NOT DELETE THIS POINTER!
999
 
  If the legend is not a dock window, 0 is returned
1000
 
  To set the legend as a dock window, call
1001
 
  KDGanttView::setLegendIsDockwindow( true );
1002
 
 
1003
 
  \return the pointer to the legend dock window
1004
 
          0 is returned, if the legend is no dock window
1005
 
          DO NOT DELETE THIS POINTER!
1006
 
  \sa setShowLegend(), setLegendIsDockwindow(),legendIsDockwindow()
1007
 
*/
1008
 
QDockWindow* KDGanttView::legendDockwindow() const
1009
 
{
1010
 
  return myLegend->dockwindow();
1011
 
}
1012
 
 
1013
 
 
1014
 
/*!
1015
 
  Specifies whether the legend should be shown or not. Besides setting
1016
 
  this programmatically, the user can also show/hide the legend by
1017
 
  using the button provided for this purpose.
1018
 
 
1019
 
  \param show force legend to be shown
1020
 
  \sa showLegend()
1021
 
*/
1022
 
void KDGanttView::setShowLegend( bool show )
1023
 
{
1024
 
    myLegend->showMe(show);
1025
 
}
1026
 
 
1027
 
 
1028
 
/*!
1029
 
  Returns whether the legend is currently shown. The visibility of the
1030
 
  legend can be changed both by \a setShowLegend(), and interactively
1031
 
  by the user.
1032
 
 
1033
 
  \return true if the legend is currently visible
1034
 
  \sa setShowLegend()
1035
 
*/
1036
 
bool KDGanttView::showLegend() const
1037
 
{
1038
 
    return myLegend->isShown();
1039
 
}
1040
 
 
1041
 
 
1042
 
/*!
1043
 
  Specifies whether the listview of the Gantt view should be shown or
1044
 
  not.
1045
 
 
1046
 
  \param show pass true in order to show the listview and false in
1047
 
  order to hide it.
1048
 
  \sa showListView()
1049
 
*/
1050
 
void KDGanttView::setShowListView( bool show )
1051
 
{
1052
 
    if(listViewIsVisible == show) return;
1053
 
    listViewIsVisible = show;
1054
 
    if (listViewIsVisible)
1055
 
        myListView->parentWidget()->show();
1056
 
    else
1057
 
        myListView->parentWidget()->hide();
1058
 
}
1059
 
 
1060
 
 
1061
 
/*!
1062
 
  Returns whether the listview of the Gantt view is shown or not.
1063
 
 
1064
 
  \return true if the listview is shown
1065
 
  \sa setShowListView()
1066
 
*/
1067
 
bool KDGanttView::showListView() const
1068
 
{
1069
 
    return listViewIsVisible;
1070
 
}
1071
 
 
1072
 
 
1073
 
/*!
1074
 
  Specifies whether it should be possible to edit the appearance of a
1075
 
  Gantt item visually in a dialog by double-clicking the item.
1076
 
 
1077
 
  \param enable pass true in order to enable the visual editor and
1078
 
  false in order to turn it off
1079
 
  \sa editorEnabled()
1080
 
*/
1081
 
 
1082
 
void KDGanttView::setEditorEnabled( bool enable )
1083
 
{
1084
 
  editorIsEnabled =  enable;
1085
 
}
1086
 
 
1087
 
 
1088
 
/*!
1089
 
  Returns whether it is possible to edit the appearance of a Gantt
1090
 
  item visually in a dialog by double-clicking the item.
1091
 
 
1092
 
  \return true if visual editing is enabled, false otherwise
1093
 
  \sa setEditorEnabled()
1094
 
*/
1095
 
 
1096
 
bool KDGanttView::editorEnabled() const
1097
 
{
1098
 
    return editorIsEnabled;
1099
 
}
1100
 
 
1101
 
 
1102
 
/*!
1103
 
  Specifies whether the Gantt chart is user-editable.
1104
 
 
1105
 
  \param editable pass true in order to get a user-editable Gantt
1106
 
  chart, pass false in order to get a read-only chart
1107
 
  \sa editable()
1108
 
*/
1109
 
 
1110
 
void KDGanttView::setEditable( bool editable )
1111
 
{
1112
 
  chartIsEditable =  editable;
1113
 
}
1114
 
 
1115
 
 
1116
 
/*!
1117
 
  Returns whether the Gantt chart is user-editable
1118
 
 
1119
 
  \return true if the Gantt chart is user-editable
1120
 
  \sa setEditable()
1121
 
*/
1122
 
 
1123
 
bool KDGanttView::editable() const
1124
 
{
1125
 
    return chartIsEditable;
1126
 
}
1127
 
 
1128
 
 
1129
 
/*!
1130
 
  Saves the state of the Gantt view in an IO device in XML format. The saved
1131
 
  data can be reloaded with \a loadProject().
1132
 
 
1133
 
  \param device a pointer to the IO device in which to store the Gantt
1134
 
  view state.
1135
 
  \return true if the data could be written, false if an error
1136
 
  occurred
1137
 
  \sa loadProject()
1138
 
*/
1139
 
 
1140
 
bool KDGanttView::saveProject( QIODevice* device )
1141
 
{
1142
 
    Q_ASSERT( device );
1143
 
 
1144
 
    QDomDocument doc = saveXML();
1145
 
    if( device->isOpen() )
1146
 
        device->close();
1147
 
    if( device->open( IO_WriteOnly ) ) {
1148
 
        QTextStream ts( device );
1149
 
        ts << doc.toString();
1150
 
        return true;
1151
 
    } else
1152
 
        return false;
1153
 
}
1154
 
 
1155
 
 
1156
 
/*!
1157
 
  Loads a previously saved state of the Gantt view. All current
1158
 
  settings and items are discarded before loading the data.
1159
 
 
1160
 
  \param device a pointer to the IO device from which to load the
1161
 
  Gantt view state.
1162
 
  \return true if the file could be read, false if an error
1163
 
  occurred
1164
 
  \sa saveProject()
1165
 
*/
1166
 
 
1167
 
bool KDGanttView::loadProject( QIODevice* device )
1168
 
{
1169
 
    Q_ASSERT( device );
1170
 
 
1171
 
    if( device->isOpen() )
1172
 
        device->close();
1173
 
    if( device->open( IO_ReadOnly ) ) {
1174
 
        QDomDocument doc( "GanttView" );
1175
 
        QString err;
1176
 
        int errline, errcol;
1177
 
        if ( !doc.setContent( device, &err, &errline, &errcol ) ) {
1178
 
          qDebug() << "KDGantt::Error parsing XML data at line " << errline << ". Message is: ";
1179
 
          qDebug() << err;
1180
 
          device->close();
1181
 
          return false;
1182
 
        }
1183
 
        device->close();
1184
 
        clearAll();
1185
 
        return loadXML( doc );
1186
 
    } else
1187
 
        return false;
1188
 
}
1189
 
 
1190
 
// slot, can be connected to menu action
1191
 
// Note: This should possibly have a setup dialog so the user can print
1192
 
//       something other than the default
1193
 
void KDGanttView::print()
1194
 
{
1195
 
    print(0);
1196
 
}
1197
 
 
1198
 
/*!
1199
 
  Sends a Gantt view to a printer. The printer should already be set
1200
 
  up for printing (by calling QPrintDialog).
1201
 
  If the printer is not set up, QPrintDialog is called before printing
1202
 
 
1203
 
  You can specify, whether the ListView, TimeLine, or Legend will be
1204
 
  printed. All combinations of these three widgets are allowed.
1205
 
 
1206
 
  \param printer a pointer to the printer to print on. If printer is
1207
 
  0, the method creates a temporary printer and discards it when it is
1208
 
  done printing.
1209
 
  \param printListView if true, the list view is printed
1210
 
  \param printTimeLine if true, the time line is printed
1211
 
  \param printLegend if true, the legend is printed
1212
 
 
1213
 
  \sa drawContents()
1214
 
*/
1215
 
 
1216
 
void KDGanttView::print( QPrinter* printer ,
1217
 
                         bool printListView, bool printTimeLine,
1218
 
                         bool printLegend )
1219
 
{
1220
 
  bool deletePrinter = false;
1221
 
  if (! printer ) {
1222
 
    printer = new QPrinter();
1223
 
    deletePrinter = true;
1224
 
    QPrintDialog dialog(printer);
1225
 
    if ( !dialog.exec() ) {
1226
 
      delete printer;
1227
 
      return;
1228
 
    }
1229
 
  }
1230
 
  // now we have a printer to print on
1231
 
  QPainter p( printer );
1232
 
  // get the paper metrics
1233
 
  float dx, dy;
1234
 
  // get the size of the desired output for scaling.
1235
 
  // here we want to print all: ListView, TimeLine, and Legend
1236
 
  // for this purpose, we call drawContents() with a 0 pointer as painter
1237
 
  QSize size = drawContents( 0, printListView, printTimeLine, printLegend );
1238
 
 
1239
 
  // at the top, we want to print current time/date
1240
 
  QString date = "Printing Time: " + QDateTime::currentDateTime().toString();
1241
 
  int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
1242
 
  p.drawText( 0, 0, date );
1243
 
 
1244
 
  // compute the scale
1245
 
#if QT_VERSION >= 0x040000
1246
 
  dx = (float) printer->width()  / (float)size.width();
1247
 
  dy  = (float)(printer->height() - ( 2 * hei )) / (float)size.height();
1248
 
#else
1249
 
  QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
1250
 
  dx = (float) m.width()  / (float)size.width();
1251
 
  dy  = (float)(m.height() - ( 2 * hei )) / (float)size.height();
1252
 
#endif
1253
 
  float scale;
1254
 
  // scale to fit the width or height of the paper
1255
 
  if ( dx < dy )
1256
 
    scale = dx;
1257
 
  else
1258
 
    scale = dy;
1259
 
  // set the scale
1260
 
  p.scale( scale, scale );
1261
 
  // now printing with y offset:  2 hei
1262
 
  p.translate( 0, 2*hei );
1263
 
  drawContents( &p, printListView, printTimeLine, printLegend );
1264
 
  // the drawContents() has the side effect, that the painter translation is
1265
 
  // after drawContents() set to the bottom of the painted stuff
1266
 
  // for instance a
1267
 
  // p.drawText(0, 0, "printend");
1268
 
  // would be painted directly below the paintout of drawContents()
1269
 
  p.end();
1270
 
  if ( deletePrinter )
1271
 
    delete printer;
1272
 
}
1273
 
 
1274
 
 
1275
 
/*!
1276
 
  Paints a Gantt view on a QPainter.
1277
 
  You can specify, whether the list view, the time line, or the legend
1278
 
  is painted.
1279
 
  All combinations of these three widgets are allowed.
1280
 
  Returns the size of the painted area.
1281
 
  Paints the list view in the top-left corner, the time line to the
1282
 
  right of the list view, and the legend below the list view.
1283
 
  If called with \a p = 0, nothing is painted and only
1284
 
  the size of the painted area is computed.
1285
 
  This is useful for determining only the painted area and setting
1286
 
  the scale of the painter, before calling this method with a painter.
1287
 
  In order to get the output fitted to your paper and your printer,
1288
 
  call first
1289
 
  QSize size = drawContents( 0, printListView, printTimeLine, printLegend );
1290
 
  //then compute the scale
1291
 
  dx = paper.width()  / size.width();
1292
 
  dy  = paper.height() / size.height();
1293
 
  //then make float scale to fit the width or height of the paper
1294
 
  if ( dx < dy )
1295
 
    scale = dx;
1296
 
  else
1297
 
    scale = dy;
1298
 
  // then set the scale
1299
 
  p.scale( scale, scale );
1300
 
  // and now call drawContents with painter p
1301
 
  drawContents( &p, printListView, printTimeLine, printLegend );
1302
 
 
1303
 
  For a detailed example, please see the commented source code in
1304
 
  KDGanttView::print(...)
1305
 
 
1306
 
  \param p  a pointer to the painter to paint on. If p is
1307
 
  0, nothing is painted and only the size of the painted area is computed
1308
 
  \param drawListView if true, the list view is painted
1309
 
  \param drawTimeLine if true, the time line is painted
1310
 
  \param drawLegend if true, the legend is painted
1311
 
  \return the size of the painted area
1312
 
  \sa print()
1313
 
*/
1314
 
QSize KDGanttView::drawContents( QPainter* p,
1315
 
                      bool drawListView , bool drawTimeLine, bool drawLegend )
1316
 
{
1317
 
    QSize size;
1318
 
    int lvX, lvY, thX, thY, tlX, tlY, lwX, lwY, allX, allY;
1319
 
    lvX = myListView->contentsWidth();
1320
 
    lvY = myTimeTable->minimumHeight() + 2;
1321
 
    thX = myTimeHeader->width();
1322
 
    thY = myTimeHeader->height();
1323
 
    tlX = myCanvasView->canvas()->width();
1324
 
    tlY = lvY;
1325
 
    lwX = myLegend->legendSize().width();
1326
 
    lwY = myLegend->legendSize().height();
1327
 
    allX = 0;
1328
 
    allY = 0;
1329
 
    if ( drawListView ) {
1330
 
        allX += lvX;
1331
 
        allY += tlY;
1332
 
    }
1333
 
    if ( drawTimeLine ) {
1334
 
        allX += thX;
1335
 
        allY += thY;
1336
 
    }
1337
 
    if ( drawLegend ) {
1338
 
        allY += lwY;
1339
 
        if ( allX < lwX )
1340
 
            allX = lwX ;
1341
 
    }
1342
 
    size = QSize( allX, allY );
1343
 
    int temp = 0;
1344
 
    if ( p ) {
1345
 
        if ( drawListView ) {
1346
 
            if ( drawTimeLine )
1347
 
                temp =  thY;
1348
 
            p->translate( 0, temp );
1349
 
            if ( headerVisible() ) {
1350
 
                p->translate( 0,  -myListView->header()->height());
1351
 
                int cou = myListView->header()->count();
1352
 
                int iii;
1353
 
                QRect rect ( 0,0,0, myListView->header()->height());
1354
 
                for ( iii = 0; iii < cou; ++iii ) {
1355
 
                    rect.setLeft ( myListView->header()->sectionPos( iii ) );
1356
 
                    rect.setRight ( myListView->header()->sectionPos( iii ) + myListView->header()->sectionSize (iii));
1357
 
                    myListView->header()->paintSection ( p,  myListView->header()->mapToIndex (iii),  rect );
1358
 
                }
1359
 
                p->translate( 0,  myListView->header()->height());
1360
 
            }
1361
 
            myListView->drawToPainter( p );
1362
 
            p->translate( lvX, -temp);
1363
 
        }
1364
 
        if ( drawTimeLine ) {
1365
 
            p->translate( myCanvasView->frameWidth(), 0);
1366
 
            myTimeHeader->repaintMe( 0, myTimeHeader->width(), p );
1367
 
            p->translate( -myCanvasView->frameWidth(), thY);
1368
 
            myCanvasView->drawToPainter( p );
1369
 
            if ( drawListView )
1370
 
                p->translate( -lvX, tlY);
1371
 
            else
1372
 
                p->translate( 0, tlY);
1373
 
        } else {
1374
 
            if ( drawListView )
1375
 
                p->translate( -lvX, 0 );
1376
 
        }
1377
 
        if ( drawLegend ) {
1378
 
            myLegend->drawToPainter( p );
1379
 
            p->translate( 0, lwY );
1380
 
        }
1381
 
    }
1382
 
    return size;
1383
 
}
1384
 
 
1385
 
/*!
1386
 
  Zooms into the Gantt chart. Values less than 1 mean zooming in,
1387
 
  values greater than 1 mean zooming out. A zooming factor of exactly
1388
 
  1.0 means original size.
1389
 
 
1390
 
  \param factor the zoom factor
1391
 
  \param absolute if true, factor is interpreted absolutely, if false,
1392
 
  factor is interpreted relatively to the current zoom factor
1393
 
  \sa zoomToFit()
1394
 
  \sa zoomToSelection()
1395
 
  \sa zoomFactor()
1396
 
*/
1397
 
 
1398
 
void KDGanttView::setZoomFactor( double factor, bool absolute )
1399
 
{
1400
 
    myTimeHeader->zoom(factor,absolute);
1401
 
}
1402
 
 
1403
 
 
1404
 
/*!
1405
 
  Returns the current zoom factor.
1406
 
 
1407
 
  \return the current zoom factor
1408
 
  \sa zoomToFit(), zoomToSelection(), setZoomFactor()
1409
 
*/
1410
 
 
1411
 
double KDGanttView::zoomFactor() const
1412
 
{
1413
 
    return myTimeHeader->zoomFactor();
1414
 
}
1415
 
 
1416
 
 
1417
 
/*!
1418
 
  Zooms such that the Gantt chart is less than the available space of the widget.
1419
 
 
1420
 
  \sa setZoomFactor()
1421
 
  \sa zoomFactor()
1422
 
  \sa zoomToSelection()
1423
 
*/
1424
 
 
1425
 
void KDGanttView::zoomToFit()
1426
 
{
1427
 
  myTimeHeader->zoomToFit();
1428
 
}
1429
 
 
1430
 
 
1431
 
/*!
1432
 
  Zooms so that at least the selected time period is visible after the zoom.
1433
 
 
1434
 
  \param start the start datetime of the selected period
1435
 
  \param end the end datetime of the selected period
1436
 
 
1437
 
  \sa zoomToSelectionAndSetStartEnd()
1438
 
  \sa setZoomFactor()
1439
 
  \sa zoomFactor()
1440
 
  \sa zoomToFit()
1441
 
*/
1442
 
 
1443
 
void KDGanttView::zoomToSelection( const QDateTime& start,  const QDateTime&  end )
1444
 
{
1445
 
 
1446
 
  myTimeHeader->zoomToSelection( start, end);
1447
 
 
1448
 
}
1449
 
/*!
1450
 
  Sets the horizon start and end to the  selected time period.
1451
 
  Zooms so that at least the selected time period is visible after the zoom.
1452
 
 
1453
 
  \param start the start datetime of the selected period
1454
 
  \param end the end datetime of the selected period
1455
 
 
1456
 
  \sa zoomToSelection()
1457
 
  \sa setZoomFactor()
1458
 
  \sa zoomFactor()
1459
 
  \sa zoomToFit()
1460
 
*/
1461
 
 
1462
 
void KDGanttView::zoomToSelectionAndSetStartEnd( const QDateTime& start,  const QDateTime&  end )
1463
 
{
1464
 
    /*
1465
 
    myTimeHeader->setHorizonStart(start);
1466
 
    myTimeHeader->setHorizonEnd(start);
1467
 
    myTimeHeader->zoomToSelection( start, end);
1468
 
    */
1469
 
    myTimeHeader->zoomToSelectionAndSetStartEnd( start, end);
1470
 
}
1471
 
 
1472
 
 
1473
 
/*!
1474
 
  Makes sure that the specified Gantt item is visible without
1475
 
  scrolling.
1476
 
 
1477
 
  \sa center(), centerTimelineAfterShow()
1478
 
*/
1479
 
void KDGanttView::ensureVisible( KDGanttViewItem* item )
1480
 
{
1481
 
    if ( item == 0 ) return;
1482
 
    myListView->ensureItemVisible (item);
1483
 
}
1484
 
 
1485
 
 
1486
 
/*!
1487
 
  Makes sure that the specified QDateTime is in the center of the
1488
 
  visible Gantt chart (if possible).
1489
 
  If you want to center the timeline when the KDGanttView is hidden,
1490
 
  calling centerTimelineAfterShow() is the better alternative.
1491
 
  There are three possibilities what does happen with the timeline
1492
 
  if you call this method:
1493
 
  If the specified QDateTime is within the datetime range of
1494
 
  horizonStart() and horizonEnd() then the specified QDateTime is made visible
1495
 
  on the timeline and the specified QDateTime is centered, if possible.
1496
 
  (It is not possible to center it if the specified QDateTime is too near to the
1497
 
  horizonStart() or horizonEnd(), of course.)
1498
 
  If userHorizonChangeEnabled() is enabled and the specified QDateTime
1499
 
  is not within the datetime range of  horizonStart() and horizonEnd()
1500
 
  then horizonStart() and horizonEnd() are moved such that
1501
 
  the specified QDateTime is in the center of the new horizonStart() and horizonEnd()
1502
 
  and the timeline is displayed centered on the specified QDateTime.
1503
 
 
1504
 
  \sa center(), centerTimelineAfterShow() userHorizonChangeEnabled()
1505
 
*/
1506
 
void KDGanttView::centerTimeline( const QDateTime& center )
1507
 
{
1508
 
    myTimeHeader->centerDateTime( center, mUserHorizonChangeEnabled );
1509
 
}
1510
 
 
1511
 
 
1512
 
/*!
1513
 
  Makes sure that the specified QDateTime is in the center of the
1514
 
  visible Gantt chart (if possible).  If the KDGanttView is currently
1515
 
  hidden, this method resets the center once again after the next
1516
 
  show() call. Use this method if you want to center the timeline when
1517
 
  the KDGanttView is hidden. After calling KDGanttView::show(), there
1518
 
  may be computations of the sizes of the widgets and subwidgets and
1519
 
  of the automatically computed start datetime. This method ensures
1520
 
  that the center of the timeline is to be properly reset after
1521
 
  show().
1522
 
 
1523
 
  \sa center(), centerTimeline()
1524
 
*/
1525
 
void KDGanttView::centerTimelineAfterShow( const QDateTime& center )
1526
 
{
1527
 
  myTimeHeader->centerDateTime( center );
1528
 
  if ( isVisible() ) return;
1529
 
  dtCenterTimeLineAfterShow = center;
1530
 
  fCenterTimeLineAfterShow = true;
1531
 
}
1532
 
 
1533
 
/*!
1534
 
  Sets the timeline to the horizon start.
1535
 
*/
1536
 
 
1537
 
void KDGanttView::setTimelineToStart()
1538
 
{
1539
 
  myCanvasView->horizontalScrollBar()->setValue( 0 );
1540
 
}
1541
 
 
1542
 
 
1543
 
/*!
1544
 
  Sets the timeline to the horizon end.
1545
 
*/
1546
 
void KDGanttView::setTimelineToEnd()
1547
 
{
1548
 
 myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->maximum());
1549
 
}
1550
 
 
1551
 
 
1552
 
/*!
1553
 
  Add \a num minor ticks of the current scale of the timeline
1554
 
  to the start of the timeline.
1555
 
  The timeline is not set automatically at the start.
1556
 
  Call \a setTimelineToStart() to ensure that the timeline is at the start
1557
 
  after calling this method.
1558
 
 
1559
 
  \param num the number of minor ticks which should be added
1560
 
  \sa addTicksRight(),setTimelineToStart(), setTimelineToEnd()
1561
 
*/
1562
 
void KDGanttView::addTicksLeft( int num )
1563
 
{
1564
 
  myTimeHeader->addTickLeft( num  );
1565
 
}
1566
 
 
1567
 
 
1568
 
/*!
1569
 
  Add \a num minor ticks of the current scale of the timeline
1570
 
  to the end of the timeline.
1571
 
  The timeline is not set automatically at the end.
1572
 
  Call \a setTimelineToEnd() to ensure that the timeline is at the end
1573
 
  after calling this method.
1574
 
  \param num the number of minor ticks which should be added
1575
 
  \sa addTicksLeft(),setTimelineToStart(), setTimelineToEnd()
1576
 
*/
1577
 
void KDGanttView::addTicksRight( int num )
1578
 
{
1579
 
  myTimeHeader->addTickRight( num );
1580
 
}
1581
 
 
1582
 
 
1583
 
/*!
1584
 
  Makes sure that the specified Gantt item is in the center of the
1585
 
  visible Gantt chart (if possible).
1586
 
*/
1587
 
void KDGanttView::center( KDGanttViewItem* item )
1588
 
{
1589
 
    ensureVisible(item);
1590
 
    int x =  myListView->contentsWidth()/2;
1591
 
    int y = myListView->itemPos (item );
1592
 
    myListView->center(x,y);
1593
 
}
1594
 
 
1595
 
 
1596
 
/*!
1597
 
  Specifies whether task links should be shown.
1598
 
 
1599
 
  \param show true for showing task links, false for not showing them
1600
 
  \sa showTaskLinks(), KDGanttViewTaskLink
1601
 
*/
1602
 
void KDGanttView::setShowTaskLinks( bool show )
1603
 
{
1604
 
    myTimeTable->setShowTaskLinks(show);
1605
 
 
1606
 
}
1607
 
 
1608
 
 
1609
 
/*!
1610
 
  Returns whether task links should be shown.
1611
 
 
1612
 
  \return true if task links are shown, false otherwise
1613
 
  \sa setShowTaskLinks(), KDGanttViewTaskLink
1614
 
*/
1615
 
bool KDGanttView::showTaskLinks() const
1616
 
{
1617
 
    return  myTimeTable->showTaskLinks();
1618
 
}
1619
 
 
1620
 
 
1621
 
/*!
1622
 
  Sets the font in the left list view widget and
1623
 
  in the right time header widget.
1624
 
  The settings of the fonts in the time table widget are not effected.
1625
 
 
1626
 
  \param font the new font of the widget
1627
 
*/
1628
 
void KDGanttView::setFont(const QFont& font)
1629
 
{
1630
 
    myListView->setFont(font);
1631
 
    myListView->repaint();
1632
 
    myTimeHeader->setFont(font);
1633
 
    myLegend->setFont( font );
1634
 
    QWidget::setFont( font );
1635
 
    setScale(scale());
1636
 
    QTimer::singleShot( 0, this, SLOT( slotHeaderSizeChanged() ) );
1637
 
}
1638
 
 
1639
 
 
1640
 
/*!
1641
 
  Specifies whether the configure popup menu should be shown on
1642
 
  right click on the time header widget.
1643
 
  This menu lets the user quickly change
1644
 
  the zoom factor,
1645
 
  the scale mode (minute, hour, day, week, month, auto) ,
1646
 
  the time format,
1647
 
  the year format,
1648
 
  the grid format,
1649
 
  and printing.
1650
 
  The default setting is not to show the popup menu.
1651
 
  This functionality must be enabled explicitly by the application
1652
 
  developer.
1653
 
  You can disable each submenu of the popmenu.
1654
 
 
1655
 
  \param show true in order to show the popup menu, false in order not
1656
 
  to. The default is true.
1657
 
  \param showZoom show the zoom submenu, default: true
1658
 
  \param showScale show the scale submenu, default: true
1659
 
  \param showTime show the time format submenu, default: true
1660
 
  \param showYear show the year format submenu, default: true
1661
 
  \param showGrid show the grid submenu, default: true
1662
 
  \param showPrint show the print submenu, default: false
1663
 
*/
1664
 
void KDGanttView::setShowHeaderPopupMenu( bool show,
1665
 
                                          bool showZoom,
1666
 
                                          bool showScale,
1667
 
                                          bool showTime,
1668
 
                                          bool showYear,
1669
 
                                          bool showGrid,
1670
 
                                          bool showPrint)
1671
 
{
1672
 
    if ( show && myTimeHeader->showPopupMenu() ) return;
1673
 
    myTimeHeader->setShowPopupMenu( show,showZoom,showScale,showTime,
1674
 
                                    showYear,showGrid,showPrint );
1675
 
}
1676
 
 
1677
 
 
1678
 
/*!
1679
 
  Returns whether the configure popup menu should be shown on right
1680
 
  click on the time header widget.
1681
 
 
1682
 
  \return true if the popup menu should be shown
1683
 
*/
1684
 
bool KDGanttView::showHeaderPopupMenu() const
1685
 
{
1686
 
    return myTimeHeader->showPopupMenu();
1687
 
}
1688
 
//****************************************************
1689
 
 
1690
 
 
1691
 
/*!
1692
 
  Specifies whether the add item popup menu should be shown on
1693
 
  right click on the time table widget.
1694
 
  This menu lets the user quickly add new items to the Gantt view
1695
 
  (as root, as child or after an item).
1696
 
  It also offers cutting and pasting of items.
1697
 
 
1698
 
  The default setting is that the popup menu is not shown.
1699
 
  It must be enabled by the program.
1700
 
 
1701
 
  \param show true in order to show popup menu, false in order not to
1702
 
 
1703
 
*/
1704
 
void KDGanttView::setShowTimeTablePopupMenu( bool show )
1705
 
{
1706
 
    myCanvasView->setShowPopupMenu( show );
1707
 
}
1708
 
 
1709
 
 
1710
 
/*!
1711
 
  Returns whether the add item popup menu should be shown on right
1712
 
  click on the time table widget.
1713
 
 
1714
 
  \return true if the popup menu should be shown
1715
 
*/
1716
 
bool KDGanttView::showTimeTablePopupMenu() const
1717
 
{
1718
 
    return myCanvasView->showPopupMenu();
1719
 
}
1720
 
 
1721
 
 
1722
 
/*!
1723
 
  Sets the shapes for a certain type of Gantt item. Not all items use
1724
 
  all three shapes (e.g., only summary items use the middle shape).
1725
 
 
1726
 
  This setting overrides any shape settings made on individual items.
1727
 
  These settings will be taken as initial values of any newly created
1728
 
  item of this certain type.
1729
 
  See also the documentation of the KDGanttViewItem class.
1730
 
 
1731
 
  \param type the type of Gantt items for which to set the shapes
1732
 
  \param start the shape to use for the beginning of the item
1733
 
  \param middle the shape to use for the middle of the item
1734
 
  \param end the shape to use for the end of the item
1735
 
  \param overwriteExisting if true, overwrites existing shape settings
1736
 
  in the individual items
1737
 
  \sa shapes()
1738
 
*/
1739
 
void KDGanttView::setShapes( KDGanttViewItem::Type type,
1740
 
                             KDGanttViewItem::Shape start,
1741
 
                             KDGanttViewItem::Shape middle,
1742
 
                             KDGanttViewItem::Shape end,
1743
 
                             bool overwriteExisting )
1744
 
{
1745
 
    if ( overwriteExisting ) {
1746
 
      QListViewItemIterator it(myListView);
1747
 
      for ( ; it.current(); ++it ) {
1748
 
        if ( ((KDGanttViewItem*)it.current())->type() == type)
1749
 
          ((KDGanttViewItem*)it.current())->setShapes(start,middle, end );
1750
 
      }
1751
 
    }
1752
 
    int index = getIndex( type );
1753
 
 
1754
 
    if ( index < 0 ) {
1755
 
      return;
1756
 
    }
1757
 
 
1758
 
    myDefaultShape [index*3] = start;
1759
 
    myDefaultShape [index*3+1] = middle;
1760
 
    myDefaultShape [index*3+2] = end;
1761
 
    undefinedShape[index] = false;
1762
 
}
1763
 
 
1764
 
 
1765
 
/*!
1766
 
  Queries the shapes for a particular type of Gantt item.
1767
 
 
1768
 
  \param type the type of Gantt items for which to query the shapes
1769
 
  \param start the start shape is returned in this parameter
1770
 
  \param middle the middle shape is returned in this parameter
1771
 
  \param end the end shape is returned in this parameter
1772
 
  \return true if there was a general shape set for the specified
1773
 
  type. If the return value is false, the values of the three shape
1774
 
  parameters are undefined.
1775
 
  \sa setShapes()
1776
 
*/
1777
 
bool KDGanttView::shapes( KDGanttViewItem::Type type,
1778
 
                          KDGanttViewItem::Shape& start,
1779
 
                          KDGanttViewItem::Shape& middle,
1780
 
                          KDGanttViewItem::Shape& end ) const
1781
 
{
1782
 
    int index = getIndex( type );
1783
 
 
1784
 
    if ( index < 0 ) {
1785
 
        return false;
1786
 
    }
1787
 
 
1788
 
    start = myDefaultShape [index*3];
1789
 
    middle = myDefaultShape [index*3+1];
1790
 
    end = myDefaultShape [index*3+2];
1791
 
    return !undefinedShape[index];
1792
 
}
1793
 
 
1794
 
 
1795
 
/*!
1796
 
  Sets the colors for a certain type of Gantt item. Not all items use
1797
 
  all three colors (e.g., only summary items use the middle color).
1798
 
 
1799
 
  This setting overrides any color settings made on individual items.
1800
 
  These settings will be taken as initial values of any newly created
1801
 
  item of this certain type.
1802
 
  See also the description of the KDGanttViewItem class.
1803
 
 
1804
 
  \param type the type of Gantt items for which to set the colors
1805
 
  \param start the color to use for the beginning of the item
1806
 
  \param middle the color to use for the middle of the item
1807
 
  \param end the color to use for the end of the item
1808
 
  \param overwriteExisting if true, overwrites existing color settings
1809
 
  on invididual items
1810
 
  \sa colors(), setDefaultColors(), defaultColors()
1811
 
*/
1812
 
void KDGanttView::setColors( KDGanttViewItem::Type type,
1813
 
                             const QColor& start, const QColor& middle,
1814
 
                             const QColor& end,
1815
 
                             bool overwriteExisting )
1816
 
{
1817
 
    if ( overwriteExisting ) {
1818
 
      QListViewItemIterator it(myListView);
1819
 
      for ( ; it.current(); ++it ) {
1820
 
        if ( ((KDGanttViewItem*)it.current())->type() == type)
1821
 
          ((KDGanttViewItem*)it.current())->setColors(start,middle, end );
1822
 
      }
1823
 
    }
1824
 
    int index = getIndex( type );
1825
 
    if (index < 0) return;
1826
 
    myColor [index*3] = start;
1827
 
    myColor [index*3+1] = middle;
1828
 
    myColor [index*3+2] = end;
1829
 
    undefinedColor[index] = false;
1830
 
}
1831
 
 
1832
 
 
1833
 
/*!
1834
 
  Queries the colors for a particular type of Gantt item.
1835
 
 
1836
 
  \param type the type of Gantt items for which to query the colors
1837
 
  \param start the start color is returned in this parameter
1838
 
  \param middle the middle color is returned in this parameter
1839
 
  \param end the end color is returned in this parameter
1840
 
  \return true if there was a general color set for the specified
1841
 
  type. If the return value is false, the values of the three color
1842
 
  parameters are undefined.
1843
 
  \sa setColors(), setDefaultColor(), defaultColor()
1844
 
*/
1845
 
bool KDGanttView::colors( KDGanttViewItem::Type type,
1846
 
                          QColor& start, QColor& middle, QColor& end ) const
1847
 
{
1848
 
    int index = getIndex( type );
1849
 
    if (index < 0) return false;
1850
 
    start = myColor [index*3];
1851
 
    middle = myColor [index*3+1];
1852
 
    end = myColor [index*3+2];
1853
 
    return !undefinedColor[index];
1854
 
}
1855
 
 
1856
 
 
1857
 
/*!
1858
 
  Sets the highlight colors for a certain type of Gantt item. Not
1859
 
  all items use all three highlight colors (e.g., only summary items
1860
 
  use the middle highlight color).
1861
 
 
1862
 
  This setting overrides any highlight color settings made on
1863
 
  individual items.
1864
 
  These settings will be taken as initial values of any newly created
1865
 
  item of this certain type.
1866
 
  See also the description of the KDGanttViewItem class.
1867
 
 
1868
 
  \param type the type of Gantt items for which to set the highlight colors
1869
 
  \param start the highlight color to use for the beginning of the item
1870
 
  \param middle the highlight color to use for the middle of the item
1871
 
  \param end the highlight color to use for the end of the item
1872
 
  \param overwriteExisting if true, overwrites existing color settings
1873
 
  in the individual items
1874
 
  \sa highlightColors(), setDefaultHighlightColor(), defaultHighlightColor()
1875
 
*/
1876
 
void KDGanttView::setHighlightColors( KDGanttViewItem::Type type,
1877
 
                                      const QColor& start,
1878
 
                                      const QColor& middle,
1879
 
                                      const QColor& end,
1880
 
                                      bool overwriteExisting )
1881
 
{
1882
 
    if ( overwriteExisting ) {
1883
 
      QListViewItemIterator it(myListView);
1884
 
      for ( ; it.current(); ++it ) {
1885
 
        if ( ((KDGanttViewItem*)it.current())->type() == type)
1886
 
          ((KDGanttViewItem*)it.current())->setHighlightColors(start,middle, end );
1887
 
      }
1888
 
    }
1889
 
    int index = getIndex( type );
1890
 
    if (index < 0) return;
1891
 
 
1892
 
    myColorHL [index*3] = start;
1893
 
    myColorHL [index*3+1] = middle;
1894
 
    myColorHL [index*3+2] = end;
1895
 
    undefinedColorHL[index] = false;
1896
 
 
1897
 
}
1898
 
 
1899
 
 
1900
 
/*!
1901
 
  Queries the highlight colors for a particular type of Gantt item.
1902
 
 
1903
 
  \param type the type of Gantt items for which to query the highlight
1904
 
  colors
1905
 
  \param start the start highlight color is returned in this parameter
1906
 
  \param middle the middle highlight color is returned in this parameter
1907
 
  \param end the end highlight color is returned in this parameter
1908
 
  \return true if there was a general highlight color set for the specified
1909
 
  type. If the return value is false, the values of the three highlight color
1910
 
  parameters are undefined.
1911
 
  \sa setHighlightColors(), setDefaultHighlightColor(),
1912
 
  defaultHighlightColor()
1913
 
*/
1914
 
bool KDGanttView::highlightColors( KDGanttViewItem::Type type,
1915
 
                                   QColor& start, QColor& middle,
1916
 
                                   QColor& end ) const
1917
 
{
1918
 
    int index = getIndex( type );
1919
 
    if (index < 0) return false;
1920
 
 
1921
 
    start = myColorHL [index*3];
1922
 
    middle = myColorHL [index*3+1];
1923
 
    end = myColorHL [index*3+2];
1924
 
    return !undefinedColorHL[index];
1925
 
}
1926
 
 
1927
 
 
1928
 
/*!
1929
 
  Sets the color used for texts in the Gantt chart.
1930
 
  Overrides all individual settings of the Gantt items.
1931
 
 
1932
 
  \param color the text color to use
1933
 
  \sa textColor()
1934
 
*/
1935
 
void KDGanttView::setTextColor( const QColor& color )
1936
 
{
1937
 
    QListViewItemIterator it(myListView);
1938
 
    for ( ; it.current(); ++it ) {
1939
 
        ((KDGanttViewItem*)it.current())->setTextColor(color);
1940
 
    }
1941
 
    myTextColor = color;
1942
 
}
1943
 
 
1944
 
 
1945
 
/*!
1946
 
  Returns the color used for texts in the Gantt chart.
1947
 
 
1948
 
  \return the color used for texts in the Gantt chart.
1949
 
  \sa setTextColor()
1950
 
*/
1951
 
QColor KDGanttView::textColor() const
1952
 
{
1953
 
    return myTextColor;
1954
 
}
1955
 
 
1956
 
 
1957
 
/*!
1958
 
  Specifies the brush in which the 'showNoInformation' line of items
1959
 
  should be drawn.
1960
 
 
1961
 
  \param  brush the brush of the 'showNoInformation' lines
1962
 
  \sa  KDGanttViewItem::showNoInformation(),
1963
 
  KDGanttViewItem::setShowNoInformation(),
1964
 
  KDGanttView::noInformationBrush()
1965
 
 
1966
 
*/
1967
 
void KDGanttView::setNoInformationBrush( const QBrush& brush )
1968
 
{
1969
 
  myTimeTable->setNoInformationBrush( brush );
1970
 
}
1971
 
 
1972
 
 
1973
 
/*!
1974
 
  Returns the brush of the 'showNoInformation' lines
1975
 
  \return  the brush of the 'showNoInformation' lines
1976
 
  \sa  KDGanttViewItem::showNoInformation(), KDGanttViewItem::setShowNoInformation(),
1977
 
  setNoInformationBrush()
1978
 
*/
1979
 
QBrush KDGanttView::noInformationBrush() const
1980
 
{
1981
 
  return myTimeTable->noInformationBrush();
1982
 
}
1983
 
 
1984
 
 
1985
 
/*!
1986
 
  Removes all items from the legend.
1987
 
 
1988
 
  \sa addLegendItem()
1989
 
*/
1990
 
void KDGanttView::clearLegend( )
1991
 
{
1992
 
    setShowLegend( false );
1993
 
    myLegend->clearLegend();
1994
 
    myLegendItems.setAutoDelete( true );
1995
 
    myLegendItems.clear();
1996
 
}
1997
 
 
1998
 
 
1999
 
/*!
2000
 
  Adds an item to the legend.
2001
 
 
2002
 
  \param shape the shape to display
2003
 
  \param shapeColor the color in which to display the shape
2004
 
  \param text the text to display
2005
 
  \sa clearLegend()
2006
 
*/
2007
 
void KDGanttView::addLegendItem( KDGanttViewItem::Shape shape,
2008
 
                                 const QColor& shapeColor,
2009
 
                                 const QString& text )
2010
 
{
2011
 
    myLegend->addLegendItem( shape,shapeColor,text );
2012
 
    legendItem* item = new legendItem;
2013
 
    item->shape = shape;
2014
 
    item->color = shapeColor;
2015
 
    item->text = text;
2016
 
    item->has2 = false;
2017
 
    myLegendItems.append( item );
2018
 
}
2019
 
 
2020
 
/*!
2021
 
  Adds an item to the legend with two shapes and text right of the shapes.
2022
 
  The text may be empty.
2023
 
 
2024
 
  \param shape the first shape to display
2025
 
  \param shapeColor the color in which to display the first shape
2026
 
  \param text the text to display right of the first shape. may be empty.
2027
 
  \param shape2 the second shape to display
2028
 
  \param shapeColor2 the color in which to display the second shape
2029
 
  \param text2 the text to display right of the second shape. may be empty.
2030
 
  \sa clearLegend()
2031
 
*/
2032
 
void KDGanttView::addLegendItem( KDGanttViewItem::Shape shape,
2033
 
                                 const QColor& shapeColor,
2034
 
                                 const QString& text,
2035
 
                                 KDGanttViewItem::Shape shape2,
2036
 
                                 const QColor& shapeColor2,
2037
 
                                 const QString& text2 )
2038
 
{
2039
 
    myLegend->addLegendItem( shape,shapeColor,text,shape2,shapeColor2,text2 );
2040
 
    legendItem* item = new legendItem;
2041
 
    item->shape = shape;
2042
 
    item->color = shapeColor;
2043
 
    item->text = text;
2044
 
    item->has2 = true;
2045
 
    item->shape2 = shape2;
2046
 
    item->color2 = shapeColor2;
2047
 
    item->text2 = text2;
2048
 
 
2049
 
    myLegendItems.append( item );
2050
 
}
2051
 
 
2052
 
 
2053
 
 
2054
 
/*!
2055
 
  Sets the start of the horizon of the Gantt chart. If \a start is
2056
 
  null, the horizon start is computed automatically.
2057
 
 
2058
 
  \param start the start of the horizon
2059
 
  \sa horizonStart()
2060
 
*/
2061
 
void KDGanttView::setHorizonStart( const QDateTime& start )
2062
 
{
2063
 
    myTimeHeader->setHorizonStart(start);
2064
 
}
2065
 
 
2066
 
 
2067
 
/*!
2068
 
  Returns the start of the horizon of the Gantt chart.
2069
 
 
2070
 
  \return the start of the horizon of the Gantt chart
2071
 
  \sa setHorizonStart()
2072
 
*/
2073
 
QDateTime KDGanttView::horizonStart() const
2074
 
{
2075
 
    return myTimeHeader->horizonStart();
2076
 
}
2077
 
 
2078
 
 
2079
 
/*!
2080
 
  Sets the end of the horizon of the Gantt chart. If \a end is
2081
 
  null, the horizon end is computed automatically.
2082
 
 
2083
 
  \param end the end of the horizon
2084
 
  \sa setHorizonEnd()
2085
 
*/
2086
 
void KDGanttView::setHorizonEnd( const QDateTime& end )
2087
 
{
2088
 
    myTimeHeader->setHorizonEnd(end);
2089
 
}
2090
 
 
2091
 
 
2092
 
/*!
2093
 
  Returns the end of the horizon of the Gantt chart.
2094
 
 
2095
 
  \return the end of the horizon of the Gantt chart
2096
 
  \sa setHorizonEnd()
2097
 
 
2098
 
*/
2099
 
QDateTime KDGanttView::horizonEnd() const
2100
 
{
2101
 
    return myTimeHeader->horizonEnd();
2102
 
}
2103
 
 
2104
 
/*!
2105
 
  Configures the unit of the lower scale of the header. The higher
2106
 
  unit is computed automatically. Does not update the header.
2107
 
  Usually used to avoid flicker if immediately another header changing operation follows.
2108
 
 
2109
 
  \param unit the unit of the lower scale of the header.
2110
 
  \sa scale() setScale()
2111
 
*/
2112
 
void KDGanttView::setScaleSilent( Scale unit )
2113
 
{
2114
 
    myTimeHeader->setScale( unit, false );
2115
 
}
2116
 
 
2117
 
/*!
2118
 
  Configures the unit of the lower scale of the header. The higher
2119
 
  unit is computed automatically.
2120
 
 
2121
 
  \param unit the unit of the lower scale of the header.
2122
 
  \sa scale() setScaleSilent()
2123
 
*/
2124
 
void KDGanttView::setScale( Scale unit )
2125
 
{
2126
 
    myTimeHeader->setScale( unit );
2127
 
}
2128
 
 
2129
 
 
2130
 
/*!
2131
 
  Returns the unit of the lower scale of the header.
2132
 
 
2133
 
  \return the unit of the lower scale of the header.
2134
 
  \sa setScale()
2135
 
*/
2136
 
KDGanttView::Scale KDGanttView::scale() const
2137
 
{
2138
 
    return myTimeHeader->scale();
2139
 
}
2140
 
 
2141
 
 
2142
 
/*!
2143
 
  Sets the maximum allowed time scale of the lower scale of the header.
2144
 
 
2145
 
  \param unit the unit of the lower scale of the header.
2146
 
  \sa scale()
2147
 
*/
2148
 
void KDGanttView::setMaximumScale( Scale unit )
2149
 
{
2150
 
    myTimeHeader->setMaximumScale( unit );
2151
 
}
2152
 
 
2153
 
 
2154
 
/*!
2155
 
  Returns the maximum allowed time scale of the lower scale of the header.
2156
 
 
2157
 
  \return the unit of the lower scale of the header.
2158
 
  \sa setScale()
2159
 
*/
2160
 
KDGanttView::Scale KDGanttView::maximumScale() const
2161
 
{
2162
 
    return myTimeHeader->maximumScale();
2163
 
}
2164
 
 
2165
 
 
2166
 
/*!
2167
 
  Sets the minimum allowed time scale of the lower scale of the header.
2168
 
 
2169
 
  \param unit the unit of the lower scale of the header.
2170
 
  \sa scale()
2171
 
*/
2172
 
void KDGanttView::setMinimumScale( Scale unit )
2173
 
{
2174
 
    myTimeHeader->setMinimumScale( unit );
2175
 
}
2176
 
 
2177
 
 
2178
 
/*!
2179
 
  Returns the minimum allowed time scale of the lower scale of the header.
2180
 
 
2181
 
  \return the unit of the lower scale of the header.
2182
 
  \sa setScale()
2183
 
*/
2184
 
KDGanttView::Scale KDGanttView::minimumScale() const
2185
 
{
2186
 
    return myTimeHeader->minimumScale();
2187
 
}
2188
 
 
2189
 
 
2190
 
/*!
2191
 
  Sets the absolute number of minor ticks, if scaling is set to Auto.
2192
 
  If the scale mode is set to Auto, then the actual scale and
2193
 
  the minorScaleCount is automatically computed, such that there are
2194
 
  count minor ticks
2195
 
 
2196
 
  \param count the number of minor ticks
2197
 
  \sa autoScaleMinorTickCount(),setScale(),scale()
2198
 
*/
2199
 
void KDGanttView::setAutoScaleMinorTickCount( int count )
2200
 
{
2201
 
  myTimeHeader->setAutoScaleMinorTickCount( count );
2202
 
}
2203
 
 
2204
 
 
2205
 
/*!
2206
 
  Returns the absolut number of minor ticks, if scaling is set to Auto
2207
 
 
2208
 
  \return the absolut number of minor ticks
2209
 
  \sa setAutoScaleMinorTickCount(),setScale(),scale()
2210
 
*/
2211
 
int KDGanttView::autoScaleMinorTickCount() const
2212
 
{
2213
 
  return myTimeHeader->autoScaleMinorTickCount();
2214
 
}
2215
 
 
2216
 
 
2217
 
/*!
2218
 
  Sets the minimum width that a column needs to have. If the size of the
2219
 
  Gantt chart and the scale would make it necessary to go below this
2220
 
  limit otherwise, the chart will automatically be made less exact.
2221
 
 
2222
 
  \param width the minimum column width
2223
 
  \sa minimumColumnWidth()
2224
 
*/
2225
 
void KDGanttView::setMinimumColumnWidth( int width )
2226
 
{
2227
 
    myTimeHeader->setMinimumColumnWidth( width );
2228
 
}
2229
 
 
2230
 
 
2231
 
/*!
2232
 
  Returns the minimum width a column needs to have.
2233
 
 
2234
 
  \return the column minimum width
2235
 
  \sa setMinimumColumnWidth()
2236
 
*/
2237
 
int KDGanttView::minimumColumnWidth() const
2238
 
{
2239
 
    return myTimeHeader->minimumColumnWidth();
2240
 
}
2241
 
 
2242
 
 
2243
 
/*!
2244
 
  Specifies the format in which to display years. If no years are
2245
 
  shown, this method has no effect.
2246
 
 
2247
 
  \param format the year format
2248
 
  \sa yearFormat(), setHourFormat(), hourFormat()
2249
 
*/
2250
 
void KDGanttView::setYearFormat( YearFormat format )
2251
 
{
2252
 
    myTimeHeader->setYearFormat(format );
2253
 
}
2254
 
 
2255
 
 
2256
 
/*!
2257
 
  Returns the format in which to display years.
2258
 
 
2259
 
  \return the year format
2260
 
  \sa setYearFormat(), setHourFormat(), hourFormat()
2261
 
*/
2262
 
KDGanttView::YearFormat KDGanttView::yearFormat() const
2263
 
{
2264
 
    return myTimeHeader->yearFormat();
2265
 
}
2266
 
 
2267
 
 
2268
 
/*!
2269
 
  Specifies the format in which to display hours. If no hours are
2270
 
  shown, this method has no effect.
2271
 
 
2272
 
  \param format the hour format
2273
 
  \sa hourFormat(), setYearFormat(), yearFormat()
2274
 
 
2275
 
*/
2276
 
void KDGanttView::setHourFormat( HourFormat format )
2277
 
{
2278
 
    myTimeHeader->setHourFormat( format );
2279
 
}
2280
 
 
2281
 
 
2282
 
/*!
2283
 
  Returns the format in which to display hours.
2284
 
 
2285
 
  \return the hour format
2286
 
  \sa setHourFormat(), setYearFormat(), yearFormat()
2287
 
 
2288
 
*/
2289
 
KDGanttView::HourFormat KDGanttView::hourFormat() const
2290
 
{
2291
 
    return myTimeHeader->hourFormat();
2292
 
}
2293
 
 
2294
 
 
2295
 
/*!
2296
 
  Hides/shows the grid for the major ticks of the time header in the gantt view.
2297
 
 
2298
 
  \param show Which grid to show. Possible values are ShowMajorTicks,
2299
 
              ShowMinorTicks and ShowNoTicks.
2300
 
  \sa showTicks()
2301
 
*/
2302
 
void KDGanttView::setShowTicks( ShowTicksType show )
2303
 
{
2304
 
    myTimeHeader->setShowTicks(show );
2305
 
}
2306
 
 
2307
 
 
2308
 
/*!
2309
 
  Returns which type of grid is shown.
2310
 
 
2311
 
  \return type of grid: ShowMajorTicks, ShowMinorTicks or ShowNoTicks
2312
 
  \sa setShowTicks()
2313
 
*/
2314
 
KDGanttView::ShowTicksType KDGanttView::showTicks() const
2315
 
{
2316
 
    return myTimeHeader->showTicks();
2317
 
}
2318
 
 
2319
 
 
2320
 
 
2321
 
/*!
2322
 
  Sets the background color for the column closest to \a column.
2323
 
  It can be specified whether the color should be shown in all scales or
2324
 
  only in specific scales.
2325
 
  If you want to define the color only for the daily view, specify
2326
 
  mini and maxi as Day.
2327
 
  If there is no value specified for mini and maxi, the color for the column
2328
 
  is shown on all scales. Note that it is possible that there are two
2329
 
  values for a column in a scale. In this case, the shown color is unspecified.
2330
 
 
2331
 
  \param column the column to set the background color for
2332
 
  \param color the background color
2333
 
  \param mini show the colour only in scales greater than this
2334
 
  \param maxi show the colour only in scales lesser than this
2335
 
  \sa columnBackgroundColor(), setWeekendBackgroundColor(),
2336
 
  weekendBackgroundColor()
2337
 
*/
2338
 
void KDGanttView::setColumnBackgroundColor( const QDateTime& column,
2339
 
                                            const QColor& color ,
2340
 
                                            Scale mini, Scale maxi )
2341
 
{
2342
 
  myTimeHeader->setColumnBackgroundColor( column, color,mini,maxi );
2343
 
}
2344
 
 
2345
 
#if 0
2346
 
/*!
2347
 
  Sets the background color for a time interval given by \a start and
2348
 
  \a end.  \a start may be later than \a end.  If there is already a
2349
 
  background interval with the same \a start and \a end values
2350
 
  defined, the values (i.e.  const QColor& color , Scale mini, Scale
2351
 
  maxi) of this background interval are changed.  Change the times of
2352
 
  an already defined interval with \a changeBackgroundInterval().
2353
 
  Delete an already defined interval with \a
2354
 
  deleteBackgroundInterval().
2355
 
s
2356
 
  It can be defined, whether the color should be shown in all scales or
2357
 
  only in specific scales.
2358
 
  If you want to define the color only for the daily view, scecify
2359
 
  mini and maxi as Day.
2360
 
  If there is no value for mini/maxi specified, the color for the columns
2361
 
  is shown in all scales.
2362
 
 
2363
 
  \param start start datetime of the time interval
2364
 
  \param end end datetime of the time interval
2365
 
  \param priority paint priority. May be 0 to 10.
2366
 
                  An interval with higher priority is painted over other intervals.
2367
 
  \param color the background color
2368
 
  \param mini show the color only in scales greater than this
2369
 
  \param maxi show the color only in scales lesser than this
2370
 
  \sa changeBackgroundInterval(), deleteBackgroundInterval(),
2371
 
  columnBackgroundColor(), setWeekendBackgroundColor(),
2372
 
  weekendBackgroundColor()
2373
 
*/
2374
 
void KDGanttView::setIntervalBackgroundColor( const QDateTime& start,
2375
 
                                              const QDateTime& end,
2376
 
                                              const QColor& color ,
2377
 
                                              int priority,
2378
 
                                              Scale mini, Scale maxi )
2379
 
{
2380
 
    myTimeHeader->setIntervalBackgroundColor( start, end, color, priority, mini,maxi );
2381
 
}
2382
 
 
2383
 
 
2384
 
/*!
2385
 
  Changes the times of an already defined background color interval.
2386
 
  The new values \a startnew and \a endnew should not be datetime
2387
 
  values of an already defined background color interval.
2388
 
  If that is the case, nothing is changed and false is returned.
2389
 
 
2390
 
  \param oldstart the start date and time of the interval to change
2391
 
  \param oldend the end date and time of the interval to change
2392
 
  \param newstart the new start date and time
2393
 
  \param newend the new end date and time
2394
 
  \return true, if there is a backgroundcolor interval with values
2395
 
  \a start and \a end found  and the new values \a startnew and \a endnew
2396
 
  are not datetime values of an already defined background color interval.
2397
 
          Returns false otherwise.
2398
 
  \sa changeBackgroundInterval(), deleteBackgroundInterval(),
2399
 
  columnBackgroundColor(), setWeekendBackgroundColor(),
2400
 
  weekendBackgroundColor()
2401
 
*/
2402
 
bool KDGanttView::changeBackgroundInterval( const QDateTime& oldstart,
2403
 
                                   const QDateTime& oldend,
2404
 
                                   const QDateTime& newstart,
2405
 
                                   const QDateTime& newend )
2406
 
{
2407
 
  return myTimeHeader->changeBackgroundInterval( oldstart, oldend,
2408
 
                                                 newstart, newend );
2409
 
}
2410
 
 
2411
 
/*!
2412
 
  Deletes an already defined background color interval.
2413
 
 
2414
 
  \param start start datetime of time interval
2415
 
  \param end end datetime of time interval
2416
 
  \return true, if there is a backgroundcolor interval with values
2417
 
  \a start and \a end found  (and hence deleted).
2418
 
  \sa changeBackgroundInterval(),  columnBackgroundColor()
2419
 
*/
2420
 
bool KDGanttView::deleteBackgroundInterval( const QDateTime& start,
2421
 
                                                   const QDateTime& end)
2422
 
{
2423
 
  return myTimeHeader->deleteBackgroundInterval( start, end );
2424
 
}
2425
 
#endif
2426
 
 
2427
 
/*!
2428
 
  Adds a filled rectangle for a time interval given by \a start and
2429
 
  \a end, across all tasks.  \a start may be later than \a end.
2430
 
  \sa KDIntervalColorRectangle
2431
 
*/
2432
 
void KDGanttView::addIntervalBackgroundColor( KDIntervalColorRectangle* newItem )
2433
 
{
2434
 
  myTimeHeader->addIntervalBackgroundColor( newItem );
2435
 
}
2436
 
 
2437
 
/*!
2438
 
  Removes all background color settings set with setColumnBackgroundColor()
2439
 
  and setIntervalBackgroundColor().
2440
 
  Does not affect the settings of setWeekendBackgroundColor().
2441
 
 
2442
 
  \sa setColumnBackgroundColor(), setWeekendBackgroundColor(),
2443
 
  weekendBackgroundColor(), setIntervalBackgroundColor()
2444
 
*/
2445
 
void KDGanttView::clearBackgroundColor()
2446
 
{
2447
 
  myTimeHeader->clearBackgroundColor();
2448
 
}
2449
 
 
2450
 
 
2451
 
/*!
2452
 
  Returns the background color for the column closest to \a column.
2453
 
 
2454
 
  \param column the column to query the background color for
2455
 
  \return the background color of the specified color
2456
 
  \sa setColumnBackgroundColor(), setWeekendBackgroundColor(),
2457
 
  weekendBackgroundColor()
2458
 
*/
2459
 
QColor KDGanttView::columnBackgroundColor( const QDateTime& column ) const
2460
 
{
2461
 
    return myTimeHeader->columnBackgroundColor( column ) ;
2462
 
}
2463
 
 
2464
 
 
2465
 
/*!
2466
 
  Specifies the background color for weekend days. If no individual
2467
 
  days are visible on the Gantt chart, this method has no visible
2468
 
  effect.
2469
 
 
2470
 
  \param color the background color to use for weekend days.
2471
 
  \sa weekendBackgroundColor(), setWeekendDays(), weekendDays()
2472
 
*/
2473
 
void KDGanttView::setWeekendBackgroundColor( const QColor& color )
2474
 
{
2475
 
    myTimeHeader->setWeekendBackgroundColor( color );
2476
 
}
2477
 
 
2478
 
 
2479
 
/*!
2480
 
  Returns the background color for weekend days.
2481
 
 
2482
 
  \return the background color for weekend days
2483
 
  \sa setWeekendBackgroundColor(), setWeekendDays(), weekendDays()
2484
 
*/
2485
 
QColor KDGanttView::weekendBackgroundColor() const
2486
 
{
2487
 
    return myTimeHeader->weekendBackgroundColor();
2488
 
}
2489
 
 
2490
 
 
2491
 
/*!
2492
 
  Specifies the background color for weekday days. If no individual
2493
 
  days are visible on the Gantt chart, this method has no visible
2494
 
  effect. The days are specified as an intervals of integer values
2495
 
  where 1 means Monday and 7 means Sunday.
2496
 
 
2497
 
  \param color the background color to use for weekend days.
2498
 
  \param weekday the day of the week (Monday = 1, Sunday = 7)
2499
 
  \sa weekendBackgroundColor(), setWeekendDays(), weekendDays()
2500
 
*/
2501
 
void KDGanttView::setWeekdayBackgroundColor( const QColor& color, int  weekday )
2502
 
{
2503
 
  myTimeHeader->setWeekdayBackgroundColor( color,  weekday );
2504
 
}
2505
 
 
2506
 
 
2507
 
/*!
2508
 
  Returns the background color for weekday days.
2509
 
 
2510
 
  \param weekday the day of the week (Monday = 1, Sunday = 7)
2511
 
  \return the background color for weekend days
2512
 
  \sa setWeekendBackgroundColor(), setWeekendDays(), weekendDays()
2513
 
*/
2514
 
QColor KDGanttView::weekdayBackgroundColor(int weekday) const
2515
 
{
2516
 
  return myTimeHeader->weekdayBackgroundColor( weekday);
2517
 
}
2518
 
 
2519
 
 
2520
 
 
2521
 
/*!
2522
 
  Defines which days are considered weekends. The days are specified
2523
 
  as an interval of integer values where 1 means Monday and 7 means
2524
 
  Sunday. In order to define a weekend from Sunday to Monday, specify
2525
 
  (7,1).
2526
 
 
2527
 
  \param start the first day of the weekend
2528
 
  \param end the last day of the weekend
2529
 
  \sa weekendDays(), setWeekendBackgroundColor(), weekendBackgroundColor()
2530
 
*/
2531
 
void KDGanttView::setWeekendDays( int start, int end )
2532
 
{
2533
 
    myTimeHeader->setWeekendDays( start,  end );
2534
 
}
2535
 
 
2536
 
 
2537
 
/*!
2538
 
  Returns which days are considered weekends.
2539
 
 
2540
 
  \param start in this parameter, the first day of the weekend is returned
2541
 
  \param end in this parameter, the end day of the weekend is returned
2542
 
  \sa setWeekendDays(), setWeekendBackgroundColor(), weekendBackgroundColor()
2543
 
*/
2544
 
void KDGanttView::weekendDays( int& start, int& end ) const
2545
 
{
2546
 
    myTimeHeader->weekendDays( start,  end );
2547
 
}
2548
 
 
2549
 
 
2550
 
/*!
2551
 
  \fn void KDGanttView::itemLeftClicked( KDGanttViewItem* )
2552
 
 
2553
 
  This signal is emitted when the user clicks on an item with the left
2554
 
  mouse button.
2555
 
*/
2556
 
 
2557
 
 
2558
 
/*!
2559
 
  \fn void KDGanttView::itemMidClicked( KDGanttViewItem* )
2560
 
 
2561
 
  This signal is emitted when the user clicks on an item with the middle
2562
 
  mouse button.
2563
 
*/
2564
 
 
2565
 
 
2566
 
/*!
2567
 
  \fn void KDGanttView::itemRightClicked( KDGanttViewItem* )
2568
 
 
2569
 
  This signal is emitted when the user clicks on an item with the right
2570
 
  mouse button.
2571
 
*/
2572
 
 
2573
 
 
2574
 
/*!
2575
 
  \fn void KDGanttView::itemDoubleClicked( KDGanttViewItem* )
2576
 
 
2577
 
  This signal is emitted when the user double-clicks an item.
2578
 
*/
2579
 
 
2580
 
 
2581
 
/*!
2582
 
  \fn void KDGanttView::itemConfigured( KDGanttViewItem* )
2583
 
 
2584
 
  This signal is emitted when the user has configured an item
2585
 
  visually. This signal is emitted on every mouse move when the user
2586
 
  is changing an item.
2587
 
  That means this signal is emitted every time when the user is about
2588
 
  to configure an item.
2589
 
 /sa itemChanged()
2590
 
*/
2591
 
/*!
2592
 
  \fn void KDGanttView::itemChanged( KDGanttViewItem* )
2593
 
 
2594
 
  This signal is emitted after the mouse key is released
2595
 
  when the user has configured an item visually.
2596
 
  That means this signal is emitted after the user has finished
2597
 
  the configured of an item.
2598
 
  /sa itemConfigured()
2599
 
*/
2600
 
 
2601
 
 
2602
 
 
2603
 
/*!
2604
 
  \fn void KDGanttView::taskLinkLeftClicked( KDGanttViewTaskLink* )
2605
 
 
2606
 
  This signal is emitted when the user clicks on a task link with the
2607
 
  left mouse button.
2608
 
*/
2609
 
 
2610
 
 
2611
 
/*!
2612
 
  \fn void KDGanttView::taskLinkMidClicked( KDGanttViewTaskLink* )
2613
 
 
2614
 
  This signal is emitted when the user clicks on a task link with the
2615
 
  middle mouse button.
2616
 
*/
2617
 
 
2618
 
 
2619
 
/*!
2620
 
  \fn void KDGanttView::taskLinkRightClicked( KDGanttViewTaskLink* )
2621
 
 
2622
 
  This signal is emitted when the user clicks on a task link with the
2623
 
  right mouse button.
2624
 
*/
2625
 
 
2626
 
 
2627
 
/*!
2628
 
  \fn void KDGanttView::taskLinkDoubleClicked( KDGanttViewTaskLink* )
2629
 
 
2630
 
  This signal is emitted when the user double-clicks a task link.
2631
 
*/
2632
 
 
2633
 
 
2634
 
/*!
2635
 
  \enum KDGanttView::YearFormat
2636
 
 
2637
 
  This enum is used to specify the year format used in the header.
2638
 
*/
2639
 
 
2640
 
 
2641
 
/*!
2642
 
  \enum KDGanttView::HourFormat
2643
 
 
2644
 
  This enum is used to specify the hour format used in the header.
2645
 
*/
2646
 
 
2647
 
 
2648
 
/*!
2649
 
  \enum KDGanttView::Scale
2650
 
 
2651
 
  This enum is used to specify the units of the scales in the header.
2652
 
*/
2653
 
 
2654
 
 
2655
 
 
2656
 
 
2657
 
/*!
2658
 
  Sets the number of ticks in the major scale.
2659
 
 
2660
 
  \param count the number of ticks in the major scale
2661
 
  \sa majorScaleCount(), setMinorScaleCount(), minorScaleCount()
2662
 
*/
2663
 
void KDGanttView::setMajorScaleCount( int count )
2664
 
{
2665
 
    myTimeHeader->setMajorScaleCount(count );
2666
 
}
2667
 
 
2668
 
 
2669
 
/*!
2670
 
  Returns the number of ticks per unit in the major scale.
2671
 
 
2672
 
  \return the number of ticks in the major scale
2673
 
  \sa setMajorScaleCount(), setMinorScaleCount(), minorScaleCount()
2674
 
*/
2675
 
int KDGanttView::majorScaleCount() const
2676
 
{
2677
 
    return myTimeHeader->majorScaleCount();
2678
 
}
2679
 
 
2680
 
 
2681
 
/*!
2682
 
  Sets the number of ticks in the minor scale.
2683
 
 
2684
 
  \param count the number of ticks in the minor scale
2685
 
  \sa minorScaleCount, setMajorScaleCount, majorScaleCount()
2686
 
*/
2687
 
void KDGanttView::setMinorScaleCount( int count )
2688
 
{
2689
 
    myTimeHeader->setMinorScaleCount(count );
2690
 
}
2691
 
 
2692
 
 
2693
 
/*!
2694
 
  Returns the number of ticks per unit in the minor scale.
2695
 
 
2696
 
  \return the number of ticks in the minor scale
2697
 
  \sa setMinorScaleCount(), setMajorScaleCount(), majorScaleCount()
2698
 
*/
2699
 
int KDGanttView::minorScaleCount() const
2700
 
{
2701
 
    return myTimeHeader->minorScaleCount();
2702
 
 
2703
 
}
2704
 
 
2705
 
 
2706
 
/*!
2707
 
  Sets the default color for a particular type of Gantt item that is
2708
 
  used for the item if no specific start, middle, or end colors are
2709
 
  set.
2710
 
 
2711
 
  \param type the type of Gantt items for which to query the highlight
2712
 
  colors
2713
 
  \param color the default color to use
2714
 
  \param overwriteExisting if true, existing settings for individual
2715
 
  items are overwritten
2716
 
  \sa defaultColor(), setColors(), colors()
2717
 
*/
2718
 
void KDGanttView::setDefaultColor( KDGanttViewItem::Type type,
2719
 
                                   const QColor& color,
2720
 
                                   bool overwriteExisting )
2721
 
{
2722
 
    if ( overwriteExisting ) {
2723
 
      QListViewItemIterator it(myListView);
2724
 
      for ( ; it.current(); ++it ) {
2725
 
        if ( ((KDGanttViewItem*)it.current())->type() == type)
2726
 
          ((KDGanttViewItem*)it.current())->setDefaultColor(color );
2727
 
      }
2728
 
    }
2729
 
    int index = getIndex( type );
2730
 
    myDefaultColor [index] = color;
2731
 
}
2732
 
 
2733
 
 
2734
 
 
2735
 
/*!
2736
 
  Returns the default color for a particular type of Gantt item that
2737
 
  is used for the item if no specific start, middle, or end colors are
2738
 
  set.
2739
 
 
2740
 
  \param type the type of Gantt items for which to query the highlight
2741
 
  colors
2742
 
  \return color the default color used
2743
 
  \sa setDefaultColor(), setColors(), colors()
2744
 
*/
2745
 
QColor KDGanttView::defaultColor( KDGanttViewItem::Type type ) const
2746
 
{
2747
 
  int index = getIndex( type );
2748
 
  return myDefaultColor [index];
2749
 
}
2750
 
 
2751
 
 
2752
 
/*!
2753
 
  Sets the default highlighting color for a particular type of
2754
 
  Gantt item that is used for the item if no specific start, middle,
2755
 
  or end colors are set.
2756
 
 
2757
 
  \param type the type of Gantt items for which to query the highlight
2758
 
  colors
2759
 
  \param color the default highlighting color to use
2760
 
  \param overwriteExisting if true, existing color settings in
2761
 
  individual items are overwritten
2762
 
  \sa defaultHighlightColor(), setHighlightColors(), highlightColors()
2763
 
*/
2764
 
void KDGanttView::setDefaultHighlightColor( KDGanttViewItem::Type type,
2765
 
                                            const QColor& color,
2766
 
                                            bool overwriteExisting )
2767
 
{
2768
 
    if ( overwriteExisting ) {
2769
 
      QListViewItemIterator it(myListView);
2770
 
      for ( ; it.current(); ++it ) {
2771
 
        if ( ((KDGanttViewItem*)it.current())->type() == type)
2772
 
          ((KDGanttViewItem*)it.current())->setDefaultHighlightColor(color );
2773
 
      }
2774
 
    }
2775
 
    int index = getIndex( type );
2776
 
    myDefaultColorHL [index] = color;
2777
 
}
2778
 
 
2779
 
 
2780
 
 
2781
 
/*!
2782
 
  Returns the default highlighting color for a particular type of
2783
 
  Gantt item that is used for the item if no specific start, middle,
2784
 
  or end colors are set.
2785
 
 
2786
 
  \param type the type of Gantt items for which to query the highlight
2787
 
  colors
2788
 
  \return color the default highlighting color used
2789
 
  \sa setDefaultHighlightColor(), setHighlightColors(), highlightColors()
2790
 
*/
2791
 
QColor KDGanttView::defaultHighlightColor( KDGanttViewItem::Type type ) const
2792
 
{
2793
 
  int index = getIndex( type );
2794
 
  return myDefaultColorHL [index];
2795
 
}
2796
 
 
2797
 
 
2798
 
/*!
2799
 
  Returns the first item in the Gantt view.
2800
 
 
2801
 
  \return the first item in the Gantt view, 0 if there are no items
2802
 
*/
2803
 
KDGanttViewItem* KDGanttView::firstChild() const
2804
 
{
2805
 
    return (KDGanttViewItem*)myListView->firstChild();
2806
 
 
2807
 
}
2808
 
/*!
2809
 
  This method turns calendar mode on and off.  In calendar mode, only
2810
 
  those items can be opened which have subitems which have
2811
 
  subitems. I.e., if an item contains multiple calendars, it can be
2812
 
  opened, but not a calendar item itself.  If you want to use this
2813
 
  GanttView as a calendar view, you have to call
2814
 
  setDisplaySubitemsAsGroup( true ); to use the root items as calendar
2815
 
  items.  To create new calendar entries for these root items, create
2816
 
  a new KDGanttViewTaskItem with this root item as a parent.  If you
2817
 
  want an item with subitems to behave like a calendar (which is
2818
 
  possibly empty at startup), please call setIsCalendar( true ); for
2819
 
  this item.
2820
 
 
2821
 
  \param mode if true, the calendar view mode is turned on
2822
 
              if false, the calendar view mode is turned off
2823
 
  \sa setDisplaySubitemsAsGroup(), displaySubitemsAsGroup(), calendarMode()
2824
 
*/
2825
 
void KDGanttView::setCalendarMode( bool mode )
2826
 
{
2827
 
  myListView->setCalendarMode( mode );
2828
 
}
2829
 
 
2830
 
 
2831
 
/*!
2832
 
  Returns true, if the Gantt view is in calendar mode. See
2833
 
  setCalendarMode() for the meaning of calendar mode.
2834
 
 
2835
 
  \return returns true, if the Gantt view is in calendermode
2836
 
  \sa setCalendarMode()
2837
 
*/
2838
 
bool  KDGanttView::calendarMode() const
2839
 
{
2840
 
  return  myListView->calendarMode();
2841
 
}
2842
 
 
2843
 
 
2844
 
 
2845
 
/*!
2846
 
  This method specifies whether hidden subitems should be displayed.
2847
 
  It iterates over all KDGanttViewItems in this Gantt view
2848
 
  and sets their displaySubitemsAsGroup() property.
2849
 
  All newly created items will have this setting by default.
2850
 
  \param show if true, the hidden subitems are displayed in all items of
2851
 
         this Gantt view.
2852
 
  \sa KDGanttViewItem::setDisplaySubitemsAsGroup(), KDGanttViewItem::displaySubitemsAsGroup()
2853
 
*/
2854
 
void KDGanttView::setDisplaySubitemsAsGroup( bool show )
2855
 
{
2856
 
 QListViewItemIterator it( myListView );
2857
 
 for ( ; it.current(); ++it ) {
2858
 
   KDGanttViewItem* currentItem = ( KDGanttViewItem* )it.current();
2859
 
   currentItem->setDisplaySubitemsAsGroup( show );
2860
 
 }
2861
 
 _displaySubitemsAsGroup = show;
2862
 
}
2863
 
 
2864
 
 
2865
 
/*!
2866
 
  Returns, whether new items are created with the
2867
 
  displayHiddenSubitems property.
2868
 
  \return true, if hidden subitems should be displayed on newly created items.
2869
 
  \sa setDisplaySubitemsAsGroup(),
2870
 
  KDGanttViewItem::setDisplaySubitemsAsGroup(),
2871
 
  KDGanttViewItem::displaySubitemsAsGroup()
2872
 
*/
2873
 
bool KDGanttView::displaySubitemsAsGroup() const
2874
 
{
2875
 
  return _displaySubitemsAsGroup;
2876
 
}
2877
 
 
2878
 
 
2879
 
/*!
2880
 
  This method specifies whether tasks where the start time and the end
2881
 
  time are the same are displayed
2882
 
  as a line over the full height of the Gantt view.
2883
 
  \param show if true, tasks with starttime == endtime are displayed
2884
 
  as a line
2885
 
*/
2886
 
void KDGanttView::setDisplayEmptyTasksAsLine( bool show )
2887
 
{
2888
 
  _displayEmptyTasksAsLine = show;
2889
 
}
2890
 
 
2891
 
 
2892
 
/*!
2893
 
  Returns, whether tasks where the start time and the end time are the
2894
 
  same are displayed
2895
 
  as a line over the full height of the Gantt view.
2896
 
  \return true, if empty tasks are displayed as line.
2897
 
*/
2898
 
bool KDGanttView::displayEmptyTasksAsLine() const
2899
 
{
2900
 
  return _displayEmptyTasksAsLine;
2901
 
}
2902
 
 
2903
 
 
2904
 
/*!
2905
 
  Defines the horizontal background lines of the Gantt chart.
2906
 
  Call setHorBackgroundLines()
2907
 
  (equivalent to setHorBackgroundLines( 2, QBrush( QColor ( 240,240,240 )) ) )
2908
 
  to draw a light grey horizontal background line for every second Gantt item.
2909
 
  Call setHorBackgroundLines(0) in order to not show horizontal
2910
 
  background lines.
2911
 
  You may specify the number of lines and the brush of the lines.
2912
 
 
2913
 
  \param count for count >=  2, every count line gets a backgroud
2914
 
               specified by brush
2915
 
               for count <  2, no background lines are drawn
2916
 
  \param brush the brush of the lines
2917
 
*/
2918
 
void KDGanttView::setHorBackgroundLines( int count, QBrush brush )
2919
 
{
2920
 
  myTimeTable->setHorBackgroundLines(  count, brush );
2921
 
}
2922
 
 
2923
 
 
2924
 
/*!
2925
 
  Returns the definition of the horizontal background lines of the
2926
 
  Gantt chart.
2927
 
 
2928
 
  \param brush the brush of the lines
2929
 
  \return every nth line gets a background specified by brush
2930
 
  if 0 is returned, no backgroud lines are drawn
2931
 
 
2932
 
*/
2933
 
int KDGanttView::horBackgroundLines( QBrush& brush ) const
2934
 
{
2935
 
  return myTimeTable->horBackgroundLines( brush );
2936
 
}
2937
 
 
2938
 
 
2939
 
/*!
2940
 
  Returns the last item in the Gantt view
2941
 
 
2942
 
  \return the last item in the Gantt view, 0 if there are no items
2943
 
*/
2944
 
KDGanttViewItem* KDGanttView::lastItem() const
2945
 
{
2946
 
    return (KDGanttViewItem*)myListView->lastItem ();
2947
 
}
2948
 
 
2949
 
 
2950
 
/*!
2951
 
  Returns the list of task links in the Gantt view.
2952
 
 
2953
 
  \return the list of task links in the Gantt view
2954
 
*/
2955
 
QPtrList<KDGanttViewTaskLink> KDGanttView::taskLinks() const
2956
 
{
2957
 
    QPtrList<KDGanttViewTaskLink> retVal = myTimeTable->taskLinks();
2958
 
    return retVal;
2959
 
}
2960
 
 
2961
 
 
2962
 
/*!
2963
 
  Returns the list of task link groups in the Gantt view.
2964
 
 
2965
 
  \return the list of task link groups in the Gantt view
2966
 
*/
2967
 
QPtrList<KDGanttViewTaskLinkGroup> KDGanttView::taskLinkGroups() const
2968
 
{
2969
 
    return myTaskLinkGroupList;
2970
 
}
2971
 
 
2972
 
 
2973
 
/**
2974
 
   Reads the parameters of the view from an XML document.
2975
 
   \param doc the XML document to read from
2976
 
   \return true if the parameters could be read, false if a file
2977
 
   format error occurred
2978
 
   \sa saveXML
2979
 
*/
2980
 
bool KDGanttView::loadXML( const QDomDocument& doc )
2981
 
{
2982
 
    bool block = getUpdateEnabled();
2983
 
    setUpdateEnabled( false );
2984
 
    QDomElement docRoot = doc.documentElement(); // ChartParams element
2985
 
    QDomNode node = docRoot.firstChild();
2986
 
    while( !node.isNull() ) {
2987
 
        QDomElement element = node.toElement();
2988
 
        if( !element.isNull() ) { // was really an element
2989
 
            QString tagName = element.tagName();
2990
 
            if( tagName == "ShowLegend" ) {
2991
 
                bool value;
2992
 
                if( KDGanttXML::readBoolNode( element, value ) )
2993
 
                    setShowLegend( value );
2994
 
            } else if( tagName == "ShowLegendButton" ) {
2995
 
                bool value;
2996
 
                if( KDGanttXML::readBoolNode( element, value ) )
2997
 
                    setShowLegendButton( value );
2998
 
            } else if( tagName == "LegendIsDockWindow" ) {
2999
 
                bool value;
3000
 
                if( KDGanttXML::readBoolNode( element, value ) )
3001
 
                    setLegendIsDockwindow( value );
3002
 
            } else if( tagName == "ShowListView" ) {
3003
 
                bool value;
3004
 
                if( KDGanttXML::readBoolNode( element, value ) )
3005
 
                    setShowListView( value );
3006
 
            } else if( tagName == "ShowHeader" ) {
3007
 
                bool value;
3008
 
                if( KDGanttXML::readBoolNode( element, value ) )
3009
 
                    setHeaderVisible( value );
3010
 
            } else if( tagName == "ShowTaskLinks" ) {
3011
 
                bool value;
3012
 
                if( KDGanttXML::readBoolNode( element, value ) )
3013
 
                    setShowTaskLinks( value );
3014
 
            } else if( tagName == "EditorEnabled" ) {
3015
 
                bool value;
3016
 
                if( KDGanttXML::readBoolNode( element, value ) )
3017
 
                    setEditorEnabled( value );
3018
 
            } else if( tagName == "DisplayEmptyTasksAsLine" ) {
3019
 
                bool value;
3020
 
                if( KDGanttXML::readBoolNode( element, value ) )
3021
 
                    setDisplayEmptyTasksAsLine( value );
3022
 
            } else if( tagName == "GlobalFont" ) {
3023
 
                QFont font;
3024
 
                if( KDGanttXML::readFontNode( element, font ) )
3025
 
                    setFont( font );
3026
 
            } else if( tagName == "HorizonStart" ) {
3027
 
                QDateTime value;
3028
 
                if( KDGanttXML::readDateTimeNode( element, value ) )
3029
 
                    setHorizonStart( value );
3030
 
            } else if( tagName == "HorizonEnd" ) {
3031
 
                QDateTime value;
3032
 
                if( KDGanttXML::readDateTimeNode( element, value ) )
3033
 
                    setHorizonEnd( value );
3034
 
            } else if( tagName == "Scale" ) {
3035
 
                QString value;
3036
 
                if( KDGanttXML::readStringNode( element, value ) )
3037
 
                    setScale( stringToScale( value ) );
3038
 
            } else if( tagName == "MinimumScale" ) {
3039
 
                QString value;
3040
 
                if( KDGanttXML::readStringNode( element, value ) )
3041
 
                    setMinimumScale( stringToScale( value ) );
3042
 
            } else if( tagName == "MaximumScale" ) {
3043
 
                QString value;
3044
 
                if( KDGanttXML::readStringNode( element, value ) )
3045
 
                    setMaximumScale( stringToScale( value ) );
3046
 
            } else if( tagName == "YearFormat" ) {
3047
 
                QString value;
3048
 
                if( KDGanttXML::readStringNode( element, value ) )
3049
 
                    setYearFormat( stringToYearFormat( value ) );
3050
 
            } else if( tagName == "HourFormat" ) {
3051
 
                QString value;
3052
 
                if( KDGanttXML::readStringNode( element, value ) )
3053
 
                    setHourFormat( stringToHourFormat( value ) );
3054
 
            } else if( tagName == "ShowMinorTicks" ) {
3055
 
                bool value;
3056
 
                if( KDGanttXML::readBoolNode( element, value ) ) {
3057
 
                  if ( value ) setShowTicks( ShowMinorTicks );
3058
 
                }
3059
 
            } else if( tagName == "ShowMajorTicks" ) {
3060
 
                bool value;
3061
 
                if( KDGanttXML::readBoolNode( element, value ) ) {
3062
 
                  if ( value ) setShowTicks( ShowMajorTicks );
3063
 
                }
3064
 
            } else if( tagName == "ShowTicks" ) {
3065
 
                int value;
3066
 
                if( KDGanttXML::readIntNode( element, value ) )
3067
 
                    setShowTicks( (ShowTicksType)value );
3068
 
            } else if( tagName == "DragEnabled" ) {
3069
 
                bool value;
3070
 
                if( KDGanttXML::readBoolNode( element, value ) )
3071
 
                    setDragEnabled( value );
3072
 
            } else if( tagName == "DropEnabled" ) {
3073
 
                bool value;
3074
 
                if( KDGanttXML::readBoolNode( element, value ) )
3075
 
                    setDropEnabled( value );
3076
 
            }  else if( tagName == "TickcountForTimeline" ) {
3077
 
                int value;
3078
 
                if( KDGanttXML::readIntNode( element, value ) )
3079
 
                    setAddTickcountForTimeline( value );
3080
 
            } else if( tagName == "DisplaySubitemsAsGroup" ) {
3081
 
                bool value;
3082
 
                if( KDGanttXML::readBoolNode( element, value ) )
3083
 
                    _displaySubitemsAsGroup = value;
3084
 
            } else if( tagName == "WeekScaleShowNumber" ) {
3085
 
                bool value;
3086
 
                if( KDGanttXML::readBoolNode( element, value ) )
3087
 
                    setWeekScaleShowNumber( value );
3088
 
            } else if( tagName == "WeekStartsMonday" ) {
3089
 
                bool value;
3090
 
                if( KDGanttXML::readBoolNode( element, value ) )
3091
 
                    setWeekStartsMonday( value );
3092
 
            } else if( tagName == "UserHorizonChangeEnabled" ) {
3093
 
                bool value;
3094
 
                if( KDGanttXML::readBoolNode( element, value ) )
3095
 
                    setUserHorizonChangeEnabled( value );
3096
 
            } else if( tagName == "TimeHeaderDatetimeFormatHour" ) {
3097
 
                QString value;
3098
 
                if( KDGanttXML::readStringNode( element, value ) )
3099
 
                    setTimeHeaderDatetimeFormatHour( value );
3100
 
            } else if( tagName == "TimeHeaderDatetimeFormatSecond" ) {
3101
 
                QString value;
3102
 
                if( KDGanttXML::readStringNode( element, value ) )
3103
 
                    setTimeHeaderDatetimeFormatSecond( value );
3104
 
            } else if( tagName == "TimeHeaderDatetimeFormatMinute" ) {
3105
 
                QString value;
3106
 
                if( KDGanttXML::readStringNode( element, value ) )
3107
 
                    setTimeHeaderDatetimeFormatMinute( value );
3108
 
            } else if( tagName == "TimeHeaderDateFormatDay" ) {
3109
 
                QString value;
3110
 
                if( KDGanttXML::readStringNode( element, value ) )
3111
 
                    setTimeHeaderDateFormatDay( value );
3112
 
            } else if( tagName == "TimeHeaderDateFormatWeek" ) {
3113
 
                QString value;
3114
 
                if( KDGanttXML::readStringNode( element, value ) )
3115
 
                    setTimeHeaderDateFormatWeek( value );
3116
 
            } else if( tagName == "TimeHeaderDateFormatMonth" ) {
3117
 
                QString value;
3118
 
                if( KDGanttXML::readStringNode( element, value ) )
3119
 
                    setTimeHeaderDateFormatMonth( value );
3120
 
            } else if( tagName == "TimeHeaderTooltipDateTimeFormat" ) {
3121
 
                QString value;
3122
 
                if( KDGanttXML::readStringNode( element, value ) )
3123
 
                    setTimeHeaderTooltipDateTimeFormat( value );
3124
 
            } else if( tagName == "CalendarMode" ) {
3125
 
                bool value;
3126
 
                if( KDGanttXML::readBoolNode( element, value ) )
3127
 
                    setCalendarMode( value );
3128
 
            } else if( tagName == "Editable" ) {
3129
 
                bool value;
3130
 
                if( KDGanttXML::readBoolNode( element, value ) )
3131
 
                    setEditable( value );
3132
 
            } else if( tagName == "TextColor" ) {
3133
 
                QColor value;
3134
 
                if( KDGanttXML::readColorNode( element, value ) )
3135
 
                    setTextColor( value );
3136
 
            } else if( tagName == "MajorScaleCount" ) {
3137
 
                int value;
3138
 
                if( KDGanttXML::readIntNode( element, value ) )
3139
 
                    setMajorScaleCount( value );
3140
 
            } else if( tagName == "MinorScaleCount" ) {
3141
 
                int value;
3142
 
                if( KDGanttXML::readIntNode( element, value ) )
3143
 
                    setMinorScaleCount( value );
3144
 
            } else if( tagName == "AutoScaleMinorTickCount" ) {
3145
 
                int value;
3146
 
                if( KDGanttXML::readIntNode( element, value ) )
3147
 
                    setAutoScaleMinorTickCount( value );
3148
 
            } else if( tagName == "MinimumColumnWidth" ) {
3149
 
                int value;
3150
 
                if( KDGanttXML::readIntNode( element, value ) )
3151
 
                    setMinimumColumnWidth( value );
3152
 
            } else if( tagName == "GanttMaximumWidth" ) {
3153
 
                int value;
3154
 
                if( KDGanttXML::readIntNode( element, value ) )
3155
 
                    setGanttMaximumWidth( value );
3156
 
            } else if( tagName == "Backgroundlines" ) {
3157
 
                QBrush value;
3158
 
                int linecount = 0;
3159
 
                QDomNode node = element.firstChild();
3160
 
                while( !node.isNull() ) {
3161
 
                    QDomElement element = node.toElement();
3162
 
                    if( !element.isNull() ) {
3163
 
                        QString tagName = element.tagName();
3164
 
                        if( tagName == "BackGroundBrush" )
3165
 
                            KDGanttXML::readBrushNode( element, value );
3166
 
                        else if( tagName == "LineCount" )
3167
 
                            KDGanttXML::readIntNode( element, linecount );
3168
 
                    }
3169
 
                    node = node.nextSibling();
3170
 
                }
3171
 
                if ( linecount )
3172
 
                    setHorBackgroundLines( linecount, value );
3173
 
            } else if( tagName == "NoInformationBrush" ) {
3174
 
                QBrush value;
3175
 
                if( KDGanttXML::readBrushNode( element, value ) )
3176
 
                    setNoInformationBrush( value );
3177
 
            } else if( tagName == "GanttViewBackgroundColor" ) {
3178
 
                QColor value;
3179
 
                if( KDGanttXML::readColorNode( element, value ) )
3180
 
                    setGvBackgroundColor( value );
3181
 
            } else if( tagName == "ListViewBackgroundColor" ) {
3182
 
                QColor value;
3183
 
                if( KDGanttXML::readColorNode( element, value ) )
3184
 
                    setLvBackgroundColor( value );
3185
 
            } else if( tagName == "TimeHeaderBackgroundColor" ) {
3186
 
                QColor value;
3187
 
                if( KDGanttXML::readColorNode( element, value ) )
3188
 
                    setTimeHeaderBackgroundColor( value );
3189
 
            } else if( tagName == "LegendHeaderBackgroundColor" ) {
3190
 
                QColor value;
3191
 
                if( KDGanttXML::readColorNode( element, value ) )
3192
 
                    setLegendHeaderBackgroundColor( value );
3193
 
            } else if( tagName == "WeekendBackgroundColor" ) {
3194
 
                QColor value;
3195
 
                if( KDGanttXML::readColorNode( element, value ) )
3196
 
                    setWeekendBackgroundColor( value );
3197
 
            } else if( tagName == "WeekdayBackgroundColor" ) {
3198
 
                QDomNode node = element.firstChild();
3199
 
                int day = 0;
3200
 
                QColor color;
3201
 
                while( !node.isNull() ) {
3202
 
                    QDomElement element = node.toElement();
3203
 
                    if( !element.isNull() ) { // was really an elemente
3204
 
                        QString tagName = element.tagName();
3205
 
                        if( tagName == "Day" ) {
3206
 
                            int value;
3207
 
                            if( KDGanttXML::readIntNode( element, value ) )
3208
 
                                day = value;
3209
 
                        } else if( tagName == "Color" ) {
3210
 
                            QColor value;
3211
 
                            if( KDGanttXML::readColorNode( element, value ) )
3212
 
                                color = value;
3213
 
                        } else {
3214
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3215
 
                            Q_ASSERT( false );
3216
 
                        }
3217
 
                    }
3218
 
                    node = node.nextSibling();
3219
 
                }
3220
 
 
3221
 
                if( day && color.isValid() )
3222
 
                    setWeekdayBackgroundColor( color, day );
3223
 
            } else if( tagName == "WeekendDays" ) {
3224
 
                QString startString = element.attribute( "Start" );
3225
 
                QString endString = element.attribute( "End" );
3226
 
                bool startOk = false, endOk = false;
3227
 
                int start = startString.toInt( &startOk );
3228
 
                int end = startString.toInt( &endOk );
3229
 
                if( startOk && endOk )
3230
 
                    setWeekendDays( start, end );
3231
 
            } else if( tagName == "ZoomFactor" ) {
3232
 
                double value;
3233
 
                if( KDGanttXML::readDoubleNode( element, value ) )
3234
 
                    setZoomFactor( value, true );
3235
 
            } else if( tagName == "ShowHeaderPopupMenu" ) {
3236
 
                bool value;
3237
 
                if( KDGanttXML::readBoolNode( element, value ) )
3238
 
                    setShowHeaderPopupMenu( value );
3239
 
            } else if( tagName == "ShowTimeTablePopupMenu" ) {
3240
 
                bool value;
3241
 
                if( KDGanttXML::readBoolNode( element, value ) )
3242
 
                    setShowTimeTablePopupMenu( value );
3243
 
            } else if( tagName == "Shapes" ) {
3244
 
                QDomNode node = element.firstChild();
3245
 
                bool undefinedShape = false;
3246
 
                while( !node.isNull() ) {
3247
 
                    QDomElement element = node.toElement();
3248
 
                    if( !element.isNull() ) { // was really an elemente
3249
 
                        QString tagName = element.tagName();
3250
 
                        if( tagName == "Event" ) {
3251
 
                            KDGanttViewItem::Shape startShape, middleShape, endShape;
3252
 
                            startShape = KDGanttViewItem::TriangleDown;
3253
 
                            middleShape = KDGanttViewItem::TriangleDown;
3254
 
                            endShape = KDGanttViewItem::TriangleDown;
3255
 
                            QDomNode node = element.firstChild();
3256
 
                            while( !node.isNull() ) {
3257
 
                                QDomElement element = node.toElement();
3258
 
                                if( !element.isNull() ) { // was really an elemente
3259
 
                                    QString tagName = element.tagName();
3260
 
                                    if( tagName == "Start" ) {
3261
 
                                        QString value;
3262
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3263
 
                                            startShape = KDGanttViewItem::stringToShape( value );
3264
 
                                        if ( value == "Undefined" )
3265
 
                                            undefinedShape = true;
3266
 
                                    } else if( tagName == "Middle" ) {
3267
 
                                        QString value;
3268
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3269
 
                                            middleShape = KDGanttViewItem::stringToShape( value );
3270
 
                                        if ( value == "Undefined" )
3271
 
                                            undefinedShape = true;
3272
 
                                    } else if( tagName == "End" ) {
3273
 
                                        QString value;
3274
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3275
 
                                            endShape = KDGanttViewItem::stringToShape( value );
3276
 
                                        if ( value == "Undefined" )
3277
 
                                            undefinedShape = true;
3278
 
                                    } else {
3279
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3280
 
                                        Q_ASSERT( false );
3281
 
                                    }
3282
 
                                }
3283
 
                                node = node.nextSibling();
3284
 
                            }
3285
 
                            if ( ! undefinedShape )
3286
 
                                setShapes( KDGanttViewItem::Event, startShape,
3287
 
                                           middleShape, endShape, false );
3288
 
                            undefinedShape = false;
3289
 
                        } else if( tagName == "Task" ) {
3290
 
                            KDGanttViewItem::Shape startShape, middleShape, endShape;
3291
 
                            startShape = KDGanttViewItem::TriangleDown;
3292
 
                            middleShape = KDGanttViewItem::TriangleDown;
3293
 
                            endShape = KDGanttViewItem::TriangleDown;
3294
 
                            QDomNode node = element.firstChild();
3295
 
                            while( !node.isNull()) {
3296
 
                                QDomElement element = node.toElement();
3297
 
                                if( !element.isNull() ) { // was really an elemente
3298
 
                                    QString tagName = element.tagName();
3299
 
                                    if( tagName == "Start" ) {
3300
 
                                        QString value;
3301
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3302
 
                                            startShape = KDGanttViewItem::stringToShape( value );
3303
 
                                        if ( value == "Undefined" )
3304
 
                                            undefinedShape = true;
3305
 
                                    } else if( tagName == "Middle" ) {
3306
 
                                        QString value;
3307
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3308
 
                                            middleShape = KDGanttViewItem::stringToShape( value );
3309
 
                                        if ( value == "Undefined" )
3310
 
                                            undefinedShape = true;
3311
 
                                    } else if( tagName == "End" ) {
3312
 
                                        QString value;
3313
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3314
 
                                            endShape = KDGanttViewItem::stringToShape( value );
3315
 
                                        if ( value == "Undefined" )
3316
 
                                            undefinedShape = true;
3317
 
                                    } else {
3318
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3319
 
                                        Q_ASSERT( false );
3320
 
                                    }
3321
 
                                }
3322
 
                                node = node.nextSibling();
3323
 
                            }
3324
 
                            if ( ! undefinedShape )
3325
 
                                setShapes( KDGanttViewItem::Task, startShape, middleShape, endShape, false );
3326
 
                            undefinedShape = false;
3327
 
                        } else if( tagName == "Summary" ) {
3328
 
                            KDGanttViewItem::Shape startShape, middleShape, endShape;
3329
 
                            startShape = KDGanttViewItem::TriangleDown;
3330
 
                            middleShape = KDGanttViewItem::TriangleDown;
3331
 
                            endShape = KDGanttViewItem::TriangleDown;
3332
 
                            QDomNode node = element.firstChild();
3333
 
                            while( !node.isNull() ) {
3334
 
                                QDomElement element = node.toElement();
3335
 
                                if( !element.isNull() ) { // was really an elemente
3336
 
                                    QString tagName = element.tagName();
3337
 
                                    if( tagName == "Start" ) {
3338
 
                                        QString value;
3339
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3340
 
                                            startShape = KDGanttViewItem::stringToShape( value );
3341
 
                                        if ( value == "Undefined" )
3342
 
                                            undefinedShape = true;
3343
 
                                    } else if( tagName == "Middle" ) {
3344
 
                                        QString value;
3345
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3346
 
                                            middleShape = KDGanttViewItem::stringToShape( value );
3347
 
                                        if ( value == "Undefined" )
3348
 
                                            undefinedShape = true;
3349
 
                                    } else if( tagName == "End" ) {
3350
 
                                        QString value;
3351
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3352
 
                                            endShape = KDGanttViewItem::stringToShape( value );
3353
 
                                        if ( value == "Undefined" )
3354
 
                                            undefinedShape = true;
3355
 
                                    } else {
3356
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3357
 
                                        Q_ASSERT( false );
3358
 
                                    }
3359
 
                                }
3360
 
                                node = node.nextSibling();
3361
 
                            }
3362
 
                            if ( ! undefinedShape )
3363
 
                                setShapes( KDGanttViewItem::Summary, startShape,
3364
 
                                           middleShape, endShape, false );
3365
 
                            undefinedShape = false;
3366
 
                        } else {
3367
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3368
 
                            Q_ASSERT( false );
3369
 
                        }
3370
 
                    }
3371
 
                    node = node.nextSibling();
3372
 
                }
3373
 
            } else if( tagName == "Colors" ) {
3374
 
                QDomNode node = element.firstChild();
3375
 
                while( !node.isNull()) {
3376
 
                    QDomElement element = node.toElement();
3377
 
                    if( !element.isNull() ) { // was really an elemente
3378
 
                        QString tagName = element.tagName();
3379
 
                        if( tagName == "Event" ) {
3380
 
                            QColor startColor, middleColor, endColor;
3381
 
                            QDomNode node = element.firstChild();
3382
 
                            while( !node.isNull() ) {
3383
 
                                QDomElement element = node.toElement();
3384
 
                                if( !element.isNull() ) { // was really an elemente
3385
 
                                    QString tagName = element.tagName();
3386
 
                                    if( tagName == "Start" ) {
3387
 
                                        QColor value;
3388
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3389
 
                                            startColor = value;
3390
 
                                    } else if( tagName == "Middle" ) {
3391
 
                                        QColor value;
3392
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3393
 
                                            middleColor = value;
3394
 
                                    } else if( tagName == "End" ) {
3395
 
                                        QColor value;
3396
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3397
 
                                            endColor = value;
3398
 
                                    } else {
3399
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3400
 
                                        Q_ASSERT( false );
3401
 
                                    }
3402
 
                                }
3403
 
                                node = node.nextSibling();
3404
 
                            }
3405
 
                            setColors( KDGanttViewItem::Event, startColor,
3406
 
                                       middleColor, endColor, false );
3407
 
                        } else if( tagName == "Task" ) {
3408
 
                            QColor startColor, middleColor, endColor;
3409
 
                            QDomNode node = element.firstChild();
3410
 
                            while( !node.isNull() ) {
3411
 
                                QDomElement element = node.toElement();
3412
 
                                if( !element.isNull() ) { // was really an elemente
3413
 
                                    QString tagName = element.tagName();
3414
 
                                    if( tagName == "Start" ) {
3415
 
                                        QColor value;
3416
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3417
 
                                            startColor = value;
3418
 
                                    } else if( tagName == "Middle" ) {
3419
 
                                        QColor value;
3420
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3421
 
                                            middleColor = value;
3422
 
                                    } else if( tagName == "End" ) {
3423
 
                                        QColor value;
3424
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3425
 
                                            endColor = value;
3426
 
                                    } else {
3427
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3428
 
                                        Q_ASSERT( false );
3429
 
                                    }
3430
 
                                }
3431
 
                                node = node.nextSibling();
3432
 
                            }
3433
 
                            setColors( KDGanttViewItem::Task, startColor,
3434
 
                                       middleColor, endColor, false );
3435
 
                        } else if( tagName == "Summary" ) {
3436
 
                            QColor startColor, middleColor, endColor;
3437
 
                            QDomNode node = element.firstChild();
3438
 
                            while( !node.isNull() ) {
3439
 
                                QDomElement element = node.toElement();
3440
 
                                if( !element.isNull() ) { // was really an elemente
3441
 
                                    QString tagName = element.tagName();
3442
 
                                    if( tagName == "Start" ) {
3443
 
                                        QColor value;
3444
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3445
 
                                            startColor = value;
3446
 
                                    } else if( tagName == "Middle" ) {
3447
 
                                        QColor value;
3448
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3449
 
                                            middleColor = value;
3450
 
                                    } else if( tagName == "End" ) {
3451
 
                                        QColor value;
3452
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3453
 
                                            endColor = value;
3454
 
                                    } else {
3455
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3456
 
                                        Q_ASSERT( false );
3457
 
                                    }
3458
 
                                }
3459
 
                                node = node.nextSibling();
3460
 
                            }
3461
 
                            setColors( KDGanttViewItem::Summary, startColor,
3462
 
                                       middleColor, endColor , false);
3463
 
                        } else {
3464
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3465
 
                            Q_ASSERT( false );
3466
 
                        }
3467
 
                    }
3468
 
                    node = node.nextSibling();
3469
 
                }
3470
 
            } else if( tagName == "DefaultColors" ) {
3471
 
                QDomNode node = element.firstChild();
3472
 
                while( !node.isNull() ) {
3473
 
                    QDomElement element = node.toElement();
3474
 
                    if( !element.isNull() ) { // was really an element
3475
 
                        QString tagName = element.tagName();
3476
 
                        if( tagName == "Event" ) {
3477
 
                            QColor value;
3478
 
                            if( KDGanttXML::readColorNode( element, value ) )
3479
 
                                setDefaultColor( KDGanttViewItem::Event,
3480
 
                                                 value, false );
3481
 
                        } else if( tagName == "Task" ) {
3482
 
                            QColor value;
3483
 
                            if( KDGanttXML::readColorNode( element, value ) )
3484
 
                                setDefaultColor( KDGanttViewItem::Task,
3485
 
                                                 value, false );
3486
 
                        } else if( tagName == "Summary" ) {
3487
 
                            QColor value;
3488
 
                            if( KDGanttXML::readColorNode( element, value ) )
3489
 
                                setDefaultColor( KDGanttViewItem::Summary,
3490
 
                                                 value , false);
3491
 
                        } else {
3492
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3493
 
                            Q_ASSERT( false );
3494
 
                        }
3495
 
                    }
3496
 
 
3497
 
                    node = node.nextSibling();
3498
 
                }
3499
 
            } else if( tagName == "HighlightColors" ) {
3500
 
                QDomNode node = element.firstChild();
3501
 
                while( !node.isNull() ) {
3502
 
                    QDomElement element = node.toElement();
3503
 
                    if( !element.isNull() ) { // was really an elemente
3504
 
                        QString tagName = element.tagName();
3505
 
                        if( tagName == "Event" ) {
3506
 
                            QColor startColor, middleColor, endColor;
3507
 
                            QDomNode node = element.firstChild();
3508
 
                            while( !node.isNull() ) {
3509
 
                                QDomElement element = node.toElement();
3510
 
                                if( !element.isNull() ) { // was really an elemente
3511
 
                                    QString tagName = element.tagName();
3512
 
                                    if( tagName == "Start" ) {
3513
 
                                        QColor value;
3514
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3515
 
                                            startColor = value;
3516
 
                                    } else if( tagName == "Middle" ) {
3517
 
                                        QColor value;
3518
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3519
 
                                            middleColor = value;
3520
 
                                    } else if( tagName == "End" ) {
3521
 
                                        QColor value;
3522
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3523
 
                                            endColor = value;
3524
 
                                    } else {
3525
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3526
 
                                        Q_ASSERT( false );
3527
 
                                    }
3528
 
                                }
3529
 
                                node = node.nextSibling();
3530
 
                            }
3531
 
                            setHighlightColors( KDGanttViewItem::Event,
3532
 
                                                startColor,
3533
 
                                                middleColor, endColor, false );
3534
 
                        } else if( tagName == "Task" ) {
3535
 
                            QColor startColor, middleColor, endColor;
3536
 
                            QDomNode node = element.firstChild();
3537
 
                            while( !node.isNull() ) {
3538
 
                                QDomElement element = node.toElement();
3539
 
                                if( !element.isNull() ) { // was really an elemente
3540
 
                                    QString tagName = element.tagName();
3541
 
                                    if( tagName == "Start" ) {
3542
 
                                        QColor value;
3543
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3544
 
                                            startColor = value;
3545
 
                                    } else if( tagName == "Middle" ) {
3546
 
                                        QColor value;
3547
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3548
 
                                            middleColor = value;
3549
 
                                    } else if( tagName == "End" ) {
3550
 
                                        QColor value;
3551
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3552
 
                                            endColor = value;
3553
 
                                    } else {
3554
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3555
 
                                        Q_ASSERT( false );
3556
 
                                    }
3557
 
                                }
3558
 
                                node = node.nextSibling();
3559
 
                            }
3560
 
                            setHighlightColors( KDGanttViewItem::Task,
3561
 
                                                startColor,
3562
 
                                                middleColor, endColor , false);
3563
 
                        } else if( tagName == "Summary" ) {
3564
 
                            QColor startColor, middleColor, endColor;
3565
 
                            QDomNode node = element.firstChild();
3566
 
                            while( !node.isNull() ) {
3567
 
                                QDomElement element = node.toElement();
3568
 
                                if( !element.isNull() ) { // was really an elemente
3569
 
                                    QString tagName = element.tagName();
3570
 
                                    if( tagName == "Start" ) {
3571
 
                                        QColor value;
3572
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3573
 
                                            startColor = value;
3574
 
                                    } else if( tagName == "Middle" ) {
3575
 
                                        QColor value;
3576
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3577
 
                                            middleColor = value;
3578
 
                                    } else if( tagName == "End" ) {
3579
 
                                        QColor value;
3580
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3581
 
                                            endColor = value;
3582
 
                                    } else {
3583
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3584
 
                                        Q_ASSERT( false );
3585
 
                                    }
3586
 
                                }
3587
 
                                node = node.nextSibling();
3588
 
                            }
3589
 
                            setHighlightColors( KDGanttViewItem::Summary,
3590
 
                                                startColor,
3591
 
                                                middleColor, endColor, false );
3592
 
                        } else {
3593
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3594
 
                            Q_ASSERT( false );
3595
 
                        }
3596
 
                    }
3597
 
                    node = node.nextSibling();
3598
 
                }
3599
 
            } else if( tagName == "DefaultHighlightColors" ) {
3600
 
                QDomNode node = element.firstChild();
3601
 
                while( !node.isNull() ) {
3602
 
                    QDomElement element = node.toElement();
3603
 
                    if( !element.isNull() ) { // was really an element
3604
 
                        QString tagName = element.tagName();
3605
 
                        if( tagName == "Event" ) {
3606
 
                            QColor value;
3607
 
                            if( KDGanttXML::readColorNode( element, value ) )
3608
 
                                setDefaultHighlightColor( KDGanttViewItem::Event,
3609
 
                                                          value , false);
3610
 
                        } else if( tagName == "Task" ) {
3611
 
                            QColor value;
3612
 
                            if( KDGanttXML::readColorNode( element, value ) )
3613
 
                                setDefaultHighlightColor( KDGanttViewItem::Task,
3614
 
                                                          value, false );
3615
 
                        } else if( tagName == "Summary" ) {
3616
 
                            QColor value;
3617
 
                            if( KDGanttXML::readColorNode( element, value ) )
3618
 
                                setDefaultHighlightColor( KDGanttViewItem::Summary,
3619
 
                                                          value, false );
3620
 
                        } else {
3621
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3622
 
                            Q_ASSERT( false );
3623
 
                        }
3624
 
                    }
3625
 
 
3626
 
                    node = node.nextSibling();
3627
 
                }
3628
 
            } else if( tagName == "Items" ) {
3629
 
                QDomNode node = element.firstChild();
3630
 
                KDGanttViewItem* previous = 0;
3631
 
                while( !node.isNull() ) {
3632
 
                    QDomElement element = node.toElement();
3633
 
                    if( !element.isNull() ) { // was really an element
3634
 
                        QString tagName = element.tagName();
3635
 
                        if( tagName == "Item" ) {
3636
 
                            KDGanttViewItem* newItem;
3637
 
                            if( previous )
3638
 
                                newItem =
3639
 
                                    KDGanttViewItem::createFromDomElement( this,
3640
 
                                                                           previous,
3641
 
                                                                           element );
3642
 
                            else
3643
 
                                newItem =
3644
 
                                    KDGanttViewItem::createFromDomElement( this,
3645
 
                                                                           element );
3646
 
                            if ( newItem )
3647
 
                                previous = newItem;
3648
 
                        } else {
3649
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3650
 
                            Q_ASSERT( false );
3651
 
                        }
3652
 
                    }
3653
 
 
3654
 
                    node = node.nextSibling();
3655
 
                }
3656
 
            } else if( tagName == "TaskLinks" ) {
3657
 
                QDomNode node = element.firstChild();
3658
 
                while( !node.isNull() ) {
3659
 
                    QDomElement element = node.toElement();
3660
 
                    if( !element.isNull() ) { // was really an element
3661
 
                        QString tagName = element.tagName();
3662
 
                        if( tagName == "TaskLink" )
3663
 
                            KDGanttViewTaskLink::createFromDomElement( element );
3664
 
                        else {
3665
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3666
 
                            Q_ASSERT( false );
3667
 
                        }
3668
 
                    }
3669
 
 
3670
 
                    node = node.nextSibling();
3671
 
                }
3672
 
            } else if( tagName == "TaskLinkGroups" ) {
3673
 
                QDomNode node = element.firstChild();
3674
 
                while( !node.isNull() ) {
3675
 
                    QDomElement element = node.toElement();
3676
 
                    if( !element.isNull() ) { // was really an element
3677
 
                        QString tagName = element.tagName();
3678
 
                        if( tagName == "TaskLinkGroup" )
3679
 
                            KDGanttViewTaskLinkGroup::createFromDomElement( element );
3680
 
                    } else {
3681
 
                        qDebug() << "Unrecognized tag name: " << tagName;
3682
 
                        Q_ASSERT( false );
3683
 
                    }
3684
 
 
3685
 
                    node = node.nextSibling();
3686
 
                }
3687
 
            } else if( tagName == "ColumnBackgroundColors" ) {
3688
 
                QDomNode node = element.firstChild();
3689
 
                while( !node.isNull() ) {
3690
 
                    QDomElement element = node.toElement();
3691
 
                    if( !element.isNull() ) { // was really an element
3692
 
                        QString tagName = element.tagName();
3693
 
                        if( tagName == "ColumnBackgroundColor" ) {
3694
 
                            QDomNode node = element.firstChild();
3695
 
                            QDateTime dateTime;
3696
 
                            QColor color;
3697
 
                            Scale mini = Minute;
3698
 
                            Scale maxi = Month;
3699
 
                            while( !node.isNull() ) {
3700
 
                                QDomElement element = node.toElement();
3701
 
                                if( !element.isNull() ) { // was
3702
 
                                    // really an
3703
 
                                    // element
3704
 
                                    QString tagName = element.tagName();
3705
 
                                    if( tagName == "DateTime" ) {
3706
 
                                        QDateTime value;
3707
 
                                        if( KDGanttXML::readDateTimeNode( element, value ) )
3708
 
                                            dateTime = value;
3709
 
                                    } else if( tagName == "Color" ) {
3710
 
                                        QColor value;
3711
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3712
 
                                            color = value;
3713
 
                                    } else if( tagName == "MinScale" ) {
3714
 
                                        QString value;
3715
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3716
 
                                            mini = stringToScale( value );
3717
 
                                    } else if( tagName == "MaxScale" ) {
3718
 
                                        QString value;
3719
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3720
 
                                            maxi = stringToScale( value );
3721
 
                                    } else {
3722
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3723
 
                                        Q_ASSERT( false );
3724
 
                                    }
3725
 
                                }
3726
 
 
3727
 
                                node = node.nextSibling();
3728
 
                            }
3729
 
                            setColumnBackgroundColor( dateTime, color, mini, maxi );
3730
 
                        } else {
3731
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3732
 
                            Q_ASSERT( false );
3733
 
                        }
3734
 
                    }
3735
 
                    node = node.nextSibling();
3736
 
                }
3737
 
            } else if( tagName == "IntervalBackgroundColors" ) {
3738
 
                QDomNode node = element.firstChild();
3739
 
                while( !node.isNull() ) {
3740
 
                    QDomElement element = node.toElement();
3741
 
                    if( !element.isNull() ) { // was really an element
3742
 
                        QString tagName = element.tagName();
3743
 
                        if( tagName == "IntervalBackgroundColor" ) {
3744
 
                            QDomNode node = element.firstChild();
3745
 
                            QDateTime dateTime;
3746
 
                            QDateTime ente;
3747
 
                            QColor color;
3748
 
                            Scale mini = Minute;
3749
 
                            Scale maxi = Month;
3750
 
                            int prio = 0;
3751
 
                            while( !node.isNull() ) {
3752
 
                                QDomElement element = node.toElement();
3753
 
                                if( !element.isNull() ) { // was
3754
 
                                    // really an
3755
 
                                    // element
3756
 
                                    QString tagName = element.tagName();
3757
 
                                    if( tagName == "DateTimeEnd" ) {
3758
 
                                        QDateTime value;
3759
 
                                        if( KDGanttXML::readDateTimeNode( element, value ) )
3760
 
                                            ente = value;
3761
 
                                    }  else if( tagName == "Priority" ) {
3762
 
                                        int value;
3763
 
                                        if( KDGanttXML::readIntNode( element, value ) )
3764
 
                                            prio = value;
3765
 
                                    } else if( tagName == "DateTimeStart" ) {
3766
 
                                        QDateTime value;
3767
 
                                        if( KDGanttXML::readDateTimeNode( element, value ) )
3768
 
                                            dateTime = value;
3769
 
                                    } else if( tagName == "Color" ) {
3770
 
                                        QColor value;
3771
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3772
 
                                            color = value;
3773
 
                                    } else if( tagName == "MinScale" ) {
3774
 
                                        QString value;
3775
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3776
 
                                            mini = stringToScale( value );
3777
 
                                    } else if( tagName == "MaxScale" ) {
3778
 
                                        QString value;
3779
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3780
 
                                            maxi = stringToScale( value );
3781
 
                                    } else {
3782
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3783
 
                                        Q_ASSERT( false );
3784
 
                                    }
3785
 
                                }
3786
 
                                node = node.nextSibling();
3787
 
                            }
3788
 
                            //setIntervalBackgroundColor( dateTime, ente, color, prio, mini, maxi );
3789
 
                            KDIntervalColorRectangle* icr = new KDIntervalColorRectangle( this );
3790
 
                            icr->setDateTimes( dateTime, ente );
3791
 
                            icr->setColor( color );
3792
 
                            Q_UNUSED( prio );
3793
 
                            Q_UNUSED( mini );
3794
 
                            Q_UNUSED( maxi );
3795
 
                            addIntervalBackgroundColor(icr);
3796
 
 
3797
 
                        } else {
3798
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3799
 
                            Q_ASSERT( false );
3800
 
                        }
3801
 
                    }
3802
 
                    node = node.nextSibling();
3803
 
                }
3804
 
            } else if( tagName == "LegendItems" ) {
3805
 
                QDomNode node = element.firstChild();
3806
 
                while( !node.isNull() ) {
3807
 
                    QDomElement element = node.toElement();
3808
 
                    if( !element.isNull() ) { // was really an element
3809
 
                        QString tagName = element.tagName();
3810
 
                        if( tagName == "LegendItem" ) {
3811
 
                            KDGanttViewItem::Shape tempLegendShape;
3812
 
                            tempLegendShape = KDGanttViewItem::TriangleDown;
3813
 
                            QColor tempLegendColor;
3814
 
                            QString tempLegendString;
3815
 
                            KDGanttViewItem::Shape tempLegendShape2;
3816
 
                            tempLegendShape2 = KDGanttViewItem::TriangleDown;
3817
 
                            QColor tempLegendColor2;
3818
 
                            QString tempLegendString2;
3819
 
                            bool has2 = false;
3820
 
                            bool ok = true;
3821
 
                            QDomNode node = element.firstChild();
3822
 
                            while( !node.isNull() ) {
3823
 
                                QDomElement element = node.toElement();
3824
 
                                if( !element.isNull() ) { // was really an element
3825
 
                                    QString tagName = element.tagName();
3826
 
                                    if( tagName == "Shape" ) {
3827
 
                                        QString value;
3828
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3829
 
                                            tempLegendShape = KDGanttViewItem::stringToShape( value );
3830
 
                                        else
3831
 
                                            ok = false;
3832
 
                                    } else if( tagName == "Color" ) {
3833
 
                                        QColor value;
3834
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3835
 
                                            tempLegendColor = value;
3836
 
                                        else
3837
 
                                            ok = false;
3838
 
                                    } else if( tagName == "Text" ) {
3839
 
                                        QString value;
3840
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3841
 
                                            tempLegendString = value;
3842
 
                                        else
3843
 
                                            ok = false;
3844
 
                                    } else if( tagName == "Shape2" ) {
3845
 
                                        QString value;
3846
 
                                        has2 = true;
3847
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3848
 
                                            tempLegendShape2 = KDGanttViewItem::stringToShape( value );
3849
 
                                        else
3850
 
                                            ok = false;
3851
 
                                    } else if( tagName == "Color2" ) {
3852
 
                                        QColor value;
3853
 
                                        has2 = true;
3854
 
                                        if( KDGanttXML::readColorNode( element, value ) )
3855
 
                                            tempLegendColor2 = value;
3856
 
                                        else
3857
 
                                            ok = false;
3858
 
                                    } else if( tagName == "Text2" ) {
3859
 
                                        QString value;
3860
 
                                        has2 = true;
3861
 
                                        if( KDGanttXML::readStringNode( element, value ) )
3862
 
                                            tempLegendString2 = value;
3863
 
                                        else
3864
 
                                            ok = false;
3865
 
                                    } else {
3866
 
                                        qDebug() << "Unrecognized tag name: " << tagName;
3867
 
                                        Q_ASSERT( false );
3868
 
                                    }
3869
 
                                }
3870
 
                                node = node.nextSibling();
3871
 
                            }
3872
 
                            if( ok ) {
3873
 
                                if ( has2 )
3874
 
                                    addLegendItem( tempLegendShape,
3875
 
                                                   tempLegendColor,
3876
 
                                                   tempLegendString,
3877
 
                                                   tempLegendShape2,
3878
 
                                                   tempLegendColor2,
3879
 
                                                   tempLegendString2 );
3880
 
                                else
3881
 
                                    addLegendItem( tempLegendShape,
3882
 
                                                   tempLegendColor,
3883
 
                                                   tempLegendString );
3884
 
                                //qDebug() << "Adding legend item " << tempLegendString;
3885
 
                            }
3886
 
                        } else {
3887
 
                            qDebug() << "Unrecognized tag name: " << tagName;
3888
 
                            Q_ASSERT( false );
3889
 
                        }
3890
 
                    }
3891
 
                    node = node.nextSibling();
3892
 
                }
3893
 
            } else if( tagName == "UserSavedData" ) {
3894
 
                userReadFromElement( element );
3895
 
            } else {
3896
 
                qDebug() << "Unrecognized tag name: " << tagName;
3897
 
                Q_ASSERT( false );
3898
 
            }
3899
 
        }
3900
 
 
3901
 
        node = node.nextSibling();
3902
 
    } // while
3903
 
    setUpdateEnabled( block );
3904
 
        return true; /* FIXME: Do real error-reporting. The ASSERT's should be "return false" stmnts */
3905
 
} // method
3906
 
 
3907
 
 
3908
 
/**
3909
 
   Saves the parameters of the view parameters to an XML document.
3910
 
 
3911
 
   \param withPI pass true to store processing instructions, false to
3912
 
   leave them out
3913
 
   \return the XML document that represents the parameters
3914
 
   \sa loadXML
3915
 
*/
3916
 
QDomDocument KDGanttView::saveXML( bool withPI ) const
3917
 
{
3918
 
    // Create an initial DOM document
3919
 
    QString docstart = "<GanttView/>";
3920
 
 
3921
 
    QDomDocument doc( "GanttView" );
3922
 
    doc.setContent( docstart );
3923
 
    if( withPI ) {
3924
 
        QDomProcessingInstruction pin = doc.createProcessingInstruction( "kdgantt", "version=\"1.0\" encoding=\"UTF-8\""  ) ;
3925
 
        doc.appendChild ( pin );
3926
 
    }
3927
 
 
3928
 
    QDomElement docRoot = doc.documentElement();
3929
 
    docRoot.setAttribute( "xmlns", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
3930
 
    docRoot.setAttribute( "xmlns:xsi", "http://www.w3.org/2000/10/XMLSchema-instance" );
3931
 
    docRoot.setAttribute( "xsi:schemaLocation", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
3932
 
 
3933
 
    // the ShowLegend element
3934
 
    KDGanttXML::createBoolNode( doc, docRoot, "ShowLegend", showLegend() );
3935
 
 
3936
 
    // the ShowLegendButton element
3937
 
    KDGanttXML::createBoolNode( doc, docRoot, "ShowLegendButton",
3938
 
                                showLegendButton() );
3939
 
 
3940
 
    // the LegendIsDockWindow element
3941
 
    KDGanttXML::createBoolNode( doc, docRoot, "LegendIsDockWindow",
3942
 
                                legendIsDockwindow() );
3943
 
 
3944
 
    // the ShowListView element
3945
 
    KDGanttXML::createBoolNode( doc, docRoot, "ShowListView", showListView() );
3946
 
 
3947
 
    // the ShowHeader element
3948
 
    KDGanttXML::createBoolNode( doc, docRoot, "ShowHeader", headerVisible() );
3949
 
 
3950
 
    // the ShowTaskLinks element
3951
 
    KDGanttXML::createBoolNode( doc, docRoot, "ShowTaskLinks", showTaskLinks() );
3952
 
 
3953
 
    // the EditorEnabled element
3954
 
    KDGanttXML::createBoolNode( doc, docRoot, "EditorEnabled", editorEnabled() );
3955
 
 
3956
 
    // the global font element
3957
 
    KDGanttXML::createFontNode( doc, docRoot, "GlobalFont", font() );
3958
 
 
3959
 
    // the DisplayEmptyTasksAsLine element
3960
 
    KDGanttXML::createBoolNode( doc, docRoot, "DisplayEmptyTasksAsLine",
3961
 
                                displayEmptyTasksAsLine() );
3962
 
 
3963
 
    // the HorizonStart element
3964
 
    KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonStart", horizonStart() );
3965
 
 
3966
 
    // the HorizonEnd element
3967
 
    KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonEnd", horizonEnd() );
3968
 
 
3969
 
    // the Scale, MinimumScale, MaximumScale elements
3970
 
    KDGanttXML::createStringNode( doc, docRoot, "Scale", scaleToString( scale() ) );
3971
 
    KDGanttXML::createStringNode( doc, docRoot, "MinimumScale",
3972
 
                                  scaleToString( minimumScale() ) );
3973
 
    KDGanttXML::createStringNode( doc, docRoot, "MaximumScale",
3974
 
                                  scaleToString( maximumScale() ) );
3975
 
 
3976
 
    // the YearFormat element
3977
 
    KDGanttXML::createStringNode( doc, docRoot, "YearFormat",
3978
 
                                  yearFormatToString( yearFormat() ) );
3979
 
 
3980
 
    // the HourFormat element
3981
 
    KDGanttXML::createStringNode( doc, docRoot, "HourFormat",
3982
 
                                  hourFormatToString( hourFormat() ) );
3983
 
 
3984
 
    // the ShowTicks element
3985
 
    KDGanttXML::createIntNode( doc, docRoot, "ShowTicks", showTicks() );
3986
 
 
3987
 
    // the Editable element
3988
 
    KDGanttXML::createBoolNode( doc, docRoot, "Editable", editable() );
3989
 
 
3990
 
    // the TextColor element
3991
 
    KDGanttXML::createColorNode( doc, docRoot, "TextColor", textColor() );
3992
 
 
3993
 
    // the MajorScaleCount element
3994
 
    KDGanttXML::createIntNode( doc, docRoot, "MajorScaleCount", majorScaleCount() );
3995
 
 
3996
 
    // the MinorScaleCount element
3997
 
    KDGanttXML::createIntNode( doc, docRoot, "MinorScaleCount", minorScaleCount() );
3998
 
 
3999
 
    // the AutoScaleMinorTickCount element
4000
 
    KDGanttXML::createIntNode( doc, docRoot, "AutoScaleMinorTickCount",
4001
 
                               autoScaleMinorTickCount() );
4002
 
 
4003
 
    // the MinimumColumnWidth element
4004
 
    KDGanttXML::createIntNode( doc, docRoot, "MinimumColumnWidth",
4005
 
                               minimumColumnWidth() );
4006
 
 
4007
 
    // the GanttMaximumWidth element
4008
 
    KDGanttXML::createIntNode( doc, docRoot, "GanttMaximumWidth",
4009
 
                               ganttMaximumWidth() );
4010
 
 
4011
 
    QBrush backBrush;
4012
 
    int backgroundlines = horBackgroundLines( backBrush );
4013
 
    if ( backgroundlines ) {
4014
 
        QDomElement backElement = doc.createElement( "Backgroundlines" );
4015
 
        docRoot.appendChild( backElement );
4016
 
        KDGanttXML::createBrushNode( doc, backElement, "BackGroundBrush",backBrush );
4017
 
        KDGanttXML::createIntNode( doc, backElement, "LineCount",  backgroundlines );
4018
 
    }
4019
 
    // the NoInformationBrush element
4020
 
    KDGanttXML::createBrushNode( doc, docRoot, "NoInformationBrush",
4021
 
                                 noInformationBrush() );
4022
 
 
4023
 
    // the GanttViewBackgroundColor element
4024
 
    KDGanttXML::createColorNode( doc, docRoot, "GanttViewBackgroundColor",
4025
 
                                 gvBackgroundColor() );
4026
 
 
4027
 
    // the ListViewBackgroundColor element
4028
 
    KDGanttXML::createColorNode( doc, docRoot, "ListViewBackgroundColor",
4029
 
                                 lvBackgroundColor() );
4030
 
 
4031
 
    // the TimeHeaderBackgroundColor element
4032
 
    KDGanttXML::createColorNode( doc, docRoot, "TimeHeaderBackgroundColor",
4033
 
                                 timeHeaderBackgroundColor() );
4034
 
 
4035
 
    // the LegendHeaderBackgroundColor element
4036
 
    KDGanttXML::createColorNode( doc, docRoot, "LegendHeaderBackgroundColor",
4037
 
                                 legendHeaderBackgroundColor() );
4038
 
 
4039
 
    // the WeekendBackgroundColor element
4040
 
    KDGanttXML::createColorNode( doc, docRoot, "WeekendBackgroundColor",
4041
 
                                 weekendBackgroundColor() );
4042
 
 
4043
 
    // the WeekdayBackgroundColor elements
4044
 
    for( int weekday = 1; weekday <= 7; weekday++ ) {
4045
 
        QColor color = weekdayBackgroundColor( weekday );
4046
 
        if( color.isValid() ) {
4047
 
            QDomElement weekendBackgroundColorElement = doc.createElement( "WeekdayBackgroundColor" );
4048
 
            docRoot.appendChild( weekendBackgroundColorElement );
4049
 
            KDGanttXML::createIntNode( doc, weekendBackgroundColorElement,
4050
 
                                       "Day", weekday );
4051
 
            KDGanttXML::createColorNode( doc, weekendBackgroundColorElement,
4052
 
                                         "Color", color );
4053
 
        }
4054
 
    }
4055
 
 
4056
 
    // the WeekendDays element
4057
 
    QDomElement weekendDaysElement = doc.createElement( "WeekendDays" );
4058
 
    docRoot.appendChild( weekendDaysElement );
4059
 
    int weekendStart, weekendEnd;
4060
 
    weekendDays( weekendStart, weekendEnd );
4061
 
    weekendDaysElement.setAttribute( "Start", weekendStart );
4062
 
    weekendDaysElement.setAttribute( "End", weekendStart );
4063
 
 
4064
 
    // the ZoomFactor element
4065
 
    KDGanttXML::createDoubleNode( doc, docRoot, "ZoomFactor",
4066
 
                                  zoomFactor() );
4067
 
 
4068
 
    // the ShowHeaderPopupMenu element
4069
 
    KDGanttXML::createBoolNode( doc, docRoot, "ShowHeaderPopupMenu",
4070
 
                                showHeaderPopupMenu() );
4071
 
 
4072
 
    // the ShowTimeTablePopupMenu element
4073
 
    KDGanttXML::createBoolNode( doc, docRoot, "ShowTimeTablePopupMenu",
4074
 
                                showTimeTablePopupMenu() );
4075
 
 
4076
 
    // the Shapes element
4077
 
    QDomElement shapesElement = doc.createElement( "Shapes" );
4078
 
    docRoot.appendChild( shapesElement );
4079
 
    QDomElement shapesEventElement = doc.createElement( "Event" );
4080
 
    shapesElement.appendChild( shapesEventElement );
4081
 
    KDGanttViewItem::Shape start, middle, end;
4082
 
    if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
4083
 
        KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
4084
 
                                      KDGanttViewItem::shapeToString( start ) );
4085
 
        KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
4086
 
                                      KDGanttViewItem::shapeToString( middle ) );
4087
 
        KDGanttXML::createStringNode( doc, shapesEventElement, "End",
4088
 
                                      KDGanttViewItem::shapeToString( end ) );
4089
 
    } else {
4090
 
        KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
4091
 
                                      "Undefined" );
4092
 
        KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
4093
 
                                      "Undefined" );
4094
 
        KDGanttXML::createStringNode( doc, shapesEventElement, "End",
4095
 
                                      "Undefined" );
4096
 
    }
4097
 
    QDomElement shapesTaskElement = doc.createElement( "Task" );
4098
 
    shapesElement.appendChild( shapesTaskElement );
4099
 
    if( shapes( KDGanttViewItem::Task, start, middle, end ) ) {
4100
 
        KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
4101
 
                                      KDGanttViewItem::shapeToString( start ) );
4102
 
        KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
4103
 
                                      KDGanttViewItem::shapeToString( middle ) );
4104
 
        KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
4105
 
                                      KDGanttViewItem::shapeToString( end ) );
4106
 
    } else {
4107
 
        KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
4108
 
                                      "Undefined" );
4109
 
        KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
4110
 
                                      "Undefined" );
4111
 
        KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
4112
 
                                      "Undefined" );
4113
 
    }
4114
 
    QDomElement shapesSummaryElement = doc.createElement( "Summary" );
4115
 
    shapesElement.appendChild( shapesSummaryElement );
4116
 
    if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
4117
 
        KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
4118
 
                                      KDGanttViewItem::shapeToString( start ) );
4119
 
        KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
4120
 
                                      KDGanttViewItem::shapeToString( middle ) );
4121
 
        KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
4122
 
                                      KDGanttViewItem::shapeToString( end ) );
4123
 
    } else {
4124
 
        KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
4125
 
                                      "Undefined" );
4126
 
        KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
4127
 
                                      "Undefined" );
4128
 
        KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
4129
 
                                      "Undefined" );
4130
 
    }
4131
 
 
4132
 
    // the Colors element
4133
 
    QDomElement colorsElement = doc.createElement( "Colors" );
4134
 
    docRoot.appendChild( colorsElement );
4135
 
    QDomElement colorsEventElement = doc.createElement( "Event" );
4136
 
    colorsElement.appendChild( colorsEventElement );
4137
 
    QColor startColor, middleColor, endColor;
4138
 
    colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
4139
 
    KDGanttXML::createColorNode( doc, colorsEventElement, "Start", startColor );
4140
 
    KDGanttXML::createColorNode( doc, colorsEventElement, "Middle", middleColor );
4141
 
    KDGanttXML::createColorNode( doc, colorsEventElement, "End", endColor );
4142
 
    QDomElement colorsTaskElement = doc.createElement( "Task" );
4143
 
    colorsElement.appendChild( colorsTaskElement );
4144
 
    colors( KDGanttViewItem::Task, startColor, middleColor, endColor );
4145
 
    KDGanttXML::createColorNode( doc, colorsTaskElement, "Start", startColor );
4146
 
    KDGanttXML::createColorNode( doc, colorsTaskElement, "Middle", middleColor );
4147
 
    KDGanttXML::createColorNode( doc, colorsTaskElement, "End", endColor );
4148
 
    QDomElement colorsSummaryElement = doc.createElement( "Summary" );
4149
 
    colorsElement.appendChild( colorsSummaryElement );
4150
 
    colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
4151
 
    KDGanttXML::createColorNode( doc, colorsSummaryElement, "Start", startColor );
4152
 
    KDGanttXML::createColorNode( doc, colorsSummaryElement, "Middle", middleColor );
4153
 
    KDGanttXML::createColorNode( doc, colorsSummaryElement, "End", endColor );
4154
 
 
4155
 
    // the DefaultColor element
4156
 
    QDomElement defaultColorsElement = doc.createElement( "DefaultColors" );
4157
 
    docRoot.appendChild( defaultColorsElement );
4158
 
    KDGanttXML::createColorNode( doc, defaultColorsElement, "Event",
4159
 
                                 defaultColor( KDGanttViewItem::Event ) );
4160
 
    KDGanttXML::createColorNode( doc, defaultColorsElement, "Task",
4161
 
                                 defaultColor( KDGanttViewItem::Task ) );
4162
 
    KDGanttXML::createColorNode( doc, defaultColorsElement, "Summary",
4163
 
                                 defaultColor( KDGanttViewItem::Summary ) );
4164
 
 
4165
 
 
4166
 
    // the HighlightColors element
4167
 
    QDomElement highlightColorsElement = doc.createElement( "HighlightColors" );
4168
 
    docRoot.appendChild( highlightColorsElement );
4169
 
    QDomElement highlightColorsEventElement = doc.createElement( "Event" );
4170
 
    highlightColorsElement.appendChild( highlightColorsEventElement );
4171
 
    highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
4172
 
    KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Start", startColor );
4173
 
    KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Middle", middleColor );
4174
 
    KDGanttXML::createColorNode( doc, highlightColorsEventElement, "End", endColor );
4175
 
    QDomElement highlightColorsTaskElement = doc.createElement( "Task" );
4176
 
    highlightColorsElement.appendChild( highlightColorsTaskElement );
4177
 
    highlightColors( KDGanttViewItem::Task, startColor, middleColor, endColor );
4178
 
    KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Start", startColor );
4179
 
    KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Middle", middleColor );
4180
 
    KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "End", endColor );
4181
 
    QDomElement highlightColorsSummaryElement = doc.createElement( "Summary" );
4182
 
    highlightColorsElement.appendChild( highlightColorsSummaryElement );
4183
 
    highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
4184
 
    KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
4185
 
    KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
4186
 
    KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );
4187
 
 
4188
 
    // the DefaultHighlightColor element
4189
 
    QDomElement defaultHighlightColorsElement = doc.createElement( "DefaultHighlightColors" );
4190
 
    docRoot.appendChild( defaultHighlightColorsElement );
4191
 
    KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Event",
4192
 
                                 defaultHighlightColor( KDGanttViewItem::Event ) );
4193
 
    KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Task",
4194
 
                                 defaultHighlightColor( KDGanttViewItem::Task ) );
4195
 
    KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Summary",
4196
 
                                 defaultHighlightColor( KDGanttViewItem::Summary ) );
4197
 
 
4198
 
 
4199
 
    // the Items element
4200
 
    QDomElement itemsElement = doc.createElement( "Items" );
4201
 
    docRoot.appendChild( itemsElement );
4202
 
    KDGanttViewItem* currentItem = firstChild();
4203
 
    while( currentItem ) {
4204
 
        currentItem->createNode( doc, itemsElement );
4205
 
        currentItem = currentItem->nextSibling();
4206
 
    }
4207
 
 
4208
 
    // the TaskLinks element
4209
 
    QDomElement taskLinksElement = doc.createElement( "TaskLinks" );
4210
 
    docRoot.appendChild( taskLinksElement );
4211
 
    QPtrList<KDGanttViewTaskLink> taskLinkList = taskLinks();
4212
 
    KDGanttViewTaskLink* currentTL = 0;
4213
 
    for( currentTL = taskLinkList.first(); currentTL;
4214
 
         currentTL = taskLinkList.next() )
4215
 
        currentTL->createNode( doc, taskLinksElement );
4216
 
 
4217
 
    // the TaskLinkGroups element
4218
 
    QDomElement taskLinkGroupsElement = doc.createElement( "TaskLinkGroups" );
4219
 
    docRoot.appendChild( taskLinkGroupsElement );
4220
 
    QPtrList<KDGanttViewTaskLinkGroup> taskLinkGroupList = taskLinkGroups();
4221
 
    KDGanttViewTaskLinkGroup* currentTLG = 0;
4222
 
    for( currentTLG = taskLinkGroupList.first(); currentTLG;
4223
 
         currentTLG = taskLinkGroupList.next() )
4224
 
        currentTLG->createNode( doc, taskLinkGroupsElement );
4225
 
 
4226
 
    // the ColumnBackgroundColors element
4227
 
    QDomElement columnBackgroundColorsElement =
4228
 
        doc.createElement( "ColumnBackgroundColors" );
4229
 
    docRoot.appendChild( columnBackgroundColorsElement );
4230
 
    KDTimeHeaderWidget::ColumnColorList ccList =
4231
 
        myTimeHeader->columnBackgroundColorList();
4232
 
    for( KDTimeHeaderWidget::ColumnColorList::iterator it = ccList.begin();
4233
 
         it != ccList.end(); ++it ) {
4234
 
        QDomElement columnBackgroundColorElement =
4235
 
            doc.createElement( "ColumnBackgroundColor" );
4236
 
        columnBackgroundColorsElement.appendChild( columnBackgroundColorElement );
4237
 
        KDGanttXML::createDateTimeNode( doc, columnBackgroundColorElement,
4238
 
                                        "DateTime", (*it).datetime );
4239
 
        KDGanttXML::createColorNode( doc, columnBackgroundColorElement,
4240
 
                                     "Color", (*it).color );
4241
 
        KDGanttXML::createStringNode( doc, columnBackgroundColorElement, "MinScale", scaleToString( (*it).minScaleView ) );
4242
 
        KDGanttXML::createStringNode( doc, columnBackgroundColorElement, "MaxScale", scaleToString( (*it).maxScaleView ) );
4243
 
    }
4244
 
 
4245
 
    // the IntervalBackgroundColors element
4246
 
    columnBackgroundColorsElement =
4247
 
        doc.createElement( "IntervalBackgroundColors" );
4248
 
    docRoot.appendChild( columnBackgroundColorsElement );
4249
 
    KDTimeHeaderWidget::IntervalColorList icList = myTimeHeader->intervalBackgroundColorList();
4250
 
    for( KDTimeHeaderWidget::IntervalColorList::iterator it = icList.begin();
4251
 
         it != icList.end(); ++it ) {
4252
 
        QDomElement columnBackgroundColorElement =
4253
 
            doc.createElement( "IntervalBackgroundColor" );
4254
 
        columnBackgroundColorsElement.appendChild( columnBackgroundColorElement );
4255
 
        KDGanttXML::createDateTimeNode( doc, columnBackgroundColorElement,
4256
 
                                        "DateTimeStart", (*it)->start() );
4257
 
        KDGanttXML::createDateTimeNode( doc, columnBackgroundColorElement,
4258
 
                                        "DateTimeEnd", (*it)->end() );
4259
 
        KDGanttXML::createColorNode( doc, columnBackgroundColorElement,
4260
 
                                     "Color", (*it)->color() );
4261
 
        //KDGanttXML::createIntNode( doc, columnBackgroundColorElement, "Priority", (*it).priority );
4262
 
        //KDGanttXML::createStringNode( doc, columnBackgroundColorElement, "MinScale", scaleToString( (*it).minScaleView ) );
4263
 
        //KDGanttXML::createStringNode( doc, columnBackgroundColorElement, "MaxScale", scaleToString( (*it).maxScaleView ) );
4264
 
    }
4265
 
 
4266
 
    // the LegendItems element
4267
 
    QDomElement legendItemsElement =
4268
 
        doc.createElement( "LegendItems" );
4269
 
    docRoot.appendChild( legendItemsElement );
4270
 
    legendItem* current;
4271
 
    QPtrListIterator<legendItem> lit( myLegendItems );
4272
 
    while( ( current = lit.current() ) ) {
4273
 
        ++lit;
4274
 
        QDomElement legendItemElement = doc.createElement( "LegendItem" );
4275
 
        legendItemsElement.appendChild( legendItemElement );
4276
 
        KDGanttXML::createStringNode( doc, legendItemElement, "Shape",
4277
 
                                      KDGanttViewItem::shapeToString( current->shape ) );
4278
 
        KDGanttXML::createColorNode( doc, legendItemElement, "Color",
4279
 
                                     current->color );
4280
 
        KDGanttXML::createStringNode( doc, legendItemElement, "Text",
4281
 
                                      current->text );
4282
 
        if ( current->has2 ) {
4283
 
            KDGanttXML::createStringNode( doc, legendItemElement, "Shape2",
4284
 
                                          KDGanttViewItem::shapeToString( current->shape2 ) );
4285
 
            KDGanttXML::createColorNode( doc, legendItemElement, "Color2",
4286
 
                                         current->color2 );
4287
 
            KDGanttXML::createStringNode( doc, legendItemElement, "Text2",
4288
 
                                          current->text2 );
4289
 
        }
4290
 
    }
4291
 
 
4292
 
    // the DragEnabled element
4293
 
    KDGanttXML::createBoolNode( doc, docRoot, "DragEnabled", isDragEnabled() );
4294
 
 
4295
 
    // the DropEnabled element
4296
 
    KDGanttXML::createBoolNode( doc, docRoot, "DropEnabled", isDropEnabled() );
4297
 
 
4298
 
    // the CalendarMode element
4299
 
    KDGanttXML::createBoolNode( doc, docRoot, "CalendarMode", calendarMode() );
4300
 
    KDGanttXML::createIntNode( doc, docRoot, "TickcountForTimeline", addTickcountForTimeline()  );
4301
 
 
4302
 
    KDGanttXML::createBoolNode( doc, docRoot, "DisplaySubitemsAsGroup", displaySubitemsAsGroup()  );
4303
 
    KDGanttXML::createBoolNode( doc, docRoot, "WeekScaleShowNumber",weekScaleShowNumber()  );
4304
 
    KDGanttXML::createBoolNode( doc, docRoot, "WeekStartsMonday", weekStartsMonday() );
4305
 
    KDGanttXML::createBoolNode( doc, docRoot, "UserHorizonChangeEnabled", userHorizonChangeEnabled() );
4306
 
 
4307
 
    KDGanttXML::createStringNode( doc, docRoot, "TimeHeaderDatetimeFormatHour",timeHeaderDatetimeFormatHour()  );
4308
 
    KDGanttXML::createStringNode( doc, docRoot, "TimeHeaderDatetimeFormatMinute", timeHeaderDatetimeFormatMinute() );
4309
 
    KDGanttXML::createStringNode( doc, docRoot, "TimeHeaderDatetimeFormatSecond", timeHeaderDatetimeFormatSecond() );
4310
 
    KDGanttXML::createStringNode( doc, docRoot, "TimeHeaderDateFormatDay", timeHeaderDateFormatDay() );
4311
 
    KDGanttXML::createStringNode( doc, docRoot, "TimeHeaderDateFormatWeek", timeHeaderDateFormatWeek() );
4312
 
    KDGanttXML::createStringNode( doc, docRoot, "TimeHeaderDateFormatMonth", timeHeaderDateFormatMonth() );
4313
 
    KDGanttXML::createStringNode( doc, docRoot, "TimeHeaderTooltipDateTimeFormat", timeHeaderTooltipDateTimeFormat() );
4314
 
    QDomElement userElement = doc.createElement( "UserSavedData" );
4315
 
    docRoot.appendChild( userElement );
4316
 
    userWriteToElement( doc, userElement );
4317
 
 
4318
 
    return doc;
4319
 
}
4320
 
/*!
4321
 
  This virtual method does nothing.
4322
 
  Reimplement it to save your own data to the QDomElement.
4323
 
  The data can be read with userReadFromElement().
4324
 
  The body contains a small example to write an int value and a QString,
4325
 
  which is commented out.
4326
 
  This method is automatically called from  KDGanttView::saveXML( bool withPI )
4327
 
  which is called from KDGanttView::saveProject().
4328
 
 
4329
 
  \param doc the DOM document to which the node belongs
4330
 
  \param parentElement the element into which to insert user defined data
4331
 
  \sa userReadFromElement()
4332
 
*/
4333
 
void KDGanttView::userWriteToElement( QDomDocument& doc,
4334
 
                                      QDomElement& userElement ) const
4335
 
{
4336
 
    Q_UNUSED( doc );
4337
 
    Q_UNUSED( userElement );
4338
 
    // example for writing user defined data
4339
 
    /*
4340
 
    int userNumber = 815;
4341
 
    QString userData = "this is saved text from the user";
4342
 
    KDGanttXML::createStringNode( doc, userElement, "ExampleText", userData );
4343
 
    KDGanttXML::createIntNode( doc, userElement, "ExampleNumber", userNumber );
4344
 
    */
4345
 
 
4346
 
}
4347
 
/*!
4348
 
  This virtual method does nothing.
4349
 
  Reimplement it to read your own data from the QDomElement.
4350
 
  The data was written from userWriteToElement().
4351
 
  The body contains a small example to read  an int value and a QString,
4352
 
  which is commented out.
4353
 
  This method is automatically called from
4354
 
  loadXML() which is called from KDGanttView::loadProject().
4355
 
 
4356
 
  \param doc the DOM document to which the node belongs
4357
 
  \param parentElement the element which contains user defined data
4358
 
  \sa userWriteToElement() createFromDomElement() loadFromDomElement()
4359
 
*/
4360
 
void KDGanttView::userReadFromElement( QDomElement& element )
4361
 
{
4362
 
    Q_UNUSED( element );
4363
 
    // example for reading user defined data
4364
 
    /*
4365
 
    int userNumber = 0;
4366
 
    QString userData = "";
4367
 
    QDomNode node = element.firstChild();
4368
 
    while( !node.isNull() ) {
4369
 
        QDomElement userElement = node.toElement();
4370
 
        QString tagName = userElement.tagName();
4371
 
        if ( tagName == "ExampleNumber" ) {
4372
 
                int value;
4373
 
                if( KDGanttXML::readIntNode( userElement, value ) )
4374
 
                    userNumber = value;
4375
 
        } else if ( tagName == "ExampleText" ) {
4376
 
                QString value;
4377
 
                if( KDGanttXML::readStringNode( userElement, value ) )
4378
 
                    userData = value;
4379
 
 
4380
 
        }
4381
 
        node = node.nextSibling();
4382
 
    }
4383
 
    qDebug() <<"User data read: " << userNumber << " " << userData;
4384
 
    */
4385
 
}
4386
 
 
4387
 
QString KDGanttView::scaleToString( Scale scale )
4388
 
{
4389
 
    switch( scale ) {
4390
 
    case Second:
4391
 
        return "Second";
4392
 
    case Minute:
4393
 
        return "Minute";
4394
 
    case Hour:
4395
 
        return "Hour";
4396
 
    case Day:
4397
 
        return "Day";
4398
 
    case Week:
4399
 
        return "Week";
4400
 
    case Month:
4401
 
        return "Month";
4402
 
    case Auto:
4403
 
        return "Auto";
4404
 
    }
4405
 
    return "";
4406
 
}
4407
 
 
4408
 
 
4409
 
KDGanttView::Scale KDGanttView::stringToScale( const QString& string )
4410
 
{
4411
 
 
4412
 
    if( string == "Second" )
4413
 
        return Second;
4414
 
    else if( string == "Minute" )
4415
 
        return Minute;
4416
 
    else if( string == "Hour" )
4417
 
        return Hour;
4418
 
    else if( string == "Day" )
4419
 
        return Day;
4420
 
    else if( string == "Week" )
4421
 
        return Week;
4422
 
    else if( string == "Month" )
4423
 
        return Month;
4424
 
    else if( string == "Auto" )
4425
 
        return Auto;
4426
 
 
4427
 
    return Auto;
4428
 
}
4429
 
 
4430
 
 
4431
 
QString KDGanttView::yearFormatToString( YearFormat format )
4432
 
{
4433
 
    switch( format ) {
4434
 
    case FourDigit:
4435
 
        return "FourDigit";
4436
 
    case TwoDigit:
4437
 
        return "TwoDigit";
4438
 
    case TwoDigitApostrophe:
4439
 
        return "TwoDigitApostrophe";
4440
 
    case NoDate:
4441
 
        return "NoDate";
4442
 
    }
4443
 
    return "";
4444
 
}
4445
 
 
4446
 
 
4447
 
KDGanttView::YearFormat KDGanttView::stringToYearFormat( const QString& string )
4448
 
{
4449
 
    if( string == "FourDigit" )
4450
 
        return FourDigit;
4451
 
    else if( string == "TwoDigit" )
4452
 
        return TwoDigit;
4453
 
    else if( string == "TwoDigitApostrophe" )
4454
 
        return TwoDigitApostrophe;
4455
 
    else if( string == "NoDate" )
4456
 
        return NoDate;
4457
 
    else
4458
 
        return FourDigit;
4459
 
}
4460
 
 
4461
 
 
4462
 
QString KDGanttView::hourFormatToString( HourFormat format )
4463
 
{
4464
 
    switch( format ) {
4465
 
    case Hour_12:
4466
 
        return "Hour_12";
4467
 
    case Hour_24:
4468
 
        return "Hour_24";
4469
 
    case Hour_24_FourDigit:
4470
 
        return "Hour_24_FourDigit";
4471
 
    }
4472
 
    return "";
4473
 
}
4474
 
 
4475
 
 
4476
 
KDGanttView::HourFormat KDGanttView::stringToHourFormat( const QString& string )
4477
 
{
4478
 
    if( string == "Hour_12" )
4479
 
        return Hour_12;
4480
 
    else if( string == "Hour_24" )
4481
 
        return Hour_24;
4482
 
 
4483
 
    return Hour_24_FourDigit;
4484
 
}
4485
 
 
4486
 
 
4487
 
void KDGanttView::addTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
4488
 
{
4489
 
    if ( group == 0 ) return;
4490
 
  if (myTaskLinkGroupList.isEmpty()) {
4491
 
    myTaskLinkGroupList.append(group);
4492
 
    return;
4493
 
  }
4494
 
    if (myTaskLinkGroupList.find(group) == -1)
4495
 
        myTaskLinkGroupList.append(group);
4496
 
}
4497
 
 
4498
 
 
4499
 
void KDGanttView::removeTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
4500
 
{
4501
 
    myTaskLinkGroupList.remove(group);
4502
 
}
4503
 
 
4504
 
 
4505
 
/*!
4506
 
  This slot is called when a new item has been added to the Gantt
4507
 
  view. It will show the item attribute dialog in case the item is
4508
 
  editable. \a item is a pointer to the item that has been created.
4509
 
*/
4510
 
void KDGanttView::editItem( KDGanttViewItem*  item)
4511
 
{
4512
 
  if ( ! item )
4513
 
    return;
4514
 
  if ( editorEnabled() ) {
4515
 
    if ( item->editable() ) {
4516
 
#if QT_VERSION < 0x040000
4517
 
        if ( !myItemAttributeDialog ) {
4518
 
            myItemAttributeDialog = new itemAttributeDialog();
4519
 
            myItemAttributeDialog->resize( myItemAttributeDialog->minimumSizeHint() );
4520
 
        }
4521
 
        myItemAttributeDialog->reset( item );
4522
 
        myItemAttributeDialog->show();
4523
 
#endif
4524
 
    }
4525
 
  }
4526
 
}
4527
 
 
4528
 
 
4529
 
/*!
4530
 
  This method returns the pixmap used for a certain shape, in the
4531
 
  selected color and size.
4532
 
 
4533
 
  \param shape the shape to generate
4534
 
  \param shapeColor the foreground color of the shape
4535
 
  \param backgroundColor the background color of the shape
4536
 
  \param itemSize the size of the shape
4537
 
  \return the generated shape pixmap
4538
 
*/
4539
 
QPixmap KDGanttView::getPixmap( KDGanttViewItem::Shape shape,
4540
 
                                const QColor& shapeColor,
4541
 
                                const QColor& backgroundColor, int itemSize)
4542
 
{
4543
 
  // 10 is a good value as size
4544
 
  int size = itemSize+2;
4545
 
  int hei = ( itemSize/3 ) / 2;
4546
 
  QPixmap p = QPixmap( size+4, size+4 );
4547
 
  p.fill( backgroundColor );
4548
 
  QPainter paint (&p);
4549
 
  QBrush b = QBrush ( Qt::SolidPattern );
4550
 
  b.setColor( shapeColor );
4551
 
  paint.setBrush( b );
4552
 
  QPen pen( Qt::black, 1 ) ;
4553
 
  paint.setPen( pen );
4554
 
  switch (shape) {
4555
 
  case KDGanttViewItem::TriangleDown:{
4556
 
    QPointArray arr = QPointArray(3);
4557
 
    arr.setPoint(0,-size/2,-hei);
4558
 
    arr.setPoint(1,size/2,-hei);
4559
 
    arr.setPoint(2,0,((size/2)-hei));
4560
 
    arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
4561
 
    paint.drawPolygon( arr );
4562
 
    break;
4563
 
  }
4564
 
  case KDGanttViewItem::TriangleUp :{
4565
 
    QPointArray arr = QPointArray(3);
4566
 
    arr.setPoint(0,-size/2,hei);
4567
 
    arr.setPoint(1,size/2,hei);
4568
 
    arr.setPoint(2,0,(-size/2)+hei);
4569
 
    arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
4570
 
    paint.drawPolygon( arr );
4571
 
    break;
4572
 
  }
4573
 
  case  KDGanttViewItem::Diamond :{
4574
 
    QPointArray arr = QPointArray(4);
4575
 
    arr.setPoint(0,0,-size/2);
4576
 
    arr.setPoint(1,size/2,0);
4577
 
    arr.setPoint(2,0,size/2);
4578
 
    arr.setPoint(3,-size/2,0);
4579
 
    arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
4580
 
    paint.drawPolygon( arr );
4581
 
    break;
4582
 
  }
4583
 
  case KDGanttViewItem::Square :{
4584
 
    QPointArray arr = QPointArray(4);
4585
 
    arr.setPoint(0,-size/2,-size/2);
4586
 
    arr.setPoint(1,size/2,-size/2);
4587
 
    arr.setPoint(2,size/2,size/2);
4588
 
    arr.setPoint(3,-size/2,size/2);
4589
 
    arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
4590
 
    paint.drawPolygon( arr );
4591
 
    break;
4592
 
  }
4593
 
  case  KDGanttViewItem::Circle  :{
4594
 
    paint.drawEllipse( 2, 2, size, size);
4595
 
    break;
4596
 
  }
4597
 
  }
4598
 
  paint.end();
4599
 
  return p;
4600
 
}
4601
 
 
4602
 
int KDGanttView::getIndex( KDGanttViewItem::Type type) const
4603
 
{
4604
 
    int index = -1;
4605
 
    switch (type) {
4606
 
    case (KDGanttViewItem::Event):
4607
 
        index = 0;
4608
 
        break;
4609
 
    case (KDGanttViewItem::Task):
4610
 
        index = 1;
4611
 
        break;
4612
 
    case (KDGanttViewItem::Summary):
4613
 
        index = 2;
4614
 
        break;
4615
 
    default:
4616
 
        index = -1;
4617
 
    }
4618
 
    return index;
4619
 
}
4620
 
 
4621
 
 
4622
 
void KDGanttView::initDefaults()
4623
 
{
4624
 
  int i;
4625
 
  // We have 3 item types. Set all undefined to true.
4626
 
    for (i = 0;i<3;++i) {
4627
 
        undefinedShape[i] = true;
4628
 
        undefinedColor[i] = true;
4629
 
        undefinedColorHL[i] = true;
4630
 
    }
4631
 
    // setting the default colors
4632
 
    myDefaultColor [ getIndex( KDGanttViewItem::Event ) ] =  Qt::blue; //event
4633
 
    myDefaultColorHL [ getIndex( KDGanttViewItem::Event ) ] =  Qt::red;
4634
 
    myDefaultColor [ getIndex( KDGanttViewItem::Task ) ] =  Qt::green;//task
4635
 
    myDefaultColorHL [ getIndex( KDGanttViewItem::Task ) ] =  Qt::red;
4636
 
    myDefaultColor [ getIndex( KDGanttViewItem::Summary ) ] =  Qt::cyan;//summary
4637
 
    myDefaultColorHL [ getIndex( KDGanttViewItem::Summary ) ] =  Qt::red;
4638
 
 
4639
 
    // setting the default shape types
4640
 
    // currently, we take for each item for all three shapes (start, middle, end) the same default shape
4641
 
    for (i = 0;i<3;++i) {
4642
 
      myDefaultShape [3*getIndex( KDGanttViewItem::Event )+ i] =  KDGanttViewItem::Diamond; //event
4643
 
      myDefaultShape [3*getIndex( KDGanttViewItem::Task ) +i] =  KDGanttViewItem::Square; //task
4644
 
      myDefaultShape [3*getIndex( KDGanttViewItem::Summary ) +i] =  KDGanttViewItem::TriangleDown; //summary
4645
 
 
4646
 
    }
4647
 
}
4648
 
 
4649
 
 
4650
 
 
4651
 
/*!
4652
 
  Calls to this method are passed through to the underlying \a QListView.
4653
 
*/
4654
 
int KDGanttView::addColumn( const QString& label, int width )
4655
 
{
4656
 
    return myListView->addColumn( label, width );
4657
 
}
4658
 
 
4659
 
 
4660
 
/*!
4661
 
  Calls to this method are passed through to the underlying \a QListView.
4662
 
*/
4663
 
 
4664
 
int KDGanttView::addColumn( const QIconSet& iconset, const QString& label,
4665
 
                            int width )
4666
 
{
4667
 
    return myListView->addColumn( iconset, label, width );
4668
 
}
4669
 
 
4670
 
 
4671
 
/*!
4672
 
  Calls to this method are passed through to the underlying \a QListView.
4673
 
*/
4674
 
void KDGanttView::removeColumn( int index )
4675
 
{
4676
 
    myListView->removeColumn( index );
4677
 
}
4678
 
 
4679
 
 
4680
 
/*!
4681
 
  Calls to this method are passed through to the underlying \a QListView.
4682
 
*/
4683
 
KDGanttViewItem* KDGanttView::selectedItem() const
4684
 
{
4685
 
    return static_cast<KDGanttViewItem*>( myListView->selectedItem() );
4686
 
}
4687
 
 
4688
 
 
4689
 
/*!
4690
 
  Calls to this method are passed through to the underlying \a QListView.
4691
 
*/
4692
 
void KDGanttView::setSelected( KDGanttViewItem* item, bool selected )
4693
 
{
4694
 
    myListView->setSelected( item, selected );
4695
 
}
4696
 
 
4697
 
 
4698
 
/*!
4699
 
  Returns the pointer to the Gantt item with the name \a name.
4700
 
  (i.e., listViewText() == name).
4701
 
  If no item is found, the return value is 0.
4702
 
  If there is more than one item with the same name in the Gantt view,
4703
 
  the first item found will be returned. This may not necessarily be
4704
 
  the first item in the listview.
4705
 
 
4706
 
  \param name the name of the Gantt item
4707
 
  \return the pointer to the item with name \a name. O, if there is no item
4708
 
  in the Gantt view with this name.
4709
 
 
4710
 
*/
4711
 
KDGanttViewItem* KDGanttView::getItemByName( const QString& name ) const
4712
 
{
4713
 
    KDGanttViewItem* temp =  firstChild(),* ret;
4714
 
    while (temp != 0) {
4715
 
      if ( (ret = temp->getChildByName( name ) ) )
4716
 
        return ret;
4717
 
      temp = temp->nextSibling();
4718
 
    }
4719
 
    return 0;
4720
 
}
4721
 
/*!
4722
 
  Returns the pointer to the Gantt item with the uid \a uid.
4723
 
  If no item is found, the return value is 0.
4724
 
  The uid of an item is not set automatically,
4725
 
  it has to be set by the programmer.
4726
 
  If there is more than one item with the same uid in the Gantt view,
4727
 
  the first item found will be returned. This may not necessarily be
4728
 
  the first item in the listview.
4729
 
 
4730
 
  \param uid the uid of the requested KDGanttViewItem item
4731
 
  \param a pointer to a KDGanttViewItem which children are searched for the
4732
 
         item with uid uid.
4733
 
         pass 0 to  search in all KDGanttViewItems in the Gantt view.
4734
 
  \return the pointer to the item with uid \a uid. O, if there is no item
4735
 
  in the Gantt view with this name.
4736
 
  \sa KDGanttViewItem::getChildByUid() KDGanttViewItem::uid() KDGanttViewItem::setUid()
4737
 
 
4738
 
*/
4739
 
KDGanttViewItem* KDGanttView::getItemByUid( const QString& uid,  KDGanttViewItem* parentItem ) const
4740
 
{
4741
 
    if ( parentItem != 0 )
4742
 
        return parentItem->getChildByUid( uid );
4743
 
 
4744
 
    KDGanttViewItem* temp =  firstChild(),* ret;
4745
 
    while (temp != 0) {
4746
 
      if ( (ret = temp->getChildByUid( uid ) ) )
4747
 
        return ret;
4748
 
      temp = temp->nextSibling();
4749
 
    }
4750
 
    return 0;
4751
 
}
4752
 
 
4753
 
 
4754
 
/*!
4755
 
  Returns the pointer to the Gantt item at the position \a pos in the
4756
 
  list view.
4757
 
  The position \a pos is a global position.
4758
 
  If no item is found, 0 is returned.
4759
 
 
4760
 
  \param pos the (global) position of the Gantt item
4761
 
  \return the pointer to the item with position \a pos. O, if there is
4762
 
  no item in the list view at this position.
4763
 
 
4764
 
*/
4765
 
KDGanttViewItem* KDGanttView::getItemByListViewPos( const QPoint& pos ) const
4766
 
{
4767
 
    return static_cast<KDGanttViewItem*>( myListView->itemAt(myListView->mapFromGlobal(pos) ));
4768
 
}
4769
 
 
4770
 
 
4771
 
/*!
4772
 
  Returns the pointer to the Gantt item at the position \a pos in the
4773
 
  Gantt view.
4774
 
  The position \a pos is a global position.
4775
 
  If no items are found, or the item is disabled, 0 is returned.
4776
 
  If there is more than one item with the same position in the Gantt view,
4777
 
  the first item found will be returned. This is not necessarily the
4778
 
  first item in the listview.
4779
 
 
4780
 
  \param pos the (global) position of the Gantt item
4781
 
  \return the pointer to the item with position \a pos. O, if there is no item
4782
 
  in the Gantt view at this position.
4783
 
 
4784
 
*/
4785
 
KDGanttViewItem* KDGanttView::getItemByGanttViewPos( const QPoint& pos ) const
4786
 
{
4787
 
  KDGanttViewItem* item;
4788
 
  QPoint local = myCanvasView->mapFromGlobal(pos);
4789
 
 
4790
 
    QCanvasItemList il = myTimeTable->collisions( myCanvasView->viewportToContents( local ));
4791
 
    QCanvasItemList::Iterator it;
4792
 
    for ( it = il.begin(); it != il.end(); ++it ) {
4793
 
      if ( myCanvasView->getType(*it) == Type_is_KDGanttViewItem) {
4794
 
        item = myCanvasView->getItem(*it);
4795
 
        if ( item->enabled() )
4796
 
          return item;
4797
 
      }
4798
 
    }
4799
 
    return 0;
4800
 
}
4801
 
 
4802
 
 
4803
 
/*!
4804
 
  Returns the pointer to the Gantt item at the position \a pos in the
4805
 
  list view part of the Gantt view.
4806
 
  The position \a pos is a global position if parameter \a global is true.
4807
 
  If the vertical part (y coordinate) of \a pos
4808
 
  (mapped to local coordinates) is less than 0 or
4809
 
  larger than the height of the listview, 0 is returned.
4810
 
  The horizontal part (x coordinate) of \a pos is ignored.
4811
 
  \param pos the position of the Gantt item
4812
 
  \param global if true, pos is assumed to be global
4813
 
  \return the pointer to the item with position \a pos. O, if there is no item
4814
 
  in the Gantt view at this position.
4815
 
 
4816
 
*/
4817
 
KDGanttViewItem* KDGanttView::getItemAt( const QPoint& pos, bool global ) const
4818
 
{
4819
 
  KDGanttViewItem* item;
4820
 
  KDGanttViewItem* retItem = 0;
4821
 
  int y;
4822
 
  if ( global )
4823
 
      y = myCanvasView->viewport()->mapFromGlobal(pos).y()+myCanvasView->contentsY ();
4824
 
  else
4825
 
    y = pos.y();
4826
 
  item = firstChild();
4827
 
  while ( item != 0 ) {
4828
 
    int yc = item->itemPos();
4829
 
    if ( yc <= y && y < yc + item->height()) {
4830
 
      retItem = item;
4831
 
      break;
4832
 
    }
4833
 
    item = item->itemBelow();
4834
 
  }
4835
 
  return retItem;
4836
 
 
4837
 
}
4838
 
/*!
4839
 
  This sets to count of minor ticks that are added to the timeline if the user
4840
 
  expand the horizon by pressing the arrow buttons of the horizontal scrollbar of the gantt view.
4841
 
  \param count the tick count
4842
 
  in the Gantt view at this position.
4843
 
  \sa addTickcountForTimeline()
4844
 
 
4845
 
*/
4846
 
void  KDGanttView::setAddTickcountForTimeline( int count )
4847
 
{
4848
 
    mAddTickcountForTimeline = count;
4849
 
}
4850
 
/*!
4851
 
  Returns the count for adding ticks to the timeline if the user clicks on the arrow
4852
 
  buttons of the horizontal scrollbar of the gantt view.
4853
 
 
4854
 
  \return the tick count
4855
 
  \sa setAddTickcountForTimeline()
4856
 
*/
4857
 
int  KDGanttView::addTickcountForTimeline() const
4858
 
{
4859
 
    return mAddTickcountForTimeline;
4860
 
}
4861
 
 
4862
 
void KDGanttView::addTickRight()
4863
 
{
4864
 
  if ( !mFixedHorizon && _enableAdding && myCanvasView->horizontalScrollBar()->value() ==  myCanvasView->horizontalScrollBar()->maximum()) {
4865
 
    //myCanvasView->horizontalScrollBar()->blockSignals( true );
4866
 
    myTimeHeader->addTickRight();
4867
 
    //myCanvasView->horizontalScrollBar()->blockSignals( false );
4868
 
    myCanvasView->updateHorScrollBar();
4869
 
    setTimelineToEnd();
4870
 
  }
4871
 
}
4872
 
 
4873
 
void KDGanttView::addTickLeft()
4874
 
{
4875
 
    if (!mUserHorizonChangeEnabled) {
4876
 
        emit addOneTickLeft();
4877
 
        return;
4878
 
    }
4879
 
    if (  myCanvasView->horizontalScrollBar()->value() == 0 ) {
4880
 
        myTimeHeader->addTickLeft( mAddTickcountForTimeline );
4881
 
    }
4882
 
  if ( !mFixedHorizon && _enableAdding && myCanvasView->horizontalScrollBar()->value() == 0 ) {
4883
 
    myCanvasView->horizontalScrollBar()->blockSignals( true );
4884
 
    myTimeHeader->addTickLeft();
4885
 
    myCanvasView->horizontalScrollBar()->blockSignals( false );
4886
 
    setTimelineToStart();
4887
 
  }
4888
 
}
4889
 
 
4890
 
 
4891
 
void KDGanttView::enableAdding( int val )
4892
 
{
4893
 
  _enableAdding = ( val == 0 || val == myCanvasView->horizontalScrollBar()->maximum());
4894
 
}
4895
 
 
4896
 
 
4897
 
/*!
4898
 
  Returns the number of ( toplevel ) root items in the Gantt view.
4899
 
 
4900
 
  \return the number of ( toplevel ) root items in the Gantt view.
4901
 
*/
4902
 
int KDGanttView::childCount() const
4903
 
{
4904
 
    return myListView->childCount();
4905
 
}
4906
 
 
4907
 
/*!
4908
 
  Clears the complete content of the Gant view.
4909
 
  That is
4910
 
  all gantt items,
4911
 
  the legend and the legend items,
4912
 
  the tasklinks,
4913
 
  the tasklink groups and
4914
 
  the background color settings for columns/time interval in the gantt view.
4915
 
 
4916
 
*/
4917
 
void KDGanttView::clearAll()
4918
 
{
4919
 
  bool block = myTimeTable->blockUpdating();
4920
 
  myTimeTable->setBlockUpdating( true );
4921
 
  clearLegend();
4922
 
  clearBackgroundColor();
4923
 
  setHorBackgroundLines( 0 );
4924
 
  QPtrList<KDGanttViewTaskLink>  tll = taskLinks();
4925
 
  tll.setAutoDelete( true );
4926
 
  tll.clear();
4927
 
  QPtrList<KDGanttViewTaskLinkGroup> tlg = myTaskLinkGroupList;
4928
 
  tlg.setAutoDelete( true );
4929
 
  tlg.clear();
4930
 
  clear();
4931
 
  myTimeTable->setBlockUpdating( block );
4932
 
}
4933
 
/*!
4934
 
  Removes all items from the Gantt view.
4935
 
*/
4936
 
void KDGanttView::clear()
4937
 
{
4938
 
    if ( ! childCount() ) return;
4939
 
  bool block = myTimeTable->blockUpdating();
4940
 
  myTimeTable->setBlockUpdating( true );
4941
 
  myListView->clear();
4942
 
  // in Qt3 wee need the processEvents(); to fix a crash
4943
 
  // in Qt4 with Qt3 compat it crashes here
4944
 
  // I had a look at the Q3ListView source code:
4945
 
  // in theory it may not crash ... in theory
4946
 
#if QT_VERSION < 0x040000
4947
 
  qApp->processEvents();
4948
 
#endif
4949
 
  myTimeTable->setBlockUpdating( false );
4950
 
  myTimeTable->updateMyContent();
4951
 
#if QT_VERSION < 0x040000
4952
 
  qApp->processEvents();
4953
 
#endif
4954
 
  myTimeTable->setBlockUpdating( block );
4955
 
}
4956
 
 
4957
 
 
4958
 
/*!
4959
 
  Passes on the signal from the list view.
4960
 
*/
4961
 
void KDGanttView::slot_lvDropped(QDropEvent* e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse  )
4962
 
{
4963
 
  emit dropped( e, droppedItem, itemBelowMouse);
4964
 
}
4965
 
 
4966
 
/*!
4967
 
  Implements a pass-through to the list view.
4968
 
*/
4969
 
QDragObject * KDGanttView::dragObject ()
4970
 
{
4971
 
  return myListView->dragObject ();
4972
 
}
4973
 
 
4974
 
 
4975
 
/*!
4976
 
  Implements a pass-through to the list view.
4977
 
*/
4978
 
void KDGanttView::startDrag ()
4979
 
{
4980
 
  //myListView->pt_startDrag ();
4981
 
}
4982
 
 
4983
 
 
4984
 
/*!
4985
 
  This method is overridden for internal purposes.
4986
 
*/
4987
 
#if 0
4988
 
// This overridden method is not called any more, as it is deprecated"
4989
 
void KDGanttView::setPaletteBackgroundColor( const QColor& col)
4990
 
{
4991
 
  QPalette pal = palette();
4992
 
  pal.setColor( backgroundRole(), col );
4993
 
  QWidget::setPalette( pal );
4994
 
  timeHeaderSpacerWidget->setPalette( pal );
4995
 
}
4996
 
#endif
4997
 
 
4998
 
/*!
4999
 
  Sets the background color of the Gantt view.
5000
 
 
5001
 
  \param c the background color of the Gantt view.
5002
 
  \sa gvBackgroundColor()
5003
 
*/
5004
 
void KDGanttView::setGvBackgroundColor ( const QColor & c )
5005
 
{
5006
 
  myTimeTable->setBackgroundColor( c );
5007
 
}
5008
 
 
5009
 
 
5010
 
/*!
5011
 
  Sets the background color of the time header.
5012
 
 
5013
 
  \param c the background color of the time header.
5014
 
  \sa timeHeaderBackgroundColor()
5015
 
*/
5016
 
void KDGanttView::setTimeHeaderBackgroundColor ( const QColor & c )
5017
 
{
5018
 
  QPalette pal;
5019
 
  pal.setColor( myTimeHeader->backgroundRole(), c );
5020
 
 
5021
 
  myTimeHeader->setPalette( pal );
5022
 
  //rightWidget->setPalette( pal );
5023
 
 
5024
 
  pal.setColor( timeHeaderSpacerWidget->backgroundRole(), c );
5025
 
  timeHeaderSpacerWidget->setPalette( pal );
5026
 
}
5027
 
 
5028
 
 
5029
 
/*!
5030
 
  Sets the background color of the legend header.
5031
 
 
5032
 
  \param c the background color of the legend header
5033
 
  \sa legendHeaderBackgroundColor()
5034
 
*/
5035
 
void KDGanttView::setLegendHeaderBackgroundColor ( const QColor & c )
5036
 
{
5037
 
  QPalette pal;
5038
 
  pal.setColor( myLegend->backgroundRole(), c );
5039
 
  myLegend->setPalette( pal );
5040
 
 
5041
 
  pal.setColor( leftWidget->backgroundRole(), c );
5042
 
  leftWidget->setPalette( pal );
5043
 
}
5044
 
 
5045
 
 
5046
 
/*!
5047
 
  Sets the background color of the list view.
5048
 
 
5049
 
  \param c the background color of the list view
5050
 
  \sa lvBackgroundColor()
5051
 
*/
5052
 
void KDGanttView::setLvBackgroundColor ( const QColor & c )
5053
 
{
5054
 
  QPalette pal;
5055
 
  pal.setColor( myListView->viewport()->backgroundRole(), c );
5056
 
  myListView->viewport()->setPalette( pal );
5057
 
}
5058
 
 
5059
 
 
5060
 
/*!
5061
 
  Returns the background color of the list view.
5062
 
 
5063
 
  \return the background color of the list view
5064
 
  \sa setLvBackgroundColor()
5065
 
*/
5066
 
QColor KDGanttView::lvBackgroundColor ( )const
5067
 
{
5068
 
  return myListView->viewport()->palette().color(myListView->viewport()->backgroundRole());
5069
 
}
5070
 
 
5071
 
 
5072
 
/*!
5073
 
  Returns the background color of the Gantt view.
5074
 
 
5075
 
  \return the background color of the Gantt view
5076
 
  \sa setGvBackgroundColor()
5077
 
*/
5078
 
QColor KDGanttView::gvBackgroundColor () const
5079
 
{
5080
 
 return myTimeTable->backgroundColor( );
5081
 
}
5082
 
 
5083
 
 
5084
 
/*!
5085
 
  Returns the background color of the time header.
5086
 
 
5087
 
  \return the background color of the time header
5088
 
  \sa setTimeHeaderBackgroundColor()
5089
 
*/
5090
 
QColor KDGanttView::timeHeaderBackgroundColor () const
5091
 
{
5092
 
  return myTimeHeader->palette().color(myTimeHeader->backgroundRole());
5093
 
}
5094
 
 
5095
 
 
5096
 
/*!
5097
 
  Returns the background color of the legend header.
5098
 
 
5099
 
  \return the background color of the legend header
5100
 
  \sa setLegendHeaderBackgroundColor()
5101
 
*/
5102
 
QColor KDGanttView::legendHeaderBackgroundColor () const
5103
 
{
5104
 
  return myLegend->palette().color(myLegend->backgroundRole());
5105
 
}
5106
 
 
5107
 
 
5108
 
/*!
5109
 
  Adds a widget to the spacer widget above the list view part and
5110
 
  below the ShowLegendButton.  To assign all the space above the
5111
 
  Listview to the spacer widget, hide the ShowLegendButton by calling
5112
 
  setShowLegendButton( false ).  The spacer widget is a QHBox.  You
5113
 
  may add as many widgets as you want. They are ordered horizontally
5114
 
  from left to right.  To remove a widget from the spacer widget, call
5115
 
  widget->reparent(newParent,...) or delete the widget.  Since the spacer
5116
 
  is a QHBox, the layout of the added widgets is managed by this
5117
 
  QHBox.
5118
 
 
5119
 
  \param w A pointer to the widget to be added.
5120
 
  \sa setShowLegendButton( )
5121
 
*/
5122
 
void KDGanttView::addUserdefinedLegendHeaderWidget( QWidget * w )
5123
 
{
5124
 
  if ( w ) {
5125
 
    w->setParent ( spacerLeft );
5126
 
    spacerLeftLayout->addWidget( w );
5127
 
  }
5128
 
}
5129
 
 
5130
 
 
5131
 
/*!
5132
 
  Specifies whether drag operations are allowed in the Gantt
5133
 
  view. Recurses over all items contained in the Gantt view and
5134
 
  enables or disabled them for dragging.
5135
 
 
5136
 
  \param b true if dragging is enabled, false if dragging is disabled
5137
 
  \sa isDragEnabled(), setDropEnabled(), isDropEnabled(), setDragDropEnabled()
5138
 
*/
5139
 
void KDGanttView::setDragEnabled( bool b )
5140
 
{
5141
 
  fDragEnabled = b;
5142
 
 QListViewItemIterator it( myListView );
5143
 
 for ( ; it.current(); ++it ) {
5144
 
   (( KDGanttViewItem* )it.current())->setDragEnabled(b);
5145
 
 }
5146
 
 
5147
 
}
5148
 
 
5149
 
 
5150
 
/*!
5151
 
  Specifies whether drop operations are allowed in the Gantt
5152
 
  view. Recurses over all items contained in the Gantt view and
5153
 
  enables or disabled them for dropping.
5154
 
 
5155
 
  \param b true if dragging is enabled, false if dragging is disabled
5156
 
  \sa setDropEnabled(), setDragEnabled(), isDragEnabled(), setDragDropEnabled()
5157
 
*/
5158
 
void KDGanttView::setDropEnabled( bool b )
5159
 
{
5160
 
  fDropEnabled = b;
5161
 
 
5162
 
  //myListView->setAcceptDrops( b );
5163
 
 QListViewItemIterator it( myListView );
5164
 
 for ( ; it.current(); ++it ) {
5165
 
   (( KDGanttViewItem* )it.current())->setDropEnabled(b);
5166
 
 }
5167
 
}
5168
 
 
5169
 
 
5170
 
/*!
5171
 
  Combines setDragEnabled() and setDropEnabled() in one convenient
5172
 
  method.
5173
 
 
5174
 
  \param b true if dragging and dropping are enabled, false if
5175
 
  dragging and dropping are disabled
5176
 
  \sa setDragEnabled(), setDropEnabled()
5177
 
*/
5178
 
void KDGanttView::setDragDropEnabled( bool b )
5179
 
{
5180
 
  setDropEnabled( b );
5181
 
  setDragEnabled( b );
5182
 
}
5183
 
 
5184
 
 
5185
 
/*!
5186
 
  Returns whether dragging is enabled for this Gantt view.
5187
 
 
5188
 
  \return true if dragging is enabled
5189
 
  \sa setDragEnabled(), setDragDropEnabled()
5190
 
*/
5191
 
bool KDGanttView::isDragEnabled() const
5192
 
{
5193
 
  return fDragEnabled;
5194
 
}
5195
 
 
5196
 
 
5197
 
/*!
5198
 
  Returns whether dropping is enabled for this Gantt view.
5199
 
 
5200
 
  \return true if dropping is enabled
5201
 
  \sa setDropEnabled(), setDragDropEnabled()
5202
 
*/
5203
 
bool KDGanttView::isDropEnabled() const
5204
 
{
5205
 
 return fDropEnabled;
5206
 
}
5207
 
 
5208
 
 
5209
 
/*!
5210
 
  \deprecated Use isDragEnabled() instead
5211
 
*/
5212
 
bool KDGanttView::dragEnabled() const
5213
 
{
5214
 
  return isDragEnabled();
5215
 
}
5216
 
 
5217
 
 
5218
 
/*!
5219
 
  \deprecated Use isDropEnabled() instead
5220
 
*/
5221
 
bool KDGanttView::dropEnabled() const
5222
 
{
5223
 
 return isDropEnabled();
5224
 
}
5225
 
 
5226
 
 
5227
 
/*!
5228
 
  This virtual method makes it possible to specify user-defined drop
5229
 
  handling.  The method is called directly before the internal drop
5230
 
  handling is executed.  Return false to execute internal drop
5231
 
  handling.  Return true to not execute internal drop handling.  In
5232
 
  order to specify user-defined drop handling, subclass
5233
 
  KDGanttView and reimplement this method.
5234
 
 
5235
 
  \param e The QDropEvent
5236
 
  Note: e->source() is a pointer to the KDGanttView from which the drag started.
5237
 
  I.e., if e->source() == this, this drag is an internal drag.
5238
 
  \param droppedItem 0, if this is a drag operation from another
5239
 
  KDGanttView instance.
5240
 
  If this drag is an internal drag (i.e., within the KDGanttView),
5241
 
  this parameter points to the dropped item.
5242
 
  \param itemBelowMouse a pointer to the item below the dragged
5243
 
  item (i.e., below the mouse).
5244
 
  If you accept, the dragged item may be inserted
5245
 
  in the KDGanttView as a child of this item.
5246
 
  The value is 0 if there is no item below the dragged item,
5247
 
  and the dragged item will be inserted as a root item.
5248
 
 
5249
 
  \return false, when the internal drop handling should be executed
5250
 
          true, when the internal drop handling should not be executed
5251
 
  \sa lvDropEvent(), lvStartDrag()
5252
 
*/
5253
 
bool  KDGanttView::lvDropEvent ( QDropEvent* e,
5254
 
                                 KDGanttViewItem* droppedItem,
5255
 
                                 KDGanttViewItem* itemBelowMouse )
5256
 
{
5257
 
    Q_UNUSED( e );
5258
 
    Q_UNUSED( droppedItem );
5259
 
    Q_UNUSED( itemBelowMouse );
5260
 
 
5261
 
  // Example code for user defined behaviour:
5262
 
  // we want to accept the usual drags and the drags of files, which may be
5263
 
  // a saved Gantt file.
5264
 
  // Please uncomment the following lines for this behaviour
5265
 
  // You have to uncomment lines in lvDragMoveEvent() and llvDragEnterEvent() as well
5266
 
 
5267
 
  // ************** begin example ************
5268
 
  /*
5269
 
  if ( QUriDrag::canDecode( e ) ) {
5270
 
    QStrList lst;
5271
 
    QUriDrag::decode( e, lst );
5272
 
    // we try the first file of icon-url-list
5273
 
    QString str = lst.at ( 0 );
5274
 
    // remove file: at beginning of string
5275
 
    str = str.right( str.length() - 5  );
5276
 
    QFileInfo info;
5277
 
    info.setFile( str ) ;
5278
 
    if ( info.isFile() ) {
5279
 
      if (!QMessageBox::information( this, "KDGantt Drag&Drop test",
5280
 
                                     "Try to insert file: "+ str + " ?",
5281
 
                                     "&Okay", "&Cancel",0,1  ) ) {
5282
 
        QFile file( str );
5283
 
        loadProject( &file ) ;
5284
 
    }
5285
 
    return true;
5286
 
  }
5287
 
  */
5288
 
  // *********** end example ****************
5289
 
  return false;
5290
 
}
5291
 
 
5292
 
 
5293
 
/*!
5294
 
  This virtual method specifies whether a drag enter event may be
5295
 
  accepted or not.
5296
 
  To accept a drag enter event, call e->accept( true );
5297
 
  To not accept a drag enter evente, call e->accept( false );
5298
 
  This method does nothing but accepting the drag enter event, in case
5299
 
  decoding is possible.
5300
 
  In order to define accepting drops for particular items yourself,
5301
 
  subclass KDGanttView and reimplement this method.
5302
 
 
5303
 
  \param e           The QDragMoveEvent
5304
 
                     Note: e->source() is a pointer to the KDGanttView, the drag started from.
5305
 
                     I.e., if e->source() == this, this drag is an internal drag.
5306
 
 
5307
 
  \sa lvDropEvent(), lvStartDrag(), lvDragMoveEvent()
5308
 
*/
5309
 
void  KDGanttView::lvDragEnterEvent ( QDragEnterEvent * e)
5310
 
{
5311
 
  // the standard behaviour:
5312
 
  // accept drag enter events, if KDGanttViewItemDrag can decode the event
5313
 
  // e->accept(KDGanttViewItemDrag::canDecode(e) );
5314
 
 
5315
 
  if ( KDGanttViewItemDrag::canDecode(e) ) {
5316
 
    e->setAccepted( true);
5317
 
    return;
5318
 
  }
5319
 
 
5320
 
  // example code for user defined behaviour:
5321
 
  // we want to accecpt the usual drags and the drags of files, which may be
5322
 
  // a saved Gantt file
5323
 
  // Please uncomment the following lines for this behaviour
5324
 
  // You have to uncomment lines in lvDragMoveEvent() and lvDropEvent () as well
5325
 
 
5326
 
  //  if ( QUriDrag::canDecode( e ) ) {
5327
 
  // e->accept(true);
5328
 
  //  return;
5329
 
  // }
5330
 
 
5331
 
  e->setAccepted( false );
5332
 
}
5333
 
 
5334
 
 
5335
 
/*!
5336
 
  This virtual method specifies whether a drop event may be accepted or not.
5337
 
  To accept a drop event, call e->accept( true );
5338
 
  To not accept a drop event, call e->accept( false );
5339
 
  This method does nothing but allowing to execute the internal
5340
 
  drag move event handling.
5341
 
 
5342
 
  In order to specify user-defined drop acceptance for particular
5343
 
  items, subclass KDGanttView and reimplement this method.
5344
 
 
5345
 
  \param e           The QDragMoveEvent
5346
 
                     Note: e->source() is a pointer to the KDGanttView, the drag started from.
5347
 
                     I.e. if e->source() == this, this drag is an internal drag.
5348
 
         draggedItem 0, if this is a drag operation from another KDGanttView instance.
5349
 
         If this drag is an internal drag (i.e., within the KDGanttView),
5350
 
         this parameter points to the dragged item.
5351
 
         itemBelowMouse a pointer to the item below the dragged item
5352
 
         (i.e., below the mouse).
5353
 
         If you accept the drop, the dragged item will be inserted
5354
 
         in the KDGanttView as a child of this item.
5355
 
         The value is 0 if there is no item below the dragged item,
5356
 
         and the dragged item will be inserted as a root item.
5357
 
  \return false, when the internal drag move event handling should be executed
5358
 
          true, when the internal drag move event handling should not
5359
 
          be executed; usually you should return true,
5360
 
          if you have called  e->accept( true ) before.
5361
 
  \sa lvDropEvent(), lvStartDrag()
5362
 
*/
5363
 
bool  KDGanttView::lvDragMoveEvent ( QDragMoveEvent* /*e*/,
5364
 
                                     KDGanttViewItem* /* draggedItem*/,
5365
 
                                     KDGanttViewItem* /*itemBelowMouse*/)
5366
 
{
5367
 
 
5368
 
  // Example code 1:
5369
 
  // To generally block items to be inserted as root items, subclass KDGanttView
5370
 
  // and reimplement this method with to following code uncommented:
5371
 
 
5372
 
  // if ( !itemBelowMouse ) {
5373
 
  //  e->accept( false );
5374
 
  //  return true;
5375
 
  //}
5376
 
  //return false;
5377
 
 
5378
 
  // Example code 2:
5379
 
  // To allow the drags of files, which may be
5380
 
  // a saved Gantt file, subclass KDGanttView
5381
 
  // and reimplement this method with to following code uncommented:
5382
 
 
5383
 
  // if ( QUriDrag::canDecode( e ) ) {
5384
 
  //   e->accept(true);
5385
 
  //   return true;
5386
 
  //  }
5387
 
 
5388
 
 
5389
 
 // normal behaviour - the internal drag move event handling should be executed
5390
 
  return false;
5391
 
}
5392
 
 
5393
 
 
5394
 
/*!
5395
 
  This virtual method creates a QDragObject and starts a drag for a
5396
 
  KDGanttViewItem.
5397
 
  In order to prevent drags of particular items, subclass from
5398
 
  KDGanttView and reimplement this method.
5399
 
 
5400
 
  \param item the KDGanttViewItem, which should be dragged
5401
 
  \sa lvDropEvent(), lvDragMoveEvent()
5402
 
*/
5403
 
void  KDGanttView::lvStartDrag (KDGanttViewItem* item)
5404
 
{
5405
 
  QDragObject* d = new KDGanttViewItemDrag(item, this, "itemdrag" );
5406
 
  // call d->drag() to start the dragging
5407
 
  // d->drag() returns true, if a move was requested as a drag
5408
 
  // if a copy (by pressing the <Ctrl>-key) was performed, d->drag() returns false
5409
 
  // In order to avoid starting drags for particular items, subclass KDGanttView
5410
 
  // an reimplement this method.
5411
 
  // insert here some code like
5412
 
  // if ( item->parent() )
5413
 
  // return;
5414
 
  // This particular code will make it impossible to drag other items but root items.
5415
 
  if ( d->drag()) {
5416
 
      delete item;
5417
 
  }
5418
 
}
5419
 
 
5420
 
 
5421
 
/*!
5422
 
  Sets the width of the list view. Space will be taken from or given
5423
 
  to the Gantt view.
5424
 
 
5425
 
  \param w the width of the list view
5426
 
  \sa listViewWidth()
5427
 
*/
5428
 
void  KDGanttView::setListViewWidth( int w )
5429
 
{
5430
 
  int sw = mySplitter->width();
5431
 
  QValueList<int> list;
5432
 
  list.append(w);
5433
 
  list.append(sw-w);
5434
 
  mySplitter->setSizes( list );
5435
 
}
5436
 
 
5437
 
 
5438
 
/*!
5439
 
  Returns the width of the list view.
5440
 
 
5441
 
  \return the width of the list view
5442
 
  \sa setListViewWidth()
5443
 
*/
5444
 
int  KDGanttView::listViewWidth( )
5445
 
{
5446
 
  return leftWidget->width();
5447
 
}
5448
 
 
5449
 
 
5450
 
/*!
5451
 
  Sets the scrollbar mode of the listview. The default is always off.
5452
 
  Possible values are always on, always off and auto.
5453
 
  It only makes sense to set this to always off
5454
 
  if setGvVScrollBarMode() is set to always on.
5455
 
 
5456
 
  \param m the scrollbar mode.
5457
 
  \sa setGvVScrollBarMode( )
5458
 
*/
5459
 
void  KDGanttView::setLvVScrollBarMode( QScrollView::ScrollBarMode m )
5460
 
{
5461
 
  myListView->setVScrollBarMode ( m );
5462
 
}
5463
 
 
5464
 
 
5465
 
/*!
5466
 
  Sets the scrollbar mode of the time table. The default is auto.
5467
 
  Possible values are auto, always on and always off.
5468
 
  It only makes sense to set this to always off
5469
 
  if setLvVScrollBarMode() is set to always on or auto.
5470
 
 
5471
 
  \param m The scrollbar mode.
5472
 
  \sa setLvVScrollBarMode( )
5473
 
*/
5474
 
void  KDGanttView::setGvVScrollBarMode( QScrollView::ScrollBarMode m )
5475
 
{
5476
 
    myCanvasView->setMyVScrollBarMode ( m );
5477
 
#if 0
5478
 
  if ( m == QScrollView::Auto )
5479
 
    qDebug() "KDGanttView::setListViewVScrollBarMode: QScrollView::Auto not supported. Nothing changed. ";
5480
 
  else
5481
 
    {
5482
 
      myCanvasView->setMyVScrollBarMode ( m );
5483
 
      if ( m == QScrollView::AlwaysOn )
5484
 
        timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
5485
 
      else
5486
 
        timeHeaderSpacerWidget->setFixedWidth( 0 );
5487
 
    }
5488
 
#endif
5489
 
}
5490
 
 
5491
 
 
5492
 
void  KDGanttView::itemAboutToBeDeleted( KDGanttViewItem * item)
5493
 
{
5494
 
#if QT_VERSION < 0x040000
5495
 
  if ( myItemAttributeDialog && myItemAttributeDialog->getItem() == item ) {
5496
 
    myItemAttributeDialog->reset( 0 );
5497
 
  }
5498
 
#endif
5499
 
  emit itemDeleted( item );
5500
 
}
5501
 
 
5502
 
 
5503
 
/*!
5504
 
  Specifies whether the user can expand the horizon
5505
 
  by pressing the arrow buttons of the horizontal scrollbar of the gantt view.
5506
 
  The default value for a newly created gantt chart is true.
5507
 
  If set to false, the signal addOneTickLeft() or addOneTickRight() is emitted,
5508
 
  depending on the arrow button the user pressed.
5509
 
 
5510
 
  \param show if true, the user can expand the horizon.
5511
 
  \sa userHorizonChangeEnabled() addOneTickLeft() addOneTickRight()
5512
 
*/
5513
 
 
5514
 
void KDGanttView::setUserHorizonChangeEnabled( bool b )
5515
 
{
5516
 
    mUserHorizonChangeEnabled = b;
5517
 
}
5518
 
 
5519
 
 
5520
 
/*!
5521
 
  Returns whether the user can expand the horizon
5522
 
  by clicking the scrollbar buttons.
5523
 
 
5524
 
  \return true if the user can expand the horizon
5525
 
  \sa setUserHorizonChangeEnabled()
5526
 
*/bool KDGanttView::userHorizonChangeEnabled() const
5527
 
{
5528
 
    return mUserHorizonChangeEnabled;
5529
 
}
5530
 
 
5531
 
/*!
5532
 
  This method is provided for convenience and as an example
5533
 
  how to set the user defined date time formats.
5534
 
  It sets the formats to formats which are used in Germany.
5535
 
  It calls
5536
 
  setTimeHeaderTooltipDateTimeFormat( "dddd, dd. MMMM yyyy - h:mm:ss" );
5537
 
  setHourFormat(Hour_24_FourDigit);
5538
 
  setWeekScaleShowNumber( true );
5539
 
  setWeekStartsMonday( true );
5540
 
  setTimeHeaderDateFormatWeek( " d. MMM 'yy" );
5541
 
  setTimeHeaderDateFormatDay( " d. MMM 'yy" );
5542
 
  setTimeHeaderDatetimeFormatHour( "dddd, dd. MMM 'yy" );
5543
 
  setTimeHeaderDatetimeFormatMinute( "ddd, dd. MMM h:mm" );
5544
 
 
5545
 
  \sa setTimeHeaderTooltipDateTimeFormat ()  setTimeHeaderDateFormatMonth() setTimeHeaderDateFormatWeek() setTimeHeaderDateFormatDay() setTimeHeaderDatetimeFormatMinute () setTimeHeaderDatetimeFormatHour() setWeekStartsMonday() setWeekScaleShowNumber()
5546
 
*/
5547
 
 
5548
 
void KDGanttView::setGermanDateTimeFormat()
5549
 
{
5550
 
    setTimeHeaderTooltipDateTimeFormat( "dddd, dd. MMMM yyyy - h:mm:ss" );
5551
 
    setHourFormat(Hour_24_FourDigit);
5552
 
    setWeekScaleShowNumber( true );
5553
 
    setWeekStartsMonday( true );
5554
 
    setTimeHeaderDateFormatWeek( " d. MMM 'yy" );
5555
 
    setTimeHeaderDateFormatDay( " d. MMM 'yy" );
5556
 
    setTimeHeaderDatetimeFormatHour( "dddd, dd. MMM 'yy" );
5557
 
    setTimeHeaderDatetimeFormatMinute( "ddd, dd. MMM h:mm" );
5558
 
    //setTimeHeaderDatetimeFormatSecond( "dddd, dd. MMM h:mm" );
5559
 
}
5560
 
 
5561
 
/*!
5562
 
  Returns the user defined datetime format of the time header tooltip.
5563
 
  Returns an empty string as default, i.e. if there is no user defined format.
5564
 
  You can find details about the possible format itself in the Qt documentation of:
5565
 
  QDateTime::toString ( const QString & format ) const
5566
 
  QDate::toString( const QString & format )
5567
 
  QTime::toString( const QString & format )
5568
 
 
5569
 
  \return user defined datetime format of the time header tooltip
5570
 
  \sa setTimeHeaderTooltipDateTimeFormat ()
5571
 
*/
5572
 
QString KDGanttView::timeHeaderTooltipDateTimeFormat() const
5573
 
{
5574
 
    return myTimeHeader->tooltipDateTimeFormat();
5575
 
}
5576
 
/*!
5577
 
  Sets the user defined datetime format of the time header tooltip.
5578
 
  As default datetime format of the time header tooltip the return value of  QDateTime::toString () is used..
5579
 
  You can find details about the possible user defined format itself in the Qt documentation of:
5580
 
  QDateTime::toString ( const QString & format ) const
5581
 
  QDate::toString( const QString & format )
5582
 
  QTime::toString( const QString & format )
5583
 
 
5584
 
  \param the datetime format of time header tooltip. To unset the user defined format pass an empty string.
5585
 
  \sa timeHeaderTooltipDateTimeFormat()
5586
 
*/
5587
 
void KDGanttView::setTimeHeaderTooltipDateTimeFormat( const QString& fmt )
5588
 
{
5589
 
    myTimeHeader->setTooltipDateTimeFormat( fmt );
5590
 
}
5591
 
 
5592
 
/*!
5593
 
  Returns the user defined date format for the upper date row of the time header if the time header scale is set to month.
5594
 
  Returns an empty string as default, i.e. if there is no user defined format.
5595
 
  You can find details about the possible format itself in the Qt documentation of:
5596
 
  QDateTime::toString ( const QString & format ) const
5597
 
  QDate::toString( const QString & format )
5598
 
  QTime::toString( const QString & format )
5599
 
 
5600
 
  \return user defined date format of the time header in monthly scale
5601
 
  \sa setTimeHeaderDateFormatMonth()
5602
 
*/
5603
 
QString KDGanttView::timeHeaderDateFormatMonth() const
5604
 
{
5605
 
    return myTimeHeader->dateFormatMonth();
5606
 
}
5607
 
 
5608
 
/*!
5609
 
  Sets the user defined date format for the upper date row of the time header if the time header scale is set to month.
5610
 
  You can find details about the possible user defined format itself in the Qt documentation of:
5611
 
  QDateTime::toString ( const QString & format ) const
5612
 
  QDate::toString( const QString & format )
5613
 
  QTime::toString( const QString & format )
5614
 
 
5615
 
  \param the user defined date format of the time header in monthly scale
5616
 
  \sa timeHeaderDateFormatMonth()
5617
 
*/
5618
 
void KDGanttView::setTimeHeaderDateFormatMonth( const QString& fmt )
5619
 
{
5620
 
    myTimeHeader->setDateFormatMonth( fmt );
5621
 
}
5622
 
 
5623
 
/*!
5624
 
  Returns the user defined date format for the upper date row of the time header if the time header scale is set to week.
5625
 
  Returns an empty string as default, i.e. if there is no user defined format.
5626
 
  You can find details about the possible format itself in the Qt documentation of:
5627
 
  QDateTime::toString ( const QString & format ) const
5628
 
  QDate::toString( const QString & format )
5629
 
  QTime::toString( const QString & format )
5630
 
 
5631
 
  \return user defined date format of the time header in weekly scale
5632
 
  \sa setTimeHeaderDateFormatWeek()
5633
 
*/
5634
 
QString KDGanttView::timeHeaderDateFormatWeek() const
5635
 
{
5636
 
    return myTimeHeader->dateFormatWeek();
5637
 
}
5638
 
/*!
5639
 
  Sets the user defined date format for the upper date row of the time header if the time header scale is set to week.
5640
 
  You can find details about the possible user defined format itself in the Qt documentation of:
5641
 
  QDateTime::toString ( const QString & format ) const
5642
 
  QDate::toString( const QString & format )
5643
 
  QTime::toString( const QString & format )
5644
 
 
5645
 
  \param the user defined date format of the time header in weekly scale
5646
 
  \sa timeHeaderDateFormatWeek()
5647
 
*/
5648
 
void KDGanttView::setTimeHeaderDateFormatWeek( const QString& fmt )
5649
 
{
5650
 
    myTimeHeader->setDateFormatWeek( fmt );
5651
 
}
5652
 
/*!
5653
 
  Returns the user defined date format for the upper date row of the time header if the time header scale is set to day.
5654
 
  Returns an empty string as default, i.e. if there is no user defined format.
5655
 
  You can find details about the possible format itself in the Qt documentation of:
5656
 
  QDateTime::toString ( const QString & format ) const
5657
 
  QDate::toString( const QString & format )
5658
 
  QTime::toString( const QString & format )
5659
 
 
5660
 
  \return user defined date format of the time header in daily scale
5661
 
  \sa setTimeHeaderDateFormatDay()
5662
 
*/
5663
 
QString KDGanttView::timeHeaderDateFormatDay() const
5664
 
{
5665
 
    return myTimeHeader->dateFormatDay();
5666
 
}
5667
 
/*!
5668
 
  Sets the user defined date format for the upper date row of the time header if the time header scale is set to day.
5669
 
  You can find details about the possible user defined format itself in the Qt documentation of:
5670
 
  QDateTime::toString ( const QString & format ) const
5671
 
  QDate::toString( const QString & format )
5672
 
  QTime::toString( const QString & format )
5673
 
 
5674
 
  \param the user defined date format of the time header in daily scale
5675
 
  \sa timeHeaderDateFormatDay()
5676
 
*/
5677
 
void KDGanttView::setTimeHeaderDateFormatDay( const QString& fmt )
5678
 
{
5679
 
    myTimeHeader->setDateFormatDay( fmt );
5680
 
}
5681
 
 
5682
 
 
5683
 
 
5684
 
/*!
5685
 
  Returns the user defined datetime format for the upper date row of the time header if the time header scale is set to second.
5686
 
  Returns an empty string as default, i.e. if there is no user defined format.
5687
 
  You can find details about the possible format itself in the Qt documentation of:
5688
 
  QDateTime::toString ( const QString & format ) const
5689
 
  QDate::toString( const QString & format )
5690
 
  QTime::toString( const QString & format )
5691
 
 
5692
 
  \return user defined date format of the time header in secondly scale
5693
 
  \sa setTimeHeaderDateFormatSecond()
5694
 
*/
5695
 
QString KDGanttView::timeHeaderDatetimeFormatSecond() const
5696
 
{
5697
 
    return myTimeHeader->datetimeFormatSecond();
5698
 
}
5699
 
/*!
5700
 
  Sets the user defined date format for the upper date row of the time header if the time header scale is set to second.
5701
 
  You can find details about the possible user defined format itself in the Qt documentation of:
5702
 
  QDateTime::toString ( const QString & format ) const
5703
 
  QDate::toString( const QString & format )
5704
 
  QTime::toString( const QString & format )
5705
 
 
5706
 
  \param the user defined date format of the time header in secondly scale
5707
 
  \sa timeHeaderDateFormatMinute()
5708
 
*/
5709
 
void KDGanttView::setTimeHeaderDatetimeFormatSecond( const QString& fmt )
5710
 
{
5711
 
    myTimeHeader->setDatetimeFormatSecond( fmt );
5712
 
}
5713
 
 
5714
 
/*!
5715
 
  Returns the user defined datetime format for the upper date row of the time header if the time header scale is set to minute.
5716
 
  Returns an empty string as default, i.e. if there is no user defined format.
5717
 
  You can find details about the possible format itself in the Qt documentation of:
5718
 
  QDateTime::toString ( const QString & format ) const
5719
 
  QDate::toString( const QString & format )
5720
 
  QTime::toString( const QString & format )
5721
 
 
5722
 
  \return user defined date format of the time header in minutely scale
5723
 
  \sa setTimeHeaderDateFormatMinute()
5724
 
*/
5725
 
QString KDGanttView::timeHeaderDatetimeFormatMinute() const
5726
 
{
5727
 
    return myTimeHeader->datetimeFormatMinute();
5728
 
}
5729
 
/*!
5730
 
  Sets the user defined date format for the upper date row of the time header if the time header scale is set to minute.
5731
 
  You can find details about the possible user defined format itself in the Qt documentation of:
5732
 
  QDateTime::toString ( const QString & format ) const
5733
 
  QDate::toString( const QString & format )
5734
 
  QTime::toString( const QString & format )
5735
 
 
5736
 
  \param the user defined date format of the time header in minutely scale
5737
 
  \sa timeHeaderDateFormatMinute()
5738
 
*/
5739
 
void KDGanttView::setTimeHeaderDatetimeFormatMinute( const QString& fmt )
5740
 
{
5741
 
    myTimeHeader->setDatetimeFormatMinute( fmt );
5742
 
}
5743
 
 
5744
 
 
5745
 
/*!
5746
 
  Returns the user defined datetime format for the upper date row of the time header if the time header scale is set to hour.
5747
 
  Returns an empty string as default, i.e. if there is no user defined format.
5748
 
  You can find details about the possible format itself in the Qt documentation of:
5749
 
  QDateTime::toString ( const QString & format ) const
5750
 
  QDate::toString( const QString & format )
5751
 
  QTime::toString( const QString & format )
5752
 
 
5753
 
  \return user defined date format of the time header in hourly scale
5754
 
  \sa setTimeHeaderDateFormatHour()
5755
 
*/
5756
 
QString KDGanttView::timeHeaderDatetimeFormatHour() const
5757
 
{
5758
 
    return myTimeHeader->datetimeFormatHour();
5759
 
}
5760
 
/*!
5761
 
  Sets the user defined date format for the upper date row of the time header if the time header scale is set to hour.
5762
 
  You can find details about the possible user defined format itself in the Qt documentation of:
5763
 
  QDateTime::toString ( const QString & format ) const
5764
 
  QDate::toString( const QString & format )
5765
 
  QTime::toString( const QString & format )
5766
 
 
5767
 
  \param the user defined date format of the time header in hourly scale
5768
 
  \sa timeHeaderDateFormatHour()
5769
 
*/
5770
 
void KDGanttView::setTimeHeaderDatetimeFormatHour( const QString& fmt )
5771
 
{
5772
 
    myTimeHeader->setDatetimeFormatHour( fmt );
5773
 
}
5774
 
/*!
5775
 
  Sets the week start to monday. The default week start is sunday.
5776
 
  This value is used in the time header to compute week starts for weekly scales.
5777
 
  If the global scale is set to day the upper row of the time header displays a weekly scale.
5778
 
  If the global scale is set to week the lower row of the time header displays a weekly scale.
5779
 
 
5780
 
 
5781
 
  \param pass true to set week start to monday
5782
 
         pass false to set week start to sunday
5783
 
  \sa weekStartsMonday()
5784
 
*/
5785
 
void KDGanttView::setWeekStartsMonday( bool b )
5786
 
{
5787
 
    myTimeHeader->setWeekStartsMonday( b );
5788
 
}
5789
 
 
5790
 
/*!
5791
 
  Returns true if the week start is monday, false if the week start is sunday
5792
 
 
5793
 
  \return true if the week start is monday, false if the week start is sunday
5794
 
  \sa setWeekStartsMonday()
5795
 
*/
5796
 
bool KDGanttView::weekStartsMonday() const
5797
 
{
5798
 
    return myTimeHeader->weekStartsMonday();
5799
 
}
5800
 
/*!
5801
 
  Sets to display week numbers if the global scale is set to week.
5802
 
  The ISO week numbering is used, i.e. the first week (week 1) of the year
5803
 
  is the first week which contains a Thursday.
5804
 
 
5805
 
 
5806
 
  \param pass true to display numbers of weeks
5807
 
         pass false display numbers of the day of the date where the week starts
5808
 
  \sa weekStartsMonday()
5809
 
*/
5810
 
void KDGanttView::setWeekScaleShowNumber( bool b )
5811
 
{
5812
 
    myTimeHeader->setWeekScaleShowNumber( b );
5813
 
}
5814
 
/*!
5815
 
  Returns true if the week scale displays week number.
5816
 
  The ISO week numbering is used, i.e. the first week (week 1) of the year
5817
 
  is the first week which contains a Thursday.
5818
 
 
5819
 
  \return true if the week scale displays week number
5820
 
  \sa setWeekScaleShowNumber()
5821
 
*/
5822
 
bool KDGanttView::weekScaleShowNumber() const
5823
 
{
5824
 
    return myTimeHeader->weekScaleShowNumber();
5825
 
}
5826
 
/*!
5827
 
  Returns the week number for a given Date.
5828
 
  The ISO week numbering is used, i.e. the first week (week 1) of the year
5829
 
  is the first week which contains a Thursday.
5830
 
 
5831
 
  \param date the date
5832
 
  \return the week number for the date
5833
 
  \sa setWeekScaleShowNumber() weekScaleShowNumber()
5834
 
*/
5835
 
int KDGanttView::getWeekOfYear( const QDate& date )
5836
 
{
5837
 
    return myTimeHeader->getWeekOfYear( date );
5838
 
}
5839
 
 
5840
 
/*!
5841
 
  This method is provided for convenience.
5842
 
  It returns the current day.
5843
 
  \return the current day
5844
 
*/
5845
 
 
5846
 
QDate KDGanttView::yesterday() const
5847
 
{
5848
 
    return myTimeHeader->yesterday() ;
5849
 
}
5850
 
/*!
5851
 
  This method is provided for convenience.
5852
 
  It returns the current day.
5853
 
  \return yesterday
5854
 
*/
5855
 
QDate KDGanttView::today() const
5856
 
{
5857
 
    return myTimeHeader->today() ;
5858
 
}
5859
 
/*!
5860
 
  This method is provided for convenience.
5861
 
  It returns the current day.
5862
 
  \return the next day
5863
 
*/
5864
 
QDate KDGanttView::tomorrow() const
5865
 
{
5866
 
    return myTimeHeader->tomorrow() ;
5867
 
}
5868
 
/*!
5869
 
  This method is provided for convenience.
5870
 
  It returns the start of the current week
5871
 
  depending on the value weekStartsOnMonday().
5872
 
  \return the start of current week
5873
 
*/
5874
 
QDate KDGanttView::currentWeek() const
5875
 
{
5876
 
    return myTimeHeader->currentWeek() ;
5877
 
}
5878
 
/*!
5879
 
  This method is provided for convenience.
5880
 
  It returns the start of the last week
5881
 
  (the week before current week)
5882
 
  depending on the value weekStartsOnMonday().
5883
 
  \return the start of last week (the week before current week)
5884
 
*/
5885
 
QDate KDGanttView::lastWeek() const
5886
 
{
5887
 
    return myTimeHeader->lastWeek() ;
5888
 
}
5889
 
/*!
5890
 
  This method is provided for convenience.
5891
 
  It returns the first day of the current month.
5892
 
  \return first day of the current month
5893
 
*/
5894
 
QDate KDGanttView::currentMonth() const
5895
 
{
5896
 
    return myTimeHeader->currentMonth() ;
5897
 
}
5898
 
/*!
5899
 
  This method is provided for convenience.
5900
 
  It returns the first day of last month.
5901
 
  \return first day of last month
5902
 
*/
5903
 
QDate KDGanttView::lastMonth() const
5904
 
{
5905
 
    return myTimeHeader->lastMonth() ;
5906
 
}
5907
 
/*!
5908
 
  This method is provided for convenience.
5909
 
  It returns first day of the current year.
5910
 
  \return first day of the current year
5911
 
*/
5912
 
QDate KDGanttView::currentYear() const
5913
 
{
5914
 
    return myTimeHeader->currentYear() ;
5915
 
}
5916
 
/*!
5917
 
  This method is provided for convenience.
5918
 
  It returns first day of the last year.
5919
 
  \return first day of the last year
5920
 
*/
5921
 
QDate KDGanttView::lastYear() const
5922
 
{
5923
 
    return myTimeHeader->lastYear() ;
5924
 
}
5925
 
 
5926
 
/*!
5927
 
  This slot is provided for convenience.
5928
 
  It centers the timeline on start of today.
5929
 
*/
5930
 
void KDGanttView::gotoToday()
5931
 
{
5932
 
    myTimeHeader->centerToday();
5933
 
}
5934
 
/*!
5935
 
  This slot is provided for convenience.
5936
 
  It centers the timeline on start of yesterday.
5937
 
*/
5938
 
void KDGanttView::gotoYesterday()
5939
 
{
5940
 
    myTimeHeader->centerYesterday();
5941
 
}
5942
 
/*!
5943
 
  This slot is provided for convenience.
5944
 
  It centers the timeline on start of current week.
5945
 
*/
5946
 
void KDGanttView::gotoCurrentWeek()
5947
 
{
5948
 
    myTimeHeader->centerCurrentWeek();
5949
 
}
5950
 
/*!
5951
 
  This slot is provided for convenience.
5952
 
  It centers the timeline on start of last week .
5953
 
*/
5954
 
void KDGanttView::gotoLastWeek()
5955
 
{
5956
 
    myTimeHeader->centerLastWeek();
5957
 
}
5958
 
/*!
5959
 
  This slot is provided for convenience.
5960
 
  It centers the timeline on start of current month.
5961
 
*/
5962
 
void KDGanttView::gotoCurrentMonth()
5963
 
{
5964
 
    myTimeHeader->centerCurrentMonth();
5965
 
}
5966
 
/*!
5967
 
  This slot is provided for convenience.
5968
 
  It centers the timeline on start of last month.
5969
 
*/
5970
 
void KDGanttView::gotoLastMonth()
5971
 
{
5972
 
    myTimeHeader->centerLastMonth();
5973
 
}
5974
 
/*!
5975
 
  This slot is provided for convenience.
5976
 
  It centers the timeline on start of current year.
5977
 
*/
5978
 
void KDGanttView::gotoCurrentYear()
5979
 
{
5980
 
    myTimeHeader->centerCurrentYear();
5981
 
}
5982
 
/*!
5983
 
  This slot is provided for convenience.
5984
 
  It centers the timeline on start of last year.
5985
 
*/
5986
 
void KDGanttView::gotoLastYear()
5987
 
{
5988
 
    myTimeHeader->centerLastYear();
5989
 
}
5990
 
/*!
5991
 
  This slot is provided for convenience.
5992
 
  It selects today as displayed timespan
5993
 
  and makes sure that the selected timespan
5994
 
  is visible in the gantt view
5995
 
  and sets the timeline start to the start
5996
 
  of the selected timespan.
5997
 
  The scale is set to KDGanttView::Hour.
5998
 
*/
5999
 
void KDGanttView::selectToday()
6000
 
{
6001
 
    myTimeHeader->showToday();
6002
 
}
6003
 
/*!
6004
 
  This slot is provided for convenience.
6005
 
  It selects yesterday as displayed timespan
6006
 
  and makes sure that the selected timespan
6007
 
  is visible in the gantt view
6008
 
  and sets the timeline start to the start
6009
 
  of the selected timespan.
6010
 
  The scale is set to KDGanttView::Hour.
6011
 
*/
6012
 
void KDGanttView::selectYesterday()
6013
 
{
6014
 
    myTimeHeader->showYesterday();
6015
 
}
6016
 
/*!
6017
 
  This slot is provided for convenience.
6018
 
  It selects the current week as displayed timespan
6019
 
  and makes sure that the selected timespan
6020
 
  is visible in the gantt view
6021
 
  and sets the timeline start to the start
6022
 
  of the selected timespan.
6023
 
  The scale is set to KDGanttView::Day.
6024
 
*/
6025
 
void KDGanttView::selectCurrentWeek()
6026
 
{
6027
 
    myTimeHeader->showCurrentWeek();
6028
 
}
6029
 
/*!
6030
 
  This slot is provided for convenience.
6031
 
  It selects the last week as displayed timespan
6032
 
  and makes sure that the selected timespan
6033
 
  is visible in the gantt view
6034
 
  and sets the timeline start to the start
6035
 
  of the selected timespan.
6036
 
  The scale is set to KDGanttView::Day.
6037
 
*/
6038
 
void KDGanttView::selectLastWeek()
6039
 
{
6040
 
    myTimeHeader->showLastWeek();
6041
 
}
6042
 
/*!
6043
 
  This slot is provided for convenience.
6044
 
  It selects the current month as displayed timespan
6045
 
  and makes sure that the selected timespan
6046
 
  is visible in the gantt view
6047
 
  and sets the timeline start to the start
6048
 
  of the selected timespan.
6049
 
  The scale is set to KDGanttView::Day.
6050
 
*/
6051
 
void KDGanttView::selectCurrentMonth()
6052
 
{
6053
 
    myTimeHeader->showCurrentMonth();
6054
 
}
6055
 
/*!
6056
 
  This slot is provided for convenience.
6057
 
  It selects the last month as displayed timespan
6058
 
  and makes sure that the selected timespan
6059
 
  is visible in the gantt view
6060
 
  and sets the timeline start to the start
6061
 
  of the selected timespan.
6062
 
  The scale is set to KDGanttView::Day.
6063
 
*/
6064
 
void KDGanttView::selectLastMonth()
6065
 
{
6066
 
    myTimeHeader->showLastMonth();
6067
 
}
6068
 
/*!
6069
 
  This slot is provided for convenience.
6070
 
  It selects the current year as displayed timespan
6071
 
  and makes sure that the selected timespan
6072
 
  is visible in the gantt view
6073
 
  and sets the timeline start to the start
6074
 
  of the selected timespan.
6075
 
  The scale is set to KDGanttView::Month.
6076
 
*/
6077
 
void KDGanttView::selectCurrentYear()
6078
 
{
6079
 
    myTimeHeader->showCurrentYear();
6080
 
}
6081
 
/*!
6082
 
  This slot is provided for convenience.
6083
 
  It selects the last year as displayed timespan
6084
 
  and makes sure that the selected timespan
6085
 
  is visible in the gantt view
6086
 
  and sets the timeline start to the start
6087
 
  of the selected timespan.
6088
 
  The scale is set to KDGanttView::Month.
6089
 
 */
6090
 
void KDGanttView::selectLastYear()
6091
 
{
6092
 
    myTimeHeader->showLastYear();
6093
 
}
6094
 
 
6095
 
/*!
6096
 
  \fn void KDGanttView::setConnectorEnabled(int connector, bool state)
6097
 
 
6098
 
  Enable or disable a connector.
6099
 
 
6100
 
  \param connector The connector to set.
6101
 
  \param state The state the connector is set to.
6102
 
  \sa isConnectorEnabled()
6103
 
 */
6104
 
void KDGanttView::setConnectorEnabled(int connector, bool state)
6105
 
{
6106
 
    myCanvasView->setConnectorEnabled(connector, state);
6107
 
}
6108
 
 
6109
 
/*!
6110
 
  \fn void KDGanttView::isConnectorEnabled()
6111
 
 
6112
 
  See if a connector is enabled or disabled.
6113
 
 
6114
 
  \param connector The connector to check.
6115
 
  \return The state of the connector.
6116
 
  \sa setConnectorEnabled()
6117
 
 */
6118
 
bool KDGanttView::isConnectorEnabled(int connector) const
6119
 
{
6120
 
    return myCanvasView->isConnectorEnabled(connector);
6121
 
}
6122
 
 
6123
 
/*!
6124
 
  \fn void KDGanttView::setAllConnectorsEnabled(bool state)
6125
 
 
6126
 
  Enable or disable all connectors.
6127
 
 
6128
 
  \param state The state the connectors are set to.
6129
 
 */
6130
 
void KDGanttView::setAllConnectorsEnabled(bool state)
6131
 
{
6132
 
    myCanvasView->setAllConnectorsEnabled(state);
6133
 
}
6134
 
 
6135
 
/*!
6136
 
  \fn void KDGanttView::setAutoScrollEnabled( bool state );
6137
 
 
6138
 
  Enables/disables scrolling when LMB is down.
6139
 
 
6140
 
  \param state If true, auto scrolling is enabled.
6141
 
 */
6142
 
void KDGanttView::setAutoScrollEnabled(bool state)
6143
 
{
6144
 
    myCanvasView->autoScrollEnabled = state;
6145
 
}
6146
 
 
6147
 
 
6148
 
/*!
6149
 
  \fn addOneTickLeft();
6150
 
 
6151
 
  This signal is emitted when userHorizonChangeEnabled() is set to false
6152
 
  and the slider of the vertical scrollbar of the gantt view is on the left side
6153
 
  and the user clicks the "left" arrow of the scrollbar
6154
 
  \sa setUserHorizonChangeEnabled() userHorizonChangeEnabled() addOneTickLeft()
6155
 
*/
6156
 
 
6157
 
/*!
6158
 
  \fn addOneTickRight();
6159
 
 
6160
 
  This signal is emitted when userHorizonChangeEnabled() is set to false
6161
 
  and the slider of the vertical scrollbar of the gantt view is on the right side
6162
 
  and the user clicks the "right" arrow of the scrollbar
6163
 
  \sa setUserHorizonChangeEnabled() userHorizonChangeEnabled() addOneTickRight()
6164
 
 
6165
 
*/
6166
 
/*!
6167
 
  \fn void KDGanttView:: itemDeleted( KDGanttViewItem* );
6168
 
 
6169
 
  This signal is emitted when a gantt item is deleted.
6170
 
  When the signal is emitted the pointer points to an existing KDGanttViewItem.
6171
 
  This  pointer will become invalid immediately after returning of the signal.
6172
 
*/
6173
 
 
6174
 
 
6175
 
/*!
6176
 
  \fn void KDGanttView::timeIntervalSelected( const QDateTime& start,  const QDateTime&  end);
6177
 
 
6178
 
  This signal is emitted when the user selects a time
6179
 
  interval with the mouse on the time header connect this signal to
6180
 
  the slot void zoomToSelection( const QDateTime& start, const
6181
 
  QDateTime& end) to obtain automatic zooming.
6182
 
*/
6183
 
 
6184
 
 
6185
 
/*!
6186
 
  \fn void KDGanttView::timeIntervallSelected( const QDateTime& start,  const QDateTime&  end);
6187
 
 
6188
 
  \deprecated This signal is deprecated, do not use it in new code;
6189
 
  use timeIntervalSelected() instead. timeIntervallSelected() will be
6190
 
  removed in future versions.
6191
 
*/
6192
 
 
6193
 
 
6194
 
/*!
6195
 
    \fn void KDGanttView::rescaling( Scale )
6196
 
 
6197
 
    This signal is emitted if another scale is chosen than the
6198
 
    specified one: i.e. if the horizon has a very wide range from
6199
 
    start to end and as scale is chosen minute it may be that the
6200
 
    size of the Gantt widget would become more than 32000 pixels. In
6201
 
    this case the scale is automatically changed to Hour and
6202
 
    rescaling( Hour ) is emitted.  If the widget size would be still
6203
 
    more than 32000 pixels, the scale is automatically changed to day
6204
 
    and rescaling( Day ) is emitted.  In the new scale, the
6205
 
    minortickcount is increased such that the horizon will fit in the
6206
 
    maximum size of 32000 pixels.
6207
 
*/
6208
 
 
6209
 
 
6210
 
/*!
6211
 
  \fn void KDGanttView::gvCurrentChanged( KDGanttViewItem* item )
6212
 
 
6213
 
  This signal is emitted whenever the user clicks on the Gantt view
6214
 
  \a item parameter is 0, if no item was clicked
6215
 
*/
6216
 
 
6217
 
 
6218
 
/*!
6219
 
  \fn void KDGanttView::gvItemLeftClicked( KDGanttViewItem* )
6220
 
 
6221
 
  This signal is emitted whenever the user clicks into the Gantt view
6222
 
  with the left mouse button.
6223
 
*/
6224
 
 
6225
 
 
6226
 
/*!
6227
 
  \fn void KDGanttView::gvItemMidClicked( KDGanttViewItem* )
6228
 
 
6229
 
  This signal is emitted whenever the user clicks into the Gantt view
6230
 
  with the middle mouse button.
6231
 
*/
6232
 
 
6233
 
/*!
6234
 
  \fn void KDGanttView::gvItemRightClicked( KDGanttViewItem* )
6235
 
 
6236
 
  This signal is emitted whenever the user clicks into the Gantt view
6237
 
  with the right mouse button.
6238
 
*/
6239
 
 
6240
 
/*!
6241
 
  \fn void KDGanttView::gvMouseButtonClicked ( int button, KDGanttViewItem* item, const QPoint & pos)
6242
 
 
6243
 
  This signal is emitted when the user clicks into the Gantt view with
6244
 
  any mouse button. Notice that \a pos is the absolute mouse position.
6245
 
*/
6246
 
 
6247
 
/*!
6248
 
  \fn void KDGanttView::gvItemDoubleClicked( KDGanttViewItem* )
6249
 
 
6250
 
  This signal is emitted whenever the user double-clicks into the Gantt view.
6251
 
*/
6252
 
 
6253
 
/*!
6254
 
  \fn void KDGanttView::gvContextMenuRequested ( KDGanttViewItem * item, const QPoint & pos )
6255
 
 
6256
 
  This signal is emitted when the user requests a context menu in the
6257
 
  Gantt view. Notice that \a pos is the absolute mouse position.
6258
 
*/
6259
 
 
6260
 
 
6261
 
/*!
6262
 
  \fn void KDGanttView::lvCurrentChanged( KDGanttViewItem* item )
6263
 
 
6264
 
  This signal is emitted whenever the user clicks on the list view
6265
 
  \a item parameter is 0, if no item was clicked
6266
 
*/
6267
 
 
6268
 
 
6269
 
/*!
6270
 
  \fn void KDGanttView::lvItemLeftClicked( KDGanttViewItem* )
6271
 
 
6272
 
  This signal is emitted whenever the user clicks into the list view
6273
 
  with the left mouse button.
6274
 
*/
6275
 
 
6276
 
 
6277
 
/*!
6278
 
  \fn void KDGanttView::lvItemMidClicked( KDGanttViewItem* )
6279
 
 
6280
 
  This signal is emitted whenever the user clicks into the list view
6281
 
  with the middle mouse button.
6282
 
*/
6283
 
 
6284
 
/*!
6285
 
  \fn void KDGanttView::lvItemRightClicked( KDGanttViewItem* )
6286
 
 
6287
 
  This signal is emitted whenever the user clicks into the list view
6288
 
  with the right mouse button.
6289
 
*/
6290
 
 
6291
 
/*!
6292
 
  \fn void KDGanttView::lvMouseButtonPressed ( int button,
6293
 
  KDGanttViewItem* item, const QPoint & pos, int col)
6294
 
 
6295
 
  This signal is emitted when the user presses any mouse button in the
6296
 
  list view. Notice that \a pos is the absolute mouse position.
6297
 
*/
6298
 
 
6299
 
/*!
6300
 
  \fn void KDGanttView::lvMouseButtonClicked ( int button,
6301
 
  KDGanttViewItem* item, const QPoint & pos, int col)
6302
 
 
6303
 
  This signal is emitted when the user clicks into the
6304
 
  list view with any mouse button . Notice that \a pos is the absolute
6305
 
  mouse position.
6306
 
*/
6307
 
 
6308
 
/*!
6309
 
  \fn void KDGanttView::lvItemDoubleClicked( KDGanttViewItem* )
6310
 
 
6311
 
  This signal is emitted whenever the user double-clicks into the list view.
6312
 
*/
6313
 
 
6314
 
/*!
6315
 
  \fn void KDGanttView::lvItemRenamed( KDGanttViewItem*, int col,
6316
 
  const QString& text )
6317
 
 
6318
 
  This signal is emitted whenever the user changes the name of an item
6319
 
  in the list view using in-place editing. \a text contains the new
6320
 
  text in the list view.
6321
 
*/
6322
 
 
6323
 
/*!
6324
 
  \fn void KDGanttView::lvContextMenuRequested( KDGanttViewItem *
6325
 
  item, const QPoint & pos, int col )
6326
 
 
6327
 
  This signal is emitted when the user requests a context menu in the
6328
 
  list view. Notice that \a pos is the absolute mouse position.
6329
 
*/
6330
 
 
6331
 
/*!
6332
 
  \fn void KDGanttView::lvSelectionChanged( KDGanttViewItem* )
6333
 
 
6334
 
  This signal is emitted whenever the user changes the selection in
6335
 
  the list view.
6336
 
*/
6337
 
 
6338
 
 
6339
 
/*!
6340
 
  \fn void KDGanttView::dropped ( QDropEvent * e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse)
6341
 
 
6342
 
  This signal is emitted whenever a Gantt item is dropped onto the
6343
 
  Gantt view. \a droppedItem is 0, if this is a drag operation from
6344
 
  another KDGanttView instance. If this drag is an internal drag
6345
 
  (i.e. within the KDGanttView), this parameter points to the dropped item.
6346
 
  \a itemBelowMouse is a pointer to the item below the dragged
6347
 
  item (i.e., below the mouse). The dragged item may be inserted
6348
 
  in the KDGanttView as a child of this item.
6349
 
  If The value is 0, if there is no item below the dragged item,
6350
 
  and the dragged item will be inserted as a root item.
6351
 
 
6352
 
  In order to get user-defined behavior for drop events, reimplement
6353
 
  KDGanttView::lvDropEvent()
6354
 
*/
6355
 
 
6356
 
 
6357
 
/*!
6358
 
  \enum KDGanttView::RepaintMode
6359
 
 
6360
 
  Please see setRepaintMode() for a description of the values of this
6361
 
  enumeration.
6362
 
*/
6363
 
 
6364
 
/*!
6365
 
  \fn void gvCreateTaskLink( KDGanttViewItem* fr, int fc, KDGanttViewItem* to, int tc)
6366
 
 
6367
 
  This signal is emitted whenever two items shall be linked.
6368
 
 
6369
 
  \param fr The item to link from.
6370
 
  \param fc The KDGanttViewItem::Connector to link from.
6371
 
  \param to The item to link to.
6372
 
  \param tc The KDGanttViewItem::Connector to link to.
6373
 
 */
6374
 
 
6375
 
#include "KDGanttView.moc"