Spectral/matrix/roomlistmodel.h

55 lines
1.3 KiB
C
Raw Normal View History

2018-02-28 09:10:42 +00:00
#ifndef ROOMLISTMODEL_H
#define ROOMLISTMODEL_H
#include <QObject>
2018-02-28 13:11:42 +00:00
#include <QtCore/QAbstractListModel>
2018-02-28 09:10:42 +00:00
#include "libqmatrixclient/connection.h"
#include "libqmatrixclient/room.h"
namespace QMatrixClient {
class Connection;
class Room;
}
2018-02-28 13:11:42 +00:00
class RoomListModel : public QAbstractListModel
{
Q_OBJECT
2018-03-02 11:58:55 +00:00
Q_PROPERTY(QMatrixClient::Connection *connection READ getConnection WRITE setConnection NOTIFY connectionChanged)
2018-02-28 09:10:42 +00:00
public:
2018-03-02 11:58:55 +00:00
explicit RoomListModel();
2018-02-28 09:10:42 +00:00
~RoomListModel();
2018-02-28 13:11:42 +00:00
enum RoomModelRoles {
2018-03-02 08:56:36 +00:00
NameRole, ValueRole, AvatarRole
2018-02-28 13:11:42 +00:00
};
2018-03-02 11:58:55 +00:00
QMatrixClient::Connection* m_connection;
QMatrixClient::Connection* getConnection() { return m_connection; }
void setConnection(QMatrixClient::Connection* conn);
2018-02-28 13:11:42 +00:00
QHash<int, QByteArray> roleNames() const;
2018-02-28 09:10:42 +00:00
Q_INVOKABLE QMatrixClient::Room* roomAt(int row);
2018-02-28 13:11:42 +00:00
QVariant data(const QModelIndex& index, int role) const override;
Q_INVOKABLE int rowCount(const QModelIndex& parent=QModelIndex()) const override;
2018-02-28 09:10:42 +00:00
signals:
2018-03-02 11:58:55 +00:00
void connectionChanged();
2018-02-28 09:10:42 +00:00
public slots:
private slots:
void namesChanged(QMatrixClient::Room* room);
void unreadMessagesChanged(QMatrixClient::Room* room);
void addRoom(QMatrixClient::Room* room);
private:
QList<QMatrixClient::Room*> m_rooms;
};
#endif // ROOMLISTMODEL_H