summaryrefslogtreecommitdiffstats
path: root/kdgantt/KDGanttView.cpp
blob: d9bd17b5fab412f57b2f85631e3251679322479a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
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
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
/* -*- Mode: C++ -*-
   $Id: KDGanttView.cpp 536225 2006-05-01 16:46:33Z tilladam $
   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 [email protected] 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 "KDGanttView.h"
#include "KDGanttViewSubwidgets.h"
#include "KDGanttMinimizeSplitter.h"
#include "KDGanttViewItem.h"
#include "KDGanttXMLTools.h"
#include "itemAttributeDialog.h"
#include <tqprinter.h>
#include <tqpainter.h>
#include <tqlayout.h>
#include <tqpaintdevicemetrics.h>
#include <tqfile.h>
#include <tqheader.h>
#include <tqscrollview.h>
#include <tqapplication.h>
#include <tqevent.h>
#include <tqiconview.h>

#include <tqmessagebox.h>
#include <tqfileinfo.h>

#ifndef KDGANTT_MASTER_CVS
#include "KDGanttView.moc"
#endif

#if defined KDAB_EVAL
#include "../evaldialog/evaldialog.h"
#endif

/*!
  \class KDGanttView KDGanttView.h
  This class represents a Gantt view with the Gantt chart, the header,
  an optional listview and an optional legend.

  In order to set up a Gantt view, create an object of this class, and
  populate it with a number of \a KDGanttViewItem objects.

  If you experience problems with the repainting of the content of the
  Gantt View after scrolling, call \a setRepaintMode().
*/

/*!
  Constructs an empty KDGanttView.

  \param parent the widget parent
  \param name the internal debugging name
*/

KDGanttView::KDGanttView( TQWidget* parent, const char* name  )
    : KDGanttMinimizeSplitter( Qt::Vertical, parent, name ),
      myCanvasView(0),
      myTimeHeaderScroll(0)
{
#if defined KDAB_EVAL
    EvalDialog::checkEvalLicense( "KD Gantt" );
#endif
  myCurrentItem = 0;
    setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
    mySplitter = new KDGanttMinimizeSplitter( this );
    mySplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
    leftWidget = new TQVBox( mySplitter );
    rightWidget = new TQVBox( mySplitter );

    myLegend = new KDLegendWidget( leftWidget, this );
    spacerLeft = new TQHBox( leftWidget );
    myListView = new KDListView(leftWidget, this);
    myListView->setVScrollBarMode (TQScrollView::AlwaysOff );
    connect( myListView, TQT_SIGNAL( selectionChanged( TQListViewItem* ) ),
             this, TQT_SLOT( slotSelectionChanged( TQListViewItem* ) ) );

    connect( myListView, TQT_SIGNAL( mouseButtonClicked ( int, TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT( slotmouseButtonClicked ( int , TQListViewItem * , const TQPoint &, int ) ) );
    connect( myListView, TQT_SIGNAL( contextMenuRequested ( TQListViewItem * , const TQPoint &, int  ) ), this, TQT_SLOT( slotcontextMenuRequested ( TQListViewItem * , const TQPoint & , int ) ) );
    connect( myListView, TQT_SIGNAL(doubleClicked ( TQListViewItem *  ) ), this, TQT_SLOT(slotdoubleClicked ( TQListViewItem * ) ) );

  connect( myListView, TQT_SIGNAL(currentChanged( TQListViewItem *  ) ), this, TQT_SLOT(slotCurrentChanged ( TQListViewItem * ) ) );
  connect( myListView, TQT_SIGNAL(itemRenamed ( TQListViewItem * , int , const TQString &  ) ), this, TQT_SLOT(slotItemRenamed ( TQListViewItem *, int , const TQString &  ) ) );
  connect( myListView, TQT_SIGNAL(mouseButtonPressed(  int, TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT(slotMouseButtonPressed (  int , TQListViewItem * , const TQPoint & , int ) ) );

    //connect( myListView, TQT_SIGNAL( ), this, TQT_SLOT( ) );
    myTimeTable = new KDTimeTableWidget (rightWidget,this);

    spacerRight = new TQWidget(  rightWidget );

    myTimeHeaderContainer = new TQHBox( rightWidget );
    myTimeHeaderContainer->setFrameStyle( TQFrame::NoFrame  );
    myTimeHeaderContainer->setMargin( 0 );
    myTimeHeaderScroll = new TQScrollView ( myTimeHeaderContainer );
    myTimeHeaderScroll->setHScrollBarMode( TQScrollView::AlwaysOff );
    myTimeHeaderScroll->setVScrollBarMode( TQScrollView::AlwaysOff );
    timeHeaderSpacerWidget = new TQWidget( myTimeHeaderContainer );


    /*
    myTimeHeaderScroll = new TQScrollView ( rightWidget );
    myTimeHeaderScroll->setHScrollBarMode( TQScrollView::AlwaysOff );
    myTimeHeaderScroll->setVScrollBarMode( TQScrollView::AlwaysOn );
    */
    //myTimeHeader = new KDTimeHeaderWidget (rightWidget,this);
    myTimeHeader = new KDTimeHeaderWidget (myTimeHeaderScroll->viewport(),this);
    myTimeHeaderScroll->addChild( myTimeHeader );
    myTimeHeaderScroll->viewport()->setBackgroundColor( myTimeHeader->backgroundColor() );
    timeHeaderSpacerWidget->setBackgroundColor( myTimeHeader->backgroundColor() );
    myCanvasView = new KDGanttCanvasView (this,myTimeTable,rightWidget);
    myTimeHeaderScroll->setFrameStyle( TQFrame::NoFrame  );
    //
    myCanvasView->setFrameStyle( TQFrame::NoFrame  );
    myCanvasView->setMargin( 0 );
    //
    myTimeHeaderScroll->setMargin( 0 );//myCanvasView->frameWidth() );
    setFrameStyle(myListView->frameStyle());
    setLineWidth( 2 );
    myListView->setFrameStyle( TQFrame::NoFrame  );
    myListView->setMargin( 0 );
    TQObject::connect(myListView, TQT_SIGNAL (  expanded ( TQListViewItem * ) ) , myTimeTable , TQT_SLOT( expandItem(TQListViewItem * ))) ;
    TQObject::connect(myListView, TQT_SIGNAL (collapsed ( TQListViewItem * ) ) , myTimeTable , TQT_SLOT(collapseItem(TQListViewItem * ))) ;

    timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
    listViewIsVisible = true;
    chartIsEditable = true;
    editorIsEnabled = true;
    _displaySubitemsAsGroup = false;
    initDefaults();
    _showHeader = false;

    myTextColor = TQt::black;
    myLegendItems = new TQPtrList<legendItem>;
    //TQObject::connect( this, TQT_SIGNAL (itemDoubleClicked( KDGanttViewItem* ) ) , this, TQT_SLOT( editItem( KDGanttViewItem*  ))) ;
    myItemAttributeDialog = new itemAttributeDialog();
    setRepaintMode( KDGanttView::Medium );
    //setRepaintMode( KDGanttView::Always );
    setShowLegendButton( true );
    setHeaderVisible( false );

    // now connecting the widgets
    connect(myCanvasView->horizontalScrollBar(), TQT_SIGNAL (  valueChanged ( int )) ,myTimeHeaderScroll->horizontalScrollBar(), TQT_SLOT( setValue ( int))) ;
    connect(myCanvasView, TQT_SIGNAL (  heightResized( int )) ,myTimeTable, TQT_SLOT( checkHeight ( int))) ;
    connect(myCanvasView, TQT_SIGNAL (  widthResized( int )) ,myTimeHeader, TQT_SLOT( checkWidth ( int))) ;

    TQObject::connect(myCanvasView->verticalScrollBar(), TQT_SIGNAL ( valueChanged ( int ) ) ,myListView->verticalScrollBar(), TQT_SLOT( setValue ( int ))) ;
    connect(myTimeHeader, TQT_SIGNAL ( sizeChanged( int ) ) ,this, TQT_SLOT(slotHeaderSizeChanged()  )) ;
    connect(myTimeHeader, TQT_SIGNAL ( sizeChanged( int ) ) ,myTimeTable, TQT_SLOT(resetWidth( int ) )) ;
    connect(myListView, TQT_SIGNAL ( contentsMoving ( int, int ) ) ,myCanvasView, TQT_SLOT(  moveMyContent( int, int ))) ;
   connect(myTimeTable, TQT_SIGNAL ( heightComputed ( int ) ) ,myCanvasView, TQT_SLOT(  setMyContentsHeight( int ))) ;
   // the next three are for adding new ticks at left/right
    connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(addTickLeft()));
    connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(addTickRight()));
    connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT( enableAdding( int )));

   // now initing
    fCenterTimeLineAfterShow = false;
    fDragEnabled = false;
    fDropEnabled = false;
    closingBlocked = false;
   myTimeHeader->computeTicks();
   centerTimelineAfterShow( TQDateTime::tqcurrentDateTime () );
   setDisplayEmptyTasksAsLine( false );
   TQValueList<int> list;
   list.append(240);
   list.append(530);
   mySplitter->setSizes( list );
   myTimeTable->setBlockUpdating();// block updating until this->show() is called
}



KDGanttView::~KDGanttView()
{
  setUpdateEnabled(false);
  // delete cut item, if there is any
  myCanvasView->resetCutPaste( 0 );
  myTimeTable->clearTaskLinks();
}
/*!
  Enables or disables updating of the content of the Gantt view.
  To avoid flickering in the Gantt view while inserting large amounts
  of Gantt items, you should call

  bool upd = KDGanttView::getUpdateEnabled();
  KDGanttView::settUpdateEnabled( false );
    ...  insert items here  ...
  KDGanttView::settUpdateEnabled( upd );

  With this code, you avoid unwanted side effects with other parts in
  your code, where you disable (and re-enable) the update.

  When calling setUpdateEnabled( true ),
  all the content is recomputed, resized, and updated.

  Before calling show() for the first time, updating is disabled.
  When calling show(), updating is automatically enabled.

  \param enable if true, the content of the Gantt view is updated after
  every insertion of a new item.
  \sa getUpdateEnabled()
*/
void KDGanttView::setUpdateEnabled( bool enable )
{
  myTimeTable->setBlockUpdating( !enable );
  if ( enable ) {
    myTimeTable->updateMyContent();
    myCanvasView->setMyContentsHeight( 0 );
  }
}

/*!
  Returns whether updating is enabled or not.

  \return true, if updating is enabled
  \sa setUpdateEnabled()
*/

bool KDGanttView::getUpdateEnabled() const
{
  return !myTimeTable->blockUpdating();
}




/*!
  Sets the maximum width of the Gantt view part widget in pixels.
  The largest allowed width is 32767.
  \param w the maximum width
*/

void KDGanttView::setGanttMaximumWidth( int w )
{
  myTimeHeader->setMaximumWidth ( w );
}
/*!
  Returns the maximum width of the Gantt view part widget in pixels.
  The default maximum width is 32767 pixels.

  \return the maximum width of the Gantt view part widget in pixels.
*/

int  KDGanttView::ganttMaximumWidth() const
{
  return myTimeHeader->maximumWidth();
}

/*!
  Updates the content of the GanttView and shows it.
  Automatically sets setUpdateEnabled( true ).
  \sa setUpdateEnabled()
*/

void KDGanttView::show()
{
  myTimeTable->setBlockUpdating( false );
  if (myCanvasView->horizontalScrollBar()->value() > 0 )
    myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->value()-1  );
  else
    myCanvasView->horizontalScrollBar()->setValue(1 );
  myTimeTable->updateMyContent();
  TQWidget::show();
  myCanvasView->setMyContentsHeight( 0 );
  if ( fCenterTimeLineAfterShow ) {
    fCenterTimeLineAfterShow = false;
    centerTimeline (dtCenterTimeLineAfterShow);
  }
}
/*!
  Closes the widget.
  The closing is rejected, if a repainting is currently being done.
  \param alsoDelete if true, the widget is deleted
  \return true, if the widget was closed
*/

bool KDGanttView::close ( bool alsoDelete )
{
  //qDebug("close ");
  if ( closingBlocked )
    return false;
  return TQWidget::close ( alsoDelete );
}


/*!
  Returns a useful size for the view.
  Returned width:
  tqsizeHint().width() of the list view + width of TimeTable
  Returned height:
  height() of TimeHeader + height() of TimeTable + height() of Legend (if shown)
*/

TQSize KDGanttView::tqsizeHint() const
{
  bool block = myTimeTable->blockUpdating();
  myTimeTable->setBlockUpdating( false );
  myTimeTable->updateMyContent();
  /* The below causes recursive calls to various size updating methods, which
   * cause TQCanvas to hide and show items like mad, which is very slow. If 
   * there is a legitimate gui updating issue here somewhere, it will need
   * to be solved differently.
   */
  //tqApp->processEvents();
  int hintHeight = myTimeHeader->height();
  int legendHeight = 0;
  if ( showLegendButton() )
    legendHeight = myLegend->height();
  int listViewHeaderHeight = 0;
  if ( headerVisible() )
    listViewHeaderHeight = myListView->header()->height();
  if ( hintHeight < legendHeight+listViewHeaderHeight )
    hintHeight = legendHeight + listViewHeaderHeight;
  hintHeight += myListView->horizontalScrollBar()->height();
  if ( myLegend->isShown() )
    hintHeight += myLegend->legendSizeHint().height() +10;
  hintHeight += myTimeTable->minimumHeight+myListView->frameWidth()*2+2;
  int hintWid = myListView->tqsizeHint().width();
  //hintWid += myTimeHeader->mySizeHint+myCanvasView->verticalScrollBar()->width();
  hintWid += myCanvasView->tqsizeHint().width();
  // add 10 for the splitter-bars
  // qDebug("sizehint %d %d ",hintWid+10, hintHeight );
  myTimeTable->setBlockUpdating( block );
  return TQSize( hintWid+10, hintHeight );
}


/*!
  Specifies whether the legend button should be visible. By default,
  it is visible.

  \param show true to show the legend button, false to hide it
  \sa showLegendButton()
*/
void KDGanttView::setShowLegendButton( bool show )
{
  _showLegendButton = show;
     if ( show )
         myLegend->show();
    else
         myLegend->hide();
     slotHeaderSizeChanged();
}


/*!
  Returns whether the legend button is visible.

  \return whether the legend button is visible
  \sa setShowLegendButton()
*/
bool KDGanttView::showLegendButton() const
{
    return _showLegendButton;
}


/*!
  Specifies whether the listview header should be visible. By default,
  it is not visible.

  \param visible true to make the header visible, false to make it invisible
*/
void KDGanttView::setHeaderVisible( bool visible )
{
    if( visible )
        myListView->header()->show();
    else
        myListView->header()->hide();
    _showHeader = visible;
    slotHeaderSizeChanged();
}


/*!
  Returns whether the listview header is visible.

  \return whether the header is visible
*/
bool KDGanttView::headerVisible() const
{
  return _showHeader;
}


/*!
  Returns the corresponding date and time of the coordinate X in the
  Gantt view.

  \param coordX the coordinate to search for
  \param global true if coordX is a global position, false otherwise
  \return the date and time at coordinate X in the Gantt view.
*/
TQDateTime KDGanttView::getDateTimeForCoordX(int coordX, bool global ) const
{
  // default for myTimeHeader->getDateTimeForIndex() is local
   return myTimeHeader->getDateTimeForIndex(coordX, !global );
}


/*!
  Implements a casted pass-through of the selectionChanged() signal.
*/
void KDGanttView::slotSelectionChanged( TQListViewItem* item )
{
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
    Q_ASSERT( gItem );
    emit lvSelectionChanged( gItem );
}


/*
  Implements a casted pass-through of the mouseButtonClicked() signal.
  Signals itemLeftClicked() , itemMidClicked() are emitted as well.
*/
void KDGanttView::slotmouseButtonClicked ( int button, TQListViewItem * item,
                                           const TQPoint & pos, int c )
{
  KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
  emit lvMouseButtonClicked ( button , gItem,  pos,  c );
  if (gItem == 0 && myCurrentItem != 0 ) {
    myCurrentItem = 0;
    emit lvCurrentChanged( gItem );
  }
  if (gItem != 0 && myCurrentItem == 0 ) {
    myCurrentItem = gItem;
    emit lvCurrentChanged( gItem );
  }

  // removed - makes no sense!
  //emit mouseButtonClicked ( button , gItem,  pos,  c );
   {
    switch ( button ) {
    case  Qt::LeftButton:
      emit lvItemLeftClicked( gItem );
      emit itemLeftClicked( gItem );
      break;
    case  Qt::MidButton:
      emit lvItemMidClicked( gItem );
      emit itemMidClicked( gItem );
      break;
    }
  }
}


/*
  Implements a casted pass-through of the contextMenuRequested() signal.
  The signal itemRightClicked() is emitted as well;
  the position is the global position.
*/
void KDGanttView::slotcontextMenuRequested ( TQListViewItem * item, const TQPoint & pos, int col )
{
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
    emit lvContextMenuRequested ( gItem,  pos,  col );
    emit lvItemRightClicked( gItem );
    emit itemRightClicked( gItem );
}


/*
  Implements a casted pass-through of the doubleClicked() signal.
*/
void KDGanttView::slotdoubleClicked ( TQListViewItem * item )
{
   {
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
    emit lvItemDoubleClicked( gItem );
    emit itemDoubleClicked( gItem );
  }
}


/*
  Implements a casted pass-through of the currentChanged() signal.
*/
void KDGanttView::slotCurrentChanged ( TQListViewItem * item )
{
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
    myCurrentItem = gItem;
    emit lvCurrentChanged( gItem );
}


/*
  Implements a casted pass-through of the itemRenamed() signal.
*/
void KDGanttView::slotItemRenamed ( TQListViewItem * item , int col,
                                    const TQString & text )
{
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
    emit lvItemRenamed( gItem,  col, text );
}


/*
  Implements a casted pass-through of the mouseButtonPressed() signal.
*/
void KDGanttView::slotMouseButtonPressed ( int button, TQListViewItem * item,
                                           const TQPoint & pos, int c )
{
    KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
    emit lvMouseButtonPressed( button, gItem,  pos,  c  );
}


