kdgantt

KDGanttViewEventItem.cpp
1/*
2 $Id$
3 KDGantt - a multi-platform charting engine
4*/
5
6/****************************************************************************
7 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
8 **
9 ** This file is part of the KDGantt library.
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 as published by the Free Software
13 ** Foundation and appearing in the file LICENSE.GPL included in the
14 ** packaging of this file.
15 **
16 ** Licensees holding valid commercial KDGantt licenses may use this file in
17 ** accordance with the KDGantt Commercial License Agreement provided with
18 ** the Software.
19 **
20 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 **
23 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
24 ** information about KDGantt Commercial License Agreements.
25 **
26 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
27 ** licensing are not clear to you.
28 **
29 ** As a special exception, permission is given to link this program
30 ** with any edition of TQt, and distribute the resulting executable,
31 ** without including the source code for TQt in the source distribution.
32 **
33 **********************************************************************/
34
35
36#include "KDGanttViewEventItem.h"
37#include "KDGanttViewSubwidgets.h"
38#include "itemAttributeDialog.h"
39
56 const TQString& lvtext,
57 const TQString& name ) :
58 KDGanttViewItem( Event, view, lvtext, name )
59{
60 initItem();
61}
62
63
73 const TQString& lvtext,
74 const TQString& name ) :
75 KDGanttViewItem( Event, parent, lvtext, name )
76{
77 initItem();
78
79}
80
81
92 KDGanttViewItem* after,
93 const TQString& lvtext,
94 const TQString& name ) :
95 KDGanttViewItem( Event, view, after, lvtext, name )
96{
97
98 initItem();
99}
100
101
112 KDGanttViewItem* after,
113 const TQString& lvtext,
114 const TQString& name ) :
115 KDGanttViewItem( Event, parent, after, lvtext, name )
116{
117
118 initItem();
119}
120
121
126{
127
128
129}
139void KDGanttViewEventItem::setStartTime( const TQDateTime& start )
140{
141 if (! start.isValid() ) {
142 tqDebug("KDGanttViewEventItem::setStartTime():Invalid parameter-no time set");
143 return;
144 }
145 myStartTime = start;
146 myEndTime = start;
147 if ( myStartTime < leadTime() )
149 else {
151 }
152
153}
154
155
167void KDGanttViewEventItem::setLeadTime( const TQDateTime& leadTimeStart )
168{
169 if (!myLeadTime) myLeadTime = new TQDateTime;
170 *myLeadTime = leadTimeStart;
171 if ( startTime() < leadTime() )
172 setStartTime( leadTimeStart );
173 else {
175 }
176
177}
178
179
190{
191 if(myLeadTime)
192 return *myLeadTime;
193 return myStartTime;
194}
195
196
197void KDGanttViewEventItem::hideMe()
198{
199 startShape->hide();
200 startShapeBack->hide();
201 startLine->hide();
202 startLineBack->hide();
203 textCanvas->hide();
204 floatStartShape->hide();
205 floatEndShape->hide();
206}
207
208
209void KDGanttViewEventItem::showItem(bool show, int coordY)
210{
212 invalidateHeight () ;
213 if (!show) {
214 hideMe();
215 return;
216 }
217 float prio = ((float) ( priority() - 100 )) / 100.0;
218 startShape->setZ( prio + 0.0055 );
219 startShapeBack->setZ( prio + 0.003 );
220 startLine->setZ( prio + 0.0015 );
221 floatStartShape->setZ(prio + 0.004);
222 floatStartShape->hide();
223 floatEndShape->setZ(prio + 0.004);
224 floatEndShape->hide();
225 textCanvas->setZ( prio + 0.006 );
226 startLineBack->setZ( prio );
227
228 if ( displaySubitemsAsGroup() && firstChild() ) {
231 }
232 int startX, endX, allY;
233 if ( coordY )
234 allY = coordY;
235 else
236 allY = getCoordY();
237 startX = myGanttView->myTimeHeader->getCoordX(myStartTime);
238 if (myLeadTime) {
239 endX = myGanttView->myTimeHeader->getCoordX(*myLeadTime);
240 startLine->setPoints(startX,allY,endX,allY);
241 startLine->show();
242 startLineBack->setPoints(startX+1,allY,endX-1,allY);
243 startLineBack->show();
244 }
245 else {
246 startLine->hide();
247 startLineBack->hide();
248 }
249 startShape->move(startX,allY);
250 startShape->show();
251 startShapeBack->move(startX,allY);
252 startShapeBack->show();
253 if (myFloatStartTime.isValid()) {
254 KDCanvasRectangle* floatStartTemp = (KDCanvasRectangle*) floatStartShape;
255 int floatStartX = myGanttView->myTimeHeader->getCoordX(myFloatStartTime);
256 int hei = startShape->boundingRect().height();
257 // FIXME: Configurable colors
258 TQBrush b(startShape->brush().color(), Dense4Pattern);
259 floatStartTemp->setBrush(b);
260 floatStartTemp->setPen(TQPen(gray));
261 if (floatStartX < startX) {
262 floatStartTemp->setSize(startX - floatStartX, hei/2);
263 floatStartTemp->move(floatStartX, allY-hei/4);
264 } else {
265 floatStartTemp->setSize(floatStartX - startX, hei/2);
266 floatStartTemp->move(startX, allY-hei/4);
267 }
268 floatStartShape->show();
269 }
270 if (myFloatEndTime.isValid()) {
271 KDCanvasRectangle* floatEndTemp = (KDCanvasRectangle*) floatEndShape;
272 int floatEndX = myGanttView->myTimeHeader->getCoordX(myFloatEndTime);
273 int hei = startShape->boundingRect().height();
274 // FIXME: Configurable colors
275 TQBrush b(startShape->brush().color(), Dense4Pattern);
276 floatEndTemp->setBrush(b);
277 floatEndTemp->setPen(TQPen(gray));
278 if (floatEndX > startX) {
279 floatEndTemp->setSize(floatEndX - startX, hei/2);
280 floatEndTemp->move(startX, allY-hei/4);
281 } else {
282 floatEndTemp->setSize(startX - floatEndX, hei/2);
283 floatEndTemp->move(floatEndX, allY-hei/4);
284 }
285 floatEndShape->show();
286 }
287
288 moveTextCanvas(startX,allY);
289 textCanvas->show();
290 if (textCanvas->text().isEmpty())
291 textCanvas->hide();
292}
293
294
295void KDGanttViewEventItem::initItem()
296{
297 isVisibleInGanttView = false;
298 myLeadTime = 0;
299 showItem(true);
300 myGanttView->myTimeTable->updateMyContent();
301 setDragEnabled( myGanttView->dragEnabled() );
302 setDropEnabled( myGanttView->dropEnabled() );
303}
304
305
306
TQDateTime leadTime() const
KDGanttViewEventItem(KDGanttView *view, const TQString &lvtext=TQString(), const TQString &name=TQString())
void setLeadTime(const TQDateTime &leadTimeStart)
void setStartTime(const TQDateTime &start)
KDCanvasText * textCanvas
KDCanvasPolygonItem * startShape
TQDateTime myStartTime
void moveTextCanvas(int x, int y)
KDCanvasPolygonItem * startShapeBack
TQDateTime myChildStartTime()
KDGanttView * myGanttView
KDCanvasLine * startLineBack
bool displaySubitemsAsGroup() const
KDGanttViewItem * firstChild() const
TQDateTime myEndTime
KDCanvasLine * startLine
TQDateTime myChildEndTime()
TQDateTime startTime() const
bool dragEnabled() const
bool dropEnabled() const