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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
|
/* -*- Mode: C++ -*-
$Id: KDGanttViewItem.cpp 523435 2006-03-28 08:01:15Z mlaurent $
KDGantt - a multi-platform charting engine
*/
/****************************************************************************
** Copyright (C) 2002-2004 Klar�lvdalens Datakonsult AB. All rights reserved.
**
** This file is part of the KDGantt library.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid commercial KDGantt licenses may use this file in
** accordance with the KDGantt Commercial License Agreement provided with
** the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
** information about KDGantt Commercial License Agreements.
**
** Contact info@klaralvdalens-datakonsult.se if any conditions of this
** licensing are not clear to you.
**
** As a special exception, permission is given to link this program
** with any edition of TQt, and distribute the resulting executable,
** without including the source code for TQt in the source distribution.
**
**********************************************************************/
#include "KDGanttViewSubwidgets.h"
#include "KDGanttViewTaskItem.h"
#include "KDGanttViewSummaryItem.h"
#include "KDGanttViewEventItem.h"
#include "itemAttributeDialog.h"
#include "tqpainter.h"
#include "KDGanttXMLTools.h"
/*!
\class KDGanttViewItem KDGanttViewItem.h
This class represents an item in a Gantt chart.
This class is an abstract base class, it cannot be instantiated
directly. Instead, you should create items of one of the
subclasses. This class provides methods common to all Gantt items.
The initialization of the shapes/colors of the item works as follows:
Shapes:
When a new item is created, the shapes are set to the default values
for items of the type of this item, defined in the KDGanttView class with
void setShapes( KDGanttViewItem::Type type,
KDGanttViewItem::Shape start,
KDGanttViewItem::Shape middle,
KDGanttViewItem::Shape end );
If there is no default value defined for this type,
the shapes are set as follows:
For TaskViewItems all three shapes are set to Square.
For SummaryViewItems all three shapes are set to TriangleDown.
For EventViewItems all three shapes are set to Diamond.
Colors:
When a new item is created, the colors are set to the default values
for items of the type of this item, defined in the KDGanttView class with
void setColors( KDGanttViewItem::Type type,
const TQColor& start,
const TQColor& middle,
const TQColor& end );
If there is no default value defined for this type,
the colors of the shapes are set to the default color for items of this type,
defined in the KDGanttView class with:
void setDefaultColor( KDGanttViewItem::Type type, const TQColor& );
The initial default color in the KDGanttView class is set to
blue for KDGanttViewItem::Event,
green for KDGanttViewItem::Task,
cyan for KDGanttViewItem::Summary.
Highlight Colors:
When a new item is created, the highlight colors are set to the default
values for items of the type of this item,
defined in the KDGanttView class with:
void setHighlightColors( KDGanttViewItem::Type type,
const TQColor& start,
const TQColor& middle,
const TQColor& end );
If there is no default value defined for this type,
the highlight colors of the shapes are set to the default color for
items of this type, defined in the KDGanttView class with:
void setDefaultHighlightColor( KDGanttViewItem::Type type, const TQColor& );
The initial default highlight color in the KDGanttView class is set to red
for all types.
Start/End time:
When a new item is created, the start time and the end time is set
automatically. The time, which is currently displayed in the middle
of the Gantt View, is set as start/end time. At startup of a newly
created Gantt view, this is the current time.
The Priority:
The priority is set with \a setPriority().
The priority determines which items are painted over which other items.
The item with the highest priority is painted on top of all others.
The priority for an item can be between 1 and 199.
A priority less than 100 means that the item is painted below the
grid in the Gantt chart.
For Task items, the default priority is 50, for all other items it is 150.
This feature only makes sense for an item which is a child of another item,
for which \a displaySubitemsAsGroup() property is set to true.
The Display Mode:
The display mode is set with \a setDisplaySubitemsAsGroup().
In the normal view mode (set with setDisplaySubitemsAsGroup( false ); ),
an item is displayed in the same manner, when its child items are
shown or not.
In the other mode (set with setDisplaySubitemsAsGroup( true ); ),
called "calendar mode", the item is displayed as follows:
If the item has no children, it is displayed as usual.
If the item is opened (i.e., its children are displayed), the
start/end time of this item is computed automatically according to
the earliest start time/latest end time of its children. The item
and its children are displayed as usual.
If the item is closed (i.e., its children are hidden in the left
list view), the item itself is hidden, and its children are displayed
on the timeline of this item instead. To control the painting of
overlapping children, call \a setPriority() for the childs.
Blocking of user interaction to open item:
If you want to block users to open items used as parents of calendar items,
call \a KDGanttView::setCalendarMode( true );
Example 1, Color:
If you create an instance of a KDGanttView class and add a SummaryViewItem
without setting any color/shape values, you get an item with three shapes
of the form TriangleDown in the color magenta. If the item is highlighted,
the color will change to the highlight color red.
Example 2, Calender View:
To use a Gantt view as a calendar view, call
\a KDGanttView::setCalendarMode( true );
\a KDGanttView::setDisplaySubitemsAsGroup( true );
Insert root items in the Gantt view.
Insert items as children of these root item in the Gantt view.
You may use any item type as parent and child; there are no limitations.
It is, however, recommended to use KDGanttViewTaskItems
Actually, you may add child items to the children themselves.
Such a child behaves then like a parent.
Now set the start/end time of the children to specify a time
interval for these items.
*/
TQDict<KDGanttViewItem> KDGanttViewItem::sItemDict;
/*!
Constructs an empty Gantt item.
\param type the type of the item to insert
\param view the Gantt view to insert this item into
\param lvtext the text to show in the list view
\param name the name by which the item can be identified. If no name
is specified, a unique name will be generated
*/
KDGanttViewItem::KDGanttViewItem( Type type, KDGanttView* view,
const TQString& lvtext,
const TQString& name ) :
TQListViewItem(view->myListView,lvtext)
{
initColorAndShapes(type);
generateAndInsertName( name );
}
/*!
Constructs an empty Gantt item.
\param type the type of the item to insert
\param parentItem a parent item under which this one goes
\param lvtext the text to show in the list view
\param name the name by which the item can be identified. If no name
is specified, a unique name will be generated
*/
KDGanttViewItem::KDGanttViewItem( Type type, KDGanttViewItem* parentItem,
const TQString& lvtext,
const TQString& name ) :
TQListViewItem(parentItem,lvtext)
{
initColorAndShapes(type);
generateAndInsertName( name );
}
/*!
Constructs an empty Gantt item.
\param type the type of the item to insert
\param view the Gantt view to insert this item into
\param after another item at the same level behind which this one should go
\param lvtext the text to show in the list view
\param name the name by which the item can be identified. If no name
is specified, a unique name will be generated
*/
KDGanttViewItem::KDGanttViewItem( Type type, KDGanttView* view,
KDGanttViewItem* after,
const TQString& lvtext,
const TQString& name ) :
TQListViewItem(view->myListView,after, lvtext)
{
initColorAndShapes(type);
generateAndInsertName( name );
}
/*!
Constructs an empty Gantt item.
\param type the type of the item to insert
\param parentItem a parent item under which this one goes
\param after another item at the same level behind which this one should go
\param lvtext the text to show in the list view
\param name the name by which the item can be identified. If no name
is specified, a unique name will be generated
*/
KDGanttViewItem::KDGanttViewItem( Type type, KDGanttViewItem* parentItem,
KDGanttViewItem* after,
const TQString& lvtext,
const TQString& name ) :
TQListViewItem( parentItem, after, lvtext )
{
initColorAndShapes(type);
generateAndInsertName( name );
}
/*!
Destroys the object and frees any allocated resources.
*/
KDGanttViewItem::~KDGanttViewItem()
{
myGanttView->notifyEditdialog( this );
if ( startLine ) delete startLine;
if ( endLine ) delete endLine ;
if ( startLineBack ) delete startLineBack ;
if ( endLineBack ) delete endLineBack ;
if ( actualEnd ) delete actualEnd ;
if ( textCanvas ) delete textCanvas ;
if ( startShape ) delete startShape ;
if ( midShape ) delete midShape ;
if ( endShape ) delete endShape ;
if ( startShapeBack ) delete startShapeBack ;
if ( midShapeBack ) delete midShapeBack ;
if ( endShapeBack ) delete endShapeBack ;
if ( progressShape ) delete progressShape ;
if ( floatStartShape ) delete floatStartShape ;
if ( floatEndShape ) delete floatEndShape ;
myGanttView->myTimeTable->removeItemFromTasklinks( this );
myGanttView->myCanvasView->resetCutPaste( this );
if ( listView() ) {
if ( isOpen() )
setOpen( false );
if ( parent() )
parent()->takeItem( this );
else
myGanttView->myListView->takeItem( this );
myGanttView->myTimeTable->updateMyContent();
}
// myGanttView->myTimeTable->removeItemFromTasklinks( this );
// myGanttView->myCanvasView->resetCutPaste( this );
}
/*!
Generates a unique name if necessary and inserts it into the item
dictionary.
*/
void KDGanttViewItem::generateAndInsertName( const TQString& name )
{
// First check if we already had a name. This can be the case if
// the item was reconstructed from an XML file.
if( !_name.isEmpty() )
// We had a name, remove it
sItemDict.remove( _name );
TQString newName;
if ( name.isEmpty() || sItemDict.find( name ) ) {
// create unique name
newName.sprintf( "%p", (void* )this );
while( sItemDict.find( newName ) ) {
newName += "_0";
}
} else {
newName = name;
}
sItemDict.insert( newName, this );
_name = newName;
}
/*!
Returns the unique name that can identify the item.
\return the unique item name
*/
TQString KDGanttViewItem::name() const
{
return _name;
}
/*!
Returns the item with the specified name.
\param name the name to search for
\return the item with the specified name; 0 if no group
with that name exists
*/
KDGanttViewItem* KDGanttViewItem::find( const TQString& name )
{
if (name.isEmpty()) // avoid error msg from TQDict
return 0;
return sItemDict.find( name );
}
/*!
Returns the type of the item.
This may be Event, Task, Summary.
\return the type of the item
*/
KDGanttViewItem::Type KDGanttViewItem::type() const
{
return myType;
}
/*!
Specifies whether this item is enabled. If disabled, the item stays in the
Gantt view and the item is shown in gray to show that the item is disabled.
All signals of this item (like itemLeftClicked( this )) are blocked.
If the item displays its subitems (childs) as a group,
(displaySubitemsAsGroup() == true)
all changes apply to all subitems as well.
\param on pass true to make this item editable
\sa enabled ()
*/
void KDGanttViewItem::setEnabled( bool on )
{
_enabled = on;
if ( displaySubitemsAsGroup() ) {
myGanttView->myTimeTable->inc_blockUpdating();
KDGanttViewItem* temp = (KDGanttViewItem*) firstChild();
while (temp != 0) {
temp->setEnabled( on );
temp = temp->nextSibling();
}
TQListViewItem::setEnabled( on );
myGanttView->myTimeTable->dec_blockUpdating();
}
updateCanvasItems();
}
/*!
Returns whether this item is enabled.
\return true if this item is enabled, false otherwise
\sa setEnabled()
*/
bool KDGanttViewItem::enabled () const
{
return _enabled;
}
// *********************************
/*!
Specifies whether this item is visible.
\param on pass true to make this item visible
\sa itemVisible ()
*/
void KDGanttViewItem::setItemVisible( bool on )
{
if ( on ) {
resetSubitemVisibility();
} else
setVisible( false );
//updateCanvasItems();
myGanttView->myTimeTable->updateMyContent();
}
/*!
Returns whether this item is visible.
\return true if this item is visible, false otherwise
\sa setItemVisible()
*/
bool KDGanttViewItem::itemVisible () const
{
return TQListViewItem::isVisible();
}
// *************************************
/*!
Specifies whether this item is editable. The whole Gantt view needs
to be editable as well for this to have any effect.
\param editable pass true to make this item editable
\sa editable(), KDGanttView::setEditable(), KDGanttView::editable()
*/
void KDGanttViewItem::setEditable( bool editable )
{
isEditable = editable;
}
/*!
Returns whether this item is editable.
\return true if this item is editable, false otherwise
\sa setEditable(), KDGanttView::setEditable(), KDGanttView::editable()
*/
bool KDGanttViewItem::editable() const
{
return isEditable;
}
/*!
Specifies whether this item shows hidden subitems on its timeline.
Useful to get a so called "calendar view" with many items in one row.
When \a displaySubitemsAsGroup() is set to true, this item has a normal view,
when it is expanded. If it is not expanded (and has at least one child),
the item itself is hidden, and all children are displayed instead.
To manage the painting priority of the childs (if overlapping),
you may set \a priority() of these items.
\param show pass true to make this item displaying hidden subitems
\sa editable(), KDGanttView::setEditable(), KDGanttView::editable(), setPriority()
*/
void KDGanttViewItem::setDisplaySubitemsAsGroup( bool show )
{
if ( !show && _displaySubitemsAsGroup)
isVisibleInGanttView = true;
_displaySubitemsAsGroup = show;
if ( parent() )
if ( parent()->isOpen() )
parent()->setOpen( true );
if ( isOpen() )
setOpen( true );
updateCanvasItems();
}
/*!
Returns whether this item displays hidden subitems.
Initial set to false.
\return true if this item displays hidden subitems, false otherwise
\sa setDisplaySubitemsAsGroup()
*/
bool KDGanttViewItem::displaySubitemsAsGroup() const
{
return _displaySubitemsAsGroup;
}
/*!
Specifies the priority of this item.
Valid values are between 1 and 199.
A priority less than 100 means that the item is painted in the
Gantt chart below the grid. A priority more than 100 means
that the item is painted in the Gantt chart over the grid.
For a value of 100, the behavior is unspecified.
An item with a higher priority is painted over an item with a lower
priority in the Gantt chart. The painting order of items with the
same priority is unspecified.
For Calendar items, the default priority is 50, for all other items
it is 150.
This feature makes only sense for an item which is a child of
another item, which \a displaySubitemsAsGroup() property is set to
true.
\param prio the new priority of this item.
\sa priority(), displaySubitemsAsGroup()
*/
void KDGanttViewItem::setPriority( int prio )
{
if ( prio < 1 )
prio = 1;
if (prio > 199 )
prio = 199;
_priority = prio;
updateCanvasItems();
}
/*!
Returns the priority of this item.
\return the priority of this item
\sa setDisplaySubitemsAsGroup()
*/
int KDGanttViewItem::priority()
{
return _priority;
}
/*!
Specifies the start time of this item. The parameter must be valid
and non-null. If the parameter is invalid or null, no value is set.
Reimplemented in the subclasses.
\param start the start time
\sa startTime(), setEndTime(), endTime()
*/
void KDGanttViewItem::setStartTime( const TQDateTime& )
{
}
/*!
Returns the start time of this item.
\return the start time of this item
\sa setStartTime(), setEndTime(), endTime()
*/
TQDateTime KDGanttViewItem::startTime() const
{
return myStartTime;
}
/*!
Specifies the end time of this item. The parameter must be valid
and non-null. If the parameter is invalid or null, no value is set.
Reimplemented in the subclasses
\param end the end time
\sa endTime(), setStartTime(), startTime()
*/
void KDGanttViewItem::setEndTime( const TQDateTime& end )
{
switch( type() ) {
case Event:
tqDebug( "KDGantt:Event Item has no end time" );
break;
case Summary:
((KDGanttViewSummaryItem*)this)->setEndTime( end );
break;
case Task:
tqDebug( "KDGantt:Task Item has no end time" );
break;
default:
tqDebug( "Unknown type in KDGanttViewItem::typeToString()" );
}
}
/*!
Returns the end time of this item.
\return the end time of this item
\sa setEndTime(), setStartTime(), startTime()
*/
TQDateTime KDGanttViewItem::endTime() const
{
return myEndTime;
}
/*!
Sets the text to be shown in this item in the Gantt view.
For a KDGanttViewTaskItem witht displaySubitemsAsGroup() == true,
the text is shown in the item itself and
the text is truncated automatically, if it does not fit in the item.
For all other item types, the text is shown to the right of the item.
\param text the text to be shown
\sa text(), setTextColor(), textColor(), setListViewText(),
listViewText()
*/
void KDGanttViewItem::setText( const TQString& text )
{
textCanvas->setText(text);
textCanvasText = text;
updateCanvasItems();
}
/*!
Returns the text to be shown in this item in the Gantt view.
\return the text to be shown in this item
\sa setText(), setTextColor(), textColor(), setListViewText(),
listViewText()
*/
TQString KDGanttViewItem::text() const
{
return textCanvasText;
}
/*!
\deprecated Use setListViewTest( int, const TQString& ) instead
*/
void KDGanttViewItem::setListViewText( const TQString& text, int column )
{
TQListViewItem::setText( column, text );
}
/*!
Sets the text to be shown in this item in the list view.
\param column the column in which the text will be shown
\param text the text to be shown
\sa text(), setTextColor(), textColor(), setText(), listViewText()
*/
void KDGanttViewItem::setListViewText( int column, const TQString& text )
{
TQListViewItem::setText( column, text );
}
/*!
Returns the text to be shown in this item in the list view.
\param column the column in which the text will be shown
\return the text to be shown in this item
\sa setText(), setTextColor(), textColor(), text(),
setListViewText()
*/
TQString KDGanttViewItem::listViewText( int column ) const
{
return TQListViewItem::text( column );
}
/*!
Sets the font to be used for the text in this item.
\param font the font to be shown
\sa font()
*/
void KDGanttViewItem::setFont( const TQFont& font )
{
textCanvas->setFont(font);
updateCanvasItems();
}
/*!
Returns the font used for the text in this item.
\return the font used for the text in this item
\sa setFont()
*/
TQFont KDGanttViewItem::font() const
{
return textCanvas->font();
}
/*!
Sets the text to show in a tooltip for this item.
\param text the tooltip text
\sa tooltipText()
*/
void KDGanttViewItem::setTooltipText( const TQString& text )
{
myToolTipText = text;
}
/*!
Returns the tooltip text of this item
\return the tooltip text
\sa setTooltipText()
*/
TQString KDGanttViewItem::tooltipText() const
{
return myToolTipText;
}
/*!
Sets the text to show in a What's This window for this item.
\param text the what's this text
\sa whatsThisText()
*/
void KDGanttViewItem::setWhatsThisText( const TQString& text )
{
myWhatsThisText = text;
}
/*!
Returns the what's this text of this item
\return the what's this text
\sa setWhatsThisText()
*/
TQString KDGanttViewItem::whatsThisText() const
{
return myWhatsThisText;
}
/*!
Specifies whether this item should be shown highlighted. The user
can also highlight items with the mouse.
If the item displays its subitems (children) as a group
(displaySubitemsAsGroup() == true),
all changes apply to all subitems as well.
\param highlight true in order to highlight, false in order to turn
highlighting off for this item
\sa highlight()
*/
void KDGanttViewItem::setHighlight( bool highlight )
{
isHighlighted = highlight;
if ( displaySubitemsAsGroup() ) {
myGanttView->myTimeTable->inc_blockUpdating();
KDGanttViewItem* temp = (KDGanttViewItem*) firstChild();
while (temp != 0) {
temp->setHighlight( highlight );
temp = temp->nextSibling();
}
myGanttView->myTimeTable->dec_blockUpdating();
}
updateCanvasItems();
}
/*!
Returns whether this item is highlighted, either programmatically
with setHighlight() or by the user with the mouse.
\return true if the item is highlighted
\sa setHighlight()
*/
bool KDGanttViewItem::highlight() const
{
return isHighlighted;
}
/*!
Specifies the shapes to be used for this item.
It is advisable not to use this method, but rather set the shapes
for all items of a type with KDGanttView::setShapes() in order to
get a uniform Gantt view.
\param start the start shape
\param middle the middle shape
\param end the end shape
\sa shapes(), setColors(), colors()
*/
void KDGanttViewItem::setShapes( Shape start, Shape middle, Shape end )
{
myStartShape = start;
myMiddleShape= middle;
myEndShape= end;
createShape(startShape,startShapeBack,start);
createShape(midShape,midShapeBack,middle);
midShape->setZ( 4 );
createShape(endShape,endShapeBack,end);
updateCanvasItems();
}
/*!
Creates shapes of the specified type \a shape.
The background shape color is set to black and the background shape
is slightly bit bigger than the foreground shape to have a black border
around the foreground shape.
\param itemShape the foreground shape
\param middle itemShapeBack the background shape
\param shape the type of the shape
(may be TriangleDown, TriangleUp, Diamond, Square, Circle)
\sa shapes(), setColors(), colors()
*/
void KDGanttViewItem::createShape( KDCanvasPolygonItem* &itemShape,
KDCanvasPolygonItem* &itemShapeBack,
Shape shape )
{
if ( itemShape && type() == Task )
return;
if (itemShape) delete itemShape;
if (itemShapeBack) delete itemShapeBack;
TQCanvasPolygonalItem * item;
TQCanvasPolygonalItem * itemBack;
int size = myItemSize+2;
int hei = (myItemSize/3)/2;
switch (shape) {
case TriangleDown:
{
item = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
TQPointArray arr = TQPointArray(3);
arr.setPoint(0,-size/2,-hei);
arr.setPoint(1,size/2,-hei);
arr.setPoint(2,0,((size/2)-hei));
((TQCanvasPolygon*)item)->setPoints(arr);
size += 4;hei +=1;
itemBack = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
arr.setPoint(0,-size/2,-hei);
arr.setPoint(1,size/2,-hei);
arr.setPoint(2,0,((size/2)-hei));
((TQCanvasPolygon*)itemBack)->setPoints(arr);
break;
}
case TriangleUp:
{
// I really do not know why, but we get only an TriangleUp-icon
// of the same size as a TriangleDown-icon, if we increment the size by 2
size+=2;
item = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
TQPointArray arr = TQPointArray(3);
arr.setPoint(0,-size/2,hei);
arr.setPoint(1,size/2,hei);
arr.setPoint(2,0,(-size/2)+hei);
((TQCanvasPolygon*)item)->setPoints(arr);
size += 4;hei +=1;
itemBack = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
arr.setPoint(0,-size/2,hei);
arr.setPoint(1,size/2,hei);
arr.setPoint(2,0,(-size/2)+hei);
((TQCanvasPolygon*)itemBack)->setPoints(arr);
break;
}
case Diamond:
{
item = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
TQPointArray arr = TQPointArray(4);
arr.setPoint(0,0,-size/2);
arr.setPoint(1,size/2,0);
arr.setPoint(2,0,size/2);
arr.setPoint(3,-size/2,0);
((TQCanvasPolygon*)item)->setPoints(arr);
size += 2;hei +=1;
itemBack = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
arr.setPoint(0,0,-size/2);
arr.setPoint(1,size/2,0);
arr.setPoint(2,0,size/2);
arr.setPoint(3,-size/2,0);
((TQCanvasPolygon*)itemBack)->setPoints(arr);
break;
}
case Square:
{
size -=2;
item = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
TQPointArray arr = TQPointArray(4);
arr.setPoint(0,-size/2,-size/2);
arr.setPoint(1,size/2,-size/2);
arr.setPoint(2,size/2,size/2);
arr.setPoint(3,-size/2,size/2);
((TQCanvasPolygon*)item)->setPoints(arr);
size += 2;hei +=1;
itemBack = new KDCanvasPolygon(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
arr.setPoint(0,-size/2,-size/2);
arr.setPoint(1,size/2,-size/2);
arr.setPoint(2,size/2,size/2);
arr.setPoint(3,-size/2,size/2);
((TQCanvasPolygon*)itemBack)->setPoints(arr);
break;
}
case Circle:
{
size -= 2;
item = new KDCanvasEllipse(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
((KDCanvasEllipse*)item)->setSize(size,size);
size += 2;hei +=1;
itemBack = new KDCanvasEllipse(myGanttView->myTimeTable, this,Type_is_KDGanttViewItem);
((KDCanvasEllipse*)itemBack)->setSize(size,size);
break;
}
default:
// Uninitialized shape, can e.g. be the case with free-busy
// items which don't have any shapes
return;
}
item->setBrush(Qt::SolidPattern);
item->setZ(5);
itemShape = (KDCanvasPolygonItem*) item;
itemBack->setBrush(Qt::SolidPattern);
itemBack->setZ(3);
itemShapeBack = (KDCanvasPolygonItem*) itemBack;
}
/*!
Returns the shapes used for this item
\param start returns the start shape
\param middle returns the middle shape
\param end returns the end shape
\sa setShapes(), setColors(), colors()
*/
void KDGanttViewItem::shapes( Shape& start, Shape& middle, Shape& end ) const
{
start = myStartShape;
middle = myMiddleShape;
end = myEndShape;
}
/*!
Specifies the colors in which to draw the shapes of this item.
It is advisable not to use this method, but rather set the colors
for all items of a type with KDGanttView::setColors() in order to
get a uniform Gantt view.
\param start the color for the start shape
\param middle the color for the middle shape
\param end the color for the end shape
\sa colors(), setShapes(), shapes(), setDefaultColor(), defaultColor()
*/
void KDGanttViewItem::setColors( const TQColor& start, const TQColor& middle,
const TQColor& end )
{
myStartColor=start ;
myMiddleColor= middle;
myEndColor= end;
if ( displaySubitemsAsGroup() ) {
myGanttView->myTimeTable->inc_blockUpdating();
KDGanttViewItem* temp = (KDGanttViewItem*) firstChild();
while (temp != 0) {
temp->setColors( start, middle, end );
temp = temp->nextSibling();
}
myGanttView->myTimeTable->dec_blockUpdating();
}
updateCanvasItems();
}
/*!
Returns the colors used for this item
\param start returns the start color
\param middle returns the middle color
\param end returns the end color
\sa setColors(), setShapes(), shapes(), setDefaultColor(), defaultColor()
*/
void KDGanttViewItem::colors( TQColor& start, TQColor& middle, TQColor& end ) const
{
start = myStartColor ;
middle = myMiddleColor;
end = myEndColor;
}
/*!
Specifies the highlight colors in which to draw the shapes of this item.
It is advisable not to use this method, but rather set the highlight
colors for all items of a type with
KDGanttView::setHighlightColors() in order to get a uniform Gantt
view.
If the item displays its subitems (children) as a group,
(displaySubitemsAsGroup() == true)
all changes apply to all subitems as well.
\param start the highlight color for the start shape
\param middle the highlight color for the middle shape
\param end the highlight color for the end shape
\sa highlightColors(), setShapes(), shapes()
*/
void KDGanttViewItem::setHighlightColors( const TQColor& start, const TQColor& middle, const TQColor& end )
{
myStartColorHL=start ;
myMiddleColorHL= middle;
myEndColorHL= end;
if ( displaySubitemsAsGroup() ) {
myGanttView->myTimeTable->inc_blockUpdating();
KDGanttViewItem* temp = (KDGanttViewItem*) firstChild();
while (temp != 0) {
temp->setHighlightColors( start, middle, end );
temp = temp->nextSibling();
}
myGanttView->myTimeTable->dec_blockUpdating();
}
updateCanvasItems();
}
/*!
Returns the highlight colors used for this item
\param start returns the start highlight color
\param middle returns the middle highlight color
\param end returns the end highlight color
\sa setHighlightColors(), setShapes(), shapes()
*/
void KDGanttViewItem::highlightColors( TQColor& start, TQColor& middle, TQColor& end ) const
{
start = myStartColorHL ;
middle = myMiddleColorHL;
end = myEndColorHL;
}
/*!
Specifies the color to be used for the text of this item.
It is advisable not to use this method, but rather set the text color
for all items with KDGanttView::setTextColor() in order to get a
uniform Gantt view.
If the item displays its subitems (children) as a group,
(displaySubitemsAsGroup() == true)
all changes apply to all subitems as well.
\param color the text color
\sa textColor(), setText(), text()
*/
void KDGanttViewItem::setTextColor( const TQColor& color )
{
myTextColor = color;
if ( displaySubitemsAsGroup() ) {
myGanttView->myTimeTable->inc_blockUpdating();
KDGanttViewItem* temp = (KDGanttViewItem*) firstChild();
while (temp != 0) {
temp->setTextColor(color);
temp = temp->nextSibling();
}
myGanttView->myTimeTable->dec_blockUpdating();
}
updateCanvasItems();
}
/*!
Returns the color used for the text of this item.
\return the text color
\sa setTextColor(), setText(), text()
*/
TQColor KDGanttViewItem::textColor() const
{
return myTextColor;
}
/*!
\enum KDGanttViewItem::Shape
This enum is used in order to specify the shapes of a Gantt chart
item.
*/
/*!
\enum KDGanttViewItem::Type
This enum is used in order to return the type of a Gantt chart item.
*/
/*!
Sets the pixmap that is shown in the listview.
\param column the column in which the pixmap is shown
\param pixmap the pixmap to show
\sa pixmap()
*/
void KDGanttViewItem::setPixmap( int column, const TQPixmap& pixmap )
{
TQListViewItem::setPixmap( column, pixmap );
}
/*!
\deprecated use setPixmap( int, const TQPixmap& ) instead
*/
void KDGanttViewItem::setPixmap( const TQPixmap& pixmap )
{
TQListViewItem::setPixmap( 0, pixmap );
}
/*!
Returns a pixmap that is shown in the listview.
\param column the column for which to query the pixmap
\return a pointer to the pixmap shown
\sa setPixmap()
*/
const TQPixmap* KDGanttViewItem::pixmap( int column ) const
{
return TQListViewItem::pixmap( column );
}
/*!
Sets the default color that is used for the item if no specific
start, middle, or end colors are set.
It is advisable not to use this method, but rather set the colors
for all items of a type with KDGanttView::setDefaultColor() in order to
get a uniform Gantt view.
If the item displays its subitems (children) as a group,
(displaySubitemsAsGroup() == true)
all changes apply to all subitems as well.
\param color the default color to use
\sa defaultColor(), setColors(), colors()
*/
void KDGanttViewItem::setDefaultColor( const TQColor& color )
{
myDefaultColor = color;
if ( displaySubitemsAsGroup() ) {
myGanttView->myTimeTable->inc_blockUpdating();
KDGanttViewItem* temp = (KDGanttViewItem*) firstChild();
while (temp != 0) {
temp->setDefaultColor( color );
temp = temp->nextSibling();
}
myGanttView->myTimeTable->dec_blockUpdating();
}
updateCanvasItems();
}
/*!
Returns the default color that is used for the item if no specific
start, middle, or end colors are set.
\return color the default color used
\sa setDefaultColor(), setColors(), colors()
*/
TQColor KDGanttViewItem::defaultColor() const
{
return myDefaultColor;
}
/*!
Sets the default highlighting color that is used for the item if no
specific start, middle, or end colors are set.
It is advisable not to use this method, but rather set the colors
for all items of a type with KDGanttView::setDefaultHighlightColor()
in order to get a uniform Gantt view.
If the item displays its subitems (children) as a group,
(displaySubitemsAsGroup() == true)
all changes apply to all subitems as well.
\param color the default highlighting color to use
\sa defaultHighlightColor(), setHighlightColors(), highlightColors()
*/
void KDGanttViewItem::setDefaultHighlightColor( const TQColor& color )
{
myDefaultColorHL = color;
if ( displaySubitemsAsGroup() ) {
myGanttView->myTimeTable->inc_blockUpdating();
KDGanttViewItem* temp = (KDGanttViewItem*) firstChild();
while (temp != 0) {
temp->setDefaultHighlightColor( color );
temp = temp->nextSibling();
}
myGanttView->myTimeTable->dec_blockUpdating();
}
updateCanvasItems();
}
/*!
Returns the default highlighting color that is used for the item if
no specific start, middle, or end colors are set.
\return color the default highlighting color used
\sa setDefaultHighlightColor(), setHighlightColors(), highlightColors()
*/
TQColor KDGanttViewItem::defaultHighlightColor() const
{
return myDefaultColorHL;
}
/*!
Returns the first child of this item.
\return the first child of this item, 0 if this item has no children
*/
KDGanttViewItem* KDGanttViewItem::firstChild() const
{
return (KDGanttViewItem* )TQListViewItem::firstChild();
}
/*!
Returns the next sibling item of this item
\return the next sibling item of this item, 0 if this item has no
more siblings
*/
KDGanttViewItem* KDGanttViewItem::nextSibling() const
{
return (KDGanttViewItem* )TQListViewItem::nextSibling();
}
/*!
Returns the parent item of this item
\return the parent item of this item, 0 if this item is a top-level
item
*/
KDGanttViewItem* KDGanttViewItem::parent() const
{
return (KDGanttViewItem*)TQListViewItem::parent();
}
/*!
Returns the item above this item in the listview
\return the item above this item, 0 if this is the first item
*/
KDGanttViewItem* KDGanttViewItem::itemAbove()
{
return (KDGanttViewItem* )TQListViewItem::itemAbove();
}
/*!
Returns the item below this item in the listview.
It can be specified whether the disabled items are taken
into account as well.
\param includeDisabled if true, disabled items are considered as well
\return the item below this item, 0 if this is the last item
*/
KDGanttViewItem* KDGanttViewItem::itemBelow( bool includeDisabled )
{
KDGanttViewItem* retItem = (KDGanttViewItem* )TQListViewItem::itemBelow();
if ( !includeDisabled ) {
return retItem;
}
if ( retItem ) {
if (itemPos() + height() == retItem->itemPos() ) {
return retItem;
}
}
KDGanttViewItem* Item2 = (KDGanttViewItem* )TQListViewItem::listView()->itemAt(TQPoint (2, TQListViewItem::itemPos() + TQListViewItem::height() +2) );
if ( Item2 != 0 )
if (!Item2->enabled() )
return Item2;
return retItem;
}
/*!
Updates the colors of the item, but not the coordinates.
*/
void KDGanttViewItem::updateCanvasItems()
{
if (blockUpdating) return;
TQPen p,pBack;
TQBrush b;
b.setStyle(Qt::SolidPattern);
if ( enabled() ) {
textCanvas->setColor(myTextColor);
if (isHighlighted) {
b.setStyle(Qt::SolidPattern);
b.setColor(myStartColorHL);
startShape->setBrush(b);
b.setColor(myMiddleColorHL);
midShape->setBrush(b);
b.setColor(myEndColorHL);
endShape->setBrush(b);
p.setWidth(myItemSize/3 -1);
p.setColor(myStartColorHL);
startLine->setPen(p);
p.setColor(myEndColorHL);
endLine->setPen(p);
} else {
b.setStyle(Qt::SolidPattern);
b.setColor(myStartColor);
// tqDebug("update color %s %s", listViewText().latin1(),myStartColor.name().latin1() );
startShape->setBrush(b);
b.setColor(myMiddleColor);
midShape->setBrush(b);
b.setColor(myEndColor);
endShape->setBrush(b);
p.setWidth(myItemSize/3-1);
p.setColor(myStartColor);
startLine->setPen(p);
p.setColor(myEndColor);
endLine->setPen(p);
}
} else {
//TQColor discol = TQt::lightGray;
TQColor discol = TQColor(232,232,232);
textCanvas->setColor( TQColor(150,150,150) );
b.setStyle(Qt::SolidPattern);
b.setColor(discol);
startShape->setBrush(b);
midShape->setBrush(b);
endShape->setBrush(b);
p.setWidth(myItemSize/3 -1);
p.setColor(discol);
startLine->setPen(p);
endLine->setPen(p);
}
pBack.setWidth((myItemSize/3-1)+2);
startLineBack->setPen(pBack);
endLineBack->setPen(pBack);
TQFont f = textCanvas->font();
f.setPixelSize(myItemSize);
textCanvas->setFont(f);
//if (isvisible) {
myGanttView->myTimeTable->updateMyContent();
//}
}
void KDGanttViewItem::initItem()
{
}
/*!
This method is reimplemented for internal purposes.
*/
void KDGanttViewItem::setOpen( bool open )
{
if ( _callListViewOnSetOpen ) {
// notify the listview about a programatically called setOpen()
if ( listView () )
listView ()->setOpen( this, open );
} else {
TQListViewItem::setOpen( open );
}
}
void KDGanttViewItem::showItem( bool, int )
{
}
TQPoint KDGanttViewItem::getTaskLinkStartCoord(TQPoint p)
{
textCanvas->move(p.x()+myItemSize, itemPos() + height()/2-myItemSize/2);
return TQPoint (myGanttView->myTimeHeader->getCoordX(myEndTime) +myItemSize/2,itemPos()+height()/2);
}
TQPoint KDGanttViewItem::getTaskLinkEndCoord()
{
return TQPoint (myGanttView->myTimeHeader->getCoordX(myStartTime)-myItemSize/2 ,itemPos()-myItemSize/2+height()/2-2);
}
void KDGanttViewItem::hideSubtree()
{
if (firstChild())
firstChild()->hideSubtree();
if ( nextSibling () )
nextSibling ()->hideSubtree();
showItem(false);
}
void KDGanttViewItem::setCallListViewOnSetOpen( bool call )
{
_callListViewOnSetOpen = call;
}
void KDGanttViewItem::initColorAndShapes(Type t)
{
setTextOffset(TQPoint(0,0));
//_isCalendar = false;
_callListViewOnSetOpen = true;
myType = t;
myProgress = 0;
progressShape = 0;
floatStartShape = 0;
floatEndShape = 0;
blockUpdating = true;
isVisibleInGanttView = false;
startShape = 0;
midShape = 0;
endShape = 0;
startShapeBack = 0;
midShapeBack = 0;
endShapeBack = 0;
myItemSize = 10;
myGanttView = ((KDListView *)listView())->myGanttView;
myGanttView->myTimeHeader->saveCenterDateTime();
myStartTime = myGanttView->myTimeHeader->myCenterDateTime;
myEndTime = myStartTime;
myToolTipText =TQListViewItem::text(0);
myWhatsThisText = TQListViewItem::text(0);
isHighlighted = false;
isEditable = true;
_displaySubitemsAsGroup = myGanttView->displaySubitemsAsGroup();
startLine = new KDCanvasLine(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);//KDGanttViewItem );
endLine = new KDCanvasLine(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
startLine->setZ(2);endLine->setZ(2);
startLineBack = new KDCanvasLine(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);//KDGanttViewItem );
endLineBack = new KDCanvasLine(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
startLineBack->setZ(1);endLineBack->setZ(1);
actualEnd = new KDCanvasLine(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
actualEnd->setZ(5);
actualEnd->setPen( TQPen ( TQt::red, 3 ) );
textCanvas = new KDCanvasText(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
textCanvas->setText("");
textCanvas->setZ(10);
// set textcolor
setTextColor( myGanttView->textColor());
// set default color
setDefaultColor( myGanttView->defaultColor(myType));
// set default highlight color
setDefaultHighlightColor(myGanttView->defaultHighlightColor(myType));
// set shapes
if (!( shapeDefined = (myGanttView->shapes(myType,myStartShape,myMiddleShape,myEndShape)))) {
//tqDebug("KDGantt::KDGanttViewItem created with not user defined shapes");
};
setShapes(myStartShape,myMiddleShape,myEndShape);
if ( type() == Task ) {
//tqDebug("new task %s ", listViewText().latin1());
if ( startShape )
delete startShape;
startShape = (KDCanvasPolygonItem*)new KDCanvasRectangle(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
progressShape = (KDCanvasPolygonItem*)new KDCanvasRectangle(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
}
floatStartShape = (KDCanvasPolygonItem*)new KDCanvasRectangle(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
floatEndShape = (KDCanvasPolygonItem*)new KDCanvasRectangle(myGanttView->myTimeTable,this,Type_is_KDGanttViewItem);
// set color of shapes
if (!( colorDefined = (myGanttView->colors(myType,myStartColor,myMiddleColor,myEndColor)))) {
};
setColors(defaultColor(),defaultColor(), defaultColor());
// set highlight color of shapes
if (!( colorHLDefined = (myGanttView->highlightColors(myType,myStartColorHL,myMiddleColorHL,myEndColorHL)))) {
};
setHighlightColors(defaultHighlightColor(),defaultHighlightColor(), defaultHighlightColor());
setFont(myGanttView->font());
// if (type() == Task)
//setText(TQListViewItem::text(0)); // testing only
//isvisible = true;
_priority = 150;
_showNoInformation = false;
_enabled = true;
blockUpdating = false;
updateCanvasItems();
}
TQString KDGanttViewItem::shapeToString( Shape shape )
{
switch( shape ) {
case TriangleDown:
return "TriangleDown";
case TriangleUp:
return "TriangleUp";
case Diamond:
return "Diamond";
case Square:
return "Square";
case Circle:
return "Circle";
}
return "";
}
KDGanttViewItem::Shape KDGanttViewItem::stringToShape( const TQString& string )
{
if( string == "TriangleDown" )
return TriangleDown;
else if( string == "TriangleUp" )
return TriangleUp;
else if( string == "Diamond" )
return Diamond;
else if( string == "Square" )
return Square;
else if( string == "Circle" )
return Circle;
else
return TriangleDown;
}
/*!
Creates a DOM node that describes this item.
\param doc the DOM document to which the node belongs
\param parentElement the element into which to insert this node
*/
void KDGanttViewItem::createNode( TQDomDocument& doc,
TQDomElement& parentElement )
{
TQDomElement itemElement = doc.createElement( "Item" );
parentElement.appendChild( itemElement );
itemElement.setAttribute( "Type", typeToString( type() ) );
KDGanttXML::createDateTimeNode( doc, itemElement, "StartTime", startTime() );
KDGanttXML::createDateTimeNode( doc, itemElement, "EndTime", endTime() );
KDGanttXML::createFontNode( doc, itemElement, "Font", font() );
KDGanttXML::createStringNode( doc, itemElement, "Text", text() );
KDGanttXML::createStringNode( doc, itemElement, "TooltipText", tooltipText() );
KDGanttXML::createStringNode( doc, itemElement, "WhatsThisText",
whatsThisText() );
if( pixmap() )
KDGanttXML::createPixmapNode( doc, itemElement, "Pixmap", *pixmap() );
if( !listViewText().isNull() )
KDGanttXML::createStringNode( doc, itemElement, "ListViewText",
listViewText() );
KDGanttXML::createBoolNode( doc, itemElement, "Open", isOpen() );
KDGanttXML::createBoolNode( doc, itemElement, "Highlight", highlight() );
Shape startShape, middleShape, endShape;
shapes( startShape, middleShape, endShape );
KDGanttXML::createStringNode( doc, itemElement, "StartShape",
shapeToString( startShape ) );
KDGanttXML::createStringNode( doc, itemElement, "MiddleShape",
shapeToString( middleShape ) );
KDGanttXML::createStringNode( doc, itemElement, "EndShape",
shapeToString( endShape ) );
KDGanttXML::createColorNode( doc, itemElement, "DefaultColor", defaultColor() );
TQColor startColor, middleColor, endColor;
colors( startColor, middleColor, endColor );
KDGanttXML::createColorNode( doc, itemElement, "StartColor", startColor );
KDGanttXML::createColorNode( doc, itemElement, "MiddleColor", middleColor );
KDGanttXML::createColorNode( doc, itemElement, "EndColor", endColor );
KDGanttXML::createColorNode( doc, itemElement, "DefaultHighlightColor",
defaultHighlightColor() );
highlightColors( startColor, middleColor, endColor );
KDGanttXML::createColorNode( doc, itemElement, "StartHighlightColor",
startColor );
KDGanttXML::createColorNode( doc, itemElement, "MiddleHighlightColor",
middleColor );
KDGanttXML::createColorNode( doc, itemElement, "EndHighlightColor", endColor );
KDGanttXML::createColorNode( doc, itemElement, "TextColor", textColor() );
KDGanttXML::createStringNode( doc, itemElement, "Name", name() );
TQDomElement itemsElement = doc.createElement( "Items" );
itemElement.appendChild( itemsElement );
KDGanttViewItem* currentItem = firstChild();
while( currentItem ) {
currentItem->createNode( doc, itemsElement );
currentItem = currentItem->nextSibling();
}
}
/*!
Creates a KDGanttViewItem according to the specification in a DOM
element.
\param view the view in which the item will be inserted
\param element the DOM element from which to read the specification
\return the newly created item
*/
KDGanttViewItem* KDGanttViewItem::createFromDomElement( KDGanttView* view,
TQDomElement& element )
{
TQString typeString = element.attribute( "Type" );
Q_ASSERT( !typeString.isEmpty() );
KDGanttViewItem* item;
if( typeString == "Task" )
item = new KDGanttViewTaskItem( view );
else if( typeString == "Summary" )
item = new KDGanttViewSummaryItem( view );
else if( typeString == "Event" )
item = new KDGanttViewEventItem( view );
else {
tqDebug( "Unknown item type %s in KDGanttViewItem::createFromDomElement()", typeString.latin1() );
return 0;
}
item->loadFromDomElement( element );
return item;
}
/*!
Creates a KDGanttViewItem according to the specification in a DOM
element.
\param view the view in which the item will be inserted
\param previous to item behind this one should appear
\param element the DOM element from which to read the specification
\return the newly created element
*/
KDGanttViewItem* KDGanttViewItem::createFromDomElement( KDGanttView* view,
KDGanttViewItem* previous,
TQDomElement& element )
{
TQString typeString = element.attribute( "Type" );
Q_ASSERT( !typeString.isEmpty() );
KDGanttViewItem* item;
if( typeString == "Task" )
item = new KDGanttViewTaskItem( view, previous );
else if( typeString == "Summary" )
item = new KDGanttViewSummaryItem( view, previous );
else if( typeString == "Event" )
item = new KDGanttViewEventItem( view, previous );
else {
tqDebug( "Unknown item type in KDGanttViewItem::createFromDomElement()" );
return 0;
}
item->loadFromDomElement( element );
return item;
}
/*!
Creates a KDGanttViewItem according to the specification in a DOM
element.
\param parent the parent item under which the item will be inserted
\param element the DOM element from which to read the specification
\return the newly created element
*/
KDGanttViewItem* KDGanttViewItem::createFromDomElement( KDGanttViewItem* parent,
TQDomElement& element )
{
TQString typeString = element.attribute( "Type" );
Q_ASSERT( !typeString.isEmpty() );
KDGanttViewItem* item;
if( typeString == "Task" )
item = new KDGanttViewTaskItem( parent );
else if( typeString == "Summary" )
item = new KDGanttViewSummaryItem( parent );
else if( typeString == "Event" )
item = new KDGanttViewEventItem( parent );
else {
tqDebug( "Unknown item type in KDGanttViewItem::createFromDomElement()" );
return 0;
}
item->loadFromDomElement( element );
return item;
}
/*!
Creates a KDGanttViewItem according to the specification in a DOM
element.
\param parent the parent item under which the item will be inserted
\param previous to item behind this one should appear
\param element the DOM element from which to read the specification
\return the newly created element
*/
KDGanttViewItem* KDGanttViewItem::createFromDomElement( KDGanttViewItem* parent,
KDGanttViewItem* previous,
TQDomElement& element )
{
TQString typeString = element.attribute( "Type" );
Q_ASSERT( !typeString.isEmpty() );
KDGanttViewItem* item;
if( typeString == "Task" )
item = new KDGanttViewTaskItem( parent, previous );
else if( typeString == "Summary" )
item = new KDGanttViewSummaryItem( parent, previous );
else if( typeString == "Event" )
item = new KDGanttViewEventItem( parent, previous );
else {
tqDebug( "Unknown item type in KDGanttViewItem::createFromDomElement()" );
return 0;
}
item->loadFromDomElement( element );
return item;
}
/*
Fills in the values in the item by reading the DOM element.
*/
void KDGanttViewItem::loadFromDomElement( TQDomElement& element )
{
TQDomNode node = element.firstChild();
Shape startShape = TriangleDown, middleShape = TriangleDown,
endShape = TriangleDown;
TQColor startColor, middleColor, endColor;
TQColor startHighlightColor, middleHighlightColor, endHighlightColor;
TQString tempName;
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
TQString tagName = element.tagName();
if( tagName == "StartTime" ) {
TQDateTime value;
if( KDGanttXML::readDateTimeNode( element, value ) )
setStartTime( value );
} else if( tagName == "EndTime" ) {
TQDateTime value;
if( KDGanttXML::readDateTimeNode( element, value ) )
setEndTime( value );
} else if( tagName == "Text" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
setText( value );
} else if( tagName == "Font" ) {
TQFont value;
if( KDGanttXML::readFontNode( element, value ) )
setFont( value );
} else if( tagName == "TooltipText" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
setTooltipText( value );
} else if( tagName == "WhatsThisText" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
setWhatsThisText( value );
} else if( tagName == "Pixmap" ) {
TQPixmap value;
if( KDGanttXML::readPixmapNode( element, value ) )
setPixmap( value );
} else if( tagName == "ListViewText" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
setListViewText( value );
} else if( tagName == "Open" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setOpen( value );
} else if( tagName == "Highlight" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setHighlight( value );
} else if( tagName == "StartShape" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
startShape = stringToShape( value );
} else if( tagName == "MiddleShape" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
middleShape = stringToShape( value );
} else if( tagName == "EndShape" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
endShape = stringToShape( value );
} else if( tagName == "DefaultColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setDefaultColor( value );
} else if( tagName == "StartColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
startColor = value;
} else if( tagName == "MiddleColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
middleColor = value;
} else if( tagName == "EndColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
endColor = value;
} else if( tagName == "DefaultHighlightColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setDefaultHighlightColor( value );
} else if( tagName == "StartHighlightColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
startHighlightColor = value;
} else if( tagName == "MiddleHighlightColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
middleHighlightColor = value;
} else if( tagName == "EndHighlightColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
endHighlightColor = value;
} else if( tagName == "TextColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setTextColor( value );
} else if( tagName == "Name" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
tempName = value;
} else if( tagName == "Items" ) {
TQDomNode node = element.firstChild();
KDGanttViewItem* previous = 0;
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
TQString tagName = element.tagName();
if( tagName == "Item" ) {
KDGanttViewItem* newItem;
if( previous )
newItem =
KDGanttViewItem::createFromDomElement( this,
previous,
element );
else
newItem =
KDGanttViewItem::createFromDomElement( this,
element );
previous = newItem;
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
setColors( startColor, middleColor, endColor );
setHighlightColors( startHighlightColor, middleHighlightColor,
endHighlightColor );
setShapes( startShape, middleShape, endShape );
generateAndInsertName( tempName );
}
TQString KDGanttViewItem::typeToString( Type type )
{
switch( type ) {
case Event:
return "Event";
case Summary:
return "Summary";
case Task:
return "Task";
default:
tqDebug( "Unknown type in KDGanttViewItem::typeToString()" );
return "Summary";
}
return "";
}
/*!
Returns the y coordinate of this item.
\return the y coordinate of this item
*/
int KDGanttViewItem::getCoordY()
{
return itemPos() + height()/2;
}
void KDGanttViewItem::showSubItems()
{
showSubitemTree( getCoordY() );
}
void KDGanttViewItem::showSubitemTree( int CoordY )
{
KDGanttViewItem* temp = firstChild();
if (temp) {
while (temp != 0) {
if (temp->isOpen() || !temp->displaySubitemsAsGroup() ) {
temp->showItem( true, CoordY );
if ( temp->firstChild() )
temp->firstChild()->hideSubtree();
} else {
if ( temp->displaySubitemsAsGroup() && temp->firstChild() )
temp->hideSubtree();
else {
temp->showSubitemTree( CoordY );
}
}
temp = temp->nextSibling();
}
showItem( false );
} else {
showItem( true, CoordY );
}
}
/*!
Returns the start time of the children of this item.
\return the start time of the children of this item
*/
TQDateTime KDGanttViewItem::myChildStartTime()
{
TQDateTime ret, tempTime;
bool set = true;
KDGanttViewItem* temp = (KDGanttViewItem*) firstChild();
if (temp) {
while (temp != 0) {
if ( !temp->displaySubitemsAsGroup() ) {
tempTime = temp->startTime();
} else {
tempTime = temp->myChildStartTime();
}
if ( set ) {
set = false;
ret = tempTime;
} else {
if ( tempTime < ret ) {
ret = tempTime;
}
}
temp = temp->nextSibling();
}
} else {
ret = startTime();
}
return ret;
}
/*!
Returns the end time of the children of this item.
\return the end time of the children of this item
*/
TQDateTime KDGanttViewItem::myChildEndTime()
{
TQDateTime ret, tempTime;
bool set = true;
KDGanttViewItem* temp = (KDGanttViewItem*) firstChild();
if (temp) {
while (temp != 0) {
if ( !temp->displaySubitemsAsGroup() ) {
tempTime = temp->endTime();
} else {
tempTime = temp->myChildEndTime();
}
if ( set ) {
set = false;
ret = tempTime;
} else {
if ( tempTime > ret ) {
ret = tempTime;
}
}
temp = temp->nextSibling();
}
} else {
ret = endTime();
}
return ret;
}
/*!
Returns whether the 'showNoInformation' line should be shown for this item
\return true if showNoInformation line should be shown
\sa setShowNoInformation(), KDGanttView::setNoInformationBrush(), KDGanttView::noInformationBrush()
*/
bool KDGanttViewItem::showNoInformation()
{
return _showNoInformation;
}
/*!
Specifies whether the 'showNoInformation' line should be shown for
this item.
The 'showNoInformation' line is drawn over the whole timeline.
The height of the line is the height of the item.
The brush of the line is specified by KDGanttView::setNoInformationBrush().
(i.e. the same brush for all items of the Gantt view).
The default brush is TQBrush( TQColor ( 100,100,100 ), TQt::FDiagPattern );
\param show if true, the 'showNoInformation' line is shown for this item
\sa showNoInformation(), KDGanttView::setNoInformationBrush(), KDGanttView::noInformationBrush()
*/
void KDGanttViewItem::setShowNoInformation( bool show )
{
_showNoInformation = show;
myGanttView->myTimeTable->updateMyContent();
}
/*!
If the name of this item is \a name (i.e., listViewText() == name),
the pointer to this item is returned. Otherwise, it looks for an
item with name \a name in the set of children and subchildren of
this item.
\param name the name of the item
\return the pointer to the item with name \a name
*/
KDGanttViewItem* KDGanttViewItem::getChildByName( const TQString& name )
{
if ( listViewText() == name )
return this;
KDGanttViewItem* temp = firstChild(),* ret;
while (temp != 0) {
if ( (ret = temp->getChildByName( name )))
return ret;
temp = temp->nextSibling();
}
return 0;
}
/*
void KDGanttViewItem::printinfo( TQString s )
{
KDGanttViewItem* temp = firstChild();
while (temp != 0) {
temp->printinfo(" "+s );
temp = temp->nextSibling();
}
}
*/
/*!
Returns whether this item has at least one subitem that is a calendar.
A subitem is a calendar, if that item has at least one subitem or
displaySubitemAsGroup() is true for that item.
\return true if the item has at least one subitem that is a calendar.
*/
bool KDGanttViewItem::subitemIsCalendar() const
{
KDGanttViewItem* temp = firstChild();
bool ret = false;
while (temp) {
if (temp->firstChild() || temp->displaySubitemsAsGroup() ) {
ret = true;
break;
}
temp = temp->nextSibling();
}
return ret;
}
int KDGanttViewItem::computeHeight()
{
int hei = 0;
// if not visible, hide item and all subitems, return height = 0
if ( !isVisible() ) {
showItem( false );
if ( firstChild() )
firstChild()->hideSubtree();
// tqDebug("KDGanttViewItem::computeHeight() %s returns 0 ", TQListViewItem::text(0).latin1());
return 0;
}
KDGanttViewItem* temp;
bool show = true;
// explanation of terms:
// display opened item as usual:
// display this item opened, display Gantt part on the timeline of this item.
// the same for all subitems: display all subitems on its own timeline
// display closed item as usual:
// display this item closed, display Gantt part on the timeline of this item.
// do not display any subitem.
// desired behaviour:
// if not in calendar mode( GanttView is NOT in calendar mode ):
// opened:
// display opened item as usual
// closed:
// if not displaySubitemsAsGroup()
// display closed item as usual
// else ( displaySubitemsAsGroup() == true )
// display not this item, display subitems on the timeline of this item
// else ( GanttView is in calendar mode )
// 4 cases:
// opened && displaySubitemsAsGroup():
// display not this item, display subitems on the timeline of this item,
// which have the property displaySubitemsAsGroup() == false
// display the other items,
// which have the property displaySubitemsAsGroup() == true,
// as usual below this item on their own timeline
// opened && NOT displaySubitemsAsGroup():
// display opened item as usual
// closed && displaySubitemsAsGroup():
// display not this item, display subitems on the timeline of this item,
// which have the property displaySubitemsAsGroup() == false
// closed && NOT displaySubitemsAsGroup():
// display closed item as usual
//
if ( isOpen() ) {
//tqDebug("KDGanttViewItem::computeHeight() %s is open ", TQListViewItem::text(0).latin1());
temp = firstChild();
// if item opened, iterate over all subitems
int tempHeight;
// introduced special for performance reasons
bool special = displaySubitemsAsGroup() && myGanttView->calendarMode();
while (temp != 0) {
tempHeight = temp->computeHeight();
if ( special ) {
if ( temp->displaySubitemsAsGroup() ) {
hei += tempHeight;
//tqDebug(" hei added ");
} else {
temp->showSubitemTree( getCoordY() );
}
} else {
hei += tempHeight;
//tqDebug(" hei added ");
}
temp = temp->nextSibling();
}
} else { // closed!
//tqDebug("KDGanttViewItem::computeHeight() %s is closed ", TQListViewItem::text(0).latin1());
if ( !displaySubitemsAsGroup() ) {
if ( firstChild() ) {
firstChild()->hideSubtree();
}
} else {
if ( firstChild() ) {
showSubitemTree( getCoordY() );
show = false ;
}
}
}
if ( show )
showItem( true );
hei += height();
//tqDebug("KDGanttViewItem::computeHeight() %s returns: %d ", TQListViewItem::text(0).latin1(), hei);
return hei;
}
// if this item has at least one subitem which has the property displaySubitemsAsGroup(),
// a false is returned
bool KDGanttViewItem::showNoCross()
{
KDGanttViewItem * temp = firstChild();
if ( !temp )
return false;
while ( temp ) {
if ( temp->displaySubitemsAsGroup() ) {
return false;
}
temp = temp->nextSibling();
}
return true;
}
void KDGanttViewItem::paintBranches ( TQPainter* p, const TQColorGroup& cg,
int w, int y, int h )
{
TQListViewItem::paintBranches ( p, cg, w, y, h);
if ( !myGanttView->calendarMode() )
return;
else {
KDGanttViewItem * temp = firstChild();
while ( temp ) {
if ( temp->showNoCross() ) {
//tqDebug("paintNoCross %s ", temp->listViewText(0).latin1());
int y_coord = temp->itemPos() -height ()- itemPos();
int hei = temp->height();
//tqDebug(" y %d w %d h %d ", y,w,h);
//tqDebug("yc %d hei %d",y_coord,hei );
myGanttView->myListView->paintemptyarea( p, TQRect( 0,y+y_coord,w,hei));
int x_c = w/2;
int y_c = y+y_coord+ temp->height ()/2;
int y_ce ;
if ( temp->itemBelow() && temp->itemBelow()->parent() == this )
y_ce =y+y_coord+ temp->height ();
else
y_ce = y_c;
int i;
for (i = y+y_coord+1; i <= y_ce; i+=2 ) {
p->drawPoint( x_c, i );
}
for (i = x_c+2; i < w; i+=2 ) {
p->drawPoint( i, y_c );
}
}
temp = temp->nextSibling();
}
}
}
// resets the visibility os the subitems according to the setting of calendar mode
void KDGanttViewItem::resetSubitemVisibility()
{
KDGanttViewItem* temp;
temp = firstChild();
bool allow = false;
if ( myGanttView->calendarMode() ) {
// in calendarmode only items can be opened which have subitems which have subitems
if ( ! temp ) {
if ( !parent() )
// has no parent, has no child : show!
setVisible( true );
else
// has parent, has no child : hide!
setVisible( false );
return;
}
setVisible( true );
while (temp) {
if (temp->firstChild()) {
allow = true;
temp->resetSubitemVisibility();
}
else {
temp->setVisible(false);
}
temp = temp->nextSibling();
}
} else {
setVisible( true );
// all items can be opened
allow = true;
while (temp != 0) {
temp->resetSubitemVisibility();
temp = temp->nextSibling();
}
}
if ( !allow && isOpen() )
setOpen( false );
}
/*!
Specifies whether this item should behave like a calendar.
In calendar mode, only those items can be opened
which have subitems which have subitems.
An item which has subitems which have no subitems is called a calendar.
I.e., an item that contains
multiple calendars can be opened, while a calendar item itself cannot.
But if all calendars of an item do not have any subitem (e.g at startup),
the program cannot detect automatically that it should be possible to open
this item.
To enable this, call setIsCalendar( true ); for at least one calendar
\param cal true in order behave this item like a calendar
highlighting off for this item
\sa isCalendar()
*/
/* removed
void KDGanttViewItem::setIsCalendar( bool cal )
{
_isCalendar = cal;
updateCanvasItems();
}
*/
/*!
Returns whether this item behaves like a calendar,
even though it has no subitem which has subitems; when highlighting
with setHighlight() or by the user with the mouse.
\return true if the item behaves like a calendar
\sa setIsCalendar()
*/
/* removed
bool KDGanttViewItem::isCalendar( ) const
{
return _isCalendar;
}
*/
/*!
\var KDGanttViewItem::startLine
the line at the beginning of the item
*/
/*!
\var KDGanttViewItem::endLine
the line at the end of the item
*/
/*!
\var KDGanttViewItem::startLineBack
the background line at the beginning of the item
*/
/*!
\var KDGanttViewItem::endLineBack
the background line at the end of the item
*/
/*!
\var KDGanttViewItem::actualEnd
the line at the actual end of the item
*/
/*!
\var KDGanttViewItem::startShape
the shape at the beginning of the item
*/
/*!
\var KDGanttViewItem::midShape
the shape in the middle of the item
*/
/*!
\var KDGanttViewItem::endShape
the shape at the end of the item
*/
/*!
\var KDGanttViewItem::startShapeBack
the background shape at the beginning of the item
*/
/*!
\var KDGanttViewItem::midShapeBack
the background shape in the middle of the item
*/
/*!
\var KDGanttViewItem::endShapeBack
the background shape at the end of the item
*/
/*!
\var KDGanttViewItem::myGanttView
a pointer to the KDGanttView object to which this item belongs
*/
/*!
\var KDGanttViewItem::textCanvas
the text object that is used for this item
*/
/*!
\var KDGanttViewItem::textCanvasText
the actual string that is displayed in the text object for this item
*/
/*!
\var KDGanttViewItem::myStartTime
the starting time of this item
*/
/*!
\var KDGanttViewItem::myEndTime
the ending time of this item
*/
/*!
\var KDGanttViewItem::isHighlighted
whether this item is currently highlighted or not
*/
/*!
\var KDGanttViewItem::isEditable
whether this item is currently editable or not
*/
/*!
\var KDGanttViewItem::myItemSize
the current size of this item
*/
/*!
\var KDGanttViewItem::blockUpdating
if true, updates to this item are currently blocked, to reduce
flicker or speed up redraws
*/
/*!
\var KDGanttViewItem::isVisibleInGanttView
this instance variable is true if the item is visible in the Gantt
view
*/
/*!
Returns the coordinate of this items middle left point
*/
TQPoint KDGanttViewItem::middleLeft()
{
return TQPoint(myGanttView->myTimeHeader->getCoordX(myStartTime), itemPos()+height()/2);
}
/*!
Returns the coordinate of this items middle right point
*/
TQPoint KDGanttViewItem::middleRight()
{
return TQPoint(myGanttView->myTimeHeader->getCoordX(myEndTime), itemPos()+height()/2);
}
/*!
Moves this items text.
*/
void KDGanttViewItem::moveTextCanvas(int x, int y)
{
int mx = x + myTextOffset.x();
int my = y + myTextOffset.y();
if (myTextOffset.x() != 0)
mx -= 2*myItemSize; // keep old behaviour
textCanvas->move(mx+2*myItemSize,my-myItemSize/2);
//tqDebug("%s: moveTextCanvas(%d,%d) offset: %d,%d moved to %d,%d",listViewText(0).latin1(),x,y,myTextOffset.x(),myTextOffset.y(),mx+2*myItemSize,my-myItemSize/2);
}
/*!
Moves this items text relative to the middle right end of the item
Used to move text away from link.
*/
void KDGanttViewItem::moveTextCanvas()
{
TQPoint m = myTextOffset+middleRight();
textCanvas->move(m.x(), m.y()-myItemSize/2);
}
/*!
Sets with how much the item text is offset.
*/
void KDGanttViewItem::setTextOffset(TQPoint p)
{
//tqDebug("%s: setTextOffset() offset: %d,%d",listViewText(0).latin1(),p.x(),p.y());
myTextOffset.setX(p.x());
myTextOffset.setY(p.y());
}
bool KDGanttViewItem::isMyTextCanvas(TQCanvasItem *tc)
{
return tc == textCanvas;
}
/*!
Specifies the progress of this item in percent.
Progress is limited to minimum 0, maximum 100.
\param percent the progress in percent.
*/
void KDGanttViewItem::setProgress(int percent)
{
myProgress = TQMAX(0, percent);
myProgress = TQMIN(100, myProgress);
}
/*!
Specifies the float start time of this item.
If the time is invalid, the start float is not shown.
\param start the float start time
*/
void KDGanttViewItem::setFloatStartTime(const TQDateTime &start)
{
myFloatStartTime = start;
}
/*!
Specifies the float end time of this item.
If the time is invalid, the end float is not shown.
\param end the float end time
*/
void KDGanttViewItem::setFloatEndTime(const TQDateTime &end)
{
myFloatEndTime = end;
}
|