/*!
  Specifies whether the content should be repainted after scrolling or
  not.

  \param mode If No, there is no repainting after scrolling. This is
                 the fastest mode.
              If Medium, there is extra repainting after releasing the
                 scrollbar. This provides fast scrolling with updated content
                 after scrolling. Recommended, when tqrepaint problems occur.
                 This is the default value after startup.
              If Always, there is an extra update after every move of the
                 scrollbar. This entails slow scrolling with updated
                 content at all time.
*/
void KDGanttView::setRepaintMode( RepaintMode mode )
{

  TQScrollBar  *cvh, *cvv;
  cvh = myCanvasView->horizontalScrollBar();
  cvv = myCanvasView->verticalScrollBar();
  // first disconnect
  cvh->disconnect( this );
  cvv->disconnect( this );

  switch ( mode ) {
  case  No:

    break;
  case Medium:
    connect( cvv, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
    connect( cvh, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
    connect( cvv, TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(forceRepaint()));
    connect( cvh, TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(forceRepaint()));
    connect( cvv, TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(forceRepaint()));
    connect( cvh, TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(forceRepaint()));
    break;
  case Always:
    connect( cvv, TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT(forceRepaint( int )));
    connect( cvh, TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT(forceRepaint( int )));
    connect( cvv, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
    connect( cvh, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
    break;
  }
}


void KDGanttView::forceRepaint( int )
{
  if ( myTimeTable->blockUpdating() )
    return;
  // qDebug("forceRepaint( int ) ");
  myTimeTable->setAllChanged();
  myTimeTable->update();
}


void KDGanttView::slotHeaderSizeChanged()
{
  int legendHeight = 0;
  if ( showLegendButton() )
    legendHeight = 24;
  int listViewHeaderHeight = 0;
  if ( headerVisible() )
    listViewHeaderHeight = myListView->header()->height();
  int timeHeaderHeight = myTimeHeader->height()+myTimeHeaderScroll->frameWidth()*2;;
  int diffY = timeHeaderHeight-legendHeight-listViewHeaderHeight;
  if ( diffY < 0 ) {
    spacerLeft->setFixedHeight( 0 );
    spacerRight->setFixedHeight(-diffY);
  } else {
    spacerRight->setFixedHeight( 0 );
    spacerLeft->setFixedHeight( diffY );
  }
  myLegend->setFixedHeight( legendHeight );
  myTimeHeaderContainer->setFixedHeight( timeHeaderHeight );
}


/*!
  Specifies whether the legend should be shown as a dock window or not.

  \param show if true, show legend as a dock window
  \sa showLegend(), legendIsDockwindow(), legendDockwindow()
*/void KDGanttView::setLegendIsDockwindow( bool show )
{
  bool isdock = myLegend->asDockwindow();
  if ( show != isdock ) {
    myLegend->setAsDockwindow(show);
    // legend is cleared - reinit legend with list
    legendItem* li;
    for ( li = myLegendItems->first(); li; li = myLegendItems->next() ) {
      myLegend->addLegendItem(li->tqshape, li->color, li->text );
    }
  }
}


/*!
  Returns whether the legend is shown as a dock window

  \return true if the legend is shown as a dock window
  \sa setShowLegend(), setLegendIsDockwindow(), legendDockwindow()
*/bool KDGanttView::legendIsDockwindow() const
{
    return myLegend->asDockwindow();
}


/*!
  Returns the pointer to the legend dock window.
  DO NOT DELETE THIS POINTER!
  If the legend is not a dock window, 0 is returned
  To set the legend as a dock window, call
  KDGanttView::setLegendIsDockwindow( true );

  \return the pointer to the legend dock window
          0 is returned, if the legend is no dock window
          DO NOT DELETE THIS POINTER!
  \sa setShowLegend(), setLegendIsDockwindow(),legendIsDockwindow()
*/
TQDockWindow* KDGanttView::legendDockwindow() const
{
  return myLegend->dockwindow();
}


/*!
  Specifies whether the legend should be shown or not. Besides setting
  this programmatically, the user can also show/hide the legend by
  using the button provided for this purpose.

  \param show force legend to be shown
  \sa showLegend()
*/
void KDGanttView::setShowLegend( bool show )
{
    myLegend->showMe(show);
}


/*!
  Returns whether the legend is currently shown. The visibility of the
  legend can be changed both by \a setShowLegend(), and interactively
  by the user.

  \return true if the legend is currently visible
  \sa setShowLegend()
*/
bool KDGanttView::showLegend() const
{
    return myLegend->isShown();
}


/*!
  Specifies whether the listview of the Gantt view should be shown or
  not.

  \param show pass true in order to show the listview and false in
  order to hide it.
  \sa showListView()
*/
void KDGanttView::setShowListView( bool show )
{
    if(listViewIsVisible == show) return;
    listViewIsVisible = show;
    if (listViewIsVisible)
        myListView->parentWidget()->show();
    else
        myListView->parentWidget()->hide();
}


/*!
  Returns whether the listview of the Gantt view is shown or not.

  \return true if the listview is shown
  \sa setShowListView()
*/
bool KDGanttView::showListView() const
{
    return listViewIsVisible;
}


/*!
  Specifies whether it should be possible to edit the appearance of a
  Gantt item visually in a dialog by double-clicking the item.

  \param enable pass true in order to enable the visual editor and
  false in order to turn it off
  \sa editorEnabled()
*/

void KDGanttView::setEditorEnabled( bool enable )
{
  editorIsEnabled =  enable;
}


/*!
  Returns whether it is possible to edit the appearance of a Gantt
  item visually in a dialog by double-clicking the item.

  \return true if visual editing is enabled, false otherwise
  \sa setEditorEnabled()
*/

bool KDGanttView::editorEnabled() const
{
    return editorIsEnabled;
}


/*!
  Specifies whether the Gantt chart is user-editable.

  \param editable pass true in order to get a user-editable Gantt
  chart, pass false in order to get a read-only chart
  \sa editable()
*/

void KDGanttView::setEditable( bool editable )
{
  chartIsEditable =  editable;
}


/*!
  Returns whether the Gantt chart is user-editable

  \return true if the Gantt chart is user-editable
  \sa setEditable()
*/

bool KDGanttView::editable() const
{
    return chartIsEditable;
}


/*!
  Saves the state of the Gantt view in an IO device in XML format. The saved
  data can be reloaded with \a loadProject().

  \param device a pointer to the IO device in which to store the Gantt
  view state.
  \return true if the data could be written, false if an error
  occurred
  \sa loadProject()
*/

bool KDGanttView::saveProject( TQIODevice* device )
{
    Q_ASSERT( device );

    TQDomDocument doc = saveXML();
    if( device->isOpen() )
        device->close();
    if( device->open( IO_WriteOnly ) ) {
        TQTextStream ts( device );
        ts << doc.toString();
        return true;
    } else
        return false;
}


/*!
  Loads a previously saved state of the Gantt view. All current
  settings and items are discarded before loading the data.

  \param device a pointer to the IO device from which to load the
  Gantt view state.
  \return true if the file could be read, false if an error
  occurred
  \sa saveProject()
*/

bool KDGanttView::loadProject( TQIODevice* device )
{
    Q_ASSERT( device );

    if( device->isOpen() )
        device->close();
    if( device->open( IO_ReadOnly ) ) {
        TQDomDocument doc( "GanttView" );
        TQString err;
        int errline, errcol;
        if ( !doc.setContent( device, &err, &errline, &errcol ) ) {
          qDebug("KDGantt::Error parsing XML data at line %d. Message is:", errline );
          qDebug("%s ", err.latin1());
          device->close();
          return false;
        }
        device->close();
        return loadXML( doc );
    } else
        return false;
}


/*!
  Sends a Gantt view to a printer. The printer should already be set
  up for printing (by calling TQPrinter::setup()).
  If the printer is not set up, TQPrinter::setup() is called before printing

  You can specify, whether the ListView, TimeLine, or Legend will be
  printed. All combinations of these three widgets are allowed.

  \param printer a pointer to the printer to print on. If printer is
  0, the method creates a temporary printer and discards it when it is
  done printing.
  \param printListView if true, the list view is printed
  \param printTimeLine if true, the time line is printed
  \param printLegend if true, the legend is printed

  \sa drawContents()
*/

void KDGanttView::print( TQPrinter* printer ,
                         bool printListView, bool printTimeLine,
                         bool printLegend )
{
  bool deletePrinter = false;
  if (! printer ) {
    printer = new TQPrinter();
    deletePrinter = true;
    if ( !printer->setup()) {
      delete printer;
      return;
    }
  }
  // now we have a printer to print on
  TQPainter p( printer );
  // get the paper metrics
  TQPaintDeviceMetrics m = TQPaintDeviceMetrics ( printer );
  float dx, dy;
  // get the size of the desired output for scaling.
  // here we want to print all: ListView, TimeLine, and Legend
  // for this purpose, we call drawContents() with a 0 pointer as painter
  TQSize size = drawContents( 0, printListView, printTimeLine, printLegend );

  // at the top, we want to print current time/date
  TQString date = "Printing Time: " + TQDateTime::tqcurrentDateTime().toString();
  int hei = p.boundingRect(0,0, 5, 5, TQt::AlignLeft, date ).height();
  p.drawText( 0, 0, date );

  // compute the scale
  dx = (float) m.width()  / (float)size.width();
  dy  = (float)(m.height() - ( 2 * hei )) / (float)size.height();
  float scale;
  // scale to fit the width or height of the paper
  if ( dx < dy )
    scale = dx;
  else
    scale = dy;
  // set the scale
  p.scale( scale, scale );
  // now printing with y offset:  2 hei
  p.translate( 0, 2*hei );
  drawContents( &p, printListView, printTimeLine, printLegend );
  // the drawContents() has the side effect, that the painter translation is
  // after drawContents() set to the bottom of the painted stuff
  // for instance a
  // p.drawText(0, 0, "printend");
  // would be painted directly below the paintout of drawContents()
  p.end();
  if ( deletePrinter )
    delete printer;
}


/*!
  Paints a Gantt view on a TQPainter.
  You can specify, whether the list view, the time line, or the legend
  is painted.
  All combinations of these three widgets are allowed.
  Returns the size of the painted area.
  Paints the list view in the top-left corner, the time line to the
  right of the list view, and the legend below the list view.
  If called with \a p = 0, nothing is painted and only
  the size of the painted area is computed.
  This is useful for determining only the painted area and setting
  the scale of the painter, before calling this method with a painter.
  In order to get the output fitted to your paper and your printer,
  call first
  TQSize size = drawContents( 0, printListView, printTimeLine, printLegend );
  //then compute the scale
  dx = paper.width()  / size.width();
  dy  = paper.height() / size.height();
  //then make float scale to fit the width or height of the paper
  if ( dx < dy )
    scale = dx;
  else
    scale = dy;
  // then set the scale
  p.scale( scale, scale );
  // and now call drawContents with painter p
  drawContents( &p, printListView, printTimeLine, printLegend );

  For a detailed example, please see the commented source code in
  KDGanttView::print(...)

  \param p  a pointer to the painter to paint on. If p is
  0, nothing is painted and only the size of the painted area is computed
  \param drawListView if true, the list view is painted
  \param drawTimeLine if true, the time line is painted
  \param drawLegend if true, the legend is painted
  \return the size of the painted area
  \sa print()
*/
TQSize KDGanttView::drawContents( TQPainter* p,
                      bool drawListView , bool drawTimeLine, bool drawLegend )
{
  TQSize size;
  int lvX, lvY, thX, thY, tlX, tlY, lwX, lwY, allX, allY;
  lvX = myListView->contentsWidth();
  lvY = myCanvasView->canvas()->height() + 20;
  thX = myTimeHeader->width();
  thY = myTimeHeader->height();
  tlX = myCanvasView->canvas()->width();
  tlY = lvY;
  lwX = myLegend->legendSize().width();
  lwY = myLegend->legendSize().height();
  allX = 0;
  allY = 0;
  if ( drawListView ) {
    allX += lvX;
    allY += tlY;
  }
  if ( drawTimeLine ) {
    allX += thX;
    allY += thY;
  }
  if ( drawLegend ) {
    allY += lwY;
    if ( allX < lwX )
      allX = lwX ;
  }
  size = TQSize( allX, allY );
  int temp = 0;
  if ( p ) {
    if ( drawListView ) {
      if ( drawTimeLine )
        temp =  thY;
      p->translate( 0, temp );
      //HACK: Only draw list headers if we draw timeline, else
      // there is no room for it. This will most probably be changed
      // with qt4 anyway, so I think we can live with it atm.
      myListView->drawToPainter( p, drawTimeLine ); 
      p->translate( lvX, -temp);
    }
    if ( drawTimeLine ) {
      p->translate( myCanvasView->frameWidth(), 0);
      myTimeHeader->repaintMe( 0, myTimeHeader->width(), p );
      p->translate( -myCanvasView->frameWidth(), thY);
      myCanvasView->drawToPainter( p );
      if ( drawListView )
        p->translate( -lvX, tlY);
      else
        p->translate( 0, tlY);
    } else {
      if ( drawListView )
        p->translate( -lvX, 0 );
    }
    if ( drawLegend ) {
       myLegend->drawToPainter( p );
       p->translate( 0, lwY );
    }
  }
  return size;
}

/*!
  Zooms into the Gantt chart. Values less than 1 mean zooming in,
  values greater than 1 mean zooming out. A zooming factor of exactly
  1.0 means original size.

  \param factor the zoom factor
  \param absolute if true, factor is interpreted absolutely, if false,
  factor is interpreted relatively to the current zoom factor
  \sa zoomToFit()
  \sa zoomToSelection()
  \sa zoomFactor()
*/

void KDGanttView::setZoomFactor( double factor, bool absolute )
{
    myTimeHeader->zoom(factor,absolute);
}


/*!
  Returns the current zoom factor.

  \return the current zoom factor
  \sa zoomToFit(), zoomToSelection(), setZoomFactor()
*/

double KDGanttView::zoomFactor() const
{
    return myTimeHeader->zoomFactor();
}


/*!
  Zooms such that the Gantt chart is less than the available space of the widget.

  \sa setZoomFactor()
  \sa zoomFactor()
  \sa zoomToSelection()
*/

void KDGanttView::zoomToFit()
{
  myTimeHeader->zoomToFit();
}


/*!
  Zooms so that at least the selected time period is visible after the zoom.

  \param start the new font of the widget
  \param end the new font of the widget

  \sa setZoomFactor()
  \sa zoomFactor()
  \sa zoomToFit()
*/

void KDGanttView::zoomToSelection( const TQDateTime& start,  const TQDateTime&  end )
{

  myTimeHeader->zoomToSelection( start, end);

}


/*!
  Makes sure that the specified Gantt item is visible without
  scrolling.

  \sa center(), centerTimelineAfterShow()
*/
void KDGanttView::ensureVisible( KDGanttViewItem* item )
{
    myListView->ensureItemVisible (item);
}


/*!
  Makes sure that the specified TQDateTime is in the center of the
  visible Gantt chart (if possible).
  If you want to center the timeline when the KDGanttView is hidden,
  calling centerTimelineAfterShow() is the better alternative.

  \sa center(), centerTimelineAfterShow()
*/
void KDGanttView::centerTimeline( const TQDateTime& center )
{
  myTimeHeader->centerDateTime( center );
}


/*!
  Makes sure that the specified TQDateTime is in the center of the
  visible Gantt chart (if possible).  If the KDGanttView is currently
  hidden, this method resets the center once again after the next
  show() call. Use this method if you want to center the timeline when
  the KDGanttView is hidden. After calling KDGanttView::show(), there
  may be computations of the sizes of the widgets and subwidgets and
  of the automatically computed start datetime. This method ensures
  that the center of the timeline is to be properly reset after
  show().

  \sa center(), centerTimeline()
*/
void KDGanttView::centerTimelineAfterShow( const TQDateTime& center )
{
  myTimeHeader->centerDateTime( center );
  if ( ! isVisible() ) {
    dtCenterTimeLineAfterShow = center;
    fCenterTimeLineAfterShow = true;
  }
}

/*!
  Sets the timeline to the horizon start.
*/

void KDGanttView::setTimelineToStart()
{
  myCanvasView->horizontalScrollBar()->setValue( 0 );
}


/*!
  Sets the timeline to the horizon end.
*/
void KDGanttView::setTimelineToEnd()
{
 myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->maxValue());
}


/*!
  Add \a num minor ticks of the current scale of the timeline
  to the start of the timeline.
  The timeline is not set automatically at the start.
  Call \a setTimelineToStart() to ensure that the timeline is at the start
  after calling this method.

  \param num the number of minor ticks which should be added
  \sa addTicksRight(),setTimelineToStart(), setTimelineToEnd()
*/
void KDGanttView::addTicksLeft( int num )
{
  myTimeHeader->addTickLeft( num  );
}


/*!
  Add \a num minor ticks of the current scale of the timeline
  to the end of the timeline.
  The timeline is not set automatically at the end.
  Call \a setTimelineToEnd() to ensure that the timeline is at the end
  after calling this method.
  \param num the number of minor ticks which should be added
  \sa addTicksLeft(),setTimelineToStart(), setTimelineToEnd()
*/
void KDGanttView::addTicksRight( int num )
{
  myTimeHeader->addTickRight( num );
}


/*!
  Makes sure that the specified Gantt item is in the center of the
  visible Gantt chart (if possible).
*/
void KDGanttView::center( KDGanttViewItem* item )
{
    ensureVisible(item);
    int x =  myListView->contentsWidth()/2;
    int y = myListView->itemPos (item );
    myListView->center(x,y);
}


/*!
  Specifies whether task links should be shown.

  \param show true for showing task links, false for not showing them
  \sa showTaskLinks(), KDGanttViewTaskLink
*/
void KDGanttView::setShowTaskLinks( bool show )
{
    myTimeTable->setShowTaskLinks(show);

}


/*!
  Returns whether task links should be shown.

  \return true if task links are shown, false otherwise
  \sa setShowTaskLinks(), KDGanttViewTaskLink
*/
bool KDGanttView::showTaskLinks() const
{
    return  myTimeTable->showTaskLinks();
}


/*!
  Sets the font in the left list view widget and
  in the right time header widget.
  The settings of the fonts in the time table widget are not effected.

  \param font the new font of the widget
*/
void KDGanttView::setFont(const TQFont& font)
{
    myListView->setFont(font);
    myListView->tqrepaint();
    myTimeHeader->setFont(font);
    myLegend->setFont( font );
    TQWidget::setFont( font );
    setScale(scale());
}


/*!
  Specifies whether the configure popup menu should be shown on
  right click on the time header widget.
  This menu lets the user quickly change
  the zoom factor,
  the scale mode (minute, hour, day, week, month, auto) ,
  the time format,
  the year format,
  the grid format,
  and printing.
  The default setting is not to show the popup menu.
  This functionality must be enabled explicitly by the application
  developer.
  You can disable each submenu of the popmenu.

  \param show true in order to show the popup menu, false in order not
  to. The default is true.
  \param showZoom show the zoom submenu, default: true
  \param showScale show the scale submenu, default: true
  \param showTime show the time format submenu, default: true
  \param showYear show the year format submenu, default: true
  \param showGrid show the grid submenu, default: true
  \param showPrint show the print submenu, default: false
*/
void KDGanttView::setShowHeaderPopupMenu( bool show,
                                          bool showZoom,
                                          bool showScale,
                                          bool showTime,
                                          bool showYear,
                                          bool showGrid,
                                          bool showPrint)
{
    myTimeHeader->setShowPopupMenu( show,showZoom,showScale,showTime,
                                    showYear,showGrid,showPrint );
}


/*!
  Returns whether the configure popup menu should be shown on right
  click on the time header widget.

  \return true if the popup menu should be shown
*/
bool KDGanttView::showHeaderPopupMenu() const
{
    return myTimeHeader->showPopupMenu();
}
//****************************************************


/*!
  Specifies whether the add item popup menu should be shown on
  right click on the time table widget.
  This menu lets the user quickly add new items to the Gantt view
  (as root, as child or after an item).
  It also offers cutting and pasting of items.

  The default setting is that the popup menu is not shown.
  It must be enabled by the program.

  \param show true in order to show popup menu, false in order not to

*/
void KDGanttView::setShowTimeTablePopupMenu( bool show )
{
    myCanvasView->setShowPopupMenu( show );
}


/*!
  Returns whether the add item popup menu should be shown on right
  click on the time table widget.

  \return true if the popup menu should be shown
*/
bool KDGanttView::showTimeTablePopupMenu() const
{
    return myCanvasView->showPopupMenu();
}


/*!
  Sets the tqshapes for a certain type of Gantt item. Not all items use
  all three tqshapes (e.g., only summary items use the middle tqshape).

  This setting overrides any tqshape settings made on individual items.
  These settings will be taken as initial values of any newly created
  item of this certain type.
  See also the documentation of the KDGanttViewItem class.

  \param type the type of Gantt items for which to set the tqshapes
  \param start the tqshape to use for the beginning of the item
  \param middle the tqshape to use for the middle of the item
  \param end the tqshape to use for the end of the item
  \param overwriteExisting if true, overwrites existing tqshape settings
  in the individual items
  \sa tqshapes()
*/
void KDGanttView::setShapes( KDGanttViewItem::Type type,
                             KDGanttViewItem::Shape start,
                             KDGanttViewItem::Shape middle,
                             KDGanttViewItem::Shape end,
                             bool overwriteExisting )
{
    if ( overwriteExisting ) {
      TQListViewItemIterator it(myListView);
      for ( ; it.current(); ++it ) {
        if ( ((KDGanttViewItem*)it.current())->type() == type)
          ((KDGanttViewItem*)it.current())->setShapes(start,middle, end );
      }
    }
    int index = getIndex( type );
    myDefaultShape [index*3] = start;
    myDefaultShape [index*3+1] = middle;
    myDefaultShape [index*3+2] = end;
    undefinedShape[index] = false;
}


/*!
  Queries the tqshapes for a particular type of Gantt item.

  \param type the type of Gantt items for which to query the tqshapes
  \param start the start tqshape is returned in this parameter
  \param middle the middle tqshape is returned in this parameter
  \param end the end tqshape is returned in this parameter
  \return true if there was a general tqshape set for the specified
  type. If the return value is false, the values of the three tqshape
  parameters are undefined.
  \sa setShapes()
*/
bool KDGanttView::tqshapes( KDGanttViewItem::Type type,
                          KDGanttViewItem::Shape& start,
                          KDGanttViewItem::Shape& middle,
                          KDGanttViewItem::Shape& end ) const
{
    int index = getIndex( type );
    start = myDefaultShape [index*3];
    middle = myDefaultShape [index*3+1];
    end = myDefaultShape [index*3+2];
    return !undefinedShape[index];
}


/*!
  Sets the colors for a certain type of Gantt item. Not all items use
  all three colors (e.g., only summary items use the middle color).

  This setting overrides any color settings made on individual items.
  These settings will be taken as initial values of any newly created
  item of this certain type.
  See also the description of the KDGanttViewItem class.

  \param type the type of Gantt items for which to set the colors
  \param start the color to use for the beginning of the item
  \param middle the color to use for the middle of the item
  \param end the color to use for the end of the item
  \param overwriteExisting if true, overwrites existing color settings
  on invididual items
  \sa colors(), setDefaultColors(), defaultColors()
*/
void KDGanttView::setColors( KDGanttViewItem::Type type,
                             const TQColor& start, const TQColor& middle,
                             const TQColor& end,
                             bool overwriteExisting )
{
    if ( overwriteExisting ) {
      TQListViewItemIterator it(myListView);
      for ( ; it.current(); ++it ) {
        if ( ((KDGanttViewItem*)it.current())->type() == type)
          ((KDGanttViewItem*)it.current())->setColors(start,middle, end );
      }
    }
    int index = getIndex( type );
    myColor [index*3] = start;
    myColor [index*3+1] = middle;
    myColor [index*3+2] = end;
    undefinedColor[index] = false;
}


/*!
  Queries the colors for a particular type of Gantt item.

  \param type the type of Gantt items for which to query the colors
  \param start the start color is returned in this parameter
  \param middle the middle color is returned in this parameter
  \param end the end color is returned in this parameter
  \return true if there was a general color set for the specified
  type. If the return value is false, the values of the three color
  parameters are undefined.
  \sa setColors(), setDefaultColor(), defaultColor()
*/
bool KDGanttView::colors( KDGanttViewItem::Type type,
                          TQColor& start, TQColor& middle, TQColor& end ) const
{
  int index = getIndex( type );
  start = myColor [index*3];
    middle = myColor [index*3+1];
    end = myColor [index*3+2];
    return !undefinedColor[index];
}


/*!
  Sets the highlight colors for a certain type of Gantt item. Not
  all items use all three highlight colors (e.g., only summary items
  use the middle highlight color).

  This setting overrides any highlight color settings made on
  individual items.
  These settings will be taken as initial values of any newly created
  item of this certain type.
  See also the description of the KDGanttViewItem class.

  \param type the type of Gantt items for which to set the highlight colors
  \param start the highlight color to use for the beginning of the item
  \param middle the highlight color to use for the middle of the item
  \param end the highlight color to use for the end of the item
  \param overwriteExisting if true, overwrites existing color settings
  in the individual items
  \sa highlightColors(), setDefaultHighlightColor(), defaultHighlightColor()
*/
void KDGanttView::setHighlightColors( KDGanttViewItem::Type type,
                                      const TQColor& start,
                                      const TQColor& middle,
                                      const TQColor& end,
                                      bool overwriteExisting )
{
    if ( overwriteExisting ) {
      TQListViewItemIterator it(myListView);
      for ( ; it.current(); ++it ) {
        if ( ((KDGanttViewItem*)it.current())->type() == type)
          ((KDGanttViewItem*)it.current())->setHighlightColors(start,middle, end );
      }
    }
    int index = getIndex( type );
    myColorHL [index*3] = start;
    myColorHL [index*3+1] = middle;
    myColorHL [index*3+2] = end;
    undefinedColorHL[index] = false;

}


/*!
  Queries the highlight colors for a particular type of Gantt item.

  \param type the type of Gantt items for which to query the highlight
  colors
  \param start the start highlight color is returned in this parameter
  \param middle the middle highlight color is returned in this parameter
  \param end the end highlight color is returned in this parameter
  \return true if there was a general highlight color set for the specified
  type. If the return value is false, the values of the three highlight color
  parameters are undefined.
  \sa setHighlightColors(), setDefaultHighlightColor(),
  defaultHighlightColor()
*/
bool KDGanttView::highlightColors( KDGanttViewItem::Type type,
                                   TQColor& start, TQColor& middle,
                                   TQColor& end ) const
{
  int index = getIndex( type );
  start = myColorHL [index*3];
    middle = myColorHL [index*3+1];
    end = myColorHL [index*3+2];
    return !undefinedColorHL[index];
}


/*!
  Sets the color used for texts in the Gantt chart.
  Overrides all individual settings of the Gantt items.

  \param color the text color to use
  \sa textColor()
*/
void KDGanttView::setTextColor( const TQColor& color )
{
    TQListViewItemIterator it(myListView);
    for ( ; it.current(); ++it ) {
        ((KDGanttViewItem*)it.current())->setTextColor(color);
    }
    myTextColor = color;
}


/*!
  Returns the color used for texts in the Gantt chart.

  \return the color used for texts in the Gantt chart.
  \sa setTextColor()
*/
TQColor KDGanttView::textColor() const
{
    return myTextColor;
}


/*!
  Specifies the brush in which the 'showNoInformation' line of items
  should be drawn.

  \param  brush the brush of the 'showNoInformation' lines
  \sa  KDGanttViewItem::showNoInformation(),
  KDGanttViewItem::setShowNoInformation(),
  KDGanttView::noInformationBrush()

*/
void KDGanttView::setNoInformationBrush( const TQBrush& brush )
{
  myTimeTable->setNoInformationBrush( brush );
}


/*!
  Returns the brush of the 'showNoInformation' lines
  \return  the brush of the 'showNoInformation' lines
  \sa  KDGanttViewItem::showNoInformation(), KDGanttViewItem::setShowNoInformation(),
  setNoInformationBrush()
*/
TQBrush KDGanttView::noInformationBrush() const
{
  return myTimeTable->noInformationBrush();
}


/*!
  Removes all items from the legend.

  \sa addLegendItem()
*/
void KDGanttView::clearLegend( )
{
    myLegend->clearLegend();
    myLegendItems->setAutoDelete( true );
    delete myLegendItems;
    myLegendItems = new TQPtrList<legendItem>;
}


/*!
  Adds an item to the legend.

  \param tqshape the tqshape to display
  \param tqshapeColor the color in which to display the tqshape
  \param text the text to display
  \sa clearLegend()
*/
void KDGanttView::addLegendItem( KDGanttViewItem::Shape tqshape,
                                 const TQColor& tqshapeColor,
                                 const TQString& text )
{
    myLegend->addLegendItem( tqshape,tqshapeColor,text );
    legendItem* item = new legendItem;
    item->tqshape = tqshape;
    item->color = tqshapeColor;
    item->text = text;
    myLegendItems->append( item );
}


/*!
  Sets the start of the horizon of the Gantt chart. If \a start is
  null, the horizon start is computed automatically.

  \param start the start of the horizon
  \sa horizonStart()
*/
void KDGanttView::setHorizonStart( const TQDateTime& start )
{
    myTimeHeader->setHorizonStart(start);
}


/*!
  Returns the start of the horizon of the Gantt chart.

  \return the start of the horizon of the Gantt chart
  \sa setHorizonStart()
*/
TQDateTime KDGanttView::horizonStart() const
{
    return myTimeHeader->horizonStart();
}


/*!
  Sets the end of the horizon of the Gantt chart. If \a end is
  null, the horizon end is computed automatically.

  \param end the end of the horizon
  \sa setHorizonEnd()
*/
void KDGanttView::setHorizonEnd( const TQDateTime& end )
{
    myTimeHeader->setHorizonEnd(end);
}


/*!
  Returns the end of the horizon of the Gantt chart.

  \return the end of the horizon of the Gantt chart
  \sa setHorizonEnd()

*/
TQDateTime KDGanttView::horizonEnd() const
{
    return myTimeHeader->horizonEnd();
}


/*!
  Configures the unit of the lower scale of the header. The higher
  unit is computed automatically.

  \param unit the unit of the lower scale of the header.
  \sa scale()
*/
void KDGanttView::setScale( Scale unit )
{
    myTimeHeader->setScale( unit );
}


/*!
  Returns the unit of the lower scale of the header.

  \return the unit of the lower scale of the header.
  \sa setScale()
*/
KDGanttView::Scale KDGanttView::scale() const
{
    return myTimeHeader->scale();
}


/*!
  Sets the maximum allowed time scale of the lower scale of the header.

  \param unit the unit of the lower scale of the header.
  \sa scale()
*/
void KDGanttView::setMaximumScale( Scale unit )
{
    myTimeHeader->setMaximumScale( unit );
}


/*!
  Returns the maximum allowed time scale of the lower scale of the header.

  \return the unit of the lower scale of the header.
  \sa setScale()
*/
KDGanttView::Scale KDGanttView::maximumScale() const
{
    return myTimeHeader->maximumScale();
}


/*!
  Sets the minimum allowed time scale of the lower scale of the header.

  \param unit the unit of the lower scale of the header.
  \sa scale()
*/
void KDGanttView::setMinimumScale( Scale unit )
{
    myTimeHeader->setMinimumScale( unit );
}


/*!
  Returns the minimum allowed time scale of the lower scale of the header.

  \return the unit of the lower scale of the header.
  \sa setScale()
*/
KDGanttView::Scale KDGanttView::minimumScale() const
{
    return myTimeHeader->minimumScale();
}


/*!
  Sets the absolute number of minor ticks, if scaling is set to Auto.
  If the scale mode is set to Auto, then the actual scale and
  the minorScaleCount is automatically computed, such that there are
  count minor ticks

  \param count the number of minor ticks
  \sa autoScaleMinorTickCount(),setScale(),scale()
*/
void KDGanttView::setAutoScaleMinorTickCount( int count )
{
  myTimeHeader->setAutoScaleMinorTickCount( count );
}


/*!
  Returns the absolut number of minor ticks, if scaling is set to Auto

  \return the absolut number of minor ticks
  \sa setAutoScaleMinorTickCount(),setScale(),scale()
*/
int KDGanttView::autoScaleMinorTickCount() const
{
  return myTimeHeader->autoScaleMinorTickCount();
}


/*!
  Sets the minimum width that a column needs to have. If the size of the
  Gantt chart and the scale would make it necessary to go below this
  limit otherwise, the chart will automatically be made less exact.

  \param width the minimum column width
  \sa minimumColumnWidth()
*/
void KDGanttView::setMinimumColumnWidth( int width )
{
    myTimeHeader->setMinimumColumnWidth( width );
}


/*!
  Returns the minimum width a column needs to have.

  \return the column minimum width
  \sa setMinimumColumnWidth()
*/
int KDGanttView::minimumColumnWidth() const
{
    return myTimeHeader->minimumColumnWidth();
}


/*!
  Specifies the format in which to display years. If no years are
  shown, this method has no effect.

  \param format the year format
  \sa yearFormat(), setHourFormat(), hourFormat()
*/
void KDGanttView::setYearFormat( YearFormat format )
{
    myTimeHeader->setYearFormat(format );
}


/*!
  Returns the format in which to display years.

  \return the year format
  \sa setYearFormat(), setHourFormat(), hourFormat()
*/
KDGanttView::YearFormat KDGanttView::yearFormat() const
{
    return myTimeHeader->yearFormat();
}


/*!
  Specifies the format in which to display hours. If no hours are
  shown, this method has no effect.

  \param format the hour format
  \sa hourFormat(), setYearFormat(), yearFormat()

*/
void KDGanttView::setHourFormat( HourFormat format )
{
    myTimeHeader->setHourFormat( format );
}


/*!
  Returns the format in which to display hours.

  \return the hour format
  \sa setHourFormat(), setYearFormat(), yearFormat()

*/
KDGanttView::HourFormat KDGanttView::hourFormat() const
{
    return myTimeHeader->hourFormat();
}


/*!
  Hides/shows the grid for the major ticks of the time header in the gantt view.

  \param show true in order to show ticks, false in order to hide them.
         If show is true, setShowMinorTicks( false ) is performed automatically
         to hide the grid of the minor ticks.
         In order to show now grid, call setShowMinorTicks( false ) and 
         setShowMajorTicks( false ).
  \sa showMajorTicks(), setShowMinorTicks(), showMinorTicks()
*/
void KDGanttView::setShowMajorTicks( bool show )
{
    myTimeHeader->setShowMajorTicks(show );
}


/*!
  Returns whether the grid is shown on the major scale.

  \return true if ticks are shown on the major scale
  \sa setShowMajorTicks(), setShowMinorTicks(), showMinorTicks()
*/
bool KDGanttView::showMajorTicks() const
{
    return myTimeHeader->showMajorTicks();
}


/*!
  Hides/shows the grid for the minor ticks of the time header in the gantt view.

  \param show true in order to show ticks, false in order to hide them.
         If show is true, setShowMajorTicks( false ) is performed automatically
         to hide the grid of the major ticks.
         In order to show now grid, call setShowMinorTicks( false ) and 
         setShowMajorTicks( false ).

  \sa showMinorTicks(), setShowMajorTicks(), showMajorTicks()

*/
void KDGanttView::setShowMinorTicks( bool show)
{
    myTimeHeader->setShowMinorTicks( show );
}


/*!
  Returns whether ticks are shown on the minor scale.

  \return true if ticks are shown on the minor scale
  \sa setShowMinorTicks(), setShowMajorTicks(), showMajorTicks()
*/
bool KDGanttView::showMinorTicks() const
{
    return myTimeHeader->showMinorTicks();
}


/*!
  Sets the background color for the column closest to \a column.
  It can be specified whether the color should be shown in all scales or
  only in specific scales.
  If you want to define the color only for the daily view, specify
  mini and maxi as Day.
  If there is no value specified for mini and maxi, the color for the column
  is shown on all scales. Note that it is possible that there are two
  values for a column in a scale. In this case, the shown color is unspecified.

  \param column the column to set the background color for
  \param color the background color
  \param mini show the colour only in scales greater than this
  \param maxi show the colour only in scales lesser than this
  \sa columnBackgroundColor(), setWeekendBackgroundColor(),
  weekendBackgroundColor()
*/
void KDGanttView::setColumnBackgroundColor( const TQDateTime& column,
                                            const TQColor& color ,
                                            Scale mini, Scale maxi )
{
  myTimeHeader->setColumnBackgroundColor( column, color,mini,maxi );
}


/*!
  Sets the background color for a time interval given by \a start and
  \a end.  \a start may be later than \a end.  If there is already a
  background interval with the same \a start and \a end values
  defined, the values (i.e.  const TQColor& color , Scale mini, Scale
  maxi) of this background interval are changed.  Change the times of
  an already defined interval with \a changeBackgroundInterval().
  Delete an already defined interval with \a
  deleteBackgroundInterval().

  It can be defined, whether the color should be shown in all scales or
  only in specific scales.
  If you want to define the color only for the daily view, scecify
  mini and maxi as Day.
  If there is no value for mini/maxi specified, the color for the columns
  is shown in all scales.

  \param start start datetime of the time interval
  \param end end datetime of the time interval
  \param color the background color
  \param mini show the color only in scales greater than this
  \param maxi show the color only in scales lesser than this
  \sa changeBackgroundInterval(), deleteBackgroundInterval(),
  columnBackgroundColor(), setWeekendBackgroundColor(),
  weekendBackgroundColor()
*/
void KDGanttView::setIntervalBackgroundColor( const TQDateTime& start,
                                              const TQDateTime& end,
                                              const TQColor& color ,
                                              Scale mini, Scale maxi )
{
  myTimeHeader->setIntervalBackgroundColor( start, end, color,mini,maxi );
}


/*!
  Changes the times of an already defined background color interval.
  The new values \a startnew and \a endnew should not be datetime
  values of an already defined background color interval.
  If that is the case, nothing is changed and false is returned.

  \param oldstart the start date and time of the interval to change
  \param oldend the end date and time of the interval to change
  \param newstart the new start date and time
  \param newend the new end date and time
  \return true, if there is a backgroundcolor interval with values
  \a start and \a end found  and the new values \a startnew and \a endnew
  are not datetime values of an already defined background color interval.
          Returns false otherwise.
  \sa changeBackgroundInterval(), deleteBackgroundInterval(),
  columnBackgroundColor(), setWeekendBackgroundColor(),
  weekendBackgroundColor()
*/
bool KDGanttView::changeBackgroundInterval( const TQDateTime& oldstart,
                                   const TQDateTime& oldend,
                                   const TQDateTime& newstart,
                                   const TQDateTime& newend )
{
  return myTimeHeader->changeBackgroundInterval( oldstart, oldend,
                                                 newstart, newend );
}

/*!
  Deletes an already defined background color interval.

  \param start start datetime of time interval
  \param end end datetime of time interval
  \return true, if there is a backgroundcolor interval with values
  \a start and \a end found  (and hence deleted).
  \sa changeBackgroundInterval(),  columnBackgroundColor()
*/
bool KDGanttView::deleteBackgroundInterval( const TQDateTime& start,
                                            const TQDateTime& end)
{
  return myTimeHeader->deleteBackgroundInterval( start, end );
}


/*!
  Removes all background color settings set with setColumnBackgroundColor()
  and setIntervalBackgroundColor().
  Does not affect the settings of setWeekendBackgroundColor().

  \sa setColumnBackgroundColor(), setWeekendBackgroundColor(),
  weekendBackgroundColor(), setIntervalBackgroundColor()
*/
void KDGanttView::clearBackgroundColor()
{
  myTimeHeader->clearBackgroundColor();
}


/*!
  Returns the background color for the column closest to \a column.

  \param column the column to query the background color for
  \return the background color of the specified color
  \sa setColumnBackgroundColor(), setWeekendBackgroundColor(),
  weekendBackgroundColor()
*/
TQColor KDGanttView::columnBackgroundColor( const TQDateTime& column ) const
{
    return myTimeHeader->columnBackgroundColor( column ) ;
}


/*!
  Specifies the background color for weekend days. If no individual
  days are visible on the Gantt chart, this method has no visible
  effect.

  \param color the background color to use for weekend days.
  \sa weekendBackgroundColor(), setWeekendDays(), weekendDays()
*/
void KDGanttView::setWeekendBackgroundColor( const TQColor& color )
{
    myTimeHeader->setWeekendBackgroundColor( color );
}


/*!
  Returns the background color for weekend days.

  \return the background color for weekend days
  \sa setWeekendBackgroundColor(), setWeekendDays(), weekendDays()
*/
TQColor KDGanttView::weekendBackgroundColor() const
{
    return myTimeHeader->weekendBackgroundColor();
}


/*!
  Specifies the background color for weekday days. If no individual
  days are visible on the Gantt chart, this method has no visible
  effect. The days are specified as an intervals of integer values
  where 1 means Monday and 7 means Sunday.

  \param color the background color to use for weekend days.
  \param weekday the day of the week (Monday = 1, Sunday = 7)
  \sa weekendBackgroundColor(), setWeekendDays(), weekendDays()
*/
void KDGanttView::setWeekdayBackgroundColor( const TQColor& color, int  weekday )
{
  myTimeHeader->setWeekdayBackgroundColor( color,  weekday );
}


/*!
  Returns the background color for weekday days.

  \param weekday the day of the week (Monday = 1, Sunday = 7)
  \return the background color for weekend days
  \sa setWeekendBackgroundColor(), setWeekendDays(), weekendDays()
*/
TQColor KDGanttView::weekdayBackgroundColor(int weekday) const
{
  return myTimeHeader->weekdayBackgroundColor( weekday);
}



/*!
  Defines which days are considered weekends. The days are specified
  as an interval of integer values where 1 means Monday and 7 means
  Sunday. In order to define a weekend from Sunday to Monday, specify
  (7,1).

  \param start the first day of the weekend
  \param end the last day of the weekend
  \sa weekendDays(), setWeekendBackgroundColor(), weekendBackgroundColor()
*/
void KDGanttView::setWeekendDays( int start, int end )
{
    myTimeHeader->setWeekendDays( start,  end );
}


/*!
  Returns which days are considered weekends.

  \param start in this parameter, the first day of the weekend is returned
  \param end in this parameter, the end day of the weekend is returned
  \sa setWeekendDays(), setWeekendBackgroundColor(), weekendBackgroundColor()
*/
void KDGanttView::weekendDays( int& start, int& end ) const
{
    myTimeHeader->weekendDays( start,  end );
}


/*!
  \fn void KDGanttView::itemLeftClicked( KDGanttViewItem* )

  This signal is emitted when the user clicks on an item with the left
  mouse button.
*/


/*!
  \fn void KDGanttView::itemMidClicked( KDGanttViewItem* )

  This signal is emitted when the user clicks on an item with the middle
  mouse button.
*/


/*!
  \fn void KDGanttView::itemRightClicked( KDGanttViewItem* )

  This signal is emitted when the user clicks on an item with the right
  mouse button.
*/


/*!
  \fn void KDGanttView::itemDoubleClicked( KDGanttViewItem* )

  This signal is emitted when the user double-clicks an item.
*/


/*!
  \fn void KDGanttView::itemConfigured( KDGanttViewItem* )

  This signal is emitted when the user has configured an item
  visually.
*/



/*!
  \fn void KDGanttView::taskLinkLeftClicked( KDGanttViewTaskLink* )

  This signal is emitted when the user clicks on a task link with the
  left mouse button.
*/


/*!
  \fn void KDGanttView::taskLinkMidClicked( KDGanttViewTaskLink* )

  This signal is emitted when the user clicks on a task link with the
  middle mouse button.
*/


/*!
  \fn void KDGanttView::taskLinkRightClicked( KDGanttViewTaskLink* )

  This signal is emitted when the user clicks on a task link with the
  right mouse button.
*/


/*!
  \fn void KDGanttView::taskLinkDoubleClicked( KDGanttViewTaskLink* )

  This signal is emitted when the user double-clicks a task link.
*/


/*!
  \enum KDGanttView::YearFormat

  This enum is used to specify the year format used in the header.
*/


/*!
  \enum KDGanttView::HourFormat

  This enum is used to specify the hour format used in the header.
*/


/*!
  \enum KDGanttView::Scale

  This enum is used to specify the units of the scales in the header.
*/




/*!
  Sets the number of ticks in the major scale.

  \param count the number of ticks in the major scale
  \sa majorScaleCount(), setMinorScaleCount(), minorScaleCount()
*/
void KDGanttView::setMajorScaleCount( int count )
{
    myTimeHeader->setMajorScaleCount(count );
}


/*!
  Returns the number of ticks per unit in the major scale.

  \return the number of ticks in the major scale
  \sa setMajorScaleCount(), setMinorScaleCount(), minorScaleCount()
*/
int KDGanttView::majorScaleCount() const
{
    return myTimeHeader->majorScaleCount();
}


/*!
  Sets the number of ticks in the minor scale.

  \param count the number of ticks in the minor scale
  \sa minorScaleCount, setMajorScaleCount, majorScaleCount()
*/
void KDGanttView::setMinorScaleCount( int count )
{
    myTimeHeader->setMinorScaleCount(count );
}


/*!
  Returns the number of ticks per unit in the minor scale.

  \return the number of ticks in the minor scale
  \sa setMinorScaleCount(), setMajorScaleCount(), majorScaleCount()
*/
int KDGanttView::minorScaleCount() const
{
    return myTimeHeader->minorScaleCount();

}


/*!
  Sets the default color for a particular type of Gantt item that is
  used for the item if no specific start, middle, or end colors are
  set.

  \param type the type of Gantt items for which to query the highlight
  colors
  \param color the default color to use
  \param overwriteExisting if true, existing settings for individual
  items are overwritten
  \sa defaultColor(), setColors(), colors()
*/
void KDGanttView::setDefaultColor( KDGanttViewItem::Type type,
                                   const TQColor& color,
                                   bool overwriteExisting )
{
    if ( overwriteExisting ) {
      TQListViewItemIterator it(myListView);
      for ( ; it.current(); ++it ) {
        if ( ((KDGanttViewItem*)it.current())->type() == type)
          ((KDGanttViewItem*)it.current())->setDefaultColor(color );
      }
    }
    int index = getIndex( type );
    myDefaultColor [index] = color;
}



/*!
  Returns the default color for a particular type of Gantt item that
  is used for the item if no specific start, middle, or end colors are
  set.

  \param type the type of Gantt items for which to query the highlight
  colors
  \return color the default color used
  \sa setDefaultColor(), setColors(), colors()
*/
TQColor KDGanttView::defaultColor( KDGanttViewItem::Type type ) const
{
  int index = getIndex( type );
  return myDefaultColor [index];
}


/*!
  Sets the default highlighting color for a particular type of
  Gantt item that is used for the item if no specific start, middle,
  or end colors are set.

  \param type the type of Gantt items for which to query the highlight
  colors
  \param color the default highlighting color to use
  \param overwriteExisting if true, existing color settings in
  individual items are overwritten
  \sa defaultHighlightColor(), setHighlightColors(), highlightColors()
*/
void KDGanttView::setDefaultHighlightColor( KDGanttViewItem::Type type,
                                            const TQColor& color,
                                            bool overwriteExisting )
{
    if ( overwriteExisting ) {
      TQListViewItemIterator it(myListView);
      for ( ; it.current(); ++it ) {
        if ( ((KDGanttViewItem*)it.current())->type() == type)
          ((KDGanttViewItem*)it.current())->setDefaultHighlightColor(color );
      }
    }
    int index = getIndex( type );
    myDefaultColorHL [index] = color;
}



/*!
  Returns the default highlighting color for a particular type of
  Gantt item that is used for the item if no specific start, middle,
  or end colors are set.

  \param type the type of Gantt items for which to query the highlight
  colors
  \return color the default highlighting color used
  \sa setDefaultHighlightColor(), setHighlightColors(), highlightColors()
*/
TQColor KDGanttView::defaultHighlightColor( KDGanttViewItem::Type type ) const
{
  int index = getIndex( type );
  return myDefaultColorHL [index];
}


/*!
  Returns the first item in the Gantt view.

  \return the first item in the Gantt view, 0 if there are no items
*/
KDGanttViewItem* KDGanttView::firstChild() const
{
    return (KDGanttViewItem*)myListView->firstChild();

}
/*!
  This method turns calendar mode on and off.  In calendar mode, only
  those items can be opened which have subitems which have
  subitems. I.e., if an item contains multiple calendars, it can be
  opened, but not a calendar item itself.  If you want to use this
  GanttView as a calendar view, you have to call
  setDisplaySubitemsAsGroup( true ); to use the root items as calendar
  items.  To create new calendar entries for these root items, create
  a new KDGanttViewTaskItem with this root item as a parent.  If you
  want an item with subitems to behave like a calendar (which is
  possibly empty at startup), please call setIsCalendar( true ); for
  this item.

  \param mode if true, the calendar view mode is turned on
              if false, the calendar view mode is turned off
  \sa setDisplaySubitemsAsGroup(), displaySubitemsAsGroup(), calendarMode()
*/
void KDGanttView::setCalendarMode( bool mode )
{
  myListView->setCalendarMode( mode );
}


/*!
  Returns true, if the Gantt view is in calendar mode. See
  setCalendarMode() for the meaning of calendar mode.

  \return returns true, if the Gantt view is in calendermode
  \sa setCalendarMode()
*/
bool  KDGanttView::calendarMode() const
{
  return  myListView->calendarMode();
}



/*!
  This method specifies whether hidden subitems should be displayed.
  It iterates over all KDGanttViewItems in this Gantt view
  and sets their displaySubitemsAsGroup() property.
  All newly created items will have this setting by default.
  \param show if true, the hidden subitems are displayed in all items of
         this Gantt view.
  \sa KDGanttViewItem::setDisplaySubitemsAsGroup(), KDGanttViewItem::displaySubitemsAsGroup()
*/
void KDGanttView::setDisplaySubitemsAsGroup( bool show )
{
 TQListViewItemIterator it( myListView );
 for ( ; it.current(); ++it ) {
   KDGanttViewItem* currentItem = ( KDGanttViewItem* )it.current();
   currentItem->setDisplaySubitemsAsGroup( show );
 }
 _displaySubitemsAsGroup = show;
}


/*!
  Returns, whether new items are created with the
  displayHiddenSubitems property.
  \return true, if hidden subitems should be displayed on newly created items.
  \sa setDisplaySubitemsAsGroup(),
  KDGanttViewItem::setDisplaySubitemsAsGroup(),
  KDGanttViewItem::displaySubitemsAsGroup()
*/
bool KDGanttView::displaySubitemsAsGroup() const
{
  return _displaySubitemsAsGroup;
}


/*!
  This method specifies whether tasks where the start time and the end
  time are the same are displayed
  as a line over the full height of the Gantt view.
  \param show if true, tasks with starttime == endtime are displayed
  as a line
*/
void KDGanttView::setDisplayEmptyTasksAsLine( bool show )
{
  _displayEmptyTasksAsLine = show;
}


/*!
  Returns, whether tasks where the start time and the end time are the
  same are displayed
  as a line over the full height of the Gantt view.
  \return true, if empty tasks are displayed as line.
*/
bool KDGanttView::displayEmptyTasksAsLine() const
{
  return _displayEmptyTasksAsLine;
}


/*!
  Defines the horizontal background lines of the Gantt chart.
  Call setHorBackgroundLines()
  (equivalent to setHorBackgroundLines( 2, TQBrush( TQColor ( 240,240,240 )) ) )
  to draw a light grey horizontal background line for every second Gantt item.
  Call setHorBackgroundLines(0) in order to not show horizontal
  background lines.
  You may specify the number of lines and the brush of the lines.

  \param count for count >=  2, every count line gets a backgroud
               specified by brush
               for count <  2, no background lines are drawn
  \param brush the brush of the lines
*/
void KDGanttView::setHorBackgroundLines( int count, TQBrush brush )
{
  myTimeTable->setHorBackgroundLines(  count, brush );
}


/*!
  Returns the definition of the horizontal background lines of the
  Gantt chart.

  \param brush the brush of the lines
  \return every nth line gets a background specified by brush
  if 0 is returned, no backgroud lines are drawn

*/
int KDGanttView::horBackgroundLines( TQBrush& brush )
{
  return myTimeTable->horBackgroundLines( brush );
}


/*!
  Returns the last item in the Gantt view

  \return the last item in the Gantt view, 0 if there are no items
*/
KDGanttViewItem* KDGanttView::lastItem() const
{
    return (KDGanttViewItem*)myListView->lastItem ();
}


/*!
  Returns the list of task links in the Gantt view.

  \return the list of task links in the Gantt view
*/
TQPtrList<KDGanttViewTaskLink> KDGanttView::taskLinks() const
{

    return myTimeTable->taskLinks();
}


/*!
  Returns the list of task link groups in the Gantt view.

  \return the list of task link groups in the Gantt view
*/
TQPtrList<KDGanttViewTaskLinkGroup> KDGanttView::taskLinkGroups() const
{
    return myTaskLinkGroupList;
}


/**
   Reads the parameters of the view from an XML document.
   \param doc the XML document to read from
   \return true if the parameters could be read, false if a file
   format error occurred
   \sa saveXML
*/
bool KDGanttView::loadXML( const TQDomDocument& doc )
{
    TQDomElement docRoot = doc.documentElement(); // ChartParams element
    TQDomNode node = docRoot.firstChild();
    while( !node.isNull() ) {
        TQDomElement element = node.toElement();
        if( !element.isNull() ) { // was really an element
            TQString tagName = element.tagName();
            if( tagName == "ShowLegend" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setShowLegend( value );
            } else if( tagName == "ShowLegendButton" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setShowLegendButton( value );
            } else if( tagName == "LegendIsDockWindow" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setLegendIsDockwindow( value );
            } else if( tagName == "ShowListView" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setShowListView( value );
            } else if( tagName == "ShowHeader" ) {
              bool value;
              if( KDGanttXML::readBoolNode( element, value ) )
                setHeaderVisible( value );
            } else if( tagName == "ShowTaskLinks" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setShowTaskLinks( value );
            } else if( tagName == "EditorEnabled" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setEditorEnabled( value );
            } else if( tagName == "DisplayEmptyTasksAsLine" ) {
              bool value;
              if( KDGanttXML::readBoolNode( element, value ) )
                setDisplayEmptyTasksAsLine( value );
            } else if( tagName == "GlobalFont" ) {
                TQFont font;
                if( KDGanttXML::readFontNode( element, font ) )
                    setFont( font );
            } else if( tagName == "HorizonStart" ) {
                TQDateTime value;
                if( KDGanttXML::readDateTimeNode( element, value ) )
                    setHorizonStart( value );
            } else if( tagName == "HorizonEnd" ) {
                TQDateTime value;
                if( KDGanttXML::readDateTimeNode( element, value ) )
                    setHorizonEnd( value );
            } else if( tagName == "Scale" ) {
                TQString value;
                if( KDGanttXML::readStringNode( element, value ) )
                    setScale( stringToScale( value ) );
            } else if( tagName == "MinimumScale" ) {
                TQString value;
                if( KDGanttXML::readStringNode( element, value ) )
                    setMinimumScale( stringToScale( value ) );
            } else if( tagName == "MaximumScale" ) {
                TQString value;
                if( KDGanttXML::readStringNode( element, value ) )
                    setMaximumScale( stringToScale( value ) );
            } else if( tagName == "YearFormat" ) {
                TQString value;
                if( KDGanttXML::readStringNode( element, value ) )
                    setYearFormat( stringToYearFormat( value ) );
            } else if( tagName == "HourFormat" ) {
                TQString value;
                if( KDGanttXML::readStringNode( element, value ) )
                    setHourFormat( stringToHourFormat( value ) );
            } else if( tagName == "ShowMinorTicks" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setShowMinorTicks( value );
            } else if( tagName == "ShowMajorTicks" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setShowMajorTicks( value );
            } else if( tagName == "DragEnabled" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setDragEnabled( value );
            } else if( tagName == "DropEnabled" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setDropEnabled( value );
            } else if( tagName == "CalendarMode" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setCalendarMode( value );
            } else if( tagName == "Editable" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setEditable( value );
            } else if( tagName == "TextColor" ) {
                TQColor value;
                if( KDGanttXML::readColorNode( element, value ) )
                    setTextColor( value );
            } else if( tagName == "MajorScaleCount" ) {
                int value;
                if( KDGanttXML::readIntNode( element, value ) )
                    setMajorScaleCount( value );
            } else if( tagName == "MinorScaleCount" ) {
                int value;
                if( KDGanttXML::readIntNode( element, value ) )
                    setMinorScaleCount( value );
            } else if( tagName == "AutoScaleMinorTickCount" ) {
                int value;
                if( KDGanttXML::readIntNode( element, value ) )
                    setAutoScaleMinorTickCount( value );
            } else if( tagName == "MinimumColumnWidth" ) {
                int value;
                if( KDGanttXML::readIntNode( element, value ) )
                    setMinimumColumnWidth( value );
            } else if( tagName == "GanttMaximumWidth" ) {
                int value;
                if( KDGanttXML::readIntNode( element, value ) )
                    setGanttMaximumWidth( value );
            } else if( tagName == "NoInformationBrush" ) {
              TQBrush value;
              if( KDGanttXML::readBrushNode( element, value ) )
                setNoInformationBrush( value );
            } else if( tagName == "GanttViewBackgroundColor" ) {
                TQColor value;
                if( KDGanttXML::readColorNode( element, value ) )
                    setGvBackgroundColor( value );
            } else if( tagName == "ListViewBackgroundColor" ) {
                TQColor value;
                if( KDGanttXML::readColorNode( element, value ) )
                    setLvBackgroundColor( value );
            } else if( tagName == "TimeHeaderBackgroundColor" ) {
                TQColor value;
                if( KDGanttXML::readColorNode( element, value ) )
                    setTimeHeaderBackgroundColor( value );
            } else if( tagName == "LegendHeaderBackgroundColor" ) {
                TQColor value;
                if( KDGanttXML::readColorNode( element, value ) )
                    setLegendHeaderBackgroundColor( value );
            } else if( tagName == "WeekendBackgroundColor" ) {
                TQColor value;
                if( KDGanttXML::readColorNode( element, value ) )
                    setWeekendBackgroundColor( value );
            } else if( tagName == "WeekdayBackgroundColor" ) {
                TQDomNode node = element.firstChild();
                int day = 0;
                TQColor color;
                while( !node.isNull() ) {
                    TQDomElement element = node.toElement();
                    if( !element.isNull() ) { // was really an elemente
                        TQString tagName = element.tagName();
                        if( tagName == "Day" ) {
                            int value;
                            if( KDGanttXML::readIntNode( element, value ) )
                                day = value;
                        } else if( tagName == "Color" ) {
                            TQColor value;
                            if( KDGanttXML::readColorNode( element, value ) )
                                color = value;
                        } else {
                            qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                            Q_ASSERT( false );
                        }
                    }
                    node = node.nextSibling();
                }

                if( day && color.isValid() )
                    setWeekdayBackgroundColor( color, day );
            } else if( tagName == "WeekendDays" ) {
                TQString startString = element.attribute( "Start" );
                TQString endString = element.attribute( "End" );
                bool startOk = false, endOk = false;
                int start = startString.toInt( &startOk );
                int end = startString.toInt( &endOk );
                if( startOk && endOk )
                    setWeekendDays( start, end );
            } else if( tagName == "ZoomFactor" ) {
                double value;
                if( KDGanttXML::readDoubleNode( element, value ) )
                    setZoomFactor( value, true );
            } else if( tagName == "ShowHeaderPopupMenu" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setShowHeaderPopupMenu( value );
            } else if( tagName == "ShowTimeTablePopupMenu" ) {
                bool value;
                if( KDGanttXML::readBoolNode( element, value ) )
                    setShowTimeTablePopupMenu( value );
            } else if( tagName == "Shapes" ) {
                TQDomNode node = element.firstChild();
                bool undefinedShape = false;
                while( !node.isNull() ) {
                    TQDomElement element = node.toElement();
                    if( !element.isNull() ) { // was really an elemente
                        TQString tagName = element.tagName();
                        if( tagName == "Event" ) {
                            KDGanttViewItem::Shape startShape, middleShape, endShape;
                            startShape = KDGanttViewItem::TriangleDown;
                            middleShape = KDGanttViewItem::TriangleDown;
                            endShape = KDGanttViewItem::TriangleDown;
                            TQDomNode node = element.firstChild();
                            while( !node.isNull() ) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was really an elemente
                                    TQString tagName = element.tagName();
                                    if( tagName == "Start" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            startShape = KDGanttViewItem::stringToShape( value );
                                        if ( value == "Undefined" )
                                          undefinedShape = true;
                                    } else if( tagName == "Middle" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            middleShape = KDGanttViewItem::stringToShape( value );
                                        if ( value == "Undefined" )
                                          undefinedShape = true;
                                    } else if( tagName == "End" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            endShape = KDGanttViewItem::stringToShape( value );
                                        if ( value == "Undefined" )
                                          undefinedShape = true;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }
                                node = node.nextSibling();
                            }
                            if ( ! undefinedShape )
                              setShapes( KDGanttViewItem::Event, startShape,
                                       middleShape, endShape, false );
                            undefinedShape = false;
                        } else if( tagName == "Task" ) {
                            KDGanttViewItem::Shape startShape, middleShape, endShape;
                            startShape = KDGanttViewItem::TriangleDown;
                            middleShape = KDGanttViewItem::TriangleDown;
                            endShape = KDGanttViewItem::TriangleDown;
                            TQDomNode node = element.firstChild();
                            while( !node.isNull()) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was really an elemente
                                    TQString tagName = element.tagName();
                                    if( tagName == "Start" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            startShape = KDGanttViewItem::stringToShape( value );
                                        if ( value == "Undefined" )
                                          undefinedShape = true;
                                    } else if( tagName == "Middle" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            middleShape = KDGanttViewItem::stringToShape( value );
                                        if ( value == "Undefined" )
                                          undefinedShape = true;
                                    } else if( tagName == "End" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            endShape = KDGanttViewItem::stringToShape( value );
                                        if ( value == "Undefined" )
                                          undefinedShape = true;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }
                                node = node.nextSibling();
                            }
                            if ( ! undefinedShape )
                              setShapes( KDGanttViewItem::Task, startShape, middleShape, endShape, false );
                            undefinedShape = false;
                        } else if( tagName == "Summary" ) {
                            KDGanttViewItem::Shape startShape, middleShape, endShape;
                            startShape = KDGanttViewItem::TriangleDown;
                            middleShape = KDGanttViewItem::TriangleDown;
                            endShape = KDGanttViewItem::TriangleDown;
                            TQDomNode node = element.firstChild();
                            while( !node.isNull() ) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was really an elemente
                                    TQString tagName = element.tagName();
                                    if( tagName == "Start" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            startShape = KDGanttViewItem::stringToShape( value );
                                        if ( value == "Undefined" )
                                          undefinedShape = true;
                                    } else if( tagName == "Middle" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            middleShape = KDGanttViewItem::stringToShape( value );
                                        if ( value == "Undefined" )
                                          undefinedShape = true;
                                    } else if( tagName == "End" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            endShape = KDGanttViewItem::stringToShape( value );
                                        if ( value == "Undefined" )
                                          undefinedShape = true;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }
                                node = node.nextSibling();
                            }
                            if ( ! undefinedShape )
                              setShapes( KDGanttViewItem::Summary, startShape,
                                       middleShape, endShape, false );
                            undefinedShape = false;
                        } else {
                            qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                            Q_ASSERT( false );
                        }
                    }
                    node = node.nextSibling();
                }
            } else if( tagName == "Colors" ) {
                TQDomNode node = element.firstChild();
                while( !node.isNull()) {
                    TQDomElement element = node.toElement();
                    if( !element.isNull() ) { // was really an elemente
                        TQString tagName = element.tagName();
                        if( tagName == "Event" ) {
                            TQColor startColor, middleColor, endColor;
                            TQDomNode node = element.firstChild();
                            while( !node.isNull() ) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was really an elemente
                                    TQString tagName = element.tagName();
                                    if( tagName == "Start" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            startColor = value;
                                    } else if( tagName == "Middle" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            middleColor = value;
                                    } else if( tagName == "End" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            endColor = value;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }
                                node = node.nextSibling();
                            }
                            setColors( KDGanttViewItem::Event, startColor,
                                       middleColor, endColor, false );
                        } else if( tagName == "Task" ) {
                            TQColor startColor, middleColor, endColor;
                            TQDomNode node = element.firstChild();
                            while( !node.isNull() ) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was really an elemente
                                    TQString tagName = element.tagName();
                                    if( tagName == "Start" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            startColor = value;
                                    } else if( tagName == "Middle" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            middleColor = value;
                                    } else if( tagName == "End" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            endColor = value;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }
                                node = node.nextSibling();
                            }
                            setColors( KDGanttViewItem::Task, startColor,
                                       middleColor, endColor, false );
                        } else if( tagName == "Summary" ) {
                            TQColor startColor, middleColor, endColor;
                            TQDomNode node = element.firstChild();
                            while( !node.isNull() ) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was really an elemente
                                    TQString tagName = element.tagName();
                                    if( tagName == "Start" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            startColor = value;
                                    } else if( tagName == "Middle" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            middleColor = value;
                                    } else if( tagName == "End" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            endColor = value;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }
                                node = node.nextSibling();
                            }
                            setColors( KDGanttViewItem::Summary, startColor,
                                       middleColor, endColor , false);
                        } else {
                            qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                            Q_ASSERT( false );
                        }
                    }
                    node = node.nextSibling();
                }
            } else if( tagName == "DefaultColors" ) {
                TQDomNode node = element.firstChild();
                while( !node.isNull() ) {
                    TQDomElement element = node.toElement();
                    if( !element.isNull() ) { // was really an element
                        TQString tagName = element.tagName();
                        if( tagName == "Event" ) {
                            TQColor value;
                            if( KDGanttXML::readColorNode( element, value ) )
                                setDefaultColor( KDGanttViewItem::Event,
                                                 value, false );
                        } else if( tagName == "Task" ) {
                            TQColor value;
                            if( KDGanttXML::readColorNode( element, value ) )
                                setDefaultColor( KDGanttViewItem::Task,
                                                 value, false );
                        } else if( tagName == "Summary" ) {
                            TQColor value;
                            if( KDGanttXML::readColorNode( element, value ) )
                                setDefaultColor( KDGanttViewItem::Summary,
                                                 value , false);
                        } else {
                            qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                            Q_ASSERT( false );
                        }
                    }

                    node = node.nextSibling();
                }
            } else if( tagName == "HighlightColors" ) {
                TQDomNode node = element.firstChild();
                while( !node.isNull() ) {
                    TQDomElement element = node.toElement();
                    if( !element.isNull() ) { // was really an elemente
                        TQString tagName = element.tagName();
                        if( tagName == "Event" ) {
                            TQColor startColor, middleColor, endColor;
                            TQDomNode node = element.firstChild();
                            while( !node.isNull() ) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was really an elemente
                                    TQString tagName = element.tagName();
                                    if( tagName == "Start" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            startColor = value;
                                    } else if( tagName == "Middle" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            middleColor = value;
                                    } else if( tagName == "End" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            endColor = value;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }
                                node = node.nextSibling();
                            }
                            setHighlightColors( KDGanttViewItem::Event,
                                                startColor,
                                                middleColor, endColor, false );
                        } else if( tagName == "Task" ) {
                            TQColor startColor, middleColor, endColor;
                            TQDomNode node = element.firstChild();
                            while( !node.isNull() ) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was really an elemente
                                    TQString tagName = element.tagName();
                                    if( tagName == "Start" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            startColor = value;
                                    } else if( tagName == "Middle" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            middleColor = value;
                                    } else if( tagName == "End" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            endColor = value;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }
                                node = node.nextSibling();
                            }
                            setHighlightColors( KDGanttViewItem::Task,
                                                startColor,
                                                middleColor, endColor , false);
                        } else if( tagName == "Summary" ) {
                            TQColor startColor, middleColor, endColor;
                            TQDomNode node = element.firstChild();
                            while( !node.isNull() ) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was really an elemente
                                    TQString tagName = element.tagName();
                                    if( tagName == "Start" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            startColor = value;
                                    } else if( tagName == "Middle" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            middleColor = value;
                                    } else if( tagName == "End" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            endColor = value;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }
                                node = node.nextSibling();
                            }
                            setHighlightColors( KDGanttViewItem::Summary,
                                                startColor,
                                                middleColor, endColor, false );
                        } else {
                            qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                            Q_ASSERT( false );
                        }
                    }
                    node = node.nextSibling();
                }
            } else if( tagName == "DefaultHighlightColors" ) {
                TQDomNode node = element.firstChild();
                while( !node.isNull() ) {
                    TQDomElement element = node.toElement();
                    if( !element.isNull() ) { // was really an element
                        TQString tagName = element.tagName();
                        if( tagName == "Event" ) {
                            TQColor value;
                            if( KDGanttXML::readColorNode( element, value ) )
                                setDefaultHighlightColor( KDGanttViewItem::Event,
                                                 value , false);
                        } else if( tagName == "Task" ) {
                            TQColor value;
                            if( KDGanttXML::readColorNode( element, value ) )
                                setDefaultHighlightColor( KDGanttViewItem::Task,
                                                 value, false );
                        } else if( tagName == "Summary" ) {
                            TQColor value;
                            if( KDGanttXML::readColorNode( element, value ) )
                                setDefaultHighlightColor( KDGanttViewItem::Summary,
                                                 value, false );
                        } else {
                            qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                            Q_ASSERT( false );
                        }
                    }

                    node = node.nextSibling();
                }
            } 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 {
                            qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                            Q_ASSERT( false );
                        }
                    }

                    node = node.nextSibling();
                }
            } else if( tagName == "TaskLinks" ) {
                TQDomNode node = element.firstChild();
                while( !node.isNull() ) {
                    TQDomElement element = node.toElement();
                    if( !element.isNull() ) { // was really an element
                        TQString tagName = element.tagName();
                        if( tagName == "TaskLink" )
                            KDGanttViewTaskLink::createFromDomElement( element );
                        else {
                            qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                            Q_ASSERT( false );
                        }
                    }

                    node = node.nextSibling();
                }
            } else if( tagName == "TaskLinkGroups" ) {
                TQDomNode node = element.firstChild();
                while( !node.isNull() ) {
                    TQDomElement element = node.toElement();
                    if( !element.isNull() ) { // was really an element
                        TQString tagName = element.tagName();
                        if( tagName == "TaskLink" )
                            KDGanttViewTaskLinkGroup::createFromDomElement( element );
                    } else {
                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                        Q_ASSERT( false );
                    }

                    node = node.nextSibling();
                }
            } else if( tagName == "ColumnBackgroundColors" ) {
                TQDomNode node = element.firstChild();
                while( !node.isNull() ) {
                    TQDomElement element = node.toElement();
                    if( !element.isNull() ) { // was really an element
                        TQString tagName = element.tagName();
                        if( tagName == "ColumnBackgroundColor" ) {
                            TQDomNode node = element.firstChild();
                            TQDateTime dateTime;
                            TQColor color;
                            while( !node.isNull() ) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was
                                                          // really an
                                                          // element
                                    TQString tagName = element.tagName();
                                    if( tagName == "DateTime" ) {
                                        TQDateTime value;
                                        if( KDGanttXML::readDateTimeNode( element, value ) )
                                            dateTime = value;
                                    } else if( tagName == "Color" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            color = value;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }

                                node = node.nextSibling();
                            }
                            setColumnBackgroundColor( dateTime, color );
                        } else {
                            qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                            Q_ASSERT( false );
                        }
                    }
                    node = node.nextSibling();
                }
            } else if( tagName == "LegendItems" ) {
                clearLegend();
                TQDomNode node = element.firstChild();
                while( !node.isNull() ) {
                    TQDomElement element = node.toElement();
                    if( !element.isNull() ) { // was really an element
                        TQString tagName = element.tagName();
                        if( tagName == "LegendItem" ) {
                            KDGanttViewItem::Shape tempLegendShape;
                            tempLegendShape = KDGanttViewItem::TriangleDown;
                            TQColor tempLegendColor;
                            TQString tempLegendString;
                            bool ok = true;
                            TQDomNode node = element.firstChild();
                            while( !node.isNull() ) {
                                TQDomElement element = node.toElement();
                                if( !element.isNull() ) { // was really an element
                                    TQString tagName = element.tagName();
                                    if( tagName == "Shape" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            tempLegendShape = KDGanttViewItem::stringToShape( value );
                                        else
                                            ok = false;
                                    } else if( tagName == "Color" ) {
                                        TQColor value;
                                        if( KDGanttXML::readColorNode( element, value ) )
                                            tempLegendColor = value;
                                        else
                                            ok = false;
                                    } else if( tagName == "Text" ) {
                                        TQString value;
                                        if( KDGanttXML::readStringNode( element, value ) )
                                            tempLegendString = value;
                                        else
                                            ok = false;
                                    } else {
                                        qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                                        Q_ASSERT( false );
                                    }
                                }
                                node = node.nextSibling();
                            }
                            if( ok ) {
                                addLegendItem( tempLegendShape,
                                               tempLegendColor,
                                               tempLegendString );
                                qDebug( "Adding legend item %s", tempLegendString.latin1() );
                            }
                        } else {
                            qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                            Q_ASSERT( false );
                        }
                    }
                    node = node.nextSibling();
                }
            } else {
                qDebug( "Unrecognized tag name: %s", tagName.latin1() );
                Q_ASSERT( false );
            }
        }

        node = node.nextSibling();
    } // while
        return true; /* FIXME: Do real error-reporting. The ASSERT's should be "return false" stmnts */
} // method


