From 73dbd3c8dd78b41c8d93392eac74231e5b4a20d5 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 14 Jul 2018 12:08:16 +0300 Subject: Re-enable groups --- include/ChatPage.h | 6 ++---- include/CommunitiesList.h | 12 +++++++----- include/CommunitiesListItem.h | 26 ++++++++++++++------------ include/Community.h | 25 ------------------------- include/MatrixClient.h | 4 ++++ 5 files changed, 27 insertions(+), 46 deletions(-) delete mode 100644 include/Community.h (limited to 'include') diff --git a/include/ChatPage.h b/include/ChatPage.h index 39fb7565..6a70acf4 100644 --- a/include/ChatPage.h +++ b/include/ChatPage.h @@ -28,7 +28,6 @@ #include "Cache.h" #include "CommunitiesList.h" -#include "Community.h" #include "MatrixClient.h" #include "notifications/Manager.h" @@ -149,10 +148,11 @@ signals: const QString &message, const QImage &icon); + void updateGroupsInfo(const mtx::responses::JoinedGroups &groups); + private slots: void showUnreadMessageNotification(int count); void updateTopBarAvatar(const QString &roomid, const QPixmap &img); - void updateOwnCommunitiesInfo(const QList &own_communities); void changeTopRoomInfo(const QString &room_id); void logout(); void removeRoom(const QString &room_id); @@ -233,8 +233,6 @@ private: UserInfoWidget *user_info_widget_; - std::map> communities_; - // Keeps track of the users currently typing on each room. std::map> typingUsers_; QTimer *typingRefresher_; diff --git a/include/CommunitiesList.h b/include/CommunitiesList.h index 78b9602e..32a64bf2 100644 --- a/include/CommunitiesList.h +++ b/include/CommunitiesList.h @@ -5,7 +5,6 @@ #include #include "CommunitiesListItem.h" -#include "Community.h" #include "ui/Theme.h" class CommunitiesList : public QWidget @@ -15,26 +14,29 @@ class CommunitiesList : public QWidget public: CommunitiesList(QWidget *parent = nullptr); - void setCommunities(const std::map> &communities); void clear() { communities_.clear(); } - void addCommunity(QSharedPointer community, const QString &id); + void addCommunity(const std::string &id); void removeCommunity(const QString &id) { communities_.erase(id); }; + std::vector roomList(const QString &id) const; signals: void communityChanged(const QString &id); void avatarRetrieved(const QString &id, const QPixmap &img); + void groupProfileRetrieved(const QString &group_id, const mtx::responses::GroupProfile &); + void groupRoomsRetrieved(const QString &group_id, const std::vector &res); public slots: void updateCommunityAvatar(const QString &id, const QPixmap &img); void highlightSelectedCommunity(const QString &id); + void setCommunities(const mtx::responses::JoinedGroups &groups); private: void fetchCommunityAvatar(const QString &id, const QString &avatarUrl); - void addGlobalItem() { addCommunity(QSharedPointer(new Community), "world"); } + void addGlobalItem() { addCommunity("world"); } //! Check whether or not a community id is currently managed. - bool communityExists(const QString &id) + bool communityExists(const QString &id) const { return communities_.find(id) != communities_.end(); } diff --git a/include/CommunitiesListItem.h b/include/CommunitiesListItem.h index 6055d732..a9b6e333 100644 --- a/include/CommunitiesListItem.h +++ b/include/CommunitiesListItem.h @@ -6,7 +6,8 @@ #include #include -#include "Community.h" +#include + #include "Config.h" #include "ui/Theme.h" @@ -25,15 +26,15 @@ class CommunitiesListItem : public QWidget Q_PROPERTY(QColor avatarBgColor READ avatarBgColor WRITE setAvatarBgColor) public: - CommunitiesListItem(QSharedPointer community, - QString community_id, - QWidget *parent = nullptr); - - void setCommunity(QSharedPointer community) { community_ = community; }; + CommunitiesListItem(QString group_id, QWidget *parent = nullptr); + void setName(QString name) { name_ = name; } bool isPressed() const { return isPressed_; } void setAvatar(const QImage &img); + void setRooms(std::vector room_ids) { room_ids_ = std::move(room_ids); } + std::vector rooms() const { return room_ids_; } + QColor highlightedBackgroundColor() const { return highlightedBackgroundColor_; } QColor hoverBackgroundColor() const { return hoverBackgroundColor_; } QColor backgroundColor() const { return backgroundColor_; } @@ -54,7 +55,7 @@ public: } signals: - void clicked(const QString &community_id); + void clicked(const QString &group_id); public slots: void setPressedState(bool state); @@ -66,12 +67,13 @@ protected: private: const int IconSize = 36; - QSharedPointer community_; - QString communityId_; - QString communityName_; - QString communityShortDescription; + QString resolveName() const; + + std::vector room_ids_; - QPixmap communityAvatar_; + QString name_; + QString groupId_; + QPixmap avatar_; QColor highlightedBackgroundColor_; QColor hoverBackgroundColor_; diff --git a/include/Community.h b/include/Community.h deleted file mode 100644 index 6a398099..00000000 --- a/include/Community.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -struct Community -{ - void parseProfile(const QJsonObject &profile); - void parseRooms(const QJsonObject &rooms); - - QUrl getAvatar() const { return avatar_; } - QString getName() const { return name_; } - QString getShortDescription() const { return short_description_; } - QString getLongDescription() const { return long_description_; } - std::vector getRoomList() const { return rooms_; } - - QUrl avatar_; - QString name_; - QString short_description_; - QString long_description_; - - std::vector rooms_; -}; diff --git a/include/MatrixClient.h b/include/MatrixClient.h index 7ea5e0b7..cf1ee8ed 100644 --- a/include/MatrixClient.h +++ b/include/MatrixClient.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -10,8 +11,11 @@ Q_DECLARE_METATYPE(mtx::responses::Messages) Q_DECLARE_METATYPE(mtx::responses::Notifications) Q_DECLARE_METATYPE(mtx::responses::Rooms) Q_DECLARE_METATYPE(mtx::responses::Sync) +Q_DECLARE_METATYPE(mtx::responses::JoinedGroups) +Q_DECLARE_METATYPE(mtx::responses::GroupProfile) Q_DECLARE_METATYPE(std::string) Q_DECLARE_METATYPE(std::vector) +Q_DECLARE_METATYPE(std::vector) namespace http { namespace v2 { -- cgit 1.5.1