Spectral/matrix/roomlistmodel.h

44 lines
1.2 KiB
C
Raw Normal View History

2018-02-28 09:10:42 +00:00
#ifndef ROOMLISTMODEL_H
#define ROOMLISTMODEL_H
2018-02-28 13:11:42 +00:00
#include <QtCore/QAbstractListModel>
#include "connection.h"
2018-07-09 02:45:26 +00:00
#include "room.h"
2018-02-28 09:10:42 +00:00
2018-07-09 02:45:26 +00:00
class RoomListModel : public QAbstractListModel {
Q_OBJECT
Q_PROPERTY(QMatrixClient::Connection* connection READ getConnection WRITE
setConnection)
2018-03-02 11:58:55 +00:00
2018-07-09 02:45:26 +00:00
public:
RoomListModel(QObject* parent = 0);
virtual ~RoomListModel();
2018-02-28 13:11:42 +00:00
2018-07-09 02:45:26 +00:00
QMatrixClient::Connection* getConnection() { return m_connection; }
void setConnection(QMatrixClient::Connection* connection);
2018-02-28 09:10:42 +00:00
2018-07-09 02:45:26 +00:00
Q_INVOKABLE QMatrixClient::Room* roomAt(int row);
2018-07-09 02:45:26 +00:00
QVariant data(const QModelIndex& index,
int role = Qt::DisplayRole) const override;
Q_INVOKABLE int rowCount(
const QModelIndex& parent = QModelIndex()) const override;
2018-02-28 09:10:42 +00:00
2018-07-09 02:45:26 +00:00
QHash<int, QByteArray> roleNames() const;
2018-02-28 09:10:42 +00:00
2018-07-09 02:45:26 +00:00
private slots:
void namesChanged(QMatrixClient::Room* room);
void unreadMessagesChanged(QMatrixClient::Room* room);
void addRoom(QMatrixClient::Room* room);
2018-07-09 05:36:28 +00:00
void deleteRoom(QMatrixClient::Room* room);
2018-02-28 09:10:42 +00:00
2018-07-09 02:45:26 +00:00
private:
QMatrixClient::Connection* m_connection = nullptr;
QList<QMatrixClient::Room*> m_rooms;
2018-03-14 09:11:45 +00:00
2018-07-09 02:45:26 +00:00
signals:
void connectionChanged();
2018-02-28 09:10:42 +00:00
};
2018-07-09 02:45:26 +00:00
#endif // ROOMLISTMODEL_H