/**
   Saves the parameters of the view parameters to an XML document.

   \param withPI pass true to store processing instructions, false to
   leave them out
   \return the XML document that represents the parameters
   \sa loadXML
*/
TQDomDocument KDGanttView::saveXML( bool withPI ) const
{
    // Create an inital DOM document
    TQString docstart = "<GanttView/>";

    TQDomDocument doc( "GanttView" );
    doc.setContent( docstart );
    if( withPI ) {
      TQDomProcessingInstruction pin = doc.createProcessingInstruction( "kdgantt", "version=\"1.0\" encoding=\"UTF-8\""  ) ;
       doc.appendChild ( pin );
    }

    TQDomElement docRoot = doc.documentElement();
    docRoot.setAttribute( "xmlns", "http://www.klaralvdalens-datakonsult.se/kdgantt" );
    docRoot.setAttribute( "xmlns:xsi", "http://www.w3.org/2000/10/XMLSchema-instance" );
    docRoot.setAttribute( "xsi:schemaLocation", "http://www.klaralvdalens-datakonsult.se/kdgantt" );

    // the ShowLegend element
    KDGanttXML::createBoolNode( doc, docRoot, "ShowLegend", showLegend() );

    // the ShowLegendButton element
    KDGanttXML::createBoolNode( doc, docRoot, "ShowLegendButton",
                           showLegendButton() );

    // the LegendIsDockWindow element
    KDGanttXML::createBoolNode( doc, docRoot, "LegendIsDockWindow",
                           legendIsDockwindow() );

    // the ShowListView element
    KDGanttXML::createBoolNode( doc, docRoot, "ShowListView", showListView() );

    // the ShowHeader element
    KDGanttXML::createBoolNode( doc, docRoot, "ShowHeader", headerVisible() );

    // the ShowTaskLinks element
    KDGanttXML::createBoolNode( doc, docRoot, "ShowTaskLinks", showTaskLinks() );

    // the EditorEnabled element
    KDGanttXML::createBoolNode( doc, docRoot, "EditorEnabled", editorEnabled() );

    // the global font element
    KDGanttXML::createFontNode( doc, docRoot, "GlobalFont", font() );

    // the DisplayEmptyTasksAsLine element
    KDGanttXML::createBoolNode( doc, docRoot, "DisplayEmptyTasksAsLine",
                           displayEmptyTasksAsLine() );

    // the HorizonStart element
    KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonStart", horizonStart() );

    // the HorizonEnd element
    KDGanttXML::createDateTimeNode( doc, docRoot, "HorizonEnd", horizonEnd() );

    // the Scale, MinimumScale, MaximumScale elements
    KDGanttXML::createStringNode( doc, docRoot, "Scale", scaleToString( scale() ) );
    KDGanttXML::createStringNode( doc, docRoot, "MinimumScale",
                             scaleToString( minimumScale() ) );
    KDGanttXML::createStringNode( doc, docRoot, "MaximumScale",
                             scaleToString( maximumScale() ) );

    // the YearFormat element
    KDGanttXML::createStringNode( doc, docRoot, "YearFormat",
                             yearFormatToString( yearFormat() ) );

    // the HourFormat element
    KDGanttXML::createStringNode( doc, docRoot, "HourFormat",
                             hourFormatToString( hourFormat() ) );

    // the ShowMinorTicks element
    KDGanttXML::createBoolNode( doc, docRoot, "ShowMinorTicks", showMinorTicks() );

    // the ShowMajorTicks element
    KDGanttXML::createBoolNode( doc, docRoot, "ShowMajorTicks", showMajorTicks() );

    // the Editable element
    KDGanttXML::createBoolNode( doc, docRoot, "Editable", editable() );

    // the TextColor element
    KDGanttXML::createColorNode( doc, docRoot, "TextColor", textColor() );

    // the MajorScaleCount element
    KDGanttXML::createIntNode( doc, docRoot, "MajorScaleCount", majorScaleCount() );

    // the MinorScaleCount element
    KDGanttXML::createIntNode( doc, docRoot, "MinorScaleCount", minorScaleCount() );

    // the AutoScaleMinorTickCount element
    KDGanttXML::createIntNode( doc, docRoot, "AutoScaleMinorTickCount",
                          autoScaleMinorTickCount() );

    // the MinimumColumnWidth element
    KDGanttXML::createIntNode( doc, docRoot, "MinimumColumnWidth",
                          minimumColumnWidth() );

    // the GanttMaximumWidth element
    KDGanttXML::createIntNode( doc, docRoot, "GanttMaximumWidth",
                          ganttMaximumWidth() );

    // the NoInformationBrush element
    KDGanttXML::createBrushNode( doc, docRoot, "NoInformationBrush",
                            noInformationBrush() );

    // the GanttViewBackgroundColor element
    KDGanttXML::createColorNode( doc, docRoot, "GanttViewBackgroundColor",
                            gvBackgroundColor() );

    // the ListViewBackgroundColor element
    KDGanttXML::createColorNode( doc, docRoot, "ListViewBackgroundColor",
                            lvBackgroundColor() );

    // the TimeHeaderBackgroundColor element
    KDGanttXML::createColorNode( doc, docRoot, "TimeHeaderBackgroundColor",
                            timeHeaderBackgroundColor() );

    // the LegendHeaderBackgroundColor element
    KDGanttXML::createColorNode( doc, docRoot, "LegendHeaderBackgroundColor",
                            legendHeaderBackgroundColor() );

    // the WeekendBackgroundColor element
    KDGanttXML::createColorNode( doc, docRoot, "WeekendBackgroundColor",
                            weekendBackgroundColor() );

    // the WeekdayBackgroundColor elements
    for( int weekday = 1; weekday <= 7; weekday++ ) {
        TQColor color = weekdayBackgroundColor( weekday );
        if( color.isValid() ) {
            TQDomElement weekendBackgroundColorElement = doc.createElement( "WeekdayBackgroundColor" );
            docRoot.appendChild( weekendBackgroundColorElement );
            KDGanttXML::createIntNode( doc, weekendBackgroundColorElement,
                                  "Day", weekday );
            KDGanttXML::createColorNode( doc, weekendBackgroundColorElement,
                                    "Color", color );
        }
    }

    // the WeekendDays element
    TQDomElement weekendDaysElement = doc.createElement( "WeekendDays" );
    docRoot.appendChild( weekendDaysElement );
    int weekendStart, weekendEnd;
    weekendDays( weekendStart, weekendEnd );
    weekendDaysElement.setAttribute( "Start", weekendStart );
    weekendDaysElement.setAttribute( "End", weekendStart );

    // the ZoomFactor element
    KDGanttXML::createDoubleNode( doc, docRoot, "ZoomFactor",
                             zoomFactor() );

    // the ShowHeaderPopupMenu element
    KDGanttXML::createBoolNode( doc, docRoot, "ShowHeaderPopupMenu",
                           showHeaderPopupMenu() );

    // the ShowTimeTablePopupMenu element
    KDGanttXML::createBoolNode( doc, docRoot, "ShowTimeTablePopupMenu",
                           showTimeTablePopupMenu() );

    // the Shapes element
    TQDomElement tqshapesElement = doc.createElement( "Shapes" );
    docRoot.appendChild( tqshapesElement );
    TQDomElement tqshapesEventElement = doc.createElement( "Event" );
    tqshapesElement.appendChild( tqshapesEventElement );
    KDGanttViewItem::Shape start, middle, end;
    if( tqshapes( KDGanttViewItem::Event, start, middle, end ) ) {
        KDGanttXML::createStringNode( doc, tqshapesEventElement, "Start",
                                 KDGanttViewItem::tqshapeToString( start ) );
        KDGanttXML::createStringNode( doc, tqshapesEventElement, "Middle",
                                 KDGanttViewItem::tqshapeToString( middle ) );
        KDGanttXML::createStringNode( doc, tqshapesEventElement, "End",
                                 KDGanttViewItem::tqshapeToString( end ) );
    } else {
        KDGanttXML::createStringNode( doc, tqshapesEventElement, "Start",
                                 "Undefined" );
        KDGanttXML::createStringNode( doc, tqshapesEventElement, "Middle",
                                 "Undefined" );
        KDGanttXML::createStringNode( doc, tqshapesEventElement, "End",
                                 "Undefined" );
    }
    TQDomElement tqshapesTaskElement = doc.createElement( "Task" );
    tqshapesElement.appendChild( tqshapesTaskElement );
    if( tqshapes( KDGanttViewItem::Task, start, middle, end ) ) {
        KDGanttXML::createStringNode( doc, tqshapesTaskElement, "Start",
                                 KDGanttViewItem::tqshapeToString( start ) );
        KDGanttXML::createStringNode( doc, tqshapesTaskElement, "Middle",
                                 KDGanttViewItem::tqshapeToString( middle ) );
        KDGanttXML::createStringNode( doc, tqshapesTaskElement, "End",
                                 KDGanttViewItem::tqshapeToString( end ) );
    } else {
        KDGanttXML::createStringNode( doc, tqshapesTaskElement, "Start",
                                 "Undefined" );
        KDGanttXML::createStringNode( doc, tqshapesTaskElement, "Middle",
                                 "Undefined" );
        KDGanttXML::createStringNode( doc, tqshapesTaskElement, "End",
                                 "Undefined" );
    }
    TQDomElement tqshapesSummaryElement = doc.createElement( "Summary" );
    tqshapesElement.appendChild( tqshapesSummaryElement );
    if( tqshapes( KDGanttViewItem::Event, start, middle, end ) ) {
        KDGanttXML::createStringNode( doc, tqshapesSummaryElement, "Start",
                                 KDGanttViewItem::tqshapeToString( start ) );
        KDGanttXML::createStringNode( doc, tqshapesSummaryElement, "Middle",
                                 KDGanttViewItem::tqshapeToString( middle ) );
        KDGanttXML::createStringNode( doc, tqshapesSummaryElement, "End",
                                 KDGanttViewItem::tqshapeToString( end ) );
    } else {
        KDGanttXML::createStringNode( doc, tqshapesSummaryElement, "Start",
                                 "Undefined" );
        KDGanttXML::createStringNode( doc, tqshapesSummaryElement, "Middle",
                                 "Undefined" );
        KDGanttXML::createStringNode( doc, tqshapesSummaryElement, "End",
                                 "Undefined" );
    }

    // the Colors element
    TQDomElement colorsElement = doc.createElement( "Colors" );
    docRoot.appendChild( colorsElement );
    TQDomElement colorsEventElement = doc.createElement( "Event" );
    colorsElement.appendChild( colorsEventElement );
    TQColor startColor, middleColor, endColor;
    colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
    KDGanttXML::createColorNode( doc, colorsEventElement, "Start", startColor );
    KDGanttXML::createColorNode( doc, colorsEventElement, "Middle", middleColor );
    KDGanttXML::createColorNode( doc, colorsEventElement, "End", endColor );
    TQDomElement colorsTaskElement = doc.createElement( "Task" );
    colorsElement.appendChild( colorsTaskElement );
    colors( KDGanttViewItem::Task, startColor, middleColor, endColor );
    KDGanttXML::createColorNode( doc, colorsTaskElement, "Start", startColor );
    KDGanttXML::createColorNode( doc, colorsTaskElement, "Middle", middleColor );
    KDGanttXML::createColorNode( doc, colorsTaskElement, "End", endColor );
    TQDomElement colorsSummaryElement = doc.createElement( "Summary" );
    colorsElement.appendChild( colorsSummaryElement );
    colors( KDGanttViewItem::Event, startColor, middleColor, endColor );
    KDGanttXML::createColorNode( doc, colorsSummaryElement, "Start", startColor );
    KDGanttXML::createColorNode( doc, colorsSummaryElement, "Middle", middleColor );
    KDGanttXML::createColorNode( doc, colorsSummaryElement, "End", endColor );

    // the DefaultColor element
    TQDomElement defaultColorsElement = doc.createElement( "DefaultColors" );
    docRoot.appendChild( defaultColorsElement );
    KDGanttXML::createColorNode( doc, defaultColorsElement, "Event",
                            defaultColor( KDGanttViewItem::Event ) );
    KDGanttXML::createColorNode( doc, defaultColorsElement, "Task",
                            defaultColor( KDGanttViewItem::Task ) );
    KDGanttXML::createColorNode( doc, defaultColorsElement, "Summary",
                            defaultColor( KDGanttViewItem::Summary ) );


    // the HighlightColors element
    TQDomElement highlightColorsElement = doc.createElement( "HighlightColors" );
    docRoot.appendChild( highlightColorsElement );
    TQDomElement highlightColorsEventElement = doc.createElement( "Event" );
    highlightColorsElement.appendChild( highlightColorsEventElement );
    highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
    KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Start", startColor );
    KDGanttXML::createColorNode( doc, highlightColorsEventElement, "Middle", middleColor );
    KDGanttXML::createColorNode( doc, highlightColorsEventElement, "End", endColor );
    TQDomElement highlightColorsTaskElement = doc.createElement( "Task" );
    highlightColorsElement.appendChild( highlightColorsTaskElement );
    highlightColors( KDGanttViewItem::Task, startColor, middleColor, endColor );
    KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Start", startColor );
    KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "Middle", middleColor );
    KDGanttXML::createColorNode( doc, highlightColorsTaskElement, "End", endColor );
    TQDomElement highlightColorsSummaryElement = doc.createElement( "Summary" );
    highlightColorsElement.appendChild( highlightColorsSummaryElement );
    highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor );
    KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
    KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
    KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );


    /*
    if( highlightColors( KDGanttViewItem::Event, startColor, middleColor, endColor ) ) {
        KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", startColor );
        KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", middleColor );
        KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", endColor );
    } else {
        KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Start", TQColor() );
        KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "Middle", TQColor() );
        KDGanttXML::createColorNode( doc, highlightColorsSummaryElement, "End", TQColor() );
    }
    */
    // the DefaultHighlightColor element
    TQDomElement defaultHighlightColorsElement = doc.createElement( "DefaultHighlightColors" );
    docRoot.appendChild( defaultHighlightColorsElement );
    KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Event",
                            defaultHighlightColor( KDGanttViewItem::Event ) );
    KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Task",
                            defaultHighlightColor( KDGanttViewItem::Task ) );
    KDGanttXML::createColorNode( doc, defaultHighlightColorsElement, "Summary",
                            defaultHighlightColor( KDGanttViewItem::Summary ) );


    // the Items element
    TQDomElement itemsElement = doc.createElement( "Items" );
    docRoot.appendChild( itemsElement );
    KDGanttViewItem* currentItem = firstChild();
    while( currentItem ) {
        currentItem->createNode( doc, itemsElement );
        currentItem = currentItem->nextSibling();
    }

    // the TaskLinks element
    TQDomElement taskLinksElement = doc.createElement( "TaskLinks" );
    docRoot.appendChild( taskLinksElement );
    TQPtrList<KDGanttViewTaskLink> taskLinkList = taskLinks();
    KDGanttViewTaskLink* currentTL = 0;
    for( currentTL = taskLinkList.first(); currentTL;
         currentTL = taskLinkList.next() )
        currentTL->createNode( doc, taskLinksElement );

    // the TaskLinkGroups element
    TQDomElement taskLinkGroupsElement = doc.createElement( "TaskLinkGroups" );
    docRoot.appendChild( taskLinkGroupsElement );
    TQPtrList<KDGanttViewTaskLinkGroup> taskLinkGroupList = taskLinkGroups();
    KDGanttViewTaskLinkGroup* currentTLG = 0;
    for( currentTLG = taskLinkGroupList.first(); currentTLG;
         currentTLG = taskLinkGroupList.next() )
        currentTLG->createNode( doc, taskLinkGroupsElement );

    // the ColumnBackgroundColors element
    TQDomElement columnBackgroundColorsElement =
        doc.createElement( "ColumnBackgroundColors" );
    docRoot.appendChild( columnBackgroundColorsElement );
    KDTimeHeaderWidget::ColumnColorList ccList =
        myTimeHeader->columnBackgroundColorList();
    for( KDTimeHeaderWidget::ColumnColorList::iterator it = ccList.begin();
         it != ccList.end(); ++it ) {
        TQDomElement columnBackgroundColorElement =
            doc.createElement( "ColumnBackgroundColor" );
        columnBackgroundColorsElement.appendChild( columnBackgroundColorElement );
        KDGanttXML::createDateTimeNode( doc, columnBackgroundColorElement,
                                   "DateTime", (*it).datetime );
        KDGanttXML::createColorNode( doc, columnBackgroundColorElement,
                                "Color", (*it).color );
    }

    // the LegendItems element
    TQDomElement legendItemsElement =
        doc.createElement( "LegendItems" );
    docRoot.appendChild( legendItemsElement );
    legendItem* current;
    TQPtrListIterator<legendItem> lit( *myLegendItems );
    while( ( current = lit.current() ) ) {
        ++lit;
        TQDomElement legendItemElement = doc.createElement( "LegendItem" );
        legendItemsElement.appendChild( legendItemElement );
        KDGanttXML::createStringNode( doc, legendItemElement, "Shape",
                                 KDGanttViewItem::tqshapeToString( current->tqshape ) );
        KDGanttXML::createColorNode( doc, legendItemElement, "Color",
                                current->color );
        KDGanttXML::createStringNode( doc, legendItemElement, "Text",
                                 current->text );
    }

    // the DragEnabled element
    KDGanttXML::createBoolNode( doc, docRoot, "DragEnabled", isDragEnabled() );

    // the DropEnabled element
    KDGanttXML::createBoolNode( doc, docRoot, "DropEnabled", isDropEnabled() );

    // the CalendarMode element
    KDGanttXML::createBoolNode( doc, docRoot, "CalendarMode", calendarMode() );

    return doc;
}



