00001 /* 00002 Copyright 2010 Ulrich Weigelt <ulrich.weigelt@gmx.de> 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU General Public License as 00006 published by the Free Software Foundation; either version 2 of 00007 the License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef ACCOUNTLIST_H 00019 #define ACCOUNTLIST_H 00020 00021 //Qt headers 00022 #include <QObject> 00023 #include <QList> 00024 #include <qitemselectionmodel.h> 00025 #include <QFile> 00026 #include <QPointer> 00027 00028 //KDE headers 00029 #include <KGlobal> 00030 #include <KConfigGroup> 00031 #include <KDebug> 00032 #include <KConfig> 00033 00034 //KShowmail headers 00035 #include "account.h" 00036 #include "constants.h" 00037 #include "types.h" 00038 #include "corruptdataexception.h" 00039 #include "filterlog.h" 00040 #include "mail.h" 00041 #include "accountviewitem.h" 00042 00043 using namespace Types; 00044 00045 class Account; 00046 00050 class AccountList : public QObject 00051 { 00052 Q_OBJECT 00053 00054 public: 00055 00060 AccountList( QObject* parent ); 00061 00065 ~AccountList(); 00066 00072 Account* addAccount( const QString& name ); 00073 00077 void print() const; 00078 00083 int numberAccounts() const; 00084 00090 Account* getAccount( int index ) const; 00091 00097 Account* getAccount( QString name ) const; 00098 00103 QList<QPointer<Account> > getAllAccounts() const; 00104 00109 QList<AccountViewItem> getAllAccountViewItems() const; 00110 00117 bool hasAccount( QString accountName ) const; 00118 00122 void loadSetup(); 00123 00130 void refreshMailLists( FilterLog* log ); 00131 00137 bool keepNew(); 00138 00143 int getNumberMails() const; 00144 00152 void deleteMails(); 00153 00158 int numberDeletedMailsLastRefresh(); 00159 00164 int numberDeletedMailsStart(); 00165 00170 int numberMovedMailsLastRefresh(); 00171 00176 int numberMovedMailsStart(); 00177 00182 int numberIgnoredMails(); 00183 00187 void refreshFilterSetup(); 00188 00195 void saveOptions(); 00196 00202 void showMails(); 00203 00208 int getNumberNewMails(); 00209 00216 void readStoredMails(); 00217 00222 QList<Mail> getAllMails() const; 00223 00227 void cancelTasks(); 00228 00229 00230 private: 00231 00235 QList<QPointer<Account> > accounts; 00236 00249 AccountTaskMap_Type accountRefreshMap; 00250 00263 AccountTaskMap_Type accountDeletionMap; 00264 00277 AccountTaskMap_Type AccountShowBodiesMap; 00278 00286 int ctrOpenMessageWindows; 00287 00291 bool keepMailsNew; 00292 00293 00294 protected: 00295 00299 void init(); 00300 00301 00302 protected slots: 00303 00314 void slotCheckRefreshState( QString account ); 00315 00326 void slotMessageWindowOpened(); 00327 00338 void slotMessageWindowClosed(); 00339 00340 00351 void slotCheckDeletionState( QString account ); 00352 00363 void slotCheckShowBodiesState( QString account ); 00364 00365 00366 signals: 00367 00371 void sigRefreshReady(); 00372 00378 void sigMessageWindowOpened(); 00379 00385 void sigAllMessageWindowsClosed(); 00386 00390 void sigDeleteReady(); 00391 00395 void sigShowBodiesReady(); 00396 00397 00398 }; 00399 00400 #endif // ACCOUNTLIST_H