mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 18:09:59 +03:00
GH-2119 Update group view scrollbar when the size of rows doesn't change
Previously, it would only update when you resize the window horizontally enough to change the number of icons that fit in a row.
This commit is contained in:
parent
3277b820a7
commit
0bcb24502e
2 changed files with 38 additions and 29 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue