/usr/share/treeline/treemainwin.py is in treeline 1.4.1-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #!/usr/bin/env python
#****************************************************************************
# treemainwin.py, provides a class for the main window
#
# TreeLine, an information storage program
# Copyright (C) 2009, Douglas W. Bell
#
# This is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License, either Version 2 or any later
# version. This program is distributed in the hope that it will be useful,
# but WITTHOUT ANY WARRANTY. See the included LICENSE file for details.
#*****************************************************************************
import sys
import os.path
import base64
from PyQt4 import QtCore, QtGui
try:
from __main__ import __version__, __author__, helpFilePath
except ImportError:
__version__ = __author__ = '??'
helpFilePath = None
import treedoc
import treeview
import treeflatview
import treerightviews
import treeeditviews
import configdialog
import treedialogs
import printdata
import globalref
import optiondefaults
import optiondlg
import output
import helpview
import spellcheck
import plugininterface
class TreeMainWin(QtGui.QMainWindow):
"""Main window, menus, toolbar, and status"""
toolIcons = None
configDlg = None
setTypeDlg = None
sortDlg = None
findDlg = None
helpView = None
tlPlainFileFilter = u'%s (*.trl *.xml)' % _('TreeLine Files - Plain')
tlCompFileFilter = u'%s (*.trl *.trl.gz)' % \
_('TreeLine Files - Compressed')
tlEncryptFileFilter = u'%s (*.trl)' % _('TreeLine Files - Encrypted')
tlGenFileFilter = u'%s (*.trl *.xml *.trl.gz)' % _('TreeLine Files')
allFileFilter = u'%s (*)' % _('All Files')
textFileFilter = u'%s (*.txt)' % _('Text Files')
treepadFileFilter = u'%s (*.hjt)' % _('Treepad Files')
xbelFileFilter = u'%s (*.xml)' % _('XBEL Bookmarks')
mozFileFilter = u'%s (*.html *.htm)' % _('Mozilla Bookmarks')
htmlFileFilter = u'%s (*.html *.htm)' % _('Html Files')
xsltFileFilter = u'%s (*.xsl *.xslt)' % _('XSLT Files')
tableFileFilter = u'%s (*.tbl *.txt)' % _('Table Files')
xmlFileFilter = u'%s (*.xml)' % _('XML Files')
odfFileFilter = u'%s (*.odt)' % _('ODF Text Files')
tagMenuEntries = [('TextAddBoldTag', _('&Bold'), ('<b>', '</b>')),
('TextAddItalicsTag', _('&Italics'), ('<i>', '</i>')),
('TextAddUnderlineTag', _('&Underline'),
('<u>', '</u>')),
('TextAddSizeTag', _('&Size...'),
('<font size="%s">', '</font>')),
('TextAddColorTag', _('&Color...'),
('<font color="%s">', '</font>'))]
tagDict = dict([(text, tag) for name, text, tag in tagMenuEntries])
defaultWinSize = (640, 500)
winCascade = 24
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.setAcceptDrops(True)
self.setStatusBar(QtGui.QStatusBar())
self.showStatusBar = globalref.options.boolData('ShowStatusBar')
self.viewStatusBar(self.showStatusBar)
globalref.mainWin = self
if globalref.options.boolData('SaveWindowGeom'):
if globalref.treeControl.windowCount():
rect = globalref.treeControl.windowList[-1].geometry()
rect.adjust(TreeMainWin.winCascade, TreeMainWin.winCascade,
TreeMainWin.winCascade, TreeMainWin.winCascade)
else:
rect = QtCore.QRect(globalref.options.intData('WindowXPos',
-1000, 10000),
globalref.options.intData('WindowYPos',
-1000, 10000),
globalref.options.intData('WindowXSize',
10, 10000),
globalref.options.intData('WindowYSize',
10, 10000))
if rect.x() != -1000 or rect.y() != -1000:
desktop = QtGui.QApplication.desktop()
if desktop.isVirtualDesktop():
availRect = desktop.screen().rect()
else:
availRect = desktop.availableGeometry(desktop.
primaryScreen())
winRect = rect.intersected(availRect)
self.setGeometry(winRect)
else:
self.resize(rect.size())
else:
self.resize(*TreeMainWin.defaultWinSize)
self.origPalette = QtGui.QApplication.palette()
self.updateColors()
self.autoSaveTimer = QtCore.QTimer(self)
self.connect(self.autoSaveTimer, QtCore.SIGNAL('timeout()'),
globalref.treeControl.autoSave)
split = QtGui.QSplitter()
self.setCentralWidget(split)
self.leftTabs = QtGui.QTabWidget()
self.leftTabs.tabBar().setFocusPolicy(QtCore.Qt.NoFocus)
split.addWidget(self.leftTabs)
self.leftTabs.setTabPosition(QtGui.QTabWidget.South)
self.treeView = treeview.TreeView()
self.leftTabs.addTab(self.treeView, _('Tree View'))
self.flatView = treeflatview.FlatView()
self.leftTabs.addTab(self.flatView, _('Flat View'))
self.rightTabs = QtGui.QTabWidget()
self.rightTabs.tabBar().setFocusPolicy(QtCore.Qt.NoFocus)
split.addWidget(self.rightTabs)
self.rightTabs.setTabPosition(QtGui.QTabWidget.South)
self.dataOutSplit = QtGui.QSplitter(QtCore.Qt.Vertical)
self.rightTabs.addTab(self.dataOutSplit, _('Data Output'))
parentOutView = treerightviews.DataOutView(False)
self.dataOutSplit.addWidget(parentOutView)
childOutView = treerightviews.DataOutView(True)
self.dataOutSplit.addWidget(childOutView)
self.dataEditSplit = QtGui.QSplitter(QtCore.Qt.Vertical)
self.rightTabs.addTab(self.dataEditSplit, _('Data Editor'))
parentEditView = treeeditviews.DataEditView(False)
self.dataEditSplit.addWidget(parentEditView)
childEditView = treeeditviews.DataEditView(True)
self.dataEditSplit.addWidget(childEditView)
self.titleListSplit = QtGui.QSplitter(QtCore.Qt.Vertical)
self.rightTabs.addTab(self.titleListSplit, _('Title List'))
parentTitleView = treerightviews.TitleListView(False)
self.titleListSplit.addWidget(parentTitleView)
childTitleView = treerightviews.TitleListView(True)
self.titleListSplit.addWidget(childTitleView)
self.showItemChildren = globalref.options.boolData('StartShowChildren')
childOutView.showDescendants = globalref.options.\
boolData('StartShowDescend')
treeFont = self.getFontFromOptions('Tree')
if treeFont:
self.treeView.setFont(treeFont)
self.flatView.setFont(treeFont)
outFont = self.getFontFromOptions('Output')
if outFont:
parentOutView.setFont(outFont)
childOutView.setFont(outFont)
editFont = self.getFontFromOptions('Editor')
if editFont:
parentEditView.setFont(editFont)
childEditView.setFont(editFont)
parentTitleView.setFont(editFont)
childTitleView.setFont(editFont)
if globalref.options.boolData('SaveWindowGeom'):
mainSplitPercent = globalref.options.intData('TreeSplitPercent', 0,
100)
treeWidth = int(split.width() / 100.0 * mainSplitPercent)
split.setSizes([treeWidth, split.width() - treeWidth])
outSplitPercent = globalref.options.intData('OutputSplitPercent',
0, 100)
outHeight = int(self.dataOutSplit.height() / 100.0 *
outSplitPercent)
self.dataOutSplit.setSizes([outHeight,
self.dataOutSplit.height() -
outHeight])
editSplitPercent = globalref.options.intData('EditorSplitPercent',
0, 100)
editHeight = int(self.dataEditSplit.height() / 100.0 *
editSplitPercent)
self.dataEditSplit.setSizes([editHeight,
self.dataEditSplit.height() -
editHeight])
titleSplitPercent = globalref.options.intData('TitleSplitPercent',
0, 100)
titleHeight = int(self.titleListSplit.height() / 100.0 *
titleSplitPercent)
self.titleListSplit.setSizes([titleHeight,
self.titleListSplit.height() -
titleHeight])
else:
childTitleView.oldViewHeight = 80
self.doc = None
self.pluginInterface = None
self.condFilter = None
self.textFilter = []
self.fileImported = False
self.duplicateSelect = None
self.storedOpenNodes = []
self.linkTagEditor = None
self.printData = printdata.PrintData()
self.actions = {}
self.shortcuts = {}
self.toolbars = []
self.recentFileSep = None
self.winMenu = None
self.setupMenus()
self.recentFileActions = []
globalref.treeControl.recentFiles.updateMenu()
self.setupShortcuts()
self.addActionIcons()
self.setupToolbars()
self.restoreToolbarPos()
self.filterStatus = QtGui.QLabel()
self.doc = treedoc.TreeDoc()
self.show() # show window outline early and fix data edit view resizing
self.updateForFileChange(False)
self.connect(self.leftTabs, QtCore.SIGNAL('currentChanged(int)'),
self.updateLeftView)
self.connect(self.rightTabs, QtCore.SIGNAL('currentChanged(int)'),
self.updateRightView)
self.connect(QtGui.QApplication.clipboard(),
QtCore.SIGNAL('dataChanged()'), self.setPasteAvail)
self.setPasteAvail()
if globalref.options.boolData('SaveWindowGeom'):
viewNum = globalref.options.intData('ActiveRightView', 0, 2)
self.rightTabs.setCurrentIndex(viewNum)
self.setupPlugins()
self.updateAddTagAvail()
def getFontFromOptions(self, optionPrefix):
"""Return font if set in options or None"""
fontName = globalref.options.strData('%sFont' % optionPrefix, True)
if fontName:
try:
fontSize = int(globalref.options.strData('%sFontSize' %
optionPrefix, True))
except ValueError:
fontSize = 10
font = QtGui.QFont(fontName, fontSize)
font.setBold(globalref.options.boolData('%sFontBold' %
optionPrefix))
font.setItalic(globalref.options.boolData('%sFontItalic' %
optionPrefix))
font.setUnderline(globalref.options.boolData('%sFontUnderline' %
optionPrefix))
font.setStrikeOut(globalref.options.boolData('%sFontStrikeOut' %
optionPrefix))
return font
return None
def saveFontToOptions(self, font, optionPrefix):
"""Store font in option settings"""
globalref.options.changeData('%sFont' % optionPrefix,
unicode(font.family()), True)
globalref.options.changeData('%sFontSize' % optionPrefix,
unicode(font.pointSize()), True)
globalref.options.changeData('%sFontBold' % optionPrefix,
font.bold() and 'yes' or 'no', True)
globalref.options.changeData('%sFontItalic' % optionPrefix,
font.italic() and 'yes' or 'no', True)
globalref.options.changeData('%sFontUnderline' % optionPrefix,
font.underline() and 'yes' or 'no', True)
globalref.options.changeData('%sFontStrikeOut' % optionPrefix,
font.strikeOut() and 'yes' or 'no', True)
globalref.options.writeChanges()
def updateViews(self):
"""Update left and right views"""
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
self.updateLeftView()
QtGui.QApplication.restoreOverrideCursor()
self.updateRightView()
def updateLeftView(self, switchFlat=False):
"""Update the active left view, switchFlat is true if switching
to the flat view"""
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
current = self.leftTabs.currentWidget()
filters = []
if current == self.treeView:
self.doc.selection.openSelection()
self.actions['ViewTree'].setChecked(True)
self.treeView.updateTree()
else:
self.actions['ViewFlat'].setChecked(True)
self.flatView.updateTree(switchFlat)
if self.condFilter:
filters.append(_('Conditional Filter'))
if self.textFilter:
filters.append(_('Text Filter'))
if filters:
self.filterStatus.setText((u' %s ' % _('and')).join(filters))
self.statusBar().addWidget(self.filterStatus)
self.filterStatus.show()
self.statusBar().show()
elif self.filterStatus.isVisible():
self.statusBar().removeWidget(self.filterStatus)
if not self.showStatusBar:
self.statusBar().hide()
QtGui.QApplication.restoreOverrideCursor()
def updateViewSelection(self):
"""Change the selection in the active left view"""
self.leftTabs.currentWidget().updateSelect()
self.updateRightView()
def updateViewItem(self, item):
"""Update item display in the active left view"""
self.leftTabs.currentWidget().updateTreeItem(item)
def updateRightView(self):
"""Update given right-hand view or the active one"""
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
splitter = self.rightTabs.currentWidget()
if splitter == self.dataOutSplit:
self.actions['ViewDataOutput'].setChecked(True)
elif splitter == self.dataEditSplit:
self.actions['ViewDataEdit'].setChecked(True)
else:
self.actions['ViewTitleList'].setChecked(True)
if splitter.width(): # not collapsed
childView = splitter.widget(1)
topView = splitter.widget(0)
if len(self.doc.selection) != 1 or not self.showItemChildren or \
(not self.doc.selection[0].childList and
childView.__class__ != treerightviews.TitleListView):
if childView.height():
childView.oldViewHeight = int(childView.height() * 100.0 /
(topView.height() +
childView.height()))
splitter.setSizes([100, 0])
elif childView.oldViewHeight:
childHeight = int(splitter.height() / 100.0 *
childView.oldViewHeight)
splitter.setSizes([splitter.height() - childHeight,
childHeight])
childView.oldViewHeight = 0
for index in range(2):
if splitter.widget(index).height(): # not collapsed
splitter.widget(index).setEnabled(True)
splitter.widget(index).updateView()
else:
splitter.widget(index).setEnabled(False)
if TreeMainWin.setTypeDlg and TreeMainWin.setTypeDlg.isVisible():
# could be updateDlg(), except needed after ConfigDialog apply
TreeMainWin.setTypeDlg.loadList()
self.updateCmdAvail()
if TreeMainWin.sortDlg and TreeMainWin.sortDlg.isVisible():
TreeMainWin.sortDlg.updateDialog()
QtGui.QApplication.restoreOverrideCursor()
def saveMultiWinTree(self):
"""Save tree select and open nodes when multiple windows show
the same file"""
self.duplicateSelect = self.doc.selection[:]
self.storedOpenNodes = [node for node in self.doc.root.descendantList()
if node.open]
def updateMultiWinTree(self):
"""Update the tree and restore tree select and open nodes when
multiple windows show the same file"""
if self.duplicateSelect:
self.doc.selection = self.duplicateSelect
for node in self.doc.root.descendantGen():
node.open = False
for node in self.storedOpenNodes:
node.open = True
self.updateViews()
def updateCmdAvail(self):
"""Update the enabled status of menus"""
notRoot = len(self.doc.selection) and \
self.doc.root not in self.doc.selection
hasPrevSib = len(self.doc.selection) and None not in \
[node.prevSibling() for node in self.doc.selection]
hasNextSib = len(self.doc.selection) and None not in \
[node.nextSibling() for node in self.doc.selection]
selectParents = [node.parent for node in self.doc.selection]
numChildren = [len(node.childList) for node in self.doc.selection]
self.selectReqdActGrp.setEnabled(len(self.doc.selection))
self.notRootActGrp.setEnabled(notRoot)
self.selParentsActGrp.setEnabled(len(filter(None, numChildren)))
self.actions['FileSave'].setEnabled(self.doc.modified)
self.actions['EditUndo'].setEnabled(len(self.doc.undoStore.undoList))
self.actions['EditRedo'].setEnabled(len(self.doc.redoStore.undoList))
self.actions['EditRename'].setEnabled(len(self.doc.selection) == 1)
self.actions['EditIndent'].setEnabled(hasPrevSib)
self.actions['EditUnindent'].setEnabled(notRoot and
self.doc.root not in
selectParents)
self.actions['EditMoveUp'].setEnabled(hasPrevSib)
self.actions['EditMoveDown'].setEnabled(hasNextSib)
self.actions['EditMoveFirst'].setEnabled(hasPrevSib)
self.actions['EditMoveLast'].setEnabled(hasNextSib)
self.actions['ViewPreviousSelect'].setEnabled(len(self.doc.selection.
prevSelects))
self.actions['ViewNextSelect'].setEnabled(len(self.doc.selection.
nextSelects))
self.actions['DataFilterClear'].setEnabled(self.condFilter != None or
len(self.textFilter))
self.actions['ToolsRemXLST'].setEnabled(len(self.doc.xlstLink))
self.actions['WinUpdateWindow'].setEnabled(len(globalref.treeControl.
duplicateWindows()))
self.statusBar().clearMessage()
if self.pluginInterface:
self.pluginInterface.execCallback(self.pluginInterface.
viewUpdateCallbacks)
def updateForFileChange(self, addToRecent=True):
"""Update GUI after file new or open"""
globalref.updateRefs(self)
self.setMainCaption()
if self.leftTabs.currentWidget() == self.flatView:
self.leftTabs.setCurrentWidget(self.treeView)
if addToRecent:
globalref.treeControl.recentFiles.addEntry(self.doc.fileName)
if addToRecent and globalref.options.boolData('PersistTreeState'):
if not globalref.treeControl.recentFiles.\
restoreTreeState(self.treeView):
self.updateViews()
else:
self.updateViews()
self.updateNonModalDialogs()
globalref.treeControl.updateWinMenu()
self.updateCmdAvail()
globalref.treeControl.resetAutoSave()
def updateNonModalDialogs(self):
"""Update any open non-modal dialogs and their toggle actions"""
if TreeMainWin.configDlg and TreeMainWin.configDlg.isVisible():
TreeMainWin.configDlg.resetParam(True)
self.actions['DataConfigType'].setChecked(True)
else:
TreeMainWin.configDlg = None
self.actions['DataConfigType'].setChecked(False)
if TreeMainWin.setTypeDlg and TreeMainWin.setTypeDlg.isVisible():
TreeMainWin.setTypeDlg.loadList()
self.actions['DataSetDescendType'].setChecked(True)
else:
TreeMainWin.setTypeDlg = None
self.actions['DataSetDescendType'].setChecked(False)
if TreeMainWin.sortDlg and TreeMainWin.sortDlg.isVisible():
TreeMainWin.sortDlg.updateDialog()
self.actions['DataSort'].setChecked(True)
else:
TreeMainWin.sortDlg = None
self.actions['DataSort'].setChecked(False)
self.actions['ToolsFind'].setChecked(bool(TreeMainWin.findDlg and \
TreeMainWin.findDlg.isVisible()))
def updateAddTagAvail(self):
"""Update enabled status of editor tag entry commands"""
self.addTagGroup.setEnabled(self.focusWidgetWithAttr('addHtmlTag') !=
None)
def setPasteAvail(self):
"""Check to see if text is available to paste"""
text = self.clipText()
self.actions['EditPaste'].setEnabled(len(text))
self.actions['EditPasteText'].setEnabled(len(text))
def clipText(self):
"""Return text from the clipboard"""
try:
# QString argument is work-around for bug in PyQt 4.6
text = unicode(QtGui.QApplication.clipboard().\
text(QtCore.QString('xml')))
if not text:
text = unicode(QtGui.QApplication.clipboard().text())
except UnicodeError:
text = ''
return text
def updateColors(self):
"""Adjust the colors to the current option settings"""
if globalref.options.boolData('UseDefaultColors'):
pal = self.origPalette
else:
pal = QtGui.QPalette()
pal.setColor(QtGui.QPalette.Base,
self.getOptionColor('Background'))
pal.setColor(QtGui.QPalette.Text,
self.getOptionColor('Foreground'))
QtGui.QApplication.setPalette(pal)
def getOptionColor(self, name):
"""Return a color from option storage"""
return QtGui.QColor(globalref.options.intData('%sR' % name, 0, 255),
globalref.options.intData('%sG' % name, 0, 255),
globalref.options.intData('%sB' % name, 0, 255))
def setOptionColor(self, name, color):
"""Store given color in options"""
globalref.options.changeData('%sR' % name, str(color.red()), True)
globalref.options.changeData('%sG' % name, str(color.green()), True)
globalref.options.changeData('%sB' % name, str(color.blue()), True)
def focusWidgetWithAttr(self, attr):
"""Return the focused widget or it's ancestor
that has the given attr or None"""
widget = QtGui.QApplication.focusWidget()
while widget and not hasattr(widget, attr):
widget = widget.parent()
return widget
def setupPlugins(self):
"""Load plugin modules"""
self.pluginInterface = plugininterface.PluginInterface(self)
pluginPaths = [os.path.join(globalref.modPath, 'plugins')]
userPluginPath = globalref.options.pluginPath
if userPluginPath:
pluginPaths.append(userPluginPath)
pluginList = []
for pluginPath in pluginPaths:
if os.access(pluginPath, os.R_OK):
sys.path.insert(1, pluginPath)
pluginList.extend([name[:-3] for name in
os.listdir(pluginPath) if
name.endswith('.py')])
self.pluginInstances = [] # saves returned ref - avoid garbage collect
self.pluginDescript = []
errorList = []
for name in pluginList:
try:
module = __import__(name)
if not hasattr(module, 'main'):
raise ImportError
self.pluginInstances.append(module.main(self.pluginInterface))
descript = module.__doc__
if descript:
descript = [line for line in descript.split('\n')
if line.strip()][0].strip()
if not descript:
descript = name
self.pluginDescript.append(descript)
except ImportError:
errorList.append(name)
if errorList:
QtGui.QMessageBox.warning(self, 'TreeLine',
_('Could not load plugin module %s') %
', '.join(errorList))
def setStatusMsg(self, text, timeout=0, forceShow=False):
"""Set the status bar message with optional timeout.
Force a hidden bar to show if forceShow is true"""
self.statusBar().showMessage(text, timeout)
if text and forceShow:
self.statusBar().show()
if not text and not self.showStatusBar:
self.statusBar().hide()
def setMainCaption(self):
"""Set main window caption using doc filename path"""
caption = ''
if self.doc.fileName:
caption = u'%s [%s] ' % (os.path.basename(self.doc.fileName),
os.path.dirname(self.doc.fileName))
caption += u'- TreeLine'
self.setWindowTitle(caption)
def getSaveFileName(self, caption, defaultExt, filterList,
currentFilter=''):
"""Return user specified file name for save as & export"""
dir, name = os.path.split(self.doc.fileName)
if not dir:
dir = globalref.treeControl.recentFiles.firstPath()
if not dir:
dir = unicode(os.environ.get('HOME', ''),
sys.getfilesystemencoding())
if name:
dir = os.path.join(dir, os.path.splitext(name)[0] + defaultExt)
currentFilter = QtCore.QString(currentFilter)
fileName = QtGui.QFileDialog.getSaveFileName(self, caption, dir,
';;'.join(filterList),
currentFilter)
fileName = unicode(fileName)
if fileName:
selectedFilter = unicode(currentFilter)
fileName = fileName.split(';*')[0] # fix windows all filter bug
if '.' not in fileName and \
selectedFilter != TreeMainWin.allFileFilter:
fileName += defaultExt
if selectedFilter == TreeMainWin.tlPlainFileFilter:
self.doc.compressFile = False
self.doc.encryptFile = False
elif selectedFilter == TreeMainWin.tlCompFileFilter:
self.doc.compressFile = True
self.doc.encryptFile = False
elif selectedFilter == TreeMainWin.tlEncryptFileFilter:
self.doc.encryptFile = True
return fileName
return ''
def getOpenFileName(self, caption, filterList):
"""Return user specified file name for file open"""
dfltPath = os.path.dirname(self.doc.fileName)
if not dfltPath:
dfltPath = globalref.treeControl.recentFiles.firstPath()
if not dfltPath:
dfltPath = unicode(os.environ.get('HOME', ''),
sys.getfilesystemencoding())
if not dfltPath:
dfltPath = '..'
fileName = QtGui.QFileDialog.getOpenFileName(self, caption, dfltPath,
';;'.join(filterList))
return unicode(fileName)
def fileNew(self, newWinOk=True):
"""New file command"""
if globalref.treeControl.savePrompt():
dlg = treedialogs.TemplateDialog(self)
if dlg.exec_() != QtGui.QDialog.Accepted:
return
globalref.treeControl.newFile(dlg.selectedPath(), newWinOk)
def fileOpen(self):
"""Open a file"""
if globalref.treeControl.savePrompt():
filters = [TreeMainWin.tlGenFileFilter, TreeMainWin.textFileFilter,
TreeMainWin.treepadFileFilter,
TreeMainWin.xbelFileFilter, TreeMainWin.mozFileFilter,
TreeMainWin.odfFileFilter, TreeMainWin.allFileFilter]
fileName = self.getOpenFileName('', filters)
if fileName:
globalref.treeControl.openFile(fileName)
def fileOpenSample(self):
"""Open a sample template file"""
if globalref.treeControl.savePrompt():
path = self.findHelpPath()
if not path:
QtGui.QMessageBox.warning(self, 'TreeLine',
_('Sample directory not found'))
return
fileName = unicode(QtGui.QFileDialog.getOpenFileName(self,
_('Open Sample Template File'),
os.path.dirname(path),
TreeMainWin.tlGenFileFilter))
if fileName:
globalref.treeControl.openFile(fileName)
def fileSave(self):
"""Save current file"""
if self.doc.fileName and not self.fileImported:
globalref.treeControl.saveFile(self.doc.fileName)
else:
self.fileSaveAs()
def fileSaveAs(self):
"""Save file with a new name"""
oldFileName = self.doc.fileName
filterList = [TreeMainWin.tlPlainFileFilter,
TreeMainWin.tlCompFileFilter,
TreeMainWin.tlEncryptFileFilter,
TreeMainWin.allFileFilter]
currentFilter = self.doc.encryptFile and 2 or \
(self.doc.compressFile and 1 or 0)
fileName = self.getSaveFileName(_('Save As'), '.trl', filterList,
filterList[currentFilter])
if fileName and globalref.treeControl.saveFile(fileName):
self.setMainCaption()
globalref.treeControl.recentFiles.addEntry(fileName)
globalref.treeControl.updateWinMenu()
self.fileImported = False
globalref.treeControl.delAutoSaveFile(oldFileName)
def fileExport(self):
"""Export the file as html, a table or text. Return fileName or ''"""
ExportDlg = treedialogs.ExportDlg
dlg = ExportDlg(self)
if dlg.exec_() != QtGui.QDialog.Accepted:
return ''
indent = globalref.options.intData('IndentOffset', 0,
optiondefaults.maxIndentOffset)
nodeList = self.doc.selection
addBranches = True
if ExportDlg.exportWhat == ExportDlg.entireTree:
nodeList = [self.doc.root]
elif ExportDlg.exportWhat == ExportDlg.selectNode:
addBranches = False
elif ExportDlg.exportType != ExportDlg.tableType:
nodeList = self.doc.selection.uniqueBranches()
if not nodeList:
QtGui.QMessageBox.warning(self, 'TreeLine',
_('Nothing to export'))
return ''
fileName = ''
try:
if ExportDlg.exportType == ExportDlg.htmlType:
fileName = self.getSaveFileName(_('Export Html'), '.html',
[TreeMainWin.htmlFileFilter,
TreeMainWin.allFileFilter])
if not fileName:
return ''
outGroup = output.OutputGroup()
if addBranches:
for node in nodeList:
branch = node.outputItemList(ExportDlg.includeRoot,
ExportDlg.openOnly, True)
outGroup.extend(branch)
else:
outGroup.extend([node.outputItem(True) for node in
nodeList])
self.doc.exportHtmlColumns(fileName, outGroup,
ExportDlg.numColumns, indent,
ExportDlg.addHeader)
elif ExportDlg.exportType == ExportDlg.dirTableType:
defaultDir, fn = os.path.split(self.doc.fileName)
if not defaultDir:
defaultDir = unicode(os.environ.get('HOME', ''),
sys.getfilesystemencoding())
dirName = QtGui.QFileDialog.getExistingDirectory(self,
_('Export to Directory'),
defaultDir)
dirName = unicode(dirName)
if dirName:
self.doc.exportDirTable(dirName, nodeList,
ExportDlg.addHeader)
fileName = dirName
elif ExportDlg.exportType == ExportDlg.dirPageType:
defaultDir, fn = os.path.split(self.doc.fileName)
if not defaultDir:
defaultDir = unicode(os.environ.get('HOME', ''),
sys.getfilesystemencoding())
dirName = QtGui.QFileDialog.getExistingDirectory(self,
_('Export to Directory'),
defaultDir)
dirName = unicode(dirName)
if dirName:
self.doc.exportDirPage(dirName, nodeList)
fileName = dirName
elif ExportDlg.exportType == ExportDlg.xsltType:
dlgText = _('A link to a stylesheet can be added to the '\
'XSL file\nEnter a CSS filename (blank for none)')
link, ok = QtGui.QInputDialog.getText(self, 'TreeLine',
dlgText,
QtGui.QLineEdit.Normal,
self.doc.xslCssLink)
if ok:
fileName = self.getSaveFileName(_('Export XSLT'), '.xsl',
[TreeMainWin.xsltFileFilter,
TreeMainWin.allFileFilter])
if fileName:
if self.doc.xslCssLink != unicode(link):
self.doc.xslCssLink = unicode(link)
self.doc.modified = True
self.doc.exportXslt(fileName, ExportDlg.includeRoot,
indent)
self.actions['FileSave'].setEnabled(self.doc.modified)
elif ExportDlg.exportType == ExportDlg.trlType:
filterList = [TreeMainWin.tlPlainFileFilter,
TreeMainWin.tlCompFileFilter,
TreeMainWin.allFileFilter]
origCompress = self.doc.compressFile
fileName = self.getSaveFileName(_('Export Subtree'), '.trl',
filterList,
self.doc.compressFile)
if fileName:
self.doc.exportTrlSubtree(fileName, nodeList, addBranches)
self.doc.compressFile = origCompress
elif ExportDlg.exportType == ExportDlg.tableType:
fileName = self.getSaveFileName(_('Export Table'), '.tbl',
[TreeMainWin.tableFileFilter,
TreeMainWin.allFileFilter])
if fileName:
self.doc.exportTable(fileName, nodeList, addBranches)
elif ExportDlg.exportType == ExportDlg.textType:
fileName = self.getSaveFileName(_('Export Titles'), '.txt',
[TreeMainWin.textFileFilter,
TreeMainWin.allFileFilter])
if fileName:
self.doc.exportTabbedTitles(fileName, nodeList,
addBranches,
ExportDlg.includeRoot,
ExportDlg.openOnly)
elif ExportDlg.exportType == ExportDlg.xbelType:
fileName = self.getSaveFileName(_('Export XBEL Bookmarks'),
'.xml',
[TreeMainWin.xbelFileFilter,
TreeMainWin.allFileFilter])
if fileName:
self.doc.exportXbel(fileName, nodeList, addBranches)
elif ExportDlg.exportType == ExportDlg.mozType:
fileName = self.getSaveFileName(_('Export Html Bookmarks'),
'.html',
[TreeMainWin.mozFileFilter,
TreeMainWin.allFileFilter])
if fileName:
self.doc.exportHtmlBookmarks(fileName, nodeList,
addBranches)
elif ExportDlg.exportType == ExportDlg.xmlType:
fileName = self.getSaveFileName(_('Export Generic XML'),
'.xml',
[TreeMainWin.xmlFileFilter,
TreeMainWin.allFileFilter])
if fileName:
self.doc.exportGenericXml(fileName, nodeList, addBranches)
else: # ODF type
fontInfo = QtGui.QFontInfo(self.dataOutSplit.widget(0).font())
fileName = self.getSaveFileName(_('Export ODF Text'), '.odt',
[TreeMainWin.odfFileFilter,
TreeMainWin.allFileFilter])
if fileName:
self.doc.exportOdf(fileName, nodeList, fontInfo.family(),
fontInfo.pointSize(),
fontInfo.fixedPitch(), addBranches,
ExportDlg.includeRoot,
ExportDlg.openOnly)
except IOError, e:
if ExportDlg.exportType == ExportDlg.dirTableType:
QtGui.QMessageBox.warning(self, 'TreeLine', unicode(e))
else:
QtGui.QMessageBox.warning(self, 'TreeLine',
_('Error - Could not write to %s') % \
fileName)
return ''
return fileName
def editUndo(self):
"""Undo the previous action"""
self.doc.undoStore.undo(self.doc.redoStore)
if TreeMainWin.setTypeDlg and TreeMainWin.setTypeDlg.isVisible():
TreeMainWin.setTypeDlg.loadList()
if TreeMainWin.configDlg:
TreeMainWin.configDlg.resetParam()
def editRedo(self):
"""Redo the previous undo"""
self.doc.redoStore.undo(self.doc.undoStore)
if TreeMainWin.setTypeDlg and TreeMainWin.setTypeDlg.isVisible():
TreeMainWin.setTypeDlg.loadList()
if TreeMainWin.configDlg:
TreeMainWin.configDlg.resetParam()
def editCut(self):
"""Cut the branch or text to the clipboard"""
widget = self.focusWidgetWithAttr('copyAvail')
if (self.treeView.hasFocus() or self.flatView.hasFocus()) or \
not widget or not widget.copyAvail():
self.editCopyTree()
self.editDelete()
else:
widget.cut()
def editCopyTree(self):
"""Copy the tree branch to the clipboard"""
if not self.doc.selection:
return
clip = QtGui.QApplication.clipboard()
if clip.supportsSelection():
textList = []
if len(self.doc.selection) > 1:
for node in self.doc.selection:
textList.extend(node.exportToText())
else:
textList = self.doc.selection[0].exportToText()
clip.setText(u'\n'.join(textList), QtGui.QClipboard.Selection)
self.mimeData = self.treeView.mimeData() # TEMP req'd for PyQt bug
clip.setMimeData(self.mimeData)
def editCopy(self):
"""Copy the branch or text to the clipboard"""
split = self.rightTabs.currentWidget()
if split == self.dataOutSplit: # check select in dataOut (no focus)
views = [view for view in split.children() if \
hasattr(view, 'copyAvail') and view.copyAvail()]
if views:
views[0].copy()
return
widget = self.focusWidgetWithAttr('copyAvail')
if (self.treeView.hasFocus() or self.flatView.hasFocus()) or \
not widget or not widget.copyAvail():
self.editCopyTree()
else:
widget.copy()
def editCopyText(self):
"""Copy node title text to the clipboard"""
if not self.doc.selection:
return
titles = [item.title() for item in self.doc.selection]
clip = QtGui.QApplication.clipboard()
if clip.supportsSelection():
clip.setText(u'\n'.join(titles), QtGui.QClipboard.Selection)
clip.setText(u'\n'.join(titles))
def editPaste(self):
"""Paste items or text from the clipboard"""
text = self.clipText()
if not text:
return
leftFocus = self.treeView.hasFocus() or self.flatView.hasFocus()
if leftFocus:
item, newFormats = self.doc.readXmlStringAndFormat(text)
if item:
if not self.doc.selection:
return
if item.formatName == treedoc.TreeDoc.copyFormat.name:
itemList = item.childList
else: # copyFormat is dummy root of multi-select
itemList = [item]
if newFormats:
self.doc.undoStore.addBranchUndo(self.doc.selection)
for format in newFormats:
self.doc.treeFormats.addIfMissing(format)
self.doc.treeFormats.updateDerivedTypes()
self.doc.treeFormats.updateUniqueID()
if TreeMainWin.configDlg:
TreeMainWin.configDlg.resetParam()
else:
self.doc.undoStore.addChildListUndo(self.doc.selection)
selectList = []
for parent in self.doc.selection:
for node in itemList:
newNode = node.duplicateNode()
parent.addTree(newNode)
selectList.append(newNode)
parent.open = True
self.doc.selection.replace(selectList)
if newFormats:
self.doc.treeFormats.updateAutoChoices()
self.updateViews()
else:
print 'Error reading XML string'
else:
item = self.doc.readXmlString(text)
if item:
text = item.title()
widget = self.focusWidgetWithAttr('paste')
if widget:
widget.paste()
def editPasteText(self):
"""Paste text from the clipboard"""
text = self.clipText()
if not text:
return
item = self.doc.readXmlString(text)
if item and item.data:
text = item.title()
elif item and item.childList:
text = item.childList[0].title()
else:
text = text.split(u'\n', 1)[0].strip()
if self.treeView.hasFocus() or self.flatView.hasFocus():
for item in self.doc.selection:
item.setTitle(text, True)
self.updateViewItem(item)
self.updateCmdAvail()
else:
widget = self.focusWidgetWithAttr('pasteText')
if widget:
widget.paste()
def editRename(self):
"""Start rename editor in selected tree node"""
view = self.leftTabs.currentWidget()
view.editItem(self.doc.selection[0].viewData)
def editInBefore(self):
"""Insert new sibling before selection"""
newList = []
self.doc.undoStore.addParentListUndo(self.doc.selection)
for sibling in self.doc.selection:
newList.append(sibling.insertSibling())
if globalref.options.boolData('RenameNewNodes'):
self.doc.selection.replace(newList)
if len(newList) == 1:
self.updateViews()
view = self.leftTabs.currentWidget()
view.editItem(newList[0].viewData)
return
self.updateViews()
def editInAfter(self):
"""Insert new sibling after selection"""
newList = []
self.doc.undoStore.addParentListUndo(self.doc.selection)
for sibling in self.doc.selection:
newList.append(sibling.insertSibling(inAfter=True))
if globalref.options.boolData('RenameNewNodes'):
self.doc.selection.replace(newList)
if len(newList) == 1:
self.updateViews()
view = self.leftTabs.currentWidget()
view.editItem(newList[0].viewData)
return
self.updateViews()
def editAddChild(self):
"""Add a new child to the selected parent"""
newList = []
self.doc.undoStore.addChildListUndo(self.doc.selection)
for parent in self.doc.selection:
newList.append(parent.addChild())
parent.open = True
if globalref.options.boolData('RenameNewNodes'):
self.doc.selection.replace(newList)
if len(newList) == 1:
self.updateViews()
view = self.leftTabs.currentWidget()
view.editItem(newList[0].viewData)
return
self.updateViews()
def editDelete(self):
"""Delete the selected items"""
if not self.doc.selection or self.doc.root in self.doc.selection:
return
nextSel = filter(None, [item.parent for item in self.doc.selection])
nextSel.extend(filter(None, [item.prevSibling() for item in
self.doc.selection]))
nextSel.extend(filter(None, [item.nextSibling() for item in
self.doc.selection]))
self.doc.undoStore.addParentListUndo(self.doc.selection)
for item in self.doc.selection:
item.delete()
try:
self.flatView.rootItems.remove(item)
except ValueError:
pass
while nextSel[-1] in self.doc.selection:
del nextSel[-1]
self.doc.selection.replace([nextSel[-1]])
self.doc.selection.currentItem = nextSel[-1] # Reqd if only root left
self.doc.selection.validateHistory()
self.updateViews()
def sortedSelection(self):
"""Return a sorted selection list for indent & move commands"""
sortedList = self.doc.selection[:]
for item in sortedList:
item.viewData.loadTempSortKey()
sortedList.sort(lambda x,y: cmp(x.viewData.tempSortKey,
y.viewData.tempSortKey))
return sortedList
def editIndent(self):
"""Indent the selected items"""
sortlist = self.sortedSelection()
parentList = [item.parent for item in sortlist]
siblingList = [item.prevSibling() for item in sortlist]
self.doc.undoStore.addChildListUndo(parentList + siblingList)
for item in sortlist:
if item.indent():
item.parent.open = True
self.updateViews()
def editUnindent(self):
"""Unindent the selected item"""
sortlist = self.sortedSelection()
parentList = [item.parent for item in sortlist]
gpList = [item.parent for item in parentList]
self.doc.undoStore.addChildListUndo(parentList + gpList)
sortlist.reverse()
for item in sortlist:
item.unindent()
self.updateViews()
def editMoveUp(self):
"""Move the selected item up"""
sortlist = self.sortedSelection()
self.doc.undoStore.addParentListUndo(sortlist, True)
for item in sortlist:
item.move(-1)
self.updateViews()
def editMoveDown(self):
"""Move the selected item down"""
sortlist = self.sortedSelection()
sortlist.reverse()
self.doc.undoStore.addParentListUndo(sortlist, True)
for item in sortlist:
item.move(1)
self.updateViews()
def editMoveFirst(self):
"""Move the selected item to be first child"""
sortlist = self.sortedSelection()
sortlist.reverse()
self.doc.undoStore.addParentListUndo(sortlist, True)
for item in sortlist:
item.moveFirst()
self.updateViews()
def editMoveLast(self):
"""Move the selected item to be first child"""
sortlist = self.sortedSelection()
self.doc.undoStore.addParentListUndo(sortlist, True)
for item in sortlist:
item.moveLast()
self.updateViews()
def viewPrevSelect(self):
"""View the previous tree selection"""
self.doc.selection.restorePrevSelect()
def viewNextSelect(self):
"""View the next tree selection"""
self.doc.selection.restoreNextSelect()
def viewLeftSelect(self, action):
"""Show left view given by action"""
if action == self.actions['ViewTree']:
self.leftTabs.setCurrentWidget(self.treeView)
else:
self.leftTabs.setCurrentWidget(self.flatView)
def viewRightSelect(self, action):
"""Show right view given by action"""
if action == self.actions['ViewDataOutput']:
self.rightTabs.setCurrentWidget(self.dataOutSplit)
elif action == self.actions['ViewDataEdit']:
self.rightTabs.setCurrentWidget(self.dataEditSplit)
else:
self.rightTabs.setCurrentWidget(self.titleListSplit)
def viewChildren(self, checked):
"""Set to view item alone, with children or with descendants"""
self.showItemChildren = checked
self.updateRightView()
def viewDescendants(self, checked):
"""Toggle showing descendants in output view"""
self.dataOutSplit.widget(1).showDescendants = checked
self.updateRightView()
def viewStatusBar(self, checked):
"""Toggle the display of the status bar"""
if checked:
self.statusBar().show()
else:
self.statusBar().hide()
self.showStatusBar = checked
def dataTypeChange(self, action):
"""Change type based on submenu selection"""
if self.doc.selection:
self.doc.undoStore.addTypeUndo(self.doc.selection)
for item in self.doc.selection:
item.changeType(unicode(action.toolTip()))
self.doc.modified = True
self.updateViews()
def dataSet(self, show):
"""Show dialog for setting item data types"""
if show:
if not TreeMainWin.setTypeDlg:
TreeMainWin.setTypeDlg = treedialogs.TypeSetDlg()
self.connect(TreeMainWin.setTypeDlg,
QtCore.SIGNAL('viewClosed'),
globalref.treeControl.updateDialogs)
else:
TreeMainWin.setTypeDlg.loadList()
TreeMainWin.setTypeDlg.setCurrentSel()
TreeMainWin.setTypeDlg.updateDlg()
TreeMainWin.setTypeDlg.show()
else:
TreeMainWin.setTypeDlg.hide()
def dataConfig(self, show):
"""Show dialog for modifying data types"""
if show:
if not TreeMainWin.configDlg:
TreeMainWin.configDlg = configdialog.ConfigDialog()
self.connect(TreeMainWin.configDlg,
QtCore.SIGNAL('dialogClosed'),
globalref.treeControl.updateDialogs)
elif not TreeMainWin.configDlg.isVisible():
TreeMainWin.configDlg.resetCurrent()
TreeMainWin.configDlg.show()
else:
TreeMainWin.configDlg.close()
def dataCopyTypes(self):
"""Copy the configuration from another TreeLine file"""
dfltDir = os.path.dirname(self.doc.fileName)
fileName = unicode(QtGui.QFileDialog.getOpenFileName(self,
_('Open Configuration File'), dfltDir,
TreeMainWin.tlGenFileFilter))
password = ''
while fileName:
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
try:
self.doc.treeFormats.configCopy(fileName, password)
QtGui.QApplication.restoreOverrideCursor()
if TreeMainWin.configDlg:
TreeMainWin.configDlg.resetParam()
return
except treedoc.PasswordError:
QtGui.QApplication.restoreOverrideCursor()
dlg = treedialogs.PasswordEntry(False, self)
if dlg.exec_() != QtGui.QDialog.Accepted:
return
password = dlg.password
except (IOError, UnicodeError, treedoc.ReadFileError):
QtGui.QApplication.restoreOverrideCursor()
QtGui.QMessageBox.warning(self, 'TreeLine',
_('Error - could not read file "%s"')
% fileName)
return
def dataSort(self, show):
"""Open the dialog for sorting nodes"""
if show:
if not TreeMainWin.sortDlg:
TreeMainWin.sortDlg = treedialogs.SortDlg()
self.connect(TreeMainWin.sortDlg, QtCore.SIGNAL('viewClosed'),
globalref.treeControl.updateDialogs)
else:
TreeMainWin.sortDlg.updateDialog()
TreeMainWin.sortDlg.show()
else:
TreeMainWin.sortDlg.hide()
def dataFilterCond(self):
"""Filter types with conditional rules"""
if self.condFilter:
type = self.condFilter.formatName
else:
typeList = self.doc.treeFormats.nameList(True)
defaultTypeNum = 0
if self.doc.selection:
defaultTypeNum = typeList.index(self.doc.selection[0].
formatName)
type, ok = QtGui.QInputDialog.getItem(self, _('Filter Data'),
_('Select data type'),
typeList, defaultTypeNum,
False)
if not ok:
return
format = self.doc.treeFormats[unicode(type)]
dlg = configdialog.ConditionDlg(_('Filter %s Data Type') % format.name,
format, self)
if self.condFilter:
dlg.setConditions(self.condFilter)
if dlg.exec_() == QtGui.QDialog.Accepted:
self.condFilter = dlg.conditional()
self.condFilter.setupFields(format)
self.condFilter.formatName = format.name
if self.leftTabs.currentWidget() == self.flatView:
self.updateLeftView()
else:
self.leftTabs.setCurrentWidget(self.flatView)
self.updateCmdAvail()
def dataFilterText(self):
"""Filter with a text search string"""
searchStr, ok = QtGui.QInputDialog.getText(self, _('Filter Data'),
_('Enter key words'),
QtGui.QLineEdit.Normal,
' '.join(self.textFilter))
if not ok:
return
self.textFilter = [text.lower() for text in
unicode(searchStr).strip().split()]
if self.leftTabs.currentWidget() == self.flatView:
self.updateLeftView()
else:
self.leftTabs.setCurrentWidget(self.flatView)
self.updateCmdAvail()
def dataFilterClear(self):
"""Clear current filtering"""
self.condFilter = None
self.textFilter = []
if self.leftTabs.currentWidget() == self.flatView:
self.updateLeftView()
self.updateCmdAvail()
def dataEditField(self):
"""Edit a child field in all selected nodes"""
if not self.doc.selection:
return
fieldList = self.doc.treeFormats.commonFields(self.doc.selection)
if fieldList: # has common fields
dlg = treedialogs.EditFieldsDlg(fieldList, self)
if dlg.exec_() != QtGui.QDialog.Accepted:
return
self.doc.undoStore.addDataUndo(self.doc.selection)
for item in self.doc.selection:
item.editFields(dlg.resultDict)
if self.pluginInterface:
fields = [item.nodeFormat().findField(name) for name in
dlg.resultDict.keys()]
self.pluginInterface.execCallback(globalref.
pluginInterface.
dataChangeCallbacks,
item, fields)
self.updateViews()
else:
QtGui.QMessageBox.warning(self, 'TreeLine',
_('No common fields to set'))
def dataNumbering(self):
"""Add numbering to a data field"""
item = self.doc.selection[0]
NumberingDlg = treedialogs.NumberingDlg
dlg = NumberingDlg(item.branchFields(), item.maxDescendLevel(), self)
if dlg.exec_() != QtGui.QDialog.Accepted:
return
self.doc.undoStore.addBranchUndo(item)
if dlg.currentStyle == NumberingDlg.outlineType:
item.addNumbering(dlg.getField(), dlg.currentFormat,
dlg.includeRoot(), False, not dlg.existOnly(),
False, dlg.startNumber())
elif dlg.currentStyle == NumberingDlg.sectionType:
item.addNumbering(dlg.getField(), dlg.currentFormat,
dlg.includeRoot(), True, not dlg.existOnly(),
False, dlg.startNumber())
else: # singleType
item.addNumbering(dlg.getField(), dlg.currentFormat,
False, False, not dlg.existOnly(), True,
dlg.startNumber())
self.updateViews()
if TreeMainWin.configDlg:
TreeMainWin.configDlg.resetParam()
def dataAddCat(self):
"""Add child's category items as a new child level"""
selectList = self.doc.selection.uniqueBranches()
children = []
for item in selectList:
children.extend(item.childList)
fieldList = self.doc.treeFormats.commonFields(children)
if fieldList: # has common fields
dlg = treedialogs.FieldSelectDlg(fieldList, _('Category Fields'),
_('Select fields for new level'),
self)
if dlg.exec_() != QtGui.QDialog.Accepted:
return
self.doc.undoStore.addBranchUndo(selectList)
for item in selectList:
item.addChildCat(dlg.getSelList())
self.updateViews()
if TreeMainWin.configDlg:
TreeMainWin.configDlg.resetParam()
else:
QtGui.QMessageBox.warning(self, 'TreeLine',
_('Cannot expand without common fields'))
def dataFlatCat(self):
"""Collapse data by merging fields"""
selectList = self.doc.selection.uniqueBranches()
self.doc.undoStore.addBranchUndo(selectList)
for item in selectList:
item.flatChildCat()
self.updateViews()
if TreeMainWin.configDlg:
TreeMainWin.configDlg.resetParam()
def dataArrangeRef(self):
"""Arrange data using parent references"""
selectList = self.doc.selection.uniqueBranches()
children = []
for item in selectList:
children.extend(item.childList)
fieldList = self.doc.treeFormats.commonFields(children)
if not fieldList:
QtGui.QMessageBox.warning(self, 'TreeLine',
_('No common fields with parent '\
'references'))
return
refField, ok = QtGui.QInputDialog.getItem(self, _('Reference Field'),
_('Select field with parent'\
' references'),
fieldList, 0, False)
if not ok:
return
self.doc.undoStore.addBranchUndo(selectList)
for item in selectList:
item.arrangeByRef(unicode(refField))
self.updateViews()
def dataFlatRef(self):
"""Collapse data after adding references to parents"""
selectList = self.doc.selection.uniqueBranches()
dlg = configdialog.FieldEntry(_('Flatten by Reference'),
_('Enter new field name for parent'\
' references:'), '',
[], self)
if dlg.exec_() != QtGui.QDialog.Accepted:
return
self.doc.undoStore.addBranchUndo(selectList)
for item in selectList:
item.flatByRef(dlg.text)
self.updateViews()
if TreeMainWin.configDlg:
TreeMainWin.configDlg.resetParam()
def toolsExpand(self):
"""Expand all children of selected item"""
for item in self.doc.selection:
item.openBranch(True)
self.updateViews()
def toolsCollapse(self):
"""Collapse all children of selected item"""
for item in self.doc.selection:
item.openBranch(False)
self.updateViews()
def toolsFind(self, show):
"""Find item matching text string"""
if show:
if not TreeMainWin.findDlg:
TreeMainWin.findDlg = treedialogs.FindTextEntry()
self.connect(TreeMainWin.findDlg, QtCore.SIGNAL('viewClosed'),
globalref.treeControl.updateDialogs)
TreeMainWin.findDlg.entry.selectAll()
TreeMainWin.findDlg.entry.setFocus()
TreeMainWin.findDlg.show()
else:
TreeMainWin.findDlg.hide()
def toolsSpellCheck(self):
"""Spell check the tree's text data strting in the selected branch"""
spellPath = globalref.options.strData('SpellCheckPath', True)
try:
spCheck = spellcheck.SpellCheck(spellPath, self.doc.spellChkLang)
except spellcheck.SpellCheckError:
if sys.platform.startswith('win'):
ans = QtGui.QMessageBox.warning(self, _('Spell Check Error'),
_('Could not find either aspell.exe '\
'or ispell.exe\nManually locate?'),
_('&Browse'), _('&Cancel'), '', 0, 1)
if ans != 0:
return
path = unicode(QtGui.QFileDialog.getOpenFileName(self,
_('Locate aspell.exe or ipsell.exe'),
'', _('Program (*.exe)')))
if path:
path = path[:-4]
if ' ' in path:
path = '"%s"' % path
globalref.options.changeData('SpellCheckPath',
path.encode(sys.getfilesystemencoding()),
True)
globalref.options.writeChanges()
self.toolsSpellCheck()
return
else:
QtGui.QMessageBox.warning(self, 'TreeLine',
_('TreeLine Spell Check Error\n'\
'Make sure aspell or ispell is installed'))
return
if self.leftTabs.currentWidget() == self.flatView:
self.leftTabs.setCurrentWidget(self.treeView)
origSelect = self.doc.selection.uniqueBranches()
dlg = treedialogs.SpellCheckDlg(spCheck, origSelect, self)
if dlg.startSpellCheck():
if dlg.exec_() != QtGui.QDialog.Accepted:
spCheck.close()
return
spCheck.close()
if origSelect[0].parent:
ans = QtGui.QMessageBox.information(self, _('TreeLine Spell Check'),
_('Finished checking the branch\n'\
'Continue from the root branch?'),
_('&Yes'), _('&No'), '', 0, 1)
if ans == 0:
globalref.docRef.selection.changeSearchOpen([self.doc.root])
self.toolsSpellCheck()
else:
QtGui.QMessageBox.information(self, _('TreeLine Spell Check'),
_('Finished checking the branch'))
globalref.docRef.selection.changeSearchOpen(origSelect)
def toolsRemXslt(self):
"""Delete reference to XSLT export"""
if self.doc.xlstLink:
self.doc.undoStore.addParamUndo([(self.doc, 'xlstLink')])
self.doc.xlstLink = ''
self.doc.modified = True
self.updateCmdAvail()
def toolsGenOpt(self):
"""Set user preferences for all files"""
oldAutoSave = globalref.options.intData('AutoSaveMinutes', 0, 999)
dlg = optiondlg.OptionDlg(globalref.options, self)
dlg.setWindowTitle(_('General Options'))
dlg.startGroupBox(_('Startup Condition'))
optiondlg.OptionDlgBool(dlg, 'AutoFileOpen',
_('Automatically open last file used'))
optiondlg.OptionDlgBool(dlg, 'StartShowChildren',
_('Show children in right-hand view'))
optiondlg.OptionDlgBool(dlg, 'StartShowDescend',
_('Show descendants in output view'))
optiondlg.OptionDlgBool(dlg, 'ShowStatusBar', _('Show status bar'))
optiondlg.OptionDlgBool(dlg, 'PersistTreeState',
_('Restore view states of recent files'))
optiondlg.OptionDlgBool(dlg, 'SaveWindowGeom',
_('Restore window geometry from last exit'))
dlg.startGroupBox(_('Features Available'))
optiondlg.OptionDlgBool(dlg, 'ClickRename', _('Click item to rename'))
optiondlg.OptionDlgBool(dlg, 'DragTree',
_('Tree drag && drop available'))
optiondlg.OptionDlgBool(dlg, 'InsertOnEnter',
_('Insert node with enter'))
optiondlg.OptionDlgBool(dlg, 'RenameNewNodes',
_('Rename new nodes when created'))
optiondlg.OptionDlgBool(dlg, 'OpenSearchNodes',
_('Automatically open search nodes'))
optiondlg.OptionDlgBool(dlg, 'ShowTreeIcons',
_('Show icons in the tree view'))
optiondlg.OptionDlgBool(dlg, 'EnableExecLinks',
_('Enable executable links'))
optiondlg.OptionDlgBool(dlg, 'OpenNewWindow',
_('Open files in new windows'))
dlg.startNewColumn()
dlg.startGroupBox(_('New Objects'))
optiondlg.OptionDlgBool(dlg, 'CompressNewFiles',
_('Set new files to compressed by default'))
optiondlg.OptionDlgBool(dlg, 'EncryptNewFiles',
_('Set new files to encrypted by default'))
optiondlg.OptionDlgBool(dlg, 'HtmlNewFields',
_('New fields default to HTML content'))
dlg.endGroupBox()
optiondlg.OptionDlgRadio(dlg, 'SelectOrder',
_('Multiple Selection Sequence'),
[('tree', _('Tree order')),
('select', _('Selection order'))])
dlg.startGroupBox(_('Data Editor Pages'))
optiondlg.OptionDlgInt(dlg, 'EditorPages',
_('Number of pages shown \n(set to 0 for all)'),
0, 999)
dlg.startGroupBox(_('Undo Memory'))
optiondlg.OptionDlgInt(dlg, 'UndoLevels',
'%s ' % _('Number of undo levels'), 0, 99)
dlg.startNewColumn()
dlg.startGroupBox(_('Auto Save'))
optiondlg.OptionDlgInt(dlg, 'AutoSaveMinutes',
_('Minutes between saves \n'
'(set to 0 to disable)'), 0, 999)
dlg.startGroupBox(_('Recent Files'))
optiondlg.OptionDlgInt(dlg, 'RecentFiles',
_('Number of recent files \nin the File menu'),
0, 99)
dlg.startGroupBox(_('Data Editor Formats'))
optiondlg.OptionDlgStr(dlg, 'EditDateFormat', _('Dates'))
optiondlg.OptionDlgStr(dlg, 'EditTimeFormat', _('Times'))
dlg.startGroupBox(_('Appearance'))
optiondlg.OptionDlgInt(dlg, 'IndentOffset',
_('Child indent offset (points)'),
0, optiondefaults.maxIndentOffset)
optiondlg.OptionDlgInt(dlg, 'MaxEditLines',
_('Default max data editor lines'),
1, optiondefaults.maxNumLines)
if dlg.exec_() == QtGui.QDialog.Accepted:
if not globalref.options.boolData('PersistTreeState'):
globalref.treeControl.recentFiles.clearTreeStates()
globalref.options.writeChanges()
if oldAutoSave != globalref.options.intData('AutoSaveMinutes',
0, 999):
globalref.treeControl.resetAutoSave()
self.doc.undoStore.levels = globalref.options.\
intData('UndoLevels', 0, 99)
self.doc.redoStore.levels = globalref.options.\
intData('UndoLevels', 0, 99)
globalref.treeControl.recentFiles.\
changeNumEntries(globalref.options.
intData('RecentFiles', 0, 99))
self.treeView.updateGenOptions()
self.flatView.updateGenOptions()
self.updateViews()
def toolsTreeFont(self):
"""Show dialog for setting custom tree font"""
oldTreeFont = self.treeView.font()
treeFont, ok = QtGui.QFontDialog.getFont(oldTreeFont, self)
if ok and treeFont != oldTreeFont:
self.treeView.setFont(treeFont)
self.flatView.setFont(treeFont)
self.saveFontToOptions(treeFont, 'Tree')
self.updateViews()
def toolsOutputFont(self):
"""Show dialog for setting custom output font"""
oldOutputFont = self.dataOutSplit.widget(0).font()
outputFont, ok = QtGui.QFontDialog.getFont(oldOutputFont, self)
if ok and outputFont != oldOutputFont:
self.dataOutSplit.widget(0).setFont(outputFont)
self.dataOutSplit.widget(1).setFont(outputFont)
self.saveFontToOptions(outputFont, 'Output')
self.updateViews()
def toolsEditFont(self):
"""Show dialog for setting custom editor font"""
oldEditFont = self.dataEditSplit.widget(0).font()
editFont, ok = QtGui.QFontDialog.getFont(oldEditFont, self)
if ok and editFont != oldEditFont:
for i in range(2):
self.dataEditSplit.widget(i).setFont(editFont)
self.titleListSplit.widget(i).setFont(editFont)
self.saveFontToOptions(editFont, 'Editor')
self.updateViews()
def toolsFileOpt(self):
"""Set file preferences"""
globalref.options.addData('SpaceBetween',
self.doc.spaceBetween and 'yes' or 'no',
False)
globalref.options.addData('LineBreaks',
self.doc.lineBreaks and 'yes' or 'no', False)
globalref.options.addData('FormHtml',
self.doc.formHtml and 'yes' or 'no', False)
globalref.options.addData('CompressFile',
self.doc.compressFile and 'yes' or 'no',
False)
globalref.options.addData('EncryptFile',
self.doc.encryptFile and 'yes' or 'no',
False)
globalref.options.addData('ChildFieldSep', self.doc.childFieldSep,
False)
globalref.options.addData('SpellChkLang', self.doc.spellChkLang, False)
dlg = optiondlg.OptionDlg(globalref.options, self)
dlg.setWindowTitle(_('File Options'))
dlg.startGroupBox(_('Output Formating'))
optiondlg.OptionDlgBool(dlg, 'SpaceBetween',
_('Add blank lines between nodes'), False)
optiondlg.OptionDlgBool(dlg, 'LineBreaks',
_('Add line breaks after each line'), False)
optiondlg.OptionDlgBool(dlg, 'FormHtml',
_('Allow HTML rich text in formats'), False)
dlg.startGroupBox(_('File Storage'))
optiondlg.OptionDlgBool(dlg, 'CompressFile',
_('Use file compression'), False)
optiondlg.OptionDlgBool(dlg, 'EncryptFile',
_('Use file encryption'), False)
dlg.startGroupBox(_('Embedded Child Fields'))
optiondlg.OptionDlgStr(dlg, 'ChildFieldSep',
_('Separator String'), False)
dlg.startGroupBox(_('Spell Check Language'))
optiondlg.OptionDlgStr(dlg, 'SpellChkLang',
'%s\n%s' % (_('2-letter code (blank'),
_('for system default)')),
False)
if dlg.exec_() == QtGui.QDialog.Accepted:
space = globalref.options.boolData('SpaceBetween')
breaks = globalref.options.boolData('LineBreaks')
html = globalref.options.boolData('FormHtml')
compress = globalref.options.boolData('CompressFile')
encrypt = globalref.options.boolData('EncryptFile')
childFieldSep = globalref.options.strData('ChildFieldSep', True)
spellChkLang = globalref.options.strData('SpellChkLang', True)
if space != self.doc.spaceBetween or \
breaks != self.doc.lineBreaks or \
html != self.doc.formHtml or \
compress != self.doc.compressFile or \
encrypt != self.doc.encryptFile or \
childFieldSep != self.doc.childFieldSep or \
spellChkLang != self.doc.spellChkLang:
self.doc.undoStore.addParamUndo([(self.doc, 'spaceBetween'),
(self.doc, 'lineBreaks'),
(self.doc, 'formHtml'),
(self.doc, 'compressFile'),
(self.doc, 'encryptFile'),
(self.doc, 'childFieldSep')])
self.doc.spaceBetween = space
self.doc.lineBreaks = breaks
self.doc.formHtml = html
self.doc.compressFile = compress
self.doc.encryptFile = encrypt
self.doc.childFieldSep = childFieldSep
self.doc.spellChkLang = spellChkLang
self.doc.modified = True
self.updateViews()
self.updateCmdAvail()
def toolsShortcuts(self):
"""Start dialog to customize keyboard shorcuts"""
dlg = treedialogs.ShortcutDlg(self)
if dlg.exec_() == QtGui.QDialog.Accepted:
self.setupShortcuts()
def toolsCustomToolbar(self):
"""Start dialog to customize toolbar buttons"""
dlg = treedialogs.ToolbarDlg(self.setupToolbars,
TreeMainWin.toolIcons, self)
if dlg.exec_() == QtGui.QDialog.Accepted:
pass
def toolsDefaultColor(self, checked):
"""Toggle default color setting"""
setting = checked and 'yes' or 'no'
globalref.options.changeData('UseDefaultColors', setting, True)
globalref.options.writeChanges()
self.updateColors()
def toolsBkColor(self):
"""Set view background color"""
background = self.getOptionColor('Background')
newColor = QtGui.QColorDialog.getColor(background, self)
if newColor.isValid() and newColor != background:
self.setOptionColor('Background', newColor)
globalref.options.writeChanges()
self.updateColors()
def toolsTxtColor(self):
"""Set view text color"""
foreground = self.getOptionColor('Foreground')
newColor = QtGui.QColorDialog.getColor(foreground, self)
if newColor.isValid() and newColor != foreground:
self.setOptionColor('Foreground', newColor)
globalref.options.writeChanges()
self.updateColors()
def helpContents(self):
"""View the Using section of the ReadMe file"""
self.helpReadMe()
if TreeMainWin.helpView:
TreeMainWin.helpView.textView.scrollToAnchor('using')
def findHelpPath(self):
"""Return the full path of the help files or ''"""
pathList = [helpFilePath, os.path.join(globalref.modPath, '../doc/'),
globalref.modPath, os.path.join(globalref.modPath, 'doc/')]
fileList = ['README.html']
if globalref.lang and globalref.lang != 'C':
fileList[0:0] = ['README_%s.html' % globalref.lang,
'README_%s.html' % globalref.lang[:2]]
for path in filter(None, pathList):
for fileName in fileList:
fullPath = os.path.join(path, fileName)
if os.access(fullPath, os.R_OK):
return fullPath
return ''
def helpReadMe(self):
"""View the ReadMe file"""
if not TreeMainWin.helpView:
path = self.findHelpPath()
if path:
TreeMainWin.toolIcons.loadIcons(['helpback', 'helpforward',
'helphome', 'helpprevious',
'helpnext'])
TreeMainWin.helpView = helpview.HelpView(path,
_('TreeLine README File'),
TreeMainWin.toolIcons)
else:
QtGui.QMessageBox.warning(self, 'TreeLine',
_('Read Me file not found'))
return
TreeMainWin.helpView.show()
TreeMainWin.helpView.textView.home()
def helpAbout(self):
"""About this program"""
QtGui.QMessageBox.about(self, 'TreeLine',
_('TreeLine, Version %(ver)s\n by %(author)s') %
{'ver':__version__, 'author':__author__})
def helpPlugin(self):
"""Show loaded plugin modules"""
dlg = treedialogs.PluginListDlg(self.pluginDescript, self)
dlg.exec_()
def addTextTag(self):
"""Add html tag to active data editor"""
editor = self.focusWidgetWithAttr('addHtmlTag')
if not editor:
return
label = unicode(self.sender().text())
openTag, closeTag = TreeMainWin.tagDict[label]
if label == _('&Size...'):
num, ok = QtGui.QInputDialog.getInteger(self, _('Font Size'),
_('Enter size factor '\
'(-6 to +6)'),
1, -6, 6)
if not ok or num == 0:
return
openTag = openTag % num
elif label == _('&Color...'):
color = QtGui.QColorDialog.getColor(QtGui.QColor(), self)
if not color.isValid():
return
openTag = openTag % color.name()
editor.addHtmlTag(openTag, closeTag)
def inlineLinkTagPrompt(self):
"""Prompt user to pick node for inline internal link"""
self.linkTagEditor = self.focusWidgetWithAttr('addHtmlLinkTag')
if not self.linkTagEditor:
return
view = self.leftTabs.currentWidget()
view.noSelectClickCallback = self.addInlineLinkTag
globalref.setStatusBar(_('Click on tree node for link destination'),
0, True)
for action in self.actions.values():
action.setEnabled(False)
def addInlineLinkTag(self, item):
"""Add link to item to active data editor"""
globalref.setStatusBar('')
self.linkTagEditor.addHtmlLinkTag(item.refFieldText(), item.title())
self.linkTagEditor = None
for action in self.actions.values():
action.setEnabled(True)
self.updateCmdAvail()
def focusLeftView(self):
"""Focus active view in the left pane"""
self.leftTabs.currentWidget().setFocus()
def treeSelectPrev(self):
"""Select the pevious tree item"""
self.doc.selection.treeSelectPrev()
def treeSelectNext(self):
"""Select the next tree item"""
self.doc.selection.treeSelectNext()
def treePrevSibling(self):
"""Select the pevious sibling item"""
self.doc.selection.treePrevSibling()
def treeNextSibling(self):
"""Select the next sibling item"""
self.doc.selection.treeNextSibling()
def treeSelectParent(self):
"""Select the parnt item"""
self.doc.selection.treeSelectParent()
def treeOpenItem(self):
"""Set selection to open"""
self.doc.selection.treeOpenItem()
def treeCloseItem(self):
"""Set selection to closed"""
self.doc.selection.treeCloseItem()
def treePageUp(self):
"""Page up in the left view"""
view = self.leftTabs.currentWidget()
view.keyPressEvent(QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_PageUp,
QtCore.Qt.NoModifier))
def treePageDown(self):
"""Page down in the left view"""
view = self.leftTabs.currentWidget()
view.keyPressEvent(QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_PageDown,
QtCore.Qt.NoModifier))
def treeIncremSearch(self):
"""Begin an incremental title search"""
leftView = self.leftTabs.currentWidget()
leftView.setFocus()
leftView.treeIncremSearch()
def treeIncremNext(self):
"""Go to next item in title search (incremental)"""
self.leftTabs.currentWidget().treeIncremNext()
def treeIncremPrev(self):
"""Go to previous item in title search (incremental)"""
self.leftTabs.currentWidget().treeIncremPrev()
def rightChildPageUp(self):
"""Page up the right-hand child view"""
self.rightTabs.currentWidget().widget(1).scrollPage(-1)
def rightChildPageDown(self):
"""Page down the right-hand child view"""
self.rightTabs.currentWidget().widget(1).scrollPage(1)
def rightParentPageUp(self):
"""Page up the right-hand parent view"""
self.rightTabs.currentWidget().widget(0).scrollPage(-1)
def rightParentPageDown(self):
"""Page down the right-hand parent view"""
self.rightTabs.currentWidget().widget(0).scrollPage(1)
def closeEvent(self, event):
"""Ask for save if doc modified"""
if globalref.treeControl.savePrompt(True):
globalref.treeControl.recentFiles.writeList()
toolbarPos = base64.b64encode(self.saveState().data())
globalref.options.changeData('ToolbarPosition', toolbarPos, True)
if globalref.options.boolData('SaveWindowGeom'):
globalref.options.changeData('WindowXSize', self.width(), True)
globalref.options.changeData('WindowYSize', self.height(),
True)
globalref.options.changeData('WindowXPos', self.geometry().x(),
True)
globalref.options.changeData('WindowYPos', self.geometry().y(),
True)
treeWidth = self.leftTabs.width()
rightWidth = self.rightTabs.width()
treePercent = int(treeWidth * 100.0 / (treeWidth + rightWidth))
globalref.options.changeData('TreeSplitPercent', treePercent,
True)
mainHeight, childHeight = self.dataOutSplit.sizes()
outPercent = int(mainHeight * 100.0 /
(mainHeight + childHeight))
outChildView = self.rightTabs.widget(0).widget(1)
if outPercent == 100 and outChildView.oldViewHeight:
outPercent = 100 - outChildView.oldViewHeight
globalref.options.changeData('OutputSplitPercent',
outPercent, True)
mainHeight, childHeight = self.dataEditSplit.sizes()
editPercent = int(mainHeight * 100.0 /
(mainHeight + childHeight))
editChildView = self.rightTabs.widget(1).widget(1)
if editPercent == 100 and editChildView.oldViewHeight:
editPercent = 100 - editChildView.oldViewHeight
globalref.options.changeData('EditorSplitPercent',
editPercent, True)
mainHeight, childHeight = self.titleListSplit.sizes()
titlePercent = int(mainHeight * 100.0 /
(mainHeight + childHeight))
globalref.options.changeData('TitleSplitPercent',
titlePercent, True)
tabNum = self.rightTabs.currentIndex()
globalref.options.changeData('ActiveRightView', tabNum, True)
globalref.options.writeChanges()
globalref.treeControl.removeWin(self)
# make clipboard data persistent and fix error message on windows
if not globalref.treeControl.windowCount():
clip = QtGui.QApplication.clipboard()
clipEvent = QtCore.QEvent(QtCore.QEvent.Clipboard)
QtGui.QApplication.sendEvent(clip, clipEvent)
event.accept()
else:
event.ignore()
def dragEnterEvent(self, event):
"""Accept drags of files to main window"""
if event.mimeData().hasUrls():
event.accept()
def dropEvent(self, event):
"""Drop a file onto window"""
fileList = event.mimeData().urls()
if fileList and globalref.treeControl.savePrompt():
globalref.treeControl.openFile(unicode(fileList[0].toLocalFile()),
False)
def loadTypeSubMenu(self):
"""Update type select submenu with type names and check marks"""
self.typeSubMenu.clear()
if not self.doc.selection:
return
selectionTypes = self.doc.selection.formatNames()
names = self.doc.treeFormats.nameList(True)
usedShortcuts = []
for name in names:
shortcutPos = 0
try:
while name[shortcutPos] in usedShortcuts:
shortcutPos += 1
usedShortcuts.append(name[shortcutPos])
text = u'%s&%s' % (name[:shortcutPos], name[shortcutPos:])
except IndexError:
text = name
action = self.typeSubMenu.addAction(text)
action.setCheckable(True)
if name in selectionTypes:
action.setChecked(True)
def setupShortcuts(self):
"""Add shortcuts from options to actions"""
for name, action in self.actions.iteritems():
seq = globalref.options.strData(name, True)
seq = '+'.join(seq.split()) # for legacy config files
action.setShortcut(QtGui.QKeySequence(seq))
for name, shortcut in self.shortcuts.iteritems():
seq = globalref.options.strData(name, True)
seq = '+'.join(seq.split()) # for legacy config files
shortcut.setKey(QtGui.QKeySequence(seq))
# add shortcut to flyout Item Type menu
setTypeKey = globalref.options.strData('DataSetItemType', True)
setTypeKey = '+'.join(setTypeKey.split())
self.typeSubMenu.setTitle('%s (%s)' % (_('Set &Item Type'),
setTypeKey))
def addActionIcons(self):
"""Add icons to actions for menus and toolbars"""
for name, action in self.actions.iteritems():
icon = TreeMainWin.toolIcons.getIcon(name.lower())
if icon:
action.setIcon(icon)
def setupToolbars(self):
"""Add actions defined in options to toolbars"""
for toolbar in self.toolbars:
toolbar.hide()
self.removeToolBar(toolbar)
self.toolbars = []
numToolbars = globalref.options.intData('ToolbarQuantity', 0,
optiondefaults.maxNumToolbars)
iconSize = globalref.options.intData('ToolbarSize', 1, 128)
for num in range(numToolbars):
toolbar = self.addToolBar(_('Toolbar %d' % num))
toolbar.setObjectName('tb%d' % num)
toolbar.setIconSize(QtCore.QSize(iconSize, iconSize))
self.toolbars.append(toolbar)
commands = globalref.options.strData('Toolbar%d' % num, True)
commandList = commands.split(',')
for command in commandList:
if command:
try:
toolbar.addAction(self.actions[command])
except KeyError:
pass
else:
toolbar.addSeparator()
def restoreToolbarPos(self):
"""Recall the positions of the toolbars"""
toolbarPos = globalref.options.strData('ToolbarPosition', True)
if toolbarPos:
self.restoreState(base64.b64decode(toolbarPos))
def setupMenus(self):
"""Add menu and toolbar items"""
fileMenu = self.menuBar().addMenu(_('&File'))
self.parentPopup = QtGui.QMenu(self)
self.childPopup = QtGui.QMenu(self)
self.selectReqdActGrp = QtGui.QActionGroup(self)
self.notRootActGrp = QtGui.QActionGroup(self)
self.selParentsActGrp = QtGui.QActionGroup(self)
fileNewAct = QtGui.QAction(_('&New...'), self)
fileNewAct.setToolTip(_('New File'))
fileNewAct.setStatusTip(_('Start a new file'))
fileMenu.addAction(fileNewAct)
self.actions['FileNew'] = fileNewAct
self.connect(fileNewAct, QtCore.SIGNAL('triggered()'), self.fileNew)
fileOpenAct = QtGui.QAction(_('&Open...'), self)
fileOpenAct.setToolTip(_('Open File'))
fileOpenAct.setStatusTip(_('Open a file from disk'))
fileMenu.addAction(fileOpenAct)
self.actions['FileOpen'] = fileOpenAct
self.connect(fileOpenAct, QtCore.SIGNAL('triggered()'), self.fileOpen)
fileOpenSampleAct = QtGui.QAction(_('Open Sa&mple...'), self)
fileOpenSampleAct.setStatusTip(_('Open a sample template file'))
fileMenu.addAction(fileOpenSampleAct)
self.actions['FileOpenSample'] = fileOpenSampleAct
self.connect(fileOpenSampleAct, QtCore.SIGNAL('triggered()'),
self.fileOpenSample)
fileMenu.addSeparator()
fileSaveAct = QtGui.QAction(_('&Save'), self)
fileSaveAct.setToolTip(_('Save File'))
fileSaveAct.setStatusTip(_('Save changes to the current file'))
fileMenu.addAction(fileSaveAct)
self.actions['FileSave'] = fileSaveAct
self.connect(fileSaveAct, QtCore.SIGNAL('triggered()'), self.fileSave)
fileSaveAsAct = QtGui.QAction(_('Save &As...'), self)
fileSaveAsAct.setStatusTip(_('Save the file with a new name'))
fileMenu.addAction(fileSaveAsAct)
self.actions['FileSaveAs'] = fileSaveAsAct
self.connect(fileSaveAsAct, QtCore.SIGNAL('triggered()'),
self.fileSaveAs)
fileExportAct = QtGui.QAction(_('&Export...'), self)
fileExportAct.setStatusTip(_('Export the file as html, as a table '\
'or as text'))
fileMenu.addAction(fileExportAct)
self.actions['FileExport'] = fileExportAct
self.connect(fileExportAct, QtCore.SIGNAL('triggered()'),
self.fileExport)
fileMenu.addSeparator()
filePrintOptAct = QtGui.QAction(_('P&rint Options...'), self)
filePrintOptAct.setStatusTip(_('Set margins, page size and other '\
'options for printing'))
fileMenu.addAction(filePrintOptAct)
self.actions['FilePrintOpt'] = filePrintOptAct
self.connect(filePrintOptAct, QtCore.SIGNAL('triggered()'),
self.printData.filePrintOpt)
filePrintPreviewAct = QtGui.QAction(_('Print Pre&view...'), self)
filePrintPreviewAct.setStatusTip(_('Show a preview of printing '\
'results'))
fileMenu.addAction(filePrintPreviewAct)
self.actions['FilePrintPreview'] = filePrintPreviewAct
self.connect(filePrintPreviewAct, QtCore.SIGNAL('triggered()'),
self.printData.filePrintPreview)
filePrintAct = QtGui.QAction(_('&Print...'), self)
filePrintAct.setStatusTip(_('Print starting at the selected node'))
fileMenu.addAction(filePrintAct)
self.actions['FilePrint'] = filePrintAct
self.connect(filePrintAct, QtCore.SIGNAL('triggered()'),
self.printData.filePrint)
fileMenu.addSeparator()
self.recentFileSep = fileMenu.addSeparator()
fileQuitAct = QtGui.QAction(_('&Quit'), self)
fileQuitAct.setStatusTip(_('Exit the application'))
fileMenu.addAction(fileQuitAct)
self.actions['FileQuit'] = fileQuitAct
self.connect(fileQuitAct, QtCore.SIGNAL('triggered()'), self.close)
editMenu = self.menuBar().addMenu(_('&Edit'))
editUndoAct = QtGui.QAction(_('&Undo'), self)
editUndoAct.setStatusTip(_('Undo the previous action'))
editMenu.addAction(editUndoAct)
self.actions['EditUndo'] = editUndoAct
self.connect(editUndoAct, QtCore.SIGNAL('triggered()'), self.editUndo)
editRedoAct = QtGui.QAction(_('&Redo'), self)
editRedoAct.setStatusTip(_('Redo the previous undo'))
editMenu.addAction(editRedoAct)
self.actions['EditRedo'] = editRedoAct
self.connect(editRedoAct, QtCore.SIGNAL('triggered()'), self.editRedo)
editMenu.addSeparator()
editCutAct = QtGui.QAction(_('Cu&t'), self)
editCutAct.setStatusTip(_('Cut the branch or text to the clipboard'))
editMenu.addAction(editCutAct)
self.parentPopup.addAction(editCutAct)
self.childPopup.addAction(editCutAct)
self.actions['EditCut'] = editCutAct
self.connect(editCutAct, QtCore.SIGNAL('triggered()'), self.editCut)
editCopyAct = QtGui.QAction(_('&Copy'), self)
editCopyAct.setStatusTip(_('Copy the branch or text to the clipboard'))
editMenu.addAction(editCopyAct)
self.parentPopup.addAction(editCopyAct)
self.childPopup.addAction(editCopyAct)
self.actions['EditCopy'] = editCopyAct
self.connect(editCopyAct, QtCore.SIGNAL('triggered()'), self.editCopy)
editCopyTextAct = QtGui.QAction(_('Cop&y Title Text'), self)
editCopyTextAct.setStatusTip(_('Copy node title text to the '\
'clipboard'))
editMenu.addAction(editCopyTextAct)
self.actions['EditCopyText'] = editCopyTextAct
self.connect(editCopyTextAct, QtCore.SIGNAL('triggered()'),
self.editCopyText)
editPasteAct = QtGui.QAction(_('&Paste'), self)
editPasteAct.setStatusTip(_('Paste nodes or text from the clipboard'))
editMenu.addAction(editPasteAct)
self.parentPopup.addAction(editPasteAct)
self.childPopup.addAction(editPasteAct)
self.actions['EditPaste'] = editPasteAct
self.connect(editPasteAct, QtCore.SIGNAL('triggered()'),
self.editPaste)
editPasteTextAct = QtGui.QAction(_('Pa&ste Text'), self)
editPasteTextAct.setStatusTip(_('Paste text from the clipboard'))
editMenu.addAction(editPasteTextAct)
self.actions['EditPasteText'] = editPasteTextAct
self.connect(editPasteTextAct, QtCore.SIGNAL('triggered()'),
self.editPasteText)
editRenameAct = QtGui.QAction(_('Re&name'), self)
editRenameAct.setStatusTip(_('Rename the current tree entry'))
editMenu.addAction(editRenameAct)
self.parentPopup.addAction(editRenameAct)
self.childPopup.addAction(editRenameAct)
self.actions['EditRename'] = editRenameAct
self.connect(editRenameAct, QtCore.SIGNAL('triggered()'),
self.editRename)
editMenu.addSeparator()
self.parentPopup.addSeparator()
self.childPopup.addSeparator()
editInBeforeAct = QtGui.QAction(_('Insert Sibling &Before'),
self.notRootActGrp)
editInBeforeAct.setStatusTip(_('Insert new sibling before selection'))
editMenu.addAction(editInBeforeAct)
self.parentPopup.addAction(editInBeforeAct)
self.childPopup.addAction(editInBeforeAct)
self.actions['EditInsertBefore'] = editInBeforeAct
self.connect(editInBeforeAct, QtCore.SIGNAL('triggered()'),
self.editInBefore)
editInAfterAct = QtGui.QAction(_('Insert Sibling &After'),
self.notRootActGrp)
editInAfterAct.setStatusTip(_('Insert new sibling after selection'))
editMenu.addAction(editInAfterAct)
self.parentPopup.addAction(editInAfterAct)
self.childPopup.addAction(editInAfterAct)
self.actions['EditInsertAfter'] = editInAfterAct
self.connect(editInAfterAct, QtCore.SIGNAL('triggered()'),
self.editInAfter)
editAddChildAct = QtGui.QAction(_('Add C&hild'), self.selectReqdActGrp)
editAddChildAct.setStatusTip(_('Add a new child to the selected '\
'parent'))
editMenu.addAction(editAddChildAct)
self.parentPopup.addAction(editAddChildAct)
self.childPopup.addAction(editAddChildAct)
self.actions['EditAddChild'] = editAddChildAct
self.connect(editAddChildAct, QtCore.SIGNAL('triggered()'),
self.editAddChild)
editMenu.addSeparator()
self.parentPopup.addSeparator()
self.childPopup.addSeparator()
editDeleteAct = QtGui.QAction(_('&Delete Node'), self.notRootActGrp)
editDeleteAct.setStatusTip(_('Delete the selected nodes'))
editMenu.addAction(editDeleteAct)
self.parentPopup.addAction(editDeleteAct)
self.childPopup.addAction(editDeleteAct)
self.actions['EditDelete'] = editDeleteAct
self.connect(editDeleteAct, QtCore.SIGNAL('triggered()'),
self.editDelete)
editIndentAct = QtGui.QAction(_('&Indent Node'), self)
editIndentAct.setStatusTip(_('Indent the selected nodes'))
editMenu.addAction(editIndentAct)
self.parentPopup.addAction(editIndentAct)
self.childPopup.addAction(editIndentAct)
self.actions['EditIndent'] = editIndentAct
self.connect(editIndentAct, QtCore.SIGNAL('triggered()'),
self.editIndent)
editUnindentAct = QtGui.QAction(_('Unind&ent Node'), self)
editUnindentAct.setStatusTip(_('Unindent the selected nodes'))
editMenu.addAction(editUnindentAct)
self.parentPopup.addAction(editUnindentAct)
self.childPopup.addAction(editUnindentAct)
self.actions['EditUnindent'] = editUnindentAct
self.connect(editUnindentAct, QtCore.SIGNAL('triggered()'),
self.editUnindent)
editMenu.addSeparator()
self.parentPopup.addSeparator()
self.childPopup.addSeparator()
editMoveUpAct = QtGui.QAction(_('&Move Up'), self)
editMoveUpAct.setStatusTip(_('Move the selected nodes up'))
editMenu.addAction(editMoveUpAct)
self.parentPopup.addAction(editMoveUpAct)
self.childPopup.addAction(editMoveUpAct)
self.actions['EditMoveUp'] = editMoveUpAct
self.connect(editMoveUpAct, QtCore.SIGNAL('triggered()'),
self.editMoveUp)
editMoveDownAct = QtGui.QAction(_('M&ove Down'), self)
editMoveDownAct.setStatusTip(_('Move the selected nodes down'))
editMenu.addAction(editMoveDownAct)
self.parentPopup.addAction(editMoveDownAct)
self.childPopup.addAction(editMoveDownAct)
self.actions['EditMoveDown'] = editMoveDownAct
self.connect(editMoveDownAct, QtCore.SIGNAL('triggered()'),
self.editMoveDown)
editMoveFirstAct = QtGui.QAction(_('Move &First'), self)
editMoveFirstAct.setStatusTip(_('Move the selected nodes to be the '\
'first children'))
editMenu.addAction(editMoveFirstAct)
self.actions['EditMoveFirst'] = editMoveFirstAct
self.connect(editMoveFirstAct, QtCore.SIGNAL('triggered()'),
self.editMoveFirst)
editMoveLastAct = QtGui.QAction(_('Move &Last'), self)
editMoveLastAct.setStatusTip(_('Move the selected nodes to be the '\
'last children'))
editMenu.addAction(editMoveLastAct)
self.actions['EditMoveLast'] = editMoveLastAct
self.connect(editMoveLastAct, QtCore.SIGNAL('triggered()'),
self.editMoveLast)
self.parentPopup.addSeparator()
self.childPopup.addSeparator()
viewMenu = self.menuBar().addMenu(_('&View'))
viewPrevSelAct = QtGui.QAction(_('&Previous Selection'), self)
viewPrevSelAct.setStatusTip(_('View the previous tree selection'))
viewMenu.addAction(viewPrevSelAct)
self.actions['ViewPreviousSelect'] = viewPrevSelAct
self.connect(viewPrevSelAct, QtCore.SIGNAL('triggered()'),
self.viewPrevSelect)
viewNextSelAct = QtGui.QAction(_('&Next Selection'), self)
viewNextSelAct.setStatusTip(_('View the next tree selection'))
viewMenu.addAction(viewNextSelAct)
self.actions['ViewNextSelect'] = viewNextSelAct
self.connect(viewNextSelAct, QtCore.SIGNAL('triggered()'),
self.viewNextSelect)
viewMenu.addSeparator()
viewLeftViewGrp = QtGui.QActionGroup(self)
viewTreeAct = QtGui.QAction(_('Show &Tree View'), viewLeftViewGrp)
viewTreeAct.setStatusTip(_('Show the tree in the right view'))
viewTreeAct.setCheckable(True)
viewMenu.addAction(viewTreeAct)
self.actions['ViewTree'] = viewTreeAct
viewFlatAct = QtGui.QAction(_('Show &Flat View'), viewLeftViewGrp)
viewFlatAct.setStatusTip(_('Show a flat list in the right view'))
viewFlatAct.setCheckable(True)
viewMenu.addAction(viewFlatAct)
self.actions['ViewFlat'] = viewFlatAct
self.connect(viewLeftViewGrp, QtCore.SIGNAL('triggered(QAction*)'),
self.viewLeftSelect)
viewMenu.addSeparator()
viewRightViewGrp = QtGui.QActionGroup(self)
viewOutAct = QtGui.QAction(_('Show Data &Output'), viewRightViewGrp)
viewOutAct.setStatusTip(_('Show data output in right view'))
viewOutAct.setCheckable(True)
viewMenu.addAction(viewOutAct)
self.actions['ViewDataOutput'] = viewOutAct
viewEditAct = QtGui.QAction(_('Show Data &Editor'), viewRightViewGrp)
viewEditAct.setStatusTip(_('Show data editor in right view'))
viewEditAct.setCheckable(True)
viewMenu.addAction(viewEditAct)
self.actions['ViewDataEdit'] = viewEditAct
viewTitleAct = QtGui.QAction(_('Show Title &List'), viewRightViewGrp)
viewTitleAct.setStatusTip(_('Show title list in right view'))
viewTitleAct.setCheckable(True)
viewMenu.addAction(viewTitleAct)
self.actions['ViewTitleList'] = viewTitleAct
self.connect(viewRightViewGrp, QtCore.SIGNAL('triggered(QAction*)'),
self.viewRightSelect)
viewMenu.addSeparator()
viewChildAct = QtGui.QAction(_('Show &Child Pane'), self)
viewChildAct.setStatusTip(_('Toggle splitting right-hand view to '\
'show children'))
viewChildAct.setCheckable(True)
viewMenu.addAction(viewChildAct)
self.actions['ViewShowChild'] = viewChildAct
viewChildAct.setChecked(self.showItemChildren)
self.connect(viewChildAct, QtCore.SIGNAL('toggled(bool)'),
self.viewChildren)
viewDescendAct = QtGui.QAction(_('Show Output &Descendants'), self)
viewDescendAct.setStatusTip(_('Toggle showing descendants in output '\
'view'))
viewDescendAct.setCheckable(True)
viewMenu.addAction(viewDescendAct)
self.actions['ViewShowDescend'] = viewDescendAct
viewDescendAct.setChecked(self.dataOutSplit.widget(1).showDescendants)
self.connect(viewDescendAct, QtCore.SIGNAL('toggled(bool)'),
self.viewDescendants)
viewMenu.addSeparator()
viewStatusAct = QtGui.QAction(_('Show Status Bar'), self)
viewStatusAct.setStatusTip(_('Toggle the display of the status bar'))
viewStatusAct.setCheckable(True)
viewMenu.addAction(viewStatusAct)
self.actions['ViewStatusBar'] = viewStatusAct
viewStatusAct.setChecked(self.showStatusBar)
self.connect(viewStatusAct, QtCore.SIGNAL('toggled(bool)'),
self.viewStatusBar)
dataMenu = self.menuBar().addMenu(_('&Data'))
self.typeSubMenu = QtGui.QMenu(self)
dataMenu.addMenu(self.typeSubMenu)
self.parentPopup.addMenu(self.typeSubMenu)
self.childPopup.addMenu(self.typeSubMenu)
self.connect(self.typeSubMenu, QtCore.SIGNAL('triggered(QAction*)'),
self.dataTypeChange)
self.connect(self.typeSubMenu, QtCore.SIGNAL('aboutToShow()'),
self.loadTypeSubMenu)
typeSubMenuShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treeView.showTypeMenu)
self.shortcuts['DataSetItemType'] = typeSubMenuShortcut
dataSetAct = QtGui.QAction(_('&Set Descendant Types...'),
self.selParentsActGrp)
dataSetAct.setCheckable(True)
dataSetAct.setStatusTip(_('Set data type of selections and children'))
dataMenu.addAction(dataSetAct)
self.actions['DataSetDescendType'] = dataSetAct
self.connect(dataSetAct, QtCore.SIGNAL('triggered(bool)'),
self.dataSet)
dataConfigAct = QtGui.QAction(_('&Configure Data Types...'), self)
dataConfigAct.setCheckable(True)
dataConfigAct.\
setStatusTip(_('Modify data types, fields & output lines'))
dataMenu.addAction(dataConfigAct)
self.actions['DataConfigType'] = dataConfigAct
self.connect(dataConfigAct, QtCore.SIGNAL('triggered(bool)'),
self.dataConfig)
dataCopyAct = QtGui.QAction(_('C&opy Types from File...'), self)
dataCopyAct.setStatusTip(_('Copy the configuration from another '\
'TreeLine file'))
dataMenu.addAction(dataCopyAct)
self.actions['DataCopyTypes'] = dataCopyAct
self.connect(dataCopyAct, QtCore.SIGNAL('triggered()'),
self.dataCopyTypes)
dataMenu.addSeparator()
self.parentPopup.addSeparator()
self.childPopup.addSeparator()
dataSortAct = QtGui.QAction(_('Sort &Nodes...'), self)
dataSortAct.setCheckable(True)
dataSortAct.setStatusTip(_('Open the dialog for sorting nodes'))
dataMenu.addAction(dataSortAct)
self.parentPopup.addAction(dataSortAct)
self.childPopup.addAction(dataSortAct)
self.actions['DataSort'] = dataSortAct
self.connect(dataSortAct, QtCore.SIGNAL('triggered(bool)'),
self.dataSort)
dataEditFieldAct = QtGui.QAction(_('C&hange Selected Data...'),
self.selectReqdActGrp)
dataEditFieldAct.setStatusTip(_('Edit data values for all selected '\
'nodes'))
dataMenu.addAction(dataEditFieldAct)
self.actions['DataChange'] = dataEditFieldAct
self.connect(dataEditFieldAct, QtCore.SIGNAL('triggered()'),
self.dataEditField)
dataNumberingAct = QtGui.QAction(_('N&umbering...'),
self.selectReqdActGrp)
dataNumberingAct.setStatusTip(_('Add numbering to a given data field'))
dataMenu.addAction(dataNumberingAct)
self.actions['DataNumber'] = dataNumberingAct
self.connect(dataNumberingAct, QtCore.SIGNAL('triggered()'),
self.dataNumbering)
dataMenu.addSeparator()
dataFilterCondAct = QtGui.QAction(_('Con&ditional Filter...'), self)
dataFilterCondAct.setStatusTip(_('Filter types with conditional'\
' rules'))
dataMenu.addAction(dataFilterCondAct)
self.actions['DataFilterCond'] = dataFilterCondAct
self.connect(dataFilterCondAct, QtCore.SIGNAL('triggered()'),
self.dataFilterCond)
dataFilterTextAct = QtGui.QAction(_('Te&xt Filter...'), self)
dataFilterTextAct.setStatusTip(_('Filter with a text search string'))
dataMenu.addAction(dataFilterTextAct)
self.actions['DataFilterText'] = dataFilterTextAct
self.connect(dataFilterTextAct, QtCore.SIGNAL('triggered()'),
self.dataFilterText)
dataFilterClearAct = QtGui.QAction(_('Cl&ear Filtering'), self)
dataFilterClearAct.setStatusTip(_('Clear current filtering'))
dataMenu.addAction(dataFilterClearAct)
self.actions['DataFilterClear'] = dataFilterClearAct
self.connect(dataFilterClearAct, QtCore.SIGNAL('triggered()'),
self.dataFilterClear)
dataMenu.addSeparator()
dataAddCatAct = QtGui.QAction(_('&Add Category Level...'),
self.selParentsActGrp)
dataAddCatAct.setStatusTip(_('Insert category nodes above children'))
dataMenu.addAction(dataAddCatAct)
self.actions['DataCategoryAdd'] = dataAddCatAct
self.connect(dataAddCatAct, QtCore.SIGNAL('triggered()'),
self.dataAddCat)
dataFlatCatAct = QtGui.QAction(_('&Flatten by Category'),
self.selParentsActGrp)
dataFlatCatAct.setStatusTip(_('Collapse data by merging fields'))
dataMenu.addAction(dataFlatCatAct)
self.actions['DataCategoryFlat'] = dataFlatCatAct
self.connect(dataFlatCatAct, QtCore.SIGNAL('triggered()'),
self.dataFlatCat)
dataMenu.addSeparator()
dataArrangeRefAct = QtGui.QAction(_('Arrange by &Reference...'),
self.selParentsActGrp)
dataArrangeRefAct.setStatusTip(_('Arrange data using parent '\
'references'))
dataMenu.addAction(dataArrangeRefAct)
self.actions['DataRefArrange'] = dataArrangeRefAct
self.connect(dataArrangeRefAct, QtCore.SIGNAL('triggered()'),
self.dataArrangeRef)
dataFlatRefAct = QtGui.QAction(_('F&latten by Reference...'),
self.selParentsActGrp)
dataFlatRefAct.setStatusTip(_('Collapse data after adding references'))
dataMenu.addAction(dataFlatRefAct)
self.actions['DataRefFlat'] = dataFlatRefAct
self.connect(dataFlatRefAct, QtCore.SIGNAL('triggered()'),
self.dataFlatRef)
toolsMenu = self.menuBar().addMenu(_('&Tools'))
toolsExpandAct = QtGui.QAction(_('&Expand Full Branch'),
self.selParentsActGrp)
toolsExpandAct.setStatusTip(_('Expand all children of selected node'))
toolsMenu.addAction(toolsExpandAct)
self.parentPopup.addAction(toolsExpandAct)
self.actions['ToolsExpand'] = toolsExpandAct
self.connect(toolsExpandAct, QtCore.SIGNAL('triggered()'),
self.toolsExpand)
toolsCollapseAct = QtGui.QAction(_('&Collapse Full Branch'),
self.selParentsActGrp)
toolsCollapseAct.setStatusTip(_('Collapse all children of the '\
'selected node'))
toolsMenu.addAction(toolsCollapseAct)
self.parentPopup.addAction(toolsCollapseAct)
self.actions['ToolsCollapse'] = toolsCollapseAct
self.connect(toolsCollapseAct, QtCore.SIGNAL('triggered()'),
self.toolsCollapse)
toolsMenu.addSeparator()
toolsFindAct = QtGui.QAction(_('&Find...'), self)
toolsFindAct.setCheckable(True)
toolsFindAct.setStatusTip(_('Find node matching text string'))
toolsMenu.addAction(toolsFindAct)
self.actions['ToolsFind'] = toolsFindAct
self.connect(toolsFindAct, QtCore.SIGNAL('triggered(bool)'),
self.toolsFind)
toolsSpellCheckAct = QtGui.QAction(_('&Spell Check'),
self.selectReqdActGrp)
toolsSpellCheckAct.setStatusTip(_('Spell check the tree\'s text data'))
toolsMenu.addAction(toolsSpellCheckAct)
self.actions['ToolsSpellCheck'] = toolsSpellCheckAct
self.connect(toolsSpellCheckAct, QtCore.SIGNAL('triggered()'),
self.toolsSpellCheck)
toolsRemXsltAct = QtGui.QAction(_('&Remove XSLT Ref'), self)
toolsRemXsltAct.setStatusTip(_('Delete reference to XSLT export'))
toolsMenu.addAction(toolsRemXsltAct)
self.actions['ToolsRemXLST'] = toolsRemXsltAct
self.connect(toolsRemXsltAct, QtCore.SIGNAL('triggered()'),
self.toolsRemXslt)
toolsMenu.addSeparator()
toolsGenOptAct = QtGui.QAction(_('&General Options...'), self)
toolsGenOptAct.setStatusTip(_('Set user preferences for all files'))
toolsMenu.addAction(toolsGenOptAct)
self.actions['ToolsGenOptions'] = toolsGenOptAct
self.connect(toolsGenOptAct, QtCore.SIGNAL('triggered()'),
self.toolsGenOpt)
toolsFileOptAct = QtGui.QAction(_('File &Options...'), self)
toolsFileOptAct.setStatusTip(_('Set preferences for this file'))
toolsMenu.addAction(toolsFileOptAct)
self.actions['ToolsFileOptions'] = toolsFileOptAct
self.connect(toolsFileOptAct, QtCore.SIGNAL('triggered()'),
self.toolsFileOpt)
fontMenu = toolsMenu.addMenu(_('Set Fo&nts'))
toolsTreeFontAct = QtGui.QAction(_('&Tree Font...'), self)
toolsTreeFontAct.setToolTip(_('Set Tree Font'))
toolsTreeFontAct.setStatusTip(_('Sets font for tree & flat views'))
fontMenu.addAction(toolsTreeFontAct)
self.actions['ToolsTreeFont'] = toolsTreeFontAct
self.connect(toolsTreeFontAct, QtCore.SIGNAL('triggered()'),
self.toolsTreeFont)
toolsOutputFontAct = QtGui.QAction(_('&Data Output Font...'), self)
toolsOutputFontAct.setToolTip(_('Set Data Output Font'))
toolsOutputFontAct.setStatusTip(_('Sets font for output views'))
fontMenu.addAction(toolsOutputFontAct)
self.actions['ToolsOutputFont'] = toolsOutputFontAct
self.connect(toolsOutputFontAct, QtCore.SIGNAL('triggered()'),
self.toolsOutputFont)
toolsEditFontAct = QtGui.QAction(_('&Editor Font...'), self)
toolsEditFontAct.setToolTip(_('Set Editor Font'))
toolsEditFontAct.setStatusTip(_('Sets font for edit views'))
fontMenu.addAction(toolsEditFontAct)
self.actions['ToolsEditFont'] = toolsEditFontAct
self.connect(toolsEditFontAct, QtCore.SIGNAL('triggered()'),
self.toolsEditFont)
toolsShortcutAct = QtGui.QAction(_('Set &Keyboard Shortcuts...'), self)
toolsShortcutAct.setStatusTip(_('Customize keyboard commands'))
toolsMenu.addAction(toolsShortcutAct)
self.actions['ToolsShortcuts'] = toolsShortcutAct
self.connect(toolsShortcutAct, QtCore.SIGNAL('triggered()'),
self.toolsShortcuts)
toolsToolbarAct = QtGui.QAction(_('Custo&mize Toolbars...'), self)
toolsToolbarAct.setStatusTip(_('Customize toolbar buttons'))
toolsMenu.addAction(toolsToolbarAct)
self.actions['ToolsCustomToolbar'] = toolsToolbarAct
self.connect(toolsToolbarAct, QtCore.SIGNAL('triggered()'),
self.toolsCustomToolbar)
toolsMenu.addSeparator()
toolsDfltColorAct = QtGui.QAction(_('&Use Default System Colors'),
self)
toolsDfltColorAct.setStatusTip(_('Use system colors, not custom'))
toolsDfltColorAct.setCheckable(True)
toolsMenu.addAction(toolsDfltColorAct)
self.actions['ToolsDefaultColor'] = toolsDfltColorAct
toolsDfltColorAct.setChecked(globalref.options.
boolData('UseDefaultColors'))
self.connect(toolsDfltColorAct, QtCore.SIGNAL('toggled(bool)'),
self.toolsDefaultColor)
toolsBkColorAct = QtGui.QAction(_('&Background Color...'), self)
toolsBkColorAct.setStatusTip(_('Set view background color'))
toolsMenu.addAction(toolsBkColorAct)
self.actions['ToolsBackColor'] = toolsBkColorAct
self.connect(toolsBkColorAct, QtCore.SIGNAL('triggered()'),
self.toolsBkColor)
toolsTxtColorAct = QtGui.QAction(_('&Text Color...'), self)
toolsTxtColorAct.setStatusTip(_('Set view text color'))
toolsMenu.addAction(toolsTxtColorAct)
self.actions['ToolsTextColor'] = toolsTxtColorAct
self.connect(toolsTxtColorAct, QtCore.SIGNAL('triggered()'),
self.toolsTxtColor)
self.winMenu = self.menuBar().addMenu(_('&Window'))
winNewAct = QtGui.QAction(_('&New Window'), self)
winNewAct.setStatusTip(_('Open a new window viewing the same file'))
self.winMenu.addAction(winNewAct)
self.actions['WinNewWindow'] = winNewAct
self.connect(winNewAct, QtCore.SIGNAL('triggered()'),
globalref.treeControl.newWindow)
winCloseAct = QtGui.QAction(_('&Close Window'), self)
winCloseAct.setStatusTip(_('Close the current window'))
self.winMenu.addAction(winCloseAct)
self.actions['WinCloseWindow'] = winCloseAct
self.connect(winCloseAct, QtCore.SIGNAL('triggered()'),
globalref.treeControl.closeWindow)
winUpdateAct = QtGui.QAction(_('&Update Other Window'), self)
winUpdateAct.setStatusTip(_('Update the contents of an alternate '
'window'))
self.winMenu.addAction(winUpdateAct)
self.actions['WinUpdateWindow'] = winUpdateAct
self.connect(winUpdateAct, QtCore.SIGNAL('triggered()'),
globalref.treeControl.forceUpdateWindow)
self.winMenu.addSeparator()
helpMenu = self.menuBar().addMenu(_('&Help'))
helpContentsAct = QtGui.QAction(_('&Help Contents'), self)
helpContentsAct.setStatusTip(_('View information about using TreeLine'))
helpMenu.addAction(helpContentsAct)
self.actions['HelpContents'] = helpContentsAct
self.connect(helpContentsAct, QtCore.SIGNAL('triggered()'),
self.helpContents)
helpReadMeAct = QtGui.QAction(_('&View Full ReadMe'), self)
helpReadMeAct.setStatusTip(_('View the entire ReadMe file'))
helpMenu.addAction(helpReadMeAct)
self.actions['HelpFullReadMe'] = helpReadMeAct
self.connect(helpReadMeAct, QtCore.SIGNAL('triggered()'),
self.helpReadMe)
helpAboutAct = QtGui.QAction(_('&About TreeLine'), self)
helpAboutAct.setStatusTip(_('About this program'))
helpMenu.addAction(helpAboutAct)
self.actions['HelpAbout'] = helpAboutAct
self.connect(helpAboutAct, QtCore.SIGNAL('triggered()'),
self.helpAbout)
helpPluginAct = QtGui.QAction(_('About &Plugins'), self)
helpPluginAct.setStatusTip(_('Show loaded plugin modules'))
helpMenu.addAction(helpPluginAct)
self.actions['HelpPlugin'] = helpPluginAct
self.connect(helpPluginAct, QtCore.SIGNAL('triggered()'),
self.helpPlugin)
self.pulldownMenuList = [fileMenu, editMenu, viewMenu, dataMenu,
toolsMenu, helpMenu]
self.tagSubMenu = QtGui.QMenu(_('&Add Font Tags'), self)
self.addTagGroup = QtGui.QActionGroup(self)
for name, text, tags in TreeMainWin.tagMenuEntries:
action = QtGui.QAction(text, self.addTagGroup)
self.tagSubMenu.addAction(action)
self.addAction(action)
self.actions[name] = action
self.connect(action, QtCore.SIGNAL('triggered()'),
self.addTextTag)
treeFocusShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.focusLeftView)
self.shortcuts['TreeFocusView'] = treeFocusShortcut
treeSelectPrevShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treeSelectPrev)
self.shortcuts['TreeSelectPrev'] = treeSelectPrevShortcut
treeSelectNextShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treeSelectNext)
self.shortcuts['TreeSelectNext'] = treeSelectNextShortcut
treePrevSiblingShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treePrevSibling)
self.shortcuts['TreePrevSibling'] = treePrevSiblingShortcut
treeNextSiblingShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treeNextSibling)
self.shortcuts['TreeNextSibling'] = treeNextSiblingShortcut
treeSelectParentShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treeSelectParent)
self.shortcuts['TreeSelectParent'] = treeSelectParentShortcut
treeOpenItemShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treeOpenItem)
self.shortcuts['TreeOpenItem'] = treeOpenItemShortcut
treeCloseItemShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treeCloseItem)
self.shortcuts['TreeCloseItem'] = treeCloseItemShortcut
treePageUpShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treePageUp)
self.shortcuts['TreePageUp'] = treePageUpShortcut
treePageDownShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treePageDown)
self.shortcuts['TreePageDown'] = treePageDownShortcut
treeIncremSearchShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treeIncremSearch)
self.shortcuts['TreeIncremSearch'] = treeIncremSearchShortcut
treeIncremNextShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treeIncremNext)
self.shortcuts['TreeIncremNext'] = treeIncremNextShortcut
treeIncremPrevShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.treeIncremPrev)
self.shortcuts['TreeIncremPrev'] = treeIncremPrevShortcut
rightChildUpShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.rightChildPageUp)
self.shortcuts['RightChildPageUp'] = rightChildUpShortcut
rightChildDownShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.rightChildPageDown)
self.shortcuts['RightChildPageDown'] = rightChildDownShortcut
rightParentUpShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.rightParentPageUp)
self.shortcuts['RightParentPageUp'] = rightParentUpShortcut
rightParentDownShortcut = QtGui.QShortcut(QtGui.QKeySequence(), self,
self.rightParentPageDown)
self.shortcuts['RightParentPageDown'] = rightParentDownShortcut
|