Model for the account view. More...
#include <accountviewmodel.h>
Public Member Functions | |
AccountViewModel (AccountList *accounts, QObject *parent) | |
Constructor. | |
~AccountViewModel () | |
Destructor. | |
virtual QModelIndex | index (int row, int column, const QModelIndex &parent) const |
Returns the index of the account data in this model specified by the given row, column. | |
virtual QModelIndex | parent (const QModelIndex &) const |
Overloaded from QAbstractItemModel. | |
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const |
Overloaded from QAbstractItemModel. | |
virtual int | columnCount (const QModelIndex &) const |
Overloaded from QAbstractItemModel. | |
virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
Overloaded from QAbstractItemModel. | |
virtual bool | hasChildren (const QModelIndex &parent=QModelIndex()) const |
Overloaded from QAbstractItemModel. | |
virtual Qt::ItemFlags | flags (const QModelIndex &index) const |
Returns the flags of the given index. | |
QVariant | headerData (int section, Qt::Orientation orientation, int role) const |
Returns the header text of the given section. | |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
Assign the given value to the account property described by the given index. | |
void | refresh () |
Emits the dataChanged signal to the views to inform they about changed data. | |
void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) |
Sorts the model by column in the given order. | |
void | sort () |
Sorts the model by the last sort properties. | |
void | saveSetup () |
Saves the setup. | |
Account * | getAccount (const QModelIndex index) const |
Returns the account at the given index. | |
Private Attributes | |
AccountList * | accounts |
Pointer to the account list. | |
QList< AccountViewItem > | viewAccountList |
In this we store the account view items. | |
KIcon | picActive |
Picture for a active account. | |
KIcon | picNotActive |
Picture for a inactive account. | |
Qt::SortOrder | lastSortOrder |
Last sort order. | |
int | lastSortColumn |
last sort column |
Model for the account view.
Definition at line 46 of file accountviewmodel.h.
AccountViewModel::AccountViewModel | ( | AccountList * | accounts, | |
QObject * | parent | |||
) |
Constructor.
accounts | pointer to the account list
|
Definition at line 20 of file accountviewmodel.cpp.
AccountViewModel::~AccountViewModel | ( | ) |
Destructor.
Definition at line 33 of file accountviewmodel.cpp.
int AccountViewModel::columnCount | ( | const QModelIndex & | ) | const [virtual] |
Overloaded from QAbstractItemModel.
Doesn't give a parent item, because the model doesn't provide tree structured data. The column count is equal to the number of showed account data. Always returns 6.
Definition at line 57 of file accountviewmodel.cpp.
QVariant AccountViewModel::data | ( | const QModelIndex & | index, | |
int | role = Qt::DisplayRole | |||
) | const [virtual] |
Overloaded from QAbstractItemModel.
Returns the data of the given index.
index | the index
|
Definition at line 62 of file accountviewmodel.cpp.
Qt::ItemFlags AccountViewModel::flags | ( | const QModelIndex & | index | ) | const [virtual] |
Returns the flags of the given index.
index | index |
Definition at line 143 of file accountviewmodel.cpp.
Account * AccountViewModel::getAccount | ( | const QModelIndex | index | ) | const |
Returns the account at the given index.
index | index |
Definition at line 317 of file accountviewmodel.cpp.
bool AccountViewModel::hasChildren | ( | const QModelIndex & | parent = QModelIndex() |
) | const [virtual] |
Overloaded from QAbstractItemModel.
It returns true if the given index is invalid because a invalid index is the root index. All content is a child of the root index. If the index is valid it always returns false because no data has a child.
parent | parent index |
Definition at line 134 of file accountviewmodel.cpp.
QVariant AccountViewModel::headerData | ( | int | section, | |
Qt::Orientation | orientation, | |||
int | role | |||
) | const |
Returns the header text of the given section.
section | header section
|
Definition at line 156 of file accountviewmodel.cpp.
QModelIndex AccountViewModel::index | ( | int | row, | |
int | column, | |||
const QModelIndex & | parent | |||
) | const [virtual] |
Returns the index of the account data in this model specified by the given row, column.
The parent index is not used. Overloaded from QAbstractItemModel
row | Row
|
Definition at line 35 of file accountviewmodel.cpp.
QModelIndex AccountViewModel::parent | ( | const QModelIndex & | ) | const [virtual] |
Overloaded from QAbstractItemModel.
Because this model doesn't provide tree structured data this function just returns an invalid index.
Definition at line 44 of file accountviewmodel.cpp.
void AccountViewModel::refresh | ( | ) |
Emits the dataChanged signal to the views to inform they about changed data.
Definition at line 206 of file accountviewmodel.cpp.
int AccountViewModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() |
) | const [virtual] |
Overloaded from QAbstractItemModel.
Doesn't give a parent item, because the model doesn't provide tree structured data The row count is equal to the number of accounts.
parent | parent index |
Definition at line 49 of file accountviewmodel.cpp.
void AccountViewModel::saveSetup | ( | ) |
Saves the setup.
Definition at line 299 of file accountviewmodel.cpp.
bool AccountViewModel::setData | ( | const QModelIndex & | index, | |
const QVariant & | value, | |||
int | role = Qt::EditRole | |||
) |
Assign the given value to the account property described by the given index.
index | index
|
Definition at line 174 of file accountviewmodel.cpp.
void AccountViewModel::sort | ( | ) |
Sorts the model by the last sort properties.
Definition at line 294 of file accountviewmodel.cpp.
void AccountViewModel::sort | ( | int | column, | |
Qt::SortOrder | order = Qt::AscendingOrder | |||
) |
Sorts the model by column in the given order.
column | column to sort
|
Definition at line 214 of file accountviewmodel.cpp.
AccountList* AccountViewModel::accounts [private] |
Pointer to the account list.
Definition at line 176 of file accountviewmodel.h.
int AccountViewModel::lastSortColumn [private] |
last sort column
Definition at line 205 of file accountviewmodel.h.
Qt::SortOrder AccountViewModel::lastSortOrder [private] |
Last sort order.
Definition at line 200 of file accountviewmodel.h.
KIcon AccountViewModel::picActive [private] |
Picture for a active account.
Set by the constructor
Definition at line 188 of file accountviewmodel.h.
KIcon AccountViewModel::picNotActive [private] |
Picture for a inactive account.
Set by the constructor
Definition at line 195 of file accountviewmodel.h.
QList<AccountViewItem > AccountViewModel::viewAccountList [private] |
In this we store the account view items.
Definition at line 181 of file accountviewmodel.h.