refactoring ui models, temp

This commit is contained in:
Blue 2019-04-03 18:09:29 +03:00
parent 4a4ba47968
commit 2bcee521c5
7 changed files with 246 additions and 143 deletions

View file

@ -5,15 +5,16 @@
#include <deque>
#include <map>
#include "../../global.h"
#include "accounts.h"
#include "item.h"
#include "account.h"
namespace Models
{
class Roster : public QAbstractItemModel
{
class Item;
class ElId;
class Account;
Q_OBJECT
public:
Roster(QObject* parent = 0);
@ -30,52 +31,14 @@ public:
QModelIndex parent ( const QModelIndex& child ) const override;
QModelIndex index ( int row, int column, const QModelIndex& parent ) const override;
Accounts* accountsModel;
private:
Item* root;
std::map<QString, Account*> accounts;
std::map<ElId, Item*> elements;
private:
class Item {
public:
enum Type {
account,
group,
contect,
conversation,
root
};
explicit Item(Type p_type, const QMap<QString, QVariant> &data, Item *parentItem = 0);
~Item();
void appendChild(Item *child);
QString name() const;
void setName(const QString& name);
Item *child(int row);
int childCount() const;
int columnCount() const;
QVariant data(int column) const;
int row() const;
Item *parentItem();
const Type type;
protected:
std::deque<Item*> childItems;
std::deque<QVariant> itemData;
Item* parent;
};
class Account : public Item {
public:
explicit Account(const QMap<QString, QVariant> &data, Item *parentItem = 0);
~Account();
void setState(int state);
};
class ElId {
public:
ElId (const QString& p_account, const QString& p_name);