matrixion/include/CommunitiesList.h
2018-01-24 20:46:37 +02:00

47 lines
1.3 KiB
C++

#pragma once
#include <QScrollArea>
#include <QSharedPointer>
#include <QVBoxLayout>
#include "CommunitiesListItem.h"
#include "Community.h"
#include "MatrixClient.h"
#include "ui/Theme.h"
class CommunitiesList : public QWidget
{
Q_OBJECT
public:
CommunitiesList(QSharedPointer<MatrixClient> client, QWidget *parent = nullptr);
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);
signals:
void communityChanged(const QString &id);
public slots:
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_;
std::map<QString, QSharedPointer<CommunitiesListItem>> communities_;
QSharedPointer<MatrixClient> client_;
};