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

« back to all changes in this revision

Viewing changes to kmail/kmfolderdialog.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
 
// -*- mode: C++; c-file-style: "gnu" -*-
2
 
/**
3
 
 * kmfolderdialog.h
4
 
 *
5
 
 * Copyright (c) 1997-2004 KMail Developers
6
 
 *
7
 
 *
8
 
 *  This program is free software; you can redistribute it and/or modify
9
 
 *  it under the terms of the GNU General Public License as published by
10
 
 *  the Free Software Foundation; version 2 of the License
11
 
 *
12
 
 *  This program is distributed in the hope that it will be useful,
13
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 *  GNU General Public License for more details.
16
 
 *
17
 
 *  You should have received a copy of the GNU General Public License
18
 
 *  along with this program; if not, write to the Free Software
19
 
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
 
 *
21
 
 *  In addition, as a special exception, the copyright holders give
22
 
 *  permission to link the code of this program with any edition of
23
 
 *  the Qt library by Trolltech AS, Norway (or with modified versions
24
 
 *  of Qt that use the same license as Qt), and distribute linked
25
 
 *  combinations including the two.  You must obey the GNU General
26
 
 *  Public License in all respects for all of the code used other than
27
 
 *  Qt.  If you modify this file, you may extend this exception to
28
 
 *  your version of the file, but you are not obligated to do so.  If
29
 
 *  you do not wish to do so, delete this exception statement from
30
 
 *  your version.
31
 
 */
32
 
#ifndef __KMFOLDERDIALOG_H
33
 
#define __KMFOLDERDIALOG_H
34
 
 
35
 
#include <kpagedialog.h>
36
 
#include "configuredialog_p.h"
37
 
 
38
 
#include "kmmainwidget.h"
39
 
 
40
 
#include <QList>
41
 
 
42
 
class QCheckBox;
43
 
class QLabel;
44
 
class KComboBox;
45
 
class KMFolder;
46
 
class KMFolderDir;
47
 
class KIconButton;
48
 
namespace KPIMIdentities { class IdentityCombo; }
49
 
class KMFolderDialog;
50
 
template <typename T> class QPointer;
51
 
 
52
 
class TemplatesConfiguration;
53
 
class KPushButton;
54
 
 
55
 
namespace MessageList {
56
 
  namespace Utils {
57
 
    class AggregationComboBox;
58
 
    class ThemeComboBox;
59
 
  }
60
 
}
61
 
 
62
 
