4
This file is part of KMail, the KDE mail client.
5
Copyright (C) 2002 Carsten Burghardt <burghardt@kde.org>
6
Copyright (C) 2009 Kevin Ottens <ervin@kde.org>
8
KMail is free software; you can redistribute it and/or modify it
9
under the terms of the GNU General Public License, version 2, as
10
published by the Free Software Foundation.
12
KMail is distributed in the hope that it will be useful, but
13
WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
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
33
#ifndef __SUBSCRIPTIONDIALOG_H__
34
#define __SUBSCRIPTIONDIALOG_H__
36
#include "imapaccount.h"
38
#include <ksubscription.h>
43
using KPIM::KSubscription;
44
using KPIM::GroupItem;
45
using KPIM::KGroupInfo;
47
// Abstract base class for the server side and client side subscription dialogs.
48
// Scott Meyers says: "Make non-leaf classes abstract" and he is right, I think.
49
// (More Effective C++, Item 33)
50
class SubscriptionDialogBase : public KSubscription
55
SubscriptionDialogBase( QWidget *parent,
56
const QString &caption,
58
bool &selectionChanged,
59
const QString &startPath = QString() );
60
virtual ~SubscriptionDialogBase() {
66
* Find the parent item
68
void findParentItem ( QString &name, QString &path, QString &compare,
69
GroupItem **parent, GroupItem **oldItem );
72
* Process the next prefix in mPrefixList
76
virtual void loadingComplete();
80
* get the listing from the imap-server
82
void slotListDirectory( KJob *job );
85
* Called from the account when a connection was established
87
void slotConnectionSuccess();
93
void slotLoadFolders();
98
* Reimplemented from KDialog to call doSave() when the OK button is clicked.
99
* This makes it possible to keep the dialog open after the user canceled the dialog
100
* from checkIfSubscriptionsEnabled().
102
virtual void slotButtonClicked( int button );
104
virtual void listAllAvailableAndCreateItems() = 0;
105
virtual void processFolderListing() = 0;
108
* @return false is saving was canceled by the user
110
virtual bool doSave() = 0;
113
/** Move all child items of @param oldItem under @param item */
114
void moveChildrenToNewParent( GroupItem *oldItem, GroupItem *item );
116
/** Create a listview item for the i-th entry in the list of available
118
void createListViewItem( int i );
121
* If subscriptions are not enabled it
122
* shows a messagebox which asks to user to enable the option.
124
* If the subscriptions should be enabled, this method will set
125
* mForceSubscriptionEnable to true, otherwise to false.
127
* This function calls subscriptionOptionEnabled() to check if the option
128
* is currently enabled and subscriptionOptionQuestion() to get the text for
131
* @return false if the user clicked cancel, true otherwise
133
bool checkIfSubscriptionsEnabled();
135
virtual bool subscriptionOptionEnabled( const ImapAccount *account ) const = 0;
136
virtual QString subscriptionOptionQuestion( const QString &accountName ) const = 0;
138
QStringList mDelimiters;
139
QStringList mFolderNames;
140
QStringList mFolderPaths;
141
QList<bool> mFolderSelectable;
143
bool mOnlySubscribed;
146
QMap<QString, GroupItem*> mItemDict;
149
bool mForceSubscriptionEnable;
150
bool &mSelectionChanged;
153
class SubscriptionDialog : public SubscriptionDialogBase
158
SubscriptionDialog( QWidget *parent,
159
const QString &caption,
161
bool &selectionChanged,
162
const QString & startPath = QString() );
163
virtual ~SubscriptionDialog();
166
virtual void listAllAvailableAndCreateItems();
168
virtual void processFolderListing();
170
virtual bool doSave();
172
virtual bool subscriptionOptionEnabled( const ImapAccount *account ) const;
174
virtual QString subscriptionOptionQuestion( const QString &accountName ) const;
178
* Create or update the listitems, depending on whether we are listing
179
* all available folders, or only subscribed ones.