Our previous iteration is hitting some limitations as the power of profiles on Matrix grows. For example, where do we put common rooms or extra profile fields? I re-arranged everything to group similar actions together - instead of throwing it all into one big list. We basically trade vertical for horizontal space, and gives us more headroom for extra fields when we want to add more.
58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
// SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com>
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <QAbstractListModel>
|
|
#include <QQmlEngine>
|
|
|
|
#include "neochatconnection.h"
|
|
|
|
#include <Quotient/events/roommessageevent.h>
|
|
#include <Quotient/roommember.h>
|
|
|
|
/**
|
|
* @brief Model to show the common or mutual rooms between you and another user.
|
|
*/
|
|
class CommonRoomsModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
QML_ELEMENT
|
|
Q_PROPERTY(NeoChatConnection *connection WRITE setConnection READ connection NOTIFY connectionChanged REQUIRED)
|
|
Q_PROPERTY(QString userId WRITE setUserId READ userId NOTIFY userIdChanged REQUIRED)
|
|
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
|
|
|
public:
|
|
enum Roles {
|
|
RoomIdRole = Qt::UserRole,
|
|
RoomNameRole,
|
|
RoomAvatarRole,
|
|
};
|
|
Q_ENUM(Roles)
|
|
|
|
explicit CommonRoomsModel(QObject *parent = nullptr);
|
|
|
|
[[nodiscard]] NeoChatConnection *connection() const;
|
|
void setConnection(NeoChatConnection *connection);
|
|
|
|
[[nodiscard]] QString userId() const;
|
|
void setUserId(const QString &userId);
|
|
|
|
[[nodiscard]] QVariant data(const QModelIndex &index, int roleName) const override;
|
|
[[nodiscard]] Q_INVOKABLE int rowCount(const QModelIndex &parent = {}) const override;
|
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
Q_SIGNALS:
|
|
void connectionChanged();
|
|
void userIdChanged();
|
|
void countChanged();
|
|
|
|
private:
|
|
void reload();
|
|
|
|
QPointer<NeoChatConnection> m_connection;
|
|
QString m_userId;
|
|
QList<QString> m_commonRooms;
|
|
};
|