TQString KDGanttView::scaleToString( Scale scale )
{
    switch( scale ) {
    case Minute:
        return "Minute";
    case Hour:
        return "Hour";
    case Day:
        return "Day";
    case Week:
        return "Week";
    case Month:
        return "Month";
    case Auto:
        return "Auto";
    }
    return "";
}


KDGanttView::Scale KDGanttView::stringToScale( const TQString& string )
{
    if( string == "Minute" )
        return Minute;
    else if( string == "Hour" )
        return Hour;
    else if( string == "Day" )
        return Day;
    else if( string == "Week" )
        return Week;
    else if( string == "Month" )
        return Month;
    else if( string == "Auto" )
        return Auto;

    return Auto;
}


TQString KDGanttView::yearFormatToString( YearFormat format )
{
    switch( format ) {
    case FourDigit:
        return "FourDigit";
    case TwoDigit:
        return "TwoDigit";
    case TwoDigitApostrophe:
        return "TwoDigitApostrophe";
    case NoDate:
        return "NoDate";
    }
    return "";
}


KDGanttView::YearFormat KDGanttView::stringToYearFormat( const TQString& string )
{
    if( string == "FourDigit" )
        return FourDigit;
    else if( string == "TwoDigit" )
        return TwoDigit;
    else if( string == "TwoDigitApostrophe" )
        return TwoDigitApostrophe;
    else if( string == "NoDate" )
        return NoDate;
    else
        return FourDigit;
}


