Improve public room list and add search functionalities.
This commit is contained in:
@@ -1,20 +1,26 @@
|
||||
#ifndef PUBLICROOMLISTMODEL_H
|
||||
#define PUBLICROOMLISTMODEL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
#include <QObject>
|
||||
|
||||
#include "connection.h"
|
||||
#include "csapi/definitions/public_rooms_response.h"
|
||||
#include "csapi/list_public_rooms.h"
|
||||
|
||||
using namespace Quotient;
|
||||
|
||||
class PublicRoomListModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Connection* connection READ connection WRITE setConnection NOTIFY connectionChanged)
|
||||
Q_PROPERTY(Connection* connection READ connection WRITE setConnection NOTIFY
|
||||
connectionChanged)
|
||||
Q_PROPERTY(QString server READ server WRITE setServer NOTIFY serverChanged)
|
||||
Q_PROPERTY(
|
||||
QString keyword READ keyword WRITE setKeyword NOTIFY keywordChanged)
|
||||
Q_PROPERTY(bool hasMore READ hasMore NOTIFY hasMoreChanged)
|
||||
|
||||
public:
|
||||
enum EventRoles { NameRole = Qt::DisplayRole + 1, TopicRole };
|
||||
enum EventRoles { NameRole = Qt::DisplayRole + 1, AvatarRole, TopicRole };
|
||||
|
||||
PublicRoomListModel(QObject* parent = nullptr);
|
||||
|
||||
@@ -26,18 +32,33 @@ class PublicRoomListModel : public QAbstractListModel {
|
||||
Connection* connection() const { return m_connection; }
|
||||
void setConnection(Connection* value);
|
||||
|
||||
QString server() const { return m_server; }
|
||||
void setServer(const QString& value);
|
||||
|
||||
QString keyword() const { return m_keyword; }
|
||||
void setKeyword(const QString& value);
|
||||
|
||||
bool hasMore() const;
|
||||
|
||||
Q_INVOKABLE void next(int count = 50);
|
||||
|
||||
private:
|
||||
Connection* m_connection = nullptr;
|
||||
QString m_server;
|
||||
QString m_keyword;
|
||||
|
||||
bool attempted = false;
|
||||
QString nextBatch;
|
||||
|
||||
QVector<PublicRoomsChunk> rooms;
|
||||
|
||||
signals:
|
||||
QueryPublicRoomsJob* job = nullptr;
|
||||
|
||||
signals:
|
||||
void connectionChanged();
|
||||
void serverChanged();
|
||||
void keywordChanged();
|
||||
void hasMoreChanged();
|
||||
};
|
||||
|
||||
#endif // PUBLICROOMLISTMODEL_H
|
||||
#endif // PUBLICROOMLISTMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user