summaryrefslogtreecommitdiffstats
path: root/application/groupview/GroupView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'application/groupview/GroupView.cpp')
-rw-r--r--application/groupview/GroupView.cpp67
1 files changed, 37 insertions, 30 deletions
diff --git a/application/groupview/GroupView.cpp b/application/groupview/GroupView.cpp
index 6178db0b..0d6aa49e 100644
--- a/application/groupview/GroupView.cpp
+++ b/application/groupview/GroupView.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2013-2017 MultiMC Contributors
+/* Copyright 2013-2018 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -104,37 +104,9 @@ inline bool operator<(const LocaleString &lhs, const LocaleString &rhs)
return (QString::localeAwareCompare(lhs, rhs) < 0);
}
-void GroupView::updateGeometries()
+void GroupView::updateScrollbar()
{
- geometryCache.clear();
int previousScroll = verticalScrollBar()->value();
-
- QMap<LocaleString, VisualGroup *> cats;
-
- for (int i = 0; i < model()->rowCount(); ++i)
- {
- const QString groupName = model()->index(i, 0).data(GroupViewRoles::GroupRole).toString();
- if (!cats.contains(groupName))
- {
- VisualGroup *old = this->category(groupName);
- if (old)
- {
- auto cat = new VisualGroup(old);
- cats.insert(groupName, cat);
- cat->update();
- }
- else
- {
- auto cat = new VisualGroup(groupName, this);
- cats.insert(groupName, cat);
- cat->update();
- }
- }
- }
-
- qDeleteAll(m_groups);
- m_groups = cats.values();
-
if (m_groups.isEmpty())
{
verticalScrollBar()->setRange(0, 0);
@@ -167,7 +139,38 @@ void GroupView::updateGeometries()
}
verticalScrollBar()->setValue(qMin(previousScroll, verticalScrollBar()->maximum()));
+}
+
+void GroupView::updateGeometries()
+{
+ geometryCache.clear();
+
+ QMap<LocaleString, VisualGroup *> cats;
+ for (int i = 0; i < model()->rowCount(); ++i)
+ {
+ const QString groupName = model()->index(i, 0).data(GroupViewRoles::GroupRole).toString();
+ if (!cats.contains(groupName))
+ {
+ VisualGroup *old = this->category(groupName);
+ if (old)
+ {
+ auto cat = new VisualGroup(old);
+ cats.insert(groupName, cat);
+ cat->update();
+ }
+ else
+ {
+ auto cat = new VisualGroup(groupName, this);
+ cats.insert(groupName, cat);
+ cat->update();
+ }
+ }
+ }
+
+ qDeleteAll(m_groups);
+ m_groups = cats.values();
+ updateScrollbar();
viewport()->update();
}
@@ -511,6 +514,10 @@ void GroupView::resizeEvent(QResizeEvent *event)
m_currentItemsPerRow = newItemsPerRow;
updateGeometries();
}
+ else
+ {
+ updateScrollbar();
+ }
}
void GroupView::dragEnterEvent(QDragEnterEvent *event)