TQString KDGanttView::hourFormatToString( HourFormat format )
{
    switch( format ) {
    case Hour_12:
        return "Hour_12";
    case Hour_24:
        return "Hour_24";
    case Hour_24_FourDigit:
        return "Hour_24_FourDigit";
    }
    return "";
}


KDGanttView::HourFormat KDGanttView::stringToHourFormat( const TQString& string )
{
    if( string == "Hour_12" )
        return Hour_12;
    else if( string == "Hour_24" )
        return Hour_24;
    else
        return Hour_24;
}


void KDGanttView::addTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
{

  if (myTaskLinkGroupList.isEmpty()) {
    myTaskLinkGroupList.append(group);
    return;
  }
    if (myTaskLinkGroupList.find(group) == -1)
        myTaskLinkGroupList.append(group);
}


void KDGanttView::removeTaskLinkGroup(KDGanttViewTaskLinkGroup* group)
{
    myTaskLinkGroupList.remove(group);
}


/*!
  This slot is called when a new item has been added to the Gantt
  view. It will show the item attribute dialog in case the item is
  editable. \a item is a pointer to the item that has been created.
*/
void KDGanttView::editItem( KDGanttViewItem*  item)
{
  if ( ! item )
    return;
  if ( editorEnabled() ) {
    if ( item->editable() ) {
      myItemAttributeDialog->reset( item );
      myItemAttributeDialog->show();
    }
  }
}


