Don't waste space for non existing subspaces

This commit is contained in:
Nicolas Werner 2021-12-01 00:46:02 +01:00
parent fee2f5c701
commit aa5d2098d0
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 12 additions and 1 deletions

View file

@ -131,7 +131,7 @@ Page {
Item {
Layout.preferredWidth: fontMetrics.lineSpacing
visible: !communitySidebar.collapsed && !model.collapsible
visible: !communitySidebar.collapsed && !model.collapsible && Communities.containsSubspaces
}
Avatar {

View file

@ -280,6 +280,7 @@ CommunitiesModel::initializeSidebar()
emit tagsChanged();
emit hiddenTagsChanged();
emit containsSubspacesChanged();
}
void

View file

@ -33,6 +33,7 @@ class CommunitiesModel : public QAbstractListModel
currentTagIdChanged RESET resetCurrentTagId)
Q_PROPERTY(QStringList tags READ tags NOTIFY tagsChanged)
Q_PROPERTY(QStringList tagsWithDefault READ tagsWithDefault NOTIFY tagsChanged)
Q_PROPERTY(bool containsSubspaces READ containsSubspaces NOTIFY containsSubspacesChanged)
public:
enum Roles
@ -103,6 +104,14 @@ public:
QVariant data(const QModelIndex &index, int role) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
bool containsSubspaces() const
{
for (const auto &e : spaceOrder_.tree)
if (e.depth > 0)
return true;
return false;
}
public slots:
void initializeSidebar();
void sync(const mtx::responses::Sync &sync_);
@ -131,6 +140,7 @@ signals:
void currentTagIdChanged(QString tagId);
void hiddenTagsChanged();
void tagsChanged();
void containsSubspacesChanged();
private:
QStringList tags_;