2
localsubscriptiondialog.cpp
4
This file is part of KMail, the KDE mail client.
5
Copyright (C) 2006 Till Adam <adam@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 along
17
with this program; if not, write to the Free Software Foundation, Inc.,
18
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
32
#include "localsubscriptiondialog.h"
36
#include <kmessagebox.h>
39
#include "accountmanager.h"
40
#include "kmmessage.h"
41
#include "imapaccountbase.h"
46
LocalSubscriptionDialog::LocalSubscriptionDialog( QWidget *parent, const QString &caption,
47
ImapAccountBase *acct, const QString &startPath )
48
: SubscriptionDialog( parent, caption, acct, startPath ),
54
LocalSubscriptionDialog::~LocalSubscriptionDialog()
59
void LocalSubscriptionDialog::listAllAvailableAndCreateItems()
61
if ( mAccount->onlySubscribedFolders() )
63
SubscriptionDialog::listAllAvailableAndCreateItems();
67
void LocalSubscriptionDialog::processFolderListing()
70
for (int i = mCount; i < mFolderNames.count(); ++i)
72
// give the dialog a chance to repaint
76
QTimer::singleShot(0, this, SLOT(processItems()));
81
createListViewItem( i );
84
if ( mPrefixList.isEmpty() && !mSubscribed )
85
loadingComplete(); // no need to load subscribed folders
90
void LocalSubscriptionDialog::setCheckedStateOfAllItems()
92
// iterate over all items and check them, unless they are
93
// in the account's local subscription blacklist
94
QMapIterator<QString, GroupItem*> it( mItemDict );
95
while ( it.hasNext() ) {
97
QString path = it.key();
98
GroupItem *item = it.value();
99
item->setOn( mAccount->locallySubscribedTo( path ) );
104
bool LocalSubscriptionDialog::doSave()
106
if ( !checkIfSubscriptionsEnabled() )
109
bool somethingHappened = false;
111
QTreeWidgetItemIterator it(subView);
113
static_cast<ImapAccountBase*>(account())->changeLocalSubscription(
114
static_cast<GroupItem*>(*it)->info().path, true );
115
somethingHappened = true;
119
QTreeWidgetItemIterator it2(unsubView);
120
if ( unsubView->topLevelItemCount() > 0 ) {
121
const QString message = i18nc( "@info", "Locally unsubscribing from folders will remove all "
122
"information that is present locally about those folders. The folders will "
123
"not be changed on the server. Press cancel now if you want to make sure "
124
"all local changes have been written to the server by checking mail first.");
125
const QString caption = i18nc( "@title:window", "Local changes will be lost when "
127
if ( KMessageBox::warningContinueCancel( this, message, caption )
128
!= KMessageBox::Cancel ) {
129
somethingHappened = true;
130
for ( ; *it2; ++it2) {
131
static_cast<ImapAccountBase*>(account())->changeLocalSubscription(
132
static_cast<GroupItem*>(*it2)->info().path, false );
138
// Slight code duplication with SubscriptionDialog follows!
139
KMail::ImapAccountBase *a = static_cast<KMail::ImapAccountBase*>( mAcct );
140
if ( mForceSubscriptionEnable ) {
141
a->setOnlyLocallySubscribedFolders( true );
144
if ( somethingHappened && subscriptionOptionEnabled( a ) ) {
145
kmkernel->acctMgr()->singleCheckMail( mAccount, true);
151
bool LocalSubscriptionDialog::subscriptionOptionEnabled( const KMail::ImapAccountBase *account ) const
153
return account->onlyLocallySubscribedFolders();
156
QString LocalSubscriptionDialog::subscriptionOptionQuestion( const QString &accountName ) const
158
return i18nc( "@info", "Currently local subscriptions are not used for account <resource>%1</resource>.<nl/>"
159
"\nDo you want to enable local subscriptions?", accountName );
162
void LocalSubscriptionDialog::loadingComplete()
164
setCheckedStateOfAllItems();
165
SubscriptionDialog::loadingComplete();
170
#include "localsubscriptiondialog.moc"