summaryrefslogtreecommitdiffstats
path: root/knode/knmainwidget.h
blob: 5c1e469ab9b373c4760a281849c6eceb5ea8c907 (plain)
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
/*
    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
*/
#ifndef KNMAINWIDGET_H
#define KNMAINWIDGET_H

#include "knodeiface.h"

#include <kdockwidget.h>
#include <kdialogbase.h>
#include "resource.h"

#include <tqglobal.h>
#include <tdemacros.h>

class TQListViewItem;

class KURL;
class TDEAccel;
class TDEAction;
class TDEToggleAction;
class TDESelectAction;
class KRSqueezedTextLabel;
class KLineEdit;
class KXMLGUIClient;

class KNHeaderView;
class KNCollectionView;
class KNCollectionViewItem;
class KNProgress;
class KNConfigManager;
class KNAccountManager;
class KNGroupManager;
class KNFolderManager;
class KNArticleManager;
class KNArticleFactory;
class KNFilterManager;
class KNScoringManager;
class KNMemoryManager;
class KNFilterSelectAction;
class KNNetAccess;
namespace Kpgp {
    class Module;
}
namespace KNode {
  class ArticleWidget;
}
class KNArticle;
class KNLocalArticle;
class KNRemoteArticle;
class TDEActionCollection;

class TDE_EXPORT KNMainWidget : public KDockArea, virtual public KNodeIface
{
  TQ_OBJECT
  
public:
  KNMainWidget( KXMLGUIClient *client, bool detachable, TQWidget* parent, const char* name );
  ~KNMainWidget();

  /** exit */
  bool queryClose();
  void prepareShutdown();

  //GUI
  void setStatusMsg(const TQString& = TQString(), int id=SB_MAIN);
  void setStatusHelpMsg(const TQString& text);
  void updateCaption();
  void setCursorBusy(bool b=true);
  void blockUI(bool b=true);
  void disableAccels(bool b=true);
  /** processEvents with some blocking */
  void secureProcessEvents();

  /** useful default value */
  virtual TQSize sizeHint() const;

  /** handle URL given as command-line argument */
  void openURL(const KURL &url);

  /** update fonts and colors */
  void configChanged();

  /** access to GUI-elements */
  KNCollectionView* collectionView()const  { return c_olView; }
  KNHeaderView*       headerView()const      { return h_drView; }
  KNode::ArticleWidget* articleViewer() const     { return mArticleViewer; }
  KRSqueezedTextLabel*  statusBarLabelGroup() const { return s_tatusGroup; }
  KRSqueezedTextLabel*  statusBarLabelFilter() const { return s_tatusFilter; }
  public: //The dcop interface
  // Implementation of KNodeIface
  /* Navigation */
  // Move to the next article
  virtual void nextArticle();
  // Move to the previous article
  virtual void previousArticle();
  // Move to the next unread article
  virtual void nextUnreadArticle();
  // Move to the next unread thread
  virtual void nextUnreadThread();
  // Move to the next group
  virtual void nextGroup();
  // Move to the previous group
  virtual void previousGroup();

  /* Group options */
  // Open the editor to post a new article in the selected group
  virtual void postArticle();
  // Fetch the new headers in the selected groups
  virtual void fetchHeadersInCurrentGroup();
  // Expire the articles in the current group
  virtual void expireArticlesInCurrentGroup();
  // Mark all the articles in the current group as read
  virtual void markAllAsRead();
  // Mark all the articles in the current group as unread
  virtual void markAllAsUnread();

  /* Header view */
  // Mark the current article as read
  virtual void markAsRead();
  // Mark the current article as unread
  virtual void markAsUnread();
  // Mark the current thread as read
  virtual void markThreadAsRead();
  // Mark the current thread as unread
  virtual void markThreadAsUnread();

  /* Articles */

  // Send the pending articles
  virtual void sendPendingMessages();
  // Delete the current article
  virtual void deleteArticle();
  // Send the current article
  virtual void sendNow();
  // Edit the current article
  virtual void editArticle();
  /// Fetch all the new article headers
  virtual void fetchHeaders();
  /// Expire articles in all groups
  virtual void expireArticles();

  /* Kontact integration */
  /// Process command-line options
  virtual bool handleCommandLine();

  //end dcop interface
signals:
  void signalCaptionChangeRequest( const TQString& );

protected:

