Spectral/matrix/roomlistmodel.h

71 lines
1.4 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 RoomModel : public QObject
2018-02-28 09:10:42 +00:00
{
Q_OBJECT
2018-02-28 13:11:42 +00:00
Q_PROPERTY(QString name READ getName)
Q_PROPERTY(QString value READ getValue)
public:
explicit RoomModel(QString name, QString value);
QString getName() { return m_name; }
QString getValue() { return m_value; }
signals:
void nameChanged();
void valueChanged();
private:
QString m_name;
QString m_value;
};
class RoomListModel : public QAbstractListModel
{
Q_OBJECT
2018-02-28 09:10:42 +00:00
public:
explicit RoomListModel(QMatrixClient::Connection* m_connection = 0);
2018-02-28 09:10:42 +00:00
~RoomListModel();
2018-02-28 13:11:42 +00:00
enum RoomModelRoles {
NameRole, ValueRole, IconRole
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:
public slots:
private slots:
void namesChanged(QMatrixClient::Room* room);
void unreadMessagesChanged(QMatrixClient::Room* room);
void addRoom(QMatrixClient::Room* room);
private:
QMatrixClient::Connection* m_connection;
2018-02-28 09:10:42 +00:00
QList<QMatrixClient::Room*> m_rooms;
};
#endif // ROOMLISTMODEL_H