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"
26 #include <Akonadi/EntityTreeView>
27 #include <Akonadi/Collection>
32 class CollectionStatisticsDelegate
;
35 namespace MailCommon
{
38 * This is an enhanced EntityTreeView specially suited for the folders in KMail's
41 class MAILCOMMON_EXPORT FolderTreeView
: public Akonadi::EntityTreeView
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();
75 void init( bool showUnreadCount
);
76 void selectModelIndex( const QModelIndex
& );
77 void setCurrentModelIndex( const QModelIndex
& );
78 QModelIndex
selectNextFolder( const QModelIndex
¤t
);
79 bool isUnreadFolder( const QModelIndex
¤t
, QModelIndex
&nextIndex
,
80 FolderTreeView::Move move
, bool confirm
);
83 void setSortingPolicy( FolderTreeWidget::SortingPolicy policy
,
84 bool writeInConfig
= false );
86 virtual void mousePressEvent( QMouseEvent
*e
);
89 void slotFocusNextFolder();
90 void slotFocusPrevFolder();
91 void slotSelectFocusFolder();
94 void slotHeaderContextMenuRequested( const QPoint
& );
95 void slotHeaderContextMenuChangeIconSize( bool );
96 void slotHeaderContextMenuChangeHeader( bool );
97 void slotHeaderContextMenuChangeToolTipDisplayPolicy( bool );
98 void slotHeaderContextMenuChangeSortingPolicy( bool );
101 void changeTooltipsPolicy( FolderTreeWidget::ToolTipDisplayPolicy
);
102 void manualSortingChanged( bool actif
);
103 void prefereCreateNewTab( bool );
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
;