35 #include "KDGanttViewTaskLink.h"
36 #include "KDGanttViewTaskLinkGroup.h"
37 #include "KDGanttViewSubwidgets.h"
38 #include "KDGanttXMLTools.h"
66 TQPtrList<KDGanttViewItem> to,
92 fromList.append(
from);
112 TQPtrList<KDGanttViewItem> from,
113 TQPtrList<KDGanttViewItem> to,
143 fromList.append(
from);
152 KDGanttViewTaskLink::~KDGanttViewTaskLink( )
155 myTimeTable->myTaskLinkList.remove(
this);
167 void KDGanttViewTaskLink::initTaskLink()
169 horLineList =
new TQPtrList<KDCanvasLine>;
170 verLineList =
new TQPtrList<KDCanvasLine>;
171 horLineList2 =
new TQPtrList<KDCanvasLine>;
172 verLineList2 =
new TQPtrList<KDCanvasLine>;
173 horLineList3 =
new TQPtrList<KDCanvasLine>;
174 topList =
new TQPtrList<KDCanvasPolygon>;
175 topLeftList =
new TQPtrList<KDCanvasPolygon>;
176 topRightList =
new TQPtrList<KDCanvasPolygon>;
177 horLineList->setAutoDelete(
true );
178 verLineList->setAutoDelete(
true );
179 horLineList2->setAutoDelete(
true );
180 verLineList2->setAutoDelete(
true );
181 horLineList3->setAutoDelete(
true );
182 topList->setAutoDelete(
true );
183 topLeftList->setAutoDelete(
true );
184 topRightList->setAutoDelete(
true );
185 myTimeTable = fromList.getFirst()->myGanttView->myTimeTable;
186 KDCanvasLine* horLine,*verLine;
187 KDCanvasLine* horLine2,*verLine2;
188 KDCanvasLine* horLine3;
189 KDCanvasPolygon* top;
190 KDCanvasPolygon* topLeft;
191 KDCanvasPolygon* topRight;
193 for ( i = 0;i < fromList.count();++i) {
194 for ( j = 0;j < toList.count();++j) {
195 horLine =
new KDCanvasLine(myTimeTable,
this,Type_is_KDGanttTaskLink);
196 verLine =
new KDCanvasLine(myTimeTable,
this,Type_is_KDGanttTaskLink);
197 horLine2 =
new KDCanvasLine(myTimeTable,
this,Type_is_KDGanttTaskLink);
198 verLine2 =
new KDCanvasLine(myTimeTable,
this,Type_is_KDGanttTaskLink);
199 horLine3 =
new KDCanvasLine(myTimeTable,
this,Type_is_KDGanttTaskLink);
200 top =
new KDCanvasPolygon(myTimeTable,
this,Type_is_KDGanttTaskLink);
201 topLeft =
new KDCanvasPolygon(myTimeTable,
this,Type_is_KDGanttTaskLink);
202 topRight =
new KDCanvasPolygon(myTimeTable,
this,Type_is_KDGanttTaskLink);
203 TQPointArray arr = TQPointArray(3);
204 arr.setPoint(0,-4,-5);
205 arr.setPoint(1,4,-5);
208 arr.setPoint(0,5,-5);
211 topLeft->setPoints(arr);
212 arr.setPoint(0,-5,-4);
213 arr.setPoint(1,-5,4);
215 topRight->setPoints(arr);
216 horLineList->append(horLine);
217 verLineList->append(verLine);
218 horLineList2->append(horLine2);
219 verLineList2->append(verLine2);
220 horLineList3->append(horLine3);
221 topList->append(top);
222 topLeftList->append(topLeft);
223 topRightList->append(topRight);
237 myTimeTable->myTaskLinkList.append(
this);
256 myTimeTable->updateMyContent();
258 void KDGanttViewTaskLink::showMe(
bool visible )
260 if (linkType() != None) {
271 b.setStyle(TQt::SolidPattern);
273 b.setColor(myColorHL);
274 p.setColor(myColorHL);
281 TQPtrListIterator<KDCanvasLine> horIt(*horLineList);
282 TQPtrListIterator<KDCanvasLine> verIt(*verLineList);
283 TQPtrListIterator<KDCanvasPolygon> topIt(*topList);
284 TQPtrListIterator<KDGanttViewItem> fromIt(fromList);
285 TQPtrListIterator<KDGanttViewItem> toIt(toList);
286 for ( ; fromIt.current(); ++fromIt ) {
287 (*fromIt)->setTextOffset(TQPoint(0,0));
289 for ( ; toIt.current(); ++toIt ) {
290 (*toIt)->setTextOffset(TQPoint(0,0));
291 if (!isvisible || ! (*fromIt)->isVisibleInGanttView || !(*toIt)->isVisibleInGanttView || !myTimeTable->taskLinksVisible) {
301 (*topIt)->setBrush(b);
302 end = (*toIt)->getTaskLinkEndCoord();
303 start = (*fromIt)->getTaskLinkStartCoord(end);
304 (*horIt)->setPoints(start.x(),start.y(),end.x()+wid,start.y());
305 (*verIt)->setPoints(end.x()+wid/2,start.y(),end.x()+wid/2,end.y()-2);
306 (*topIt)->move(end.x()+wid/2,end.y());
317 while ( horIt.current() ) {
327 void KDGanttViewTaskLink::showMeType(
bool visible )
336 b.setStyle(TQt::SolidPattern);
338 b.setColor(myColorHL);
339 p.setColor(myColorHL);
346 TQPtrListIterator<KDCanvasLine> horIt(*horLineList);
347 TQPtrListIterator<KDCanvasLine> verIt(*verLineList);
348 TQPtrListIterator<KDCanvasLine> horIt2(*horLineList2);
349 TQPtrListIterator<KDCanvasLine> verIt2(*verLineList2);
350 TQPtrListIterator<KDCanvasLine> horIt3(*horLineList3);
351 TQPtrListIterator<KDCanvasPolygon> topIt(*topList);
352 TQPtrListIterator<KDCanvasPolygon> topLeftIt(*topLeftList);
353 TQPtrListIterator<KDCanvasPolygon> topRightIt(*topRightList);
354 TQPtrListIterator<KDGanttViewItem> fromIt(fromList);
355 TQPtrListIterator<KDGanttViewItem> toIt(toList);
356 for ( ; fromIt.current(); ++fromIt ) {
357 (*fromIt)->setTextOffset(TQPoint(30,0));
358 (*fromIt)->moveTextCanvas();
360 for ( ; toIt.current(); ++toIt ) {
361 if (isvisible && (*fromIt)->isVisibleInGanttView &&
362 (*toIt)->isVisibleInGanttView && myTimeTable->taskLinksVisible) {
365 (*horIt2)->setPen(p);
366 (*verIt2)->setPen(p);
367 (*horIt3)->setPen(p);
368 (*topIt)->setBrush(b);
369 (*topLeftIt)->setBrush(b);
370 (*topRightIt)->setBrush(b);
371 (*toIt)->setTextOffset(TQPoint(30,0));
372 (*toIt)->moveTextCanvas();
373 switch (linkType()) {
375 start = (*fromIt)->middleLeft();
376 end = (*toIt)->middleLeft()-TQPoint(12,0);
377 bool down = start.y() < end.y();
378 (*horIt)->setPoints(start.x()-xOffset(*fromIt),start.y(),
379 start.x()-10, start.y());
381 (*horIt)->endPoint().x(),
382 (*horIt)->endPoint().y(),
383 (*horIt)->endPoint().x(),
384 (down ? (*toIt)->itemPos()+1
385 : (*toIt)->itemPos()+(*toIt)->height()-1));
386 (*horIt2)->setPoints((*verIt)->endPoint().x(),
387 (*verIt)->endPoint().y(),
389 (*verIt)->endPoint().y());
390 (*verIt2)->setPoints((*horIt2)->endPoint().x(),
391 (*horIt2)->endPoint().y(),
392 (*horIt2)->endPoint().x(),
394 (*horIt3)->setPoints((*verIt2)->endPoint().x(),
395 (*verIt2)->endPoint().y(),
398 (*topRightIt)->move(end.x(),end.y());
399 (*topRightIt)->show();
403 start = (*fromIt)->middleRight();
404 end = (*toIt)->middleRight()+TQPoint(12,0);
405 bool down = start.y() < end.y();
406 (*horIt)->setPoints(start.x()+xOffset(*fromIt),start.y(),
407 start.x()+10, start.y());
409 (*horIt)->endPoint().x(),
410 (*horIt)->endPoint().y(),
411 (*horIt)->endPoint().x(),
412 (down ? (*toIt)->itemPos()+1
413 : (*toIt)->itemPos()+(*toIt)->height()-1));
414 (*horIt2)->setPoints((*verIt)->endPoint().x(),
415 (*verIt)->endPoint().y(),
417 (*verIt)->endPoint().y());
418 (*verIt2)->setPoints((*horIt2)->endPoint().x(),
419 (*horIt2)->endPoint().y(),
420 (*horIt2)->endPoint().x(),
422 (*horIt3)->setPoints((*verIt2)->endPoint().x(),
423 (*verIt2)->endPoint().y(),
426 (*topLeftIt)->move(end.x(),end.y());
427 (*topLeftIt)->show();
431 start = (*fromIt)->middleRight();
432 end = (*toIt)->middleLeft() - TQPoint(12,0);
433 bool down = start.y() < end.y();
434 (*horIt)->setPoints(start.x()+xOffset(*fromIt),start.y(),
435 start.x()+10,start.y());
437 (*horIt)->endPoint().x(),
438 (*horIt)->endPoint().y(),
439 (*horIt)->endPoint().x(),
440 (down ? (*toIt)->itemPos()+1
441 : (*toIt)->itemPos()+(*toIt)->height()-1));
442 (*horIt2)->setPoints((*verIt)->endPoint().x(),
443 (*verIt)->endPoint().y(),
445 (*verIt)->endPoint().y());
446 (*verIt2)->setPoints((*horIt2)->endPoint().x(),
447 (*horIt2)->endPoint().y(),
448 (*horIt2)->endPoint().x(),
450 (*horIt3)->setPoints((*verIt2)->endPoint().x(),
451 (*verIt2)->endPoint().y(),
454 (*topRightIt)->move(end.x(),end.y());
456 (*topRightIt)->show();
461 start = (*fromIt)->middleRight();
462 end = (*toIt)->middleRight()+TQPoint(12,0);
463 bool down = start.y() < end.y();
464 (*horIt)->setPoints(start.x()+xOffset(*fromIt),start.y(),
465 start.x()+10, start.y());
467 (*horIt)->endPoint().x(),
468 (*horIt)->endPoint().y(),
469 (*horIt)->endPoint().x(),
470 (down ? (*toIt)->itemPos()+1
471 : (*toIt)->itemPos()+(*toIt)->height()-1));
472 (*horIt2)->setPoints((*verIt)->endPoint().x(),
473 (*verIt)->endPoint().y(),
475 (*verIt)->endPoint().y());
476 (*verIt2)->setPoints((*horIt2)->endPoint().x(),
477 (*horIt2)->endPoint().y(),
478 (*horIt2)->endPoint().x(),
480 (*horIt3)->setPoints((*verIt2)->endPoint().x(),
481 (*verIt2)->endPoint().y(),
484 (*topRightIt)->move(end.x(),end.y());
485 (*topRightIt)->show();
489 tqWarning(
"KDGanttViewTaskLink: Unknown link type");
547 myTimeTable->myGanttView->addTaskLinkGroup(
group);
551 myGroup->removeItem(
this);
554 myGroup->insertItem(
this);
569 myTimeTable->updateMyContent();
582 return ishighlighted;
596 myTimeTable->updateMyContent();
622 myTimeTable->updateMyContent();
646 myToolTipText = text;
658 return myToolTipText;
670 myWhatsThisText = text;
683 return myWhatsThisText;
706 bool itemremoved =
false;
707 if (fromList.remove( item )) {
710 if ( toList.remove( item )) {
738 TQDomElement& parentElement )
740 TQDomElement taskLinkElement = doc.createElement(
"TaskLink" );
741 parentElement.appendChild( taskLinkElement );
743 TQDomElement fromItemsElement = doc.createElement(
"FromItems" );
744 taskLinkElement.appendChild( fromItemsElement );
745 TQPtrList<KDGanttViewItem> fromList =
from();
747 for( item = fromList.first(); item;
748 item = fromList.next() )
749 KDGanttXML::createStringNode( doc, fromItemsElement,
"Item", item->
name() );
751 TQDomElement toItemsElement = doc.createElement(
"ToItems" );
752 taskLinkElement.appendChild( toItemsElement );
753 TQPtrList<KDGanttViewItem> toList =
to();
754 for( item = toList.first(); item;
755 item = toList.next() )
756 KDGanttXML::createStringNode( doc, toItemsElement,
"Item", item->
name() );
758 KDGanttXML::createBoolNode( doc, taskLinkElement,
"Highlight",
highlight() );
759 KDGanttXML::createColorNode( doc, taskLinkElement,
"Color",
color() );
760 KDGanttXML::createColorNode( doc, taskLinkElement,
"HighlightColor",
762 KDGanttXML::createStringNode( doc, taskLinkElement,
"TooltipText",
764 KDGanttXML::createStringNode( doc, taskLinkElement,
"WhatsThisText",
767 KDGanttXML::createStringNode( doc, taskLinkElement,
"Group",
769 KDGanttXML::createBoolNode( doc, taskLinkElement,
"Visible",
771 KDGanttXML::createStringNode( doc, taskLinkElement,
"Linktype",
772 linkTypeToString( myLinkType ) );
785 TQDomNode node = element.firstChild();
786 TQStringList fromList, toList;
790 LinkType linktype=None;
791 while( !node.isNull() ) {
792 TQDomElement element = node.toElement();
793 if( !element.isNull() ) {
794 TQString tagName = element.tagName();
795 if( tagName ==
"FromItems" ) {
796 TQDomNode node = element.firstChild();
797 while( !node.isNull() ) {
798 TQDomElement element = node.toElement();
799 if( !element.isNull() ) {
800 TQString tagName = element.tagName();
801 if( tagName ==
"Item" ) {
803 if( KDGanttXML::readStringNode( element, value ) )
806 tqDebug(
"Unrecognized tag name: %s", tagName.latin1() );
810 node = node.nextSibling();
812 }
else if( tagName ==
"ToItems" ) {
813 TQDomNode node = element.firstChild();
814 while( !node.isNull() ) {
815 TQDomElement element = node.toElement();
816 if( !element.isNull() ) {
817 TQString tagName = element.tagName();
818 if( tagName ==
"Item" ) {
820 if( KDGanttXML::readStringNode( element, value ) )
823 tqDebug(
"Unrecognized tag name: %s", tagName.latin1() );
827 node = node.nextSibling();
829 }
else if( tagName ==
"Highlight" ) {
831 if( KDGanttXML::readBoolNode( element, value ) )
833 }
else if( tagName ==
"Visible" ) {
835 if( KDGanttXML::readBoolNode( element, value ) )
837 }
else if( tagName ==
"Color" ) {
839 if( KDGanttXML::readColorNode( element, value ) )
841 }
else if( tagName ==
"HighlightColor" ) {
843 if( KDGanttXML::readColorNode( element, value ) )
845 }
else if( tagName ==
"TooltipText" ) {
847 if( KDGanttXML::readStringNode( element, value ) )
849 }
else if( tagName ==
"WhatsThisText" ) {
851 if( KDGanttXML::readStringNode( element, value ) )
853 }
else if( tagName ==
"Group" ) {
855 if( KDGanttXML::readStringNode( element, value ) )
857 }
else if( tagName ==
"Linktype" ) {
859 if( KDGanttXML::readStringNode( element, value ) )
860 linktype = stringToLinkType( value );
862 tqDebug(
"Unrecognized tag name: %s", tagName.latin1() );
866 node = node.nextSibling();
869 TQPtrList<KDGanttViewItem> fromItemList;
870 TQPtrList<KDGanttViewItem> toItemList;
871 for( TQStringList::const_iterator fromIt = fromList.begin();
872 fromIt != fromList.end(); ++fromIt ) {
875 fromItemList.append( item );
877 for( TQStringList::const_iterator toIt = toList.begin();
878 toIt != toList.end(); ++toIt ) {
881 toItemList.append( item );
884 if (fromItemList.isEmpty()) {
885 tqDebug(
"Cannot create link: fromItemList is empty");
888 if (toItemList.isEmpty()) {
889 tqDebug(
"Cannot create link: toItemList is empty");
894 tl->setLinkType( linktype );
908 int KDGanttViewTaskLink::linkType()
913 void KDGanttViewTaskLink::setLinkType(
int type)
915 myLinkType =
static_cast<LinkType
>(type);
920 switch (item->
type()) {
921 case KDGanttViewItem::Task:
924 case KDGanttViewItem::Event:
927 case KDGanttViewItem::Summary:
936 void KDGanttViewTaskLink::hide()
938 TQPtrListIterator<KDCanvasLine> horIt(*horLineList);
939 TQPtrListIterator<KDCanvasLine> verIt(*verLineList);
940 TQPtrListIterator<KDCanvasLine> horIt2(*horLineList2);
941 TQPtrListIterator<KDCanvasLine> verIt2(*verLineList2);
942 TQPtrListIterator<KDCanvasLine> horIt3(*horLineList3);
943 TQPtrListIterator<KDCanvasPolygon> topIt(*topList);
944 TQPtrListIterator<KDCanvasPolygon> topLeftIt(*topLeftList);
945 TQPtrListIterator<KDCanvasPolygon> topRightIt(*topRightList);
946 TQPtrListIterator<KDGanttViewItem> fromIt(fromList);
947 TQPtrListIterator<KDGanttViewItem> toIt(toList);
948 for ( ; fromIt.current(); ++fromIt ) {
950 for ( ; toIt.current(); ++toIt ) {
957 (*topLeftIt)->hide();
958 (*topRightIt)->hide();
971 TQString KDGanttViewTaskLink::linkTypeToString( LinkType type )
978 return "FinishStart";
981 return "FinishFinish";
987 return "StartFinish";
995 KDGanttViewTaskLink::LinkType KDGanttViewTaskLink::stringToLinkType(
const TQString type )
997 if (type ==
"FinishStart")
999 if (type ==
"FinishFinish")
1000 return FinishFinish;
1001 if (type ==
"StartStart")
1003 if (type ==
"StartFinish")
static KDGanttViewItem * find(const TQString &name)
static KDGanttViewTaskLinkGroup * find(const TQString &name)
TQPtrList< KDGanttViewItem > from() const
void setHighlightColor(const TQColor &color)
TQColor highlightColor() const
void setColor(const TQColor &color)
TQPtrList< KDGanttViewItem > to() const
void setGroup(KDGanttViewTaskLinkGroup *)
void removeItemFromList(KDGanttViewItem *)
void setWhatsThisText(const TQString &text)
TQString tooltipText() const
void setTooltipText(const TQString &text)
void setHighlight(bool highlight)
KDGanttViewTaskLink(TQPtrList< KDGanttViewItem > from, TQPtrList< KDGanttViewItem > to, LinkType type=None)
TQString whatsThisText() const
void createNode(TQDomDocument &doc, TQDomElement &parentElement)
static KDGanttViewTaskLink * createFromDomElement(TQDomElement &)
KDGanttViewTaskLinkGroup * group()