2018-01-09 16:07:32 +03:00
|
|
|
#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);
|
|
|
|
|
2018-01-24 21:46:37 +03:00
|
|
|
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);
|
2018-01-09 16:07:32 +03:00
|
|
|
|
|
|
|
signals:
|
2018-01-24 21:46:37 +03:00
|
|
|
void communityChanged(const QString &id);
|
2018-01-09 16:07:32 +03:00
|
|
|
|
|
|
|
public slots:
|
2018-01-24 21:46:37 +03:00
|
|
|
void updateCommunityAvatar(const QString &id, const QPixmap &img);
|
|
|
|
void highlightSelectedCommunity(const QString &id);
|
2018-01-09 16:07:32 +03:00
|
|
|
|
|
|
|
private:
|
2018-01-24 21:46:37 +03:00
|
|
|
//! Check whether or not a community id is currently managed.
|
|
|
|
bool communityExists(const QString &id)
|
|
|
|
{
|
|
|
|
return communities_.find(id) != communities_.end();
|
|
|
|
}
|
|
|
|
|
2018-01-09 16:07:32 +03:00
|
|
|
QVBoxLayout *topLayout_;
|
|
|
|
QVBoxLayout *contentsLayout_;
|
|
|
|
QWidget *scrollAreaContents_;
|
|
|
|
QScrollArea *scrollArea_;
|
|
|
|
|
2018-01-24 21:46:37 +03:00
|
|
|
std::map<QString, QSharedPointer<CommunitiesListItem>> communities_;
|
2018-01-09 16:07:32 +03:00
|
|
|
|
|
|
|
QSharedPointer<MatrixClient> client_;
|
|
|
|
};
|