00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef KDGANTTVIEW_H
00036 #define KDGANTTVIEW_H
00037
00038 #include <qptrlist.h>
00039 #include <qwidget.h>
00040 #include <qlistview.h>
00041 #include <qsplitter.h>
00042 #include <qlayout.h>
00043 #include <qfont.h>
00044 #include <qdom.h>
00045 #include <qvbox.h>
00046
00047
00048 #include "KDGanttViewItem.h"
00049 #include "KDGanttViewTaskLinkGroup.h"
00050 #include "KDGanttMinimizeSplitter.h"
00051 #include "KDGanttViewItemDrag.h"
00052
00053 class KDIntervalColorRectangle;
00054 class KDGanttViewTaskLink;
00055 class QPrinter;
00056 class QIODevice;
00057 class itemAttributeDialog;
00058 class KDListView;
00059 class KDGanttViewItem;
00060 class KDGanttViewEventItem;
00061 class KDGanttViewTaskItem;
00062 class KDGanttViewSummaryItem;
00063 class KDTimeTableWidget;
00064 class KDTimeHeaderWidget;
00065 class KDLegendWidget;
00066 class KDGanttCanvasView;
00067 class KDGanttViewTaskLink;
00068 class KDGanttMinimizeSplitter;
00069
00070 class KDGanttView : public KDGanttMinimizeSplitter
00071 {
00072 Q_OBJECT
00073
00074 Q_PROPERTY( bool showLegend READ showLegend WRITE setShowLegend )
00075 Q_PROPERTY( bool showListView READ showListView WRITE setShowListView )
00076 Q_PROPERTY( bool showTaskLinks READ showTaskLinks WRITE setShowTaskLinks )
00077 Q_PROPERTY( bool editorEnabled READ editorEnabled WRITE setEditorEnabled )
00078 Q_PROPERTY( QDateTime horizonStart READ horizonStart WRITE setHorizonStart )
00079 Q_PROPERTY( QDateTime horizonEnd READ horizonEnd WRITE setHorizonEnd )
00080 Q_PROPERTY( Scale scale READ scale WRITE setScale )
00081 Q_PROPERTY( YearFormat yearFormat READ yearFormat WRITE setYearFormat )
00082 Q_PROPERTY( HourFormat hourFormat READ hourFormat WRITE setHourFormat )
00083 Q_PROPERTY( bool showMinorTicks READ showMinorTicks WRITE setShowMinorTicks )
00084 Q_PROPERTY( bool showMajorTicks READ showMajorTicks WRITE setShowMajorTicks )
00085 Q_PROPERTY( bool editable READ editable WRITE setEditable )
00086 Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor )
00087 Q_PROPERTY( int majorScaleCount READ majorScaleCount WRITE setMajorScaleCount )
00088 Q_PROPERTY( int minorScaleCount READ minorScaleCount WRITE setMinorScaleCount )
00089 Q_PROPERTY( int autoScaleMinorTickCount READ autoScaleMinorTickCount WRITE setAutoScaleMinorTickCount )
00090 Q_PROPERTY( Scale maximumScale READ maximumScale WRITE setMaximumScale )
00091 Q_PROPERTY( Scale minimumScale READ minimumScale WRITE setMinimumScale )
00092 Q_PROPERTY( int minimumColumnWidth READ minimumColumnWidth WRITE setMinimumColumnWidth )
00093 Q_PROPERTY( int ganttMaximumWidth READ ganttMaximumWidth WRITE setGanttMaximumWidth )
00094 Q_PROPERTY( QColor weekendBackgroundColor READ weekendBackgroundColor WRITE setWeekendBackgroundColor )
00095 Q_PROPERTY( QColor ganttViewBackgroundColor READ gvBackgroundColor WRITE setGvBackgroundColor )
00096 Q_PROPERTY( QColor listViewBackgroundColor READ lvBackgroundColor WRITE setLvBackgroundColor )
00097 Q_PROPERTY( QColor timeHeaderBackgroundColor READ timeHeaderBackgroundColor WRITE setTimeHeaderBackgroundColor )
00098 Q_PROPERTY( QColor legendHeaderBackgroundColor READ legendHeaderBackgroundColor WRITE setLegendHeaderBackgroundColor )
00099 Q_PROPERTY( double zoomFactor READ zoomFactor )
00100 Q_PROPERTY( bool showHeaderPopupMenu READ showHeaderPopupMenu WRITE setShowHeaderPopupMenu )
00101 Q_PROPERTY( bool showTimeTablePopupMenu READ showTimeTablePopupMenu WRITE setShowTimeTablePopupMenu )
00102 Q_PROPERTY( bool headerVisible READ headerVisible WRITE setHeaderVisible )
00103 Q_PROPERTY( bool showLegendButton READ showLegendButton WRITE setShowLegendButton )
00104 Q_PROPERTY( bool legendIsDockwindow READ legendIsDockwindow WRITE setLegendIsDockwindow )
00105 Q_PROPERTY( bool displayEmptyTasksAsLine READ displayEmptyTasksAsLine WRITE setDisplayEmptyTasksAsLine )
00106 Q_PROPERTY( QBrush noInformationBrush READ noInformationBrush WRITE setNoInformationBrush )
00107 Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled )
00108 Q_PROPERTY( bool dropEnabled READ dropEnabled WRITE setDropEnabled )
00109 Q_PROPERTY( bool calendarMode READ calendarMode WRITE setCalendarMode )
00110
00111 Q_ENUMS( Scale )
00112 Q_ENUMS( YearFormat )
00113 Q_ENUMS( HourFormat )
00114
00115 public:
00116 enum Scale { Minute, Hour, Day, Week, Month, Auto };
00117 enum YearFormat { FourDigit, TwoDigit, TwoDigitApostrophe, NoDate };
00118 enum HourFormat { Hour_24, Hour_12, Hour_24_FourDigit };
00119 enum RepaintMode { No, Medium, Always };
00120
00121 KDGanttView( QWidget* parent = 0, const char* name = 0 );
00122 ~KDGanttView();
00123
00124 virtual void show();
00125 virtual bool close ( bool alsoDelete );
00126 void setRepaintMode( RepaintMode mode );
00127 void setUpdateEnabled( bool enable);
00128 bool getUpdateEnabled( )const;
00129
00130 void setGanttMaximumWidth( int w );
00131 int ganttMaximumWidth() const;
00132 void setShowLegend( bool show );
00133 bool showLegend() const;
00134 void setLegendIsDockwindow( bool dock );
00135 bool legendIsDockwindow( ) const;
00136 QDockWindow* legendDockwindow( ) const;
00137 void setShowListView( bool show );
00138 bool showListView() const;
00139 void setEditorEnabled( bool enable );
00140 bool editorEnabled() const;
00141 void setListViewWidth( int );
00142 int listViewWidth();
00143 void setEditable( bool editable );
00144 bool editable() const;
00145 void setCalendarMode( bool mode );
00146 bool calendarMode() const;
00147 void setDisplaySubitemsAsGroup( bool show );
00148 bool displaySubitemsAsGroup() const;
00149 void setDisplayEmptyTasksAsLine( bool show );
00150 bool displayEmptyTasksAsLine() const;
00151
00152 void setHorBackgroundLines( int count = 2,
00153 QBrush brush =
00154 QBrush( QColor ( 200,200,200 ),
00155 Qt::Dense6Pattern ));
00156 int horBackgroundLines( QBrush& brush );
00157 bool saveProject( QIODevice* );
00158 bool loadProject( QIODevice* );
00159 void print( QPrinter* printer = 0 ,
00160 bool printListView = true, bool printTimeLine = true,
00161 bool printLegend = false );
00162 QSize drawContents( QPainter* p = 0,
00163 bool drawListView = true, bool drawTimeLine = true,
00164 bool drawLegend = false );
00165 void setZoomFactor( double factor, bool absolute );
00166 double zoomFactor() const;
00167 void zoomToFit();
00168 void ensureVisible( KDGanttViewItem* );
00169 void center( KDGanttViewItem* );
00170 void centerTimeline( const QDateTime& center );
00171 void centerTimelineAfterShow( const QDateTime& center );
00172 void setTimelineToStart();
00173 void setTimelineToEnd();
00174 void addTicksLeft( int num = 1 );
00175 void addTicksRight( int num = 1 );
00176 void setShowTaskLinks( bool show );
00177 bool showTaskLinks() const;
00178
00179 void setFont(const QFont& f);
00180 void setShowHeaderPopupMenu( bool show = true,
00181 bool showZoom = true,
00182 bool showScale = true,
00183 bool showTime = true,
00184 bool showYear = true,
00185 bool showGrid = true,
00186 bool showPrint = false);
00187 bool showHeaderPopupMenu() const;
00188 void setShowTimeTablePopupMenu( bool );
00189 bool showTimeTablePopupMenu() const;
00190 void setShapes( KDGanttViewItem::Type type,
00191 KDGanttViewItem::Shape start,
00192 KDGanttViewItem::Shape middle,
00193 KDGanttViewItem::Shape end,
00194 bool overwriteExisting = true );
00195 bool shapes( KDGanttViewItem::Type type,
00196 KDGanttViewItem::Shape& start,
00197 KDGanttViewItem::Shape& middle,
00198 KDGanttViewItem::Shape& end ) const;
00199 void setColors( KDGanttViewItem::Type type,
00200 const QColor& start, const QColor& middle,
00201 const QColor& end,
00202 bool overwriteExisting = true );
00203 bool colors( KDGanttViewItem::Type type,
00204 QColor& start, QColor& middle, QColor& end ) const;
00205 void setDefaultColor( KDGanttViewItem::Type type,
00206 const QColor&,
00207 bool overwriteExisting = true );
00208 QColor defaultColor( KDGanttViewItem::Type type ) const;
00209 void setHighlightColors( KDGanttViewItem::Type type,
00210 const QColor& start, const QColor& middle,
00211 const QColor& end,
00212 bool overwriteExisting = true );
00213 bool highlightColors( KDGanttViewItem::Type type,
00214 QColor& start, QColor& middle, QColor& end ) const;
00215 void setDefaultHighlightColor( KDGanttViewItem::Type type,
00216 const QColor&,
00217 bool overwriteExisting = true );
00218 QColor defaultHighlightColor( KDGanttViewItem::Type type ) const;
00219 void setTextColor( const QColor& color );
00220 QColor textColor() const;
00221
00222 void setNoInformationBrush( const QBrush& brush );
00223 QBrush noInformationBrush() const;
00224
00225
00226 QPtrList<KDGanttViewTaskLink> taskLinks() const;
00227 QPtrList<KDGanttViewTaskLinkGroup> taskLinkGroups() const;
00228
00229
00230 void addLegendItem( KDGanttViewItem::Shape shape, const QColor& shapeColor, const QString& text );
00231 void clearLegend();
00232
00233 void setHorizonStart( const QDateTime& start );
00234 QDateTime horizonStart() const;
00235 void setHorizonEnd( const QDateTime& start );
00236 QDateTime horizonEnd() const;
00237 void setScale( Scale );
00238 Scale scale() const;
00239 void setMaximumScale( Scale );
00240 Scale maximumScale() const;
00241 void setMinimumScale( Scale );
00242 Scale minimumScale() const;
00243 void setAutoScaleMinorTickCount( int count );
00244 int autoScaleMinorTickCount() const;
00245 void setMajorScaleCount( int count );
00246 int majorScaleCount() const;
00247 void setMinorScaleCount( int count );
00248 int minorScaleCount() const;
00249 void setMinimumColumnWidth( int width );
00250 int minimumColumnWidth() const;
00251 void setYearFormat( YearFormat format );
00252 YearFormat yearFormat() const;
00253 void setHourFormat( HourFormat format );
00254 HourFormat hourFormat() const;
00255 void setShowMajorTicks( bool );
00256 bool showMajorTicks() const;
00257 void setShowMinorTicks( bool );
00258 bool showMinorTicks() const;
00259 void setColumnBackgroundColor( const QDateTime& column,
00260 const QColor& color,
00261 Scale mini = KDGanttView::Minute ,
00262 Scale maxi = KDGanttView::Month);
00263 #if 0
00264
00265 void setIntervalBackgroundColor( const QDateTime& start,
00266 const QDateTime& end,
00267 const QColor& color,
00268 Scale mini = KDGanttView::Minute ,
00269 Scale maxi = KDGanttView::Month);
00270 bool changeBackgroundInterval( const QDateTime& oldstart,
00271 const QDateTime& oldend,
00272 const QDateTime& newstart,
00273 const QDateTime& newend );
00274 bool deleteBackgroundInterval( const QDateTime& start,
00275 const QDateTime& end );
00276 #endif
00277 void addIntervalBackgroundColor( KDIntervalColorRectangle* newItem );
00278 void clearBackgroundColor();
00279 QColor columnBackgroundColor( const QDateTime& column ) const;
00280 void setWeekendBackgroundColor( const QColor& color );
00281 QColor weekendBackgroundColor() const;
00282 void setWeekdayBackgroundColor( const QColor& color, int weekday );
00283 QColor weekdayBackgroundColor(int weekday) const;
00284
00285
00286 void setPaletteBackgroundColor(const QColor& col);
00287 void setGvBackgroundColor ( const QColor & );
00288 void setLvBackgroundColor ( const QColor & );
00289 void setTimeHeaderBackgroundColor ( const QColor & );
00290 void setLegendHeaderBackgroundColor ( const QColor & );
00291 QColor gvBackgroundColor () const ;
00292 QColor lvBackgroundColor () const ;
00293 QColor timeHeaderBackgroundColor () const ;
00294 QColor legendHeaderBackgroundColor () const ;
00295 void addUserdefinedLegendHeaderWidget( QWidget * w );
00296
00297 void setWeekendDays( int start, int end );
00298 void weekendDays( int& start, int& end ) const;
00299
00300 static QPixmap getPixmap( KDGanttViewItem::Shape shape, const QColor& shapeColor,const QColor& backgroundColor, int itemSize);
00301
00302 void setHeaderVisible( bool );
00303 bool headerVisible() const;
00304
00305 void setShowLegendButton( bool show );
00306 bool showLegendButton() const;
00307
00308
00309 virtual int addColumn( const QString& label, int width = -1 );
00310 virtual int addColumn( const QIconSet& iconset, const QString& label,
00311 int width = -1 );
00312 virtual void removeColumn( int index );
00313 KDGanttViewItem* selectedItem() const;
00314 void setSelected( KDGanttViewItem*, bool );
00315 KDGanttViewItem* firstChild() const;
00316 KDGanttViewItem* lastItem() const;
00317 int childCount() const;
00318 void clear();
00319
00320 void setDragEnabled( bool b );
00321 void setDropEnabled( bool b );
00322 void setDragDropEnabled( bool b );
00323 bool dragEnabled() const;
00324 bool dropEnabled() const;
00325 bool isDragEnabled() const;
00326 bool isDropEnabled() const;
00327
00328 virtual bool lvDropEvent ( QDropEvent *e, KDGanttViewItem*, KDGanttViewItem*);
00329 virtual void lvStartDrag (KDGanttViewItem*);
00330 virtual bool lvDragMoveEvent (QDragMoveEvent * e,KDGanttViewItem*, KDGanttViewItem*);
00331 virtual void lvDragEnterEvent (QDragEnterEvent * e );
00332 virtual QSize sizeHint() const;
00333 KDGanttViewItem* getItemByName( const QString& name ) const;
00334 QDateTime getDateTimeForCoordX(int coordX, bool global = true ) const;
00335 KDGanttViewItem* getItemByListViewPos( const QPoint& pos ) const;
00336 KDGanttViewItem* getItemByGanttViewPos( const QPoint& pos ) const;
00337 KDGanttViewItem* getItemAt( const QPoint& pos , bool global = true ) const;
00338
00339
00340
00341 void setLvVScrollBarMode( QScrollView::ScrollBarMode );
00342 void setGvVScrollBarMode( QScrollView::ScrollBarMode );
00343
00344 void setLinkItemsEnabled(bool on);
00345 bool isLinkItemsEnabled() const;
00346
00347 KDTimeTableWidget * timeTableWidget() { return myTimeTable; }
00348 KDTimeHeaderWidget * timeHeaderWidget() { return myTimeHeader; }
00349
00350 void setFixedHorizon( bool f ) { mFixedHorizon = f; }
00351
00352 public slots:
00353 void editItem( KDGanttViewItem* );
00354 void zoomToSelection( const QDateTime& start, const QDateTime& end);
00355
00356 signals:
00357 void timeIntervallSelected( const QDateTime& start, const QDateTime& end);
00358 void timeIntervalSelected( const QDateTime& start, const QDateTime& end);
00359 void rescaling( KDGanttView::Scale );
00360 void intervalColorRectangleMoved( const QDateTime& start, const QDateTime& end );
00361
00362
00363
00364 void itemLeftClicked( KDGanttViewItem* );
00365 void itemMidClicked( KDGanttViewItem* );
00366 void itemRightClicked( KDGanttViewItem* );
00367 void itemDoubleClicked( KDGanttViewItem* );
00368
00369
00370 void linkItems( KDGanttViewItem* from, KDGanttViewItem* to, int linkType );
00371
00372
00373
00374
00375
00376 void gvCurrentChanged( KDGanttViewItem* );
00377 void gvItemLeftClicked( KDGanttViewItem* );
00378 void gvItemMidClicked( KDGanttViewItem* );
00379 void gvItemRightClicked( KDGanttViewItem* );
00380
00381 void gvMouseButtonClicked ( int button, KDGanttViewItem* item, const QPoint & pos);
00382 void gvItemDoubleClicked( KDGanttViewItem* );
00383
00384 void gvContextMenuRequested ( KDGanttViewItem * item, const QPoint & pos );
00385 void gvItemMoved( KDGanttViewItem* );
00386
00387
00388 void lvCurrentChanged( KDGanttViewItem* );
00389 void lvItemRenamed( KDGanttViewItem* , int col, const QString & text );
00390 void lvMouseButtonPressed( int button, KDGanttViewItem * item, const QPoint & pos, int c );
00391 void lvItemLeftClicked( KDGanttViewItem* );
00392 void lvItemMidClicked( KDGanttViewItem* );
00393 void lvItemRightClicked( KDGanttViewItem* );
00394 void lvContextMenuRequested ( KDGanttViewItem * item, const QPoint & pos, int col );
00395 void lvMouseButtonClicked ( int button, KDGanttViewItem* item, const QPoint & pos, int c );
00396 void lvItemDoubleClicked( KDGanttViewItem* );
00397 void lvSelectionChanged( KDGanttViewItem* );
00398
00399 void itemConfigured( KDGanttViewItem* );
00400
00401 void taskLinkLeftClicked( KDGanttViewTaskLink* );
00402 void taskLinkMidClicked( KDGanttViewTaskLink* );
00403 void taskLinkRightClicked( KDGanttViewTaskLink* );
00404 void taskLinkDoubleClicked( KDGanttViewTaskLink* );
00405
00406 void dateTimeDoubleClicked (const QDateTime& );
00407
00408 void dropped ( QDropEvent * e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse);
00409 private slots:
00410 void forceRepaint( int val = 0 );
00411 void slotSelectionChanged( QListViewItem* item );
00412 void slotCurrentChanged ( QListViewItem * item );
00413 void slotItemRenamed ( QListViewItem * item, int col, const QString & text );
00414 void slotMouseButtonPressed ( int button, QListViewItem * item, const QPoint & pos, int c );
00415 void slotmouseButtonClicked ( int button, QListViewItem * item, const QPoint & pos, int c );
00416 void slotcontextMenuRequested ( QListViewItem * item, const QPoint & pos, int col );
00417 void slotdoubleClicked ( QListViewItem * item );
00418 void slotHeaderSizeChanged();
00419 void addTickRight();
00420 void addTickLeft();
00421 void enableAdding( int );
00422 void slot_lvDropped(QDropEvent* e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse );
00423 private:
00424 struct legendItem {
00425 KDGanttViewItem::Shape shape;
00426 QColor color;
00427 QString text;
00428 };
00429 bool loadXML( const QDomDocument& doc );
00430 QDomDocument saveXML( bool withPI = true ) const;
00431
00432 void emptySpaceDoubleClicked( QMouseEvent* e );
00433
00434 static QString scaleToString( Scale scale );
00435 static QString yearFormatToString( YearFormat format );
00436 static QString hourFormatToString( HourFormat format );
00437 static Scale stringToScale( const QString& string );
00438 static YearFormat stringToYearFormat( const QString& string );
00439 static HourFormat stringToHourFormat( const QString& string );
00440
00441
00442 friend class KDGanttCanvasView;
00443 friend class KDGanttViewEventItem;
00444 friend class KDGanttViewItem;
00445 friend class KDGanttViewTaskItem;
00446 friend class KDGanttViewSummaryItem;
00447 friend class KDGanttViewTaskLink;
00448 friend class KDGanttViewCalendarItem;
00449 friend class KDTimeTableWidget;
00450 friend class KDTimeHeaderWidget;
00451 friend class KDListView;
00452 friend class KDGanttViewTaskLinkGroup;
00453 friend class KDLegendWidget;
00454
00455 KDListView * myListView;
00456 KDGanttCanvasView *myCanvasView;
00457 KDTimeHeaderWidget * myTimeHeader;
00458 KDTimeTableWidget * myTimeTable;
00459 KDLegendWidget * myLegend;
00460 itemAttributeDialog* myItemAttributeDialog;
00461 QVBox * leftWidget, * rightWidget;
00462 QHBox * spacerLeft;
00463 QScrollView* myTimeHeaderScroll;
00464 QHBox* myTimeHeaderContainer ;
00465 QWidget* timeHeaderSpacerWidget;
00466 QWidget *spacerRight;
00467
00468 bool listViewIsVisible;
00469 bool chartIsEditable;
00470 bool editorIsEnabled;
00471 bool _displaySubitemsAsGroup;
00472 bool _displayEmptyTasksAsLine;
00473 bool _showLegendButton;
00474 bool _showHeader;
00475 bool _enableAdding;
00476 bool fCenterTimeLineAfterShow;
00477 bool fDragEnabled;
00478 bool fDropEnabled;
00479 bool closingBlocked;
00480 QDateTime dtCenterTimeLineAfterShow;
00481 KDGanttViewItem::Shape myDefaultShape [9];
00482 QColor myColor[9],myColorHL[9];
00483 bool undefinedShape[3],undefinedColor[3],undefinedColorHL[3];
00484 QColor myTextColor;
00485 QColor myDefaultColor[3],myDefaultColorHL[3];
00486 QPtrList<KDGanttViewTaskLinkGroup> myTaskLinkGroupList;
00487 QPtrList<legendItem> *myLegendItems;
00488 void addTaskLinkGroup(KDGanttViewTaskLinkGroup*);
00489 void removeTaskLinkGroup(KDGanttViewTaskLinkGroup*);
00490 int getIndex( KDGanttViewItem::Type ) const;
00491 void notifyEditdialog( KDGanttViewItem * );
00492 void initDefaults();
00493 KDGanttViewItem* myCurrentItem;
00494 KDGanttMinimizeSplitter *mySplitter;
00495 bool mFixedHorizon;
00496 protected:
00497 virtual QDragObject * dragObject ();
00498 virtual void startDrag ();
00499 };
00500
00501
00502
00503 #endif