/*!
  This method returns the pixmap used for a certain tqshape, in the
  selected color and size.

  \param tqshape the tqshape to generate
  \param tqshapeColor the foreground color of the tqshape
  \param backgroundColor the background color of the tqshape
  \param itemSize the size of the tqshape
  \return the generated tqshape pixmap
*/
TQPixmap KDGanttView::getPixmap( KDGanttViewItem::Shape tqshape,
                                const TQColor& tqshapeColor,
                                const TQColor& backgroundColor, int itemSize)
{
  // 10 is a good value as size
  int size = itemSize+2;
  int hei = ( itemSize/3 ) / 2;
  TQPixmap p = TQPixmap( size+4, size+4 );
  p.fill( backgroundColor );
  TQPainter paint (&p);
  TQBrush b = TQBrush ( TQt::SolidPattern );
  b.setColor( tqshapeColor );
  paint.setBrush( b );
  TQPen pen( TQt::black, 1 ) ;
  paint.setPen( pen );
  switch (tqshape) {
  case KDGanttViewItem::TriangleDown:{
    TQPointArray arr = TQPointArray(3);
    arr.setPoint(0,-size/2,-hei);
    arr.setPoint(1,size/2,-hei);
    arr.setPoint(2,0,((size/2)-hei));
    arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
    paint.drawPolygon( arr );
    break;
  }
  case KDGanttViewItem::TriangleUp :{
    TQPointArray arr = TQPointArray(3);
    arr.setPoint(0,-size/2,hei);
    arr.setPoint(1,size/2,hei);
    arr.setPoint(2,0,(-size/2)+hei);
    arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
    paint.drawPolygon( arr );
    break;
  }
  case  KDGanttViewItem::Diamond :{
    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);
    arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
    paint.drawPolygon( arr );
    break;
  }
  case KDGanttViewItem::Square :{
    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);
    arr.translate( ( size/2 ) +2 , ( size/2 ) +2);
    paint.drawPolygon( arr );
    break;
  }
  case  KDGanttViewItem::Circle  :{
    paint.drawEllipse( 2, 2, size, size);
    break;
  }
  }
  paint.end();
  return p;
}

