libtdepim

kfoldertree.h
1 /*
2  This file is part of libtdepim.
3 
4  Copyright (C) 2002 Carsten Burghardt <burghardt@kde.org>
5  Copyright (C) 2002 Marc Mutz <mutz@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License version 2 as published by the Free Software Foundation.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 #ifndef __KFOLDERTREE
22 #define __KFOLDERTREE
23 
24 #include <tqpixmap.h>
25 #include <tqbitarray.h>
26 #include <tqdragobject.h>
27 #include <tqcolor.h>
28 #include <tdelistview.h>
29 #include <kdemacros.h>
30 
31 class KFolderTree;
32 
34 struct KPaintInfo {
35 
36  // Popup ids for toggle-able columns
37  enum ColumnIds
38  {
39  COL_SIZE,
40  COL_ATTACHMENT,
41  COL_INVITATION,
42  COL_IMPORTANT,
43  COL_TODO,
44  COL_SPAM_HAM,
45  COL_WATCHED_IGNORED,
46  COL_STATUS,
47  COL_SIGNED,
48  COL_CRYPTO,
49  COL_RECEIVER,
50  COL_SCORE
51  };
52 
53  KPaintInfo() :
54  pixmapOn(false),
55 
56  showSize(false),
57  showAttachment(false),
58  showInvitation(false),
59  showImportant(false),
60  showTodo(false),
61  showSpamHam(false),
62  showWatchedIgnored(false),
63  showStatus(false),
64  showSigned(false),
65  showCrypto(false),
66  showReceiver(false),
67  showScore(false),
68 
69  scoreCol(-1),
70  flagCol(-1),
71  senderCol(-1),
72  receiverCol(-1),
73  subCol(-1),
74  dateCol(-1),
75  sizeCol(-1),
76  attachmentCol(-1),
77  invitationCol(-1),
78  importantCol(-1),
79  todoCol(-1),
80  spamHamCol(-1),
81  watchedIgnoredCol(-1),
82  statusCol(-1),
83  signedCol(-1),
84  cryptoCol(-1),
85 
86  orderOfArrival(false),
87  status(false),
88  showCryptoIcons(false),
89  showAttachmentIcon(false),
90  showInvitationIcon(false)
91  {}
92 
93  bool pixmapOn;
94  TQPixmap pixmap;
95  TQColor colFore;
96  TQColor colBack;
97  TQColor colNew;
98  TQColor colUnread;
99  TQColor colFlag;
100  TQColor colTodo;
101  TQColor colCloseToQuota;
102 
103  bool showSize;
104  bool showAttachment;
105  bool showInvitation;
106  bool showImportant;
107  bool showTodo;
108  bool showSpamHam;
109  bool showWatchedIgnored;
110  bool showStatus;
111  bool showSigned;
112  bool showCrypto;
113  bool showReceiver;
114  bool showScore;
115 
116  int scoreCol;
117  int flagCol;
118  int senderCol;
119  int receiverCol;
120  int subCol;
121  int dateCol;
122  int sizeCol;
123  int attachmentCol;
124  int invitationCol;
125  int importantCol;
126  int todoCol;
127  int spamHamCol;
128  int watchedIgnoredCol;
129  int statusCol;
130  int signedCol;
131  int cryptoCol;
132 
133  bool orderOfArrival;
134  bool status;
135  bool showCryptoIcons;
136  bool showAttachmentIcon;
137  bool showInvitationIcon;
138 };
139 
140 //==========================================================================
141 
142 class TDE_EXPORT KFolderTreeItem : public TDEListViewItem
143 {
144  public:
146  enum Protocol {
147  Imap,
148  Local,
149  News,
150  CachedImap,
151  Search,
152  NONE
153  };
154 
156  enum Type {
157  Inbox,
158  Outbox,
159  SentMail,
160  Trash,
161  Drafts,
162  Templates,
163  Root,
164  Calendar,
165  Tasks,
166  Journals,
167  Contacts,
168  Notes,
169  Other
170  };
171 
173  KFolderTreeItem( KFolderTree *parent, const TQString & label=TQString(),
174  Protocol protocol=NONE, Type type=Root );
175 
177  KFolderTreeItem( KFolderTreeItem *parent, const TQString & label=TQString(),
178  Protocol protocol=NONE, Type type=Other, int unread=0, int total=0 );
179 
181  virtual int compare( TQListViewItem * i, int col,
182  bool ascending ) const;
183 
185  int unreadCount() { return mUnread; }
186  virtual void setUnreadCount( int aUnread );
187 
189  int totalCount() { return mTotal; }
190  virtual void setTotalCount( int aTotal );
191 
193  TQ_INT64 folderSize() { return mSize; }
194  virtual void setFolderSize( TQ_INT64 aSize );
195 
197  Protocol protocol() const { return mProtocol; }
198  virtual void setProtocol( Protocol aProtocol ) { mProtocol = aProtocol; }
199 
201  Type type() const { return mType; }
202  virtual void setType( Type aType ) { mType = aType; }
203 
205  virtual int countUnreadRecursive();
206 
207  virtual TQ_INT64 recursiveFolderSize() const;
208 
210  virtual void paintCell( TQPainter * p, const TQColorGroup & cg,
211  int column, int width, int align );
212 
214  virtual bool acceptDrag(TQDropEvent* ) const { return true; }
215 
216  void setFolderIsCloseToQuota( bool );
217  bool folderIsCloseToQuota() const;
218 
219  private:
221  int protocolSortingKey() const;
223  int typeSortingKey() const;
224 
225  protected:
227  virtual TQString squeezeFolderName( const TQString &text,
228  const TQFontMetrics &fm,
229  uint width ) const;
230 
231  Protocol mProtocol;
232  Type mType;
233  int mUnread;
234  int mTotal;
235  TQ_INT64 mSize;
236  bool mFolderIsCloseToQuota;
237 };
238 
239 //==========================================================================
240 
241 class TDE_EXPORT KFolderTree : public TDEListView
242 {
243  TQ_OBJECT
244 
245 
246  public:
247  KFolderTree( TQWidget *parent, const char *name=0 );
248 
253  virtual void addAcceptableDropMimetype( const char *mimeType, bool outsideOk );
254 
256  virtual bool acceptDrag( TQDropEvent* event ) const;
257 
259  KPaintInfo paintInfo() const { return mPaintInfo; }
260 
262  virtual void addUnreadColumn( const TQString & name, int width=70 );
263  virtual void removeUnreadColumn();
264  virtual void addTotalColumn( const TQString & name, int width=70 );
265  virtual void removeTotalColumn();
266  virtual void addSizeColumn( const TQString & name, int width=70 );
267  virtual void removeSizeColumn();
268 
269 
271  int unreadIndex() const { return mUnreadIndex; }
272  int totalIndex() const { return mTotalIndex; }
273  int sizeIndex() const { return mSizeIndex; }
274 
276  bool isUnreadActive() const { return mUnreadIndex >= 0; }
277  bool isTotalActive() const { return mTotalIndex >= 0; }
278  bool isSizeActive() const { return mSizeIndex >= 0; }
279 
281  virtual void setFullWidth( bool fullWidth );
282 
283  protected:
286  void styleChange( TQStyle& oldStyle );
287 
290  void setStyleDependantFrameWidth();
291 
292  virtual void drawContentsOffset( TQPainter * p, int ox, int oy,
293  int cx, int cy, int cw, int ch );
294 
295  virtual void contentsMousePressEvent( TQMouseEvent *e );
296  virtual void contentsMouseReleaseEvent( TQMouseEvent *e );
297 
299  TQMemArray<const char*> mAcceptableDropMimetypes;
300  TQBitArray mAcceptOutside;
301  // ### why isn't it then static? ;-)
303  KPaintInfo mPaintInfo;
304 
307  int mUnreadIndex;
308  int mTotalIndex;
309  int mSizeIndex;
310 
311  private slots:
314  void slotSizeChanged( int section, int oldSize, int newSize );
315 
316 };
317 
318 #endif
Information shared by all items in a list view.
Definition: kfoldertree.h:34