• 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.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * This file is part of libkdepim.
4  *
5  * Copyright (C) 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
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 as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  *****************************************************************************/
23 
24 #include "foldertreewidget.h"
25 
26 #include <kio/global.h> // for KIO::filesize_t and related functions
27 #include <klineedit.h>
28 #include <klocale.h>
29 
30 #include <QHeaderView>
31 #include <QDropEvent>
32 #include <QMimeData>
33 #include <QStyledItemDelegate>
34 #include <QStyle>
35 #include <QPainter>
36 #include <QFontMetrics>
37 #include <QApplication>
38 
39 #define FOLDERTREEWIDGETITEM_TYPE ( QTreeWidgetItem::UserType + 0xcafe )
40 
41 
42 namespace KPIM {
43 
44 #define ITEM_LABEL_RIGHT_MARGIN 2
45 #define ITEM_LABEL_TO_UNREADCOUNT_SPACING 2
46 
47 class FolderTreeWidgetItemLabelColumnDelegate : public QStyledItemDelegate
48 {
49 protected:
50  FolderTreeWidget *mFolderTreeWidget;
51 
52 public:
53  FolderTreeWidgetItemLabelColumnDelegate( FolderTreeWidget *parent )
54  : QStyledItemDelegate( parent ), mFolderTreeWidget( parent ) {}
55 
56  ~FolderTreeWidgetItemLabelColumnDelegate()
57  {};
58 
59  virtual QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const
60  {
61  QStyleOptionViewItemV4 opt = option;
62  initStyleOption( &opt, index );
63 
64  opt.text = "X"; // fake a text (so the height is computed correctly)
65  opt.features |= QStyleOptionViewItemV2::HasDisplay;
66 
67  return mFolderTreeWidget->style()->sizeFromContents( QStyle::CT_ItemViewItem, &opt, QSize(), mFolderTreeWidget );
68  }
69 
70  virtual void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
71  {
72  //
73  // The equilibrism in this function attempts to rely on QStyle for most of the job.
74  //
75  QStyleOptionViewItemV4 opt = option;
76  initStyleOption( &opt, index );
77 
78  opt.text = ""; // draw no text for me, please.. I'll do it in a while
79 
80  QStyle * style = mFolderTreeWidget->style();
81 
82  style->drawControl( QStyle::CE_ItemViewItem, &opt, painter, mFolderTreeWidget );
83 
84  // FIXME: this is plain ugly :D
85  // OTOH seaching the item by model index is extremely expensive when compared to a cast.
86  // We're also using static_cast<> instead of dynamic_cast<> to avoid performance loss:
87  // we actually trust the developer to add only real FolderTreeWidgetItems to this widget.
88  FolderTreeWidgetItem * item = static_cast<FolderTreeWidgetItem *>( index.internalPointer() );
89  if ( !item )
90  return; // ugh :/
91 
92  // draw the labelText().
93  QRect textRect = style->subElementRect( QStyle::SE_ItemViewItemText, &opt, mFolderTreeWidget );
94  textRect.setWidth( textRect.width() - ITEM_LABEL_RIGHT_MARGIN );
95 
96  // keeping indipendent state variables is faster than saving and restoring the whole painter state
97  QPen oldPen = painter->pen();
98  QFont oldFont = painter->font();
99 
100  if ( item->isCloseToQuota() && ( !( opt.state & QStyle::State_Selected ) ) )
101  {
102  painter->setPen( QPen( mFolderTreeWidget->closeToQuotaWarningColor(), 0 ) );
103  } else {
104  QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
105 
106  if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active))
107  cg = QPalette::Inactive;
108 
109  QPalette::ColorRole cr = ( opt.state & QStyle::State_Selected ) ? QPalette::HighlightedText : QPalette::Text;
110  painter->setPen( QPen( opt.palette.brush( cg, cr ), 0 ) );
111  }
112 
113  int unread = item->unreadCount();
114  int childUnread = item->childrenUnreadCount();
115  bool displayChildUnread = ( childUnread > 0 ) && ( !item->isExpanded() );
116 
117  if ( ( unread > 0 ) || displayChildUnread )
118  {
119  // font is bold for sure (unread stuff in folder)
120  QFont f = opt.font;
121  f.setBold( true );
122  painter->setFont( f );
123 
124  QFontMetrics fm( painter->font() ); // use the bold font metrics
125 
126  if (
127  ( mFolderTreeWidget->unreadColumnIndex() == -1 ) ||
128  mFolderTreeWidget->isColumnHidden( mFolderTreeWidget->unreadColumnIndex() )
129  )
130  {
131  // we need to paint the unread count too
132  QString unreadText;
133 
134  if ( unread > 0 )
135  {
136  if ( displayChildUnread )
137  unreadText = QString("(%1 + %2)").arg( unread ).arg( childUnread );
138  else
139  unreadText = QString("(%1)").arg( unread );
140  } else
141  unreadText = QString("(0 + %1)").arg( childUnread );
142 
143  // compute the potential width so we know if elision has to be performed
144 
145  int unreadWidth = fm.width( unreadText );
146  int labelWidth = fm.width( item->labelText() );
147  int maxWidth = labelWidth + ITEM_LABEL_TO_UNREADCOUNT_SPACING + unreadWidth;
148 
149  QString label;
150  if ( maxWidth > textRect.width() )
151  {
152  // must elide
153  label = item->elidedLabelText( fm, textRect.width() - ( ITEM_LABEL_TO_UNREADCOUNT_SPACING + unreadWidth ) );
154  labelWidth = fm.width( label );
155 
156  // the condition inside this call is an optimization (it's faster than simply label != item->labelText())
157  item->setLabelTextElided( ( label.length() != item->labelText().length() ) || ( label != item->labelText() ) );
158  } else {
159  label = item->labelText();
160  // no elision needed
161  item->setLabelTextElided( false );
162  }
163 
164  painter->drawText( textRect, Qt::AlignLeft | Qt::TextSingleLine | Qt::AlignVCenter, label );
165 
166  if ( QApplication::isLeftToRight() )
167  textRect.setLeft( textRect.left() + labelWidth + ITEM_LABEL_TO_UNREADCOUNT_SPACING );
168  else
169  textRect.setRight( textRect.right() - labelWidth - ITEM_LABEL_TO_UNREADCOUNT_SPACING );
170 
171  if ( !( opt.state & QStyle::State_Selected ) ) {
172  painter->setPen( QPen( mFolderTreeWidget->unreadCountColor(), 0 ) );
173  }
174  painter->drawText( textRect, Qt::AlignLeft | Qt::TextSingleLine | Qt::AlignVCenter, unreadText );
175  } else {
176  // got unread messages: bold font but no special text tricks
177  QString label = item->elidedLabelText( fm, textRect.width() );
178 
179  // the condition inside this call is an optimization (it's faster than simply label != item->labelText())
180  item->setLabelTextElided( ( label.length() != item->labelText().length() ) || ( label != item->labelText() ) );
181 
182  painter->drawText( textRect, Qt::AlignLeft | Qt::TextSingleLine | Qt::AlignVCenter, label );
183  }
184  } else {
185  // no unread messages: normal font, no text tricks
186  QString label = item->elidedLabelText( opt.fontMetrics, textRect.width() );
187 
188  // the condition inside this call is an optimization (it's faster than simply label != item->labelText())
189  item->setLabelTextElided( ( label.length() != item->labelText().length() ) || ( label != item->labelText() ) );
190 
191  painter->setFont( opt.font );
192  painter->drawText( textRect, Qt::AlignLeft | Qt::TextSingleLine | Qt::AlignVCenter, label );
193  }
194 
195  painter->setPen( oldPen );
196  painter->setFont( oldFont );
197  }
198 
199  virtual void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
200  {
201  QStyledItemDelegate::setModelData( editor, model, index );
202  FolderTreeWidgetItem *item = static_cast<FolderTreeWidgetItem *>( index.internalPointer() );
203  if ( item ) {
204  // test if old text != new text
205  if( item->labelText() != item->text( mFolderTreeWidget->labelColumnIndex() ) ) {
206  item->setLabelText( item->text( mFolderTreeWidget->labelColumnIndex() ) );
207  mFolderTreeWidget->emitRenamed( item );
208  }
209  }
210  }
211 };
212 
213 
214 
215 
216 FolderTreeWidget::FolderTreeWidget( QWidget *parent , const char *name )
217 : KPIM::TreeWidget( parent , name ),
218  mUnreadCountColor( Qt::blue ), mCloseToQuotaWarningColor( Qt::red )
219 {
220  mLabelColumnIndex = -1;
221  mUnreadColumnIndex = -1;
222  mTotalColumnIndex = -1;
223  mDataSizeColumnIndex = -1;
224 
225  setAlternatingRowColors( true );
226  setAcceptDrops( true );
227  setAllColumnsShowFocus( true );
228  setRootIsDecorated( true );
229  setSortingEnabled( true );
230  setUniformRowHeights( true ); // optimize please
231  //setAnimated( true ); // this slows down everything a lot
232 
233  header()->setSortIndicatorShown( true );
234  header()->setClickable( true );
235  //setSelectionMode( Extended );
236 
237  connect( this, SIGNAL(itemExpanded(QTreeWidgetItem*)),
238  SLOT(updateExpandedState(QTreeWidgetItem*)) );
239  connect( this, SIGNAL(itemCollapsed(QTreeWidgetItem*)),
240  SLOT(updateExpandedState(QTreeWidgetItem*)) );
241 
242 }
243 
244 int FolderTreeWidget::addLabelColumn( const QString &headerLabel )
245 {
246  if ( mLabelColumnIndex == -1 )
247  {
248  mLabelColumnIndex = addColumn( headerLabel );
249  setItemDelegateForColumn( mLabelColumnIndex, new FolderTreeWidgetItemLabelColumnDelegate( this ) );
250  }
251  return mLabelColumnIndex;
252 }
253 
254 bool FolderTreeWidget::labelColumnVisible() const
255 {
256  if ( mLabelColumnIndex == -1 )
257  return false;
258  return !isColumnHidden( mLabelColumnIndex );
259 }
260 
261 int FolderTreeWidget::addTotalColumn( const QString &headerLabel )
262 {
263  if ( mTotalColumnIndex == -1 )
264  mTotalColumnIndex = addColumn( headerLabel , Qt::AlignRight );
265  return mTotalColumnIndex;
266 }
267 
268 bool FolderTreeWidget::totalColumnVisible() const
269 {
270  if ( mTotalColumnIndex == -1 )
271  return false;
272  return !isColumnHidden( mTotalColumnIndex );
273 }
274 
275 int FolderTreeWidget::addUnreadColumn( const QString &headerLabel )
276 {
277  if ( mUnreadColumnIndex == -1 )
278  mUnreadColumnIndex = addColumn( headerLabel , Qt::AlignRight );
279  return mUnreadColumnIndex;
280 }
281 
282 bool FolderTreeWidget::unreadColumnVisible() const
283 {
284  if ( mUnreadColumnIndex == -1 )
285  return false;
286  return !isColumnHidden( mUnreadColumnIndex );
287 }
288 
289 int FolderTreeWidget::addDataSizeColumn( const QString &headerLabel )
290 {
291  if ( mDataSizeColumnIndex == -1 )
292  mDataSizeColumnIndex = addColumn( headerLabel , Qt::AlignRight );
293  return mDataSizeColumnIndex;
294 }
295 
296 bool FolderTreeWidget::dataSizeColumnVisible() const
297 {
298  if ( mDataSizeColumnIndex == -1 )
299  return false;
300  return !isColumnHidden( mDataSizeColumnIndex );
301 }
302 
303 void FolderTreeWidget::updateColumnForItem( FolderTreeWidgetItem * item, int columnIndex )
304 {
305  update( indexFromItem( item, columnIndex ) );
306 }
307 
308 void FolderTreeWidget::updateExpandedState( QTreeWidgetItem *item )
309 {
310  FolderTreeWidgetItem *folderItem = dynamic_cast<FolderTreeWidgetItem*>( item );
311  Q_ASSERT( folderItem );
312  if ( folderItem )
313  folderItem->updateExpandedState();
314 }
315 
316 void FolderTreeWidget::setCloseToQuotaWarningColor( const QColor &clr )
317 {
318  mCloseToQuotaWarningColor = clr;
319  update();
320 }
321 
322 void FolderTreeWidget::setUnreadCountColor( const QColor &clr )
323 {
324  mUnreadCountColor = clr;
325  update();
326 }
327 
328 void FolderTreeWidget::emitRenamed( QTreeWidgetItem *item )
329 {
330  emit renamed( item );
331 }
332 
333 
334 FolderTreeWidgetItem::FolderTreeWidgetItem(
335  FolderTreeWidget *parent,
336  const QString &label,
337  Protocol protocol,
338  FolderType folderType
339  ) : QTreeWidgetItem( parent, FOLDERTREEWIDGETITEM_TYPE ),
340  mProtocol( protocol ), mFolderType( folderType ), mLabelText( label ),
341  mTotalCount( 0 ), mUnreadCount( 0 ), mDataSize( -1 ), mIsCloseToQuota( 0 ),
342  mLabelTextElided( 0 ), mChildrenTotalCount( 0 ), mChildrenUnreadCount( 0 ),
343  mChildrenDataSize( -1 ), mAlwaysDisplayCounts( false )
344 {
345  setText( parent->labelColumnIndex(), label );
346 }
347 
348 FolderTreeWidgetItem::FolderTreeWidgetItem(
349  FolderTreeWidgetItem *parent,
350  const QString &label,
351  Protocol protocol,
352  FolderType folderType
353  ) : QTreeWidgetItem( parent, FOLDERTREEWIDGETITEM_TYPE ),
354  mProtocol( protocol ), mFolderType( folderType ), mLabelText( label ),
355  mTotalCount( 0 ), mUnreadCount( 0 ), mDataSize( -1 ), mIsCloseToQuota( 0 ),
356  mLabelTextElided( 0 ), mChildrenTotalCount( 0 ), mChildrenUnreadCount( 0 ),
357  mChildrenDataSize( -1 ), mAlwaysDisplayCounts( false )
358 {
359  FolderTreeWidget * tree = dynamic_cast< FolderTreeWidget * >( treeWidget() );
360  if ( tree )
361  setText( tree->labelColumnIndex(), label );
362 }
363 
364 QString FolderTreeWidgetItem::protocolDescription() const
365 {
366  switch( mProtocol )
367  {
368  case Local:
369  return i18n( "Local" );
370  break;
371  case Imap:
372  return i18n( "IMAP" );
373  break;
374  case CachedImap:
375  return i18n( "Cached IMAP" );
376  break;
377  case News:
378  return i18n( "News" );
379  break;
380  case Search:
381  return i18n( "Search" );
382  break;
383  case NONE:
384  return i18n( "None" );
385  break;
386  default:
387  break;
388  }
389 
390  return i18n( "Unknown" );
391 }
392 
393 bool FolderTreeWidgetItem::updateChildrenCounts()
394 {
395  int cc = childCount();
396 
397  if ( cc < 1 )
398  return false;
399 
400  int idx = 0;
401 
402 
403  int oldTotal = mChildrenTotalCount;
404  int oldUnread = mChildrenUnreadCount;
405  qint64 oldSize = mChildrenDataSize;
406 
407  mChildrenTotalCount = 0;
408  mChildrenUnreadCount = 0;
409  mChildrenDataSize = 0;
410 
411  bool gotValidDataSize = false;
412 
413  while ( idx < cc )
414  {
415  FolderTreeWidgetItem *it = static_cast< FolderTreeWidgetItem * >( QTreeWidgetItem::child( idx ) );
416  mChildrenTotalCount += it->totalCount() + it->childrenTotalCount();
417  mChildrenUnreadCount += it->unreadCount() + it->childrenUnreadCount();
418  if ( it->dataSize() >= 0)
419  {
420  gotValidDataSize = true;
421  mChildrenDataSize += it->dataSize();
422  }
423  if ( it->childrenDataSize() >= 0 )
424  {
425  gotValidDataSize = true;
426  mChildrenDataSize += it->childrenDataSize();
427  }
428  idx++;
429  }
430 
431  if ( !gotValidDataSize )
432  mChildrenDataSize = -1; // keep it invald
433 
434  return ( oldTotal != mChildrenTotalCount ) ||
435  ( oldUnread != mChildrenUnreadCount ) ||
436  ( oldSize != mChildrenDataSize );
437 }
438 
439 void FolderTreeWidgetItem::setLabelText( const QString &label )
440 {
441  mLabelText = label;
442  // We set the text of the item so QStyle will compute the height correctly
443  FolderTreeWidget * tree = dynamic_cast< FolderTreeWidget * >( treeWidget() );
444  Q_ASSERT ( tree );
445  int idx = tree->labelColumnIndex();
446  if ( idx >= 0 )
447  {
448  setText( idx, label );
449  setTextAlignment( idx, Qt::AlignRight );
450  }
451 }
452 
453 void FolderTreeWidgetItem::setUnreadCount( int unreadCount )
454 {
455  mUnreadCount = unreadCount;
456  int unreadCountToDisplay = unreadCount;
457 
458  if ( mChildrenUnreadCount > 0 && !isExpanded() )
459  unreadCountToDisplay += mChildrenUnreadCount;
460 
461  FolderTreeWidget * tree = dynamic_cast< FolderTreeWidget * >( treeWidget() );
462  if ( tree )
463  {
464  int idx = tree->unreadColumnIndex();
465  if ( idx >= 0 )
466  {
467  if ( ( parent() || mAlwaysDisplayCounts || !isExpanded() ) && unreadCountToDisplay > 0 )
468  setText( idx, QString::number( unreadCountToDisplay ) );
469  else
470  setText( idx, QString() );
471  }
472  setTextAlignment( idx, Qt::AlignRight );
473  }
474 }
475 
476 void FolderTreeWidgetItem::setTotalCount( int totalCount )
477 {
478  mTotalCount = totalCount;
479  int totalCountToDisplay = totalCount;
480 
481  if ( mChildrenTotalCount > 0 && !isExpanded() )
482  totalCountToDisplay += mChildrenTotalCount;
483 
484  FolderTreeWidget * tree = dynamic_cast< FolderTreeWidget * >( treeWidget() );
485  if( tree ) {
486  int idx = tree->totalColumnIndex();
487  if ( idx >= 0 )
488  {
489  // FIXME: Why the "parent()" logic is hardwired here ?
490  if ( parent() || mAlwaysDisplayCounts || !isExpanded() )
491  setText( idx, QString::number( totalCountToDisplay ) );
492  else
493  setText( idx, QString() );
494  setTextAlignment( idx, Qt::AlignRight );
495  }
496  }
497 }
498 
499 void FolderTreeWidgetItem::setDataSize( qint64 dataSize )
500 {
501  mDataSize = dataSize;
502 
503  QString txt;
504  QString sizeText = KIO::convertSize( mDataSize >= 0 ? (KIO::filesize_t)mDataSize : (KIO::filesize_t)0 );
505  QString childSizeText = KIO::convertSize( (KIO::filesize_t)mChildrenDataSize );
506 
507  // A top level item, they all have size 0
508  // FIXME: Why this logic is hardwired here ?
509  if ( !parent() && !mAlwaysDisplayCounts ) {
510  if ( mChildrenDataSize >= 0 && !isExpanded() )
511  txt = childSizeText;
512  else
513  txt = QString();
514  }
515 
516  // Not a top level item (or always displays counts)
517  else if ( ( mDataSize >= 0 ) || ( mChildrenDataSize >= 0 ) ) {
518  txt = sizeText;
519  if ( !isExpanded() ) {
520  if ( mChildrenDataSize >= 0 )
521  txt += " + " + childSizeText;
522  }
523  }
524  else
525  txt = "-";
526 
527  FolderTreeWidget * tree = dynamic_cast< FolderTreeWidget * >( treeWidget() );
528  if( tree ) {
529  int idx = tree->dataSizeColumnIndex();
530  if ( idx >= 0 )
531  {
532  setText( idx, txt );
533  setTextAlignment( idx, Qt::AlignRight );
534  }
535  }
536 }
537 
538 void FolderTreeWidgetItem::updateExpandedState()
539 {
540  // Just trigger an update of the column text, it will all be handled thaere.
541  setDataSize( mDataSize );
542  setTotalCount( mTotalCount );
543  setUnreadCount( mUnreadCount );
544 }
545 
546 void FolderTreeWidgetItem::updateColumn( int columnIndex )
547 {
548  FolderTreeWidget * tree = dynamic_cast< FolderTreeWidget * >( treeWidget() );
549  if ( tree ) {
550  tree->updateColumnForItem( this, columnIndex );
551  if ( columnIndex!=tree->labelColumnIndex() && !tree->unreadColumnVisible() && tree->labelColumnVisible() ) {
552  updateColumn( tree->labelColumnIndex() );
553  }
554  }
555 }
556 
557 void FolderTreeWidgetItem::setIsCloseToQuota( bool closeToQuota )
558 {
559  if ( ( mIsCloseToQuota == 1 ) == closeToQuota )
560  return;
561  mIsCloseToQuota = closeToQuota ? 1 : 0;
562 
563  FolderTreeWidget * tree = dynamic_cast< FolderTreeWidget * >( treeWidget() );
564  if ( tree && tree->labelColumnVisible() )
565  updateColumn( tree->labelColumnIndex() );
566 }
567 
568 
569 bool FolderTreeWidgetItem::operator < ( const QTreeWidgetItem &other ) const
570 {
571  // FIXME: Sort by children counts too ?
572 
573  int sortCol = treeWidget()->sortColumn();
574  if ( sortCol < 0 )
575  return true; // just "yes" :D
576 
577  FolderTreeWidget * w = dynamic_cast< FolderTreeWidget * >( treeWidget() );
578  if ( w )
579  {
580  // sanity check
581  if ( dynamic_cast<const FolderTreeWidgetItem*>( &other ) )
582  {
583  const FolderTreeWidgetItem * oitem = dynamic_cast< const FolderTreeWidgetItem * >( &other );
584  if ( oitem )
585  {
586  if ( sortCol == w->unreadColumnIndex() )
587  return mUnreadCount < oitem->unreadCount();
588  if ( sortCol == w->totalColumnIndex() )
589  return mTotalCount < oitem->totalCount();
590  if ( sortCol == w->dataSizeColumnIndex() )
591  return mDataSize < oitem->dataSize();
592  if ( sortCol == w->labelColumnIndex() )
593  {
594  // Special sorting based on the item type
595  int thisProto = ( int ) mProtocol;
596  int thatProto = ( int ) oitem->protocol();
597  if ( thisProto < thatProto )
598  return true;
599  if ( thisProto > thatProto )
600  return false;
601 
602  int thisType = ( int ) mFolderType;
603  int thatType = ( int ) oitem->folderType();
604  if ( thisType < thatType )
605  return true;
606  if ( thisType > thatType )
607  return false;
608 
609  // and finally compare by name
610  return mLabelText.toLower() < oitem->labelText().toLower();
611  }
612  }
613  }
614  }
615 
616  return text(sortCol) < other.text(sortCol);
617 }
618 
619 QString FolderTreeWidgetItem::elidedLabelText( const QFontMetrics &metrics, unsigned int width ) const
620 {
621  return metrics.elidedText( labelText(), Qt::ElideRight, width );
622 }
623 
624 }
625 
626 #include "foldertreewidget.moc"
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
KPIM::FolderTreeWidget::addDataSizeColumn
int addDataSizeColumn(const QString &headerLabel)
Adds a special "DataSize" column to this view and returns its logical index.
Definition: foldertreewidget.cpp:289
KPIM::FolderTreeWidgetItem::updateColumn
void updateColumn(int columnIndex)
Triggers an update for the specified column of this item.
Definition: foldertreewidget.cpp:546
KPIM::FolderTreeWidget::addTotalColumn
int addTotalColumn(const QString &headerLabel)
Adds a special "Total" column to this view and returns its logical index.
Definition: foldertreewidget.cpp:261
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
text
virtual QByteArray text(quint32 serialNumber) const =0
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::unreadColumnVisible
bool unreadColumnVisible() const
Returns true if the widget contains an "Unread" column and it's currently visible.
Definition: foldertreewidget.cpp:282
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
KPIM::FolderTreeWidgetItem::setDataSize
void setDataSize(qint64 s)
Sets the size in bytes of the folder to be displayed in the special "DataSize" column.
Definition: foldertreewidget.cpp:499
KPIM::FolderTreeWidgetItem::elidedLabelText
virtual QString elidedLabelText(const QFontMetrics &metrics, unsigned int width) const
Returns the label text that has been elided if necessary to fit into the width for the given font met...
Definition: foldertreewidget.cpp:619
QWidget
KPIM::FolderTreeWidgetItem::folderType
FolderType folderType() const
Returns the type of the folder.
Definition: foldertreewidget.h:396
KPIM::FolderTreeWidget::setUnreadCountColor
void setUnreadCountColor(const QColor &clr)
Sets the color used to display the unread message count in the "Label" column.
Definition: foldertreewidget.cpp:322
KPIM::FolderTreeWidget::dataSizeColumnVisible
bool dataSizeColumnVisible() const
Returns true if the widget contains a "DataSize" column and it's currently visible.
Definition: foldertreewidget.cpp:296
QStyledItemDelegate
KPIM::FolderTreeWidget::addUnreadColumn
int addUnreadColumn(const QString &headerLabel)
Adds a special "Unread" column to this view and returns its logical index.
Definition: foldertreewidget.cpp:275
KPIM::FolderTreeWidgetItem::setUnreadCount
void setUnreadCount(int unreadCount)
Sets the unread message count to be displayed in the special "Unread" column.
Definition: foldertreewidget.cpp:453
KPIM::FolderTreeWidgetItem::updateChildrenCounts
bool updateChildrenCounts()
Gathers the counts for the children.
Definition: foldertreewidget.cpp:393
KPIM::TreeWidget::isColumnHidden
bool isColumnHidden(int logicalIndex) const
Returns true if the column specified by logicalIndex is actually hidden.
Definition: treewidget.cpp:207
KPIM::FolderTreeWidget::FolderTreeWidget
FolderTreeWidget(QWidget *parent, const char *name=0)
Constructs a FolderTreeWidget instance.
Definition: foldertreewidget.cpp:216
KPIM::FolderTreeWidget::totalColumnVisible
bool totalColumnVisible() const
Returns true if the widget contains a "Total" column and it's currently visible.
Definition: foldertreewidget.cpp:268
FOLDERTREEWIDGETITEM_TYPE
#define FOLDERTREEWIDGETITEM_TYPE
Definition: foldertreewidget.cpp:39
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::FolderTreeWidget::setCloseToQuotaWarningColor
void setCloseToQuotaWarningColor(const QColor &clr)
Sets the color used to display the "Label" column text when the item is marked as close to quota...
Definition: foldertreewidget.cpp:316
foldertreewidget.h
A basic implementation of an UI for a tree of folders.
KPIM::FolderTreeWidgetItem::protocolDescription
QString protocolDescription() const
Returns a descriptive string of the folder's protocol.
Definition: foldertreewidget.cpp:364
KPIM::FolderTreeWidgetItem::unreadCount
int unreadCount() const
Returns the unread message count.
Definition: foldertreewidget.h:312
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
ITEM_LABEL_RIGHT_MARGIN
#define ITEM_LABEL_RIGHT_MARGIN
Definition: foldertreewidget.cpp:44
KPIM::FolderTreeWidgetItem::Search
Definition: foldertreewidget.h:235
KPIM::FolderTreeWidgetItem::CachedImap
Definition: foldertreewidget.h:235
KPIM::FolderTreeWidgetItem::Protocol
Protocol
Protocol information associated to the item.
Definition: foldertreewidget.h:234
KPIM::FolderTreeWidgetItem::labelText
const QString & labelText() const
Returns the textual data for the "Label" column of the parent FolderTreeWidget.
Definition: foldertreewidget.h:300
KPIM::TreeWidget::addColumn
int addColumn(const QString &label, int headerAlignment=Qt::AlignLeft|Qt::AlignVCenter)
Convenience function that adds a column to this tree widget and returns its logical index...
Definition: treewidget.cpp:279
KPIM::FolderTreeWidgetItem::setIsCloseToQuota
void setIsCloseToQuota(bool closeToQuota)
Sets the status of the close to quota warning.
Definition: foldertreewidget.cpp:557
KPIM::FolderTreeWidget::FolderTreeWidgetItemLabelColumnDelegate
friend class FolderTreeWidgetItemLabelColumnDelegate
Definition: foldertreewidget.h:75
KPIM::FolderTreeWidget::renamed
void renamed(QTreeWidgetItem *item)
This signal is emitted when the label of item has changed after an edition.
ITEM_LABEL_TO_UNREADCOUNT_SPACING
#define ITEM_LABEL_TO_UNREADCOUNT_SPACING
Definition: foldertreewidget.cpp:45
KPIM::FolderTreeWidgetItem::FolderTreeWidgetItem
FolderTreeWidgetItem(FolderTreeWidget *parent, const QString &label, Protocol protocol, FolderType folderType)
Constructs a root-item.
Definition: foldertreewidget.cpp:334
KPIM::FolderTreeWidgetItem::Imap
Definition: foldertreewidget.h:235
KPIM::FolderTreeWidgetItem::setLabelText
void setLabelText(const QString &label)
Sets the textual data for the "Label" column of the parent FolderTreeWidget.
Definition: foldertreewidget.cpp:439
KPIM::FolderTreeWidgetItem::operator<
virtual bool operator<(const QTreeWidgetItem &other) const
Operator used for item sorting.
Definition: foldertreewidget.cpp:569
KPIM::FolderTreeWidgetItem::NONE
Definition: foldertreewidget.h:235
KPIM::FolderTreeWidgetItem::setTotalCount
void setTotalCount(int totalCount)
Sets the total message count to be displayed in the special "Total" column.
Definition: foldertreewidget.cpp:476
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::childrenDataSize
qint64 childrenDataSize() const
Returns the size in bytes of the children folders displayed in the special "DataSize" column...
Definition: foldertreewidget.h:364
KPIM::FolderTreeWidget::updateColumnForItem
void updateColumnForItem(FolderTreeWidgetItem *item, int columnIndex)
Triggers an update for the specified column of the specified item.
Definition: foldertreewidget.cpp:303
KPIM::FolderTreeWidgetItem::updateExpandedState
void updateExpandedState()
This should be called whenever this item is expanded/collapsed.
Definition: foldertreewidget.cpp:538
KPIM::FolderTreeWidgetItem::Local
Definition: foldertreewidget.h:235
KPIM::FolderTreeWidget::labelColumnVisible
bool labelColumnVisible() const
Returns true if the widget contains a "Label" column and it's currently visible.
Definition: foldertreewidget.cpp:254
KPIM::FolderTreeWidget::addLabelColumn
int addLabelColumn(const QString &headerLabel)
Adds a special "Label" column to this view and returns its logical index.
Definition: foldertreewidget.cpp:244
KPIM::FolderTreeWidgetItem::News
Definition: foldertreewidget.h:235
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