1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 This file is part of KMail, the KDE mail client.
3 Copyright (c) 2009, 2010 Montel Laurent <montel@kde.org>
5 KMail is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License, version 2, as
7 published by the Free Software Foundation.
9 KMail is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef FOLDERTREEWIDGET_H
20 #define FOLDERTREEWIDGET_H
22 #include "kmail_export.h"
23 #include "readablecollectionproxymodel.h"
26 #include <QAbstractItemView>
27 #include <akonadi/collection.h>
30 class QItemSelectionModel
;
33 class EntityCollectionOrderProxyModel
;
36 class StatisticsProxyModel
;
40 * This is the widget that shows the main folder tree in KMail.
42 * It consists of the view (FolderTreeView) and a search line.
43 * Internally, several proxy models are used on top of a entity tree model.
45 class KMAIL_EXPORT FolderTreeWidget
: public QWidget
53 UseLineEditForFiltering
= 2,
54 UseDistinctSelectionModel
= 4,
55 ShowCollectionStatisticAnimation
= 8
57 Q_DECLARE_FLAGS( TreeViewOptions
, TreeViewOption
)
59 FolderTreeWidget( QWidget
*parent
= 0, KXMLGUIClient
*xmlGuiClient
= 0,
60 TreeViewOptions option
= (TreeViewOptions
) (ShowUnreadCount
|ShowCollectionStatisticAnimation
),
61 ReadableCollectionProxyModel::ReadableCollectionOptions optReadableProxy
= ReadableCollectionProxyModel::None
);
65 * The possible tooltip display policies.
67 enum ToolTipDisplayPolicy
69 DisplayAlways
, ///< Always display a tooltip when hovering over an item
70 DisplayWhenTextElided
, ///< Display the tooltip if the item text is actually elided
71 DisplayNever
///< Nevery display tooltips
75 * The available sorting policies.
79 SortByCurrentColumn
, ///< Columns are clickable, sorting is by the current column
80 SortByDragAndDropKey
///< Columns are NOT clickable, sorting is done by drag and drop
85 void selectCollectionFolder( const Akonadi::Collection
& col
);
87 void setSelectionMode( QAbstractItemView::SelectionMode mode
);
89 QAbstractItemView::SelectionMode
selectionMode() const;
91 QItemSelectionModel
* selectionModel () const;
93 QModelIndex
currentIndex() const;
95 Akonadi::Collection
selectedCollection() const;
97 Akonadi::Collection::List
selectedCollections() const;
99 FolderTreeView
*folderTreeView() const;
101 Akonadi::StatisticsProxyModel
* statisticsProxyModel() const;
103 ReadableCollectionProxyModel
*readableCollectionProxyModel() const;
105 EntityCollectionOrderProxyModel
*entityOrderProxy() const;
107 void quotaWarningParameters( const QColor
&color
, qreal threshold
);
108 void readQuotaConfig();
110 KLineEdit
*filterFolderLineEdit() const;
111 void applyFilter( const QString
& );
113 void disableContextMenuAndExtraColumn();
118 void changeToolTipsPolicyConfig( ToolTipDisplayPolicy
);
121 void slotChangeTooltipsPolicy( FolderTreeWidget::ToolTipDisplayPolicy
);
122 void slotManualSortingChanged( bool );
125 class FolderTreeWidgetPrivate
;
126 FolderTreeWidgetPrivate
* const d
;