mirror of
https://github.com/ModOrganizer2/modorganizer.git
synced 2026-07-27 13:58:24 -07:00
don't sort items when they're not expanded
This commit is contained in:
@@ -178,12 +178,14 @@ public:
|
||||
|
||||
void FileTreeItem::sort()
|
||||
{
|
||||
m_model->sortItem(*this);
|
||||
if (!m_children.empty()) {
|
||||
m_model->sortItem(*this, true);
|
||||
}
|
||||
}
|
||||
|
||||
void FileTreeItem::sort(int column, Qt::SortOrder order)
|
||||
void FileTreeItem::sort(int column, Qt::SortOrder order, bool force)
|
||||
{
|
||||
if (!m_expanded) {
|
||||
if (!force && !m_expanded) {
|
||||
m_sortingStale = true;
|
||||
return;
|
||||
}
|
||||
@@ -220,7 +222,7 @@ void FileTreeItem::sort(int column, Qt::SortOrder order)
|
||||
});
|
||||
|
||||
for (auto& child : m_children) {
|
||||
child->sort(column, order);
|
||||
child->sort(column, order, force);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ public:
|
||||
return -1;
|
||||
}
|
||||
|
||||
void sort(int column, Qt::SortOrder order);
|
||||
void sort(int column, Qt::SortOrder order, bool force);
|
||||
|
||||
FileTreeItem* parent()
|
||||
{
|
||||
|
||||
@@ -379,7 +379,7 @@ Qt::ItemFlags FileTreeModel::flags(const QModelIndex& index) const
|
||||
return f;
|
||||
}
|
||||
|
||||
void FileTreeModel::sortItem(FileTreeItem& item)
|
||||
void FileTreeModel::sortItem(FileTreeItem& item, bool force)
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
|
||||
@@ -394,7 +394,7 @@ void FileTreeModel::sortItem(FileTreeItem& item)
|
||||
oldItems.push_back({itemFromIndex(index), index.column()});
|
||||
}
|
||||
|
||||
item.sort(m_sort.column, m_sort.order);
|
||||
item.sort(m_sort.column, m_sort.order, force);
|
||||
|
||||
QModelIndexList newList;
|
||||
newList.reserve(itemCount);
|
||||
@@ -414,7 +414,7 @@ void FileTreeModel::sort(int column, Qt::SortOrder order)
|
||||
m_sort.column = column;
|
||||
m_sort.order = order;
|
||||
|
||||
sortItem(*m_root);
|
||||
sortItem(*m_root, false);
|
||||
}
|
||||
|
||||
FileTreeItem* FileTreeModel::itemFromIndex(const QModelIndex& index) const
|
||||
@@ -487,7 +487,7 @@ void FileTreeModel::update(
|
||||
}
|
||||
|
||||
if (added) {
|
||||
parentItem.sort(m_sort.column, m_sort.order);
|
||||
parentItem.sort(m_sort.column, m_sort.order, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public:
|
||||
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override;
|
||||
|
||||
FileTreeItem* itemFromIndex(const QModelIndex& index) const;
|
||||
void sortItem(FileTreeItem& item);
|
||||
void sortItem(FileTreeItem& item, bool force);
|
||||
|
||||
private:
|
||||
class Range;
|
||||
|
||||
Reference in New Issue
Block a user