Framework for looking up contacts directly in nepomuk in addition to going through...
[kdepim.git] / mailcommon / foldertreeview.h
blob285e917911cdccfc1e45845da8e7628b5daab213
1 /* -*- mode: C++; c-file-style: "gnu" -*-
3 Copyright (c) 2009, 2010 Montel Laurent <montel@kde.org>
5 This program 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 This program 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 MAILCOMMON_FOLDERTREEVIEW_H
20 #define MAILCOMMON_FOLDERTREEVIEW_H
22 #include "mailcommon_export.h"
23 #include "foldertreewidget.h"
24 #include "mailutil.h"
26 #include <Akonadi/EntityTreeView>
27 #include <Akonadi/Collection>
29 class QMouseEvent;
31 namespace Akonadi {
32 class CollectionStatisticsDelegate;
35 namespace MailCommon {
37 /**
38 * This is an enhanced EntityTreeView specially suited for the folders in KMail's
39 * main folder widget.
41 class MAILCOMMON_EXPORT FolderTreeView : public Akonadi::EntityTreeView
43 Q_OBJECT
45 public:
46 explicit FolderTreeView( QWidget *parent = 0, bool showUnreadCount = true );
48 explicit FolderTreeView( KXMLGUIClient *xmlGuiClient, QWidget *parent = 0,
49 bool showUnreadCount = true );
51 virtual ~FolderTreeView();
53 void selectNextUnreadFolder( bool confirm = false );
54 void selectPrevUnreadFolder( bool confirm = false );
56 void showStatisticAnimation( bool anim );
58 void disableContextMenuAndExtraColumn();
60 void setTooltipsPolicy( FolderTreeWidget::ToolTipDisplayPolicy );
62 void restoreHeaderState( const QByteArray &data );
64 Akonadi::Collection currentFolder() const;
66 void disableSaveConfig();
67 void readConfig();
69 protected:
70 enum Move {
71 Next = 0,
72 Previous = 1
75 void init( bool showUnreadCount );
76 void selectModelIndex( const QModelIndex & );
77 void setCurrentModelIndex( const QModelIndex & );
78 QModelIndex selectNextFolder( const QModelIndex &current );
79 bool isUnreadFolder( const QModelIndex &current, QModelIndex &nextIndex,
80 FolderTreeView::Move move, bool confirm );
81 void writeConfig();
83 void setSortingPolicy( FolderTreeWidget::SortingPolicy policy,
84 bool writeInConfig = false );
86 virtual void mousePressEvent( QMouseEvent *e );
88 public slots:
89 void slotFocusNextFolder();
90 void slotFocusPrevFolder();
91 void slotSelectFocusFolder();
93 protected slots:
94 void slotHeaderContextMenuRequested( const QPoint & );
95 void slotHeaderContextMenuChangeIconSize( bool );
96 void slotHeaderContextMenuChangeHeader( bool );
97 void slotHeaderContextMenuChangeToolTipDisplayPolicy( bool );
98 void slotHeaderContextMenuChangeSortingPolicy( bool );
100 signals:
101 void changeTooltipsPolicy( FolderTreeWidget::ToolTipDisplayPolicy );
102 void manualSortingChanged( bool actif );
103 void prefereCreateNewTab( bool );
105 private:
106 bool ignoreUnreadFolder( const Akonadi::Collection &, bool ) const;
107 bool allowedToEnterFolder( const Akonadi::Collection &, bool ) const;
108 bool trySelectNextUnreadFolder( const QModelIndex &, MailCommon::Util::SearchDirection, bool );
110 FolderTreeWidget::ToolTipDisplayPolicy mToolTipDisplayPolicy;
111 FolderTreeWidget::SortingPolicy mSortingPolicy;
112 Akonadi::CollectionStatisticsDelegate *mCollectionStatisticsDelegate;
113 bool mbDisableContextMenuAndExtraColumn;
114 bool mbDisableSaveConfig;
119 #endif