kmail

kmfoldertree.h
1 /*
2  This file is part of the KDE libraries
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 #ifndef __KMFOLDERTREE
19 #define __KMFOLDERTREE
20 
21 #include "foldertreebase.h"
22 
23 #include <tdelocale.h>
24 #include <tdemacros.h>
25 
26 #include <tqguardedptr.h>
27 #include <tqwidget.h>
28 #include <tqtimer.h>
29 #include <tqheader.h>
30 
31 class TQDropEvent;
32 class TQPixmap;
33 class TQPainter;
34 class TQPopupMenu;
35 class TDEPopupMenu;
36 class KMFolder;
37 class KMFolderDir;
38 class KMFolderImap;
39 class KMFolderTree;
40 class KMAccount;
41 // duplication from kmcommands.h, to avoid the include
42 typedef TQMap<int,KMFolder*> KMMenuToFolder;
43 template <typename T> class TQGuardedPtr;
44 
45 class TDE_EXPORT KMFolderTreeItem : public TQObject, public KFolderTreeItem
46 {
47  TQ_OBJECT
48 
49 public:
51  KMFolderTreeItem( KFolderTree *parent, const TQString & name,
52  KFolderTreeItem::Protocol protocol=KFolderTreeItem::NONE );
53 
55  KMFolderTreeItem( KFolderTree *parent, const TQString & name,
56  KMFolder* folder );
57 
59  KMFolderTreeItem( KFolderTreeItem* parent, const TQString & name,
60  KMFolder* folder );
61  virtual ~KMFolderTreeItem();
62 
63  TQPixmap normalIcon( int size ) const;
64  TQPixmap unreadIcon( int size ) const;
65 
66  void setNeedsRepaint( bool value ) { mNeedsRepaint = value; }
67  bool needsRepaint() const { return mNeedsRepaint; }
68 
70  KMFolder* folder() const { return mFolder; }
71  TQListViewItem* parent() const { return KFolderTreeItem::parent(); }
72 
75  void adjustUnreadCount( int newUnreadCount );
76 
78  virtual bool acceptDrag(TQDropEvent* e) const;
79 
80 signals:
82  void iconChanged( KMFolderTreeItem * );
84  void nameChanged( KMFolderTreeItem * );
85 
86 public slots:
87  void properties();
88  void assignShortcut();
89  void slotShowExpiryProperties();
90  void slotIconsChanged();
91  void slotNameChanged();
92  void slotNoContentChanged();
93  void updateCount();
94 
95 protected:
96  void init();
97  KMFolder* mFolder;
99  virtual bool useTopLevelIcon() const { return depth() == 0; }
101  virtual int iconSize() const { return 16; }
102 
103 private:
104  bool mNeedsRepaint;
105 };
106 
107 //==========================================================================
108 
109 class KMFolderTree : public KMail::FolderTreeBase
110 {
111  TQ_OBJECT
112 
113 
114 public:
115  KMFolderTree( KMMainWidget *mainWidget, TQWidget *parent=0,
116  const char *name=0 );
117 
119  void writeConfig();
120 
122  virtual void addDirectory( KMFolderDir *fdir, KMFolderTreeItem* parent );
123 
125  void createFolderList( TQStringList *str,
126  TQValueList<TQGuardedPtr<KMFolder> > *folders,
127  bool localFolders=true,
128  bool imapFolders=true,
129  bool dimapFolders=true,
130  bool searchFolders=false,
131  bool includeNoContent=true,
132  bool includeNoChildren=true );
133 
135  virtual void readConfig(void);
136 
138  void cleanupConfigFile();
139 
141  void nextUnreadFolder(bool confirm);
142 
144  bool checkUnreadFolder(KMFolderTreeItem* ftl, bool confirm);
145 
146  KMFolder *currentFolder() const;
147 
148  TQValueList<TQGuardedPtr<KMFolder> > selectedFolders();
149 
150  enum ColumnMode {unread=15, total=16, foldersize=17};
151 
153  void toggleColumn(int column, bool openFolders = false);
154 
157  virtual void updatePopup() const;
158 
160  void showFolder( KMFolder* );
161 
163  enum MenuAction {
164  CopyMessage,
165  MoveMessage,
166  CopyFolder,
167  MoveFolder
168  };
169 
171  void folderToPopupMenu( MenuAction action, TQObject *receiver, KMMenuToFolder *,
172  TQPopupMenu *menu, TQListViewItem *start = 0 );
173 
174 signals:
176  void folderSelected(KMFolder*);
177 
179  void folderSelectedUnread( KMFolder * );
180 
182  void syncStateChanged();
183 
185  void columnsChanged();
186 
188  void iconChanged( KMFolderTreeItem * );
189 
191  void nameChanged( KMFolderTreeItem * );
192 
193 public slots:
195  virtual void reload(bool openFolders = false);
196 
198  void nextUnreadFolder();
199 
201  void prevUnreadFolder();
202 
204  void incCurrentFolder();
205 
207  void decCurrentFolder();
208 
210  void selectCurrentFolder();
211 
213  void delayedUpdate();
214 
216  void slotAccountRemoved(KMAccount*);
217 
219  void doFolderSelected(TQListViewItem *qlvi, bool keepSelection = false);
220 
226  void slotResetFolderList( TQListViewItem* item = 0, bool startList = true );
227 
229  void addChildFolder( KMFolder *folder = 0, TQWidget * parent = 0 );
230 
232  void copyFolder();
233 
235  void cutFolder();
236 
238  void pasteFolder();
239 
241  void delayedReload();
242 
243 protected slots:
244  // void slotRMB(int, int);
246  void doFolderListChanged();
247 
249  void slotFolderRemoved(KMFolder *);
250 
252  void slotFolderMoveOrCopyOperationFinished();
253 
255  void refresh();
256 
258  void openFolder();
259 
261  void slotFolderExpanded( TQListViewItem * item );
262 
264  void slotFolderCollapsed( TQListViewItem * item );
265 
267  void slotRenameFolder( TQListViewItem * item, int col, const TQString& text);
268 
270  void slotUpdateCountsDelayed(KMFolder * folder);
271  void slotUpdateCountTimeout();
272  void slotUpdateOneCount();
273 
275  void slotToggleUnreadColumn();
276  void slotToggleTotalColumn();
277  void slotToggleSizeColumn();
278 
279  void slotContextMenuRequested( TQListViewItem *, const TQPoint & );
280 
282  void slotCheckMail();
283 
284  void slotNewMessageToMailingList();
285 
287  virtual void moveSelectedToFolder( int menuId );
289  virtual void copySelectedToFolder( int menuId );
290 
292  void updateCopyActions();
293 
294  void slotSyncStateChanged();
295 
296 protected:
297  virtual void contentsMousePressEvent( TQMouseEvent *e );
298  virtual void contentsMouseReleaseEvent(TQMouseEvent* me);
299 
301  virtual void updateUnreadAll( );
302 
303  virtual void resizeEvent(TQResizeEvent*);
304 
306  bool readIsListViewItemOpen(KMFolderTreeItem *fti);
307  void writeIsListViewItemOpen(KMFolderTreeItem *fti);
308 
309  TQTimer mUpdateTimer;
310 
312  void contentsDragEnterEvent( TQDragEnterEvent *e );
313  void contentsDragMoveEvent( TQDragMoveEvent *e );
314  void contentsDragLeaveEvent( TQDragLeaveEvent *e );
315  void contentsDropEvent( TQDropEvent *e );
316  virtual TQDragObject* dragObject();
317 
319  TQListViewItem *oldCurrent, *oldSelected;
320  TQListViewItem *dropItem;
321  KMFolderTreeItem *mLastItem;
322  TQTimer autoopen_timer;
323 
324  // filter some rmb-events
325  bool eventFilter(TQObject*, TQEvent*);
326 
328  void prepareItem( KMFolderTreeItem* );
329 
331  void connectSignals();
332 
334  void moveOrCopyFolder( TQValueList<TQGuardedPtr<KMFolder> > sources, KMFolder* destination, bool move=false );
335 
336 private slots:
337  void slotAddToFavorites();
338  void slotUnhideLocalInbox();
339 
340 private:
342  TQListViewItemIterator mUpdateIterator;
343 
345  TDEPopupMenu* mPopup;
346  int mUnreadPop;
347  int mTotalPop;
348  int mSizePop;
349 
350  bool mReloading;
351  TQValueList<TQGuardedPtr<KMFolder> > mCopySourceFolders;
352  bool mCutFolder;
353 
354  TQTimer *mUpdateCountTimer;
355  TQMap<TQString,KMFolder*> mFolderToUpdateCount;
356 
358  KMMenuToFolder mMenuToFolder;
359 };
360 
361 #endif
KMail list that manages the contents of one directory that may contain folders and/or other directori...
Definition: kmfolderdir.h:16
Mail folder.
Definition: kmfolder.h:69