  TDEActionCollection* actionCollection() const;
  KXMLGUIFactory *factory() const;

  void initActions();
  void iniStatusBar();

  /** checks if run for the first time, sets some global defaults (email configuration) */
  bool firstStart();

  void readOptions();
  void saveOptions();

  bool requestShutdown();

  virtual void showEvent(TQShowEvent *);

  /** update appearance */
  virtual void fontChange( const TQFont & );
  virtual void paletteChange ( const TQPalette & );

  bool eventFilter(TQObject *, TQEvent *);

  // convenience methods...
  void getSelectedArticles( TQValueList<KNArticle*> &l );
  void getSelectedArticles( TQValueList<KNRemoteArticle*> &l );
  void getSelectedThreads( TQValueList<KNRemoteArticle*> &l );
  void getSelectedArticles( TQValueList<KNLocalArticle*> &l );
  void closeCurrentThread();

  //GUI
  TDEAccel          *a_ccel;
  KNProgress      *p_rogBar;
  KNode::ArticleWidget *mArticleViewer;
  KNCollectionView *c_olView;
  KNHeaderView      *h_drView;
  KDockWidget     *c_olDock, *h_drDock, *a_rtDock;
  bool b_lockui;
  TDEToolBar        *q_uicksearch;
  TQLineEdit       *s_earchLineEdit;

  //Core
  KNConfigManager   *c_fgManager;
  KNNetAccess       *n_etAccess;
  KNAccountManager  *a_ccManager;
  KNGroupManager    *g_rpManager;
  KNArticleManager  *a_rtManager;
  KNArticleFactory  *a_rtFactory;
  KNFolderManager   *f_olManager;
  KNFilterManager   *f_ilManager;
  KNScoringManager  *s_coreManager;
  KNMemoryManager   *m_emManager;
  Kpgp::Module      *p_gp;

protected slots:
  //listview slots
  void slotArticleSelected(TQListViewItem*);
  void slotArticleSelectionChanged();
  void slotCollectionSelected(TQListViewItem*);
  void slotCollectionRenamed(TQListViewItem*);
  void slotCollectionViewDrop(TQDropEvent* e, KNCollectionViewItem* after);
  void slotArticleRMB(TDEListView*, TQListViewItem *i, const TQPoint &p);
  void slotCollectionRMB(TDEListView*, TQListViewItem *i, const TQPoint &p);
  /** Open selected article in own composer/reader window */
  void slotOpenArticle(TQListViewItem *item);
  void slotHdrViewSortingChanged(int i);

  //network slots
  void slotNetworkActive(bool b);

  //dock widget slots
  void slotCheckDockWidgeStatus();
  void slotGroupDockHidden();
  void slotHeaderDockHidden();
  void slotArticleDockHidden();
  void slotDockWidgetFocusChangeRequest(TQWidget *w);

  //---------------------------------- <Actions> ----------------------------------

protected:

  //navigation
  TDEAction   *a_ctNavNextArt,
    *a_ctNavPrevArt,
    *a_ctNavNextUnreadArt,
    *a_ctNavNextUnreadThread,
    *a_ctNavNextGroup,
    *a_ctNavPrevGroup,
    *a_ctNavReadThrough;

  //collection-view - accounts
  TDEAction   *a_ctAccProperties,
    *a_ctAccRename,
    *a_ctAccSubscribe,
    *a_ctAccExpireAll,
    *a_ctAccGetNewHdrs,
    *a_ctAccGetNewHdrsAll,
    *a_ctAccDelete,
    *a_ctAccPostNewArticle;

  //collection-view - groups
  TDEAction   *a_ctGrpProperties,
    *a_ctGrpRename,
    *a_ctGrpGetNewHdrs,
    *a_ctGrpExpire,
    *a_ctGrpReorganize,
    *a_ctGrpUnsubscribe,
    *a_ctGrpSetAllRead,
    *a_ctGrpSetAllUnread,
    *a_ctGrpSetUnread;

  //collection-view - folder
  TDEAction   *a_ctFolNew,
    *a_ctFolNewChild,
    *a_ctFolDelete,
    *a_ctFolRename,
    *a_ctFolCompact,
    *a_ctFolCompactAll,
    *a_ctFolEmpty,
    *a_ctFolMboxImport,
    *a_ctFolMboxExport;

