diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/modlistbypriorityproxy.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/modlistbypriorityproxy.cpp b/src/modlistbypriorityproxy.cpp index 86664213..f898b85b 100644 --- a/src/modlistbypriorityproxy.cpp +++ b/src/modlistbypriorityproxy.cpp @@ -172,6 +172,7 @@ bool ModListByPriorityProxy::setData(const QModelIndex& index, const QVariant& v bool ModListByPriorityProxy::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) const { + std::vector<int> sourceRows; bool hasSeparator = false; bool firstRowSeparator = false; @@ -181,7 +182,8 @@ bool ModListByPriorityProxy::canDropMimeData(const QMimeData* data, Qt::DropActi int firstRowPriority = INT_MAX; unsigned int firstRowIndex = -1; - for (auto sourceRow : ModList::sourceRows(data)) { + sourceRows = ModList::sourceRows(data); + for (auto sourceRow : sourceRows) { hasSeparator = hasSeparator || ModInfo::getByIndex(sourceRow)->isSeparator(); if (m_Profile->getModPriority(sourceRow) < firstRowPriority) { firstRowIndex = sourceRow; @@ -197,9 +199,19 @@ bool ModListByPriorityProxy::canDropMimeData(const QMimeData* data, Qt::DropActi } // row = -1 and invalid parent means we're dropping onto an item, we don't want to drop - // separators onto items - if (hasSeparator && row == -1 && parent.isValid()) { - return !static_cast<TreeItem*>(parent.internalPointer())->mod->isSeparator(); + // separators onto items or items into their own separator + if (row == -1 && parent.isValid()) { + auto* parentItem = static_cast<TreeItem*>(parent.internalPointer()); + if (hasSeparator) { + return !parentItem->mod->isSeparator(); + } + + for (auto row : sourceRows) { + auto it = m_IndexToItem.find(row); + if (it != m_IndexToItem.end() && it->second->parent == parentItem) { + return false; + } + } } // first row is a separator, we can drop it anywhere |
