summaryrefslogtreecommitdiff
path: root/src/modlistbypriorityproxy.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-12-29 01:01:12 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-02 15:38:15 +0100
commit54ea4445b00301fe30eb346eb10f83e55e6d0ea0 (patch)
treeeae5825d1e7e8a739cd8d1c64969c1c2ac105976 /src/modlistbypriorityproxy.cpp
parent64f771bc1f974c60c508a65b7a0d0e412a27fb04 (diff)
Fix sorting of backups when using collapsible separators.
Diffstat (limited to 'src/modlistbypriorityproxy.cpp')
-rw-r--r--src/modlistbypriorityproxy.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/modlistbypriorityproxy.cpp b/src/modlistbypriorityproxy.cpp
index addefb6f..a5f8667f 100644
--- a/src/modlistbypriorityproxy.cpp
+++ b/src/modlistbypriorityproxy.cpp
@@ -43,6 +43,7 @@ void ModListByPriorityProxy::buildTree()
TreeItem* root = &m_Root;
std::unique_ptr<TreeItem> overwrite;
+ std::vector<std::unique_ptr<TreeItem>> backups;
for (auto& [priority, index] : m_Profile->getAllIndexesByPriority()) {
ModInfo::Ptr modInfo = ModInfo::getByIndex(index);
@@ -58,6 +59,10 @@ void ModListByPriorityProxy::buildTree()
overwrite = std::make_unique<TreeItem>(modInfo, index, &m_Root);
item = overwrite.get();
}
+ else if (modInfo->isBackup()) {
+ backups.push_back(std::make_unique<TreeItem>(modInfo, index, &m_Root));
+ item = backups.back().get();
+ }
else {
root->children.push_back(std::make_unique<TreeItem>(modInfo, index, root));
item = root->children.back().get();
@@ -66,6 +71,8 @@ void ModListByPriorityProxy::buildTree()
m_IndexToItem[index] = item;
}
+ m_Root.children.insert(m_Root.children.begin(),
+ std::make_move_iterator(backups.begin()), std::make_move_iterator(backups.end()));
m_Root.children.push_back(std::move(overwrite));
endResetModel();
@@ -101,6 +108,7 @@ QModelIndex ModListByPriorityProxy::mapToSource(const QModelIndex& proxyIndex) c
return QModelIndex();
}
auto* item = static_cast<TreeItem*>(proxyIndex.internalPointer());
+
return sourceModel()->index(item->index, proxyIndex.column());
}
@@ -124,7 +132,6 @@ int ModListByPriorityProxy::columnCount(const QModelIndex& index) const
return sourceModel()->columnCount(mapToSource(index));
}
-
QModelIndex ModListByPriorityProxy::parent(const QModelIndex& child) const
{
if (!child.isValid()) {
@@ -137,7 +144,7 @@ QModelIndex ModListByPriorityProxy::parent(const QModelIndex& child) const
return QModelIndex();
}
- return createIndex(item->parent->parent->childIndex(item->parent), 0, item->parent);
+ return createIndex(item->parent->parent->childIndex(item->parent), child.column(), item->parent);
}
bool ModListByPriorityProxy::hasChildren(const QModelIndex& parent) const
@@ -270,6 +277,7 @@ QModelIndex ModListByPriorityProxy::index(int row, int column, const QModelIndex
else {
parentItem = static_cast<TreeItem*>(parent.internalPointer());
}
+
return createIndex(row, column, parentItem->children[row].get());
}