  //header-view - list-handling
  TDESelectAction         *a_ctArtSortHeaders;
  KNFilterSelectAction  *a_ctArtFilter;
  TDEAction               *a_ctArtSortHeadersKeyb,
    *a_ctArtFilterKeyb,
    *a_ctArtSearch,
    *a_ctArtRefreshList,
    *a_ctArtCollapseAll,
    *a_ctArtExpandAll,
    *a_ctArtToggleThread;
  TDEToggleAction         *a_ctArtToggleShowThreads;

  //header-view - remote articles
  TDEAction *a_ctArtSetArtRead,
    *a_ctArtSetArtUnread,
    *a_ctArtSetThreadRead,
    *a_ctArtSetThreadUnread,
    *a_ctArtOpenNewWindow;

  // scoring
  TDEAction *a_ctScoresEdit,
    *a_ctReScore,
    *a_ctScoreLower,
    *a_ctScoreRaise,
    *a_ctArtToggleIgnored,
    *a_ctArtToggleWatched;

  //header-view local articles
  TDEAction *a_ctArtSendOutbox,
    *a_ctArtDelete,
    *a_ctArtSendNow,
    *a_ctArtEdit;

  //network
  TDEAction *a_ctNetCancel;

  TDEAction *a_ctFetchArticleWithID;

  // settings menu
  TDEToggleAction *a_ctToggleGroupView,
    *a_ctToggleHeaderView,
    *a_ctToggleArticleViewer,
    *a_ctToggleQuickSearch;
  TDEAction *a_ctSwitchToGroupView,
    *a_ctSwitchToHeaderView,
    *a_ctSwitchToArticleViewer;

protected slots:
  void slotNavNextUnreadArt();
  void slotNavNextUnreadThread();
  void slotNavReadThrough();

  void slotAccProperties();
  void slotAccRename();
  void slotAccSubscribe();
  void slotAccExpireAll();
  void slotAccGetNewHdrs();
  void slotAccGetNewHdrsAll();
  void slotAccDelete();
  void slotAccPostNewArticle();

  void slotGrpProperties();
  void slotGrpRename();
  void slotGrpGetNewHdrs();
  void slotGrpExpire();
  void slotGrpReorganize();
  void slotGrpUnsubscribe();
  void slotGrpSetAllRead();
  void slotGrpSetAllUnread();
  void slotGrpSetUnread();

  void slotFolNew();
  void slotFolNewChild();
  void slotFolDelete();
  void slotFolRename();
  void slotFolCompact();
  void slotFolCompactAll();
  void slotFolEmpty();
  void slotFolMBoxImport();
  void slotFolMBoxExport();

  void slotArtSortHeaders(int i);
  void slotArtSortHeadersKeyb();
  void slotArtSearch();
  void slotArtRefreshList();
  void slotArtCollapseAll();
  void slotArtExpandAll();
  void slotArtToggleThread();
  void slotArtToggleShowThreads();

  void slotArtSetArtRead();
  void slotArtSetArtUnread();
  void slotArtSetThreadRead();
  void slotArtSetThreadUnread();

  void slotScoreEdit();
  void slotReScore();
  void slotScoreLower();
  void slotScoreRaise();
  void slotArtToggleIgnored();
  void slotArtToggleWatched();

  void slotArtOpenNewWindow();
  void slotArtSendOutbox();
  void slotArtDelete();
  void slotArtSendNow();
  void slotArtEdit();

  void slotNetCancel();

  void slotFetchArticleWithID();

  void slotToggleGroupView();
  void slotToggleHeaderView();
  void slotToggleArticleViewer();
  void slotToggleQuickSearch();
  void slotSwitchToGroupView();
  void slotSwitchToHeaderView();
  void slotSwitchToArticleViewer();
  void slotSettings();

  //--------------------------- </Actions> -----------------------------

private:
  KRSqueezedTextLabel *s_tatusGroup; // widget used in the statusBar() for the group status
  KRSqueezedTextLabel *s_tatusFilter;
  KXMLGUIClient *m_GUIClient;
};


class  FetchArticleIdDlg : public KDialogBase
{
    TQ_OBJECT
  
public:
    FetchArticleIdDlg(TQWidget *parent, const char */*name*/ );
    TQString messageId() const;

protected slots:
    void slotTextChanged(const TQString & );
protected:
    KLineEdit *edit;
};

#endif