From 3b574d7c3e3229365cec0acb0cbbf4c328fcf8b3 Mon Sep 17 00:00:00 2001 From: Goombert Date: Fri, 31 Jul 2020 18:40:52 -0400 Subject: [PATCH] use full path comparison for drag and drop --- Models/TreeModel.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Models/TreeModel.cpp b/Models/TreeModel.cpp index debbc198c..dd1fb11e4 100644 --- a/Models/TreeModel.cpp +++ b/Models/TreeModel.cpp @@ -174,7 +174,14 @@ QMimeData *TreeModel::mimeData(const QModelIndexList &indexes) const { // rows are moved starting with the lowest so we can create // unique names in the order of insertion - std::sort(nodes.begin(), nodes.end(), std::less()); + using pathComparator = std::function; + pathComparator compareIndexes = + [&compareIndexes](const QModelIndex & a, const QModelIndex & b) -> bool { + if (a.parent() == b.parent()) + return a < b; + return compareIndexes(a.parent(),b.parent()); + }; + std::sort(nodes.begin(), nodes.end(), compareIndexes); stream << QCoreApplication::applicationPid(); stream << nodes.count();