kmail

localsubscriptiondialog.cpp
1/*
2 localsubscriptiondialog.cpp
3
4 This file is part of KMail, the KDE mail client.
5 Copyright (C) 2006 Till Adam <adam@kde.org>
6
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.
10
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.
15
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
19
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 TQt library by Trolltech AS, Norway (or with modified versions
23 of TQt that use the same license as TQt), 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 TQt. 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.
30*/
31
32#ifdef HAVE_CONFIG_H
33#include <config.h>
34#endif
35
36#include <kdebug.h>
37#include <tdelocale.h>
38#include <tdemessagebox.h>
39
40#include "localsubscriptiondialog.h"
41#include "kmkernel.h"
42#include "accountmanager.h"
43#include "kmmessage.h"
44#include "imapaccountbase.h"
45#include "listjob.h"
46
47namespace KMail {
48
49LocalSubscriptionDialog::LocalSubscriptionDialog( TQWidget *parent, const TQString &caption,
50 ImapAccountBase *acct, TQString startPath )
51 : SubscriptionDialog( parent, caption, acct, startPath ),
52 mAccount( acct )
53{
54}
55
56/* virtual */
57LocalSubscriptionDialog::~LocalSubscriptionDialog()
58{
59
60}
61
62void LocalSubscriptionDialog::listAllAvailableAndCreateItems()
63{
64 if ( mAccount->onlySubscribedFolders() )
65 mSubscribed = true;
66 SubscriptionDialog::listAllAvailableAndCreateItems();
67}
68
69/* virtual */
70void LocalSubscriptionDialog::processFolderListing()
71{
72 uint done = 0;
73 for (uint i = mCount; i < mFolderNames.count(); ++i)
74 {
75 // give the dialog a chance to repaint
76 if (done == 1000)
77 {
78 emit listChanged();
79 TQTimer::singleShot(0, this, TQ_SLOT(processItems()));
80 return;
81 }
82 ++mCount;
83 ++done;
84 createListViewItem( i );
85 }
86
87 if ( mPrefixList.isEmpty() && !mSubscribed )
88 loadingComplete(); // no need to load subscribed folders
89 else
90 processNext();
91}
92
93void LocalSubscriptionDialog::setCheckedStateOfAllItems()
94{
95 // iterate over all items and check them, unless they are
96 // in the account's local subscription blacklist
97 TQDictIterator<GroupItem> it( mItemDict );
98 for ( ; it.current(); ++it ) {
99 GroupItem *item = it.current();
100 TQString path = it.currentKey();
101 item->setOn( mAccount->locallySubscribedTo( path ) );
102 }
103}
104
105/*virtual*/
106void LocalSubscriptionDialog::doSave()
107{
108 bool somethingHappened = false;
109 // subscribe
110 TQListViewItemIterator it(subView);
111 for ( ; it.current(); ++it) {
112 static_cast<ImapAccountBase*>(account())->changeLocalSubscription(
113 static_cast<GroupItem*>(it.current())->info().path, true );
114 somethingHappened = true;
115 }
116
117 // unsubscribe
118 TQListViewItemIterator it2(unsubView);
119 if ( unsubView->childCount() > 0 ) {
120 const TQString message = i18n("Locally unsubscribing from folders will remove all "
121 "information that is present locally about those folders. The folders will "
122 "not be changed on the server. Press cancel now if you want to make sure "
123 "all local changes have been written to the server by checking mail first.");
124 const TQString caption = i18n("Local changes will be lost when unsubscribing");
125 if ( KMessageBox::warningContinueCancel( this, message, caption )
126 != KMessageBox::Cancel ) {
127 somethingHappened = true;
128 for ( ; it2.current(); ++it2) {
129 static_cast<ImapAccountBase*>(account())->changeLocalSubscription(
130 static_cast<GroupItem*>(it2.current())->info().path, false );
131 }
132
133 }
134 }
135 if ( somethingHappened ) {
136 kmkernel->acctMgr()->singleCheckMail( mAccount, true);
137 }
138}
139
140void LocalSubscriptionDialog::loadingComplete()
141{
142 setCheckedStateOfAllItems();
143 SubscriptionDialog::loadingComplete();
144}
145
146} // namespace
147
148#include "localsubscriptiondialog.moc"
folderdiaquotatab.h
Definition: aboutdata.cpp:40