Build with clang.
[kdepim.git] / mailcommon / foldertreeview.h
blobf36664bf0ae9324fa8e8d4f47de2205285ff3bab
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 MAILCOMMON_FOLDERTREEVIEW_H
20 #define MAILCOMMON_FOLDERTREEVIEW_H
22 #include "mailcommon_export.h"
24 #include "foldertreewidget.h"
25 #include "mailutil.h"
27 #include <akonadi/entitytreeview.h>
28 #include <akonadi/collection.h>
30 class QMouseEvent;
32 namespace Akonadi
34 class CollectionStatisticsDelegate;
37 namespace MailCommon {
39 /**
40 * This is an enhanced EntityTreeView specially suited for the folders in KMail's
41 * main folder widget.
43 class MAILCOMMON_EXPORT FolderTreeView : public Akonadi::EntityTreeView
45 Q_OBJECT
46 public:
47 explicit FolderTreeView( QWidget *parent = 0, bool showUnreadCount = true );
49 explicit FolderTreeView( KXMLGUIClient *xmlGuiClient, QWidget *parent = 0, 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 protected:
67 enum Move { Next = 0, Previous = 1};
68 void init( bool showUnreadCount );
69 void selectModelIndex( const QModelIndex & );
70 void setCurrentModelIndex( const QModelIndex & );
71 QModelIndex selectNextFolder( const QModelIndex & current );
72 bool isUnreadFolder( const QModelIndex & current, QModelIndex &nextIndex,FolderTreeView::Move move, bool confirm);
73 void readConfig();
74 void writeConfig();
76 void setSortingPolicy( FolderTreeWidget::SortingPolicy policy );
78 virtual void mousePressEvent( QMouseEvent *e );
81 public slots:
82 void slotFocusNextFolder();
83 void slotFocusPrevFolder();
84 void slotSelectFocusFolder();
86 protected slots:
87 void slotHeaderContextMenuRequested( const QPoint& );
88 void slotHeaderContextMenuChangeIconSize( bool );
89 void slotHeaderContextMenuChangeHeader( bool );
90 void slotHeaderContextMenuChangeToolTipDisplayPolicy( bool );
91 void slotHeaderContextMenuChangeSortingPolicy( bool );
93 signals:
94 void changeTooltipsPolicy( FolderTreeWidget::ToolTipDisplayPolicy );
95 void manualSortingChanged( bool actif );
96 void prefereCreateNewTab( bool );
97 private:
98 bool ignoreUnreadFolder( const Akonadi::Collection&, bool ) const;
99 bool allowedToEnterFolder( const Akonadi::Collection&, bool ) const;
100 bool trySelectNextUnreadFolder( const QModelIndex&, MailCommon::Util::SearchDirection, bool );
102 FolderTreeWidget::ToolTipDisplayPolicy mToolTipDisplayPolicy;
103 FolderTreeWidget::SortingPolicy mSortingPolicy;
104 Akonadi::CollectionStatisticsDelegate *mCollectionStatisticsDelegate;
105 bool mbDisableContextMenuAndExtraColumn;
106 bool mLastButtonPressedWasMiddle;
111 #endif