Menu

[2179ca]: / mainwindow.cpp  Maximize  Restore  History

Download this file

4554 lines (3909 with data), 141.5 kB

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
#include "mainwindow.h"
#include <QtGui>
#include <iostream>
#include <typeinfo>
#include "aboutdialog.h"
#include "branchpropwindow.h"
#include "branchitem.h"
#include "exportoofiledialog.h"
#include "exports.h"
#include "file.h"
#include "findresultwidget.h"
#include "flagrow.h"
#include "headingeditor.h"
#include "historywindow.h"
#include "imports.h"
#include "mapeditor.h"
#include "misc.h"
#include "options.h"
#include "process.h"
#include "settings.h"
#include "shortcuts.h"
#include "noteeditor.h"
#include "treeeditor.h"
#include "warningdialog.h"
#include "xlinkitem.h"
QPrinter *printer;
//#include <modeltest.h>
#if defined(Q_OS_WIN32)
// Define only this structure as opposed to
// including full 'windows.h'. FindWindow
// clashes with the one in Win32 API.
typedef struct _PROCESS_INFORMATION
{
long hProcess;
long hThread;
long dwProcessId;
long dwThreadId;
} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
#endif
extern NoteEditor *noteEditor;
extern HeadingEditor *headingEditor;
extern Main *mainWindow;
extern FindResultWidget *findResultWidget;
extern QString tmpVymDir;
extern QString clipboardDir;
extern QString clipboardFile;
extern bool clipboardEmpty;
extern int statusbarTime;
extern FlagRow *standardFlagsMaster;
extern FlagRow *systemFlagsMaster;
extern QString vymName;
extern QString vymVersion;
extern QString vymBuildDate;
extern bool debug;
extern bool bugzillaClientAvailable;
QMenu* targetsContextMenu;
QMenu* branchContextMenu;
QMenu* branchAddContextMenu;
QMenu* branchRemoveContextMenu;
QMenu* branchLinksContextMenu;
QMenu* branchXLinksContextMenuEdit;
QMenu* branchXLinksContextMenuFollow;
QMenu* floatimageContextMenu;
QMenu* canvasContextMenu;
QMenu* fileLastMapsMenu;
QMenu* fileImportMenu;
QMenu* fileExportMenu;
extern Settings settings;
extern Options options;
extern ImageIO imageIO;
extern QDir vymBaseDir;
extern QDir lastImageDir;
extern QDir lastMapDir;
#if defined(Q_OS_WIN32)
extern QDir vymInstallDir;
#endif
extern QString iconPath;
extern QString flagsPath;
Main::Main(QWidget* parent, Qt::WFlags f) : QMainWindow(parent,f)
{
mainWindow=this;
setWindowTitle ("VYM - View Your Mind");
// Load window settings
#if defined(Q_OS_WIN32)
if (settings.value("/mainwindow/geometry/maximized", false).toBool())
{
setWindowState(Qt::WindowMaximized);
}
else
#endif
{
resize (settings.value("/mainwindow/geometry/size", QSize (1024,900)).toSize());
move (settings.value("/mainwindow/geometry/pos", QPoint(50,50)).toPoint());
}
// Sometimes we may need to remember old selections
prevSelection="";
// Default color
currentColor=Qt::black;
// Create unique temporary directory
bool ok;
tmpVymDir=makeTmpDir (ok,"vym");
if (!ok)
{
qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
exit (1);
}
if (debug) qDebug ()<<"tmpDir="<<tmpVymDir;
// Create direcctory for clipboard
clipboardDir=tmpVymDir+"/clipboard";
clipboardFile="map.xml";
QDir d(clipboardDir);
d.mkdir (clipboardDir);
makeSubDirs (clipboardDir);
clipboardEmpty=true;
// Remember PID of our friendly webbrowser
browserPID=new qint64;
*browserPID=0;
// Dock widgets ///////////////////////////////////////////////
QDockWidget *dw;
if (settings.value("/satellite/noteeditor/isDockWindow",true).toBool())
{
dw = new QDockWidget (tr("Note Editor"),this);
dw->setWidget (noteEditor);
dw->setObjectName ("NoteEditor");
dw->hide();
noteEditorDW=dw;
addDockWidget (Qt::LeftDockWidgetArea,dw);
} else
noteEditorDW=NULL;
dw = new QDockWidget (tr("Heading Editor"),this);
dw->setWidget (headingEditor);
dw->setObjectName ("HeadingEditor");
dw->hide();
headingEditorDW=dw;
addDockWidget (Qt::BottomDockWidgetArea,dw);
findResultWidget=new FindResultWidget ();
dw= new QDockWidget (tr ("Search results list","FindResultWidget"),this);
dw->setWidget (findResultWidget);
dw->setObjectName ("FindResultWidget");
dw->hide();
addDockWidget (Qt::RightDockWidgetArea,dw);
connect (
findResultWidget, SIGNAL (noteSelected (QString, int)),
this, SLOT (selectInNoteEditor (QString, int)));
connect (
findResultWidget, SIGNAL (findPressed (QString) ),
this, SLOT (editFindNext(QString) ) );
// Satellite windows //////////////////////////////////////////
// history window
historyWindow=new HistoryWindow();
connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
// properties window
branchPropertyWindow = new BranchPropertyWindow();
branchPropertyWindow->hide();
connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
// Connect NoteEditor, so that we can update flags if text changes
connect (noteEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
connect (noteEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
// Connect heading editor
connect (headingEditor, SIGNAL (textHasChanged() ), this, SLOT (updateHeading()));
// Initialize script editor
scriptEditor = new SimpleScriptEditor();
scriptEditor->move (50,50);
connect( scriptEditor, SIGNAL( runScript ( QString ) ),
this, SLOT( runScript( QString ) ) );
// Initialize some settings, which are platform dependant
QString p,s;
// application to open URLs
p="/mainwindow/readerURL";
#if defined(Q_OS_LINUX)
s=settings.value (p,"xdg-open").toString();
#else
#if defined(Q_OS_MACX)
s=settings.value (p,"/usr/bin/open").toString();
#else
#if defined(Q_OS_WIN32)
// Assume that system has been set up so that
// Explorer automagically opens up the URL
// in the user's preferred browser.
s=settings.value (p,"explorer").toString();
#else
s=settings.value (p,"mozilla").toString();
#endif
#endif
#endif
settings.setValue( p,s);
// application to open PDFs
p="/mainwindow/readerPDF";
#if defined(Q_OS_LINUX)
s=settings.value (p,"xdg-open").toString();
#else
#if defined(Q_OS_MACX)
s=settings.value (p,"/usr/bin/open").toString();
#elif defined(Q_OS_WIN32)
s=settings.value (p,"acrord32").toString();
#else
s=settings.value (p,"acroread").toString();
#endif
#endif
settings.setValue( p,s);
// width of xLinksMenu
xLinkMenuWidth=60;
// Create Layout
QWidget* centralWidget = new QWidget (this);
QVBoxLayout *layout=new QVBoxLayout (centralWidget);
setCentralWidget(centralWidget);
// Create tab widget which holds the maps
tabWidget= new QTabWidget (centralWidget);
connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
this, SLOT( editorChanged( QWidget * ) ) );
layout->addWidget (tabWidget);
setupFileActions();
setupEditActions();
setupSelectActions();
setupFormatActions();
setupViewActions();
setupModeActions();
setupNetworkActions();
setupSettingsActions();
setupContextMenus();
setupMacros();
setupToolbars();
setupFlagActions();
if (options.isOn("shortcuts")) switchboard.print();
if (options.isOn("shortcutsLaTeX")) switchboard.printLaTeX();
if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
setupHelpActions();
// Status bar and progress bar there
statusBar();
progressMax=0;
progressCounter=0;
progressCounterTotal=0;
progressDialog.setAutoReset(false);
progressDialog.setAutoClose(false);
progressDialog.setMinimumWidth (600);
//progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down
progressDialog.setCancelButton (NULL);
restoreState (settings.value("/mainwindow/state",0).toByteArray());
// Global Printer
printer=new QPrinter (QPrinter::HighResolution );
updateGeometry();
}
Main::~Main()
{
// Save Settings
#if defined(Q_OS_WIN32)
settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
#endif
settings.setValue ("/mainwindow/geometry/size", size());
settings.setValue ("/mainwindow/geometry/pos", pos());
settings.setValue ("/mainwindow/state",saveState(0));
settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isChecked());
settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isChecked());
settings.setValue( "/version/version", vymVersion );
settings.setValue( "/version/builddate", vymBuildDate );
settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isChecked() );
settings.setValue ("/mainwindow/autosave/ms", settings.value("/mainwindow/autosave/ms",60000));
settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutoLayoutToggle->isChecked() );
settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isChecked() );
settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isChecked() );
settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isChecked() );
settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isChecked() );
settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isChecked() );
settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isChecked() );
settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isChecked() );
settings.setValue( "/satellite/noteeditor/isDockWindow",actionSettingsNoteEditorIsDockWindow->isChecked());
//FIXME-4 save scriptEditor settings
// call the destructors
delete noteEditor; // FIXME-3 shouldn't this be done in main?
delete historyWindow;
delete branchPropertyWindow;
// Remove temporary directory
removeDir (QDir(tmpVymDir));
}
void Main::loadCmdLine()
{
QStringList flist=options.getFileList();
QStringList::Iterator it=flist.begin();
initProgressCounter (flist.count());
while (it !=flist.end() )
{
fileLoad (*it, NewMap);
*it++;
}
removeProgressCounter();
}
void Main::statusMessage(const QString &s)
{
// Surpress messages while progressdialog during
// load is active
//if (progressMax==0) //FIXME-3 needed?
statusBar()->showMessage( s,statusbarTime);
}
void Main::setProgressMaximum (int max) {
if (progressCounter==0)
{
// Init range only on first time, when progressCounter still 0
// Normalize range to 1000
progressDialog.setRange (0,1000);
progressDialog.setValue (0);
}
progressCounter++; // Another map is loaded
progressMax=max*1000;
//cout << "Main max="<<max<<" v="<<progressDialog.value()<<endl;
if (!options.isOn("batch"))
progressDialog.show();
else
progressDialog.hide();
}
void Main::addProgressValue (float v)
{
/*
cout << "addVal v="<<v
<<" cur="<<progressDialog.value()
<<" pCounter="<<progressCounter
<<" pCounterTotal="<<progressCounterTotal
<<endl;
*/
if (!options.isOn("batch"))
progressDialog.show();
else
progressDialog.hide();
progressDialog.setValue ( (v + progressCounter -1)*1000/progressCounterTotal );
progressDialog.repaint();
}
void Main::initProgressCounter(uint n)
{
progressCounterTotal=n;
}
void Main::removeProgressCounter()
{
// Hide dialog again
progressCounter=0;
progressCounterTotal=0;
progressDialog.reset();
progressDialog.hide();
}
void Main::closeEvent (QCloseEvent* event)
{
if (fileExitVYM())
event->ignore();
else
event->accept();
}
// File Actions
void Main::setupFileActions()
{
QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map","Toolbar for file actions") );
QAction *a;
a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
switchboard.addConnection(fileMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
actionFileNew=a;
a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
switchboard.addConnection(fileMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
actionFileNewCopy=a;
a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
a->setShortcut ( Qt::CTRL + Qt::Key_L ); //Open map
switchboard.addConnection(fileMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
actionFileOpen=a;
a = new QAction( tr( "&Restore last session" ,"File menu"),this);
switchboard.addConnection(fileMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileRestoreSession() ) );
fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
fileMenu->addSeparator();
a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
switchboard.addConnection(fileMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
actionFileSave=a;
a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
switchboard.addConnection(fileMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
fileMenu->addSeparator();
fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
a = new QAction(tr("KDE 3 Bookmarks","Import filters"), this);
switchboard.addConnection(fileImportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
a = new QAction(tr("KDE 4 Bookmarks","Import filters"), this);
switchboard.addConnection(fileImportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
if (settings.value( "/mainwindow/showTestMenu",false).toBool())
{
a = new QAction( QPixmap(), tr("Firefox Bookmarks","Import filters"),this);
switchboard.addConnection(fileImportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
}
a = new QAction("Freemind...",this);
switchboard.addConnection(fileImportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
a = new QAction("Mind Manager...",this);
switchboard.addConnection(fileImportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
a = new QAction( tr( "Import Dir%1","Import Filters").arg("... (experimental)"), this);
switchboard.addConnection(fileImportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
a = new QAction( QPixmap(iconPath+"file-document-export.png"),tr("Repeat last export (%1)").arg("-"), this);
a->setShortcut (Qt::ALT + Qt::Key_E);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLast() ) );
actionFileExportLast=a;
a = new QAction( tr("Image%1","File export menu").arg("..."), this);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
a = new QAction( tr("PDF%1","File export menu").arg("..."), this);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportPDF() ) );
a = new QAction( tr("SVG%1","File export menu").arg("..."), this);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportSVG() ) );
a = new QAction( "Open Office...", this);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
a = new QAction( "Webpage (HTML)...",this );
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
a = new QAction( "Text (A&O report)... (experimental)", this);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
a = new QAction( "Text (ASCII)...", this);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
a = new QAction( "Spreadsheet (CSV)... (experimental)", this);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
a = new QAction( "Taskjuggler... (experimental)", this );
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
a = new QAction( "LaTeX... (experimental)", this);
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
a = new QAction( "XML..." , this );
switchboard.addConnection(fileExportMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
fileMenu->addSeparator();
a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
switchboard.addConnection(fileMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
actionFilePrint=a;
a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
switchboard.addConnection(fileMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
switchboard.addConnection(fileMenu, a,tr("File","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
}
//Edit Actions
void Main::setupEditActions()
{
QMenu *editMenu = menuBar()->addMenu( tr("E&dit","Edit menu") );
QAction *a;
a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
a->setEnabled (false);
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
actionUndo=a;
a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
actionRedo=a;
editMenu->addSeparator();
a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
a->setEnabled (false);
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
actionCopy=a;
a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
a->setEnabled (false);
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
actionCut=a;
connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
a->setEnabled (false);
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
actionPaste=a;
// Shortcut to delete selection
a = new QAction( tr( "Delete Selection","Edit menu" ),this);
a->setShortcut ( Qt::Key_Delete); //Delete selection
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
actionDelete=a;
// Shortcut to add attribute
a= new QAction(tr( "Add attribute" ), this);
if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
{
a->setShortcut ( Qt::Key_Q);
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
}
addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
actionAddAttribute= a;
// Shortcut to add mapcenter
a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
a->setShortcut ( Qt::Key_C);
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
//actionListBranches.append(a);
actionAddMapCenter = a;
// Shortcut to add branch
a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
a->setShortcut (Qt::Key_A); //Add branch
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
actionListBranches.append(a);
actionAddBranch=a;
// Add branch by inserting it at selection
a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
actionListBranches.append(a);
actionAddBranchBefore=a;
// Add branch above
a = new QAction(tr( "Add branch above","Edit menu" ), this);
a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
a->setEnabled (false);
actionListBranches.append(a);
actionAddBranchAbove=a;
a = new QAction(tr( "Add branch above","Edit menu" ), this);
a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
actionListBranches.append(a);
// Add branch below
a = new QAction(tr( "Add branch below","Edit menu" ), this);
a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
a->setEnabled (false);
actionListBranches.append(a);
actionAddBranchBelow=a;
a = new QAction(tr( "Add branch below","Edit menu" ), this);
a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
actionListBranches.append(a);
a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
a->setShortcut (Qt::Key_PageUp ); // Move branch up
a->setShortcutContext (Qt::WidgetShortcut);
a->setEnabled (false);
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
actionMoveUp=a;
a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
a->setShortcut ( Qt::Key_PageDown ); // Move branch down
a->setShortcutContext (Qt::WidgetShortcut);
a->setEnabled (false);
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
actionMoveDown=a;
a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
a->setShortcut ( Qt::Key_D ); // Detach branch
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
actionDetach=a;
a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
a->setEnabled (true);
a->setShortcut ( Qt::Key_O ); // Sort children
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
actionSortChildren=a;
a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
a->setEnabled (true);
a->setShortcut ( Qt::SHIFT + Qt::Key_O ); // Reverse sort children
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
actionSortBackChildren=a;
a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
a->setShortcut ( Qt::Key_S ); // Scroll branch
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
a->setEnabled (false);
a->setCheckable(true);
actionToggleScroll=a;
addAction (a);
actionListBranches.append(actionToggleScroll);
a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
actionExpandAll=a;
actionExpandAll->setEnabled (false);
actionExpandAll->setCheckable(false);
addAction (a);
actionListBranches.append(actionExpandAll);
a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
a->setEnabled (false);
a->setCheckable(false);
actionExpandOneLevel=a;
addAction (a);
actionListBranches.append(a);
a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
a->setShortcut ( Qt::Key_Less + Qt::CTRL); // Collapse one level in tree editor
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
a->setEnabled (false);
a->setCheckable(false);
actionCollapseOneLevel=a;
addAction (a);
actionListBranches.append(a);
a = new QAction( QPixmap(), tr( "Collapse unselected levels","Edit menu" ), this);
a->setShortcut ( Qt::Key_Less); // Collapse all branches with greater depth than current selection
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseUnselected() ) );
a->setEnabled (false);
a->setCheckable(false);
actionCollapseUnselected=a;
addAction (a);
actionListBranches.append(a);
a = new QAction( tr( "Unscroll children","Edit menu" ), this);
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
a = new QAction( tr( "Grow selection","Edit menu" ), this);
a->setShortcut ( Qt::CTRL + Qt::Key_Plus); // Grow selection
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editGrowSelectionSize() ) );
a = new QAction( tr( "Shrink selection","Edit menu" ), this);
a->setShortcut ( Qt::CTRL + Qt::Key_Minus); // Shrink selection
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editShrinkSelectionSize() ) );
a = new QAction( tr( "Reset selection size","Edit menu" ), this);
a->setShortcut ( Qt::CTRL + Qt::Key_0); // Shrink selection
switchboard.addConnection(editMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editResetSelectionSize() ) );
editMenu->addSeparator();
a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
a->setShortcut (Qt::SHIFT + Qt::Key_U );
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
actionOpenURL=a;
a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
//a->setShortcut (Qt::CTRL+Qt::Key_U );
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
actionOpenURLTab=a;
a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
a->setShortcut ( Qt::CTRL + Qt::Key_U );
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction(a);
actionListBranches.append(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
actionOpenMultipleVisURLTabs=a;
a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction(a);
actionListBranches.append(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
actionOpenMultipleURLTabs=a;
a = new QAction(QPixmap(), tr( "Extract URLs from note","Edit menu"), this);
a->setShortcut ( Qt::SHIFT + Qt::Key_N );
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
actionListBranches.append(a);
addAction(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editNote2URLs() ) );
actionGetURLsFromNote=a;
a = new QAction(QPixmap(flagsPath+"flag-url.png"), tr( "Edit URL...","Edit menu"), this);
a->setShortcut ( Qt::Key_U );
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
actionListBranches.append(a);
addAction(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
actionURLNew=a;
a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
//a->setShortcut (Qt::SHIFT + Qt::Key_U );
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
actionListBranches.append(a);
addAction(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
actionLocalURL=a;
a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
a->setShortcut ( Qt::ALT + Qt::Key_U );
a->setShortcutContext (Qt::ApplicationShortcut);
a->setEnabled (false);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
actionListBranches.append(a);
addAction(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
actionHeading2URL=a;
a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
a->setEnabled (false);
actionListBranches.append(a);
a->setShortcut ( Qt::Key_B );
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
actionBugzilla2URL=a;
a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
a->setShortcut ( Qt::Key_B + Qt::SHIFT);
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction(a);
connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
actionGetBugzillaData=a;
a = new QAction(tr( "Get data from Novell Bugzilla for subtree","Edit menu" ), this);
a->setShortcut ( Qt::Key_B + Qt::CTRL);
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction(a);
connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaDataSubtree() ) );
actionGetBugzillaDataSubtree=a;
a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
a->setEnabled (false);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
actionListBranches.append(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
actionFATE2URL=a;
a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
a->setEnabled (false);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
actionOpenVymLink=a;
a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
a->setEnabled (false);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
actionListBranches.append(a);
connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
actionOpenMultipleVymLinks=a;
a = new QAction(QPixmap(flagsPath+"flag-vymlinknew.png"), tr( "Edit vym link...","Edit menu" ), this);
a->setEnabled (false);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
actionListBranches.append(a);
actionEditVymLink=a;
a = new QAction(tr( "Delete vym link","Edit menu" ),this);
a->setEnabled (false);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
actionDeleteVymLink=a;
a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
a->setShortcut (Qt::Key_H );
a->setShortcutContext (Qt::WindowShortcut);
a->setCheckable(true);
a->setEnabled (false);
switchboard.addConnection(this, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
actionToggleHideExport=a;
a = new QAction(tr( "Add timestamp","Edit menu" ), this);
a->setEnabled (false);
actionListBranches.append(a);
a->setShortcut ( Qt::Key_T ); // Add timestamp
a->setShortcutContext (Qt::WindowShortcut);
switchboard.addConnection(this, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
actionAddTimestamp=a;
a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
a->setEnabled (true);
switchboard.addConnection(NULL, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
actionMapInfo=a;
// Import at selection (adding to selection)
a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
a->setEnabled (false);
switchboard.addConnection(NULL, a,tr("Edit","Shortcut group"));
actionListBranches.append(a);
actionImportAdd=a;
// Import at selection (replacing selection)
a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
a->setEnabled (false);
actionListBranches.append(a);
actionImportReplace=a;
// Save selection
a = new QAction( tr( "Save selection","Edit menu" ), this);
connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
a->setEnabled (false);
switchboard.addConnection(a,tr("Edit","Shortcut group"));
actionListBranches.append(a);
actionSaveBranch=a;
// Only remove branch, not its children
a = new QAction(tr( "Remove only branch and keep its children ","Edit menu" ), this);
a->setShortcut (Qt::ALT + Qt::Key_X );
connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
a->setEnabled (false);
switchboard.addConnection(this, a,tr("Edit","Shortcut group"));
actionListBranches.append(a);
actionDeleteKeepChildren=a;
// Only remove children of a branch
a = new QAction( tr( "Remove children","Edit menu" ), this);
a->setShortcut (Qt::SHIFT + Qt::Key_X );
switchboard.addConnection(a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
a->setEnabled (false);
addAction (a);
actionListBranches.append(a);
actionDeleteChildren=a;
a = new QAction( tr( "Add Image...","Edit menu" ), this);
a->setShortcutContext (Qt::WindowShortcut);
a->setShortcut (Qt::Key_I );
switchboard.addConnection(a,tr("Edit","Shortcut group"));
addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
actionLoadImage=a;
a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
a->setShortcut ( Qt::Key_P ); //Property window
a->setShortcutContext (Qt::WindowShortcut);
a->setCheckable (true);
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
actionViewTogglePropertyWindow=a;
}
// Select Actions
void Main::setupSelectActions()
{
QMenu *selectMenu = menuBar()->addMenu( tr("&Select","Select menu") );
QAction *a;
a = new QAction( QPixmap(flagsPath + "flag-target"), tr( "Toggle target...","Edit menu"), this);
a->setShortcut (Qt::SHIFT + Qt::Key_T ); //Goto target
a->setCheckable(true);
switchboard.addConnection(selectMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editToggleTarget() ) );
actionToggleTarget=a;
a = new QAction( QPixmap(flagsPath + "flag-target"), tr( "Goto target...","Edit menu"), this);
a->setShortcut (Qt::Key_G ); //Goto target
switchboard.addConnection(selectMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editGoToTarget() ) );
a = new QAction( QPixmap(flagsPath + "flag-target"), tr( "Move to target...","Edit menu"), this);
a->setShortcut (Qt::Key_M ); //Move to target
switchboard.addConnection(selectMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editMoveToTarget() ) );
a = new QAction( QPixmap(iconPath + "selectprevious.png"), tr( "Select previous","Edit menu"), this);
a->setShortcut (Qt::CTRL+ Qt::Key_O );
switchboard.addConnection(selectMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editSelectPrevious() ) );
actionSelectPrevious=a;
a = new QAction( QPixmap(iconPath + "selectnext.png"), tr( "Select next","Edit menu"), this);
a->setShortcut (Qt::CTRL + Qt::Key_I );
switchboard.addConnection(selectMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editSelectNext() ) );
actionSelectNext=a;
a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
switchboard.addConnection(selectMenu, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindResultWidget() ) );
actionFind=a;
a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
switchboard.addConnection(a,tr("Edit","Shortcut group"));
if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
selectMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
}
// Format Actions
void Main::setupFormatActions()
{
QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
QAction *a;
QPixmap pix( 16,16);
pix.fill (Qt::black);
a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
switchboard.addConnection(formatMenu, a,tr("Format shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
actionFormatColor=a;
a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
a->setShortcut (Qt::CTRL + Qt::Key_K );
switchboard.addConnection(formatMenu, a,tr("Format shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
a->setEnabled (false);
actionListBranches.append(a);
actionFormatPickColor=a;
a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
//a->setShortcut (Qt::CTRL + Qt::Key_B + Qt::SHIFT);
switchboard.addConnection(formatMenu, a,tr("Format shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
a->setEnabled (false);
actionListBranches.append(a);
actionFormatColorBranch=a;
a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
//a->setShortcut (Qt::CTRL + Qt::Key_B); // Color subtree
switchboard.addConnection(formatMenu, a,tr("Format shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
a->setEnabled (false);
actionListBranches.append(a);
actionFormatColorSubtree=a;
formatMenu->addSeparator();
a= new QAction( tr( "Select default font","Branch attribute" )+"...", this);
a->setCheckable(false);
connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectFont() ) );
formatMenu->addAction (a);
actionFormatFont=a;
formatMenu->addSeparator();
actionGroupFormatLinkStyles=new QActionGroup ( this);
actionGroupFormatLinkStyles->setExclusive (true);
a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
a->setCheckable(true);
connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
formatMenu->addAction (a);
actionFormatLinkStyleLine=a;
a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
a->setCheckable(true);
connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
formatMenu->addAction (a);
actionFormatLinkStyleParabel=a;
a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
a->setCheckable(true);
connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
formatMenu->addAction (a);
actionFormatLinkStylePolyLine=a;
a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
a->setCheckable(true);
a->setChecked (true);
connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
formatMenu->addAction (a);
formatMenu->addSeparator();
actionFormatLinkStylePolyParabel=a;
a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
a->setCheckable(true);
connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
actionFormatHideLinkUnselected=a;
a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
a->setCheckable(true);
connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
formatMenu->addAction (a);
actionFormatLinkColorHint=a;
pix.fill (Qt::white);
a= new QAction( pix, tr( "Set &Link Color")+"..." , this );
formatMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
actionFormatLinkColor=a;
a= new QAction( pix, tr( "Set &Selection Color")+"...", this );
formatMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
actionFormatSelectionColor=a;
a= new QAction( pix, tr( "Set &Background Color" )+"...", this );
formatMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
actionFormatBackColor=a;
a= new QAction( pix, tr( "Set &Background image" )+"...", this );
formatMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
actionFormatBackImage=a;
}
// View Actions
void Main::setupViewActions()
{
QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
toolbarsMenu=viewMenu->addMenu (tr("Toolbars","Toolbars overview in view menu") );
viewMenu->addSeparator();
QAction *a;
a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
a->setShortcut(Qt::Key_Plus);
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
viewMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
actionZoomIn=a;
a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
a->setShortcut(Qt::Key_Minus);
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
viewMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
actionZoomOut=a;
a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
a->setShortcut (Qt::Key_Comma); // Reset zoom
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
viewMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
actionZoomReset=a;
a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Center on selection","View action" ), this);
a->setShortcut(Qt::Key_Period);
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
viewMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
actionCenterOn=a;
viewMenu->addSeparator();
if (noteEditorDW)
a=noteEditorDW->toggleViewAction();
else
a = new QAction(QPixmap(), tr( "Show Note Editor","View action" ),this);
a->setShortcut ( Qt::Key_N ); // Toggle Note Editor
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
a->setCheckable(true);
a->setIcon (QPixmap(flagsPath+"flag-note.png"));
viewMenu->addAction (a);
actionViewToggleNoteEditor=a;
if (!noteEditorDW)
connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
a=headingEditorDW->toggleViewAction();
a->setShortcut ( Qt::Key_E ); // Toggle Heading Editor
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
a->setCheckable(true);
a->setIcon (QPixmap(iconPath+"headingeditor.png"));
viewMenu->addAction (a);
actionViewToggleHeadingEditor=a;
// Original icon is "category" from KDE
a = new QAction(QPixmap(iconPath+"treeeditor.png"), tr( "Toggle Tree editor","View action" ),this);
a->setShortcut ( Qt::CTRL + Qt::Key_T ); // Toggle Tree Editor
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
a->setCheckable(true);
viewMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
actionViewToggleTreeEditor=a;
a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
a->setCheckable(true);
viewMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
actionViewToggleHistoryWindow=a;
viewMenu->addAction (actionViewTogglePropertyWindow);
viewMenu->addSeparator();
a = new QAction(tr( "Antialiasing","View action" ),this );
a->setCheckable(true);
a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
viewMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
actionViewToggleAntiAlias=a;
a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
a->setStatusTip (a->text());
a->setCheckable(true);
a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
viewMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
actionViewToggleSmoothPixmapTransform=a;
a = new QAction(tr( "Next Map","View action" ), this);
a->setStatusTip (a->text());
a->setShortcut (Qt::SHIFT+ Qt::Key_Right );
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
viewMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
a = new QAction (tr( "Previous Map","View action" ), this );
a->setStatusTip (a->text());
a->setShortcut (Qt::SHIFT+ Qt::Key_Left );
switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
viewMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
}
// Mode Actions
void Main::setupModeActions()
{
//QPopupMenu *menu = new QPopupMenu( this );
//menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
QAction *a;
actionGroupModModes=new QActionGroup ( this);
actionGroupModModes->setExclusive (true);
a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
a->setShortcut (Qt::Key_J);
switchboard.addConnection(this,a,tr("Modes","Shortcut group"));
a->setCheckable(true);
a->setChecked(true);
actionModModeColor=a;
a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
a->setShortcut( Qt::Key_K);
switchboard.addConnection(this,a,tr("Modes","Shortcut group"));
a->setCheckable(true);
actionModModeCopy=a;
a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
a->setShortcut (Qt::Key_L);
switchboard.addConnection(this,a,tr("Modes","Shortcut group"));
a->setCheckable(true);
actionModModeXLink=a;
}
// Flag Actions
void Main::setupFlagActions()
{
// Create System Flags
Flag *flag=new Flag(flagsPath+"flag-note.png");
setupFlag (flag,NULL,"system-note",tr("Note","SystemFlag"));
flag=new Flag(flagsPath+"flag-url.png");
setupFlag (flag,NULL,"system-url",tr("URL to Document ","SystemFlag"));
flag=new Flag(flagsPath+"flag-url-bugzilla-novell.png");
setupFlag (flag,NULL,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
flag=new Flag(flagsPath+"flag-url-bugzilla-novell-closed.png");
setupFlag (flag,NULL,"system-url-bugzilla-novell-closed",tr("URL to Bugzilla ","SystemFlag"));
flag=new Flag(flagsPath+"flag-target.png");
setupFlag (flag,NULL,"system-target",tr("Map target","SystemFlag"));
flag=new Flag(flagsPath+"flag-vymlink.png");
setupFlag (flag,NULL,"system-vymLink",tr("Link to another vym map","SystemFlag"));
flag=new Flag(flagsPath+"flag-scrolled-right.png");
setupFlag (flag,NULL,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
flag=new Flag(flagsPath+"flag-tmpUnscrolled-right.png");
setupFlag (flag,NULL,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
flag=new Flag(flagsPath+"flag-hideexport.png");
setupFlag (flag,NULL,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
addToolBarBreak();
// Create Standard Flags
standardFlagsToolbar=addToolBar (tr ("Standard Flags toolbar","Standard Flag Toolbar"));
standardFlagsToolbar->setObjectName ("standardFlagTB");
standardFlagsMaster->setToolBar (standardFlagsToolbar);
// Add entry now, to avoid chicken and egg problem and position toolbar
// after all others:
toolbarsMenu->addAction (standardFlagsToolbar->toggleViewAction() );
flag=new Flag(flagsPath+"flag-exclamationmark.png");
flag->setGroup("standard-mark");
setupFlag (flag,standardFlagsToolbar,"exclamationmark",tr("Take care!","Standardflag"));
flag=new Flag(flagsPath+"flag-questionmark.png");
flag->setGroup("standard-mark");
setupFlag (flag,standardFlagsToolbar,"questionmark",tr("Really?","Standardflag"));
flag=new Flag(flagsPath+"flag-hook-green.png");
flag->setGroup("standard-status");
setupFlag (flag,standardFlagsToolbar,"hook-green",tr("Status - ok,done","Standardflag"));
flag=new Flag(flagsPath+"flag-wip.png");
flag->setGroup("standard-status");
setupFlag (flag,standardFlagsToolbar,"wip",tr("Status - work in progress","Standardflag"));
flag=new Flag(flagsPath+"flag-cross-red.png");
flag->setGroup("standard-status");
setupFlag (flag,standardFlagsToolbar,"cross-red",tr("Status - missing, not started","Standardflag"));
flag=new Flag(flagsPath+"flag-stopsign.png");
flag->setGroup("standard-status");
setupFlag (flag,standardFlagsToolbar,"stopsign",tr("This won't work!","Standardflag"));
flag->unsetGroup();
flag=new Flag(flagsPath+"flag-smiley-good.png");
flag->setGroup("standard-smiley");
setupFlag (flag,standardFlagsToolbar,"smiley-good",tr("Good","Standardflag"));
flag=new Flag(flagsPath+"flag-smiley-sad.png");
flag->setGroup("standard-smiley");
setupFlag (flag,standardFlagsToolbar,"smiley-sad",tr("Bad","Standardflag"));
flag=new Flag(flagsPath+"flag-smiley-omg.png");
flag->setGroup("standard-smiley");
setupFlag (flag,standardFlagsToolbar,"smiley-omb",tr("Oh no!","Standardflag"));
// Original omg.png (in KDE emoticons)
flag->unsetGroup();
flag=new Flag(flagsPath+"flag-kalarm.png");
setupFlag (flag,standardFlagsToolbar,"clock",tr("Time critical","Standardflag"));
flag=new Flag(flagsPath+"flag-phone.png");
setupFlag (flag,standardFlagsToolbar,"phone",tr("Call...","Standardflag"));
flag=new Flag(flagsPath+"flag-lamp.png");
setupFlag (flag,standardFlagsToolbar,"lamp",tr("Idea!","Standardflag"));
flag=new Flag(flagsPath+"flag-arrow-up.png");
flag->setGroup("standard-arrow");
setupFlag (flag,standardFlagsToolbar,"arrow-up",tr("Important","Standardflag"));
flag=new Flag(flagsPath+"flag-arrow-down.png");
flag->setGroup("standard-arrow");
setupFlag (flag,standardFlagsToolbar,"arrow-down",tr("Unimportant","Standardflag"));
flag=new Flag(flagsPath+"flag-arrow-2up.png");
flag->setGroup("standard-arrow");
setupFlag (flag,standardFlagsToolbar,"2arrow-up",tr("Very important!","Standardflag"));
flag=new Flag(flagsPath+"flag-arrow-2down.png");
flag->setGroup("standard-arrow");
setupFlag (flag,standardFlagsToolbar,"2arrow-down",tr("Very unimportant!","Standardflag"));
flag->unsetGroup();
flag=new Flag(flagsPath+"flag-thumb-up.png");
flag->setGroup("standard-thumb");
setupFlag (flag,standardFlagsToolbar,"thumb-up",tr("I like this","Standardflag"));
flag=new Flag(flagsPath+"flag-thumb-down.png");
flag->setGroup("standard-thumb");
setupFlag (flag,standardFlagsToolbar,"thumb-down",tr("I do not like this","Standardflag"));
flag->unsetGroup();
flag=new Flag(flagsPath+"flag-rose.png");
setupFlag (flag,standardFlagsToolbar,"rose",tr("Rose","Standardflag"));
flag=new Flag(flagsPath+"flag-heart.png");
setupFlag (flag,standardFlagsToolbar,"heart",tr("I just love...","Standardflag"));
flag=new Flag(flagsPath+"flag-present.png");
setupFlag (flag,standardFlagsToolbar,"present",tr("Surprise!","Standardflag"));
flag=new Flag(flagsPath+"flag-flash.png");
setupFlag (flag,standardFlagsToolbar,"flash",tr("Dangerous","Standardflag"));
// Original: xsldbg_output.png
flag=new Flag(flagsPath+"flag-info.png");
setupFlag (flag,standardFlagsToolbar,"info",tr("Info","Standardflag"));
// Original khelpcenter.png
flag=new Flag(flagsPath+"flag-lifebelt.png");
setupFlag (flag,standardFlagsToolbar,"lifebelt",tr("This will help","Standardflag"));
// Freemind flags
flag=new Flag(flagsPath+"freemind/warning.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar, "freemind-warning",tr("Important","Freemind-Flag"));
for (int i=1; i<8; i++)
{
flag=new Flag(flagsPath+QString("freemind/priority-%1.png").arg(i));
flag->setVisible(false);
flag->setGroup ("Freemind-priority");
setupFlag (flag,standardFlagsToolbar, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
}
flag=new Flag(flagsPath+"freemind/back.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-back",tr("Back","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/forward.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-forward",tr("forward","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/attach.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-attach",tr("Look here","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/clanbomber.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/desktopnew.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/flag.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-flag",tr("Flag","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/gohome.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-gohome",tr("Home","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/kaddressbook.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/knotify.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-knotify",tr("Music","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/korn.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-korn",tr("Mailbox","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/mail.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-mail",tr("Maix","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/password.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-password",tr("Password","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/pencil.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-pencil",tr("To be improved","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/stop.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-stop",tr("Stop","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/wizard.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-wizard",tr("Magic","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/xmag.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/bell.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-bell",tr("Reminder","Freemind-Flag"));
flag=new Flag(flagsPath+"freemind/bookmark.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
flag= new Flag(flagsPath+"freemind/penguin.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-penguin",tr("Linux","Freemind-Flag"));
flag=new Flag (flagsPath+"freemind/licq.png");
flag->setVisible(false);
setupFlag (flag,standardFlagsToolbar,"freemind-licq",tr("Sweet","Freemind-Flag"));
}
void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
{
flag->setName(name);
flag->setToolTip (tooltip);
QAction *a;
if (tb)
{
a=new QAction (flag->getPixmap(),name,this);
// StandardFlag
tb->addAction (a);
flag->setAction (a);
a->setVisible (flag->isVisible());
a->setCheckable(true);
a->setObjectName(name);
a->setToolTip(tooltip);
connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
standardFlagsMaster->addFlag (flag);
} else
{
// SystemFlag
systemFlagsMaster->addFlag (flag);
}
}
// Network Actions
void Main::setupNetworkActions()
{
if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
return;
QMenu *netMenu = menuBar()->addMenu( "Network" );
QAction *a;
a = new QAction( "Start TCPserver for MapEditor",this);
//a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
switchboard.addConnection(netMenu, a,tr("Network shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
a = new QAction( "Connect MapEditor to server",this);
a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
switchboard.addConnection(netMenu, a,tr("Network shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
}
// Settings Actions
void Main::setupSettingsActions()
{
QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
QAction *a;
a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
settingsMenu->addAction (a);
a = new QAction( tr( "Set application to open external links","Settings action"), this);
connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
settingsMenu->addAction (a);
a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
settingsMenu->addAction (a);
a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
settingsMenu->addAction (a);
settingsMenu->addSeparator();
a = new QAction( tr( "Autosave","Settings action"), this);
a->setCheckable(true);
a->setChecked ( settings.value ("/mainwindow/autosave/use",true).toBool());
connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
settingsMenu->addAction (a);
actionSettingsAutosaveToggle=a;
a = new QAction( tr( "Autosave time","Settings action")+"...", this);
connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
settingsMenu->addAction (a);
actionSettingsAutosaveTime=a;
a = new QAction( tr( "Write backup file on save","Settings action"), this);
a->setCheckable(true);
a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
settingsMenu->addAction (a);
actionSettingsWriteBackupFile=a;
settingsMenu->addSeparator();
a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
a->setCheckable(true);
a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
settingsMenu->addAction (a);
actionSettingsAutoEditNewBranch=a;
a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
a->setCheckable(true);
a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
settingsMenu->addAction (a);
actionSettingsAutoSelectNewBranch=a;
a= new QAction(tr( "Select existing heading","Settings action" ), this);
a->setCheckable(true);
a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
settingsMenu->addAction (a);
actionSettingsAutoSelectText=a;
a= new QAction( tr( "Delete key","Settings action" ), this);
a->setCheckable(true);
a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
settingsMenu->addAction (a);
connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
actionSettingsUseDelKey=a;
a= new QAction( tr( "Exclusive flags","Settings action" ), this);
a->setCheckable(true);
a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
settingsMenu->addAction (a);
actionSettingsUseFlagGroups=a;
a= new QAction( tr( "Use hide flags","Settings action" ), this);
a->setCheckable(true);
a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
settingsMenu->addAction (a);
actionSettingsUseHideExport=a;
a= new QAction( tr( "Note editor is dockable","Settings action" ), this);
a->setCheckable(true);
a->setChecked ( settings.value ("/satellite/noteeditor/isDockWindow",true).toBool() );
connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleNoteEditorIsDockWindow() ) );
actionSettingsNoteEditorIsDockWindow=a;
settingsMenu->addAction (a);
settingsMenu->addSeparator();
a = new QAction( tr( "Animation","Settings action"), this);
a->setCheckable(true);
a->setChecked (settings.value("/animation/use",true).toBool() );
connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
settingsMenu->addAction (a);
actionSettingsUseAnimation=a;
a = new QAction( tr( "Automatic layout","Settings action"), this);
a->setCheckable(true);
a->setChecked ( settings.value ("/mainwindow/autoLayout/use",true).toBool());
connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutoLayoutToggle() ) );
settingsMenu->addAction (a);
actionSettingsAutoLayoutToggle=a;
}
// Test Actions
void Main::setupTestActions()
{
QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
QAction *a;
a = new QAction( "Test function 1" , this);
a->setShortcut (Qt::ALT + Qt::Key_T); // Test function
switchboard.addConnection(testMenu, a, tr("Test shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
a = new QAction( "Test function 2" , this);
switchboard.addConnection(testMenu, a, tr("Test shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
a = new QAction( "Command" , this); //FIXME-3+ Make this available in release?
switchboard.addConnection(testMenu, a, tr("Test shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
}
// Help Actions
void Main::setupHelpActions()
{
QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
QAction *a;
a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
switchboard.addConnection(helpMenu, a,tr("Help shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
switchboard.addConnection(helpMenu, a,tr("Help shortcuts","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
a = new QAction( tr( "About VYM","Help action" ), this);
connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
helpMenu->addAction (a);
a = new QAction( tr( "About QT","Help action" ), this);
connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
helpMenu->addAction (a);
}
// Context Menus
void Main::setupContextMenus()
{
// Context menu for goto/move targets (populated on demand)
targetsContextMenu = new QMenu (this);
// Context Menu for branch or mapcenter
branchContextMenu =new QMenu (this);
branchContextMenu->addAction (actionViewTogglePropertyWindow);
branchContextMenu->addSeparator();
// Submenu "Add"
branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
branchAddContextMenu->addAction (actionPaste );
branchAddContextMenu->addAction ( actionAddMapCenter );
branchAddContextMenu->addAction ( actionAddBranch );
branchAddContextMenu->addAction ( actionAddBranchBefore );
branchAddContextMenu->addAction ( actionAddBranchAbove);
branchAddContextMenu->addAction ( actionAddBranchBelow );
branchAddContextMenu->addSeparator();
branchAddContextMenu->addAction ( actionImportAdd );
branchAddContextMenu->addAction ( actionImportReplace );
// Submenu "Remove"
branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
branchRemoveContextMenu->addAction (actionCut);
branchRemoveContextMenu->addAction ( actionDelete );
branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
branchRemoveContextMenu->addAction ( actionDeleteChildren );
branchContextMenu->addAction(actionSaveBranch);
branchContextMenu->addAction( actionFileNewCopy);
branchContextMenu->addAction(actionDetach);
branchContextMenu->addSeparator();
branchContextMenu->addAction ( actionLoadImage);
if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
branchContextMenu->addAction ( actionAddAttribute);
// Submenu for Links (URLs, vymLinks)
branchLinksContextMenu =new QMenu (this);
branchContextMenu->addSeparator();
branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
branchLinksContextMenu->addAction ( actionOpenURL );
branchLinksContextMenu->addAction ( actionOpenURLTab );
branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
branchLinksContextMenu->addAction ( actionURLNew );
branchLinksContextMenu->addAction ( actionLocalURL );
branchLinksContextMenu->addAction ( actionGetURLsFromNote );
branchLinksContextMenu->addAction ( actionHeading2URL );
branchLinksContextMenu->addAction ( actionBugzilla2URL );
branchLinksContextMenu->addAction ( actionGetBugzillaData );
branchLinksContextMenu->addAction ( actionGetBugzillaDataSubtree );
if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
branchLinksContextMenu->addAction ( actionFATE2URL );
branchLinksContextMenu->addSeparator();
branchLinksContextMenu->addAction ( actionOpenVymLink );
branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
branchLinksContextMenu->addAction ( actionEditVymLink );
branchLinksContextMenu->addAction ( actionDeleteVymLink );
// Context Menu for XLinks in a branch menu
// This will be populated "on demand" in MapEditor::updateActions
branchContextMenu->addSeparator();
branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
connect(
branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ),
this, SLOT( editEditXLink(QAction * ) ) );
QAction *a;
a = new QAction( tr("Follow XLink","Context menu") , this);
a->setShortcut (Qt::Key_F);
switchboard.addConnection(this, a,tr("Edit","Shortcut group"));
connect( a, SIGNAL( triggered() ), this, SLOT( popupFollowXLink() ) );
branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
connect(
branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ),
this, SLOT( editFollowXLink(QAction * ) ) );
// Context menu for floatimage
floatimageContextMenu =new QMenu (this);
a= new QAction (tr ("Save image","Context action"),this);
connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
floatimageContextMenu->addAction (a);
floatimageContextMenu->addSeparator();
floatimageContextMenu->addAction(actionCopy);
floatimageContextMenu->addAction(actionCut);
floatimageContextMenu->addSeparator();
floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
// Context menu for canvas
canvasContextMenu =new QMenu (this);
canvasContextMenu->addAction (actionAddMapCenter);
canvasContextMenu->addAction (actionMapInfo); //FIXME-3 move to File menu?
canvasContextMenu->insertSeparator(actionMapInfo);
canvasContextMenu->addAction(actionFormatFont);
canvasContextMenu->insertSeparator(actionFormatFont);
canvasContextMenu->addActions(actionGroupFormatLinkStyles->actions() );
canvasContextMenu->insertSeparator(actionGroupFormatLinkStyles->actions().first() );
canvasContextMenu->addAction(actionFormatLinkColorHint);
canvasContextMenu->insertSeparator(actionFormatLinkColorHint);
canvasContextMenu->addAction(actionFormatLinkColor);
canvasContextMenu->addAction(actionFormatSelectionColor);
canvasContextMenu->addAction(actionFormatBackColor);
// actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
// Menu for last opened files
// Create actions
for (int i = 0; i < MaxRecentFiles; ++i)
{
recentFileActions[i] = new QAction(this);
recentFileActions[i]->setVisible(false);
fileLastMapsMenu->addAction(recentFileActions[i]);
connect(recentFileActions[i], SIGNAL(triggered()),
this, SLOT(fileLoadRecent()));
}
setupRecentMapsMenu();
}
void Main::setupRecentMapsMenu()
{
QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
for (int i = 0; i < numRecentFiles; ++i) {
QString text = QString("&%1 %2").arg(i + 1).arg(files[i]);
recentFileActions[i]->setText(text);
recentFileActions[i]->setData(files[i]);
recentFileActions[i]->setVisible(true);
}
for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
recentFileActions[j]->setVisible(false);
}
void Main::setupMacros()
{
for (int i = 0; i <= 11; i++)
{
macroActions[i] = new QAction(this);
macroActions[i]->setData(i);
addAction (macroActions[i]);
//switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
connect(macroActions[i], SIGNAL(triggered()),
this, SLOT(callMacro()));
}
macroActions[0]->setShortcut ( Qt::Key_F1 );
macroActions[1]->setShortcut ( Qt::Key_F2 );
macroActions[2]->setShortcut ( Qt::Key_F3 );
macroActions[3]->setShortcut ( Qt::Key_F4 );
macroActions[4]->setShortcut ( Qt::Key_F5 );
macroActions[5]->setShortcut ( Qt::Key_F6 );
macroActions[6]->setShortcut ( Qt::Key_F7 );
macroActions[7]->setShortcut ( Qt::Key_F8 );
macroActions[8]->setShortcut ( Qt::Key_F9 );
macroActions[9]->setShortcut ( Qt::Key_F10 );
macroActions[10]->setShortcut ( Qt::Key_F11 );
macroActions[11]->setShortcut ( Qt::Key_F12 );
}
void Main::setupToolbars()
{
// File actions
fileToolbar = addToolBar( tr ("File actions toolbar","Toolbar for file actions"));
fileToolbar->setObjectName ("fileTB");
fileToolbar->addAction(actionFileNew);
fileToolbar->addAction(actionFileOpen);
fileToolbar->addAction(actionFileSave);
fileToolbar->addAction(actionFileExportLast);
fileToolbar->addAction(actionFilePrint);
// Undo/Redo and clipboard
clipboardToolbar =addToolBar( tr ("Undo and clipboard toolbar","Toolbar for redo/undo and clipboard"));
clipboardToolbar->setObjectName ("clipboard toolbar");
clipboardToolbar->addAction (actionUndo);
clipboardToolbar->addAction (actionRedo);
clipboardToolbar->addAction (actionCopy);
clipboardToolbar->addAction (actionCut);
clipboardToolbar->addAction (actionPaste);
// Basic edits
editActionsToolbar = addToolBar( tr ("Edit actions toolbar","Toolbar name") );
editActionsToolbar->setObjectName ("basic edit actions TB");
editActionsToolbar->addAction (actionAddMapCenter);
editActionsToolbar->addAction (actionAddBranch);
editActionsToolbar->addAction (actionMoveUp);
editActionsToolbar->addAction (actionMoveDown);
editActionsToolbar->addAction (actionSortChildren);
editActionsToolbar->addAction (actionSortBackChildren);
editActionsToolbar->addAction (actionToggleScroll);
editActionsToolbar->addAction (actionToggleHideExport);
//editActionsToolbar->addAction (actionExpandAll);
//editActionsToolbar->addAction (actionExpandOneLevel);
//editActionsToolbar->addAction (actionCollapseOneLevel);
//editActionsToolbar->addAction (actionCollapseUnselected);
// Selections
selectionToolbar = addToolBar( tr ("Selection toolbar","Toolbar name") );
selectionToolbar->setObjectName ("toolbar for selecting items");
selectionToolbar->addAction (actionToggleTarget);
selectionToolbar->addAction (actionSelectPrevious);
selectionToolbar->addAction (actionSelectNext);
selectionToolbar->addAction (actionFind);
// URLs and vymLinks
referencesToolbar=addToolBar( tr ("URLs and vymLinks toolbar","Toolbar for URLs and vymlinks"));
referencesToolbar->setObjectName ("URLs and vymlinks toolbar");
referencesToolbar->addAction (actionOpenURL);
referencesToolbar->addAction (actionURLNew);
referencesToolbar->addAction (actionOpenVymLink);
referencesToolbar->addAction (actionEditVymLink);
// Format and colors
colorsToolbar = addToolBar( tr("Colors toolbar","Colors toolbar name"));
colorsToolbar->setObjectName ("colorsTB");
colorsToolbar->addAction(actionFormatColor);
colorsToolbar->addAction(actionFormatPickColor);
colorsToolbar->addAction(actionFormatColorBranch);
colorsToolbar->addAction(actionFormatColorSubtree);
// Zoom
zoomToolbar = addToolBar( tr("Zoom toolbar","View Toolbar name") );
zoomToolbar->setObjectName ("viewTB");
zoomToolbar->addAction(actionZoomIn);
zoomToolbar->addAction(actionZoomOut);
zoomToolbar->addAction(actionZoomReset);
zoomToolbar->addAction(actionCenterOn);
// Editors
editorsToolbar = addToolBar( tr("Editors toolbar","Editor Toolbar name") );
editorsToolbar->setObjectName ("editorsTB");
editorsToolbar->addAction (actionViewToggleNoteEditor);
editorsToolbar->addAction (actionViewToggleHeadingEditor);
editorsToolbar->addAction (actionViewToggleTreeEditor);
editorsToolbar->addAction (actionViewToggleHistoryWindow);
// Modifier modes
modModesToolbar = addToolBar( tr ("Modifier modes toolbar","Modifier Toolbar name") );
modModesToolbar->setObjectName ("modesTB");
modModesToolbar->addAction(actionModModeColor);
modModesToolbar->addAction(actionModModeCopy);
modModesToolbar->addAction(actionModModeXLink);
// Add all toolbars to View menu
toolbarsMenu->addAction (fileToolbar->toggleViewAction() );
toolbarsMenu->addAction (clipboardToolbar->toggleViewAction() );
toolbarsMenu->addAction (editActionsToolbar->toggleViewAction() );
toolbarsMenu->addAction (selectionToolbar->toggleViewAction() );
toolbarsMenu->addAction (colorsToolbar->toggleViewAction() );
toolbarsMenu->addAction (zoomToolbar->toggleViewAction() );
toolbarsMenu->addAction (modModesToolbar->toggleViewAction() );
toolbarsMenu->addAction (referencesToolbar->toggleViewAction() );
toolbarsMenu->addAction (editorsToolbar->toggleViewAction() );
// Default visibility to not overload new users
fileToolbar->show();
clipboardToolbar->show();
editActionsToolbar->show();
selectionToolbar->hide();
colorsToolbar->show();
zoomToolbar->show();
modModesToolbar->hide();
referencesToolbar->hide();
editorsToolbar->hide();
}
void Main::hideEvent (QHideEvent * )
{
if (!noteEditor->isMinimized() ) noteEditor->hide();
}
void Main::showEvent (QShowEvent * )
{
if (actionViewToggleNoteEditor->isChecked()) noteEditor->showNormal();
}
MapEditor* Main::currentMapEditor() const
{
if ( tabWidget->currentWidget())
return vymViews.at(tabWidget->currentIndex())->getMapEditor();
return NULL;
}
uint Main::currentModelID() const
{
if (currentModel())
return currentModel()->getID();
return 0;
}
VymModel* Main::currentModel() const
{
if ( tabWidget->currentWidget())
return vymViews.at(tabWidget->currentIndex())->getModel();
return NULL;
}
VymModel* Main::getModel(uint id) const
{
// Used in BugAgent
for (int i=0; i<vymViews.count();i++)
if (vymViews.at(i)->getModel()->getID()==id)
return vymViews.at(i)->getModel();
return NULL;
}
void Main::editorChanged(QWidget *)
{
// Unselect all possibly selected objects
// (Important to update note editor)
VymModel *m;
for (int i=0;i<=tabWidget->count() -1;i++)
{
m= vymViews.at(i)->getModel();
if (m) m->unselect();
}
m=currentModel();
if (m)
{
m->reselect();
updateQueries (m);
}
// Update actions to in menus and toolbars according to editor
updateActions();
}
void Main::fileNew()
{
VymModel *vm=new VymModel;
/////////////////////////////////////
// new ModelTest(vm, this);
/////////////////////////////////////
VymView *vv=new VymView (vm);
vymViews.append (vv);
tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
tabWidget->setCurrentIndex (vymViews.count() );
vv->initFocus();
// Create MapCenter for empty map
vm->addMapCenter(false);
vm->makeDefault();
// For the very first map we do not have flagrows yet...
vm->select("mc:");
// Switch to new tab
tabWidget->setCurrentIndex (tabWidget->count() -1);
}
void Main::fileNewCopy()
{
QString fn="unnamed";
VymModel *srcModel=currentModel();
if (srcModel)
{
srcModel->copy();
fileNew();
VymModel *dstModel=vymViews.last()->getModel();
if (dstModel->select("mc:0"))
dstModel->loadMap (clipboardDir+"/"+clipboardFile,ImportReplace,false);
else
qWarning ()<<"Main::fileNewCopy couldn't select mapcenter";
}
}
ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
{
ErrorCode err=success;
// fn is usually the archive, mapfile the file after uncompressing
QString mapfile;
// Make fn absolute (needed for unzip)
fn=QDir (fn).absolutePath();
VymModel *vm;
if (lmode==NewMap)
{
// Check, if map is already loaded
int i=0;
while (i<=tabWidget->count() -1)
{
if (vymViews.at(i)->getModel()->getFilePath() == fn)
{
// Already there, ask for confirmation
QMessageBox mb( vymName,
tr("The map %1\nis already opened."
"Opening the same map in multiple editors may lead \n"
"to confusion when finishing working with vym."
"Do you want to").arg(fn),
QMessageBox::Warning,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::Cancel | QMessageBox::Escape,
QMessageBox::NoButton);
mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
switch( mb.exec() )
{
case QMessageBox::Yes:
// end loop and load anyway
i=tabWidget->count();
break;
case QMessageBox::Cancel:
// do nothing
return aborted;
break;
}
}
i++;
}
}
int tabIndex=tabWidget->currentIndex();
// Try to load map
if ( !fn.isEmpty() )
{
vm = currentModel();
// Check first, if mapeditor exists
// If it is not default AND we want a new map,
// create a new mapeditor in a new tab
if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
{
vm=new VymModel;
VymView *vv=new VymView (vm);
vymViews.append (vv);
tabWidget->addTab (vv,fn);
tabIndex=tabWidget->count()-1;
//tabWidget->setCurrentIndex (tabIndex);
vv->initFocus();
}
// Check, if file exists (important for creating new files
// from command line
if (!QFile(fn).exists() )
{
QMessageBox mb( vymName,
tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
QMessageBox::Question,
QMessageBox::Yes ,
QMessageBox::Cancel | QMessageBox::Default,
QMessageBox::NoButton );
mb.setButtonText( QMessageBox::Yes, tr("Create"));
mb.setButtonText( QMessageBox::No, tr("Cancel"));
switch( mb.exec() )
{
case QMessageBox::Yes:
// Create new map
currentMapEditor()->getModel()->setFilePath(fn);
tabWidget->setTabText (tabIndex,
currentMapEditor()->getModel()->getFileName() );
statusBar()->showMessage( "Created " + fn , statusbarTime );
return success;
case QMessageBox::Cancel:
// don't create new map
statusBar()->showMessage( "Loading " + fn + " failed!", statusbarTime );
int cur=tabWidget->currentIndex();
tabWidget->setCurrentIndex (tabWidget->count()-1);
fileCloseMap();
tabWidget->setCurrentIndex (cur);
return aborted;
}
}
//tabWidget->setCurrentIndex (tabIndex);
if (err!=aborted)
{
// Save existing filename in case we import
QString fn_org=vm->getFilePath();
// Finally load map into mapEditor
progressDialog.setLabelText (tr("Loading: %1","Progress dialog while loading maps").arg(fn));
vm->setFilePath (fn);
err=vm->loadMap(fn,lmode,true,ftype);
// Restore old (maybe empty) filepath, if this is an import
if (lmode!=NewMap)
vm->setFilePath (fn_org);
}
// Finally check for errors and go home
if (err==aborted)
{
if (lmode==NewMap) fileCloseMap();
statusBar()->showMessage( "Could not load " + fn, statusbarTime );
} else
{
if (lmode==NewMap)
{
vm->setFilePath (fn);
tabWidget->setTabText (tabIndex, vm->getFileName());
if (!isInTmpDir (fn))
{
// Only append to lastMaps if not loaded from a tmpDir
// e.g. imported bookmarks are in a tmpDir
addRecentMap(vm->getFilePath() );
}
actionFilePrint->setEnabled (true);
}
vm->emitShowSelection();
statusBar()->showMessage( "Loaded " + fn, statusbarTime );
}
}
return err;
}
void Main::fileLoad(const LoadMode &lmode)
{
QStringList filters;
filters <<"VYM map (*.vym *.vyp)"<<"VYM Backups (*.vym~)"<<"XML (*.xml)"<<"All (* *.*)";
QFileDialog fd;
fd.setDirectory (lastMapDir);
fd.setFileMode (QFileDialog::ExistingFiles);
fd.setFilters (filters);
fd.setAcceptMode (QFileDialog::AcceptOpen);
switch (lmode)
{
case NewMap:
fd.setWindowTitle(vymName+ " - " +tr("Load vym map"));
break;
case ImportAdd:
fd.setWindowTitle(vymName+ " - " +tr("Import: Add vym map to selection"));
break;
case ImportReplace:
fd.setWindowTitle(vymName+ " - " +tr("Import: Replace selection with vym map"));
break;
}
QString fn;
if ( fd.exec() == QDialog::Accepted )
{
lastMapDir=fd.directory().path();
QStringList flist = fd.selectedFiles();
QStringList::Iterator it = flist.begin();
progressCounterTotal=flist.count();
while( it != flist.end() )
{
fn = *it;
fileLoad(*it, lmode);
++it;
}
}
removeProgressCounter();
fileSaveSession();
}
void Main::fileLoad()
{
fileLoad (NewMap);
}
void Main::fileSaveSession()
{
QStringList flist;
for (int i=0;i<vymViews.count(); i++)
flist.append (vymViews.at(i)->getModel()->getFilePath() );
settings.setValue("/mainwindow/sessionFileList", flist);
}
void Main::fileRestoreSession()
{
QStringList flist= settings.value("/mainwindow/sessionFileList").toStringList();
QStringList::Iterator it=flist.begin();
initProgressCounter (flist.count());
while (it !=flist.end() )
{
fileLoad (*it, NewMap);
*it++;
}
removeProgressCounter();
}
void Main::fileLoadRecent()
{
QAction *action = qobject_cast<QAction *>(sender());
if (action)
{
initProgressCounter ();
fileLoad (action->data().toString(), NewMap);
removeProgressCounter();
}
}
void Main::addRecentMap (const QString &fileName)
{
QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
files.removeAll(fileName);
files.prepend(fileName);
while (files.size() > MaxRecentFiles)
files.removeLast();
settings.setValue("/mainwindow/recentFileList", files);
setupRecentMapsMenu();
}
void Main::fileSave(VymModel *m, const SaveMode &savemode)
{
if (!m) return;
if ( m->getFilePath().isEmpty() )
{
// We have no filepath yet,
// call fileSaveAs() now, this will call fileSave()
// again.
// First switch to editor
//FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
fileSaveAs(savemode);
}
if (m->save (savemode)==success)
{
statusBar()->showMessage(
tr("Saved %1").arg(m->getFilePath()),
statusbarTime );
addRecentMap (m->getFilePath() );
fileSaveSession();
} else
statusBar()->showMessage(
tr("Couldn't save ").arg(m->getFilePath()),
statusbarTime );
}
void Main::fileSave()
{
fileSave (currentModel(), CompleteMap);
}
void Main::fileSave(VymModel *m)
{
fileSave (m,CompleteMap);
}
void Main::fileSaveAs(const SaveMode& savemode)
{
if (currentMapEditor())
{
QStringList filters;
if (savemode==CompleteMap)
filters<<"VYM map (*.vym)";
else
filters<<"VYM part of map (*vyp)";
filters<<"All (* *.*)";
QFileDialog fd;
fd.setDirectory (lastMapDir);
fd.setFileMode (QFileDialog::AnyFile);
fd.setFilters (filters);
fd.setAcceptMode (QFileDialog::AcceptSave);
fd.setConfirmOverwrite (false);
if ( fd.exec() == QDialog::Accepted && !fd.selectedFiles().isEmpty())
{
QString fn=fd.selectedFiles().first();
// Check for existing file
if (QFile (fn).exists())
{
QMessageBox mb( vymName,
tr("The file %1\nexists already. Do you want to").arg(fn),
QMessageBox::Warning,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::Cancel | QMessageBox::Escape,
QMessageBox::NoButton);
mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
switch( mb.exec() )
{
case QMessageBox::Yes:
// save
break;
case QMessageBox::Cancel:
// do nothing
return;
break;
}
} else
{
// New file, add extension to filename, if missing
// This is always .vym or .vyp, depending on savemode
if (savemode==CompleteMap)
{
if (!fn.contains (".vym") && !fn.contains (".xml"))
fn +=".vym";
} else
{
if (!fn.contains (".vyp") && !fn.contains (".xml"))
fn +=".vyp";
}
}
// Save now
VymModel *m=currentModel();
m->setFilePath(fn);
fileSave(m, savemode);
// Set name of tab, assuming current tab is the one we just saved
if (savemode==CompleteMap)
tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
return;
}
}
}
void Main::fileSaveAs()
{
fileSaveAs (CompleteMap);
}
void Main::fileImportKDE3Bookmarks()
{
ImportKDE3Bookmarks im;
im.transform();
if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
currentMapEditor()->getModel()->setFilePath ("");
}
void Main::fileImportKDE4Bookmarks()
{
ImportKDE4Bookmarks im;
im.transform();
if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
currentMapEditor()->getModel()->setFilePath ("");
}
void Main::fileImportFirefoxBookmarks()
{
QFileDialog fd;
fd.setDirectory (vymBaseDir.homePath()+"/.mozilla/firefox");
fd.setFileMode (QFileDialog::ExistingFiles);
QStringList filters;
filters<<"Firefox "+tr("Bookmarks")+" (*.html)";
fd.setFilters(filters);
fd.setAcceptMode (QFileDialog::AcceptOpen);
fd.setWindowTitle(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
if ( fd.exec() == QDialog::Accepted )
{
ImportFirefoxBookmarks im;
QStringList flist = fd.selectedFiles();
QStringList::Iterator it = flist.begin();
while( it != flist.end() )
{
im.setFile (*it);
if (im.transform() &&
aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
currentMapEditor() )
currentMapEditor()->getModel()->setFilePath ("");
++it;
}
}
}
void Main::fileImportFreemind()
{
QStringList filters;
filters <<"Freemind map (*.mm)"<<"All files (*)";
QFileDialog fd;
fd.setDirectory (lastMapDir);
fd.setFileMode (QFileDialog::ExistingFiles);
fd.setFilters (filters);
fd.setWindowTitle(vymName+ " - " +tr("Load Freemind map"));
fd.setAcceptMode (QFileDialog::AcceptOpen);
QString fn;
if ( fd.exec() == QDialog::Accepted )
{
lastMapDir=fd.directory().path();
QStringList flist = fd.selectedFiles();
QStringList::Iterator it = flist.begin();
while( it != flist.end() )
{
fn = *it;
if ( fileLoad (fn,NewMap, FreemindMap) )
{
currentMapEditor()->getModel()->setFilePath ("");
}
++it;
}
}
}
void Main::fileImportMM()
{
ImportMM im;
QFileDialog fd;
fd.setDirectory (lastMapDir);
fd.setFileMode (QFileDialog::ExistingFiles);
QStringList filters;
filters<<"Mind Manager (*.mmap)";
fd.setFilters (filters);
fd.setAcceptMode (QFileDialog::AcceptOpen);
fd.setWindowTitle(tr("Import")+" "+"Mind Manager");
if ( fd.exec() == QDialog::Accepted )
{
lastMapDir=fd.directory();
QStringList flist = fd.selectedFiles();
QStringList::Iterator it = flist.begin();
while( it != flist.end() )
{
im.setFile (*it);
if (im.transform() &&
success==fileLoad (im.getTransformedFile(),NewMap) &&
currentMapEditor() )
currentMapEditor()->getModel()->setFilePath ("");
++it;
}
}
}
void Main::fileImportDir()
{
VymModel *m=currentModel();
if (m) m->importDir();
}
void Main::fileExportXML()
{
VymModel *m=currentModel();
if (m) m->exportXML();
}
void Main::fileExportHTML()
{
VymModel *m=currentModel();
if (m) m->exportHTML();
}
void Main::fileExportImage()
{
VymModel *m=currentModel();
if (m) m->exportImage();
}
void Main::fileExportPDF()
{
VymModel *m=currentModel();
if (m) m->exportPDF();
}
void Main::fileExportSVG()
{
VymModel *m=currentModel();
if (m) m->exportSVG();
}
void Main::fileExportAO()
{
VymModel *m=currentModel();
if (m) m->exportAO();
}
void Main::fileExportASCII()
{
VymModel *m=currentModel();
if (m) m->exportASCII();
}
void Main::fileExportCSV() //FIXME-3 not scriptable yet
{
VymModel *m=currentModel();
if (m)
{
ExportCSV ex;
ex.setModel (m);
ex.addFilter ("CSV (*.csv)");
ex.setDir(lastImageDir);
ex.setWindowTitle(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
if (ex.execDialog() )
{
m->setExportMode(true);
ex.doExport();
m->setExportMode(false);
}
}
}
void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
{
VymModel *m=currentModel();
if (m)
{
ExportLaTeX ex;
ex.setModel (m);
ex.addFilter ("Tex (*.tex)");
ex.setDir(lastImageDir);
ex.setWindowTitle(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
if (ex.execDialog() )
{
m->setExportMode(true);
ex.doExport();
m->setExportMode(false);
}
}
}
void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
{
ExportKDE3Bookmarks ex;
VymModel *m=currentModel();
if (m)
{
ex.setModel (m);
ex.doExport();
}
}
void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
{
ExportKDE4Bookmarks ex;
VymModel *m=currentModel();
if (m)
{
ex.setModel (m);
ex.doExport();
}
}
void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
{
ExportTaskjuggler ex;
VymModel *m=currentModel();
if (m)
{
ex.setModel (m);
ex.setWindowTitle ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
ex.setDir(lastImageDir);
ex.addFilter ("Taskjuggler (*.tjp)");
if (ex.execDialog() )
{
m->setExportMode(true);
ex.doExport();
m->setExportMode(false);
}
}
}
void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
{
ExportOOFileDialog fd;
// TODO add preview in dialog
fd.setWindowTitle(vymName+" - "+tr("Export to")+" Open Office");
fd.setDirectory (QDir().current());
fd.setAcceptMode (QFileDialog::AcceptSave);
fd.setFileMode (QFileDialog::AnyFile);
if (fd.foundConfig())
{
if ( fd.exec() == QDialog::Accepted )
{
if (!fd.selectedFiles().isEmpty())
{
QString fn=fd.selectedFiles().first();
if (!fn.contains (".odp")) fn +=".odp";
//lastImageDir=fn.left(fn.findRev ("/"));
VymModel *m=currentModel();
if (m) m->exportOOPresentation(fn,fd.selectedConfig());
}
}
} else
{
QMessageBox::warning(0,
tr("Warning"),
tr("Couldn't find configuration for export to Open Office\n"));
}
}
void Main::fileExportLast()
{
VymModel *m=currentModel();
if (m) m->exportLast();
}
bool Main::fileCloseMap()
{
VymModel *m=currentModel();
if (m)
{
if (m->hasChanged())
{
QMessageBox mb( vymName,
tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
QMessageBox::Warning,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No,
QMessageBox::Cancel | QMessageBox::Escape );
mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
mb.setButtonText( QMessageBox::No, tr("Discard changes"));
mb.setModal (true);
mb.show();
//FIXME-3 not needed? mb.setActiveWindow();
switch( mb.exec() )
{
case QMessageBox::Yes:
// save and close
fileSave(m, CompleteMap);
break;
case QMessageBox::No:
// close without saving
break;
case QMessageBox::Cancel:
// do nothing
return true;
}
}
vymViews.removeAt (tabWidget->currentIndex() );
tabWidget->removeTab (tabWidget->currentIndex() );
delete (m);
updateActions();
return false;
}
return true; // Better don't exit vym if there is no currentModel()...
}
void Main::filePrint()
{
if (currentMapEditor())
currentMapEditor()->print();
}
bool Main::fileExitVYM()
{
fileSaveSession();
// Check if one or more editors have changed
int i=0;
while (vymViews.count()>0)
{
tabWidget->setCurrentIndex(i);
if (fileCloseMap()) return true;
}
qApp->quit();
return false;
}
void Main::editUndo()
{
VymModel *m=currentModel();
if (m) m->undo();
}
void Main::editRedo()
{
VymModel *m=currentModel();
if (m) m->redo();
}
void Main::gotoHistoryStep (int i)
{
VymModel *m=currentModel();
if (m) m->gotoHistoryStep(i);
}
void Main::editCopy()
{
VymModel *m=currentModel();
if (m) m->copy();
}
void Main::editPaste()
{
VymModel *m=currentModel();
if (m) m->paste();
}
void Main::editCut()
{
VymModel *m=currentModel();
if (m) m->cut();
}
void Main::openTabs(QStringList urls)
{
if (!urls.isEmpty())
{
bool success=true;
QStringList args;
QString browser=settings.value("/mainwindow/readerURL" ).toString();
//qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
if (*browserPID==0 ||
(browser.contains("konqueror") &&
!QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
)
{
// Start a new browser, if there is not one running already or
// if a previously started konqueror is gone.
if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
QString u=urls.takeFirst();
args<<u;
QString workDir=QDir::currentPath();
if (!QProcess::startDetached(browser,args,workDir,browserPID))
{
// try to set path to browser
QMessageBox::warning(0,
tr("Warning"),
tr("Couldn't find a viewer to open %1.\n").arg(u)+
tr("Please use Settings->")+tr("Set application to open an URL"));
return;
}
if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
#if defined(Q_OS_WIN32)
// There's no sleep in VCEE, replace it with Qt's QThread::wait().
this->thread()->wait(3000);
#else
sleep (3); //needed to open first konqueror
#endif
}
if (browser.contains("konqueror"))
{
for (int i=0; i<urls.size(); i++)
{
// Open new browser
// Try to open new tab in existing konqueror started previously by vym
args.clear();
args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
"/konqueror/MainWindow_1"<<
"newTab" <<
urls.at(i)<<
"false";
if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
if (!QProcess::startDetached ("qdbus",args))
success=false;
}
if (!success)
QMessageBox::warning(0,
tr("Warning"),
tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
return;
} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
{
for (int i=0; i<urls.size(); i++)
{
// Try to open new tab in firefox
args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
if (!QProcess::startDetached (browser,args))
success=false;
}
if (!success)
QMessageBox::warning(0,
tr("Warning"),
tr("Couldn't start %1 to open a new tab").arg(browser));
return;
}
QMessageBox::warning(0,
tr("Warning"),
tr("Sorry, currently only Konqueror supports integrated tabbed browsing.","Mainwindow, open URL")+
tr("Currently vym is using %1 to open external links.\n(Change in Settings menu)","Mainwindow, open URL")
.arg(settings.value("/mainwindow/readerURL" ).toString()));
}
}
void Main::editOpenURL()
{
// Open new browser
VymModel *m=currentModel();
if (m)
{
QString url=m->getURL();
QStringList args;
if (url=="") return;
QString browser=settings.value("/mainwindow/readerURL" ).toString();
args<<url;
QString workDir=QDir::currentPath();
if (!QProcess::startDetached(browser,args))
{
// try to set path to browser
QMessageBox::warning(0,
tr("Warning"),
tr("Couldn't find a viewer to open %1.\n").arg(url)+
tr("Please use Settings->")+tr("Set application to open an URL"));
settingsURL() ;
}
}
}
void Main::editOpenURLTab()
{
VymModel *m=currentModel();
if (m)
{
QStringList urls;
urls.append(m->getURL());
openTabs (urls);
}
}
void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
{
VymModel *m=currentModel();
if (m)
{
QStringList urls;
urls=m->getURLs(ignoreScrolled);
openTabs (urls);
}
}
void Main::editOpenMultipleURLTabs()
{
editOpenMultipleVisURLTabs (false);
}
void Main::editNote2URLs()
{
VymModel *m=currentModel();
if (m) m->note2URLs();
}
void Main::editURL()
{
VymModel *m=currentModel();
if (m)
{
QInputDialog dia (this);
dia.setLabelText (tr("Enter URL:"));
dia.setWindowTitle (vymName);
dia.setInputMode (QInputDialog::TextInput);
TreeItem *selti=m->getSelectedItem();
if (selti) dia.setTextValue (selti->getURL());
dia.resize(width()*0.8,0);
if ( dia.exec() ) m->setURL(dia.textValue() );
}
}
void Main::editLocalURL()
{
VymModel *m=currentModel();
if (m)
{
TreeItem *selti=m->getSelectedItem();
if (selti)
{
QStringList filters;
filters <<"All files (*)";
filters << tr("HTML","Filedialog") + " (*.html,*.htm)";
filters << tr("Text","Filedialog") + " (*.txt)";
filters << tr("Spreadsheet","Filedialog") + " (*.odp,*.sxc)";
filters << tr("Textdocument","Filedialog") +" (*.odw,*.sxw)";
filters << tr("Images","Filedialog") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)";
QFileDialog fd( NULL,vymName+" - " +tr("Set URL to a local file"));
fd.setFilters (filters);
fd.setWindowTitle(vymName+" - " +tr("Set URL to a local file"));
fd.setDirectory (lastMapDir);
fd.setAcceptMode (QFileDialog::AcceptOpen);
if (! selti->getVymLink().isEmpty() )
fd.selectFile( selti->getURL() );
fd.show();
if ( fd.exec() == QDialog::Accepted &&!fd.selectedFiles().isEmpty() )
{
lastMapDir=QDir (fd.directory().path());
m->setURL (fd.selectedFiles().first() );
}
}
}
}
void Main::editHeading2URL()
{
VymModel *m=currentModel();
if (m) m->editHeading2URL();
}
void Main::editBugzilla2URL()
{
VymModel *m=currentModel();
if (m) m->editBugzilla2URL();
}
void Main::getBugzillaData()
{
VymModel *m=currentModel();
/*
QProgressDialog progress ("Doing stuff","cancl",0,10,this);
progress.setWindowModality(Qt::WindowModal);
//progress.setCancelButton (NULL);
progress.show();
progress.setMinimumDuration (0);
progress.setValue (1);
progress.setValue (5);
progress.update();
*/
/*
QProgressBar *pb=new QProgressBar;
pb->setMinimum (0);
pb->setMaximum (0);
pb->show();
pb->repaint();
*/
if (m) m->getBugzillaData(false);
}
void Main::getBugzillaDataSubtree()
{
VymModel *m=currentModel();
if (m) m->getBugzillaData(true);
}
void Main::editFATE2URL()
{
VymModel *m=currentModel();
if (m) m->editFATE2URL();
}
void Main::editHeadingFinished(VymModel *m)
{
if (m)
{
if (!actionSettingsAutoSelectNewBranch->isChecked() &&
!prevSelection.isEmpty())
m->select(prevSelection);
prevSelection="";
}
}
void Main::openVymLinks(const QStringList &vl)
{
QStringList vlmin;
int index;
for (int j=0; j<vl.size(); ++j)
{
// compare path with already loaded maps
int i;
index=-1;
for (i=0;i<=vymViews.count() -1;i++)
{
if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
{
index=i;
break;
}
}
if (index<0) vlmin.append (vl.at(j));
}
progressCounterTotal=vlmin.size();
for (int j=0; j<vlmin.size(); j++)
{
// Load map
if (!QFile(vlmin.at(j)).exists() )
QMessageBox::critical( 0, tr( "Critical Error" ),
tr("Couldn't open map %1").arg(vlmin.at(j)));
else
{
fileLoad (vlmin.at(j), NewMap);
tabWidget->setCurrentIndex (tabWidget->count()-1);
}
}
// Go to tab containing the map
if (index>=0)
tabWidget->setCurrentIndex (index);
removeProgressCounter();
}
void Main::editOpenVymLink()
{
VymModel *m=currentModel();
if (m)
{
QStringList vl;
vl.append(m->getVymLink());
openVymLinks (vl);
}
}
void Main::editOpenMultipleVymLinks()
{
QString currentVymLink;
VymModel *m=currentModel();
if (m)
{
QStringList vl=m->getVymLinks();
openVymLinks (vl);
}
}
void Main::editVymLink()
{
VymModel *m=currentModel();
if (m)
{
BranchItem *bi=m->getSelectedBranch();
if (bi)
{
QStringList filters;
filters <<"VYM map (*.vym)";
QFileDialog fd;
fd.setWindowTitle (vymName+" - " +tr("Link to another map"));
fd.setFilters (filters);
fd.setWindowTitle(vymName+" - " +tr("Link to another map"));
fd.setDirectory (lastMapDir);
fd.setAcceptMode (QFileDialog::AcceptOpen);
if (! bi->getVymLink().isEmpty() )
fd.selectFile( bi->getVymLink() );
fd.show();
QString fn;
if ( fd.exec() == QDialog::Accepted &&!fd.selectedFiles().isEmpty() )
{
QString fn=fd.selectedFiles().first();
lastMapDir=QDir (fd.directory().path());
m->setVymLink (fn);
}
}
}
}
void Main::editDeleteVymLink()
{
VymModel *m=currentModel();
if (m) m->deleteVymLink();
}
void Main::editToggleHideExport()
{
VymModel *m=currentModel();
if (m) m->toggleHideExport();
}
void Main::editAddTimestamp()
{
VymModel *m=currentModel();
if (m) m->addTimestamp();
}
void Main::editMapInfo()
{
VymModel *m=currentModel();
if (!m) return;
ExtraInfoDialog dia;
dia.setMapName (m->getFileName() );
dia.setAuthor (m->getAuthor() );
dia.setComment(m->getComment() );
// Calc some stats
QString stats;
stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
uint b=0;
uint f=0;
uint n=0;
uint xl=0;
BranchItem *cur=NULL;
BranchItem *prev=NULL;
m->nextBranch(cur,prev);
while (cur)
{
if (!cur->getNote().isEmpty() ) n++;
f+= cur->imageCount();
b++;
xl+=cur->xlinkCount();
m->nextBranch(cur,prev);
}
stats+=QString ("%1 xLinks \n").arg (xl/2,6);
stats+=QString ("%1 notes\n").arg (n,6);
stats+=QString ("%1 images\n").arg (f,6);
stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
dia.setStats (stats);
// Finally show dialog
if (dia.exec() == QDialog::Accepted)
{
m->setAuthor (dia.getAuthor() );
m->setComment (dia.getComment() );
}
}
void Main::editMoveUp()
{
VymModel *m=currentModel();
if (m) m->moveUp();
}
void Main::editMoveDown()
{
VymModel *m=currentModel();
if (m) m->moveDown();
}
void Main::editDetach()
{
VymModel *m=currentModel();
if (m) m->detach();
}
void Main::editSortChildren()
{
VymModel *m=currentModel();
if (m) m->sortChildren(false);
}
void Main::editSortBackChildren()
{
VymModel *m=currentModel();
if (m) m->sortChildren(true);
}
void Main::editToggleScroll()
{
VymModel *m=currentModel();
if (m) m->toggleScroll();
}
void Main::editExpandAll()
{
VymModel *m=currentModel();
if (m) m->emitExpandAll();
}
void Main::editExpandOneLevel()
{
VymModel *m=currentModel();
if (m) m->emitExpandOneLevel();
}
void Main::editCollapseOneLevel()
{
VymModel *m=currentModel();
if (m) m->emitCollapseOneLevel();
}
void Main::editCollapseUnselected()
{
VymModel *m=currentModel();
if (m) m->emitCollapseUnselected();
}
void Main::editUnscrollChildren()
{
VymModel *m=currentModel();
if (m) m->unscrollChildren();
}
void Main::editGrowSelectionSize()
{
VymModel *m=currentModel();
if (m) m->growSelectionSize();
}
void Main::editShrinkSelectionSize()
{
VymModel *m=currentModel();
if (m) m->shrinkSelectionSize();
}
void Main::editResetSelectionSize()
{
VymModel *m=currentModel();
if (m) m->resetSelectionSize();
}
void Main::editAddAttribute()
{
VymModel *m=currentModel();
if (m)
{
m->addAttribute();
}
}
void Main::editAddMapCenter()
{
VymModel *m=currentModel();
if (m)
{
m->select (m->addMapCenter ());
MapEditor *me=currentMapEditor();
if (me)
{
m->setHeading("");
me->editHeading();
}
}
}
void Main::editNewBranch()
{
VymModel *m=currentModel();
if (m)
{
BranchItem *bi=m->addNewBranch();
if (!bi) return;
if (actionSettingsAutoEditNewBranch->isChecked()
&& !actionSettingsAutoSelectNewBranch->isChecked() )
prevSelection=m->getSelectString();
else
prevSelection=QString();
if (actionSettingsAutoSelectNewBranch->isChecked()
|| actionSettingsAutoEditNewBranch->isChecked())
{
m->select (bi);
if (actionSettingsAutoEditNewBranch->isChecked())
currentMapEditor()->editHeading();
}
}
}
void Main::editNewBranchBefore()
{
VymModel *m=currentModel();
if (m)
{
BranchItem *bi=m->addNewBranchBefore();
if (bi)
m->select (bi);
else
return;
if (actionSettingsAutoEditNewBranch->isChecked())
{
if (!actionSettingsAutoSelectNewBranch->isChecked())
prevSelection=m->getSelectString(bi);
currentMapEditor()->editHeading();
}
}
}
void Main::editNewBranchAbove()
{
VymModel *m=currentModel();
if ( m)
{
BranchItem *bi=m->addNewBranch (-1);
if (bi)
m->select (bi);
else
return;
if (actionSettingsAutoEditNewBranch->isChecked())
{
if (!actionSettingsAutoSelectNewBranch->isChecked())
prevSelection=m->getSelectString (bi);
currentMapEditor()->editHeading();
}
}
}
void Main::editNewBranchBelow()
{
VymModel *m=currentModel();
if (m)
{
BranchItem *bi=m->addNewBranch (1);
if (bi)
m->select (bi);
else
return;
if (actionSettingsAutoEditNewBranch->isChecked())
{
if (!actionSettingsAutoSelectNewBranch->isChecked())
prevSelection=m->getSelectString(bi);
currentMapEditor()->editHeading();
}
}
}
void Main::editImportAdd()
{
fileLoad (ImportAdd);
}
void Main::editImportReplace()
{
fileLoad (ImportReplace);
}
void Main::editSaveBranch()
{
fileSaveAs (PartOfMap);
}
void Main::editDeleteKeepChildren()
{
VymModel *m=currentModel();
if (m) m->deleteKeepChildren();
}
void Main::editDeleteChildren()
{
VymModel *m=currentModel();
if (m) m->deleteChildren();
}
void Main::editDeleteSelection()
{
VymModel *m=currentModel();
if (m && actionSettingsUseDelKey->isChecked())
m->deleteSelection();
}
void Main::editLoadImage()
{
VymModel *m=currentModel();
if (m) m->loadFloatImage();
}
void Main::editSaveImage()
{
VymModel *m=currentModel();
if (m) m->saveFloatImage();
}
void Main::editEditXLink(QAction *a)
{
VymModel *m=currentModel();
if (m)
{
BranchItem *selbi=m->getSelectedBranch();
if (selbi)
{
Link *l=selbi->getXLinkItemNum(branchXLinksContextMenuEdit->actions().indexOf(a))->getLink();
if (l && m->select (l->getBeginLinkItem() ) )
m->editXLink();
}
}
}
void Main::popupFollowXLink()
{
branchXLinksContextMenuFollow->exec( QCursor::pos());
}
void Main::editFollowXLink(QAction *a)
{
VymModel *m=currentModel();
if (m)
m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
}
void Main::editToggleTarget()
{
VymModel *m=currentModel();
if (m) m->toggleTarget();
}
void Main::editGoToTarget()
{
VymModel *m=currentModel();
if (m)
{
targetsContextMenu->clear();
ItemList targets=m->getTargets();
QMap<uint,QString>::const_iterator i = targets.constBegin();
while (i != targets.constEnd())
{
(targetsContextMenu->addAction (i.value() ) )->setData (i.key());
++i;
}
QAction *a=targetsContextMenu->exec (QCursor::pos());
if (a) m->select (m->findID (a->data().toUInt() ) );
}
}
void Main::editMoveToTarget()
{
VymModel *m=currentModel();
if (m)
{
targetsContextMenu->clear();
ItemList targets=m->getTargets();
QMap<uint,QString>::const_iterator i = targets.constBegin();
while (i != targets.constEnd())
{
(targetsContextMenu->addAction (i.value() ) )->setData (i.key());
++i;
}
QAction *a=targetsContextMenu->exec (QCursor::pos());
if (a)
{
TreeItem *ti=m->findID (a->data().toUInt());
BranchItem *selbi=m->getSelectedBranch();
if (!selbi) return;
if (ti && ti->isBranchLikeType() && selbi)
{
BranchItem *pi =selbi->parentBranch();
// If branch below exists, select that one
// Makes it easier to quickly resort using the MoveTo function
BranchItem *below=pi->getBranchNum(selbi->num()+1);
LinkableMapObj *lmo=selbi->getLMO();
QPointF orgPos;
if (lmo) orgPos=lmo->getAbsPos();
m->relinkBranch ( selbi, (BranchItem*)ti,-1,true,orgPos);
if (below)
m->select (below);
else
if (pi) m->select (pi);
}
}
}
}
void Main::editSelectPrevious()
{
VymModel *m=currentModel();
if (m) m->selectPrevious();
}
void Main::editSelectNext()
{
VymModel *m=currentModel();
if (m) m->selectNext();
}
void Main::editOpenFindResultWidget()
{
if (!findResultWidget->parentWidget()->isVisible())
{
// findResultWidget->parentWidget()->show();
findResultWidget->popup();
} else
findResultWidget->parentWidget()->hide();
}
/* FIXME-3 not needed
void Main::editHideFindWidget()
{
// findWidget hides itself, but we want
// to have focus back at mapEditor usually
MapEditor *me=currentMapEditor();
if (me) me->setFocus();
}
*/
#include "findwidget.h" // FIXME-3 Integrated FRW and FW
void Main::editFindNext(QString s)
{
Qt::CaseSensitivity cs=Qt::CaseInsensitive;
VymModel *m=currentModel();
if (m)
{
if (m->findAll (findResultWidget->getResultModel(),s,cs) )
findResultWidget->setStatus (FindWidget::Success);
else
findResultWidget->setStatus (FindWidget::Failed);
}
}
void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
{
VymModel *m=currentModel();
if (m) m->findDuplicateURLs();
}
void Main::updateQueries (VymModel* m) //FIXME-3 disabled for now to avoid selection in FRW
{
// qDebug() << "MW::updateQueries m="<<m<<" cM="<<currentModel();
return;
if (m && currentModel()==m)
{
QString s=findResultWidget->getFindText();
if (!s.isEmpty() ) editFindNext (s);
}
}
void Main::formatSelectColor()
{
QColor col = QColorDialog::getColor((currentColor ), this );
if ( !col.isValid() ) return;
colorChanged( col );
}
void Main::formatPickColor()
{
VymModel *m=currentModel();
if (m)
colorChanged( m->getCurrentHeadingColor() );
}
void Main::colorChanged(QColor c)
{
QPixmap pix( 16, 16 );
pix.fill( c );
actionFormatColor->setIcon( pix );
currentColor=c;
}
void Main::formatColorBranch()
{
VymModel *m=currentModel();
if (m) m->colorBranch(currentColor);
}
void Main::formatColorSubtree()
{
VymModel *m=currentModel();
if (m) m->colorSubtree (currentColor);
}
void Main::formatLinkStyleLine()
{
VymModel *m=currentModel();
if (m)
{
m->setMapLinkStyle("StyleLine");
actionFormatLinkStyleLine->setChecked(true);
}
}
void Main::formatLinkStyleParabel()
{
VymModel *m=currentModel();
if (m)
{
m->setMapLinkStyle("StyleParabel");
actionFormatLinkStyleParabel->setChecked(true);
}
}
void Main::formatLinkStylePolyLine()
{
VymModel *m=currentModel();
if (m)
{
m->setMapLinkStyle("StylePolyLine");
actionFormatLinkStylePolyLine->setChecked(true);
}
}
void Main::formatLinkStylePolyParabel()
{
VymModel *m=currentModel();
if (m)
{
m->setMapLinkStyle("StylePolyParabel");
actionFormatLinkStylePolyParabel->setChecked(true);
}
}
void Main::formatSelectBackColor()
{
VymModel *m=currentModel();
if (m) m->selectMapBackgroundColor();
}
void Main::formatSelectBackImage()
{
VymModel *m=currentModel();
if (m)
m->selectMapBackgroundImage();
}
void Main::formatSelectLinkColor()
{
VymModel *m=currentModel();
if (m)
{
QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
m->setMapDefLinkColor( col );
}
}
void Main::formatSelectSelectionColor()
{
VymModel *m=currentModel();
if (m)
{
QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
m->setSelectionColor (col);
}
}
void Main::formatSelectFont()
{
VymModel *m=currentModel();
if (m)
{
bool ok;
QFont font = QFontDialog::getFont( &ok, m->getMapDefaultFont(), this);
if (ok)
{
m->setMapDefaultFont (font);
m->setMapDefaultFontSize (font.pointSizeF() );
}
}
}
void Main::formatToggleLinkColorHint()
{
VymModel *m=currentModel();
if (m) m->toggleMapLinkColorHint();
}
void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
{
VymModel *m=currentModel();
if (m)
m->setHideLinkUnselected(actionFormatHideLinkUnselected->isChecked());
}
void Main::viewZoomReset()
{
MapEditor *me=currentMapEditor();
if (me) me->setZoomFactorTarget (1);
}
void Main::viewZoomIn()
{
MapEditor *me=currentMapEditor();
if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.15);
}
void Main::viewZoomOut()
{
MapEditor *me=currentMapEditor();
if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.85);
}
void Main::viewCenter()
{
VymModel *m=currentModel();
if (m) m->emitShowSelection();
}
void Main::networkStartServer()
{
VymModel *m=currentModel();
if (m) m->newServer();
}
void Main::networkConnect()
{
VymModel *m=currentModel();
if (m) m->connectToServer();
}
bool Main::settingsPDF()
{
// Default browser is set in constructor
bool ok;
QString text = QInputDialog::getText(
this,
"VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
settings.value("/mainwindow/readerPDF").toString(), &ok);
if (ok)
settings.setValue ("/mainwindow/readerPDF",text);
return ok;
}
bool Main::settingsURL()
{
// Default browser is set in constructor
bool ok;
QString text = QInputDialog::getText(
this,
"VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
settings.value("/mainwindow/readerURL").toString()
, &ok);
if (ok)
settings.setValue ("/mainwindow/readerURL",text);
return ok;
}
void Main::settingsMacroDir()
{
QDir defdir(vymBaseDir.path() + "/macros");
if (!defdir.exists())
defdir=vymBaseDir;
QDir dir=QFileDialog::getExistingDirectory (
this,
tr ("Directory with vym macros:"),
settings.value ("/macros/macroDir",defdir.path()).toString()
);
if (dir.exists())
settings.setValue ("/macros/macroDir",dir.absolutePath());
}
void Main::settingsUndoLevels()
{
bool ok;
int i = QInputDialog::getInteger(
this,
"QInputDialog::getInteger()",
tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
if (ok)
{
settings.setValue ("/mapeditor/stepsTotal",i);
QMessageBox::information( this, tr( "VYM -Information:" ),
tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
}
}
void Main::settingsAutosaveToggle()
{
settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isChecked() );
}
void Main::settingsAutosaveTime()
{
bool ok;
int i = QInputDialog::getInteger(
this,
"QInputDialog::getInteger()",
tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 60000, 1, &ok);
if (ok)
settings.setValue ("/mainwindow/autosave/ms",i * 1000);
}
void Main::settingsAutoLayoutToggle()
{
settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutosaveToggle->isChecked() );
}
void Main::settingsWriteBackupFileToggle()
{
settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isChecked() );
}
void Main::settingsToggleNoteEditorIsDockWindow()
{
QMessageBox::information(0,
tr("Information"),
tr("Changed settings will be applied after restarting vym"));
}
void Main::settingsToggleAnimation()
{
settings.setValue ("/animation/use",actionSettingsUseAnimation->isChecked() );
}
void Main::settingsToggleDelKey()
{
if (actionSettingsUseDelKey->isChecked())
{
actionDelete->setShortcut (QKeySequence (Qt::Key_Delete));
} else
{
actionDelete->setShortcut (QKeySequence (""));
}
}
void Main::windowToggleNoteEditor()
{
if (noteEditor->isVisible() )
windowHideNoteEditor();
else
windowShowNoteEditor();
}
void Main::windowToggleTreeEditor()
{
if ( tabWidget->currentWidget())
vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
}
void Main::windowToggleHistory()
{
if (historyWindow->isVisible())
historyWindow->hide();
else
historyWindow->show();
}
void Main::windowToggleProperty()
{
if (branchPropertyWindow->isVisible())
branchPropertyWindow->hide();
else
branchPropertyWindow->show();
branchPropertyWindow->setModel (currentModel() );
}
void Main::windowToggleAntiAlias()
{
bool b=actionViewToggleAntiAlias->isChecked();
MapEditor *me;
for (int i=0;i<vymViews.count();i++)
{
me=vymViews.at(i)->getMapEditor();
if (me) me->setAntiAlias(b);
}
}
bool Main::isAliased()
{
return actionViewToggleAntiAlias->isChecked();
}
bool Main::hasSmoothPixmapTransform()
{
return actionViewToggleSmoothPixmapTransform->isChecked();
}
void Main::windowToggleSmoothPixmap()
{
bool b=actionViewToggleSmoothPixmapTransform->isChecked();
MapEditor *me;
for (int i=0;i<vymViews.count();i++)
{
me=vymViews.at(i)->getMapEditor();
if (me) me->setSmoothPixmap(b);
}
}
void Main::updateHistory(SimpleSettings &undoSet)
{
historyWindow->update (undoSet);
}
void Main::updateHeading()
{
VymModel *m=currentModel();
if (m) m->setHeading (headingEditor->getText() );
}
void Main::updateNoteFlag()
{
// this slot is connected to noteEditor::textHasChanged()
VymModel *m=currentModel();
if (m) m->updateNoteFlag();
}
void Main::updateNoteEditor(QModelIndex index )
{
TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
/*
cout << "Main::updateNoteEditor model="<<sender();
cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
*/
noteEditor->setNote (ti->getNoteObj() );
}
void Main::selectInNoteEditor(QString s,int i)
{
// TreeItem is already selected at this time, therefor
// the note is already in the editor
noteEditor->findText (s,0,i);
}
void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
{
branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
if (model && model==currentModel() )
{
// NoteEditor
TreeItem *ti;
if (!oldsel.indexes().isEmpty() )
{
ti=model->getItem(oldsel.indexes().first());
// Don't update note if both treeItem and noteEditor are empty
//if (! (ti->hasEmptyNote() && noteEditor->isEmpty() ))
// ti->setNoteObj (noteEditor->getNoteObj(),false );
}
if (!newsel.indexes().isEmpty() )
{
ti=model->getItem(newsel.indexes().first());
if (!ti->hasEmptyNote() )
noteEditor->setNote(ti->getNoteObj() );
else
noteEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
// Show URL and link in statusbar
QString status;
QString s=ti->getURL();
if (!s.isEmpty() ) status+="URL: "+s+" ";
s=ti->getVymLink();
if (!s.isEmpty() ) status+="Link: "+s;
if (!status.isEmpty() ) statusMessage (status);
headingEditor->setText (ti->getHeading() );
} else
noteEditor->setInactive();
updateActions();
}
}
void Main::updateActions()
{
// updateActions is also called when satellites are closed
actionViewToggleNoteEditor->setChecked (noteEditor->isVisible());
actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
if ( tabWidget->currentWidget())
actionViewToggleTreeEditor->setChecked (
vymViews.at(tabWidget->currentIndex())->getTreeEditor()->isVisible()
);
VymModel *m =currentModel();
if (m)
{
// Printing
actionFilePrint->setEnabled (true);
// Link style in context menu
switch (m->getMapLinkStyle())
{
case LinkableMapObj::Line:
actionFormatLinkStyleLine->setChecked(true);
break;
case LinkableMapObj::Parabel:
actionFormatLinkStyleParabel->setChecked(true);
break;
case LinkableMapObj::PolyLine:
actionFormatLinkStylePolyLine->setChecked(true);
break;
case LinkableMapObj::PolyParabel:
actionFormatLinkStylePolyParabel->setChecked(true);
break;
default:
break;
}
// Update colors
QPixmap pix( 16, 16 );
pix.fill( m->getMapBackgroundColor() );
actionFormatBackColor->setIcon( pix );
pix.fill( m->getSelectionColor() );
actionFormatSelectionColor->setIcon( pix );
pix.fill( m->getMapDefLinkColor() );
actionFormatLinkColor->setIcon( pix );
// Selection history
if (m->canSelectPrevious() )
actionSelectPrevious->setEnabled(true);
else
actionSelectPrevious->setEnabled(false);
if (m->canSelectNext() )
actionSelectNext->setEnabled(true);
else
actionSelectNext->setEnabled(false);
// History window
historyWindow->setWindowTitle (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
// Expanding/collapsing
actionExpandAll->setEnabled (true);
actionExpandOneLevel->setEnabled (true);
actionCollapseOneLevel->setEnabled (true);
actionCollapseUnselected->setEnabled (true);
} else
{
// Printing
actionFilePrint->setEnabled (false);
// Expanding/collapsing
actionExpandAll->setEnabled (false);
actionExpandOneLevel->setEnabled (false);
actionCollapseOneLevel->setEnabled (false);
actionCollapseUnselected->setEnabled (false);
}
if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
actionFormatLinkColorHint->setChecked(true);
else
actionFormatLinkColorHint->setChecked(false);
if (m && m->hasChanged() )
actionFileSave->setEnabled( true);
else
actionFileSave->setEnabled( false);
if (m && m->isUndoAvailable())
actionUndo->setEnabled( true);
else
actionUndo->setEnabled( false);
if (m && m->isRedoAvailable())
actionRedo->setEnabled( true);
else
actionRedo->setEnabled( false);
// Export last
QString s, t, u;
if (m && m->exportLastAvailable(s,t,u) )
actionFileExportLast->setEnabled (true);
else
{
actionFileExportLast->setEnabled (false);
t=u="";
s=" - ";
}
actionFileExportLast->setText( tr( "Export in last used format (%1) to: %2","status tip" ).arg(s).arg(u));
if (m)
{
TreeItem *selti=m->getSelectedItem();
BranchItem *selbi=m->getSelectedBranch();
if (selti)
{
actionToggleTarget->setChecked (selti->isTarget() );
if (selbi || selti->getType()==TreeItem::Image)
{
actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
actionFormatHideLinkUnselected->setEnabled (true);
}
if (selbi)
{
actionHeading2URL->setEnabled (true);
// Note
actionGetURLsFromNote->setEnabled (!selbi->getNote().isEmpty());
// Take care of xlinks
// FIXME-3 similar code in mapeditor mousePressEvent
int b=selbi->xlinkCount();
branchXLinksContextMenuEdit->setEnabled(b);
branchXLinksContextMenuFollow->setEnabled(b);
branchXLinksContextMenuEdit->clear();
branchXLinksContextMenuFollow->clear();
if (b)
{
BranchItem *bi;
QString s;
for (int i=0; i<selbi->xlinkCount();++i)
{
bi=selbi->getXLinkItemNum(i)->getPartnerBranch();
if (bi)
{
s=bi->getHeading();
if (s.length()>xLinkMenuWidth)
s=s.left(xLinkMenuWidth)+"...";
branchXLinksContextMenuEdit->addAction (s);
branchXLinksContextMenuFollow->addAction (s);
}
}
}
//Standard Flags
standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
// System Flags
actionToggleScroll->setEnabled (true);
if ( selbi->isScrolled() )
actionToggleScroll->setChecked(true);
else
actionToggleScroll->setChecked(false);
actionGetBugzillaDataSubtree->setEnabled (bugzillaClientAvailable);
if ( selti->getURL().isEmpty() )
{
actionOpenURL->setEnabled (false);
actionOpenURLTab->setEnabled (false);
actionGetBugzillaData->setEnabled (false);
}
else
{
actionOpenURL->setEnabled (true);
actionOpenURLTab->setEnabled (true);
actionGetBugzillaData->setEnabled (
selti->getURL().contains("bugzilla") && bugzillaClientAvailable);
}
if ( selti->getVymLink().isEmpty() )
{
actionOpenVymLink->setEnabled (false);
actionDeleteVymLink->setEnabled (false);
} else
{
actionOpenVymLink->setEnabled (true);
actionDeleteVymLink->setEnabled (true);
}
if (selbi->canMoveUp())
actionMoveUp->setEnabled (true);
else
actionMoveUp->setEnabled (false);
if (selbi->canMoveDown())
actionMoveDown->setEnabled (true);
else
actionMoveDown->setEnabled (false);
actionSortChildren->setEnabled (true);
actionSortBackChildren->setEnabled (true);
actionToggleHideExport->setEnabled (true);
actionToggleHideExport->setChecked (selbi->hideInExport() );
actionCopy->setEnabled (true);
actionCut->setEnabled (true);
if (!clipboardEmpty)
actionPaste->setEnabled (true);
else
actionPaste->setEnabled (false);
for (int i=0; i<actionListBranches.size(); ++i)
actionListBranches.at(i)->setEnabled(true);
actionDelete->setEnabled (true);
actionDeleteChildren->setEnabled (true);
} // Branch
if ( selti->getType()==TreeItem::Image)
{
actionOpenURL->setEnabled (false);
actionOpenVymLink->setEnabled (false);
actionDeleteVymLink->setEnabled (false);
actionToggleHideExport->setEnabled (true);
actionToggleHideExport->setChecked (selti->hideInExport() );
actionCopy->setEnabled (true);
actionCut->setEnabled (true);
actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
for (int i=0; i<actionListBranches.size(); ++i)
actionListBranches.at(i)->setEnabled(false);
actionDelete->setEnabled (true);
actionMoveUp->setEnabled (false);
actionMoveDown->setEnabled (false);
} // Image
} else
{ // !selti
actionCopy->setEnabled (false);
actionCut->setEnabled (false);
actionPaste->setEnabled (false);
for (int i=0; i<actionListBranches.size(); ++i)
actionListBranches.at(i)->setEnabled(false);
actionToggleScroll->setEnabled (false);
actionOpenURL->setEnabled (false);
actionOpenVymLink->setEnabled (false);
actionDeleteVymLink->setEnabled (false);
actionHeading2URL->setEnabled (false);
actionDelete->setEnabled (false);
actionDeleteChildren->setEnabled (false);
actionMoveUp->setEnabled (false);
actionMoveDown->setEnabled (false);
actionFormatHideLinkUnselected->setEnabled (false);
actionSortChildren->setEnabled (false);
actionSortBackChildren->setEnabled (false);
actionToggleHideExport->setEnabled (false);
actionToggleTarget->setChecked (false);
}
} // m
}
Main::ModMode Main::getModMode()
{
if (actionModModeColor->isChecked()) return ModModeColor;
if (actionModModeCopy->isChecked()) return ModModeCopy;
if (actionModModeXLink->isChecked()) return ModModeXLink;
return ModModeNone;
}
bool Main::autoEditNewBranch()
{
return actionSettingsAutoEditNewBranch->isChecked();
}
bool Main::autoSelectNewBranch()
{
return actionSettingsAutoSelectNewBranch->isChecked();
}
void Main::windowShowNoteEditor()
{
noteEditor->setShowWithMain(true);
noteEditor->show();
actionViewToggleNoteEditor->setChecked (true);
}
void Main::windowHideNoteEditor()
{
noteEditor->setShowWithMain(false);
noteEditor->hide();
actionViewToggleNoteEditor->setChecked (false);
}
void Main::setScript (const QString &script)
{
scriptEditor->setScript (script);
}
void Main::runScript (const QString &script)
{
VymModel *m=currentModel();
if (m) m->runScript (script);
}
void Main::runScriptEverywhere (const QString &script)
{
MapEditor *me;
for (int i=0;i<=tabWidget->count() -1;i++)
{
me=(MapEditor*)tabWidget->widget(i);
if (me) me->getModel()->runScript (script);
}
}
void Main::windowNextEditor()
{
if (tabWidget->currentIndex() < tabWidget->count())
tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
}
void Main::windowPreviousEditor()
{
if (tabWidget->currentIndex() >0)
tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
}
void Main::standardFlagChanged()
{
if (currentModel())
{
if ( actionSettingsUseFlagGroups->isChecked() )
currentModel()->toggleStandardFlag(sender()->objectName(),standardFlagsMaster);
else
currentModel()->toggleStandardFlag(sender()->objectName());
updateActions();
}
}
void Main::testFunction1()
{
if (!currentMapEditor()) return;
currentMapEditor()->testFunction1();
}
void Main::testFunction2()
{
if (!currentMapEditor()) return;
currentMapEditor()->testFunction2();
}
void Main::testCommand()
{
if (!currentMapEditor()) return;
scriptEditor->show();
}
void Main::helpDoc()
{
QString locale = QLocale::system().name();
QString docname;
if (locale.left(2)=="es")
docname="vym_es.pdf";
else
docname="vym.pdf";
QStringList searchList;
QDir docdir;
#if defined(Q_OS_MACX)
searchList << "./vym.app/Contents/Resources/doc";
#elif defined(Q_OS_WIN32)
searchList << vymInstallDir.path() + "/share/doc/packages/vym";
#else
#if defined(VYM_DOCDIR)
searchList << VYM_DOCDIR;
#endif
// default path in SUSE LINUX
searchList << "/usr/share/doc/packages/vym";
#endif
searchList << "doc"; // relative path for easy testing in tarball
searchList << "doc/tex"; // Easy testing working on vym.tex
searchList << "/usr/share/doc/vym"; // Debian
searchList << "/usr/share/doc/packages";// Knoppix
bool found=false;
QFile docfile;
for (int i=0; i<searchList.count(); ++i)
{
docfile.setFileName(searchList.at(i)+"/"+docname);
if (docfile.exists())
{
found=true;
break;
}
}
if (!found)
{
QMessageBox::critical(0,
tr("Critcal error"),
tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
return;
}
QStringList args;
Process *pdfProc = new Process();
args << QDir::toNativeSeparators(docfile.fileName());
if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
{
// error handling
QMessageBox::warning(0,
tr("Warning"),
tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
tr("Please use Settings->")+tr("Set application to open PDF files"));
settingsPDF();
return;
}
}
void Main::helpDemo()
{
QStringList filters;
filters <<"VYM example map (*.vym)";
QFileDialog fd;
#if defined(Q_OS_MACX)
fd.setDir (QDir("./vym.app/Contents/Resources/demos"));
#else
// default path in SUSE LINUX
fd.setDirectory (QDir(vymBaseDir.path()+"/demos"));
#endif
fd.setFileMode (QFileDialog::ExistingFiles);
fd.setFilters (filters);
fd.setWindowTitle (vymName+ " - " +tr("Load vym example map"));
fd.setAcceptMode (QFileDialog::AcceptOpen);
QString fn;
if ( fd.exec() == QDialog::Accepted )
{
lastMapDir=fd.directory().path();
QStringList flist = fd.selectedFiles();
QStringList::Iterator it = flist.begin();
while( it != flist.end() )
{
fn = *it;
fileLoad(*it, NewMap);
++it;
}
}
}
void Main::helpAbout()
{
AboutDialog ad;
ad.setMinimumSize(500,500);
ad.resize (QSize (500,500));
ad.exec();
}
void Main::helpAboutQT()
{
QMessageBox::aboutQt( this, "Qt Application Example" );
}
void Main::callMacro ()
{
QAction *action = qobject_cast<QAction *>(sender());
int i=-1;
if (action)
{
i=action->data().toInt();
QString mDir (settings.value ("macros/macroDir",vymBaseDir.path()+"/macros").toString() );
QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
QFile f (fn);
if ( !f.open( QIODevice::ReadOnly ) )
{
QMessageBox::warning(0,
tr("Warning"),
tr("Couldn't find a macro at %1.\n").arg(fn)+
tr("Please use Settings->")+tr("Set directory for vym macros"));
return;
}
QTextStream ts( &f );
QString macro= ts.readAll();
if (! macro.isEmpty())
{
VymModel *m=currentModel();
if (m) m->runScript(macro);
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.