Public room directory.

This commit is contained in:
Black Hat
2019-12-25 00:02:01 +08:00
parent 29b396add3
commit e5032c686a
12 changed files with 230 additions and 44 deletions

43
src/publicroomlistmodel.h Normal file
View File

@@ -0,0 +1,43 @@
#ifndef PUBLICROOMLISTMODEL_H
#define PUBLICROOMLISTMODEL_H
#include <QObject>
#include <QAbstractListModel>
#include "connection.h"
#include "csapi/definitions/public_rooms_response.h"
using namespace Quotient;
class PublicRoomListModel : public QAbstractListModel {
Q_OBJECT
Q_PROPERTY(Connection* connection READ connection WRITE setConnection NOTIFY connectionChanged)
public:
enum EventRoles { NameRole = Qt::DisplayRole + 1, TopicRole };
PublicRoomListModel(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;
Connection* connection() const { return m_connection; }
void setConnection(Connection* value);
Q_INVOKABLE void next(int count = 50);
private:
Connection* m_connection = nullptr;
bool attempted = false;
QString nextBatch;
QVector<PublicRoomsChunk> rooms;
signals:
void connectionChanged();
};
#endif // PUBLICROOMLISTMODEL_H