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
|
/****************************************************************************
**
** Implementation of TQObject class
**
****************************************************************************/
#include "tqtglobaldefines.h"
#ifdef USE_QT4
#include "tqobject.h"
#include "tqwidget.h"
#include "tqvariant.h"
#include "tqapplication.h"
#include "tqobject.h"
#include "tqobjectlist.h"
#include "tqsignalslotimp.h"
#include "tqregexp.h"
#include "tqmetaobject.h"
#include <private/tqucom_p.h>
#include "tqucomextra_p.h"
#include "tqptrvector.h"
#include "tqlayout.h"
#include <Qt/qabstracteventdispatcher.h>
#ifdef TQT_THREAD_SUPPORT
#include <tqmutex.h>
#include <private/tqmutexpool_p.h>
#endif
#include <ctype.h>
// Event functions, implemented in qapplication_xxx.cpp
// int qStartTimer( int interval, TQObject *obj );
// bool tqKillTimer( int id );
// bool tqKillTimer( TQObject *obj );
#ifndef TQT_NO_USERDATA
class TQObjectPrivate : public TQPtrVector<TQObjectUserData>
{
public:
TQObjectPrivate( uint s ) : TQPtrVector<TQObjectUserData>(s){ setAutoDelete( TRUE ); }
};
#else
class TQObjectPrivate {
}
#endif
class TQSenderObjectList : public TQObjectList, public TQShared
{
public:
TQSenderObjectList() : currentSender( 0 ) { }
TQObject *currentSender;
};
/*!
\class TQt tqnamespace.h
\brief The TQt class is a namespace for miscellaneous identifiers
that need to be global-like.
\ingroup misc
Normally, you can ignore this class. TQObject and a few other
classes inherit it, so all the identifiers in the TQt namespace are
normally usable without qualification.
However, you may occasionally need to say \c TQt::black instead of
just \c black, particularly in static utility functions (such as
many class factories).
*/
TQObject::TQObject( TQT_BASE_OBJECT_NAME *tqparent, const char *name ) : TQT_BASE_OBJECT_NAME ( tqparent ) {
setObjectName(QString::fromAscii(name));
TQT_TQOBJECT_REQUIRED_INITIALIZATION(tqparent)
}
const char * TQObject::name(const char *defaultName) const {
TQString s = objectName();
return s.isEmpty()?defaultName:s.latin1_helper();
}
void TQObject::insertChild( TQObject *object ) {
TQChildEvent *e = new TQChildEvent( (QEvent::Type)TQEvent::ChildInserted, object );
QApplication::postEvent( this, e );
object->setParent(this);
}
void TQObject::removeChild( TQObject *object ) {
object->setParent(0);
}
void TQObject::setName(const char *aName) {
setObjectName(aName);
}
TQVariant TQObject::property( const char *name ) const {
return TQT_TQVARIANT_OBJECT(TQT_BASE_OBJECT_NAME::property(name));
}
// Qt4 handler interface
bool TQObject::eventFilter( QObject *q, QEvent *e ) {
return eventFilter(static_cast<TQObject*>(q), static_cast<TQEvent*>(e));
}
bool TQObject::event( QEvent *e ) {
return event(static_cast<TQEvent*>(e));
}
bool TQObject::checkConnectArgs(const char *signal, const TQT_BASE_OBJECT_NAME*, const char *member) {
return QMetaObject::checkConnectArgs(signal, member);
}
void TQObject::timerEvent(QTimerEvent *e) {
timerEvent(static_cast<TQTimerEvent*>(e));
}
void TQObject::childEvent(QChildEvent *e) {
TQT_TQOBJECT_CHILDEVENT_CONDITIONAL childEvent(static_cast<TQChildEvent*>(e));
}
void TQObject::customEvent(QEvent *e) {
customEvent(static_cast<TQCustomEvent*>(e));
}
// [FIXME]
// Verify that this is truly equivalent to its Qt3 counterpart!
void TQObject::activate_signal( int signal ) {
QMetaMethod method = metaObject()->method(signal);
method.invoke(this, Qt::QueuedConnection);
}
void TQObject::tqt_handle_qt_destroyed(QObject* obj) {
emit destroyed(TQT_TQOBJECT(obj));
}
bool TQObject::tqsignalsBlocked() const {
return signalsBlocked();
}
/*!
\enum Orientation
This type is used to signify an object's orientation.
\value Horizontal
\value Vertical
Orientation is used with TQScrollBar for example.
*/
// See http://doc.trolltech.com/4.0/porting4.html#qobject
// [FIXME] Yet ANOTHER feature missing in Qt4...kinda gets old doesn't it?
// Just think of having to "fix" it 50 times in the Trinity source code (without TQt), each and every time the Qt API changes!
const TQObjectList *objectTrees() {
printf("[WARNING] static const TQObjectList *objectTrees() unimplemented\n\r");
return 0;
}
const TQObjectList TQObject::objectTreesListObject() {
printf("[WARNING] const TQObjectList *objectTreesListObject() unimplemented\n\r");
return TQObjectList();
}
TQObject *TQObject::tqparent() const {
return static_cast<TQObject*>(parent());
}
TQObjectList TQObject::childrenListObject() {
QObjectList qlr;
TQObjectList tqt_tqobject_list;
qlr = this->children();
tqt_tqobject_list.clear();
for (int i = 0; i < qlr.size(); ++i) {
tqt_tqobject_list.append(static_cast<TQObject*>(qlr.at(i)));
}
return tqt_tqobject_list;
}
const TQObjectList TQObject::childrenListObject() const {
QObjectList qlr;
TQObjectList tqt_tqobject_list;
qlr = this->children();
tqt_tqobject_list.clear();
for (int i = 0; i < qlr.size(); ++i) {
tqt_tqobject_list.append(static_cast<TQObject*>(qlr.at(i)));
}
return tqt_tqobject_list;
}
const char *TQObject::tqname() const {
if (dynamic_cast<const TQObject*>(static_cast<const QObject*>(this))) {
static_object_name = TQT_OBJECT_NAME_HANDLER(objectName());
return static_object_name.ascii();
}
else {
if (dynamic_cast<const TQWidget*>(static_cast<const QWidget*>(static_cast<const QObject*>(this)))) {
return TQT_TQWIDGET_CONST(this)->tqname();
}
else if (dynamic_cast<const TQLayout*>(static_cast<const QLayout*>(static_cast<const QObject*>(this)))) {
return dynamic_cast<const TQLayout*>(static_cast<const QLayout*>(static_cast<const QObject*>(this)))->tqname();
}
else if (dynamic_cast<const TQApplication*>(static_cast<const QApplication*>(static_cast<const QObject*>(this)))) {
return dynamic_cast<const TQApplication*>(static_cast<const QApplication*>(static_cast<const QObject*>(this)))->tqname();
}
printf("[WARNING] Attempted to call TQObject::tqname() on an object without a constructed TQObject object or base object. Returning \"\"\n\r");
return "";
}
}
const char *TQObject::name() const {
if (dynamic_cast<const TQObject*>(static_cast<const QObject*>(this))) {
static_object_name = TQT_OBJECT_NAME_HANDLER(objectName());
return static_object_name.ascii();
}
else {
if (dynamic_cast<const TQWidget*>(static_cast<const QWidget*>(static_cast<const QObject*>(this)))) {
return TQT_TQWIDGET_CONST(this)->name();
}
else if (dynamic_cast<const TQLayout*>(static_cast<const QLayout*>(static_cast<const QObject*>(this)))) {
return dynamic_cast<const TQLayout*>(static_cast<const QLayout*>(static_cast<const QObject*>(this)))->name();
}
else if (dynamic_cast<const TQApplication*>(static_cast<const QApplication*>(static_cast<const QObject*>(this)))) {
return dynamic_cast<const TQApplication*>(static_cast<const QApplication*>(static_cast<const QObject*>(this)))->name();
}
printf("[WARNING] Attempted to call TQObject::name() on an object without a constructed TQObject object or base object. Returning \"\"\n\r");
return "";
}
}
/*! \internal
TQT_BASE_OBJECT_NAME::child is compat but needs to call itself recursively,
that's why we need this helper.
*/
static TQT_BASE_OBJECT_NAME *qChildHelper(const char *objName, const char *inheritsClass,
bool recursiveSearch, const QObjectList &children)
{
if (children.isEmpty())
return 0;
bool onlyWidgets = (inheritsClass && qstrcmp(inheritsClass, "QWidget") == 0);
const QLatin1String oName(objName);
for (int i = 0; i < children.size(); ++i) {
TQT_BASE_OBJECT_NAME *obj = children.at(i);
if (onlyWidgets) {
if (obj->isWidgetType() && (!objName || obj->objectName() == oName))
return obj;
} else if ((!inheritsClass || obj->inherits(inheritsClass))
&& (!objName || obj->objectName() == oName))
return obj;
if (recursiveSearch && (obj = qChildHelper(objName, inheritsClass,
recursiveSearch, obj->children())))
return obj;
}
return 0;
}
TQObject *TQObject::child( const char *objName, const char *inheritsClass, bool recursiveSearch ) {
return static_cast<TQObject*>(qChildHelper(objName, inheritsClass, recursiveSearch, children()));
}
#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
/*
Preliminary signal spy
*/
TQ_EXPORT TQObject* qt_preliminary_signal_spy = 0;
static TQObject* qt_spy_signal_sender = 0;
// static void qt_spy_signal( TQObject* sender, int signal, TQUObject* o )
// {
// QMetaObject* mo = sender->metaObject();
// while ( mo && signal - mo->signalOffset() < 0 )
// mo = mo->superClass();
// if ( !mo )
// return;
// const TQMetaData* sigData = mo->signal( signal - mo->signalOffset() );
// if ( !sigData )
// return;
// TQCString s;
// mo = sender->tqmetaObject();
// while ( mo ) {
// s.sprintf( "%s_%s", mo->className(), sigData->name );
// int slot = qt_preliminary_signal_spy->tqmetaObject()->tqfindSlot( s, TRUE );
// if ( slot >= 0 ) {
// #ifdef TQT_THREAD_SUPPORT
// // protect access to qt_spy_signal_sender
// void * const address = &qt_spy_signal_sender;
// TQMutexLocker locker( tqt_global_mutexpool ?
// tqt_global_mutexpool->get( address ) : 0 );
// #endif // TQT_THREAD_SUPPORT
//
// TQObject* old_sender = qt_spy_signal_sender;
// qt_spy_signal_sender = sender;
// qt_preliminary_signal_spy->qt_invoke( slot, o );
// qt_spy_signal_sender = old_sender;
// break;
// }
// mo = mo->superClass();
// }
// }
/*
End Preliminary signal spy
*/
#endif // TQT_NO_PRELIMINARY_SIGNAL_SPY
//
// Remove white space from TQT_SIGNAL and TQT_SLOT names.
// Internal for TQObject::connect() and TQObject::disconnect()
//
static inline bool isIdentChar( char x )
{ // Avoid bug in isalnum
return x == '_' || (x >= '0' && x <= '9') ||
(x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z');
}
static inline bool isSpace( char x )
{
#if defined(TQ_CC_BOR)
/*
Borland C++ 4.5 has a weird isspace() bug.
isspace() usually works, but not here.
This implementation is sufficient for our internal use: rmWS()
*/
return (uchar) x <= 32;
#else
return isspace( (uchar) x );
#endif
}
static TQCString qt_rmWS( const char *s )
{
TQCString result( tqstrlen(s)+1 );
char *d = result.data();
char last = 0;
while( *s && isSpace(*s) ) // skip leading space
s++;
while ( *s ) {
while ( *s && !isSpace(*s) )
last = *d++ = *s++;
while ( *s && isSpace(*s) )
s++;
if ( *s && isIdentChar(*s) && isIdentChar(last) )
last = *d++ = ' ';
}
*d = '\0';
result.truncate( (int)(d - result.data()) );
int void_pos = result.tqfind("(void)");
if ( void_pos >= 0 )
result.remove( void_pos+1, (uint)strlen("void") );
return result;
}
TQConnectionList *TQObject::tqreceivers( const char* signal ) const
{
TQConnectionList* clist = new TQConnectionList;
clist->setAutoDelete( TRUE );
if (receivers(signal) > 0) {
printf("[WARNING] TQConnectionList *TQObject::tqreceivers( const char* signal ) is UNIMPLEMENTED and connected signals were detected!\n\r");
}
return clist;
}
TQConnectionList *TQObject::tqreceivers( int signal ) const
{
TQConnectionList* clist = new TQConnectionList;
clist->setAutoDelete( TRUE );
printf("[WARNING] TQConnectionList *TQObject::tqreceivers( int signal ) const UNIMPLEMENTED\n\r");
return clist;
}
/*! \internal
Returns a list of objects/slot pairs that are connected to the
\a signal, or 0 if nothing is connected to it.
*/
// TQConnectionList *TQObject::tqreceivers( const char* signal ) const
// {
// if ( connections && signal ) {
// if ( *signal == '2' ) { // tag == 2, i.e. signal
// TQCString s = qt_rmWS( signal+1 );
// return tqreceivers( metaObject()->indexOfSignal( (const char*)s ) );
// } else {
// return tqreceivers( metaObject()->indexOfSignal(signal ) );
// }
// }
// return 0;
// }
/*! \internal
Returns a list of objects/slot pairs that are connected to the
signal, or 0 if nothing is connected to it.
*/
// TQConnectionList *TQObject::tqreceivers( int signal ) const
// {
// #ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
// if ( qt_preliminary_signal_spy && signal >= 0 ) {
// if ( !connections ) {
// TQObject* that = (TQObject*) this;
// that->connections = new TQSignalVec( signal+1 );
// that->connections->setAutoDelete( TRUE );
// }
// if ( !connections->at( signal ) ) {
// TQConnectionList* clist = new TQConnectionList;
// clist->setAutoDelete( TRUE );
// connections->insert( signal, clist );
// return clist;
// }
// }
// #endif
// if ( connections && signal >= 0 )
// return connections->at( signal );
// return 0;
// }
#if 0
/*!
\internal
Signal activation with the most frequently used parameter/argument
types. All other combinations are generated by the meta object
compiler.
*/
void TQObject::activate_signal( int signal )
{
#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
if ( qt_preliminary_signal_spy ) {
if ( !tqsignalsBlocked() && signal >= 0 &&
( !connections || !connections->at( signal ) ) ) {
TQUObject o[1];
qt_spy_signal( this, signal, o );
return;
}
}
#endif
if ( !connections || tqsignalsBlocked() || signal < 0 )
return;
TQConnectionList *clist = connections->at( signal );
if ( !clist )
return;
TQUObject o[1];
activate_signal( clist, o );
}
#endif
/*! \internal */
void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
{
if ( !clist )
return;
// #ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
// if ( qt_preliminary_signal_spy )
// qt_spy_signal( this, connections->tqfindRef( clist), o );
// #endif
TQObject *object;
TQSenderObjectList* sol;
TQObject* oldSender = 0;
TQConnection *c;
if ( clist->count() == 1 ) { // save iterator
c = clist->first();
object = c->object();
sol = object->senderObjects;
if ( sol ) {
oldSender = sol->currentSender;
sol->ref();
sol->currentSender = this;
}
if ( c->memberType() == TQSIGNAL_CODE ) {
// object->qt_emit( c->member(), o );
QMetaMethod method = metaObject()->method(c->member());
method.invoke(this, Qt::QueuedConnection);
}
else {
// object->qt_invoke( c->member(), o );
QMetaMethod method = metaObject()->method(c->member());
method.invoke(this, Qt::QueuedConnection);
}
if ( sol ) {
sol->currentSender = oldSender;
if ( sol->deref() )
delete sol;
}
} else {
TQConnection *cd = 0;
TQConnectionListIt it(*clist);
while ( (c=it.current()) ) {
++it;
if ( c == cd )
continue;
cd = c;
object = c->object();
sol = object->senderObjects;
if ( sol ) {
oldSender = sol->currentSender;
sol->ref();
sol->currentSender = this;
}
if ( c->memberType() == TQSIGNAL_CODE ) {
// object->qt_emit( c->member(), o );
QMetaMethod method = metaObject()->method(c->member());
method.invoke(this, Qt::QueuedConnection);
}
else {
// object->qt_invoke( c->member(), o );
QMetaMethod method = metaObject()->method(c->member());
method.invoke(this, Qt::QueuedConnection);
}
if (sol ) {
sol->currentSender = oldSender;
if ( sol->deref() )
delete sol;
}
}
}
}
/*!
\overload void TQObject::activate_signal( int signal, int )
*/
/*!
\overload void TQObject::activate_signal( int signal, double )
*/
/*!
\overload void TQObject::activate_signal( int signal, TQString )
*/
/*!
\fn void TQObject::activate_signal_bool( int signal, bool )
\internal
Like the above functions, but since bool is sometimes
only a typedef it cannot be a simple overload.
*/
// #ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
// #define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \
// void TQObject::FNAME( int signal, TYPE param ) \
// { \
// if ( qt_preliminary_signal_spy ) { \
// if ( !tqsignalsBlocked() && signal >= 0 && \
// ( !connections || !connections->at( signal ) ) ) { \
// TQUObject o[2]; \
// static_TQUType_##TYPE.set( o+1, param ); \
// qt_spy_signal( this, signal, o ); \
// return; \
// } \
// } \
// if ( !connections || tqsignalsBlocked() || signal < 0 ) \
// return; \
// TQConnectionList *clist = connections->at( signal ); \
// if ( !clist ) \
// return; \
// TQUObject o[2]; \
// static_TQUType_##TYPE.set( o+1, param ); \
// activate_signal( clist, o ); \
// }
// #else
// #define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \
// void TQObject::FNAME( int signal, TYPE param ) \
// { \
// if ( !connections || tqsignalsBlocked() || signal < 0 ) \
// return; \
// TQConnectionList *clist = connections->at( signal ); \
// if ( !clist ) \
// return; \
// TQUObject o[2]; \
// static_TQUType_##TYPE.set( o+1, param ); \
// activate_signal( clist, o ); \
// }
//
// #endif
// // We don't want to duplicate too much text so...
//
// ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, int )
// ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, double )
// ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, TQString )
// ACTIVATE_SIGNAL_WITH_PARAM( activate_signal_bool, bool )
static void objSearch( TQObjectList *result,
TQObjectList *list,
const char *inheritsClass,
bool onlyWidgets,
const char *objName,
TQRegExp *rx,
bool recurse )
{
if ( !list || list->isEmpty() ) // nothing to search
return;
TQObject *obj = list->first();
while ( obj ) {
bool ok = TRUE;
if ( onlyWidgets )
ok = obj->isWidgetType();
else if ( inheritsClass && !obj->inherits(inheritsClass) )
ok = FALSE;
if ( ok ) {
if ( objName )
ok = ( qstrcmp(objName,obj->name()) == 0 );
#ifndef TQT_NO_REGEXP
else if ( rx )
ok = ( rx->search(TQString::tqfromLatin1(obj->name())) != -1 );
#endif
}
if ( ok ) // match!
result->append( obj );
if ( recurse && !obj->childrenListObject().isEmpty() ) {
TQObjectList tqlist = obj->childrenListObject();
objSearch( result, &tqlist, inheritsClass,
onlyWidgets, objName, rx, recurse );
}
obj = list->next();
}
}
/*!
Searches the tqchildren and optionally grandtqchildren of this object,
and returns a list of those objects that are named or that match
\a objName and inherit \a inheritsClass. If \a inheritsClass is 0
(the default), all classes match. If \a objName is 0 (the
default), all object names match.
If \a regexpMatch is TRUE (the default), \a objName is a regular
expression that the objects's names must match. The syntax is that
of a TQRegExp. If \a regexpMatch is FALSE, \a objName is a string
and object names must match it exactly.
Note that \a inheritsClass uses single inheritance from TQObject,
the way inherits() does. According to inherits(), TQMenuBar
inherits TQWidget but not TQMenuData. This does not quite match
reality, but is the best that can be done on the wide variety of
compilers TQt supports.
Finally, if \a recursiveSearch is TRUE (the default), queryList()
searches \e{n}th-generation as well as first-generation tqchildren.
If all this seems a bit complex for your needs, the simpler
child() function may be what you want.
This somewhat contrived example disables all the buttons in this
window:
\code
TQObjectList *l = tqtopLevelWidget()->queryList( "TQButton" );
TQObjectListIt it( *l ); // iterate over the buttons
TQObject *obj;
while ( (obj = it.current()) != 0 ) {
// for each found object...
++it;
((TQButton*)obj)->setEnabled( FALSE );
}
delete l; // delete the list, not the objects
\endcode
The TQObjectList class is defined in the \c tqobjectlist.h header
file.
\warning Delete the list as soon you have finished using it. The
list tqcontains pointers that may become invalid at almost any time
without notice (as soon as the user closes a window you may have
dangling pointers, for example).
\sa child() childrenListObject(), tqparent(), inherits(), name(), TQRegExp
*/
TQObjectList *TQObject::queryList( const char *inheritsClass,
const char *objName,
bool regexpMatch,
bool recursiveSearch ) const
{
TQObjectList *list = new TQObjectList;
TQ_CHECK_PTR( list );
bool onlyWidgets = ( inheritsClass && qstrcmp(inheritsClass, "TQWidget") == 0 );
#ifndef TQT_NO_REGEXP
if ( regexpMatch && objName ) { // regexp matching
TQRegExp rx(TQString::tqfromLatin1(objName));
TQObjectList tqlist = childrenListObject();
objSearch( list, &tqlist, inheritsClass, onlyWidgets,
0, &rx, recursiveSearch );
} else
#endif
{
TQObjectList tqlist = childrenListObject();
objSearch( list, &tqlist, inheritsClass, onlyWidgets,
objName, 0, recursiveSearch );
}
return list;
}
/*!
Normlizes the signal or slot definition \a signalSlot by removing
unnecessary whitespace.
*/
TQCString TQObject::normalizeSignalSlot( const char *signalSlot )
{
if ( !signalSlot )
return TQCString();
return qt_rmWS( signalSlot );
}
TQMetaObject *TQObject::tqmetaObject() const {
return const_cast<TQMetaObject*>(static_cast<const TQMetaObject*>(metaObject()));
}
// TQMetaObject* TQObject::tqstaticMetaObject()
// {
// return const_cast<TQMetaObject*>(static_cast<const TQMetaObject*>(&TQT_BASE_OBJECT_NAME::staticMetaObject));
// }
TQMetaObject* tqstaticMetaObject_helper(const QMetaObject* mobj)
{
return const_cast<TQMetaObject*>(static_cast<const TQMetaObject*>(mobj));
}
/*!
This virtual function receives events to an object and should
return TRUE if the event \a e was recognized and processed.
The event() function can be reimplemented to customize the
behavior of an object.
\sa installEventFilter(), timerEvent(), TQApplication::sendEvent(),
TQApplication::postEvent(), TQWidget::event()
*/
bool TQObject::event( TQEvent *e )
{
#if defined(TQT_CHECK_NULL)
if ( e == 0 )
qWarning( "TQObject::event: Null events are not permitted" );
#endif
// if ( eventFilters ) { // try filters
// if ( activate_filters(e) ) // stopped by a filter
// return TRUE;
// }
//
switch ( e->type() ) {
// case TQEvent::Timer:
// timerEvent( (TQTimerEvent*)e );
// return TRUE;
//
// case TQEvent::DeferredDelete:
// delete this;
// return TRUE;
//
// default:
// if ( e->type() >= TQEvent::User ) {
// customEvent( (TQCustomEvent*) e );
// return TRUE;
// }
// break;
// }
case TQEvent::ChildInserted:
// case TQEvent::ChildRemoved: // Causes a recursion loop if uncommented
childEvent( (TQChildEvent*)e );
return TRUE;
default:
return QObject::event(e);
}
return FALSE;
}
/*!
This event handler can be reimplemented in a subclass to receive
timer events for the object.
TQTimer provides a higher-level interface to the timer
functionality, and also more general information about timers.
\sa startTimer(), killTimer(), killTimers(), event()
*/
void TQObject::timerEvent( TQTimerEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
child events.
Child events are sent to objects when tqchildren are inserted or
removed.
Note that events with TQEvent::type() \c TQEvent::ChildInserted are
posted (with \l{TQApplication::postEvent()}) to make sure that the
child's construction is completed before this function is called.
If a child is removed immediately after it is inserted, the \c
ChildInserted event may be suppressed, but the \c ChildRemoved
event will always be sent. In such cases it is possible that there
will be a \c ChildRemoved event without a corresponding \c
ChildInserted event.
If you change state based on \c ChildInserted events, call
TQWidget::constPolish(), or do
\code
TQApplication::sendPostedEvents( this, TQEvent::ChildInserted );
\endcode
in functions that depend on the state. One notable example is
TQWidget::sizeHint().
\sa event(), TQChildEvent
*/
void TQObject::childEvent( TQChildEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
custom events. Custom events are user-defined events with a type
value at least as large as the "User" item of the \l TQEvent::Type
enum, and is typically a TQCustomEvent or TQCustomEvent subclass.
\sa event(), TQCustomEvent
*/
void TQObject::customEvent( TQCustomEvent * )
{
}
/*!
Filters events if this object has been installed as an event
filter for the \a watched object.
In your reimplementation of this function, if you want to filter
the event \a e, out, i.e. stop it being handled further, return
TRUE; otherwise return FALSE.
Example:
\code
class MyMainWindow : public TQMainWindow
{
public:
MyMainWindow( TQWidget *tqparent = 0, const char *name = 0 );
protected:
bool eventFilter( TQObject *obj, TQEvent *ev );
private:
TQTextEdit *textEdit;
};
MyMainWindow::MyMainWindow( TQWidget *tqparent, const char *name )
: TQMainWindow( tqparent, name )
{
textEdit = new TQTextEdit( this );
setCentralWidget( textEdit );
textEdit->installEventFilter( this );
}
bool MyMainWindow::eventFilter( TQObject *obj, TQEvent *ev )
{
if ( obj == textEdit ) {
if ( e->type() == TQEvent::KeyPress ) {
TQKeyEvent *k = (TQKeyEvent*)ev;
qDebug( "Ate key press %d", k->key() );
return TRUE;
} else {
return FALSE;
}
} else {
// pass the event on to the tqparent class
return TQMainWindow::eventFilter( obj, ev );
}
}
\endcode
Notice in the example above that unhandled events are passed to
the base class's eventFilter() function, since the base class
might have reimplemented eventFilter() for its own internal
purposes.
\warning If you delete the receiver object in this function, be
sure to return TRUE. Otherwise, TQt will forward the event to the
deleted object and the program might crash.
\sa installEventFilter()
*/
bool TQObject::eventFilter( TQObject * /* watched */, TQEvent * /* e */ )
{
return FALSE;
}
/*!
\relates TQObject
Returns a pointer to the object named \a name that inherits \a
type and with a given \a tqparent.
Returns 0 if there is no such child.
\code
TQListBox *c = (TQListBox *) qt_tqfind_obj_child( myWidget, "TQListBox",
"my list box" );
if ( c )
c->insertItem( "another string" );
\endcode
*/
void *qt_tqfind_obj_child( TQObject *tqparent, const char *type, const char *name )
{
if ( !tqparent->childrenListObject().isEmpty() ) {
TQObjectListIt it( tqparent->childrenListObject() );
TQObject *obj;
while ( (obj = it.current()) ) {
++it;
if ( qstrcmp(name,obj->name()) == 0 &&
obj->inherits(type) )
return obj;
}
}
return 0;
}
/*!
Kills all timers that this object has started.
\warning Using this function can cause hard-to-find bugs: it kills
timers started by sub- and superclasses as well as those started
by you, which is often not what you want. We recommend using a
TQTimer or perhaps killTimer().
\sa timerEvent(), startTimer(), killTimer()
*/
void TQObject::killTimers()
{
QAbstractEventDispatcher *qed = QAbstractEventDispatcher::instance();
qed->unregisterTimers(this);
}
bool TQObject::isA( const char *classname ) const
{
if (tqstrcmp(classname, metaObject()->className()) == 0) return true;
else {
TQString cn = metaObject()->className();
if (cn[0] == 'T')
cn = cn.remove(0,1);
return (tqstrcmp(classname, cn.ascii()) == 0);
}
}
bool TQObject::inherits( const char *classname ) const {
if (QObject::inherits(classname)) return true;
else {
TQString cn = classname;
if (cn[0] != 'T')
cn = cn.prepend('T');
return QObject::inherits(cn.ascii());
}
}
#else // USE_QT4
/****************************************************************************
**
** Implementation of TQObject class
**
** Created : 930418
**
** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
**
** This file is part of the kernel module of the TQt GUI Toolkit.
**
** This file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the files LICENSE.GPL2
** and LICENSE.GPL3 included in the packaging of this file.
** Alternatively you may (at your option) use any later version
** of the GNU General Public License if such license has been
** publicly approved by Trolltech ASA (or its successors, if any)
** and the KDE Free TQt Foundation.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/.
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** This file may be used under the terms of the Q Public License as
** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
** included in the packaging of this file. Licensees holding valid TQt
** Commercial licenses may use this file in accordance with the TQt
** Commercial License Agreement provided with the Software.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
** herein.
**
**********************************************************************/
#include "tqvariant.h"
#include "tqapplication.h"
#include "tqobject.h"
#include "tqobjectlist.h"
#include "tqsignalslotimp.h"
#include "tqregexp.h"
#include "tqmetaobject.h"
#include <private/tqucom_p.h>
#include "tqucomextra_p.h"
#include "tqptrvector.h"
#ifdef TQT_THREAD_SUPPORT
#include <tqmutex.h>
#include <private/tqmutexpool_p.h>
#endif
#include <ctype.h>
#ifndef TQT_NO_USERDATA
class TQObjectPrivate : public TQPtrVector<TQObjectUserData>
{
public:
TQObjectPrivate( uint s ) : TQPtrVector<TQObjectUserData>(s){ setAutoDelete( TRUE ); }
};
#else
class TQObjectPrivate {
}
#endif
class TQSenderObjectList : public TQObjectList, public TQShared
{
public:
TQSenderObjectList() : currentSender( 0 ) { }
TQObject *currentSender;
};
/*!
\class TQt tqnamespace.h
\brief The TQt class is a namespace for miscellaneous identifiers
that need to be global-like.
\ingroup misc
Normally, you can ignore this class. TQObject and a few other
classes inherit it, so all the identifiers in the TQt namespace are
normally usable without qualification.
However, you may occasionally need to say \c TQt::black instead of
just \c black, particularly in static utility functions (such as
many class factories).
*/
/*!
\enum Orientation
This type is used to signify an object's orientation.
\value Horizontal
\value Vertical
Orientation is used with TQScrollBar for example.
*/
/*!
\class TQObject tqobject.h
\brief The TQObject class is the base class of all TQt objects.
\ingroup objectmodel
\mainclass
\reentrant
TQObject is the heart of the \link object.html TQt object model.
\endlink The central feature in this model is a very powerful
mechanism for seamless object communication called \link
Q_SIGNALSandQ_SLOTS.html Q_SIGNALS and Q_SLOTS \endlink. You can
connect a signal to a slot with connect() and destroy the
connection with disconnect(). To avoid never ending notification
loops you can temporarily block Q_SIGNALS with blockSignals(). The
protected functions connectNotify() and disconnectNotify() make it
possible to track connections.
TQObjects organize themselves in object trees. When you create a
TQObject with another object as tqparent, the object will
automatically do an insertChild() on the tqparent and thus show up
in the tqparent's childrenListObject() list. The tqparent takes ownership of the
object i.e. it will automatically delete its tqchildren in its
destructor. You can look for an object by name and optionally type
using child() or queryList(), and get the list of tree roots using
objectTrees().
Every object has an object name() and can report its className()
and whether it inherits() another class in the TQObject inheritance
hierarchy.
When an object is deleted, it emits a destroyed() signal. You can
catch this signal to avoid dangling references to TQObjects. The
TQGuardedPtr class provides an elegant way to use this feature.
TQObjects can receive events through event() and filter the events
of other objects. See installEventFilter() and eventFilter() for
details. A convenience handler, childEvent(), can be reimplemented
to catch child events.
Last but not least, TQObject provides the basic timer support in
TQt; see TQTimer for high-level support for timers.
Notice that the TQ_OBJECT macro is mandatory for any object that
implements Q_SIGNALS, Q_SLOTS or properties. You also need to run the
\link tqmoc.html tqmoc program (Meta Object Compiler) \endlink on the
source file. We strongly recommend the use of this macro in \e all
subclasses of TQObject regardless of whether or not they actually
use Q_SIGNALS, Q_SLOTS and properties, since failure to do so may lead
certain functions to exhibit undefined behaviour.
All TQt widgets inherit TQObject. The convenience function
isWidgetType() returns whether an object is actually a widget. It
is much faster than inherits( "TQWidget" ).
Some TQObject functions, e.g. childrenListObject(), objectTrees() and
queryList() return a TQObjectList. A TQObjectList is a TQPtrList of
TQObjects. TQObjectLists support the same operations as TQPtrLists
and have an iterator class, TQObjectListIt.
*/
//
// Remove white space from TQT_SIGNAL and TQT_SLOT names.
// Internal for TQObject::connect() and TQObject::disconnect()
//
static inline bool isIdentChar( char x )
{ // Avoid bug in isalnum
return x == '_' || (x >= '0' && x <= '9') ||
(x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z');
}
static inline bool isSpace( char x )
{
#if defined(TQ_CC_BOR)
/*
Borland C++ 4.5 has a weird isspace() bug.
isspace() usually works, but not here.
This implementation is sufficient for our internal use: rmWS()
*/
return (uchar) x <= 32;
#else
return isspace( (uchar) x );
#endif
}
static TQCString qt_rmWS( const char *s )
{
TQCString result( tqstrlen(s)+1 );
char *d = result.data();
char last = 0;
while( *s && isSpace(*s) ) // skip leading space
s++;
while ( *s ) {
while ( *s && !isSpace(*s) )
last = *d++ = *s++;
while ( *s && isSpace(*s) )
s++;
if ( *s && isIdentChar(*s) && isIdentChar(last) )
last = *d++ = ' ';
}
*d = '\0';
result.truncate( (int)(d - result.data()) );
int void_pos = result.tqfind("(void)");
if ( void_pos >= 0 )
result.remove( void_pos+1, (uint)strlen("void") );
return result;
}
// Event functions, implemented in qapplication_xxx.cpp
int qStartTimer( int interval, TQObject *obj );
bool qKillTimer( int id );
bool qKillTimer( TQObject *obj );
static void removeObjFromList( TQObjectList *objList, const TQObject *obj,
bool single=FALSE )
{
if ( !objList )
return;
int index = objList->tqfindRef( obj );
while ( index >= 0 ) {
objList->remove();
if ( single )
return;
index = objList->tqfindNextRef( obj );
}
}
/*!
\relates TQObject
Returns a pointer to the object named \a name that inherits \a
type and with a given \a tqparent.
Returns 0 if there is no such child.
\code
TQListBox *c = (TQListBox *) qt_tqfind_obj_child( myWidget, "TQListBox",
"my list box" );
if ( c )
c->insertItem( "another string" );
\endcode
*/
void *qt_tqfind_obj_child( TQObject *tqparent, const char *type, const char *name )
{
if ( !tqparent->childrenListObject().isEmpty() ) {
TQObjectListIt it( tqparent->childrenListObject() );
TQObject *obj;
while ( (obj = it.current()) ) {
++it;
if ( qstrcmp(name,obj->name()) == 0 &&
obj->inherits(type) )
return obj;
}
}
return 0;
}
#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
/*
Preliminary signal spy
*/
TQ_EXPORT TQObject* qt_preliminary_signal_spy = 0;
static TQObject* qt_spy_signal_sender = 0;
static void qt_spy_signal( TQObject* sender, int signal, TQUObject* o )
{
TQMetaObject* mo = sender->tqmetaObject();
while ( mo && signal - mo->signalOffset() < 0 )
mo = mo->superClass();
if ( !mo )
return;
const TQMetaData* sigData = mo->signal( signal - mo->signalOffset() );
if ( !sigData )
return;
TQCString s;
mo = sender->tqmetaObject();
while ( mo ) {
s.sprintf( "%s_%s", mo->className(), sigData->name );
int slot = qt_preliminary_signal_spy->tqmetaObject()->tqfindSlot( s, TRUE );
if ( slot >= 0 ) {
#ifdef TQT_THREAD_SUPPORT
// protect access to qt_spy_signal_sender
void * const address = &qt_spy_signal_sender;
TQMutexLocker locker( tqt_global_mutexpool ?
tqt_global_mutexpool->get( address ) : 0 );
#endif // TQT_THREAD_SUPPORT
TQObject* old_sender = qt_spy_signal_sender;
qt_spy_signal_sender = sender;
qt_preliminary_signal_spy->qt_invoke( slot, o );
qt_spy_signal_sender = old_sender;
break;
}
mo = mo->superClass();
}
}
/*
End Preliminary signal spy
*/
#endif // TQT_NO_PRELIMINARY_SIGNAL_SPY
static TQObjectList* object_trees = 0;
#ifdef TQT_THREAD_SUPPORT
static TQMutex *obj_trees_mutex = 0;
#endif
static void cleanup_object_trees()
{
delete object_trees;
object_trees = 0;
#ifdef TQT_THREAD_SUPPORT
delete obj_trees_mutex;
obj_trees_mutex = 0;
#endif
}
static void ensure_object_trees()
{
object_trees = new TQObjectList;
qAddPostRoutine( cleanup_object_trees );
}
static void insert_tree( TQObject* obj )
{
#ifdef TQT_THREAD_SUPPORT
if ( !obj_trees_mutex )
obj_trees_mutex = new TQMutex();
TQMutexLocker locker( obj_trees_mutex );
#endif
if ( !object_trees )
ensure_object_trees();
object_trees->insert(0, obj );
}
static void remove_tree( TQObject* obj )
{
if ( object_trees ) {
#ifdef TQT_THREAD_SUPPORT
TQMutexLocker locker( obj_trees_mutex );
#endif
object_trees->removeRef( obj );
}
}
/*****************************************************************************
TQObject member functions
*****************************************************************************/
/*!
Constructs an object called \a name with tqparent object, \a tqparent.
The tqparent of an object may be viewed as the object's owner. For
instance, a \link TQDialog dialog box\endlink is the tqparent of the
"OK" and "Cancel" buttons it tqcontains.
The destructor of a tqparent object destroys all child objects.
Setting \a tqparent to 0 constructs an object with no tqparent. If the
object is a widget, it will become a top-level window.
The object name is some text that can be used to identify a
TQObject. It's particularly useful in conjunction with \link
designer-manual.book <i>TQt Designer</i>\endlink. You can tqfind an
object by name (and type) using child(). To tqfind several objects
use queryList().
\sa tqparent(), name(), child(), queryList()
*/
TQObject::TQObject( TQObject *tqparent, const char *name )
:
isSignal( FALSE ), // assume not a signal object
isWidget( FALSE ), // assume not a widget object
pendTimer( FALSE ), // no timers yet
blockSig( FALSE ), // not blocking Q_SIGNALS
wasDeleted( FALSE ), // double-delete catcher
isTree( FALSE ), // no tree yet
objname( name ? qstrdup(name) : 0 ), // set object name
parentObj( 0 ), // no tqparent yet. It is set by insertChild()
childObjects( 0 ), // no tqchildren yet
connections( 0 ), // no connections yet
senderObjects( 0 ), // no Q_SIGNALS connected yet
eventFilters( 0 ), // no filters installed
postedEvents( 0 ), // no events posted
d( 0 )
{
if ( !metaObj ) // will create object dict
(void) staticMetaObject();
if ( tqparent ) { // add object to tqparent
tqparent->insertChild( this );
} else {
insert_tree( this );
isTree = TRUE;
}
}
/*!
Destroys the object, deleting all its child objects.
All Q_SIGNALS to and from the object are automatically disconnected.
\warning All child objects are deleted. If any of these objects
are on the stack or global, sooner or later your program will
crash. We do not recommend holding pointers to child objects from
outside the tqparent. If you still do, the TQObject::destroyed()
signal gives you an opportunity to detect when an object is
destroyed.
\warning Deleting a TQObject while pending events are waiting to be
delivered can cause a crash. You must not delete the TQObject
directly from a thread that is not the GUI thread. Use the
TQObject::deleteLater() method instead, which will cause the event
loop to delete the object after all pending events have been
delivered to the object.
*/
TQObject::~TQObject()
{
if ( wasDeleted ) {
#if defined(TQT_DEBUG)
qWarning( "Double TQObject deletion detected." );
#endif
return;
}
wasDeleted = 1;
blockSig = 0; // unblock Q_SIGNALS to keep TQGuardedPtr happy
emit destroyed( this );
emit destroyed();
if ( objname )
delete [] (char*)objname;
objname = 0;
if ( pendTimer ) // might be pending timers
qKillTimer( this );
TQApplication::removePostedEvents( this );
if ( isTree ) {
remove_tree( this ); // remove from global root list
isTree = FALSE;
}
if ( parentObj ) // remove it from tqparent object
parentObj->removeChild( this );
register TQObject *obj;
if ( senderObjects ) { // disconnect from senders
TQSenderObjectList *tmp = senderObjects;
senderObjects = 0;
obj = tmp->first();
while ( obj ) { // for all senders...
obj->disconnect( this );
obj = tmp->next();
}
if ( tmp->deref() )
delete tmp;
}
if ( connections ) { // disconnect tqreceivers
for ( int i = 0; i < (int) connections->size(); i++ ) {
TQConnectionList* clist = (*connections)[i]; // for each signal...
if ( !clist )
continue;
register TQConnection *c;
TQConnectionListIt cit(*clist);
while( (c=cit.current()) ) { // for each connected slot...
++cit;
if ( (obj=c->object()) )
removeObjFromList( obj->senderObjects, this );
}
}
delete connections;
connections = 0;
}
if ( eventFilters ) {
delete eventFilters;
eventFilters = 0;
}
if ( childObjects ) { // delete tqchildren objects
TQObjectListIt it(*childObjects);
while ( (obj=it.current()) ) {
++it;
obj->parentObj = 0;
childObjects->removeRef( obj );
delete obj;
}
delete childObjects;
}
delete d;
}
/*!
\fn TQMetaObject *TQObject::tqmetaObject() const
Returns a pointer to the meta object of this object.
A meta object tqcontains information about a class that inherits
TQObject, e.g. class name, superclass name, properties, Q_SIGNALS and
Q_SLOTS. Every class that tqcontains the TQ_OBJECT macro will also have
a meta object.
The meta object information is required by the signal/slot
connection mechanism and the property system. The functions isA()
and inherits() also make use of the meta object.
*/
/*!
\fn const char *TQObject::className() const
Returns the class name of this object.
This function is generated by the \link metaobjects.html Meta
Object Compiler. \endlink
\warning This function will return the wrong name if the class
definition lacks the TQ_OBJECT macro.
\sa name(), inherits(), isA(), isWidgetType()
*/
/*!
Returns TRUE if this object is an instance of the class \a clname;
otherwise returns FALSE.
Example:
\code
TQTimer *t = new TQTimer; // TQTimer inherits TQObject
t->isA( "TQTimer" ); // returns TRUE
t->isA( "TQObject" ); // returns FALSE
\endcode
\sa inherits() tqmetaObject()
*/
bool TQObject::isA( const char *clname ) const
{
return qstrcmp( clname, className() ) == 0;
}
/*!
Returns TRUE if this object is an instance of a class that
inherits \a clname, and \a clname inherits TQObject; otherwise
returns FALSE.
A class is considered to inherit itself.
Example:
\code
TQTimer *t = new TQTimer; // TQTimer inherits TQObject
t->inherits( "TQTimer" ); // returns TRUE
t->inherits( "TQObject" ); // returns TRUE
t->inherits( "TQButton" ); // returns FALSE
// TQScrollBar inherits TQWidget and TQRangeControl
TQScrollBar *s = new TQScrollBar( 0 );
s->inherits( "TQWidget" ); // returns TRUE
s->inherits( "TQRangeControl" ); // returns FALSE
\endcode
(\l TQRangeControl is not a TQObject.)
\sa isA(), tqmetaObject()
*/
bool TQObject::inherits( const char *clname ) const
{
return tqmetaObject()->inherits( clname );
}
/*!
\internal
Returns TRUE if \a object inherits \a superClass within
the meta object inheritance chain; otherwise returns FALSE.
\sa inherits()
*/
void *qt_inheritedBy( TQMetaObject *superClass, const TQObject *object )
{
if (!object)
return 0;
register TQMetaObject *mo = object->tqmetaObject();
while (mo) {
if (mo == superClass)
return (void*)object;
mo = mo->superClass();
}
return 0;
}
/*!
\property TQObject::name
\brief the name of this object
You can tqfind an object by name (and type) using child(). You can
tqfind a set of objects with queryList().
The object name is set by the constructor or by the setName()
function. The object name is not very useful in the current
version of TQt, but will become increasingly important in the
future.
If the object does not have a name, the name() function returns
"unnamed", so printf() (used in qDebug()) will not be asked to
output a null pointer. If you want a null pointer to be returned
for unnamed objects, you can call name( 0 ).
\code
qDebug( "MyClass::setPrecision(): (%s) invalid precision %f",
name(), newPrecision );
\endcode
\sa className(), child(), queryList()
*/
const char * TQObject::name() const
{
// If you change the name here, the builder will be broken
return objname ? objname : "unnamed";
}
/*!
Sets the object's name to \a name.
*/
void TQObject::setName( const char *name )
{
if ( objname )
delete [] (char*) objname;
objname = name ? qstrdup(name) : 0;
}
/*!
\overload
Returns the name of this object, or \a defaultName if the object
does not have a name.
*/
const char * TQObject::name( const char * defaultName ) const
{
return objname ? objname : defaultName;
}
/*!
Searches the tqchildren and optionally grandtqchildren of this object,
and returns a child that is called \a objName that inherits \a
inheritsClass. If \a inheritsClass is 0 (the default), any class
matches.
If \a recursiveSearch is TRUE (the default), child() performs a
depth-first search of the object's tqchildren.
If there is no such object, this function returns 0. If there are
more than one, the first one found is retured; if you need all of
them, use queryList().
*/
TQObject* TQObject::child( const char *objName, const char *inheritsClass,
bool recursiveSearch )
{
if ( childrenListObject().isEmpty() )
return 0;
bool onlyWidgets = ( inheritsClass && qstrcmp( inheritsClass, "TQWidget" ) == 0 );
TQObjectListIt it( childrenListObject() );
TQObject *obj;
while ( ( obj = it.current() ) ) {
++it;
if ( onlyWidgets ) {
if ( obj->isWidgetType() && ( !objName || qstrcmp( objName, obj->name() ) == 0 ) )
break;
} else if ( ( !inheritsClass || obj->inherits(inheritsClass) ) && ( !objName || qstrcmp( objName, obj->name() ) == 0 ) )
break;
if ( recursiveSearch && (obj = obj->child( objName, inheritsClass, recursiveSearch ) ) )
break;
}
return obj;
}
/*!
\fn bool TQObject::isWidgetType() const
Returns TRUE if the object is a widget; otherwise returns FALSE.
Calling this function is equivalent to calling
inherits("TQWidget"), except that it is much faster.
*/
/*!
\fn bool TQObject::highPriority() const
Returns TRUE if the object is a high-priority object, or FALSE if
it is a standard-priority object.
High-priority objects are placed first in TQObject's list of
tqchildren on the assumption that they will be referenced very
often.
*/
/*!
This virtual function receives events to an object and should
return TRUE if the event \a e was recognized and processed.
The event() function can be reimplemented to customize the
behavior of an object.
\sa installEventFilter(), timerEvent(), TQApplication::sendEvent(),
TQApplication::postEvent(), TQWidget::event()
*/
bool TQObject::event( TQEvent *e )
{
#if defined(TQT_CHECK_NULL)
if ( e == 0 )
qWarning( "TQObject::event: Null events are not permitted" );
#endif
if ( eventFilters ) { // try filters
if ( activate_filters(e) ) // stopped by a filter
return TRUE;
}
switch ( e->type() ) {
case TQEvent::Timer:
timerEvent( (TQTimerEvent*)e );
return TRUE;
case TQEvent::ChildInserted:
case TQEvent::ChildRemoved:
childEvent( (TQChildEvent*)e );
return TRUE;
case TQEvent::DeferredDelete:
delete this;
return TRUE;
default:
if ( e->type() >= TQEvent::User ) {
customEvent( (TQCustomEvent*) e );
return TRUE;
}
break;
}
return FALSE;
}
/*!
This event handler can be reimplemented in a subclass to receive
timer events for the object.
TQTimer provides a higher-level interface to the timer
functionality, and also more general information about timers.
\sa startTimer(), killTimer(), killTimers(), event()
*/
void TQObject::timerEvent( TQTimerEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
child events.
Child events are sent to objects when tqchildren are inserted or
removed.
Note that events with TQEvent::type() \c TQEvent::ChildInserted are
posted (with \l{TQApplication::postEvent()}) to make sure that the
child's construction is completed before this function is called.
If a child is removed immediately after it is inserted, the \c
ChildInserted event may be suppressed, but the \c ChildRemoved
event will always be sent. In such cases it is possible that there
will be a \c ChildRemoved event without a corresponding \c
ChildInserted event.
If you change state based on \c ChildInserted events, call
TQWidget::constPolish(), or do
\code
TQApplication::sendPostedEvents( this, TQEvent::ChildInserted );
\endcode
in functions that depend on the state. One notable example is
TQWidget::sizeHint().
\sa event(), TQChildEvent
*/
void TQObject::childEvent( TQChildEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
custom events. Custom events are user-defined events with a type
value at least as large as the "User" item of the \l TQEvent::Type
enum, and is typically a TQCustomEvent or TQCustomEvent subclass.
\sa event(), TQCustomEvent
*/
void TQObject::customEvent( TQCustomEvent * )
{
}
/*!
Filters events if this object has been installed as an event
filter for the \a watched object.
In your reimplementation of this function, if you want to filter
the event \a e, out, i.e. stop it being handled further, return
TRUE; otherwise return FALSE.
Example:
\code
class MyMainWindow : public TQMainWindow
{
public:
MyMainWindow( TQWidget *tqparent = 0, const char *name = 0 );
protected:
bool eventFilter( TQObject *obj, TQEvent *ev );
private:
TQTextEdit *textEdit;
};
MyMainWindow::MyMainWindow( TQWidget *tqparent, const char *name )
: TQMainWindow( tqparent, name )
{
textEdit = new TQTextEdit( this );
setCentralWidget( textEdit );
textEdit->installEventFilter( this );
}
bool MyMainWindow::eventFilter( TQObject *obj, TQEvent *ev )
{
if ( obj == textEdit ) {
if ( e->type() == TQEvent::KeyPress ) {
TQKeyEvent *k = (TQKeyEvent*)ev;
qDebug( "Ate key press %d", k->key() );
return TRUE;
} else {
return FALSE;
}
} else {
// pass the event on to the tqparent class
return TQMainWindow::eventFilter( obj, ev );
}
}
\endcode
Notice in the example above that unhandled events are passed to
the base class's eventFilter() function, since the base class
might have reimplemented eventFilter() for its own internal
purposes.
\warning If you delete the receiver object in this function, be
sure to return TRUE. Otherwise, TQt will forward the event to the
deleted object and the program might crash.
\sa installEventFilter()
*/
bool TQObject::eventFilter( TQObject * /* watched */, TQEvent * /* e */ )
{
return FALSE;
}
/*!
\internal
Activates all event filters for this object.
This function is normally called from TQObject::event() or TQWidget::event().
*/
bool TQObject::activate_filters( TQEvent *e )
{
if ( !eventFilters ) // no event filter
return FALSE;
TQObjectListIt it( *eventFilters );
register TQObject *obj = it.current();
while ( obj ) { // send to all filters
++it; // until one returns TRUE
if ( obj->eventFilter(this,e) ) {
return TRUE;
}
obj = it.current();
}
return FALSE; // don't do anything with it
}
/*!
\fn bool TQObject::tqsignalsBlocked() const
Returns TRUE if Q_SIGNALS are blocked; otherwise returns FALSE.
Signals are not blocked by default.
\sa blockSignals()
*/
/*!
Blocks Q_SIGNALS if \a block is TRUE, or unblocks Q_SIGNALS if \a
block is FALSE.
Emitted Q_SIGNALS disappear into hyperspace if Q_SIGNALS are blocked.
Note that the destroyed() Q_SIGNALS will be emitted even if the Q_SIGNALS
for this object have been blocked.
*/
void TQObject::blockSignals( bool block )
{
blockSig = block;
}
//
// The timer flag hasTimer is set when startTimer is called.
// It is not reset when killing the timer because more than
// one timer might be active.
//
/*!
Starts a timer and returns a timer identifier, or returns zero if
it could not start a timer.
A timer event will occur every \a interval milliseconds until
killTimer() or killTimers() is called. If \a interval is 0, then
the timer event occurs once every time there are no more window
system events to process.
The virtual timerEvent() function is called with the TQTimerEvent
event parameter class when a timer event occurs. Reimplement this
function to get timer events.
If multiple timers are running, the TQTimerEvent::timerId() can be
used to tqfind out which timer was activated.
Example:
\code
class MyObject : public TQObject
{
TQ_OBJECT
public:
MyObject( TQObject *tqparent = 0, const char *name = 0 );
protected:
void timerEvent( TQTimerEvent * );
};
MyObject::MyObject( TQObject *tqparent, const char *name )
: TQObject( tqparent, name )
{
startTimer( 50 ); // 50-millisecond timer
startTimer( 1000 ); // 1-second timer
startTimer( 60000 ); // 1-minute timer
}
void MyObject::timerEvent( TQTimerEvent *e )
{
qDebug( "timer event, id %d", e->timerId() );
}
\endcode
Note that TQTimer's accuracy depends on the underlying operating
system and hardware. Most platforms support an accuracy of 20 ms;
some provide more. If TQt is unable to deliver the requested
number of timer clicks, it will silently discard some.
The TQTimer class provides a high-level programming interface with
one-shot timers and timer Q_SIGNALS instead of events.
\sa timerEvent(), killTimer(), killTimers(), TQEventLoop::awake(),
TQEventLoop::aboutToBlock()
*/
int TQObject::startTimer( int interval )
{
pendTimer = TRUE; // set timer flag
return qStartTimer( interval, (TQObject *)this );
}
/*!
Kills the timer with timer identifier, \a id.
The timer identifier is returned by startTimer() when a timer
event is started.
\sa timerEvent(), startTimer(), killTimers()
*/
void TQObject::killTimer( int id )
{
qKillTimer( id );
}
/*!
Kills all timers that this object has started.
\warning Using this function can cause hard-to-tqfind bugs: it kills
timers started by sub- and superclasses as well as those started
by you, which is often not what you want. We recommend using a
TQTimer or perhaps killTimer().
\sa timerEvent(), startTimer(), killTimer()
*/
void TQObject::killTimers()
{
qKillTimer( this );
}
static void objSearch( TQObjectList *result,
TQObjectList *list,
const char *inheritsClass,
bool onlyWidgets,
const char *objName,
TQRegExp *rx,
bool recurse )
{
if ( !list || list->isEmpty() ) // nothing to search
return;
TQObject *obj = list->first();
while ( obj ) {
bool ok = TRUE;
if ( onlyWidgets )
ok = obj->isWidgetType();
else if ( inheritsClass && !obj->inherits(inheritsClass) )
ok = FALSE;
if ( ok ) {
if ( objName )
ok = ( qstrcmp(objName,obj->name()) == 0 );
#ifndef TQT_NO_REGEXP
else if ( rx )
ok = ( rx->search(TQString::tqfromLatin1(obj->name())) != -1 );
#endif
}
if ( ok ) // match!
result->append( obj );
if ( recurse && !obj->childrenListObject().isEmpty ) {
TQObjectList tqlist = obj->childrenListObject();
objSearch( result, &tqlist, inheritsClass,
onlyWidgets, objName, rx, recurse );
}
obj = list->next();
}
}
/*!
\fn TQObject *TQObject::tqparent() const
Returns a pointer to the tqparent object.
\sa childrenListObject()
*/
/*!
\fn const TQObjectList *TQObject::childrenListObject() const
Returns a list of child objects, or 0 if this object has no
tqchildren.
The TQObjectList class is defined in the \c tqobjectlist.h header
file.
The first child added is the \link TQPtrList::first() first\endlink
object in the list and the last child added is the \link
TQPtrList::last() last\endlink object in the list, i.e. new
tqchildren are appended at the end.
Note that the list order changes when TQWidget tqchildren are \link
TQWidget::raise() raised\endlink or \link TQWidget::lower()
lowered.\endlink A widget that is raised becomes the last object
in the list, and a widget that is lowered becomes the first object
in the list.
\sa child(), queryList(), tqparent(), insertChild(), removeChild()
*/
/*!
Returns a pointer to the list of all object trees (their root
objects), or 0 if there are no objects.
The TQObjectList class is defined in the \c tqobjectlist.h header
file.
The most recent root object created is the \link TQPtrList::first()
first\endlink object in the list and the first root object added
is the \link TQPtrList::last() last\endlink object in the list.
\sa childrenListObject(), tqparent(), insertChild(), removeChild()
*/
const TQObjectList *TQObject::objectTrees()
{
return object_trees;
}
/*!
Searches the tqchildren and optionally grandtqchildren of this object,
and returns a list of those objects that are named or that match
\a objName and inherit \a inheritsClass. If \a inheritsClass is 0
(the default), all classes match. If \a objName is 0 (the
default), all object names match.
If \a regexpMatch is TRUE (the default), \a objName is a regular
expression that the objects's names must match. The syntax is that
of a TQRegExp. If \a regexpMatch is FALSE, \a objName is a string
and object names must match it exactly.
Note that \a inheritsClass uses single inheritance from TQObject,
the way inherits() does. According to inherits(), TQMenuBar
inherits TQWidget but not TQMenuData. This does not quite match
reality, but is the best that can be done on the wide variety of
compilers TQt supports.
Finally, if \a recursiveSearch is TRUE (the default), queryList()
searches \e{n}th-generation as well as first-generation tqchildren.
If all this seems a bit complex for your needs, the simpler
child() function may be what you want.
This somewhat contrived example disables all the buttons in this
window:
\code
TQObjectList *l = tqtopLevelWidget()->queryList( "TQButton" );
TQObjectListIt it( *l ); // iterate over the buttons
TQObject *obj;
while ( (obj = it.current()) != 0 ) {
// for each found object...
++it;
((TQButton*)obj)->setEnabled( FALSE );
}
delete l; // delete the list, not the objects
\endcode
The TQObjectList class is defined in the \c tqobjectlist.h header
file.
\warning Delete the list as soon you have finished using it. The
list tqcontains pointers that may become invalid at almost any time
without notice (as soon as the user closes a window you may have
dangling pointers, for example).
\sa child() childrenListObject(), tqparent(), inherits(), name(), TQRegExp
*/
TQObjectList *TQObject::queryList( const char *inheritsClass,
const char *objName,
bool regexpMatch,
bool recursiveSearch ) const
{
TQObjectList *list = new TQObjectList;
TQ_CHECK_PTR( list );
bool onlyWidgets = ( inheritsClass && qstrcmp(inheritsClass, "TQWidget") == 0 );
#ifndef TQT_NO_REGEXP
if ( regexpMatch && objName ) { // regexp matching
TQRegExp rx(TQString::tqfromLatin1(objName));
TQObjectList tqlist = childrenListObject();
objSearch( list, &tqlist, inheritsClass, onlyWidgets,
0, &rx, recursiveSearch );
} else
#endif
{
TQObjectList tqlist = childrenListObject();
objSearch( list, &tqlist, inheritsClass, onlyWidgets,
objName, 0, recursiveSearch );
}
return list;
}
/*! \internal
Returns a list of objects/slot pairs that are connected to the
\a signal, or 0 if nothing is connected to it.
*/
TQConnectionList *TQObject::tqreceivers( const char* signal ) const
{
if ( connections && signal ) {
if ( *signal == '2' ) { // tag == 2, i.e. signal
TQCString s = qt_rmWS( signal+1 );
return tqreceivers( tqmetaObject()->tqfindSignal( (const char*)s, TRUE ) );
} else {
return tqreceivers( tqmetaObject()->tqfindSignal(signal, TRUE ) );
}
}
return 0;
}
/*! \internal
Returns a list of objects/slot pairs that are connected to the
signal, or 0 if nothing is connected to it.
*/
TQConnectionList *TQObject::tqreceivers( int signal ) const
{
#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
if ( qt_preliminary_signal_spy && signal >= 0 ) {
if ( !connections ) {
TQObject* that = (TQObject*) this;
that->connections = new TQSignalVec( signal+1 );
that->connections->setAutoDelete( TRUE );
}
if ( !connections->at( signal ) ) {
TQConnectionList* clist = new TQConnectionList;
clist->setAutoDelete( TRUE );
connections->insert( signal, clist );
return clist;
}
}
#endif
if ( connections && signal >= 0 )
return connections->at( signal );
return 0;
}
/*!
Inserts an object \a obj into the list of child objects.
\warning This function cannot be used to make one widget the child
widget of another widget. Child widgets can only be created by
setting the tqparent widget in the constructor or by calling
TQWidget::reparent().
\sa removeChild(), TQWidget::reparent()
*/
void TQObject::insertChild( TQObject *obj )
{
if ( obj->isTree ) {
remove_tree( obj );
obj->isTree = FALSE;
}
if ( obj->parentObj && obj->parentObj != this ) {
#if defined(TQT_CHECK_STATE)
if ( obj->parentObj != this && obj->isWidgetType() )
qWarning( "TQObject::insertChild: Cannot reparent a widget, "
"use TQWidget::reparent() instead" );
#endif
obj->parentObj->removeChild( obj );
}
if ( !childObjects ) {
childObjects = new TQObjectList;
TQ_CHECK_PTR( childObjects );
} else if ( obj->parentObj == this ) {
#if defined(TQT_CHECK_STATE)
qWarning( "TQObject::insertChild: Object %s::%s already in list",
obj->className(), obj->name( "unnamed" ) );
#endif
return;
}
obj->parentObj = this;
childObjects->append( obj );
TQChildEvent *e = new TQChildEvent( TQEvent::ChildInserted, obj );
TQApplication::postEvent( this, e );
}
/*!
Removes the child object \a obj from the list of tqchildren.
\warning This function will not remove a child widget from the
screen. It will only remove it from the tqparent widget's list of
tqchildren.
\sa insertChild(), TQWidget::reparent()
*/
void TQObject::removeChild( TQObject *obj )
{
if ( childObjects && childObjects->removeRef(obj) ) {
obj->parentObj = 0;
if ( !obj->wasDeleted ) {
insert_tree( obj ); // it's a root object now
obj->isTree = TRUE;
}
if ( childObjects->isEmpty() ) {
delete childObjects; // last child removed
childObjects = 0; // reset tqchildren list
}
// remove events must be sent, not posted!!!
TQChildEvent ce( TQEvent::ChildRemoved, obj );
TQApplication::sendEvent( this, &ce );
}
}
/*!
\fn void TQObject::installEventFilter( const TQObject *filterObj )
Installs an event filter \a filterObj on this object. For example:
\code
monitoredObj->installEventFilter( filterObj );
\endcode
An event filter is an object that receives all events that are
sent to this object. The filter can either stop the event or
forward it to this object. The event filter \a filterObj receives
events via its eventFilter() function. The eventFilter() function
must return TRUE if the event should be filtered, (i.e. stopped);
otherwise it must return FALSE.
If multiple event filters are installed on a single object, the
filter that was installed last is activated first.
Here's a \c KeyPressEater class that eats the key presses of its
monitored objects:
\code
class KeyPressEater : public TQObject
{
...
protected:
bool eventFilter( TQObject *o, TQEvent *e );
};
bool KeyPressEater::eventFilter( TQObject *o, TQEvent *e )
{
if ( e->type() == TQEvent::KeyPress ) {
// special processing for key press
TQKeyEvent *k = (TQKeyEvent *)e;
qDebug( "Ate key press %d", k->key() );
return TRUE; // eat event
} else {
// standard event processing
return FALSE;
}
}
\endcode
And here's how to install it on two widgets:
\code
KeyPressEater *keyPressEater = new KeyPressEater( this );
TQPushButton *pushButton = new TQPushButton( this );
TQListView *listView = new TQListView( this );
pushButton->installEventFilter( keyPressEater );
listView->installEventFilter( keyPressEater );
\endcode
The TQAccel class, for example, uses this technique to intercept
accelerator key presses.
\warning If you delete the receiver object in your eventFilter()
function, be sure to return TRUE. If you return FALSE, TQt sends
the event to the deleted object and the program will crash.
\sa removeEventFilter(), eventFilter(), event()
*/
void TQObject::installEventFilter( const TQObject *obj )
{
if ( !obj )
return;
if ( eventFilters ) {
int c = eventFilters->tqfindRef( obj );
if ( c >= 0 )
eventFilters->take( c );
disconnect( obj, TQT_SIGNAL(destroyed(TQObject*)),
this, TQT_SLOT(cleanupEventFilter(TQObject*)) );
} else {
eventFilters = new TQObjectList;
TQ_CHECK_PTR( eventFilters );
}
eventFilters->insert( 0, obj );
connect( obj, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(cleanupEventFilter(TQObject*)) );
}
/*!
Removes an event filter object \a obj from this object. The
request is ignored if such an event filter has not been installed.
All event filters for this object are automatically removed when
this object is destroyed.
It is always safe to remove an event filter, even during event
filter activation (i.e. from the eventFilter() function).
\sa installEventFilter(), eventFilter(), event()
*/
void TQObject::removeEventFilter( const TQObject *obj )
{
if ( eventFilters && eventFilters->removeRef(obj) ) {
if ( eventFilters->isEmpty() ) { // last event filter removed
delete eventFilters;
eventFilters = 0; // reset event filter list
}
disconnect( obj, TQT_SIGNAL(destroyed(TQObject*)),
this, TQT_SLOT(cleanupEventFilter(TQObject*)) );
}
}
/*****************************************************************************
Signal connection management
*****************************************************************************/
#if defined(TQT_CHECK_RANGE)
static bool check_signal_macro( const TQObject *sender, const char *signal,
const char *func, const char *op )
{
int sigcode = (int)(*signal) - '0';
if ( sigcode != TQSIGNAL_CODE ) {
if ( sigcode == TQSLOT_CODE )
qWarning( "TQObject::%s: Attempt to %s non-signal %s::%s",
func, op, sender->className(), signal+1 );
else
qWarning( "TQObject::%s: Use the TQT_SIGNAL macro to %s %s::%s",
func, op, sender->className(), signal );
return FALSE;
}
return TRUE;
}
static bool check_member_code( int code, const TQObject *object,
const char *member, const char *func )
{
if ( code != TQSLOT_CODE && code != TQSIGNAL_CODE ) {
qWarning( "TQObject::%s: Use the TQT_SLOT or TQT_SIGNAL macro to "
"%s %s::%s", func, func, object->className(), member );
return FALSE;
}
return TRUE;
}
static void err_member_notfound( int code, const TQObject *object,
const char *member, const char *func )
{
const char *type = 0;
switch ( code ) {
case TQSLOT_CODE: type = "slot"; break;
case TQSIGNAL_CODE: type = "signal"; break;
}
if ( strchr(member,')') == 0 ) // common typing mistake
qWarning( "TQObject::%s: Parentheses expected, %s %s::%s",
func, type, object->className(), member );
else
qWarning( "TQObject::%s: No such %s %s::%s",
func, type, object->className(), member );
}
static void err_info_about_objects( const char * func,
const TQObject * sender,
const TQObject * receiver )
{
const char * a = sender->name(), * b = receiver->name();
if ( a )
qWarning( "TQObject::%s: (sender name: '%s')", func, a );
if ( b )
qWarning( "TQObject::%s: (receiver name: '%s')", func, b );
}
static void err_info_about_candidates( int code,
const TQMetaObject* mo,
const char* member,
const char *func )
{
if ( strstr(member,"const char*") ) {
// porting help
TQCString newname = member;
int p;
while ( (p=newname.tqfind("const char*")) >= 0 ) {
newname.tqreplace(p, 11, "const TQString&");
}
const TQMetaData *rm = 0;
switch ( code ) {
case TQSLOT_CODE:
rm = mo->slot( mo->tqfindSlot( newname, TRUE ), TRUE );
break;
case TQSIGNAL_CODE:
rm = mo->signal( mo->tqfindSignal( newname, TRUE ), TRUE );
break;
}
if ( rm ) {
qWarning("TQObject::%s: Candidate: %s", func, newname.data());
}
}
}
#endif // TQT_CHECK_RANGE
/*!
Returns a pointer to the object that sent the signal, if called in
a slot activated by a signal; otherwise it returns 0. The pointer
is valid only during the execution of the slot that calls this
function.
The pointer returned by this function becomes invalid if the
sender is destroyed, or if the slot is disconnected from the
sender's signal.
\warning This function violates the object-oriented principle of
modularity. However, getting access to the sender might be useful
when many Q_SIGNALS are connected to a single slot. The sender is
undefined if the slot is called as a normal C++ function.
*/
const TQObject *TQObject::sender()
{
#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
if ( this == qt_preliminary_signal_spy ) {
# ifdef TQT_THREAD_SUPPORT
// protect access to qt_spy_signal_sender
void * const address = &qt_spy_signal_sender;
TQMutexLocker locker( tqt_global_mutexpool ?
tqt_global_mutexpool->get( address ) : 0 );
# endif // TQT_THREAD_SUPPORT
return qt_spy_signal_sender;
}
#endif
if ( senderObjects &&
senderObjects->currentSender &&
/*
* currentSender may be a dangling pointer in case the object
* it was pointing to was destructed from inside a slot. Thus
* verify it still is contained inside the senderObjects list
* which gets cleaned on both destruction and disconnect.
*/
senderObjects->tqfindRef( senderObjects->currentSender ) != -1 )
return senderObjects->currentSender;
return 0;
}
/*!
\fn void TQObject::connectNotify( const char *signal )
This virtual function is called when something has been connected
to \a signal in this object.
\warning This function violates the object-oriented principle of
modularity. However, it might be useful when you need to perform
expensive initialization only if something is connected to a
signal.
\sa connect(), disconnectNotify()
*/
void TQObject::connectNotify( const char * )
{
}
/*!
\fn void TQObject::disconnectNotify( const char *signal )
This virtual function is called when something has been
disconnected from \a signal in this object.
\warning This function violates the object-oriented principle of
modularity. However, it might be useful for optimizing access to
expensive resources.
\sa disconnect(), connectNotify()
*/
void TQObject::disconnectNotify( const char * )
{
}
/*!
\fn bool TQObject::checkConnectArgs( const char *signal, const TQObject *receiver, const char *member )
Returns TRUE if the \a signal and the \a member arguments are
compatible; otherwise returns FALSE. (The \a receiver argument is
currently ignored.)
\warning We recommend that you use the default implementation and
do not reimplement this function.
\omit
TRUE: "signal(<anything>)", "member()"
TRUE: "signal(a,b,c)", "member(a,b,c)"
TRUE: "signal(a,b,c)", "member(a,b)", "member(a)" etc.
FALSE: "signal(const a)", "member(a)"
FALSE: "signal(a)", "member(const a)"
FALSE: "signal(a)", "member(b)"
FALSE: "signal(a)", "member(a,b)"
\endomit
*/
bool TQObject::checkConnectArgs( const char *signal,
const TQObject *,
const char *member )
{
const char *s1 = signal;
const char *s2 = member;
while ( *s1++ != '(' ) { } // scan to first '('
while ( *s2++ != '(' ) { }
if ( *s2 == ')' || qstrcmp(s1,s2) == 0 ) // member has no args or
return TRUE; // exact match
int s1len = tqstrlen(s1);
int s2len = tqstrlen(s2);
if ( s2len < s1len && tqstrncmp(s1,s2,s2len-1)==0 && s1[s2len-1]==',' )
return TRUE; // member has less args
return FALSE;
}
/*!
Normlizes the signal or slot definition \a signalSlot by removing
unnecessary whitespace.
*/
TQCString TQObject::normalizeSignalSlot( const char *signalSlot )
{
if ( !signalSlot )
return TQCString();
return qt_rmWS( signalSlot );
}
/*!
\overload bool TQObject::connect( const TQObject *sender, const char *signal, const char *member ) const
Connects \a signal from the \a sender object to this object's \a
member.
Equivalent to: \c{TQObject::connect(sender, signal, this, member)}.
\sa disconnect()
*/
/*!
Connects \a signal from the \a sender object to \a member in object
\a receiver, and returns TRUE if the connection succeeds; otherwise
returns FALSE.
You must use the TQT_SIGNAL() and TQT_SLOT() macros when specifying the \a signal
and the \a member, for example:
\code
TQLabel *label = new TQLabel;
TQScrollBar *scroll = new TQScrollBar;
TQObject::connect( scroll, TQT_SIGNAL(valueChanged(int)),
label, TQT_SLOT(setNum(int)) );
\endcode
This example ensures that the label always displays the current
scroll bar value. Note that the signal and Q_SLOTS parameters must not
contain any variable names, only the type. E.g. the following would
not work and return FALSE:
TQObject::connect( scroll, TQT_SIGNAL(valueChanged(int v)),
label, TQT_SLOT(setNum(int v)) );
A signal can also be connected to another signal:
\code
class MyWidget : public TQWidget
{
TQ_OBJECT
public:
MyWidget();
Q_SIGNALS:
void myUsefulSignal();
private:
TQPushButton *aButton;
};
MyWidget::MyWidget()
{
aButton = new TQPushButton( this );
connect( aButton, TQT_SIGNAL(clicked()), TQT_SIGNAL(myUsefulSignal()) );
}
\endcode
In this example, the MyWidget constructor relays a signal from a
private member variable, and makes it available under a name that
relates to MyWidget.
A signal can be connected to many Q_SLOTS and Q_SIGNALS. Many Q_SIGNALS
can be connected to one slot.
If a signal is connected to several Q_SLOTS, the Q_SLOTS are activated
in an arbitrary order when the signal is emitted.
The function returns TRUE if it successfully connects the signal
to the slot. It will return FALSE if it cannot create the
connection, for example, if TQObject is unable to verify the
existence of either \a signal or \a member, or if their signatures
aren't compatible.
A signal is emitted for \e{every} connection you make, so if you
duplicate a connection, two Q_SIGNALS will be emitted. You can
always break a connection using \c{disconnect()}.
\sa disconnect()
*/
bool TQObject::connect( const TQObject *sender, const char *signal,
const TQObject *receiver, const char *member )
{
#if defined(TQT_CHECK_NULL)
if ( sender == 0 || receiver == 0 || signal == 0 || member == 0 ) {
qWarning( "TQObject::connect: Cannot connect %s::%s to %s::%s",
sender ? sender->className() : "(null)",
signal ? signal+1 : "(null)",
receiver ? receiver->className() : "(null)",
member ? member+1 : "(null)" );
return FALSE;
}
#endif
TQMetaObject *smeta = sender->tqmetaObject();
#if defined(TQT_CHECK_RANGE)
if ( !check_signal_macro( sender, signal, "connect", "bind" ) )
return FALSE;
#endif
TQCString nw_signal(signal); // Assume already normalized
++signal; // skip member type code
int signal_index = smeta->tqfindSignal( signal, TRUE );
if ( signal_index < 0 ) { // normalize and retry
nw_signal = qt_rmWS( signal-1 ); // remove whitespace
signal = nw_signal.data()+1; // skip member type code
signal_index = smeta->tqfindSignal( signal, TRUE );
}
if ( signal_index < 0 ) { // no such signal
#if defined(TQT_CHECK_RANGE)
err_member_notfound( TQSIGNAL_CODE, sender, signal, "connect" );
err_info_about_candidates( TQSIGNAL_CODE, smeta, signal, "connect" );
err_info_about_objects( "connect", sender, receiver );
#endif
return FALSE;
}
const TQMetaData *sm = smeta->signal( signal_index, TRUE );
signal = sm->name; // use name from meta object
int membcode = member[0] - '0'; // get member code
TQObject *s = (TQObject *)sender; // we need to change them
TQObject *r = (TQObject *)receiver; // internally
#if defined(TQT_CHECK_RANGE)
if ( !check_member_code( membcode, r, member, "connect" ) )
return FALSE;
#endif
member++; // skip code
TQCString nw_member ;
TQMetaObject *rmeta = r->tqmetaObject();
int member_index = -1;
switch ( membcode ) { // get receiver member
case TQSLOT_CODE:
member_index = rmeta->tqfindSlot( member, TRUE );
if ( member_index < 0 ) { // normalize and retry
nw_member = qt_rmWS(member); // remove whitespace
member = nw_member;
member_index = rmeta->tqfindSlot( member, TRUE );
}
break;
case TQSIGNAL_CODE:
member_index = rmeta->tqfindSignal( member, TRUE );
if ( member_index < 0 ) { // normalize and retry
nw_member = qt_rmWS(member); // remove whitespace
member = nw_member;
member_index = rmeta->tqfindSignal( member, TRUE );
}
break;
}
if ( member_index < 0 ) {
#if defined(TQT_CHECK_RANGE)
err_member_notfound( membcode, r, member, "connect" );
err_info_about_candidates( membcode, rmeta, member, "connect" );
err_info_about_objects( "connect", sender, receiver );
#endif
return FALSE;
}
#if defined(TQT_CHECK_RANGE)
if ( !s->checkConnectArgs(signal,receiver,member) ) {
qWarning( "TQObject::connect: Incompatible sender/receiver arguments"
"\n\t%s::%s --> %s::%s",
s->className(), signal,
r->className(), member );
return FALSE;
} else {
const TQMetaData *rm = membcode == TQSLOT_CODE ?
rmeta->slot( member_index, TRUE ) :
rmeta->signal( member_index, TRUE );
if ( rm ) {
int si = 0;
int ri = 0;
while ( si < sm->method->count && ri < rm->method->count ) {
if ( sm->method->parameters[si].inOut == TQUParameter::Out )
si++;
else if ( rm->method->parameters[ri].inOut == TQUParameter::Out )
ri++;
else if ( !TQUType::isEqual( sm->method->parameters[si++].type,
rm->method->parameters[ri++].type ) ) {
if ( ( TQUType::isEqual( sm->method->parameters[si-1].type, &static_TQUType_ptr )
&& TQUType::isEqual( rm->method->parameters[ri-1].type, &static_TQUType_varptr ) )
|| ( TQUType::isEqual( sm->method->parameters[si-1].type, &static_TQUType_varptr )
&& TQUType::isEqual( rm->method->parameters[ri-1].type, &static_TQUType_ptr ) ) )
continue; // varptr got introduced in 3.1 and is binary compatible with ptr
qWarning( "TQObject::connect: Incompatible sender/receiver marshalling"
"\n\t%s::%s --> %s::%s",
s->className(), signal,
r->className(), member );
return FALSE;
}
}
}
}
#endif
connectInternal( sender, signal_index, receiver, membcode, member_index );
s->connectNotify( nw_signal );
return TRUE;
}
/*! \internal */
void TQObject::connectInternal( const TQObject *sender, int signal_index, const TQObject *receiver,
int membcode, int member_index )
{
TQObject *s = (TQObject*)sender;
TQObject *r = (TQObject*)receiver;
if ( !s->connections ) { // create connections lookup table
s->connections = new TQSignalVec( signal_index+1 );
TQ_CHECK_PTR( s->connections );
s->connections->setAutoDelete( TRUE );
}
TQConnectionList *clist = s->connections->at( signal_index );
if ( !clist ) { // create receiver list
clist = new TQConnectionList;
TQ_CHECK_PTR( clist );
clist->setAutoDelete( TRUE );
s->connections->insert( signal_index, clist );
}
TQMetaObject *rmeta = r->tqmetaObject();
const TQMetaData *rm = 0;
switch ( membcode ) { // get receiver member
case TQSLOT_CODE:
rm = rmeta->slot( member_index, TRUE );
break;
case TQSIGNAL_CODE:
rm = rmeta->signal( member_index, TRUE );
break;
}
TQConnection *c = new TQConnection( r, member_index, rm ? rm->name : "qt_invoke", membcode );
TQ_CHECK_PTR( c );
clist->append( c );
if ( !r->senderObjects ) // create list of senders
r->senderObjects = new TQSenderObjectList;
r->senderObjects->append( s ); // add sender to list
}
/*!
\overload bool TQObject::disconnect( const char *signal, const TQObject *receiver, const char *member )
Disconnects \a signal from \a member of \a receiver.
A signal-slot connection is removed when either of the objects
involved are destroyed.
*/
/*!
\overload bool TQObject::disconnect( const TQObject *receiver, const char *member )
Disconnects all Q_SIGNALS in this object from \a receiver's \a
member.
A signal-slot connection is removed when either of the objects
involved are destroyed.
*/
/*!
Disconnects \a signal in object \a sender from \a member in object
\a receiver.
A signal-slot connection is removed when either of the objects
involved are destroyed.
disconnect() is typically used in three ways, as the following
examples demonstrate.
\list 1
\i Disconnect everything connected to an object's Q_SIGNALS:
\code
disconnect( myObject, 0, 0, 0 );
\endcode
equivalent to the non-static overloaded function
\code
myObject->disconnect();
\endcode
\i Disconnect everything connected to a specific signal:
\code
disconnect( myObject, TQT_SIGNAL(mySignal()), 0, 0 );
\endcode
equivalent to the non-static overloaded function
\code
myObject->disconnect( TQT_SIGNAL(mySignal()) );
\endcode
\i Disconnect a specific receiver:
\code
disconnect( myObject, 0, myReceiver, 0 );
\endcode
equivalent to the non-static overloaded function
\code
myObject->disconnect( myReceiver );
\endcode
\endlist
0 may be used as a wildcard, meaning "any signal", "any receiving
object", or "any slot in the receiving object", respectively.
The \a sender may never be 0. (You cannot disconnect Q_SIGNALS from
more than one object in a single call.)
If \a signal is 0, it disconnects \a receiver and \a member from
any signal. If not, only the specified signal is disconnected.
If \a receiver is 0, it disconnects anything connected to \a
signal. If not, Q_SLOTS in objects other than \a receiver are not
disconnected.
If \a member is 0, it disconnects anything that is connected to \a
receiver. If not, only Q_SLOTS named \a member will be disconnected,
and all other Q_SLOTS are left alone. The \a member must be 0 if \a
receiver is left out, so you cannot disconnect a
specifically-named slot on all objects.
\sa connect()
*/
bool TQObject::disconnect( const TQObject *sender, const char *signal,
const TQObject *receiver, const char *member )
{
#if defined(TQT_CHECK_NULL)
if ( sender == 0 || (receiver == 0 && member != 0) ) {
qWarning( "TQObject::disconnect: Unexpected null parameter" );
return FALSE;
}
#endif
if ( !sender->connections ) // no connected Q_SIGNALS
return FALSE;
TQObject *s = (TQObject *)sender;
TQObject *r = (TQObject *)receiver;
int member_index = -1;
int membcode = -1;
TQCString nw_member;
if ( member ) {
membcode = member[0] - '0';
#if defined(TQT_CHECK_RANGE)
if ( !check_member_code( membcode, r, member, "disconnect" ) )
return FALSE;
#endif
++member;
TQMetaObject *rmeta = r->tqmetaObject();
switch ( membcode ) { // get receiver member
case TQSLOT_CODE:
member_index = rmeta->tqfindSlot( member, TRUE );
if ( member_index < 0 ) { // normalize and retry
nw_member = qt_rmWS(member); // remove whitespace
member = nw_member;
member_index = rmeta->tqfindSlot( member, TRUE );
}
break;
case TQSIGNAL_CODE:
member_index = rmeta->tqfindSignal( member, TRUE );
if ( member_index < 0 ) { // normalize and retry
nw_member = qt_rmWS(member); // remove whitespace
member = nw_member;
member_index = rmeta->tqfindSignal( member, TRUE );
}
break;
}
if ( member_index < 0 ) { // no such member
#if defined(TQT_CHECK_RANGE)
err_member_notfound( membcode, r, member, "disconnect" );
err_info_about_candidates( membcode, rmeta, member, "connect" );
err_info_about_objects( "disconnect", sender, receiver );
#endif
return FALSE;
}
}
if ( signal == 0 ) { // any/all Q_SIGNALS
if ( disconnectInternal( s, -1, r, membcode, member_index ) )
s->disconnectNotify( 0 );
else
return FALSE;
} else { // specific signal
#if defined(TQT_CHECK_RANGE)
if ( !check_signal_macro( s, signal, "disconnect", "unbind" ) )
return FALSE;
#endif
TQCString nw_signal(signal); // Assume already normalized
++signal; // skip member type code
TQMetaObject *smeta = s->tqmetaObject();
if ( !smeta ) // no meta object
return FALSE;
int signal_index = smeta->tqfindSignal( signal, TRUE );
if ( signal_index < 0 ) { // normalize and retry
nw_signal = qt_rmWS( signal-1 ); // remove whitespace
signal = nw_signal.data()+1; // skip member type code
signal_index = smeta->tqfindSignal( signal, TRUE );
}
if ( signal_index < 0 ) {
#if defined(TQT_CHECK_RANGE)
qWarning( "TQObject::disconnect: No such signal %s::%s",
s->className(), signal );
#endif
return FALSE;
}
/* compatibility and safety: If a receiver has several Q_SLOTS
* with the same name, disconnect them all*/
bool res = FALSE;
if ( membcode == TQSLOT_CODE && r ) {
TQMetaObject * rmeta = r->tqmetaObject();
do {
int mi = rmeta->tqfindSlot( member );
if ( mi != -1 )
res |= disconnectInternal( s, signal_index, r, membcode, mi );
} while ( (rmeta = rmeta->superClass()) );
} else {
res = disconnectInternal( s, signal_index, r, membcode, member_index );
}
if ( res )
s->disconnectNotify( nw_signal );
return res;
}
return TRUE;
}
/*! \internal */
bool TQObject::disconnectInternal( const TQObject *sender, int signal_index,
const TQObject *receiver, int membcode, int member_index )
{
TQObject *s = (TQObject*)sender;
TQObject *r = (TQObject*)receiver;
if ( !s->connections )
return FALSE;
bool success = FALSE;
TQConnectionList *clist;
register TQConnection *c;
if ( signal_index == -1 ) {
for ( int i = 0; i < (int) s->connections->size(); i++ ) {
clist = (*s->connections)[i]; // for all Q_SIGNALS...
if ( !clist )
continue;
c = clist->first();
while ( c ) { // for all tqreceivers...
if ( r == 0 ) { // remove all tqreceivers
removeObjFromList( c->object()->senderObjects, s );
success = TRUE;
c = clist->next();
} else if ( r == c->object() &&
( member_index == -1 ||
member_index == c->member() && c->memberType() == membcode ) ) {
removeObjFromList( c->object()->senderObjects, s, TRUE );
success = TRUE;
clist->remove();
c = clist->current();
} else {
c = clist->next();
}
}
if ( r == 0 ) // disconnect all tqreceivers
s->connections->insert( i, 0 );
}
} else {
clist = s->connections->at( signal_index );
if ( !clist )
return FALSE;
c = clist->first();
while ( c ) { // for all tqreceivers...
if ( r == 0 ) { // remove all tqreceivers
removeObjFromList( c->object()->senderObjects, s, TRUE );
success = TRUE;
c = clist->next();
} else if ( r == c->object() &&
( member_index == -1 ||
member_index == c->member() && c->memberType() == membcode ) ) {
removeObjFromList( c->object()->senderObjects, s, TRUE );
success = TRUE;
clist->remove();
c = clist->current();
} else {
c = clist->next();
}
}
if ( r == 0 ) // disconnect all tqreceivers
s->connections->insert( signal_index, 0 );
}
return success;
}
/*!
\fn TQObject::destroyed()
This signal is emitted when the object is being destroyed.
Note that the signal is emitted by the TQObject destructor, so
the object's virtual table is already degenerated at this point,
and it is not safe to call any functions on the object emitting
the signal. This signal can not be blocked.
All the objects's tqchildren are destroyed immediately after this
signal is emitted.
*/
/*!
\overload TQObject::destroyed( TQObject* obj)
This signal is emitted immediately before the object \a obj is
destroyed, and can not be blocked.
All the objects's tqchildren are destroyed immediately after this
signal is emitted.
*/
/*!
Performs a deferred deletion of this object.
Instead of an immediate deletion this function schedules a
deferred delete event for processing when TQt returns to the main
event loop.
*/
void TQObject::deleteLater()
{
TQApplication::postEvent( this, new TQEvent( TQEvent::DeferredDelete) );
}
/*!
This slot is connected to the destroyed() signal of other objects
that have installed event filters on this object. When the other
object, \a obj, is destroyed, we want to remove its event filter.
*/
void TQObject::cleanupEventFilter(TQObject* obj)
{
removeEventFilter( obj );
}
/*!
\fn TQString TQObject::tr( const char *sourceText, const char * comment )
\reentrant
Returns a translated version of \a sourceText, or \a sourceText
itself if there is no appropriate translated version. The
translation context is TQObject with \a comment (0 by default).
All TQObject subclasses using the TQ_OBJECT macro automatically have
a reimplementation of this function with the subclass name as
context.
\warning This method is reentrant only if all translators are
installed \e before calling this method. Installing or removing
translators while performing translations is not supported. Doing
so will probably result in crashes or other undesirable behavior.
\sa trUtf8() TQApplication::translate()
\link i18n.html Internationalization with TQt\endlink
*/
/*!
\fn TQString TQObject::trUtf8( const char *sourceText,
const char *comment )
\reentrant
Returns a translated version of \a sourceText, or
TQString::fromUtf8(\a sourceText) if there is no appropriate
version. It is otherwise identical to tr(\a sourceText, \a
comment).
\warning This method is reentrant only if all translators are
installed \e before calling this method. Installing or removing
translators while performing translations is not supported. Doing
so will probably result in crashes or other undesirable behavior.
\sa tr() TQApplication::translate()
*/
static TQMetaObjectCleanUp cleanUp_TQt = TQMetaObjectCleanUp( "TQObject", &TQObject::staticMetaObject );
TQMetaObject* TQObject::staticTQtMetaObject()
{
static TQMetaObject* qtMetaObject = 0;
if ( qtMetaObject )
return qtMetaObject;
#ifndef TQT_NO_PROPERTIES
static const TQMetaEnum::Item enum_0[] = {
{ "AlignLeft", (int) TQt::AlignLeft },
{ "AlignRight", (int) TQt::AlignRight },
{ "AlignHCenter", (int) TQt::AlignHCenter },
{ "AlignTop", (int) TQt::AlignTop },
{ "AlignBottom", (int) TQt::AlignBottom },
{ "AlignVCenter", (int) TQt::AlignVCenter },
{ "AlignCenter", (int) TQt::AlignCenter },
{ "AlignAuto", (int) TQt::AlignAuto },
{ "AlignJustify", (int) TQt::AlignJustify },
{ "WordBreak", (int) TQt::WordBreak }
};
static const TQMetaEnum::Item enum_1[] = {
{ "Horizontal", (int) Qt::Horizontal },
{ "Vertical", (int) Qt::Vertical }
};
static const TQMetaEnum::Item enum_2[] = {
{ "PlainText", (int) TQt::PlainText },
{ "RichText", (int) TQt::RichText },
{ "AutoText", (int) TQt::AutoText },
{ "LogText", (int) TQt::LogText }
};
static const TQMetaEnum::Item enum_3[] = {
{ "NoBackground", (int) TQt::NoBackground },
{ "PaletteForeground", (int) TQt::PaletteForeground },
{ "PaletteButton", (int) TQt::PaletteButton },
{ "PaletteLight", (int) TQt::PaletteLight },
{ "PaletteMidlight", (int) TQt::PaletteMidlight },
{ "PaletteDark", (int) TQt::PaletteDark },
{ "PaletteMid", (int) TQt::PaletteMid },
{ "PaletteText", (int) TQt::PaletteText },
{ "PaletteBrightText", (int) TQt::PaletteBrightText },
{ "PaletteBase", (int) TQt::PaletteBase },
{ "PaletteBackground", (int) TQt::PaletteBackground },
{ "PaletteShadow", (int) TQt::PaletteShadow },
{ "PaletteHighlight", (int) TQt::PaletteHighlight },
{ "PaletteHighlightedText", (int) TQt::PaletteHighlightedText },
{ "PaletteButtonText", (int) TQt::PaletteButtonText },
{ "PaletteLink", (int) TQt::PaletteLink },
{ "PaletteLinkVisited", (int) TQt::PaletteLinkVisited }
};
static const TQMetaEnum::Item enum_4[] = {
{ "TextDate", (int) TQt::TextDate },
{ "ISODate", (int) TQt::ISODate },
{ "LocalDate", (int) TQt::LocalDate }
};
static const TQMetaEnum enum_tbl[] = {
{ "Alignment", 10, enum_0, TRUE },
{ "Orientation", 2, enum_1, FALSE },
{ "TextFormat", 4, enum_2, FALSE },
{ "BackgroundMode", 17, enum_3, FALSE },
{ "DateFormat", 3, enum_4, FALSE }
};
#endif
qtMetaObject = new TQMetaObject( "TQt", 0,
0, 0,
0, 0,
#ifndef TQT_NO_PROPERTIES
0, 0,
enum_tbl, 5,
#endif
0, 0 );
cleanUp_TQt.setMetaObject( qtMetaObject );
return qtMetaObject;
}
/*!
\internal
Signal activation with the most frequently used parameter/argument
types. All other combinations are generated by the meta object
compiler.
*/
void TQObject::activate_signal( int signal )
{
#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
if ( qt_preliminary_signal_spy ) {
if ( !tqsignalsBlocked() && signal >= 0 &&
( !connections || !connections->at( signal ) ) ) {
TQUObject o[1];
qt_spy_signal( this, signal, o );
return;
}
}
#endif
if ( !connections || tqsignalsBlocked() || signal < 0 )
return;
TQConnectionList *clist = connections->at( signal );
if ( !clist )
return;
TQUObject o[1];
activate_signal( clist, o );
}
/*! \internal */
void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
{
if ( !clist )
return;
#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
if ( qt_preliminary_signal_spy )
qt_spy_signal( this, connections->tqfindRef( clist), o );
#endif
TQObject *object;
TQSenderObjectList* sol;
TQObject* oldSender = 0;
TQConnection *c;
if ( clist->count() == 1 ) { // save iterator
c = clist->first();
object = c->object();
sol = object->senderObjects;
if ( sol ) {
oldSender = sol->currentSender;
sol->ref();
sol->currentSender = this;
}
if ( c->memberType() == TQSIGNAL_CODE )
object->qt_emit( c->member(), o );
else
object->qt_invoke( c->member(), o );
if ( sol ) {
sol->currentSender = oldSender;
if ( sol->deref() )
delete sol;
}
} else {
TQConnection *cd = 0;
TQConnectionListIt it(*clist);
while ( (c=it.current()) ) {
++it;
if ( c == cd )
continue;
cd = c;
object = c->object();
sol = object->senderObjects;
if ( sol ) {
oldSender = sol->currentSender;
sol->ref();
sol->currentSender = this;
}
if ( c->memberType() == TQSIGNAL_CODE )
object->qt_emit( c->member(), o );
else
object->qt_invoke( c->member(), o );
if (sol ) {
sol->currentSender = oldSender;
if ( sol->deref() )
delete sol;
}
}
}
}
/*!
\overload void TQObject::activate_signal( int signal, int )
*/
/*!
\overload void TQObject::activate_signal( int signal, double )
*/
/*!
\overload void TQObject::activate_signal( int signal, TQString )
*/
/*!
\fn void TQObject::activate_signal_bool( int signal, bool )
\internal
Like the above functions, but since bool is sometimes
only a typedef it cannot be a simple overload.
*/
#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY
#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \
void TQObject::FNAME( int signal, TYPE param ) \
{ \
if ( qt_preliminary_signal_spy ) { \
if ( !tqsignalsBlocked() && signal >= 0 && \
( !connections || !connections->at( signal ) ) ) { \
TQUObject o[2]; \
static_TQUType_##TYPE.set( o+1, param ); \
qt_spy_signal( this, signal, o ); \
return; \
} \
} \
if ( !connections || tqsignalsBlocked() || signal < 0 ) \
return; \
TQConnectionList *clist = connections->at( signal ); \
if ( !clist ) \
return; \
TQUObject o[2]; \
static_TQUType_##TYPE.set( o+1, param ); \
activate_signal( clist, o ); \
}
#else
#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \
void TQObject::FNAME( int signal, TYPE param ) \
{ \
if ( !connections || tqsignalsBlocked() || signal < 0 ) \
return; \
TQConnectionList *clist = connections->at( signal ); \
if ( !clist ) \
return; \
TQUObject o[2]; \
static_TQUType_##TYPE.set( o+1, param ); \
activate_signal( clist, o ); \
}
#endif
// We don't want to duplicate too much text so...
ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, int )
ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, double )
ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, TQString )
ACTIVATE_SIGNAL_WITH_PARAM( activate_signal_bool, bool )
/*****************************************************************************
TQObject debugging output routines.
*****************************************************************************/
static void dumpRecursive( int level, TQObject *object )
{
#if defined(TQT_DEBUG)
if ( object ) {
TQString buf;
buf.fill( '\t', level/2 );
if ( level % 2 )
buf += " ";
const char *name = object->name();
TQString flags="";
if ( tqApp->tqfocusWidget() == object )
flags += 'F';
if ( object->isWidgetType() ) {
TQWidget * w = (TQWidget *)object;
if ( w->isVisible() ) {
TQString t( "<%1,%2,%3,%4>" );
flags += t.arg(w->x()).arg(w->y()).arg(w->width()).arg(w->height());
} else {
flags += 'I';
}
}
qDebug( "%s%s::%s %s", (const char*)buf, object->className(), name,
flags.latin1() );
if ( !object->childrenListObject().isEmpty() ) {
TQObjectListIt it(object->childrenListObject());
TQObject * c;
while ( (c=it.current()) != 0 ) {
++it;
dumpRecursive( level+1, c );
}
}
}
#else
TQ_UNUSED( level )
TQ_UNUSED( object )
#endif
}
/*!
Dumps a tree of tqchildren to the debug output.
This function is useful for debugging, but does nothing if the
library has been compiled in release mode (i.e. without debugging
information).
*/
void TQObject::dumpObjectTree()
{
dumpRecursive( 0, this );
}
/*!
Dumps information about signal connections, etc. for this object
to the debug output.
This function is useful for debugging, but does nothing if the
library has been compiled in release mode (i.e. without debugging
information).
*/
void TQObject::dumpObjectInfo()
{
#if defined(TQT_DEBUG)
qDebug( "OBJECT %s::%s", className(), name( "unnamed" ) );
int n = 0;
qDebug( " SIGNALS OUT" );
if ( connections ) {
TQConnectionList *clist;
for ( uint i = 0; i < connections->size(); i++ ) {
if ( ( clist = connections->at( i ) ) ) {
qDebug( "\t%s", tqmetaObject()->signal( i, TRUE )->name );
n++;
register TQConnection *c;
TQConnectionListIt cit(*clist);
while ( (c=cit.current()) ) {
++cit;
qDebug( "\t --> %s::%s %s", c->object()->className(),
c->object()->name( "unnamed" ), c->memberName() );
}
}
}
}
if ( n == 0 )
qDebug( "\t<None>" );
qDebug( " SIGNALS IN" );
n = 0;
if ( senderObjects ) {
TQObject *sender = senderObjects->first();
while ( sender ) {
qDebug( "\t%s::%s",
sender->className(), sender->name( "unnamed" ) );
n++;
sender = senderObjects->next();
}
}
if ( n == 0 )
qDebug( "\t<None>" );
#endif
}
#ifndef TQT_NO_PROPERTIES
/*!
Sets the value of the object's \a name property to \a value.
Returns TRUE if the operation was successful; otherwise returns
FALSE.
Information about all available properties is provided through the
tqmetaObject().
\sa property(), tqmetaObject(), TQMetaObject::propertyNames(), TQMetaObject::property()
*/
bool TQObject::setProperty( const char *name, const TQVariant& value )
{
if ( !value.isValid() )
return FALSE;
TQVariant v = value;
TQMetaObject* meta = tqmetaObject();
if ( !meta )
return FALSE;
int id = meta->tqfindProperty( name, TRUE );
const TQMetaProperty* p = meta->property( id, TRUE );
if ( !p || !p->isValid() || !p->writable() ) {
qWarning( "%s::setProperty( \"%s\", value ) failed: property invalid, read-only or does not exist",
className(), name );
return FALSE;
}
if ( p->isEnumType() ) {
if ( v.type() == TQVariant::String || v.type() == TQVariant::CString ) {
if ( p->isSetType() ) {
TQString s = value.toString();
// TQStrList does not support split, use TQStringList for that.
TQStringList l = TQStringList::split( '|', s );
TQStrList keys;
for ( TQStringList::Iterator it = l.begin(); it != l.end(); ++it )
keys.append( (*it).stripWhiteSpace().latin1() );
v = TQVariant( p->keysToValue( keys ) );
} else {
v = TQVariant( p->keyToValue( value.toCString().data() ) );
}
} else if ( v.type() != TQVariant::Int && v.type() != TQVariant::UInt ) {
return FALSE;
}
return qt_property( id, 0, &v );
}
TQVariant::Type type = (TQVariant::Type)(p->flags >> 24);
if ( type == TQVariant::Invalid )
type = TQVariant::nameToType( p->type() );
if ( type != TQVariant::Invalid && !v.canCast( type ) )
return FALSE;
return qt_property( id, 0, &v );
}
/*!
Returns the value of the object's \a name property.
If no such property exists, the returned variant is invalid.
Information about all available properties are provided through
the tqmetaObject().
\sa setProperty(), TQVariant::isValid(), tqmetaObject(),
TQMetaObject::propertyNames(), TQMetaObject::property()
*/
TQVariant TQObject::property( const char *name ) const
{
TQVariant v;
TQMetaObject* meta = tqmetaObject();
if ( !meta )
return v;
int id = meta->tqfindProperty( name, TRUE );
const TQMetaProperty* p = meta->property( id, TRUE );
if ( !p || !p->isValid() ) {
qWarning( "%s::property( \"%s\" ) failed: property invalid or does not exist",
className(), name );
return v;
}
TQObject* that = (TQObject*) this; // tqmoc ensures constness for the qt_property call
that->qt_property( id, 1, &v );
return v;
}
#endif // TQT_NO_PROPERTIES
#ifndef TQT_NO_USERDATA
/*!\internal
*/
uint TQObject::registerUserData()
{
static int user_data_registration = 0;
return user_data_registration++;
}
/*!\internal
*/
TQObjectUserData::~TQObjectUserData()
{
}
/*!\internal
*/
void TQObject::setUserData( uint id, TQObjectUserData* data)
{
if ( !d )
d = new TQObjectPrivate( id+1 );
if ( id >= d->size() )
d->resize( id+1 );
d->insert( id, data );
}
/*!\internal
*/
TQObjectUserData* TQObject::userData( uint id ) const
{
if ( d && id < d->size() )
return d->at( id );
return 0;
}
#endif // TQT_NO_USERDATA
#endif // USE_QT4
|