int KDGanttView::getIndex( KDGanttViewItem::Type type) const
{
    int index = -1;
    switch (type) {
    case (KDGanttViewItem::Event):
        index = 0;
        break;
    case (KDGanttViewItem::Task):
        index = 1;
        break;
    case (KDGanttViewItem::Summary):
        index = 2;
        break;
    }
    return index;
}


void KDGanttView::initDefaults()
{
  int i;
  // We have 3 item types. Set all undefined to true.
    for (i = 0;i<3;++i) {
        undefinedShape[i] = true;
        undefinedColor[i] = true;
        undefinedColorHL[i] = true;
    }
    // setting the default colors
    myDefaultColor [ getIndex( KDGanttViewItem::Event ) ] =  TQt::blue; //event
    myDefaultColorHL [ getIndex( KDGanttViewItem::Event ) ] =  TQt::red;
    myDefaultColor [ getIndex( KDGanttViewItem::Task ) ] =  TQt::green;//task
    myDefaultColorHL [ getIndex( KDGanttViewItem::Task ) ] =  TQt::red;
    myDefaultColor [ getIndex( KDGanttViewItem::Summary ) ] =  TQt::cyan;//summary
    myDefaultColorHL [ getIndex( KDGanttViewItem::Summary ) ] =  TQt::red;

    // setting the default tqshape types
    // currently, we take for each item for all three tqshapes (start, middle, end) the same default tqshape
    for (i = 0;i<3;++i) {
      myDefaultShape [3*getIndex( KDGanttViewItem::Event )+ i] =  KDGanttViewItem::Diamond; //event
      myDefaultShape [3*getIndex( KDGanttViewItem::Task ) +i] =  KDGanttViewItem::Square; //task
      myDefaultShape [3*getIndex( KDGanttViewItem::Summary ) +i] =  KDGanttViewItem::TriangleDown; //summary

    }
}



/*!
  Calls to this method are passed through to the underlying \a TQListView.
*/
int KDGanttView::addColumn( const TQString& label, int width )
{
    return myListView->addColumn( label, width );
}


/*!
  Calls to this method are passed through to the underlying \a TQListView.
*/

int KDGanttView::addColumn( const TQIconSet& iconset, const TQString& label,
                            int width )
{
    return myListView->addColumn( iconset, label, width );
}


/*!
  Calls to this method are passed through to the underlying \a TQListView.
*/
void KDGanttView::removeColumn( int index )
{
    myListView->removeColumn( index );
}


/*!
  Calls to this method are passed through to the underlying \a TQListView.
*/
KDGanttViewItem* KDGanttView::selectedItem() const
{
    return static_cast<KDGanttViewItem*>( myListView->selectedItem() );
}


/*!
  Calls to this method are passed through to the underlying \a TQListView.
*/
void KDGanttView::setSelected( KDGanttViewItem* item, bool selected )
{
    myListView->setSelected( item, selected );
}


/*!
  Returns the pointer to the Gantt item with the name \a name.
  If no item is found, the return value is 0.
  If there is more than one item with the same name in the Gantt view,
  the first item found will be returned. This may not necessarily be
  the first item in the listview.

  \param name the name of the Gantt item
  \return the pointer to the item with name \a name. O, if there is no item
  in the Gantt view with this name.

*/
KDGanttViewItem* KDGanttView::getItemByName( const TQString& name ) const
{
    KDGanttViewItem* temp =  firstChild(),* ret;
    while (temp != 0) {
      if ( (ret = temp->getChildByName( name ) ) )
        return ret;
      temp = temp->nextSibling();
    }
    return 0;
}


/*!
  Returns the pointer to the Gantt item at the position \a pos in the
  list view.
  The position \a pos is a global position.
  If no item is found, 0 is returned.

  \param pos the (global) position of the Gantt item
  \return the pointer to the item with position \a pos. O, if there is
  no item in the list view at this position.

*/
KDGanttViewItem* KDGanttView::getItemByListViewPos( const TQPoint& pos ) const
{
    return static_cast<KDGanttViewItem*>( myListView->itemAt(myListView->mapFromGlobal(pos) ));
}


/*!
  Returns the pointer to the Gantt item at the position \a pos in the
  Gantt view.
  The position \a pos is a global position.
  If no items are found, or the item is disabled, 0 is returned.
  If there is more than one item with the same position in the Gantt view,
  the first item found will be returned. This is not necessarily the
  first item in the listview.

  \param pos the (global) position of the Gantt item
  \return the pointer to the item with position \a pos. O, if there is no item
  in the Gantt view at this position.

*/
KDGanttViewItem* KDGanttView::getItemByGanttViewPos( const TQPoint& pos ) const
{
  KDGanttViewItem* item;
  TQPoint local = myCanvasView->mapFromGlobal(pos);

    TQCanvasItemList il = myTimeTable->collisions( myCanvasView->viewportToContents( local ));
    TQCanvasItemList::Iterator it;
    for ( it = il.begin(); it != il.end(); ++it ) {
      if ( myCanvasView->getType(*it) == Type_is_KDGanttViewItem) {
        item = myCanvasView->getItem(*it);
        if ( item->enabled() )
          return item;
      }
    }
    return 0;
}


/*!
  Returns the pointer to the Gantt item at the position \a pos in the
  list view part of the Gantt view.
  The position \a pos is a global position if parameter \a global is true.
  If the vertical part (y coordinate) of \a pos
  (mapped to local coordinates) is less than 0 or
  larger than the height of the listview, 0 is returned.
  The horizontal part (x coordinate) of \a pos is ignored.
  \param pos the position of the Gantt item
  \param global if true, pos is assumed to be global
  \return the pointer to the item with position \a pos. O, if there is no item
  in the Gantt view at this position.

*/
KDGanttViewItem* KDGanttView::getItemAt( const TQPoint& pos, bool global ) const
{
  /* buggy code - commented out
  TQPoint myPos;
  if (  global )
    myPos = myListView->contentsToViewport( myListView->mapFromGlobal(pos) );
  else
     myPos = myListView->contentsToViewport( pos );
  return (KDGanttViewItem*) myListView->itemAt( myPos );
  */

  KDGanttViewItem* item;
  KDGanttViewItem* retItem = 0;
  int y;
  if ( global )
    y = myCanvasView->mapFromGlobal(pos).y();
  else
    y = pos.y();
  item = firstChild();
  while ( item != 0 ) {
    int yc = item->itemPos();
    if ( yc <= y && y < yc + item->height()) {
      retItem = item;
      break;
    }
    item = item->itemBelow();
  }
  return retItem;

}


void KDGanttView::addTickRight()
{
  if ( _enableAdding && myCanvasView->horizontalScrollBar()->value() ==  myCanvasView->horizontalScrollBar()->maxValue()) {
    //myCanvasView->horizontalScrollBar()->blockSignals( true );
    myTimeHeader->addTickRight();
    //myCanvasView->horizontalScrollBar()->blockSignals( false );
    myCanvasView->updateHorScrollBar();
    setTimelineToEnd();
  }
}


void KDGanttView::addTickLeft()
{
  if ( _enableAdding && myCanvasView->horizontalScrollBar()->value() == 0 ) {
    myCanvasView->horizontalScrollBar()->blockSignals( true );
    myTimeHeader->addTickLeft();
    myCanvasView->horizontalScrollBar()->blockSignals( false );
    setTimelineToStart();
  }
}


void KDGanttView::enableAdding( int val )
{
  _enableAdding = ( val == 0 || val == myCanvasView->horizontalScrollBar()->maxValue());
}


/*!
  Returns the number of items in the Gantt view.

  \return the number of items in the Gantt view.
*/
int KDGanttView::childCount() const
{
    return myListView->childCount();
}


/*!
  Removes all items from the Gantt view.
*/
void KDGanttView::clear()
{
  bool block = myTimeTable->blockUpdating();
  myTimeTable->setBlockUpdating( true );
  myListView->clear();
  myTimeTable->setBlockUpdating( false );
  myTimeTable->updateMyContent();
  myTimeTable->setBlockUpdating( block );
}


/*!
  Passes on the signal from the list view.
*/
void KDGanttView::slot_lvDropped(TQDropEvent* e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse  )
{
  emit dropped( e, droppedItem, itemBelowMouse);
}

/*!
  Implements a pass-through to the list view.
*/
TQDragObject * KDGanttView::dragObject ()
{
  return myListView->dragObject ();
}


/*!
  Implements a pass-through to the list view.
*/
void KDGanttView::startDrag ()
{
  //myListView->pt_startDrag ();
}


/*!
  This method is overridden for internal purposes.
*/
void KDGanttView::setPaletteBackgroundColor( const TQColor& col)
{
  TQWidget::setPaletteBackgroundColor( col );
  timeHeaderSpacerWidget->setPaletteBackgroundColor( col );
}


/*!
  Sets the background color of the Gantt view.

  \param c the background color of the Gantt view.
  \sa gvBackgroundColor()
*/
void KDGanttView::setGvBackgroundColor ( const TQColor & c )
{
  myTimeTable->setBackgroundColor( c );
}


/*!
  Sets the background color of the time header.

  \param c the background color of the time header.
  \sa timeHeaderBackgroundColor()
*/
void KDGanttView::setTimeHeaderBackgroundColor ( const TQColor & c )
{
  myTimeHeader->setPaletteBackgroundColor( c );
  //rightWidget->setPaletteBackgroundColor( c );
  timeHeaderSpacerWidget->setPaletteBackgroundColor( c );
}


/*!
  Sets the background color of the legend header.

  \param c the background color of the legend header
  \sa legendHeaderBackgroundColor()
*/
void KDGanttView::setLegendHeaderBackgroundColor ( const TQColor & c )
{
  myLegend->setPaletteBackgroundColor( c );
  leftWidget->setPaletteBackgroundColor( c );
}


/*!
  Sets the background color of the list view.

  \param c the background color of the list view
  \sa lvBackgroundColor()
*/
void KDGanttView::setLvBackgroundColor ( const TQColor & c )
{
 myListView->viewport()->setPaletteBackgroundColor( c );
}


/*!
  Returns the background color of the list view.

  \return the background color of the list view
  \sa setLvBackgroundColor()
*/
TQColor KDGanttView::lvBackgroundColor ( )const
{
 return myListView->viewport()->paletteBackgroundColor( );
}


/*!
  Returns the background color of the Gantt view.

  \return the background color of the Gantt view
  \sa setGvBackgroundColor()
*/
TQColor KDGanttView::gvBackgroundColor () const
{
 return myTimeTable->backgroundColor( );
}


/*!
  Returns the background color of the time header.

  \return the background color of the time header
  \sa setTimeHeaderBackgroundColor()
*/
TQColor KDGanttView::timeHeaderBackgroundColor () const
{
 return myTimeHeader->paletteBackgroundColor( );
}


/*!
  Returns the background color of the legend header.

  \return the background color of the legend header
  \sa setLegendHeaderBackgroundColor()
*/
TQColor KDGanttView::legendHeaderBackgroundColor () const
{
 return myLegend->paletteBackgroundColor( );
}


