kdgantt

KDGanttViewItem.cpp
1 /*
2  $Id$
3  KDGantt - a multi-platform charting engine
4 */
5 
6 /****************************************************************************
7  ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
8  **
9  ** This file is part of the KDGantt library.
10  **
11  ** This file may be distributed and/or modified under the terms of the
12  ** GNU General Public License version 2 as published by the Free Software
13  ** Foundation and appearing in the file LICENSE.GPL included in the
14  ** packaging of this file.
15  **
16  ** Licensees holding valid commercial KDGantt licenses may use this file in
17  ** accordance with the KDGantt Commercial License Agreement provided with
18  ** the Software.
19  **
20  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22  **
23  ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
24  ** information about KDGantt Commercial License Agreements.
25  **
26  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
27  ** licensing are not clear to you.
28  **
29  ** As a special exception, permission is given to link this program
30  ** with any edition of TQt, and distribute the resulting executable,
31  ** without including the source code for TQt in the source distribution.
32  **
33  **********************************************************************/
34 
35 
36 #include "KDGanttViewSubwidgets.h"
37 #include "KDGanttViewTaskItem.h"
38 #include "KDGanttViewSummaryItem.h"
39 #include "KDGanttViewEventItem.h"
40 #include "itemAttributeDialog.h"
41 
42 #include "tqpainter.h"
43 
44 #include "KDGanttXMLTools.h"
45 
46 
160 TQDict<KDGanttViewItem> KDGanttViewItem::sItemDict;
161 
172  const TQString& lvtext,
173  const TQString& name ) :
174  TQListViewItem(view->myListView,lvtext)
175 {
176  initColorAndShapes(type);
178 }
179 
180 
192  const TQString& lvtext,
193  const TQString& name ) :
194  TQListViewItem(parentItem,lvtext)
195 {
196  initColorAndShapes(type);
198 }
199 
200 
213  KDGanttViewItem* after,
214  const TQString& lvtext,
215  const TQString& name ) :
216  TQListViewItem(view->myListView,after, lvtext)
217 {
218  initColorAndShapes(type);
220 }
221 
222 
235  KDGanttViewItem* after,
236  const TQString& lvtext,
237  const TQString& name ) :
238  TQListViewItem( parentItem, after, lvtext )
239 {
240  initColorAndShapes(type);
242 }
243 
244 
249 {
250  myGanttView->notifyEditdialog( this );
251  if ( startLine ) delete startLine;
252  if ( endLine ) delete endLine ;
253  if ( startLineBack ) delete startLineBack ;
254  if ( endLineBack ) delete endLineBack ;
255  if ( actualEnd ) delete actualEnd ;
256  if ( textCanvas ) delete textCanvas ;
257  if ( startShape ) delete startShape ;
258  if ( midShape ) delete midShape ;
259  if ( endShape ) delete endShape ;
260  if ( startShapeBack ) delete startShapeBack ;
261  if ( midShapeBack ) delete midShapeBack ;
262  if ( endShapeBack ) delete endShapeBack ;
263  if ( progressShape ) delete progressShape ;
264  if ( floatStartShape ) delete floatStartShape ;
265  if ( floatEndShape ) delete floatEndShape ;
266  myGanttView->myTimeTable->removeItemFromTasklinks( this );
267  myGanttView->myCanvasView->resetCutPaste( this );
268  if ( listView() ) {
269  if ( isOpen() )
270  setOpen( false );
271  if ( parent() )
272  parent()->takeItem( this );
273  else
274  myGanttView->myListView->takeItem( this );
275  myGanttView->myTimeTable->updateMyContent();
276  }
277  // myGanttView->myTimeTable->removeItemFromTasklinks( this );
278  // myGanttView->myCanvasView->resetCutPaste( this );
279 }
280 
281 
286 void KDGanttViewItem::generateAndInsertName( const TQString& name )
287 {
288  // First check if we already had a name. This can be the case if
289  // the item was reconstructed from an XML file.
290  if( !_name.isEmpty() )
291  // We had a name, remove it
292  sItemDict.remove( _name );
293 
294  TQString newName;
295  if ( name.isEmpty() || sItemDict.find( name ) ) {
296  // create unique name
297  newName.sprintf( "%p", (void* )this );
298  while( sItemDict.find( newName ) ) {
299  newName += "_0";
300  }
301  } else {
302  newName = name;
303  }
304  sItemDict.insert( newName, this );
305  _name = newName;
306 }
307 
308 
314 TQString KDGanttViewItem::name() const
315 {
316  return _name;
317 }
318 
319 
328 KDGanttViewItem* KDGanttViewItem::find( const TQString& name )
329 {
330  if (name.isEmpty()) // avoid error msg from TQDict
331  return 0;
332  return sItemDict.find( name );
333 }
334 
335 
336 
345 {
346 
347  return myType;
348 }
349 
350 
363 {
364  _enabled = on;
365  if ( displaySubitemsAsGroup() ) {
366  myGanttView->myTimeTable->inc_blockUpdating();
368  while (temp != 0) {
369  temp->setEnabled( on );
370  temp = temp->nextSibling();
371  }
372  TQListViewItem::setEnabled( on );
373  myGanttView->myTimeTable->dec_blockUpdating();
374  }
376 }
377 
378 
386 {
387  return _enabled;
388 }
389 
390 
391 // *********************************
399 {
400  if ( on ) {
401  resetSubitemVisibility();
402  } else
403  setVisible( false );
404  //updateCanvasItems();
405  myGanttView->myTimeTable->updateMyContent();
406 }
407 
408 
416 {
417  return TQListViewItem::isVisible();
418 }
419 
420 
421 // *************************************
422 
430 void KDGanttViewItem::setEditable( bool editable )
431 {
433 }
434 
435 
444 {
445  return isEditable;
446 }
447 
448 
462 {
463  if ( !show && _displaySubitemsAsGroup)
464  isVisibleInGanttView = true;
465  _displaySubitemsAsGroup = show;
466  if ( parent() )
467  if ( parent()->isOpen() )
468  parent()->setOpen( true );
469  if ( isOpen() )
470  setOpen( true );
472 }
473 
474 
483 {
484  return _displaySubitemsAsGroup;
485 }
486 
487 
508 {
509  if ( prio < 1 )
510  prio = 1;
511  if (prio > 199 )
512  prio = 199;
513  _priority = prio;
515 }
516 
517 
524 {
525  return _priority;
526 }
527 
528 
537 void KDGanttViewItem::setStartTime( const TQDateTime& )
538 {
539 }
540 
541 
548 TQDateTime KDGanttViewItem::startTime() const
549 {
550  return myStartTime;
551 }
552 
553 
562 void KDGanttViewItem::setEndTime( const TQDateTime& end )
563 {
564  switch( type() ) {
565  case Event:
566  tqDebug( "KDGantt:Event Item has no end time" );
567  break;
568  case Summary:
569  ((KDGanttViewSummaryItem*)this)->setEndTime( end );
570  break;
571  case Task:
572  tqDebug( "KDGantt:Task Item has no end time" );
573  break;
574  default:
575  tqDebug( "Unknown type in KDGanttViewItem::typeToString()" );
576  }
577 }
578 
579 
586 TQDateTime KDGanttViewItem::endTime() const
587 {
588  return myEndTime;
589 }
590 
591 
603 void KDGanttViewItem::setText( const TQString& text )
604 {
605  textCanvas->setText(text);
608 }
609 
610 
618 TQString KDGanttViewItem::text() const
619 {
620  return textCanvasText;
621 }
622 
623 
627 void KDGanttViewItem::setListViewText( const TQString& text, int column )
628 {
629  TQListViewItem::setText( column, text );
630 }
631 
632 
640 void KDGanttViewItem::setListViewText( int column, const TQString& text )
641 {
642  TQListViewItem::setText( column, text );
643 }
644 
645 
654 TQString KDGanttViewItem::listViewText( int column ) const
655 {
656  return TQListViewItem::text( column );
657 }
658 
659 
666 void KDGanttViewItem::setFont( const TQFont& font )
667 {
668  textCanvas->setFont(font);
670 }
671 
672 
679 TQFont KDGanttViewItem::font() const
680 {
681  return textCanvas->font();
682 }
683 
684 
691 void KDGanttViewItem::setTooltipText( const TQString& text )
692 {
693  myToolTipText = text;
694 }
695 
696 
704 {
705 
706  return myToolTipText;
707 }
708 
709 
716 void KDGanttViewItem::setWhatsThisText( const TQString& text )
717 {
718  myWhatsThisText = text;
719 }
720 
721 
730 {
731  return myWhatsThisText;
732 }
733 
734 
746 void KDGanttViewItem::setHighlight( bool highlight )
747 {
749  if ( displaySubitemsAsGroup() ) {
750  myGanttView->myTimeTable->inc_blockUpdating();
752  while (temp != 0) {
753  temp->setHighlight( highlight );
754  temp = temp->nextSibling();
755  }
756  myGanttView->myTimeTable->dec_blockUpdating();
757  }
759 }
760 
761 
770 {
771  return isHighlighted;
772 }
773 
774 
787 void KDGanttViewItem::setShapes( Shape start, Shape middle, Shape end )
788 {
789 
790  myStartShape = start;
791  myMiddleShape= middle;
792  myEndShape= end;
793  createShape(startShape,startShapeBack,start);
794  createShape(midShape,midShapeBack,middle);
795  midShape->setZ( 4 );
796  createShape(endShape,endShapeBack,end);
798 }
799 
800 
813 void KDGanttViewItem::createShape( KDCanvasPolygonItem* &itemShape,
814  KDCanvasPolygonItem* &itemShapeBack,
815  Shape shape )
816 {
817  if ( itemShape && type() == Task )
818  return;
819  if (itemShape) delete itemShape;
820  if (itemShapeBack) delete itemShapeBack;
821 
822  TQCanvasPolygonalItem * item;
823  TQCanvasPolygonalItem * itemBack;
824  int size = myItemSize+2;
825  int hei = (myItemSize/3)/2;
826  switch (shape) {
827  case TriangleDown:
828  {
829  item = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
830  TQPointArray arr = TQPointArray(3);
831  arr.setPoint(0,-size/2,-hei);
832  arr.setPoint(1,size/2,-hei);
833  arr.setPoint(2,0,((size/2)-hei));
834  ((TQCanvasPolygon*)item)->setPoints(arr);
835  size += 4;hei +=1;
836  itemBack = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
837  arr.setPoint(0,-size/2,-hei);
838  arr.setPoint(1,size/2,-hei);
839  arr.setPoint(2,0,((size/2)-hei));
840  ((TQCanvasPolygon*)itemBack)->setPoints(arr);
841 
842  break;
843  }
844  case TriangleUp:
845  {
846  // I really do not know why, but we get only an TriangleUp-icon
847  // of the same size as a TriangleDown-icon, if we increment the size by 2
848  size+=2;
849  item = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
850  TQPointArray arr = TQPointArray(3);
851  arr.setPoint(0,-size/2,hei);
852  arr.setPoint(1,size/2,hei);
853  arr.setPoint(2,0,(-size/2)+hei);
854  ((TQCanvasPolygon*)item)->setPoints(arr);
855  size += 4;hei +=1;
856  itemBack = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
857  arr.setPoint(0,-size/2,hei);
858  arr.setPoint(1,size/2,hei);
859  arr.setPoint(2,0,(-size/2)+hei);
860  ((TQCanvasPolygon*)itemBack)->setPoints(arr);
861 
862  break;
863  }
864 
865  case Diamond:
866  {
867  item = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
868  TQPointArray arr = TQPointArray(4);
869  arr.setPoint(0,0,-size/2);
870  arr.setPoint(1,size/2,0);
871  arr.setPoint(2,0,size/2);
872  arr.setPoint(3,-size/2,0);
873  ((TQCanvasPolygon*)item)->setPoints(arr);
874  size += 2;hei +=1;
875  itemBack = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
876  arr.setPoint(0,0,-size/2);
877  arr.setPoint(1,size/2,0);
878  arr.setPoint(2,0,size/2);
879  arr.setPoint(3,-size/2,0);
880  ((TQCanvasPolygon*)itemBack)->setPoints(arr);
881  break;
882  }
883 
884  case Square:
885  {
886  size -=2;
887  item = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
888  TQPointArray arr = TQPointArray(4);
889  arr.setPoint(0,-size/2,-size/2);
890  arr.setPoint(1,size/2,-size/2);
891  arr.setPoint(2,size/2,size/2);
892  arr.setPoint(3,-size/2,size/2);
893  ((TQCanvasPolygon*)item)->setPoints(arr);
894  size += 2;hei +=1;
895  itemBack = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
896  arr.setPoint(0,-size/2,-size/2);
897  arr.setPoint(1,size/2,-size/2);
898  arr.setPoint(2,size/2,size/2);
899  arr.setPoint(3,-size/2,size/2);
900  ((TQCanvasPolygon*)itemBack)->setPoints(arr);
901  break;
902  }
903 
904  case Circle:
905  {
906  size -= 2;
907  item = new KDCanvasEllipse(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
908  ((KDCanvasEllipse*)item)->setSize(size,size);
909  size += 2;hei +=1;
910  itemBack = new KDCanvasEllipse(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
911  ((KDCanvasEllipse*)itemBack)->setSize(size,size);
912  break;
913  }
914  default:
915  // Uninitialized shape, can e.g. be the case with free-busy
916  // items which don't have any shapes
917  return;
918  }
919  item->setBrush(TQt::SolidPattern);
920  item->setZ(5);
921  itemShape = (KDCanvasPolygonItem*) item;
922  itemBack->setBrush(TQt::SolidPattern);
923  itemBack->setZ(3);
924  itemShapeBack = (KDCanvasPolygonItem*) itemBack;
925 
926 }
927 
928 
937 void KDGanttViewItem::shapes( Shape& start, Shape& middle, Shape& end ) const
938 {
939  start = myStartShape;
940  middle = myMiddleShape;
941  end = myEndShape;
942 }
943 
944 
957 void KDGanttViewItem::setColors( const TQColor& start, const TQColor& middle,
958  const TQColor& end )
959 {
960 
961  myStartColor=start ;
962  myMiddleColor= middle;
963  myEndColor= end;
964  if ( displaySubitemsAsGroup() ) {
965  myGanttView->myTimeTable->inc_blockUpdating();
967  while (temp != 0) {
968  temp->setColors( start, middle, end );
969  temp = temp->nextSibling();
970  }
971  myGanttView->myTimeTable->dec_blockUpdating();
972  }
974 }
975 
976 
985 void KDGanttViewItem::colors( TQColor& start, TQColor& middle, TQColor& end ) const
986 {
987  start = myStartColor ;
988  middle = myMiddleColor;
989  end = myEndColor;
990 
991 }
992 
993 
1011 void KDGanttViewItem::setHighlightColors( const TQColor& start, const TQColor& middle, const TQColor& end )
1012 {
1013  myStartColorHL=start ;
1014  myMiddleColorHL= middle;
1015  myEndColorHL= end;
1016  if ( displaySubitemsAsGroup() ) {
1017  myGanttView->myTimeTable->inc_blockUpdating();
1019  while (temp != 0) {
1020  temp->setHighlightColors( start, middle, end );
1021  temp = temp->nextSibling();
1022  }
1023  myGanttView->myTimeTable->dec_blockUpdating();
1024  }
1026 }
1027 
1028 
1037 void KDGanttViewItem::highlightColors( TQColor& start, TQColor& middle, TQColor& end ) const
1038 {
1039  start = myStartColorHL ;
1040  middle = myMiddleColorHL;
1041  end = myEndColorHL;
1042 }
1043 
1044 
1057 void KDGanttViewItem::setTextColor( const TQColor& color )
1058 {
1059 
1060  myTextColor = color;
1061  if ( displaySubitemsAsGroup() ) {
1062  myGanttView->myTimeTable->inc_blockUpdating();
1064  while (temp != 0) {
1065  temp->setTextColor(color);
1066  temp = temp->nextSibling();
1067  }
1068  myGanttView->myTimeTable->dec_blockUpdating();
1069  }
1071 }
1072 
1073 
1081 {
1082  return myTextColor;
1083 }
1084 
1085 
1108 void KDGanttViewItem::setPixmap( int column, const TQPixmap& pixmap )
1109 {
1110  TQListViewItem::setPixmap( column, pixmap );
1111 }
1112 
1116 void KDGanttViewItem::setPixmap( const TQPixmap& pixmap )
1117 {
1118  TQListViewItem::setPixmap( 0, pixmap );
1119 }
1120 
1121 
1129 const TQPixmap* KDGanttViewItem::pixmap( int column ) const
1130 {
1131  return TQListViewItem::pixmap( column );
1132 }
1133 
1134 
1150 void KDGanttViewItem::setDefaultColor( const TQColor& color )
1151 {
1152  myDefaultColor = color;
1153 
1154 
1155  if ( displaySubitemsAsGroup() ) {
1156  myGanttView->myTimeTable->inc_blockUpdating();
1158  while (temp != 0) {
1159  temp->setDefaultColor( color );
1160  temp = temp->nextSibling();
1161  }
1162  myGanttView->myTimeTable->dec_blockUpdating();
1163  }
1165 }
1166 
1167 
1168 
1177 {
1178  return myDefaultColor;
1179 }
1180 
1181 
1197 void KDGanttViewItem::setDefaultHighlightColor( const TQColor& color )
1198 {
1199  myDefaultColorHL = color;
1200  if ( displaySubitemsAsGroup() ) {
1201  myGanttView->myTimeTable->inc_blockUpdating();
1203  while (temp != 0) {
1204  temp->setDefaultHighlightColor( color );
1205  temp = temp->nextSibling();
1206  }
1207  myGanttView->myTimeTable->dec_blockUpdating();
1208  }
1210 }
1211 
1212 
1221 {
1222  return myDefaultColorHL;
1223 }
1224 
1225 
1232 {
1233 
1234  return (KDGanttViewItem* )TQListViewItem::firstChild();
1235 }
1236 
1237 
1245 {
1246  return (KDGanttViewItem* )TQListViewItem::nextSibling();
1247 }
1248 
1249 
1257 {
1258  return (KDGanttViewItem*)TQListViewItem::parent();
1259 }
1260 
1261 
1268 {
1269  return (KDGanttViewItem* )TQListViewItem::itemAbove();
1270 }
1271 
1272 
1282 {
1283 
1284  KDGanttViewItem* retItem = (KDGanttViewItem* )TQListViewItem::itemBelow();
1285  if ( !includeDisabled ) {
1286  return retItem;
1287  }
1288  if ( retItem ) {
1289  if (itemPos() + height() == retItem->itemPos() ) {
1290  return retItem;
1291  }
1292  }
1293  KDGanttViewItem* Item2 = (KDGanttViewItem* )TQListViewItem::listView()->itemAt(TQPoint (2, TQListViewItem::itemPos() + TQListViewItem::height() +2) );
1294  if ( Item2 != 0 )
1295  if (!Item2->enabled() )
1296  return Item2;
1297  return retItem;
1298 }
1299 
1300 
1305 {
1306  if (blockUpdating) return;
1307  TQPen p,pBack;
1308  TQBrush b;
1309  b.setStyle(TQt::SolidPattern);
1310  if ( enabled() ) {
1311  textCanvas->setColor(myTextColor);
1312  if (isHighlighted) {
1313  b.setStyle(TQt::SolidPattern);
1314  b.setColor(myStartColorHL);
1315  startShape->setBrush(b);
1316  b.setColor(myMiddleColorHL);
1317  midShape->setBrush(b);
1318  b.setColor(myEndColorHL);
1319  endShape->setBrush(b);
1320  p.setWidth(myItemSize/3 -1);
1321  p.setColor(myStartColorHL);
1322  startLine->setPen(p);
1323  p.setColor(myEndColorHL);
1324  endLine->setPen(p);
1325  } else {
1326  b.setStyle(TQt::SolidPattern);
1327  b.setColor(myStartColor);
1328  // tqDebug("update color %s %s", listViewText().latin1(),myStartColor.name().latin1() );
1329  startShape->setBrush(b);
1330  b.setColor(myMiddleColor);
1331  midShape->setBrush(b);
1332  b.setColor(myEndColor);
1333  endShape->setBrush(b);
1334  p.setWidth(myItemSize/3-1);
1335  p.setColor(myStartColor);
1336  startLine->setPen(p);
1337  p.setColor(myEndColor);
1338  endLine->setPen(p);
1339  }
1340  } else {
1341  //TQColor discol = TQt::lightGray;
1342  TQColor discol = TQColor(232,232,232);
1343  textCanvas->setColor( TQColor(150,150,150) );
1344  b.setStyle(TQt::SolidPattern);
1345  b.setColor(discol);
1346  startShape->setBrush(b);
1347  midShape->setBrush(b);
1348  endShape->setBrush(b);
1349  p.setWidth(myItemSize/3 -1);
1350  p.setColor(discol);
1351  startLine->setPen(p);
1352  endLine->setPen(p);
1353  }
1354  pBack.setWidth((myItemSize/3-1)+2);
1355  startLineBack->setPen(pBack);
1356  endLineBack->setPen(pBack);
1357  TQFont f = textCanvas->font();
1358  f.setPixelSize(myItemSize);
1359  textCanvas->setFont(f);
1360  //if (isvisible) {
1361  myGanttView->myTimeTable->updateMyContent();
1362  //}
1363 }
1364 
1365 
1366 void KDGanttViewItem::initItem()
1367 {
1368 }
1369 
1370 
1374 void KDGanttViewItem::setOpen( bool open )
1375 {
1376  if ( _callListViewOnSetOpen ) {
1377  // notify the listview about a programatically called setOpen()
1378  if ( listView () )
1379  listView ()->setOpen( this, open );
1380 
1381  } else {
1382 
1383  TQListViewItem::setOpen( open );
1384  }
1385 }
1386 
1387 
1388 void KDGanttViewItem::showItem( bool, int )
1389 {
1390 }
1391 
1392 
1393 TQPoint KDGanttViewItem::getTaskLinkStartCoord(TQPoint p)
1394 {
1395  textCanvas->move(p.x()+myItemSize, itemPos() + height()/2-myItemSize/2);
1396  return TQPoint (myGanttView->myTimeHeader->getCoordX(myEndTime) +myItemSize/2,itemPos()+height()/2);
1397 }
1398 
1399 
1400 TQPoint KDGanttViewItem::getTaskLinkEndCoord()
1401 {
1402  return TQPoint (myGanttView->myTimeHeader->getCoordX(myStartTime)-myItemSize/2 ,itemPos()-myItemSize/2+height()/2-2);
1403 }
1404 
1405 
1406 void KDGanttViewItem::hideSubtree()
1407 {
1408  if (firstChild())
1409  firstChild()->hideSubtree();
1410  if ( nextSibling () )
1411  nextSibling ()->hideSubtree();
1412  showItem(false);
1413 }
1414 
1415 
1416 void KDGanttViewItem::setCallListViewOnSetOpen( bool call )
1417 {
1418  _callListViewOnSetOpen = call;
1419 }
1420 
1421 
1422 void KDGanttViewItem::initColorAndShapes(Type t)
1423 {
1424  _isMoveable = false;
1425  _isResizeable = false;
1426  setTextOffset(TQPoint(0,0));
1427  //_isCalendar = false;
1428  _callListViewOnSetOpen = true;
1429  myType = t;
1430  myProgress = 0;
1431  progressShape = 0;
1432  floatStartShape = 0;
1433  floatEndShape = 0;
1434  blockUpdating = true;
1435  isVisibleInGanttView = false;
1436  startShape = 0;
1437  midShape = 0;
1438  endShape = 0;
1439  startShapeBack = 0;
1440  midShapeBack = 0;
1441  endShapeBack = 0;
1442 
1443  myItemSize = 10;
1444  myGanttView = ((KDListView *)listView())->myGanttView;
1445  myGanttView->myTimeHeader->saveCenterDateTime();
1446  myStartTime = myGanttView->myTimeHeader->myCenterDateTime;
1448  myToolTipText =TQListViewItem::text(0);
1449  myWhatsThisText = TQListViewItem::text(0);
1450  isHighlighted = false;
1451  isEditable = true;
1452  _displaySubitemsAsGroup = myGanttView->displaySubitemsAsGroup();
1453  startLine = new KDCanvasLine(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);//KDGanttViewItem );
1454  endLine = new KDCanvasLine(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
1455  startLine->setZ(2);endLine->setZ(2);
1456  startLineBack = new KDCanvasLine(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);//KDGanttViewItem );
1457  endLineBack = new KDCanvasLine(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
1458  startLineBack->setZ(1);endLineBack->setZ(1);
1459  actualEnd = new KDCanvasLine(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
1460  actualEnd->setZ(5);
1461  actualEnd->setPen( TQPen ( TQt::red, 3 ) );
1462 
1463  textCanvas = new KDCanvasText(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
1464  textCanvas->setText("");
1465  textCanvas->setZ(10);
1466  // set textcolor
1468  // set default color
1470  // set default highlight color
1472  // set shapes
1473  if (!( shapeDefined = (myGanttView->shapes(myType,myStartShape,myMiddleShape,myEndShape)))) {
1474 
1475  //tqDebug("KDGantt::KDGanttViewItem created with not user defined shapes");
1476  };
1477 
1478  setShapes(myStartShape,myMiddleShape,myEndShape);
1479  if ( type() == Task ) {
1480  //tqDebug("new task %s ", listViewText().latin1());
1481  if ( startShape )
1482  delete startShape;
1483  startShape = (KDCanvasPolygonItem*)new KDCanvasRectangle(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
1484  progressShape = (KDCanvasPolygonItem*)new KDCanvasRectangle(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
1485  }
1486  floatStartShape = (KDCanvasPolygonItem*)new KDCanvasRectangle(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
1487  floatEndShape = (KDCanvasPolygonItem*)new KDCanvasRectangle(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
1488 
1489  // set color of shapes
1490  if (!( colorDefined = (myGanttView->colors(myType,myStartColor,myMiddleColor,myEndColor)))) {
1491 
1492  };
1494  // set highlight color of shapes
1495  if (!( colorHLDefined = (myGanttView->highlightColors(myType,myStartColorHL,myMiddleColorHL,myEndColorHL)))) {
1496 
1497  };
1499  setFont(myGanttView->font());
1500  // if (type() == Task)
1501  //setText(TQListViewItem::text(0)); // testing only
1502  //isvisible = true;
1503  _priority = 150;
1504  _showNoInformation = false;
1505  _enabled = true;
1506  blockUpdating = false;
1508 }
1509 
1510 
1511 TQString KDGanttViewItem::shapeToString( Shape shape )
1512 {
1513  switch( shape ) {
1514  case TriangleDown:
1515  return "TriangleDown";
1516  case TriangleUp:
1517  return "TriangleUp";
1518  case Diamond:
1519  return "Diamond";
1520  case Square:
1521  return "Square";
1522  case Circle:
1523  return "Circle";
1524  }
1525  return "";
1526 }
1527 
1528 
1529 KDGanttViewItem::Shape KDGanttViewItem::stringToShape( const TQString& string )
1530 {
1531  if( string == "TriangleDown" )
1532  return TriangleDown;
1533  else if( string == "TriangleUp" )
1534  return TriangleUp;
1535  else if( string == "Diamond" )
1536  return Diamond;
1537  else if( string == "Square" )
1538  return Square;
1539  else if( string == "Circle" )
1540  return Circle;
1541  else
1542  return TriangleDown;
1543 }
1544 
1545 
1552 void KDGanttViewItem::createNode( TQDomDocument& doc,
1553  TQDomElement& parentElement )
1554 {
1555  TQDomElement itemElement = doc.createElement( "Item" );
1556  parentElement.appendChild( itemElement );
1557  itemElement.setAttribute( "Type", typeToString( type() ) );
1558 
1559  KDGanttXML::createDateTimeNode( doc, itemElement, "StartTime", startTime() );
1560  KDGanttXML::createDateTimeNode( doc, itemElement, "EndTime", endTime() );
1561  KDGanttXML::createFontNode( doc, itemElement, "Font", font() );
1562  KDGanttXML::createStringNode( doc, itemElement, "Text", text() );
1563  KDGanttXML::createStringNode( doc, itemElement, "TooltipText", tooltipText() );
1564  KDGanttXML::createStringNode( doc, itemElement, "WhatsThisText",
1565  whatsThisText() );
1566  if( pixmap() )
1567  KDGanttXML::createPixmapNode( doc, itemElement, "Pixmap", *pixmap() );
1568  if( !listViewText().isNull() )
1569  KDGanttXML::createStringNode( doc, itemElement, "ListViewText",
1570  listViewText() );
1571  KDGanttXML::createBoolNode( doc, itemElement, "Open", isOpen() );
1572  KDGanttXML::createBoolNode( doc, itemElement, "Highlight", highlight() );
1573  Shape startShape, middleShape, endShape;
1574  shapes( startShape, middleShape, endShape );
1575  KDGanttXML::createStringNode( doc, itemElement, "StartShape",
1576  shapeToString( startShape ) );
1577  KDGanttXML::createStringNode( doc, itemElement, "MiddleShape",
1578  shapeToString( middleShape ) );
1579  KDGanttXML::createStringNode( doc, itemElement, "EndShape",
1580  shapeToString( endShape ) );
1581  KDGanttXML::createColorNode( doc, itemElement, "DefaultColor", defaultColor() );
1582  TQColor startColor, middleColor, endColor;
1583  colors( startColor, middleColor, endColor );
1584  KDGanttXML::createColorNode( doc, itemElement, "StartColor", startColor );
1585  KDGanttXML::createColorNode( doc, itemElement, "MiddleColor", middleColor );
1586  KDGanttXML::createColorNode( doc, itemElement, "EndColor", endColor );
1587  KDGanttXML::createColorNode( doc, itemElement, "DefaultHighlightColor",
1589  highlightColors( startColor, middleColor, endColor );
1590  KDGanttXML::createColorNode( doc, itemElement, "StartHighlightColor",
1591  startColor );
1592  KDGanttXML::createColorNode( doc, itemElement, "MiddleHighlightColor",
1593  middleColor );
1594  KDGanttXML::createColorNode( doc, itemElement, "EndHighlightColor", endColor );
1595  KDGanttXML::createColorNode( doc, itemElement, "TextColor", textColor() );
1596  KDGanttXML::createStringNode( doc, itemElement, "Name", name() );
1597  TQDomElement itemsElement = doc.createElement( "Items" );
1598  itemElement.appendChild( itemsElement );
1599  KDGanttViewItem* currentItem = firstChild();
1600  while( currentItem ) {
1601  currentItem->createNode( doc, itemsElement );
1602  currentItem = currentItem->nextSibling();
1603  }
1604 
1605 }
1606 
1607 
1608 
1618  TQDomElement& element )
1619 {
1620  TQString typeString = element.attribute( "Type" );
1621  Q_ASSERT( !typeString.isEmpty() );
1622  KDGanttViewItem* item;
1623  if( typeString == "Task" )
1624  item = new KDGanttViewTaskItem( view );
1625  else if( typeString == "Summary" )
1626  item = new KDGanttViewSummaryItem( view );
1627  else if( typeString == "Event" )
1628  item = new KDGanttViewEventItem( view );
1629  else {
1630  tqDebug( "Unknown item type %s in KDGanttViewItem::createFromDomElement()", typeString.latin1() );
1631  return 0;
1632  }
1633 
1634  item->loadFromDomElement( element );
1635  return item;
1636 }
1637 
1638 
1649  KDGanttViewItem* previous,
1650  TQDomElement& element )
1651 {
1652  TQString typeString = element.attribute( "Type" );
1653  Q_ASSERT( !typeString.isEmpty() );
1654  KDGanttViewItem* item;
1655  if( typeString == "Task" )
1656  item = new KDGanttViewTaskItem( view, previous );
1657  else if( typeString == "Summary" )
1658  item = new KDGanttViewSummaryItem( view, previous );
1659  else if( typeString == "Event" )
1660  item = new KDGanttViewEventItem( view, previous );
1661  else {
1662  tqDebug( "Unknown item type in KDGanttViewItem::createFromDomElement()" );
1663  return 0;
1664  }
1665 
1666  item->loadFromDomElement( element );
1667  return item;
1668 }
1669 
1670 
1671 
1672 
1682  TQDomElement& element )
1683 {
1684  TQString typeString = element.attribute( "Type" );
1685  Q_ASSERT( !typeString.isEmpty() );
1686  KDGanttViewItem* item;
1687  if( typeString == "Task" )
1688  item = new KDGanttViewTaskItem( parent );
1689  else if( typeString == "Summary" )
1690  item = new KDGanttViewSummaryItem( parent );
1691  else if( typeString == "Event" )
1692  item = new KDGanttViewEventItem( parent );
1693  else {
1694  tqDebug( "Unknown item type in KDGanttViewItem::createFromDomElement()" );
1695  return 0;
1696  }
1697 
1698  item->loadFromDomElement( element );
1699  return item;
1700 }
1701 
1702 
1713  KDGanttViewItem* previous,
1714  TQDomElement& element )
1715 {
1716  TQString typeString = element.attribute( "Type" );
1717  Q_ASSERT( !typeString.isEmpty() );
1718  KDGanttViewItem* item;
1719  if( typeString == "Task" )
1720  item = new KDGanttViewTaskItem( parent, previous );
1721  else if( typeString == "Summary" )
1722  item = new KDGanttViewSummaryItem( parent, previous );
1723  else if( typeString == "Event" )
1724  item = new KDGanttViewEventItem( parent, previous );
1725  else {
1726  tqDebug( "Unknown item type in KDGanttViewItem::createFromDomElement()" );
1727  return 0;
1728  }
1729 
1730  item->loadFromDomElement( element );
1731  return item;
1732 }
1733 
1734 
1735 /*
1736  Fills in the values in the item by reading the DOM element.
1737 */
1738 void KDGanttViewItem::loadFromDomElement( TQDomElement& element )
1739 {
1740  TQDomNode node = element.firstChild();
1741  Shape startShape = TriangleDown, middleShape = TriangleDown,
1742  endShape = TriangleDown;
1743  TQColor startColor, middleColor, endColor;
1744  TQColor startHighlightColor, middleHighlightColor, endHighlightColor;
1745  TQString tempName;
1746  while( !node.isNull() ) {
1747  TQDomElement element = node.toElement();
1748  if( !element.isNull() ) { // was really an element
1749  TQString tagName = element.tagName();
1750  if( tagName == "StartTime" ) {
1751  TQDateTime value;
1752  if( KDGanttXML::readDateTimeNode( element, value ) )
1753  setStartTime( value );
1754  } else if( tagName == "EndTime" ) {
1755  TQDateTime value;
1756  if( KDGanttXML::readDateTimeNode( element, value ) )
1757  setEndTime( value );
1758  } else if( tagName == "Text" ) {
1759  TQString value;
1760  if( KDGanttXML::readStringNode( element, value ) )
1761  setText( value );
1762  } else if( tagName == "Font" ) {
1763  TQFont value;
1764  if( KDGanttXML::readFontNode( element, value ) )
1765  setFont( value );
1766  } else if( tagName == "TooltipText" ) {
1767  TQString value;
1768  if( KDGanttXML::readStringNode( element, value ) )
1769  setTooltipText( value );
1770  } else if( tagName == "WhatsThisText" ) {
1771  TQString value;
1772  if( KDGanttXML::readStringNode( element, value ) )
1773  setWhatsThisText( value );
1774  } else if( tagName == "Pixmap" ) {
1775  TQPixmap value;
1776  if( KDGanttXML::readPixmapNode( element, value ) )
1777  setPixmap( value );
1778  } else if( tagName == "ListViewText" ) {
1779  TQString value;
1780  if( KDGanttXML::readStringNode( element, value ) )
1781  setListViewText( value );
1782  } else if( tagName == "Open" ) {
1783  bool value;
1784  if( KDGanttXML::readBoolNode( element, value ) )
1785  setOpen( value );
1786  } else if( tagName == "Highlight" ) {
1787  bool value;
1788  if( KDGanttXML::readBoolNode( element, value ) )
1789  setHighlight( value );
1790  } else if( tagName == "StartShape" ) {
1791  TQString value;
1792  if( KDGanttXML::readStringNode( element, value ) )
1793  startShape = stringToShape( value );
1794  } else if( tagName == "MiddleShape" ) {
1795  TQString value;
1796  if( KDGanttXML::readStringNode( element, value ) )
1797  middleShape = stringToShape( value );
1798  } else if( tagName == "EndShape" ) {
1799  TQString value;
1800  if( KDGanttXML::readStringNode( element, value ) )
1801  endShape = stringToShape( value );
1802  } else if( tagName == "DefaultColor" ) {
1803  TQColor value;
1804  if( KDGanttXML::readColorNode( element, value ) )
1805  setDefaultColor( value );
1806  } else if( tagName == "StartColor" ) {
1807  TQColor value;
1808  if( KDGanttXML::readColorNode( element, value ) )
1809  startColor = value;
1810  } else if( tagName == "MiddleColor" ) {
1811  TQColor value;
1812  if( KDGanttXML::readColorNode( element, value ) )
1813  middleColor = value;
1814  } else if( tagName == "EndColor" ) {
1815  TQColor value;
1816  if( KDGanttXML::readColorNode( element, value ) )
1817  endColor = value;
1818  } else if( tagName == "DefaultHighlightColor" ) {
1819  TQColor value;
1820  if( KDGanttXML::readColorNode( element, value ) )
1821  setDefaultHighlightColor( value );
1822  } else if( tagName == "StartHighlightColor" ) {
1823  TQColor value;
1824  if( KDGanttXML::readColorNode( element, value ) )
1825  startHighlightColor = value;
1826  } else if( tagName == "MiddleHighlightColor" ) {
1827  TQColor value;
1828  if( KDGanttXML::readColorNode( element, value ) )
1829  middleHighlightColor = value;
1830  } else if( tagName == "EndHighlightColor" ) {
1831  TQColor value;
1832  if( KDGanttXML::readColorNode( element, value ) )
1833  endHighlightColor = value;
1834  } else if( tagName == "TextColor" ) {
1835  TQColor value;
1836  if( KDGanttXML::readColorNode( element, value ) )
1837  setTextColor( value );
1838  } else if( tagName == "Name" ) {
1839  TQString value;
1840  if( KDGanttXML::readStringNode( element, value ) )
1841  tempName = value;
1842  } else if( tagName == "Items" ) {
1843  TQDomNode node = element.firstChild();
1844  KDGanttViewItem* previous = 0;
1845  while( !node.isNull() ) {
1846  TQDomElement element = node.toElement();
1847  if( !element.isNull() ) { // was really an element
1848  TQString tagName = element.tagName();
1849  if( tagName == "Item" ) {
1850  KDGanttViewItem* newItem;
1851  if( previous )
1852  newItem =
1854  previous,
1855  element );
1856  else
1857  newItem =
1859  element );
1860  previous = newItem;
1861  } else {
1862  tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
1863  Q_ASSERT( false );
1864  }
1865  }
1866 
1867  node = node.nextSibling();
1868  }
1869  } else {
1870  tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
1871  Q_ASSERT( false );
1872  }
1873  }
1874 
1875  node = node.nextSibling();
1876  }
1877 
1878  setColors( startColor, middleColor, endColor );
1879  setHighlightColors( startHighlightColor, middleHighlightColor,
1880  endHighlightColor );
1881  setShapes( startShape, middleShape, endShape );
1882  generateAndInsertName( tempName );
1883 }
1884 
1885 
1886 TQString KDGanttViewItem::typeToString( Type type )
1887 {
1888  switch( type ) {
1889  case Event:
1890  return "Event";
1891  case Summary:
1892  return "Summary";
1893  case Task:
1894  return "Task";
1895  default:
1896  tqDebug( "Unknown type in KDGanttViewItem::typeToString()" );
1897  return "Summary";
1898  }
1899  return "";
1900 }
1901 
1902 
1909 {
1910  return itemPos() + height()/2;
1911 }
1912 
1913 
1914 void KDGanttViewItem::showSubItems()
1915 {
1916  showSubitemTree( getCoordY() );
1917 }
1918 
1919 
1920 void KDGanttViewItem::showSubitemTree( int CoordY )
1921 {
1922 
1923  KDGanttViewItem* temp = firstChild();
1924  if (temp) {
1925  while (temp != 0) {
1926  if (temp->isOpen() || !temp->displaySubitemsAsGroup() ) {
1927  temp->showItem( true, CoordY );
1928  if ( temp->firstChild() )
1929  temp->firstChild()->hideSubtree();
1930  } else {
1931  if ( temp->displaySubitemsAsGroup() && temp->firstChild() )
1932  temp->hideSubtree();
1933  else {
1934  temp->showSubitemTree( CoordY );
1935  }
1936  }
1937  temp = temp->nextSibling();
1938  }
1939  showItem( false );
1940  } else {
1941  showItem( true, CoordY );
1942  }
1943 }
1944 
1945 
1952 {
1953  TQDateTime ret, tempTime;
1954  bool set = true;
1956  if (temp) {
1957  while (temp != 0) {
1958  if ( !temp->displaySubitemsAsGroup() ) {
1959  tempTime = temp->startTime();
1960  } else {
1961  tempTime = temp->myChildStartTime();
1962  }
1963  if ( set ) {
1964  set = false;
1965  ret = tempTime;
1966  } else {
1967  if ( tempTime < ret ) {
1968  ret = tempTime;
1969  }
1970  }
1971  temp = temp->nextSibling();
1972  }
1973  } else {
1974  ret = startTime();
1975  }
1976  return ret;
1977 }
1978 
1979 
1986 {
1987  TQDateTime ret, tempTime;
1988  bool set = true;
1990  if (temp) {
1991  while (temp != 0) {
1992  if ( !temp->displaySubitemsAsGroup() ) {
1993  tempTime = temp->endTime();
1994  } else {
1995  tempTime = temp->myChildEndTime();
1996  }
1997  if ( set ) {
1998  set = false;
1999  ret = tempTime;
2000  } else {
2001  if ( tempTime > ret ) {
2002  ret = tempTime;
2003  }
2004  }
2005  temp = temp->nextSibling();
2006  }
2007  } else {
2008  ret = endTime();
2009  }
2010  return ret;
2011 }
2012 
2013 
2021 {
2022  return _showNoInformation;
2023 }
2024 
2025 
2038 {
2039  _showNoInformation = show;
2040  myGanttView->myTimeTable->updateMyContent();
2041 }
2042 
2043 
2053 {
2054  if ( listViewText() == name )
2055  return this;
2056  KDGanttViewItem* temp = firstChild(),* ret;
2057  while (temp != 0) {
2058  if ( (ret = temp->getChildByName( name )))
2059  return ret;
2060  temp = temp->nextSibling();
2061  }
2062  return 0;
2063 }
2064 
2065 
2066 /*
2067 void KDGanttViewItem::printinfo( TQString s )
2068 {
2069  KDGanttViewItem* temp = firstChild();
2070  while (temp != 0) {
2071  temp->printinfo(" "+s );
2072  temp = temp->nextSibling();
2073  }
2074 }
2075 */
2076 
2077 
2086 {
2087  KDGanttViewItem* temp = firstChild();
2088  bool ret = false;
2089  while (temp) {
2090  if (temp->firstChild() || temp->displaySubitemsAsGroup() ) {
2091  ret = true;
2092  break;
2093  }
2094  temp = temp->nextSibling();
2095  }
2096  return ret;
2097 }
2098 
2099 
2100 int KDGanttViewItem::computeHeight()
2101 {
2102  int hei = 0;
2103  // if not visible, hide item and all subitems, return height = 0
2104  if ( !isVisible() ) {
2105  showItem( false );
2106  if ( firstChild() )
2107  firstChild()->hideSubtree();
2108  // tqDebug("KDGanttViewItem::computeHeight() %s returns 0 ", TQListViewItem::text(0).latin1());
2109  return 0;
2110  }
2111 
2112  KDGanttViewItem* temp;
2113  bool show = true;
2114 
2115  // explanation of terms:
2116  // display opened item as usual:
2117  // display this item opened, display Gantt part on the timeline of this item.
2118  // the same for all subitems: display all subitems on its own timeline
2119  // display closed item as usual:
2120  // display this item closed, display Gantt part on the timeline of this item.
2121  // do not display any subitem.
2122 
2123  // desired behaviour:
2124  // if not in calendar mode( GanttView is NOT in calendar mode ):
2125  // opened:
2126  // display opened item as usual
2127  // closed:
2128  // if not displaySubitemsAsGroup()
2129  // display closed item as usual
2130  // else ( displaySubitemsAsGroup() == true )
2131  // display not this item, display subitems on the timeline of this item
2132  // else ( GanttView is in calendar mode )
2133  // 4 cases:
2134  // opened && displaySubitemsAsGroup():
2135  // display not this item, display subitems on the timeline of this item,
2136  // which have the property displaySubitemsAsGroup() == false
2137  // display the other items,
2138  // which have the property displaySubitemsAsGroup() == true,
2139  // as usual below this item on their own timeline
2140  // opened && NOT displaySubitemsAsGroup():
2141  // display opened item as usual
2142  // closed && displaySubitemsAsGroup():
2143  // display not this item, display subitems on the timeline of this item,
2144  // which have the property displaySubitemsAsGroup() == false
2145  // closed && NOT displaySubitemsAsGroup():
2146  // display closed item as usual
2147  //
2148  if ( isOpen() ) {
2149  //tqDebug("KDGanttViewItem::computeHeight() %s is open ", TQListViewItem::text(0).latin1());
2150  temp = firstChild();
2151  // if item opened, iterate over all subitems
2152  int tempHeight;
2153  // introduced special for performance reasons
2154  bool special = displaySubitemsAsGroup() && myGanttView->calendarMode();
2155  while (temp != 0) {
2156  tempHeight = temp->computeHeight();
2157  if ( special ) {
2158  if ( temp->displaySubitemsAsGroup() ) {
2159  hei += tempHeight;
2160  //tqDebug(" hei added ");
2161  } else {
2162  temp->showSubitemTree( getCoordY() );
2163 
2164  }
2165  } else {
2166  hei += tempHeight;
2167  //tqDebug(" hei added ");
2168  }
2169  temp = temp->nextSibling();
2170  }
2171  } else { // closed!
2172  //tqDebug("KDGanttViewItem::computeHeight() %s is closed ", TQListViewItem::text(0).latin1());
2173 
2174  if ( !displaySubitemsAsGroup() ) {
2175  if ( firstChild() ) {
2176  firstChild()->hideSubtree();
2177  }
2178  } else {
2179  if ( firstChild() ) {
2180  showSubitemTree( getCoordY() );
2181  show = false ;
2182  }
2183  }
2184 
2185  }
2186  if ( show )
2187  showItem( true );
2188 
2189  hei += height();
2190  //tqDebug("KDGanttViewItem::computeHeight() %s returns: %d ", TQListViewItem::text(0).latin1(), hei);
2191  return hei;
2192 }
2193 
2194 
2195 // if this item has at least one subitem which has the property displaySubitemsAsGroup(),
2196 // a false is returned
2197 bool KDGanttViewItem::showNoCross()
2198 {
2199  KDGanttViewItem * temp = firstChild();
2200  if ( !temp )
2201  return false;
2202  while ( temp ) {
2203  if ( temp->displaySubitemsAsGroup() ) {
2204  return false;
2205  }
2206  temp = temp->nextSibling();
2207  }
2208  return true;
2209 }
2210 
2211 
2212 void KDGanttViewItem::paintBranches ( TQPainter* p, const TQColorGroup& cg,
2213  int w, int y, int h )
2214 {
2215  TQListViewItem::paintBranches ( p, cg, w, y, h);
2216  if ( !myGanttView->calendarMode() )
2217  return;
2218  else {
2219  KDGanttViewItem * temp = firstChild();
2220  while ( temp ) {
2221  if ( temp->showNoCross() ) {
2222  //tqDebug("paintNoCross %s ", temp->listViewText(0).latin1());
2223  int y_coord = temp->itemPos() -height ()- itemPos();
2224  int hei = temp->height();
2225  //tqDebug(" y %d w %d h %d ", y,w,h);
2226  //tqDebug("yc %d hei %d",y_coord,hei );
2227  myGanttView->myListView->paintemptyarea( p, TQRect( 0,y+y_coord,w,hei));
2228  int x_c = w/2;
2229  int y_c = y+y_coord+ temp->height ()/2;
2230  int y_ce ;
2231  if ( temp->itemBelow() && temp->itemBelow()->parent() == this )
2232  y_ce =y+y_coord+ temp->height ();
2233  else
2234  y_ce = y_c;
2235  int i;
2236  for (i = y+y_coord+1; i <= y_ce; i+=2 ) {
2237  p->drawPoint( x_c, i );
2238  }
2239  for (i = x_c+2; i < w; i+=2 ) {
2240  p->drawPoint( i, y_c );
2241  }
2242  }
2243  temp = temp->nextSibling();
2244  }
2245  }
2246 }
2247 
2248 
2249 // resets the visibility os the subitems according to the setting of calendar mode
2250 void KDGanttViewItem::resetSubitemVisibility()
2251 {
2252  KDGanttViewItem* temp;
2253  temp = firstChild();
2254  bool allow = false;
2255  if ( myGanttView->calendarMode() ) {
2256  // in calendarmode only items can be opened which have subitems which have subitems
2257  if ( ! temp ) {
2258  if ( !parent() )
2259  // has no parent, has no child : show!
2260  setVisible( true );
2261  else
2262  // has parent, has no child : hide!
2263  setVisible( false );
2264  return;
2265  }
2266  setVisible( true );
2267  while (temp) {
2268  if (temp->firstChild()) {
2269  allow = true;
2270  temp->resetSubitemVisibility();
2271  }
2272  else {
2273  temp->setVisible(false);
2274  }
2275  temp = temp->nextSibling();
2276  }
2277  } else {
2278  setVisible( true );
2279  // all items can be opened
2280  allow = true;
2281  while (temp != 0) {
2282  temp->resetSubitemVisibility();
2283  temp = temp->nextSibling();
2284  }
2285  }
2286  if ( !allow && isOpen() )
2287  setOpen( false );
2288 
2289 }
2290 
2291 
2309 /* removed
2310 void KDGanttViewItem::setIsCalendar( bool cal )
2311 {
2312  _isCalendar = cal;
2313  updateCanvasItems();
2314 }
2315 */
2316 
2325 /* removed
2326 bool KDGanttViewItem::isCalendar( ) const
2327 {
2328  return _isCalendar;
2329 }
2330 */
2331 
2332 
2468 TQPoint KDGanttViewItem::middleLeft()
2469 {
2470  return TQPoint(myGanttView->myTimeHeader->getCoordX(myStartTime), itemPos()+height()/2);
2471 }
2475 TQPoint KDGanttViewItem::middleRight()
2476 {
2477  return TQPoint(myGanttView->myTimeHeader->getCoordX(myEndTime), itemPos()+height()/2);
2478 }
2483 {
2484  int mx = x + myTextOffset.x();
2485  int my = y + myTextOffset.y();
2486  if (myTextOffset.x() != 0)
2487  mx -= 2*myItemSize; // keep old behaviour
2488 
2489  textCanvas->move(mx+2*myItemSize,my-myItemSize/2);
2490  //tqDebug("%s: moveTextCanvas(%d,%d) offset: %d,%d moved to %d,%d",listViewText(0).latin1(),x,y,myTextOffset.x(),myTextOffset.y(),mx+2*myItemSize,my-myItemSize/2);
2491 }
2492 
2497 void KDGanttViewItem::moveTextCanvas()
2498 {
2499  TQPoint m = myTextOffset+middleRight();
2500  textCanvas->move(m.x(), m.y()-myItemSize/2);
2501 }
2502 
2506 void KDGanttViewItem::setTextOffset(TQPoint p)
2507 {
2508  //tqDebug("%s: setTextOffset() offset: %d,%d",listViewText(0).latin1(),p.x(),p.y());
2509  myTextOffset.setX(p.x());
2510  myTextOffset.setY(p.y());
2511 }
2512 
2513 bool KDGanttViewItem::isMyTextCanvas(TQCanvasItem *tc)
2514 {
2515  return tc == textCanvas;
2516 }
2517 
2526 {
2527  myProgress = TQMAX(0, percent);
2528  myProgress = TQMIN(100, myProgress);
2529 }
2530 
2537 void KDGanttViewItem::setFloatStartTime(const TQDateTime &start)
2538 {
2539  myFloatStartTime = start;
2540 }
2541 
2548 void KDGanttViewItem::setFloatEndTime(const TQDateTime &end)
2549 {
2550  myFloatEndTime = end;
2551 }
2552 
2553 void KDGanttViewItem::setMoveable(bool m)
2554 {
2555  _isMoveable = m;
2556 }
2557 
2558 bool KDGanttViewItem::isMoveable() const
2559 {
2560  return _isMoveable;
2561 }
2562 
2563 bool KDGanttViewItem::isResizeable() const
2564 {
2565  return _isResizeable;
2566 }
2567 
2568 void KDGanttViewItem::setResizeable(bool r)
2569 {
2570  _isResizeable = r;
2571 }
void setTextColor(const TQColor &color)
KDCanvasPolygonItem * midShapeBack
TQString listViewText(int column=0) const
TQColor defaultColor() const
void setFont(const TQFont &font)
void setTooltipText(const TQString &text)
KDCanvasLine * endLine
KDCanvasText * textCanvas
TQString textCanvasText
void setText(const TQString &text)
KDGanttViewItem * getChildByName(const TQString &name)
void setItemVisible(bool on)
const TQPixmap * pixmap(int column=0) const
void setShowNoInformation(bool show)
KDGanttViewItem * itemBelow(bool includeDisabled=true)
TQFont font() const
KDCanvasPolygonItem * startShape
KDCanvasPolygonItem * midShape
virtual void setEndTime(const TQDateTime &end)
TQDateTime myStartTime
void moveTextCanvas(int x, int y)
void setPriority(int prio)
KDGanttViewItem * itemAbove()
virtual void setStartTime(const TQDateTime &start)
void setHighlight(bool)
void setEditable(bool editable)
void generateAndInsertName(const TQString &name)
static KDGanttViewItem * find(const TQString &name)
KDCanvasLine * actualEnd
KDCanvasPolygonItem * endShapeBack
KDCanvasLine * endLineBack
void setEnabled(bool on)
TQString whatsThisText() const
void setColors(const TQColor &start, const TQColor &middle, const TQColor &end)
void createNode(TQDomDocument &doc, TQDomElement &parentElement)
KDCanvasPolygonItem * startShapeBack
KDGanttViewItem * nextSibling() const
KDGanttViewItem * parent() const
TQDateTime myChildStartTime()
TQDateTime endTime() const
bool enabled() const
TQString tooltipText() const
KDGanttView * myGanttView
bool editable() const
bool itemVisible() const
KDCanvasLine * startLineBack
TQColor defaultHighlightColor() const
void setFloatStartTime(const TQDateTime &start)
void highlightColors(TQColor &start, TQColor &middle, TQColor &end) const
TQString text() const
void setPixmap(int column, const TQPixmap &pixmap)
static KDGanttViewItem * createFromDomElement(KDGanttView *view, TQDomElement &element)
void setProgress(int percent)
void setShapes(Shape start, Shape middle, Shape end)
void colors(TQColor &start, TQColor &middle, TQColor &end) const
void setFloatEndTime(const TQDateTime &end)
void setDisplaySubitemsAsGroup(bool show)
bool displaySubitemsAsGroup() const
KDGanttViewItem * firstChild() const
TQDateTime myEndTime
void setDefaultColor(const TQColor &)
KDCanvasLine * startLine
void setHighlightColors(const TQColor &start, const TQColor &middle, const TQColor &end)
void setListViewText(const TQString &text, int column=0)
TQColor textColor() const
TQDateTime myChildEndTime()
TQDateTime startTime() const
bool subitemIsCalendar() const
TQString name() const
KDGanttViewItem(Type type, KDGanttView *view, const TQString &lvtext=TQString(), const TQString &name=TQString())
void setWhatsThisText(const TQString &text)
KDCanvasPolygonItem * endShape
bool highlight() const
void shapes(Shape &start, Shape &middle, Shape &end) const
void setDefaultHighlightColor(const TQColor &)
virtual void setOpen(bool o)
virtual ~KDGanttViewItem()
bool colors(KDGanttViewItem::Type type, TQColor &start, TQColor &middle, TQColor &end) const
bool calendarMode() const
bool highlightColors(KDGanttViewItem::Type type, TQColor &start, TQColor &middle, TQColor &end) const
TQColor defaultHighlightColor(KDGanttViewItem::Type type) const
TQColor defaultColor(KDGanttViewItem::Type type) const
bool shapes(KDGanttViewItem::Type type, KDGanttViewItem::Shape &start, KDGanttViewItem::Shape &middle, KDGanttViewItem::Shape &end) const
TQColor textColor() const
bool displaySubitemsAsGroup() const