Minimum code to get multiple accounts working.

This commit is contained in:
Black Hat
2018-09-09 10:12:45 +08:00
parent 8fb16d0700
commit 2992804472
10 changed files with 401 additions and 196 deletions

34
src/accountlistmodel.h Normal file
View File

@@ -0,0 +1,34 @@
#ifndef ACCOUNTLISTMODEL_H
#define ACCOUNTLISTMODEL_H
#include "controller.h"
#include <QAbstractListModel>
#include <QObject>
class AccountListModel : public QAbstractListModel {
Q_OBJECT
Q_PROPERTY(Controller* controller READ controller WRITE setController NOTIFY
controllerChanged)
public:
enum EventRoles { NameRole = Qt::UserRole + 1, AvatarRole, ConnectionRole };
AccountListModel(QObject* parent = nullptr);
QVariant data(const QModelIndex& index, int role = NameRole) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QHash<int, QByteArray> roleNames() const override;
Controller* controller() { return m_controller; }
void setController(Controller* value);
private:
Controller* m_controller;
QVector<Connection*> m_connections;
signals:
void controllerChanged();
};
#endif // ACCOUNTLISTMODEL_H