diff options
Diffstat (limited to 'src/modlistbypriorityproxy.cpp')
| -rw-r--r-- | src/modlistbypriorityproxy.cpp | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/modlistbypriorityproxy.cpp b/src/modlistbypriorityproxy.cpp index dc51617e..eb931aa9 100644 --- a/src/modlistbypriorityproxy.cpp +++ b/src/modlistbypriorityproxy.cpp @@ -160,35 +160,30 @@ 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 { - bool firstRowSeparator = false; - try { - QByteArray encoded = data->data("application/x-qabstractitemmodeldatalist"); - QDataStream stream(&encoded, QIODevice::ReadOnly); + if (data->hasText()) { + bool firstRowSeparator = false; - int firstRowPriority = INT_MAX; - unsigned int firstRowIndex = -1; + try { + int firstRowPriority = INT_MAX; + unsigned int firstRowIndex = -1; - while (!stream.atEnd()) { - int sourceRow, col; - QMap<int, QVariant> roleDataMap; - stream >> sourceRow >> col >> roleDataMap; - if (col == 0) { + for (auto sourceRow : ModList::sourceRows(data)) { if (m_Profile->getModPriority(sourceRow) < firstRowPriority) { firstRowIndex = sourceRow; firstRowPriority = m_Profile->getModPriority(sourceRow); } } - } - firstRowSeparator = firstRowIndex != -1 && ModInfo::getByIndex(firstRowIndex)->isSeparator(); - } - catch (std::exception const&) { + firstRowSeparator = firstRowIndex != -1 && ModInfo::getByIndex(firstRowIndex)->isSeparator(); + } + catch (std::exception const&) { - } + } - // first row is a separator, we can drop it anywhere - if (firstRowSeparator) { - return QAbstractProxyModel::canDropMimeData(data, action, row, column, parent); + // first row is a separator, we can drop it anywhere + if (firstRowSeparator) { + return QAbstractProxyModel::canDropMimeData(data, action, row, column, parent); + } } if (!parent.isValid() && row >= 0) { |
