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