19 #include "timelineitem.h"
23 #define protected public
24 #include <kdgantt/KDGanttViewSubwidgets.h>
28 #include <libkcal/incidenceformatter.h>
29 #include <libkcal/resourcecalendar.h>
34 TimelineItem::TimelineItem(
const TQString &label,
KCal::Calendar *calendar, KDGanttView * parent) :
35 KDGanttViewTaskItem( parent ), mCalendar( calendar )
37 setListViewText( 0, label );
38 setDisplaySubitemsAsGroup(
true );
40 listView()->setRootIsDecorated(
false );
43 void TimelineItem::insertIncidence(
KCal::Incidence * incidence,
const TQDateTime & _start,
const TQDateTime & _end)
45 TQDateTime start = incidence->
dtStart(), end = incidence->
dtEnd();
46 if ( _start.isValid() )
51 end = end.addDays( 1 );
53 typedef TQValueList<TimelineSubItem*> ItemList;
54 ItemList list = mItemMap[incidence];
55 for ( ItemList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it )
56 if ( (*it)->startTime() == start && (*it)->endTime() == end )
59 TimelineSubItem * item =
new TimelineSubItem( mCalendar, incidence,
this );
62 item->setColors( c1, c2, c3 );
64 item->setStartTime( start );
65 item->setOriginalStart( start );
66 item->setEndTime( end );
68 mItemMap[incidence].append( item );
73 typedef TQValueList<TimelineSubItem*> ItemList;
74 ItemList list = mItemMap[incidence];
75 for ( ItemList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it )
77 mItemMap.remove( incidence );
80 void TimelineItem::moveItems(
KCal::Incidence * incidence,
int delta,
int duration)
82 typedef TQValueList<TimelineSubItem*> ItemList;
83 ItemList list = mItemMap[incidence];
84 for ( ItemList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it ) {
85 TQDateTime start = (*it)->originalStart();
86 start = start.addSecs( delta );
87 (*it)->setStartTime( start );
88 (*it)->setOriginalStart( start );
89 (*it)->setEndTime( start.addSecs( duration ) );
96 KDGanttViewTaskItem( parent ),
97 mIncidence( incidence ),
102 setTooltipText( IncidenceFormatter::toolTipStr( calendar, incidence,
103 originalStart().date(),
true ) );
106 setResizeable(
true );
110 TimelineSubItem::~TimelineSubItem()
116 void TimelineSubItem::showItem(
bool show,
int coordY)
118 KDGanttViewTaskItem::showItem( show, coordY );
124 int startX = myGanttView->timeHeaderWidget()->getCoordX(myStartTime);
125 int endX = myGanttView->timeHeaderWidget()->getCoordX(myEndTime);
127 const int mw = TQMAX( 1, TQMIN( 4, endX - startX ) );
128 if ( !mLeft || mw != mMarkerWidth ) {
130 mLeft =
new KDCanvasPolygon( myGanttView->timeTableWidget(),
this, Type_is_KDGanttViewItem );
131 mLeft->setBrush( TQt::black );
133 TQPointArray a = TQPointArray( 4 );
134 a.setPoint( 0, 0, -mw -myItemSize/2 - 2 );
135 a.setPoint( 1, mw, -myItemSize/2 - 2 );
136 a.setPoint( 2, mw, myItemSize/2 + 2 );
137 a.setPoint( 3, 0, myItemSize/2 + mw + 2 );
138 mLeft->setPoints( a );
140 if ( !mRight || mw != mMarkerWidth ) {
142 mRight =
new KDCanvasPolygon( myGanttView->timeTableWidget(),
this, Type_is_KDGanttViewItem );
143 mRight->setBrush( TQt::black );
145 TQPointArray a = TQPointArray( 4 );
146 a.setPoint( 0, -mw, -myItemSize/2 - 2 );
147 a.setPoint( 1, 0, -myItemSize/2 - mw - 2 );
148 a.setPoint( 2, 0, myItemSize/2 + mw + 2 );
149 a.setPoint( 3, -mw, myItemSize/2 + 2 );
150 mRight->setPoints( a );
153 mLeft->setX( startX );
155 mLeft->setZ( startShape->z() - 1 );
157 mRight->setX( endX );
159 mRight->setZ( startShape->z() - 1 );
virtual TQDateTime dtStart() const
virtual TQDateTime dtEnd() const