~ubuntu-branches/ubuntu/karmic/kdepim/karmic-backports

« back to all changes in this revision

Viewing changes to akonadi/resources/imap/subscriptiondialog.h

  • Committer: Bazaar Package Importer
  • Author(s): Christian Mangold
  • Date: 2009-07-10 06:34:50 UTC
  • mfrom: (1.1.40 upstream)
  • Revision ID: james.westby@ubuntu.com-20090710063450-neojgew2fh0n3y0u
Tags: 4:4.2.96-0ubuntu1
* New upstream release
* Bump kde build-deps to 4.2.96

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  -*- c++ -*-
2
 
    subscriptiondialog.h
3
 
 
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>
7
 
 
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.
11
 
 
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.
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
 
 
33
 
#ifndef __SUBSCRIPTIONDIALOG_H__
34
 
#define __SUBSCRIPTIONDIALOG_H__
35
 
 
36
 
#include "imapaccount.h"
37
 
 
38
 
#include <ksubscription.h>
39
 
 
40
 
#include <QMap>
41
 
 
42
 
using KPIM::KAccount;
43
 
using KPIM::KSubscription;
44
 
using KPIM::GroupItem;
45
 
using KPIM::KGroupInfo;
46
 
 
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
51
 
{
52
 
  Q_OBJECT
53
 
 
54
 
  public:
55
 
    SubscriptionDialogBase( QWidget *parent,
56
 
                            const QString &caption,
57
 
                            KAccount* acct,
58
 
                            bool &selectionChanged,
59
 
                            const QString &startPath = QString() );
60
 
    virtual ~SubscriptionDialogBase() {
61
 
      mItemDict.clear();
62
 
    }
63
 
 
64
 
  protected:
65
 
    /**
66
 
     * Find the parent item
67
 
     */
68
 
    void findParentItem ( QString &name, QString &path, QString &compare,
69
 
                          GroupItem **parent, GroupItem **oldItem );
70
 
 
71
 
    /**
72
 
     * Process the next prefix in mPrefixList
73
 
     */
74
 
    void processNext();
75
 
 
76
 
    virtual void loadingComplete();
77
 
 
78
 
  public slots:
79
 
    /**
80
 
     * get the listing from the imap-server
81
 
     */
82
 
    void slotListDirectory( KJob *job );
83
 
 
84
 
    /**
85
 
     * Called from the account when a connection was established
86
 
     */
87
 
    void slotConnectionSuccess();
88
 
 
89
 
  protected slots:
90
 
    /**
91
 
     * Loads the folders
92
 
     */
93
 
    void slotLoadFolders();
94
 
 
95
 
  protected:
96
 
 
97
 
    /**
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().
101
 
     */
102
 
    virtual void slotButtonClicked( int button );
103
 
 
104
 
    virtual void listAllAvailableAndCreateItems() = 0;
105
 
    virtual void processFolderListing() = 0;
106
 
 
107
 
    /**
108
 
     * @return false is saving was canceled by the user
109
 
     */
110
 
    virtual bool doSave() = 0;
111
 
 
112
 
    // helpers
113
 
    /** Move all child items of @param oldItem under @param item */
114
 
    void moveChildrenToNewParent( GroupItem *oldItem, GroupItem *item  );
115
 
 
116
 
    /** Create a listview item for the i-th entry in the list of available
117
 
     * folders. */
118
 
    void createListViewItem( int i );
119
 
 
120
 
    /**
121
 
     * If subscriptions are not enabled it
122
 
     * shows a messagebox which asks to user to enable the option.
123
 
     *
124
 
     * If the subscriptions should be enabled, this method will set
125
 
     * mForceSubscriptionEnable to true, otherwise to false.
126
 
     *
127
 
     * This function calls subscriptionOptionEnabled() to check if the option
128
 
     * is currently enabled and subscriptionOptionQuestion() to get the text for
129
 
     * the messagebox.
130
 
     *
131
 
     * @return false if the user clicked cancel, true otherwise
132
 
     */
133
 
    bool checkIfSubscriptionsEnabled();
134
 
 
135
 
    virtual bool subscriptionOptionEnabled( const ImapAccount *account ) const = 0;
136
 
    virtual QString subscriptionOptionQuestion( const QString &accountName ) const = 0;
137
 
 
138
 
    QStringList mDelimiters;
139
 
    QStringList mFolderNames;
140
 
    QStringList mFolderPaths;
141
 
    QList<bool> mFolderSelectable;
142
 
 
143
 
    bool mOnlySubscribed;
144
 
    uint mCount;
145
 
 
146
 
    QMap<QString, GroupItem*> mItemDict;
147
 
    QString mStartPath;
148
 
    bool mSubscribed;
149
 
    bool mForceSubscriptionEnable;
150
 
    bool &mSelectionChanged;
151
 
};
152
 
 
153
 
class SubscriptionDialog : public SubscriptionDialogBase
154
 
{
155
 
  Q_OBJECT
156
 
 
157
 
  public:
158
 
    SubscriptionDialog( QWidget *parent,
159
 
                        const QString &caption,
160
 
                        KAccount* acct,
161
 
                        bool &selectionChanged,
162
 
                        const QString & startPath = QString() );
163
 
    virtual ~SubscriptionDialog();
164
 
  protected:
165
 
    /** reimpl */
166
 
    virtual void listAllAvailableAndCreateItems();
167
 
    /** reimpl */
168
 
    virtual void processFolderListing();
169
 
    /** reimpl */
170
 
    virtual bool doSave();
171
 
    /** reimpl */
172
 
    virtual bool subscriptionOptionEnabled( const ImapAccount *account ) const;
173
 
    /** reimpl */
174
 
    virtual QString subscriptionOptionQuestion( const QString &accountName ) const;
175
 
 
176
 
  private:
177
 
    /**
178
 
     * Create or update the listitems, depending on whether we are listing
179
 
     * all available folders, or only subscribed ones.
180
 
     */
181
 
    void processItems();
182
 
};
183
 
 
184
 
#endif