kmail
localsubscriptiondialog.cppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifdef HAVE_CONFIG_H
00033 #include <config.h>
00034 #endif
00035
00036 #include <kdebug.h>
00037 #include <klocale.h>
00038 #include <kmessagebox.h>
00039
00040 #include "localsubscriptiondialog.h"
00041 #include "kmkernel.h"
00042 #include "accountmanager.h"
00043 #include "kmmessage.h"
00044 #include "imapaccountbase.h"
00045 #include "listjob.h"
00046
00047 namespace KMail {
00048
00049 LocalSubscriptionDialog::LocalSubscriptionDialog( QWidget *parent, const QString &caption,
00050 ImapAccountBase *acct, QString startPath )
00051 : SubscriptionDialog( parent, caption, acct, startPath ),
00052 mAccount( acct )
00053 {
00054 }
00055
00056
00057 LocalSubscriptionDialog::~LocalSubscriptionDialog()
00058 {
00059
00060 }
00061
00062 void LocalSubscriptionDialog::listAllAvailableAndCreateItems()
00063 {
00064 if ( mAccount->onlySubscribedFolders() )
00065 mSubscribed = true;
00066 SubscriptionDialog::listAllAvailableAndCreateItems();
00067 }
00068
00069
00070 void LocalSubscriptionDialog::processFolderListing()
00071 {
00072 uint done = 0;
00073 for (uint i = mCount; i < mFolderNames.count(); ++i)
00074 {
00075
00076 if (done == 1000)
00077 {
00078 emit listChanged();
00079 QTimer::singleShot(0, this, SLOT(processItems()));
00080 return;
00081 }
00082 ++mCount;
00083 ++done;
00084 createListViewItem( i );
00085 }
00086
00087 if ( mPrefixList.isEmpty() && !mSubscribed )
00088 loadingComplete();
00089 else
00090 processNext();
00091 }
00092
00093 void LocalSubscriptionDialog::setCheckedStateOfAllItems()
00094 {
00095
00096
00097 QDictIterator<GroupItem> it( mItemDict );
00098 for ( ; it.current(); ++it ) {
00099 GroupItem *item = it.current();
00100 QString path = it.currentKey();
00101 item->setOn( mAccount->locallySubscribedTo( path ) );
00102 }
00103 }
00104
00105
00106 void LocalSubscriptionDialog::doSave()
00107 {
00108 bool somethingHappened = false;
00109
00110 QListViewItemIterator it(subView);
00111 for ( ; it.current(); ++it) {
00112 static_cast<ImapAccountBase*>(account())->changeLocalSubscription(
00113 static_cast<GroupItem*>(it.current())->info().path, true );
00114 somethingHappened = true;
00115 }
00116
00117
00118 QListViewItemIterator it2(unsubView);
00119 if ( unsubView->childCount() > 0 ) {
00120 const QString message = i18n("Locally unsubscribing from folders will remove all "
00121 "information that is present locally about those folders. The folders will "
00122 "not be changed on the server. Press cancel now if you want to make sure "
00123 "all local changes have been written to the server by checking mail first.");
00124 const QString caption = i18n("Local changes will be lost when unsubscribing");
00125 if ( KMessageBox::warningContinueCancel( this, message, caption )
00126 != KMessageBox::Cancel ) {
00127 somethingHappened = true;
00128 for ( ; it2.current(); ++it2) {
00129 static_cast<ImapAccountBase*>(account())->changeLocalSubscription(
00130 static_cast<GroupItem*>(it2.current())->info().path, false );
00131 }
00132
00133 }
00134 }
00135 if ( somethingHappened ) {
00136 kmkernel->acctMgr()->singleCheckMail( mAccount, true);
00137 }
00138 }
00139
00140 void LocalSubscriptionDialog::loadingComplete()
00141 {
00142 setCheckedStateOfAllItems();
00143 SubscriptionDialog::loadingComplete();
00144 }
00145
00146 }
00147
00148 #include "localsubscriptiondialog.moc"
|