summaryrefslogtreecommitdiffstats
path: root/kgantt/kgantt/KGantt.h
blob: 200b5a434259241d0d2a0e23d4385f216e7eeeb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#ifndef _KGANTT_H_
#define _KGANTT_H_
 
/*

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.

    author  : jh, jochen@ifb.bv.tu-berlin.de

    file    : KGantt.h
    date    : 26 oct 2000


    changelog : 23 nov 2000, jh

                24 nov 2000, jh

		10 jan 2001m jh, changed to KDE :
		xQGantt -> KGantt

*/


#include <tqwidget.h>
#include <tqsplitter.h> 

#include <kpopupmenu.h>
#include <tdepimmacros.h>

#include "KGanttItem.h"
#include "xQGanttListView.h"
#include "xQGanttBarView.h"



/**
 *  \mainpage KGantt Module <br> <IMG SRC="gantt.png">
 *
 *  The kgantt module contains several classes (KGanttItem, KGantt)
 *  for drawing and editing gantt-diagramms.
 *
 *  This example shows how to use the gantt module:
 *  \code
 *  #include "kgantt/KGantt.h"
 *  
 *  int main(int args, char* argv[])
 *  {
       ...

       KGantt* gantt = new KGantt(0, mainwindow);

       KGanttItem* toplevel = gantt->getToplevelItem();

       KGanttItem* t1 = new KGanttItem(toplevel, 
                                       "task 1, no subtasks", 
                	               TQDateTime::currentDateTime().addDays(10),
                                       TQDateTime::currentDateTime().addDays(20) );

       ...

 *  }
 *  \endcode
 *
 *  You just have to create an object of class KGantt and add several objects of
 *  class KGanttItem.
 *
 */



///  Gantt Widget.
/*!
 *   A gantt widget contains two parts, a list view and a
 *   bar view.
 */
////////////////////////////////
class KDE_EXPORT KGantt : public TQWidget
////////////////////////////////
{

  Q_OBJECT
  


public:  


  ///  Constructor.
  /*!
   *
   */
  KGantt(KGanttItem* toplevelitem = 0,
	 TQWidget* parent = 0, const char * name=0, WFlags f=0 );


  ///  Destructor.
  /*!
   *
   */
  ~KGantt();



  ///  Set toplevel item.
  /*!
   *   If no toplevel item was specified at construction of this widget a
   *   toplevel item was created. This will be deleted by setting a new
   *   toplevel item. A toplevel item that was passed to the constructor will
   *   not be deleted.
   */
  void setToplevelItem(KGanttItem* item) {
    if(_deleteItem)
      delete _toplevelitem;
    _toplevelitem = item; 
  }



  ///  Get toplevel item.
  /*!
   *
   */
  KGanttItem* getToplevelItem() { 
    return _toplevelitem; 
  }



  ///  Get bar view of items.
  /*!
   *
   */
  xQGanttBarView* barView() {
    return _ganttbar;
  }



  ///  Get list view of items.
  /*!
   *
   */
  xQGanttListView* listView() {
    return _ganttlist;
  }



  TQSplitter* splitter() {
    return _splitter;
  }


  
  ///
  /*!
   *
   */
  void zoom(double factor) {
    barView()->viewport()->zoom(factor);
  }



  ///  Get popup menu.
  /*!
   *
   */
  KPopupMenu* menu() {
    return _ganttbar->viewport()->menu();
  }



  ///  Add gantt toolbar to main window.
  /*!
   *   If you want to embed a toolbar with specific actions
   *   like zooming or configuring the gantt, you can add a toolbar
   *   automatically by invoking this method. You have to pass your
   *   mainwindow as a parameter if you call this method the first
   *   time because teh toolbar will be created then. If you
   *   you want to access the pointer to a already created toolbar you
   *   can invoke this method without any parameter.
   */
  KToolBar* toolbar(TQMainWindow* mw = 0) {
    return _ganttbar->viewport()->toolbar(mw);
  }



  ///  Print to stdout.
  /*
   *
   */
  void dumpItems();



  ///  Get all selected items.
  /*!
   *   All selected KGanttItems will be added to the passed list. 
   */
  void getSelectedItems(TQPtrList<KGanttItem>& list) {
    _ganttbar->viewport()->getSelectedItems(list);
  }



  void addHoliday(int y, int m, int d) {
    _ganttbar->viewport()->addHoliday(y,m,d);
  }



  void removeHoliday(int y, int m, int d) {
    _ganttbar->viewport()->addHoliday(y,m,d);
  }



public slots:


  void setSelect() {
    _ganttbar->viewport()->setSelect();
  }

  void setZoom() {
    _ganttbar->viewport()->setZoom();
  }

  void setMove() {
    _ganttbar->viewport()->setMove();
  }


  void zoomIn() {
    _ganttbar->viewport()->zoomIn();
  }

  void zoomOut() {
    _ganttbar->viewport()->zoomOut();
  }

  void zoomAll() {
    _ganttbar->viewport()->zoomAll();
  }

  void selectAll() {
    _ganttbar->viewport()->selectAll();
  }

  void unselectAll() {
    _ganttbar->viewport()->unselectAll();
  }

  void deleteSelectedItems() {
    _ganttbar->viewport()->deleteSelectedItems();
  }

  void insertIntoSelectedItem() {
    _ganttbar->viewport()->insertIntoSelectedItem();
  }


  ///  Show list view.
  /*!
   *
   */
  void showList() {
    _ganttlist->show();
  }


  ///  Hide list view.
  /*
   *
   */
  void hideList() {
    _ganttlist->hide();
  }


protected:


  void resizeEvent(TQResizeEvent* /*e*/) {
    _splitter->resize(width(),height());
  };


private:

  KGanttItem* _toplevelitem;

  TQSplitter *_splitter;

  xQGanttBarView* _ganttbar;
  xQGanttListView* _ganttlist;

  bool _deleteItem;

};


#endif