• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

knode

  • sources
  • kde-4.12
  • kdepim
  • knode
foldertreewidget.h
Go to the documentation of this file.
1 #ifndef KDEPIM_FOLDERTREEWIDGET_H
2 #define KDEPIM_FOLDERTREEWIDGET_H
3 
4 /******************************************************************************
5  *
6  * This file is part of libkdepim.
7  *
8  * Copyright (C) 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public License
21  * along with this library; see the file COPYING.LIB. If not, write to
22  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  *
25  *****************************************************************************/
26 
31 #include "knode_export.h"
32 #include "treewidget.h"
33 
34 #include <QHash>
35 #include <QColor>
36 
37 namespace KPIM
38 {
39 
40 class FolderTreeWidgetItem;
41 
73 class KNODE_EXPORT FolderTreeWidget : public KPIM::TreeWidget
74 {
75  friend class FolderTreeWidgetItemLabelColumnDelegate;
76  Q_OBJECT
77 public:
81  explicit FolderTreeWidget( QWidget *parent , const char *name = 0 );
82 
83 private:
87  void emitRenamed( QTreeWidgetItem *item );
88  int mLabelColumnIndex;
89  int mUnreadColumnIndex;
90  int mTotalColumnIndex;
91  int mDataSizeColumnIndex;
92 
93  QColor mUnreadCountColor;
94  QColor mCloseToQuotaWarningColor;
95 
96 public:
102  int addLabelColumn( const QString &headerLabel );
103 
108  int labelColumnIndex() const
109  { return mLabelColumnIndex; };
110 
114  bool labelColumnVisible() const;
115 
121  int addUnreadColumn( const QString &headerLabel );
122 
127  int unreadColumnIndex() const
128  { return mUnreadColumnIndex; };
129 
133  bool unreadColumnVisible() const;
134 
140  int addTotalColumn( const QString &headerLabel );
141 
146  int totalColumnIndex() const
147  { return mTotalColumnIndex; };
148 
152  bool totalColumnVisible() const;
153 
159  int addDataSizeColumn( const QString &headerLabel );
160 
165  int dataSizeColumnIndex() const
166  { return mDataSizeColumnIndex; };
167 
171  bool dataSizeColumnVisible() const;
172 
177  const QColor & closeToQuotaWarningColor() const
178  { return mCloseToQuotaWarningColor; };
179 
184  void setCloseToQuotaWarningColor( const QColor &clr );
185 
189  const QColor & unreadCountColor() const
190  { return mUnreadCountColor; };
191 
195  void setUnreadCountColor( const QColor &clr );
196 
200  void updateColumnForItem( FolderTreeWidgetItem * item, int columnIndex );
201 
202 Q_SIGNALS:
207  void renamed( QTreeWidgetItem *item );
208 
209 private Q_SLOTS:
210 
215  void updateExpandedState( QTreeWidgetItem *item );
216 };
217 
218 class FolderTreeWidgetItemLabelColumnDelegate;
219 
225 class KNODE_EXPORT FolderTreeWidgetItem : public QTreeWidgetItem
226 {
227  friend class FolderTreeWidgetItemLabelColumnDelegate;
228 public:
234  enum Protocol {
235  Local, Imap, CachedImap, News, Search, NONE
236  };
237 
244  // FIXME: Rename to FolderItemType
245  enum FolderType {
246  Inbox, Outbox, SentMail, Trash, Drafts, Templates, Root,
247  Calendar, Tasks, Journals, Contacts, Notes, Other
248  };
249 
250 private:
251  Protocol mProtocol;
252  FolderType mFolderType;
253  QString mLabelText;
254  int mTotalCount;
255  int mUnreadCount;
256  qint64 mDataSize;
257  unsigned int mIsCloseToQuota:1;
258  unsigned int mLabelTextElided:1;
259  int mChildrenTotalCount;
260  int mChildrenUnreadCount;
261  qint64 mChildrenDataSize;
262  bool mAlwaysDisplayCounts;
263 
264 public:
268  explicit FolderTreeWidgetItem(
269  FolderTreeWidget *parent,
270  const QString &label,
271  Protocol protocol,
272  FolderType folderType
273  );
274 
278  explicit FolderTreeWidgetItem(
279  FolderTreeWidgetItem *parent,
280  const QString &label,
281  Protocol protocol,
282  FolderType folderType
283  );
284 
285 public:
289  bool isCloseToQuota() const
290  { return mIsCloseToQuota; };
291 
295  void setIsCloseToQuota( bool closeToQuota );
296 
300  const QString & labelText() const
301  { return mLabelText; };
302 
306  void setLabelText( const QString &label );
307 
312  int unreadCount() const
313  { return mUnreadCount; };
314 
318  void setUnreadCount( int unreadCount );
319 
324  int totalCount() const
325  { return mTotalCount; };
326 
330  void setTotalCount( int totalCount );
331 
337  qint64 dataSize() const
338  { return mDataSize; };
339 
344  void setDataSize( qint64 s );
345 
350  int childrenUnreadCount() const
351  { return mChildrenUnreadCount; };
352 
357  int childrenTotalCount() const
358  { return mChildrenTotalCount; };
359 
364  qint64 childrenDataSize() const
365  { return mChildrenDataSize; };
366 
374  bool updateChildrenCounts();
375 
379  Protocol protocol() const
380  { return mProtocol; };
381 
385  void setProtocol( Protocol protocol )
386  { mProtocol = protocol; };
387 
391  QString protocolDescription() const;
392 
396  FolderType folderType() const
397  { return mFolderType; };
398 
402  void setFolderType( FolderType folderType )
403  { mFolderType = folderType; };
404 
408  virtual bool operator < ( const QTreeWidgetItem &other ) const;
409 
413  void updateColumn( int columnIndex );
414 
421  void updateExpandedState();
422 
428  bool labelTextElided() const
429  { return mLabelTextElided; };
430 
438  bool alwaysDisplayCounts() const
439  { return mAlwaysDisplayCounts; };
440 
448  void setAlwaysDisplayCounts( bool alwaysDisplayCounts )
449  { mAlwaysDisplayCounts = alwaysDisplayCounts; };
450 
451 protected:
456  void setLabelTextElided( bool labelTextElided )
457  { mLabelTextElided = labelTextElided ? 1 : 0; };
458 
464  virtual QString elidedLabelText( const QFontMetrics &metrics, unsigned int width ) const;
465 };
466 
467 } // namespace KPIM
468 
469 #endif
KPIM::FolderTreeWidgetItem::childrenUnreadCount
int childrenUnreadCount() const
Returns the unread message count for the children.
Definition: foldertreewidget.h:350
KPIM::TreeWidget
A QTreeWidget with expanded capabilities.
Definition: treewidget.h:56
treewidget.h
A common QTreeWidget extension.
KPIM::FolderTreeWidgetItem::totalCount
int totalCount() const
Returns the total message count.
Definition: foldertreewidget.h:324
KPIM::FolderTreeWidgetItem
A folder tree node to be used with FolderTreeWidget.
Definition: foldertreewidget.h:225
KPIM::FolderTreeWidget
A tree widget useful for displaying a tree of folders containing messages.
Definition: foldertreewidget.h:73
KPIM::FolderTreeWidget::unreadColumnIndex
int unreadColumnIndex() const
Returns the logical index of the "Unread" column or -1 if such a column has not been added (yet)...
Definition: foldertreewidget.h:127
KPIM::FolderTreeWidget::totalColumnIndex
int totalColumnIndex() const
Returns the logical index of the "Total" column or -1 if such a column has not been added (yet)...
Definition: foldertreewidget.h:146
QWidget
KPIM::FolderTreeWidgetItem::folderType
FolderType folderType() const
Returns the type of the folder.
Definition: foldertreewidget.h:396
KPIM::FolderTreeWidget::closeToQuotaWarningColor
const QColor & closeToQuotaWarningColor() const
Returns the color used to display the "Label" column text when the item is marked as close to quota...
Definition: foldertreewidget.h:177
KPIM::FolderTreeWidgetItem::Tasks
Definition: foldertreewidget.h:247
KPIM::FolderTreeWidgetItem::setLabelTextElided
void setLabelTextElided(bool labelTextElided)
This is called by FolderTreeWidgetItemLabelColumnDelegate to update the mLabelTextElided flag...
Definition: foldertreewidget.h:456
KPIM::FolderTreeWidgetItem::Trash
Definition: foldertreewidget.h:246
KPIM::FolderTreeWidgetItem::alwaysDisplayCounts
bool alwaysDisplayCounts() const
Returns true if this item should bypass the size, total and unread display logic. ...
Definition: foldertreewidget.h:438
knode_export.h
KPIM::FolderTreeWidgetItem::FolderType
FolderType
Folder type information Please note that this list should be kept in the order of items that one want...
Definition: foldertreewidget.h:245
KPIM::FolderTreeWidgetItem::dataSize
qint64 dataSize() const
Returns the size in bytes of the folder, displayed in the special "DataSize" column.
Definition: foldertreewidget.h:337
KPIM::FolderTreeWidgetItem::unreadCount
int unreadCount() const
Returns the unread message count.
Definition: foldertreewidget.h:312
KPIM::FolderTreeWidgetItem::setFolderType
void setFolderType(FolderType folderType)
Sets the type of the folder.
Definition: foldertreewidget.h:402
KPIM::FolderTreeWidgetItem::protocol
Protocol protocol() const
Returns the protocol associated to the folder item.
Definition: foldertreewidget.h:379
KPIM::FolderTreeWidget::dataSizeColumnIndex
int dataSizeColumnIndex() const
Returns the logical index of the "DataSize" column or -1 if such a column has not been added (yet)...
Definition: foldertreewidget.h:165
QTreeWidgetItem
KPIM::FolderTreeWidgetItem::childrenTotalCount
int childrenTotalCount() const
Returns the total message count for the children.
Definition: foldertreewidget.h:357
KPIM::FolderTreeWidgetItem::isCloseToQuota
bool isCloseToQuota() const
Returns the sate of the "Close to quota" warning for this folder.
Definition: foldertreewidget.h:289
KPIM::FolderTreeWidgetItem::Search
Definition: foldertreewidget.h:235
KPIM::FolderTreeWidgetItem::Protocol
Protocol
Protocol information associated to the item.
Definition: foldertreewidget.h:234
KPIM::FolderTreeWidgetItem::setAlwaysDisplayCounts
void setAlwaysDisplayCounts(bool alwaysDisplayCounts)
Sets whether this item should bypass the size, total and unread display logic.
Definition: foldertreewidget.h:448
KPIM::FolderTreeWidgetItem::labelText
const QString & labelText() const
Returns the textual data for the "Label" column of the parent FolderTreeWidget.
Definition: foldertreewidget.h:300
KPIM::FolderTreeWidget::unreadCountColor
const QColor & unreadCountColor() const
Returns the color used to display the unread message count in the "Label" column. ...
Definition: foldertreewidget.h:189
KNODE_EXPORT
#define KNODE_EXPORT
Definition: knode_export.h:35
KPIM::FolderTreeWidgetItem::labelTextElided
bool labelTextElided() const
Returns true if the last painting operation had to elide the label text thus making it partially invi...
Definition: foldertreewidget.h:428
KPIM::FolderTreeWidget::labelColumnIndex
int labelColumnIndex() const
Returns the logical index of the "Label" column or -1 if such a column has not been added (yet)...
Definition: foldertreewidget.h:108
KPIM::FolderTreeWidgetItem::setProtocol
void setProtocol(Protocol protocol)
Sets the protocol associated to the folder item.
Definition: foldertreewidget.h:385
KPIM::FolderTreeWidgetItem::childrenDataSize
qint64 childrenDataSize() const
Returns the size in bytes of the children folders displayed in the special "DataSize" column...
Definition: foldertreewidget.h:364
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:36 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knode

Skip menu "knode"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal