You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nheko/include/CommunitiesList.h

47 lines
1.3 KiB

#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) { communities_.erase(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_;
};