Save collapsed categories

This commit is contained in:
Carl Schwan
2020-11-17 17:01:09 +01:00
parent f98834bb03
commit be1467f718
4 changed files with 19 additions and 3 deletions

View File

@@ -7,6 +7,7 @@
#include "user.h"
#include "utils.h"
#include "neochatconfig.h"
#include "events/roomevent.h"
@@ -20,6 +21,10 @@
RoomListModel::RoomListModel(QObject *parent)
: QAbstractListModel(parent)
{
const auto collaposedSections = NeoChatConfig::collapsedSections();
for (auto collapsedSection : collaposedSections) {
m_categoryVisibility[collapsedSection] = false;
}
}
RoomListModel::~RoomListModel()
@@ -311,6 +316,15 @@ QString RoomListModel::categoryName(int section) const
void RoomListModel::setCategoryVisible(int category, bool visible)
{
beginResetModel();
auto collaposedSections = NeoChatConfig::collapsedSections();
if (visible) {
collaposedSections.removeAll(category);
} else {
collaposedSections.push_back(category);
}
NeoChatConfig::setCollapsedSections(collaposedSections);
NeoChatConfig::self()->save();
m_categoryVisibility[category] = visible;
endResetModel();
}