/*!
  Adds a widget to the spacer widget above the list view part and
  below the ShowLegendButton.  To assign all the space above the
  Listview to the spacer widget, hide the ShowLegendButton by calling
  setShowLegendButton( false ).  The spacer widget is a TQHBox.  You
  may add as many widgets as you want. They are ordered horizontally
  from left to right.  To remove a widget from the spacer widget, call
  widget->reparent(newParent,...) or delete the widget.  Since the spacer
  is a TQHBox, the tqlayout of the added widgets is managed by this
  TQHBox.

  \param w A pointer to the widget to be added.
  \sa setShowLegendButton( )
*/
void KDGanttView::addUserdefinedLegendHeaderWidget( TQWidget * w )
{
  if ( w ) {
    w->reparent ( spacerLeft, 0, TQPoint(0,0) );
  }
}


/*!
  Specifies whether drag operations are allowed in the Gantt
  view. Recurses over all items contained in the Gantt view and
  enables or disabled them for dragging.

  \param b true if dragging is enabled, false if dragging is disabled
  \sa isDragEnabled(), setDropEnabled(), isDropEnabled(), setDragDropEnabled()
*/
void KDGanttView::setDragEnabled( bool b )
{
  fDragEnabled = b;
 TQListViewItemIterator it( myListView );
 for ( ; it.current(); ++it ) {
   (( KDGanttViewItem* )it.current())->setDragEnabled(b);
 }

}


/*!
  Specifies whether drop operations are allowed in the Gantt
  view. Recurses over all items contained in the Gantt view and
  enables or disabled them for dropping.

  \param b true if dragging is enabled, false if dragging is disabled
  \sa setDropEnabled(), setDragEnabled(), isDragEnabled(), setDragDropEnabled()
*/
void KDGanttView::setDropEnabled( bool b )
{
  fDropEnabled = b;

  //myListView->setAcceptDrops( b );
 TQListViewItemIterator it( myListView );
 for ( ; it.current(); ++it ) {
   (( KDGanttViewItem* )it.current())->setDropEnabled(b);
 }
}


/*!
  Combines setDragEnabled() and setDropEnabled() in one convenient
  method.

  \param b true if dragging and dropping are enabled, false if
  dragging and dropping are disabled
  \sa setDragEnabled(), setDropEnabled()
*/
void KDGanttView::setDragDropEnabled( bool b )
{
  setDropEnabled( b );
  setDragEnabled( b );
}


/*!
  Returns whether dragging is enabled for this Gantt view.

  \return true if dragging is enabled
  \sa setDragEnabled(), setDragDropEnabled()
*/
bool KDGanttView::isDragEnabled() const
{
  return fDragEnabled;
}


/*!
  Returns whether dropping is enabled for this Gantt view.

  \return true if dropping is enabled
  \sa setDropEnabled(), setDragDropEnabled()
*/
bool KDGanttView::isDropEnabled() const
{
 return fDropEnabled;
}


/*!
  \deprecated Use isDragEnabled() instead
*/
bool KDGanttView::dragEnabled() const
{
  return isDragEnabled();
}


/*!
  \deprecated Use isDropEnabled() instead
*/
bool KDGanttView::dropEnabled() const
{
 return isDropEnabled();
}


/*!
  This virtual method makes it possible to specify user-defined drop
  handling.  The method is called directly before the internal drop
  handling is executed.  Return false to execute internal drop
  handling.  Return true to not execute internal drop handling.  In
  order to specify user-defined drop handling, subclass
  KDGanttView and reimplement this method.

  \param e The TQDropEvent
  Note: e->source() is a pointer to the KDGanttView from which the drag started.
  I.e., if e->source() == this, this drag is an internal drag.
  \param droppedItem 0, if this is a drag operation from another
  KDGanttView instance.
  If this drag is an internal drag (i.e., within the KDGanttView),
  this parameter points to the dropped item.
  \param itemBelowMouse a pointer to the item below the dragged
  item (i.e., below the mouse).
  If you accept, the dragged item may be inserted
  in the KDGanttView as a child of this item.
  The value is 0 if there is no item below the dragged item,
  and the dragged item will be inserted as a root item.

  \return false, when the internal drop handling should be executed
          true, when the internal drop handling should not be executed
  \sa lvDropEvent(), lvStartDrag()
*/
bool  KDGanttView::lvDropEvent ( TQDropEvent* e,
                                 KDGanttViewItem* droppedItem,
                                 KDGanttViewItem* itemBelowMouse )
{
    Q_UNUSED( e );
    Q_UNUSED( droppedItem );
    Q_UNUSED( itemBelowMouse );

  // Example code for user defined behaviour:
  // we want to accept the usual drags and the drags of files, which may be
  // a saved Gantt file.
  // Please uncomment the following lines for this behaviour
  // You have to uncomment lines in lvDragMoveEvent() and llvDragEnterEvent() as well

  // ************** begin example ************
  /*
  if ( TQUriDrag::canDecode( e ) ) {
    TQStrList lst;
    TQUriDrag::decode( e, lst );
    // we try the first file of icon-url-list
    TQString str = lst.at ( 0 );
    // remove file: at beginning of string
    str = str.right( str.length() - 5  );
    TQFileInfo info;
    info.setFile( str ) ;
    if ( info.isFile() ) {
      if (!TQMessageBox::information( this, "KDGantt Drag&Drop test",
                                     "Try to insert file: "+ str + " ?",
                                     "&Okay", "&Cancel",0,1  ) ) {
        TQFile file( str );
        // store current updating status
        bool uen = myTimeTable->blockUpdating();
        // block updating while insertion of items
        myTimeTable->setBlockUpdating();
        loadProject( &file ) ;
        // restore updating status and execute an update via setUpdateEnabled( true );
        if ( !uen )
          setUpdateEnabled( true );
      }
    }
    return true;
  }
  */
  // *********** end example ****************
  return false;
}


/*!
  This virtual method specifies whether a drag enter event may be
  accepted or not.
  To accept a drag enter event, call e->accept( true );
  To not accept a drag enter evente, call e->accept( false );
  This method does nothing but accepting the drag enter event, in case
  decoding is possible.
  In order to define accepting drops for particular items yourself,
  subclass KDGanttView and reimplement this method.

  \param e           The TQDragMoveEvent
                     Note: e->source() is a pointer to the KDGanttView, the drag started from.
                     I.e., if e->source() == this, this drag is an internal drag.

  \sa lvDropEvent(), lvStartDrag(), lvDragMoveEvent()
*/
void  KDGanttView::lvDragEnterEvent ( TQDragEnterEvent * e)
{
  // the standard behaviour:
  // accept drag enter events, if KDGanttViewItemDrag can decode the event
  // e->accept(KDGanttViewItemDrag::canDecode(e) );

  if ( KDGanttViewItemDrag::canDecode(e) ) {
    e->accept( true);
    return;
  }

  // example code for user defined behaviour:
  // we want to accecpt the usual drags and the drags of files, which may be
  // a saved Gantt file
  // Please uncomment the following lines for this behaviour
  // You have to uncomment lines in lvDragMoveEvent() and lvDropEvent () as well

  //  if ( TQUriDrag::canDecode( e ) ) {
  // e->accept(true);
  //  return;
  // }

  e->accept( false );
}


/*!
  This virtual method specifies whether a drop event may be accepted or not.
  To accept a drop event, call e->accept( true );
  To not accept a drop event, call e->accept( false );
  This method does nothing but allowing to execute the internal
  drag move event handling.

  In order to specify user-defined drop acceptance for particular
  items, subclass KDGanttView and reimplement this method.

  \param e           The TQDragMoveEvent
                     Note: e->source() is a pointer to the KDGanttView, the drag started from.
                     I.e. if e->source() == this, this drag is an internal drag.
         draggedItem 0, if this is a drag operation from another KDGanttView instance.
         If this drag is an internal drag (i.e., within the KDGanttView),
         this parameter points to the dragged item.
         itemBelowMouse a pointer to the item below the dragged item
         (i.e., below the mouse).
         If you accept the drop, the dragged item will be inserted
         in the KDGanttView as a child of this item.
         The value is 0 if there is no item below the dragged item,
         and the dragged item will be inserted as a root item.
  \return false, when the internal drag move event handling should be executed
          true, when the internal drag move event handling should not
          be executed; usually you should return true,
          if you have called  e->accept( true ) before.
  \sa lvDropEvent(), lvStartDrag()
*/
bool  KDGanttView::lvDragMoveEvent ( TQDragMoveEvent* /*e*/,
                                     KDGanttViewItem* /* draggedItem*/,
                                     KDGanttViewItem* /*itemBelowMouse*/)
{

  // Example code 1:
  // To generally block items to be inserted as root items, subclass KDGanttView
  // and reimplement this method with to following code uncommented:

  // if ( !itemBelowMouse ) {
  //  e->accept( false );
  //  return true;
  //}
  //return false;

  // Example code 2:
  // To allow the drags of files, which may be
  // a saved Gantt file, subclass KDGanttView
  // and reimplement this method with to following code uncommented:

  // if ( TQUriDrag::canDecode( e ) ) {
  //   e->accept(true);
  //   return true;
  //  }


 // normal behaviour - the internal drag move event handling should be executed
  return false;
}


/*!
  This virtual method creates a TQDragObject and starts a drag for a
  KDGanttViewItem.
  In order to prevent drags of particular items, subclass from
  KDGanttView and reimplement this method.

  \param item the KDGanttViewItem, which should be dragged
  \sa lvDropEvent(), lvDragMoveEvent()
*/
void  KDGanttView::lvStartDrag (KDGanttViewItem* item)
{
  TQDragObject* d = new KDGanttViewItemDrag(item, this, "itemdrag" );
  // call d->drag() to start the dragging
  // d->drag() returns true, if a move was requested as a drag
  // if a copy (by pressing the <Ctrl>-key) was performed, d->drag() returns false
  // In order to avoid starting drags for particular items, subclass KDGanttView
  // an reimplement this method.
  // insert here some code like
  // if ( item->parent() )
  // return;
  // This particular code will make it impossible to drag other items but root items.
  if ( d->drag()  ) {
      delete item;
  }
}


/*!
  Sets the width of the list view. Space will be taken from or given
  to the Gantt view.

  \param w the width of the list view
  \sa listViewWidth()
*/
void  KDGanttView::setListViewWidth( int w )
{
  int sw = mySplitter->width();
  TQValueList<int> list;
  list.append(w);
  list.append(sw-w);
  mySplitter->setSizes( list );
}


/*!
  Returns the width of the list view.

  \return the width of the list view
  \sa setListViewWidth()
*/
int  KDGanttView::listViewWidth( )
{
  return leftWidget->width();
}


/*!
  Sets the scrollbar mode of the listview. The default is always off.
  Possible values are always on, always off and auto.
  It only makes sense to set this to always off
  if setGvVScrollBarMode() is set to always on.

  \param m the scrollbar mode.
  \sa setGvVScrollBarMode( )
*/
void  KDGanttView::setLvVScrollBarMode( TQScrollView::ScrollBarMode m )
{
  myListView->setVScrollBarMode ( m );
}


/*!
  Sets the scrollbar mode of the time table. The default is always on.
  Possible values are always on and always off.
  It only makes sense to set this to always off
  if setLvVScrollBarMode() is set to always on or auto.

  \param m The scrollbar mode.
  \sa setLvVScrollBarMode( )
*/
void  KDGanttView::setGvVScrollBarMode( TQScrollView::ScrollBarMode m )
{
  if ( m == TQScrollView::Auto )
    qDebug("KDGanttView::setListViewVScrollBarMode: TQScrollView::Auto not supported. Nothing changed. ");
  else
    {
      myCanvasView->setVScrollBarMode ( m );
      if ( m == TQScrollView::AlwaysOn )
        timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
      else
        timeHeaderSpacerWidget->setFixedWidth( 0 );
    }
}


void  KDGanttView::notifyEditdialog( KDGanttViewItem * item)
{
  if (myItemAttributeDialog->getItem() == item ) {
    myItemAttributeDialog->reset( 0 );
  }
}

/*!
  \fn void KDGanttView::setLinkItemsEnabled( bool on );

  This enables/disables the linking ui of KDGanttViewItems in KDGanttView.
  A signal linkItems() is emitted when two items shall be linked and can
  be used to create the actual link.
*/
void KDGanttView::setLinkItemsEnabled(bool on)
{
    myCanvasView->linkItemsEnabled = on;
    myCanvasView->autoScrollEnabled = true;    
}

/*!
  \fn void KDGanttView::isLinkItemsEnabled();

  Returns if the linking functionallity is enabled or disabled.
*/
bool KDGanttView::isLinkItemsEnabled() const 
{
    return myCanvasView->linkItemsEnabled;
}

/*!
  \fn void KDGanttView::timeIntervalSelected( const TQDateTime& start,  const TQDateTime&  end);

  This signal is emitted when the user selects a time
  interval with the mouse on the time header connect this signal to
  the slot void zoomToSelection( const TQDateTime& start, const
  TQDateTime& end) to obtain automatic zooming.
*/


/*!
  \fn void KDGanttView::timeIntervallSelected( const TQDateTime& start,  const TQDateTime&  end);

  \deprecated This signal is deprecated, do not use it in new code;
  use timeIntervalSelected() instead. timeIntervallSelected() will be
  removed in future versions.
*/


/*!
    \fn void KDGanttView::rescaling( Scale )

    This signal is emitted if another scale is choosen than the
    specified one: i.e. if the horizon has a very wide range from
    start to end and as scale is choosen minute it may be that the
    size of the Gantt widget would become more than 32000 pixels. In
    this case the scale is automatically changed to Hour and
    rescaling( Hour ) is emitted.  If the widget size would be still
    more than 32000 pixels, the scale is automatically changed to day
    and rescaling( Day ) is emitted.  In the new scale, the
    minortickcount is increased such that the horizon will fit in the
    maximum size of 32000 pixels.
*/


/*!
  \fn void KDGanttView::gvCurrentChanged( KDGanttViewItem* item )

  This signal is emitted whenever the user clicks on the Gantt view
  \a item parameter is 0, if no item was clicked
*/


/*!
  \fn void KDGanttView::gvItemLeftClicked( KDGanttViewItem* )

  This signal is emitted whenever the user clicks into the Gantt view
  with the left mouse button.
*/


/*!
  \fn void KDGanttView::gvItemMidClicked( KDGanttViewItem* )

  This signal is emitted whenever the user clicks into the Gantt view
  with the middle mouse button.
*/

/*!
  \fn void KDGanttView::gvItemRightClicked( KDGanttViewItem* )

  This signal is emitted whenever the user clicks into the Gantt view
  with the right mouse button.
*/

/*!
  \fn void KDGanttView::gvMouseButtonClicked ( int button, KDGanttViewItem* item, const TQPoint & pos)

  This signal is emitted when the user clicks into the Gantt view with
  any mouse button. Notice that \a pos is the absolute mouse position.
*/

/*!
  \fn void KDGanttView::gvItemDoubleClicked( KDGanttViewItem* )

  This signal is emitted whenever the user double-clicks into the Gantt view.
*/

/*!
  \fn void KDGanttView::gvContextMenuRequested ( KDGanttViewItem * item, const TQPoint & pos )

  This signal is emitted when the user requests a context menu in the
  Gantt view. Notice that \a pos is the absolute mouse position.
*/


/*!
  \fn void KDGanttView::linkItems ( KDGanttViewItem* from, KDGanttViewItem* to, int linkType )

  This signal is emitted when the user wants to link two items in the Gantt view.
*/


/*!
  \fn void KDGanttView::lvCurrentChanged( KDGanttViewItem* item )

  This signal is emitted whenever the user clicks on the list view
  \a item parameter is 0, if no item was clicked
*/


/*!
  \fn void KDGanttView::lvItemLeftClicked( KDGanttViewItem* )

  This signal is emitted whenever the user clicks into the list view
  with the left mouse button.
*/


/*!
  \fn void KDGanttView::lvItemMidClicked( KDGanttViewItem* )

  This signal is emitted whenever the user clicks into the list view
  with the middle mouse button.
*/

/*!
  \fn void KDGanttView::lvItemRightClicked( KDGanttViewItem* )

  This signal is emitted whenever the user clicks into the list view
  with the right mouse button.
*/

/*!
  \fn void KDGanttView::lvMouseButtonPressed ( int button,
  KDGanttViewItem* item, const TQPoint & pos, int col)

  This signal is emitted when the user presses any mouse button in the
  list view. Notice that \a pos is the absolute mouse position.
*/

/*!
  \fn void KDGanttView::lvMouseButtonClicked ( int button,
  KDGanttViewItem* item, const TQPoint & pos, int col)

  This signal is emitted when the user clicks into the
  list view with any mouse button . Notice that \a pos is the absolute
  mouse position.
*/

/*!
  \fn void KDGanttView::lvItemDoubleClicked( KDGanttViewItem* )

  This signal is emitted whenever the user double-clicks into the list view.
*/

/*!
  \fn void KDGanttView::lvItemRenamed( KDGanttViewItem*, int col,
  const TQString& text )

  This signal is emitted whenever the user changes the name of an item
  in the list view using in-place editing. \a text contains the new
  text in the list view.
*/

/*!
  \fn void KDGanttView::lvContextMenuRequested( KDGanttViewItem *
  item, const TQPoint & pos, int col )

  This signal is emitted when the user requests a context menu in the
  list view. Notice that \a pos is the absolute mouse position.
*/

/*!
  \fn void KDGanttView::lvSelectionChanged( KDGanttViewItem* )

  This signal is emitted whenever the user changes the selection in
  the list view.
*/


/*!
  \fn void KDGanttView::dropped ( TQDropEvent * e, KDGanttViewItem* droppedItem, KDGanttViewItem* itemBelowMouse)

  This signal is emitted whenever a Gantt item is dropped onto the
  Gantt view. \a droppedItem is 0, if this is a drag operation from
  another KDGanttView instance. If this drag is an internal drag
  (i.e. within the KDGanttView), this parameter points to the dropped item.
  \a itemBelowMouse is a pointer to the item below the dragged
  item (i.e., below the mouse). The dragged item may be inserted
  in the KDGanttView as a child of this item.
  If The value is 0, if there is no item below the dragged item,
  and the dragged item will be inserted as a root item.

  In order to get user-defined behavior for drop events, reimplement
  KDGanttView::lvDropEvent()
*/


/*!
  \enum KDGanttView::RepaintMode

  Please see setRepaintMode() for a description of the values of this
  enumeration.
*/