2019-03-31 21:05:09 +00:00
|
|
|
#ifndef MODELS_ROSTER_H
|
|
|
|
#define MODELS_ROSTER_H
|
|
|
|
|
|
|
|
#include <qabstractitemmodel.h>
|
|
|
|
#include <deque>
|
|
|
|
#include <map>
|
2019-04-02 21:58:43 +00:00
|
|
|
#include "../../global.h"
|
2019-04-03 15:09:29 +00:00
|
|
|
#include "accounts.h"
|
|
|
|
#include "item.h"
|
|
|
|
#include "account.h"
|
2019-03-31 21:05:09 +00:00
|
|
|
|
|
|
|
namespace Models
|
|
|
|
{
|
|
|
|
|
|
|
|
class Roster : public QAbstractItemModel
|
|
|
|
{
|
|
|
|
class ElId;
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
Roster(QObject* parent = 0);
|
|
|
|
~Roster();
|
|
|
|
|
|
|
|
void addAccount(const QMap<QString, QVariant> &data);
|
2019-04-02 21:58:43 +00:00
|
|
|
void updateAccount(const QString& account, const QString& field, const QVariant& value);
|
2019-03-31 21:05:09 +00:00
|
|
|
|
2019-04-02 21:58:43 +00:00
|
|
|
QVariant data ( const QModelIndex& index, int role ) const override;
|
2019-03-31 21:05:09 +00:00
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
2019-04-02 21:58:43 +00:00
|
|
|
int columnCount ( const QModelIndex& parent ) const override;
|
|
|
|
int rowCount ( const QModelIndex& parent ) const override;
|
|
|
|
QModelIndex parent ( const QModelIndex& child ) const override;
|
|
|
|
QModelIndex index ( int row, int column, const QModelIndex& parent ) const override;
|
2019-03-31 21:05:09 +00:00
|
|
|
|
2019-04-03 15:09:29 +00:00
|
|
|
Accounts* accountsModel;
|
|
|
|
|
2019-03-31 21:05:09 +00:00
|
|
|
private:
|
|
|
|
Item* root;
|
2019-04-02 21:58:43 +00:00
|
|
|
std::map<QString, Account*> accounts;
|
2019-03-31 21:05:09 +00:00
|
|
|
std::map<ElId, Item*> elements;
|
|
|
|
|
|
|
|
private:
|
|
|
|
class ElId {
|
|
|
|
public:
|
|
|
|
ElId (const QString& p_account, const QString& p_name);
|
|
|
|
|
|
|
|
const QString account;
|
|
|
|
const QString name;
|
|
|
|
|
|
|
|
bool operator < (const ElId& other) const;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MODELS_ROSTER_H
|