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
|
/*
KNode, the KDE newsreader
Copyright (c) 2003 Zack Rusin <zack@kde.org>
Copyright (c) 2004-2005 Volker Krause <volker.krause@rwth-aachen.de>
This program 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 2 of the License, or
(at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
*/
#include "knmainwidget.h"
#include <tqhbox.h>
#include <tqlayout.h>
#include <tdetoolbar.h>
#include <kinputdialog.h>
#include <tdeaccel.h>
#include <kxmlguiclient.h>
#include <tdeconfig.h>
#include <tdemessagebox.h>
#include <kedittoolbar.h>
#include <kstdaction.h>
#include <kdebug.h>
#include <tdemenubar.h>
#include <kiconloader.h>
#include <kstatusbar.h>
#include <tdelocale.h>
#include <tdeapplication.h>
#include "broadcaststatus.h"
#include "krsqueezedtextlabel.h"
#include "recentaddresses.h"
using KPIM::BroadcastStatus;
using TDERecentAddress::RecentAddresses;
//GUI
#include "knmainwidget.h"
#include "knarticlewindow.h"
#include "kncollectionview.h"
#include "kncollectionviewitem.h"
#include "knhdrviewitem.h"
//Core
#include "articlewidget.h"
#include "knglobals.h"
#include "knconfigmanager.h"
#include "knarticlemanager.h"
#include "knarticlefactory.h"
#include "kngroupmanager.h"
#include "knnntpaccount.h"
#include "knaccountmanager.h"
#include "knnetaccess.h"
#include "knfiltermanager.h"
#include "knfoldermanager.h"
#include "knfolder.h"
#include "kncleanup.h"
#include "utilities.h"
#include "knscoring.h"
#include <kpgp.h>
#include "knmemorymanager.h"
#include <tdecmdlineargs.h>
#include <tdelistviewsearchline.h>
using namespace KNode;
KNGlobals knGlobals;
KNMainWidget::KNMainWidget( KXMLGUIClient* client, bool detachable, TQWidget* parent,
const char* name )
: DCOPObject("KNodeIface"), KDockArea( parent, name ),
b_lockui( false ), m_GUIClient( client )
{
knGlobals.top=this;
knGlobals.guiClient=client;
knGlobals.topWidget=this;
//------------------------------- <CONFIG> ----------------------------------
c_fgManager = knGlobals.configManager();
//------------------------------- </CONFIG> ----------------------------------
//-------------------------------- <GUI> ------------------------------------
TQAccel *accel = new TQAccel( this );
iniStatusBar();
//setup splitter behavior
manager()->setSplitterHighResolution(true);
manager()->setSplitterOpaqueResize(true);
//article view
a_rtDock = createDockWidget("article_viewer", SmallIcon("contents"), 0,
kapp->makeStdCaption(i18n("Article Viewer")), i18n("Article Viewer"));
if (!detachable) {
a_rtDock->setEnableDocking(KDockWidget::DockFullSite);
}
KDockWidgetHeader *header = new KDockWidgetHeader(a_rtDock, "artDockHeader");
a_rtDock->setHeader(header);
mArticleViewer = new ArticleWidget( a_rtDock, knGlobals.guiClient, actionCollection(), "articleViewer");
header->setDragPanel( new KNDockWidgetHeaderDrag( mArticleViewer, header, a_rtDock ) );
knGlobals.artWidget = mArticleViewer;
a_rtDock->setWidget( mArticleViewer );
//setView(a_rtDock);
setMainDockWidget(a_rtDock);
connect(a_rtDock, TQ_SIGNAL(iMBeingClosed()), TQ_SLOT(slotArticleDockHidden()));
connect(a_rtDock, TQ_SIGNAL(hasUndocked()), TQ_SLOT(slotArticleDockHidden()));
connect( mArticleViewer, TQ_SIGNAL(focusChangeRequest(TQWidget*)), TQ_SLOT(slotDockWidgetFocusChangeRequest(TQWidget*)) );
//collection view
c_olDock = createDockWidget("group_view", UserIcon("group"), 0,
kapp->makeStdCaption(i18n("Group View")), i18n("Group View"));
if (!detachable) {
c_olDock->setEnableDocking(KDockWidget::DockFullSite);
}
header = new KDockWidgetHeader(c_olDock, "colDockHeader");
c_olDock->setHeader(header);
c_olView = new KNCollectionView(this, "collectionView");
header->setDragPanel(new KNDockWidgetHeaderDrag(c_olView, header, c_olDock));
c_olDock->setWidget(c_olView);
c_olDock->manualDock(a_rtDock, KDockWidget::DockLeft, 3000);
connect(c_olDock, TQ_SIGNAL(iMBeingClosed()), TQ_SLOT(slotGroupDockHidden()));
connect(c_olDock, TQ_SIGNAL(hasUndocked()), TQ_SLOT(slotGroupDockHidden()));
connect(c_olView, TQ_SIGNAL(focusChangeRequest(TQWidget *)), TQ_SLOT(slotDockWidgetFocusChangeRequest(TQWidget *)));
connect(c_olView, TQ_SIGNAL(selectionChanged(TQListViewItem*)),
TQ_SLOT(slotCollectionSelected(TQListViewItem*)));
connect(c_olView, TQ_SIGNAL(contextMenu(TDEListView*, TQListViewItem*, const TQPoint&)),
TQ_SLOT(slotCollectionRMB(TDEListView*, TQListViewItem*, const TQPoint&)));
connect(c_olView, TQ_SIGNAL(folderDrop(TQDropEvent*, KNCollectionViewItem*)),
TQ_SLOT(slotCollectionViewDrop(TQDropEvent*, KNCollectionViewItem*)));
connect(c_olView, TQ_SIGNAL(itemRenamed(TQListViewItem*)),
TQ_SLOT(slotCollectionRenamed(TQListViewItem*)));
accel->connectItem( accel->insertItem(Key_Up), mArticleViewer, TQ_SLOT(scrollUp()) );
accel->connectItem( accel->insertItem(Key_Down), mArticleViewer, TQ_SLOT(scrollDown()) );
accel->connectItem( accel->insertItem(Key_Prior), mArticleViewer, TQ_SLOT(scrollPrior()) );
accel->connectItem( accel->insertItem(Key_Next), mArticleViewer, TQ_SLOT(scrollNext()) );
//header view
h_drDock = createDockWidget("header_view", SmallIcon("text_block"), 0,
kapp->makeStdCaption(i18n("Header View")), i18n("Header View"));
if (!detachable) {
h_drDock->setEnableDocking(KDockWidget::DockFullSite);
}
header = new KDockWidgetHeader(h_drDock, "headerDockHeader");
h_drDock->setHeader(header);
TQWidget *dummy = new TQWidget(h_drDock);
TQVBoxLayout *vlay = new TQVBoxLayout(dummy);
h_drView = new KNHeaderView( dummy, "hdrView" );
header->setDragPanel(new KNDockWidgetHeaderDrag(h_drView, header, h_drDock));
h_drDock->setWidget(dummy);
h_drDock->manualDock(a_rtDock, KDockWidget::DockTop, 5000);
q_uicksearch = new TDEToolBar(dummy, "search toolbar");
TDEAction *resetQuickSearch = new TDEAction( i18n( "Reset Quick Search" ),
TQApplication::reverseLayout()
? "clear_left"
: "locationbar_erase",
0, actionCollection(),
"reset_quicksearch" );
resetQuickSearch->plug( q_uicksearch );
resetQuickSearch->setWhatsThis( i18n( "<b>Reset Quick Search</b><br>"
"Resets the quick search so that "
"all messages are shown again." ) );
TQLabel *lbl = new TQLabel(i18n("&Search:"), q_uicksearch, "tde toolbar widget");
s_earchLineEdit = new TDEListViewSearchLine(q_uicksearch, h_drView, "TDEListViewSearchLine");
q_uicksearch->setStretchableWidget(s_earchLineEdit);
lbl->setBuddy(s_earchLineEdit);
connect( resetQuickSearch, TQ_SIGNAL( activated() ), s_earchLineEdit, TQ_SLOT( clear() ));
vlay->addWidget(q_uicksearch);
vlay->addWidget(h_drView);
connect(h_drDock, TQ_SIGNAL(iMBeingClosed()), TQ_SLOT(slotHeaderDockHidden()));
connect(h_drDock, TQ_SIGNAL(hasUndocked()), TQ_SLOT(slotHeaderDockHidden()));
connect(h_drView, TQ_SIGNAL(focusChangeRequest(TQWidget *)),
TQ_SLOT(slotDockWidgetFocusChangeRequest(TQWidget *)));
connect(h_drView, TQ_SIGNAL(itemSelected(TQListViewItem*)),
TQ_SLOT(slotArticleSelected(TQListViewItem*)));
connect(h_drView, TQ_SIGNAL(selectionChanged()),
TQ_SLOT(slotArticleSelectionChanged()));
connect(h_drView, TQ_SIGNAL(contextMenu(TDEListView*, TQListViewItem*, const TQPoint&)),
TQ_SLOT(slotArticleRMB(TDEListView*, TQListViewItem*, const TQPoint&)));
connect(h_drView, TQ_SIGNAL(doubleClick(TQListViewItem *)),
TQ_SLOT(slotOpenArticle(TQListViewItem *)));
connect(h_drView, TQ_SIGNAL(sortingChanged(int)),
TQ_SLOT(slotHdrViewSortingChanged(int)));
//actions
initActions();
//-------------------------------- </GUI> ------------------------------------
//-------------------------------- <CORE> ------------------------------------
//Network
n_etAccess = knGlobals.netAccess();
connect(n_etAccess, TQ_SIGNAL(netActive(bool)), this, TQ_SLOT(slotNetworkActive(bool)));
//Filter Manager
f_ilManager = knGlobals.filterManager();
f_ilManager->setMenuAction(a_ctArtFilter, a_ctArtFilterKeyb);
//Article Manager
a_rtManager = knGlobals.articleManager();
a_rtManager->setView(h_drView);
//Group Manager
g_rpManager = knGlobals.groupManager();
//Folder Manager
f_olManager = knGlobals.folderManager();
//Account Manager
a_ccManager = knGlobals.accountManager();
//Article Factory
a_rtFactory=new KNArticleFactory();
knGlobals.artFactory=a_rtFactory;
// Score Manager
s_coreManager = knGlobals.scoringManager();
//connect(s_coreManager, TQ_SIGNAL(changedRules()), TQ_SLOT(slotReScore()));
connect(s_coreManager, TQ_SIGNAL(finishedEditing()), TQ_SLOT(slotReScore()));
// Memory Manager
m_emManager = knGlobals.memoryManager();
// create a global pgp instance
p_gp = new Kpgp::Module();
knGlobals.pgp = p_gp;
//-------------------------------- </CORE> -----------------------------------
//apply saved options
readOptions();
//apply configuration
configChanged();
// set the keyboard focus indicator on the first item in the Collection View
if( c_olView->firstChild() ) {
TQListViewItem *i = c_olView->firstChild();
bool open = i->isOpen();
c_olView->setActive( i );
i->setOpen( open );
}
c_olView->setFocus();
setStatusMsg();
if( firstStart() ) { // open the config dialog on the first start
show(); // the settings dialog must appear in front of the main window!
slotSettings();
}
}
KNMainWidget::~KNMainWidget()
{
delete a_ccel;
h_drView->clear(); //avoid some random crashes in KNHdrViewItem::~KNHdrViewItem()
delete n_etAccess;
kdDebug(5003) << "KNMainWidget::~KNMainWidget() : Net deleted" << endl;
delete a_rtManager;
kdDebug(5003) << "KNMainWidget::~KNMainWidget() : Article Manager deleted" << endl;
delete a_rtFactory;
kdDebug(5003) << "KNMainWidget::~KNMainWidget() : Article Factory deleted" << endl;
delete g_rpManager;
kdDebug(5003) << "KNMainWidget::~KNMainWidget() : Group Manager deleted" << endl;
delete f_olManager;
kdDebug(5003) << "KNMainWidget::~KNMainWidget() : Folder Manager deleted" << endl;
delete f_ilManager;
kdDebug(5003) << "KNMainWidget::~KNMainWidget() : Filter Manager deleted" << endl;
delete a_ccManager;
kdDebug(5003) << "KNMainWidget::~KNMainWidget() : Account Manager deleted" << endl;
delete c_fgManager;
kdDebug(5003) << "KNMainWidget::~KNMainWidget() : Config deleted" << endl;
delete m_emManager;
kdDebug(5003) << "KNMainWidget::~KNMainWidget() : Memory Manager deleted" << endl;
delete p_gp;
kdDebug(5003) << "KNMainWidget::~KNMainWidget() : PGP deleted" << endl;
delete c_olDock;
delete h_drDock;
delete a_rtDock;
}
void KNMainWidget::iniStatusBar()
{
//statusbar
TDEMainWindow *mainWin = dynamic_cast<TDEMainWindow*>(topLevelWidget());
KStatusBar *sb = mainWin ? mainWin->statusBar() : 0;
s_tatusFilter = new KRSqueezedTextLabel( TQString(), sb );
s_tatusFilter->setAlignment( AlignLeft | AlignVCenter );
s_tatusGroup = new KRSqueezedTextLabel( TQString(), sb );
s_tatusGroup->setAlignment( AlignLeft | AlignVCenter );
}
//================================== GUI =================================
void KNMainWidget::setStatusMsg(const TQString& text, int id)
{
TDEMainWindow *mainWin = dynamic_cast<TDEMainWindow*>(topLevelWidget());
KStatusBar *bar = mainWin ? mainWin->statusBar() : 0;
if ( !bar )
return;
bar->clear();
if (text.isEmpty() && (id==SB_MAIN)) {
if (knGlobals.netAccess()->currentMsg().isEmpty())
BroadcastStatus::instance()->setStatusMsg(i18n(" Ready"));
else
BroadcastStatus::instance()->setStatusMsg(knGlobals.netAccess()->currentMsg());
} else {
switch(id) {
case SB_MAIN:
BroadcastStatus::instance()->setStatusMsg(text); break;
case SB_GROUP:
s_tatusGroup->setText(text); break;
case SB_FILTER:
s_tatusFilter->setText(text); break;
}
}
}
void KNMainWidget::setStatusHelpMsg(const TQString& text)
{
TDEMainWindow *mainWin = dynamic_cast<TDEMainWindow*>(topLevelWidget());
KStatusBar *bar = mainWin ? mainWin->statusBar() : 0;
if ( bar )
bar->message(text, 2000);
}
void KNMainWidget::updateCaption()
{
TQString newCaption=i18n("TDE News Reader");
if (g_rpManager->currentGroup()) {
newCaption = g_rpManager->currentGroup()->name();
if (g_rpManager->currentGroup()->status()==KNGroup::moderated)
newCaption += i18n(" (moderated)");
} else if (a_ccManager->currentAccount()) {
newCaption = a_ccManager->currentAccount()->name();
} else if (f_olManager->currentFolder()) {
newCaption = f_olManager->currentFolder()->name();
}
emit signalCaptionChangeRequest(newCaption);
}
void KNMainWidget::setCursorBusy(bool b)
{
if(b) TDEApplication::setOverrideCursor(waitCursor);
else TDEApplication::restoreOverrideCursor();
}
void KNMainWidget::blockUI(bool b)
{
b_lockui = b;
TDEMainWindow *mainWin = dynamic_cast<TDEMainWindow*>(topLevelWidget());
KMenuBar *mbar = mainWin ? mainWin->menuBar() : 0;
if ( mbar )
mbar->setEnabled(!b);
a_ccel->setEnabled(!b);
TDEAccel *naccel = mainWin ? mainWin->accel() : 0;
if ( naccel )
naccel->setEnabled(!b);
if (b)
installEventFilter(this);
else
removeEventFilter(this);
setCursorBusy(b);
}
void KNMainWidget::disableAccels(bool b)
{
a_ccel->setEnabled(!b);
TDEMainWindow *mainWin = dynamic_cast<TDEMainWindow*>(topLevelWidget());
TDEAccel *naccel = mainWin ? mainWin->accel() : 0;
if ( naccel )
naccel->setEnabled(!b);
if (b)
installEventFilter(this);
else
removeEventFilter(this);
}
// processEvents with some blocking
void KNMainWidget::secureProcessEvents()
{
b_lockui = true;
TDEMainWindow *mainWin = dynamic_cast<TDEMainWindow*>(topLevelWidget());
KMenuBar *mbar = mainWin ? mainWin->menuBar() : 0;
if ( mbar )
mbar->setEnabled(false);
a_ccel->setEnabled(false);
TDEAccel *naccel = mainWin ? mainWin->accel() : 0;
if ( naccel )
naccel->setEnabled(false);
installEventFilter(this);
kapp->processEvents();
b_lockui = false;
if ( mbar )
mbar->setEnabled(true);
a_ccel->setEnabled(true);
if ( naccel )
naccel->setEnabled(true);
removeEventFilter(this);
}
TQSize KNMainWidget::sizeHint() const
{
return TQSize(759,478); // default optimized for 800x600
}
void KNMainWidget::openURL(const KURL &url)
{
kdDebug(5003) << k_funcinfo << url << endl;
TQString host = url.host();
unsigned short int port = url.port();
KNNntpAccount *acc=0;
if (url.url().left(7) == "news://") {
// lets see if we already have an account for this host...
TQValueList<KNNntpAccount*>::Iterator it;
for ( it = a_ccManager->begin(); it != a_ccManager->end(); ++it ) {
if ( (*it)->server().lower() == host.lower() && ( port==0 || (*it)->port() == port ) ) {
acc = *it;
break;
}
}
if(!acc) {
acc=new KNNntpAccount();
acc->setName(host);
acc->setServer(host);
if(port!=0)
acc->setPort(port);
if(url.hasUser() && url.hasPass()) {
acc->setNeedsLogon(true);
acc->setUser(url.user());
acc->setPass(url.pass());
}
if(!a_ccManager->newAccount(acc))
return;
}
} else {
if (url.url().left(5) == "news:") {
// TODO: make the default server configurable
acc = a_ccManager->currentAccount();
if ( acc == 0 )
acc = a_ccManager->first();
} else {
kdDebug(5003) << "KNMainWidget::openURL() URL is not a valid news URL" << endl;
}
}
if (acc) {
bool isMID=(url.url().contains('@')==1);
if (!isMID) {
TQString groupname=url.path(-1);
while(groupname.startsWith("/"))
groupname.remove(0,1);
TQListViewItem *item=0;
if(groupname.isEmpty())
item=acc->listItem();
else {
KNGroup *grp= g_rpManager->group(groupname, acc);
if(!grp) {
KNGroupInfo inf(groupname, "");
g_rpManager->subscribeGroup(&inf, acc);
grp=g_rpManager->group(groupname, acc);
if(grp)
item=grp->listItem();
}
else
item=grp->listItem();
}
if (item) {
c_olView->ensureItemVisible(item);
c_olView->setActive( item );
}
} else {
TQString groupname = url.url().mid( url.protocol().length()+1 );
KNGroup *g = g_rpManager->currentGroup();
if (g == 0)
g = g_rpManager->firstGroupOfAccount(acc);
if (g) {
if(!KNArticleWindow::raiseWindowForArticle(groupname.latin1())) { //article not yet opened
KNRemoteArticle *a=new KNRemoteArticle(g);
TQString messageID = "<"+groupname+">";
a->messageID()->from7BitString(messageID.latin1());
KNArticleWindow *awin=new KNArticleWindow(a);
awin->show();
}
} else {
// TODO: fetch without group
kdDebug(5003) << "KNMainWidget::openURL() account has no groups" << endl;
}
}
}
}
// update fonts and colors
void KNMainWidget::configChanged()
{
h_drView->readConfig();
c_olView->readConfig();
a_rtManager->updateListViewItems();
}
void KNMainWidget::initActions()
{
a_ccel=new TDEAccel(this);
mArticleViewer->setCharsetKeyboardAction()->plugAccel(a_ccel);
//navigation
a_ctNavNextArt = new TDEAction( KGuiItem(i18n("&Next Article"), "go-next",
i18n("Go to next article")), "N;Right", h_drView,
TQ_SLOT(nextArticle()), actionCollection(), "go_nextArticle" );
a_ctNavPrevArt = new TDEAction( KGuiItem(i18n("&Previous Article"), "go-previous",
i18n("Go to previous article")), "P;Left" , h_drView,
TQ_SLOT(prevArticle()), actionCollection(), "go_prevArticle" );
a_ctNavNextUnreadArt = new TDEAction(i18n("Next Unread &Article"), "1rightarrow", ALT+SHIFT+Key_Space , this,
TQ_SLOT(slotNavNextUnreadArt()), actionCollection(), "go_nextUnreadArticle");
a_ctNavNextUnreadThread = new TDEAction(i18n("Next Unread &Thread"),"2rightarrow", SHIFT+Key_Space , this,
TQ_SLOT(slotNavNextUnreadThread()), actionCollection(), "go_nextUnreadThread");
a_ctNavNextGroup = new TDEAction(i18n("Ne&xt Group"), "go-down", Key_Plus , c_olView,
TQ_SLOT(nextGroup()), actionCollection(), "go_nextGroup");
a_ctNavPrevGroup = new TDEAction(i18n("Pre&vious Group"), "go-up", Key_Minus , c_olView,
TQ_SLOT(prevGroup()), actionCollection(), "go_prevGroup");
a_ctNavReadThrough = new TDEAction(i18n("Read &Through Articles"), Key_Space , this,
TQ_SLOT(slotNavReadThrough()), actionCollection(), "go_readThrough");
a_ctNavReadThrough->plugAccel(a_ccel);
TQAccel *accel = new TQAccel( this );
new TDEAction( i18n("Focus on Next Folder"), CTRL+Key_Right, c_olView,
TQ_SLOT(incCurrentFolder()), actionCollection(), "inc_current_folder" );
accel->connectItem(accel->insertItem(CTRL+Key_Right),
c_olView, TQ_SLOT(incCurrentFolder()));
new TDEAction( i18n("Focus on Previous Folder"), CTRL+Key_Left, c_olView,
TQ_SLOT(decCurrentFolder()), actionCollection(), "dec_current_folder" );
accel->connectItem(accel->insertItem(CTRL+Key_Left),
c_olView, TQ_SLOT(decCurrentFolder()));
new TDEAction( i18n("Select Folder with Focus"), CTRL+Key_Space, c_olView,
TQ_SLOT(selectCurrentFolder()), actionCollection(), "select_current_folder" );
accel->connectItem(accel->insertItem(CTRL+Key_Space),
c_olView, TQ_SLOT(selectCurrentFolder()));
new TDEAction( i18n("Focus on Next Article"), ALT+Key_Right, h_drView,
TQ_SLOT(incCurrentArticle()), actionCollection(), "inc_current_article" );
accel->connectItem( accel->insertItem(ALT+Key_Right),
h_drView, TQ_SLOT(incCurrentArticle()) );
new TDEAction( i18n("Focus on Previous Article"), ALT+Key_Left, h_drView,
TQ_SLOT(decCurrentArticle()), actionCollection(), "dec_current_article" );
accel->connectItem( accel->insertItem(ALT+Key_Left),
h_drView, TQ_SLOT(decCurrentArticle()) );
new TDEAction( i18n("Select Article with Focus"), ALT+Key_Space, h_drView,
TQ_SLOT(selectCurrentArticle()), actionCollection(), "select_current_article" );
accel->connectItem( accel->insertItem(ALT+Key_Space),
h_drView, TQ_SLOT(selectCurrentArticle()) );
//collection-view - accounts
a_ctAccProperties = new TDEAction(i18n("Account &Properties"), "configure", 0, this,
TQ_SLOT(slotAccProperties()), actionCollection(), "account_properties");
a_ctAccRename = new TDEAction(i18n("&Rename Account"), "text", 0, this,
TQ_SLOT(slotAccRename()), actionCollection(), "account_rename");
a_ctAccSubscribe = new TDEAction(i18n("&Subscribe to Newsgroups..."), "news_subscribe", 0, this,
TQ_SLOT(slotAccSubscribe()), actionCollection(), "account_subscribe");
a_ctAccExpireAll = new TDEAction(i18n("&Expire All Groups"), 0, this,
TQ_SLOT(slotAccExpireAll()), actionCollection(), "account_expire_all");
a_ctAccGetNewHdrs = new TDEAction(i18n("&Get New Articles in All Groups"), "mail_get", 0, this,
TQ_SLOT(slotAccGetNewHdrs()), actionCollection(), "account_dnlHeaders");
a_ctAccGetNewHdrsAll = new TDEAction(i18n("&Get New Articles in All Accounts"), "mail_get_all", 0, this,
TQ_SLOT(slotAccGetNewHdrsAll()), actionCollection(), "account_dnlAllHeaders");
a_ctAccDelete = new TDEAction(i18n("&Delete Account"), "edit-delete", 0, this,
TQ_SLOT(slotAccDelete()), actionCollection(), "account_delete");
a_ctAccPostNewArticle = new TDEAction(i18n("&Post to Newsgroup..."), "mail-message-new", CTRL+Key_N, this,
TQ_SLOT(slotAccPostNewArticle()), actionCollection(), "article_postNew");
//collection-view - groups
a_ctGrpProperties = new TDEAction(i18n("Group &Properties"), "configure", 0, this,
TQ_SLOT(slotGrpProperties()), actionCollection(), "group_properties");
a_ctGrpRename = new TDEAction(i18n("Rename &Group"), "text", 0, this,
TQ_SLOT(slotGrpRename()), actionCollection(), "group_rename");
a_ctGrpGetNewHdrs = new TDEAction(i18n("&Get New Articles"), "mail_get" , 0, this,
TQ_SLOT(slotGrpGetNewHdrs()), actionCollection(), "group_dnlHeaders");
a_ctGrpExpire = new TDEAction(i18n("E&xpire Group"), "wizard", 0, this,
TQ_SLOT(slotGrpExpire()), actionCollection(), "group_expire");
a_ctGrpReorganize = new TDEAction(i18n("Re&organize Group"), 0, this,
TQ_SLOT(slotGrpReorganize()), actionCollection(), "group_reorg");
a_ctGrpUnsubscribe = new TDEAction(i18n("&Unsubscribe From Group"), "news_unsubscribe", 0, this,
TQ_SLOT(slotGrpUnsubscribe()), actionCollection(), "group_unsubscribe");
a_ctGrpSetAllRead = new TDEAction(i18n("Mark All as &Read"), "goto", 0, this,
TQ_SLOT(slotGrpSetAllRead()), actionCollection(), "group_allRead");
a_ctGrpSetAllUnread = new TDEAction(i18n("Mark All as U&nread"), 0, this,
TQ_SLOT(slotGrpSetAllUnread()), actionCollection(), "group_allUnread");
a_ctGrpSetUnread = new TDEAction(i18n("Mark Last as Unr&ead..."), 0, this,
TQ_SLOT(slotGrpSetUnread()), actionCollection(), "group_unread");
(void) new TDEAction( i18n("&Configure KNode..."),
"configure", 0, this,
TQ_SLOT(slotSettings()), actionCollection(),
"knode_configure_knode" );
//collection-view - folder
a_ctFolNew = new TDEAction(i18n("&New Folder"), "folder-new", 0, this,
TQ_SLOT(slotFolNew()), actionCollection(), "folder-new");
a_ctFolNewChild = new TDEAction(i18n("New &Subfolder"), "folder-new", 0, this,
TQ_SLOT(slotFolNewChild()), actionCollection(), "folder_newChild");
a_ctFolDelete = new TDEAction(i18n("&Delete Folder"), "edit-delete", 0, this,
TQ_SLOT(slotFolDelete()), actionCollection(), "folder_delete");
a_ctFolRename = new TDEAction(i18n("&Rename Folder"), "text", 0, this,
TQ_SLOT(slotFolRename()), actionCollection(), "folder_rename");
a_ctFolCompact = new TDEAction(i18n("C&ompact Folder"), "wizard", 0, this,
TQ_SLOT(slotFolCompact()), actionCollection(), "folder_compact");
a_ctFolCompactAll = new TDEAction(i18n("Co&mpact All Folders"), 0, this,
TQ_SLOT(slotFolCompactAll()), actionCollection(), "folder_compact_all");
a_ctFolEmpty = new TDEAction(i18n("&Empty Folder"), 0, this,
TQ_SLOT(slotFolEmpty()), actionCollection(), "folder_empty");
a_ctFolMboxImport = new TDEAction(i18n("&Import MBox Folder..."), 0, this,
TQ_SLOT(slotFolMBoxImport()), actionCollection(), "folder_MboxImport");
a_ctFolMboxExport = new TDEAction(i18n("E&xport as MBox Folder..."), 0, this,
TQ_SLOT(slotFolMBoxExport()), actionCollection(), "folder_MboxExport");
//header-view - list-handling
a_ctArtSortHeaders = new TDESelectAction(i18n("S&ort"), 0, actionCollection(), "view_Sort");
TQStringList items;
items += i18n("By &Subject");
items += i18n("By S&ender");
items += i18n("By S&core");
items += i18n("By &Lines");
items += i18n("By &Date");
a_ctArtSortHeaders->setItems(items);
a_ctArtSortHeaders->setShortcutConfigurable(false);
connect(a_ctArtSortHeaders, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotArtSortHeaders(int)));
a_ctArtSortHeadersKeyb = new TDEAction(i18n("Sort"), TQString(), Key_F7 , this,
TQ_SLOT(slotArtSortHeadersKeyb()), actionCollection(), "view_Sort_Keyb");
a_ctArtSortHeadersKeyb->plugAccel(a_ccel);
a_ctArtFilter = new KNFilterSelectAction(i18n("&Filter"), "filter",
actionCollection(), "view_Filter");
a_ctArtFilter->setShortcutConfigurable(false);
a_ctArtFilterKeyb = new TDEAction(i18n("Filter"), Key_F6, actionCollection(), "view_Filter_Keyb");
a_ctArtFilterKeyb->plugAccel(a_ccel);
a_ctArtSearch = new TDEAction(i18n("&Search Articles..."),"mail_find" , Key_F4 , this,
TQ_SLOT(slotArtSearch()), actionCollection(), "article_search");
a_ctArtRefreshList = new TDEAction(i18n("&Refresh List"),"reload", TDEStdAccel::shortcut(TDEStdAccel::Reload), this,
TQ_SLOT(slotArtRefreshList()), actionCollection(), "view_Refresh");
a_ctArtCollapseAll = new TDEAction(i18n("&Collapse All Threads"), 0 , this,
TQ_SLOT(slotArtCollapseAll()), actionCollection(), "view_CollapseAll");
a_ctArtExpandAll = new TDEAction(i18n("E&xpand All Threads"), 0 , this,
TQ_SLOT(slotArtExpandAll()), actionCollection(), "view_ExpandAll");
a_ctArtToggleThread = new TDEAction(i18n("&Toggle Subthread"), Key_T, this,
TQ_SLOT(slotArtToggleThread()), actionCollection(), "thread_toggle");
a_ctArtToggleShowThreads = new TDEToggleAction(i18n("Show T&hreads"), 0 , this,
TQ_SLOT(slotArtToggleShowThreads()), actionCollection(), "view_showThreads");
a_ctArtToggleShowThreads->setCheckedState(i18n("Hide T&hreads"));
a_ctArtToggleShowThreads->setChecked(c_fgManager->readNewsGeneral()->showThreads());
//header-view - remote articles
a_ctArtSetArtRead = new TDEAction(i18n("Mark as &Read"), Key_D , this,
TQ_SLOT(slotArtSetArtRead()), actionCollection(), "article_read");
a_ctArtSetArtUnread = new TDEAction(i18n("Mar&k as Unread"), Key_U , this,
TQ_SLOT(slotArtSetArtUnread()), actionCollection(), "article_unread");
a_ctArtSetThreadRead = new TDEAction(i18n("Mark &Thread as Read"), CTRL+Key_D , this,
TQ_SLOT(slotArtSetThreadRead()), actionCollection(), "thread_read");
a_ctArtSetThreadUnread = new TDEAction(i18n("Mark T&hread as Unread"), CTRL+Key_U , this,
TQ_SLOT(slotArtSetThreadUnread()), actionCollection(), "thread_unread");
a_ctArtOpenNewWindow = new TDEAction(i18n("Open in Own &Window"), "window-new", Key_O , this,
TQ_SLOT(slotArtOpenNewWindow()), actionCollection(), "article_ownWindow");
// scoring
a_ctScoresEdit = new TDEAction(i18n("&Edit Scoring Rules..."), "edit", CTRL+Key_E, this,
TQ_SLOT(slotScoreEdit()), actionCollection(), "scoreedit");
a_ctReScore = new TDEAction(i18n("Recalculate &Scores"), 0, this,
TQ_SLOT(slotReScore()),actionCollection(),"rescore");
a_ctScoreLower = new TDEAction(i18n("&Lower Score for Author..."), CTRL+Key_L, this,
TQ_SLOT(slotScoreLower()), actionCollection(), "scorelower");
a_ctScoreRaise = new TDEAction(i18n("&Raise Score for Author..."), CTRL+Key_I, this,
TQ_SLOT(slotScoreRaise()),actionCollection(),"scoreraise");
a_ctArtToggleIgnored = new TDEAction(i18n("&Ignore Thread"), "go-bottom", Key_I , this,
TQ_SLOT(slotArtToggleIgnored()), actionCollection(), "thread_ignore");
a_ctArtToggleWatched = new TDEAction(i18n("&Watch Thread"), "go-top", Key_W , this,
TQ_SLOT(slotArtToggleWatched()), actionCollection(), "thread_watch");
//header-view local articles
a_ctArtSendOutbox = new TDEAction(i18n("Sen&d Pending Messages"), "mail-send", 0, this,
TQ_SLOT(slotArtSendOutbox()), actionCollection(), "net_sendPending");
a_ctArtDelete = new TDEAction(i18n("&Delete Article"), "edit-delete", Key_Delete, this,
TQ_SLOT(slotArtDelete()), actionCollection(), "article_delete");
a_ctArtSendNow = new TDEAction(i18n("Send &Now"),"mail-send", 0 , this,
TQ_SLOT(slotArtSendNow()), actionCollection(), "article_sendNow");
a_ctArtEdit = new TDEAction(i18n("edit article","&Edit Article..."), "edit", Key_E , this,
TQ_SLOT(slotArtEdit()), actionCollection(), "article_edit");
//network
a_ctNetCancel = new TDEAction(i18n("Stop &Network"),"process-stop",0, this,
TQ_SLOT(slotNetCancel()), actionCollection(), "net_stop");
a_ctNetCancel->setEnabled(false);
a_ctFetchArticleWithID = new TDEAction(i18n("&Fetch Article with ID..."), 0, this,
TQ_SLOT(slotFetchArticleWithID()), actionCollection(), "fetch_article_with_id");
a_ctFetchArticleWithID->setEnabled(false);
a_ctToggleGroupView = new TDEToggleAction(i18n("Show &Group View"), CTRL+Key_G, this,
TQ_SLOT(slotToggleGroupView()), actionCollection(), "settings_show_groupView");
a_ctToggleGroupView->setCheckedState(i18n("Hide &Group View"));
a_ctToggleHeaderView = new TDEToggleAction(i18n("Show &Header View"), CTRL+Key_H, this,
TQ_SLOT(slotToggleHeaderView()), actionCollection(), "settings_show_headerView");
a_ctToggleHeaderView->setCheckedState(i18n("Hide &Header View"));
a_ctToggleArticleViewer = new TDEToggleAction(i18n("Show &Article Viewer"), CTRL+Key_J, this,
TQ_SLOT(slotToggleArticleViewer()), actionCollection(), "settings_show_articleViewer");
a_ctToggleArticleViewer->setCheckedState(i18n("Hide &Article Viewer"));
a_ctToggleQuickSearch = new TDEToggleAction(i18n("Show Quick Search"), TQString(), this,
TQ_SLOT(slotToggleQuickSearch()), actionCollection(), "settings_show_quickSearch");
a_ctToggleQuickSearch->setCheckedState(i18n("Hide Quick Search"));
a_ctSwitchToGroupView = new TDEAction(i18n("Switch to Group View"), Key_G , this,
TQ_SLOT(slotSwitchToGroupView()), actionCollection(), "switch_to_group_view");
a_ctSwitchToGroupView->plugAccel(a_ccel);
a_ctSwitchToHeaderView = new TDEAction(i18n("Switch to Header View"), Key_H , this,
TQ_SLOT(slotSwitchToHeaderView()), actionCollection(), "switch_to_header_view");
a_ctSwitchToHeaderView->plugAccel(a_ccel);
a_ctSwitchToArticleViewer = new TDEAction(i18n("Switch to Article Viewer"), Key_J , this,
TQ_SLOT(slotSwitchToArticleViewer()), actionCollection(), "switch_to_article_viewer");
a_ctSwitchToArticleViewer->plugAccel(a_ccel);
}
bool KNMainWidget::firstStart()
{
TDEConfig *conf=knGlobals.config();
conf->setGroup("GENERAL");
TQString ver = conf->readEntry("Version");
if(!ver.isEmpty())
return false;
TDEConfig emailConf("emaildefaults");
emailConf.setGroup("Defaults");
TQString group = emailConf.readEntry("Profile","Default");
emailConf.setGroup(TQString("PROFILE_%1").arg(group));
KNConfig::Identity *id=knGlobals.configManager()->identity();
id->setName(emailConf.readEntry("FullName"));
id->setEmail(emailConf.readEntry("EmailAddress").latin1());
id->setOrga(emailConf.readEntry("Organization"));
id->setReplyTo(emailConf.readEntry("ReplyAddr"));
id->save();
KNServerInfo *smtp=knGlobals.accountManager()->smtp();
smtp->setServer(emailConf.readEntry("OutgoingServer").latin1());
smtp->setPort(25);
conf->setGroup("MAILSERVER");
smtp->saveConf(conf);
conf->setGroup("GENERAL");
conf->writeEntry("Version", KNODE_VERSION);
return true;
}
void KNMainWidget::readOptions()
{
TDEConfig *conf=knGlobals.config();
conf->setGroup("APPEARANCE");
if (conf->readBoolEntry("quicksearch", true))
a_ctToggleQuickSearch->setChecked(true);
else
q_uicksearch->hide();
c_olView->readConfig();
h_drView->readConfig();
a_ctArtSortHeaders->setCurrentItem( h_drView->sortColumn() );
resize(787,478); // default optimized for 800x600
//applyMainWindowSettings(TDEGlobal::config(),"mainWindow_options");
// restore dock configuration
manager()->readConfig(knGlobals.config(),"dock_configuration");
}
void KNMainWidget::saveOptions()
{
TDEConfig *conf=knGlobals.config();
conf->setGroup("APPEARANCE");
conf->writeEntry("quicksearch", q_uicksearch->isShown());
//saveMainWindowSettings(TDEGlobal::config(),"mainWindow_options");
c_olView->writeConfig();
h_drView->writeConfig();
mArticleViewer->writeConfig();
// store dock configuration
manager()->writeConfig(knGlobals.config(),"dock_configuration");
}
bool KNMainWidget::requestShutdown()
{
kdDebug(5003) << "KNMainWidget::requestShutdown()" << endl;
if( a_rtFactory->jobsPending() &&
KMessageBox::No==KMessageBox::warningYesNo(this, i18n(
"KNode is currently sending articles. If you quit now you might lose these \
articles.\nDo you want to quit anyway?"), TQString(), KStdGuiItem::quit(), KStdGuiItem::cancel())
)
return false;
if(!a_rtFactory->closeComposeWindows())
return false;
return true;
}
void KNMainWidget::prepareShutdown()
{
kdDebug(5003) << "KNMainWidget::prepareShutdown()" << endl;
//cleanup article-views
ArticleWidget::cleanup();
// expire groups (if necessary)
KNCleanUp *cup = new KNCleanUp();
g_rpManager->expireAll(cup);
cup->start();
// compact folders
KNConfig::Cleanup *conf=c_fgManager->cleanup();
if (conf->compactToday()) {
cup->reset();
f_olManager->compactAll(cup);
cup->start();
conf->setLastCompactDate();
}
delete cup;
saveOptions();
RecentAddresses::self(knGlobals.config())->save( knGlobals.config() );
c_fgManager->syncConfig();
a_rtManager->deleteTempFiles();
g_rpManager->syncGroups();
f_olManager->syncFolders();
f_ilManager->prepareShutdown();
a_ccManager->prepareShutdown();
s_coreManager->save();
}
bool KNMainWidget::queryClose()
{
if(b_lockui)
return false;
if(!requestShutdown())
return false;
prepareShutdown();
return true;
}
void KNMainWidget::showEvent(TQShowEvent *)
{
slotCheckDockWidgeStatus();
}
void KNMainWidget::fontChange( const TQFont & )
{
a_rtFactory->configChanged();
ArticleWidget::configChanged();
configChanged();
}
void KNMainWidget::paletteChange( const TQPalette & )
{
ArticleWidget::configChanged();
configChanged();
}
bool KNMainWidget::eventFilter(TQObject *o, TQEvent *e)
{
if (((e->type() == TQEvent::KeyPress) ||
(e->type() == TQEvent::KeyRelease) ||
(e->type() == TQEvent::Accel) ||
(e->type() == TQEvent::AccelOverride)) &&
b_lockui)
return true;
return KDockArea::eventFilter(o, e);
}
void KNMainWidget::getSelectedArticles(KNArticle::List &l)
{
if(!g_rpManager->currentGroup() && !f_olManager->currentFolder())
return;
for(TQListViewItem *i=h_drView->firstChild(); i; i=i->itemBelow())
if(i->isSelected() || (static_cast<KNHdrViewItem*>(i)->isActive()))
l.append( static_cast<KNArticle*> ((static_cast<KNHdrViewItem*>(i))->art) );
}
void KNMainWidget::getSelectedArticles(KNRemoteArticle::List &l)
{
if(!g_rpManager->currentGroup()) return;
for(TQListViewItem *i=h_drView->firstChild(); i; i=i->itemBelow())
if(i->isSelected() || (static_cast<KNHdrViewItem*>(i)->isActive()))
l.append( static_cast<KNRemoteArticle*> ((static_cast<KNHdrViewItem*>(i))->art) );
}
void KNMainWidget::getSelectedThreads(KNRemoteArticle::List &l)
{
KNRemoteArticle *art;
for(TQListViewItem *i=h_drView->firstChild(); i; i=i->itemBelow())
if(i->isSelected() || (static_cast<KNHdrViewItem*>(i)->isActive())) {
art=static_cast<KNRemoteArticle*> ((static_cast<KNHdrViewItem*>(i))->art);
// ignore the article if it is already in the list
// (multiple aritcles are selected in one thread)
if ( l.find(art) == l.end() )
art->thread(l);
}
}
void KNMainWidget::getSelectedArticles( KNLocalArticle::List &l )
{
if(!f_olManager->currentFolder()) return;
for(TQListViewItem *i=h_drView->firstChild(); i; i=i->itemBelow())
if(i->isSelected() || (static_cast<KNHdrViewItem*>(i)->isActive()))
l.append( static_cast<KNLocalArticle*> ((static_cast<KNHdrViewItem*>(i))->art) );
}
void KNMainWidget::closeCurrentThread()
{
TQListViewItem *item = h_drView->currentItem();
if (item) {
while (item->parent())
item = item->parent();
h_drView->setCurrentItem(item);
item->setOpen(false);
h_drView->ensureItemVisible(item);
}
}
void KNMainWidget::slotArticleSelected(TQListViewItem *i)
{
kdDebug(5003) << "KNMainWidget::slotArticleSelected(TQListViewItem *i)" << endl;
if(b_lockui)
return;
KNArticle *selectedArticle=0;
if(i)
selectedArticle=(static_cast<KNHdrViewItem*>(i))->art;
mArticleViewer->setArticle( selectedArticle );
//actions
bool enabled;
enabled=( selectedArticle && selectedArticle->type()==KMime::Base::ATremote );
if(a_ctArtSetArtRead->isEnabled() != enabled) {
a_ctArtSetArtRead->setEnabled(enabled);
a_ctArtSetArtUnread->setEnabled(enabled);
a_ctArtSetThreadRead->setEnabled(enabled);
a_ctArtSetThreadUnread->setEnabled(enabled);
a_ctArtToggleIgnored->setEnabled(enabled);
a_ctArtToggleWatched->setEnabled(enabled);
a_ctScoreLower->setEnabled(enabled);
a_ctScoreRaise->setEnabled(enabled);
}
a_ctArtOpenNewWindow->setEnabled( selectedArticle && (f_olManager->currentFolder()!=f_olManager->outbox())
&& (f_olManager->currentFolder()!=f_olManager->drafts()));
enabled=( selectedArticle && selectedArticle->type()==KMime::Base::ATlocal );
a_ctArtDelete->setEnabled(enabled);
a_ctArtSendNow->setEnabled(enabled && (f_olManager->currentFolder()==f_olManager->outbox()));
a_ctArtEdit->setEnabled(enabled && ((f_olManager->currentFolder()==f_olManager->outbox())||
(f_olManager->currentFolder()==f_olManager->drafts())));
}
void KNMainWidget::slotArticleSelectionChanged()
{
// enable all actions that work with multiple selection
//actions
bool enabled = (g_rpManager->currentGroup()!=0);
if(a_ctArtSetArtRead->isEnabled() != enabled) {
a_ctArtSetArtRead->setEnabled(enabled);
a_ctArtSetArtUnread->setEnabled(enabled);
a_ctArtSetThreadRead->setEnabled(enabled);
a_ctArtSetThreadUnread->setEnabled(enabled);
a_ctArtToggleIgnored->setEnabled(enabled);
a_ctArtToggleWatched->setEnabled(enabled);
a_ctScoreLower->setEnabled(enabled);
a_ctScoreRaise->setEnabled(enabled);
}
enabled = (f_olManager->currentFolder()!=0);
a_ctArtDelete->setEnabled(enabled);
a_ctArtSendNow->setEnabled(enabled && (f_olManager->currentFolder()==f_olManager->outbox()));
}
void KNMainWidget::slotCollectionSelected(TQListViewItem *i)
{
kdDebug(5003) << "KNMainWidget::slotCollectionSelected(TQListViewItem *i)" << endl;
if(b_lockui)
return;
KNCollection *c=0;
KNNntpAccount *selectedAccount=0;
KNGroup *selectedGroup=0;
KNFolder *selectedFolder=0;
s_earchLineEdit->clear();
h_drView->clear();
slotArticleSelected(0);
// mark all articles in current group as not new/read
if ( knGlobals.configManager()->readNewsNavigation()->leaveGroupMarkAsRead() )
a_rtManager->setAllRead( true );
a_rtManager->setAllNotNew();
if(i) {
c=(static_cast<KNCollectionViewItem*>(i))->coll;
switch(c->type()) {
case KNCollection::CTnntpAccount :
selectedAccount=static_cast<KNNntpAccount*>(c);
if(!i->isOpen())
i->setOpen(true);
break;
case KNCollection::CTgroup :
if ( !h_drView->hasFocus() && !mArticleViewer->hasFocus() )
h_drView->setFocus();
selectedGroup=static_cast<KNGroup*>(c);
selectedAccount=selectedGroup->account();
break;
case KNCollection::CTfolder :
if ( !h_drView->hasFocus() && !mArticleViewer->hasFocus() )
h_drView->setFocus();
selectedFolder=static_cast<KNFolder*>(c);
break;
default: break;
}
}
a_ccManager->setCurrentAccount(selectedAccount);
g_rpManager->setCurrentGroup(selectedGroup);
f_olManager->setCurrentFolder(selectedFolder);
if (!selectedGroup && !selectedFolder) // called from showHeaders() otherwise
a_rtManager->updateStatusString();
updateCaption();
//actions
bool enabled;
enabled=(selectedGroup) || (selectedFolder && !selectedFolder->isRootFolder());
if(a_ctNavNextArt->isEnabled() != enabled) {
a_ctNavNextArt->setEnabled(enabled);
a_ctNavPrevArt->setEnabled(enabled);
}
enabled=( selectedGroup!=0 );
if(a_ctNavNextUnreadArt->isEnabled() != enabled) {
a_ctNavNextUnreadArt->setEnabled(enabled);
a_ctNavNextUnreadThread->setEnabled(enabled);
a_ctNavReadThrough->setEnabled(enabled);
a_ctFetchArticleWithID->setEnabled(enabled);
}
enabled=( selectedAccount!=0 );
if(a_ctAccProperties->isEnabled() != enabled) {
a_ctAccProperties->setEnabled(enabled);
a_ctAccRename->setEnabled(enabled);
a_ctAccSubscribe->setEnabled(enabled);
a_ctAccExpireAll->setEnabled(enabled);
a_ctAccGetNewHdrs->setEnabled(enabled);
a_ctAccGetNewHdrsAll->setEnabled(enabled);
a_ctAccDelete->setEnabled(enabled);
a_ctAccPostNewArticle->setEnabled(enabled);
}
enabled=( selectedGroup!=0 );
if(a_ctGrpProperties->isEnabled() != enabled) {
a_ctGrpProperties->setEnabled(enabled);
a_ctGrpRename->setEnabled(enabled);
a_ctGrpGetNewHdrs->setEnabled(enabled);
a_ctGrpExpire->setEnabled(enabled);
a_ctGrpReorganize->setEnabled(enabled);
a_ctGrpUnsubscribe->setEnabled(enabled);
a_ctGrpSetAllRead->setEnabled(enabled);
a_ctGrpSetAllUnread->setEnabled(enabled);
a_ctGrpSetUnread->setEnabled(enabled);
a_ctArtFilter->setEnabled(enabled);
a_ctArtFilterKeyb->setEnabled(enabled);
a_ctArtRefreshList->setEnabled(enabled);
a_ctArtCollapseAll->setEnabled(enabled);
a_ctArtExpandAll->setEnabled(enabled);
a_ctArtToggleShowThreads->setEnabled(enabled);
a_ctReScore->setEnabled(enabled);
}
a_ctFolNewChild->setEnabled(selectedFolder!=0);
enabled=( selectedFolder!=0 && !selectedFolder->isRootFolder() && !selectedFolder->isStandardFolder() );
if(a_ctFolDelete->isEnabled() != enabled) {
a_ctFolDelete->setEnabled(enabled);
a_ctFolRename->setEnabled(enabled);
}
enabled=( selectedFolder!=0 && !selectedFolder->isRootFolder() );
if(a_ctFolCompact->isEnabled() != enabled) {
a_ctFolCompact->setEnabled(enabled);
a_ctFolEmpty->setEnabled(enabled);
a_ctFolMboxImport->setEnabled(enabled);
a_ctFolMboxExport->setEnabled(enabled);
}
}
void KNMainWidget::slotCollectionRenamed(TQListViewItem *i)
{
kdDebug(5003) << "KNMainWidget::slotCollectionRenamed(TQListViewItem *i)" << endl;
if (i) {
(static_cast<KNCollectionViewItem*>(i))->coll->setName(i->text(0));
updateCaption();
a_rtManager->updateStatusString();
if ((static_cast<KNCollectionViewItem*>(i))->coll->type()==KNCollection::CTnntpAccount)
a_ccManager->accountRenamed(static_cast<KNNntpAccount*>((static_cast<KNCollectionViewItem*>(i))->coll));
disableAccels(false);
}
}
void KNMainWidget::slotCollectionViewDrop(TQDropEvent* e, KNCollectionViewItem* after)
{
kdDebug(5003) << "KNMainWidget::slotCollectionViewDrop() : type = " << e->format(0) << endl;
KNCollectionViewItem *cvi=static_cast<KNCollectionViewItem*>(after);
if (cvi && cvi->coll->type() != KNCollection::CTfolder) // safety measure...
return;
KNFolder *dest=cvi ? static_cast<KNFolder*>(cvi->coll) : 0;
if (e->provides("x-knode-drag/folder") && f_olManager->currentFolder()) {
f_olManager->moveFolder(f_olManager->currentFolder(), dest);
}
else if(dest && e->provides("x-knode-drag/article")) {
if(f_olManager->currentFolder()) {
if (e->action() == TQDropEvent::Move) {
KNLocalArticle::List l;
getSelectedArticles(l);
a_rtManager->moveIntoFolder(l, dest);
} else {
KNArticle::List l;
getSelectedArticles(l);
a_rtManager->copyIntoFolder(l, dest);
}
}
else if(g_rpManager->currentGroup()) {
KNArticle::List l;
getSelectedArticles(l);
a_rtManager->copyIntoFolder(l, dest);
}
}
}
void KNMainWidget::slotArticleRMB(TDEListView*, TQListViewItem *i, const TQPoint &p)
{
if(b_lockui)
return;
if(i) {
TQPopupMenu *popup;
if( (static_cast<KNHdrViewItem*>(i))->art->type()==KMime::Base::ATremote) {
popup = static_cast<TQPopupMenu *>(factory()->container("remote_popup", m_GUIClient));
} else {
popup = static_cast<TQPopupMenu *>(factory()->container("local_popup", m_GUIClient));
}
if ( popup )
popup->popup(p);
}
}
void KNMainWidget::slotCollectionRMB(TDEListView*, TQListViewItem *i, const TQPoint &p)
{
if(b_lockui)
return;
if(i) {
if( (static_cast<KNCollectionViewItem*>(i))->coll->type()==KNCollection::CTgroup) {
TQPopupMenu *popup = static_cast<TQPopupMenu *>(factory()->container("group_popup", m_GUIClient));
if ( popup )
popup->popup(p);
} else if ((static_cast<KNCollectionViewItem*>(i))->coll->type()==KNCollection::CTfolder) {
if (static_cast<KNFolder*>(static_cast<KNCollectionViewItem*>(i)->coll)->isRootFolder()) {
TQPopupMenu *popup = static_cast<TQPopupMenu *>(factory()->container("root_folder_popup", m_GUIClient));
if ( popup )
popup->popup(p);
} else {
TQPopupMenu *popup = static_cast<TQPopupMenu *>(factory()->container("folder_popup", m_GUIClient));
if ( popup )
popup->popup(p);
}
} else {
TQPopupMenu *popup = static_cast<TQPopupMenu *>(factory()->container("account_popup", m_GUIClient));
if ( popup )
popup->popup( p );
}
}
}
void KNMainWidget::slotOpenArticle(TQListViewItem *item)
{
if(b_lockui)
return;
if (item) {
KNArticle *art=(static_cast<KNHdrViewItem*>(item))->art;
if ((art->type()==KMime::Base::ATlocal) && ((f_olManager->currentFolder()==f_olManager->outbox())||
(f_olManager->currentFolder()==f_olManager->drafts()))) {
a_rtFactory->edit( static_cast<KNLocalArticle*>(art) );
} else {
if (!KNArticleWindow::raiseWindowForArticle(art)) {
KNArticleWindow *w=new KNArticleWindow(art);
w->show();
}
}
}
}
void KNMainWidget::slotHdrViewSortingChanged(int i)
{
a_ctArtSortHeaders->setCurrentItem(i);
}
void KNMainWidget::slotNetworkActive(bool b)
{
a_ctNetCancel->setEnabled(b);
}
void KNMainWidget::slotCheckDockWidgeStatus()
{
a_ctToggleGroupView->setChecked(c_olDock->isVisible());
a_ctToggleArticleViewer->setChecked(a_rtDock->isVisible());
a_ctToggleHeaderView->setChecked(h_drDock->isVisible());
}
void KNMainWidget::slotGroupDockHidden()
{
a_ctToggleGroupView->setChecked(false);
}
void KNMainWidget::slotHeaderDockHidden()
{
a_ctToggleHeaderView->setChecked(false);
}
void KNMainWidget::slotArticleDockHidden()
{
a_ctToggleArticleViewer->setChecked(false);
}
void KNMainWidget::slotDockWidgetFocusChangeRequest(TQWidget *w)
{
if ( w == mArticleViewer ) {
if (c_olView->isVisible()) {
c_olView->setFocus();
if (!w->hasFocus()) // fails if the view is visible but floating
return;
}
if (h_drView->isVisible()) {
h_drView->setFocus();
return;
}
}
if (w == c_olView) {
if (h_drView->isVisible()) {
h_drView->setFocus();
if (!w->hasFocus()) // fails if the view is visible but floating
return;
}
if ( mArticleViewer->isVisible() ) {
mArticleViewer->setFocus();
return;
}
}
if (w == h_drView) {
if ( mArticleViewer->isVisible() ) {
mArticleViewer->setFocus();
if (!w->hasFocus()) // fails if the view is visible but floating
return;
}
if (c_olView->isVisible()) {
c_olView->setFocus();
return;
}
}
}
//------------------------------ <Actions> --------------------------------
void KNMainWidget::slotNavNextUnreadArt()
{
if ( !h_drView->nextUnreadArticle() )
c_olView->nextGroup();
}
void KNMainWidget::slotNavNextUnreadThread()
{
if ( !h_drView->nextUnreadThread() )
c_olView->nextGroup();
}
void KNMainWidget::slotNavReadThrough()
{
kdDebug(5003) << "KNMainWidget::slotNavReadThrough()" << endl;
if ( !mArticleViewer->atBottom() )
mArticleViewer->scrollNext();
else if(g_rpManager->currentGroup() != 0)
slotNavNextUnreadArt();
}
void KNMainWidget::slotAccProperties()
{
kdDebug(5003) << "KNMainWidget::slotAccProperties()" << endl;
if(a_ccManager->currentAccount())
a_ccManager->editProperties(a_ccManager->currentAccount());
updateCaption();
a_rtManager->updateStatusString();
}
void KNMainWidget::slotAccRename()
{
kdDebug(5003) << "KNMainWidget::slotAccRename()" << endl;
if(a_ccManager->currentAccount()) {
disableAccels(true); // hack: global accels break the inplace renaming
c_olView->rename(a_ccManager->currentAccount()->listItem(), 0);
}
}
void KNMainWidget::slotAccSubscribe()
{
kdDebug(5003) << "KNMainWidget::slotAccSubscribe()" << endl;
if(a_ccManager->currentAccount())
g_rpManager->showGroupDialog(a_ccManager->currentAccount());
}
void KNMainWidget::slotAccExpireAll()
{
kdDebug(5003) << "KNMainWidget::slotAccExpireAll()" << endl;
if(a_ccManager->currentAccount())
g_rpManager->expireAll(a_ccManager->currentAccount());
}
void KNMainWidget::slotAccGetNewHdrs()
{
kdDebug(5003) << "KNMainWidget::slotAccGetNewHdrs()" << endl;
if(a_ccManager->currentAccount())
g_rpManager->checkAll(a_ccManager->currentAccount());
}
void KNMainWidget::slotAccDelete()
{
kdDebug(5003) << "KNMainWidget::slotAccDelete()" << endl;
if(a_ccManager->currentAccount()) {
if (a_ccManager->removeAccount(a_ccManager->currentAccount()))
slotCollectionSelected(0);
}
}
void KNMainWidget::slotAccGetNewHdrsAll()
{
TQValueList<KNNntpAccount*>::Iterator it;
for ( it = a_ccManager->begin(); it != a_ccManager->end(); ++it )
g_rpManager->checkAll( *it );
}
void KNMainWidget::slotAccPostNewArticle()
{
kdDebug(5003) << "KNMainWidget::slotAccPostNewArticle()" << endl;
if(g_rpManager->currentGroup())
a_rtFactory->createPosting(g_rpManager->currentGroup());
else if(a_ccManager->currentAccount())
a_rtFactory->createPosting(a_ccManager->currentAccount());
}
void KNMainWidget::slotGrpProperties()
{
kdDebug(5003) << "slotGrpProperties()" << endl;
if(g_rpManager->currentGroup())
g_rpManager->showGroupProperties(g_rpManager->currentGroup());
updateCaption();
a_rtManager->updateStatusString();
}
void KNMainWidget::slotGrpRename()
{
kdDebug(5003) << "slotGrpRename()" << endl;
if(g_rpManager->currentGroup()) {
disableAccels(true); // hack: global accels break the inplace renaming
c_olView->rename(g_rpManager->currentGroup()->listItem(), 0);
}
}
void KNMainWidget::slotGrpGetNewHdrs()
{
kdDebug(5003) << "KNMainWidget::slotGrpGetNewHdrs()" << endl;
if(g_rpManager->currentGroup())
g_rpManager->checkGroupForNewHeaders(g_rpManager->currentGroup());
}
void KNMainWidget::slotGrpExpire()
{
kdDebug(5003) << "KNMainWidget::slotGrpExpire()" << endl;
if(g_rpManager->currentGroup())
g_rpManager->expireGroupNow(g_rpManager->currentGroup());
}
void KNMainWidget::slotGrpReorganize()
{
kdDebug(5003) << "KNMainWidget::slotGrpReorganize()" << endl;
g_rpManager->reorganizeGroup(g_rpManager->currentGroup());
}
void KNMainWidget::slotGrpUnsubscribe()
{
kdDebug(5003) << "KNMainWidget::slotGrpUnsubscribe()" << endl;
if(g_rpManager->currentGroup()) {
if(KMessageBox::Yes==KMessageBox::questionYesNo(knGlobals.topWidget,
i18n("Do you really want to unsubscribe from %1?").arg(g_rpManager->currentGroup()->groupname()), TQString(), i18n("Unsubscribe"), KStdGuiItem::cancel()))
if (g_rpManager->unsubscribeGroup(g_rpManager->currentGroup()))
slotCollectionSelected(0);
}
}
void KNMainWidget::slotGrpSetAllRead()
{
kdDebug(5003) << "KNMainWidget::slotGrpSetAllRead()" << endl;
a_rtManager->setAllRead(true);
if (c_fgManager->readNewsNavigation()->markAllReadGoNext())
c_olView->nextGroup();
}
void KNMainWidget::slotGrpSetAllUnread()
{
kdDebug(5003) << "KNMainWidget::slotGrpSetAllUnread()" << endl;
a_rtManager->setAllRead(false);
}
void KNMainWidget::slotGrpSetUnread()
{
kdDebug(5003) << "KNMainWidget::slotGrpSetUnread()" << endl;
int groupLength = g_rpManager->currentGroup()->length();
bool ok = false;
int res = KInputDialog::getInteger(
i18n( "Mark Last as Unread" ),
i18n( "Enter how many articles should be marked unread:" ), groupLength, 1, groupLength, 1, &ok, this );
if ( ok )
a_rtManager->setAllRead( false, res );
}
void KNMainWidget::slotFolNew()
{
kdDebug(5003) << "KNMainWidget::slotFolNew()" << endl;
KNFolder *f = f_olManager->newFolder(0);
if (f) {
f_olManager->setCurrentFolder(f);
c_olView->ensureItemVisible(f->listItem());
c_olView->setActive( f->listItem() );
slotFolRename();
}
}
void KNMainWidget::slotFolNewChild()
{
kdDebug(5003) << "KNMainWidget::slotFolNew()" << endl;
if(f_olManager->currentFolder()) {
KNFolder *f = f_olManager->newFolder(f_olManager->currentFolder());
if (f) {
f_olManager->setCurrentFolder(f);
c_olView->ensureItemVisible(f->listItem());
c_olView->setActive( f->listItem() );
slotFolRename();
}
}
}
void KNMainWidget::slotFolDelete()
{
kdDebug(5003) << "KNMainWidget::slotFolDelete()" << endl;
if(!f_olManager->currentFolder() || f_olManager->currentFolder()->isRootFolder())
return;
if(f_olManager->currentFolder()->isStandardFolder())
KMessageBox::sorry(knGlobals.topWidget, i18n("You cannot delete a standard folder."));
else if( KMessageBox::Continue==KMessageBox::warningContinueCancel(knGlobals.topWidget,
i18n("Do you really want to delete this folder and all its children?"),"",KGuiItem(i18n("&Delete"),"edit-delete")) ) {
if(!f_olManager->deleteFolder(f_olManager->currentFolder()))
KMessageBox::sorry(knGlobals.topWidget,
i18n("This folder cannot be deleted because some of\n its articles are currently in use.") );
else
slotCollectionSelected(0);
}
}
void KNMainWidget::slotFolRename()
{
kdDebug(5003) << "KNMainWidget::slotFolRename()" << endl;
if(f_olManager->currentFolder() && !f_olManager->currentFolder()->isRootFolder()) {
if(f_olManager->currentFolder()->isStandardFolder())
KMessageBox::sorry(knGlobals.topWidget, i18n("You cannot rename a standard folder."));
else {
disableAccels(true); // hack: global accels break the inplace renaming
c_olView->rename(f_olManager->currentFolder()->listItem(), 0);
}
}
}
void KNMainWidget::slotFolCompact()
{
kdDebug(5003) << "KNMainWidget::slotFolCompact()" << endl;
if(f_olManager->currentFolder() && !f_olManager->currentFolder()->isRootFolder())
f_olManager->compactFolder(f_olManager->currentFolder());
}
void KNMainWidget::slotFolCompactAll()
{
kdDebug(5003) << "KNMainWidget::slotFolCompactAll()" << endl;
f_olManager->compactAll();
}
void KNMainWidget::slotFolEmpty()
{
kdDebug(5003) << "KNMainWidget::slotFolEmpty()" << endl;
if(f_olManager->currentFolder() && !f_olManager->currentFolder()->isRootFolder()) {
if(f_olManager->currentFolder()->lockedArticles()>0) {
KMessageBox::sorry(this,
i18n("This folder cannot be emptied at the moment\nbecause some of its articles are currently in use.") );
return;
}
if( KMessageBox::Continue == KMessageBox::warningContinueCancel(
this, i18n("Do you really want to delete all articles in %1?").arg(f_olManager->currentFolder()->name()),"",KGuiItem(i18n("&Delete"),"edit-delete")) )
f_olManager->emptyFolder(f_olManager->currentFolder());
}
}
void KNMainWidget::slotFolMBoxImport()
{
kdDebug(5003) << "KNMainWidget::slotFolMBoxImport()" << endl;
if(f_olManager->currentFolder() && !f_olManager->currentFolder()->isRootFolder()) {
f_olManager->importFromMBox(f_olManager->currentFolder());
}
}
void KNMainWidget::slotFolMBoxExport()
{
kdDebug(5003) << "KNMainWidget::slotFolMBoxExport()" << endl;
if(f_olManager->currentFolder() && !f_olManager->currentFolder()->isRootFolder()) {
f_olManager->exportToMBox(f_olManager->currentFolder());
}
}
void KNMainWidget::slotArtSortHeaders(int i)
{
kdDebug(5003) << "KNMainWidget::slotArtSortHeaders(int i)" << endl;
h_drView->setSorting( i );
}
void KNMainWidget::slotArtSortHeadersKeyb()
{
kdDebug(5003) << "KNMainWidget::slotArtSortHeadersKeyb()" << endl;
int newCol = KNHelper::selectDialog(this, i18n("Select Sort Column"), a_ctArtSortHeaders->items(), a_ctArtSortHeaders->currentItem());
if (newCol != -1)
h_drView->setSorting( newCol );
}
void KNMainWidget::slotArtSearch()
{
kdDebug(5003) << "KNMainWidget::slotArtSearch()" << endl;
a_rtManager->search();
}
void KNMainWidget::slotArtRefreshList()
{
kdDebug(5003) << "KNMainWidget::slotArtRefreshList()" << endl;
a_rtManager->showHdrs(true);
}
void KNMainWidget::slotArtCollapseAll()
{
kdDebug(5003) << "KNMainWidget::slotArtCollapseAll()" << endl;
closeCurrentThread();
a_rtManager->setAllThreadsOpen(false);
if (h_drView->currentItem())
h_drView->ensureItemVisible(h_drView->currentItem());
}
void KNMainWidget::slotArtExpandAll()
{
kdDebug(5003) << "KNMainWidget::slotArtExpandAll()" << endl;
a_rtManager->setAllThreadsOpen(true);
if (h_drView->currentItem())
h_drView->ensureItemVisible(h_drView->currentItem());
}
void KNMainWidget::slotArtToggleThread()
{
kdDebug(5003) << "KNMainWidget::slotArtToggleThread()" << endl;
if( mArticleViewer->article() && mArticleViewer->article()->listItem()->isExpandable() ) {
bool o = !(mArticleViewer->article()->listItem()->isOpen());
mArticleViewer->article()->listItem()->setOpen( o );
}
}
void KNMainWidget::slotArtToggleShowThreads()
{
kdDebug(5003) << "KNMainWidget::slotArtToggleShowThreads()" << endl;
if(g_rpManager->currentGroup()) {
c_fgManager->readNewsGeneral()->setShowThreads(!c_fgManager->readNewsGeneral()->showThreads());
a_rtManager->showHdrs(true);
}
}
void KNMainWidget::slotArtSetArtRead()
{
kdDebug(5003) << "KNMainWidget::slotArtSetArtRead()" << endl;
if(!g_rpManager->currentGroup())
return;
KNRemoteArticle::List l;
getSelectedArticles(l);
a_rtManager->setRead(l, true);
}
void KNMainWidget::slotArtSetArtUnread()
{
kdDebug(5003) << "KNMainWidget::slotArtSetArtUnread()" << endl;
if(!g_rpManager->currentGroup())
return;
KNRemoteArticle::List l;
getSelectedArticles(l);
a_rtManager->setRead(l, false);
}
void KNMainWidget::slotArtSetThreadRead()
{
kdDebug(5003) << "slotArtSetThreadRead()" << endl;
if( !g_rpManager->currentGroup() )
return;
KNRemoteArticle::List l;
getSelectedThreads(l);
a_rtManager->setRead(l, true);
if (h_drView->currentItem()) {
if (c_fgManager->readNewsNavigation()->markThreadReadCloseThread())
closeCurrentThread();
if (c_fgManager->readNewsNavigation()->markThreadReadGoNext())
slotNavNextUnreadThread();
}
}
void KNMainWidget::slotArtSetThreadUnread()
{
kdDebug(5003) << "KNMainWidget::slotArtSetThreadUnread()" << endl;
if( !g_rpManager->currentGroup() )
return;
KNRemoteArticle::List l;
getSelectedThreads(l);
a_rtManager->setRead(l, false);
}
void KNMainWidget::slotScoreEdit()
{
kdDebug(5003) << "KNMainWidget::slotScoreEdit()" << endl;
s_coreManager->configure();
}
void KNMainWidget::slotReScore()
{
kdDebug(5003) << "KNMainWidget::slotReScore()" << endl;
if( !g_rpManager->currentGroup() )
return;
g_rpManager->currentGroup()->scoreArticles(false);
a_rtManager->showHdrs(true);
}
void KNMainWidget::slotScoreLower()
{
kdDebug(5003) << "KNMainWidget::slotScoreLower() start" << endl;
if( !g_rpManager->currentGroup() )
return;
if ( mArticleViewer->article() && mArticleViewer->article()->type() == KMime::Base::ATremote ) {
KNRemoteArticle *ra = static_cast<KNRemoteArticle*>( mArticleViewer->article() );
s_coreManager->addRule(KNScorableArticle(ra), g_rpManager->currentGroup()->groupname(), -10);
}
}
void KNMainWidget::slotScoreRaise()
{
kdDebug(5003) << "KNMainWidget::slotScoreRaise() start" << endl;
if( !g_rpManager->currentGroup() )
return;
if ( mArticleViewer->article() && mArticleViewer->article()->type() == KMime::Base::ATremote ) {
KNRemoteArticle *ra = static_cast<KNRemoteArticle*>( mArticleViewer->article() );
s_coreManager->addRule(KNScorableArticle(ra), g_rpManager->currentGroup()->groupname(), +10);
}
}
void KNMainWidget::slotArtToggleIgnored()
{
kdDebug(5003) << "KNMainWidget::slotArtToggleIgnored()" << endl;
if( !g_rpManager->currentGroup() )
return;
KNRemoteArticle::List l;
getSelectedThreads(l);
bool revert = !a_rtManager->toggleIgnored(l);
a_rtManager->rescoreArticles(l);
if (h_drView->currentItem() && !revert) {
if (c_fgManager->readNewsNavigation()->ignoreThreadCloseThread())
closeCurrentThread();
if (c_fgManager->readNewsNavigation()->ignoreThreadGoNext())
slotNavNextUnreadThread();
}
}
void KNMainWidget::slotArtToggleWatched()
{
kdDebug(5003) << "KNMainWidget::slotArtToggleWatched()" << endl;
if( !g_rpManager->currentGroup() )
return;
KNRemoteArticle::List l;
getSelectedThreads(l);
a_rtManager->toggleWatched(l);
a_rtManager->rescoreArticles(l);
}
void KNMainWidget::slotArtOpenNewWindow()
{
kdDebug(5003) << "KNMainWidget::slotArtOpenNewWindow()" << endl;
if( mArticleViewer->article() ) {
if ( !KNArticleWindow::raiseWindowForArticle( mArticleViewer->article() )) {
KNArticleWindow *win=new KNArticleWindow( mArticleViewer->article() );
win->show();
}
}
}
void KNMainWidget::slotArtSendOutbox()
{
kdDebug(5003) << "KNMainWidget::slotArtSendOutbox()" << endl;
a_rtFactory->sendOutbox();
}
void KNMainWidget::slotArtDelete()
{
kdDebug(5003) << "KNMainWidget::slotArtDelete()" << endl;
if (!f_olManager->currentFolder())
return;
KNLocalArticle::List lst;
getSelectedArticles(lst);
if(!lst.isEmpty())
a_rtManager->deleteArticles(lst);
if(h_drView->currentItem())
h_drView->setActive( h_drView->currentItem() );
}
void KNMainWidget::slotArtSendNow()
{
kdDebug(5003) << "KNMainWidget::slotArtSendNow()" << endl;
if (!f_olManager->currentFolder())
return;
KNLocalArticle::List lst;
getSelectedArticles(lst);
if(!lst.isEmpty())
a_rtFactory->sendArticles( lst, true );
}
void KNMainWidget::slotArtEdit()
{
kdDebug(5003) << "KNodeVew::slotArtEdit()" << endl;
if (!f_olManager->currentFolder())
return;
if ( mArticleViewer->article() && mArticleViewer->article()->type() == KMime::Base::ATlocal )
a_rtFactory->edit( static_cast<KNLocalArticle*>( mArticleViewer->article() ) );
}
void KNMainWidget::slotNetCancel()
{
kdDebug(5003) << "KNMainWidget::slotNetCancel()" << endl;
n_etAccess->cancelAllJobs();
}
void KNMainWidget::slotFetchArticleWithID()
{
kdDebug(5003) << "KNMainWidget::slotFetchArticleWithID()" << endl;
if( !g_rpManager->currentGroup() )
return;
FetchArticleIdDlg *dlg = new FetchArticleIdDlg(this, "messageid" );
if (dlg->exec()) {
TQString id = dlg->messageId().simplifyWhiteSpace();
if (id.find(TQRegExp("*@*",false,true))!=-1) {
if (id.find(TQRegExp("<*>",false,true))==-1) // add "<>" when necessary
id = TQString("<%1>").arg(id);
if(!KNArticleWindow::raiseWindowForArticle(id.latin1())) { //article not yet opened
KNRemoteArticle *a=new KNRemoteArticle(g_rpManager->currentGroup());
a->messageID()->from7BitString(id.latin1());
KNArticleWindow *awin=new KNArticleWindow(a);
awin->show();
}
}
}
KNHelper::saveWindowSize("fetchArticleWithID",dlg->size());
delete dlg;
}
void KNMainWidget::slotToggleGroupView()
{
c_olDock->changeHideShowState();
slotCheckDockWidgeStatus();
}
void KNMainWidget::slotToggleHeaderView()
{
if ( !h_drDock->isVisible() )
if ( !h_drDock->isDockBackPossible() ) {
h_drDock->manualDock( a_rtDock, KDockWidget::DockTop );
h_drDock->makeDockVisible();
slotCheckDockWidgeStatus();
return;
}
h_drDock->changeHideShowState();
slotCheckDockWidgeStatus();
}
void KNMainWidget::slotToggleArticleViewer()
{
a_rtDock->changeHideShowState();
slotCheckDockWidgeStatus();
}
void KNMainWidget::slotToggleQuickSearch()
{
if (q_uicksearch->isHidden())
q_uicksearch->show();
else
q_uicksearch->hide();
}
void KNMainWidget::slotSwitchToGroupView()
{
if (!c_olView->isVisible())
slotToggleGroupView();
c_olView->setFocus();
}
void KNMainWidget::slotSwitchToHeaderView()
{
if (!h_drView->isVisible())
slotToggleHeaderView();
h_drView->setFocus();
}
void KNMainWidget::slotSwitchToArticleViewer()
{
if ( !mArticleViewer->isVisible() )
slotToggleArticleViewer();
mArticleViewer->setFocus();
}
void KNMainWidget::slotSettings()
{
c_fgManager->configure();
}
TDEActionCollection* KNMainWidget::actionCollection() const
{
return m_GUIClient->actionCollection();
}
KXMLGUIFactory* KNMainWidget::factory() const
{
kdDebug(5003)<<"m_guiclient is "<< m_GUIClient
<<", the factory is " << m_GUIClient->factory() <<endl;
return m_GUIClient->factory();
}
//--------------------------------
FetchArticleIdDlg::FetchArticleIdDlg(TQWidget *parent, const char */*name*/ )
:KDialogBase(parent, 0, true, i18n("Fetch Article with ID"), KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok)
{
TQHBox *page = makeHBoxMainWidget();
TQLabel *label = new TQLabel(i18n("&Message-ID:"),page);
edit = new KLineEdit(page);
label->setBuddy(edit);
edit->setFocus();
enableButtonOK( false );
setButtonOK( i18n("&Fetch") );
connect( edit, TQ_SIGNAL(textChanged( const TQString & )), this, TQ_SLOT(slotTextChanged(const TQString & )));
KNHelper::restoreWindowSize("fetchArticleWithID", this, TQSize(325,66));
}
TQString FetchArticleIdDlg::messageId() const
{
return edit->text();
}
void FetchArticleIdDlg::slotTextChanged(const TQString &_text )
{
enableButtonOK( !_text.isEmpty() );
}
////////////////////////////////////////////////////////////////////////
//////////////////////// DCOP implementation
// Move to the next article
void KNMainWidget::nextArticle()
{
h_drView->nextArticle();
}
// Move to the previous article
void KNMainWidget::previousArticle()
{
h_drView->prevArticle();
}
// Move to the next unread article
void KNMainWidget::nextUnreadArticle()
{
slotNavNextUnreadArt();
}
// Move to the next unread thread
void KNMainWidget::nextUnreadThread()
{
slotNavNextUnreadThread();
}
// Move to the next group
void KNMainWidget::nextGroup()
{
c_olView->nextGroup();
}
// Move to the previous group
void KNMainWidget::previousGroup()
{
c_olView->prevGroup();
}
void KNMainWidget::fetchHeaders()
{
// Simply call the slot
slotAccGetNewHdrs();
}
void KNMainWidget::expireArticles()
{
slotAccExpireAll();
}
// Open the editor to post a new article in the selected group
void KNMainWidget::postArticle()
{
slotAccPostNewArticle();
}
// Fetch the new headers in the selected groups
void KNMainWidget::fetchHeadersInCurrentGroup()
{
slotGrpGetNewHdrs();
}
// Expire the articles in the current group
void KNMainWidget::expireArticlesInCurrentGroup()
{
slotGrpExpire();
}
// Mark all the articles in the current group as read
void KNMainWidget::markAllAsRead()
{
slotGrpSetAllRead();
}
// Mark all the articles in the current group as unread
void KNMainWidget::markAllAsUnread()
{
slotGrpSetAllUnread();
}
// Mark the current article as read
void KNMainWidget::markAsRead()
{
slotArtSetArtRead();
}
// Mark the current article as unread
void KNMainWidget::markAsUnread()
{
slotArtSetArtUnread();
}
// Mark the current thread as read
void KNMainWidget::markThreadAsRead()
{
slotArtSetThreadRead();
}
// Mark the current thread as unread
void KNMainWidget::markThreadAsUnread()
{
slotArtSetThreadUnread();
}
// Send the pending articles
void KNMainWidget::sendPendingMessages()
{
slotArtSendOutbox();
}
// Delete the current article
void KNMainWidget::deleteArticle()
{
slotArtDelete();
}
// Send the current article
void KNMainWidget::sendNow()
{
slotArtSendNow();
}
// Edit the current article
void KNMainWidget::editArticle()
{
slotArtEdit();
}
bool KNMainWidget::handleCommandLine()
{
bool doneSomething = false;
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
if (args->count()>0) {
KURL url=args->url(0); // we take only one URL
openURL(url);
doneSomething = true;
}
args->clear();
return doneSomething;
}
//////////////////////// end DCOP implementation
////////////////////////////////////////////////////////////////////////
#include "knmainwidget.moc"
|