1
// -*- mode: C++; c-file-style: "gnu" -*-
5
* Copyright (c) 1997-2004 KMail Developers
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
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.
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.
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
32
#ifndef __KMFOLDERDIALOG_H
33
#define __KMFOLDERDIALOG_H
35
#include <kpagedialog.h>
36
#include "configuredialog_p.h"
38
#include "kmmainwidget.h"
48
namespace KPIMIdentities { class IdentityCombo; }
50
template <typename T> class QPointer;
52
class TemplatesConfiguration;
55
namespace MessageList {
57
class AggregationComboBox;
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.
74
* Feel free to rename and move this base class somewhere else if it
75
* can be useful for other dialogs.
77
class FolderDialogTab : public QWidget
81
explicit FolderDialogTab( KMFolderDialog *dlg,
83
const char *name = 0 )
87
setObjectName( name );
90
virtual void load() = 0;
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;
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;
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();
112
/// Emit this, i.e. after a job had an error, to tell the dialog to cancel
116
/// Called when this module was changed [not really used yet]
120
KMFolderDialog *mDlg;
124
* "General" tab in the folder dialog
125
* Internal class, only used by KMFolderDialog
127
class FolderDialogGeneralTab : public FolderDialogTab
132
FolderDialogGeneralTab( KMFolderDialog* dlg,
133
const QString& aName,
134
QWidget* parent, const char* name = 0 );
141
* is called if the folder dropdown changes
142
* then we update the other items to reflect the capabilities
144
void slotFolderNameChanged( const QString& );
145
void slotFolderContentsSelectionChanged( int );
146
void slotIdentityCheckboxChanged();
149
void initializeWithValuesFromFolder( KMFolder* folder );
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;
163
KPIMIdentities::IdentityCombo *mIdentityComboBox;
165
bool mIsLocalSystemFolder;
166
bool mIsResourceFolder;
171
* "View" tab in the folder dialog
172
* Internal class, only used by KMFolderDialog
174
class FolderDialogViewTab : public FolderDialogTab
179
FolderDialogViewTab( KMFolderDialog * dlg, QWidget * parent );
185
void slotChangeIcon( const QString & icon );
186
void slotAggregationCheckboxChanged();
187
void slotThemeCheckboxChanged();
188
void slotSelectFolderAggregation();
189
void slotSelectFolderTheme();
192
void initializeWithValuesFromFolder( KMFolder * folder );
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;
211
* "Maintenance" tab in the folder dialog
212
* Internal class, only used by KMFolderDialog
214
class FolderDialogMaintenanceTab : public FolderDialogTab
219
FolderDialogMaintenanceTab( KMFolderDialog *dlg, QWidget *parent );
225
void slotCompactNow();
226
void slotRebuildIndex();
227
void slotRebuildImap();
228
void updateFolderIndexSizes();
231
void updateControls();
236
QLabel *mFolderSizeLabel;
237
QLabel *mIndexSizeLabel;
238
QPushButton *mRebuildIndexButton;
239
QPushButton *mRebuildImapButton;
240
QLabel *mCompactStatusLabel;
241
QPushButton *mCompactNowButton;
246
* "Templates" tab in the folder dialog
247
* Internal class, only used by KMFolderDialog
249
class FolderDialogTemplatesTab : public FolderDialogTab
254
FolderDialogTemplatesTab( KMFolderDialog *dlg, QWidget *parent );
260
void slotEmitChanged(); // do nothing for now
262
void slotCopyGlobal();
265
void initializeWithValuesFromFolder( KMFolder* folder );
269
TemplatesConfiguration* mWidget;
270
KPushButton* mCopyGlobal;
275
} // end of namespace KMail
278
* Dialog for handling the properties of a mail folder
280
class KMFolderDialog : public KPageDialog
285
KMFolderDialog( KMFolder *folder, KMFolderDir *aFolderDir,
286
KMail::MainFolderView *parent, const QString& caption,
287
const QString& name = QString() );
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; }
295
KMFolderDir* folderDir() const;
296
typedef QList<QPointer<KMFolder> > FolderList;
298
KMFolder* parentFolder() const { return mParentFolder; }
300
bool setPage( KMMainWidget::PropsPage whichPage );
303
void slotChanged( bool );
304
virtual void slotOk();
305
virtual void slotApply();
307
void slotReadyForAccept();
308
void slotCancelAccept();
311
void addTab( KMail::FolderDialogTab* tab );
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;
319
bool mIsNewFolder; // if true, save() did set mFolder.
321
KPageWidgetItem *mShortcutTab;
322
KPageWidgetItem *mExpiryTab;
323
KPageWidgetItem *mMaillistTab;
324
KPageWidgetItem *mMaintenanceTab;
326
QVector<KMail::FolderDialogTab*> mTabs;
327
int mDelayedSavingTabs; // this should go into a base class one day
330
#endif /*__KMFOLDERDIALOG_H*/