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 <tqptrlist.h>
00039 #include <tqwidget.h>
00040 #include <tqlistview.h>
00041 #include <tqsplitter.h>
00042 #include <tqlayout.h>
00043 #include <tqfont.h>
00044 #include <tqdom.h>
00045 #include <tqvbox.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 TQPrinter;
00056 class TQIODevice;
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( TQDateTime horizonStart READ horizonStart WRITE setHorizonStart )
00079 Q_PROPERTY( TQDateTime 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( TQColor 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( TQColor weekendBackgroundColor READ weekendBackgroundColor WRITE setWeekendBackgroundColor )
00095 Q_PROPERTY( TQColor ganttViewBackgroundColor READ gvBackgroundColor WRITE setGvBackgroundColor )
00096 Q_PROPERTY( TQColor listViewBackgroundColor READ lvBackgroundColor WRITE setLvBackgroundColor )
00097 Q_PROPERTY( TQColor timeHeaderBackgroundColor READ timeHeaderBackgroundColor WRITE setTimeHeaderBackgroundColor )
00098 Q_PROPERTY( TQColor 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( TQBrush 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( TQWidget* 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 TQDockWindow* 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 TQBrush brush =
00154 TQBrush( TQColor ( 200,200,200 ),
00155 Qt::Dense6Pattern ));
00156 int horBackgroundLines( TQBrush& brush );
00157 bool saveProject( TQIODevice* );
00158 bool loadProject( TQIODevice* );
00159 void print( TQPrinter* printer = 0 ,
00160 bool printListView = true, bool printTimeLine = true,
00161 bool printLegend = false );
00162 TQSize drawContents( TQPainter* 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 TQDateTime& center );
00171 void centerTimelineAfterShow( const TQDateTime& 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 TQFont& 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 TQColor& start, const TQColor& middle,
00201 const TQColor& end,
00202 bool overwriteExisting = true );
00203 bool colors( KDGanttViewItem::Type type,
00204 TQColor& start, TQColor& middle, TQColor& end ) const;
00205 void setDefaultColor( KDGanttViewItem::Type type,
00206 const TQColor&,
00207 bool overwriteExisting = true );
00208 TQColor defaultColor( KDGanttViewItem::Type type ) const;
00209 void setHighlightColors( KDGanttViewItem::Type type,
00210 const TQColor& start, const TQColor& middle,
00211 const TQColor& end,
00212 bool overwriteExisting = true );
00213 bool highlightColors( KDGanttViewItem::Type type,
00214 TQColor& start, TQColor& middle, TQColor& end ) const;
00215 void setDefaultHighlightColor( KDGanttViewItem::Type type,
00216 const TQColor&,
00217 bool overwriteExisting = true );
00218 TQColor defaultHighlightColor( KDGanttViewItem::Type type ) const;
00219 void setTextColor( const TQColor& color );
00220 TQColor textColor() const;
00221
00222 void setNoInformationBrush( const TQBrush& brush );
00223 TQBrush noInformationBrush() const;
00224
00225
00226 TQPtrList<KDGanttViewTaskLink> taskLinks() const;
00227 TQPtrList<KDGanttViewTaskLinkGroup> taskLinkGroups() const;
00228
00229
00230 void addLegendItem( KDGanttViewItem::Shape shape, const TQColor& shapeColor, const TQString& text );
00231 void clearLegend();
00232
00233 void setHorizonStart( const TQDateTime& start );
00234 TQDateTime horizonStart() const;
00235 void setHorizonEnd( const TQDateTime& start );
00236 TQDateTime 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 TQDateTime& column,
00260 const TQColor& color,
00261 Scale mini = KDGanttView::Minute ,
00262 Scale maxi = KDGanttView::Month);
00263 #if 0
00264
00265 void setIntervalBackgroundColor( const TQDateTime& start,
00266 const TQDateTime& end,
00267 const TQColor& color,
00268 Scale mini = KDGanttView::Minute ,
00269 Scale maxi = KDGanttView::Month);
00270 bool changeBackgroundInterval( const TQDateTime& oldstart,
00271 const TQDateTime& oldend,
00272 const TQDateTime& newstart,
00273 const TQDateTime& newend );
00274 bool deleteBackgroundInterval( const TQDateTime& start,
00275 const TQDateTime& end );
00276 #endif
00277 void addIntervalBackgroundColor( KDIntervalColorRectangle* newItem );
00278 void clearBackgroundColor();
00279 TQColor columnBackgroundColor( const TQDateTime& column ) const;
00280 void setWeekendBackgroundColor( const TQColor& color );
00281 TQColor weekendBackgroundColor() const;
00282 void setWeekdayBackgroundColor( const TQColor& color, int weekday );
00283 TQColor weekdayBackgroundColor(int weekday) const;
00284
00285
00286 void setPaletteBackgroundColor(const TQColor& col);
00287 void setGvBackgroundColor ( const TQColor & );
00288 void setLvBackgroundColor ( const TQColor & );
00289 void setTimeHeaderBackgroundColor ( const TQColor & );
00290 void setLegendHeaderBackgroundColor ( const TQColor & );
00291 TQColor gvBackgroundColor () const ;
00292 TQColor lvBackgroundColor () const ;
00293 TQColor timeHeaderBackgroundColor () const ;
00294 TQColor legendHeaderBackgroundColor () const ;
00295 void addUserdefinedLegendHeaderWidget( TQWidget * w );
00296
00297 void setWeekendDays( int start, int end );
00298 void weekendDays( int& start, int& end ) const;
00299
00300 static TQPixmap getPixmap( KDGanttViewItem::Shape shape, const TQColor& shapeColor,const TQColor& 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 TQString& label, int width = -1 );
00310 virtual int addColumn( const TQIconSet& iconset, const TQString& 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 ( TQDropEvent *e, KDGanttViewItem*, KDGanttViewItem*);
00329 virtual void lvStartDrag (KDGanttViewItem*);
00330 virtual bool lvDragMoveEvent (TQDragMoveEvent * e,KDGanttViewItem*, KDGanttViewItem*);
00331 virtual void lvDragEnterEvent (TQDragEnterEvent * e );
00332 virtual TQSize sizeHint() const;
00333 KDGanttViewItem* getItemByName( const TQString& name ) const;
00334 TQDateTime getDateTimeForCoordX(int coordX, bool global = true ) const;
00335 KDGanttViewItem* getItemByListViewPos( const TQPoint& pos ) const;
00336 KDGanttViewItem* getItemByGanttViewPos( const TQPoint& pos ) const;
00337 KDGanttViewItem* getItemAt( const TQPoint& pos , bool global = true ) const;
00338
00339
00340
00341 void setLvVScrollBarMode( TQScrollView::ScrollBarMode );
00342 void setGvVScrollBarMode( TQScrollView::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 TQDateTime& start, const TQDateTime& end);
00355
00356 signals:
00357 void timeIntervallSelected( const TQDateTime& start, const TQDateTime& end);
00358 void timeIntervalSelected( const TQDateTime& start, const TQDateTime& end);
00359 void rescaling( KDGanttView::Scale );
00360 void intervalColorRectangleMoved( const TQDateTime& start, const TQDateTime& 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 TQPoint & pos);
00382 void gvItemDoubleClicked( KDGanttViewItem* );
00383
00384 void gvContextMenuRequested ( KDGanttViewItem * item, const TQPoint & pos );
00385 void gvItemMoved( KDGanttViewItem* );
00386
00387
00388 void lvCurrentChanged( KDGanttViewItem* );
00389 void lvItemRenamed( KDGanttViewItem* , int col, const TQString & text );
00390 void lvMouseButtonPressed( int button, KDGanttViewItem * item, const TQPoint & pos, int c );
00391 void lvItemLeftClicked( KDGanttViewItem* );
00392 void lvItemMidClicked( KDGanttViewItem* );
00393 void lvItemRightClicked( KDGanttViewItem* );
00394 void lvContextMenuRequested ( KDGanttViewItem * item, const TQPoint & pos, int col );
00395 void lvMouseButtonClicked ( int button, KDGanttViewItem* item, const TQPoint & 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 TQDateTime& );
00407
00408 void dropped ( TQDropEvent * e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse);
00409 private slots:
00410 void forceRepaint( int val = 0 );
00411 void slotSelectionChanged( TQListViewItem* item );
00412 void slotCurrentChanged ( TQListViewItem * item );
00413 void slotItemRenamed ( TQListViewItem * item, int col, const TQString & text );
00414 void slotMouseButtonPressed ( int button, TQListViewItem * item, const TQPoint & pos, int c );
00415 void slotmouseButtonClicked ( int button, TQListViewItem * item, const TQPoint & pos, int c );
00416 void slotcontextMenuRequested ( TQListViewItem * item, const TQPoint & pos, int col );
00417 void slotHeaderSizeChanged();
00418 void addTickRight();
00419 void addTickLeft();
00420 void enableAdding( int );
00421 void slot_lvDropped(TQDropEvent* e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse );
00422 private:
00423 struct legendItem {
00424 KDGanttViewItem::Shape shape;
00425 TQColor color;
00426 TQString text;
00427 };
00428 bool loadXML( const TQDomDocument& doc );
00429 TQDomDocument saveXML( bool withPI = true ) const;
00430
00431 void emptySpaceDoubleClicked( TQMouseEvent* e );
00432
00433 static TQString scaleToString( Scale scale );
00434 static TQString yearFormatToString( YearFormat format );
00435 static TQString hourFormatToString( HourFormat format );
00436 static Scale stringToScale( const TQString& string );
00437 static YearFormat stringToYearFormat( const TQString& string );
00438 static HourFormat stringToHourFormat( const TQString& string );
00439
00440
00441 friend class KDGanttCanvasView;
00442 friend class KDGanttViewEventItem;
00443 friend class KDGanttViewItem;
00444 friend class KDGanttViewTaskItem;
00445 friend class KDGanttViewSummaryItem;
00446 friend class KDGanttViewTaskLink;
00447 friend class KDGanttViewCalendarItem;
00448 friend class KDTimeTableWidget;
00449 friend class KDTimeHeaderWidget;
00450 friend class KDListView;
00451 friend class KDGanttViewTaskLinkGroup;
00452 friend class KDLegendWidget;
00453
00454 KDListView * myListView;
00455 KDGanttCanvasView *myCanvasView;
00456 KDTimeHeaderWidget * myTimeHeader;
00457 KDTimeTableWidget * myTimeTable;
00458 KDLegendWidget * myLegend;
00459 itemAttributeDialog* myItemAttributeDialog;
00460 TQVBox * leftWidget, * rightWidget;
00461 TQHBox * spacerLeft;
00462 TQScrollView* myTimeHeaderScroll;
00463 TQHBox* myTimeHeaderContainer ;
00464 TQWidget* timeHeaderSpacerWidget;
00465 TQWidget *spacerRight;
00466
00467 bool listViewIsVisible;
00468 bool chartIsEditable;
00469 bool editorIsEnabled;
00470 bool _displaySubitemsAsGroup;
00471 bool _displayEmptyTasksAsLine;
00472 bool _showLegendButton;
00473 bool _showHeader;
00474 bool _enableAdding;
00475 bool fCenterTimeLineAfterShow;
00476 bool fDragEnabled;
00477 bool fDropEnabled;
00478 bool closingBlocked;
00479 TQDateTime dtCenterTimeLineAfterShow;
00480 KDGanttViewItem::Shape myDefaultShape [9];
00481 TQColor myColor[9],myColorHL[9];
00482 bool undefinedShape[3],undefinedColor[3],undefinedColorHL[3];
00483 TQColor myTextColor;
00484 TQColor myDefaultColor[3],myDefaultColorHL[3];
00485 TQPtrList<KDGanttViewTaskLinkGroup> myTaskLinkGroupList;
00486 TQPtrList<legendItem> *myLegendItems;
00487 void addTaskLinkGroup(KDGanttViewTaskLinkGroup*);
00488 void removeTaskLinkGroup(KDGanttViewTaskLinkGroup*);
00489 int getIndex( KDGanttViewItem::Type ) const;
00490 void notifyEditdialog( KDGanttViewItem * );
00491 void initDefaults();
00492 KDGanttViewItem* myCurrentItem;
00493 KDGanttMinimizeSplitter *mySplitter;
00494 bool mFixedHorizon;
00495 protected:
00496 virtual TQDragObject * dragObject ();
00497 virtual void startDrag ();
00498 };
00499
00500
00501
00502 #endif