00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef ACCOUNTVIEWMODEL_H
00019 #define ACCOUNTVIEWMODEL_H
00020
00021 class AccountList;
00022
00023
00024 #include <QAbstractItemModel>
00025 #include <QModelIndex>
00026 #include <QList>
00027
00028
00029 #include <KDebug>
00030 #include <KDE/KLocale>
00031 #include <KIcon>
00032 #include <KStandardDirs>
00033 #include <KConfigGroup>
00034
00035
00036 #include "accountlist.h"
00037 #include "account.h"
00038 #include "accountviewitem.h"
00039
00040
00041 #define NUMBER_ACCOUNTVIEW_COLUMNS 6
00042
00046 class AccountViewModel : public QAbstractItemModel
00047 {
00048 Q_OBJECT
00049
00050 public:
00051
00057 AccountViewModel( AccountList* accounts, QObject* parent );
00058
00062 ~AccountViewModel();
00063
00073 virtual QModelIndex index( int row, int column, const QModelIndex& parent ) const;
00074
00081 virtual QModelIndex parent( const QModelIndex& ) const;
00082
00090 virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
00091
00099 virtual int columnCount ( const QModelIndex& ) const;
00100
00108 virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
00109
00118 virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
00119
00125 virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
00126
00133 QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
00134
00141 bool setData( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
00142
00146 void refresh();
00147
00153 void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );
00154
00158 void sort();
00159
00163 void saveSetup();
00164
00169 Account* getAccount( const QModelIndex index ) const;
00170
00171 private:
00172
00176 AccountList* accounts;
00177
00181 QList<AccountViewItem > viewAccountList;
00182
00188 KIcon picActive;
00189
00195 KIcon picNotActive;
00196
00200 Qt::SortOrder lastSortOrder;
00201
00205 int lastSortColumn;
00206
00207
00208
00209 };
00210
00211 #endif // ACCOUNTVIEWMODEL_H