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 00194 void saveMails(); 00195 00201 void showMails(); 00202 00207 int getNumberNewMails(); 00208 00215 void readStoredMails(); 00216 00221 QList<Mail> getAllMails() const; 00222 00226 void cancelTasks(); 00227 00228 00229 private: 00230 00234 QList<QPointer<Account> > accounts; 00235 00248 AccountTaskMap_Type accountRefreshMap; 00249 00262 AccountTaskMap_Type accountDeletionMap; 00263 00276 AccountTaskMap_Type AccountShowBodiesMap; 00277 00285 int ctrOpenMessageWindows; 00286 00290 bool keepMailsNew; 00291 00292 00293 protected: 00294 00298 void init(); 00299 00300 00301 protected slots: 00302 00313 void slotCheckRefreshState( QString account ); 00314 00325 void slotMessageWindowOpened(); 00326 00337 void slotMessageWindowClosed(); 00338 00339 00350 void slotCheckDeletionState( QString account ); 00351 00362 void slotCheckShowBodiesState( QString account ); 00363 00364 00365 signals: 00366 00370 void sigRefreshReady(); 00371 00377 void sigMessageWindowOpened(); 00378 00384 void sigAllMessageWindowsClosed(); 00385 00389 void sigDeleteReady(); 00390 00394 void sigShowBodiesReady(); 00395 00396 00397 }; 00398 00399 #endif // ACCOUNTLIST_H