36 #include "KDGanttViewSubwidgets.h"
37 #include "KDGanttViewEventItem.h"
38 #include "KDGanttViewSummaryItem.h"
39 #include "KDGanttViewTaskItem.h"
40 #ifndef KDGANTT_MASTER_CVS
41 #include "KDGanttViewSubwidgets.moc"
46 #include <tqpainter.h>
48 #include <tqtooltip.h>
49 #include <tqapplication.h>
50 #include <tqdrawutil.h>
51 #include <tqpalette.h>
52 #include <tqdragobject.h>
53 #include <tqptrlist.h>
56 #include <tdeglobal.h>
57 #include <tdelocale.h>
58 #include <kcalendarsystem.h>
61 KDTimeTableWidget:: KDTimeTableWidget( TQWidget* parent,
KDGanttView* myGantt)
64 myGanttView = myGantt;
65 taskLinksVisible =
true;
66 flag_blockUpdating =
false;
67 int_blockUpdating = 0;
68 gridPen.setStyle(TQt::DotLine);
69 gridPen.setColor(TQColor(100,100,100));
70 maximumComputedGridHeight = 0;
72 denseLineBrush = TQBrush( TQColor ( 240,240,240 ));
73 noInfoLineBrush = TQBrush( TQColor ( 100,100,100 ), TQt::FDiagPattern );
80 TQPtrList<KDGanttViewTaskLink> KDTimeTableWidget::taskLinks()
82 return myTaskLinkList;
85 void KDTimeTableWidget::clearTaskLinks()
88 TQPtrListIterator<KDGanttViewTaskLink> it(myTaskLinkList);
89 while (it.current()) {
95 void KDTimeTableWidget::resetWidth(
int wid )
97 if ( wid == width() ) {
104 if ( ! pendingHeight )
105 pendingHeight = height();
110 void KDTimeTableWidget::checkHeight(
int hei )
114 if ( pendingHeight < hei+100)
115 pendingHeight = hei+100;
116 if ( ! pendingWidth )
117 pendingWidth = width();
118 maximumComputedGridHeight = 0;
123 void KDTimeTableWidget::setNoInformationBrush(
const TQBrush& brush )
125 noInfoLineBrush = brush;
128 TQBrush KDTimeTableWidget::noInformationBrush()
const
130 return noInfoLineBrush;
133 void KDTimeTableWidget::removeItemFromTasklinks(
KDGanttViewItem* item)
135 TQPtrListIterator<KDGanttViewTaskLink> it((myTaskLinkList));
136 for ( ; it.current(); ++it ) {
137 it.current()->removeItemFromList( item );
141 void KDTimeTableWidget::expandItem( TQListViewItem * item)
143 item->invalidateHeight () ;
147 void KDTimeTableWidget::collapseItem( TQListViewItem * item)
149 item->invalidateHeight () ;
154 void KDTimeTableWidget::highlightItem( TQListViewItem * item )
156 static bool itemwashighlighted;
161 itemwashighlighted = highlightedItem->
highlight();
163 item->invalidateHeight () ;
164 myGanttView->myListView->contentsY();
167 int KDTimeTableWidget::computeHeight()
175 hei += temp->computeHeight();
183 emit heightComputed( hei );
186 void KDTimeTableWidget::computeVerticalGrid()
192 int cw = myGanttView->myTimeHeader->myGridMinorWidth;
195 if (pendingHeight > height() )
204 KDCanvasLine* templine;
205 KDCanvasRectangle* temprect;
208 bool colorIterator =
true;
211 if (myGanttView->showMinorTicks()){
213 TQPtrListIterator<KDCanvasRectangle> itcol(columnColorList);
214 TQPtrListIterator<KDCanvasLine> itgrid(verGridList);
215 for ( ; itgrid.current(); ++itgrid ) {
217 itgrid.current()->setPoints(i,0,i,h);
218 itgrid.current()->show();
220 if (myGanttView->myTimeHeader->getColumnColor(colcol,i,i+cw))
223 colPen.setColor(colcol);
225 colorIterator = itcol.current();
232 itcol.current()->setPen( TQPen(TQPen::NoPen) );
233 itcol.current()->setBrush( TQBrush( colcol, TQt::SolidPattern) );
234 itcol.current()->setSize(cw ,h );
235 itcol.current()->move( i, 0 );
236 itcol.current()->show();
245 temprect =
new KDCanvasRectangle(
this,0,Type_is_KDGanttGridItem);
246 temprect->setPen( TQPen(TQPen::NoPen) );
247 temprect->setBrush( TQBrush( colcol, TQt::SolidPattern) );
248 temprect->setSize(cw ,h );
249 temprect->move( i, 0 );
252 columnColorList.append(temprect);
257 itgrid.current()->hide();
261 for ( ;i < wid;i += cw) {
262 templine =
new KDCanvasLine(
this,0,Type_is_KDGanttGridItem);
263 templine->setPen(gridPen);
264 templine->setPoints(i,0,i,h);
267 verGridList.append(templine);
268 if (myGanttView->myTimeHeader->getColumnColor(colcol,i,i+cw))
270 colPen.setColor(colcol);
272 colorIterator = itcol.current();
278 itcol.current()->setPen( TQPen(TQPen::NoPen) );
279 itcol.current()->setBrush( TQBrush( colcol, TQt::SolidPattern) );
280 itcol.current()->setSize(cw ,h );
281 itcol.current()->move( i, 0 );
282 itcol.current()->show();
285 temprect =
new KDCanvasRectangle(
this,0,Type_is_KDGanttGridItem);
286 temprect->setPen( TQPen(TQPen::NoPen) );
287 temprect->setBrush( TQBrush( colcol, TQt::SolidPattern) );
288 temprect->setSize(cw ,h );
289 temprect->move( i, 0 );
292 columnColorList.append(temprect);
305 for ( ; itcol.current(); ++itcol )
306 itcol.current()->hide();
308 if (myGanttView->showMajorTicks()) {
309 TQValueList<int>::iterator intIt = myGanttView->myTimeHeader->majorTicks.begin();
310 TQValueList<int>::iterator intItEnd = myGanttView->myTimeHeader->majorTicks.end();
311 TQPtrListIterator<KDCanvasRectangle> itcol(columnColorList);
312 TQPtrListIterator<KDCanvasLine> itgrid(verGridList);
314 for ( ; itgrid.current(); ++itgrid ) {
315 if (intIt != intItEnd) {
318 itgrid.current()->setPoints(left,0,left,h);
319 itgrid.current()->show();
322 if (myGanttView->myTimeHeader->getColumnColor(colcol,left,(*intIt) ))
324 int mid = (-left+(*intIt));
325 colPen.setColor(colcol);
326 colPen.setWidth((*intIt)-left);
328 colorIterator = itcol.current();
334 itcol.current()->setPen( TQPen(TQPen::NoPen) );
335 itcol.current()->setBrush( TQBrush( colcol, TQt::SolidPattern) );
336 itcol.current()->setSize(mid ,h );
337 itcol.current()->move( left, 0 );
338 itcol.current()->show();
341 temprect =
new KDCanvasRectangle(
this,0,Type_is_KDGanttGridItem);
342 temprect->setPen( TQPen(TQPen::NoPen) );
343 temprect->setBrush( TQBrush( colcol, TQt::SolidPattern) );
344 temprect->setSize(mid,h );
345 temprect->move( left, 0 );
348 columnColorList.append(temprect);
362 itgrid.current()->hide();
365 KDCanvasLine* templine;
367 for ( ;intIt != intItEnd ;++intIt) {
369 templine =
new KDCanvasLine(
this,0,Type_is_KDGanttGridItem);
370 templine->setPen(gridPen);
371 templine->setPoints((*intIt),0,(*intIt),h);
374 verGridList.append(templine);
376 if (myGanttView->myTimeHeader->getColumnColor(colcol,left,(*intIt)))
378 int mid = (-left+(*intIt));
379 colPen.setColor(colcol);
380 colPen.setWidth((*intIt)-left);
382 colorIterator = itcol.current();
388 itcol.current()->setPen( TQPen(TQPen::NoPen) );
389 itcol.current()->setBrush( TQBrush( colcol, TQt::SolidPattern) );
390 itcol.current()->setSize(mid ,h );
391 itcol.current()->move( left, 0 );
392 itcol.current()->show();
395 temprect =
new KDCanvasRectangle(
this,0,Type_is_KDGanttGridItem);
396 temprect->setPen( TQPen(TQPen::NoPen) );
397 temprect->setBrush( TQBrush( colcol, TQt::SolidPattern) );
398 temprect->setSize(mid ,h );
399 temprect->move( left, 0 );
402 columnColorList.append(temprect);
416 for ( ; itcol.current(); ++itcol ) {
417 itcol.current()->hide();
423 TQPtrListIterator<KDCanvasLine> itgrid(verGridList);
424 for ( ; itgrid.current(); ++itgrid ) {
425 itgrid.current()->hide();
427 TQPtrListIterator<KDCanvasRectangle> itcol(columnColorList);
428 for ( ; itcol.current(); ++itcol ) {
429 itcol.current()->hide();
434 void KDTimeTableWidget::computeHorizontalGrid()
444 KDCanvasLine* templine;
445 TQPtrListIterator<KDCanvasLine> ithor(horGridList);
446 if ( ithor.current() ) {
447 templine = ithor.current();
450 templine =
new KDCanvasLine(
this,0,Type_is_KDGanttGridItem);
451 templine->setPen(gridPen);
453 horGridList.append(templine);
455 templine->setPoints(0,0,wid,0);
459 posY = temp->itemPos() + temp->height();
460 if ( ithor.current() ) {
461 templine = ithor.current();
465 templine =
new KDCanvasLine(
this,0,Type_is_KDGanttGridItem);
466 templine->setPen(gridPen);
468 horGridList.append(templine);
470 if ( templine->endPoint() != TQPoint(wid,posY ))
471 templine->setPoints(0,posY,wid,posY );
472 if ( !templine->isVisible() )
481 while ( ithor.current() ) {
482 if ( ithor.current()->isVisible() )
483 ithor.current()->hide();
488 void KDTimeTableWidget::computeDenseLines()
496 TQPtrListIterator<KDCanvasRectangle> ithordense(horDenseList);
497 KDCanvasRectangle* denseLine;
498 int tempDenseLineCount = 0;
500 if ( temp->isVisible() ) {
501 ++tempDenseLineCount;
502 if ( tempDenseLineCount == denseLineCount ) {
503 tempDenseLineCount = 0;
504 if ( ithordense.current() ) {
505 denseLine = ithordense.current();
508 denseLine =
new KDCanvasRectangle(
this,0,Type_is_KDGanttGridItem);
510 horDenseList.append( denseLine );
512 if ( denseLine->rect() != TQRect(0, temp->itemPos(),wid, temp->height()) ) {
513 denseLine->move( 0, temp->itemPos() );
514 denseLine->setSize( wid, temp->height());
516 if (denseLine->brush() != denseLineBrush ) {
517 denseLine->setPen( TQPen( TQt::NoPen ) );
518 denseLine->setBrush( denseLineBrush);
520 if (!denseLine->isVisible() )
529 while ( ithordense.current() ) {
530 if ( ithordense.current()->isVisible() ) {
531 ithordense.current()->hide();
536 void KDTimeTableWidget::computeShowNoInformation()
544 TQPtrListIterator<KDCanvasRectangle> itnoinfo(showNoInfoList);
545 KDCanvasRectangle* noInfoLine;
548 if ( itnoinfo.current() ) {
549 noInfoLine = itnoinfo.current();
552 noInfoLine =
new KDCanvasRectangle(
this,0,Type_is_KDGanttGridItem);
553 showNoInfoList.append( noInfoLine );
554 noInfoLine->setZ(-1);
556 noInfoLine->move( 0, temp->itemPos() );
557 noInfoLine->setSize( wid, temp->height());
558 noInfoLine->setPen( TQPen( TQt::NoPen ) );
559 noInfoLine->setBrush( noInfoLineBrush);
564 while ( itnoinfo.current() ) {
565 itnoinfo.current()->hide();
571 void KDTimeTableWidget::computeTaskLinks()
574 TQPtrListIterator<KDGanttViewTaskLink> it((myTaskLinkList));
575 for ( ; it.current(); ++it ) {
576 if (it.current()->isVisible())
577 it.current()->showMe(
true);
579 it.current()->showMe(
false);
586 void KDTimeTableWidget::updateMyContent()
588 if ( flag_blockUpdating || int_blockUpdating ) {
601 int hei = computeHeight();
603 int viewport_hei = myGanttView->myCanvasView->viewport()->height();
604 if ( viewport_hei > hei )
605 hei = viewport_hei + 100;
606 if ( myGanttView->myTimeHeader->registerStartTime() )
608 if ( myGanttView->myTimeHeader->registerEndTime() )
610 if ( hei > height() ) {
611 if ( ! pendingWidth )
612 pendingWidth = width();
613 if ( pendingHeight < hei )
616 if (pendingHeight > hei )
618 if (hei > maximumComputedGridHeight)
620 maximumComputedGridHeight = hei;
622 myGanttView->myTimeHeader->computeIntervals( hei );
624 computeVerticalGrid();
627 computeHorizontalGrid();
629 computeShowNoInformation();
632 if (pendingWidth && pendingHeight ) {
633 resize( pendingWidth, pendingHeight );
636 emit heightComputed( 0 );
646 void KDTimeTableWidget::inc_blockUpdating( )
648 ++ int_blockUpdating;
651 void KDTimeTableWidget::dec_blockUpdating( )
653 -- int_blockUpdating;
656 void KDTimeTableWidget::setBlockUpdating(
bool block )
659 int_blockUpdating = 0;
660 flag_blockUpdating = block;
662 bool KDTimeTableWidget::blockUpdating()
664 return flag_blockUpdating;
667 void KDTimeTableWidget::setShowTaskLinks(
bool show )
669 taskLinksVisible = show;
672 bool KDTimeTableWidget::showTaskLinks()
674 return taskLinksVisible;
676 void KDTimeTableWidget::setHorBackgroundLines(
int count, TQBrush brush )
678 denseLineBrush = brush;
681 denseLineCount = count;
685 int KDTimeTableWidget::horBackgroundLines( TQBrush& brush )
687 brush = denseLineBrush;
688 return denseLineCount;
691 int KDTimeTableWidget::getCoordX( TQDateTime dt ) {
692 return myGanttView->myTimeHeader->getCoordX(dt);
698 KDTimeHeaderWidget:: KDTimeHeaderWidget( TQWidget* parent,
KDGanttView* gant )
701 myToolTip =
new KDTimeHeaderToolTip(
this,
this);
704 flagDoNotRecomputeAfterChange =
true;
705 TQDateTime start = (TQDateTime::currentDateTime ()).addSecs(-3600);
706 setHorizonStart(start);
707 setHorizonEnd( start.addSecs(3600*2));
708 flagStartTimeSet =
false;
709 flagEndTimeSet =
false;
710 myCenterDateTime = TQDateTime::currentDateTime ();
711 setScale(KDGanttView::Auto);
713 myMaxScale = KDGanttView::Month;
714 myMinScale = KDGanttView::Minute;
715 myAutoScaleMinorTickcount = 100;
716 setMajorScaleCount( 1 );
717 setMinorScaleCount( 1);
718 setMinimumColumnWidth( 5 );
719 setYearFormat(KDGanttView::FourDigit );
720 setHourFormat( KDGanttView::Hour_12 );
722 setWeekendBackgroundColor(TQColor(220,220,220) );
723 setWeekendDays( 6, 7 );
724 myGridMinorWidth = 0;
725 myPopupMenu =
new TQPopupMenu(
this);
726 TQPopupMenu * zoomPopupMenu =
new TQPopupMenu(
this);
727 myPopupMenu->insertItem (i18n(
"Zoom"),zoomPopupMenu, 1);
728 zoomPopupMenu->insertItem( i18n(
"Zoom to 100%"),
this, TQ_SLOT(setSettings(
int)),0 ,21,21 );
729 zoomPopupMenu->insertItem( i18n(
"Zoom to Fit"),
this, TQ_SLOT(setSettings(
int)),0 ,20,20 );
730 zoomPopupMenu->insertItem( i18n(
"Zoom In (x 2)"),
this, TQ_SLOT(setSettings(
int)),0 ,22,22 );
731 zoomPopupMenu->insertItem( i18n(
"Zoom In (x 6)"),
this, TQ_SLOT(setSettings(
int)),0 ,24,24 );
732 zoomPopupMenu->insertItem( i18n(
"Zoom In (x 12)"),
this, TQ_SLOT(setSettings(
int)),0 ,26,26 );
733 zoomPopupMenu->insertItem( i18n(
"Zoom Out (x 1/2)"),
this, TQ_SLOT(setSettings(
int)),0 ,23,23 );
734 zoomPopupMenu->insertItem( i18n(
"Zoom Out (x 1/6)"),
this, TQ_SLOT(setSettings(
int)),0 ,25,25 );
735 zoomPopupMenu->insertItem( i18n(
"Zoom Out (x 1/12)"),
this, TQ_SLOT(setSettings(
int)),0 ,27,27 );
736 scalePopupMenu =
new TQPopupMenu(
this);
737 myPopupMenu->insertItem (i18n(
"Scale"),scalePopupMenu, 2);
738 scalePopupMenu->insertItem( i18n(
"Minute"),
this, TQ_SLOT(setSettings(
int)),0 ,1,1 );
739 scalePopupMenu->insertItem( i18n(
"Hour"),
this, TQ_SLOT(setSettings(
int)),0 ,2,2 );
740 scalePopupMenu->insertItem( i18n(
"Day"),
this, TQ_SLOT(setSettings(
int)),0 ,3,3 );
741 scalePopupMenu->insertItem( i18n(
"Week"),
this, TQ_SLOT(setSettings(
int)),0 ,4,4 );
742 scalePopupMenu->insertItem( i18n(
"Month"),
this, TQ_SLOT(setSettings(
int)),0 ,5,5 );
743 scalePopupMenu->insertItem( i18n(
"Auto"),
this, TQ_SLOT(setSettings(
int)),0 ,6,6 );
744 scalePopupMenu->setCheckable (
true );
745 timePopupMenu =
new TQPopupMenu(
this);
746 myPopupMenu->insertItem (i18n(
"Time Format"),timePopupMenu, 3);
747 timePopupMenu->insertItem( i18n(
"24 Hour"),
this, TQ_SLOT(setSettings(
int)),0 ,40,40 );
748 timePopupMenu->insertItem( i18n(
"12 PM Hour"),
this, TQ_SLOT(setSettings(
int)),0 ,41,41 );
749 timePopupMenu->insertItem( i18n(
"24:00 Hour"),
this, TQ_SLOT(setSettings(
int)),0 ,42,42 );
750 yearPopupMenu =
new TQPopupMenu(
this);
751 myPopupMenu->insertItem (i18n(
"Year Format"),yearPopupMenu, 4);
752 yearPopupMenu->insertItem( i18n(
"Four Digit"),
this, TQ_SLOT(setSettings(
int)),0 ,50,50 );
753 yearPopupMenu->insertItem( i18n(
"Two Digit"),
this, TQ_SLOT(setSettings(
int)),0 ,51,51 );
754 yearPopupMenu->insertItem( i18n(
"Two Digit Apostrophe"),
this, TQ_SLOT(setSettings(
int)),0 ,52,52 );
755 yearPopupMenu->insertItem( i18n(
"No Date on Minute/Hour Scale"),
this, TQ_SLOT(setSettings(
int)),0 ,53,53 );
757 gridPopupMenu =
new TQPopupMenu(
this);
758 myPopupMenu->insertItem (i18n(
"Grid"),gridPopupMenu,5);
759 gridPopupMenu->insertItem( i18n(
"Show Minor Grid"),
this, TQ_SLOT(setSettings(
int)),0 ,10,10 );
760 gridPopupMenu->insertItem( i18n(
"Show Major Grid"),
this, TQ_SLOT(setSettings(
int)),0 ,11,11 );
761 gridPopupMenu->insertItem( i18n(
"Show No Grid"),
this, TQ_SLOT(setSettings(
int)),0 ,12,12 );
762 myPopupMenu->insertItem( i18n(
"Print"),
this, TQ_SLOT(setSettings(
int)),0 ,30,30 );
763 connect(myPopupMenu, TQ_SIGNAL ( aboutToShow () ) ,
this, TQ_SLOT( preparePopupMenu() )) ;
764 flagZoomToFit =
false;
765 setShowMinorTicks(
true );
766 myRealEnd = myHorizonEnd;
767 myRealStart = myHorizonStart;
768 autoComputeTimeLine =
true;
769 flagDoNotRecomputeAfterChange =
false;
770 flagDoNotRepaintAfterChange =
false;
771 setShowPopupMenu(
false,
false,
false,
false,
false,
false,
false);
772 for (
int j =1;j<8;++j)
773 weekdayColor[j] = TQt::white;
780 KDTimeHeaderWidget::~KDTimeHeaderWidget()
784 void KDTimeHeaderWidget::preparePopupMenu()
786 myPopupMenu->setItemVisible ( 1, flagShowZoom );
787 myPopupMenu->setItemVisible ( 2, flagShowScale );
788 myPopupMenu->setItemVisible ( 3, flagShowTime );
789 myPopupMenu->setItemVisible ( 4, flagShowYear );
790 myPopupMenu->setItemVisible ( 5, flagShowGrid);
791 myPopupMenu->setItemVisible ( 30, flagShowPrint );
793 myPopupMenu->changeItem( 1, i18n(
"Zoom (Fit)"));
795 myPopupMenu->changeItem( 1, i18n(
"Zoom (%1)").arg( TQString::number( zoomFactor(),
'f',3) ) );
798 while ( (
id = scalePopupMenu->idAt( i++ )) >= 0 ) {
799 scalePopupMenu->setItemChecked (
id,
false );
801 scalePopupMenu->setItemChecked ( scalePopupMenu->idAt ( (
int)( scale()) ),
true );
803 while ( (
id = timePopupMenu->idAt( i++ )) >= 0 ) {
804 timePopupMenu->setItemChecked (
id,
false );
806 timePopupMenu->setItemChecked ( timePopupMenu->idAt ( (
int)( hourFormat()) ),
true );
808 while ( (
id = yearPopupMenu->idAt( i++ )) >= 0 ) {
809 yearPopupMenu->setItemChecked (
id,
false );
811 yearPopupMenu->setItemChecked ( yearPopupMenu->idAt ( (
int)( yearFormat()) ),
true );
813 while ( (
id = gridPopupMenu->idAt( i++ )) >= 0 ) {
814 gridPopupMenu->setItemChecked (
id,
false );
817 gridPopupMenu->setItemChecked ( gridPopupMenu->idAt ( 0 ), showMinorTicks() );
818 gridPopupMenu->setItemChecked ( gridPopupMenu->idAt ( 1 ), showMajorTicks() );
819 gridPopupMenu->setItemChecked ( gridPopupMenu->idAt ( 2 ),
820 !(showMajorTicks() || showMinorTicks()) );
825 TQString KDTimeHeaderWidget::getToolTipText(TQPoint p)
827 return TDEGlobal::locale()->formatDateTime(getDateTimeForIndex(p.x()));
829 void KDTimeHeaderWidget::addTickRight(
int num )
831 int secs = ((num*getTickTime())-30);
832 setHorizonEnd(getDateTimeForIndex(width()).addSecs(secs));
836 void KDTimeHeaderWidget::addTickLeft(
int num )
838 int secs = ((num*getTickTime())-30);
839 setHorizonStart(getDateTimeForIndex(0).addSecs(-secs));
843 int KDTimeHeaderWidget::getTickTime()
845 return getDateTimeForIndex(0).secsTo(getDateTimeForIndex(myGridMinorWidth));
849 void KDTimeHeaderWidget::checkWidth(
int wid )
854 myMinimumWidth = wid + 1;
855 if ( myMinimumWidth > width() ||
856 ( myMinimumWidth > mySizeHint &&
857 myMinimumWidth < (width() - myGridMinorWidth )) )
864 if (myGanttView && myGanttView->myCanvasView)
865 myGanttView->myCanvasView->updateScrollBars();
868 bool KDTimeHeaderWidget::registerStartTime()
871 TQListViewItemIterator it( myGanttView->myListView );
872 if (!flagStartTimeSet) {
873 TQDateTime temp , time;
875 bool setNewTime =
false;
881 for ( ; it.current(); ++it ) {
886 switch( item->
type() ) {
887 case KDGanttViewItem::Event:
891 case KDGanttViewItem::Summary:
892 case KDGanttViewItem::Task:
905 if ( myHorizonStart != temp) {
906 myHorizonStart = temp;
916 bool KDTimeHeaderWidget::registerEndTime()
918 if (!flagEndTimeSet) {
919 TQDateTime temp , time;
921 bool setNewTime =
false;
926 TQListViewItemIterator it( myGanttView->myListView );
927 for ( ; it.current(); ++it ) {
932 switch( item->
type() ) {
933 case KDGanttViewItem::Event:
937 case KDGanttViewItem::Summary:
943 case KDGanttViewItem::Task:
956 if (myHorizonEnd != temp ) {
967 void KDTimeHeaderWidget::setShowPopupMenu(
bool show,
975 flagShowPopupMenu = show;
976 flagShowZoom = showZoom;
977 flagShowScale = showScale;
978 flagShowTime = showTime;
979 flagShowYear = showYear;
980 flagShowGrid = showGrid;
981 flagShowPrint = showPrint;
985 bool KDTimeHeaderWidget::showPopupMenu()
const
987 return flagShowPopupMenu;
990 void KDTimeHeaderWidget::setSettings(
int i)
995 setScale(KDGanttView::Minute );
998 setScale(KDGanttView::Hour );
1001 setScale(KDGanttView::Day );
1004 setScale(KDGanttView::Week );
1007 setScale(KDGanttView::Month );
1010 setScale(KDGanttView::Auto );
1013 setShowMinorTicks(
true );
1016 setShowMajorTicks(
true );{
1021 setShowMajorTicks(
false );
1022 setShowMinorTicks(
false);
1040 zoom(0.16666,
false);
1046 zoom(0.08333,
false);
1049 myGanttView->print();
1085 void KDTimeHeaderWidget::zoomToFit()
1087 flagZoomToFit =
true;
1090 if (myGanttView && myGanttView->myCanvasView)
1091 myGanttView->myCanvasView->updateScrollBars();
1093 double KDTimeHeaderWidget::zoomFactor()
1095 return myZoomFactor;
1097 double KDTimeHeaderWidget::secsFromTo( TQDateTime begin, TQDateTime end )
1101 days = begin.daysTo(end);
1102 temp = begin.addDays((
int) days);
1103 secs = temp.secsTo(end);
1104 secs += days * 86400.0;
1109 void KDTimeHeaderWidget::zoomToSelection( TQDateTime start, TQDateTime end)
1111 if (start < myHorizonStart) {
1112 myHorizonStart = start;
1113 flagStartTimeSet =
true;
1116 if (end > myHorizonEnd) {
1118 flagEndTimeSet =
true;
1121 flagDoNotRepaintAfterChange =
true;
1123 int viewWid = myGanttView->myCanvasView->viewport()->width();
1124 int timeWid = getCoordX(end)-getCoordX(start);
1126 fac = ( (double)viewWid)/((double) timeWid );
1128 timeWid = getCoordX(end)-getCoordX(start);
1130 int lastScaleCount = 0;
1131 while (timeWid >viewWid || ( ( myRealMinorScaleCount != lastScaleCount) && timeWid*2 < viewWid ) ) {
1132 lastScaleCount = myRealMinorScaleCount;
1133 fac = (fac * (double)viewWid)/(double)timeWid;
1135 timeWid = getCoordX(end)-getCoordX(start);
1136 if ( count++ > 10 ) {
1141 flagDoNotRepaintAfterChange =
false;
1144 moveTimeLineTo((getCoordX(start)-(viewWid-timeWid)/2));
1146 if (myGanttView && myGanttView->myCanvasView)
1147 myGanttView->myCanvasView->updateScrollBars();
1149 void KDTimeHeaderWidget::moveTimeLineTo(
int X)
1151 int Y = myGanttView->myCanvasView->contentsY ();
1152 myGanttView->myCanvasView->setContentsPos (X, Y );
1155 void KDTimeHeaderWidget::zoom(
double factor,
bool absolute)
1157 flagZoomToFit =
false;
1158 if ( factor < 0.000001 ) {
1159 tqDebug(
"KDGanttView::zoom() : Zoom factor to low. Nothing zoomed. ");
1166 newZoom = myZoomFactor * factor;
1167 double relativeZoom;
1168 relativeZoom = newZoom / myZoomFactor;
1172 int viewWid = myGanttView->myCanvasView->viewport()->width();
1173 if ( width() * relativeZoom < viewWid && ( newZoom > 1.01 || newZoom < 0.99 ) ) {
1174 tqDebug(
"KDGanttView::zoom() : Zoom factor to low for current horizon. ");
1178 myZoomFactor = newZoom;
1181 if (myGanttView && myGanttView->myCanvasView)
1182 myGanttView->myCanvasView->updateScrollBars();
1192 void KDTimeHeaderWidget::setHorizonStart(
const TQDateTime& start )
1194 myHorizonStart = start;
1195 flagStartTimeSet =
true;
1206 TQDateTime KDTimeHeaderWidget::horizonStart()
const
1208 return myHorizonStart;
1219 void KDTimeHeaderWidget::setHorizonEnd(
const TQDateTime& start )
1221 myHorizonEnd = start;
1222 flagEndTimeSet =
true;
1234 TQDateTime KDTimeHeaderWidget::horizonEnd()
const
1236 return myHorizonEnd;
1248 void KDTimeHeaderWidget::setScale(Scale unit )
1254 if (myGanttView && myGanttView->myCanvasView)
1255 myGanttView->myCanvasView->updateHorScrollBar();
1277 void KDTimeHeaderWidget::setMaximumScale( Scale unit )
1302 void KDTimeHeaderWidget::setMinimumScale( Scale unit )
1329 void KDTimeHeaderWidget::setMinimumColumnWidth(
int width )
1331 myMinimumColumWidth = width;
1342 int KDTimeHeaderWidget::minimumColumnWidth()
const
1344 return myMinimumColumWidth;
1355 void KDTimeHeaderWidget::setYearFormat( YearFormat format )
1357 myYearFormat = format;
1370 return myYearFormat;
1381 void KDTimeHeaderWidget::setHourFormat( HourFormat format )
1383 myHourFormat = format;
1396 return myHourFormat;
1406 void KDTimeHeaderWidget::setShowMajorTicks(
bool show )
1408 flagShowMajorTicks = show;
1410 setShowMinorTicks(
false);
1422 bool KDTimeHeaderWidget::showMajorTicks()
const
1424 return flagShowMajorTicks;
1434 void KDTimeHeaderWidget::setShowMinorTicks(
bool show )
1436 flagShowMinorTicks = show;
1438 setShowMajorTicks(
false );
1450 bool KDTimeHeaderWidget::showMinorTicks()
const
1452 return flagShowMinorTicks;
1464 void KDTimeHeaderWidget::setColumnBackgroundColor(
const TQDateTime& column,
1465 const TQColor& color,
1466 Scale mini, Scale maxi )
1468 ColumnColorList::iterator it;
1469 for ( it = ccList.begin(); it != ccList.end(); ++it ) {
1470 if ((*it).datetime == column) {
1471 (*it).color = color;
1472 (*it).minScaleView = mini;
1473 (*it).maxScaleView = maxi;
1477 DateTimeColor newItem;
1478 newItem.datetime = column;
1479 newItem.color = color;
1480 newItem.minScaleView = mini;
1481 newItem.maxScaleView = maxi;
1482 ccList.append(newItem);
1486 void KDTimeHeaderWidget::computeIntervals(
int height )
1488 IntervalColorList::const_iterator it;
1489 for ( it = icList.begin(); it != icList.end(); ++it ) {
1490 (*it)->layout(
this, height );
1494 void KDTimeHeaderWidget::addIntervalBackgroundColor( KDIntervalColorRectangle* newItem )
1496 icList.append(newItem);
1501 bool KDTimeHeaderWidget::changeBackgroundInterval(
const TQDateTime& oldstart,
1502 const TQDateTime& oldend,
1503 const TQDateTime& newstart,
1504 const TQDateTime& newend )
1506 IntervalColorList::iterator it;
1507 for ( it = icList.begin(); it != icList.end(); ++it ) {
1508 if ((*it).datetime == oldstart && (*it).end == oldend ) {
1509 IntervalColorList::iterator it2;
1510 for ( it2 = icList.begin(); it2 != icList.end(); ++it2 ) {
1511 if ((*it2).datetime == newstart && (*it2).end == newend )
1514 (*it).datetime = newstart;
1522 bool KDTimeHeaderWidget::deleteBackgroundInterval(
const TQDateTime& start,
1523 const TQDateTime& end)
1525 IntervalColorList::iterator it;
1526 for ( it = icList.begin(); it != icList.end(); ++it ) {
1527 if ((*it).datetime == start && (*it).end == end ) {
1529 delete (*it).canvasRect;
1538 void KDTimeHeaderWidget::setIntervalBackgroundColor(
const TQDateTime& start,
1539 const TQDateTime& end,
1540 const TQColor& color,
1545 IntervalColorList::iterator it;
1546 for ( it = icList.begin(); it != icList.end(); ++it ) {
1547 if ((*it).datetime == start && (*it).end == end ) {
1548 (*it).color = color;
1549 (*it).minScaleView = mini;
1550 (*it).maxScaleView = maxi;
1554 DateTimeColor newItem;
1555 if ( start <= end ) {
1556 newItem.datetime = start;
1559 newItem.datetime = end;
1560 newItem.end = start;
1562 newItem.color = color;
1563 newItem.minScaleView = mini;
1564 newItem.maxScaleView = maxi;
1566 newItem.canvasRect =
new KDCanvasRectangle(myGanttView->myTimeTable,0,Type_is_KDGanttGridItem);
1567 newItem.canvasRect->setZ(-19);
1568 icList.append(newItem);
1573 void KDTimeHeaderWidget::clearBackgroundColor()
1576 IntervalColorList::iterator itic;
1577 for ( itic = icList.begin(); itic != icList.end(); ++itic ) {
1584 TQDateTime KDTimeHeaderWidget::getDateTimeForIndex(
int X,
bool local )
1588 TQPoint p = TQPoint ( X, 1 );
1589 coordX = myGanttView->myTimeHeaderScroll->viewportToContents(myGanttView->myTimeHeaderScroll->mapFromGlobal( p )).x();
1592 double secs = (secsFromTo( myRealStart, myRealEnd ) * ((double)coordX))/(
double)width();
1593 double days = secs/86400.0;
1594 secs = secs - ( ((int) days) *86400.0 );
1595 return (myRealStart.addDays ( (
int) days )).addSecs( (
int) secs);
1605 bool KDTimeHeaderWidget::getColumnColor(TQColor& col,
int coordLow,
int coordHigh)
1607 if (!flagShowMajorTicks && !flagShowMinorTicks)
1609 TQDateTime start,end;
1610 start = getDateTimeForIndex(coordLow);
1611 end = getDateTimeForIndex(coordHigh).addSecs(-1);
1612 Scale tempScale = myRealScale;
1613 if (flagShowMajorTicks)
1614 switch (myRealScale)
1616 case KDGanttView::Minute: tempScale = KDGanttView::Hour;
break;
1617 case KDGanttView::Hour: tempScale = KDGanttView::Day ;
break;
1618 case KDGanttView::Day: tempScale = KDGanttView::Week ;
break;
1619 case KDGanttView::Week: tempScale = KDGanttView::Month ;
break;
1620 case KDGanttView::Month:
return false ;
break;
1621 case KDGanttView::Auto:
return false ;
break;
1624 ColumnColorList::iterator it;
1625 for ( it = ccList.begin(); it != ccList.end(); ++it ) {
1626 if ((*it).datetime >= start && (*it).datetime <= end) {
1627 if (tempScale >= (*it).minScaleView && tempScale <= (*it).maxScaleView ) {
1634 if (tempScale > KDGanttView::Day)
return false;
1636 start = getDateTimeForIndex((coordLow+coordHigh)/2);
1637 int day = start.date().dayOfWeek ();
1639 if (weekdayColor[day] != TQt::white) {
1640 col = weekdayColor[day];
1644 int endday = myWeekendDaysEnd;
1645 col = myWeekendBackgroundColor;
1646 if (myWeekendDaysStart > myWeekendDaysEnd)
1648 if (day >= myWeekendDaysStart && day <= endday) {
1651 if (day+7 >= myWeekendDaysStart && day+7 <= endday) {
1666 TQColor KDTimeHeaderWidget::columnBackgroundColor(
const TQDateTime& column )
const
1670 ColumnColorList::const_iterator ite;
1671 for ( ite = ccList.begin(); ite != ccList.end(); ++ite ) {
1672 if ((*ite).datetime == column) {
1688 void KDTimeHeaderWidget::setWeekendBackgroundColor(
const TQColor& color )
1690 myWeekendBackgroundColor = color ;
1701 TQColor KDTimeHeaderWidget::weekendBackgroundColor()
const
1703 return myWeekendBackgroundColor;
1716 void KDTimeHeaderWidget::setWeekdayBackgroundColor(
const TQColor& color,
int weekday )
1718 weekdayColor[weekday] = color;
1730 TQColor KDTimeHeaderWidget::weekdayBackgroundColor(
int weekday)
const
1732 return weekdayColor[weekday];
1746 void KDTimeHeaderWidget::setWeekendDays(
int start,
int end )
1748 myWeekendDaysStart = start;
1749 myWeekendDaysEnd = end;
1761 void KDTimeHeaderWidget::weekendDays(
int& start,
int& end )
const
1763 start = myWeekendDaysStart;
1764 end = myWeekendDaysEnd ;
1775 void KDTimeHeaderWidget::setMajorScaleCount(
int count )
1777 myMajorScaleCount=count;
1788 int KDTimeHeaderWidget::majorScaleCount()
const
1790 return myMajorScaleCount;
1800 void KDTimeHeaderWidget::setMinorScaleCount(
int count )
1802 myMinorScaleCount = count;
1813 int KDTimeHeaderWidget::minorScaleCount()
const
1815 return myMinorScaleCount ;
1820 void KDTimeHeaderWidget::resizeEvent ( TQResizeEvent * )
1823 paintPix.resize( 800, height () );
1827 void KDTimeHeaderWidget::updateTimeTable()
1830 if (flagDoNotRecomputeAfterChange)
return;
1832 int scrollLineStep = myGridMinorWidth;
1833 if (showMajorTicks()) {
1834 TQValueList<int>::iterator intIt = majorTicks.begin();
1835 scrollLineStep = 5 * myGridMinorWidth;
1836 if (intIt != majorTicks.end()) {
1839 if (intIt != majorTicks.end()) {
1840 scrollLineStep = *intIt-left;
1844 myGanttView->myCanvasView->horizontalScrollBar()->setLineStep(scrollLineStep);
1845 myGanttView->myTimeTable->maximumComputedGridHeight = 0;
1846 myGanttView->myTimeTable->updateMyContent();
1850 void KDTimeHeaderWidget::setAutoScaleMinorTickCount(
int count )
1852 myAutoScaleMinorTickcount = count;
1858 int KDTimeHeaderWidget::autoScaleMinorTickCount()
1860 return myAutoScaleMinorTickcount;
1864 void KDTimeHeaderWidget::repaintMe(
int left,
int paintwid, TQPainter* painter)
1866 if (flagDoNotRecomputeAfterChange)
return;
1867 TQColorGroup qcg =TQColorGroup( white, black,white, darkGray,black,gray,gray) ;
1870 if ( paintwid > paintPix.width()-100 )
1871 paintPix.resize( paintwid+100, height () );
1875 p =
new TQPainter( &paintPix );
1876 offsetLeft = left-50;
1879 p->fillRect( left-offsetLeft, 0, paintwid, height(), TQBrush(paletteBackgroundColor()) );
1882 if ( beginMouseDown < endMouseDown ) {
1883 start = beginMouseDown ;
1884 wid = endMouseDown - beginMouseDown ;
1886 start = endMouseDown ;
1887 wid = -endMouseDown + beginMouseDown ;
1889 p->fillRect( start-offsetLeft, 0, wid, height(), TQBrush(paletteBackgroundColor().dark()) );
1892 p->fillRect( left-offsetLeft, 0, paintwid, height(), TQBrush(paletteBackgroundColor()) );
1894 p->setPen(TQColor(40,40,40));
1895 TQFont tempFont = p->font();
1896 tempFont.setWeight(63);
1897 p->setFont(tempFont);
1898 int hei1 = myMajorGridHeight,
1900 wid1 = myGridMinorWidth;
1904 TQValueList<TQString>::iterator it;
1905 TQValueList<int>::iterator intIt = majorTicks.begin();
1906 for ( it = majorText.begin(); it != majorText.end(); ++it ) {
1907 xCoord = (*intIt++);
1908 if (((*intIt)>= left && xCoord <= left+paintwid)) {
1909 qDrawShadeLine ( p,xCoord-offsetLeft ,hei1+1, xCoord-offsetLeft, -2, qcg,
true, lwid, 1 );
1910 p->drawText(xCoord+4-offsetLeft,hei1-4,(*it));
1913 qDrawShadeLine ( p,left-offsetLeft ,hei1, left+paintwid-offsetLeft, hei1, qcg,
true, lwid, 1 );
1915 for ( it = minorText.begin(); it != minorText.end(); ++it ) {
1916 if (i*wid1 >= left-wid1 && i*wid1 <= left+paintwid) {
1917 qDrawShadeLine ( p,i*wid1-offsetLeft ,hei1-1, i*wid1-offsetLeft, hei2, qcg,
true, lwid, 1 );
1918 p->drawText(i*wid1+1-offsetLeft,hei1+1,wid1-1,hei2-hei1,TQt::AlignCenter,(*it));
1923 p->drawLine(left-offsetLeft,hei1,left+paintwid-offsetLeft,hei1);
1924 qDrawShadeLine ( p,left-offsetLeft ,hei2-1, left+paintwid-offsetLeft, hei2-1, qcg,
true, lwid, 1 );
1925 p->drawLine(left-offsetLeft,hei2-1,left+paintwid-offsetLeft,hei2-1);
1929 bitBlt (
this, left, 0, &paintPix, 50, 0, paintwid, height() );
1936 TQDateTime KDTimeHeaderWidget::getEvenTimeDate(TQDateTime tempdatetime ,Scale sc)
1940 int tempMinorScaleCount = myRealMinorScaleCount;
1943 case KDGanttView::Month:
1944 tempdate = tempdatetime.date();
1945 while (tempdate.day ()!= 1 )
1946 tempdate = tempdate.addDays(-1);
1949 tempdatetime = TQDateTime (tempdate, TQTime (0,0));
1951 case KDGanttView::Week:
1952 tempdate = tempdatetime.date();
1953 while (tempdate.dayOfWeek ()!= TDEGlobal::locale()->weekStartDay())
1954 tempdate = tempdate.addDays(-1);
1956 tempdatetime = TQDateTime (tempdate, TQTime (0,0));
1958 case KDGanttView::Day:
1959 tempdatetime = TQDateTime (tempdatetime.date(), TQTime ( 0,0 ) );
1961 case KDGanttView::Hour:
1962 hour = tempdatetime.time().hour();
1963 while (24%tempMinorScaleCount > 0 && 24%tempMinorScaleCount < 24)
1964 ++tempMinorScaleCount;
1965 hour = ( hour /tempMinorScaleCount)*tempMinorScaleCount;
1966 tempdatetime = TQDateTime (tempdatetime.date(), TQTime (hour, 0 ));
1968 case KDGanttView::Minute:
1969 min = tempdatetime.time().minute();
1970 while (60%tempMinorScaleCount > 0 && 60%tempMinorScaleCount < 60)
1971 ++tempMinorScaleCount;
1973 min = (min /tempMinorScaleCount)*tempMinorScaleCount;
1974 tempdatetime = TQDateTime (tempdatetime.date(), TQTime (tempdatetime.time().hour(),min ));
1977 case KDGanttView::Auto:
1980 return tempdatetime;
1984 void KDTimeHeaderWidget::computeRealScale(TQDateTime start)
1987 if (myScale ==KDGanttView::Auto) {
1990 double secsPerMinor = (((double)start.secsTo(myHorizonEnd)))/((double)myAutoScaleMinorTickcount);
1991 secsPerMinor /= myZoomFactor;
1992 if (secsPerMinor <= 1800) {
1993 myRealScale = KDGanttView::Minute;
1994 myRealMinorScaleCount = (int) secsPerMinor/60;
1996 if (secsPerMinor <= 12*3600) {
1997 myRealScale = KDGanttView::Hour;
1998 myRealMinorScaleCount = (int) secsPerMinor/3600;
2000 if (secsPerMinor <= 24*3600*3) {
2001 myRealScale = KDGanttView::Day;
2002 myRealMinorScaleCount = (int) secsPerMinor/(3600*24);
2004 if (secsPerMinor <= 24*3600*14) {
2005 myRealScale = KDGanttView::Week;
2006 myRealMinorScaleCount = (int) secsPerMinor/(3600*24*7);
2008 myRealScale = KDGanttView::Month;
2009 myRealMinorScaleCount = (int) secsPerMinor/(3600*24*30);
2015 if(myRealMinorScaleCount == 0)
2016 myRealMinorScaleCount = 1;
2017 myRealMajorScaleCount = 1;
2021 myRealScale = myScale;
2022 if (myRealScale > myMaxScale)
2023 myRealScale = myMaxScale;
2024 if (myRealScale < myMinScale)
2025 myRealScale = myMinScale;
2026 myRealMinorScaleCount = (int) ( ((
double)myMinorScaleCount) /myZoomFactor );
2027 double tempZoom = myZoomFactor;
2028 myRealMajorScaleCount = myMajorScaleCount;
2029 while (myRealMinorScaleCount == 0) {
2030 if (myRealScale == myMinScale) {
2031 myRealMinorScaleCount = 1;
2034 switch (myRealScale)
2036 case KDGanttView::Minute:
2037 myRealMinorScaleCount = 1;
2040 case KDGanttView::Hour:
2041 myRealScale = KDGanttView::Minute;
2042 tempZoom = tempZoom/60;
2044 case KDGanttView::Day:
2045 myRealScale = KDGanttView::Hour;
2046 tempZoom = tempZoom/24;
2048 case KDGanttView::Week:
2049 myRealScale = KDGanttView::Day;
2050 tempZoom = tempZoom/7;
2052 case KDGanttView::Month:
2053 myRealScale = KDGanttView::Week ;
2054 tempZoom = tempZoom*7/30;
2056 case KDGanttView::Auto:
2059 myRealMinorScaleCount = (int) ( myMinorScaleCount /tempZoom );
2065 void KDTimeHeaderWidget::computeTicks(
bool doNotComputeRealScale)
2067 if (flagDoNotRecomputeAfterChange)
return;
2068 bool block = myGanttView->myTimeTable->blockUpdating();
2069 myGanttView->myTimeTable->setBlockUpdating(
true );
2074 if ( !doNotComputeRealScale )
2075 saveCenterDateTime();
2076 if (!doNotComputeRealScale)
2077 computeRealScale(myHorizonStart);
2078 myRealStart = getEvenTimeDate(myHorizonStart ,myRealScale);
2079 if (!doNotComputeRealScale)
2080 computeRealScale(myRealStart);
2081 int tempMinorScaleCount = myRealMinorScaleCount,
2082 tempMajorScaleCount = myRealMajorScaleCount;
2083 int minorItems,minorPerMajor = 1;
2084 minorItems = (int) (secsFromTo( myRealStart, myHorizonEnd)/60.0);
2088 TQString testTextMinor,testTextMajor, tempStr;
2089 TQRect itemRectMinor, itemRectMajor;
2090 TQDate tempDate = myRealStart.date();
2091 myRealEnd = myRealStart;
2093 switch (myRealScale)
2096 case KDGanttView::Minute:
2097 testTextMinor =
"60";
2098 if (myHourFormat == KDGanttView::Hour_12)
2099 testTextMajor =
"Mon Aug 30, 12 AMx";
2101 testTextMajor =
"Mon Aug 30, 24:00x";
2102 minorPerMajor = 6000;
2104 case KDGanttView::Hour:
2105 minorItems = minorItems/60;
2106 if (myHourFormat == KDGanttView::Hour_24)
2107 testTextMinor =
"24x";
2109 testTextMinor =
"12 AM";
2110 testTextMajor =
"Mon Aug 30, x";
2111 if ( yearFormat() != KDGanttView::NoDate )
2112 testTextMajor += getYear(TQDate::currentDate());
2113 minorPerMajor = 2400;
2115 case KDGanttView::Day:
2116 minorItems = minorItems/(60*24);
2117 testTextMinor =
"88";
2118 testTextMajor =
"Aug 30, x"+getYear(TQDate::currentDate());
2119 minorPerMajor = 700;
2121 case KDGanttView::Week:
2122 minorItems = minorItems/(60*24*7);
2123 testTextMinor =
"88";
2124 testTextMajor =
"Aug x"+getYear(TQDate::currentDate());
2125 minorPerMajor = 435;
2127 case KDGanttView::Month:
2128 minorItems = (minorItems*12)/(60*24*365);
2129 testTextMinor =
"M";
2130 testTextMajor =
"x"+getYear(TQDate::currentDate());
2131 minorPerMajor = 1200;
2133 case KDGanttView::Auto:
2134 tqDebug(
"KDGanttView::Internal Error in KDTimeHeaderWidget::computeTicks() ");
2135 tqDebug(
" RealScale == Auto : This may not be! ");
2138 itemRectMinor = p.boundingRect ( 10, 10, 2, 2, TQt::AlignLeft,testTextMinor);
2139 itemRectMajor = p.boundingRect ( 10, 10, 2, 2, TQt::AlignLeft,testTextMajor);
2142 Height = itemRectMinor.height()+itemRectMajor.height()+11;
2143 Width = (itemRectMinor.width()+5);
2144 if (Width < minimumColumnWidth()) Width = minimumColumnWidth();
2147 int maxWid = myGanttView->myCanvasView->viewport()->width();
2149 maxWid = maximumWidth();
2150 while((minorItems/tempMinorScaleCount+1)*Width > maxWid)
2151 ++tempMinorScaleCount;
2153 mySizeHint = (minorItems/tempMinorScaleCount+1)*Width;
2154 switch (myRealScale)
2156 case KDGanttView::Minute:
2157 if (tempMinorScaleCount < 60)
2158 while (60%tempMinorScaleCount > 0 && 60%tempMinorScaleCount < 60)
2159 ++tempMinorScaleCount;
2160 if (tempMinorScaleCount >= 60) {
2161 myRealScale = KDGanttView::Hour;
2162 myRealMinorScaleCount = tempMinorScaleCount/ 60;
2164 myRealMajorScaleCount = 1;
2165 tqDebug(
"KDGantt::Overzoom:Rescaling from Minute to Hour");
2166 myGanttView->myTimeTable->setBlockUpdating( block );
2167 emit myGanttView->rescaling( KDGanttView::Hour );
2172 case KDGanttView::Hour:
2173 while (24%tempMinorScaleCount > 0 && 24%tempMinorScaleCount < 24)
2174 ++tempMinorScaleCount;
2175 if (tempMinorScaleCount >= 24) {
2176 myRealScale = KDGanttView::Day;
2177 myRealMinorScaleCount = tempMinorScaleCount/ 24;
2179 myRealMajorScaleCount = 1;
2180 tqDebug(
"KDGantt::Overzoom:Rescaling from Hour to Day");
2181 myGanttView->myTimeTable->setBlockUpdating( block );
2182 emit myGanttView->rescaling( KDGanttView::Day );
2191 while((minorItems/tempMinorScaleCount+1)*Width < myMinimumWidth ) {
2194 minorItems = (minorItems/tempMinorScaleCount)+1;
2196 minorPerMajor = (minorPerMajor*tempMajorScaleCount)/tempMinorScaleCount;
2200 while ((minorPerMajor*Width)/100 < itemRectMajor.width()) {
2201 minorPerMajor = minorPerMajor/tempMajorScaleCount;
2202 ++tempMajorScaleCount;
2203 minorPerMajor = minorPerMajor*tempMajorScaleCount;
2207 myGridMinorWidth = Width;
2209 Width *= minorItems;
2211 if (width() != Width || height() != Height )
2213 resize( Width, Height );
2214 emit sizeChanged( Width );
2216 myMajorGridHeight = itemRectMajor.height()+5;
2217 TQTime tempTime = myRealStart.time();
2218 TQDateTime tempDateTime;
2220 const KCalendarSystem * calendar = TDEGlobal::locale()->calendar();
2221 switch (myRealScale)
2223 case KDGanttView::Minute:
2224 myRealEnd = myRealEnd.addSecs((minorItems)*tempMinorScaleCount*60);
2225 for ( i = 0; i < minorItems;++i) {
2226 tempStr.setNum(tempTime.minute());
2227 minorText.append(tempStr);
2228 tempTime = tempTime.addSecs(60*tempMinorScaleCount);
2230 tempDateTime = myRealStart;
2231 while (tempDateTime.time().minute() != 0)
2232 tempDateTime = tempDateTime.addSecs(60);
2233 while (tempDateTime < myRealEnd) {
2234 majorTicks.append( getCoordX(tempDateTime));
2235 tempStr.setNum(tempDateTime.date().day());
2236 if ( yearFormat() == KDGanttView::NoDate ) {
2237 tempStr = calendar->weekDayName( tempDateTime.date() )+
", "
2238 +getHour(tempDateTime.time());
2240 tempStr = calendar->weekDayName( tempDateTime.date(),
true )+
" "+
2241 calendar->monthName( tempDateTime.date().month(), tempDateTime.date().year(),
true)+
" "+
2242 tempStr+
", "+getHour(tempDateTime.time());
2245 majorText.append(tempStr);
2246 tempDateTime = tempDateTime.addSecs(3600*tempMajorScaleCount);
2248 majorTicks.append( getCoordX(tempDateTime));
2251 case KDGanttView::Hour:
2252 myRealEnd = myRealEnd.addSecs(minorItems*tempMinorScaleCount*60*60);
2254 for ( i = 0; i < minorItems;++i) {
2255 tempStr = getHour(tempTime);
2256 minorText.append(tempStr);
2257 tempTime = tempTime.addSecs(3600*tempMinorScaleCount);
2259 tempDateTime = myRealStart;
2260 while (tempDateTime.time().hour() != 0)
2261 tempDateTime = tempDateTime.addSecs(3600);
2262 while (tempDateTime < myRealEnd) {
2263 majorTicks.append( getCoordX(tempDateTime));
2264 tempStr.setNum(tempDateTime.date().day());
2265 if ( yearFormat() == KDGanttView::NoDate ) {
2266 tempStr = calendar->weekDayName( tempDateTime.date() );
2268 tempStr = calendar->weekDayName( tempDateTime.date(),
true )+
" "+
2269 calendar->monthName( tempDateTime.date().month(), tempDateTime.date().year(),
true)+
" "+
2270 tempStr+
", "+getYear(tempDateTime.date());
2272 majorText.append(tempStr);
2273 tempDateTime = tempDateTime.addDays(tempMajorScaleCount);
2275 majorTicks.append( getCoordX(tempDateTime));
2277 case KDGanttView::Day:
2278 myRealEnd = myRealEnd.addDays(minorItems*tempMinorScaleCount);
2279 for ( i = 0; i < minorItems;++i) {
2280 if (tempMinorScaleCount == 1)
2281 minorText.append((calendar->weekDayName(tempDate,
true)).left(1));
2283 minorText.append(TQString::number(tempDate.day()));
2284 tempDate = tempDate.addDays(tempMinorScaleCount);
2286 tempDate = myRealStart.date();
2287 while (tempDate.dayOfWeek() != TDEGlobal::locale()->weekStartDay())
2288 tempDate = tempDate.addDays(1);
2289 while (tempDate < myRealEnd.date()) {
2290 majorTicks.append( getCoordX(tempDate));
2291 tempStr.setNum(tempDate.day());
2292 tempStr = calendar->monthName(tempDate.month(), tempDate.year(),
true)+
" "+
2293 tempStr+
", "+getYear(tempDate);
2294 majorText.append(tempStr);
2295 tempDate = tempDate.addDays(7*tempMajorScaleCount);
2297 majorTicks.append( getCoordX(tempDate));
2299 case KDGanttView::Week:
2300 myRealEnd = myRealEnd.addDays(minorItems*tempMinorScaleCount*7);
2301 for ( i = 0; i < minorItems;++i) {
2302 tempStr.setNum(tempDate.day());
2303 minorText.append(tempStr);
2304 tempDate = tempDate.addDays(7*tempMinorScaleCount);
2306 tempDate = myRealStart.date();
2307 while (tempDate.day() != TDEGlobal::locale()->weekStartDay())
2308 tempDate = tempDate.addDays(1);
2309 while (tempDate < myRealEnd.date()) {
2310 majorTicks.append( getCoordX(tempDate));
2311 tempStr = calendar->monthName(tempDate.month(), tempDate.year(),
true)+
" "+getYear(tempDate);
2312 majorText.append(tempStr);
2313 tempDate = tempDate.addMonths(tempMajorScaleCount);
2315 majorTicks.append( getCoordX(tempDate));
2317 case KDGanttView::Month:
2318 myRealEnd = myRealEnd.addMonths(minorItems*tempMinorScaleCount);
2319 for ( i = 0; i < minorItems;++i) {
2320 minorText.append((calendar->monthName(tempDate.month(), tempDate.year(),
true)).left(1));
2321 tempDate = tempDate.addMonths(tempMinorScaleCount);
2323 tempDate = myRealStart.date();
2324 while (tempDate.month() != 1)
2325 tempDate = tempDate.addMonths(1);
2326 while (tempDate < myRealEnd.date()) {
2327 majorTicks.append( getCoordX(tempDate));
2328 tempStr = getYear(tempDate);
2329 majorText.append(tempStr);
2330 tempDate = tempDate.addYears(tempMajorScaleCount);
2332 majorTicks.append( getCoordX(tempDate));
2334 case KDGanttView::Auto:
2338 if (flagDoNotRepaintAfterChange) {
2339 myGanttView->myTimeTable->setBlockUpdating( block );
2343 myGanttView->myTimeTable->setBlockUpdating( block );
2345 centerDateTime(myCenterDateTime);
2350 void KDTimeHeaderWidget::saveCenterDateTime()
2352 double wid = width();
2353 double allsecs = secsFromTo( myRealStart, myRealEnd );
2354 double center = myGanttView->myCanvasView->viewport()->width();
2355 center = center / 2;
2356 center = center + myGanttView->myCanvasView->contentsX();
2357 double secs = (allsecs*center)/wid;
2358 double days = secs/86400.0;
2359 secs = secs - ( (int) days *86400.0 );
2360 myCenterDateTime = (myRealStart.addDays ( (
int) days )).addSecs( (
int) secs);
2364 void KDTimeHeaderWidget::centerDateTime(
const TQDateTime& center )
2366 moveTimeLineTo(getCoordX( center )-(myGanttView->myCanvasView->viewport()->width() /2));
2372 void KDTimeHeaderWidget::paintEvent(TQPaintEvent *p)
2374 repaintMe(p->rect().x(),p->rect().width());
2378 int KDTimeHeaderWidget::getCoordX(TQDate date)
2381 int daysAll = myRealStart.daysTo(myRealEnd);
2382 if (daysAll == 0)
return 0;
2383 int days = myRealStart.daysTo(TQDateTime(date));
2384 return (wid *days) /daysAll;
2388 int KDTimeHeaderWidget::getCoordX(TQDateTime datetime)
2390 double wid = width();
2391 double secsAll = secsFromTo( myRealStart, myRealEnd );
2392 if (secsAll == 0.0)
return 0;
2393 double secs = secsFromTo( myRealStart, datetime);
2394 return ((
int)((wid *(secs /secsAll))+0.5));
2398 TQString KDTimeHeaderWidget::getYear(TQDate date)
2401 ret.setNum(date.year());
2402 switch (yearFormat()) {
2403 case KDGanttView::FourDigit:
2406 case KDGanttView::TwoDigit:
2409 case KDGanttView::TwoDigitApostrophe:
2410 ret =
"'"+ret.right(2);
2412 case KDGanttView::NoDate:
2420 TQString KDTimeHeaderWidget::getHour(TQTime time)
2423 int hour = time.hour();
2424 if (myHourFormat == KDGanttView::Hour_12) {
2426 if (hour > 12) hour -=12;
2430 if (hour == 0) hour = 12;
2435 if (myHourFormat == KDGanttView::Hour_24)
2446 void KDTimeHeaderWidget::mousePressEvent ( TQMouseEvent * e )
2449 switch ( e->button() ) {
2450 case TQt::LeftButton:
2452 beginMouseDown = e->pos().x();
2453 endMouseDown = e->pos().x();
2455 case TQt::RightButton:
2456 if (flagShowPopupMenu)
2457 myPopupMenu->popup(e->globalPos());
2459 case TQt::MidButton:
2468 void KDTimeHeaderWidget::mouseReleaseEvent ( TQMouseEvent * )
2474 if ( beginMouseDown < endMouseDown ) {
2475 start = beginMouseDown;
2478 start = endMouseDown;
2479 end = beginMouseDown;
2483 if ( end > width() )
2487 emit myGanttView->timeIntervalSelected( getDateTimeForIndex(start),getDateTimeForIndex(end) );
2488 emit myGanttView->timeIntervallSelected( getDateTimeForIndex(start),getDateTimeForIndex(end) );
2496 void KDTimeHeaderWidget::mouseDoubleClickEvent ( TQMouseEvent * )
2502 void KDTimeHeaderWidget::mouseMoveEvent ( TQMouseEvent * e )
2505 if ( e->pos().y() < -height() || e->pos().y() > 2* height() ) {
2510 endMouseDown = e->pos().x();
2513 if (endMouseDown < -x() ) {
2514 val = myGanttView->myCanvasView->horizontalScrollBar()->value() -
2515 myGanttView->myCanvasView->horizontalScrollBar()->lineStep();
2520 if (endMouseDown > -x() +parentWidget()->width() ) {
2521 val = myGanttView->myCanvasView->horizontalScrollBar()->value() +
2522 myGanttView->myCanvasView->horizontalScrollBar()->lineStep();
2525 repaintMe(-x(),parentWidget()->width());
2527 if ( val > myGanttView->myCanvasView->horizontalScrollBar()->maxValue() ) {
2528 val = myGanttView->myCanvasView->horizontalScrollBar()->maxValue();
2530 myGanttView->myCanvasView->horizontalScrollBar()->setValue( val );
2540 KDLegendWidget:: KDLegendWidget( TQWidget* parent,
2545 myLegendParent = legendParent;
2547 scroll =
new TQScrollView( legendParent );
2548 setMaximizedWidget( scroll );
2550 setMinimizedWidget( myLabel =
new TQLabel( i18n(
" Legend is hidden" ),
this) );
2551 setGeometry( 0, 0, 50, 50 );
2556 void KDLegendWidget::setAsDoctwindow(
bool dockwin )
2558 if ( (dock == 0 && !dockwin) || ( dock && dockwin ) )
2562 setMaximizedWidget( 0 );
2564 if ( dock )
delete dock;
2565 dock =
new TQDockWindow(TQDockWindow:: OutsideDock,0 );
2566 dock->resize( 200, 100 );
2567 dock->setHorizontallyStretchable(
true );
2568 dock->setVerticallyStretchable(
true );
2569 dock->setCaption(i18n(
"Legend: ") );
2570 dock->setResizeEnabled (
true );
2574 scroll =
new TQScrollView( dock );
2576 dock->setWidget(scroll);
2577 setMaximizedWidget( dock );
2581 setMaximizedWidget( 0 );
2588 scroll =
new TQScrollView( myLegendParent );
2590 setMaximizedWidget( scroll );
2597 bool KDLegendWidget::asDoctwindow( )
2605 TQDockWindow* KDLegendWidget::dockwindow( )
2611 void KDLegendWidget::setFont( TQFont font)
2613 myLegend->setFont( font);
2614 myLabel->setFont( font);
2615 TQWidget::setFont( font );
2619 void KDLegendWidget::drawToPainter( TQPainter *p )
2621 p->drawPixmap( 0, 0, TQPixmap::grabWidget( myLegend ) );
2625 TQSize KDLegendWidget::legendSize()
2627 return myLegend->size();
2631 TQSize KDLegendWidget::legendSizeHint()
2633 TQApplication::sendPostedEvents( 0, TQEvent::LayoutHint );
2634 return TQSize( myLegend->sizeHint().width(), myLegend->sizeHint().height()+scroll->horizontalScrollBar()->height());
2638 void KDLegendWidget::showMe (
bool show )
2644 void KDLegendWidget::clearLegend ( )
2646 if ( myLegend )
delete myLegend;
2648 myLegend =
new TQGroupBox( 1, TQt::Horizontal, scroll->viewport() );
2650 myLegend =
new TQGroupBox( 1, TQt::Horizontal, i18n(
"Legend" ), scroll->viewport() );
2651 myLegend->setBackgroundColor( TQt::white );
2652 myLegend->setFont( font() );
2653 scroll->addChild( myLegend );
2654 scroll->setResizePolicy( TQScrollView::AutoOneFit );
2655 myLegend->layout()->setMargin( 11 );
2656 myLegend->setFrameStyle( TQFrame::NoFrame );
2658 scroll->setMaximumHeight( 32000 );
2660 scroll->setMaximumHeight( legendSizeHint().height() );
2664 void KDLegendWidget::addLegendItem(
KDGanttViewItem::Shape shape,
const TQColor& shapeColor,
const TQString& text )
2668 TQWidget *w =
new TQWidget( myLegend );
2669 w->setBackgroundColor( TQt::white );
2670 TQHBoxLayout *lay =
new TQHBoxLayout( w ,0, 6);
2671 temp =
new TQLabel ( w );
2672 lay->addWidget( temp, 0, TQt:: AlignRight);
2674 temp =
new TQLabel ( text, w );
2675 temp->setBackgroundColor( TQt::white );
2676 lay->addWidget( temp, 0, TQt:: AlignLeft);
2679 scroll->setMaximumHeight( 32000 );
2681 scroll->setMaximumHeight( legendSizeHint().height() );
2685 bool KDLegendWidget::isShown ( )
2687 return !isMinimized();
2691 KDListView::KDListView(TQWidget* parent,
KDGanttView* gantView):TQListView (parent)
2693 myGanttView = gantView;
2694 setAcceptDrops(
true);
2695 new KDListViewWhatsThis(viewport(),
this);
2696 setRootIsDecorated(
true );
2697 setAllColumnsShowFocus(
true );
2698 addColumn( i18n(
"Task Name" ) );
2701 setHScrollBarMode (TQScrollView::AlwaysOn );
2702 setDefaultRenameAction(TQListView::Accept);
2703 setColumnWidthMode ( 0,Maximum );
2704 _calendarMode =
false;
2709 void KDListView::dragItem( TQListViewItem * )
2714 TQString KDListView::getWhatsThisText(TQPoint p)
2719 return i18n(
"No item Found" );
2722 void KDListView::setCalendarMode(
bool mode )
2724 _calendarMode = mode;
2728 void KDListView::setOpen(TQListViewItem * item,
bool open )
2730 if (! _calendarMode || ! open ) {
2732 TQListView::setOpen ( item, open );
2739 TQListViewItem* temp;
2740 temp = item->firstChild();
2741 bool openItem =
false;
2744 temp->setVisible(
true );
2748 temp->setVisible(
false );
2751 temp = temp->nextSibling();
2755 TQListView::setOpen ( item, open );
2761 void KDListView::contentsMouseDoubleClickEvent ( TQMouseEvent * e )
2763 TQListView::contentsMouseDoubleClickEvent ( e );
2769 emit myGanttView->lvItemDoubleClicked ( (
KDGanttViewItem*) itemAt(e->pos() ) );
2770 emit myGanttView->itemDoubleClicked ( (
KDGanttViewItem*) itemAt(e->pos() ) );
2776 void KDListView::drawToPainter ( TQPainter * p,
bool drawHeader )
2779 drawAllContents ( p, 0, 0, contentsWidth(), contentsHeight() );
2784 TQPen pen = TQPen(TQt::lightGray, 1);
2786 TQHeader *h = header();
2787 for (
int s = 0; s < h->count(); ++s) {
2788 TQRect r = h->sectionRect(s);
2790 p->translate(0, -r.height());
2793 p->drawText(r.x()+2, r.y(), r.width()-2, r.height(), columnAlignment(s)|TQt::AlignVCenter, h->label(s), -1);
2796 p->drawRect(r.x(), r.y()+1, r.width(), r.height()-2);
2803 int KDListView::buildDrawables(TQPtrList<KDListView::DrawableItem> &lst,
int level,
int ypos, TQListViewItem *item,
int ymin,
int ymax)
const {
2805 int ih = item->height();
2806 if (y < ymin && y+ih > ymin) {
2809 if (y >= ymin && y < ymax) {
2810 KDListView::DrawableItem *dr =
new KDListView::DrawableItem(level, y, item);
2815 if (item->isOpen()) {
2816 TQListViewItem *child = item->firstChild();
2817 for (; child; child = child->nextSibling()) {
2818 y = buildDrawables(lst, level+1, y, child, ymin, ymax);
2827 void KDListView::drawAllContents(TQPainter * p,
int cx,
int cy,
int cw,
int ch) {
2828 if ( columns() == 0 ) {
2829 paintEmptyArea( p, TQRect( cx, cy, cw, ch ) );
2833 TQPtrList<KDListView::DrawableItem> drawables;
2834 drawables.setAutoDelete(
true);
2835 TQListViewItem *child = firstChild();
2838 for (; child; child = child->nextSibling()) {
2839 ypos = buildDrawables(drawables, level, ypos, child, cy, cy+ch);
2842 p->setFont( font() );
2844 TQPtrListIterator<KDListView::DrawableItem> it(drawables);
2847 int fx = -1, x, fc = 0, lc = 0;
2849 KDListView::DrawableItem * current;
2851 while ( (current = it.current()) != 0 ) {
2853 int ih = current->i->height();
2854 int ith = current->i->totalHeight();
2859 if ( ih > 0 && current->y < cy+ch && current->y+ih > cy ) {
2865 cs = header()->cellSize( 0 );
2866 while ( x + cs <= cx && c < header()->count() ) {
2869 if ( c < header()->count() )
2870 cs = header()->cellSize( c );
2874 while( x < cx + cw && c < header()->count() ) {
2877 if ( c < header()->count() )
2878 cs = header()->cellSize( c );
2887 const TQColorGroup &cg = ( palette().inactive() );
2889 while ( c < lc && !drawables.isEmpty() ) {
2890 int i = header()->mapToLogical( c );
2891 cs = header()->cellSize( c );
2892 r.setRect( x, current->y-cy, cs, ih );
2894 r.setLeft( r.left() + current->l * treeStepSize() );
2898 if ( !( r.width() == 0 || r.height() == 0 ) ) {
2899 p->translate( r.left(), r.top() );
2900 int ac = header()->mapToLogical( c );
2903 int align = columnAlignment( ac );
2904 if ( align == AlignAuto ) align = AlignLeft;
2905 bool sel = current->i->isSelected();
2907 current->i->setSelected(
false);
2908 current->i->paintCell( p, cg, ac, r.width(), align );
2910 current->i->setSelected(sel);
2919 const int cell = header()->mapToActual( 0 );
2922 tx = header()->cellPos( cell );
2960 void KDListView::resizeEvent(TQResizeEvent *)
2964 void KDListView::dragEnterEvent ( TQDragEnterEvent * e)
2966 if ( !myGanttView->dropEnabled() ) {
2970 myGanttView->lvDragEnterEvent(e);
2974 void KDListView::dragMoveEvent ( TQDragMoveEvent * e)
2976 if ( !myGanttView->dropEnabled() ) {
2982 setCurrentItem( gItem );
2983 if ( e->source() == myGanttView )
2984 draggedItem = myGanttView->myCanvasView->lastClickedItem;
2986 if (myGanttView->lvDragMoveEvent ( e , draggedItem, gItem ) )
2992 if ( e->source() == myGanttView && gItem ){
2996 if ( pItem == myGanttView->myCanvasView->lastClickedItem ) {
3002 if ( gItem == myGanttView->myCanvasView->lastClickedItem ) {
3010 void KDListView::dragLeaveEvent ( TQDragLeaveEvent * )
3014 void KDListView::dropEvent ( TQDropEvent *e )
3016 if ( !myGanttView->dropEnabled() ) {
3022 if ( e->source() == myGanttView )
3023 draggedItem = myGanttView->myCanvasView->lastClickedItem;
3024 if (myGanttView->lvDropEvent ( e, draggedItem, gItem ))
3030 if ( gItem == myGanttView->myCanvasView->lastClickedItem && gItem != 0 ) {
3031 tqDebug(
"KDGanttView::Possible bug in drag&drop code ");
3035 TQDomDocument doc(
"GanttView" );
3036 doc.setContent(
string );
3037 TQDomElement docRoot = doc.documentElement();
3038 TQDomNode node = docRoot.firstChild();
3039 bool enable = myGanttView->myTimeTable->blockUpdating( );
3040 myGanttView->myTimeTable->setBlockUpdating(
true );
3041 while( !node.isNull() ) {
3042 TQDomElement element = node.toElement();
3043 if( !element.isNull() ) {
3044 TQString tagName = element.tagName();
3045 if( tagName ==
"Items" ) {
3046 TQDomNode node = element.firstChild();
3047 while( !node.isNull() ) {
3048 TQDomElement element = node.toElement();
3049 if( !element.isNull() ) {
3050 TQString tagName = element.tagName();
3051 if( tagName ==
"Item" ) {
3059 tqDebug(
"Unrecognized tag name: %s", tagName.latin1() );
3064 node = node.nextSibling();
3069 node = node.nextSibling();
3072 newItem->resetSubitemVisibility();
3073 myGanttView->slot_lvDropped(e, draggedItem, gItem);
3074 myGanttView->myTimeTable->setBlockUpdating( enable );
3075 myGanttView->myTimeTable->updateMyContent();
3079 TQDragObject * KDListView::dragObject ()
3081 return TQListView::dragObject ();
3084 void KDListView::startDrag ()
3086 if ( ! myGanttView->dragEnabled() )
3089 myGanttView->myCanvasView->lastClickedItem = cItem;
3090 myGanttView->lvStartDrag (cItem);
3093 KDCanvasText::KDCanvasText( KDTimeTableWidget* canvas,
3096 TQCanvasText(canvas)
3098 myParentType = type;
3099 myParentItem = parentItem;
3103 KDCanvasLine::KDCanvasLine( KDTimeTableWidget* canvas,
3106 TQCanvasLine(canvas)
3108 myParentType = type;
3109 myParentItem = parentItem;
3113 KDCanvasPolygonItem::KDCanvasPolygonItem( KDTimeTableWidget* canvas,
3116 TQCanvasPolygonalItem( canvas )
3118 myParentType = type;
3119 myParentItem = parentItem;
3123 KDCanvasPolygon::KDCanvasPolygon( KDTimeTableWidget* canvas,
3126 TQCanvasPolygon( canvas )
3128 myParentType = type;
3129 myParentItem = parentItem;
3133 KDCanvasEllipse::KDCanvasEllipse( KDTimeTableWidget* canvas,
3136 TQCanvasEllipse( canvas )
3138 myParentType = type;
3139 myParentItem = parentItem;
3143 KDCanvasRectangle::KDCanvasRectangle( KDTimeTableWidget* canvas,
3146 TQCanvasRectangle( canvas )
3148 myParentType = type;
3149 myParentItem = parentItem;
3155 KDGanttCanvasView::KDGanttCanvasView(
KDGanttView* sender,TQCanvas* canvas, TQWidget* parent,
const
3156 char* name ) : TQCanvasView ( canvas, parent, name ),
3158 scrollBarTimer( 0,
"scrollBarTimer" )
3160 setHScrollBarMode (TQScrollView::AlwaysOn );
3161 setVScrollBarMode( TQScrollView::AlwaysOn );
3162 myToolTip =
new KDCanvasToolTip(viewport(),
this);
3163 mySignalSender = sender;
3169 linkItemsEnabled =
false;
3171 linkLine =
new TQCanvasLine(canvas);
3173 linkLine->setZ(1000);
3174 set_Mouse_Tracking(
true);
3175 new KDCanvasWhatsThis(viewport(),
this);
3176 onItem =
new TQPopupMenu(
this );
3177 TQPopupMenu * newMenu =
new TQPopupMenu(
this );
3178 TQPopupMenu * onView =
new TQPopupMenu(
this );
3179 onView->insertItem( i18n(
"Summary" ),
this,
3180 TQ_SLOT ( newRootItem(
int ) ), 0, 0 );
3181 onView->insertItem( i18n(
"Event" ),
this,
3182 TQ_SLOT ( newRootItem(
int ) ), 0, 1);
3183 onView->insertItem( i18n(
"Task" ),
this,
3184 TQ_SLOT ( newRootItem(
int ) ), 0, 2 );
3186 onItem->insertItem( i18n(
"New Root" ), onView );
3187 newMenu->insertItem( i18n(
"Summary" ),
3188 this, TQ_SLOT ( newChildItem(
int) ), 0, 0 );
3189 newMenu->insertItem( i18n(
"Event" ),
3190 this, TQ_SLOT ( newChildItem(
int ) ), 0, 1 );
3191 newMenu->insertItem( i18n(
"Task" ),
3192 this, TQ_SLOT ( newChildItem(
int ) ), 0, 2 );
3194 onItem->insertItem( i18n(
"New Child" ), newMenu );
3195 TQPopupMenu * afterMenu =
new TQPopupMenu(
this );
3196 afterMenu->insertItem( i18n(
"Summary" ),
3197 this, TQ_SLOT ( newChildItem(
int) ), 0, 0+4 );
3198 afterMenu->insertItem( i18n(
"Event" ),
3199 this, TQ_SLOT ( newChildItem(
int ) ), 0, 1+4 );
3200 afterMenu->insertItem( i18n(
"Task" ),
3201 this, TQ_SLOT ( newChildItem(
int ) ), 0, 2+4 );
3202 onItem->insertItem( i18n(
"New After" ), afterMenu );
3203 TQPopupMenu *pasteMenu =
new TQPopupMenu(
this );
3204 pasteMenu->insertItem( i18n(
"As Root" ),
3205 this, TQ_SLOT ( pasteItem(
int ) ), 0, 0 );
3206 pasteMenu->insertItem( i18n(
"As Child" ),
3207 this, TQ_SLOT ( pasteItem(
int ) ), 0, 1 );
3208 pasteMenu->insertItem( i18n(
"After" ),
3209 this, TQ_SLOT ( pasteItem(
int ) ), 0, 2 );
3210 onItem->insertItem( i18n(
"Paste" ), pasteMenu, 3 );
3211 onItem->insertItem( i18n(
"Cut Item" ),
this, TQ_SLOT ( cutItem() ) );
3212 onItem->setItemEnabled( 3,
false );
3213 myMyContentsHeight = 0;
3214 _showItemAddPopupMenu =
false;
3216 TQObject *scrollViewTimer = child(
"scrollview scrollbar timer",
"TQTimer",
false );
3217 Q_ASSERT( scrollViewTimer );
3218 if ( scrollViewTimer ) {
3219 disconnect( scrollViewTimer, TQ_SIGNAL(timeout()),
this, TQ_SLOT(updateScrollBars() ) );
3222 connect( &scrollBarTimer, TQ_SIGNAL(timeout()),
this, TQ_SLOT(myUpdateScrollBars() ) );
3224 myScrollTimer =
new TQTimer(
this,
"myScrollTimer" );
3225 connect( myScrollTimer, TQ_SIGNAL( timeout() ), TQ_SLOT( slotScrollTimer() ) );
3226 autoScrollEnabled =
false;
3230 KDGanttCanvasView::~KDGanttCanvasView()
3236 void KDGanttCanvasView::setShowPopupMenu(
bool show )
3238 _showItemAddPopupMenu = show;
3240 bool KDGanttCanvasView::showPopupMenu()
3242 return _showItemAddPopupMenu;
3246 void KDGanttCanvasView::moveMyContent(
int,
int y)
3248 setContentsPos(contentsX(), y);
3251 void KDGanttCanvasView::resizeEvent ( TQResizeEvent * e )
3253 int ho = e->oldSize().height();
3254 int wo = e->oldSize().width();
3259 verticalScrollBar()->setUpdatesEnabled(
false );
3260 TQScrollView::resizeEvent ( e ) ;
3262 emit heightResized( viewport()->height());
3264 emit widthResized( viewport()->width() );
3267 scrollBarTimer.start(0,
true);
3270 void KDGanttCanvasView::myUpdateScrollBars()
3272 setMyContentsHeight( 0 );
3274 void KDGanttCanvasView::setMyContentsHeight(
int hei )
3278 myMyContentsHeight = hei;
3279 verticalScrollBar()->setUpdatesEnabled(
true );
3280 if ( viewport()->height() <= myMyContentsHeight )
3281 verticalScrollBar()->setRange( 0, myMyContentsHeight- viewport()->height()+1);
3283 verticalScrollBar()->setRange( 0,0 );
3286 if ( horizontalScrollBar()->value() != mySignalSender->myTimeHeaderScroll->horizontalScrollBar()->value() ) {
3288 mySignalSender->myTimeHeaderScroll->horizontalScrollBar()->setValue(horizontalScrollBar()->value() );
3296 void KDGanttCanvasView::updateHorScrollBar() {
3299 horizontalScrollBar()->setRange(mySignalSender->myTimeHeaderScroll->horizontalScrollBar()->minValue(), mySignalSender->myTimeHeaderScroll->horizontalScrollBar()->maxValue());
3305 lastClickedItem = item;
3310 mySignalSender->myListView->insertItem( item );
3311 if ( item == cuttedItem )
3316 parent->insertItem( cuttedItem );
3317 if ( item == cuttedItem )
3322 if ( parent->
parent() ) {
3323 parent->
parent()->insertItem( item );
3326 mySignalSender->myListView->insertItem( item );
3327 item->moveItem( parent );
3328 if ( item == cuttedItem )
3332 void KDGanttCanvasView::cutItem()
3334 lastClickedItem->hideSubtree();
3336 if ( lastClickedItem->parent() )
3337 lastClickedItem->parent()->takeItem(lastClickedItem);
3339 mySignalSender->myListView->takeItem( lastClickedItem );
3340 mySignalSender->myTimeTable->updateMyContent();
3343 cuttedItem = lastClickedItem;
3344 onItem->setItemEnabled( 3,
true );
3351 if ( item == 0 && cuttedItem ) {
3355 if (item == cuttedItem) {
3356 onItem->setItemEnabled( 3,
false );
3361 void KDGanttCanvasView::pasteItem(
int type )
3367 mySignalSender->myListView->insertItem( cuttedItem );
3370 lastClickedItem->insertItem( cuttedItem );
3373 if ( lastClickedItem->parent() ) {
3374 lastClickedItem->parent()->insertItem( cuttedItem );
3377 mySignalSender->myListView->insertItem( cuttedItem );
3378 cuttedItem->moveItem( lastClickedItem );
3384 onItem->setItemEnabled( 3,
false );
3385 mySignalSender->myTimeTable->updateMyContent();
3387 void KDGanttCanvasView::newRootItem(
int type)
3404 mySignalSender->editItem( temp );
3407 void KDGanttCanvasView::newChildItem(
int type )
3421 if ( lastClickedItem->parent() )
3422 temp =
new KDGanttViewEventItem( lastClickedItem->parent(), lastClickedItem, i18n(
"New Event" ) );
3427 if ( lastClickedItem->parent() )
3433 if ( lastClickedItem->parent() )
3434 temp =
new KDGanttViewTaskItem( lastClickedItem->parent(), lastClickedItem, i18n(
"New Task" ) );
3444 mySignalSender->editItem( temp );
3447 void KDGanttCanvasView::drawToPainter ( TQPainter * p )
3449 drawContents ( p, 0, 0, canvas()->width(), canvas()->height() );
3451 TQString KDGanttCanvasView::getToolTipText(TQPoint p)
3453 TQCanvasItemList il = canvas()->collisions ( viewportToContents( p ));
3454 TQCanvasItemList::Iterator it;
3455 for ( it = il.begin(); it != il.end(); ++it ) {
3456 switch (getType(*it)) {
3457 case Type_is_KDGanttViewItem:
3458 return (getItem(*it))->tooltipText();
3460 case Type_is_KDGanttTaskLink:
3461 return (getLink(*it))->tooltipText();
3470 TQString KDGanttCanvasView::getWhatsThisText(TQPoint p)
3472 TQCanvasItemList il = canvas() ->collisions (viewportToContents( p ));
3473 TQCanvasItemList::Iterator it;
3474 for ( it = il.begin(); it != il.end(); ++it ) {
3475 switch (getType(*it)) {
3476 case Type_is_KDGanttViewItem:
3477 return (getItem(*it))->whatsThisText();
3479 case Type_is_KDGanttTaskLink:
3480 return (getLink(*it))->whatsThisText();
3490 KDGanttCanvasView::MovingOperation KDGanttCanvasView::gvItemHitTest(
KDGanttViewItem *item, KDTimeHeaderWidget* timeHeader,
const TQPoint &pos )
3492 const int left = timeHeader->getCoordX( item->
startTime() );
3493 const int right = timeHeader->getCoordX( item->
endTime() );
3494 const int width = right - left + 1;
3495 const int x = pos.x();
3496 if ( x < left + width / 10 )
3497 return KDGanttCanvasView::ResizingLeft;
3498 if ( x > right - width / 10 )
3499 return KDGanttCanvasView::ResizingRight;
3500 return KDGanttCanvasView::Moving;
3510 void KDGanttCanvasView::contentsMousePressEvent ( TQMouseEvent * e )
3519 if (e->button() == TQt::RightButton && mySignalSender->editable()) {
3520 lastClickedItem = (
KDGanttViewItem*) mySignalSender->myListView->itemAt( TQPoint(2,e->pos().y()));
3521 if ( lastClickedItem ) {
3522 if ( lastClickedItem->displaySubitemsAsGroup() && ! lastClickedItem->isOpen() ) {
3524 TQCanvasItemList il = canvas() ->collisions ( e->pos() );
3525 TQCanvasItemList::Iterator it;
3526 for ( it = il.begin(); it != il.end(); ++it ) {
3527 if ( getType(*it) == Type_is_KDGanttViewItem ) {
3528 lastClickedItem = getItem(*it);
3532 if ( _showItemAddPopupMenu )
3533 onItem->popup(e->globalPos());
3536 TQCanvasItemList il = canvas() ->collisions ( e->pos() );
3537 TQCanvasItemList::Iterator it;
3538 for ( it = il.begin(); it != il.end(); ++it ) {
3539 switch ( e->button() ) {
3540 case TQt::LeftButton:
3541 switch (getType(*it)) {
3542 case Type_is_KDGanttViewItem:
3543 currentItem = getItem(*it);
3544 if (! currentItem->enabled() ) {
3546 }
else if (linkItemsEnabled &&
3547 !currentItem->isMyTextCanvas(*it)) {
3548 fromArea = getItemArea(currentItem, e->pos().x());
3550 fromItem = currentItem;
3551 linkLine->setPoints(e->pos().x(), e->pos().y(), e->pos().x(), e->pos().y());
3556 KDCanvasRectangle *rect =
dynamic_cast<KDCanvasRectangle*
>( *it );
3559 if ( movingGVItem ) {
3560 movingStart = e->pos();
3561 movingStartDate = movingGVItem->
startTime();
3562 movingOperation = gvItemHitTest( movingGVItem, mySignalSender->myTimeHeader, e->pos() );
3563 if ( movingOperation == Moving && !movingGVItem->isMoveable() )
3565 else if ( movingOperation != Moving && !movingGVItem->isResizeable() )
3566 movingOperation = Moving;
3573 case Type_is_KDGanttTaskLink:
3574 currentLink = getLink(*it);
3576 case Type_is_KDGanttGridItem:
3577 if ( (*it)->rtti() == KDIntervalColorRectangle::RTTI ) {
3580 movingItem =
static_cast<TQCanvasRectangle *
>(*it);
3581 movingStart = e->pos();
3582 KDIntervalColorRectangle* icr =
static_cast<KDIntervalColorRectangle *
>( movingItem );
3583 KDIntervalColorRectangle::HitTest hitTest = icr->hitTest( mySignalSender->myTimeHeader, movingStart );
3584 movingOperation = hitTest == KDIntervalColorRectangle::Start ? ResizingLeft :
3585 hitTest == KDIntervalColorRectangle::End ? ResizingRight :
3593 case TQt::RightButton:
3594 switch (getType(*it)) {
3595 case Type_is_KDGanttViewItem:
3596 currentItem = getItem(*it);
3597 if (! currentItem->enabled() )
3600 case Type_is_KDGanttTaskLink:
3601 currentLink = getLink(*it);
3605 case TQt::MidButton:
3606 switch (getType(*it)) {
3607 case Type_is_KDGanttViewItem:
3608 currentItem = getItem(*it);
3609 if (! currentItem->enabled() )
3612 case Type_is_KDGanttTaskLink:
3613 currentLink = getLink(*it);
3621 if (e->button() == TQt::RightButton ) {
3622 mySignalSender->gvContextMenuRequested( currentItem, e->globalPos() );
3624 if (autoScrollEnabled && e->button() == TQt::LeftButton) {
3625 myScrollTimer->start(50);
3635 void KDGanttCanvasView::contentsMouseReleaseEvent ( TQMouseEvent * e )
3639 mySignalSender->gvMouseButtonClicked( e->button(), currentItem , e->globalPos() );
3645 switch ( e->button() ) {
3646 case TQt::LeftButton:
3647 myScrollTimer->stop();
3649 mySignalSender->itemLeftClicked( currentItem );
3650 mySignalSender->gvItemLeftClicked( currentItem );
3653 mySignalSender->taskLinkLeftClicked( currentLink );
3654 if (linkItemsEnabled && fromItem) {
3657 TQCanvasItemList il = canvas() ->collisions ( e->pos() );
3658 TQCanvasItemList::Iterator it;
3659 for ( it = il.begin(); it != il.end(); ++it ) {
3660 if (getType(*it) == Type_is_KDGanttViewItem) {
3662 if (!toItem->isMyTextCanvas(*it)) {
3663 int toArea = getItemArea(toItem, e->pos().x());
3664 if (toArea > 0 && toItem && fromItem != toItem) {
3665 mySignalSender->linkItems(fromItem, toItem, getLinkType(fromArea, toArea));
3673 if ( movingGVItem ) {
3674 mySignalSender->gvItemMoved( movingGVItem );
3678 case TQt::RightButton:
3680 mySignalSender->itemRightClicked( currentItem );
3681 mySignalSender->gvItemRightClicked( currentItem );
3685 mySignalSender->taskLinkRightClicked( currentLink );
3687 case TQt::MidButton:
3689 mySignalSender->itemMidClicked( currentItem );
3690 mySignalSender->gvItemMidClicked( currentItem );
3693 mySignalSender->taskLinkRightClicked( currentLink );
3699 if ( lastClicked != currentItem )
3700 mySignalSender->gvCurrentChanged( currentItem );
3701 lastClicked = currentItem;
3712 void KDGanttCanvasView::contentsMouseDoubleClickEvent ( TQMouseEvent * e )
3714 TQCanvasItemList il = canvas() ->collisions ( e->pos() );
3716 if ( il.isEmpty() && e->button() == TQt::LeftButton ) {
3718 mySignalSender->emptySpaceDoubleClicked(e);
3722 TQCanvasItemList::Iterator it;
3723 for ( it = il.begin(); it != il.end(); ++it ) {
3724 switch ( e->button() ) {
3725 case TQt::LeftButton:
3726 switch (getType(*it)) {
3727 case Type_is_KDGanttViewItem:
3728 if ( getItem(*it)->enabled() )
3729 mySignalSender->itemDoubleClicked(getItem(*it));
3730 mySignalSender->gvItemDoubleClicked(getItem(*it));
3733 case Type_is_KDGanttTaskLink:
3734 mySignalSender->taskLinkDoubleClicked(getLink(*it));
3779 void KDGanttCanvasView::contentsMouseMoveEvent ( TQMouseEvent *e )
3784 TQCanvasItemList il = canvas() ->collisions ( e->pos() );
3785 TQCanvasItemList::Iterator it;
3786 for ( it = il.begin(); it != il.end(); ++it ) {
3787 if ( (*it)->rtti() == KDIntervalColorRectangle::RTTI ) {
3789 KDIntervalColorRectangle* icr =
static_cast<KDIntervalColorRectangle *
>( *it );
3790 KDIntervalColorRectangle::HitTest hitTest = icr->hitTest( mySignalSender->myTimeHeader, e->pos() );
3791 switch ( hitTest ) {
3792 case KDIntervalColorRectangle::Start:
3793 case KDIntervalColorRectangle::End:
3794 setCursor( splitHCursor );
3803 MovingOperation op = gvItemHitTest( gvItem, mySignalSender->myTimeHeader, e->pos() );
3807 if ( gvItem->isResizeable() )
3808 setCursor( splitHCursor );
3820 const TQPoint p = e->pos();
3822 int x = tqRound( movingItem->x() );
3823 int width = movingItem->width();
3824 switch( movingOperation ) {
3826 x += p.x() - movingStart.x();
3828 case ResizingLeft: {
3829 width = tqRound( movingItem->x() + movingItem->width() - p.x() );
3838 if ( movingItem->rtti() == KDIntervalColorRectangle::RTTI ) {
3839 KDIntervalColorRectangle* icr =
static_cast<KDIntervalColorRectangle *
>(movingItem);
3840 const TQDateTime newStart = mySignalSender->myTimeHeader->getDateTimeForIndex(x);
3841 const TQDateTime newEnd = mySignalSender->myTimeHeader->getDateTimeForIndex(x + width);
3842 icr->setDateTimes( newStart, newEnd );
3843 emit mySignalSender->intervalColorRectangleMoved( newStart, newEnd );
3844 mySignalSender->myTimeHeader->computeIntervals( movingItem->height() );
3849 if ( movingGVItem ) {
3850 int dx = movingStart.x() - e->pos().x();
3851 int x = movingGVItem->middleLeft().x() - dx;
3852 TQDateTime dt = mySignalSender->getDateTimeForCoordX( x,
false );
3853 int duration = movingGVItem->startTime().secsTo( movingGVItem->endTime() );
3854 if ( movingOperation == Moving ) {
3855 movingGVItem->setStartTime( dt );
3856 movingGVItem->setEndTime( dt.addSecs( duration ) );
3857 }
else if ( movingOperation == ResizingLeft ) {
3858 movingGVItem->setStartTime( dt );
3859 }
else if ( movingOperation == ResizingRight ) {
3860 movingGVItem->setEndTime( dt.addSecs( duration ) );
3862 movingStart = e->pos();
3865 static int moves = 0;
3866 if ( (currentLink || currentItem) && (moves < 3) ) {
3873 if (autoScrollEnabled)
3874 mousePos = e->pos()- TQPoint(contentsX(),contentsY());
3877 linkLine->setPoints(linkLine->startPoint().x(), linkLine->startPoint().y(), e->pos().x(), e->pos().y());
3882 void KDGanttCanvasView::viewportPaintEvent ( TQPaintEvent * pe )
3884 TQCanvasView::viewportPaintEvent ( pe );
3886 void KDGanttCanvasView::set_Mouse_Tracking(
bool on)
3888 viewport()->setMouseTracking(on);
3890 int KDGanttCanvasView::getType(TQCanvasItem* it)
3892 switch (it->rtti()) {
3893 case TQCanvasItem::Rtti_Line:
return ((KDCanvasLine*)it)->myParentType;
3894 case TQCanvasItem::Rtti_Ellipse:
return ((KDCanvasEllipse *)it)->myParentType;
3895 case TQCanvasItem::Rtti_Text:
return ((KDCanvasText *)it)->myParentType;
3896 case TQCanvasItem::Rtti_Polygon:
return ((KDCanvasPolygon *)it)->myParentType;
3897 case TQCanvasItem::Rtti_Rectangle:
3898 case KDIntervalColorRectangle::RTTI:
3899 return ((KDCanvasRectangle *)it)->myParentType;
3905 switch (it->rtti()) {
3906 case TQCanvasItem::Rtti_Line:
return (
KDGanttViewItem*) ((KDCanvasLine*)it)->myParentItem;
3907 case TQCanvasItem::Rtti_Ellipse:
return (
KDGanttViewItem*) ((KDCanvasEllipse *)it)->myParentItem;
3908 case TQCanvasItem::Rtti_Text:
return (
KDGanttViewItem*) ((KDCanvasText *)it)->myParentItem;
3909 case TQCanvasItem::Rtti_Polygon:
return (
KDGanttViewItem*) ((KDCanvasPolygon *)it)->myParentItem;
3910 case TQCanvasItem::Rtti_Rectangle:
return (
KDGanttViewItem*) ((KDCanvasRectangle *)it)->myParentItem;
3917 switch (it->rtti()) {
3918 case TQCanvasItem::Rtti_Line:
return (
KDGanttViewTaskLink*) ((KDCanvasLine*)it)->myParentItem;
3919 case TQCanvasItem::Rtti_Ellipse:
return (
KDGanttViewTaskLink*) ((KDCanvasEllipse *)it)->myParentItem;
3920 case TQCanvasItem::Rtti_Text:
return (
KDGanttViewTaskLink*) ((KDCanvasText *)it)->myParentItem;
3921 case TQCanvasItem::Rtti_Polygon:
return (
KDGanttViewTaskLink*) ((KDCanvasPolygon *)it)->myParentItem;
3926 void KDGanttCanvasView::slotScrollTimer() {
3927 int mx = mousePos.x();
3928 int my = mousePos.y();
3933 else if (mx > visibleWidth())
3937 else if (my > visibleHeight())
3938 dy = TQMIN(5, verticalScrollBar()->maxValue()-verticalScrollBar()->value());
3940 if (dx != 0 || dy != 0)
3947 KDTimeTableWidget *tt =
dynamic_cast<KDTimeTableWidget *
>(canvas());
3949 tqWarning(
"Cannot cast canvas to KDTimeTableWidget");
3953 int start = tt->getCoordX(item->
startTime());
3955 if (item->
type() == KDGanttViewItem::Event) {
3956 x > start ? area = 2 : area = 1;
3958 end = tt->getCoordX(item->
endTime());
3959 if ((end - start)/2 > (x - start))
3967 int KDGanttCanvasView::getLinkType(
int from,
int to) {
3969 if ((from == 1) && (to == 1)) {
3970 return KDGanttViewTaskLink::StartStart;
3972 if ((from == 1) && (to == 2)) {
3973 return KDGanttViewTaskLink::StartFinish;
3975 if ((from == 2) && (to == 1)) {
3976 return KDGanttViewTaskLink::FinishStart;
3978 if ((from == 2) && (to == 2)) {
3979 return KDGanttViewTaskLink::FinishFinish;
3981 return KDGanttViewTaskLink::None;
3989 KDIntervalColorRectangle::KDIntervalColorRectangle(
KDGanttView* view )
3990 : KDCanvasRectangle( view->timeTableWidget(), 0, Type_is_KDGanttGridItem ),
4000 void KDIntervalColorRectangle::setDateTimes(
const TQDateTime& start,
4001 const TQDateTime& end )
4005 if ( mEnd < mStart )
4006 tqSwap( mStart, mEnd );
4013 void KDIntervalColorRectangle::setColor(
const TQColor& color )
4021 void KDIntervalColorRectangle::layout( KDTimeHeaderWidget* timeHeader,
int height )
4023 int left = timeHeader->getCoordX(mStart);
4024 int right = timeHeader->getCoordX(mEnd);
4025 if ( right == left )
4027 setPen( TQPen(TQPen::NoPen) );
4028 setBrush( TQBrush(mColor, TQt::SolidPattern) );
4029 setSize( right - left, height );
4037 KDIntervalColorRectangle::HitTest KDIntervalColorRectangle::hitTest( KDTimeHeaderWidget* timeHeader,
const TQPoint& pos )
const
4039 const int left = timeHeader->getCoordX(mStart);
4040 const int right = timeHeader->getCoordX(mEnd);
4041 const int width = right - left + 1;
4042 const int x = pos.x();
4043 if ( x < left + width / 10 )
4045 if ( x > right - width / 10 )
The KDGanttMinimizeSplitter class implements a splitter widget with minimize buttons.
static bool decode(const TQMimeSource *e, TQString &)
static bool canDecode(const TQMimeSource *e)
KDGanttViewItem * itemBelow(bool includeDisabled=true)
TQString whatsThisText() const
KDGanttViewItem * nextSibling() const
KDGanttViewItem * parent() const
TQDateTime endTime() const
static KDGanttViewItem * createFromDomElement(KDGanttView *view, TQDomElement &element)
void setDisplaySubitemsAsGroup(bool show)
KDGanttViewItem * firstChild() const
bool isVisibleInGanttView
TQDateTime startTime() const
static TQPixmap getPixmap(KDGanttViewItem::Shape shape, const TQColor &shapeColor, const TQColor &backgroundColor, int itemSize)