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