matrixion/src/CommunitiesList.h

51 lines
1.6 KiB
C
Raw Normal View History

2018-01-09 16:07:32 +03:00
#pragma once
#include <QScrollArea>
#include <QSharedPointer>
#include <QVBoxLayout>
#include "CommunitiesListItem.h"
#include "ui/Theme.h"
class CommunitiesList : public QWidget
{
Q_OBJECT
public:
CommunitiesList(QWidget *parent = nullptr);
2018-01-09 16:07:32 +03:00
void clear() { communities_.clear(); }
2018-07-14 12:08:16 +03:00
void addCommunity(const std::string &id);
2018-01-25 15:34:15 +03:00
void removeCommunity(const QString &id) { communities_.erase(id); };
std::map<QString, bool> roomList(const QString &id) const;
2018-01-09 16:07:32 +03:00
signals:
void communityChanged(const QString &id);
void avatarRetrieved(const QString &id, const QPixmap &img);
2018-07-14 12:08:16 +03:00
void groupProfileRetrieved(const QString &group_id, const mtx::responses::GroupProfile &);
void groupRoomsRetrieved(const QString &group_id, const std::map<QString, bool> &res);
2018-01-09 16:07:32 +03:00
public slots:
void updateCommunityAvatar(const QString &id, const QPixmap &img);
void highlightSelectedCommunity(const QString &id);
2018-07-14 12:08:16 +03:00
void setCommunities(const mtx::responses::JoinedGroups &groups);
2018-01-09 16:07:32 +03:00
private:
void fetchCommunityAvatar(const QString &id, const QString &avatarUrl);
2018-07-14 12:08:16 +03:00
void addGlobalItem() { addCommunity("world"); }
//! Check whether or not a community id is currently managed.
2018-07-14 12:08:16 +03:00
bool communityExists(const QString &id) const
{
return communities_.find(id) != communities_.end();
}
2018-01-09 16:07:32 +03:00
QVBoxLayout *topLayout_;
QVBoxLayout *contentsLayout_;
QWidget *scrollAreaContents_;
QScrollArea *scrollArea_;
std::map<QString, QSharedPointer<CommunitiesListItem>> communities_;
2018-01-09 16:07:32 +03:00
};