namespace KMail {
63
 
 
64
 
class MainFolderView;
65
 
 
66
 
/**
67
 
 * This is the base class for tabs in the folder dialog.
68
 
 * It uses the API from ConfigModuleTab (basically: it's a widget that can load and save)
69
 
 * but it also adds support for delayed-saving:
70
 
 * when save() needs to use async jobs (e.g. KIO) for saving,
71
 
 * we need to delay the closing until after the jobs are finished,
72
 
 * and to cancel the saving on error.
73
 
 *
74
 
 * Feel free to rename and move this base class somewhere else if it
75
 
 * can be useful for other dialogs.
76
 
 */
77
 
class FolderDialogTab : public QWidget
78
 
{
79
 
  Q_OBJECT
80
 
public:
81
 
   explicit FolderDialogTab( KMFolderDialog *dlg,
82
 
                             QWidget *parent = 0,
83
 
                             const char *name = 0 )
84
 
     : QWidget( parent ),
85
 
       mDlg( dlg )
86
 
   {
87
 
     setObjectName( name );
88
 
   }
89
 
 
90
 
  virtual void load() = 0;
91
 
 
92
 
  /// Unlike ConfigModuleTab, we return a bool from save.
93
 
  /// This allows to cancel closing on error.
94
 
  /// When called from the Apply button, the return value is ignored
95
 
  /// @return whether save succeeded
96
 
  virtual bool save() = 0;
97
 
 
98
 
  enum AcceptStatus { Accepted, Canceled, Delayed };
99
 
  /// Called when clicking OK.
100
 
  /// If a module returns Delayed, the closing is canceled for now,
101
 
  /// and the module can close the dialog later on (i.e. after an async
102
 
  /// operation like a KIO job).
103
 
  virtual AcceptStatus accept() {
104
 
    return save() ? Accepted : Canceled;
105
 
  }
106
 
 
107
 
signals:
108
 
  /// Emit this to tell the dialog that you're done with the async jobs,
109
 
  /// and that the dialog can be closed.
110
 
  void readyForAccept();
111
 
 
112
 
  /// Emit this, i.e. after a job had an error, to tell the dialog to cancel
113
 
  /// the closing.
114
 
  void cancelAccept();
115
 
 
116
 
  /// Called when this module was changed [not really used yet]
117
 
  void changed(bool);
118
 
 
119
 
protected:
120
 
  KMFolderDialog *mDlg;
121
 
};
122
 
 
123
 
/**
124
 
 * "General" tab in the folder dialog
125
 
 * Internal class, only used by KMFolderDialog
126
 
 */
127
 
class FolderDialogGeneralTab : public FolderDialogTab
128
 
{
129
 
  Q_OBJECT
130
 
 
131
 
public:
132
 
  FolderDialogGeneralTab( KMFolderDialog* dlg,
133
 
                          const QString& aName,
134
 
                          QWidget* parent, const char* name = 0 );
135
 
 
136
 
  virtual void load();
137
 
  virtual bool save();
138
 
 
139
 
private slots:
140
 
  /*
141
 
   * is called if the folder dropdown changes
142
 
   * then we update the other items to reflect the capabilities
143
 
   */
144
 
  void slotFolderNameChanged( const QString& );
145
 
  void slotFolderContentsSelectionChanged( int );
146
 
  void slotIdentityCheckboxChanged();
147
 
 
148
 
private:
149
 
  void initializeWithValuesFromFolder( KMFolder* folder );
150
 
 
151
 
private:
152
 
  KComboBox *mContentsComboBox;
153
 
  KComboBox *mIncidencesForComboBox;
154
 
  QCheckBox *mAlarmsBlockedCheckBox;
155
 
  QCheckBox *mSharedSeenFlagsCheckBox;
156
 
  QCheckBox   *mNewMailCheckBox;
157
 
  QCheckBox   *mNotifyOnNewMailCheckBox;
158
 
  QCheckBox   *mKeepRepliesInSameFolderCheckBox;
159
 
  QCheckBox   *mHideInSelectionDialogCheckBox;
160
 
  QCheckBox   *mUseDefaultIdentityCheckBox;
161
 
  KLineEdit   *mNameEdit;
162
 
 
163
 
  KPIMIdentities::IdentityCombo *mIdentityComboBox;
164
 
 
165
 
  bool mIsLocalSystemFolder;
166
 
  bool mIsResourceFolder;
167
 
};
168
 
 
169
 
 
170
 
/**
171
 
 * "View" tab in the folder dialog
172
 
 * Internal class, only used by KMFolderDialog
173
 
 */
174
 
class FolderDialogViewTab : public FolderDialogTab
175
 
{
176
 
  Q_OBJECT
177
 
 
178
 
public:
179
 
  FolderDialogViewTab( KMFolderDialog * dlg, QWidget * parent );
180
 
 
181
 
  virtual void load();
182
 
  virtual bool save();
183
 
 
184
 
public slots:
185
 
  void slotChangeIcon( const QString & icon );
186
 
  void slotAggregationCheckboxChanged();
187
 
  void slotThemeCheckboxChanged();
188
 
  void slotSelectFolderAggregation();
189
 
  void slotSelectFolderTheme();
190
 
 
191
 
private:
192
 
  void initializeWithValuesFromFolder( KMFolder * folder );
193
 
 
194
 
private:
195
 
  bool mIsLocalSystemFolder;
196
 
  bool mIsResourceFolder;
197
 
  QCheckBox   *mIconsCheckBox;
198
 
  QLabel      *mNormalIconLabel;
199
 
  KIconButton *mNormalIconButton;
200
 
  QLabel      *mUnreadIconLabel;
201
 
  KIconButton *mUnreadIconButton;
202
 
  KComboBox *mShowSenderReceiverComboBox;
203
 
  QCheckBox *mUseDefaultAggregationCheckBox;
204
 
  MessageList::Utils::AggregationComboBox *mAggregationComboBox;
205
 
  QCheckBox *mUseDefaultThemeCheckBox;
206
 
  MessageList::Utils::ThemeComboBox *mThemeComboBox;
207
 
};
208
 
 
209
 
 
210
 
