summary refs log tree commit diff
path: root/include/CommunitiesList.h
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-01-24 20:46:37 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-01-24 20:46:37 +0200
commit1fad9398fce58a8d7bf96bdaa2629a80b336b14c (patch)
tree28483acf18d91d6ccfa40eaa0564e50dd9291c51 /include/CommunitiesList.h
parentRemove trailing whitespace from text messages (diff)
downloadnheko-1fad9398fce58a8d7bf96bdaa2629a80b336b14c.tar.xz
Use more stl containers & minor refactorings
Diffstat (limited to 'include/CommunitiesList.h')
-rw-r--r--include/CommunitiesList.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/include/CommunitiesList.h b/include/CommunitiesList.h

index 53715363..8bb6aaad 100644 --- a/include/CommunitiesList.h +++ b/include/CommunitiesList.h
@@ -3,7 +3,6 @@ #include <QScrollArea> #include <QSharedPointer> #include <QVBoxLayout> -#include <QWidget> #include "CommunitiesListItem.h" #include "Community.h" @@ -16,27 +15,33 @@ class CommunitiesList : public QWidget public: CommunitiesList(QSharedPointer<MatrixClient> client, QWidget *parent = nullptr); - ~CommunitiesList(); - void setCommunities(const QMap<QString, QSharedPointer<Community>> &communities); - void clear(); + void setCommunities(const std::map<QString, QSharedPointer<Community>> &communities); + void clear() { communities_.clear(); } + + void addCommunity(QSharedPointer<Community> community, const QString &id); + void removeCommunity(const QString &id); - void addCommunity(QSharedPointer<Community> community, const QString &community_id); - void removeCommunity(const QString &community_id); signals: - void communityChanged(const QString &community_id); + void communityChanged(const QString &id); public slots: - void updateCommunityAvatar(const QString &community_id, const QPixmap &img); - void highlightSelectedCommunity(const QString &community_id); + void updateCommunityAvatar(const QString &id, const QPixmap &img); + void highlightSelectedCommunity(const QString &id); private: + //! Check whether or not a community id is currently managed. + bool communityExists(const QString &id) + { + return communities_.find(id) != communities_.end(); + } + QVBoxLayout *topLayout_; QVBoxLayout *contentsLayout_; QWidget *scrollAreaContents_; QScrollArea *scrollArea_; - QMap<QString, QSharedPointer<CommunitiesListItem>> communities_; + std::map<QString, QSharedPointer<CommunitiesListItem>> communities_; QSharedPointer<MatrixClient> client_; };