summaryrefslogtreecommitdiffstats
path: root/application/groupview/GroupView.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-12-19 00:34:03 +0100
committerPetr Mrázek <peterix@gmail.com>2016-12-19 00:35:57 +0100
commit92bb0017878c11cc09376fae12279d401db707e3 (patch)
tree81bccda75d912c386159ae551fa500488b968721 /application/groupview/GroupView.cpp
parent03d2858c62764230a52a242e7adf45f73f20878e (diff)
downloadMultiMC-92bb0017878c11cc09376fae12279d401db707e3.tar
MultiMC-92bb0017878c11cc09376fae12279d401db707e3.tar.gz
MultiMC-92bb0017878c11cc09376fae12279d401db707e3.tar.lz
MultiMC-92bb0017878c11cc09376fae12279d401db707e3.tar.xz
MultiMC-92bb0017878c11cc09376fae12279d401db707e3.zip
NOISSUE fix crash caused by missing instance view layout updates
Layout wasn't updated in some cases while deleting instances.
Diffstat (limited to 'application/groupview/GroupView.cpp')
-rw-r--r--application/groupview/GroupView.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/application/groupview/GroupView.cpp b/application/groupview/GroupView.cpp
index 5a380318..a6844102 100644
--- a/application/groupview/GroupView.cpp
+++ b/application/groupview/GroupView.cpp
@@ -45,6 +45,7 @@ void GroupView::setModel(QAbstractItemModel *model)
{
QAbstractItemView::setModel(model);
connect(model, &QAbstractItemModel::modelReset, this, &GroupView::modelReset);
+ connect(model, &QAbstractItemModel::rowsRemoved, this, &GroupView::rowsRemoved);
}
void GroupView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
@@ -62,6 +63,16 @@ void GroupView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int e
scheduleDelayedItemsLayout();
}
+void GroupView::modelReset()
+{
+ scheduleDelayedItemsLayout();
+}
+
+void GroupView::rowsRemoved()
+{
+ scheduleDelayedItemsLayout();
+}
+
class LocaleString : public QString
{
public:
@@ -87,35 +98,28 @@ void GroupView::updateGeometries()
for (int i = 0; i < model()->rowCount(); ++i)
{
- const QString groupName =
- model()->index(i, 0).data(GroupViewRoles::GroupRole).toString();
+ const QString groupName = model()->index(i, 0).data(GroupViewRoles::GroupRole).toString();
if (!cats.contains(groupName))
{
VisualGroup *old = this->category(groupName);
if (old)
{
- cats.insert(groupName, new VisualGroup(old));
+ auto cat = new VisualGroup(old);
+ cats.insert(groupName, cat);
+ cat->update();
}
else
{
- cats.insert(groupName, new VisualGroup(groupName, this));
+ auto cat = new VisualGroup(groupName, this);
+ cats.insert(groupName, cat);
+ cat->update();
}
}
}
- /*if (m_editedCategory)
- {
- m_editedCategory = cats[m_editedCategory->text];
- }*/
-
qDeleteAll(m_groups);
m_groups = cats.values();
- for (auto cat : m_groups)
- {
- cat->update();
- }
-
if (m_groups.isEmpty())
{
verticalScrollBar()->setRange(0, 0);
@@ -152,12 +156,6 @@ void GroupView::updateGeometries()
viewport()->update();
}
-void GroupView::modelReset()
-{
- scheduleDelayedItemsLayout();
- executeDelayedItemsLayout();
-}
-
bool GroupView::isIndexHidden(const QModelIndex &index) const
{
VisualGroup *cat = category(index);