kdgantt

itemAttributeDialog.ui.h
1 /****************************************************************************
2  ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
3  **
4  ** This file is part of the KDGantt library.
5  **
6  ** This file may be distributed and/or modified under the terms of the
7  ** GNU General Public License version 2 as published by the Free Software
8  ** Foundation and appearing in the file LICENSE.GPL included in the
9  ** packaging of this file.
10  **
11  ** Licensees holding valid commercial KDGantt licenses may use this file in
12  ** accordance with the KDGantt Commercial License Agreement provided with
13  ** the Software.
14  **
15  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17  **
18  ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
19  ** information about KDGantt Commercial License Agreements.
20  **
21  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
22  ** licensing are not clear to you.
23  **
24  ** As a special exception, permission is given to link this program
25  ** with any edition of TQt, and distribute the resulting executable,
26  ** without including the source code for TQt in the source distribution.
27  **
28  **********************************************************************/
29 
30 
31 /****************************************************************************
32 ** ui.h extension file, included from the uic-generated form implementation.
33 **
34 ** If you wish to add, delete or rename slots use TQt Designer which will
35 ** update this file, preserving your code. Create an init() slot in place of
36 ** a constructor, and a destroy() slot in place of a destructor.
37 *****************************************************************************/
38 
39 #include <tqcolordialog.h>
40 void itemAttributeDialog::init( )
41 {
42 
43  myItem = 0;
44 }
45 
46 
47 
48 
49 void itemAttributeDialog::ChangeText_clicked()
50 {
51  if ( !myItem) return;
52  TQColor c = TQColorDialog::getColor( myItem->textColor(), this );
53  if ( c.isValid() )
54  myItem->setTextColor( c );
55  TQPixmap * pix = (TQPixmap *)ChangeText->pixmap();
56  pix->fill( myItem->textColor() );
57  ChangeText->repaint();
58 }
59 
60 
61 void itemAttributeDialog::ChangeStart_clicked()
62 {
63  if ( !myItem) return;
64  KDGanttViewItem::Shape start, middle, end;
65  myItem->shapes( start, middle, end );
66  TQColor st, mi, en;
67  myItem->colors( st, mi, en );
68  TQColor c = TQColorDialog::getColor( st, this );
69  if ( c.isValid() ) {
70  st = c;
71  ChangeStart->setPixmap( KDGanttView::getPixmap( start, st, backgroundColor(), 10 ) );
72  myItem->setColors( st, mi, en );
73  }
74 
75 }
76 
77 
78 void itemAttributeDialog::ChangeMiddle_clicked()
79 {
80  if ( !myItem) return;
81  KDGanttViewItem::Shape start, middle, end;
82  myItem->shapes( start, middle, end );
83  TQColor st, mi, en;
84  myItem->colors( st, mi, en );
85  TQColor c = TQColorDialog::getColor( mi, this );
86  if ( c.isValid() ) {
87  mi = c;
88  ChangeMiddle->setPixmap( KDGanttView::getPixmap( middle, mi, backgroundColor(), 10 ) );
89  myItem->setColors( st, mi, en );
90  }
91 }
92 
93 
94 void itemAttributeDialog::ChangeEnd_clicked()
95 {
96  if ( !myItem) return;
97  KDGanttViewItem::Shape start, middle, end;
98  myItem->shapes( start, middle, end );
99  TQColor st, mi, en;
100  myItem->colors( st, mi, en );
101  TQColor c = TQColorDialog::getColor( en, this );
102  if ( c.isValid() ) {
103  en = c;
104  ChangeEnd->setPixmap( KDGanttView::getPixmap( end, en, backgroundColor(), 10 ) );
105  myItem->setColors( st, mi, en );
106  }
107 }
108 void itemAttributeDialog::resetTime( KDGanttViewItem * item )
109 {
110  if ( !item ) return;
111  myItem = 0;
112  DateEdit1->setDate( item->startTime().date() );
113  TimeEdit1->setTime( item->startTime().time() );
114  switch( item->type() ) {
115  case KDGanttViewItem::Event:
116 
117  DateEdit4->setDate( ((KDGanttViewEventItem*)item)->leadTime().date() );
118  TimeEdit4->setTime( ((KDGanttViewEventItem*)item)->leadTime().time() );
119 
120  break;
121  case KDGanttViewItem::Summary:
122 
123 
124  DateEdit3->setDate( item->endTime().date() );
125  TimeEdit3->setTime( item->endTime().time() );
126  DateEdit2->setDate(((KDGanttViewSummaryItem*)item) ->middleTime().date() );
127  TimeEdit2->setTime( ((KDGanttViewSummaryItem*)item)->middleTime().time() );
128  DateEdit5->setDate(((KDGanttViewSummaryItem*)item) ->actualEndTime().date() );
129  TimeEdit5->setTime( ((KDGanttViewSummaryItem*)item)->actualEndTime().time() );
130  break;
131  case KDGanttViewItem::Task:
132 
133 
134  DateEdit3->setDate( item->endTime().date() );
135  TimeEdit3->setTime( item->endTime().time() );
136  break;
137  default:
138  ;
139  }
140  myItem = item;
141 }
142 
143 void itemAttributeDialog::reset( KDGanttViewItem * item )
144 {
145  myItem = 0;
146  if ( !item ) {
147  hide();
148  return;
149  }
150  StartBox->setEnabled( true );
151  switch( item->type() ) {
152  case KDGanttViewItem::Event:
153  MiddleBox->setEnabled( false );
154  EndBox->setEnabled( false );
155  ChangeMiddle->setEnabled( false );
156  ChangeEnd->setEnabled( false );
157  HighMiddle->setEnabled( false );
158  HighEnd->setEnabled( false );
159  DateEdit2->setEnabled( false );
160  TimeEdit2->setEnabled( false );
161  DateEdit3->setEnabled( false );
162  TimeEdit3->setEnabled( false );
163  DateEdit4->setEnabled( true );
164  TimeEdit4->setEnabled( true );
165  DateEdit5->setEnabled( false );
166  TimeEdit5->setEnabled( false );
167  DateEdit4->setDate( ((KDGanttViewEventItem*)item)->leadTime().date() );
168  TimeEdit4->setTime( ((KDGanttViewEventItem*)item)->leadTime().time() );
169 
170  break;
171  case KDGanttViewItem::Summary:
172  MiddleBox->setEnabled( true );
173  EndBox->setEnabled( true );
174  ChangeMiddle->setEnabled( true );
175  ChangeEnd->setEnabled( true );
176  HighMiddle->setEnabled( true );
177  HighEnd->setEnabled( true );
178 
179  DateEdit2->setEnabled( true );
180  TimeEdit2->setEnabled( true );
181  DateEdit3->setEnabled( true );
182  TimeEdit3->setEnabled( true );
183  DateEdit4->setEnabled( false );
184  TimeEdit4->setEnabled( false );
185  DateEdit5->setEnabled( true );
186  TimeEdit5->setEnabled( true );
187 
188  DateEdit3->setDate( item->endTime().date() );
189  TimeEdit3->setTime( item->endTime().time() );
190  DateEdit2->setDate(((KDGanttViewSummaryItem*)item) ->middleTime().date() );
191  TimeEdit2->setTime( ((KDGanttViewSummaryItem*)item)->middleTime().time() );
192  DateEdit5->setDate(((KDGanttViewSummaryItem*)item) ->actualEndTime().date() );
193  TimeEdit5->setTime( ((KDGanttViewSummaryItem*)item)->actualEndTime().time() );
194  break;
195  case KDGanttViewItem::Task:
196  MiddleBox->setEnabled( false );
197  StartBox->setEnabled( false );
198  EndBox->setEnabled( false );
199  ChangeMiddle->setEnabled( false );
200  ChangeEnd->setEnabled( false );
201  HighMiddle->setEnabled( false );
202  HighEnd->setEnabled( false );
203 
204  DateEdit2->setEnabled( false );
205  TimeEdit2->setEnabled( false );
206  DateEdit3->setEnabled( true );
207  TimeEdit3->setEnabled( true );
208  DateEdit4->setEnabled( false );
209  TimeEdit4->setEnabled( false );
210  DateEdit5->setEnabled( false );
211  TimeEdit5->setEnabled( false );
212 
213  DateEdit3->setDate( item->endTime().date() );
214  TimeEdit3->setTime( item->endTime().time() );
215  break;
216  default:
217  ;
218  }
219  if (item->firstChild() && item->displaySubitemsAsGroup() ) {
220 
221  DateEdit2->setEnabled( false );
222  TimeEdit2->setEnabled( false );
223  DateEdit3->setEnabled( false );
224  TimeEdit3->setEnabled( false );
225  DateEdit4->setEnabled( false );
226  TimeEdit4->setEnabled( false );
227  DateEdit5->setEnabled( false );
228  TimeEdit5->setEnabled( false );
229  DateEdit1->setEnabled( false );
230  TimeEdit1->setEnabled( false );
231 
232  } else {
233  DateEdit1->setEnabled( true );
234  TimeEdit1->setEnabled( true );
235  }
236  DateEdit1->setDate( item->startTime().date() );
237  TimeEdit1->setTime( item->startTime().time() );
238  if ( item->pixmap() != 0 )
239  setIcon( *(item->pixmap()) );
240  setCaption( "Properties of " + ((TQListViewItem*)item)->text(0) );
241  itemName->setText(((TQListViewItem*)item)->text(0) );
242 
243 // DateEdit1->setRange(item->startTime().date().addYears(-10), item->endTime().date() );
244  // DateEdit3->setRange(item->startTime().date(), item->endTime().date().addYears(10));
245  LineEdit1->setText( item->text() );
246  KDGanttViewItem::Shape start, middle, end;
247  item->shapes( start, middle, end );
248  TQColor st, mi, en;
249  item->colors( st, mi, en );
250  ChangeStart->setPixmap( KDGanttView::getPixmap( start, st, backgroundColor(), 10 ) );
251  ChangeMiddle->setPixmap( KDGanttView::getPixmap( middle, mi, backgroundColor(), 10 ) );
252  ChangeEnd->setPixmap( KDGanttView::getPixmap( end, en, backgroundColor(), 10 ) );
253  item->highlightColors( st, mi, en );
254  HighStart->setPixmap( KDGanttView::getPixmap( start, st, backgroundColor(), 10 ) );
255  HighMiddle->setPixmap( KDGanttView::getPixmap( middle, mi, backgroundColor(), 10 ) );
256  HighEnd->setPixmap( KDGanttView::getPixmap( end, en, backgroundColor(), 10 ) );
257  ChangeText->setPixmap(TQPixmap( 16,16 ));
258  TQPixmap * pix;
259  pix = (TQPixmap *)ChangeText->pixmap();
260  pix->fill( item->textColor() );
261  StartBox->setCurrentItem((int)start );
262  MiddleBox->setCurrentItem((int)middle );
263  EndBox->setCurrentItem( (int) end );
264  CalBox->setChecked( item-> displaySubitemsAsGroup() );
265  PrioSpinBox->setValue( item->priority() );
266  PrioSlider->setValue( item->priority() );
267  myItem = item;
268 
269 }
270 
271 void itemAttributeDialog::HighStart_clicked()
272 {
273  if ( !myItem) return;
274  KDGanttViewItem::Shape start, middle, end;
275  myItem->shapes( start, middle, end );
276  TQColor st, mi, en;
277  myItem->highlightColors( st, mi, en );
278  TQColor c = TQColorDialog::getColor( st, this );
279  if ( c.isValid() ) {
280  st = c;
281  HighStart->setPixmap( KDGanttView::getPixmap( start, st, backgroundColor(), 10 ) );
282  myItem->setHighlightColors( st, mi, en );
283  }
284 
285 }
286 
287 
288 void itemAttributeDialog::HighMiddle_clicked()
289 {
290  if ( !myItem) return;
291  KDGanttViewItem::Shape start, middle, end;
292  myItem->shapes( start, middle, end );
293  TQColor st, mi, en;
294  myItem->highlightColors( st, mi, en );
295  TQColor c = TQColorDialog::getColor( mi, this );
296  if ( c.isValid() ) {
297  mi = c;
298  HighMiddle->setPixmap( KDGanttView::getPixmap( middle, mi, backgroundColor(), 10 ) );
299  myItem->setHighlightColors( st, mi, en );
300  }
301 
302 }
303 
304 
305 void itemAttributeDialog::HighEnd_clicked()
306 {
307  if ( !myItem) return;
308  KDGanttViewItem::Shape start, middle, end;
309  myItem->shapes( start, middle, end );
310  TQColor st, mi, en;
311  myItem->highlightColors( st, mi, en );
312  TQColor c = TQColorDialog::getColor( en, this );
313  if ( c.isValid() ) {
314  en = c;
315  HighEnd->setPixmap( KDGanttView::getPixmap( end, en, backgroundColor(), 10 ) );
316  myItem->setHighlightColors( st, mi, en );
317  }
318 
319 }
320 
321 
322 void itemAttributeDialog::DateEdit1_valueChanged( const TQDate & )
323 {
324  if ( !myItem) return;
325  TQDateTime dt;
326  dt.setDate( DateEdit1->date() );
327  dt.setTime( TimeEdit1->time() );
328  if ( dt.isValid() )
329  {
330  myItem->setStartTime( dt );
331  resetTime( myItem );
332  }
333 }
334 
335 
336 void itemAttributeDialog::TimeEdit1_valueChanged( const TQTime & )
337 {
338  if ( !myItem) return;
339  TQDateTime dt;
340  dt.setDate( DateEdit1->date() );
341  dt.setTime( TimeEdit1->time() );
342  if ( dt.isValid() ) {
343  myItem->setStartTime( dt );
344 
345  resetTime( myItem );
346 }
347 }
348 
349 
350 void itemAttributeDialog::DateEdit2_valueChanged( const TQDate & )
351 {
352  if ( !myItem) return;
353  TQDateTime dt;
354  dt.setDate( DateEdit2->date() );
355  dt.setTime( TimeEdit2->time() );
356  if ( dt.isValid() ) {
357  ((KDGanttViewSummaryItem*)myItem)->setMiddleTime( dt );
358  resetTime( myItem );
359 }
360 }
361 
362 
363 void itemAttributeDialog::TimeEdit2_valueChanged( const TQTime & )
364 {
365  if ( !myItem) return;
366  TQDateTime dt;
367  dt.setDate( DateEdit2->date() );
368  dt.setTime( TimeEdit2->time() );
369  if ( dt.isValid() ) {
370  ((KDGanttViewSummaryItem*)myItem)->setMiddleTime( dt );
371  resetTime( myItem );
372 }
373 }
374 
375 
376 void itemAttributeDialog::DateEdit3_valueChanged( const TQDate & )
377 {
378  if ( !myItem) return;
379  TQDateTime dt;
380  dt.setDate( DateEdit3->date() );
381  dt.setTime( TimeEdit3->time() );
382  if ( dt.isValid() ) {
383  myItem->setEndTime( dt );
384  resetTime( myItem );
385 }
386 }
387 
388 
389 void itemAttributeDialog::TimeEdit3_valueChanged( const TQTime & )
390 {
391  if ( !myItem) return;
392  TQDateTime dt;
393  dt.setDate( DateEdit3->date() );
394  dt.setTime( TimeEdit3->time() );
395  if ( dt.isValid() ) {
396  myItem->setEndTime( dt );
397  resetTime( myItem );
398 }
399 }
400 
401 
402 void itemAttributeDialog::LineEdit1_textChanged( const TQString & )
403 {
404  if ( !myItem) return;
405  myItem->setText(LineEdit1->text());
406 }
407 
408 
409 void itemAttributeDialog::StartBox_activated( const TQString & s )
410 {
411  KDGanttViewItem::Shape start, middle, end;
412  myItem->shapes( start, middle, end );
413  start = KDGanttViewItem::stringToShape( s );
414  myItem->setShapes( start, middle, end );
415  reset( myItem );
416 }
417 
418 
419 void itemAttributeDialog::MiddleBox_activated( const TQString & s )
420 {
421  KDGanttViewItem::Shape start, middle, end;
422  myItem->shapes( start, middle, end );
423  middle = KDGanttViewItem::stringToShape( s );
424  myItem->setShapes( start, middle, end );
425  reset( myItem );
426 
427 }
428 
429 
430 void itemAttributeDialog::EndBox_activated( const TQString & s )
431 {
432  KDGanttViewItem::Shape start, middle, end;
433  myItem->shapes( start, middle, end );
434  end = KDGanttViewItem::stringToShape( s );
435  myItem->setShapes( start, middle, end );
436  reset( myItem );
437 
438 }
439 
440 
441 void itemAttributeDialog::DateEdit4_valueChanged( const TQDate & )
442 {
443  if ( !myItem) return;
444  TQDateTime dt;
445  dt.setDate( DateEdit4->date() );
446  dt.setTime( TimeEdit4->time() );
447  if ( dt.isValid() ) {
448  ((KDGanttViewEventItem*)myItem)->setLeadTime( dt );
449  resetTime( myItem );
450  }
451 }
452 
453 
454 void itemAttributeDialog::TimeEdit4_valueChanged( const TQTime & )
455 {
456  if ( !myItem) return;
457  TQDateTime dt;
458  dt.setDate( DateEdit4->date() );
459  dt.setTime( TimeEdit4->time() );
460  if ( dt.isValid() ) {
461  ((KDGanttViewEventItem*)myItem)->setLeadTime( dt );
462  resetTime( myItem );
463 }
464 }
465 
466 
467 void itemAttributeDialog::DateEdit5_valueChanged( const TQDate & )
468 {
469  if ( !myItem) return;
470  TQDateTime dt;
471  dt.setDate( DateEdit5->date() );
472  dt.setTime( TimeEdit5->time() );
473  if ( dt.isValid() ) {
474  ((KDGanttViewSummaryItem*)myItem)->setActualEndTime( dt );
475  resetTime( myItem );
476 }
477 }
478 
479 
480 void itemAttributeDialog::TimeEdit5_valueChanged( const TQTime & )
481 {
482  if ( !myItem) return;
483  TQDateTime dt;
484  dt.setDate( DateEdit5->date() );
485  dt.setTime( TimeEdit5->time() );
486  if ( dt.isValid() ) {
487  ((KDGanttViewSummaryItem*)myItem)->setActualEndTime( dt );
488  resetTime( myItem );
489 }
490 }
491 
492 
493 
494 void itemAttributeDialog::itemName_textChanged( const TQString & )
495 {
496  if ( !myItem) return;
497  ((TQListViewItem*)myItem)->setText( 0, itemName->text() );
498  setCaption( "Properties of " + itemName->text() );
499 }
500 
501 
502 void itemAttributeDialog::PrioSpinBox_valueChanged( int val )
503 {
504  if ( !myItem) return;
505  myItem->setPriority( val );
506  PrioSlider->blockSignals( true );
507  PrioSlider->setValue( val );
508  PrioSlider->blockSignals( false );
509 
510 }
511 
512 
513 void itemAttributeDialog::CalBox_toggled( bool mode )
514 {
515  if ( !myItem) return;
516  myItem->setDisplaySubitemsAsGroup( mode );
517  if (myItem->firstChild() )
518  reset(myItem);
519 }
520 
521 
522 void itemAttributeDialog::PrioSlider_valueChanged( int val )
523 {
524 if ( !myItem) return;
525  myItem->setPriority( val );
526  PrioSpinBox->blockSignals( true );
527  PrioSpinBox->setValue( val );
528  PrioSpinBox->blockSignals( false );
529 }
530 
531 
532 KDGanttViewItem* itemAttributeDialog::getItem()
533 {
534  return myItem;
535 }
const TQPixmap * pixmap(int column=0) const
TQDateTime endTime() const
bool displaySubitemsAsGroup() const
KDGanttViewItem * firstChild() const
TQDateTime startTime() const
static TQPixmap getPixmap(KDGanttViewItem::Shape shape, const TQColor &shapeColor, const TQColor &backgroundColor, int itemSize)