~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to kmail/folderselectiontreewidget.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef __FOLDERSELECTIONTREEWIDGET_H__
2
 
#define __FOLDERSELECTIONTREEWIDGET_H__
3
 
 
4
 
/******************************************************************************
5
 
 *
6
 
 * KMail Folder Selection Tree Widget
7
 
 *
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>
11
 
 *
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.
16
 
 *
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.
21
 
 *
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
 
 *****************************************************************************/
26
 
 
27
 
#include <libkdepim/foldertreewidget.h>
28
 
 
29
 
class KMFolder;
30
 
class KAction;
31
 
 
32
 
namespace KMail {
33
 
 
34
 
class MainFolderView;
35
 
class FolderViewItem;
36
 
class FolderSelectionTreeWidgetItem;
37
 
 
38
 
/**
39
 
 * @brief A simple tree of folders useful for a "quick selection"
40
 
 * 
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.
44
 
 *
45
 
 * Items can be filtered by typing in a string to be matched in the
46
 
 * folder path.
47
 
 */
48
 
class FolderSelectionTreeWidget : public KPIM::FolderTreeWidget
49
 
{
50
 
  Q_OBJECT
51
 
 
52
 
public:
53
 
  /**
54
 
   * Construct the simple folder tree.
55
 
   * Note that the widget is initially empty and you must call reload()
56
 
   * to fill it up.
57
 
   *
58
 
   * @param parent The parent widget
59
 
   * @param folderTree The folder tree to fetch the hierarchy of folders from
60
 
   */
61
 
  FolderSelectionTreeWidget(
62
 
      QWidget *parent,
63
 
      ::KMail::MainFolderView *folderTree
64
 
   );
65
 
 
66
 
public:
67
 
  /**
68
 
   * Reload the tree and select which folders to show and which not
69
 
   *
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
74
 
   */
75
 
  void reload(
76
 
      bool mustBeReadWrite,
77
 
      bool showOutbox,
78
 
      bool showImapFolders,
79
 
      const QString &preSelection = QString()
80
 
    );
81
 
 
82
 
  /**
83
 
   * Return the currently selected folder, or 0 if no folder is selected (yet)
84
 
   */
85
 
  KMFolder * folder() const;
86
 
 
87
 
  /**
88
 
   * Set the current folder.
89
 
   * The folder parameter must come from the KMFolderTree specified in the
90
 
   * constructor.
91
 
   */
92
 
  void setFolder( KMFolder *folder );
93
 
  /**
94
 
   * Set the current folder.
95
 
   * This is an overload that first lookups the folder by id in kmkernel.
96
 
   */
97
 
  void setFolder( const QString &idString );
98
 
 
99
 
  /**
100
 
   * Apply the given filter string.
101
 
   * Folders NOT matching the string are hidden and disabled (can't be selected).
102
 
   */
103
 
  void applyFilter( const QString &filter );
104
 
 
105
 
  /**
106
 
   * Returns the folder name column logical index.
107
 
   */
108
 
  int nameColumnIndex() const
109
 
    { return mNameColumnIndex; };
110
 
 
111
 
  /**
112
 
   * Returns the folder path column logical index.
113
 
   */
114
 
  int pathColumnIndex() const
115
 
    { return mPathColumnIndex; };
116
 
 
117
 
public slots:
118
 
  /**
119
 
   * Invokes the child folder creation dialog on the currently selected
120
 
   * folder in the widget. Nothing happens if there is no current folder.
121
 
   */
122
 
  void addChildFolder();
123
 
 
124
 
protected slots:
125
 
  /**
126
 
   * Pops up a contextual menu for the currently selected folder.
127
 
   * At the moment of writing the menu allows to invoke the addChildFolder()
128
 
   * method.
129
 
   */
130
 
  void slotContextMenuRequested( const QPoint & );
131
 
 
132
 
  /**
133
 
   * Selects the folder that was added. Connected to the folderAdded signal
134
 
   * when creating a new subfolder.
135
 
   */
136
 
  void slotFolderAdded( KMFolder *addedFolder );
137
 
 
138
 
  /**
139
 
   * Called when the selection changes.
140
 
   * See documentation for QTreeWidget::itemSelectionChanged()
141
 
   */
142
 
  void slotItemSelectionChanged();
143
 
 
144
 
protected:
145
 
  /**
146
 
   * Handles key presses for the purpose of filtering.
147
 
   */
148
 
  virtual void keyPressEvent( QKeyEvent *e );
149
 
 
150
 
  /**
151
 
   * Recursively fetches folder items from the FolderTreeWiget
152
 
   * by starting at fti (as root). This is internal api: use reload() instead.
153
 
   */
154
 
  void recursiveReload( FolderViewItem *fti, FolderSelectionTreeWidgetItem *parent );
155
 
 
156
 
  /**
157
 
   * Returns false if the item is read-only and we need write access or has no content.
158
 
   */
159
 
  bool itemSelectable( const FolderSelectionTreeWidgetItem *item ) const;
160
 
 
161
 
signals:
162
 
  /**
163
 
   * Emitted when the tree widget selection changes, to inform the parent dialogue
164
 
   * of the actions that are allowed for the selected folder.
165
 
   *
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.
168
 
   */
169
 
  void actionsAllowed( bool allowOk, bool allowCreate );
170
 
 
171
 
private:
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
176
 
 
177
 
  bool mLastMustBeReadWrite;            ///< Internal state for reload()
178
 
  bool mLastShowOutbox;                 ///< Internal state for reload()
179
 
  bool mLastShowImapFolders;            ///< Internal state for reload()
180
 
 
181
 
  KAction *mCreateFolderAction;         ///< "New Subfolder" action for popup menu
182
 
};
183
 
 
184
 
} // namespace KMail
185
 
 
186
 
#endif /*!__FOLDERSELECTIONTREEWIDGET_H__*/