1
#ifndef __FOLDERSELECTIONTREEWIDGET_H__
2
#define __FOLDERSELECTIONTREEWIDGET_H__
4
/******************************************************************************
6
* KMail Folder Selection Tree Widget
8
* Copyright (c) 1997-1998 Stefan Taferner <taferner@kde.org>
9
* Copyright (c) 2004-2005 Carsten Burghardt <burghardt@kde.org>
10
* Copyright (c) 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
12
* This program is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License as published by
14
* the Free Software Foundation; either version 2 of the License, or
15
* (at your option) any later version.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* You should have received a copy of the GNU General Public License along
23
* with this program; if not, write to the Free Software Foundation, Inc.,
24
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
*****************************************************************************/
27
#include <libkdepim/foldertreewidget.h>
36
class FolderSelectionTreeWidgetItem;
39
* @brief A simple tree of folders useful for a "quick selection"
41
* This widget displays a two column tree of folders with the folder
42
* name on the left and its full path on the right. The tree is filled
43
* by fetching data from a FolderTreeWiget.
45
* Items can be filtered by typing in a string to be matched in the
48
class FolderSelectionTreeWidget : public KPIM::FolderTreeWidget
54
* Construct the simple folder tree.
55
* Note that the widget is initially empty and you must call reload()
58
* @param parent The parent widget
59
* @param folderTree The folder tree to fetch the hierarchy of folders from
61
FolderSelectionTreeWidget(
63
::KMail::MainFolderView *folderTree
68
* Reload the tree and select which folders to show and which not
70
* @param mustBeReadWrite If true, the read-only folders become non selectable
71
* @param showOutbox If true, the outbox folder is shown
72
* @param showImapFolders Whether to show the IMAP folder hierarchy
73
* @param preSelection The initial folder to select
79
const QString &preSelection = QString()
83
* Return the currently selected folder, or 0 if no folder is selected (yet)
85
KMFolder * folder() const;
88
* Set the current folder.
89
* The folder parameter must come from the KMFolderTree specified in the
92
void setFolder( KMFolder *folder );
94
* Set the current folder.
95
* This is an overload that first lookups the folder by id in kmkernel.
97
void setFolder( const QString &idString );
100
* Apply the given filter string.
101
* Folders NOT matching the string are hidden and disabled (can't be selected).
103
void applyFilter( const QString &filter );
106
* Returns the folder name column logical index.
108
int nameColumnIndex() const
109
{ return mNameColumnIndex; };
112
* Returns the folder path column logical index.
114
int pathColumnIndex() const
115
{ return mPathColumnIndex; };
119
* Invokes the child folder creation dialog on the currently selected
120
* folder in the widget. Nothing happens if there is no current folder.
122
void addChildFolder();
126
* Pops up a contextual menu for the currently selected folder.
127
* At the moment of writing the menu allows to invoke the addChildFolder()
130
void slotContextMenuRequested( const QPoint & );
133
* Selects the folder that was added. Connected to the folderAdded signal
134
* when creating a new subfolder.
136
void slotFolderAdded( KMFolder *addedFolder );
139
* Called when the selection changes.
140
* See documentation for QTreeWidget::itemSelectionChanged()
142
void slotItemSelectionChanged();
146
* Handles key presses for the purpose of filtering.
148
virtual void keyPressEvent( QKeyEvent *e );
151
* Recursively fetches folder items from the FolderTreeWiget
152
* by starting at fti (as root). This is internal api: use reload() instead.
154
void recursiveReload( FolderViewItem *fti, FolderSelectionTreeWidgetItem *parent );
157
* Returns false if the item is read-only and we need write access or has no content.
159
bool itemSelectable( const FolderSelectionTreeWidgetItem *item ) const;
163
* Emitted when the tree widget selection changes, to inform the parent dialogue
164
* of the actions that are allowed for the selected folder.
166
* @param allowOk if true, the OK action (accepting the selected folder) is allowed.
167
* @param allowCreate if true, the "New Subfolder" action is allowed.
169
void actionsAllowed( bool allowOk, bool allowCreate );
172
int mNameColumnIndex; ///< The index of the folder name column
173
int mPathColumnIndex; ///< The index of the path column
174
KMail::MainFolderView* mFolderTree; ///< The MainFolderView to fetch the data from
175
QString mFilter; ///< The current folder path filter string
177
bool mLastMustBeReadWrite; ///< Internal state for reload()
178
bool mLastShowOutbox; ///< Internal state for reload()
179
bool mLastShowImapFolders; ///< Internal state for reload()
181
KAction *mCreateFolderAction; ///< "New Subfolder" action for popup menu
186
#endif /*!__FOLDERSELECTIONTREEWIDGET_H__*/