KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4845 lines
165KB

  1. /* -*- Mode: C++ -*-
  2. $Id: KDGanttView.cpp 536225 2006-05-01 16:46:33Z tilladam $
  3. KDGantt - a multi-platform charting engine
  4. */
  5. /****************************************************************************
  6. ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
  7. **
  8. ** This file is part of the KDGantt library.
  9. **
  10. ** This file may be distributed and/or modified under the terms of the
  11. ** GNU General Public License version 2 as published by the Free Software
  12. ** Foundation and appearing in the file LICENSE.GPL included in the
  13. ** packaging of this file.
  14. **
  15. ** Licensees holding valid commercial KDGantt licenses may use this file in
  16. ** accordance with the KDGantt Commercial License Agreement provided with
  17. ** the Software.
  18. **
  19. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. **
  22. ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
  23. ** information about KDGantt Commercial License Agreements.
  24. **
  25. ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
  26. ** licensing are not clear to you.
  27. **
  28. ** As a special exception, permission is given to link this program
  29. ** with any edition of TQt, and distribute the resulting executable,
  30. ** without including the source code for TQt in the source distribution.
  31. **
  32. **********************************************************************/
  33. #include "KDGanttView.h"
  34. #include "KDGanttViewSubwidgets.h"
  35. #include "KDGanttMinimizeSplitter.h"
  36. #include "KDGanttViewItem.h"
  37. #include "KDGanttXMLTools.h"
  38. #include "itemAttributeDialog.h"
  39. #include <tqprinter.h>
  40. #include <tqpainter.h>
  41. #include <tqlayout.h>
  42. #include <tqpaintdevicemetrics.h>
  43. #include <tqfile.h>
  44. #include <tqheader.h>
  45. #include <tqscrollview.h>
  46. #include <tqapplication.h>
  47. #include <tqevent.h>
  48. #include <tqiconview.h>
  49. #include <tqmessagebox.h>
  50. #include <tqfileinfo.h>
  51. #ifndef KDGANTT_MASTER_CVS
  52. #include "KDGanttView.moc"
  53. #endif
  54. #if defined KDAB_EVAL
  55. #include "../evaldialog/evaldialog.h"
  56. #endif
  57. /*!
  58. \class KDGanttView KDGanttView.h
  59. This class represents a Gantt view with the Gantt chart, the header,
  60. an optional listview and an optional legend.
  61. In order to set up a Gantt view, create an object of this class, and
  62. populate it with a number of \a KDGanttViewItem objects.
  63. If you experience problems with the repainting of the content of the
  64. Gantt View after scrolling, call \a setRepaintMode().
  65. */
  66. /*!
  67. Constructs an empty KDGanttView.
  68. \param parent the widget parent
  69. \param name the internal debugging name
  70. */
  71. KDGanttView::KDGanttView( TQWidget* parent, const char* name )
  72. : KDGanttMinimizeSplitter( Qt::Vertical, parent, name ),
  73. myCanvasView(0),
  74. myTimeHeaderScroll(0)
  75. {
  76. #if defined KDAB_EVAL
  77. EvalDialog::checkEvalLicense( "KD Gantt" );
  78. #endif
  79. myCurrentItem = 0;
  80. setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
  81. mySplitter = new KDGanttMinimizeSplitter( this );
  82. mySplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
  83. leftWidget = new TQVBox( mySplitter );
  84. rightWidget = new TQVBox( mySplitter );
  85. myLegend = new KDLegendWidget( leftWidget, this );
  86. spacerLeft = new TQHBox( leftWidget );
  87. myListView = new KDListView(leftWidget, this);
  88. myListView->setVScrollBarMode (TQScrollView::AlwaysOff );
  89. connect( myListView, TQT_SIGNAL( selectionChanged( TQListViewItem* ) ),
  90. this, TQT_SLOT( slotSelectionChanged( TQListViewItem* ) ) );
  91. connect( myListView, TQT_SIGNAL( mouseButtonClicked ( int, TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT( slotmouseButtonClicked ( int , TQListViewItem * , const TQPoint &, int ) ) );
  92. connect( myListView, TQT_SIGNAL( contextMenuRequested ( TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT( slotcontextMenuRequested ( TQListViewItem * , const TQPoint & , int ) ) );
  93. connect( myListView, TQT_SIGNAL(doubleClicked ( TQListViewItem * ) ), this, TQT_SLOT(slotdoubleClicked ( TQListViewItem * ) ) );
  94. connect( myListView, TQT_SIGNAL(currentChanged( TQListViewItem * ) ), this, TQT_SLOT(slotCurrentChanged ( TQListViewItem * ) ) );
  95. connect( myListView, TQT_SIGNAL(itemRenamed ( TQListViewItem * , int , const TQString & ) ), this, TQT_SLOT(slotItemRenamed ( TQListViewItem *, int , const TQString & ) ) );
  96. connect( myListView, TQT_SIGNAL(mouseButtonPressed( int, TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT(slotMouseButtonPressed ( int , TQListViewItem * , const TQPoint & , int ) ) );
  97. //connect( myListView, TQT_SIGNAL( ), this, TQT_SLOT( ) );
  98. myTimeTable = new KDTimeTableWidget (rightWidget,this);
  99. spacerRight = new TQWidget( rightWidget );
  100. myTimeHeaderContainer = new TQHBox( rightWidget );
  101. myTimeHeaderContainer->setFrameStyle( TQFrame::NoFrame );
  102. myTimeHeaderContainer->setMargin( 0 );
  103. myTimeHeaderScroll = new TQScrollView ( myTimeHeaderContainer );
  104. myTimeHeaderScroll->setHScrollBarMode( TQScrollView::AlwaysOff );
  105. myTimeHeaderScroll->setVScrollBarMode( TQScrollView::AlwaysOff );
  106. timeHeaderSpacerWidget = new TQWidget( myTimeHeaderContainer );
  107. /*
  108. myTimeHeaderScroll = new TQScrollView ( rightWidget );
  109. myTimeHeaderScroll->setHScrollBarMode( TQScrollView::AlwaysOff );
  110. myTimeHeaderScroll->setVScrollBarMode( TQScrollView::AlwaysOn );
  111. */
  112. //myTimeHeader = new KDTimeHeaderWidget (rightWidget,this);
  113. myTimeHeader = new KDTimeHeaderWidget (myTimeHeaderScroll->viewport(),this);
  114. myTimeHeaderScroll->addChild( myTimeHeader );
  115. myTimeHeaderScroll->viewport()->setBackgroundColor( myTimeHeader->backgroundColor() );
  116. timeHeaderSpacerWidget->setBackgroundColor( myTimeHeader->backgroundColor() );
  117. myCanvasView = new KDGanttCanvasView (this,myTimeTable,rightWidget);
  118. myTimeHeaderScroll->setFrameStyle( TQFrame::NoFrame );
  119. //
  120. myCanvasView->setFrameStyle( TQFrame::NoFrame );
  121. myCanvasView->setMargin( 0 );
  122. //
  123. myTimeHeaderScroll->setMargin( 0 );//myCanvasView->frameWidth() );
  124. setFrameStyle(myListView->frameStyle());
  125. setLineWidth( 2 );
  126. myListView->setFrameStyle( TQFrame::NoFrame );
  127. myListView->setMargin( 0 );
  128. TQObject::connect(myListView, TQT_SIGNAL ( expanded ( TQListViewItem * ) ) , myTimeTable , TQT_SLOT( expandItem(TQListViewItem * ))) ;
  129. TQObject::connect(myListView, TQT_SIGNAL (collapsed ( TQListViewItem * ) ) , myTimeTable , TQT_SLOT(collapseItem(TQListViewItem * ))) ;
  130. timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
  131. listViewIsVisible = true;
  132. chartIsEditable = true;
  133. editorIsEnabled = true;
  134. _displaySubitemsAsGroup = false;
  135. initDefaults();
  136. _showHeader = false;
  137. myTextColor = TQt::black;
  138. myLegendItems = new TQPtrList<legendItem>;
  139. //TQObject::connect( this, TQT_SIGNAL (itemDoubleClicked( KDGanttViewItem* ) ) , this, TQT_SLOT( editItem( KDGanttViewItem* ))) ;
  140. myItemAttributeDialog = new itemAttributeDialog();
  141. setRepaintMode( KDGanttView::Medium );
  142. //setRepaintMode( KDGanttView::Always );
  143. setShowLegendButton( true );
  144. setHeaderVisible( false );
  145. // now connecting the widgets
  146. connect(myCanvasView->horizontalScrollBar(), TQT_SIGNAL ( valueChanged ( int )) ,myTimeHeaderScroll->horizontalScrollBar(), TQT_SLOT( setValue ( int))) ;
  147. connect(myCanvasView, TQT_SIGNAL ( heightResized( int )) ,myTimeTable, TQT_SLOT( checkHeight ( int))) ;
  148. connect(myCanvasView, TQT_SIGNAL ( widthResized( int )) ,myTimeHeader, TQT_SLOT( checkWidth ( int))) ;
  149. TQObject::connect(myCanvasView->verticalScrollBar(), TQT_SIGNAL ( valueChanged ( int ) ) ,myListView->verticalScrollBar(), TQT_SLOT( setValue ( int ))) ;
  150. connect(myTimeHeader, TQT_SIGNAL ( sizeChanged( int ) ) ,this, TQT_SLOT(slotHeaderSizeChanged() )) ;
  151. connect(myTimeHeader, TQT_SIGNAL ( sizeChanged( int ) ) ,myTimeTable, TQT_SLOT(resetWidth( int ) )) ;
  152. connect(myListView, TQT_SIGNAL ( contentsMoving ( int, int ) ) ,myCanvasView, TQT_SLOT( moveMyContent( int, int ))) ;
  153. connect(myTimeTable, TQT_SIGNAL ( heightComputed ( int ) ) ,myCanvasView, TQT_SLOT( setMyContentsHeight( int ))) ;
  154. // the next three are for adding new ticks at left/right
  155. connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(addTickLeft()));
  156. connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(addTickRight()));
  157. connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT( enableAdding( int )));
  158. // now initing
  159. fCenterTimeLineAfterShow = false;
  160. fDragEnabled = false;
  161. fDropEnabled = false;
  162. closingBlocked = false;
  163. myTimeHeader->computeTicks();
  164. centerTimelineAfterShow( TQDateTime::currentDateTime () );
  165. setDisplayEmptyTasksAsLine( false );
  166. TQValueList<int> list;
  167. list.append(240);
  168. list.append(530);
  169. mySplitter->setSizes( list );
  170. myTimeTable->setBlockUpdating();// block updating until this->show() is called
  171. }
  172. KDGanttView::~KDGanttView()
  173. {
  174. setUpdateEnabled(false);
  175. // delete cut item, if there is any
  176. myCanvasView->resetCutPaste( 0 );
  177. myTimeTable->clearTaskLinks();
  178. }
  179. /*!
  180. Enables or disables updating of the content of the Gantt view.
  181. To avoid flickering in the Gantt view while inserting large amounts
  182. of Gantt items, you should call
  183. bool upd = KDGanttView::getUpdateEnabled();
  184. KDGanttView::settUpdateEnabled( false );
  185. ... insert items here ...
  186. KDGanttView::settUpdateEnabled( upd );
  187. With this code, you avoid unwanted side effects with other parts in
  188. your code, where you disable (and re-enable) the update.
  189. When calling setUpdateEnabled( true ),
  190. all the content is recomputed, resized, and updated.
  191. Before calling show() for the first time, updating is disabled.
  192. When calling show(), updating is automatically enabled.
  193. \param enable if true, the content of the Gantt view is updated after
  194. every insertion of a new item.
  195. \sa getUpdateEnabled()
  196. */
  197. void KDGanttView::setUpdateEnabled( bool enable )
  198. {
  199. myTimeTable->setBlockUpdating( !enable );
  200. if ( enable ) {
  201. myTimeTable->updateMyContent();
  202. myCanvasView->setMyContentsHeight( 0 );
  203. }
  204. }
  205. /*!
  206. Returns whether updating is enabled or not.
  207. \return true, if updating is enabled
  208. \sa setUpdateEnabled()
  209. */
  210. bool KDGanttView::getUpdateEnabled() const
  211. {
  212. return !myTimeTable->blockUpdating();
  213. }
  214. /*!
  215. Sets the maximum width of the Gantt view part widget in pixels.
  216. The largest allowed width is 32767.
  217. \param w the maximum width
  218. */
  219. void KDGanttView::setGanttMaximumWidth( int w )
  220. {
  221. myTimeHeader->setMaximumWidth ( w );
  222. }
  223. /*!
  224. Returns the maximum width of the Gantt view part widget in pixels.
  225. The default maximum width is 32767 pixels.
  226. \return the maximum width of the Gantt view part widget in pixels.
  227. */
  228. int KDGanttView::ganttMaximumWidth() const
  229. {
  230. return myTimeHeader->maximumWidth();
  231. }
  232. /*!
  233. Updates the content of the GanttView and shows it.
  234. Automatically sets setUpdateEnabled( true ).
  235. \sa setUpdateEnabled()
  236. */
  237. void KDGanttView::show()
  238. {
  239. myTimeTable->setBlockUpdating( false );
  240. if (myCanvasView->horizontalScrollBar()->value() > 0 )
  241. myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->value()-1 );
  242. else
  243. myCanvasView->horizontalScrollBar()->setValue(1 );
  244. myTimeTable->updateMyContent();
  245. TQWidget::show();
  246. myCanvasView->setMyContentsHeight( 0 );
  247. if ( fCenterTimeLineAfterShow ) {
  248. fCenterTimeLineAfterShow = false;
  249. centerTimeline (dtCenterTimeLineAfterShow);
  250. }
  251. }
  252. /*!
  253. Closes the widget.
  254. The closing is rejected, if a repainting is currently being done.
  255. \param alsoDelete if true, the widget is deleted
  256. \return true, if the widget was closed
  257. */
  258. bool KDGanttView::close ( bool alsoDelete )
  259. {
  260. //tqDebug("close ");
  261. if ( closingBlocked )
  262. return false;
  263. return TQWidget::close ( alsoDelete );
  264. }
  265. /*!
  266. Returns a useful size for the view.
  267. Returned width:
  268. sizeHint().width() of the list view + width of TimeTable
  269. Returned height:
  270. height() of TimeHeader + height() of TimeTable + height() of Legend (if shown)
  271. */
  272. TQSize KDGanttView::sizeHint() const
  273. {
  274. bool block = myTimeTable->blockUpdating();
  275. myTimeTable->setBlockUpdating( false );
  276. myTimeTable->updateMyContent();
  277. /* The below causes recursive calls to various size updating methods, which
  278. * cause TQCanvas to hide and show items like mad, which is very slow. If
  279. * there is a legitimate gui updating issue here somewhere, it will need
  280. * to be solved differently.
  281. */
  282. //tqApp->processEvents();
  283. int hintHeight = myTimeHeader->height();
  284. int legendHeight = 0;
  285. if ( showLegendButton() )
  286. legendHeight = myLegend->height();
  287. int listViewHeaderHeight = 0;
  288. if ( headerVisible() )
  289. listViewHeaderHeight = myListView->header()->height();
  290. if ( hintHeight < legendHeight+listViewHeaderHeight )
  291. hintHeight = legendHeight + listViewHeaderHeight;
  292. hintHeight += myListView->horizontalScrollBar()->height();
  293. if ( myLegend->isShown() )
  294. hintHeight += myLegend->legendSizeHint().height() +10;
  295. hintHeight += myTimeTable->minimumHeight+myListView->frameWidth()*2+2;
  296. int hintWid = myListView->sizeHint().width();
  297. //hintWid += myTimeHeader->mySizeHint+myCanvasView->verticalScrollBar()->width();
  298. hintWid += myCanvasView->sizeHint().width();
  299. // add 10 for the splitter-bars
  300. // tqDebug("sizehint %d %d ",hintWid+10, hintHeight );
  301. myTimeTable->setBlockUpdating( block );
  302. return TQSize( hintWid+10, hintHeight );
  303. }
  304. /*!
  305. Specifies whether the legend button should be visible. By default,
  306. it is visible.
  307. \param show true to show the legend button, false to hide it
  308. \sa showLegendButton()
  309. */
  310. void KDGanttView::setShowLegendButton( bool show )
  311. {
  312. _showLegendButton = show;
  313. if ( show )
  314. myLegend->show();
  315. else
  316. myLegend->hide();
  317. slotHeaderSizeChanged();
  318. }
  319. /*!
  320. Returns whether the legend button is visible.
  321. \return whether the legend button is visible
  322. \sa setShowLegendButton()
  323. */
  324. bool KDGanttView::showLegendButton() const
  325. {
  326. return _showLegendButton;
  327. }
  328. /*!
  329. Specifies whether the listview header should be visible. By default,
  330. it is not visible.
  331. \param visible true to make the header visible, false to make it invisible
  332. */
  333. void KDGanttView::setHeaderVisible( bool visible )
  334. {
  335. if( visible )
  336. myListView->header()->show();
  337. else
  338. myListView->header()->hide();
  339. _showHeader = visible;
  340. slotHeaderSizeChanged();
  341. }
  342. /*!
  343. Returns whether the listview header is visible.
  344. \return whether the header is visible
  345. */
  346. bool KDGanttView::headerVisible() const
  347. {
  348. return _showHeader;
  349. }
  350. /*!
  351. Returns the corresponding date and time of the coordinate X in the
  352. Gantt view.
  353. \param coordX the coordinate to search for
  354. \param global true if coordX is a global position, false otherwise
  355. \return the date and time at coordinate X in the Gantt view.
  356. */
  357. TQDateTime KDGanttView::getDateTimeForCoordX(int coordX, bool global ) const
  358. {
  359. // default for myTimeHeader->getDateTimeForIndex() is local
  360. return myTimeHeader->getDateTimeForIndex(coordX, !global );
  361. }
  362. /*!
  363. Implements a casted pass-through of the selectionChanged() signal.
  364. */
  365. void KDGanttView::slotSelectionChanged( TQListViewItem* item )
  366. {
  367. KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
  368. Q_ASSERT( gItem );
  369. emit lvSelectionChanged( gItem );
  370. }
  371. /*
  372. Implements a casted pass-through of the mouseButtonClicked() signal.
  373. Signals itemLeftClicked() , itemMidClicked() are emitted as well.
  374. */
  375. void KDGanttView::slotmouseButtonClicked ( int button, TQListViewItem * item,
  376. const TQPoint & pos, int c )
  377. {
  378. KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
  379. emit lvMouseButtonClicked ( button , gItem, pos, c );
  380. if (gItem == 0 && myCurrentItem != 0 ) {
  381. myCurrentItem = 0;
  382. emit lvCurrentChanged( gItem );
  383. }
  384. if (gItem != 0 && myCurrentItem == 0 ) {
  385. myCurrentItem = gItem;
  386. emit lvCurrentChanged( gItem );
  387. }
  388. // removed - makes no sense!
  389. //emit mouseButtonClicked ( button , gItem, pos, c );
  390. {
  391. switch ( button ) {
  392. case Qt::LeftButton:
  393. emit lvItemLeftClicked( gItem );
  394. emit itemLeftClicked( gItem );
  395. break;
  396. case Qt::MidButton:
  397. emit lvItemMidClicked( gItem );
  398. emit itemMidClicked( gItem );
  399. break;
  400. }
  401. }
  402. }
  403. /*
  404. Implements a casted pass-through of the contextMenuRequested() signal.
  405. The signal itemRightClicked() is emitted as well;
  406. the position is the global position.
  407. */
  408. void KDGanttView::slotcontextMenuRequested ( TQListViewItem * item, const TQPoint & pos, int col )
  409. {
  410. KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
  411. emit lvContextMenuRequested ( gItem, pos, col );
  412. emit lvItemRightClicked( gItem );
  413. emit itemRightClicked( gItem );
  414. }
  415. /*
  416. Implements a casted pass-through of the doubleClicked() signal.
  417. */
  418. void KDGanttView::slotdoubleClicked ( TQListViewItem * item )
  419. {
  420. {
  421. KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
  422. emit lvItemDoubleClicked( gItem );
  423. emit itemDoubleClicked( gItem );
  424. }
  425. }
  426. /*
  427. Implements a casted pass-through of the currentChanged() signal.
  428. */
  429. void KDGanttView::slotCurrentChanged ( TQListViewItem * item )
  430. {
  431. KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
  432. myCurrentItem = gItem;
  433. emit lvCurrentChanged( gItem );
  434. }
  435. /*
  436. Implements a casted pass-through of the itemRenamed() signal.
  437. */
  438. void KDGanttView::slotItemRenamed ( TQListViewItem * item , int col,
  439. const TQString & text )
  440. {
  441. KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
  442. emit lvItemRenamed( gItem, col, text );
  443. }
  444. /*
  445. Implements a casted pass-through of the mouseButtonPressed() signal.
  446. */
  447. void KDGanttView::slotMouseButtonPressed ( int button, TQListViewItem * item,
  448. const TQPoint & pos, int c )
  449. {
  450. KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
  451. emit lvMouseButtonPressed( button, gItem, pos, c );
  452. }
  453. /*!
  454. Specifies whether the content should be repainted after scrolling or
  455. not.
  456. \param mode If No, there is no repainting after scrolling. This is
  457. the fastest mode.
  458. If Medium, there is extra repainting after releasing the
  459. scrollbar. This provides fast scrolling with updated content
  460. after scrolling. Recommended, when repaint problems occur.
  461. This is the default value after startup.
  462. If Always, there is an extra update after every move of the
  463. scrollbar. This entails slow scrolling with updated
  464. content at all time.
  465. */
  466. void KDGanttView::setRepaintMode( RepaintMode mode )
  467. {
  468. TQScrollBar *cvh, *cvv;
  469. cvh = myCanvasView->horizontalScrollBar();
  470. cvv = myCanvasView->verticalScrollBar();
  471. // first disconnect
  472. cvh->disconnect( this );
  473. cvv->disconnect( this );
  474. switch ( mode ) {
  475. case No:
  476. break;
  477. case Medium:
  478. connect( cvv, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
  479. connect( cvh, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
  480. connect( cvv, TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(forceRepaint()));
  481. connect( cvh, TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(forceRepaint()));
  482. connect( cvv, TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(forceRepaint()));
  483. connect( cvh, TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(forceRepaint()));
  484. break;
  485. case Always:
  486. connect( cvv, TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT(forceRepaint( int )));
  487. connect( cvh, TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT(forceRepaint( int )));
  488. connect( cvv, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
  489. connect( cvh, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
  490. break;
  491. }
  492. }
  493. void KDGanttView::forceRepaint( int )
  494. {
  495. if ( myTimeTable->blockUpdating() )
  496. return;
  497. // tqDebug("forceRepaint( int ) ");
  498. myTimeTable->setAllChanged();
  499. myTimeTable->update();
  500. }
  501. void KDGanttView::slotHeaderSizeChanged()
  502. {
  503. int legendHeight = 0;
  504. if ( showLegendButton() )
  505. legendHeight = 24;
  506. int listViewHeaderHeight = 0;
  507. if ( headerVisible() )
  508. listViewHeaderHeight = myListView->header()->height();
  509. int timeHeaderHeight = myTimeHeader->height()+myTimeHeaderScroll->frameWidth()*2;;
  510. int diffY = timeHeaderHeight-legendHeight-listViewHeaderHeight;
  511. if ( diffY < 0 ) {
  512. spacerLeft->setFixedHeight( 0 );
  513. spacerRight->setFixedHeight(-diffY);
  514. } else {
  515. spacerRight->setFixedHeight( 0 );
  516. spacerLeft->setFixedHeight( diffY );
  517. }
  518. myLegend->setFixedHeight( legendHeight );
  519. myTimeHeaderContainer->setFixedHeight( timeHeaderHeight );
  520. }
  521. /*!
  522. Specifies whether the legend should be shown as a dock window or not.
  523. \param show if true, show legend as a dock window
  524. \sa showLegend(), legendIsDoctwindow(), legendDoctwindow()
  525. */void KDGanttView::setLegendIsDoctwindow( bool show )
  526. {
  527. bool isdock = myLegend->asDoctwindow();
  528. if ( show != isdock ) {
  529. myLegend->setAsDoctwindow(show);
  530. // legend is cleared - reinit legend with list
  531. legendItem* li;
  532. for ( li = myLegendItems->first(); li; li = myLegendItems->next() ) {
  533. myLegend->addLegendItem(li->shape, li->color, li->text );
  534. }
  535. }
  536. }
  537. /*!
  538. Returns whether the legend is shown as a dock window
  539. \return true if the legend is shown as a dock window
  540. \sa setShowLegend(), setLegendIsDoctwindow(), legendDoctwindow()
  541. */bool KDGanttView::legendIsDoctwindow() const
  542. {
  543. return myLegend->asDoctwindow();
  544. }
  545. /*!
  546. Returns the pointer to the legend dock window.
  547. DO NOT DELETE THIS POINTER!
  548. If the legend is not a dock window, 0 is returned
  549. To set the legend as a dock window, call
  550. KDGanttView::setLegendIsDoctwindow( true );
  551. \return the pointer to the legend dock window
  552. 0 is returned, if the legend is no dock window
  553. DO NOT DELETE THIS POINTER!
  554. \sa setShowLegend(), setLegendIsDoctwindow(),legendIsDoctwindow()
  555. */
  556. TQDockWindow* KDGanttView::legendDoctwindow() const
  557. {
  558. return myLegend->dockwindow();
  559. }
  560. /*!
  561. Specifies whether the legend should be shown or not. Besides setting
  562. this programmatically, the user can also show/hide the legend by
  563. using the button provided for this purpose.
  564. \param show force legend to be shown
  565. \sa showLegend()
  566. */
  567. void KDGanttView::setShowLegend( bool show )
  568. {
  569. myLegend->showMe(show);
  570. }
  571. /*!
  572. Returns whether the legend is currently shown. The visibility of the
  573. legend can be changed both by \a setShowLegend(), and interactively
  574. by the user.
  575. \return true if the legend is currently visible
  576. \sa setShowLegend()
  577. */
  578. bool KDGanttView::showLegend() const
  579. {
  580. return myLegend->isShown();
  581. }
  582. /*!
  583. Specifies whether the listview of the Gantt view should be shown or
  584. not.
  585. \param show pass true in order to show the listview and false in
  586. order to hide it.
  587. \sa showListView()
  588. */
  589. void KDGanttView::setShowListView( bool show )
  590. {
  591. if(listViewIsVisible == show) return;
  592. listViewIsVisible = show;
  593. if (listViewIsVisible)
  594. myListView->parentWidget()->show();
  595. else
  596. myListView->parentWidget()->hide();
  597. }
  598. /*!
  599. Returns whether the listview of the Gantt view is shown or not.
  600. \return true if the listview is shown
  601. \sa setShowListView()
  602. */
  603. bool KDGanttView::showListView() const
  604. {
  605. return listViewIsVisible;
  606. }
  607. /*!
  608. Specifies whether it should be possible to edit the appearance of a
  609. Gantt item visually in a dialog by double-clicking the item.
  610. \param enable pass true in order to enable the visual editor and
  611. false in order to turn it off
  612. \sa editorEnabled()
  613. */
  614. void KDGanttView::setEditorEnabled( bool enable )
  615. {
  616. editorIsEnabled = enable;
  617. }
  618. /*!
  619. Returns whether it is possible to edit the appearance of a Gantt
  620. item visually in a dialog by double-clicking the item.
  621. \return true if visual editing is enabled, false otherwise
  622. \sa setEditorEnabled()
  623. */
  624. bool KDGanttView::editorEnabled() const
  625. {
  626. return editorIsEnabled;
  627. }
  628. /*!
  629. Specifies whether the Gantt chart is user-editable.
  630. \param editable pass true in order to get a user-editable Gantt
  631. chart, pass false in order to get a read-only chart
  632. \sa editable()
  633. */
  634. void KDGanttView::setEditable( bool editable )
  635. {
  636. chartIsEditable = editable;
  637. }
  638. /*!
  639. Returns whether the Gantt chart is user-editable
  640. \return true if the Gantt chart is user-editable
  641. \sa setEditable()
  642. */
  643. bool KDGanttView::editable() const
  644. {
  645. return chartIsEditable;
  646. }
  647. /*!
  648. Saves the state of the Gantt view in an IO device in XML format. The saved
  649. data can be reloaded with \a loadProject().
  650. \param device a pointer to the IO device in which to store the Gantt
  651. view state.
  652. \return true if the data could be written, false if an error
  653. occurred
  654. \sa loadProject()
  655. */
  656. bool KDGanttView::saveProject( TQIODevice* device )
  657. {
  658. Q_ASSERT( device );
  659. TQDomDocument doc = saveXML();
  660. if( device->isOpen() )
  661. device->close();
  662. if( device->open( IO_WriteOnly ) ) {
  663. TQTextStream ts( device );
  664. ts << doc.toString();
  665. return true;
  666. } else
  667. return false;
  668. }
  669. /*!
  670. Loads a previously saved state of the Gantt view. All current
  671. settings and items are discarded before loading the data.
  672. \param device a pointer to the IO device from which to load the
  673. Gantt view state.
  674. \return true if the file could be read, false if an error
  675. occurred
  676. \sa saveProject()
  677. */
  678. bool KDGanttView::loadProject( TQIODevice* device )
  679. {
  680. Q_ASSERT( device );
  681. if( device->isOpen() )
  682. device->close();
  683. if( device->open( IO_ReadOnly ) ) {
  684. TQDomDocument doc( "GanttView" );
  685. TQString err;
  686. int errline, errcol;
  687. if ( !doc.setContent( device, &err, &errline, &errcol ) ) {
  688. tqDebug("KDGantt::Error parsing XML data at line %d. Message is:", errline );
  689. tqDebug("%s ", err.latin1());
  690. device->close();
  691. return false;
  692. }
  693. device->close();
  694. return loadXML( doc );
  695. } else
  696. return false;
  697. }
  698. /*!
  699. Sends a Gantt view to a printer. The printer should already be set
  700. up for printing (by calling TQPrinter::setup()).
  701. If the printer is not set up, TQPrinter::setup() is called before printing
  702. You can specify, whether the ListView, TimeLine, or Legend will be
  703. printed. All combinations of these three widgets are allowed.
  704. \param printer a pointer to the printer to print on. If printer is
  705. 0, the method creates a temporary printer and discards it when it is
  706. done printing.
  707. \param printListView if true, the list view is printed
  708. \param printTimeLine if true, the time line is printed
  709. \param printLegend if true, the legend is printed
  710. \sa drawContents()
  711. */
  712. void KDGanttView::print( TQPrinter* printer ,
  713. bool printListView, bool printTimeLine,
  714. bool printLegend )
  715. {
  716. bool deletePrinter = false;
  717. if (! printer ) {
  718. printer = new TQPrinter();
  719. deletePrinter = true;
  720. if ( !printer->setup()) {
  721. delete printer;
  722. return;
  723. }
  724. }
  725. // now we have a printer to print on
  726. TQPainter p( printer );
  727. // get the paper metrics
  728. TQPaintDeviceMetrics m = TQPaintDeviceMetrics ( printer );
  729. float dx, dy;
  730. // get the size of the desired output for scaling.
  731. // here we want to print all: ListView, TimeLine, and Legend
  732. // for this purpose, we call drawContents() with a 0 pointer as painter
  733. TQSize size = drawContents( 0, printListView, printTimeLine, printLegend );
  734. // at the top, we want to print current time/date
  735. TQString date = "Printing Time: " + TQDateTime::currentDateTime().toString();
  736. int hei = p.boundingRect(0,0, 5, 5, TQt::AlignLeft, date ).height();
  737. p.drawText( 0, 0, date );
  738. // compute the scale
  739. dx = (float) m.width() / (float)size.width();
  740. dy = (float)(m.height() - ( 2 * hei )) / (float)size.height();
  741. float scale;
  742. // scale to fit the width or height of the paper
  743. if ( dx < dy )
  744. scale = dx;
  745. else
  746. scale = dy;
  747. // set the scale
  748. p.scale( scale, scale );
  749. // now printing with y offset: 2 hei
  750. p.translate( 0, 2*hei );
  751. drawContents( &p, printListView, printTimeLine, printLegend );
  752. // the drawContents() has the side effect, that the painter translation is
  753. // after drawContents() set to the bottom of the painted stuff
  754. // for instance a
  755. // p.drawText(0, 0, "printend");
  756. // would be painted directly below the paintout of drawContents()
  757. p.end();
  758. if ( deletePrinter )
  759. delete printer;
  760. }
  761. /*!
  762. Paints a Gantt view on a TQPainter.
  763. You can specify, whether the list view, the time line, or the legend
  764. is painted.
  765. All combinations of these three widgets are allowed.
  766. Returns the size of the painted area.
  767. Paints the list view in the top-left corner, the time line to the
  768. right of the list view, and the legend below the list view.
  769. If called with \a p = 0, nothing is painted and only
  770. the size of the painted area is computed.
  771. This is useful for determining only the painted area and setting
  772. the scale of the painter, before calling this method with a painter.
  773. In order to get the output fitted to your paper and your printer,
  774. call first
  775. TQSize size = drawContents( 0, printListView, printTimeLine, printLegend );
  776. //then compute the scale
  777. dx = paper.width() / size.width();
  778. dy = paper.height() / size.height();
  779. //then make float scale to fit the width or height of the paper
  780. if ( dx < dy )
  781. scale = dx;
  782. else
  783. scale = dy;
  784. // then set the scale
  785. p.scale( scale, scale );
  786. // and now call drawContents with painter p
  787. drawContents( &p, printListView, printTimeLine, printLegend );
  788. For a detailed example, please see the commented source code in
  789. KDGanttView::print(...)
  790. \param p a pointer to the painter to paint on. If p is
  791. 0, nothing is painted and only the size of the painted area is computed
  792. \param drawListView if true, the list view is painted
  793. \param drawTimeLine if true, the time line is painted
  794. \param drawLegend if true, the legend is painted
  795. \return the size of the painted area
  796. \sa print()
  797. */
  798. TQSize KDGanttView::drawContents( TQPainter* p,
  799. bool drawListView , bool drawTimeLine, bool drawLegend )
  800. {
  801. TQSize size;
  802. int lvX, lvY, thX, thY, tlX, tlY, lwX, lwY, allX, allY;
  803. lvX = myListView->contentsWidth();
  804. lvY = myCanvasView->canvas()->height() + 20;
  805. thX = myTimeHeader->width();
  806. thY = myTimeHeader->height();
  807. tlX = myCanvasView->canvas()->width();
  808. tlY = lvY;
  809. lwX = myLegend->legendSize().width();
  810. lwY = myLegend->legendSize().height();
  811. allX = 0;
  812. allY = 0;
  813. if ( drawListView ) {
  814. allX += lvX;
  815. allY += tlY;
  816. }
  817. if ( drawTimeLine ) {
  818. allX += thX;
  819. allY += thY;
  820. }
  821. if ( drawLegend ) {
  822. allY += lwY;
  823. if ( allX < lwX )
  824. allX = lwX ;
  825. }
  826. size = TQSize( allX, allY );
  827. int temp = 0;
  828. if ( p ) {
  829. if ( drawListView ) {
  830. if ( drawTimeLine )
  831. temp = thY;
  832. p->translate( 0, temp );
  833. //HACK: Only draw list headers if we draw timeline, else
  834. // there is no room for it. This will most probably be changed
  835. // with qt4 anyway, so I think we can live with it atm.
  836. myListView->drawToPainter( p, drawTimeLine );
  837. p->translate( lvX, -temp);
  838. }
  839. if ( drawTimeLine ) {
  840. p->translate( myCanvasView->frameWidth(), 0);
  841. myTimeHeader->repaintMe( 0, myTimeHeader->width(), p );
  842. p->translate( -myCanvasView->frameWidth(), thY);
  843. myCanvasView->drawToPainter( p );
  844. if ( drawListView )
  845. p->translate( -lvX, tlY);
  846. else
  847. p->translate( 0, tlY);
  848. } else {
  849. if ( drawListView )
  850. p->translate( -lvX, 0 );
  851. }
  852. if ( drawLegend ) {
  853. myLegend->drawToPainter( p );
  854. p->translate( 0, lwY );
  855. }
  856. }
  857. return size;
  858. }
  859. /*!
  860. Zooms into the Gantt chart. Values less than 1 mean zooming in,
  861. values greater than 1 mean zooming out. A zooming factor of exactly
  862. 1.0 means original size.
  863. \param factor the zoom factor
  864. \param absolute if true, factor is interpreted absolutely, if false,
  865. factor is interpreted relatively to the current zoom factor
  866. \sa zoomToFit()
  867. \sa zoomToSelection()
  868. \sa zoomFactor()
  869. */
  870. void KDGanttView::setZoomFactor( double factor, bool absolute )
  871. {
  872. myTimeHeader->zoom(factor,absolute);
  873. }
  874. /*!
  875. Returns the current zoom factor.
  876. \return the current zoom factor
  877. \sa zoomToFit(), zoomToSelection(), setZoomFactor()
  878. */
  879. double KDGanttView::zoomFactor() const
  880. {
  881. return myTimeHeader->zoomFactor();
  882. }
  883. /*!
  884. Zooms such that the Gantt chart is less than the available space of the widget.
  885. \sa setZoomFactor()
  886. \sa zoomFactor()
  887. \sa zoomToSelection()
  888. */
  889. void KDGanttView::zoomToFit()
  890. {
  891. myTimeHeader->zoomToFit();
  892. }
  893. /*!
  894. Zooms so that at least the selected time period is visible after the zoom.
  895. \param start the new font of the widget
  896. \param end the new font of the widget
  897. \sa setZoomFactor()
  898. \sa zoomFactor()
  899. \sa zoomToFit()
  900. */
  901. void KDGanttView::zoomToSelection( const TQDateTime& start, const TQDateTime& end )
  902. {
  903. myTimeHeader->zoomToSelection( start, end);
  904. }
  905. /*!
  906. Makes sure that the specified Gantt item is visible without
  907. scrolling.
  908. \sa center(), centerTimelineAfterShow()
  909. */
  910. void KDGanttView::ensureVisible( KDGanttViewItem* item )
  911. {
  912. myListView->ensureItemVisible (item);
  913. }
  914. /*!
  915. Makes sure that the specified TQDateTime is in the center of the
  916. visible Gantt chart (if possible).
  917. If you want to center the timeline when the KDGanttView is hidden,
  918. calling centerTimelineAfterShow() is the better alternative.
  919. \sa center(), centerTimelineAfterShow()
  920. */
  921. void KDGanttView::centerTimeline( const TQDateTime& center )
  922. {
  923. myTimeHeader->centerDateTime( center );
  924. }
  925. /*!
  926. Makes sure that the specified TQDateTime is in the center of the
  927. visible Gantt chart (if possible). If the KDGanttView is currently
  928. hidden, this method resets the center once again after the next
  929. show() call. Use this method if you want to center the timeline when
  930. the KDGanttView is hidden. After calling KDGanttView::show(), there
  931. may be computations of the sizes of the widgets and subwidgets and
  932. of the automatically computed start datetime. This method ensures
  933. that the center of the timeline is to be properly reset after
  934. show().
  935. \sa center(), centerTimeline()
  936. */
  937. void KDGanttView::centerTimelineAfterShow( const TQDateTime& center )
  938. {
  939. myTimeHeader->centerDateTime( center );
  940. if ( ! isVisible() ) {
  941. dtCenterTimeLineAfterShow = center;
  942. fCenterTimeLineAfterShow = true;
  943. }
  944. }
  945. /*!
  946. Sets the timeline to the horizon start.
  947. */
  948. void KDGanttView::setTimelineToStart()
  949. {
  950. myCanvasView->horizontalScrollBar()->setValue( 0 );
  951. }
  952. /*!
  953. Sets the timeline to the horizon end.
  954. */
  955. void KDGanttView::setTimelineToEnd()
  956. {
  957. myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->maxValue());
  958. }
  959. /*!
  960. Add \a num minor ticks of the current scale of the timeline
  961. to the start of the timeline.
  962. The timeline is not set automatically at the start.
  963. Call \a setTimelineToStart() to ensure that the timeline is at the start
  964. after calling this method.
  965. \param num the number of minor ticks which should be added
  966. \sa addTicksRight(),setTimelineToStart(), setTimelineToEnd()
  967. */
  968. void KDGanttView::addTicksLeft( int num )
  969. {
  970. myTimeHeader->addTickLeft( num );
  971. }
  972. /*!
  973. Add \a num minor ticks of the current scale of the timeline
  974. to the end of the timeline.
  975. The timeline is not set automatically at the end.
  976. Call \a setTimelineToEnd() to ensure that the timeline is at the end
  977. after calling this method.
  978. \param num the number of minor ticks which should be added
  979. \sa addTicksLeft(),setTimelineToStart(), setTimelineToEnd()
  980. */
  981. void KDGanttView::addTicksRight( int num )
  982. {
  983. myTimeHeader->addTickRight( num );
  984. }
  985. /*!
  986. Makes sure that the specified Gantt item is in the center of the
  987. visible Gantt chart (if possible).
  988. */
  989. void KDGanttView::center( KDGanttViewItem* item )
  990. {
  991. ensureVisible(item);
  992. int x = myListView->contentsWidth()/2;
  993. int y = myListView->itemPos (item );
  994. myListView->center(x,y);
  995. }
  996. /*!
  997. Specifies whether task links should be shown.
  998. \param show true for showing task links, false for not showing them
  999. \sa showTaskLinks(), KDGanttViewTaskLink
  1000. */
  1001. void KDGanttView::setShowTaskLinks( bool show )
  1002. {
  1003. myTimeTable->setShowTaskLinks(show);
  1004. }
  1005. /*!
  1006. Returns whether task links should be shown.
  1007. \return true if task links are shown, false otherwise
  1008. \sa setShowTaskLinks(), KDGanttViewTaskLink
  1009. */
  1010. bool KDGanttView::showTaskLinks() const
  1011. {
  1012. return myTimeTable->showTaskLinks();
  1013. }
  1014. /*!
  1015. Sets the font in the left list view widget and
  1016. in the right time header widget.
  1017. The settings of the fonts in the time table widget are not effected.
  1018. \param font the new font of the widget
  1019. */
  1020. void KDGanttView::setFont(const TQFont& font)
  1021. {
  1022. myListView->setFont(font);
  1023. myListView->repaint();
  1024. myTimeHeader->setFont(font);
  1025. myLegend->setFont( font );
  1026. TQWidget::setFont( font );
  1027. setScale(scale());
  1028. }
  1029. /*!
  1030. Specifies whether the configure popup menu should be shown on
  1031. right click on the time header widget.
  1032. This menu lets the user quickly change
  1033. the zoom factor,
  1034. the scale mode (minute, hour, day, week, month, auto) ,
  1035. the time format,
  1036. the year format,
  1037. the grid format,
  1038. and printing.
  1039. The default setting is not to show the popup menu.
  1040. This functionality must be enabled explicitly by the application
  1041. developer.
  1042. You can disable each submenu of the popmenu.
  1043. \param show true in order to show the popup menu, false in order not
  1044. to. The default is true.
  1045. \param showZoom show the zoom submenu, default: true
  1046. \param showScale show the scale submenu, default: true
  1047. \param showTime show the time format submenu, default: true
  1048. \param showYear show the year format submenu, default: true
  1049. \param showGrid show the grid submenu, default: true
  1050. \param showPrint show the print submenu, default: false
  1051. */
  1052. void KDGanttView::setShowHeaderPopupMenu( bool show,
  1053. bool showZoom,
  1054. bool showScale,
  1055. bool showTime,
  1056. bool showYear,
  1057. bool showGrid,
  1058. bool showPrint)
  1059. {
  1060. myTimeHeader->setShowPopupMenu( show,showZoom,showScale,showTime,
  1061. showYear,showGrid,showPrint );
  1062. }
  1063. /*!
  1064. Returns whether the configure popup menu should be shown on right
  1065. click on the time header widget.
  1066. \return true if the popup menu should be shown
  1067. */
  1068. bool KDGanttView::showHeaderPopupMenu() const
  1069. {
  1070. return myTimeHeader->showPopupMenu();
  1071. }
  1072. //****************************************************
  1073. /*!
  1074. Specifies whether the add item popup menu should be shown on
  1075. right click on the time table widget.
  1076. This menu lets the user quickly add new items to the Gantt view
  1077. (as root, as child or after an item).
  1078. It also offers cutting and pasting of items.
  1079. The default setting is that the popup menu is not shown.
  1080. It must be enabled by the program.
  1081. \param show true in order to show popup menu, false in order not to
  1082. */
  1083. void KDGanttView::setShowTimeTablePopupMenu( bool show )
  1084. {
  1085. myCanvasView->setShowPopupMenu( show );
  1086. }
  1087. /*!
  1088. Returns whether the add item popup menu should be shown on right
  1089. click on the time table widget.
  1090. \return true if the popup menu should be shown
  1091. */
  1092. bool KDGanttView::showTimeTablePopupMenu() const
  1093. {
  1094. return myCanvasView->showPopupMenu();
  1095. }
  1096. /*!
  1097. Sets the shapes for a certain type of Gantt item. Not all items use
  1098. all three shapes (e.g., only summary items use the middle shape).
  1099. This setting overrides any shape settings made on individual items.
  1100. These settings will be taken as initial values of any newly created
  1101. item of this certain type.
  1102. See also the documentation of the KDGanttViewItem class.
  1103. \param type the type of Gantt items for which to set the shapes
  1104. \param start the shape to use for the beginning of the item
  1105. \param middle the shape to use for the middle of the item
  1106. \param end the shape to use for the end of the item
  1107. \param overwriteExisting if true, overwrites existing shape settings
  1108. in the individual items
  1109. \sa shapes()
  1110. */
  1111. void KDGanttView::setShapes( KDGanttViewItem::Type type,
  1112. KDGanttViewItem::Shape start,
  1113. KDGanttViewItem::Shape middle,
  1114. KDGanttViewItem::Shape end,
  1115. bool overwriteExisting )
  1116. {
  1117. if ( overwriteExisting ) {
  1118. TQListViewItemIterator it(myListView);
  1119. for ( ; it.current(); ++it ) {
  1120. if ( ((KDGanttViewItem*)it.current())->type() == type)
  1121. ((KDGanttViewItem*)it.current())->setShapes(start,middle, end );
  1122. }
  1123. }
  1124. int index = getIndex( type );
  1125. myDefaultShape [index*3] = start;
  1126. myDefaultShape [index*3+1] = middle;
  1127. myDefaultShape [index*3+2] = end;
  1128. undefinedShape[index] = false;
  1129. }
  1130. /*!
  1131. Queries the shapes for a particular type of Gantt item.
  1132. \param type the type of Gantt items for which to query the shapes
  1133. \param start the start shape is returned in this parameter
  1134. \param middle the middle shape is returned in this parameter
  1135. \param end the end shape is returned in this parameter
  1136. \return true if there was a general shape set for the specified
  1137. type. If the return value is false, the values of the three shape
  1138. parameters are undefined.
  1139. \sa setShapes()
  1140. */
  1141. bool KDGanttView::shapes( KDGanttViewItem::Type type,
  1142. KDGanttViewItem::Shape& start,
  1143. KDGanttViewItem::Shape& middle,
  1144. KDGanttViewItem::Shape& end ) const
  1145. {
  1146. int index = getIndex( type );
  1147. start = myDefaultShape [index*3];
  1148. middle = myDefaultShape [index*3+1];
  1149. end = myDefaultShape [index*3+2];
  1150. return !undefinedShape[index];
  1151. }
  1152. /*!
  1153. Sets the colors for a certain type of Gantt item. Not all items use
  1154. all three colors (e.g., only summary items use the middle color).
  1155. This setting overrides any color settings made on individual items.
  1156. These settings will be taken as initial values of any newly created
  1157. item of this certain type.
  1158. See also the description of the KDGanttViewItem class.
  1159. \param type the type of Gantt items for which to set the colors
  1160. \param start the color to use for the beginning of the item
  1161. \param middle the color to use for the middle of the item
  1162. \param end the color to use for the end of the item
  1163. \param overwriteExisting if true, overwrites existing color settings
  1164. on invididual items
  1165. \sa colors(), setDefaultColors(), defaultColors()
  1166. */
  1167. void KDGanttView::setColors( KDGanttViewItem::Type type,
  1168. const TQColor& start, const TQColor& middle,
  1169. const TQColor& end,
  1170. bool overwriteExisting )
  1171. {
  1172. if ( overwriteExisting ) {
  1173. TQListViewItemIterator it(myListView);
  1174. for ( ; it.current(); ++it ) {
  1175. if ( ((KDGanttViewItem*)it.current())->type() == type)
  1176. ((KDGanttViewItem*)it.current())->setColors(start,middle, end );
  1177. }
  1178. }
  1179. int index = getIndex( type );
  1180. myColor [index*3] = start;
  1181. myColor [index*3+1] = middle;
  1182. myColor [index*3+2] = end;
  1183. undefinedColor[index] = false;
  1184. }
  1185. /*!
  1186. Queries the colors for a particular type of Gantt item.
  1187. \param type the type of Gantt items for which to query the colors
  1188. \param start the start color is returned in this parameter
  1189. \param middle the middle color is returned in this parameter
  1190. \param end the end color is returned in this parameter
  1191. \return true if there was a general color set for the specified
  1192. type. If the return value is false, the values of the three color
  1193. parameters are undefined.
  1194. \sa setColors(), setDefaultColor(), defaultColor()
  1195. */
  1196. bool KDGanttView::colors( KDGanttViewItem::Type type,
  1197. TQColor& start, TQColor& middle, TQColor& end ) const
  1198. {
  1199. int index = getIndex( type );
  1200. start = myColor [index*3];
  1201. middle = myColor [index*3+1];
  1202. end = myColor [index*3+2];
  1203. return !undefinedColor[index];
  1204. }
  1205. /*!
  1206. Sets the highlight colors for a certain type of Gantt item. Not
  1207. all items use all three highlight colors (e.g., only summary items
  1208. use the middle highlight color).
  1209. This setting overrides any highlight color settings made on
  1210. individual items.
  1211. These settings will be taken as initial values of any newly created
  1212. item of this certain type.
  1213. See also the description of the KDGanttViewItem class.
  1214. \param type the type of Gantt items for which to set the highlight colors
  1215. \param start the highlight color to use for the beginning of the item
  1216. \param middle the highlight color to use for the middle of the item
  1217. \param end the highlight color to use for the end of the item
  1218. \param overwriteExisting if true, overwrites existing color settings
  1219. in the individual items
  1220. \sa highlightColors(), setDefaultHighlightColor(), defaultHighlightColor()
  1221. */
  1222. void KDGanttView::setHighlightColors( KDGanttViewItem::Type type,
  1223. const TQColor& start,
  1224. const TQColor& middle,
  1225. const TQColor& end,
  1226. bool overwriteExisting )
  1227. {
  1228. if ( overwriteExisting ) {
  1229. TQListViewItemIterator it(myListView);
  1230. for ( ; it.current(); ++it ) {
  1231. if ( ((KDGanttViewItem*)it.current())->type() == type)
  1232. ((KDGanttViewItem*)it.current())->setHighlightColors(start,middle, end );
  1233. }
  1234. }
  1235. int index = getIndex( type );
  1236. myColorHL [index*3] = start;
  1237. myColorHL [index*3+1] = middle;
  1238. myColorHL [index*3+2] = end;
  1239. undefinedColorHL[index] = false;
  1240. }
  1241. /*!
  1242. Queries the highlight colors for a particular type of Gantt item.
  1243. \param type the type of Gantt items for which to query the highlight
  1244. colors
  1245. \param start the start highlight color is returned in this parameter
  1246. \param middle the middle highlight color is returned in this parameter
  1247. \param end the end highlight color is returned in this parameter
  1248. \return true if there was a general highlight color set for the specified
  1249. type. If the return value is false, the values of the three highlight color
  1250. parameters are undefined.
  1251. \sa setHighlightColors(), setDefaultHighlightColor(),
  1252. defaultHighlightColor()
  1253. */
  1254. bool KDGanttView::highlightColors( KDGanttViewItem::Type type,
  1255. TQColor& start, TQColor& middle,
  1256. TQColor& end ) const
  1257. {
  1258. int index = getIndex( type );
  1259. start = myColorHL [index*3];
  1260. middle = myColorHL [index*3+1];
  1261. end = myColorHL [index*3+2];
  1262. return !undefinedColorHL[index];
  1263. }
  1264. /*!
  1265. Sets the color used for texts in the Gantt chart.
  1266. Overrides all individual settings of the Gantt items.
  1267. \param color the text color to use
  1268. \sa textColor()
  1269. */
  1270. void KDGanttView::setTextColor( const TQColor& color )
  1271. {
  1272. TQListViewItemIterator it(myListView);
  1273. for ( ; it.current(); ++it ) {
  1274. ((KDGanttViewItem*)it.current())->setTextColor(color);
  1275. }
  1276. myTextColor = color;
  1277. }
  1278. /*!
  1279. Returns the color used for texts in the Gantt chart.
  1280. \return the color used for texts in the Gantt chart.
  1281. \sa setTextColor()
  1282. */
  1283. TQColor KDGanttView::textColor() const
  1284. {
  1285. return myTextColor;
  1286. }
  1287. /*!
  1288. Specifies the brush in which the 'showNoInformation' line of items
  1289. should be drawn.
  1290. \param brush the brush of the 'showNoInformation' lines
  1291. \sa KDGanttViewItem::showNoInformation(),
  1292. KDGanttViewItem::setShowNoInformation(),
  1293. KDGanttView::noInformationBrush()
  1294. */
  1295. void KDGanttView::setNoInformationBrush( const TQBrush& brush )
  1296. {
  1297. myTimeTable->setNoInformationBrush( brush );
  1298. }
  1299. /*!
  1300. Returns the brush of the 'showNoInformation' lines
  1301. \return the brush of the 'showNoInformation' lines
  1302. \sa KDGanttViewItem::showNoInformation(), KDGanttViewItem::setShowNoInformation(),
  1303. setNoInformationBrush()
  1304. */
  1305. TQBrush KDGanttView::noInformationBrush() const
  1306. {
  1307. return myTimeTable->noInformationBrush();
  1308. }
  1309. /*!
  1310. Removes all items from the legend.
  1311. \sa addLegendItem()
  1312. */
  1313. void KDGanttView::clearLegend( )
  1314. {
  1315. myLegend->clearLegend();
  1316. myLegendItems->setAutoDelete( true );
  1317. delete myLegendItems;
  1318. myLegendItems = new TQPtrList<legendItem>;
  1319. }
  1320. /*!
  1321. Adds an item to the legend.
  1322. \param shape the shape to display
  1323. \param shapeColor the color in which to display the shape
  1324. \param text the text to display
  1325. \sa clearLegend()
  1326. */
  1327. void KDGanttView::addLegendItem( KDGanttViewItem::Shape shape,
  1328. const TQColor& shapeColor,
  1329. const TQString& text )
  1330. {
  1331. myLegend->addLegendItem( shape,shapeColor,text );
  1332. legendItem* item = new legendItem;
  1333. item->shape = shape;
  1334. item->color = shapeColor;
  1335. item->text = text;
  1336. myLegendItems->append( item );
  1337. }
  1338. /*!
  1339. Sets the start of the horizon of the Gantt chart. If \a start is
  1340. null, the horizon start is computed automatically.
  1341. \param start the start of the horizon
  1342. \sa horizonStart()
  1343. */
  1344. void KDGanttView::setHorizonStart( const TQDateTime& start )
  1345. {
  1346. myTimeHeader->setHorizonStart(start);
  1347. }
  1348. /*!
  1349. Returns the start of the horizon of the Gantt chart.
  1350. \return the start of the horizon of the Gantt chart
  1351. \sa setHorizonStart()
  1352. */
  1353. TQDateTime KDGanttView::horizonStart() const
  1354. {
  1355. return myTimeHeader->horizonStart();
  1356. }
  1357. /*!
  1358. Sets the end of the horizon of the Gantt chart. If \a end is
  1359. null, the horizon end is computed automatically.
  1360. \param end the end of the horizon
  1361. \sa setHorizonEnd()
  1362. */
  1363. void KDGanttView::setHorizonEnd( const TQDateTime& end )
  1364. {
  1365. myTimeHeader->setHorizonEnd(end);
  1366. }
  1367. /*!
  1368. Returns the end of the horizon of the Gantt chart.
  1369. \return the end of the horizon of the Gantt chart
  1370. \sa setHorizonEnd()
  1371. */
  1372. TQDateTime KDGanttView::horizonEnd() const
  1373. {
  1374. return myTimeHeader->horizonEnd();
  1375. }
  1376. /*!
  1377. Configures the unit of the lower scale of the header. The higher
  1378. unit is computed automatically.
  1379. \param unit the unit of the lower scale of the header.
  1380. \sa scale()
  1381. */
  1382. void KDGanttView::setScale( Scale unit )
  1383. {
  1384. myTimeHeader->setScale( unit );
  1385. }
  1386. /*!
  1387. Returns the unit of the lower scale of the header.
  1388. \return the unit of the lower scale of the header.
  1389. \sa setScale()
  1390. */
  1391. KDGanttView::Scale KDGanttView::scale() const
  1392. {
  1393. return myTimeHeader->scale();
  1394. }
  1395. /*!
  1396. Sets the maximum allowed time scale of the lower scale of the header.
  1397. \param unit the unit of the lower scale of the header.
  1398. \sa scale()
  1399. */
  1400. void KDGanttView::setMaximumScale( Scale unit )
  1401. {
  1402. myTimeHeader->setMaximumScale( unit );
  1403. }
  1404. /*!
  1405. Returns the maximum allowed time scale of the lower scale of the header.
  1406. \return the unit of the lower scale of the header.
  1407. \sa setScale()
  1408. */
  1409. KDGanttView::Scale KDGanttView::maximumScale() const
  1410. {
  1411. return myTimeHeader->maximumScale();
  1412. }
  1413. /*!
  1414. Sets the minimum allowed time scale of the lower scale of the header.
  1415. \param unit the unit of the lower scale of the header.
  1416. \sa scale()
  1417. */
  1418. void KDGanttView::setMinimumScale( Scale unit )
  1419. {
  1420. myTimeHeader->setMinimumScale( unit );
  1421. }
  1422. /*!
  1423. Returns the minimum allowed time scale of the lower scale of the header.
  1424. \return the unit of the lower scale of the header.
  1425. \sa setScale()
  1426. */
  1427. KDGanttView::Scale KDGanttView::minimumScale() const
  1428. {
  1429. return myTimeHeader->minimumScale();
  1430. }
  1431. /*!
  1432. Sets the absolute number of minor ticks, if scaling is set to Auto.
  1433. If the scale mode is set to Auto, then the actual scale and
  1434. the minorScaleCount is automatically computed, such that there are
  1435. count minor ticks
  1436. \param count the number of minor ticks
  1437. \sa autoScaleMinorTickCount(),setScale(),scale()
  1438. */
  1439. void KDGanttView::setAutoScaleMinorTickCount( int count )
  1440. {
  1441. myTimeHeader->setAutoScaleMinorTickCount( count );
  1442. }
  1443. /*!
  1444. Returns the absolut number of minor ticks, if scaling is set to Auto
  1445. \return the absolut number of minor ticks
  1446. \sa setAutoScaleMinorTickCount(),setScale(),scale()
  1447. */
  1448. int KDGanttView::autoScaleMinorTickCount() const
  1449. {
  1450. return myTimeHeader->autoScaleMinorTickCount();
  1451. }
  1452. /*!
  1453. Sets the minimum width that a column needs to have. If the size of the
  1454. Gantt chart and the scale would make it necessary to go below this
  1455. limit otherwise, the chart will automatically be made less exact.
  1456. \param width the minimum column width
  1457. \sa minimumColumnWidth()
  1458. */
  1459. void KDGanttView::setMinimumColumnWidth( int width )
  1460. {
  1461. myTimeHeader->setMinimumColumnWidth( width );
  1462. }
  1463. /*!
  1464. Returns the minimum width a column needs to have.
  1465. \return the column minimum width
  1466. \sa setMinimumColumnWidth()
  1467. */
  1468. int KDGanttView::minimumColumnWidth() const
  1469. {
  1470. return myTimeHeader->minimumColumnWidth();
  1471. }
  1472. /*!
  1473. Specifies the format in which to display years. If no years are
  1474. shown, this method has no effect.
  1475. \param format the year format
  1476. \sa yearFormat(), setHourFormat(), hourFormat()
  1477. */
  1478. void KDGanttView::setYearFormat( YearFormat format )
  1479. {
  1480. myTimeHeader->setYearFormat(format );
  1481. }
  1482. /*!
  1483. Returns the format in which to display years.
  1484. \return the year format
  1485. \sa setYearFormat(), setHourFormat(), hourFormat()
  1486. */
  1487. KDGanttView::YearFormat KDGanttView::yearFormat() const
  1488. {
  1489. return myTimeHeader->yearFormat();
  1490. }
  1491. /*!
  1492. Specifies the format in which to display hours. If no hours are
  1493. shown, this method has no effect.
  1494. \param format the hour format
  1495. \sa hourFormat(), setYearFormat(), yearFormat()
  1496. */
  1497. void KDGanttView::setHourFormat( HourFormat format )
  1498. {
  1499. myTimeHeader->setHourFormat( format );
  1500. }
  1501. /*!
  1502. Returns the format in which to display hours.
  1503. \return the hour format
  1504. \sa setHourFormat(), setYearFormat(), yearFormat()
  1505. */
  1506. KDGanttView::HourFormat KDGanttView::hourFormat() const
  1507. {
  1508. return myTimeHeader->hourFormat();
  1509. }
  1510. /*!
  1511. Hides/shows the grid for the major ticks of the time header in the gantt view.
  1512. \param show true in order to show ticks, false in order to hide them.
  1513. If show is true, setShowMinorTicks( false ) is performed automatically
  1514. to hide the grid of the minor ticks.
  1515. In order to show now grid, call setShowMinorTicks( false ) and
  1516. setShowMajorTicks( false ).
  1517. \sa showMajorTicks(), setShowMinorTicks(), showMinorTicks()
  1518. */
  1519. void KDGanttView::setShowMajorTicks( bool show )
  1520. {
  1521. myTimeHeader->setShowMajorTicks(show );
  1522. }
  1523. /*!
  1524. Returns whether the grid is shown on the major scale.
  1525. \return true if ticks are shown on the major scale
  1526. \sa setShowMajorTicks(), setShowMinorTicks(), showMinorTicks()
  1527. */
  1528. bool KDGanttView::showMajorTicks() const
  1529. {
  1530. return myTimeHeader->showMajorTicks();
  1531. }
  1532. /*!
  1533. Hides/shows the grid for the minor ticks of the time header in the gantt view.
  1534. \param show true in order to show ticks, false in order to hide them.
  1535. If show is true, setShowMajorTicks( false ) is performed automatically
  1536. to hide the grid of the major ticks.
  1537. In order to show now grid, call setShowMinorTicks( false ) and
  1538. setShowMajorTicks( false ).
  1539. \sa showMinorTicks(), setShowMajorTicks(), showMajorTicks()
  1540. */
  1541. void KDGanttView::setShowMinorTicks( bool show)
  1542. {
  1543. myTimeHeader->setShowMinorTicks( show );
  1544. }
  1545. /*!
  1546. Returns whether ticks are shown on the minor scale.
  1547. \return true if ticks are shown on the minor scale
  1548. \sa setShowMinorTicks(), setShowMajorTicks(), showMajorTicks()
  1549. */
  1550. bool KDGanttView::showMinorTicks() const
  1551. {
  1552. return myTimeHeader->showMinorTicks();
  1553. }
  1554. /*!
  1555. Sets the background color for the column closest to \a column.
  1556. It can be specified whether the color should be shown in all scales or
  1557. only in specific scales.
  1558. If you want to define the color only for the daily view, specify
  1559. mini and maxi as Day.
  1560. If there is no value specified for mini and maxi, the color for the column
  1561. is shown on all scales. Note that it is possible that there are two
  1562. values for a column in a scale. In this case, the shown color is unspecified.
  1563. \param column the column to set the background color for
  1564. \param color the background color
  1565. \param mini show the colour only in scales greater than this
  1566. \param maxi show the colour only in scales lesser than this
  1567. \sa columnBackgroundColor(), setWeekendBackgroundColor(),
  1568. weekendBackgroundColor()
  1569. */
  1570. void KDGanttView::setColumnBackgroundColor( const TQDateTime& column,
  1571. const TQColor& color ,
  1572. Scale mini, Scale maxi )
  1573. {
  1574. myTimeHeader->setColumnBackgroundColor( column, color,mini,maxi );
  1575. }
  1576. /*!
  1577. Sets the background color for a time interval given by \a start and
  1578. \a end. \a start may be later than \a end. If there is already a
  1579. background interval with the same \a start and \a end values
  1580. defined, the values (i.e. const TQColor& color , Scale mini, Scale
  1581. maxi) of this background interval are changed. Change the times of
  1582. an already defined interval with \a changeBackgroundInterval().
  1583. Delete an already defined interval with \a
  1584. deleteBackgroundInterval().
  1585. It can be defined, whether the color should be shown in all scales or
  1586. only in specific scales.
  1587. If you want to define the color only for the daily view, scecify
  1588. mini and maxi as Day.
  1589. If there is no value for mini/maxi specified, the color for the columns
  1590. is shown in all scales.
  1591. \param start start datetime of the time interval
  1592. \param end end datetime of the time interval
  1593. \param color the background color
  1594. \param mini show the color only in scales greater than this
  1595. \param maxi show the color only in scales lesser than this
  1596. \sa changeBackgroundInterval(), deleteBackgroundInterval(),
  1597. columnBackgroundColor(), setWeekendBackgroundColor(),
  1598. weekendBackgroundColor()
  1599. */
  1600. void KDGanttView::setIntervalBackgroundColor( const TQDateTime& start,
  1601. const TQDateTime& end,
  1602. const TQColor& color ,
  1603. Scale mini, Scale maxi )
  1604. {
  1605. myTimeHeader->setIntervalBackgroundColor( start, end, color,mini,maxi );
  1606. }
  1607. /*!
  1608. Changes the times of an already defined background color interval.
  1609. The new values \a startnew and \a endnew should not be datetime
  1610. values of an already defined background color interval.
  1611. If that is the case, nothing is changed and false is returned.
  1612. \param oldstart the start date and time of the interval to change
  1613. \param oldend the end date and time of the interval to change
  1614. \param newstart the new start date and time
  1615. \param newend the new end date and time
  1616. \return true, if there is a backgroundcolor interval with values
  1617. \a start and \a end found and the new values \a startnew and \a endnew
  1618. are not datetime values of an already defined background color interval.
  1619. Returns false otherwise.
  1620. \sa changeBackgroundInterval(), deleteBackgroundInterval(),
  1621. columnBackgroundColor(), setWeekendBackgroundColor(),
  1622. weekendBackgroundColor()
  1623. */
  1624. bool KDGanttView::changeBackgroundInterval( const TQDateTime& oldstart,
  1625. const TQDateTime& oldend,
  1626. const TQDateTime& newstart,
  1627. const TQDateTime& newend )
  1628. {
  1629. return myTimeHeader->changeBackgroundInterval( oldstart, oldend,
  1630. newstart, newend );
  1631. }
  1632. /*!
  1633. Deletes an already defined background color interval.
  1634. \param start start datetime of time interval
  1635. \param end end datetime of time interval
  1636. \return true, if there is a backgroundcolor interval with values
  1637. \a start and \a end found (and hence deleted).
  1638. \sa changeBackgroundInterval(), columnBackgroundColor()
  1639. */
  1640. bool KDGanttView::deleteBackgroundInterval( const TQDateTime& start,
  1641. const TQDateTime& end)
  1642. {
  1643. return myTimeHeader->deleteBackgroundInterval( start, end );
  1644. }
  1645. /*!
  1646. Removes all background color settings set with setColumnBackgroundColor()
  1647. and setIntervalBackgroundColor().
  1648. Does not affect the settings of setWeekendBackgroundColor().
  1649. \sa setColumnBackgroundColor(), setWeekendBackgroundColor(),
  1650. weekendBackgroundColor(), setIntervalBackgroundColor()
  1651. */
  1652. void KDGanttView::clearBackgroundColor()
  1653. {
  1654. myTimeHeader->clearBackgroundColor();
  1655. }
  1656. /*!
  1657. Returns the background color for the column closest to \a column.
  1658. \param column the column to query the background color for
  1659. \return the background color of the specified color
  1660. \sa setColumnBackgroundColor(), setWeekendBackgroundColor(),
  1661. weekendBackgroundColor()
  1662. */
  1663. TQColor KDGanttView::columnBackgroundColor( const TQDateTime& column ) const
  1664. {
  1665. return myTimeHeader->columnBackgroundColor( column ) ;
  1666. }
  1667. /*!
  1668. Specifies the background color for weekend days. If no individual
  1669. days are visible on the Gantt chart, this method has no visible
  1670. effect.
  1671. \param color the background color to use for weekend days.
  1672. \sa weekendBackgroundColor(), setWeekendDays(), weekendDays()
  1673. */
  1674. void KDGanttView::setWeekendBackgroundColor( const TQColor& color )
  1675. {
  1676. myTimeHeader->setWeekendBackgroundColor( color );
  1677. }
  1678. /*!
  1679. Returns the background color for weekend days.
  1680. \return the background color for weekend days
  1681. \sa setWeekendBackgroundColor(), setWeekendDays(), weekendDays()
  1682. */
  1683. TQColor KDGanttView::weekendBackgroundColor() const
  1684. {
  1685. return myTimeHeader->weekendBackgroundColor();
  1686. }
  1687. /*!
  1688. Specifies the background color for weekday days. If no individual
  1689. days are visible on the Gantt chart, this method has no visible
  1690. effect. The days are specified as an intervals of integer values
  1691. where 1 means Monday and 7 means Sunday.
  1692. \param color the background color to use for weekend days.
  1693. \param weekday the day of the week (Monday = 1, Sunday = 7)
  1694. \sa weekendBackgroundColor(), setWeekendDays(), weekendDays()
  1695. */
  1696. void KDGanttView::setWeekdayBackgroundColor( const TQColor& color, int weekday )
  1697. {
  1698. myTimeHeader->setWeekdayBackgroundColor( color, weekday );
  1699. }
  1700. /*!
  1701. Returns the background color for weekday days.
  1702. \param weekday the day of the week (Monday = 1, Sunday = 7)
  1703. \return the background color for weekend days
  1704. \sa setWeekendBackgroundColor(), setWeekendDays(), weekendDays()
  1705. */
  1706. TQColor KDGanttView::weekdayBackgroundColor(int weekday) const
  1707. {
  1708. return myTimeHeader->weekdayBackgroundColor( weekday);
  1709. }
  1710. /*!
  1711. Defines which days are considered weekends. The days are specified
  1712. as an interval of integer values where 1 means Monday and 7 means
  1713. Sunday. In order to define a weekend from Sunday to Monday, specify
  1714. (7,1).
  1715. \param start the first day of the weekend
  1716. \param end the last day of the weekend
  1717. \sa weekendDays(), setWeekendBackgroundColor(), weekendBackgroundColor()
  1718. */
  1719. void KDGanttView::setWeekendDays( int start, int end )
  1720. {
  1721. myTimeHeader->setWeekendDays( start, end );
  1722. }
  1723. /*!
  1724. Returns which days are considered weekends.
  1725. \param start in this parameter, the first day of the weekend is returned
  1726. \param end in this parameter, the end day of the weekend is returned
  1727. \sa setWeekendDays(), setWeekendBackgroundColor(), weekendBackgroundColor()
  1728. */
  1729. void KDGanttView::weekendDays( int& start, int& end ) const
  1730. {
  1731. myTimeHeader->weekendDays( start, end );
  1732. }
  1733. /*!
  1734. \fn void KDGanttView::itemLeftClicked( KDGanttViewItem* )
  1735. This signal is emitted when the user clicks on an item with the left
  1736. mouse button.
  1737. */
  1738. /*!
  1739. \fn void KDGanttView::itemMidClicked( KDGanttViewItem* )
  1740. This signal is emitted when the user clicks on an item with the middle
  1741. mouse button.
  1742. */
  1743. /*!
  1744. \fn void KDGanttView::itemRightClicked( KDGanttViewItem* )
  1745. This signal is emitted when the user clicks on an item with the right
  1746. mouse button.
  1747. */
  1748. /*!
  1749. \fn void KDGanttView::itemDoubleClicked( KDGanttViewItem* )
  1750. This signal is emitted when the user double-clicks an item.
  1751. */
  1752. /*!
  1753. \fn void KDGanttView::itemConfigured( KDGanttViewItem* )
  1754. This signal is emitted when the user has configured an item
  1755. visually.
  1756. */
  1757. /*!
  1758. \fn void KDGanttView::taskLinkLeftClicked( KDGanttViewTaskLink* )
  1759. This signal is emitted when the user clicks on a task link with the
  1760. left mouse button.
  1761. */
  1762. /*!
  1763. \fn void KDGanttView::taskLinkMidClicked( KDGanttViewTaskLink* )
  1764. This signal is emitted when the user clicks on a task link with the
  1765. middle mouse button.
  1766. */
  1767. /*!
  1768. \fn void KDGanttView::taskLinkRightClicked( KDGanttViewTaskLink* )
  1769. This signal is emitted when the user clicks on a task link with the
  1770. right mouse button.
  1771. */
  1772. /*!
  1773. \fn void KDGanttView::taskLinkDoubleClicked( KDGanttViewTaskLink* )
  1774. This signal is emitted when the user double-clicks a task link.
  1775. */
  1776. /*!
  1777. \enum KDGanttView::YearFormat
  1778. This enum is used to specify the year format used in the header.
  1779. */
  1780. /*!
  1781. \enum KDGanttView::HourFormat
  1782. This enum is used to specify the hour format used in the header.
  1783. */
  1784. /*!
  1785. \enum KDGanttView::Scale
  1786. This enum is used to specify the units of the scales in the header.
  1787. */
  1788. /*!
  1789. Sets the number of ticks in the major scale.
  1790. \param count the number of ticks in the major scale
  1791. \sa majorScaleCount(), setMinorScaleCount(), minorScaleCount()
  1792. */
  1793. void KDGanttView::setMajorScaleCount( int count )
  1794. {
  1795. myTimeHeader->setMajorScaleCount(count );
  1796. }
  1797. /*!
  1798. Returns the number of ticks per unit in the major scale.
  1799. \return the number of ticks in the major scale
  1800. \sa setMajorScaleCount(), setMinorScaleCount(), minorScaleCount()
  1801. */
  1802. int KDGanttView::majorScaleCount() const
  1803. {
  1804. return myTimeHeader->majorScaleCount();
  1805. }
  1806. /*!
  1807. Sets the number of ticks in the minor scale.
  1808. \param count the number of ticks in the minor scale
  1809. \sa minorScaleCount, setMajorScaleCount, majorScaleCount()
  1810. */
  1811. void KDGanttView::setMinorScaleCount( int count )
  1812. {
  1813. myTimeHeader->setMinorScaleCount(count );
  1814. }
  1815. /*!
  1816. Returns the number of ticks per unit in the minor scale.
  1817. \return the number of ticks in the minor scale
  1818. \sa setMinorScaleCount(), setMajorScaleCount(), majorScaleCount()
  1819. */
  1820. int KDGanttView::minorScaleCount() const
  1821. {
  1822. return myTimeHeader->minorScaleCount();
  1823. }
  1824. /*!
  1825. Sets the default color for a particular type of Gantt item that is
  1826. used for the item if no specific start, middle, or end colors are
  1827. set.
  1828. \param type the type of Gantt items for which to query the highlight
  1829. colors
  1830. \param color the default color to use
  1831. \param overwriteExisting if true, existing settings for individual
  1832. items are overwritten
  1833. \sa defaultColor(), setColors(), colors()
  1834. */
  1835. void KDGanttView::setDefaultColor( KDGanttViewItem::Type type,
  1836. const TQColor& color,
  1837. bool overwriteExisting )
  1838. {
  1839. if ( overwriteExisting ) {
  1840. TQListViewItemIterator it(myListView);
  1841. for ( ; it.current(); ++it ) {
  1842. if ( ((KDGanttViewItem*)it.current())->type() == type)
  1843. ((KDGanttViewItem*)it.current())->setDefaultColor(color );
  1844. }
  1845. }
  1846. int index = getIndex( type );
  1847. myDefaultColor [index] = color;
  1848. }
  1849. /*!
  1850. Returns the default color for a particular type of Gantt item that
  1851. is used for the item if no specific start, middle, or end colors are
  1852. set.
  1853. \param type the type of Gantt items for which to query the highlight
  1854. colors
  1855. \return color the default color used
  1856. \sa setDefaultColor(), setColors(), colors()
  1857. */
  1858. TQColor KDGanttView::defaultColor( KDGanttViewItem::Type type ) const
  1859. {
  1860. int index = getIndex( type );
  1861. return myDefaultColor [index];
  1862. }
  1863. /*!
  1864. Sets the default highlighting color for a particular type of
  1865. Gantt item that is used for the item if no specific start, middle,
  1866. or end colors are set.
  1867. \param type the type of Gantt items for which to query the highlight
  1868. colors
  1869. \param color the default highlighting color to use
  1870. \param overwriteExisting if true, existing color settings in
  1871. individual items are overwritten
  1872. \sa defaultHighlightColor(), setHighlightColors(), highlightColors()
  1873. */
  1874. void KDGanttView::setDefaultHighlightColor( KDGanttViewItem::Type type,
  1875. const TQColor& color,
  1876. bool overwriteExisting )
  1877. {
  1878. if ( overwriteExisting ) {
  1879. TQListViewItemIterator it(myListView);
  1880. for ( ; it.current(); ++it ) {
  1881. if ( ((KDGanttViewItem*)it.current())->type() == type)
  1882. ((KDGanttViewItem*)it.current())->setDefaultHighlightColor(color );
  1883. }
  1884. }
  1885. int index = getIndex( type );
  1886. myDefaultColorHL [index] = color;
  1887. }
  1888. /*!
  1889. Returns the default highlighting color for a particular type of
  1890. Gantt item that is used for the item if no specific start, middle,
  1891. or end colors are set.
  1892. \param type the type of Gantt items for which to query the highlight
  1893. colors
  1894. \return color the default highlighting color used
  1895. \sa setDefaultHighlightColor(), setHighlightColors(), highlightColors()
  1896. */
  1897. TQColor KDGanttView::defaultHighlightColor( KDGanttViewItem::Type type ) const
  1898. {
  1899. int index = getIndex( type );
  1900. return myDefaultColorHL [index];
  1901. }
  1902. /*!
  1903. Returns the first item in the Gantt view.
  1904. \return the first item in the Gantt view, 0 if there are no items
  1905. */
  1906. KDGanttViewItem* KDGanttView::firstChild() const
  1907. {
  1908. return (KDGanttViewItem*)myListView->firstChild();
  1909. }
  1910. /*!
  1911. This method turns calendar mode on and off. In calendar mode, only
  1912. those items can be opened which have subitems which have
  1913. subitems. I.e., if an item contains multiple calendars, it can be
  1914. opened, but not a calendar item itself. If you want to use this
  1915. GanttView as a calendar view, you have to call
  1916. setDisplaySubitemsAsGroup( true ); to use the root items as calendar
  1917. items. To create new calendar entries for these root items, create
  1918. a new KDGanttViewTaskItem with this root item as a parent. If you
  1919. want an item with subitems to behave like a calendar (which is
  1920. possibly empty at startup), please call setIsCalendar( true ); for
  1921. this item.
  1922. \param mode if true, the calendar view mode is turned on
  1923. if false, the calendar view mode is turned off
  1924. \sa setDisplaySubitemsAsGroup(), displaySubitemsAsGroup(), calendarMode()
  1925. */
  1926. void KDGanttView::setCalendarMode( bool mode )
  1927. {
  1928. myListView->setCalendarMode( mode );
  1929. }
  1930. /*!
  1931. Returns true, if the Gantt view is in calendar mode. See
  1932. setCalendarMode() for the meaning of calendar mode.
  1933. \return returns true, if the Gantt view is in calendermode
  1934. \sa setCalendarMode()
  1935. */
  1936. bool KDGanttView::calendarMode() const
  1937. {
  1938. return myListView->calendarMode();
  1939. }
  1940. /*!
  1941. This method specifies whether hidden subitems should be displayed.
  1942. It iterates over all KDGanttViewItems in this Gantt view
  1943. and sets their displaySubitemsAsGroup() property.
  1944. All newly created items will have this setting by default.
  1945. \param show if true, the hidden subitems are displayed in all items of
  1946. this Gantt view.
  1947. \sa KDGanttViewItem::setDisplaySubitemsAsGroup(), KDGanttViewItem::displaySubitemsAsGroup()
  1948. */
  1949. void KDGanttView::setDisplaySubitemsAsGroup( bool show )
  1950. {
  1951. TQListViewItemIterator it( myListView );
  1952. for ( ; it.current(); ++it ) {
  1953. KDGanttViewItem* currentItem = ( KDGanttViewItem* )it.current();
  1954. currentItem->setDisplaySubitemsAsGroup( show );
  1955. }
  1956. _displaySubitemsAsGroup = show;
  1957. }
  1958. /*!
  1959. Returns, whether new items are created with the
  1960. displayHiddenSubitems property.
  1961. \return true, if hidden subitems should be displayed on newly created items.
  1962. \sa setDisplaySubitemsAsGroup(),
  1963. KDGanttViewItem::setDisplaySubitemsAsGroup(),
  1964. KDGanttViewItem::displaySubitemsAsGroup()
  1965. */
  1966. bool KDGanttView::displaySubitemsAsGroup() const
  1967. {
  1968. return _displaySubitemsAsGroup;
  1969. }
  1970. /*!
  1971. This method specifies whether tasks where the start time and the end
  1972. time are the same are displayed
  1973. as a line over the full height of the Gantt view.
  1974. \param show if true, tasks with starttime == endtime are displayed
  1975. as a line
  1976. */
  1977. void KDGanttView::setDisplayEmptyTasksAsLine( bool show )
  1978. {
  1979. _displayEmptyTasksAsLine = show;
  1980. }
  1981. /*!
  1982. Returns, whether tasks where the start time and the end time are the
  1983. same are displayed
  1984. as a line over the full height of the Gantt view.
  1985. \return true, if empty tasks are displayed as line.
  1986. */
  1987. bool KDGanttView::displayEmptyTasksAsLine() const
  1988. {
  1989. return _displayEmptyTasksAsLine;
  1990. }
  1991. /*!
  1992. Defines the horizontal background lines of the Gantt chart.
  1993. Call setHorBackgroundLines()
  1994. (equivalent to setHorBackgroundLines( 2, TQBrush( TQColor ( 240,240,240 )) ) )
  1995. to draw a light grey horizontal background line for every second Gantt item.
  1996. Call setHorBackgroundLines(0) in order to not show horizontal
  1997. background lines.
  1998. You may specify the number of lines and the brush of the lines.
  1999. \param count for count >= 2, every count line gets a backgroud
  2000. specified by brush
  2001. for count < 2, no background lines are drawn
  2002. \param brush the brush of the lines
  2003. */
  2004. void KDGanttView::setHorBackgroundLines( int count, TQBrush brush )
  2005. {
  2006. myTimeTable->setHorBackgroundLines( count, brush );
  2007. }
  2008. /*!
  2009. Returns the definition of the horizontal background lines of the
  2010. Gantt chart.
  2011. \param brush the brush of the lines
  2012. \return every nth line gets a background specified by brush
  2013. if 0 is returned, no backgroud lines are drawn
  2014. */
  2015. int KDGanttView::horBackgroundLines( TQBrush& brush )
  2016. {
  2017. return myTimeTable->horBackgroundLines( brush );
  2018. }
  2019. /*!
  2020. Returns the last item in the Gantt view
  2021. \return the last item in the Gantt view, 0 if there are no items
  2022. */
  2023. KDGanttViewItem* KDGanttView::lastItem() const
  2024. {
  2025. return (KDGanttViewItem*)myListView->lastItem ();
  2026. }
  2027. /*!
  2028. Returns the list of task links in the Gantt view.
  2029. \return the list of task links in the Gantt view
  2030. */
  2031. TQPtrList<KDGanttViewTaskLink> KDGanttView::taskLinks() const
  2032. {
  2033. return myTimeTable->taskLinks();
  2034. }
  2035. /*!
  2036. Returns the list of task link groups in the Gantt view.
  2037. \return the list of task link groups in the Gantt view
  2038. */
  2039. TQPtrList<KDGanttViewTaskLinkGroup> KDGanttView::taskLinkGroups() const
  2040. {
  2041. return myTaskLinkGroupList;
  2042. }
  2043. /**
  2044. Reads the parameters of the view from an XML document.
  2045. \param doc the XML document to read from
  2046. \return true if the parameters could be read, false if a file
  2047. format error occurred
  2048. \sa saveXML
  2049. */
  2050. bool KDGanttView::loadXML( const TQDomDocument& doc )
  2051. {
  2052. TQDomElement docRoot = doc.documentElement(); // ChartParams element
  2053. TQDomNode node = docRoot.firstChild();
  2054. while( !node.isNull() ) {
  2055. TQDomElement element = node.toElement();
  2056. if( !element.isNull() ) { // was really an element
  2057. TQString tagName = element.tagName();
  2058. if( tagName == "ShowLegend" ) {
  2059. bool value;
  2060. if( KDGanttXML::readBoolNode( element, value ) )
  2061. setShowLegend( value );
  2062. } else if( tagName == "ShowLegendButton" ) {
  2063. bool value;
  2064. if( KDGanttXML::readBoolNode( element, value ) )
  2065. setShowLegendButton( value );
  2066. } else if( tagName == "LegendIsDockWindow" ) {
  2067. bool value;
  2068. if( KDGanttXML::readBoolNode( element, value ) )
  2069. setLegendIsDoctwindow( value );
  2070. } else if( tagName == "ShowListView" ) {
  2071. bool value;
  2072. if( KDGanttXML::readBoolNode( element, value ) )
  2073. setShowListView( value );
  2074. } else if( tagName == "ShowHeader" ) {
  2075. bool value;
  2076. if( KDGanttXML::readBoolNode( element, value ) )
  2077. setHeaderVisible( value );
  2078. } else if( tagName == "ShowTaskLinks" ) {
  2079. bool value;
  2080. if( KDGanttXML::readBoolNode( element, value ) )
  2081. setShowTaskLinks( value );
  2082. } else if( tagName == "EditorEnabled" ) {
  2083. bool value;
  2084. if( KDGanttXML::readBoolNode( element, value ) )
  2085. setEditorEnabled( value );
  2086. } else if( tagName == "DisplayEmptyTasksAsLine" ) {
  2087. bool value;
  2088. if( KDGanttXML::readBoolNode( element, value ) )
  2089. setDisplayEmptyTasksAsLine( value );
  2090. } else if( tagName == "GlobalFont" ) {
  2091. TQFont font;
  2092. if( KDGanttXML::readFontNode( element, font ) )
  2093. setFont( font );
  2094. } else if( tagName == "HorizonStart" ) {
  2095. TQDateTime value;
  2096. if( KDGanttXML::readDateTimeNode( element, value ) )
  2097. setHorizonStart( value );
  2098. } else if( tagName == "HorizonEnd" ) {
  2099. TQDateTime value;
  2100. if( KDGanttXML::readDateTimeNode( element, value ) )
  2101. setHorizonEnd( value );
  2102. } else if( tagName == "Scale" ) {
  2103. TQString value;
  2104. if( KDGanttXML::readStringNode( element, value ) )
  2105. setScale( stringToScale( value ) );
  2106. } else if( tagName == "MinimumScale" ) {
  2107. TQString value;
  2108. if( KDGanttXML::readStringNode( element, value ) )
  2109. setMinimumScale( stringToScale( value ) );
  2110. } else if( tagName == "MaximumScale" ) {
  2111. TQString value;
  2112. if( KDGanttXML::readStringNode( element, value ) )
  2113. setMaximumScale( stringToScale( value ) );
  2114. } else if( tagName == "YearFormat" ) {
  2115. TQString value;
  2116. if( KDGanttXML::readStringNode( element, value ) )
  2117. setYearFormat( stringToYearFormat( value ) );
  2118. } else if( tagName == "HourFormat" ) {
  2119. TQString value;
  2120. if( KDGanttXML::readStringNode( element, value ) )
  2121. setHourFormat( stringToHourFormat( value ) );
  2122. } else if( tagName == "ShowMinorTicks" ) {
  2123. bool value;
  2124. if( KDGanttXML::readBoolNode( element, value ) )
  2125. setShowMinorTicks( value );
  2126. } else if( tagName == "ShowMajorTicks" ) {
  2127. bool value;
  2128. if( KDGanttXML::readBoolNode( element, value ) )
  2129. setShowMajorTicks( value );
  2130. } else if( tagName == "DragEnabled" ) {
  2131. bool value;
  2132. if( KDGanttXML::readBoolNode( element, value ) )
  2133. setDragEnabled( value );
  2134. } else if( tagName == "DropEnabled" ) {
  2135. bool value;
  2136. if( KDGanttXML::readBoolNode( element, value ) )
  2137. setDropEnabled( value );
  2138. } else if( tagName == "CalendarMode" ) {
  2139. bool value;
  2140. if( KDGanttXML::readBoolNode( element, value ) )
  2141. setCalendarMode( value );
  2142. } else if( tagName == "Editable" ) {
  2143. bool value;
  2144. if( KDGanttXML::readBoolNode( element, value ) )
  2145. setEditable( value );
  2146. } else if( tagName == "TextColor" ) {
  2147. TQColor value;
  2148. if( KDGanttXML::readColorNode( element, value ) )
  2149. setTextColor( value );
  2150. } else if( tagName == "MajorScaleCount" ) {
  2151. int value;
  2152. if( KDGanttXML::readIntNode( element, value ) )
  2153. setMajorScaleCount( value );
  2154. } else if( tagName == "MinorScaleCount" ) {
  2155. int value;
  2156. if( KDGanttXML::readIntNode( element, value ) )
  2157. setMinorScaleCount( value );
  2158. } else if( tagName == "AutoScaleMinorTickCount" ) {
  2159. int value;
  2160. if( KDGanttXML::readIntNode( element, value ) )
  2161. setAutoScaleMinorTickCount( value );
  2162. } else if( tagName == "MinimumColumnWidth" ) {
  2163. int value;
  2164. if( KDGanttXML::readIntNode( element, value ) )
  2165. setMinimumColumnWidth( value );
  2166. } else if( tagName == "GanttMaximumWidth" ) {
  2167. int value;
  2168. if( KDGanttXML::readIntNode( element, value ) )
  2169. setGanttMaximumWidth( value );
  2170. } else if( tagName == "NoInformationBrush" ) {
  2171. TQBrush value;
  2172. if( KDGanttXML::readBrushNode( element, value ) )
  2173. setNoInformationBrush( value );
  2174. } else if( tagName == "GanttViewBackgroundColor" ) {
  2175. TQColor value;
  2176. if( KDGanttXML::readColorNode( element, value ) )
  2177. setGvBackgroundColor( value );
  2178. } else if( tagName == "ListViewBackgroundColor" ) {
  2179. TQColor value;
  2180. if( KDGanttXML::readColorNode( element, value ) )
  2181. setLvBackgroundColor( value );
  2182. } else if( tagName == "TimeHeaderBackgroundColor" ) {
  2183. TQColor value;
  2184. if( KDGanttXML::readColorNode( element, value ) )
  2185. setTimeHeaderBackgroundColor( value );
  2186. } else if( tagName == "LegendHeaderBackgroundColor" ) {
  2187. TQColor value;
  2188. if( KDGanttXML::readColorNode( element, value ) )
  2189. setLegendHeaderBackgroundColor( value );
  2190. } else if( tagName == "WeekendBackgroundColor" ) {
  2191. TQColor value;
  2192. if( KDGanttXML::readColorNode( element, value ) )
  2193. setWeekendBackgroundColor( value );
  2194. } else if( tagName == "WeekdayBackgroundColor" ) {
  2195. TQDomNode node = element.firstChild();
  2196. int day = 0;
  2197. TQColor color;
  2198. while( !node.isNull() ) {
  2199. TQDomElement element = node.toElement();
  2200. if( !element.isNull() ) { // was really an elemente
  2201. TQString tagName = element.tagName();
  2202. if( tagName == "Day" ) {
  2203. int value;
  2204. if( KDGanttXML::readIntNode( element, value ) )
  2205. day = value;
  2206. } else if( tagName == "Color" ) {
  2207. TQColor value;
  2208. if( KDGanttXML::readColorNode( element, value ) )
  2209. color = value;
  2210. } else {
  2211. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2212. Q_ASSERT( false );
  2213. }
  2214. }
  2215. node = node.nextSibling();
  2216. }
  2217. if( day && color.isValid() )
  2218. setWeekdayBackgroundColor( color, day );
  2219. } else if( tagName == "WeekendDays" ) {
  2220. TQString startString = element.attribute( "Start" );
  2221. TQString endString = element.attribute( "End" );
  2222. bool startOk = false, endOk = false;
  2223. int start = startString.toInt( &startOk );
  2224. int end = startString.toInt( &endOk );
  2225. if( startOk && endOk )
  2226. setWeekendDays( start, end );
  2227. } else if( tagName == "ZoomFactor" ) {
  2228. double value;
  2229. if( KDGanttXML::readDoubleNode( element, value ) )
  2230. setZoomFactor( value, true );
  2231. } else if( tagName == "ShowHeaderPopupMenu" ) {
  2232. bool value;
  2233. if( KDGanttXML::readBoolNode( element, value ) )
  2234. setShowHeaderPopupMenu( value );
  2235. } else if( tagName == "ShowTimeTablePopupMenu" ) {
  2236. bool value;
  2237. if( KDGanttXML::readBoolNode( element, value ) )
  2238. setShowTimeTablePopupMenu( value );
  2239. } else if( tagName == "Shapes" ) {
  2240. TQDomNode node = element.firstChild();
  2241. bool undefinedShape = false;
  2242. while( !node.isNull() ) {
  2243. TQDomElement element = node.toElement();
  2244. if( !element.isNull() ) { // was really an elemente
  2245. TQString tagName = element.tagName();
  2246. if( tagName == "Event" ) {
  2247. KDGanttViewItem::Shape startShape, middleShape, endShape;
  2248. startShape = KDGanttViewItem::TriangleDown;
  2249. middleShape = KDGanttViewItem::TriangleDown;
  2250. endShape = KDGanttViewItem::TriangleDown;
  2251. TQDomNode node = element.firstChild();
  2252. while( !node.isNull() ) {
  2253. TQDomElement element = node.toElement();
  2254. if( !element.isNull() ) { // was really an elemente
  2255. TQString tagName = element.tagName();
  2256. if( tagName == "Start" ) {
  2257. TQString value;
  2258. if( KDGanttXML::readStringNode( element, value ) )
  2259. startShape = KDGanttViewItem::stringToShape( value );
  2260. if ( value == "Undefined" )
  2261. undefinedShape = true;
  2262. } else if( tagName == "Middle" ) {
  2263. TQString value;
  2264. if( KDGanttXML::readStringNode( element, value ) )
  2265. middleShape = KDGanttViewItem::stringToShape( value );
  2266. if ( value == "Undefined" )
  2267. undefinedShape = true;
  2268. } else if( tagName == "End" ) {
  2269. TQString value;
  2270. if( KDGanttXML::readStringNode( element, value ) )
  2271. endShape = KDGanttViewItem::stringToShape( value );
  2272. if ( value == "Undefined" )
  2273. undefinedShape = true;
  2274. } else {
  2275. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2276. Q_ASSERT( false );
  2277. }
  2278. }
  2279. node = node.nextSibling();
  2280. }
  2281. if ( ! undefinedShape )
  2282. setShapes( KDGanttViewItem::Event, startShape,
  2283. middleShape, endShape, false );
  2284. undefinedShape = false;
  2285. } else if( tagName == "Task" ) {
  2286. KDGanttViewItem::Shape startShape, middleShape, endShape;
  2287. startShape = KDGanttViewItem::TriangleDown;
  2288. middleShape = KDGanttViewItem::TriangleDown;
  2289. endShape = KDGanttViewItem::TriangleDown;
  2290. TQDomNode node = element.firstChild();
  2291. while( !node.isNull()) {
  2292. TQDomElement element = node.toElement();
  2293. if( !element.isNull() ) { // was really an elemente
  2294. TQString tagName = element.tagName();
  2295. if( tagName == "Start" ) {
  2296. TQString value;
  2297. if( KDGanttXML::readStringNode( element, value ) )
  2298. startShape = KDGanttViewItem::stringToShape( value );
  2299. if ( value == "Undefined" )
  2300. undefinedShape = true;
  2301. } else if( tagName == "Middle" ) {
  2302. TQString value;
  2303. if( KDGanttXML::readStringNode( element, value ) )
  2304. middleShape = KDGanttViewItem::stringToShape( value );
  2305. if ( value == "Undefined" )
  2306. undefinedShape = true;
  2307. } else if( tagName == "End" ) {
  2308. TQString value;
  2309. if( KDGanttXML::readStringNode( element, value ) )
  2310. endShape = KDGanttViewItem::stringToShape( value );
  2311. if ( value == "Undefined" )
  2312. undefinedShape = true;
  2313. } else {
  2314. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2315. Q_ASSERT( false );
  2316. }
  2317. }
  2318. node = node.nextSibling();
  2319. }
  2320. if ( ! undefinedShape )
  2321. setShapes( KDGanttViewItem::Task, startShape, middleShape, endShape, false );
  2322. undefinedShape = false;
  2323. } else if( tagName == "Summary" ) {
  2324. KDGanttViewItem::Shape startShape, middleShape, endShape;
  2325. startShape = KDGanttViewItem::TriangleDown;
  2326. middleShape = KDGanttViewItem::TriangleDown;
  2327. endShape = KDGanttViewItem::TriangleDown;
  2328. TQDomNode node = element.firstChild();
  2329. while( !node.isNull() ) {
  2330. TQDomElement element = node.toElement();
  2331. if( !element.isNull() ) { // was really an elemente
  2332. TQString tagName = element.tagName();
  2333. if( tagName == "Start" ) {
  2334. TQString value;
  2335. if( KDGanttXML::readStringNode( element, value ) )
  2336. startShape = KDGanttViewItem::stringToShape( value );
  2337. if ( value == "Undefined" )
  2338. undefinedShape = true;
  2339. } else if( tagName == "Middle" ) {
  2340. TQString value;
  2341. if( KDGanttXML::readStringNode( element, value ) )
  2342. middleShape = KDGanttViewItem::stringToShape( value );
  2343. if ( value == "Undefined" )
  2344. undefinedShape = true;
  2345. } else if( tagName == "End" ) {
  2346. TQString value;
  2347. if( KDGanttXML::readStringNode( element, value ) )
  2348. endShape = KDGanttViewItem::stringToShape( value );
  2349. if ( value == "Undefined" )
  2350. undefinedShape = true;
  2351. } else {
  2352. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2353. Q_ASSERT( false );
  2354. }
  2355. }
  2356. node = node.nextSibling();
  2357. }
  2358. if ( ! undefinedShape )
  2359. setShapes( KDGanttViewItem::Summary, startShape,
  2360. middleShape, endShape, false );
  2361. undefinedShape = false;
  2362. } else {
  2363. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2364. Q_ASSERT( false );
  2365. }
  2366. }
  2367. node = node.nextSibling();
  2368. }
  2369. } else if( tagName == "Colors" ) {
  2370. TQDomNode node = element.firstChild();
  2371. while( !node.isNull()) {
  2372. TQDomElement element = node.toElement();
  2373. if( !element.isNull() ) { // was really an elemente
  2374. TQString tagName = element.tagName();
  2375. if( tagName == "Event" ) {
  2376. TQColor startColor, middleColor, endColor;
  2377. TQDomNode node = element.firstChild();
  2378. while( !node.isNull() ) {
  2379. TQDomElement element = node.toElement();
  2380. if( !element.isNull() ) { // was really an elemente
  2381. TQString tagName = element.tagName();
  2382. if( tagName == "Start" ) {
  2383. TQColor value;
  2384. if( KDGanttXML::readColorNode( element, value ) )
  2385. startColor = value;
  2386. } else if( tagName == "Middle" ) {
  2387. TQColor value;
  2388. if( KDGanttXML::readColorNode( element, value ) )
  2389. middleColor = value;
  2390. } else if( tagName == "End" ) {
  2391. TQColor value;
  2392. if( KDGanttXML::readColorNode( element, value ) )
  2393. endColor = value;
  2394. } else {
  2395. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2396. Q_ASSERT( false );
  2397. }
  2398. }
  2399. node = node.nextSibling();
  2400. }
  2401. setColors( KDGanttViewItem::Event, startColor,
  2402. middleColor, endColor, false );
  2403. } else if( tagName == "Task" ) {
  2404. TQColor startColor, middleColor, endColor;
  2405. TQDomNode node = element.firstChild();
  2406. while( !node.isNull() ) {
  2407. TQDomElement element = node.toElement();
  2408. if( !element.isNull() ) { // was really an elemente
  2409. TQString tagName = element.tagName();
  2410. if( tagName == "Start" ) {
  2411. TQColor value;
  2412. if( KDGanttXML::readColorNode( element, value ) )
  2413. startColor = value;
  2414. } else if( tagName == "Middle" ) {
  2415. TQColor value;
  2416. if( KDGanttXML::readColorNode( element, value ) )
  2417. middleColor = value;
  2418. } else if( tagName == "End" ) {
  2419. TQColor value;
  2420. if( KDGanttXML::readColorNode( element, value ) )
  2421. endColor = value;
  2422. } else {
  2423. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2424. Q_ASSERT( false );
  2425. }
  2426. }
  2427. node = node.nextSibling();
  2428. }
  2429. setColors( KDGanttViewItem::Task, startColor,
  2430. middleColor, endColor, false );
  2431. } else if( tagName == "Summary" ) {
  2432. TQColor startColor, middleColor, endColor;
  2433. TQDomNode node = element.firstChild();
  2434. while( !node.isNull() ) {
  2435. TQDomElement element = node.toElement();
  2436. if( !element.isNull() ) { // was really an elemente
  2437. TQString tagName = element.tagName();
  2438. if( tagName == "Start" ) {
  2439. TQColor value;
  2440. if( KDGanttXML::readColorNode( element, value ) )
  2441. startColor = value;
  2442. } else if( tagName == "Middle" ) {
  2443. TQColor value;
  2444. if( KDGanttXML::readColorNode( element, value ) )
  2445. middleColor = value;
  2446. } else if( tagName == "End" ) {
  2447. TQColor value;
  2448. if( KDGanttXML::readColorNode( element, value ) )
  2449. endColor = value;
  2450. } else {
  2451. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2452. Q_ASSERT( false );
  2453. }
  2454. }
  2455. node = node.nextSibling();
  2456. }
  2457. setColors( KDGanttViewItem::Summary, startColor,
  2458. middleColor, endColor , false);
  2459. } else {
  2460. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2461. Q_ASSERT( false );
  2462. }
  2463. }
  2464. node = node.nextSibling();
  2465. }
  2466. } else if( tagName == "DefaultColors" ) {
  2467. TQDomNode node = element.firstChild();
  2468. while( !node.isNull() ) {
  2469. TQDomElement element = node.toElement();
  2470. if( !element.isNull() ) { // was really an element
  2471. TQString tagName = element.tagName();
  2472. if( tagName == "Event" ) {
  2473. TQColor value;
  2474. if( KDGanttXML::readColorNode( element, value ) )
  2475. setDefaultColor( KDGanttViewItem::Event,
  2476. value, false );
  2477. } else if( tagName == "Task" ) {
  2478. TQColor value;
  2479. if( KDGanttXML::readColorNode( element, value ) )
  2480. setDefaultColor( KDGanttViewItem::Task,
  2481. value, false );
  2482. } else if( tagName == "Summary" ) {
  2483. TQColor value;
  2484. if( KDGanttXML::readColorNode( element, value ) )
  2485. setDefaultColor( KDGanttViewItem::Summary,
  2486. value , false);
  2487. } else {
  2488. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2489. Q_ASSERT( false );
  2490. }
  2491. }
  2492. node = node.nextSibling();
  2493. }
  2494. } else if( tagName == "HighlightColors" ) {
  2495. TQDomNode node = element.firstChild();
  2496. while( !node.isNull() ) {
  2497. TQDomElement element = node.toElement();
  2498. if( !element.isNull() ) { // was really an elemente
  2499. TQString tagName = element.tagName();
  2500. if( tagName == "Event" ) {
  2501. TQColor startColor, middleColor, endColor;
  2502. TQDomNode node = element.firstChild();
  2503. while( !node.isNull() ) {
  2504. TQDomElement element = node.toElement();
  2505. if( !element.isNull() ) { // was really an elemente
  2506. TQString tagName = element.tagName();
  2507. if( tagName == "Start" ) {
  2508. TQColor value;
  2509. if( KDGanttXML::readColorNode( element, value ) )
  2510. startColor = value;
  2511. } else if( tagName == "Middle" ) {
  2512. TQColor value;
  2513. if( KDGanttXML::readColorNode( element, value ) )
  2514. middleColor = value;
  2515. } else if( tagName == "End" ) {
  2516. TQColor value;
  2517. if( KDGanttXML::readColorNode( element, value ) )
  2518. endColor = value;
  2519. } else {
  2520. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2521. Q_ASSERT( false );
  2522. }
  2523. }
  2524. node = node.nextSibling();
  2525. }
  2526. setHighlightColors( KDGanttViewItem::Event,
  2527. startColor,
  2528. middleColor, endColor, false );
  2529. } else if( tagName == "Task" ) {
  2530. TQColor startColor, middleColor, endColor;
  2531. TQDomNode node = element.firstChild();
  2532. while( !node.isNull() ) {
  2533. TQDomElement element = node.toElement();
  2534. if( !element.isNull() ) { // was really an elemente
  2535. TQString tagName = element.tagName();
  2536. if( tagName == "Start" ) {
  2537. TQColor value;
  2538. if( KDGanttXML::readColorNode( element, value ) )
  2539. startColor = value;
  2540. } else if( tagName == "Middle" ) {
  2541. TQColor value;
  2542. if( KDGanttXML::readColorNode( element, value ) )
  2543. middleColor = value;
  2544. } else if( tagName == "End" ) {
  2545. TQColor value;
  2546. if( KDGanttXML::readColorNode( element, value ) )
  2547. endColor = value;
  2548. } else {
  2549. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2550. Q_ASSERT( false );
  2551. }
  2552. }
  2553. node = node.nextSibling();
  2554. }
  2555. setHighlightColors( KDGanttViewItem::Task,
  2556. startColor,
  2557. middleColor, endColor , false);
  2558. } else if( tagName == "Summary" ) {
  2559. TQColor startColor, middleColor, endColor;
  2560. TQDomNode node = element.firstChild();
  2561. while( !node.isNull() ) {
  2562. TQDomElement element = node.toElement();
  2563. if( !element.isNull() ) { // was really an elemente
  2564. TQString tagName = element.tagName();
  2565. if( tagName == "Start" ) {
  2566. TQColor value;
  2567. if( KDGanttXML::readColorNode( element, value ) )
  2568. startColor = value;
  2569. } else if( tagName == "Middle" ) {
  2570. TQColor value;
  2571. if( KDGanttXML::readColorNode( element, value ) )
  2572. middleColor = value;
  2573. } else if( tagName == "End" ) {
  2574. TQColor value;
  2575. if( KDGanttXML::readColorNode( element, value ) )
  2576. endColor = value;
  2577. } else {
  2578. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2579. Q_ASSERT( false );
  2580. }
  2581. }
  2582. node = node.nextSibling();
  2583. }
  2584. setHighlightColors( KDGanttViewItem::Summary,
  2585. startColor,
  2586. middleColor, endColor, false );
  2587. } else {
  2588. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2589. Q_ASSERT( false );
  2590. }
  2591. }
  2592. node = node.nextSibling();
  2593. }
  2594. } else if( tagName == "DefaultHighlightColors" ) {
  2595. TQDomNode node = element.firstChild();
  2596. while( !node.isNull() ) {
  2597. TQDomElement element = node.toElement();
  2598. if( !element.isNull() ) { // was really an element
  2599. TQString tagName = element.tagName();
  2600. if( tagName == "Event" ) {
  2601. TQColor value;
  2602. if( KDGanttXML::readColorNode( element, value ) )
  2603. setDefaultHighlightColor( KDGanttViewItem::Event,
  2604. value , false);
  2605. } else if( tagName == "Task" ) {
  2606. TQColor value;
  2607. if( KDGanttXML::readColorNode( element, value ) )
  2608. setDefaultHighlightColor( KDGanttViewItem::Task,
  2609. value, false );
  2610. } else if( tagName == "Summary" ) {
  2611. TQColor value;
  2612. if( KDGanttXML::readColorNode( element, value ) )
  2613. setDefaultHighlightColor( KDGanttViewItem::Summary,
  2614. value, false );
  2615. } else {
  2616. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2617. Q_ASSERT( false );
  2618. }
  2619. }
  2620. node = node.nextSibling();
  2621. }
  2622. } else if( tagName == "Items" ) {
  2623. TQDomNode node = element.firstChild();
  2624. KDGanttViewItem* previous = 0;
  2625. while( !node.isNull() ) {
  2626. TQDomElement element = node.toElement();
  2627. if( !element.isNull() ) { // was really an element
  2628. TQString tagName = element.tagName();
  2629. if( tagName == "Item" ) {
  2630. KDGanttViewItem* newItem;
  2631. if( previous )
  2632. newItem =
  2633. KDGanttViewItem::createFromDomElement( this,
  2634. previous,
  2635. element );
  2636. else
  2637. newItem =
  2638. KDGanttViewItem::createFromDomElement( this,
  2639. element );
  2640. previous = newItem;
  2641. } else {
  2642. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2643. Q_ASSERT( false );
  2644. }
  2645. }
  2646. node = node.nextSibling();
  2647. }
  2648. } else if( tagName == "TaskLinks" ) {
  2649. TQDomNode node = element.firstChild();
  2650. while( !node.isNull() ) {
  2651. TQDomElement element = node.toElement();
  2652. if( !element.isNull() ) { // was really an element
  2653. TQString tagName = element.tagName();
  2654. if( tagName == "TaskLink" )
  2655. KDGanttViewTaskLink::createFromDomElement( element );
  2656. else {
  2657. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2658. Q_ASSERT( false );
  2659. }
  2660. }
  2661. node = node.nextSibling();
  2662. }
  2663. } else if( tagName == "TaskLinkGroups" ) {
  2664. TQDomNode node = element.firstChild();
  2665. while( !node.isNull() ) {
  2666. TQDomElement element = node.toElement();
  2667. if( !element.isNull() ) { // was really an element
  2668. TQString tagName = element.tagName();
  2669. if( tagName == "TaskLink" )
  2670. KDGanttViewTaskLinkGroup::createFromDomElement( element );
  2671. } else {
  2672. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2673. Q_ASSERT( false );
  2674. }
  2675. node = node.nextSibling();
  2676. }
  2677. } else if( tagName == "ColumnBackgroundColors" ) {
  2678. TQDomNode node = element.firstChild();
  2679. while( !node.isNull() ) {
  2680. TQDomElement element = node.toElement();
  2681. if( !element.isNull() ) { // was really an element
  2682. TQString tagName = element.tagName();
  2683. if( tagName == "ColumnBackgroundColor" ) {
  2684. TQDomNode node = element.firstChild();
  2685. TQDateTime dateTime;
  2686. TQColor color;
  2687. while( !node.isNull() ) {
  2688. TQDomElement element = node.toElement();
  2689. if( !element.isNull() ) { // was
  2690. // really an
  2691. // element
  2692. TQString tagName = element.tagName();
  2693. if( tagName == "DateTime" ) {
  2694. TQDateTime value;
  2695. if( KDGanttXML::readDateTimeNode( element, value ) )
  2696. dateTime = value;
  2697. } else if( tagName == "Color" ) {
  2698. TQColor value;
  2699. if( KDGanttXML::readColorNode( element, value ) )
  2700. color = value;
  2701. } else {
  2702. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2703. Q_ASSERT( false );
  2704. }
  2705. }
  2706. node = node.nextSibling();
  2707. }
  2708. setColumnBackgroundColor( dateTime, color );
  2709. } else {
  2710. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2711. Q_ASSERT( false );
  2712. }
  2713. }
  2714. node = node.nextSibling();
  2715. }
  2716. } else if( tagName == "LegendItems" ) {
  2717. clearLegend();
  2718. TQDomNode node = element.firstChild();
  2719. while( !node.isNull() ) {
  2720. TQDomElement element = node.toElement();
  2721. if( !element.isNull() ) { // was really an element
  2722. TQString tagName = element.tagName();
  2723. if( tagName == "LegendItem" ) {
  2724. KDGanttViewItem::Shape tempLegendShape;
  2725. tempLegendShape = KDGanttViewItem::TriangleDown;
  2726. TQColor tempLegendColor;
  2727. TQString tempLegendString;
  2728. bool ok = true;
  2729. TQDomNode node = element.firstChild();
  2730. while( !node.isNull() ) {
  2731. TQDomElement element = node.toElement();
  2732. if( !element.isNull() ) { // was really an element
  2733. TQString tagName = element.tagName();
  2734. if( tagName == "Shape" ) {
  2735. TQString value;
  2736. if( KDGanttXML::readStringNode( element, value ) )
  2737. tempLegendShape = KDGanttViewItem::stringToShape( value );
  2738. else
  2739. ok = false;
  2740. } else if( tagName == "Color" ) {
  2741. TQColor value;
  2742. if( KDGanttXML::readColorNode( element, value ) )
  2743. tempLegendColor = value;
  2744. else
  2745. ok = false;
  2746. } else if( tagName == "Text" ) {
  2747. TQString value;
  2748. if( KDGanttXML::readStringNode( element, value ) )
  2749. tempLegendString = value;
  2750. else
  2751. ok = false;
  2752. } else {
  2753. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2754. Q_ASSERT( false );
  2755. }
  2756. }
  2757. node = node.nextSibling();
  2758. }
  2759. if( ok ) {
  2760. addLegendItem( tempLegendShape,
  2761. tempLegendColor,
  2762. tempLegendString );
  2763. tqDebug( "Adding legend item %s", tempLegendString.latin1() );
  2764. }
  2765. } else {
  2766. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2767. Q_ASSERT( false );
  2768. }
  2769. }
  2770. node = node.nextSibling();
  2771. }
  2772. } else {
  2773. tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
  2774. Q_ASSERT( false );
  2775. }
  2776. }
  2777. node = node.nextSibling();
  2778. } // while
  2779. return true; /* FIXME: Do real error-reporting. The ASSERT's should be "return false" stmnts */
  2780. } // method
  2781. /**
  2782. Saves the parameters of the view parameters to an XML document.
  2783. \param withPI pass true to store processing instructions, false to
  2784. leave them out
  2785. \return the XML document that represents the parameters
  2786. \sa loadXML
  2787. */
  2788. TQDomDocument KDGanttView::saveXML( bool withPI ) const
  2789. {
  2790. // Create an inital DOM document
  2791. TQString docstart = "<GanttView/>";
  2792. TQDomDocument doc( "GanttView" );
  2793. doc.setContent( docstart );
  2794. if( withPI ) {
  2795. TQDomProcessingInstruction pin = doc.createProcessingInstruction( "kdgantt", "version=\"1.0\" encoding=\"UTF-8\"" ) ;
  2796. doc.appendChild ( pin );
  2797. }
  2798. TQDomElement docRoot = doc.documentElement();
  2799. docRoot.setAttribute( "xmlns", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
  2800. docRoot.setAttribute( "xmlns:xsi", "http://www.w3.org/2000/10/XMLSchema-instance" );
  2801. docRoot.setAttribute( "xsi:schemaLocation", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
  2802. // the ShowLegend element
  2803. KDGanttXML::createBoolNode( doc, docRoot, "ShowLegend", showLegend() );
  2804. // the ShowLegendButton element
  2805. KDGanttXML::createBoolNode( doc, docRoot, "ShowLegendButton",
  2806. showLegendButton() );
  2807. // the LegendIsDockWindow element
  2808. KDGanttXML::createBoolNode( doc, docRoot, "LegendIsDockWindow",
  2809. legendIsDoctwindow() );
  2810. // the ShowListView element
  2811. KDGanttXML::createBoolNode( doc, docRoot, "ShowListView", showListView() );
  2812. // the ShowHeader element
  2813. KDGanttXML::createBoolNode( doc, docRoot, "ShowHeader", headerVisible() );
  2814. // the ShowTaskLinks element
  2815. KDGanttXML::createBoolNode( doc, docRoot, "ShowTaskLinks", showTaskLinks() );
  2816. // the EditorEnabled element
  2817. KDGanttXML::createBoolNode( doc, docRoot, "EditorEnabled", editorEnabled() );
  2818. // the global font element
  2819. KDGanttXML::createFontNode( doc, docRoot, "GlobalFont", font() );
  2820. // the DisplayEmptyTasksAsLine element
  2821. KDGanttXML::createBoolNode( doc, docRoot, "DisplayEmptyTasksAsLine",
  2822. displayEmptyTasksAsLine() );
  2823. // the HorizonStart element
  2824. KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonStart", horizonStart() );
  2825. // the HorizonEnd element
  2826. KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonEnd", horizonEnd() );
  2827. // the Scale, MinimumScale, MaximumScale elements
  2828. KDGanttXML::createStringNode( doc, docRoot, "Scale", scaleToString( scale() ) );
  2829. KDGanttXML::createStringNode( doc, docRoot, "MinimumScale",
  2830. scaleToString( minimumScale() ) );
  2831. KDGanttXML::createStringNode( doc, docRoot, "MaximumScale",
  2832. scaleToString( maximumScale() ) );
  2833. // the YearFormat element
  2834. KDGanttXML::createStringNode( doc, docRoot, "YearFormat",
  2835. yearFormatToString( yearFormat() ) );
  2836. // the HourFormat element
  2837. KDGanttXML::createStringNode( doc, docRoot, "HourFormat",
  2838. hourFormatToString( hourFormat() ) );
  2839. // the ShowMinorTicks element
  2840. KDGanttXML::createBoolNode( doc, docRoot, "ShowMinorTicks", showMinorTicks() );
  2841. // the ShowMajorTicks element
  2842. KDGanttXML::createBoolNode( doc, docRoot, "ShowMajorTicks", showMajorTicks() );
  2843. // the Editable element
  2844. KDGanttXML::createBoolNode( doc, docRoot, "Editable", editable() );
  2845. // the TextColor element
  2846. KDGanttXML::createColorNode( doc, docRoot, "TextColor", textColor() );
  2847. // the MajorScaleCount element
  2848. KDGanttXML::createIntNode( doc, docRoot, "MajorScaleCount", majorScaleCount() );
  2849. // the MinorScaleCount element
  2850. KDGanttXML::createIntNode( doc, docRoot, "MinorScaleCount", minorScaleCount() );
  2851. // the AutoScaleMinorTickCount element
  2852. KDGanttXML::createIntNode( doc, docRoot, "AutoScaleMinorTickCount",
  2853. autoScaleMinorTickCount() );
  2854. // the MinimumColumnWidth element
  2855. KDGanttXML::createIntNode( doc, docRoot, "MinimumColumnWidth",
  2856. minimumColumnWidth() );
  2857. // the GanttMaximumWidth element
  2858. KDGanttXML::createIntNode( doc, docRoot, "GanttMaximumWidth",
  2859. ganttMaximumWidth() );
  2860. // the NoInformationBrush element
  2861. KDGanttXML::createBrushNode( doc, docRoot, "NoInformationBrush",
  2862. noInformationBrush() );
  2863. // the GanttViewBackgroundColor element
  2864. KDGanttXML::createColorNode( doc, docRoot, "GanttViewBackgroundColor",
  2865. gvBackgroundColor() );
  2866. // the ListViewBackgroundColor element
  2867. KDGanttXML::createColorNode( doc, docRoot, "ListViewBackgroundColor",
  2868. lvBackgroundColor() );
  2869. // the TimeHeaderBackgroundColor element
  2870. KDGanttXML::createColorNode( doc, docRoot, "TimeHeaderBackgroundColor",
  2871. timeHeaderBackgroundColor() );
  2872. // the LegendHeaderBackgroundColor element
  2873. KDGanttXML::createColorNode( doc, docRoot, "LegendHeaderBackgroundColor",
  2874. legendHeaderBackgroundColor() );
  2875. // the WeekendBackgroundColor element
  2876. KDGanttXML::createColorNode( doc, docRoot, "WeekendBackgroundColor",
  2877. weekendBackgroundColor() );
  2878. // the WeekdayBackgroundColor elements
  2879. for( int weekday = 1; weekday <= 7; weekday++ ) {
  2880. TQColor color = weekdayBackgroundColor( weekday );
  2881. if( color.isValid() ) {
  2882. TQDomElement weekendBackgroundColorElement = doc.createElement( "WeekdayBackgroundColor" );
  2883. docRoot.appendChild( weekendBackgroundColorElement );
  2884. KDGanttXML::createIntNode( doc, weekendBackgroundColorElement,
  2885. "Day", weekday );
  2886. KDGanttXML::createColorNode( doc, weekendBackgroundColorElement,
  2887. "Color", color );
  2888. }
  2889. }
  2890. // the WeekendDays element
  2891. TQDomElement weekendDaysElement = doc.createElement( "WeekendDays" );
  2892. docRoot.appendChild( weekendDaysElement );
  2893. int weekendStart, weekendEnd;
  2894. weekendDays( weekendStart, weekendEnd );
  2895. weekendDaysElement.setAttribute( "Start", weekendStart );
  2896. weekendDaysElement.setAttribute( "End", weekendStart );
  2897. // the ZoomFactor element
  2898. KDGanttXML::createDoubleNode( doc, docRoot, "ZoomFactor",
  2899. zoomFactor() );
  2900. // the ShowHeaderPopupMenu element
  2901. KDGanttXML::createBoolNode( doc, docRoot, "ShowHeaderPopupMenu",
  2902. showHeaderPopupMenu() );
  2903. // the ShowTimeTablePopupMenu element
  2904. KDGanttXML::createBoolNode( doc, docRoot, "ShowTimeTablePopupMenu",
  2905. showTimeTablePopupMenu() );
  2906. // the Shapes element
  2907. TQDomElement shapesElement = doc.createElement( "Shapes" );
  2908. docRoot.appendChild( shapesElement );
  2909. TQDomElement shapesEventElement = doc.createElement( "Event" );
  2910. shapesElement.appendChild( shapesEventElement );
  2911. KDGanttViewItem::Shape start, middle, end;
  2912. if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
  2913. KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
  2914. KDGanttViewItem::shapeToString( start ) );
  2915. KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
  2916. KDGanttViewItem::shapeToString( middle ) );
  2917. KDGanttXML::createStringNode( doc, shapesEventElement, "End",
  2918. KDGanttViewItem::shapeToString( end ) );
  2919. } else {
  2920. KDGanttXML::createStringNode( doc, shapesEventElement, "Start",
  2921. "Undefined" );
  2922. KDGanttXML::createStringNode( doc, shapesEventElement, "Middle",
  2923. "Undefined" );
  2924. KDGanttXML::createStringNode( doc, shapesEventElement, "End",
  2925. "Undefined" );
  2926. }
  2927. TQDomElement shapesTaskElement = doc.createElement( "Task" );
  2928. shapesElement.appendChild( shapesTaskElement );
  2929. if( shapes( KDGanttViewItem::Task, start, middle, end ) ) {
  2930. KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
  2931. KDGanttViewItem::shapeToString( start ) );
  2932. KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
  2933. KDGanttViewItem::shapeToString( middle ) );
  2934. KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
  2935. KDGanttViewItem::shapeToString( end ) );
  2936. } else {
  2937. KDGanttXML::createStringNode( doc, shapesTaskElement, "Start",
  2938. "Undefined" );
  2939. KDGanttXML::createStringNode( doc, shapesTaskElement, "Middle",
  2940. "Undefined" );
  2941. KDGanttXML::createStringNode( doc, shapesTaskElement, "End",
  2942. "Undefined" );
  2943. }
  2944. TQDomElement shapesSummaryElement = doc.createElement( "Summary" );
  2945. shapesElement.appendChild( shapesSummaryElement );
  2946. if( shapes( KDGanttViewItem::Event, start, middle, end ) ) {
  2947. KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
  2948. KDGanttViewItem::shapeToString( start ) );
  2949. KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
  2950. KDGanttViewItem::shapeToString( middle ) );
  2951. KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
  2952. KDGanttViewItem::shapeToString( end ) );
  2953. } else {
  2954. KDGanttXML::createStringNode( doc, shapesSummaryElement, "Start",
  2955. "Undefined" );
  2956. KDGanttXML::createStringNode( doc, shapesSummaryElement, "Middle",
  2957. "Undefined" );
  2958. KDGanttXML::createStringNode( doc, shapesSummaryElement, "End",
  2959. "Undefined" );
  2960. }
  2961. // the Colors element
  2962. TQDomElement colorsElement = doc.createElement( "Colors" );
  2963. docRoot.appendChild( colorsElement );
  2964. TQDomElement colorsEventElement = doc.createElement( "Event" );
  2965. colorsElement.appendChild( colorsEventElement );
  2966. TQColor startColor, middleColor, endColor;
  2967. colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
  2968. KDGanttXML::createColorNode( doc, colorsEventElement, "Start", startColor );
  2969. KDGanttXML::createColorNode( doc, colorsEventElement, "Middle", middleColor );
  2970. KDGanttXML::createColorNode( doc, colorsEventElement, "End", endColor );
  2971. TQDomElement colorsTaskElement = doc.createElement( "Task" );
  2972. colorsElement.appendChild( colorsTaskElement );
  2973. colors( KDGanttViewItem::Task, startColor, middleColor, endColor );
  2974. KDGanttXML::createColorNode( doc, colorsTaskElement, "Start", startColor );
  2975. KDGanttXML::createColorNode( doc, colorsTaskElement, "Middle", middleColor );
  2976. KDGanttXML::createColorNode( doc, colorsTaskElement, "End", endColor );
  2977. TQDomElement colorsSummaryElement = doc.createElement( "Summary" );
  2978. colorsElement.appendChild( colorsSummaryElement );
  2979. colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
  2980. KDGanttXML::createColorNode( doc, colorsSummaryElement, "Start", startColor );
  2981. KDGanttXML::createColorNode( doc, colorsSummaryElement, "Middle", middleColor );
  2982. KDGanttXML::createColorNode( doc, colorsSummaryElement, "End", endColor );
  2983. // the DefaultColor element
  2984. TQDomElement defaultColorsElement = doc.createElement( "DefaultColors" );
  2985. docRoot.appendChild( defaultColorsElement );
  2986. KDGanttXML::createColorNode( doc, defaultColorsElement, "Event",
  2987. defaultColor( KDGanttViewItem::Event ) );
  2988. KDGanttXML::createColorNode( doc, defaultColorsElement, "Task",
  2989. defaultColor( KDGanttViewItem::Task ) );
  2990. KDGanttXML::createColorNode( doc, defaultColorsElement, "Summary",
  2991. defaultColor( KDGanttViewItem::Summary ) );
  2992. // the HighlightColors element
  2993. TQDomElement highlightColorsElement = doc.createElement( "HighlightColors" );
  2994. docRoot.appendChild( highlightColorsElement );
  2995. TQDomElement highlightColorsEventElement = doc.createElement( "Event" );
  2996. highlightColorsElement.appendChild( highlightColorsEventElement );
  2997. highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
  2998. KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Start", startColor );
  2999. KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Middle", middleColor );
  3000. KDGanttXML::createColorNode( doc, highlightColorsEventElement, "End", endColor );
  3001. TQDomElement highlightColorsTaskElement = doc.createElement( "Task" );
  3002. highlightColorsElement.appendChild( highlightColorsTaskElement );
  3003. highlightColors( KDGanttViewItem::Task, startColor, middleColor, endColor );
  3004. KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Start", startColor );
  3005. KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Middle", middleColor );
  3006. KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "End", endColor );
  3007. TQDomElement highlightColorsSummaryElement = doc.createElement( "Summary" );
  3008. highlightColorsElement.appendChild( highlightColorsSummaryElement );
  3009. highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
  3010. KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
  3011. KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
  3012. KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );
  3013. /*
  3014. if( highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor ) ) {
  3015. KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
  3016. KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
  3017. KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );
  3018. } else {
  3019. KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", TQColor() );
  3020. KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", TQColor() );
  3021. KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", TQColor() );
  3022. }
  3023. */
  3024. // the DefaultHighlightColor element
  3025. TQDomElement defaultHighlightColorsElement = doc.createElement( "DefaultHighlightColors" );
  3026. docRoot.appendChild( defaultHighlightColorsElement );
  3027. KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Event",
  3028. defaultHighlightColor( KDGanttViewItem::Event ) );
  3029. KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Task",
  3030. defaultHighlightColor( KDGanttViewItem::Task ) );
  3031. KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Summary",
  3032. defaultHighlightColor( KDGanttViewItem::Summary ) );
  3033. // the Items element
  3034. TQDomElement itemsElement = doc.createElement( "Items" );
  3035. docRoot.appendChild( itemsElement );
  3036. KDGanttViewItem* currentItem = firstChild();
  3037. while( currentItem ) {
  3038. currentItem->createNode( doc, itemsElement );
  3039. currentItem = currentItem->nextSibling();
  3040. }
  3041. // the TaskLinks element
  3042. TQDomElement taskLinksElement = doc.createElement( "TaskLinks" );
  3043. docRoot.appendChild( taskLinksElement );
  3044. TQPtrList<KDGanttViewTaskLink> taskLinkList = taskLinks();
  3045. KDGanttViewTaskLink* currentTL = 0;
  3046. for( currentTL = taskLinkList.first(); currentTL;
  3047. currentTL = taskLinkList.next() )
  3048. currentTL->createNode( doc, taskLinksElement );
  3049. // the TaskLinkGroups element
  3050. TQDomElement taskLinkGroupsElement = doc.createElement( "TaskLinkGroups" );
  3051. docRoot.appendChild( taskLinkGroupsElement );
  3052. TQPtrList<KDGanttViewTaskLinkGroup> taskLinkGroupList = taskLinkGroups();
  3053. KDGanttViewTaskLinkGroup* currentTLG = 0;
  3054. for( currentTLG = taskLinkGroupList.first(); currentTLG;
  3055. currentTLG = taskLinkGroupList.next() )
  3056. currentTLG->createNode( doc, taskLinkGroupsElement );
  3057. // the ColumnBackgroundColors element
  3058. TQDomElement columnBackgroundColorsElement =
  3059. doc.createElement( "ColumnBackgroundColors" );
  3060. docRoot.appendChild( columnBackgroundColorsElement );
  3061. KDTimeHeaderWidget::ColumnColorList ccList =
  3062. myTimeHeader->columnBackgroundColorList();
  3063. for( KDTimeHeaderWidget::ColumnColorList::iterator it = ccList.begin();
  3064. it != ccList.end(); ++it ) {
  3065. TQDomElement columnBackgroundColorElement =
  3066. doc.createElement( "ColumnBackgroundColor" );
  3067. columnBackgroundColorsElement.appendChild( columnBackgroundColorElement );
  3068. KDGanttXML::createDateTimeNode( doc, columnBackgroundColorElement,
  3069. "DateTime", (*it).datetime );
  3070. KDGanttXML::createColorNode( doc, columnBackgroundColorElement,
  3071. "Color", (*it).color );
  3072. }
  3073. // the LegendItems element
  3074. TQDomElement legendItemsElement =
  3075. doc.createElement( "LegendItems" );
  3076. docRoot.appendChild( legendItemsElement );
  3077. legendItem* current;
  3078. TQPtrListIterator<legendItem> lit( *myLegendItems );
  3079. while( ( current = lit.current() ) ) {
  3080. ++lit;
  3081. TQDomElement legendItemElement = doc.createElement( "LegendItem" );
  3082. legendItemsElement.appendChild( legendItemElement );
  3083. KDGanttXML::createStringNode( doc, legendItemElement, "Shape",
  3084. KDGanttViewItem::shapeToString( current->shape ) );
  3085. KDGanttXML::createColorNode( doc, legendItemElement, "Color",
  3086. current->color );
  3087. KDGanttXML::createStringNode( doc, legendItemElement, "Text",
  3088. current->text );
  3089. }
  3090. // the DragEnabled element
  3091. KDGanttXML::createBoolNode( doc, docRoot, "DragEnabled", isDragEnabled() );
  3092. // the DropEnabled element
  3093. KDGanttXML::createBoolNode( doc, docRoot, "DropEnabled", isDropEnabled() );
  3094. // the CalendarMode element
  3095. KDGanttXML::createBoolNode( doc, docRoot, "CalendarMode", calendarMode() );
  3096. return doc;
  3097. }
  3098. TQString KDGanttView::scaleToString( Scale scale )
  3099. {
  3100. switch( scale ) {
  3101. case Minute:
  3102. return "Minute";
  3103. case Hour:
  3104. return "Hour";
  3105. case Day:
  3106. return "Day";
  3107. case Week:
  3108. return "Week";
  3109. case Month:
  3110. return "Month";
  3111. case Auto:
  3112. return "Auto";
  3113. }
  3114. return "";
  3115. }
  3116. KDGanttView::Scale KDGanttView::stringToScale( const TQString& string )
  3117. {
  3118. if( string == "Minute" )
  3119. return Minute;
  3120. else if( string == "Hour" )
  3121. return Hour;
  3122. else if( string == "Day" )
  3123. return Day;
  3124. else if( string == "Week" )
  3125. return Week;
  3126. else if( string == "Month" )
  3127. return Month;
  3128. else if( string == "Auto" )
  3129. return Auto;
  3130. return Auto;
  3131. }
  3132. TQString KDGanttView::yearFormatToString( YearFormat format )
  3133. {
  3134. switch( format ) {
  3135. case FourDigit:
  3136. return "FourDigit";
  3137. case TwoDigit:
  3138. return "TwoDigit";
  3139. case TwoDigitApostrophe:
  3140. return "TwoDigitApostrophe";
  3141. case NoDate:
  3142. return "NoDate";
  3143. }
  3144. return "";
  3145. }
  3146. KDGanttView::YearFormat KDGanttView::stringToYearFormat( const TQString& string )
  3147. {
  3148. if( string == "FourDigit" )
  3149. return FourDigit;
  3150. else if( string == "TwoDigit" )
  3151. return TwoDigit;
  3152. else if( string == "TwoDigitApostrophe" )
  3153. return TwoDigitApostrophe;
  3154. else if( string == "NoDate" )
  3155. return NoDate;
  3156. else
  3157. return FourDigit;
  3158. }
  3159. TQString KDGanttView::hourFormatToString( HourFormat format )
  3160. {
  3161. switch( format ) {
  3162. case Hour_12:
  3163. return "Hour_12";
  3164. case Hour_24:
  3165. return "Hour_24";
  3166. case Hour_24_FourDigit:
  3167. return "Hour_24_FourDigit";
  3168. }
  3169. return "";
  3170. }
  3171. KDGanttView::HourFormat KDGanttView::stringToHourFormat( const TQString& string )
  3172. {
  3173. if( string == "Hour_12" )
  3174. return Hour_12;
  3175. else if( string == "Hour_24" )
  3176. return Hour_24;
  3177. else
  3178. return Hour_24;
  3179. }
  3180. void KDGanttView::addTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
  3181. {
  3182. if (myTaskLinkGroupList.isEmpty()) {
  3183. myTaskLinkGroupList.append(group);
  3184. return;
  3185. }
  3186. if (myTaskLinkGroupList.find(group) == -1)
  3187. myTaskLinkGroupList.append(group);
  3188. }
  3189. void KDGanttView::removeTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
  3190. {
  3191. myTaskLinkGroupList.remove(group);
  3192. }
  3193. /*!
  3194. This slot is called when a new item has been added to the Gantt
  3195. view. It will show the item attribute dialog in case the item is
  3196. editable. \a item is a pointer to the item that has been created.
  3197. */
  3198. void KDGanttView::editItem( KDGanttViewItem* item)
  3199. {
  3200. if ( ! item )
  3201. return;
  3202. if ( editorEnabled() ) {
  3203. if ( item->editable() ) {
  3204. myItemAttributeDialog->reset( item );
  3205. myItemAttributeDialog->show();
  3206. }
  3207. }
  3208. }
  3209. /*!
  3210. This method returns the pixmap used for a certain shape, in the
  3211. selected color and size.
  3212. \param shape the shape to generate
  3213. \param shapeColor the foreground color of the shape
  3214. \param backgroundColor the background color of the shape
  3215. \param itemSize the size of the shape
  3216. \return the generated shape pixmap
  3217. */
  3218. TQPixmap KDGanttView::getPixmap( KDGanttViewItem::Shape shape,
  3219. const TQColor& shapeColor,
  3220. const TQColor& backgroundColor, int itemSize)
  3221. {
  3222. // 10 is a good value as size
  3223. int size = itemSize+2;
  3224. int hei = ( itemSize/3 ) / 2;
  3225. TQPixmap p = TQPixmap( size+4, size+4 );
  3226. p.fill( backgroundColor );
  3227. TQPainter paint (&p);
  3228. TQBrush b = TQBrush ( TQt::SolidPattern );
  3229. b.setColor( shapeColor );
  3230. paint.setBrush( b );
  3231. TQPen pen( TQt::black, 1 ) ;
  3232. paint.setPen( pen );
  3233. switch (shape) {
  3234. case KDGanttViewItem::TriangleDown:{
  3235. TQPointArray arr = TQPointArray(3);
  3236. arr.setPoint(0,-size/2,-hei);
  3237. arr.setPoint(1,size/2,-hei);
  3238. arr.setPoint(2,0,((size/2)-hei));
  3239. arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
  3240. paint.drawPolygon( arr );
  3241. break;
  3242. }
  3243. case KDGanttViewItem::TriangleUp :{
  3244. TQPointArray arr = TQPointArray(3);
  3245. arr.setPoint(0,-size/2,hei);
  3246. arr.setPoint(1,size/2,hei);
  3247. arr.setPoint(2,0,(-size/2)+hei);
  3248. arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
  3249. paint.drawPolygon( arr );
  3250. break;
  3251. }
  3252. case KDGanttViewItem::Diamond :{
  3253. TQPointArray arr = TQPointArray(4);
  3254. arr.setPoint(0,0,-size/2);
  3255. arr.setPoint(1,size/2,0);
  3256. arr.setPoint(2,0,size/2);
  3257. arr.setPoint(3,-size/2,0);
  3258. arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
  3259. paint.drawPolygon( arr );
  3260. break;
  3261. }
  3262. case KDGanttViewItem::Square :{
  3263. TQPointArray arr = TQPointArray(4);
  3264. arr.setPoint(0,-size/2,-size/2);
  3265. arr.setPoint(1,size/2,-size/2);
  3266. arr.setPoint(2,size/2,size/2);
  3267. arr.setPoint(3,-size/2,size/2);
  3268. arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
  3269. paint.drawPolygon( arr );
  3270. break;
  3271. }
  3272. case KDGanttViewItem::Circle :{
  3273. paint.drawEllipse( 2, 2, size, size);
  3274. break;
  3275. }
  3276. }
  3277. paint.end();
  3278. return p;
  3279. }
  3280. int KDGanttView::getIndex( KDGanttViewItem::Type type) const
  3281. {
  3282. int index = -1;
  3283. switch (type) {
  3284. case (KDGanttViewItem::Event):
  3285. index = 0;
  3286. break;
  3287. case (KDGanttViewItem::Task):
  3288. index = 1;
  3289. break;
  3290. case (KDGanttViewItem::Summary):
  3291. index = 2;
  3292. break;
  3293. }
  3294. return index;
  3295. }
  3296. void KDGanttView::initDefaults()
  3297. {
  3298. int i;
  3299. // We have 3 item types. Set all undefined to true.
  3300. for (i = 0;i<3;++i) {
  3301. undefinedShape[i] = true;
  3302. undefinedColor[i] = true;
  3303. undefinedColorHL[i] = true;
  3304. }
  3305. // setting the default colors
  3306. myDefaultColor [ getIndex( KDGanttViewItem::Event ) ] = TQt::blue; //event
  3307. myDefaultColorHL [ getIndex( KDGanttViewItem::Event ) ] = TQt::red;
  3308. myDefaultColor [ getIndex( KDGanttViewItem::Task ) ] = TQt::green;//task
  3309. myDefaultColorHL [ getIndex( KDGanttViewItem::Task ) ] = TQt::red;
  3310. myDefaultColor [ getIndex( KDGanttViewItem::Summary ) ] = TQt::cyan;//summary
  3311. myDefaultColorHL [ getIndex( KDGanttViewItem::Summary ) ] = TQt::red;
  3312. // setting the default shape types
  3313. // currently, we take for each item for all three shapes (start, middle, end) the same default shape
  3314. for (i = 0;i<3;++i) {
  3315. myDefaultShape [3*getIndex( KDGanttViewItem::Event )+ i] = KDGanttViewItem::Diamond; //event
  3316. myDefaultShape [3*getIndex( KDGanttViewItem::Task ) +i] = KDGanttViewItem::Square; //task
  3317. myDefaultShape [3*getIndex( KDGanttViewItem::Summary ) +i] = KDGanttViewItem::TriangleDown; //summary
  3318. }
  3319. }
  3320. /*!
  3321. Calls to this method are passed through to the underlying \a TQListView.
  3322. */
  3323. int KDGanttView::addColumn( const TQString& label, int width )
  3324. {
  3325. return myListView->addColumn( label, width );
  3326. }
  3327. /*!
  3328. Calls to this method are passed through to the underlying \a TQListView.
  3329. */
  3330. int KDGanttView::addColumn( const TQIconSet& iconset, const TQString& label,
  3331. int width )
  3332. {
  3333. return myListView->addColumn( iconset, label, width );
  3334. }
  3335. /*!
  3336. Calls to this method are passed through to the underlying \a TQListView.
  3337. */
  3338. void KDGanttView::removeColumn( int index )
  3339. {
  3340. myListView->removeColumn( index );
  3341. }
  3342. /*!
  3343. Calls to this method are passed through to the underlying \a TQListView.
  3344. */
  3345. KDGanttViewItem* KDGanttView::selectedItem() const
  3346. {
  3347. return static_cast<KDGanttViewItem*>( myListView->selectedItem() );
  3348. }
  3349. /*!
  3350. Calls to this method are passed through to the underlying \a TQListView.
  3351. */
  3352. void KDGanttView::setSelected( KDGanttViewItem* item, bool selected )
  3353. {
  3354. myListView->setSelected( item, selected );
  3355. }
  3356. /*!
  3357. Returns the pointer to the Gantt item with the name \a name.
  3358. If no item is found, the return value is 0.
  3359. If there is more than one item with the same name in the Gantt view,
  3360. the first item found will be returned. This may not necessarily be
  3361. the first item in the listview.
  3362. \param name the name of the Gantt item
  3363. \return the pointer to the item with name \a name. O, if there is no item
  3364. in the Gantt view with this name.
  3365. */
  3366. KDGanttViewItem* KDGanttView::getItemByName( const TQString& name ) const
  3367. {
  3368. KDGanttViewItem* temp = firstChild(),* ret;
  3369. while (temp != 0) {
  3370. if ( (ret = temp->getChildByName( name ) ) )
  3371. return ret;
  3372. temp = temp->nextSibling();
  3373. }
  3374. return 0;
  3375. }
  3376. /*!
  3377. Returns the pointer to the Gantt item at the position \a pos in the
  3378. list view.
  3379. The position \a pos is a global position.
  3380. If no item is found, 0 is returned.
  3381. \param pos the (global) position of the Gantt item
  3382. \return the pointer to the item with position \a pos. O, if there is
  3383. no item in the list view at this position.
  3384. */
  3385. KDGanttViewItem* KDGanttView::getItemByListViewPos( const TQPoint& pos ) const
  3386. {
  3387. return static_cast<KDGanttViewItem*>( myListView->itemAt(myListView->mapFromGlobal(pos) ));
  3388. }
  3389. /*!
  3390. Returns the pointer to the Gantt item at the position \a pos in the
  3391. Gantt view.
  3392. The position \a pos is a global position.
  3393. If no items are found, or the item is disabled, 0 is returned.
  3394. If there is more than one item with the same position in the Gantt view,
  3395. the first item found will be returned. This is not necessarily the
  3396. first item in the listview.
  3397. \param pos the (global) position of the Gantt item
  3398. \return the pointer to the item with position \a pos. O, if there is no item
  3399. in the Gantt view at this position.
  3400. */
  3401. KDGanttViewItem* KDGanttView::getItemByGanttViewPos( const TQPoint& pos ) const
  3402. {
  3403. KDGanttViewItem* item;
  3404. TQPoint local = myCanvasView->mapFromGlobal(pos);
  3405. TQCanvasItemList il = myTimeTable->collisions( myCanvasView->viewportToContents( local ));
  3406. TQCanvasItemList::Iterator it;
  3407. for ( it = il.begin(); it != il.end(); ++it ) {
  3408. if ( myCanvasView->getType(*it) == Type_is_KDGanttViewItem) {
  3409. item = myCanvasView->getItem(*it);
  3410. if ( item->enabled() )
  3411. return item;
  3412. }
  3413. }
  3414. return 0;
  3415. }
  3416. /*!
  3417. Returns the pointer to the Gantt item at the position \a pos in the
  3418. list view part of the Gantt view.
  3419. The position \a pos is a global position if parameter \a global is true.
  3420. If the vertical part (y coordinate) of \a pos
  3421. (mapped to local coordinates) is less than 0 or
  3422. larger than the height of the listview, 0 is returned.
  3423. The horizontal part (x coordinate) of \a pos is ignored.
  3424. \param pos the position of the Gantt item
  3425. \param global if true, pos is assumed to be global
  3426. \return the pointer to the item with position \a pos. O, if there is no item
  3427. in the Gantt view at this position.
  3428. */
  3429. KDGanttViewItem* KDGanttView::getItemAt( const TQPoint& pos, bool global ) const
  3430. {
  3431. /* buggy code - commented out
  3432. TQPoint myPos;
  3433. if ( global )
  3434. myPos = myListView->contentsToViewport( myListView->mapFromGlobal(pos) );
  3435. else
  3436. myPos = myListView->contentsToViewport( pos );
  3437. return (KDGanttViewItem*) myListView->itemAt( myPos );
  3438. */
  3439. KDGanttViewItem* item;
  3440. KDGanttViewItem* retItem = 0;
  3441. int y;
  3442. if ( global )
  3443. y = myCanvasView->mapFromGlobal(pos).y();
  3444. else
  3445. y = pos.y();
  3446. item = firstChild();
  3447. while ( item != 0 ) {
  3448. int yc = item->itemPos();
  3449. if ( yc <= y && y < yc + item->height()) {
  3450. retItem = item;
  3451. break;
  3452. }
  3453. item = item->itemBelow();
  3454. }
  3455. return retItem;
  3456. }
  3457. void KDGanttView::addTickRight()
  3458. {
  3459. if ( _enableAdding && myCanvasView->horizontalScrollBar()->value() == myCanvasView->horizontalScrollBar()->maxValue()) {
  3460. //myCanvasView->horizontalScrollBar()->blockSignals( true );
  3461. myTimeHeader->addTickRight();
  3462. //myCanvasView->horizontalScrollBar()->blockSignals( false );
  3463. myCanvasView->updateHorScrollBar();
  3464. setTimelineToEnd();
  3465. }
  3466. }
  3467. void KDGanttView::addTickLeft()
  3468. {
  3469. if ( _enableAdding && myCanvasView->horizontalScrollBar()->value() == 0 ) {
  3470. myCanvasView->horizontalScrollBar()->blockSignals( true );
  3471. myTimeHeader->addTickLeft();
  3472. myCanvasView->horizontalScrollBar()->blockSignals( false );
  3473. setTimelineToStart();
  3474. }
  3475. }
  3476. void KDGanttView::enableAdding( int val )
  3477. {
  3478. _enableAdding = ( val == 0 || val == myCanvasView->horizontalScrollBar()->maxValue());
  3479. }
  3480. /*!
  3481. Returns the number of items in the Gantt view.
  3482. \return the number of items in the Gantt view.
  3483. */
  3484. int KDGanttView::childCount() const
  3485. {
  3486. return myListView->childCount();
  3487. }
  3488. /*!
  3489. Removes all items from the Gantt view.
  3490. */
  3491. void KDGanttView::clear()
  3492. {
  3493. bool block = myTimeTable->blockUpdating();
  3494. myTimeTable->setBlockUpdating( true );
  3495. myListView->clear();
  3496. myTimeTable->setBlockUpdating( false );
  3497. myTimeTable->updateMyContent();
  3498. myTimeTable->setBlockUpdating( block );
  3499. }
  3500. /*!
  3501. Passes on the signal from the list view.
  3502. */
  3503. void KDGanttView::slot_lvDropped(TQDropEvent* e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse )
  3504. {
  3505. emit dropped( e, droppedItem, itemBelowMouse);
  3506. }
  3507. /*!
  3508. Implements a pass-through to the list view.
  3509. */
  3510. TQDragObject * KDGanttView::dragObject ()
  3511. {
  3512. return myListView->dragObject ();
  3513. }
  3514. /*!
  3515. Implements a pass-through to the list view.
  3516. */
  3517. void KDGanttView::startDrag ()
  3518. {
  3519. //myListView->pt_startDrag ();
  3520. }
  3521. /*!
  3522. This method is overridden for internal purposes.
  3523. */
  3524. void KDGanttView::setPaletteBackgroundColor( const TQColor& col)
  3525. {
  3526. TQWidget::setPaletteBackgroundColor( col );
  3527. timeHeaderSpacerWidget->setPaletteBackgroundColor( col );
  3528. }
  3529. /*!
  3530. Sets the background color of the Gantt view.
  3531. \param c the background color of the Gantt view.
  3532. \sa gvBackgroundColor()
  3533. */
  3534. void KDGanttView::setGvBackgroundColor ( const TQColor & c )
  3535. {
  3536. myTimeTable->setBackgroundColor( c );
  3537. }
  3538. /*!
  3539. Sets the background color of the time header.
  3540. \param c the background color of the time header.
  3541. \sa timeHeaderBackgroundColor()
  3542. */
  3543. void KDGanttView::setTimeHeaderBackgroundColor ( const TQColor & c )
  3544. {
  3545. myTimeHeader->setPaletteBackgroundColor( c );
  3546. //rightWidget->setPaletteBackgroundColor( c );
  3547. timeHeaderSpacerWidget->setPaletteBackgroundColor( c );
  3548. }
  3549. /*!
  3550. Sets the background color of the legend header.
  3551. \param c the background color of the legend header
  3552. \sa legendHeaderBackgroundColor()
  3553. */
  3554. void KDGanttView::setLegendHeaderBackgroundColor ( const TQColor & c )
  3555. {
  3556. myLegend->setPaletteBackgroundColor( c );
  3557. leftWidget->setPaletteBackgroundColor( c );
  3558. }
  3559. /*!
  3560. Sets the background color of the list view.
  3561. \param c the background color of the list view
  3562. \sa lvBackgroundColor()
  3563. */
  3564. void KDGanttView::setLvBackgroundColor ( const TQColor & c )
  3565. {
  3566. myListView->viewport()->setPaletteBackgroundColor( c );
  3567. }
  3568. /*!
  3569. Returns the background color of the list view.
  3570. \return the background color of the list view
  3571. \sa setLvBackgroundColor()
  3572. */
  3573. TQColor KDGanttView::lvBackgroundColor ( )const
  3574. {
  3575. return myListView->viewport()->paletteBackgroundColor( );
  3576. }
  3577. /*!
  3578. Returns the background color of the Gantt view.
  3579. \return the background color of the Gantt view
  3580. \sa setGvBackgroundColor()
  3581. */
  3582. TQColor KDGanttView::gvBackgroundColor () const
  3583. {
  3584. return myTimeTable->backgroundColor( );
  3585. }
  3586. /*!
  3587. Returns the background color of the time header.
  3588. \return the background color of the time header
  3589. \sa setTimeHeaderBackgroundColor()
  3590. */
  3591. TQColor KDGanttView::timeHeaderBackgroundColor () const
  3592. {
  3593. return myTimeHeader->paletteBackgroundColor( );
  3594. }
  3595. /*!
  3596. Returns the background color of the legend header.
  3597. \return the background color of the legend header
  3598. \sa setLegendHeaderBackgroundColor()
  3599. */
  3600. TQColor KDGanttView::legendHeaderBackgroundColor () const
  3601. {
  3602. return myLegend->paletteBackgroundColor( );
  3603. }
  3604. /*!
  3605. Adds a widget to the spacer widget above the list view part and
  3606. below the ShowLegendButton. To assign all the space above the
  3607. Listview to the spacer widget, hide the ShowLegendButton by calling
  3608. setShowLegendButton( false ). The spacer widget is a TQHBox. You
  3609. may add as many widgets as you want. They are ordered horizontally
  3610. from left to right. To remove a widget from the spacer widget, call
  3611. widget->reparent(newParent,...) or delete the widget. Since the spacer
  3612. is a TQHBox, the layout of the added widgets is managed by this
  3613. TQHBox.
  3614. \param w A pointer to the widget to be added.
  3615. \sa setShowLegendButton( )
  3616. */
  3617. void KDGanttView::addUserdefinedLegendHeaderWidget( TQWidget * w )
  3618. {
  3619. if ( w ) {
  3620. w->reparent ( spacerLeft, 0, TQPoint(0,0) );
  3621. }
  3622. }
  3623. /*!
  3624. Specifies whether drag operations are allowed in the Gantt
  3625. view. Recurses over all items contained in the Gantt view and
  3626. enables or disabled them for dragging.
  3627. \param b true if dragging is enabled, false if dragging is disabled
  3628. \sa isDragEnabled(), setDropEnabled(), isDropEnabled(), setDragDropEnabled()
  3629. */
  3630. void KDGanttView::setDragEnabled( bool b )
  3631. {
  3632. fDragEnabled = b;
  3633. TQListViewItemIterator it( myListView );
  3634. for ( ; it.current(); ++it ) {
  3635. (( KDGanttViewItem* )it.current())->setDragEnabled(b);
  3636. }
  3637. }
  3638. /*!
  3639. Specifies whether drop operations are allowed in the Gantt
  3640. view. Recurses over all items contained in the Gantt view and
  3641. enables or disabled them for dropping.
  3642. \param b true if dragging is enabled, false if dragging is disabled
  3643. \sa setDropEnabled(), setDragEnabled(), isDragEnabled(), setDragDropEnabled()
  3644. */
  3645. void KDGanttView::setDropEnabled( bool b )
  3646. {
  3647. fDropEnabled = b;
  3648. //myListView->setAcceptDrops( b );
  3649. TQListViewItemIterator it( myListView );
  3650. for ( ; it.current(); ++it ) {
  3651. (( KDGanttViewItem* )it.current())->setDropEnabled(b);
  3652. }
  3653. }
  3654. /*!
  3655. Combines setDragEnabled() and setDropEnabled() in one convenient
  3656. method.
  3657. \param b true if dragging and dropping are enabled, false if
  3658. dragging and dropping are disabled
  3659. \sa setDragEnabled(), setDropEnabled()
  3660. */
  3661. void KDGanttView::setDragDropEnabled( bool b )
  3662. {
  3663. setDropEnabled( b );
  3664. setDragEnabled( b );
  3665. }
  3666. /*!
  3667. Returns whether dragging is enabled for this Gantt view.
  3668. \return true if dragging is enabled
  3669. \sa setDragEnabled(), setDragDropEnabled()
  3670. */
  3671. bool KDGanttView::isDragEnabled() const
  3672. {
  3673. return fDragEnabled;
  3674. }
  3675. /*!
  3676. Returns whether dropping is enabled for this Gantt view.
  3677. \return true if dropping is enabled
  3678. \sa setDropEnabled(), setDragDropEnabled()
  3679. */
  3680. bool KDGanttView::isDropEnabled() const
  3681. {
  3682. return fDropEnabled;
  3683. }
  3684. /*!
  3685. \deprecated Use isDragEnabled() instead
  3686. */
  3687. bool KDGanttView::dragEnabled() const
  3688. {
  3689. return isDragEnabled();
  3690. }
  3691. /*!
  3692. \deprecated Use isDropEnabled() instead
  3693. */
  3694. bool KDGanttView::dropEnabled() const
  3695. {
  3696. return isDropEnabled();
  3697. }
  3698. /*!
  3699. This virtual method makes it possible to specify user-defined drop
  3700. handling. The method is called directly before the internal drop
  3701. handling is executed. Return false to execute internal drop
  3702. handling. Return true to not execute internal drop handling. In
  3703. order to specify user-defined drop handling, subclass
  3704. KDGanttView and reimplement this method.
  3705. \param e The TQDropEvent
  3706. Note: e->source() is a pointer to the KDGanttView from which the drag started.
  3707. I.e., if e->source() == this, this drag is an internal drag.
  3708. \param droppedItem 0, if this is a drag operation from another
  3709. KDGanttView instance.
  3710. If this drag is an internal drag (i.e., within the KDGanttView),
  3711. this parameter points to the dropped item.
  3712. \param itemBelowMouse a pointer to the item below the dragged
  3713. item (i.e., below the mouse).
  3714. If you accept, the dragged item may be inserted
  3715. in the KDGanttView as a child of this item.
  3716. The value is 0 if there is no item below the dragged item,
  3717. and the dragged item will be inserted as a root item.
  3718. \return false, when the internal drop handling should be executed
  3719. true, when the internal drop handling should not be executed
  3720. \sa lvDropEvent(), lvStartDrag()
  3721. */
  3722. bool KDGanttView::lvDropEvent ( TQDropEvent* e,
  3723. KDGanttViewItem* droppedItem,
  3724. KDGanttViewItem* itemBelowMouse )
  3725. {
  3726. Q_UNUSED( e );
  3727. Q_UNUSED( droppedItem );
  3728. Q_UNUSED( itemBelowMouse );
  3729. // Example code for user defined behaviour:
  3730. // we want to accept the usual drags and the drags of files, which may be
  3731. // a saved Gantt file.
  3732. // Please uncomment the following lines for this behaviour
  3733. // You have to uncomment lines in lvDragMoveEvent() and llvDragEnterEvent() as well
  3734. // ************** begin example ************
  3735. /*
  3736. if ( TQUriDrag::canDecode( e ) ) {
  3737. TQStrList lst;
  3738. TQUriDrag::decode( e, lst );
  3739. // we try the first file of icon-url-list
  3740. TQString str = lst.at ( 0 );
  3741. // remove file: at beginning of string
  3742. str = str.right( str.length() - 5 );
  3743. TQFileInfo info;
  3744. info.setFile( str ) ;
  3745. if ( info.isFile() ) {
  3746. if (!TQMessageBox::information( this, "KDGantt Drag&Drop test",
  3747. "Try to insert file: "+ str + " ?",
  3748. "&Okay", "&Cancel",0,1 ) ) {
  3749. TQFile file( str );
  3750. // store current updating status
  3751. bool uen = myTimeTable->blockUpdating();
  3752. // block updating while insertion of items
  3753. myTimeTable->setBlockUpdating();
  3754. loadProject( &file ) ;
  3755. // restore updating status and execute an update via setUpdateEnabled( true );
  3756. if ( !uen )
  3757. setUpdateEnabled( true );
  3758. }
  3759. }
  3760. return true;
  3761. }
  3762. */
  3763. // *********** end example ****************
  3764. return false;
  3765. }
  3766. /*!
  3767. This virtual method specifies whether a drag enter event may be
  3768. accepted or not.
  3769. To accept a drag enter event, call e->accept( true );
  3770. To not accept a drag enter evente, call e->accept( false );
  3771. This method does nothing but accepting the drag enter event, in case
  3772. decoding is possible.
  3773. In order to define accepting drops for particular items yourself,
  3774. subclass KDGanttView and reimplement this method.
  3775. \param e The TQDragMoveEvent
  3776. Note: e->source() is a pointer to the KDGanttView, the drag started from.
  3777. I.e., if e->source() == this, this drag is an internal drag.
  3778. \sa lvDropEvent(), lvStartDrag(), lvDragMoveEvent()
  3779. */
  3780. void KDGanttView::lvDragEnterEvent ( TQDragEnterEvent * e)
  3781. {
  3782. // the standard behaviour:
  3783. // accept drag enter events, if KDGanttViewItemDrag can decode the event
  3784. // e->accept(KDGanttViewItemDrag::canDecode(e) );
  3785. if ( KDGanttViewItemDrag::canDecode(e) ) {
  3786. e->accept( true);
  3787. return;
  3788. }
  3789. // example code for user defined behaviour:
  3790. // we want to accecpt the usual drags and the drags of files, which may be
  3791. // a saved Gantt file
  3792. // Please uncomment the following lines for this behaviour
  3793. // You have to uncomment lines in lvDragMoveEvent() and lvDropEvent () as well
  3794. // if ( TQUriDrag::canDecode( e ) ) {
  3795. // e->accept(true);
  3796. // return;
  3797. // }
  3798. e->accept( false );
  3799. }
  3800. /*!
  3801. This virtual method specifies whether a drop event may be accepted or not.
  3802. To accept a drop event, call e->accept( true );
  3803. To not accept a drop event, call e->accept( false );
  3804. This method does nothing but allowing to execute the internal
  3805. drag move event handling.
  3806. In order to specify user-defined drop acceptance for particular
  3807. items, subclass KDGanttView and reimplement this method.
  3808. \param e The TQDragMoveEvent
  3809. Note: e->source() is a pointer to the KDGanttView, the drag started from.
  3810. I.e. if e->source() == this, this drag is an internal drag.
  3811. draggedItem 0, if this is a drag operation from another KDGanttView instance.
  3812. If this drag is an internal drag (i.e., within the KDGanttView),
  3813. this parameter points to the dragged item.
  3814. itemBelowMouse a pointer to the item below the dragged item
  3815. (i.e., below the mouse).
  3816. If you accept the drop, the dragged item will be inserted
  3817. in the KDGanttView as a child of this item.
  3818. The value is 0 if there is no item below the dragged item,
  3819. and the dragged item will be inserted as a root item.
  3820. \return false, when the internal drag move event handling should be executed
  3821. true, when the internal drag move event handling should not
  3822. be executed; usually you should return true,
  3823. if you have called e->accept( true ) before.
  3824. \sa lvDropEvent(), lvStartDrag()
  3825. */
  3826. bool KDGanttView::lvDragMoveEvent ( TQDragMoveEvent* /*e*/,
  3827. KDGanttViewItem* /* draggedItem*/,
  3828. KDGanttViewItem* /*itemBelowMouse*/)
  3829. {
  3830. // Example code 1:
  3831. // To generally block items to be inserted as root items, subclass KDGanttView
  3832. // and reimplement this method with to following code uncommented:
  3833. // if ( !itemBelowMouse ) {
  3834. // e->accept( false );
  3835. // return true;
  3836. //}
  3837. //return false;
  3838. // Example code 2:
  3839. // To allow the drags of files, which may be
  3840. // a saved Gantt file, subclass KDGanttView
  3841. // and reimplement this method with to following code uncommented:
  3842. // if ( TQUriDrag::canDecode( e ) ) {
  3843. // e->accept(true);
  3844. // return true;
  3845. // }
  3846. // normal behaviour - the internal drag move event handling should be executed
  3847. return false;
  3848. }
  3849. /*!
  3850. This virtual method creates a TQDragObject and starts a drag for a
  3851. KDGanttViewItem.
  3852. In order to prevent drags of particular items, subclass from
  3853. KDGanttView and reimplement this method.
  3854. \param item the KDGanttViewItem, which should be dragged
  3855. \sa lvDropEvent(), lvDragMoveEvent()
  3856. */
  3857. void KDGanttView::lvStartDrag (KDGanttViewItem* item)
  3858. {
  3859. TQDragObject* d = new KDGanttViewItemDrag(item, this, "itemdrag" );
  3860. // call d->drag() to start the dragging
  3861. // d->drag() returns true, if a move was requested as a drag
  3862. // if a copy (by pressing the <Ctrl>-key) was performed, d->drag() returns false
  3863. // In order to avoid starting drags for particular items, subclass KDGanttView
  3864. // an reimplement this method.
  3865. // insert here some code like
  3866. // if ( item->parent() )
  3867. // return;
  3868. // This particular code will make it impossible to drag other items but root items.
  3869. if ( d->drag() ) {
  3870. delete item;
  3871. }
  3872. }
  3873. /*!
  3874. Sets the width of the list view. Space will be taken from or given
  3875. to the Gantt view.
  3876. \param w the width of the list view
  3877. \sa listViewWidth()
  3878. */
  3879. void KDGanttView::setListViewWidth( int w )
  3880. {
  3881. int sw = mySplitter->width();
  3882. TQValueList<int> list;
  3883. list.append(w);
  3884. list.append(sw-w);
  3885. mySplitter->setSizes( list );
  3886. }
  3887. /*!
  3888. Returns the width of the list view.
  3889. \return the width of the list view
  3890. \sa setListViewWidth()
  3891. */
  3892. int KDGanttView::listViewWidth( )
  3893. {
  3894. return leftWidget->width();
  3895. }
  3896. /*!
  3897. Sets the scrollbar mode of the listview. The default is always off.
  3898. Possible values are always on, always off and auto.
  3899. It only makes sense to set this to always off
  3900. if setGvVScrollBarMode() is set to always on.
  3901. \param m the scrollbar mode.
  3902. \sa setGvVScrollBarMode( )
  3903. */
  3904. void KDGanttView::setLvVScrollBarMode( TQScrollView::ScrollBarMode m )
  3905. {
  3906. myListView->setVScrollBarMode ( m );
  3907. }
  3908. /*!
  3909. Sets the scrollbar mode of the time table. The default is always on.
  3910. Possible values are always on and always off.
  3911. It only makes sense to set this to always off
  3912. if setLvVScrollBarMode() is set to always on or auto.
  3913. \param m The scrollbar mode.
  3914. \sa setLvVScrollBarMode( )
  3915. */
  3916. void KDGanttView::setGvVScrollBarMode( TQScrollView::ScrollBarMode m )
  3917. {
  3918. if ( m == TQScrollView::Auto )
  3919. tqDebug("KDGanttView::setListViewVScrollBarMode: TQScrollView::Auto not supported. Nothing changed. ");
  3920. else
  3921. {
  3922. myCanvasView->setVScrollBarMode ( m );
  3923. if ( m == TQScrollView::AlwaysOn )
  3924. timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
  3925. else
  3926. timeHeaderSpacerWidget->setFixedWidth( 0 );
  3927. }
  3928. }
  3929. void KDGanttView::notifyEditdialog( KDGanttViewItem * item)
  3930. {
  3931. if (myItemAttributeDialog->getItem() == item ) {
  3932. myItemAttributeDialog->reset( 0 );
  3933. }
  3934. }
  3935. /*!
  3936. \fn void KDGanttView::setLinkItemsEnabled( bool on );
  3937. This enables/disables the linking ui of KDGanttViewItems in KDGanttView.
  3938. A signal linkItems() is emitted when two items shall be linked and can
  3939. be used to create the actual link.
  3940. */
  3941. void KDGanttView::setLinkItemsEnabled(bool on)
  3942. {
  3943. myCanvasView->linkItemsEnabled = on;
  3944. myCanvasView->autoScrollEnabled = true;
  3945. }
  3946. /*!
  3947. \fn void KDGanttView::isLinkItemsEnabled();
  3948. Returns if the linking functionallity is enabled or disabled.
  3949. */
  3950. bool KDGanttView::isLinkItemsEnabled() const
  3951. {
  3952. return myCanvasView->linkItemsEnabled;
  3953. }
  3954. /*!
  3955. \fn void KDGanttView::timeIntervalSelected( const TQDateTime& start, const TQDateTime& end);
  3956. This signal is emitted when the user selects a time
  3957. interval with the mouse on the time header connect this signal to
  3958. the slot void zoomToSelection( const TQDateTime& start, const
  3959. TQDateTime& end) to obtain automatic zooming.
  3960. */
  3961. /*!
  3962. \fn void KDGanttView::timeIntervallSelected( const TQDateTime& start, const TQDateTime& end);
  3963. \deprecated This signal is deprecated, do not use it in new code;
  3964. use timeIntervalSelected() instead. timeIntervallSelected() will be
  3965. removed in future versions.
  3966. */
  3967. /*!
  3968. \fn void KDGanttView::rescaling( Scale )
  3969. This signal is emitted if another scale is choosen than the
  3970. specified one: i.e. if the horizon has a very wide range from
  3971. start to end and as scale is choosen minute it may be that the
  3972. size of the Gantt widget would become more than 32000 pixels. In
  3973. this case the scale is automatically changed to Hour and
  3974. rescaling( Hour ) is emitted. If the widget size would be still
  3975. more than 32000 pixels, the scale is automatically changed to day
  3976. and rescaling( Day ) is emitted. In the new scale, the
  3977. minortickcount is increased such that the horizon will fit in the
  3978. maximum size of 32000 pixels.
  3979. */
  3980. /*!
  3981. \fn void KDGanttView::gvCurrentChanged( KDGanttViewItem* item )
  3982. This signal is emitted whenever the user clicks on the Gantt view
  3983. \a item parameter is 0, if no item was clicked
  3984. */
  3985. /*!
  3986. \fn void KDGanttView::gvItemLeftClicked( KDGanttViewItem* )
  3987. This signal is emitted whenever the user clicks into the Gantt view
  3988. with the left mouse button.
  3989. */
  3990. /*!
  3991. \fn void KDGanttView::gvItemMidClicked( KDGanttViewItem* )
  3992. This signal is emitted whenever the user clicks into the Gantt view
  3993. with the middle mouse button.
  3994. */
  3995. /*!
  3996. \fn void KDGanttView::gvItemRightClicked( KDGanttViewItem* )
  3997. This signal is emitted whenever the user clicks into the Gantt view
  3998. with the right mouse button.
  3999. */
  4000. /*!
  4001. \fn void KDGanttView::gvMouseButtonClicked ( int button, KDGanttViewItem* item, const TQPoint & pos)
  4002. This signal is emitted when the user clicks into the Gantt view with
  4003. any mouse button. Notice that \a pos is the absolute mouse position.
  4004. */
  4005. /*!
  4006. \fn void KDGanttView::gvItemDoubleClicked( KDGanttViewItem* )
  4007. This signal is emitted whenever the user double-clicks into the Gantt view.
  4008. */
  4009. /*!
  4010. \fn void KDGanttView::gvContextMenuRequested ( KDGanttViewItem * item, const TQPoint & pos )
  4011. This signal is emitted when the user requests a context menu in the
  4012. Gantt view. Notice that \a pos is the absolute mouse position.
  4013. */
  4014. /*!
  4015. \fn void KDGanttView::linkItems ( KDGanttViewItem* from, KDGanttViewItem* to, int linkType )
  4016. This signal is emitted when the user wants to link two items in the Gantt view.
  4017. */
  4018. /*!
  4019. \fn void KDGanttView::lvCurrentChanged( KDGanttViewItem* item )
  4020. This signal is emitted whenever the user clicks on the list view
  4021. \a item parameter is 0, if no item was clicked
  4022. */
  4023. /*!
  4024. \fn void KDGanttView::lvItemLeftClicked( KDGanttViewItem* )
  4025. This signal is emitted whenever the user clicks into the list view
  4026. with the left mouse button.
  4027. */
  4028. /*!
  4029. \fn void KDGanttView::lvItemMidClicked( KDGanttViewItem* )
  4030. This signal is emitted whenever the user clicks into the list view
  4031. with the middle mouse button.
  4032. */
  4033. /*!
  4034. \fn void KDGanttView::lvItemRightClicked( KDGanttViewItem* )
  4035. This signal is emitted whenever the user clicks into the list view
  4036. with the right mouse button.
  4037. */
  4038. /*!
  4039. \fn void KDGanttView::lvMouseButtonPressed ( int button,
  4040. KDGanttViewItem* item, const TQPoint & pos, int col)
  4041. This signal is emitted when the user presses any mouse button in the
  4042. list view. Notice that \a pos is the absolute mouse position.
  4043. */
  4044. /*!
  4045. \fn void KDGanttView::lvMouseButtonClicked ( int button,
  4046. KDGanttViewItem* item, const TQPoint & pos, int col)
  4047. This signal is emitted when the user clicks into the
  4048. list view with any mouse button . Notice that \a pos is the absolute
  4049. mouse position.
  4050. */
  4051. /*!
  4052. \fn void KDGanttView::lvItemDoubleClicked( KDGanttViewItem* )
  4053. This signal is emitted whenever the user double-clicks into the list view.
  4054. */
  4055. /*!
  4056. \fn void KDGanttView::lvItemRenamed( KDGanttViewItem*, int col,
  4057. const TQString& text )
  4058. This signal is emitted whenever the user changes the name of an item
  4059. in the list view using in-place editing. \a text contains the new
  4060. text in the list view.
  4061. */
  4062. /*!
  4063. \fn void KDGanttView::lvContextMenuRequested( KDGanttViewItem *
  4064. item, const TQPoint & pos, int col )
  4065. This signal is emitted when the user requests a context menu in the
  4066. list view. Notice that \a pos is the absolute mouse position.
  4067. */
  4068. /*!
  4069. \fn void KDGanttView::lvSelectionChanged( KDGanttViewItem* )
  4070. This signal is emitted whenever the user changes the selection in
  4071. the list view.
  4072. */
  4073. /*!
  4074. \fn void KDGanttView::dropped ( TQDropEvent * e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse)
  4075. This signal is emitted whenever a Gantt item is dropped onto the
  4076. Gantt view. \a droppedItem is 0, if this is a drag operation from
  4077. another KDGanttView instance. If this drag is an internal drag
  4078. (i.e. within the KDGanttView), this parameter points to the dropped item.
  4079. \a itemBelowMouse is a pointer to the item below the dragged
  4080. item (i.e., below the mouse). The dragged item may be inserted
  4081. in the KDGanttView as a child of this item.
  4082. If The value is 0, if there is no item below the dragged item,
  4083. and the dragged item will be inserted as a root item.
  4084. In order to get user-defined behavior for drop events, reimplement
  4085. KDGanttView::lvDropEvent()
  4086. */
  4087. /*!
  4088. \enum KDGanttView::RepaintMode
  4089. Please see setRepaintMode() for a description of the values of this
  4090. enumeration.
  4091. */