1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360
|
/***************************************************************************
mainwindow.cpp - description
-------------------
begin : sept 2011
copyright : (C) 2011 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with KLog. If not, see <https://www.gnu.org/licenses/>. *
* *
*****************************************************************************/
//#include "global.h"
#include <QtWidgets>
#include <QtSql>
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include "callsign.h"
#include "updatesettings.h"
//#include "database.h"
#include "mainwindow.h"
MainWindow::MainWindow(DataProxy_SQLite *dp, World *injectedWorld):
// dataProxy(Q_FUNC_INFO, tversion),
awards(dp, injectedWorld, Q_FUNC_INFO) // Pass Awards instance to DXCCStatusWidget
{
dataProxy = dp;
world = injectedWorld;
//world = new World(dataProxy, Q_FUNC_INFO);
softwareVersion = dataProxy->getSoftVersion();
pkgVersion = dataProxy->getPKGVersion();
//qDebug() << Q_FUNC_INFO << ": " << " Ver: " << softwareVersion << QTime::currentTime().toString("hh:mm:ss") ;
//logEvent(Q_FUNC_INFO, "Start: " + _klogDir + "/" + tversion, Debug);
dxccStatusWidget = std::make_unique<DXCCStatusWidget>(&awards, world, this);
dxClusterWidget = std::make_unique<DXClusterWidget>(&awards, world, this);
searchWidget = std::make_unique<SearchWidget>(&awards, world, this);
logWindow = std::make_unique<LogWindow>(&awards, this);
showKLogLogWidget = new ShowKLogLogWidget;
showErrorDialog = new ShowErrorDialog();
UDPLogServer = new UDPServer();
util = new Utilities(Q_FUNC_INFO);
backupQSO = new QSO;
logLevel = Info;
dupeSlotInSeconds = 15;
needToEnd = false;
upAndRunning = false; // To define some actions that can only be run when starting the software
QRZCOMAutoCheckAct = new QAction(tr("Always check the current callsign in QRZ.com"), this);
//qDebug() << "MainWindow::MainWindow: Debug File: "<< util->getDebugLogFile() ;
//dataProxy = new DataProxy_SQLite(Q_FUNC_INFO, softwareVersion);
world->create(util->getCTYFile());
//qDebug() << Q_FUNC_INFO << ": BEFORE HAMLIB " << QTime::currentTime().toString("hh:mm:ss") ;
hamlib = new HamLibClass();
//qDebug() << Q_FUNC_INFO << ": AFTER HAMLIB " << QTime::currentTime().toString("hh:mm:ss") ;
//qDebug() << Q_FUNC_INFO << ": AFTER dataproxy ";
lotwUtilities = new LoTWUtilities(util->getHomeDir (), softwareVersion, Q_FUNC_INFO, dataProxy);
//qDebug() << Q_FUNC_INFO << ": AFTER lotwUtilities";
eqslUtilities = new eQSLUtilities(Q_FUNC_INFO);
//qDebug() << Q_FUNC_INFO << ": AFTER eQSLUtilities";
mapWindow = new MapWindowWidget(dataProxy, this);
mapWindow->init();
//qDebug() << Q_FUNC_INFO << ": Before DXCCStatusWidget " << QTime::currentTime().toString("hh:mm:ss") ;
//dxccStatusWidget = new DXCCStatusWidget(dataProxy, Q_FUNC_INFO);
//qDebug() << Q_FUNC_INFO << ": After DXCCStatusWidget " << QTime::currentTime().toString("hh:mm:ss") ;
elogClublog = new eLogClubLog();
//qDebug() << Q_FUNC_INFO << ": 00082: " << QTime::currentTime().toString("hh:mm:ss") ;
elogQRZcom = new eLogQrzLog(dataProxy, Q_FUNC_INFO, softwareVersion);
//qDebug() << Q_FUNC_INFO << ": 00083: " << QTime::currentTime().toString("hh:mm:ss") ;
updateSatsData = new UpdateSatsData(dataProxy);
//qDebug() << Q_FUNC_INFO << ": 00084: " << QTime::currentTime().toString("hh:mm:ss") ;
statsWidget = new StatisticsWidget(dataProxy);
//qDebug() << Q_FUNC_INFO << ": 00085: " << QTime::currentTime().toString("hh:mm:ss") ;
infoLabel1 = new QLabel(tr("Status bar ..."));
infoLabel2 = new QLabel(tr("DX Entity"));
//qDebug() << "MainWindow::MainWindow: 00086" << QTime::currentTime().toString("hh:mm:ss") ;
//logWindow = new LogWindow(dataProxy, this);
//qDebug() << Q_FUNC_INFO << ": 00087: " << QTime::currentTime().toString("hh:mm:ss") ;
//searchWidget = new SearchWidget(dataProxy, this);
//qDebug() << Q_FUNC_INFO << ": 00087.1: " << QTime::currentTime().toString("hh:mm:ss") ;
//advancedSearchWidget = new AdvancedSearchWidget(dataProxy, this);
//qDebug() << "MainWindow::MainWindow: 00087.2" << QTime::currentTime().toString("hh:mm:ss") ;
infoWidget = new InfoWidget(dataProxy, world, this);
//qDebug() << Q_FUNC_INFO << ": 00088: " << QTime::currentTime().toString("hh:mm:ss") ;
awardsWidget = new AwardsWidget(dataProxy, world, this);
//qDebug() << Q_FUNC_INFO << ": 0009: " << QTime::currentTime().toString("hh:mm:ss") ;
aboutDialog = new AboutDialog(softwareVersion, pkgVersion);
tipsDialog = new TipsDialog();
downloadcty = new DownLoadCTY(util->getHomeDir (), softwareVersion);
statusBarMessage = tr("Starting KLog");
//qDebug() << Q_FUNC_INFO << ": 40: " << QTime::currentTime().toString("hh:mm:ss") ;
//qDebug() << Q_FUNC_INFO << ": 50: " << QTime::currentTime().toString("hh:mm:ss") ;
//qDebug() << Q_FUNC_INFO << ": 51: " << QTime::currentTime().toString("hh:mm:ss") ;
setupDialog = new SetupDialog(dataProxy, world, this);
//qDebug() << Q_FUNC_INFO << ": satTabWidget to be created " ;
satTabWidget = new MainWindowSatTab(dataProxy);
//qDebug() << Q_FUNC_INFO << ": 52: " << QTime::currentTime().toString("hh:mm:ss") ;
QSOTabWidget = new MainWindowInputQSO(dataProxy);
//qDebug() << Q_FUNC_INFO << ": 53: " << QTime::currentTime().toString("hh:mm:ss") ;
myDataTabWidget = new MainWindowMyDataTab(dataProxy);
//qDebug() << Q_FUNC_INFO << ": 54: " << QTime::currentTime().toString("hh:mm:ss") ;
commentTabWidget = new MainWindowInputComment();
//qDebug() << Q_FUNC_INFO << ": 55: " << QTime::currentTime().toString("hh:mm:ss") ;
othersTabWidget = new MainWindowInputOthers(dataProxy, world);
//qDebug() << Q_FUNC_INFO << ": 56: " << QTime::currentTime().toString("hh:mm:ss") ;
eQSLTabWidget = new MainWindowInputEQSL(dataProxy);
//qDebug() << Q_FUNC_INFO << ": 57: " << QTime::currentTime().toString("hh:mm:ss") ;
QSLTabWidget = new MainWindowInputQSL(dataProxy);
//qDebug() << Q_FUNC_INFO << ": 58: " << QTime::currentTime().toString("hh:mm:ss") ;
mainQSOEntryWidget = new MainQSOEntryWidget(dataProxy);
//qDebug() << Q_FUNC_INFO << ": locator to be created 59" << QTime::currentTime().toString("hh:mm:ss") ;
//locator = new Locator();
mainWidget = new QWidget(this);
//qDebug() << Q_FUNC_INFO << ": 60 " << QTime::currentTime().toString("hh:mm:ss") ;
dateTime = std::make_unique<QDateTime>();
// UI DX
infoLabel2 = new QLabel(tr("DX Entity"));
loggWinAct = new QAction(tr("&Log Window"), this);
//dxClusterAssistant = new DXClusterAssistant(Q_FUNC_INFO);
//qDebug() << Q_FUNC_INFO << ": Awards to be created " << QTime::currentTime().toString("hh:mm:ss") ;
//awards = new Awards(dataProxy, Q_FUNC_INFO);
//qDebug() << Q_FUNC_INFO << ": Awards created " << QTime::currentTime().toString("hh:mm:ss") ;
// </UI>
if (needToEnd)
{
exit(0);
}
//qDebug() << Q_FUNC_INFO << ": Software update to be created " << QTime::currentTime().toString("hh:mm:ss") ;
softUpdate = new SoftwareUpdate(softwareVersion);
//qDebug() << Q_FUNC_INFO << ": FileManager to be created " << QTime::currentTime().toString("hh:mm:ss") ;
filemanager = new FileManager(dataProxy, world);
//qDebug() << Q_FUNC_INFO << ": FileAwardManager to be created " << QTime::currentTime().toString("hh:mm:ss") ;
//fileAwardManager = new FileAwardManager(dataProxy, Q_FUNC_INFO);
lotwCallTQSL = new QAction(tr("Upload queued QSOs to LoTW"), this);
//qDebug() << Q_FUNC_INFO << ": AdifLoTWExportWidget to be created " << QTime::currentTime().toString("hh:mm:ss") ;
adifLoTWExportWidget = new AdifLoTWExportWidget(dataProxy, Q_FUNC_INFO);
//qDebug() << Q_FUNC_INFO << ": ShowAdifImportWidget to be created " << QTime::currentTime().toString("hh:mm:ss") ;
showAdifImportWidget = new ShowAdifImportWidget(dataProxy, Q_FUNC_INFO);
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << ": END " << QTime::currentTime().toString("hh:mm:ss") ;
}
MainWindow::~MainWindow()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
if (hamlibActive)
{
hamlib->stop();
}
delete(showErrorDialog);
delete(lotwUtilities);
delete(eqslUtilities);
delete(elogQRZcom);
//delete(elogClublog);
delete(downloadcty);
//delete(world);
delete(mapWindow);
//delete(locator);
//delete(qso);
delete(backupQSO);
//delete(modifyingQSO);
//dateTime.reset();
//delete(dateTime);
//delete(dateTimeTemp);
//delete(awards);
delete(softUpdate);
delete(filemanager);
//delete(fileAwardManager);
delete(util);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::saveWindowsSize()
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
windowSize = this->size();
//int height = windowSize.height();
//int width = windowSize.width();
QSettings settings(util->getCfgFile (), QSettings::IniFormat);
settings.setValue ("MainWindowSize", windowSize);
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::windowsSizeAndPosition: END" ;
}
void MainWindow::setWindowSize(const QSize &_size)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//QSize size;
//size.setHeight(_height);
//size.setWidth(_width);
if (_size.isValid ())
{
this->resize(_size);
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::init_variables()
{
//qDebug() << Q_FUNC_INFO << " - Start";
QRZCOMAutoCheckAct->setCheckable(true);
QRZCOMAutoCheckAct->setChecked(false);
manualMode = false;
qrzAutoChanging = false;
logEvents = true;
//Default band/modes
bands << "10M" << "15M" << "20M" << "40M" << "80M" << "160M";
modes << "SSB" << "CW";
//qDebug() << Q_FUNC_INFO << " - 00" << (QTime::currentTime()).toString("HH:mm:ss") ;
hamlibActive = false;
hamlibModeNotADIFSupported = false;
hamlibChangingMode = false;
yearChangedDuringModification = false;
readingTheUI = false;
itIsANewversion = false;
infoLabel1T = QString();
infoLabel2T = QString();
infoTimeout = 2000; // default timeout
defaultADIFLogFile = "klog.adi";
InValidCharsInPrevCall = false;
checkNewVersions = true;
reportInfo = false;
configured = false;
noMoreErrorShown = false;
noMoreModeErrorShown = false;
qslingNeeded = false; // When clicking on Find QSO to QSL
manageMode = false;
txFreqBeingAutoChanged = false;
//rxFreqBeingChanged = false;
updatingBands = false;
selectedYear = 0;
defaultMode = 1;
defaultBand = 1;
//qDebug() << Q_FUNC_INFO << " - 20" << (QTime::currentTime()).toString("HH:mm:ss") ;
currentMode = 1;
currentModeShown = currentMode;
currentBand = 1;
currentBandShown = currentBand;
currentLog = 1;
operatorQRZ = "";
stationCallsign = "";
mainQRZ = "";
dxLocator ="";
UDPServerStart = false; // By default the UDP server is started
//qDebug() << Q_FUNC_INFO << " - 30" << (QTime::currentTime()).toString("HH:mm:ss") ;
currentEntity = -1; // To optimize the calls to different world methods if the entity does not change. Used in slotQRZTextChanged
previousEntity = -1;// To optimize the calls to different world methods if the entity does not change.
completeWithPrevious=false;
completedWithPreviousQTH=false;
completedWithPreviousLocator=false;
completedWithPreviousName=false;
completedWithPreviousIOTA=false;
completedWithPreviousQSLVia=false;
alwaysADIF=false;
useDefaultLogFileName=false;
needToSave=false;
qrzSmallModDontCalculate=false;
imperialSystem=false;
sendQSLWhenRec = true;
manageDxMarathon = false;
dxClusterShowHF=true;
dxClusterShowVHF=true;
dxClusterShowWARC=true;
dxClusterShowWorked=true;
dxClusterShowConfirmed=true;
dxClusterShowAnn=true;
dxClusterShowWWV=true;
dxClusterShowWCY=true;
dxclusterSendSpotsToMap = false;
keepSatPage = false;
//qDebug() << Q_FUNC_INFO << " - 40" << (QTime::currentTime()).toString("HH:mm:ss") ;
clublogActive = false;
clublogRealTime = false;
eQSLActive = false;
qrzcomActive = false;
lotwActive = false;
qrzcomSubscriber = false;
callingUpdate = false; // to control whether the update is mannually launched or at the begining
selectedYear = (dateTime->currentDateTime()).date().year();
loggWinAct->setShortcut(Qt::CTRL | Qt::Key_L);
palRed.setColor(QPalette::Text, Qt::red);
palBlack.setColor(QPalette::Text, Qt::black);
clublogAnswer = -1;
//qDebug() << Q_FUNC_INFO << " - Changing colors to default";
defaultColor.fromString(QAnyStringView("slategrey")); //To be replaced by .fromString in Qt6.6
neededColor.fromString(QAnyStringView("yellow"));
workedColor.fromString(QAnyStringView("blue"));
confirmedColor.fromString(QAnyStringView("red"));
newOneColor.fromString(QAnyStringView("green"));
//qDebug() << Q_FUNC_INFO << " - END";
}
void MainWindow::checkDebugFile()
{
QFile debugFile(util->getDebugLogFile());
if (!debugFile.open(QIODevice::WriteOnly | QIODevice::Text)) /* Flawfinder: ignore */
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - File not open"));
QString aux = tr("It was not possible to open the debug file for writing. No debug log will be saved!");
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
else
{
debugFile.close();
logEvent(Q_FUNC_INFO, "KLog started!", Debug);
}
}
void MainWindow::checkHomeDir()
{
if (!QDir::setCurrent ( util->getHomeDir () )){
QDir d1(util->getHomeDir ());
if (d1.mkdir(util->getHomeDir ()))
{
if (!QDir::setCurrent ( util->getHomeDir () ))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - KLog folder not found"));
QString aux = tr("It was not possible to define the KLog folder. Some functions may not work properly!");
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
}
}
void MainWindow::init()
{
//qDebug() << Q_FUNC_INFO << " - Start - " << (QTime::currentTime()).toString("HH:mm:ss") ;
logLevel = Debug;
logEvent(Q_FUNC_INFO, "Start", Debug);
checkHomeDir();
checkDebugFile();
//qDebug() << Q_FUNC_INFO << " - 00" ;
setupDialog->init(softwareVersion, 0, configured);
//qDebug() << Q_FUNC_INFO << " - 01" ;
filemanager->init();
init_variables();
hamlib->initClass();
qsoInUI.clear();
setCleaning(false);
//qDebug() << Q_FUNC_INFO << " - 10" ;
dxClusterWidget->init();
setModifying(false);
//qDebug() << Q_FUNC_INFO << " - 50" << (QTime::currentTime()).toString("HH:mm:ss") ;
checkExistingData();
readSettingsFile();
//qDebug() << Q_FUNC_INFO << " - 70" << (QTime::currentTime()).toString("HH:mm:ss") ;
//qDebug() << Q_FUNC_INFO << " - 71" << (QTime::currentTime()).toString("HH:mm:ss") ;
logWindow->createlogPanel(currentLog);
//qDebug() << Q_FUNC_INFO << " - 72" << (QTime::currentTime()).toString("HH:mm:ss") ;
awards.setManageModes(manageMode);
//qDebug() << Q_FUNC_INFO << " - 73" << (QTime::currentTime()).toString("HH:mm:ss") ;
if (dataProxy->getNumberOfManagedLogs()<1)
{
//qDebug() << Q_FUNC_INFO << " - 73.1" << (QTime::currentTime()).toString("HH:mm:ss") ;
openSetup(6);
//qDebug() << Q_FUNC_INFO << " - 73.2" << (QTime::currentTime()).toString("HH:mm:ss") ;
}
//qDebug() << Q_FUNC_INFO << " - 74" << (QTime::currentTime()).toString("HH:mm:ss") ;
awardsWidget->fillOperatingYears();
awardsWidget->showAwards();
awardsWidget->setManageDXMarathon(manageDxMarathon);
dxClusterWidget->setCurrentLog(currentLog);
//dxClusterAssistant->init();
//qDebug() << Q_FUNC_INFO << " - 80" << (QTime::currentTime()).toString("HH:mm:ss") ;
//qDebug() << Q_FUNC_INFO << ": calling Software update ..." << (QTime::currentTime()).toString("HH:mm:ss") ;
checkVersions();
//qDebug() << Q_FUNC_INFO << " - 90" << (QTime::currentTime()).toString("HH:mm:ss") ;
currentBandShown = dataProxy->getIdFromBandName(mainQSOEntryWidget->getBand());
//qDebug() << Q_FUNC_INFO << " - 91" << (QTime::currentTime()).toString("HH:mm:ss") ;
currentModeShown = dataProxy->getIdFromModeName(mainQSOEntryWidget->getMode());
//qDebug() << Q_FUNC_INFO << " - 92" << (QTime::currentTime()).toString("HH:mm:ss") ;
currentBand = currentBandShown;
currentMode = currentModeShown;
timerInfoBars = new QTimer(this);
//qDebug() << Q_FUNC_INFO << " - Calling createUI" << (QTime::currentTime()).toString("HH:mm:ss") ;
createUI();
//qDebug() << Q_FUNC_INFO << " - Calling slotClearButtonClicked" << (QTime::currentTime()).toString("HH:mm:ss") ;
//qDebug() << Q_FUNC_INFO << " - 100";
slotClearButtonClicked(Q_FUNC_INFO);
//qDebug() << Q_FUNC_INFO << " - 110";
infoWidget->showInfo(-1);
//qDebug() << Q_FUNC_INFO << " - 120";
upAndRunning = true;
mainQSOEntryWidget->setUpAndRunning(upAndRunning);
//qDebug() << Q_FUNC_INFO << " - 130";
applySettings ();
//qDebug() << Q_FUNC_INFO << " - END" << (QTime::currentTime()).toString("HH:mm:ss") ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::checkExistingData()
{
//qDebug() << Q_FUNC_INFO << " - " << (QTime::currentTime()).toString("HH:mm:ss") ;
bool existingData = QFile::exists(util->getKLogDBFile());
//qDebug() << Q_FUNC_INFO << " - 1" ;
ctyDatFile = util->getCTYFile();
//qDebug() << Q_FUNC_INFO << " - 2" ;
if ((!existingData) || (!world->hasSpecialEntities()))
{
//qDebug() << Q_FUNC_INFO << " - Recreating world" ;
world->recreate(ctyDatFile);
//qDebug() << Q_FUNC_INFO << " - 3" ;
//world->create(ctyDatFile);
//qDebug() << Q_FUNC_INFO << " - 4" ;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - CTY.dat update"));
msgBox.setText(tr("KLog needs to update the Entities database."));
msgBox.setDetailedText(tr("You can update the entities database in Tools->Update cty.csv"));
msgBox.setInformativeText(tr("Do you want to update now?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Yes :
slotUpdateCTYDAT();
break;
default:
break;
}
//qDebug() << Q_FUNC_INFO << " - 7" << (QTime::currentTime()).toString("HH:mm:ss") ;
}
//qDebug() << Q_FUNC_INFO << " - END" ;
}
void MainWindow::readSettingsFile()
{
if (util->fileExists(util->getCfgFile()))
{
UpdateSettings settingsUpdate;
if (settingsUpdate.updateFile())
{
configured = loadSettings();
}
}
QSettings settings(util->getCfgFile(), QSettings::IniFormat);
settings.setValue("Version", softwareVersion);
}
void MainWindow::checkVersions()
{
if (checkNewVersions)
{
if (reportInfo)
{
softUpdate->addCall(stationCallsign);
}
softUpdate->needToUpdate();
}
}
void MainWindow::createActionsCommon(){
// Functional widgets connections
//TODO: Reimplement the possibility to enter a QSO with enter inthe following widgets:
//connect(qslViaLineEdit, SIGNAL(returnPressed()), this, SLOT(slotQRZReturnPressed() ) );
logEvent(Q_FUNC_INFO, "Start", Debug);
connect(util, SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)));
//qDebug() << Q_FUNC_INFO << " - Connecting QSO";
connect(&qsoInUI, SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)));
//qDebug() << Q_FUNC_INFO << " - Connected QSO";
connect(QSOTabWidget, SIGNAL(returnPressed()), this, SLOT(slotQRZReturnPressed() ) );
connect(QSOTabWidget, SIGNAL(dxLocatorChanged(QString)), this, SLOT(slotLocatorTextChanged(QString) ) );
connect(myDataTabWidget, SIGNAL(myLocChangedSignal(QString)), this, SLOT(slotMyLocatorTextChanged(QString) ) );
connect(myDataTabWidget, SIGNAL(returnPressed()), this, SLOT(slotQRZReturnPressed() ) );
connect(myDataTabWidget, SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)) );
connect(QSOTabWidget, SIGNAL(rxFreqChanged(double)), this, SLOT(slotFreqRXChanged(double) )) ;
connect(QSOTabWidget, SIGNAL(txFreqChanged(double)), this, SLOT(slotFreqTXChanged(double) )) ;
connect(QSOTabWidget, SIGNAL(handOverFocusSignal()), this, SLOT(slotTakeOverFocusToMainQSOInput() ));
connect(loggWinAct, SIGNAL(triggered()), this, SLOT(slotLogWinShow()));
//Buttons Actions
connect(mainQSOEntryWidget, SIGNAL(handOverFocusSignal()), this, SLOT(slotTakeOverFocusToQSOTabWidget()));
connect(mainQSOEntryWidget, SIGNAL(currentQRZSignal(QString)), this, SLOT(slotQRZTextChanged(QString)));
connect(mainQSOEntryWidget, SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)) );
connect(mainQSOEntryWidget, SIGNAL(showInfoLabel(QString)), this, SLOT(slotShowInfoLabel(QString)) );
connect(mainQSOEntryWidget, SIGNAL(clearForNextQSOSignal(QString)), this, SLOT(slotClearButtonClicked(QString)) );
connect(mainQSOEntryWidget, SIGNAL(OKClicked()), this, SLOT(slotQRZReturnPressed() ) );
connect(mainQSOEntryWidget, SIGNAL(bandChanged(QString)), this, SLOT(slotBandChanged(QString) ) );
connect(mainQSOEntryWidget, SIGNAL(modeChanged(QString)), this, SLOT(slotModeChanged(QString) ) );
connect(mainQSOEntryWidget, SIGNAL(validBands(QStringList)), this, SLOT(slotValidBandsReceived(QStringList) ) );
connect(mainQSOEntryWidget, SIGNAL(manualModeSignal(bool)), this, SLOT(slotManualMode(bool) ) );
// LOGVIEW
connect(logWindow.get(), SIGNAL(actionQSODoubleClicked ( int ) ), this, SLOT(slotDoubleClickLog( const int ) ) );
connect(logWindow.get(), SIGNAL(actionDeleteQSO ( int ) ), this, SLOT(slotQSODelete(int) ) );
connect(logWindow.get(), SIGNAL(deleteTheseQSOs ( QList<int> ) ), this, SLOT(slotQSOsDelete(QList<int>) ) );
connect(logWindow.get(), SIGNAL(exportToADIFTheseQSOs ( QList<int> ) ), this, SLOT(slotQSOsExportToADIF(QList<int>) ) );
connect(logWindow.get(), SIGNAL(updateAwards() ), this, SLOT(slotShowAwards() ) );
connect(logWindow.get(), SIGNAL(queryError(QString, QString, QString, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, QString, QString)) );
//CLUSTER
connect(dxClusterWidget.get(), SIGNAL(dxspotclicked(DXSpot)), this, SLOT(slotAnalyzeDxClusterSignal(DXSpot) ) );
connect(dxClusterWidget.get(), SIGNAL(dxspotArrived(DXSpot)), this, SLOT(slotDXClusterSpotArrived(DXSpot) ) );
// CLUBLOG
connect (elogClublog, SIGNAL (showMessage(QString)), this, SLOT (slotElogClubLogShowMessage(QString)));
connect (elogClublog, SIGNAL (actionReturnDownload(int, int)), this, SLOT (slotElogClubLogProcessAnswer(int, int)));
connect (elogClublog, SIGNAL (disableClubLogAction(bool)), this, SLOT (slotElogClubLogDisable(bool)));
connect (elogClublog, SIGNAL (signalFileUploaded(QNetworkReply::NetworkError, QList<int>)), this, SLOT (slotElogClubLogFileUploaded(QNetworkReply::NetworkError, QList<int>)));
connect (eqslUtilities, SIGNAL (showMessage(QString)), this, SLOT (slotElogClubLogShowMessage(QString)));
connect (eqslUtilities, SIGNAL (signalFileUploaded(QNetworkReply::NetworkError, QList<int>)), this, SLOT (slotElogEQSLFileUploaded(QNetworkReply::NetworkError, QList<int>)));
// QRZCOM
connect (elogQRZcom, SIGNAL (showMessage(QString)), this, SLOT (slotElogQRZCOMShowMessage(QString)));
connect (elogQRZcom, SIGNAL (dataFoundSignal(QString, QString)), this, SLOT (slotElogQRZCOMFoundData(QString, QString)));
connect (elogQRZcom, SIGNAL (signalLogUploaded(QNetworkReply::NetworkError, QList<int>)), this, SLOT (slotElogQRZCOMLogUploaded(QNetworkReply::NetworkError, QList<int>)));
//connect (elogQRZcom, SIGNAL (disableQRZAction(bool)), this, SLOT (slotElogQRZCOMDisable(bool)));
connect(world, &World::queryError, this, &MainWindow::slotQueryErrorManagement);
//connect(world, SIGNAL(queryError(QString, QString, QString, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, QString, QString)) );
// QSL TAB
connect(QSLTabWidget, SIGNAL(returnPressed()), this, SLOT(slotQRZReturnPressed()) );
// SEARCH TAB
connect(searchWidget.get(), SIGNAL(actionQSODoubleClicked ( int ) ), this, SLOT(slotDoubleClickLog( const int ) ) );
connect(searchWidget.get(), SIGNAL(updateAwards() ), this, SLOT(slotShowAwards() ) );
connect(searchWidget.get(), SIGNAL(logRefresh() ), this, SLOT(slotLogRefresh() ) );
connect(searchWidget.get(), SIGNAL(toStatusBar(QString) ), this, SLOT(slotUpdateStatusBar(QString) ) );
connect(searchWidget.get(), SIGNAL(requestBeingShown() ), this, SLOT(slotShowSearchWidget() ) );
connect(searchWidget.get(), SIGNAL(actionQSODelete( int ) ), this, SLOT(slotQSODelete(int) ) );
connect(searchWidget.get(), SIGNAL(queryError(QString, QString, QString, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, QString, QString)) );
connect(&awards, SIGNAL(queryError(QString, QString, QString, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, QString, QString)) );
connect(&awards, SIGNAL(awardDXCCUpdated()), this, SLOT(slotRefreshDXCCWidget()) );
connect(awardsWidget, SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)) );
connect(awardsWidget, SIGNAL(requireCurrentLogSignal()), this, SLOT(slotAwardsWidgetSetLog()) );
connect(awardsWidget, SIGNAL(requireCurrentYearSignal()), this, SLOT(slotAwardsWidgetSetYear()) );
//DXCCWIDGET TAB
//connect(dxccStatusWidget, SIGNAL(showQso(int)), this, SLOT(slotShowQSOFromDXCCWidget(int) ) );
connect(dxccStatusWidget.get(), SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)) );
connect(dxccStatusWidget.get(), SIGNAL(showQsos(QList<int>)), this, SLOT(slotShowQSOsFromDXCCWidget(QList<int>) ) );
connect(dxccStatusWidget.get(), SIGNAL(fillInQSOSignal()), this, SLOT(fillQSOData()) );
//connect(dxccStatusWidget, SIGNAL(updateAwards()), this, SLOT(slotShowAwards() ) );
connect(filemanager, SIGNAL(queryError(QString, QString, QString, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, QString, QString)) );
connect(filemanager, SIGNAL(addQSOToList(QStringList)), this, SLOT(slotReceiveQSOListToShowFromFile(QStringList)) );
//connect(scoreeWinAct, SIGNAL(triggered()), this, SLOT(slotScoreWinShow()));
// UDPLogServer - WSJT-x
connect(UDPLogServer, SIGNAL(status_update(int, QString, double, QString, QString, QString, QString, QString, QString)), this, SLOT(slotWSJXstatusFromUDPServer(int, QString, double, QString, QString, QString, QString, QString, QString) ) );
connect(UDPLogServer, SIGNAL(clearSignal(QString)), this, SLOT(slotClearButtonClicked(QString) ) );
connect(UDPLogServer, SIGNAL(logged(QSO)), this, SLOT(slotQSOReceived(QSO) ) );
connect(this, SIGNAL(queryError(QString, QString, QString, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, QString, QString)) );
connect(setupDialog, SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)) );
connect(setupDialog, SIGNAL(queryError(QString, QString, QString, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, QString, QString)) );
connect(setupDialog, SIGNAL(exitSignal(int)), this, SLOT(slotExitFromSlotDialog(int)) );
//connect(setupDialog, SIGNAL(qrzcomAuto(bool)), this, SLOT(slotElogQRZCOMAutoCheckFromSetup(bool)) );
connect(setupDialog, SIGNAL(finished(int)), this, SLOT(slotSetupDialogFinished(int)) );
connect(setupDialog, SIGNAL(darkModeChanged(bool)), this, SLOT(slotDarkModeChanged(bool)) );
connect(tipsDialog, SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)) );
connect(tipsDialog, SIGNAL(findQSL2QSOSignal()), this, SLOT(slotSearchToolNeededQSLToSend()) );
connect(tipsDialog, SIGNAL(fillInDXCCSignal()), this, SLOT(slotFillEmptyDXCCInTheLog()) );
connect(tipsDialog, SIGNAL(fillInQSOSignal()), this, SLOT(fillQSOData()) );
connect(tipsDialog, SIGNAL(fileExportToPrintSignal()), this, SLOT(slotRQSLExport()) );
connect(tipsDialog, SIGNAL(fileOpenKLogFolderSignal()), this, SLOT(slotOpenKLogFolder()));
connect(tipsDialog, SIGNAL(toolSendPendingQSLSignal()), this, SLOT(slotToolSearchRequestedQSLToSend()));
connect(tipsDialog, SIGNAL(toolRecPendingQSLSignal()), this, SLOT(slotToolSearchNeededQSLPendingToReceive()));
connect(tipsDialog, SIGNAL(toolRecRecPendingQSLSignal()), this, SLOT(slotToolSearchNeededQSLRequested()));
connect(tipsDialog, SIGNAL(toolsUploadLoTWSignal()), this, SLOT(slotLoTWExport()));
// SATELLITES TAB
//connect(satTabWidget, SIGNAL(newBandsToBeAdded(QStringList)), this, SLOT(slotDefineNewBands(QStringList)) );
connect(satTabWidget, SIGNAL(satTxFreqChanged(double)), this, SLOT(slotFreqTXChangedFromSat(double) ) );
//connect(satTabWidget, SIGNAL(satRxFreqChanged(double)), this, SLOT(slotFreqRXChanged(double) ) );
//connect(satTabWidget, SIGNAL(dxLocatorChanged(QString)), this, SLOT(slotUpdateLocator(QString)) );
connect(satTabWidget, SIGNAL(setPropModeSat(QString,bool)), this, SLOT(slotSetPropModeFromSat(QString,bool)) ) ;
connect(satTabWidget, SIGNAL(satTXFreqNeeded(double)), this, SLOT(slotFreqTXChanged(double)));
connect(satTabWidget, SIGNAL(satRXFreqNeeded(double)), this, SLOT(slotFreqRXChanged(double)));
//connect(satTabWidget, SIGNAL (satBandTXChanged(QString)), this, SLOT (slotSatBandTXComboBoxChanged(QString)));
connect(satTabWidget, SIGNAL(returnPressed()), this, SLOT(slotQRZReturnPressed()) );
connect(othersTabWidget, SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)) );
connect(othersTabWidget, SIGNAL(setPropMode(QString)), this, SLOT(slotSetPropModeFromOther(QString)) ) ;
connect(downloadcty, SIGNAL(done(bool)), this, SLOT(slotWorldReload(bool)) );
connect(timerInfoBars, SIGNAL(timeout()), this, SLOT(slotTimeOutInfoBars()) );
connect(hamlib, SIGNAL(freqChanged(double)), this, SLOT(slotHamlibTXFreqChanged(double)) );
connect(hamlib, SIGNAL(modeChanged(QString)), this, SLOT(slotHamlibModeChanged(QString)) );
connect(lotwUtilities, SIGNAL(actionProcessLoTWDownloadedFile(QString)), this, SLOT(slotLoTWDownloadedFileProcess(QString)) );
connect(adifLoTWExportWidget, SIGNAL(qsosToSend(QString, QList<int>, ExportMode)), this, SLOT(slotADIFExportSelection(QString, QList<int>, ExportMode)) );
connect(adifLoTWExportWidget, SIGNAL(askingToClose()), this, SLOT(slotADIFExportClose()) );
connect(dataProxy, SIGNAL(queryError(QString, QString, QString, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, QString, QString)) );
connect(dataProxy, SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)) );
connect(showKLogLogWidget, SIGNAL(newLogLevel(DebugLogLevel)), this, SLOT(slotNewLogLevel(DebugLogLevel)) );
//connect(this, SIGNAL(focusC), this, SLOT(slotTimeOutInfoBars()) );
// Following calls answer calls from the QSO to receive information.
connect (&qsoInUI, SIGNAL(getModeSignal(QString)), this, SLOT(slotQSO_SetMode(QString)));
connect(&qsoInUI, SIGNAL(queryError(QString, QString, QString, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, QString, QString)) );
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotQSO_SetMode(const QString _submode)
{
qsoInUI.setMode(dataProxy->getNameFromSubMode (_submode));
}
void MainWindow::recommendBackupIfNeeded()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
if (dataProxy->getHowManyQSOInLog(-1)<1)
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
}
QDateTime lastBackupDate;
lastBackupDate = QDateTime();
lastBackupDate = filemanager->getDateTimeOfLastBackup();
//qDebug() << Q_FUNC_INFO << " - lastDate: " << util->getDateTimeSQLiteStringFromDateTime(lastBackupDate) << (QTime::currentTime()).toString(" HH:mm:ss") ;
bool backupNeeded = false;
QString msg;
if (lastBackupDate == QDateTime())
{
backupNeeded = true;
msg = tr("You seem to have never backed up or exported your log to ADIF.");
}
else if (lastBackupDate.addMonths(1) < QDateTime::currentDateTime())
{
//qDebug() << Q_FUNC_INFO << " - More than a month" << (QTime::currentTime()).toString(" HH:mm:ss") ;
backupNeeded = true;
msg = tr("Your latest backup seems older than one month.");
}
if (backupNeeded)
{
//qDebug() << Q_FUNC_INFO << " - We need to backup" << (QTime::currentTime()).toString(" HH:mm:ss") ;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
//msg = msg + tr("Do you want to backup your logs now?");
//msgBox.setText(msg);
msgBox.setWindowTitle(tr("Log backup recommended!"));
msgBox.setText(msg);
msgBox.setInformativeText(tr("Regular backups prevent data loss and are good operator practice.\n"
"Once exported, copy your ADIF file to a safe place such as a USB drive, cloud drive or other offsite computer.\n\n"
"KLog will remind you to backup on a monthly basis.\n\n"));
msgBox.addButton(QMessageBox::Yes);
msgBox.addButton(QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Yes:
QString filename = util->getBackupADIFile();
//qDebug() << Q_FUNC_INFO << " - Backup to: " << filename << (QTime::currentTime()).toString(" HH:mm:ss") ;
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - Backup"));
if (filemanager->adifLogExport(filename, 0)) // 0 will save ALL the logs)
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("Backup completed successfully"));
msgBox.setInformativeText(tr("KLog will remind you again in approximately one month."));
}
else
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Backup failed."));
msgBox.setInformativeText(tr("Periodic data backups are recommended to prevent data loss and corruption of your log."));
}
msgBox.exec();
break;
}
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::checkIfNewVersion()
{
//qDebug() << Q_FUNC_INFO << " - " << util->getVersion();
logEvent(Q_FUNC_INFO, "Start", Debug);
//itIsANewversion = true;
if (itIsANewversion)
{
if (util->getVersion() == "2.2")
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - New version detected!"));
msgBox.setText(tr("This version of KLog requires that the DXCC database is updated."));
msgBox.setInformativeText(tr("The database will be updated."));
msgBox.exec();
slotWorldReload(true);
}
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - New version detected!"));
msgBox.setText(tr("It seems that you are running this version of KLog for the first time."));
msgBox.setInformativeText(tr("The setup will now open to allow you to change your settings."));
msgBox.exec();
openSetup(0);
}
//qDebug() << Q_FUNC_INFO << " - END" ;
}
void MainWindow::createStatusBar()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
statusBar()->showMessage(tr("Ready"));
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotShowMap()
{
Locator locator;
Coordinate center = locator.getLocatorCoordinate(world->getQRZLocator(stationCallsign));
mapWindow->setCenter(center);
QSize size = this->size();
//qDebug() << Q_FUNC_INFO << QString(" - Size: %1x%2").arg(size.width()).arg(size.height());
size = size/2;
//qDebug() << Q_FUNC_INFO << QString(" - Size: %1x%2").arg(size.width()).arg(size.height());
mapWindow->resize(size);
mapWindow->show();
//QStringList a;
//a.clear();
//a << dataProxy->getFilteredLocators("All", "All", "All", "All");
//a << locator->getAll();
//foreach (QString ai, a)
//{
// mapWindow->addMarker (locator->getLocatorCoordinate (ai));
//}
//mapWindow->addLocators(a, QColor(0, 0, 255, 127));
}
//void MainWindow::slotShowDXClusterAssistant()
//{
//dxClusterAssistant->show();
//}
void MainWindow::setMainWindowTitle()
{
//qDebug() << Q_FUNC_INFO << " - Start";
QString aux = dataProxy->getCommentsFromLog(currentLog);
int numberOfQSOs = dataProxy->getHowManyQSOInLog (currentLog);
//qDebug() << Q_FUNC_INFO << " - (comment): " << aux ;
QString msg;
if (mainQRZ == stationCallsign)
{
msg = QString(tr("KLog-%1 - Logbook of %2 - QSOs: %3" )).arg(pkgVersion).arg(stationCallsign).arg(numberOfQSOs);
}
else
{
msg = QString(tr("KLog-%1 - Logbook of %2 - Station Callsign: %3 - QSOs: %4" )).arg(pkgVersion).arg(mainQRZ).arg(stationCallsign).arg(numberOfQSOs);
}
if (aux.length ()>0)
{
setWindowTitle(QString("%1 - %2").arg(msg).arg(aux));
}
else
{
setWindowTitle(msg);
}
}
void MainWindow::createUI()
{
//qDebug() << Q_FUNC_INFO << " - Start";
logEvent(Q_FUNC_INFO, "Start", Debug);
createStatusBar();
setWindowTitle(tr("KLog"));
createUIDX();
createActionsCommon();
createMenusCommon();
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << " - END" ;
}
void MainWindow::slotTimeOutInfoBars()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << " - - Start" ;
slotShowInfoLabel(infoLabel1T);
infoLabel2->setText(infoLabel2T);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::setModeFromFreq()
{
//TODO: define frequency ranges for the different modes
if (hamlibActive && !manualMode)
{
if (QSOTabWidget->getTXFreq () >= dataProxy->getLowLimitBandFromBandName("20M"))
{
hamlib->setMode("USB");
}
else
{
hamlib->setMode("LSB");
}
if (!hamlibChangingMode)
{
hamlib->setMode(mainQSOEntryWidget->getMode());
}
}
}
void MainWindow::slotBandChanged (const QString &_b)
{
//qDebug() << Q_FUNC_INFO << " - " << _b ;
logEvent(Q_FUNC_INFO, "Start", Debug);
if ((!upAndRunning) || (_b.length()<2))
{
//qDebug() << Q_FUNC_INFO << " - !upAndRunning or band short" ;
return;
}
if (updatingBands)
{
//qDebug() << "MainWindow::slotBandChanged: updating Bands" ;
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
}
bool isFRinBand = dataProxy->isThisFreqInBand(_b, QString::number(QSOTabWidget->getTXFreq ()));
if ((isFRinBand) && (QSOTabWidget->getTXFreq () >0 ))
{ // No change in txFreq
//qDebug() << "MainWindow::slotBandChanged: isFRinBand and Freq >0" ;
logEvent(Q_FUNC_INFO, "END-2", Debug);
return;
}
currentBandShown = dataProxy->getIdFromBandName(_b);
currentModeShown = dataProxy->getIdFromModeName(mainQSOEntryWidget->getMode());
currentBand = currentBandShown;
currentMode = currentModeShown;
if ((!isFRinBand) || (QSOTabWidget->getTXFreq()<=0))
{
//qDebug() << "MainWindow::slotBandChanged: Freq is not in band or empty" ;
//qDebug() << "MainWindow::slotBandChanged: Band: " << mainQSOEntryWidget->getBand() ;
//qDebug() << "MainWindow::slotBandChanged: Freq: " << QString::number(QSOTabWidget->getTXFreq()) ;
double txFr = (dataProxy->getFreqFromBandId(currentBandShown)).toDouble();
//qDebug() << "MainWindow::slotBandChanged: New Freq: " << QString::number(txFr) ;
slotFreqTXChanged (txFr);
//if (!dataProxy->isThisFreqInBand(_b, QString::number(rxFreqSpinBox->value ())))
//{
// rxFreqSpinBox->setvalue (QSOTabWidget->getTXFreq());
//}
}
//qDebug() << "MainWindow::slotBandChanged: Checking to update Freq - DONE" ;
EntityStatus _entityStatus;
_entityStatus.dxcc = currentEntity;
_entityStatus.bandId = currentBandShown;
_entityStatus.modeId = currentModeShown;
_entityStatus.logId = currentLog;
//qDebug() << "MainWindow:: - calling showStatusOfDXCC-02 " ;
if (currentEntity>0)
{
showStatusOfDXCC(_entityStatus);
}
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::slotBandChanged: END" ;
}
void MainWindow::slotModeChanged (const QString &_m)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
if (!upAndRunning || modify)
{
return;
}
//qDebug() << "MainWindow::slotModeChanged: " << _m ;
currentBandShown = dataProxy->getIdFromBandName(mainQSOEntryWidget->getBand());
//qDebug() << "MainWindow::slotModeComboBoxChanged: currentBandShown2: " << QString::number(currentBandShown) ;
currentModeShown = dataProxy->getIdFromModeName(_m);
currentBand = currentBandShown;
currentMode = currentModeShown;
EntityStatus _entityStatus;
_entityStatus.dxcc = currentEntity;
_entityStatus.bandId = currentBandShown;
_entityStatus.modeId = currentModeShown;
_entityStatus.logId = currentLog;
showStatusOfDXCC(_entityStatus);
if (!modify)
{
QSOTabWidget->setRSTToMode(mainQSOEntryWidget->getMode(), readingTheUI);
}
//QString _modeSeen = mainQSOEntryWidget->getMode();
if (hamlibActive && !manualMode)
{
hamlib->setMode(mainQSOEntryWidget->getMode());
}
/* if (_modeSeen == "SSB")
{
setModeFromFreq();
}
*/
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << " - " << mainQSOEntryWidget->getMode() ;
}
void MainWindow::slotOKButtonClicked(){
logEvent(Q_FUNC_INFO, "Start", Debug);
slotQRZReturnPressed();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotQRZReturnPressed()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << " - Start" ;
if (mainQSOEntryWidget->getQrz().length()<=0)
{
//qDebug() << Q_FUNC_INFO << " - no QRZ" ;
return;
}
readingTheUI = true;
if (!readQSOFromUI())
{
//qDebug() << Q_FUNC_INFO << " - readQSOFromUI returned FALSE";
return;
}
if (!qsoInUI.isValid())
{
//qDebug() << Q_FUNC_INFO << " - QSO Not valid!";
return;
}
int addedOK = qsoInUI.toDB (modifyingQSOid);
//qDebug() << Q_FUNC_INFO << ": id: " << QString::number(addedOK);
if (addedOK>0)
{
//qDebug() << Q_FUNC_INFO << ": QSO Added: " << QString::number(addedOK);
mapWindow->addLocator(qsoInUI.getGridSquare(), workedColor);
actionsJustAfterAddingOneQSO();
}
// Just to prepare or some tasks before reading DATA from UI
yearChangedDuringModification = false;
readingTheUI = false;
//qDebug() << Q_FUNC_INFO << "Just before cleaning";
slotClearButtonClicked(Q_FUNC_INFO);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::actionsJustAfterAddingOneQSO()
{
//qDebug() << Q_FUNC_INFO << " - Start" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
int lastId = -1;
needToSave = true;
if (modify)
{
//qDebug() << Q_FUNC_INFO << " - Modifying! " ;
needToSave = true;
if(modifyingQSOid>0)
{
awards.setAwards();
if (yearChangedDuringModification)
{
awardsWidget->fillOperatingYears();
yearChangedDuringModification = false;
}
if ((clublogActive) && (clublogRealTime))
{
//qDebug() << Q_FUNC_INFO << " - (Modifiying ClubLog) Lastid: "<< QString::number(lastId) ;
// Delete QSO in CLubLog
elogClublog->deleteQSO(clublogPrevQSO);
// Add modified QSO in ClubLog
elogClublog->sendQSO(dataProxy->getClubLogRealTimeFromId(modifyingQSOid));
}
else
{
//qDebug() << Q_FUNC_INFO << " - (No ClubLog) Lastid: "<< QString::number(lastId) ;
}
awards.setAwards(); //Update the DXCC award status
}
// CHECK WHAT WAS THE QSOID to add the awards, if needed
}
else
{
//qDebug() << Q_FUNC_INFO << " - Not Modifying " ;
lastId = dataProxy->getLastQSOid();
if (lastId>=0)
{
//qDebug() << Q_FUNC_INFO << " - Lastid: "<< QString::number(lastId) ;
awards.setAwards(); //Update the DXCC award status
// Send to CLUBLOG if enabled
if ((clublogActive) && (clublogRealTime))
{
//qDebug() << Q_FUNC_INFO << " - (Sending ClubLog) Lastid: "<< QString::number(lastId) ;
elogClublog->sendQSO(dataProxy->getClubLogRealTimeFromId(lastId));
}
else
{
//qDebug() << Q_FUNC_INFO << " - (No ClubLog) Lastid: "<< QString::number(lastId) ;
}
//<CLUBLOG>
}
else
{
//qDebug() << Q_FUNC_INFO << " - Lastid < 0 "<< QString::number(lastId) ;
}
//awards.setAwards(lastId);
}
logWindow->refresh();
//awards.updateDXCCStatus(-1);
dxccStatusWidget->refresh();
searchWidget->refresh();
awardsWidget->showAwards ();
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << " - END" ;
}
bool MainWindow::checkValidCallBeforeAddingToLog(const QString &_call)
{
//qDebug() << Q_FUNC_INFO << " : " << _call;
Callsign callsign(_call);
if (!callsign.isValid())
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - Not valid call"));
QString aux = QString(tr("The callsign %1 is not a valid call. Do you really want to add this callsign to the log?") ).arg(_call);
msgBox.setText(aux);
msgBox.setInformativeText(tr("Adding non-valid calls to the log may create problems when applying for awards, exporting ADIF files to other systems or applications."));
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Yes:
// Ok was clicked
return true;
case QMessageBox::No:
return false;
default:
// should never be reached
return true;
}
}
return true;
}
int MainWindow::checkDXCCBeforeAddingToLog(const int dxcc_Call, const int dxcc_qso)
{
int selected = world->selectEntity(dxcc_Call, dxcc_qso);
if ((dxcc_Call!=dxcc_qso) && (selected < 0))
{
QString dxcc1_name = world->getEntityName(dxcc_Call);
QString dxcc1_prefix = world->getEntityMainPrefix(dxcc_Call);
QString dxcc2_name = world->getEntityName(dxcc_qso);
QString dxcc2_prefix = world->getEntityMainPrefix(dxcc_qso);
QString message = QString(tr("The entity that is selected is different from the one proposed by KLog:") + "\n\n");
QString message_dxcc_qso = dxcc1_prefix + " - " + dxcc1_name + "\n\n";
if (dxcc1_prefix.length()<1)
{
dxcc1_prefix = tr ("Unknown", "Keep it short, its a button text");
message_dxcc_qso = QString(tr("- There is no selected DXCC.") + "\n\n");
}
QString message_dxcc_klog = dxcc2_prefix + " - " + dxcc2_name;
if (dxcc2_prefix.length()<1)
{
dxcc2_prefix = tr ("Unknown", "Keep it short, its a button text");
message_dxcc_klog = QString (tr("- KLog couldn't find a DXCC") + "\n\n");
}
message = message + message_dxcc_qso + message_dxcc_klog + "\n\n" + tr("Please select the one you want to keep for this QSO.");
QPushButton *button2 = new QPushButton(this);
QPushButton *button1 = new QPushButton(this);
button1->setText(dxcc1_prefix);
button2->setText(dxcc2_prefix);
int ret;
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - Select correct entity"));
msgBox.setText(message);
msgBox.addButton(button2, QMessageBox::AcceptRole);
msgBox.addButton(button1, QMessageBox::ActionRole);
msgBox.addButton(QMessageBox::Cancel);
ret = msgBox.exec();
if (ret == QMessageBox::AcceptRole)
{
return dxcc_qso;
}
else if (ret == QMessageBox::ActionRole)
{
return dxcc_Call;
}
else if (ret == QMessageBox::Cancel)
{
return -1;
}
}
if (selected>0)
return selected;
return dxcc_Call;
}
void MainWindow::getQSODataFromUI()
{
//qDebug() << Q_FUNC_INFO << " - Call-01 : " << qsoInUI.getCall();
qsoInUI.clear();
qsoInUI = mainQSOEntryWidget->getQSOData(qsoInUI);
qsoInUI = QSOTabWidget->getQSOData(qsoInUI);
qsoInUI = commentTabWidget->getQSOData(qsoInUI);
qsoInUI = othersTabWidget->getQSOData(qsoInUI);
qsoInUI = eQSLTabWidget->getQSOData(qsoInUI);
qsoInUI = QSLTabWidget->getQSOData(qsoInUI);
qsoInUI = mainQSOEntryWidget->getQSOData(qsoInUI);
qsoInUI = satTabWidget->getQSOData(qsoInUI);
qsoInUI = myDataTabWidget->getQSOData(qsoInUI);
//*qso = mainQSOEntryWidget->getQSOData(*qso);
//*qso = QSOTabWidget->getQSOData(*qso);
//*qso = commentTabWidget->getQSOData(*qso);
//*qso = othersTabWidget->getQSOData(*qso);
//*qso = eQSLTabWidget->getQSOData(*qso);
//*qso = QSLTabWidget->getQSOData(*qso);
//*qso = mainQSOEntryWidget->getQSOData(*qso);
//*qso = satTabWidget->getQSOData(*qso);
//*qso = myDataTabWidget->getQSOData(*qso);
//qDebug() << Q_FUNC_INFO << " - Call-02 : " << qsoInUI.getCall();
}
bool MainWindow::readQSOFromUI()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << " - 010";
//qDebug() << Q_FUNC_INFO << " - CALL-01 : " << qsoInUI.getCall();
getQSODataFromUI();
if (!checkValidCallBeforeAddingToLog(qsoInUI.getCall()))
{
//qDebug() << Q_FUNC_INFO << ": Not valid Call" ;
return false;
}
//qDebug() << Q_FUNC_INFO << " - 030";
QString tqrz = (qsoInUI.getCall());
//qDebug() << Q_FUNC_INFO << " - tqrz: " << tqrz;
//qDebug() << Q_FUNC_INFO << " - ARRLid: " << world->getQRZARRLId(tqrz);
//qDebug() << Q_FUNC_INFO << " - DXCC : " << qsoInUI.getDXCC();
int dxcc = checkDXCCBeforeAddingToLog(world->getQRZARRLId(tqrz), qsoInUI.getDXCC());
//qDebug() << Q_FUNC_INFO << ": " << dxcc;
if (dxcc < 0)
{
return false;
}
qsoInUI.setDXCC (dxcc);
//qDebug() << Q_FUNC_INFO << " - 040";
qsoInUI.setContinent (dataProxy->getContinentShortNameFromEntity(dxcc));
qsoInUI.setCQZone(infoWidget->getCQ());
qsoInUI.setItuZone(infoWidget->getITU());
qsoInUI.setMyCQZone(my_CQz);
qsoInUI.setMyITUZone(my_ITUz);
qsoInUI.setLogId (currentLog);
//qDebug() << Q_FUNC_INFO << " - 050";
if (qsoInUI.getDistance()<=0.0)
qsoInUI.setDistance (infoWidget->getDistance ());
keepSatPage = satTabWidget->getKeep();
//qDebug() << Q_FUNC_INFO << " - 060";
//qDebug() << Q_FUNC_INFO << " - END" ;
logEvent(Q_FUNC_INFO, "END", Debug);
return true;
}
void MainWindow::slotQSOsExportToADIF(QList<int> _qsos)
{
logEvent(Q_FUNC_INFO, "Start: " + QString::number(_qsos.length ()), Debug);
if (_qsos.length()<1)
{
return; // NO QSO TO EXPORT
}
//qDebug() << Q_FUNC_INFO << " - xxy";
QString fileName = QFileDialog::getSaveFileName(this, tr("Save ADIF File"), util->getHomeDir(), "ADIF (*.adi *.adif)");
//qDebug() << Q_FUNC_INFO << fileName ;
if ((!fileName.endsWith(".adi")) && ( !fileName.endsWith(".adif") ))
{
//qDebug() << Q_FUNC_INFO << ": Adding the .adi to the file" << fileName ;
fileName = fileName + ".adi";
}
//qDebug() << Q_FUNC_INFO << "-1: " << fileName ;
filemanager->adifQSOsExport2(fileName, QString(), _qsos, ModeADIF);
//filemanager->adifQSOsExport(fileName, _qsos);
//qDebug() << Q_FUNC_INFO << "-3" ;
showNumberOfSavedQSO(fileName, _qsos.count());
//qDebug() << Q_FUNC_INFO << " - END" ;
}
void MainWindow::slotQRZcomUpload(QList<int> _qsos)
{
logEvent(Q_FUNC_INFO, "Start: " + QString::number(_qsos.length ()), Debug);
elogQRZcom->sendQSOs(_qsos);
//qDebug() << "MainWindow::slotQRZcomUpload - END" ;
}
void MainWindow::slotQSOsDelete(QList<int> _qsos)
{
//qDebug() << "MainWindow::slotQSOsDelete " << QString::number(_qsos.length()) ;
//foreach(int i, _qsos)
//{
// //qDebug() << "MainWindow::slotQSOsDelete " << QString::number(i) ;
//}
QString message = QString(tr("You have requested to delete several QSOs "));
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setText(message);
msgBox.setDetailedText(tr("This operation shall remove definitely all the selected QSO and associated data and you will not be able to recover it again."));
msgBox.setInformativeText(tr("Are you sure?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Yes :
foreach (int i, _qsos)
{
QStringList qsoToDelete;
qsoToDelete.clear();
qsoToDelete << dataProxy->getClubLogRealTimeFromId(i);
if(dataProxy->deleteQSO(i))
{
//qDebug() << "MainWindow::slotQSODelete: Just removed from log, now I will try to remove from ClubLog, if needed" ;
if (clublogActive && clublogRealTime)
{
//qDebug() << "MainWindow::slotQSODelete: Removing from ClubLog" ;
elogClublog->deleteQSO(qsoToDelete);
}
else
{
//qDebug() << "MainWindow::slotQSODelete: NOT emoving from ClubLog" ;
}
}
}
dxccStatusWidget->refresh();
logWindow->refresh();
slotShowAwards();
break;
case QMessageBox::No :
break;
}
}
void MainWindow::slotQSODelete(const int _id)
{
logEvent(Q_FUNC_INFO, "Start: " + QString::number(_id), Debug);
//qDebug() << "MainWindow::slotQSODelete " << QString::number(_id) ;
int QSOid = _id;
//int x = -1;
QString _qrz = dataProxy->getCallFromId(QSOid);
if (_qrz.length()>=3)
{
QString message = QString(tr("You have requested to delete the QSO with: %1").arg(_qrz));
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setText(message);
msgBox.setInformativeText(tr("Are you sure?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Yes :
{
QStringList qsoToDelete;
qsoToDelete.clear();
qsoToDelete << dataProxy->getClubLogRealTimeFromId(QSOid);
if(dataProxy->deleteQSO(QSOid))
{
//qDebug() << "MainWindow::slotQSODelete: Just removed from log, now I will try to remove from ClubLog, if needed" ;
if (clublogActive && clublogRealTime)
{
//qDebug() << "MainWindow::slotQSODelete: Removing from ClubLog" ;
elogClublog->deleteQSO(qsoToDelete);
}
else
{
//qDebug() << "MainWindow::slotQSODelete: NOT emoving from ClubLog" ;
}
dxccStatusWidget->refresh();
logWindow->refresh();
searchWidget->refresh();
slotShowAwards();
//emit updateSearchText();
}
else
{
//TODO: The QSO could not be removed...
}
}
break;
case QMessageBox::No :
// No was clicked
break;
default:
// should never be reached
break;
}
}
else
{
// TODO: The QSO to be removed was not found in the log
}
//qDebug() << "MainWindow::slotQSODelete END " ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotShowSearchWidget()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
dxUpRightTab->setCurrentIndex(dxUpRightTab->indexOf(searchWidget.get()));
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotLogRefresh()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
logWindow->refresh();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotElogClubLogDisable(const bool _b)
{
//qDebug() << Q_FUNC_INFO;
logEvent(Q_FUNC_INFO, "Start", Debug);
clublogActive = !_b;
//setupDialog->setClubLogActive(clublogActive);
QSettings settings(util->getCfgFile (), QSettings::IniFormat);
settings.beginGroup ("ClubLog");
settings.setValue ("ClubLogActive", _b);
settings.endGroup();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotElogClubLogFileUploaded (QNetworkReply::NetworkError _error, QList<int> _qsos)
{
logEvent(Q_FUNC_INFO, "Start: " + QString::number(_error) + "/" + QString::number(_qsos.length ()), Debug);
QMessageBox msgBox;
if (_error != QNetworkReply::NoError)
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - ClubLog error"));
msgBox.setText(tr("The ClubLog upload process has finished with an error and the log was possibly not uploaded."));
msgBox.setDetailedText(tr("Please check your credentials, your Internet connection and your Clublog account. The received error code was: %1").arg(_error));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
return;
}
QString fileName = util->getClubLogFile();
if (QFile::exists(fileName))
{
//qDebug() << "MainWindow::slotElogClubLogFileUploaded file exist" ;
}
else
{
//qDebug() << "MainWindow::slotElogClubLogFileUploaded file DOES NOT exist" ;
}
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setText(tr("Do you want to mark as Uploaded all the QSOs uploaded to ClubLog?") );
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
int i = msgBox.exec();
if (i == QMessageBox::Yes)
{
bool uploadedToClubLog = dataProxy->clublogSentQSOs(_qsos);
slotLogRefresh();
// TODO: Check if QSOS where sent
if (!uploadedToClubLog)
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was an error while updating to Yes the ClubLog QSO upload information."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
if (!deleteAlwaysAdiFile)
{
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setText(tr("The ClubLog upload process has finished and KLog created a file (%1) in your KLog folder.\n\nDo you want KLog to remove that file?").arg(fileName));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
i = msgBox.exec();
if (i == QMessageBox::Yes)
{
if (QFile::remove(fileName))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setText(tr("The file has been removed."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
//qDebug() << "MainWindow::slotElogClubLogFileUploaded - FILE REMOVED: " << fileName ;
}
else
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setText(tr("The file has not been removed."));
msgBox.setDetailedText(tr("It seems that there was something that prevented KLog from removing the file\nYou can remove it manually."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
//qDebug() << "MainWindow::slotElogClubLogFileUploaded - FILE NOT REMOVED: " << fileName ;
}
//i = msgBox.exec();
}
}
else
{
QFile::remove(fileName);
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotElogClubLogShowMessage(const QString &_s)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
slotUpdateStatusBar(_s);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotElogClubLogProcessAnswer(const int _i, const int _qID)
{
logEvent(Q_FUNC_INFO, "Start: " + QString::number(_i) + "/" + QString::number(_qID), Debug);
clublogAnswer = _i;
if (clublogAnswer == 0) // NO ERROR
{
dataProxy->setClubLogSent(_qID, "Y", eQSLTabWidget->getClubLogDate());
}
else
{
dataProxy->setClubLogSent(_qID, "M", eQSLTabWidget->getClubLogDate());
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotElogEQSLFileUploaded (QNetworkReply::NetworkError _error, QList<int> _qsos)
{
logEvent(Q_FUNC_INFO, "Start: " + QString::number(_error) , Debug);
QMessageBox msgBox;
if (_error != QNetworkReply::NoError)
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - eQSL error"));
msgBox.setText(tr("The eQSL upload process has finished with an error and the log was possibly not uploaded."));
msgBox.setDetailedText(tr("Please check your credentials, your Internet connection and your eQSL account. The received error code was: %1").arg(_error));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
return;
}
QString fileName = util->getEQSLFile();
if (QFile::exists(fileName))
{
//qDebug() << "MainWindow::slotElogEQSLFileUploaded file exist" << fileName ;
}
else
{
//qDebug() << "MainWindow::slotElogEQSLFileUploaded file DOES NOT exist" ;
}
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - eQSL"));
msgBox.setText(tr("Do you want to mark as Uploaded all the QSOs uploaded to eQSL?") );
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
int i = msgBox.exec();
if (i == QMessageBox::Yes)
{
bool uploadedToeQSL = dataProxy->eQSLSentQSOs(_qsos);
slotLogRefresh();
// TODO: Check if QSOS where sent
if (!uploadedToeQSL)
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - eQSL"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was an error while updating to Yes the eQSL QSO upload information."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
if (!deleteAlwaysAdiFile)
{
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - eQSL"));
msgBox.setText(tr("The eQSL upload process has finished and KLog created a file (%1) in your KLog folder.\n\nDo you want KLog to remove that file?").arg(fileName));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
i = msgBox.exec();
if (i == QMessageBox::Yes)
{
if (QFile::remove(fileName))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - eQSL"));
msgBox.setText(tr("The file has been removed."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
//qDebug() << "MainWindow::slotElogEQSLFileUploaded - FILE REMOVED: " << fileName ;
}
else
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - eQSL"));
msgBox.setText(tr("The file has not been removed."));
msgBox.setDetailedText(tr("It seems that there was something that prevented KLog from removing the file\nYou can remove it manually."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
//qDebug() << "MainWindow::slotElogEQSLFileUploaded - FILE NOT REMOVED: " << fileName ;
}
//i = msgBox.exec();
}
}
else
{
QFile::remove(fileName);
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotElogQRZCOMDisable(const bool _b)
{
//qDebug() << Q_FUNC_INFO;
logEvent(Q_FUNC_INFO, "Start", Debug);
if ((_b) && (elogQRZcom->getSubscription ()))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - QRZ.com warning"));
msgBox.setText(tr("QRZ.com has returned a non-subcribed error and queries to QRZ.com will be disabled."));
msgBox.setDetailedText(tr("Please check your QRZ.com subcription or credentials."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
qrzcomActive = false;
QSettings settings(util->getCfgFile (), QSettings::IniFormat);
settings.beginGroup ("QRZcom");
settings.setValue ("QRZcomActive", false);
settings.endGroup ();
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotElogQRZCOMLogUploaded (QNetworkReply::NetworkError _error, QList<int> _qsos)
{
//qDebug() << "MainWindow::slotElogQRZCOMLogUploaded: " << QString::number(_error) ;
logEvent(Q_FUNC_INFO, "Start: " + QString::number(_error) , Debug);
QMessageBox msgBox;
if (_error != QNetworkReply::NoError)
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - QRZ.com error"));
msgBox.setText(tr("The QRZ.com upload process has finished with an error and the log was possibly not uploaded."));
msgBox.setDetailedText(tr("Please check your credentials, your Internet connection and your eQSL account. The received error code was: %1").arg(_error));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
return;
}
QString fileName = util->getEQSLFile();
if (QFile::exists(fileName))
{
//qDebug() << "MainWindow::slotElogQRZCOMLogUploaded file exist" ;
}
else
{
//qDebug() << "MainWindow::slotElogEQSLFileUploaded file DOES NOT exist" ;
}
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - QRZ.com"));
msgBox.setText(tr("Do you want to mark as Uploaded all the QSOs uploaded to QRZ.com?") );
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
int i = msgBox.exec();
if (i == QMessageBox::Yes)
{
bool uploadedToeQSL = dataProxy->QRZCOMSentQSOs(_qsos);
slotLogRefresh();
// TODO: Check if QSOS where sent
if (!uploadedToeQSL)
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - QRZ.com"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was an error while updating to Yes the QRZ.com QSO upload information."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - QRZ.com"));
msgBox.setText(tr("The QRZ.com upload process has finished successfully"));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
//qDebug() << "MainWindow::slotElogEQSLFileUploaded - END" ;
}
void MainWindow::slotElogQRZCOMShowMessage(const QString &_s)
{
//qDebug() << "MainWindow::slotElogQRZCOMShowMessage: " << _s ;
logEvent(Q_FUNC_INFO, "Start", Debug);
slotUpdateStatusBar(_s);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::cleanQRZCOMreceivedDataFromUI()
{
//qDebug() << Q_FUNC_INFO;
if (!modify)
{
QSOTabWidget->cleanQRZCOM(true);
}
completedWithPreviousName = false;
completedWithPreviousLocator = false;
}
void MainWindow::slotElogQRZCOMFoundData(const QString &_t, const QString & _d)
{
//qDebug() << Q_FUNC_INFO << ": " << _t << "/" << _d ;
if (_t == "name")
{
if (QSOTabWidget->getName().length()<1)
{
qrzAutoChanging = true;
QSOTabWidget->setName(_d);
qrzAutoChanging = false;
}
}
else if (_t == "grid")
{
//qDebug() << Q_FUNC_INFO << " Grid found: " << _d;
if ((QSOTabWidget->getDXLocator()).length()<1)
{
qrzAutoChanging = true;
QSOTabWidget->setDXLocator(_d);
qrzAutoChanging = false;
}
else
{
//qDebug() << Q_FUNC_INFO << " There was already a Grid: " << QSOTabWidget->getDXLocator();
}
}
else if (_t == "qth")
{
if (QSOTabWidget->getQTH().length()<1)
{
qrzAutoChanging = true;
QSOTabWidget->setQTH(_d);
qrzAutoChanging = false;
}
}
else if (_t == "qslmgr")
{
//QSLTabWidget->setQSLVia(_d);
}
else if (_t == "error")
{
//qDebug() << Q_FUNC_INFO << " ERROR" << _t << "/" << _d ;
if (_d.contains("Not found: "))
{
cleanQRZCOMreceivedDataFromUI();
//qDebug() << Q_FUNC_INFO << ": call Not found" ;
slotUpdateStatusBar(tr("Call not found in QRZ.com"));
return;
}
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - QRZ.com error"));
QString aux = QString(tr("KLog has received an error from QRZ.com.") );
msgBox.setText(aux);
msgBox.setDetailedText(_d);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
else
{
//qDebug() << Q_FUNC_INFO << ": QRZ value not recognized" ;
}
}
void MainWindow::slotElogQRZCOMCheckThisCall()
{
//qDebug() << Q_FUNC_INFO ;
if (qrzcomActive)
{
elogQRZcom->checkQRZ(mainQSOEntryWidget->getQrz());
}
else
{
showMessageToEnableTheOnlineService(QRZ) ;
}
//qDebug() << Q_FUNC_INFO << " - END" ;
}
void MainWindow::showMessageToEnableTheOnlineService(const OnLineProvider _service)
{
QString aux = util->getOnlineServiceName(_service);
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - %1").arg(aux));
msgBox.setText(tr("You need to activate the %1 service in the eLog preferences.").arg(aux) );
msgBox.exec();
}
void MainWindow::slotElogQRZCOMAutoCheck()
{
//qDebug() << Q_FUNC_INFO << ": " << util->boolToQString(QRZCOMAutoCheckAct->isChecked()) ;
if (!qrzcomActive)
{
showMessageToEnableTheOnlineService(QRZ);
return;
}
QSettings settings(util->getCfgFile (), QSettings::IniFormat);
settings.beginGroup ("QRZcom");
settings.setValue ("QRZcomAuto", false);
settings.endGroup ();
//qDebug() << Q_FUNC_INFO << " - END" ;
}
void MainWindow::slotExitFromSlotDialog(const int exitID)
{
//qDebug() << "MainWindow::slotExitFromSlotDialog: " << QString::number(exitID) ;
logEvent(Q_FUNC_INFO, "Start", Debug);
if (exitID == 2)
{
needToEnd = true;
exitQuestion();
}
//qDebug() << "MainWindow::slotExitFromSlotDialog: END " ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotFileClose()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
exitQuestion();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::exitQuestion()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << "MainWindow::exitQuestion" ;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - Exit"));
QString aux = QString(tr("Do you really want to exit KLog?") );
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Yes:
// Ok was clicked
logEvent(Q_FUNC_INFO, "Exiting KLog!", Debug);
//maybeSave();
saveWindowsSize();
close();
exit(0);
default:
// should never be reached
break;
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotQRZTextChanged(QString _qrz)
{
//qDebug()<< Q_FUNC_INFO << ": " << _qrz ;
logEvent(Q_FUNC_INFO, QString("Start: %1").arg(_qrz), Debug);
//qDebug()<< Q_FUNC_INFO << " - 10" ;
if (_qrz.length()<1)
{
//qDebug()<< Q_FUNC_INFO << " - 11" ;
infoLabel1->clear();
infoLabel2->clear();
slotClearButtonClicked(Q_FUNC_INFO);
logEvent(Q_FUNC_INFO, "END-Empty", Devel);
return;
}
//qDebug()<< Q_FUNC_INFO << " - 20" ;
if (cleaning)
{
//qDebug()<< Q_FUNC_INFO << ": Cleaning" ;
logEvent(Q_FUNC_INFO, "END-Cleaning", Devel);
return;
}
//qDebug()<< Q_FUNC_INFO << " - 30" ;
if (modify)
{
logEvent(Q_FUNC_INFO, "END-Modify", Devel);
return;
}
//qDebug()<< Q_FUNC_INFO << ": checking for modify or length<1" ;
if (qrzSmallModDontCalculate)
//if ((modify) || ((qrzLineEdit->text()).length() < 1) || (qrzSmallModDontCalculate))
{
//qDebug()<< Q_FUNC_INFO << ": MODIFY or Lenght < 1" ;
qrzSmallModDontCalculate=false;
logEvent(Q_FUNC_INFO, "END-Small QRZ, don't calculate", Devel);
return;
}
//qDebug()<< Q_FUNC_INFO << " - 40" ;
//qDebug()<< Q_FUNC_INFO << ": running ..." ;
qrzSmallModDontCalculate = true; // A kind of flag to prevent multiple calls to this method.
//int i;
int dx_CQz = -1;
int dxE_CQz = -1;
int dx_ITUz = -1;
int dxE_ITUz = -1;
cleanQRZCOMreceivedDataFromUI();
//qDebug()<< Q_FUNC_INFO << ": currentQRZ: " <<_qrz ;
currentEntity = world->getQRZARRLId(_qrz);
//qDebug()<< Q_FUNC_INFO << " - 50 - currentEntity: " << QString::number(currentEntity) ;
logEvent(Q_FUNC_INFO, QString("Entity: %1").arg(currentEntity), Devel);
//othersTabWidget->setEntity(currentEntity);
dxE_CQz = world->getEntityCqz(currentEntity);
dx_CQz = world->getQRZCqz(_qrz);
dx_ITUz = world->getQRZItuz(_qrz);
dxE_ITUz = world->getEntityItuz(currentEntity);
//qDebug()<< Q_FUNC_INFO << " - 60" ;
//qDebug()<< Q_FUNC_INFO << ": CQ: " << QString::number(dx_CQz) ;
//qDebug()<< Q_FUNC_INFO << ": CQe: " << QString::number(dxE_CQz) ;
//qDebug()<< Q_FUNC_INFO << ": ITU: " << QString::number(dx_ITUz) ;
//qDebug()<< Q_FUNC_INFO << ": ITUe: " << QString::number(dxE_ITUz) ;
if (dx_CQz == dxE_CQz)
{
dx_CQz = dxE_CQz;
}
if (dx_ITUz == dxE_ITUz)
{
dx_ITUz = dxE_ITUz;
}
EntityStatus _entityStatus;
_entityStatus.dxcc = currentEntity;
_entityStatus.bandId = currentBandShown;
_entityStatus.modeId = currentModeShown;
_entityStatus.logId = currentLog;
Locator locator;
//qDebug()<< Q_FUNC_INFO << ": 60 - currentEntity: " << QString::number(currentEntity) ;
if ( locator.isValidLocator(QSOTabWidget->getDXLocator()))
{
dxLocator = QSOTabWidget->getDXLocator();
}
else
{
dxLocator = world->getLocator(currentEntity);
}
//TODO: Look for a way to prevent updating when not needed. i.e. if the prefix is already defined and only suffix is being sent
// Maybe a wat could be to send the hostprefix and not the callsign?
//qDebug()<< Q_FUNC_INFO << " - currentEntity: " << QString::number(currentEntity);
//qDebug()<< Q_FUNC_INFO << " - c_qrz : " << _qrz;
othersTabWidget->setEntityAndPrefix(currentEntity, _qrz);
//qDebug()<< Q_FUNC_INFO << ": Going to check the DXCC" ;
//qDebug()<< Q_FUNC_INFO << ": current/previous" << QString::number(currentEntity) << "/" << QString::number(previousEntity) ;
if ( (currentEntity != previousEntity) || ((infoLabel2->text()).length() < 1) || (InValidCharsInPrevCall) || (dx_CQz != dxE_CQz) || (dx_ITUz != dxE_ITUz))
{
//qDebug()<< Q_FUNC_INFO << ": currentEntity=" << QString::number(currentEntity) << "/previousEntity=" << QString::number(previousEntity) ;
previousEntity = currentEntity;
InValidCharsInPrevCall = false;
infoLabel2->setText(world->getEntityName(currentEntity));
infoWidget->showEntityInfo(currentEntity, dx_CQz, dx_ITUz);
infoWidget->showDistanceAndBearing(myDataTabWidget->getMyLocator(), dxLocator);
//qDebug()<< Q_FUNC_INFO << ": 70";
showStatusOfDXCC(_entityStatus);
showDXMarathonNeeded(currentEntity, dx_CQz, mainQSOEntryWidget->getDate().year(), currentLog);
//othersTabWidget->setEntity(currentEntity);
// we need to update the list of Primary Subdivisions
}
else if ((dx_CQz == dxE_CQz) || (dx_ITUz == dxE_ITUz))
{
//qDebug()<< Q_FUNC_INFO << ": 101" ;
//slotShowInfoLabel(world->getEntityName(currentEntity), 2);
infoLabel2->setText(world->getEntityName(currentEntity));
infoWidget->showEntityInfo(currentEntity, dx_CQz, dx_ITUz);
}
else
{
//qDebug()<< Q_FUNC_INFO << ": 110" ;
}
//qDebug()<< Q_FUNC_INFO << ": 120" ;
qrzSmallModDontCalculate = false; // If the text has not been modified in this method
//qDebug()<< Q_FUNC_INFO << ": 150 - cursorP at the end : " ;
if (completeWithPrevious)
{
//qDebug()<< Q_FUNC_INFO << ": 160" ;
completeWithPreviousQSO(_qrz);
}
//qDebug()<< Q_FUNC_INFO << ": 170" ;
if (!modify)
{
//qDebug()<< Q_FUNC_INFO << ": 180" ;
searchWidget->setCallToSearch(_qrz);
//qDebug() << Q_FUNC_INFO << " qrz.length>2: " << _qrz;
//qDebug() << Q_FUNC_INFO << " qrzcomActive: " << util->boolToQString (qrzcomActive);
//qDebug() << Q_FUNC_INFO << " QRZCOMAutoCheckAct: " << util->boolToQString (QRZCOMAutoCheckAct->isChecked());
if (qrzcomActive && QRZCOMAutoCheckAct->isChecked() && (_qrz.length ()>2))
{
//qDebug()<< Q_FUNC_INFO << ": 185 Checking QRZ.com";
elogQRZcom->checkQRZ(_qrz);
}
else
{
//qDebug()<< Q_FUNC_INFO << ": 189 NOT checking QRZ.com";
}
}
//qDebug()<< Q_FUNC_INFO << ": 190" ;
//qrzAutoChanging = false;
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug()<< Q_FUNC_INFO << ": END" ;
}
void MainWindow::setCleaning(const bool _c)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
cleaning = _c;
mainQSOEntryWidget->setCleaning(cleaning);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotClearButtonClicked(const QString &_func)
{
//qDebug() << Q_FUNC_INFO << " - Start: " << _func ;
logEvent(Q_FUNC_INFO, "Start", Debug);
Q_UNUSED(_func);
bool needToRecover = modify;
setCleaning(true);
yearChangedDuringModification = false;
setModifying(false);
currentEntity = -1;
//dateTimeTemp = dateTime;
modifyingQSOid = -1;
QSOTabWidget->setRSTToMode(mainQSOEntryWidget->getMode(), readingTheUI);
//qDebug() << Q_FUNC_INFO << " - 10" ;
if (currentBand < 0)
{
currentBand = defaultBand;
}
if (currentMode < 0)
{
currentMode = defaultMode;
//qDebug() << Q_FUNC_INFO << " 12b - currentMode: " << QString::number(currentMode) ;
}
//qDebug() << Q_FUNC_INFO << " - 20" ;
clublogAnswer = -1;
clublogPrevQSO.clear();
//qDebug() << Q_FUNC_INFO << " - 11" ;
setCleaning(false);
//qDebug() << Q_FUNC_INFO << " - 25" ;
//qDebug() << Q_FUNC_INFO << " Log: " << QString::number(currentLog) ;
setMainWindowTitle();
//qDebug() << Q_FUNC_INFO << " - 27" ;
if (needToRecover)
{
//qDebug() << Q_FUNC_INFO << " - 28" ;
//qDebug() << Q_FUNC_INFO << ": Recovening the previous status...";
restoreCurrentQSO(true);
}
else
{
//qDebug() << Q_FUNC_INFO << " - 40" ;
clearUIDX(); // Clear the UI
qsoInUI.clear(); // Clear the QSO
statusBar()->clearMessage();
//qDebug() << Q_FUNC_INFO << ": NOT recovening the previous status...";
}
//qDebug() << Q_FUNC_INFO << " - currentMode = " << QString::number(currentMode) ;
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << " - END" ;
}
void MainWindow::clearUIDX(bool _full)
{
//qDebug() << Q_FUNC_INFO << " - Start" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
mainQSOEntryWidget->clear();
QSOTabWidget->clear();
commentTabWidget->clear(_full);
infoLabel1->clear();
infoLabel2->clear();
eQSLTabWidget->clear();
QSLTabWidget->clear();
othersTabWidget->clear(_full);
infoWidget->clear();
satTabWidget->clear(_full);
myDataTabWidget->clear(_full);
completedWithPreviousName = false;
completedWithPreviousQTH = false;
completedWithPreviousLocator = false;
//qDebug() << Q_FUNC_INFO << " deciding wether to change or not the Freq: " << QString::number(QSOTabWidget->getTXFreq()) ;
if (QSOTabWidget->getTXFreq()<=0)
{
//qDebug() << Q_FUNC_INFO << " Setting TX Freq from: " << QString::number(QSOTabWidget->getTXFreq()) ;
QSOTabWidget->setTXFreq((dataProxy->getFreqFromBandId(dataProxy->getIdFromBandName(mainQSOEntryWidget->getBand()))).toDouble());
//qDebug() << Q_FUNC_INFO << " Setting TX Freq to: " << QString::number(QSOTabWidget->getTXFreq()) ;
QSOTabWidget->setRXFreq(QSOTabWidget->getTXFreq());
}
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << " - END" ;
}
void MainWindow::slotRefreshDXCCWidget()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
dxccStatusWidget->slotRefreshButtonClicked();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::closeEvent(QCloseEvent *event)
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
saveWindowsSize();
if (maybeSave())
{
//qDebug() << Q_FUNC_INFO << " saving needed" ;
dataProxy->unMarkAllQSO();
dataProxy->compressDB();
event->accept();
}
else
{
//qDebug() << Q_FUNC_INFO << " not saving needed" ;
event->ignore();
}
//qDebug() << Q_FUNC_INFO << " - END" ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
bool MainWindow::maybeSave()
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QString str = tr("The logfile has been modified.") + "\n" + tr("Do you want to save your changes?");
if (alwaysADIF)
{
//qDebug() << Q_FUNC_INFO << "- Saving" ;
if (needToSave)
{
QMessageBox::StandardButton ret;
ret = QMessageBox::warning(this, "KLog",
str,
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
if (ret == QMessageBox::Save)
{
if (useDefaultLogFileName)
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
//qDebug() << Q_FUNC_INFO << " - Use default file name" ;
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - ADIF export"));
msgBox.setInformativeText(tr("It is important to export to ADIF and save a copy as a backup."));
if (filemanager->adifLogExport(defaultADIFLogFile, currentLog)) // 0 will save ALL the logs)
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("Saving the log was done successfully."));
msgBox.exec();
//qDebug() << Q_FUNC_INFO << " - Log exported" ;
return true;
}
else
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("The ADIF export was not properly done."));
msgBox.exec();
//qDebug() << Q_FUNC_INFO << " - ERROR Log not exported" ;
return false;
}
}
else
{
logEvent(Q_FUNC_INFO, "END-2", Debug);
//qDebug() << Q_FUNC_INFO << " - Going to import??" ;
slotADIFImport();
return true;
//return saveFileAs();
}
}
else if (ret == QMessageBox::Cancel)
{
logEvent(Q_FUNC_INFO, "END-3", Debug);
//qDebug() << Q_FUNC_INFO << "- Cancel" ;
return false;
}
}
else
{
//qDebug() << Q_FUNC_INFO << " - Not needing to save" ;
}
}
else
{
//qDebug() << Q_FUNC_INFO << "- Not Checking if needed to save" ;
}
logEvent(Q_FUNC_INFO, "END", Debug);
return true;
}
/*
void MainWindow::slotAWAImport()
{
//qDebug() << Q_FUNC_INFO ;
fileAwardManager->importNewAwardFile();
//qDebug() << Q_FUNC_INFO << " - END" ;
}
*/
void MainWindow::createMenusCommon()
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
fileMenu = menuBar()->addMenu(tr("&File"));
//awardAddAct = new QAction(tr("Import Award definition file ..."), this);
//fileMenu->addAction(awardAddAct);
//connect(awardAddAct , SIGNAL(triggered()), this, SLOT(slotAWAImport()));
//awardAddAct ->setToolTip(tr("Import an Award file."));
//TestAct = new QAction(tr("TEST: Advanced search ..."), this);
//fileMenu->addAction(TestAct);
//connect(TestAct, SIGNAL(triggered()), this, SLOT(slotTest()));
ADIFImport = new QAction(tr("&Import from ADIF ..."), this);
fileMenu->addAction(ADIFImport);
connect(ADIFImport, SIGNAL(triggered()), this, SLOT(slotADIFImport()));
ADIFImport->setToolTip(tr("Import an ADIF file into the current log."));
//LoTWImport = new QAction(tr("&Import from LoTW ..."), this);
//fileMenu->addAction(LoTWImport);
//connect(LoTWImport, SIGNAL(triggered()), this, SLOT(slotLoTWImport()));
//LoTWImport->setToolTip(tr("Import an LoTW file into the current log"));
fileMenu->addSeparator();
//fileMenu->addSeparator();
ADIFExport = new QAction(tr("Export to ADIF ..."), this);
fileMenu->addAction(ADIFExport);
//ADIFExport->setMenuRole(QAction::ApplicationSpecificRole);
connect(ADIFExport, SIGNAL(triggered()), this, SLOT(slotADIFExport()));
ADIFExport->setToolTip(tr("Export the current log to an ADIF logfile."));
ADIFExportAll = new QAction(tr("Export all logs to ADIF ..."), this);
fileMenu->addAction(ADIFExportAll);
//ADIFExport->setMenuRole(QAction::ApplicationSpecificRole);
connect(ADIFExportAll, SIGNAL(triggered()), this, SLOT(slotADIFExportAll()));
ADIFExportAll->setToolTip(tr("Export ALL the QSOs into one ADIF file, merging QSOs from all the logs."));
fileMenu->addSeparator();
printLogAct = new QAction(tr("&Print Log ..."), this);
fileMenu->addAction(printLogAct);
printLogAct->setShortcut(Qt::CTRL | Qt::Key_P);
printLogAct->setToolTip(tr("Print your log."));
connect(printLogAct, SIGNAL(triggered()), this, SLOT(slotFilePrint()));
fileMenu->addSeparator();
klogFolderAct = new QAction(tr("KLog folder"), this);
fileMenu->addAction(klogFolderAct);
printLogAct->setToolTip(tr("Opens the data folder of KLog."));
connect(klogFolderAct, SIGNAL(triggered()), this, SLOT(slotOpenKLogFolder()));
fileMenu->addSeparator();
setupAct = new QAction(tr("Settings ..."), this);
fileMenu->addAction(setupAct);
//setupAct->setMenuRole(QAction::PreferencesRole);
connect(setupAct, SIGNAL(triggered()), this, SLOT(slotSetup()));
fileMenu->addSeparator();
exitAct = new QAction(tr("E&xit"), this);
fileMenu->addAction(exitAct);
//exitAct->setMenuRole(QAction::QuitRole);
exitAct->setShortcut(Qt::CTRL | Qt::Key_X);
//connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
connect(exitAct, SIGNAL(triggered()), this, SLOT(slotFileClose()));
toolMenu = menuBar()->addMenu(tr("&Tools"));
fillQsoAct = new QAction(tr("Fill in QSO data"), this);
toolMenu->addAction(fillQsoAct);
//fillQsoAct->setMenuRole(QAction::ApplicationSpecificRole);
connect(fillQsoAct, SIGNAL(triggered()), this, SLOT(fillQSOData()));
fillQsoAct->setToolTip(tr("Go through the log reusing previous QSOs to fill missing information in other QSOs."));
toolMenu->addSeparator();
qslToolMenu = toolMenu->addMenu(tr("QSL tools ..."));
findQSO2QSLAct = new QAction(tr("Find QSO to QSL"), this);
qslToolMenu->addAction(findQSO2QSLAct);
connect(findQSO2QSLAct, SIGNAL(triggered()), this, SLOT(slotSearchToolNeededQSLToSend()));
findQSO2QSLAct->setToolTip(tr("Shows QSOs for which you should send your QSL and request the DX QSL."));
findRequestedQSLAct = new QAction(tr("Find My-QSLs pending to send"), this);
qslToolMenu->addAction(findRequestedQSLAct);
//findQSO2QSLAct->setMenuRole(QAction::ApplicationSpecificRole);
connect(findRequestedQSLAct, SIGNAL(triggered()), this, SLOT(slotToolSearchRequestedQSLToSend()));
findRequestedQSLAct->setToolTip(tr("Shows the QSOs with pending requests to send QSLs. You should keep this queue empty!"));
findQSLPendingToReceiveAct = new QAction(tr("Find DX-QSLs pending to receive"), this);
qslToolMenu->addAction(findQSLPendingToReceiveAct);
connect(findQSLPendingToReceiveAct, SIGNAL(triggered()), this, SLOT(slotToolSearchNeededQSLPendingToReceive()));
findQSLPendingToReceiveAct->setToolTip(tr("Shows DX-QSLs for which requests or QSLs have been sent with no answer."));
findQSLDXRequestedAct = new QAction(tr("Find requested pending to receive"), this);
qslToolMenu->addAction(findQSLDXRequestedAct);
connect(findQSLDXRequestedAct, SIGNAL(triggered()), this, SLOT(slotToolSearchNeededQSLRequested()));
findQSLDXRequestedAct->setToolTip(tr("Shows the DX-QSLs that have been requested."));
toolMenu->addSeparator();
lotwToolMenu = toolMenu->addMenu(tr("LoTW tools ..."));
lotwMarkSentQueuedThisLogAct = new QAction(tr("Queue all QSOs from this log to be sent"), this);
lotwToolMenu->addAction(lotwMarkSentQueuedThisLogAct);
connect(lotwMarkSentQueuedThisLogAct, SIGNAL(triggered()), this, SLOT(slotToolLoTWMarkAllQueuedThisLog()));
lotwMarkSentQueuedThisLogAct->setToolTip(tr("Mark all non-sent QSOs in this log as queued to be uploaded."));
lotwMarkSentQueuedAct = new QAction(tr("Queue all QSLs to be sent"), this);
lotwToolMenu ->addAction(lotwMarkSentQueuedAct);
connect(lotwMarkSentQueuedAct, SIGNAL(triggered()), this, SLOT(slotToolLoTWMarkAllQueued()));
lotwMarkSentQueuedAct->setToolTip(tr("Put all the non-sent QSOs in the queue to be uploaded."));
lotwToolMenu->addSeparator();
lotwMarkSentYesThisLogAct = new QAction(tr("Mark all queued QSOs from this log as sent"), this);
lotwToolMenu->addAction(lotwMarkSentYesThisLogAct);
connect(lotwMarkSentYesThisLogAct, SIGNAL(triggered()), this, SLOT(slotToolLoTWMarkAllYesThisLog()));
lotwMarkSentYesThisLogAct->setToolTip(tr("Mark all queued QSOs in this log as sent to LoTW."));
lotwMarkSentYesAct = new QAction(tr("Mark all queued QSOs as sent"), this);
lotwToolMenu ->addAction(lotwMarkSentYesAct);
connect(lotwMarkSentYesAct, SIGNAL(triggered()), this, SLOT(slotToolLoTWMarkAllYes()));
lotwMarkSentYesAct->setToolTip(tr("Mark all queued QSOs as sent to LoTW."));
lotwToolMenu->addSeparator();
lotwToolMenu ->addAction(lotwCallTQSL);
connect(lotwCallTQSL, SIGNAL(triggered()), this, SLOT(slotLoTWExport()));
lotwCallTQSL->setToolTip("Sends the log to LoTW calling TQSL. You will be able to select the Station Callsign and start and end dates.");
lotwToolMenu->addSeparator();
lotwUpdateFromLoTWAct = new QAction(tr("Download from LoTW ..."), this);
lotwToolMenu ->addAction(lotwUpdateFromLoTWAct);
connect(lotwUpdateFromLoTWAct, SIGNAL(triggered()), this, SLOT(slotLoTWDownload()));
lotwUpdateFromLoTWAct->setToolTip("Updates your LoTW status from LoTW.");
lotwFullDownloadFromLoTWAct = new QAction(tr("Download the full log from LoTW ..."), this);
lotwToolMenu ->addAction(lotwFullDownloadFromLoTWAct);
connect(lotwFullDownloadFromLoTWAct, SIGNAL(triggered()), this, SLOT(slotLoTWFullDownload()));
toolMenu->addSeparator();
clublogToolMenu = toolMenu->addMenu(tr("ClubLog tools ..."));
clublogLogModifyCurrentLogAct = new QAction(tr("Queue all the QSOs to be uploaded"), this);
clublogToolMenu->addAction(clublogLogModifyCurrentLogAct);
connect(clublogLogModifyCurrentLogAct, SIGNAL(triggered()), this, SLOT( slotElogClubLogModifyCurrentLog()));
clublogLogModifyCurrentLogAct->setToolTip("Mark as modified all the QSO so they can be uploaded again to CLubLog.");
clublogLogUploadAct = new QAction(tr("Upload the queued QSOs to ClubLog ..."), this);
clublogToolMenu->addAction(clublogLogUploadAct);
connect(clublogLogUploadAct, SIGNAL(triggered()), this, SLOT(slotClubLogLogUpload()));
clublogLogUploadAct->setToolTip("Uploads your log to ClubLog. Please ensure that you have created log for that callsign before uploading.");
toolMenu->addSeparator();
eQSLToolMenu = toolMenu->addMenu(tr("eQSL tools ..."));
eqslLogModifyCurrentLogAct = new QAction(tr("Queue all the QSOs to be uploaded"), this);
eQSLToolMenu->addAction(eqslLogModifyCurrentLogAct);
connect(eqslLogModifyCurrentLogAct, SIGNAL(triggered()), this, SLOT( slotElogEQSLModifyCurrentLog()));
eqslLogModifyCurrentLogAct->setToolTip("Mark as modified all the QSO so they can be uploaded again to eQSL.");
eqslUploadAct = new QAction(tr("Upload the queued QSOs to eQSL.cc ..."), this);
eQSLToolMenu->addAction(eqslUploadAct);
connect(eqslUploadAct, SIGNAL(triggered()), this, SLOT(sloteQSLLogUpload()));
eqslUploadAct->setToolTip("Uploads your log to eQSL.cc.");
toolMenu->addSeparator();
QRZCOMToolMenu = toolMenu->addMenu(tr("QRZ.com tools ..."));
QRZCOMCheckThisCallAct = new QAction(tr("Check the current callsign in QRZ.com"), this);
QRZCOMLogModifyCurrentLogAct = new QAction(tr("Queue all the QSO to be uploaded"), this);
QRZCOMLogUploadAct = new QAction(tr("Upload the queued QSOs to QRZ.com ..."), this);
QRZCOMToolMenu->addAction(QRZCOMCheckThisCallAct);
connect(QRZCOMCheckThisCallAct, SIGNAL(triggered()), this, SLOT( slotElogQRZCOMCheckThisCall()));
QRZCOMCheckThisCallAct->setToolTip("Checks the current callsign in QRZ.com.");
QRZCOMAutoCheckAct->setText(tr("Check always the current callsign in QRZ.com"));
QRZCOMToolMenu->addAction(QRZCOMAutoCheckAct);
connect(QRZCOMAutoCheckAct, SIGNAL(triggered()), this, SLOT( slotElogQRZCOMAutoCheck()));
QRZCOMAutoCheckAct->setToolTip("Checks always the current callsign in QRZ.com");
QRZCOMToolMenu->addSeparator();
QRZCOMToolMenu->addAction(QRZCOMLogModifyCurrentLogAct);
connect(QRZCOMLogModifyCurrentLogAct, SIGNAL(triggered()), this, SLOT( slotElogQRZCOMModifyCurrentLog()));
QRZCOMLogModifyCurrentLogAct->setToolTip("Mark as modified all the QSO so they can be uploaded again to QRZ.com.");
QRZCOMToolMenu->addAction(QRZCOMLogUploadAct);
connect(QRZCOMLogUploadAct, SIGNAL(triggered()), this, SLOT(slotQRZCOMLogUpload()));
QRZCOMLogUploadAct->setToolTip("Uploads your log to QRZ.com. Please ensure that you have created log and the API-KEY configured in the setup for that callsign before uploading.");
toolMenu->addSeparator();
downloadCTYAct = new QAction (tr("Update cty.csv"), this);
toolMenu->addAction(downloadCTYAct);
//downloadCTYAct->setMenuRole(QAction::ApplicationSpecificRole);
connect(downloadCTYAct, SIGNAL(triggered()), this, SLOT(slotUpdateCTYDAT()));
downloadCTYAct->setToolTip(tr("For updated DX-Entity data, update cty.csv."));
downloadSATSAct = new QAction (tr("Update Satellite Data"), this);
toolMenu->addAction(downloadSATSAct);
connect(downloadSATSAct, SIGNAL(triggered()), this, SLOT(slotUpdateSATSDAT()));
downloadSATSAct->setToolTip(tr("For updated DX-Entity data, update cty.csv."));
toolMenu->addSeparator();
showStatsAct = new QAction (tr("Stats"), this);
toolMenu->addAction(showStatsAct);
connect(showStatsAct, SIGNAL(triggered()), this, SLOT(slotShowStats()));
showStatsAct->setToolTip(tr("Show the statistics of your radio activity."));
showMapAct = new QAction (tr("Show Map"), this);
toolMenu->addAction(showMapAct);
connect(showMapAct, SIGNAL(triggered()), this, SLOT(slotShowMap()));
showMapAct->setToolTip(tr("Show the statistics of your radio activity."));
//dxClusterAssistantAct = new QAction (tr("DXCluster Assistant"), this);
//toolMenu->addAction(dxClusterAssistantAct);
//connect(dxClusterAssistantAct, SIGNAL(triggered()), this, SLOT(slotShowDXClusterAssistant()));
//dxClusterAssistantAct->setToolTip(tr("Show the statistics of your radio activity."));
//qDebug() << "MainWindow::createMenusCommon before" ;
//toolMenu->addSeparator();
//showRotatorAct = new QAction (tr("Rotator"), this);
//toolMenu->addAction(showRotatorAct);
//connect(showRotatorAct, SIGNAL(triggered()), this, SLOT(slotRotatorShow()));
//showRotatorAct->setToolTip(tr("Show the rotator controller."));
//qDebug() << "MainWindow::createMenusCommon after" ;
//showWorldMapAct = new QAction(tr("CQ zones world map"), this);
//toolMenu->addAction(showWorldMapAct);
//connect(showWorldMapAct, SIGNAL(triggered()), this, SLOT(slotWorldMapShow()));
//showWorldMapAct->setToolTip(tr("Show a world map with your radio activity."));
//toolMenu->addSeparator();
//setupMenu = menuBar()->addMenu(tr("Setup"));
//TODO: To be added once the help dialog has been implemented
helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addSeparator();
helpAct= new QAction(tr("Online manual (F1) ..."), this);
helpMenu->addAction(helpAct);
//helpAct->setMenuRole(QAction::ApplicationSpecificRole);
connect(helpAct, SIGNAL(triggered()), this, SLOT(slotOpenWiki()));
tipsAct = new QAction(tr("&Tips ..."), this);
helpMenu->addAction(tipsAct);
//tipsAct->setMenuRole(QAction::ApplicationSpecificRole);
connect(tipsAct, SIGNAL(triggered()), this, SLOT(slotTipsAction()));
helpMenu->addSeparator();
debugAct = new QAction(tr("&Debug ..."), this);
helpMenu->addAction(debugAct);
//debugAct->setMenuRole(QAction::ApplicationSpecificRole);
connect(debugAct, SIGNAL(triggered()), this, SLOT(slotDebugAction()));
aboutAct = new QAction(tr("&About ..."), this);
helpMenu->addAction(aboutAct);
//aboutAct->setMenuRole(QAction::AboutRole);
connect(aboutAct, SIGNAL(triggered()), this, SLOT(slotHelpAboutAction()));
//connect(aboutAct, SIGNAL(triggered()), this, SLOT(slotLoTWTest()) );
#if defined(Q_OS_MACOS) // It seems that on MAC if I try to show both, only the last one (or Qt) is shown
#else // I can define the setMenuRole but then no standard locations are used on macOS
aboutQtAct = new QAction(tr("About Qt ..."), this);
helpMenu->addAction(aboutQtAct);
//aboutQtAct->setMenuRole(QAction::AboutQtRole);
connect(aboutQtAct, SIGNAL(triggered()), this, SLOT(slotAboutQt()));
logEvent(Q_FUNC_INFO, "END", Debug);
#endif
helpMenu->addSeparator();
updateAct = new QAction(tr("Check updates ..."), this);
helpMenu->addAction(updateAct);
//updateAct->setMenuRole(QAction::ApplicationSpecificRole);
connect(updateAct, SIGNAL(triggered()), this, SLOT(slotHelpCheckUpdatesAction()));
}
void MainWindow::slotDebugAction()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
showKLogLogWidget->show();
logEvent(Q_FUNC_INFO, "END", Debug);
}
/*
void MainWindow::slotTest()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO ;
//showKLogLogWidget->setWindowModality(false);
showKLogLogWidget->show();
//advancedSearchWidget->show();
//qDebug() << Q_FUNC_INFO << " - END ";
logEvent(Q_FUNC_INFO, "END", Debug);
}
*/
void MainWindow::slotSearchToolNeededQSLToSend()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
slotShowSearchWidget();
searchWidget->searchToolNeededQSLToSend();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotToolSearchRequestedQSLToSend()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
searchWidget->slotToolSearchRequestedQSLToSend();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotToolSearchNeededQSLPendingToReceive()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
searchWidget->slotToolSearchNeededQSLPendingToReceive();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotToolSearchNeededQSLRequested()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
searchWidget->slotToolSearchNeededQSLRequested();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotToolLoTWMarkAllQueuedThisLog()
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
//QString tdate = util->getDateSQLiteStringFromDate(mainQSOEntryWidget->getDate());
QMessageBox msgConfirm;
msgConfirm.setIcon(QMessageBox::Question);
msgConfirm.setWindowTitle(tr("KLog - LoTW"));
msgConfirm.setText(tr("Do you really want to mark ALL the QSOs of this log to be UPLOADED? Must be done ONLY IF THIS IS YOUR FIRST TIME uploading these QSOs to LoTW."));
msgConfirm.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgConfirm.setDefaultButton(QMessageBox::No);
int i = msgConfirm.exec();
if (i == QMessageBox::Yes)
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - LoTW"));
if(dataProxy->lotwSentQueue(mainQSOEntryWidget->getDate(), currentLog))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("All pending QSOs of this log has been marked as queued for LoTW!") + "\n\n" + tr("Now you can upload them to LoTW."));
}
else
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was a problem to mark all pending QSOs of this log as queued for LoTW!") );
}
msgBox.exec();
logEvent(Q_FUNC_INFO, "END", Debug);
}
}
/*
void MainWindow::slotLoTWTest()
{
//qDebug() << "MainWindow::slotLoTWTest: " ;
slotLoTWDownloadedFileProcess("lotwimport.adi");
//qDebug() << "MainWindow::slotLoTWTest - END" ;
}
*/
void MainWindow::slotLoTWDownloadedFileProcess(const QString &_fn)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << _fn ;
//QList<int> a;
//a.clear();
//a.append(filemanager->adifLoTWReadLog2(_fn, currentLog));
int added_qsos = filemanager->adifLoTWReadLog2(_fn, currentLog);
QString aux;
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - LoTW"));
//qDebug() << Q_FUNC_INFO << " - QSOs added: " << added_qsos;
if (added_qsos>0)
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("Your log has been updated with the LoTW downloaded QSOs."));
aux = QString(tr("KLog has updated %1 QSOs from LoTW.")).arg(added_qsos);
msgBox.setInformativeText(aux);
msgBox.exec();
logWindow->refresh();
dxccStatusWidget->refresh();
//TODO: Add the QSOs to the widget and show showAdifImportWidget->show();
}
else
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Your log has not been updated."));
aux = QString(tr("No QSO was updated with the data coming from LoTW. This may be because of errors in the logfile or simply because your log was already updated."));
msgBox.setInformativeText(aux);
msgBox.exec();
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotToolLoTWMarkAllQueued()
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
//QString tdate = util->getDateSQLiteStringFromDate(mainQSOEntryWidget->getDate());
QMessageBox msgConfirm;
msgConfirm.setIcon(QMessageBox::Question);
msgConfirm.setWindowTitle(tr("KLog - LoTW"));
msgConfirm.setText(tr("Do you really want to mark ALL pending QSOs to be UPLOADED? Must be done ONLY IF THIS IS YOUR FIRST TIME uploading these QSOs to LoTW."));
msgConfirm.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgConfirm.setDefaultButton(QMessageBox::No);
int i = msgConfirm.exec();
if (i == QMessageBox::Yes)
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - LoTW"));
if (dataProxy->lotwSentQueue(mainQSOEntryWidget->getDate(), -1))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("All pending QSOs has been marked as queued for LoTW!") + "\n\n" + tr("Now you can upload them to LoTW."));
}
else
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was a problem to mark all pending QSOs as queued for LoTW!") );
}
msgBox.exec();
logEvent(Q_FUNC_INFO, "END", Debug);
}
}
bool MainWindow::callTQSL(const QString &_filename, const QString &_call)
{ //https://lotw.arrl.org/lotw-help/cmdline/
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << lotwTQSLpath ;
QStringList arguments;
arguments.clear();
//arguments << "--action=compliant" << QString("-c %1").arg(_call) << "-d" << "-u" << "-x" << _filename;
arguments << QString("-c %1").arg(_call) << "-u" << _filename;
int ok = -1;
QString msg;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - TQSL"));
if (!QFile::exists(lotwTQSLpath))
{
msg = tr("TQSL is not installed or KLog can't find it. Please check the configuration.");
ok = 6; // A positive value here will return false, an error below.
}
else
{
ok = QProcess::execute(lotwTQSLpath, arguments);
//qDebug() << Q_FUNC_INFO << " -ok: " << QString::number(ok) ;
switch (ok)
{
case 0: // success: all qsos submitted were signed and saved or signed and uploaded
//qDebug() << Q_FUNC_INFO << ": 0" ;
//msg = tr("All the QSOs were signed and uploaded with no error.");
//msg = tr("TQSL finished with no error.");
//msgBox.setIcon(QMessageBox::Information);
break;
case 1: // cancelled by user
//qDebug() << Q_FUNC_INFO << ": 1" ;
msg = tr("Error #1: The process was cancelled by the user or TQSL was not configured. No QSOs were uploaded.");
break;
case 2: // rejected by LoTW
//qDebug() << Q_FUNC_INFO << ": 2" ;
msg = tr("Error #2: Upload was rejected by LoTW, please check your data.");
break;
case 3: // unexpected response from TQSL server
//qDebug() << Q_FUNC_INFO << "L: 3" ;
msg = tr("Error #3: The TQSL server returned an unexpected response.");
break;
case 4: // TQSL error
//qDebug() << Q_FUNC_INFO << ": 4" ;
msg = tr("Error #4: There was a TQSL error.");
break;
case 5: // TQSLlib error
//qDebug() << Q_FUNC_INFO << ": 5" ;
msg = tr("Error #5: There was a TQSLLib error.");
break;
case 6: // unable to open input file
//qDebug() << Q_FUNC_INFO << ": 6" ;
msg = tr("Error #6: It was not possible to open the input file.");
break;
case 7: // unable to open output file
//qDebug() << Q_FUNC_INFO << "L: 7" ;
msg = tr("Error #7: It was not possible to open the ouput file.");
break;
case 8: // No QSOs were processed since some QSOs were duplicates or out of date range
//qDebug() << Q_FUNC_INFO << ": 8" ;
msg = tr("Error #8: No QSOs were processed since some QSOs were duplicates or out of date range.");
break;
case 9: // Some QSOs were processed, and some QSOs were ignored because they were duplicates or out of date range
//qDebug() << Q_FUNC_INFO << ": 9" ;
msg = tr("Error #9: Some QSOs were processed, and some QSOs were ignored because they were duplicates or out of date range.");
break;
case 10: // command syntax error
//qDebug() << Q_FUNC_INFO << ": 10" ;
msg = tr("Error #10: Command syntax error. KLog sent a bad syntax command.");
break;
case 11: // LoTW Connection error (no network or LoTW is unreachable)
//qDebug() << Q_FUNC_INFO << ": 11" ;
msg = tr("Error #11: LoTW Connection error (no network or LoTW is unreachable).");
break;
default:
msg = tr("Error #00: Unexpected error. Please contact the development team.");
return false;
// should never be reached
}
}
if (ok>0)
{
msgBox.setText(msg);
msgBox.exec();
return false;
}
else
{
return true;
}
//logEvent(Q_FUNC_INFO, "END", Debug);
}
QString MainWindow::selectStationCallsign()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
QString stationCallToUse = QString();
QStringList stationCallSigns;
stationCallSigns.clear();
stationCallSigns << "NONE";
stationCallSigns << dataProxy->getStationCallSignsFromLog(-1);
//bool callsignTyped = false;
if (stationCallSigns.length()>1)
{
QString msg = QString(tr("The log that you have selected contains more than just one station callsign.") + "\n\n" + tr("Please select the station callsign you want to mark as sent to LoTW:"));
bool ok;
stationCallToUse = QInputDialog::getItem(this, tr("Station Callsign:"),
msg, stationCallSigns, 0, false, &ok);
Callsign callsign(stationCallToUse);
if (ok && callsign.isValid())
//if (ok && !stationCallToUse.isEmpty())
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
return stationCallToUse;
}
else
{
stationCallToUse = (QInputDialog::getText(this, tr("Define Station Callsign"),
tr("You have selected no callsign. KLog will complete the QSOs without a station callsign defined and those with the callsign you are entering here.") + "\n\n" + tr("Enter the station callsign to use for this log or leave it empty for QSO without station callsign defined:"), QLineEdit::Normal,
"", &ok)).toUpper();
if (ok)
{
callsign(stationCallToUse);
if (callsign.isValid())
{
logEvent(Q_FUNC_INFO, "END-2", Debug);
return stationCallToUse;
}
}
else
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - No station selected"));
QString aux = QString(tr("No station callsign has been selected and therefore no log will be marked") );
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
// Ok was clicked
//return ;
break;
default:
// should never be reached
break;
}
}
}
}
logEvent(Q_FUNC_INFO, "END", Debug);
return QString();
}
void MainWindow::slotToolLoTWMarkAllYesThisLog()
{
//qDebug() << Q_FUNC_INFO ;
//QString tdate = util->getDateSQLiteStringFromDate(mainQSOEntryWidget->getDate());
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - LoTW"));
logEvent(Q_FUNC_INFO, "Start", Debug);
if(dataProxy->lotwSentYes(mainQSOEntryWidget->getDate(), currentLog, "ALL"))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("All queued QSOs of this log has been marked as sent to LoTW!") );
}
else
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was a problem to mark all queued QSOs of this log as sent to LoTW!") );
}
msgBox.exec();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotToolLoTWMarkAllYes()
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QString stationCallToUse = selectStationCallsign();
//QString tdate = util->getDateSQLiteStringFromDate(mainQSOEntryWidget->getDate());
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - LoTW"));
if (dataProxy->lotwSentYes(mainQSOEntryWidget->getDate(), -1, stationCallToUse))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("All queued QSOs has been marked as sent to LoTW!") );
}
else
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was a problem to mark all queued QSOs as sent to LoTW!") );
}
msgBox.exec();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotReceiveQSOListToShowFromFile(QStringList _qs)
{
//qDebug() << Q_FUNC_INFO << QString::number(_qs.length()) ;
logEvent(Q_FUNC_INFO, "Start", Debug);
// Receiving: modifiedQSOList << _call << _date + "-" +_time << _band << _mode << _qslrdate;
// Must send QRZ-DX, Date-Time(yyyyMMdd-hhmmss), Band, Mode
if (_qs.length()!=4)
{
//qDebug() << Q_FUNC_INFO << " - NO valid qso list received - length: " << QString::number(_qs.length()) ;
return;
}
Callsign callsign(_qs.at(0));
if (!callsign.isValid())
{
//qDebug() << Q_FUNC_INFO << " - NO valid QRZ received - " << _qs.at(0) ;
return;
}
if (dataProxy->getIdFromBandName(_qs.at(2))<0)
{
//qDebug() << Q_FUNC_INFO << " - NO valid BAND received"<< _qs.at(2) ;
return;
}
if (dataProxy->getIdFromModeName(_qs.at(3))<0)
{
//qDebug() << Q_FUNC_INFO << " - NO valid Mode received" << _qs.at(3);
return;
}
if (!util->isValidDateTimeFromString(_qs.at(1)))
{
//qDebug() << Q_FUNC_INFO << " No valid date" ;
return;
}
//qDebug() << Q_FUNC_INFO << " ALL OK" ;
//QStringList qsoToSend;
//qsoToSend.clear();
//qsoToSend << _qs.at(0) << _qs.at(1) << _qs.at(2) << _qs.at(3);
showAdifImportWidget->addQSOToTheList(_qs);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotAboutQt()
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QMessageBox::aboutQt(this,tr("About ..."));
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotHelpAboutAction()
{
//qDebug() << Q_FUNC_INFO ;
// QMessageBox::about(this, tr("About KLog"),
// tr("<b>KLog</b> "
// "Find the last release at https://jaime.robles.es/klog."));
logEvent(Q_FUNC_INFO, "Start", Debug);
aboutDialog->exec();
logEvent(Q_FUNC_INFO, "END", Debug);
//helpAboutDialog->exec();
}
void MainWindow::slotTipsAction()
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
tipsDialog->exec();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotHelpCheckUpdatesAction()
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
callingUpdate = true;
softUpdate->addCall(stationCallsign);
softUpdate->needToUpdate(true);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotShowSoftUpdateResults(const bool _b)
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
if (_b == true)
{
//qDebug() << Q_FUNC_INFO << " _b = TRUE " ;
}
else
{
//qDebug() << Q_FUNC_INFO << " _b = FALSE " ;
}
if (callingUpdate == true)
{
if (_b == false)
{
//qDebug() << Q_FUNC_INFO << " UPDATE NOT NEEDED" ;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - Update checking result"));
msgBox.setText(tr("Congratulations!") + "\n\n" + tr("You already have the latest version."));
msgBox.exec();
}
else
{
//qDebug() << Q_FUNC_INFO << ": UPDATE NEEDED" ;
}
}
callingUpdate = false;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotLogWinShow()
{
//qDebug() << Q_FUNC_INFO ;
logEvent(Q_FUNC_INFO, "Start", Debug);
if (!(logWindow->isVisible()) )
{
logWinAct->setChecked ( true );
logWindow->show();
}else
{
logWinAct->setChecked ( false );
logWindow->hide();
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotSetup(const int _page)
{
//qDebug() << Q_FUNC_INFO << QString::number(_page) ;
logEvent(Q_FUNC_INFO, "Start", Debug);
configured = false;
//qDebug() << Q_FUNC_INFO << " - 010" ;
backupCurrentQSO();
//qDebug() << Q_FUNC_INFO << " - 020" ;
openSetup(_page);
//qDebug() << Q_FUNC_INFO << " - END" ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::openSetup(const int _page)
{
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_page) ;
logEvent(Q_FUNC_INFO, "Start", Debug);
//int result = -1;
//qDebug() << Q_FUNC_INFO << " - 000 - " << (QTime::currentTime()).toString("HH:mm:ss");
hamlib->stop();
//qDebug() << Q_FUNC_INFO << " - 001 - " << (QTime::currentTime()).toString("HH:mm:ss");
if (!needToEnd)
{
//qDebug() << Q_FUNC_INFO << " - 010 - " << (QTime::currentTime()).toString("HH:mm:ss");
logEvent(Q_FUNC_INFO, "Just before setData", Devel);
//qDebug() << "MainWindow::openSetup - Just before setupDialog->exec-1" ;
if (upAndRunning)
{
//qDebug() << Q_FUNC_INFO << " - 011 - " << (QTime::currentTime()).toString("HH:mm:ss");
setupDialog->setData(softwareVersion, _page, !configured);
//qDebug() << Q_FUNC_INFO << " - 012 - " << (QTime::currentTime()).toString("HH:mm:ss");
}
else
{
//qDebug() << Q_FUNC_INFO << " - 013 - " << (QTime::currentTime()).toString("HH:mm:ss");
setupDialog->setData(softwareVersion, 0, !configured);
//qDebug() << Q_FUNC_INFO << " - 014 - " << (QTime::currentTime()).toString("HH:mm:ss");
}
if ( (!configured) || (itIsANewversion) )
{
//qDebug() << Q_FUNC_INFO << " - 015 - " << (QTime::currentTime()).toString("HH:mm:ss");
logEvent(Q_FUNC_INFO, "Just before SetupDialog->exec", Devel);
itIsANewversion = false;
//setupDialog->exec();
setupDialog->setModal(true);
//qDebug() << Q_FUNC_INFO << " - 016 - " << (QTime::currentTime()).toString("HH:mm:ss");
setupDialog->show();
//qDebug() << Q_FUNC_INFO << " - 017 - " << (QTime::currentTime()).toString("HH:mm:ss");
// move part of this code to slotSetupDialogFinished
logEvent(Q_FUNC_INFO, "Just after setupDialog->show", Devel);
//qDebug() << "MainWindow::openSetup - Just after setupDialog->show" ;
}
else
{
//qDebug() << Q_FUNC_INFO << " - 020 - " << (QTime::currentTime()).toString("HH:mm:ss");
logEvent(Q_FUNC_INFO, "No setupDialog->exec needed", Devel);
//qDebug() << "MainWindow::openSetup - No setupDialog->show needed" ;
}
}
//qDebug() << Q_FUNC_INFO << " - 050 - " << (QTime::currentTime()).toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - END";
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotSetupDialogFinished (const int _s)
{
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_s) << " - " << (QTime::currentTime()).toString ("HH:mm:ss");
if (needToEnd)
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
}
//bool restoreQSOConfig = false;
if (_s == QDialog::Accepted)
{
//qDebug() << Q_FUNC_INFO << " - QDialog::Accepted - " << (QTime::currentTime()).toString ("HH:mm:ss");
logEvent(Q_FUNC_INFO, "Just before loadSettings", Debug);
//readConfigData();
configured = loadSettings ();
applySettings ();
//qDebug() << Q_FUNC_INFO << " - 010 - " << (QTime::currentTime()).toString ("HH:mm:ss");
reconfigureDXMarathonUI(manageDxMarathon);
logEvent(Q_FUNC_INFO, "Just after loadSettings", Debug);
//qDebug() << "MainWindow::slotSetupDialogFinished: logmodel to be created-2" ;
logEvent(Q_FUNC_INFO, "logmodel to be created-2", Debug);
//qDebug() << Q_FUNC_INFO << " - 011 - " << (QTime::currentTime()).toString ("HH:mm:ss");
logWindow->createlogPanel(currentLog);
//qDebug() << Q_FUNC_INFO << " - 012 - " << (QTime::currentTime()).toString ("HH:mm:ss");
logEvent(Q_FUNC_INFO, "logmodel has been created-2", Debug);
//defineStationCallsign(stationCallsign);
//qDebug() << Q_FUNC_INFO << " - 013 - " << (QTime::currentTime()).toString ("HH:mm:ss");
logEvent(Q_FUNC_INFO, "before db->reConnect", Debug);
//qDebug() << "MainWindow::openSetup: before db->reConnect" ;
dataProxy->reconnectDB();
//qDebug() << Q_FUNC_INFO << " - 014 - " << (QTime::currentTime()).toString ("HH:mm:ss");
logEvent(Q_FUNC_INFO, "after db->reConnect", Debug);
//qDebug() << "MainWindow::openSetup: after db->reConnect" ;
}
else
{
//qDebug() << Q_FUNC_INFO << " - !QDialog::Accepted";
//qDebug() << Q_FUNC_INFO << " - 019 - " << (QTime::currentTime()).toString ("HH:mm:ss");
}
//qDebug() << Q_FUNC_INFO << " - 020 - " << (QTime::currentTime()).toString ("HH:mm:ss");
if (qsoInUI.getBackup())
{
//qDebug() << (QTime::currentTime()).toString ("HH:mm:ss") << Q_FUNC_INFO << " - 021 - ";
//qDebug() << Q_FUNC_INFO << ": Restoring..." ;
restoreCurrentQSO (QDialog::Accepted);
//qDebug() << (QTime::currentTime()).toString ("HH:mm:ss") << Q_FUNC_INFO << " - 022 - " ;
}
else
{
//qDebug() << "MainWindow::slotSetupDialogFinished: NO Restoring qsoInUI..." ;
//qDebug()<< (QTime::currentTime()).toString ("HH:mm:ss") << Q_FUNC_INFO << " - 023 - ";
}
//qDebug() << (QTime::currentTime()).toString ("HH:mm:ss") << Q_FUNC_INFO << " - 030 - " ;
hamlibActive = setHamlib(hamlibActive);
//qDebug() << (QTime::currentTime()).toString ("HH:mm:ss") << Q_FUNC_INFO << " - END";
logEvent(Q_FUNC_INFO, "END", Debug);
}
bool MainWindow::slotOpenKLogFolder()
{
//qDebug() << "MainWindow::slotOpenKLogFolder: " << util->getHomeDir() ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QString _aux = "<ul><li><a href=file://" + util->getHomeDir() + ">file://" + util->getHomeDir() + "</a></li>" +
"<li><a href=file://" + util->getKLogDBFile() + ">file://" + util->getKLogDBFile() + "</a></i></ul>" ;
QString _text = tr("You can find the KLog data folder here: ") + _aux;
QMessageBox::information(this, tr("KLog"),
_text,
QMessageBox::Ok,
QMessageBox::Ok);
//qDebug() << "MainWindow::slotOpenKLogFolder: END" ;
logEvent(Q_FUNC_INFO, "END", Debug);
return true;
}
void MainWindow::slotUpdateStatusBar(const QString &statusm)
{
//qDebug() << "MainWindow::slotUpdateStatusBar: " << statusm ;
logEvent(Q_FUNC_INFO, "Start", Debug);
statusBar()->showMessage(statusm, 2000);
logEvent(Q_FUNC_INFO, "END", Debug);
}
//bool MainWindow::readCtyFile()
//{
// logEvent(Q_FUNC_INFO, "Start", Debug);
// logEvent(Q_FUNC_INFO, "END", Debug);
// return false;
//}
void MainWindow::slotDoubleClickLog(const int _qsoID)
{
//qDebug() << Q_FUNC_INFO << ": QSOid: " << QString::number(_qsoID) ;
logEvent(Q_FUNC_INFO, "Start", Debug);
//int row = _qsoID.row();
qsoToEdit(_qsoID);
logEvent(Q_FUNC_INFO, "END", Debug);
//TODO: To be added to the logWindow and create an action that emist the QSO id to be edited
}
bool MainWindow::setUDPServer(const bool _b)
{
//qDebug() << Q_FUNC_INFO << ": upAndRunning: " << util->boolToQString (upAndRunning) ;
//qDebug() << Q_FUNC_INFO << ": " << util->boolToQString (_b) ;
QString errorMSG, aux;
if (_b)
{
//qDebug() << Q_FUNC_INFO << ": Starting the server" ;
if (!UDPLogServer->isStarted())
{
//qDebug() << Q_FUNC_INFO << ": Server is not started, starting...";
if (!UDPLogServer->start())
{
//qDebug() << Q_FUNC_INFO << ": Server could not be started, exiting...";
errorMSG = tr("start");
aux = tr("UDP Server error\nThe UDP server failed to %1.", "start or stop").arg(errorMSG);
showErrorDialog->setText(aux);
showErrorDialog->exec();
return false;
}
else
{
//qDebug() << Q_FUNC_INFO << ": UDP Log server started!" << QTime::currentTime().toString("hh:mm:ss") ;
}
return true;
}
else
{
return true;
//qDebug() << Q_FUNC_INFO << ": UDP Log server already started no need to restart!" << QTime::currentTime().toString("hh:mm:ss") ;
}
}
else
{
//qDebug() << Q_FUNC_INFO << ": UDPServerStart FALSE" << QTime::currentTime().toString("hh:mm:ss") ;
if (UDPLogServer->isStarted())
{
//qDebug() << Q_FUNC_INFO << ": Server is startted and should be Disabled";
if (!UDPLogServer->stop())
{
//qDebug() << Q_FUNC_INFO << ": Server should be disabled and I can't stop it";
errorMSG = tr("stop");
aux = tr("UDP Server error\nThe UDP server failed to %1.", "start or stop").arg(errorMSG);
showErrorDialog->setText(aux);
showErrorDialog->exec();
return UDPLogServer->isStarted ();
}
else
{
//qDebug() << Q_FUNC_INFO << ": UDP Log server stopped!" << QTime::currentTime().toString("hh:mm:ss") ;
return false;
}
}
else
{
//qDebug() << Q_FUNC_INFO << ": UDP Log server already stopped no need to restop!" ;
return false;
}
}
//qDebug() << Q_FUNC_INFO << ": It should not reach this, default to false";
return false;
}
bool MainWindow::setHamlib(const bool _b)
{
//qDebug() << (QTime::currentTime()).toString ("HH:mm:ss - ") << Q_FUNC_INFO << ": " << util->boolToQString (_b) ;
if (!upAndRunning)
{
//qDebug() << (QTime::currentTime()).toString ("HH:mm:ss - ") << Q_FUNC_INFO << ": Hamlib upAndRunning FALSE";
return false;
}
if (_b)
{
//qDebug() << (QTime::currentTime()).toString ("HH:mm:ss - ") << Q_FUNC_INFO << ": Hamlib active";
hamlib->init(true);
//qDebug() << (QTime::currentTime()).toString ("HH:mm:ss - ") << Q_FUNC_INFO << ": After Hamlib active";
return hamlib->readRadio(true); // Forcing the radio update
}
else
{
//qDebug() << (QTime::currentTime()).toString ("HH:mm:ss - ") << Q_FUNC_INFO << ": Hamlib NOT active";
hamlib->init(false);
//qDebug() << (QTime::currentTime()).toString ("HH:mm:ss - ") << Q_FUNC_INFO << ": After Hamlib NOT active";
return false;
}
}
void MainWindow::showEvent(QShowEvent *event)
{
//qDebug() << Q_FUNC_INFO ;
(void)event;
setWindowSize(windowSize);
}
void MainWindow::keyPressEvent(QKeyEvent *event){
//qDebug() << "MainWindow::keyPressEvent: " ;
logEvent(Q_FUNC_INFO, "Start", Debug);
switch (event->key()) {
case Qt::Key_Return:
// ENTER PRESSED
slotQRZReturnPressed();
//qDebug() << "MainWindow::keyPressEvent: RETURN" ;
break;
case Qt::Key_Enter:
// ENTER PRESSED
//qDebug() << "MainWindow::keyPressEvent: ENTER" ;
slotQRZReturnPressed();
break;
case Qt::Key_F1:
slotOpenWiki();
break;
case Qt::Key_F4:
//qDebug << "MainWindow::keyPressEvent: F4" ;
mainQSOEntryWidget->toggleRealTime ();
break;
default:
//QFrame::keyPressEvent(event);
break;
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotOpenWiki()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO ;
QDesktopServices::openUrl(QUrl("https://github.com/ea4k/klog/wiki/"));
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default)
{
//qDebug() << Q_FUNC_INFO << "Confirmed: " << _newOne.name(QColor::HexRgb) << " / Needed: " << _needed.name(QColor::HexRgb) ;
// " / Worked: " << _worked.name(QColor::HexRgb) << " / Confirmed: " << _confirmed.name(QColor::HexRgb) <<
// " / Default: " << _default.name(QColor::HexRgb);
searchWidget->setColors(_newOne, _needed, _worked, _confirmed, _default);
awards.setColors (_newOne, _needed, _worked, _confirmed, _default);
mapWindow->setColors (_worked, _confirmed, _default);
dxClusterWidget->setColors (_newOne, _needed, _worked, _confirmed, _default);
infoWidget->setColors(_newOne, _needed, _worked, _confirmed, _default);
dxccStatusWidget->setColors(_newOne, _needed, _worked, _confirmed, _default);
}
bool MainWindow::applySettings()
{
//qDebug() << Q_FUNC_INFO << " - Start";
if ((useDefaultLogFileName) && (!defaultADIFLogFile.isEmpty()))
{
useDefaultLogFileName = true;
}
else
{
useDefaultLogFileName = false;
}
checkIfNewBandOrMode ();
infoWidget->setImperialSystem(imperialSystem);
infoLabel2->setText(world->getEntityName(currentEntity));
infoWidget->showEntityInfo(currentEntity);
dxClusterWidget->setDXClusterSpotConfig(dxClusterShowHF, dxClusterShowVHF, dxClusterShowWARC, dxClusterShowWorked, dxClusterShowConfirmed, dxClusterShowAnn, dxClusterShowWWV, dxClusterShowWCY );
setMainWindowTitle();
dxClusterWidget->setMyQRZ(stationCallsign);
elogClublog->setDefaultCallsign (stationCallsign);
if (qrzcomActive)
{
//elogQRZcom->setCredentials(qrzcomUser, qrzcomPass);
elogQRZcom->login();
}
util->setVersion(softwareVersion);
searchWidget->setVersion(softwareVersion);
searchWidget->setCurrentLog(currentLog);
infoWidget->setCurrentLog(currentLog);
satTabWidget->refreshData();
adifLoTWExportWidget->setLogNumber (currentLog);
//setWindowSize (windowSize);
if (upAndRunning)
{
startServices();
}
//qDebug() << Q_FUNC_INFO << " - END";
logEvent(Q_FUNC_INFO, "END", Debug);
return true;
}
void MainWindow::startServices()
{
//qDebug() << QTime::currentTime().toString("hh:mm:ss - ") ;
logEvent(Q_FUNC_INFO, "Start", Debug);
hamlibActive = setHamlib(hamlibActive);
setUDPServer(UDPServerStart);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::checkIfNewBandOrMode()
{//Checks the log to see if there is a QSO with a band/mode
//that is not currently selected as active
//qDebug() << "MainWindow::checkIfNewBandOrMode - START " << QTime::currentTime().toString("hh:mm:ss") ;
logEvent(Q_FUNC_INFO, "Start", Debug);
if (!upAndRunning || modify)
return;
QString currentBand = mainQSOEntryWidget->getBand();
QString currentMode = mainQSOEntryWidget->getMode();
setupDialog->checkIfNewBandOrMode(); // Update the Setup dialog with new bands or modes
//qDebug() << "MainWindow::checkIfNewBandOrMode - 1 " << QTime::currentTime().toString("hh:mm:ss") ;
QStringList bandsInLog = dataProxy->getBandsInLog(currentLog);
//qDebug() << "MainWindow::checkIfNewBandOrMode - 2 " << QTime::currentTime().toString("hh:mm:ss") ;
QStringList modesInLog = dataProxy->getModesInLog(currentLog);
//qDebug() << "MainWindow::checkIfNewBandOrMode - 3 " << QTime::currentTime().toString("hh:mm:ss") ;
QStringList qsTemp;
qsTemp.clear();
//qDebug() << "MainWindow::checkIfNewBandOrMode - 3.1 " << QTime::currentTime().toString("hh:mm:ss") ;
bands << bandsInLog;
bands.removeDuplicates();
//qDebug() << "MainWindow::checkIfNewBandOrMode - 3.2 " << QTime::currentTime().toString("hh:mm:ss") ;
qsTemp << dataProxy->sortBandNamesBottonUp(bands);
//qDebug() << "MainWindow::checkIfNewBandOrMode - 3.3 " << QTime::currentTime().toString("hh:mm:ss") ;
bands.clear();
bands = qsTemp;
modes << modesInLog;
modes.removeDuplicates();
modes.sort();
//qDebug() << "MainWindow::checkIfNewBandOrMode - bands -" << QString::number(bands.length()) << " - " << QTime::currentTime().toString("hh:mm:ss") ;
mainQSOEntryWidget->setBands(bands);
satTabWidget->addBands(bands);
mapWindow->setBands(bands);
//qDebug() << "MainWindow::checkIfNewBandOrMode - modes -" << QString::number(modes.length()) << " - " << QTime::currentTime().toString("hh:mm:ss") ;
mainQSOEntryWidget->setModes(modes);
mapWindow->setModes(modes);
//qDebug() << "MainWindow::checkIfNewBandOrMode - setting bands" << QTime::currentTime().toString("hh:mm:ss") ;
logEvent(Q_FUNC_INFO, "Setting bands", Debug);
dxccStatusWidget->setBands(Q_FUNC_INFO, bands, true);
//qDebug() << "MainWindow::checkIfNewBandOrMode - currentBand: " << currentBand << QTime::currentTime().toString("hh:mm:ss") ;
if (bands.contains(currentBand))
{
mainQSOEntryWidget->setBand(currentBand);
}
else
{
selectDefaultBand();
}
//qDebug() << "MainWindow::checkIfNewBandOrMode-99 " << QTime::currentTime().toString("hh:mm:ss") ;
if (modes.contains(currentMode))
{
mainQSOEntryWidget->setMode(currentMode);
}
else
{
selectDefaultMode();
}
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::checkIfNewBandOrMode END " << QTime::currentTime().toString("hh:mm:ss") ;
}
void MainWindow::selectDefaultBand()
{
//qDebug() << "MainWindow::selectDefaultBand" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
if (!upAndRunning)
{
return;
}
QString aux;
aux = QString();
defaultBand = dataProxy->getMostUsedBand(currentLog);
if (defaultBand<1)
{
defaultBand = dataProxy->getIdFromBandName(mainQSOEntryWidget->getBand(0));
//defaultBand = dataProxy->getIdFromBandName(bandComboBox->itemText(1));
}
aux = dataProxy->getNameFromBandId(defaultBand);
mainQSOEntryWidget->setBand(aux);
//bandComboBox->setCurrentIndex(bandComboBox->findText(aux));
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::selectDefaultBand_END" ;
}
void MainWindow::selectDefaultMode()
{
//qDebug() << "MainWindow::selectDefaultMode" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
if (!upAndRunning)
{
return;
}
//int aux = 1;
defaultMode = dataProxy->getMostUsedMode(currentLog);
//qDebug() << "MainWindow::selectDefaultMode: " << QString::number(defaultMode) ;
if (defaultMode < 1)
{
defaultMode = dataProxy->getIdFromModeName(mainQSOEntryWidget->getMode(0));
//defaultMode = dataProxy->getIdFromModeName((modeComboBox->itemText(0)));
//qDebug() << "MainWindow::selectDefaultMode2: " << QString::number(defaultMode) ;
//qDebug() << "MainWindow::selectDefaultMode2S: " ;
}
mainQSOEntryWidget->setMode(dataProxy->getSubModeFromId(defaultMode));
//modeComboBox->setCurrentIndex(modeComboBox->findText(dataProxy->getSubModeFromId(defaultMode)));
//qDebug() << "MainWindow::selectDefaultMode3: " << QString::number(defaultMode) ;
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::selectDefaultMode-END" ;
}
void MainWindow::readActiveBands (const QStringList actives)
{ // Checks a "10m, 12m" QString, checks if they are valid bands and import to the
//qDebug() << Q_FUNC_INFO << " - Start";
logEvent(Q_FUNC_INFO, "Start", Debug);
foreach (QString aux, actives)
{
//qDebug() << Q_FUNC_INFO << ": " << aux;
}
bool atLeastOne = false;
QString aux;
bands.clear();
QStringList __bands;
__bands.clear();
__bands = actives;
__bands << dataProxy->getBandsInLog(currentLog);
__bands.removeDuplicates();
bands = __bands;
for (int i = 0; i < __bands.size() ; i++)
{
if (dataProxy->getIdFromBandName(__bands.at(i)) > 0)
{
if (!atLeastOne)
{
atLeastOne = true;
}
aux = __bands.at(i);
if (!aux.isEmpty())
{
//qDebug() << Q_FUNC_INFO << ": " << aux;
bands << aux;
}
}
}
bands.removeDuplicates();
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::readActiveBands - END" ;
}
void MainWindow::readActiveModes (const QStringList actives)
{
//qDebug() << Q_FUNC_INFO << " - Start";
logEvent(Q_FUNC_INFO, "Start", Debug);
QString aux;
aux.clear();
QStringList __modes;
__modes.clear();
__modes = actives;
__modes << dataProxy->getModesInLog(currentLog);
__modes.removeDuplicates();
modes.clear();
for (int i = 0; i < __modes.size() ; i++)
{
//qDebug() << "MainWindow::readActiveModes: checking: " << __modes.at(i) ;
if (dataProxy->getIdFromModeName(__modes.at(i)) > 0)
{
//qDebug() << "MainWindow::readActiveModes: checking-exist: " << __modes.at(i) ;
aux = __modes.at(i);
if (!aux.isEmpty())
{
//qDebug() << "MainWindow::readActiveModes: adding: " << aux ;
modes << aux;
}
}
}
modes.removeDuplicates();
modes.sort();
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::readActiveModes - END" ;
}
void MainWindow::createUIDX()
{
// //qDebug() << "MainWindow::createUIDX ;
logEvent(Q_FUNC_INFO, "Start", Debug);
infoLabel1->setToolTip(tr("Status of the DX entity."));
//qDebug() << "MainWindow::createUIDX-13" ;
infoLabel2->setToolTip(tr("Name of the DX entity."));
//qDebug() << "MainWindow::createUIDX-14" ;
dxUpLeftInputFrame = new QFrame;
dxUpLeftTab = new QTabWidget;
dxUpRightTab = new QTabWidget;
dxBottonTab = new QTabWidget;
dxUpLeftTab->setTabPosition(QTabWidget::North);
dxUpRightTab->setTabPosition(QTabWidget::South);
//qDebug() << "MainWindow::createUIDX-30" ;
QHBoxLayout *dxUpLeftInputFrameLayout = new QHBoxLayout;
dxUpLeftInputFrameLayout->addWidget (mainQSOEntryWidget);
//dxUpLeftInputFrameLayout->setSizeConstraint(QLayout::SetFixedSize);
dxUpLeftInputFrame->setLayout (dxUpLeftInputFrameLayout);
dxUpLeftTab->addTab (QSOTabWidget, tr("QSO"));
dxUpLeftTab->addTab(QSLTabWidget, tr("QSL"));
dxUpLeftTab->addTab(eQSLTabWidget, tr("eQSL"));
dxUpLeftTab->addTab(commentTabWidget, tr("Comment"));
dxUpLeftTab->addTab(othersTabWidget, tr("Others"));
dxUpLeftTab->addTab(myDataTabWidget, tr("My Data"));
dxUpLeftTab->addTab(satTabWidget, tr("Satellite"));
//qDebug() << "MainWindow::createUIDX-90" ;
QSplitter *upLeftSplitter = new QSplitter (this);
upLeftSplitter->addWidget(dxUpLeftInputFrame);
//upLeftSplitter->addWidget(mainQSOEntryWidget);
upLeftSplitter->addWidget(dxUpLeftTab);
upLeftSplitter->setOrientation(Qt::Vertical);
QVBoxLayout *dxUpRightFixLayout = new QVBoxLayout;
dxUpRightFixLayout->addWidget(infoLabel1);
dxUpRightFixLayout->addWidget(infoLabel2);
infoLabel1->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
infoLabel2->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
dxUpRightTab->addTab(infoWidget, tr("Info"));
//qDebug() << "MainWindow::createUIDX-100" ;
reconfigureDXMarathonUI(manageDxMarathon);
//qDebug() << "MainWindow::createUIDX-122" ;
dxUpRightTab->addTab(awardsWidget, tr("Awards"));
dxUpRightTab->addTab(searchWidget.get(), tr("Search"));
dxBottonTab->addTab(logWindow.get(), tr("Log"));
dxBottonTab->addTab(dxClusterWidget.get(), tr("DX-Cluster"));
dxBottonTab->addTab(dxccStatusWidget.get(), tr("DXCC"));
QVBoxLayout *dxUpRightLayout = new QVBoxLayout;
dxUpRightLayout->addLayout(dxUpRightFixLayout);
dxUpRightLayout->addWidget(dxUpRightTab);
QWidget *upRightWidget = new QWidget;
upRightWidget->setLayout(dxUpRightLayout);
QSplitter *upSplitter = new QSplitter (this);
upSplitter->addWidget(upLeftSplitter);
upSplitter->addWidget(upRightWidget);
QSplitter *splitter = new QSplitter(this);
splitter->addWidget(upSplitter);
splitter->addWidget(dxBottonTab);
splitter->setOrientation(Qt::Vertical);
QHBoxLayout *mLayout = new QHBoxLayout;
mLayout->addWidget(splitter);
//mLayout->setSizeConstraint(QLayout::SetFixedSize);
mainWidget->setLayout(mLayout);
//qDebug() << "MainWindow::createUIDX - OS DETECTION" ;
#ifdef Q_OS_WIN
//qDebug() << "MainWindow::createUIDX - WINDOWS DETECTED!" ;
dxUpLeftInputFrame->setFrameShadow(QFrame::Raised);
dxUpLeftInputFrame->setFrameStyle(QFrame::StyledPanel);
#else
//qDebug() << "MainWindow::createUIDX - NO WINDOWS DETECTED!" ;
dxUpLeftInputFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
infoLabel1->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
infoLabel2->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
#endif
setCentralWidget(mainWidget);
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::createUIDX-END" ;
}
void MainWindow::slotADIFExport()
{
//qDebug() << "MainWindow::slotADIFExport - Start" ;
adifLoTWExportWidget->setExportMode(ModeADIF);
adifLoTWExportWidget->show();
//filemanager->adifLogExport(fileName, currentLog);
//qDebug() << "MainWindow::slotADIFExport -END " ;
}
void MainWindow::showNumberOfSavedQSO(const QString &_fn, const int _n)
{
//qDebug() << "MainWindow::showNumberOfSavedQSO: " << _fn << "/" << QString::number(_n) ;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - ADIF export"));
if (_n <= 0)
{ // TODO: Check if errors should be managed.
msgBox.setText(tr("No QSOs have been exported to ADIF.") );
}
else
{
QString msg = QString(tr("KLog has exported %1 QSOs to the ADIF file: %2")).arg(QString::number(_n)).arg(_fn);
msgBox.setText(msg);
}
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
//qDebug() << "MainWindow::showNumberOfSavedQSO - END" ;
}
/*
void MainWindow::fileExportADIF(const QString &_st, const QString &_grid, const QDate &_startDate, const QDate &_endDate)
{
//qDebug() << Q_FUNC_INFO << ": " << _st ;
QString fileName = QFileDialog::getSaveFileName(this, tr("Save ADIF File"), util->getHomeDir(), "ADIF (*.adi *.adif)");
QList<int> qsos = filemanager->adifLogExportReturnList(fileName, _st, _grid, _startDate, _endDate, currentLog, ModeADIF);
showNumberOfSavedQSO(fileName, qsos.count());
//qDebug() << Q_FUNC_INFO << " - END";
}
*/
void MainWindow::fileExportADIF2(const QString &_call, QList<int> _qsos)
{
//qDebug() << Q_FUNC_INFO ;
QString fileName = QFileDialog::getSaveFileName(this, tr("Save ADIF File"), util->getHomeDir(), "ADIF (*.adi *.adif)");
QList<int> qsos = filemanager->adifLogExportReturnList(fileName, _call, _qsos, ModeADIF, currentLog);
showNumberOfSavedQSO(fileName, qsos.count());
//qDebug() << Q_FUNC_INFO << " - END";
}
void MainWindow::slotADIFExportAll()
{
//qDebug() << Q_FUNC_INFO << " - Start";
logEvent(Q_FUNC_INFO, "Start", Debug);
QString _callToUse = "ALL";
QList <int> _qsos;
_qsos.clear();
_qsos.append(-1); //Code to specify to export ALL QSOs;
QString fileName = QFileDialog::getSaveFileName(this, tr("Save ADIF File"), util->getHomeDir(), "ADIF (*.adi *.adif)");
QList<int> qsos = filemanager->adifLogExportReturnList(fileName, _callToUse, _qsos, ModeADIF, currentLog);
showNumberOfSavedQSO(fileName, dataProxy->getHowManyQSOInLog(-1));
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::fileExportLoTW2(const QString &_call, QList<int> _qsos)
{
//qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << QString(" - Start: %1 / QSOs: %2" ).arg(_call).arg(_qsos.length ());
if (_qsos.length ()<1)
{
//TODO SHOW MESSAGE Asking for at least one QSO and exit
}
QMessageBox msgBox;
Callsign callsign(_call);
if (!callsign.isValid())
{
//qDebug() << Q_FUNC_INFO << " - no valid call" ;
if (_call == "ALL")
{
msgBox.setWindowTitle(tr("KLog - LoTW"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("You need to select one station callsign to be able to send your log to LoTW."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
return;
}
QString fileName = util->getLoTWAdifFile();
QList<int> qsos = filemanager->adifLogExportReturnList(fileName, _call, _qsos, ModeLotW, currentLog);
if (qsos.count() <= 0)
{ // TODO: Check if errors should be managed.
//qDebug() << Q_FUNC_INFO << " - NO QSOs" ;
return;
}
//qDebug() << Q_FUNC_INFO << " - 50" ;
bool uploadedToLoTW = callTQSL(fileName, _call);
//qDebug() << Q_FUNC_INFO << " - 51" ;
int i ;
if (uploadedToLoTW)
{
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - LoTW"));
msgBox.setText(tr("TQSL finished with no error.\n\nDo you want to mark as Sent all the QSOs uploaded to LoTW?") );
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
int i = msgBox.exec();
if (i == QMessageBox::Yes)
{
uploadedToLoTW = dataProxy->lotwSentQSOs(qsos);
slotLogRefresh();
if (!uploadedToLoTW)
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - LoTW"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was an error while updating to Yes the LoTW QSL sent information."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
}
if (!deleteAlwaysAdiFile)
{
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - LoTW"));
msgBox.setText(tr("The LoTW upload process has finished and KLog created a file (%1) in your KLog folder.\n\nDo you want KLog to remove that file?").arg(fileName));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
i = msgBox.exec();
if (i == QMessageBox::Yes)
{
if (QFile::remove(fileName))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - LoTW"));
msgBox.setText(tr("The file has been removed."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
}
}
}
else
{
QFile::remove(fileName);
}
//qDebug() << Q_FUNC_INFO << " - END";
}
void MainWindow::fileExportClubLog2(const QString &_call, QList<int> _qsos)
{
//qDebug() << Q_FUNC_INFO << QString(" - Start: %1 / QSOs: %2" ).arg(_call).arg(_qsos.length ());
QMessageBox msgBox;
Callsign callsign(_call);
if (!callsign.isValid())
{
//qDebug() << Q_FUNC_INFO << " - no valid call" ;
if (_call == "ALL")
{
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("You need to select one station callsign to be able to send your log to ClubLog."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
return;
}
QString fileName = util->getClubLogFile();
QList<int> qsos = filemanager->adifLogExportReturnList(fileName, _call, _qsos, ModeClubLog, currentLog);
if (qsos.count() <= 0)
{ // TODO: Check if errors should be managed.
//qDebug() << Q_FUNC_INFO << " - NO QSOs" ;
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("The selection you have done does not include any QSO"));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
return;
}
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Do you want to add this QSOs to your ClubLog existing log?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::No);
msgBox.setDetailedText(tr("If you don't agree, this upload will overwrite your current ClubLog existing log."));
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
bool overwrite = false;
switch (ret)
{
case QMessageBox::Ok: // General ADIF
overwrite = false;
break;
case QMessageBox::No: // ClubLog
overwrite = true;
break;
}
//qDebug() << Q_FUNC_INFO << " - 50" ;
elogClublog->sendLogFile(fileName, _qsos, overwrite);
logWindow->refresh();
//qDebug() << Q_FUNC_INFO << " - END " ;
}
void MainWindow::fileExportEQSL2(const QString &_call, QList<int> _qsos)
{
//qDebug() << Q_FUNC_INFO << QString(" - Start: QSOs: %2" ).arg(_qsos.length ());
//QString fileName = "klog-eqsl-upload.adi";
QString fileName = util->getEQSLFile();
QList<int> qsos = filemanager->adifLogExportReturnList(fileName, _call, _qsos, ModeEQSL, currentLog);
if (qsos.count() <= 0)
{ // TODO: Check if errors should be managed.
//qDebug() << Q_FUNC_INFO << " - NO QSOs" ;
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("The selection you have done does not include any QSO."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
return;
}
eqslUtilities->sendLogFile(fileName, _qsos);
logWindow->refresh();
//qDebug() << Q_FUNC_INFO << "-END " ;
}
void MainWindow::slotADIFExportSelection(const QString &_call, QList<int> _qsos, ExportMode _eM)
{
//qDebug() << Q_FUNC_INFO << QString(" - Start: %1 / QSOs: %2" ).arg(_call).arg(_qsos.length ());
//qDebug() << Q_FUNC_INFO << " - Trigered by signal: selection";
switch (_eM)
{
case ModeADIF: // General ADIF
fileExportADIF2(_call, _qsos);
break;
case ModeLotW: // LoTW
//qDebug() << Q_FUNC_INFO << " - LoTW" ;
fileExportLoTW2(_call, _qsos);
break;
case ModeClubLog: // ClubLog
//qDebug() << Q_FUNC_INFO << " - ClubLog" ;
fileExportClubLog2(_call, _qsos);
break;
case ModeEQSL: // General eQSL
//qDebug() << Q_FUNC_INFO << " - eQSL" ;
fileExportEQSL2(_call, _qsos);
break;
case ModeQRZ: // General eQSL
//qDebug() << Q_FUNC_INFO << " - QRZ.com" ;
elogQRZcom->sendQSOs(_qsos);
break;
}
logWindow->refresh();
//qDebug() << Q_FUNC_INFO << " - END " ;
}
void MainWindow::slotADIFExportClose()
{
adifLoTWExportWidget->close();
}
void MainWindow::slotLoTWExport()
{
// 1.- Selec call
// 2.- Select file and export (fixed filename?)
// 3.- Call tqsl with the filename
// 4.- Ask for the user to remove or not the file
//qDebug() << "MainWindow::slotLoTWExport - Start" ;
// bool emptyCall = false;
if (!lotwActive)
{
showMessageToEnableTheOnlineService(LoTW);
return;
}
adifLoTWExportWidget->setExportMode(ModeLotW);
adifLoTWExportWidget->show();
//qDebug() << "MainWindow::slotLoTWExport- END" ;
}
void MainWindow::slotLoTWDownload()
{
//qDebug() << "MainWindow::slotDownUpload - Start" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QStringList calls;
calls << dataProxy->getStationCallSignsFromLog(-1);
bool ok;
QString callToUse = QInputDialog::getItem(this, tr("KLog - Select the Station Callsign."),
tr("Select the Station Callsign to use when quering LoTW:"), calls, 0, false, &ok);
//qDebug() << "MainWindow::slotDownUpload: " << callToUse ;
if (ok && !callToUse.isEmpty())
{
lotwUtilities->setStationCallSign(callToUse);
}
else
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
}
if (!lotwUtilities->getIsReady())
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - LoTW"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Please check the LoTW setup"));
msgBox.setInformativeText(tr("You have not defined a LoTW user or a proper Station Callsign.\nOpen the LoTW tab in the Setup and configure your LoTW connection."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
logEvent(Q_FUNC_INFO, "END-2", Debug);
return;
}
lotwUtilities->download();
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::slotDownUpload - END" ;
}
void MainWindow::slotLoTWFullDownload()
{
//qDebug() << "MainWindow::slotLoTWFullDownload - Start" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QStringList calls;
calls << dataProxy->getStationCallSignsFromLog(-1);
bool ok;
QString callToUse = QInputDialog::getItem(this, tr("KLog - Select the Station Callsign."),
tr("Select the Station Callsign to use when quering LoTW:"), calls, 0, false, &ok);
//qDebug() << "MainWindow::slotLoTWFullDownload: " << callToUse ;
if (ok && !callToUse.isEmpty())
{
lotwUtilities->setStationCallSign(callToUse);
}
else
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
}
if (!lotwUtilities->getIsReady())
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - LoTW"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Please check the LoTW setup"));
msgBox.setInformativeText(tr("You have not defined a LoTW user or a proper Station Callsign.\nOpen the LoTW tab in the Setup and configure your LoTW connection."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
logEvent(Q_FUNC_INFO, "END-2", Debug);
return;
}
lotwUtilities->fullDownload();
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::slotLoTWFullDownload - END" ;
}
void MainWindow::slotElogClubLogModifyCurrentLog()
{
QMessageBox msgConfirm;
msgConfirm.setIcon(QMessageBox::Question);
msgConfirm.setWindowTitle(tr("KLog - ClubLog"));
msgConfirm.setText(tr("Do you really want to mark ALL your QSOs to be UPLOADED? Must be done ONLY IF THIS IS YOUR FIRST TIME uploading QSOs to %1").arg(tr("ClubLog")));
msgConfirm.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgConfirm.setDefaultButton(QMessageBox::No);
int i = msgConfirm.exec();
if (i == QMessageBox::Yes)
{
QMessageBox msgBox;
if (dataProxy->clublogModifyFullLog(currentLog))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("The log is ready to be uploaded to ClubLog."));
msgBox.setDetailedText(tr("All the QSOs in this log has been marked as Modified in the ClubLog status field"));
}
else
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("KLog could not mark the full log to be sent to ClubLog"));
msgBox.setDetailedText(tr("Something prevented KLog from marking the QSOs as modified. Restart KLog and try again before contacting the KLog developers."));
}
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
void MainWindow::slotElogEQSLModifyCurrentLog()
{
QMessageBox msgConfirm;
msgConfirm.setIcon(QMessageBox::Question);
msgConfirm.setWindowTitle(tr("KLog - eQSL"));
msgConfirm.setText(tr("Do you really want to mark ALL your QSOs to be UPLOADED? Must be done ONLY IF THIS IS YOUR FIRST TIME uploading QSOs to %1").arg(tr("eQSL")));
msgConfirm.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgConfirm.setDefaultButton(QMessageBox::No);
int i = msgConfirm.exec();
if (i == QMessageBox::Yes)
{
QMessageBox msgBox;
if (dataProxy->eQSLModifyFullLog(currentLog))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("The log is ready to be uploaded to eQSL.cc."));
msgBox.setDetailedText(tr("All the QSOs in this log has been marked as Modified in the eQSL.cc status field"));
}
else
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("KLog could not mark the full log to be sent to eQSL"));
msgBox.setDetailedText(tr("Something prevented KLog from marking the QSOs as modified. Restart KLog and try again before contacting the KLog developers."));
}
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
void MainWindow::slotElogQRZCOMModifyCurrentLog()
{
QMessageBox msgConfirm;
msgConfirm.setIcon(QMessageBox::Question);
msgConfirm.setWindowTitle(tr("KLog - QRZ.COM"));
msgConfirm.setText(tr("Do you really want to mark ALL your QSOs to be UPLOADED? Must be done ONLY IF THIS IS YOUR FIRST TIME uploading QSOs to %1").arg(tr("QRZ.COM")));
msgConfirm.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgConfirm.setDefaultButton(QMessageBox::No);
int i = msgConfirm.exec();
if (i == QMessageBox::Yes)
{
QMessageBox msgBox;
if (dataProxy->QRZCOMModifyFullLog(currentLog))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("The log is ready to be uploaded to QRZ.com."));
msgBox.setDetailedText(tr("All the QSOs in this log has been marked as Modified in the QRZ.com status field"));
}
else
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("KLog could not mark the full log to be sent to QRZ.com"));
msgBox.setDetailedText(tr("Something prevented KLog from marking the QSOs as modified. Restart KLog and try again before contacting the KLog developers."));
}
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
void MainWindow::slotClubLogLogUpload()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
if (!clublogActive)
{
showMessageToEnableTheOnlineService(ClubLog);
return;
}
adifLoTWExportWidget->setExportMode(ModeClubLog);
adifLoTWExportWidget->show();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::sloteQSLLogUpload()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
if (!eQSLActive)
{
showMessageToEnableTheOnlineService(eQSL) ;
return;
}
adifLoTWExportWidget->setExportMode(ModeEQSL);
adifLoTWExportWidget->show();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotQRZCOMLogUpload()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO ;
if (!qrzcomActive)
{
showMessageToEnableTheOnlineService(QRZ) ;
//qDebug() << Q_FUNC_INFO << " - END" ;
return;
}
if (!qrzcomSubscriber)
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - QRZ.com"));
msgBox.setText(tr("To upload QSOs you need a qrz.com subscription. If you have one, go to Setup->QRZ.com tab to enable it.") );
msgBox.exec();
//qDebug() << Q_FUNC_INFO << " - END" ;
return;
}
if (!elogQRZcom->hasLogBookKey())
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - QRZ.com"));
msgBox.setText(tr("You need to define a proper API Key for your QRZ.com logbook in the eLog preferences.") );
msgBox.exec();
//qDebug() << Q_FUNC_INFO << " - END" ;
return;
}
adifLoTWExportWidget->setExportMode(ModeQRZ);
adifLoTWExportWidget->show();
//qDebug() << Q_FUNC_INFO << " - END" ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotRQSLExport()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
QString fileName = QFileDialog::getSaveFileName(this, tr("Save ADIF File"),
util->getHomeDir(),
"ADIF (*.adi *.adif)");
filemanager->adifReqQSLExport(fileName);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotADIFImport(){
//qDebug() << "MainWindow::slotADIFImport " ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
util->getHomeDir(),
"ADIF (*.adi *.adif)");
if (!fileName.isNull())
{
//qDebug() << "MainWindow::slotADIFImport -1" ;
//filemanager->adifReadLog(fileName, currentLog);
int loggedQSOs = filemanager->adifReadLog(fileName, QString(), currentLog); // Empty StationCallsign by default
if (loggedQSOs>0)
{
updateQSLRecAndSent();
logWindow->refresh();
//qDebug() << Q_FUNC_INFO << " -3";
checkIfNewBandOrMode();
//qDebug() << Q_FUNC_INFO << " -4" ;
awardsWidget->fillOperatingYears();
//qDebug() << Q_FUNC_INFO << " -5" ;
slotShowAwards();
awardsWidget->showAwards();
//qDebug() << Q_FUNC_INFO << " -6" ;
}
//qDebug() << "MainWindow::slotADIFImport-7" ;
}
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::slotADIFImport-END" ;
}
void MainWindow::sendQSOToUI(const QSO &_qso)
{
//qDebug() << Q_FUNC_INFO << (_qso.getEQSLQSLSDate()).toString("yyyy-MM-dd");
QSOTabWidget->setRSTToMode(_qso.getSubmode(), false);
//qDebug() << Q_FUNC_INFO << ": " << _qso.getCall();
//qDebug() << Q_FUNC_INFO << ": " << _qso.getMode();
//qDebug() << Q_FUNC_INFO << ": " << _qso.getSubmode();
mainQSOEntryWidget->setQSOData(_qso);
commentTabWidget->setQSOData(_qso);
satTabWidget->setQSOData(_qso);
othersTabWidget->setQSOData(_qso);
QSLTabWidget->setQSOData(_qso);
eQSLTabWidget->setQSOData(_qso);
myDataTabWidget->setQSOData(_qso);
satTabWidget->setQSOData(_qso);
QSOTabWidget->setQSOData(_qso);
}
void MainWindow::qsoToEdit (const int _qso)
{
//qDebug() << Q_FUNC_INFO << QString::number(_qso) ;
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << " - 000";
if (!modify)
{
backupCurrentQSO ();
//qDebug() << Q_FUNC_INFO << ": Callsign: " << backupQSO->getCall();
//qDebug() << Q_FUNC_INFO << ": Mode " << backupQSO->getMode();
//qDebug() << Q_FUNC_INFO << ": SubMode " << backupQSO->getSubmode();
}
//qDebug() << Q_FUNC_INFO << " - 005";
clearUIDX(true);
readingTheUI = true;
setModifying(true);
//qDebug() << Q_FUNC_INFO << " - 010";
modifyingQSOid = _qso;
//qDebug() << Q_FUNC_INFO << " - 051 ";
if ((clublogActive) && (clublogRealTime))
{
clublogPrevQSO = dataProxy->getClubLogRealTimeFromId(modifyingQSOid);
}
manualMode = true; // We stop hamlib & wsjtx receiving data while editing a QSO
mainQSOEntryWidget->setManualMode (manualMode);
// ** Start of SAT data
//qDebug() << Q_FUNC_INFO << " - SATELLITE - satName" ;
satTabWidget->setFillingToEdit(true);
QSO qsoE;
qsoE.fromDB(modifyingQSOid);
//qDebug() << Q_FUNC_INFO << " - QSO: " << qsoE.getCall();
//qDebug() << Q_FUNC_INFO << " - QSO: " << qsoE.getMode();
//qDebug() << Q_FUNC_INFO << " - QSO: " << qsoE.getSubmode();
qsoInUI.copy(qsoE);
//qDebug() << Q_FUNC_INFO << " - m: " << (qsoE.getEQSLQSLSDate()).toString("yyyy-MM-dd");
sendQSOToUI(qsoE);
QString currentQrz = qsoE.getCall();
currentEntity = world->getQRZARRLId(currentQrz);
currentEntity = qsoE.getDXCC();
infoLabel2->setText(world->getEntityName(currentEntity));
infoWidget->showEntityInfo(currentEntity);
//qDebug() << Q_FUNC_INFO << " - in default - 101" ;
EntityStatus _entityStatus;
_entityStatus.dxcc = currentEntity;
_entityStatus.bandId = currentBandShown;
_entityStatus.modeId = currentModeShown;
_entityStatus.logId = currentLog;
//qDebug() << Q_FUNC_INFO << " - in default - 104" ;
showStatusOfDXCC(_entityStatus);
readingTheUI = false;
satTabWidget->setFillingToEdit(false);
//qDebug() << Q_FUNC_INFO << " - END" ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::setModifying(const bool _m)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
modify = _m;
QSOTabWidget->setModifying (modify);
mainQSOEntryWidget->setModify(modify);
satTabWidget->setModifying(modify);
myDataTabWidget->setModify (modify);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotLocatorTextChanged(const QString &_loc)
{//TO BE REMOVED ONCE InfoWidget is FINISHED - At least modified
//qDebug() << "MainWindow::slotLocatorTextChanged: " << _loc;
logEvent(Q_FUNC_INFO, "Start", Debug);
Locator locator;
if ( locator.isValidLocator(_loc) )
{
infoWidget->showDistanceAndBearing(myDataTabWidget->getMyLocator(), _loc);
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotMyLocatorTextChanged(const QString &_loc)
{
//qDebug() << "MainWindowMy::slotMyLocatorTextChanged: " <<_loc ;
logEvent(Q_FUNC_INFO, "Start", Debug);
Locator locator;
if ( locator.isValidLocator(_loc))
{
dxccStatusWidget->setMyLocator(_loc);
slotLocatorTextChanged(QSOTabWidget->getDXLocator());
}
else
{
logEvent(Q_FUNC_INFO, "END-2", Debug);
return;
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::showStatusOfDXCC(EntityStatus _entityStatus)
{
//qDebug() << Q_FUNC_INFO << " - Entity: " << _entityStatus.dxcc << "/ Bandid :" << _entityStatus.bandId << "/Modeid: " << _entityStatus.modeId ;
logEvent(Q_FUNC_INFO, "Start", Debug);
// Receives: QStringList _qs;
//_qs << Entity << BandId << ModeId << lognumber;
// Check if new one, needed, worked, confirmed
// Print the infoLabel1
// Print/Color the band boxes/labels
/*
0 - New One
1 - Needed
2 - Worked
3 - Confirmed
*/
//qDebug() << Q_FUNC_INFO << " - 10";
if (_entityStatus.bandId <= 0) // is the status valid?
{
//qDebug() << Q_FUNC_INFO << " - 20";
infoWidget->clear();
slotShowInfoLabel("--");
//infoLabel1->setText("--");
logEvent(Q_FUNC_INFO, "END-1", Debug);
//qDebug() << Q_FUNC_INFO << " - END-1" ;
return;
}
//qDebug() << Q_FUNC_INFO << " - 30";
// Set the status bar with the appropriate message
int status = awards.getDXStatus (_entityStatus);
//qDebug() << Q_FUNC_INFO << " - " << QString::number(status) ;
QString message = awards.getDXStatusString(status);
//qDebug() << Q_FUNC_INFO << " - 40";
slotShowInfoLabel(message);
//qDebug() << Q_FUNC_INFO << " - 10";
//infoLabel1->setText(message);
//infoWidget->showInfo((_qs.at(0)).toInt(), (_qs.at(1)).toInt(), (_qs.at(2)).toInt(), (_qs.at(3)).toInt() );
//qDebug() << Q_FUNC_INFO << " - 50";
infoWidget->showInfo(_entityStatus.dxcc);
//qDebug() << Q_FUNC_INFO << " - 51";
//qDebug() << Q_FUNC_INFO << " - END-2" ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::showDXMarathonNeeded(const int _dxcc, const int _cqz, const int _year, const int _log)
{
//qDebug() << "MainWindow::showDXMarathonNeeded" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
if ((_dxcc<=0) || (_cqz<=0) || (!manageDxMarathon))
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
}
if ( awards.isDXMarathonNeed(_dxcc, _cqz, _year, _log))
{
slotShowInfoLabel(infoLabel1->text()+ tr(" - Needed for DXMarathon"));
//infoLabel1->setText(infoLabel1->text()+ tr(" - Needed for DXMarathon"));
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotShowAwards()
{ //To be called from the logWindow & searchWidget
//qDebug() << Q_FUNC_INFO;
logEvent(Q_FUNC_INFO, "Start", Debug);
awards.recalculateAwards();
//qDebug() << Q_FUNC_INFO << " - 1";
//logWindow->refresh();
//qDebug() << Q_FUNC_INFO << " - 2";
awardsWidget->showAwards();
//qDebug() << Q_FUNC_INFO << " - 3";
//dxccStatusWidget->refresh();
setMainWindowTitle();
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << " - END";
}
void MainWindow::fillQSOData()
{ // Updates all QSO with the dxcc, CQZ, ... if empty.
//qDebug() << "MainWindow::fillQSOData" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QString stringQuery = QString("SELECT call, bandid, modeid, qso_date, lognumber, id, cqz, ituz, dxcc, cont FROM log WHERE ((dxcc<1) OR (cqz<1) OR (ituz<1) OR (dxcc IS NULL) OR (cqz IS NULL) OR (ituz IS NULL))");
QSqlQuery query;
bool sqlOK = query.exec(stringQuery);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().text(), query.lastQuery());
return;
}
QSqlQuery query1;
QSqlRecord rec = query.record();
int nameCol;
QString aux, queryString;
QString _call, _bandid, _modeid, _tdate, _ttime, _lognumber, _id, aux1, updateString;//, _confirmed;
bool toModify = false;
bool noMoreQso = false;
int numberOfQsos = 0;
int i = 0;
int _dxcc = 0;
numberOfQsos = dataProxy->getHowManyQSOInLog(currentLog);
//int progressBarPosition = 0;
QProgressDialog progress(tr("Filling QSOs ..."), tr("Abort filling"), 0, numberOfQsos, this);
progress.setWindowModality(Qt::WindowModal);
while ( (query.next()) && (!noMoreQso) ) {
if (query.isValid())
{
i++;
toModify = false;
nameCol = rec.indexOf("call");
if ( (query.value (nameCol)).isValid() )
{
_call = (query.value (nameCol)).toString();
}
nameCol = rec.indexOf("bandid");
if ( (query.value (nameCol)).isValid() )
{
_bandid = (query.value (nameCol)).toString();
}
nameCol = rec.indexOf("modeid");
if ( (query.value (nameCol)).isValid() )
{
_modeid = (query.value (nameCol)).toString();
}
nameCol = rec.indexOf("qso_date");
if ( (query.value (nameCol)).isValid() )
{
_tdate = (query.value (nameCol)).toString();
}
nameCol = rec.indexOf("id");
if ( (query.value (nameCol)).isValid() )
{
_id = (query.value (nameCol)).toString();
}
//qDebug() << Q_FUNC_INFO << ": ID: " << _id ;
//TODO: Prepare this query
updateString = "UPDATE log SET call = '" + _call + "', bandid = '" + _bandid + "', modeid = '" + _modeid + "', qso_date = '" + _tdate + "'" ;// + "', confirmed = '" + _confirmed + "'";
nameCol = rec.indexOf("cqz");
if (( (query.value (nameCol)).toString()).length() < 1 )
{
aux1 = QString::number(world->getQRZCqz(_call));
updateString = updateString + ", cqz='" + aux1 + "'";
toModify = true;
}
nameCol = rec.indexOf("ituz");
if (( (query.value (nameCol)).toString()).length() < 1 )
{
aux1 = QString::number( world->getQRZItuz(_call) );
updateString = updateString + ", ituz='" + aux1 + "'";
toModify = true;
}
//qDebug() << Q_FUNC_INFO << ": DXCC" ;
nameCol = rec.indexOf("dxcc");
_dxcc = (query.value (nameCol)).toInt();
//qDebug() << Q_FUNC_INFO << ": DXCC: " << QString::number(_dxcc) ;
if (_dxcc < 1)
{
aux1 = QString::number(world->getQRZARRLId(_call) );
//qDebug() << Q_FUNC_INFO << ": DXCC proposed: " << aux1 ;
updateString = updateString + ", dxcc='" + aux1 + "'";
toModify = true;
_dxcc = aux1.toInt();
}
else
{
//qDebug() << Q_FUNC_INFO << ": DXCC already existed" ;
}
nameCol = rec.indexOf("cont");
if (( (query.value (nameCol)).toString()).length() < 2 )
{
aux1 = world->getContinentShortName(_dxcc);
updateString = updateString + ", cont='" + aux1 + "'";
toModify = true;
}
//_dxcc = -1;
//qDebug() << "MainWindow::fillQSOData1: " << updateString ;
if (toModify)
{
updateString = updateString + " WHERE id = " + "'" + _id + "'";
//qDebug() << "MainWindow::fillQSOData2: " << updateString ;
sqlOK = query1.exec(updateString);
if (sqlOK)
{
//qDebug() << Q_FUNC_INFO << ": sqlOK=True" ;
}
else
{
emit queryError(Q_FUNC_INFO, query1.lastError().databaseText(), query1.lastError().nativeErrorCode(), query1.lastQuery());
//qDebug() << Q_FUNC_INFO << ": sqlOK=False" ;
}
}
else
{
updateString.clear();
}
aux = tr("Filling DXCC, CQz, ITUz, Continent in QSOs...\n QSO: ") + QString::number(i) + "/" + QString::number(numberOfQsos);
progress.setLabelText(aux);
progress.setValue (i);
if ( progress.wasCanceled() )
{
//qDebug() << "MainWindow::fillQSOData3: " ;
noMoreQso = true;
}
} // Closes the next.isValid
} // Closes the While
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotFillEmptyDXCCInTheLog()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
world->fillEmptyDXCCInTheLog();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotUpdateCTYDAT()
{
//qDebug() << "MainWindow::slotUpdateCTYDAT" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
downloadcty->download();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotUpdateSATSDAT()
{
//qDebug() << "MainWindow::slotUpdateSATSDAT" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
updateSatsData->readSatDataFile();
satTabWidget->refreshData();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotShowStats()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
statsWidget->show();
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotWorldReload(const bool _b)
{
//qDebug() << "MainWindow::slotWorldReload" ;
//TODO: world.recreate returns a boolean, so it is possible to manage the errors
logEvent(Q_FUNC_INFO, "Start", Debug);
if (_b)
{
world->recreate(ctyDatFile);
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotFilePrint()
{
//qDebug() << "MainWindow::slotFilePrint" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QPrinter printer;
QString aux;
QSqlQuery query, query1;
int row = 0;
int _numberOfQsos = 0;
bool cancelPrinting = false;
bool sqlOK;
_numberOfQsos = dataProxy->getHowManyQSOInLog(currentLog);
int step = util->getProgresStepForDialog(_numberOfQsos);
QTextDocument *doc = new QTextDocument;
QTextCursor cursor(doc);
QTextTable *textTable = cursor.insertTable(1, 9);
QTextBlockFormat centerAlignment;
centerAlignment.setAlignment(Qt::AlignCenter);
QTextTableFormat tableFormat;
tableFormat.setHeaderRowCount(1);
tableFormat.setCellPadding(5);
tableFormat.setAlignment(Qt::AlignCenter);
textTable->setFormat(tableFormat); //The first row is the header
cursor = textTable->cellAt(row, 0).firstCursorPosition();
cursor.setBlockFormat(centerAlignment);
cursor.insertText(tr("Number"));
cursor = textTable->cellAt(row, 1).firstCursorPosition();
cursor.insertText(tr("Date/Time"));
cursor = textTable->cellAt(row, 2).firstCursorPosition();
cursor.insertText(tr("Callsign"));
cursor = textTable->cellAt(row, 3).firstCursorPosition();
cursor.insertText(tr("RSTtx"));
cursor = textTable->cellAt(row, 4).firstCursorPosition();
cursor.insertText(tr("RSTrx"));
cursor = textTable->cellAt(row, 5).firstCursorPosition();
cursor.insertText(tr("Band"));
cursor = textTable->cellAt(row, 6).firstCursorPosition();
cursor.insertText(tr("Mode"));
cursor = textTable->cellAt(row, 7).firstCursorPosition();
cursor.insertText(tr("Comment"));
int nameCol = 0;
//int qsoPerPage = 25;
//int maxPages = (int)(Klog::number / qsoPerPage)+1; // To print just 10 QSO per page
//int printedSoFar = 0;
//int page = 1;
printer.setPageOrientation(QPageLayout::Landscape); // For testing, the log will be printed landscape.
printer.setDocName(stationCallsign+"-log");
QPrintDialog printDialog(&printer, this);
printDialog.setWindowTitle(tr("Print Log"));
if (printDialog.exec() == QDialog::Accepted)
{
int _qsos = 0;
QProgressDialog progress(tr("Printing the log ..."), tr("Abort printing"), 0, _numberOfQsos, this);
progress.setMaximum(_numberOfQsos);
progress.setWindowModality(Qt::WindowModal);
QString stringQuery = QString("SELECT id, qso_date, call, rst_sent, rst_rcvd, bandid, modeid, comment FROM log WHERE lognumber='%1'").arg(currentLog);
sqlOK = query.exec(stringQuery);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().text(), query.lastQuery());
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
//TODO: Print a message showing an error and exit.
}
QSqlRecord rec = query.record();
aux = tr("Printing the log...\n QSO: ") + QString::number(_qsos) + "/" + QString::number(_numberOfQsos);
progress.setLabelText(aux);
progress.setValue (_qsos);
while ((query.next()) && (!cancelPrinting))
{
if (query.isValid())
{
textTable->appendRows(1);
row++;
_qsos++;
//qDebug() << "MainWindow::slotFilePrint: QSO: " << QString::number(_qsos) << " - Step: " << QString::number(step) << " - Div: " << QString::number(_qsos % step);
if (( (_qsos % step )== 0) )
{ // To update the speed I will only show the progress once each X QSOs
aux = tr("Printing the log...\n QSO: ") + QString::number(_qsos) + "/" + QString::number(_numberOfQsos);
progress.setLabelText(aux);
progress.setValue (_qsos);
}
nameCol = rec.indexOf("id");
cursor = textTable->cellAt(row, 0).firstCursorPosition();
cursor.insertText((query.value (nameCol)).toString());
nameCol = rec.indexOf("qso_date");
cursor = textTable->cellAt(row, 1).firstCursorPosition();
cursor.insertText((query.value (nameCol)).toString());
nameCol = rec.indexOf("call");
cursor = textTable->cellAt(row, 2).firstCursorPosition();
cursor.insertText((query.value (nameCol)).toString());
nameCol = rec.indexOf("rst_sent");
cursor = textTable->cellAt(row, 3).firstCursorPosition();
cursor.insertText((query.value (nameCol)).toString());
nameCol = rec.indexOf("rst_rcvd");
cursor = textTable->cellAt(row, 4).firstCursorPosition();
cursor.insertText((query.value (nameCol)).toString());
nameCol = rec.indexOf("bandid");
aux = (query.value (nameCol)).toString();
stringQuery = QString("SELECT name FROM band WHERE id='%1'").arg(aux);
sqlOK = query1.exec(stringQuery);
if (sqlOK)
{
query1.next();
if (query1.isValid())
{
cursor = textTable->cellAt(row, 5).firstCursorPosition();
cursor.insertText((query1.value (0)).toString());
}
}
else
{
emit queryError(Q_FUNC_INFO, query1.lastError().databaseText(), query1.lastError().nativeErrorCode(), query1.lastQuery());
}
//qDebug() << "MainWindow::slotFilePrint: Band: " << aux ;
nameCol = rec.indexOf("modeid");
//qDebug() << "MainWindow::slotFilePrint: nameCol: " << QString::number(nameCol) ;
aux = (query.value (nameCol)).toString();
//qDebug() << "MainWindow::slotFilePrint: Mode1: " << aux ;
aux = dataProxy->getSubModeFromId(aux.toInt());
//qDebug() << "MainWindow::slotFilePrint: Mode2: " << aux ;
if (aux.length()>1)
{
cursor = textTable->cellAt(row, 6).firstCursorPosition();
cursor.insertText(aux);
}
else
{
//qDebug() << "MainWindow::slotFilePrint: ERROR: " << aux ;
}
nameCol = rec.indexOf("comment");
aux = (query.value (nameCol)).toString();
if ((aux.length())>0)
{
cursor = textTable->cellAt(row, 7).firstCursorPosition();
cursor.insertText(aux);
}
}
if ( progress.wasCanceled() )
{
cancelPrinting = true;
}
}
progress.setValue (_numberOfQsos);
if (!cancelPrinting)
{
doc->print(&printer);
}
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
//DX-CLUSTER - DXCLUSTER
void MainWindow::slotAnalyzeDxClusterSignal(const DXSpot &_spot)
{
//qDebug() << Q_FUNC_INFO;
logEvent(Q_FUNC_INFO, "Start", Debug);
DXSpot spot = _spot;
//if (spot.isValid())
//qDebug() << Q_FUNC_INFO << " - Spot is Valid";
//else
//qDebug() << Q_FUNC_INFO << " - Spot is NOT Valid";
//qDebug() << Q_FUNC_INFO << ": spot-dxCall : " << spot.getDxCall();
//qDebug() << Q_FUNC_INFO << ": spot-Spotter : " << spot.getSpotter();
//qDebug() << Q_FUNC_INFO << ": spot-Freq : " << spot.getFrequency().toQString();
//qDebug() << Q_FUNC_INFO << ": spot-Comment : " << spot.getComment();
EntityStatus _entityStatus;
_entityStatus.dxcc = world->getQRZARRLId(spot.getDxCall());
if (!manageMode)
{
_entityStatus.modeId = -1;
}
if (spot.getClickStatus() == SingleClick)
{
infoLabel2->setText(world->getEntityName(_entityStatus.dxcc));
infoWidget->showEntityInfo(_entityStatus.dxcc );
// Becareful, he Frecuency arrives in KHz instead of bandid!!
// db.getBandFromFreq expects a MHz!
//(ql.at(1)).toDouble()
_entityStatus.bandId = dataProxy->getBandIdFromFreq((spot.getFrequency().toDouble()));
//qls << QRZ << BandId << ModeId << lognumber;
showStatusOfDXCC(_entityStatus);
}
else if (spot.getClickStatus() == DoubleClick)
{
clusterSpotToLog(spot.getDxCall(), spot.getFrequency());
}
int statusI = awards.getDXStatus (_entityStatus);
//proposedQSOs pQSO;
//pQSO.status = awards.getQSOStatus(statusI);
//Callsign callsign(spot.getDxCall());
//if (callsign.isValid())
//{
// pQSO.call = spot.getDxCall();
// dxClusterAssistant->newDXClusterSpot(pQSO);
//}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotDXClusterSpotArrived(const DXSpot &_spot)
{
//qDebug() << Q_FUNC_INFO;
//(void)_dxCall;
//(void)_freq;
DXSpot sp = _spot;
if (!sp.isValid())
return;
Callsign callsign(sp.getDxCall());
//if (callsign.isValid())
//{
// proposedQSOs pQSO;
// pQSO.call = sp.getDxCall();
// pQSO.status = ATNO;
// pQSO.freq = sp.getFrequency();
// dxClusterAssistant->newDXClusterSpot(pQSO);
//qDebug() << Q_FUNC_INFO << ": DXCall not valid: " << pQSO.call;
//}
//else
//{
//qDebug() << Q_FUNC_INFO << ": DXCall not valid: " << sp.getDxCall();
//}
if (!dxclusterSendSpotsToMap)
{
return;
}
logEvent(Q_FUNC_INFO, "Start", Debug);
QString dxGrid = world->getQRZLocator (sp.getDxCall());
Locator locator;
Coordinate coord = locator.getLocatorCoordinate (dxGrid);
//qDebug() << Q_FUNC_INFO << QString(" %1: Locator: %2 - (lat/lon)=>(%3/%4)").arg(sp.getDxCall()).arg(dxGrid).arg(coord.lat).arg(coord.lon);
//qDebug() << "Lat: " << QString::number(coord.lat) << " - Lon: " << QString::number(coord.lon);
mapWindow->addMarker(coord, dxGrid);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::clusterSpotToLog(const QString &_call, Frequency _fr)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
QString _aux;
double _freqN = _fr.toDouble(MHz);
//qDebug() << Q_FUNC_INFO << " - calling setQRZ-2" ;
mainQSOEntryWidget->setQRZ(_call);
QSOTabWidget->setTXFreq (_freqN);
QSOTabWidget->setRXFreq(_freqN);
//freqQLCDNumber->display(_freqN);
//_aux = QString::number(_freqN);
//qDebug() << Q_FUNC_INFO << " - Freq: " << _aux ;
int _bandi = dataProxy->getBandIdFromFreq(_freqN);
//qDebug() << Q_FUNC_INFO << " - Bandi: " << QString::number(_bandi) ;
_aux = QString::number(_bandi);
_aux = QString("SELECT name FROM band WHERE id ='%1'").arg(_aux);
//qDebug() << Q_FUNC_INFO << " - Band: " << _aux ;
QSqlQuery query(_aux);
query.next();
if (query.isValid())
{
_aux = (query.value (0)).toString();
mainQSOEntryWidget->setBand(_aux);
//bandComboBox->setCurrentIndex(bandComboBox->findText(_aux, Qt::MatchCaseSensitive));
}
else
{
mainQSOEntryWidget->setBand(dataProxy->getNameFromBandId(defaultBand));
//bandComboBox->setCurrentIndex(bandComboBox->findText(dataProxy->getNameFromBandId(defaultBand), Qt::MatchCaseSensitive));
//bandComboBox->setCurrentIndex(defaultBand);
}
//qDebug() << Q_FUNC_INFO << " - END " ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
//DX-CLUSTER - DXCLUSTER
void MainWindow::updateQSLRecAndSent()
{
//qDebug() << "MainWindow::updateQSLRecAndSent " ;
logEvent(Q_FUNC_INFO, "Start", Debug);
// Checks the log to fill all the qsl_rcvd and qsl_sent
QSqlQuery query, query1;
QString queryString, aux, idT;
//int nameCol=0;
//queryString = QString("SELECT id, qsl_rcvd, qsl_sent FROM log WHERE lognumber='%1'").arg(currentLog);
//queryString = QString("SELECT id, qsl_rcvd, qsl_sent FROM log WHERE qsl_rcvd !='Y' AND qsl_rcvd !='N' AND qsl_rcvd !='R' AND qsl_rcvd !='I' AND qsl_rcvd !='V' AND lognumber='%1'").arg(currentLog);
//queryString = QString("SELECT id, qsl_rcvd, qsl_sent FROM log WHERE qsl_rcvd ='' OR qsl_rcvd IS NULL OR qsl_sent ='' AND lognumber='%1'").arg(currentLog);
queryString = QString("UPDATE log SET qsl_rcvd='N' WHERE qsl_rcvd ='' AND lognumber='%1'").arg(currentLog);
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().text(), query.lastQuery());
}
queryString = QString("UPDATE log SET qsl_sent='N' WHERE qsl_sent ='' AND lognumber='%1'").arg(currentLog);
sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().text(), query.lastQuery());
}
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::updateQSLRecAndSent - END" ;
}
QString MainWindow::findStationCallsignToUse()
{
//QString foundCall = dataProxy->getStationCallSignFromLog (currentLog);
QString foundCall = dataProxy->getStationCallSignFromLog (currentLog);
Callsign callsign(foundCall);
if (callsign.isValid())
return foundCall;
return mainQRZ;
}
void MainWindow::defineStationCallsign()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
QString logQRZ = findStationCallsignToUse();
//qDebug() << Q_FUNC_INFO << ": StationCallsign: " << logQRZ;
Callsign callsign(logQRZ);
if (!callsign.isValid())
{
return;
}
stationCallsign = logQRZ;
//qDebug() << Q_FUNC_INFO << ": " << stationCallsign ;
filemanager->setStationCallSign(stationCallsign);
//qDebug() << Q_FUNC_INFO << ": AFTER" ;
myDataTabWidget->setData(stationCallsign, operatorQRZ, myDataTabWidget->getMyLocator());
dxccStatusWidget->setMyLocator(myDataTabWidget->getMyLocator());
searchWidget->setStationCallsign(stationCallsign);
if (lotwActive)
{
lotwUtilities->setStationCallSign(stationCallsign);
}
dxClusterWidget->setMyQRZ(stationCallsign);
adifLoTWExportWidget->setDefaultStationCallsign(stationCallsign);
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << ": " << stationCallsign << " - END" ;
}
void MainWindow::slotSetPropModeFromSat(const QString &_p, bool _keep)
{
//qDebug() << Q_FUNC_INFO << ": " << _p << "- _keep: " << util->boolToQString(_keep) ;;
logEvent(Q_FUNC_INFO, "Start", Debug);
othersTabWidget->setPropMode(_p, _keep);
QSOTabWidget->setPropModeFromSat(_p);
logEvent(Q_FUNC_INFO, "END", Debug);
//int indexC = propModeComboBox->findText(" - " + _p + " - ", Qt::MatchContains);
//propModeComboBox->setCurrentIndex(indexC);
}
void MainWindow::slotSetPropModeFromOther(const QString &_p)
{
//qDebug() << Q_FUNC_INFO << ": " << _p;
if (_p!="SAT")
{
//qDebug() << Q_FUNC_INFO << ": Is NOT SAT propagation mode";
satTabWidget->setNoSat();
}
}
void MainWindow::clearIfNotCompleted()
{
if (completedWithPreviousIOTA)
{
othersTabWidget->clearIOTA();
completedWithPreviousIOTA = false;
}
if (completedWithPreviousQSLVia)
{
QSLTabWidget->setQSLVia("");
completedWithPreviousQSLVia = false;
}
}
void MainWindow::completeWithPreviousQSO(const QString &_call)
{
//qDebug() << "MainWindow::completeWithPreviousQSO" ;
//This function completes: Name, QTH, Locator, Entity, Iota
logEvent(Q_FUNC_INFO, "Start", Debug);
int previousQSOId = dataProxy->isWorkedB4(_call, -1);
if ((!completeWithPrevious) || (_call.length()<=0) || (previousQSOId<=0))
//if ( (_call.length()<=0) || (dataProxy->isWorkedB4(_call, -1)<=0))
{
//qDebug() << "MainWindow::completeWithPreviousQSO NOT completing..." ;
QSOTabWidget->setName(QString());
QSOTabWidget->setQTH(QString());
QSOTabWidget->setDXLocator(QString());
clearIfNotCompleted();
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
}
QSO prevQSO;
prevQSO.fromDB(previousQSOId);
//qDebug() << "MainWindow::completeWithPreviousQSO completing..." ;
QString aux = QString();
QSOTabWidget->setName(prevQSO.getName(), true);
QSOTabWidget->setQTH(prevQSO.getQTH(), true);
QSOTabWidget->setDXLocator(prevQSO.getGridSquare(), true);
aux = prevQSO.getIOTA();
if ((aux.length()>=0) && (othersTabWidget->isIOTAModified()) )
{
aux = awards.checkIfValidIOTA(aux);
if ((aux.length())==6)
{
othersTabWidget->setIOTA(aux);
completedWithPreviousIOTA=true;
}
else if (completedWithPreviousIOTA && (aux != othersTabWidget->getIOTA()))
{
othersTabWidget->clearIOTA();
completedWithPreviousIOTA = false;
}
}
else if (completedWithPreviousIOTA )
{
othersTabWidget->clearIOTA();
completedWithPreviousIOTA = false;
}
aux = prevQSO.getQSLVia();
if ((aux.length()>=0) && ((QSLTabWidget->getQSLVia()).length()<=0) )
{
QSLTabWidget->setQSLVia(aux, Qt::red);
completedWithPreviousQSLVia=true;
}
else if (completedWithPreviousQSLVia && (aux != QSLTabWidget->getQSLVia()))
{
QSLTabWidget->setQSLVia("");
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotValidBandsReceived(const QStringList &_b)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO ;
dxccStatusWidget->setBands(Q_FUNC_INFO, _b, true);
satTabWidget->addBands(_b);
mapWindow->setBands(_b);
//qDebug() << Q_FUNC_INFO << " - END" ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotFreqRXChanged(const double _fr)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_fr);
if (!upAndRunning || modify)
{
//qDebug() << Q_FUNC_INFO << " - not running" ;
return;
}
int bandId = dataProxy->getBandIdFromFreq(_fr);
if (bandId < 1)
{
//qDebug() << Q_FUNC_INFO << " - wrong band" ;
return;
}
// The following line is needed to ensure that the band of the freqRX is included
// in the list of available bands and include it if it is not.
mainQSOEntryWidget->setFreq (_fr, true);
QSOTabWidget->setRXFreq (_fr);
satTabWidget->setDownLinkFreq(_fr);
//qDebug() << Q_FUNC_INFO << " - END";
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotFreqTXChangedFromSat(const double _fr)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
if (!upAndRunning || modify)
{
//qDebug() << Q_FUNC_INFO << " - END-1";
return;
}
if (dataProxy->isThisFreqInBand (mainQSOEntryWidget->getBand (), QString::number(_fr)))
{
//qDebug() << Q_FUNC_INFO << " - END-2";
return;
}
slotFreqTXChanged (_fr);
//qDebug() << Q_FUNC_INFO << " - END";
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotFreqTXChanged(const double _fr)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_fr);
if (!upAndRunning || modify)
{
//qDebug() << Q_FUNC_INFO << " - END-1";
return;
}
//qDebug() << Q_FUNC_INFO << " - 10";
QSOTabWidget->setTXFreq (_fr);
//qDebug() << Q_FUNC_INFO << " - 11";
mainQSOEntryWidget->setFreq (_fr);
//qDebug() << Q_FUNC_INFO << " - calling setUpLinkFreq";
satTabWidget->setUpLinkFreq(_fr);
if (hamlibActive && !manualMode)
{
hamlib->setFreq(_fr);
}
mainQSOEntryWidget->setMode(util->getDefaultModeForFreq(_fr));
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << " - END";
}
void MainWindow::slotShowQSOsFromDXCCWidget(QList<int> _qsos)
{
//qDebug() << "MainWindow::slotShowQSOsFromDXCCWidget" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
slotShowSearchWidget();
searchWidget->showQSOs(_qsos);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotQSOReceived(const QSO &_qso)
{
//qDebug() << Q_FUNC_INFO << " - Start";
//logEvent(Q_FUNC_INFO, "Start", Debug);
if (!wsjtxAutoLog)
if (!askToAddQSOReceived(_qso))
return;
//qDebug() << Q_FUNC_INFO << "010";
QSO q;
//qDebug() << Q_FUNC_INFO << "020";
q.copy(_qso);
q.setLogId(currentLog);
//qDebug() << Q_FUNC_INFO << "030";
//qDebug() << Q_FUNC_INFO << "Call: " << q.getCall();
//qDebug() << Q_FUNC_INFO << "Mode: " << q.getMode();
int dxcc = world->getQRZARRLId(q.getCall());
//qDebug() << Q_FUNC_INFO << "040";
dxcc = util->getNormalizedDXCCValue (dxcc);
//qDebug() << Q_FUNC_INFO << "050";
q.setDXCC(dxcc);
q.setClubLogStatus(clublogSentDefault);
q.setLoTWQSL_SENT(lotwSentDefault);
q.setEQSLQSL_SENT(eqslSentDefault);
q.setQRZCOMStatus(qrzcomSentDefault);
//qDebug() << Q_FUNC_INFO << "060";
if (!showWSJTXDuplicatedMSG(q))
return;
//qDebug() << Q_FUNC_INFO << "070";
int addedQSO = q.toDB();
//qDebug() << Q_FUNC_INFO << "addedQSO: " << addedQSO;
if (addedQSO>0)
{
//qDebug() << Q_FUNC_INFO << "090";
//qDebug() << Q_FUNC_INFO << " - QSO added: " << QString::number(addedQSO);
actionsJustAfterAddingOneQSO();
slotShowInfoLabel(tr("QSO logged from WSJT-X:"));
infoLabel2->setText(q.getCall() + " - " + dataProxy->getBandNameFromFreq(q.getFreqTX()) + "/" + q.getSubmode());
slotClearButtonClicked(Q_FUNC_INFO);
}
else
{
//qDebug() << Q_FUNC_INFO << "100";
}
//qDebug() << Q_FUNC_INFO << " - END";
logEvent(Q_FUNC_INFO, "END", Debug);
}
bool MainWindow::askToAddQSOReceived(const QSO &_qso)
{
//qDebug() << Q_FUNC_INFO << " - Start";
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - QSO received - NEW"));
msgBox.setTextFormat(Qt::RichText);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
QSO qsoM(_qso);
QString aux = QString(tr("<HTML><body>ASK-The following QSO data has been received from to be logged:\n\n"
"<table>"
"<tr><TH>Callsign:</TH><TD>%1</TD></TR>"
"<TR><TH>Freq:</TH><TD>%2</TD></TR>"
"<TR><TH>Mode:</TH><TD>%3</TD></TR>"
"<TR><TH>Time On:</TH><TD>%4</TD></TR>"
"<TR><TH>Time Off:</TH><TD>%5</TD></TR>"
"<TR><TH>RST TX:</TH><TD>%6</TD></TR>"
"<TR><TH>RST RX:</TH><TD>%7</TD></TR>"
"<TR><TH>Comment:</TH><TD>%8</TD></TR>"
"<TR><TH>DX-Grid:</TH><TD>%9</TD></TR>"
"<TR><TH>Local-Grid:</TH><TD>%10</TD></TR>"
"<TR><TH>Station Callsign:</TH><TD>%11</TD></TR>"
"<TR><TH>Operator Callsign:</TH><TD>%12</TD></TR></table></body></html>")).arg(qsoM.getCall(), QString::number(qsoM.getFreqTX()), qsoM.getSubmode(),
util->getADIFTimeFromQTime(qsoM.getTimeOn()), util->getADIFTimeFromQTime(qsoM.getTimeOff()), qsoM.getRSTTX(), qsoM.getRSTRX(),
qsoM.getComment(), qsoM.getGridSquare(), qsoM.getMyGridSquare(),
qsoM.getStationCallsign(), qsoM.getOperatorCallsign());
msgBox.setText(aux);
int ret = msgBox.exec();
switch (ret)
{
//case QMessageBox::Yes:
//break;
case QMessageBox::No:
//logTheQso = false;
return false;
break;
default:
// should never be reached
//logTheQso = false;
return true;
break;
}
}
bool MainWindow::showWSJTXDuplicatedMSG(const QSO &_qso)
{
QSO q = _qso;
//qDebug() << Q_FUNC_INFO << " - Calling isThisQSODuplicated with call: " << q.getCall();
if (!((dataProxy->isThisQSODuplicated(q, dupeSlotInSeconds)).length()>0))
return true;
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - WSJTX Dupe QSO"));
msgBox.setIcon(QMessageBox::Warning);
QString aux = tr("This QSO seems to be duplicated. Do you want to save or discard it?");
msgBox.setText(aux);
msgBox.setDetailedText(tr("Duplicated QSOs have to match another existing QSO with the same call, band, mode, date and time, taking into account the period that can be defined in the settings."));
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard );
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Save:
logEvent(Q_FUNC_INFO, "END-1", Debug);
return true;
break;
case QMessageBox::Discard:
logEvent(Q_FUNC_INFO, "END-1", Debug);
return false; //No more error shown
// break;
default:
// should never be reached
logEvent(Q_FUNC_INFO, "END-3", Debug);
return false; // The user wants to keepseeing errors
//break;
}
}
bool MainWindow::checkIfNewMode(const QString &_mode)
{
//qDebug() << "MainWindow::checkIfNewMode: " << _mode ;
logEvent(Q_FUNC_INFO, "Start", Debug);
if (dataProxy->getIdFromModeName(_mode)<0)
{// The mode is not existing; it is not an accepted mode for KLog
// TODO: Show an error to the user
//qDebug() << "MainWindow::checkIfNewMode: Mode not valid! - " << _mode ;
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - Non-supported mode"));
msgBox.setIcon(QMessageBox::Warning);
QString aux = tr("A new mode not supported by KLog has been received from an external program or radio:") + "(" + _mode + ")\n\n" + tr("If the received mode is correct, please contact KLog development team and request support for that mode") + "\n\n" + tr("Do you want to keep receiving these alerts? (disabling these alerts will prevent non-valid modes being detected)");
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Yes:
logEvent(Q_FUNC_INFO, "END-1", Debug);
return false; // The user wants to keepseeing errors
//break;
case QMessageBox::No:
logEvent(Q_FUNC_INFO, "END-1", Debug);
return true; //No more error shown
// break;
default:
// should never be reached
logEvent(Q_FUNC_INFO, "END-3", Debug);
return false; // The user wants to keepseeing errors
//break;
}
}
else
{
//noMoreModeErrorShown = false;
//TODO: Add the new mode to the list of active modes
//qDebug() << "MainWindow::checkIfNewMode: VALID NEW MODE: Adding... - " << _mode ;
addNewValidMode(_mode);
}
logEvent(Q_FUNC_INFO, "END", Debug);
return false;
}
void MainWindow::slotWSJXstatusFromUDPServer(const int _type, const QString &_dxcall, const double _freq, const QString &_mode,
const QString &_report, const QString &_de_call, const QString &_de_grid,
const QString &_dx_grid, const QString &_sub_mode)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
(void)_sub_mode;
if (manualMode)
{
return;
}
if (modify)
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
}
//qDebug() << Q_FUNC_INFO << " type: " << QString::number(_type) ;
//qDebug() << Q_FUNC_INFO << " dxcall: " << _dxcall ;
//qDebug() << Q_FUNC_INFO << " freq: " << QString::number(_freq/1000000) ;
//qDebug() << Q_FUNC_INFO << " mode: " << _mode ;
//qDebug() << Q_FUNC_INFO << " report: " << _report ;
//qDebug() << Q_FUNC_INFO << " de_call: " << _de_call ;
//qDebug() << Q_FUNC_INFO << " _de_grid: " << _de_grid ;
//qDebug() << Q_FUNC_INFO << " dx_grid: " << _dx_grid ;
//qDebug() << Q_FUNC_INFO << " sub_mode: " << _sub_mode ;
if ((!mainQSOEntryWidget->isModeExisting(_mode)) && (!noMoreModeErrorShown))
{
noMoreModeErrorShown = checkIfNewMode(_mode);
}
switch (_type)
{
case 0:
//qDebug() << "MainWindow::slotStatusFromUDPServer: - type = " << QString::number(_type) << " - OUT/IN - Heartbeat" ;
break;
case 1:
//qDebug() << "MainWindow::slotStatusFromUDPServer: - type = " << QString::number(_type) << " - OUT - Status" ;
//qDebug() << Q_FUNC_INFO << " - calling setQRZ-3" ;
mainQSOEntryWidget->setQRZ(_dxcall);
if ((!noMoreModeErrorShown) && (dataProxy->getIdFromModeName(_mode)>0) )
{
mainQSOEntryWidget->setMode(_mode);
//modeComboBox->setCurrentIndex(modeComboBox->findText(_mode, Qt::MatchCaseSensitive));
}
//qDebug() << "MainWindow::slotWSJXstatusFromUDPServer updating txFreqSpinBox" << QString::number(_freq) ;
QSOTabWidget->setTXFreq (_freq);
QSOTabWidget->setRXFreq (_freq);
if (!_dx_grid.isEmpty())
{
slotUpdateLocator(_dx_grid);
}
QSOTabWidget->setRSTTX (_report);
myDataTabWidget->setMyLocator(_de_grid);
myDataTabWidget->setStationCallsign(_de_call.toUpper());
//TODO: Check what to do with _de_call -> Check if _de_call == station callsign and update if needed.
//TODO: Check what to do with _de_grid -> Check if _de_grid == My Grid and update if needed.
//TODO: Check what to do with _submode.
//bandComboBox->setCurrentIndex(bandComboBox->findText(, Qt::MatchCaseSensitive));
break;
default: //NO
//qDebug() << "MainWindow::slotStatusFromUDPServer: - type = " << QString::number(_type) << " - ERROR on Type" ;
break;
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::addNewValidMode(const QString &_mode)
{
//qDebug() << "MainWindow::addNewMode: " << _mode ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QStringList _newM;
_newM.clear();
_newM << _mode;
_newM << mainQSOEntryWidget->getModes();
readActiveModes (_newM);
mainQSOEntryWidget->setModes(modes);
mapWindow->setModes(modes);
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << "MainWindow::addNewValidMode: END" ;
}
void MainWindow::slotClearNoMorErrorShown()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
noMoreErrorShown = false;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotQueryErrorManagement(QString functionFailed, QString errorCodeS, QString nativeError, QString queryFailed)
{
//qDebug() << Q_FUNC_INFO << " - Function: " << functionFailed ;
//qDebug() << Q_FUNC_INFO << " - Error: - " << errorCodeS;
//qDebug() << Q_FUNC_INFO << " - Native: - " << nativeError;
//qDebug() << Q_FUNC_INFO << " - QueryFailed: - " << queryFailed;
logEvent(Q_FUNC_INFO, "Start", Debug);
if (noMoreErrorShown)
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
}
QString aux;
bool showDebug = true;
if (nativeError.toInt() == 2067)
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
if (functionFailed == "int QSO::toDB(int)")
{
msgBox.setWindowTitle(tr("KLog - QSO Dupe"));
msgBox.setText(tr("A dupe QSO has been detected in the file and will not be added to the log."));
msgBox.setInformativeText(tr("Please check the QSO information file and ensure it is properly added.") );
showDebug = false;
}
else if (functionFailed == "virtual bool DataProxy_SQLite::addSatellite(QString, QString, QString, QString, QString)")
{
msgBox.setWindowTitle(tr("KLog - Duplicated satellite"));
msgBox.setText(tr("A duplicated satellite has been detected in the file and will not be imported."));
msgBox.setInformativeText(tr("Please check the satellite information file and ensure it is properly populated.") + "\n" + tr("Now you will see a more detailed error that can be used for debugging..."));
}
msgBox.exec();
return;
}
if (showDebug)
{
// TODO: An error on DB has been detected.
// KLog should suggest to export ALL the data to an ADIF file to prevent any log lose
aux = "<br><b>" + tr("An unexpected error ocurred!!") + "</b><br><br>" + tr("If the problem persists, please contact the developers") + "(<a href=mailto:klog@groups.io>klog@groups.io</a>)" + tr("for analysis:") + "<br>";
QString errorMSG = "<ul>"
"<li><b>" + tr("Error in function") + ":</b> " + functionFailed + "</li>" +
"<li><b>" + tr("Native Error") +":</b> " + nativeError + "</li>" +
"<li><b>" + tr("Error text") + ":</b> " + errorCodeS + "</li>" +
"<li><b>" + tr("Failed query") + ":</b> " + queryFailed + "</li>" +
"</ul><br>" +
"<b>" + tr("Recommendation:") + "</b>" + tr("Periodically export your data to ADIF to prevent a potential data loss.") + "<br>";
showErrorDialog->setText(aux + errorMSG);
//showErrorDialog->setModal(true);
showErrorDialog->exec();
}
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - Show errors"));
msgBox.setIcon(QMessageBox::Question);
aux = tr("Do you want to keep showing errors?");
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Ok:
break;
case QMessageBox::No:
noMoreErrorShown = true;
break;
default:
// should never be reached
break;
}
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotDefineNewBands (const QStringList _bands)
{
//qDebug() << "MainWindow::defineNewBands: " ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QStringList qsTemp;
qsTemp.clear();
//qsTemp << _bands;
//qsTemp.removeDuplicates();
qsTemp << dataProxy->sortBandNamesBottonUp(_bands);
qsTemp.removeDuplicates();
bands.clear();
bands = qsTemp;
mainQSOEntryWidget->setBands(bands);
mapWindow->setBands(bands);
satTabWidget->addBands(bands);
//qDebug() << "MainWindow::defineNewBands - END" ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotHamlibTXFreqChanged(const double _f)
{
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_f) ;
logEvent(Q_FUNC_INFO, "Start", Debug);
if (manualMode)
{
return;
}
if (upAndRunning)
{
if (!util->isSameFreq (_f, QSOTabWidget->getTXFreq ()))
{
//qDebug() << Q_FUNC_INFO << ": Updating the freq... " ;
QSOTabWidget->setTXFreq (_f);
}
else
{
//qDebug() << "MainWindow::slotHamlibTXFreqChanged - Not updating Freq" ;
}
}
else
{
//qDebug() << "MainWindow::slotHamlibTXFreqChanged - Not Up&Running" ;
}
//qDebug() << "MainWindow::slotHamlibTXFreqChanged - END " ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotHamlibModeChanged(const QString &_m)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
if (manualMode)
{
return;
}
if (_m.length()<2)
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
return;
}
if ((mainQSOEntryWidget->getMode()).toUpper() == _m.toUpper())
{
return;
}
hamlibChangingMode = true;
if (checkIfNewMode(_m))
{
hamlibChangingMode = false;
logEvent(Q_FUNC_INFO, "END-2", Debug);
return;
}
if (mainQSOEntryWidget->isModeExisting(_m))
{
//qDebug() << "slotHamlibModeChanged: Mode in the Combobox: " ;
mainQSOEntryWidget->setMode(_m);
//modeComboBox->setCurrentIndex(modeComboBox->findText(_m, Qt::MatchCaseSensitive));
}
else
{
//qDebug() << "MainWindow::slotHamlibModeChanged: Mode not found in combobox" << _m ;
}
hamlibChangingMode = false;
logEvent(Q_FUNC_INFO, "END", Debug);
}
/*
void MainWindow::slotRotatorShow()
{
rotatorWidget->show();
}
*/
void MainWindow::slotUpdateLocator(QString _loc)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << "MainWindow::slotUpdateLocator: " << _loc;
QSOTabWidget->setDXLocator (_loc);
//qDebug() << "MainWindow::slotUpdateLocator - END" ;
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::reconfigureDXMarathonUI(const bool _dxM)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
dxClusterWidget->setDXMarathon(_dxM);
awardsWidget->setManageDXMarathon(_dxM);
//awardsWidget->reconfigureDXMarathonUI(_dxM);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotShowInfoLabel(const QString &_m)
{
infoLabel1->setText(_m);
}
void MainWindow::slotAwardsWidgetSetLog()
{
awardsWidget->setLog(currentLog);
}
void MainWindow::slotAwardsWidgetSetYear()
{
awardsWidget->setYear(selectedYear);
}
void MainWindow::slotManualMode(bool _enable)
{
//qDebug() << Q_FUNC_INFO << ": " << util->boolToQString (_enable);
manualMode = _enable;
if ((manualMode) && (hamlibActive))
{
hamlib->readRadio(true);
}
}
void MainWindow::backupCurrentQSO()
{ // This function reads the full UI and stores it in a QSO
//qDebug() << Q_FUNC_INFO << " - Start" ;
logEvent(Q_FUNC_INFO, "Start", Debug);
backupQSO->clear();
getQSODataFromUI();
backupQSO->copy(qsoInUI);
backupQSO->setBackup (true);
backupQSO->setModifying (mainQSOEntryWidget->getModifying());
backupQSO->setRealTime (mainQSOEntryWidget->getRealTime());
backupQSO->setManualMode (mainQSOEntryWidget->getManualMode());
backupQSO->setLogId (currentLog);
backupQSO->setKeepComment (commentTabWidget->getKeep ());
backupQSO->setKeepOthers (othersTabWidget->getKeep ());
backupQSO->setKeepMyData (myDataTabWidget->getKeep ());
backupQSO->setKeepSatTab (satTabWidget->getKeep ());
//qDebug() << Q_FUNC_INFO << ": Callsign: " << backupQSO->getCall();
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << " - END" ;
//qDebug() << Q_FUNC_INFO << ": Realtime: " << util->boolToQString (backupQSO->getRealTime ());
}
void MainWindow::restoreCurrentQSO(const bool restoreConfig)
{ // This function restores a QSO that was backed up to the UI.
// MainQSOEntryWidget
//qDebug() << Q_FUNC_INFO << ": " << util->boolToQString (restoreConfig);
clearUIDX();
if (backupQSO->getModifying())
{
mainQSOEntryWidget->setModify(true);
}
//qso = backupQSO;
//qDebug() << Q_FUNC_INFO << " - calling setQRZ-4" ;
mainQSOEntryWidget->setQRZ(backupQSO->getCall ());
mainQSOEntryWidget->setBand(backupQSO->getBand ());
//mainQSOEntryWidget->setMode(backupQSO->getMode ());
mainQSOEntryWidget->setMode(backupQSO->getSubmode());
mainQSOEntryWidget->setDateTime (backupQSO->getDateTimeOn ());
//qDebug() << Q_FUNC_INFO << ": restoring config: " << util->boolToQString (restoreConfig);
if (restoreConfig)
{
mainQSOEntryWidget->setRealTime (backupQSO->getRealTime());
manualMode = backupQSO->getManualMode();
//qDebug() << Q_FUNC_INFO << ": manualMode: " << util->boolToQString (manualMode);
mainQSOEntryWidget->setManualMode (manualMode);
}
// MainWindowInputQSO
QSOTabWidget->setRSTRX (backupQSO->getRSTRX ());
QSOTabWidget->setRSTTX (backupQSO->getRSTTX ());
QSOTabWidget->setTXFreq (backupQSO->getFreqTX ());
QSOTabWidget->setRXFreq (backupQSO->getFreqRX ());
QSOTabWidget->setDXLocator (backupQSO->getGridSquare ());
QSOTabWidget->setName (backupQSO->getName ());
QSOTabWidget->setQTH (backupQSO->getQTH ());
QSOTabWidget->setRXPwr (backupQSO->getRXPwr ());
// MainWindowInputQSL
QSLTabWidget->setQSLSenStatus (backupQSO->getQSL_SENT ());
QSLTabWidget->setQSLRecStatus (backupQSO->getQSL_RCVD ());
QSLTabWidget->setQSLRecDate (backupQSO->getQSLRDate ());
QSLTabWidget->setQSLSenDate (backupQSO->getQSLSDate ());
QSLTabWidget->setQSLSenVia (backupQSO->getQSLSentVia());
QSLTabWidget->setQSLRecVia (backupQSO->getQSLRecVia());
QSLTabWidget->setQSLVia (backupQSO->getQSLVia ());
QSLTabWidget->setQSLMsg (backupQSO->getQSLMsg ());
// MainWindowInputEQSL
eQSLTabWidget->setClubLogStatus (backupQSO->getClubLogStatus ());
eQSLTabWidget->setClubLogDate (backupQSO->getClubLogDate ());
eQSLTabWidget->setEQSLSenStatus (backupQSO->getEQSLQSL_SENT ());
eQSLTabWidget->setEQSLSenDate (backupQSO->getEQSLQSLSDate ());
eQSLTabWidget->setEQSLRecStatus (backupQSO->getEQSLQSL_RCVD ());
eQSLTabWidget->setEQSLRecDate (backupQSO->getEQSLQSLRDate ());
eQSLTabWidget->setLOTWSenStatus (backupQSO->getLoTWQSL_SENT ());
eQSLTabWidget->setLOTWSenDate (backupQSO->getLoTWQSLSDate ());
eQSLTabWidget->setLOTWRecStatus (backupQSO->getLoTWQSL_RCVD ());
eQSLTabWidget->setLOTWRecDate (backupQSO->getLoTWQSLRDate ());
eQSLTabWidget->setQRZCOMStatus (backupQSO->getQRZCOMStatus ());
eQSLTabWidget->setQRZCOMDate (backupQSO->getQRZCOMDate ());
// MainWindowInputComment
commentTabWidget->setData (backupQSO->getComment ());
commentTabWidget->setKeep (backupQSO->getKeepComment ());
// MainWindowInputOthers
othersTabWidget->setVUCCGrids (backupQSO->getVUCCGrids ());
othersTabWidget->setSOTA (backupQSO->getSOTA_REF ());
othersTabWidget->setAge(backupQSO->getAge ());
othersTabWidget->setDistance(backupQSO->getDistance());
othersTabWidget->setPOTA_REF(backupQSO->getPOTA_Ref());
othersTabWidget->setSIG(backupQSO->getSIG());
othersTabWidget->setSIG_INFO(backupQSO->getSIG_INFO());
othersTabWidget->setWWFF_Ref(backupQSO->getWWFF_Ref());
othersTabWidget->setEntity (backupQSO->getDXCC ());
othersTabWidget->setIOTA (backupQSO->getIOTA ());
//qDebug() << Q_FUNC_INFO << ": Restoring propMode";
othersTabWidget->setPropMode (backupQSO->getPropMode ());
//qDebug() << Q_FUNC_INFO << ": Restoring Keep";
othersTabWidget->setKeep (backupQSO->getKeepOthers ());
//qDebug() << Q_FUNC_INFO << ": END";
// MainWindowMyDataTab
if (backupQSO->getLogId () == currentLog)
{
myDataTabWidget->setStationCallsign (backupQSO->getStationCallsign());
}
else
{
myDataTabWidget->setStationCallsign (stationCallsign);
}
myDataTabWidget->setMyPower (backupQSO->getTXPwr ());
myDataTabWidget->setOperator (backupQSO->getOperatorCallsign());
myDataTabWidget->setMyLocator (backupQSO->getMyGridSquare ());
myDataTabWidget->setKeep (backupQSO->getKeepMyData ());
myDataTabWidget->setMyRig (backupQSO->getMyRig ());
myDataTabWidget->setMyAntenna (backupQSO->getMyAntenna ());
myDataTabWidget->setMySOTA (backupQSO->getMySOTA_REF ());
myDataTabWidget->setMyVUCCGrids (backupQSO->getMyVUCCGrids ());
myDataTabWidget->setMyPota_ref(backupQSO->getMyPOTA_Ref());
myDataTabWidget->setMySig(backupQSO->getMySig());
myDataTabWidget->setMySig_info(backupQSO->getMySigInfo());
myDataTabWidget->setMyWWFF_Ref(backupQSO->getMyWWFF_Ref());
//MainWindowSatTab
satTabWidget->setSatName (backupQSO->getSatName ());
satTabWidget->setSatMode (backupQSO->getSatMode ());
satTabWidget->setKeep (backupQSO->getKeepSatTab ());
backupQSO->setBackup (false);
backupQSO->clear();
//qDebug() << Q_FUNC_INFO << " - END";
}
void MainWindow::setLogLevel(const DebugLogLevel _sev)
{
//qDebug() << Q_FUNC_INFO << ": " << util->debugLevelToString(_sev);
logEvent(Q_FUNC_INFO, "Start", Debug);
logLevel = _sev;
showKLogLogWidget->setLogLevel(logLevel);
//setupDialog->setLogLevel(logLevel);
QSettings settings(util->getCfgFile (), QSettings::IniFormat);
settings.beginGroup ("Misc");
settings.setValue ("DebugLog",util->debugLevelToString (logLevel));
settings.endGroup ();
tipsDialog->setLogLevel(logLevel);
dataProxy->setLogLevel(logLevel);
mainQSOEntryWidget->setLogLevel(logLevel);
util->setLogLevel(logLevel);
qsoInUI.setLogLevel(logLevel);
othersTabWidget->setLogLevel(logLevel);
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::slotTakeOverFocusToQSOTabWidget()
{
//qDebug() << Q_FUNC_INFO;
dxUpLeftTab->setCurrentIndex (0);
QSOTabWidget->raise ();
QSOTabWidget->setFocus ();
}
void MainWindow::slotTakeOverFocusToMainQSOInput()
{
//qDebug() << Q_FUNC_INFO;
mainQSOEntryWidget->raise();
mainQSOEntryWidget->setFocus ();
mainQSOEntryWidget->setFocusToOK ();
}
void MainWindow::slotCaptureDebugLogs(const QString &_func, const QString &_msg, DebugLogLevel _level)
{
//qDebug() << Q_FUNC_INFO << _func << "/" << _msg << "/" << QString::number(_level);
logEvent(_func, _msg, _level);
}
void MainWindow::slotNewLogLevel(DebugLogLevel l)
{
//qDebug() << Q_FUNC_INFO;
setLogLevel(l);
QSettings settings(util->getCfgFile (), QSettings::IniFormat);
settings.beginGroup ("Misc");
settings.setValue ("DebugLog", util->debugLevelToString(l));
settings.endGroup ();
}
bool MainWindow::loadSettings()
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << " - Start";
QSettings settings(util->getCfgFile (), QSettings::IniFormat);
//qDebug() << Q_FUNC_INFO << " - 10 - General";
QString value = settings.value ("Version").toString ();
if (softwareVersion!=value)
{
//qDebug() << Q_FUNC_INFO << " - It seems it is a new version ";
//qDebug() << Q_FUNC_INFO << QString("softwareversion: %1 / version: %2").arg(softwareVersion).arg(value);
itIsANewversion = true;
}
currentLog = settings.value ("SelectedLog").toInt();
setWindowSize (settings.value ("MainWindowSize").toSize ());
//qDebug() << Q_FUNC_INFO << " - 20 - user";
settings.beginGroup ("UserData");
value = settings.value ("Callsign").toString ();
//qDebug() << Q_FUNC_INFO << " stationCallSign: " << value;
Callsign callsign(value);
if (callsign.isValid())
{
mainQRZ = value;
}
my_ITUz = 0;
my_CQz = 0;
my_CQz = settings.value ("CQz").toInt ();
my_ITUz = settings.value ("ITUz").toInt ();
// We Select the log after the mainQRZ is defined to prevent call conflicts
selectTheLog(currentLog);
Locator locator;
value = settings.value ("StationLocator").toString ();
if ( locator.isValidLocator(value) )
{
myDataTabWidget->setMyLocator(value.toUpper());
adifLoTWExportWidget->setDefaultMyGrid(value.toUpper());
}
settings.endGroup ();
myDataTabWidget->loadSettings ();
settings.beginGroup ("ClubLog");
clublogSentDefault = settings.value("ClubLogSentDefault", "M").toString();
settings.endGroup ();
settings.beginGroup ("eQSL");
eqslSentDefault = settings.value("eQSLSentDefault", "Q").toString();
settings.endGroup ();
settings.beginGroup ("QRZcom");
qrzcomSentDefault = settings.value("QRZcomSentDefault", "M").toString();
settings.endGroup ();
settings.beginGroup ("LoTW");
lotwSentDefault = settings.value("LoTWSentDefault", "Q").toString();
settings.endGroup ();
eQSLTabWidget->loadSettings();
//qDebug() << Q_FUNC_INFO << " - 30 - modes";
settings.beginGroup ("BandMode");
QStringList listAux;
listAux.clear();
listAux << "SSB" << "CW";
readActiveModes (settings.value("Modes", listAux ).toStringList ());
//qDebug() << Q_FUNC_INFO << " - 31 - bands";
listAux.clear();
listAux << "10M" << "15M" << "20M" << "40M" << "80M" << "160M";
readActiveBands (settings.value("Bands", listAux).toStringList ());
settings.endGroup ();
logWindow->setColumns(settings.value ("LogViewFields").toStringList ());
//qDebug() << Q_FUNC_INFO << " - 41 - logs";
//qDebug() << Q_FUNC_INFO << " - 50 - dxcluster";
settings.beginGroup ("DXCluster");
// Get the server string from settings
QString server = settings.value("DXClusterServerToUse", "dxfun.com:8000").toString();
// Split the server string into host and port
QStringList serverList = server.split(':');
QString host = "dxfun.com";
int port = 8000;
// Check if the server string has both host and port
if (serverList.size() == 2) {
host = serverList.at(0); // Extract host
port = serverList.at(1).toInt(); // Convert port to integer
}
dxClusterWidget->setDXClusterServer(host, port);
dxClusterWidget->setSaveSpots(settings.value ("DXClusterSave", false).toBool ());
dxClusterShowHF = settings.value ("DXClusterShowHF", true).toBool ();
dxClusterShowVHF = settings.value ("DXClusterShowVHF", true).toBool ();
dxClusterShowWARC = settings.value ("DXClusterShowWARC", true).toBool ();
dxClusterShowWorked = settings.value ("DXClusterShowWorked", true).toBool ();
dxClusterShowConfirmed = settings.value ("DXClusterShowConfirmed", true).toBool ();
dxClusterShowAnn = settings.value ("DXClusterShowAnn", true).toBool ();
dxClusterShowWWV = settings.value ("DXClusterShowWWV", true).toBool ();
dxClusterShowWCY = settings.value ("DXClusterShowWCY", true).toBool ();
dxclusterSendSpotsToMap = settings.value ("DXClusterSendToMap", true).toBool ();
dxClusterWidget->loadSettings ();
settings.endGroup ();
//qDebug() << Q_FUNC_INFO << " - 60 - colors";
settings.beginGroup ("Colors");
newOneColor = settings.value("NewOneColor").value<QColor>();
neededColor = settings.value("NeededColor").value<QColor>();
workedColor = settings.value("WorkedColor").value<QColor>();
confirmedColor = settings.value("ConfirmedColor").value<QColor>();
defaultColor = settings.value("DefaultColor").value<QColor>();
bool darkMode = settings.value("DarkMode", false).toBool ();
//qDebug() << Q_FUNC_INFO << " - NewOneColor: " << newOneColor.name(QColor::HexRgb);
//qDebug() << Q_FUNC_INFO << " - NewOneColor: " << newOneColor.name();
//qDebug() << Q_FUNC_INFO << " - NeededColor: " << neededColor.name(QColor::HexRgb);
//qDebug() << Q_FUNC_INFO << " - WorkedColor: " << workedColor.name(QColor::HexRgb);
//qDebug() << Q_FUNC_INFO << " - ConfirmedColor: " << confirmedColor.name(QColor::HexRgb);
//qDebug() << Q_FUNC_INFO << " - DefaultColor: " << defaultColor.name(QColor::HexRgb);
settings.endGroup ();
setColors(newOneColor, neededColor, workedColor, confirmedColor, defaultColor);
setupDialog->loadDarkMode ();
setDarkMode(darkMode);
//qDebug() << Q_FUNC_INFO << " - 70 - misc";
settings.beginGroup ("Misc");
mainQSOEntryWidget->setRealTime (settings.value ("RealTime", true).toBool ());
mainQSOEntryWidget->setShowSeconds (settings.value ("ShowSeconds", false).toBool ());
useDefaultLogFileName = (settings.value ("UseDefaultName", true).toBool ());
imperialSystem = (settings.value ("ImperialSystem", false).toBool ());
sendQSLWhenRec = (settings.value ("SendQSLWhenRec", true).toBool ());
manageDxMarathon = (settings.value ("ManageDXMarathon", false).toBool ());
awardsWidget->setManageDXMarathon (manageDxMarathon);
searchWidget->setShowCallInSearch(settings.value ("ShowCallsignInSearch", true).toBool ());
checkNewVersions = settings.value ("CheckNewVersions", true).toBool ();
reportInfo = false;
alwaysADIF = settings.value ("AlwaysADIF", true).toBool ();
setLogLevel(util->stringToDebugLevel(settings.value ("DebugLog").toString ()));
mainQSOEntryWidget->setUTC(settings.value ("UTCTime", true).toBool ());
dupeSlotInSeconds = settings.value ("DuplicatedQSOSlot", 300).toInt ();
filemanager->setDuplicatedQSOSlot(dupeSlotInSeconds);
mainQSOEntryWidget->setDuplicatedQSOSlot(dupeSlotInSeconds);
completeWithPrevious = settings.value ("CompleteWithPrevious", true).toBool ();
defaultADIFLogFile = settings.value ("DefaultADIFFile").toString ();
deleteAlwaysAdiFile = settings.value ("DeleteAlwaysAdiFile", true).toBool ();
//util->setCallValidation(settings.value ("CheckValidCalls", true).toBool ());
//mainQSOEntryWidget->setCallValidation(settings.value ("CheckValidCalls", true).toBool ());
//filemanager->setCallValidation(settings.value ("CheckValidCalls", true).toBool ());
//adifLoTWExportWidget->setCallValidation(settings.value ("CheckValidCalls", true).toBool ());
settings.endGroup ();
//qDebug() << Q_FUNC_INFO << " - 90 - elog";
settings.beginGroup ("ClubLog");
clublogActive = settings.value ("ClubLogActive", false).toBool ();
//setupDialog->setClubLogActive(clublogActive);
clublogRealTime = settings.value ("ClubLogRealTime", false).toBool ();
settings.endGroup ();
elogClublog->loadSettings ();
settings.beginGroup ("QRZcom");
qrzcomActive = settings.value ("QRZcomActive", false).toBool ();
//setupDialog->setQRZCOMAutoCheckActive(QRZCOMAutoCheckAct->isChecked());
qrzcomSubscriber = settings.value ("QRZcomSubscriber", false).toBool ();
elogQRZcom->setSubcription (qrzcomSubscriber);
QRZCOMAutoCheckAct->setChecked(settings.value ("QRZcomSubscriber", false).toBool ());
//setupDialog->setQRZCOMAutoCheckActive(settings.value ("QRZcomSubscriber", false).toBool ());
elogQRZcom->setUser (settings.value ("QRZcomUser").toString ());
elogQRZcom->setPassword (settings.value ("QRZcomPass").toString ());
elogQRZcom->setLogBookKey(settings.value ("QRZcomLogBookKey").toString ());
settings.endGroup ();
settings.beginGroup ("eQSL");
eQSLActive = settings.value ("eQSLActive", false).toBool ();
eqslUtilities->setUser(settings.value ("eQSLCall").toString ());
eqslUtilities->setPass(settings.value ("eQSLPass").toString ());
settings.endGroup ();
settings.beginGroup ("LoTW");
lotwActive = settings.value ("LoTWActive", false).toBool ();
lotwTQSLpath = settings.value ("LoTWPath").toString ();
lotwUtilities->setUser(settings.value ("LoTWUser").toString ());
lotwUtilities->setPass(settings.value ("LoTWPass").toString ());
settings.endGroup ();
//qDebug() << Q_FUNC_INFO << " - 50 - UDPServer";
UDPLogServer->loadSettings ();
settings.beginGroup ("UDPServer");
UDPServerStart = settings.value ("UDPServer", false).toBool ();
//qDebug() << Q_FUNC_INFO << "UDPServer = " << util->boolToQString (UDPServerStart);
//UDPLogServer->setNetworkInterface(settings.value ("UDPNetworkInterface").toString ());
//UDPLogServer->setPort(settings.value ("UDPServerPort", 2237).toInt ());
infoTimeout = settings.value ("InfoTimeOut", 2000).toInt ();
//UDPLogServer->setLogging(settings.value ("LogFromWSJTX", false).toBool ());
//UDPLogServer->setRealTimeUpdate(settings.value ("RealTimeFromWSJTX", false).toBool ());
wsjtxAutoLog = settings.value ("LogAutoFromWSJTX", false).toBool ();
settings.endGroup ();
//qDebug() << Q_FUNC_INFO << " - 110 - Sats";
//qDebug() << Q_FUNC_INFO << " - 120 - HamLib";
settings.beginGroup ("HamLib");
hamlibActive = settings.value ("HamlibActive").toBool ();
settings.endGroup ();
hamlib->loadSettings();
logEvent(Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << " - END";
return true;
}
void MainWindow::setDarkMode(const bool _dm)
{
othersTabWidget->setDarkMode(_dm);
QSOTabWidget->setDarkMode(_dm);
myDataTabWidget->setDarkMode(_dm);
}
void MainWindow::slotDarkModeChanged(const bool _dm)
{
setDarkMode(_dm);
}
void MainWindow::selectTheLog(const int _i)
{
//qDebug() << Q_FUNC_INFO;
currentLog = _i;
if (!dataProxy->doesThisLogExist(currentLog))
{
int _howManyQSOMax = -1; // NUmber of QSO of the log with more QSO
int _howManyQSOMaxT = 0; // Number of QSO in ine specific log
int _logWithMoreQSOs = -1;
QStringList logs = QStringList();
logs << dataProxy->getListOfManagedLogs();
for (int i = 0;i<logs.length();i++)
{
_howManyQSOMaxT = dataProxy->getHowManyQSOInLog(i);
if (_howManyQSOMax < _howManyQSOMaxT)
{
_howManyQSOMax = _howManyQSOMaxT;
_logWithMoreQSOs = (logs.at(i)).toInt();
}
}
if (_logWithMoreQSOs>0)
{
currentLog = _logWithMoreQSOs;
QSettings settings(util->getCfgFile (), QSettings::IniFormat);
settings.setValue ("SelectedLog", currentLog);
}
else
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
QString aux = tr("It seems that there are no QSOs in the database.") + "\n\n" + tr("If you are sure that the database contains QSOs and KLog is not able to find them, please contact the developers (see About KLog) for help.");
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Ok:
break;
default:
// should never be reached
break;
}
}
}
defineStationCallsign ();
dxClusterWidget->setCurrentLog(currentLog);
dxccStatusWidget->setCurrentLog(currentLog);
}
void MainWindow::logEvent(const QString &_func, const QString &_msg, DebugLogLevel _level)
{ //This function is the only one not logging the activity
//qDebug() << Q_FUNC_INFO << "_level: " << _func << "/" << _msg << "/" << util->debugLevelToString(_level);
//qDebug() << Q_FUNC_INFO << "upAndRunning: " << util->boolToQString(upAndRunning);
showKLogLogWidget->add(_func, _msg, _level);
return;
if (!upAndRunning)
{
showKLogLogWidget->add(_func, _msg, None);
return;
}
if (logLevel<=_level)
showKLogLogWidget->add(_func, _msg, _level);
}
|