Backport r950340 | aacid | 2009-04-06 23:21:18 +0200 (Mon, 06 Apr 2009) | 4 lines
[kdepim.git] / kmail / subscriptiondialog.h
blob52fa201d4b5b5867c50d1a9f2e71ae537270ce4d
1 /* -*- c++ -*-
2 subscriptiondialog.h
4 This file is part of KMail, the KDE mail client.
5 Copyright (C) 2002 Carsten Burghardt <burghardt@kde.org>
7 KMail is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License, version 2, as
9 published by the Free Software Foundation.
11 KMail is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 In addition, as a special exception, the copyright holders give
21 permission to link the code of this program with any edition of
22 the Qt library by Trolltech AS, Norway (or with modified versions
23 of Qt that use the same license as Qt), and distribute linked
24 combinations including the two. You must obey the GNU General
25 Public License in all respects for all of the code used other than
26 Qt. If you modify this file, you may extend this exception to
27 your version of the file, but you are not obligated to do so. If
28 you do not wish to do so, delete this exception statement from
29 your version.
32 #ifndef __SUBSCRIPTIONDIALOG
33 #define __SUBSCRIPTIONDIALOG
35 #include "imapaccountbase.h"
37 #include <ksubscription.h>
39 #include <QMap>
41 using KPIM::KSubscription;
42 using KPIM::GroupItem;
43 using KPIM::KGroupInfo;
45 namespace KMail {
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
52 Q_OBJECT
54 public:
55 SubscriptionDialogBase( QWidget *parent,
56 const QString &caption,
57 KAccount* acct,
58 const QString &startPath = QString() );
59 virtual ~SubscriptionDialogBase() {
60 mItemDict.clear();
63 void show();
65 protected:
66 /**
67 * Find the parent item
69 void findParentItem ( QString &name, QString &path, QString &compare,
70 GroupItem **parent, GroupItem **oldItem );
72 /**
73 * Process the next prefix in mPrefixList
75 void processNext();
77 /**
78 * Fill mPrefixList
80 void initPrefixList();
82 virtual void loadingComplete();
84 public slots:
85 /**
86 * get the listing from the imap-server
88 void slotListDirectory(const QStringList&, const QStringList&,
89 const QStringList&, const QStringList&, const ImapAccountBase::jobData &);
91 /**
92 * called by Ok-button, saves the changes
94 void slotSave();
96 /**
97 * Called from the account when a connection was established
99 void slotConnectionResult( int errorCode, const QString& errorMsg );
101 protected slots:
103 * Loads the folders
105 void slotLoadFolders();
107 protected:
108 virtual void listAllAvailableAndCreateItems() = 0;
109 virtual void processFolderListing() = 0;
110 virtual void doSave() = 0;
112 // helpers
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
117 * folders. */
118 void createListViewItem( int i );
120 /** If subscriptions are not used for the server,
121 * asks "Do you want to enable subscriptions?" */
122 void checkIfSubscriptionsEnabled();
124 QString mDelimiter;
125 QStringList mFolderNames, mFolderPaths,
126 mFolderMimeTypes, mFolderAttributes;
127 ImapAccountBase::jobData mJobData;
128 uint mCount;
129 QMap<QString, GroupItem*> mItemDict;
130 QString mStartPath;
131 bool mSubscribed, mForceSubscriptionEnable;
132 QStringList mPrefixList;
133 QString mCurrentNamespace;
136 class SubscriptionDialog : public SubscriptionDialogBase
138 Q_OBJECT
139 public:
141 SubscriptionDialog( QWidget *parent,
142 const QString &caption,
143 KAccount* acct,
144 const QString & startPath = QString() );
145 virtual ~SubscriptionDialog();
146 protected:
147 /** reimpl */
148 virtual void listAllAvailableAndCreateItems();
149 /** reimpl */
150 virtual void processFolderListing();
151 /** reimpl */
152 virtual void doSave();
154 private:
156 * Create or update the listitems, depending on whether we are listing
157 * all available folders, or only subscribed ones.
159 void processItems();
163 } // namespace KMail
165 #endif