korganizer

timelineitem.h
1 /*
2  Copyright (c) 2007 Volker Krause <vkrause@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
19 #ifndef KORG_TIMELINEITEM_H
20 #define KORG_TIMELINEITEM_H
21 
22 #define private protected
23 #include <kdgantt/KDGanttViewTaskItem.h>
24 #undef protected
25 
26 #include <tqmap.h>
27 #include <tqvaluelist.h>
28 
29 class KDGanttView;
30 class KDCanvasPolygon;
31 
32 namespace KCal {
33  class Calendar;
34  class ResourceCalendar;
35  class Incidence;
36 }
37 
38 namespace KOrg {
39 
40 class TimelineSubItem;
41 
42 class TimelineItem : public KDGanttViewTaskItem
43 {
44  public:
45  TimelineItem( const TQString &label, KCal::Calendar *calendar, KDGanttView* parent );
46 
47  void insertIncidence( KCal::Incidence *incidence,
48  const TQDateTime &start = TQDateTime(),
49  const TQDateTime &end = TQDateTime() );
50  void removeIncidence( KCal::Incidence *incidence );
51 
52  void moveItems( KCal::Incidence* incidence, int delta, int duration );
53 
54  private:
55  KCal::Calendar *mCalendar;
56  TQMap<KCal::Incidence*, TQValueList<TimelineSubItem*> > mItemMap;
57 };
58 
59 class TimelineSubItem : public KDGanttViewTaskItem
60 {
61  public:
62  TimelineSubItem( KCal::Calendar *calendar, KCal::Incidence *incidence, TimelineItem *parent );
63  ~TimelineSubItem();
64 
65  KCal::Incidence* incidence() const { return mIncidence; }
66 
67  TQDateTime originalStart() const { return mStart; }
68  void setOriginalStart( const TQDateTime &dt ) { mStart = dt; }
69 
70  private:
71  void showItem( bool show = true, int coordY = 0 );
72 
73  private:
74  KCal::Incidence *mIncidence;
75  TQDateTime mStart;
76  KDCanvasPolygon *mLeft, *mRight;
77  int mMarkerWidth;
78 };
79 
80 }
81 
82 #endif