 /**
211
 
 * "Maintenance" tab in the folder dialog
212
 
 * Internal class, only used by KMFolderDialog
213
 
 */
214
 
class FolderDialogMaintenanceTab : public FolderDialogTab
215
 
{
216
 
  Q_OBJECT
217
 
 
218
 
public:
219
 
  FolderDialogMaintenanceTab( KMFolderDialog *dlg, QWidget *parent );
220
 
 
221
 
  virtual void load();
222
 
  virtual bool save();
223
 
 
224
 
private slots:
225
 
  void slotCompactNow();
226
 
  void slotRebuildIndex();
227
 
  void slotRebuildImap();
228
 
  void updateFolderIndexSizes();
229
 
 
230
 
private:
231
 
  void updateControls();
232
 
 
233
 
private:
234
 
  KMFolder* mFolder;
235
 
 
236
 
  QLabel *mFolderSizeLabel;
237
 
  QLabel *mIndexSizeLabel;
238
 
  QPushButton *mRebuildIndexButton;
239
 
  QPushButton *mRebuildImapButton;
240
 
  QLabel *mCompactStatusLabel;
241
 
  QPushButton *mCompactNowButton;
242
 
};
243
 
 
244
 
 
245
 
/**
246
 
 * "Templates" tab in the folder dialog
247
 
 * Internal class, only used by KMFolderDialog
248
 
 */
249
 
class FolderDialogTemplatesTab : public FolderDialogTab
250
 
{
251
 
  Q_OBJECT
252
 
 
253
 
public:
254
 
  FolderDialogTemplatesTab( KMFolderDialog *dlg, QWidget *parent );
255
 
 
256
 
  virtual void load();
257
 
  virtual bool save();
258
 
 
259
 
public slots:
260
 
  void slotEmitChanged(); // do nothing for now
261
 
 
262
 
  void slotCopyGlobal();
263
 
 
264
 
private:
265
 
  void initializeWithValuesFromFolder( KMFolder* folder );
266
 
 
267
 
private:
268
 
  QCheckBox* mCustom;
269
 
  TemplatesConfiguration* mWidget;
270
 
  KPushButton* mCopyGlobal;
271
 
  KMFolder* mFolder;
272
 
  uint mIdentity;
273
 
};
274
 
 
275
 
} // end of namespace KMail
276
 
 
277
 
/**
278
 
 * Dialog for handling the properties of a mail folder
279
 
 */
280
 
class KMFolderDialog : public KPageDialog
281
 
{
282
 
  Q_OBJECT
283
 
 
284
 
public:
285
 
  KMFolderDialog( KMFolder *folder, KMFolderDir *aFolderDir,
286
 
                  KMail::MainFolderView *parent, const QString& caption,
287
 
                  const QString& name = QString() );
288
 
 
289
 
  KMFolder* folder() const { return mFolder; }
290
 
  void setFolder( KMFolder* folder );
291
 
  // Was mFolder just created? (This only makes sense from save())
292
 
  // If Apply is clicked, or OK proceeeds half-way, then next time "new folder" will be false.
293
 
  bool isNewFolder() const { return mIsNewFolder; }
294
 
 
295
 
  KMFolderDir* folderDir() const;
296
 
  typedef QList<QPointer<KMFolder> > FolderList;
297
 
 
298
 
  KMFolder* parentFolder() const { return mParentFolder; }
299
 
 
300
 
  bool setPage( KMMainWidget::PropsPage whichPage );
301
 
 
302
 
protected slots:
303
 
  void slotChanged( bool );
304
 
  virtual void slotOk();
305
 
  virtual void slotApply();
306
 
 
307
 
  void slotReadyForAccept();
308
 
  void slotCancelAccept();
309
 
 
310
 
private:
311
 
  void addTab( KMail::FolderDialogTab* tab );
312
 
 
313
 
private:
314
 
  // Can be 0 initially when creating a folder, but will be set by save() in the first tab.
315
 
  QPointer<KMFolder> mFolder;
316
 
  QPointer<KMFolderDir> mFolderDir;
317
 
  QPointer<KMFolder> mParentFolder;
318
 
 
319
 
  bool mIsNewFolder; // if true, save() did set mFolder.
320
 
 
321
 
  KPageWidgetItem *mShortcutTab;
322
 
  KPageWidgetItem *mExpiryTab;
323
 
  KPageWidgetItem *mMaillistTab;
324
 
  KPageWidgetItem *mMaintenanceTab;
325
 
 
326
 
  QVector<KMail::FolderDialogTab*> mTabs;
327
 
  int mDelayedSavingTabs; // this should go into a base class one day
328
 
};
329
 
 
330
 
#endif /*__KMFOLDERDIALOG_H*/
331