summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modlistbypriorityproxy.cpp55
-rw-r--r--src/modlistsortproxy.cpp11
-rw-r--r--src/modlistsortproxy.h4
3 files changed, 48 insertions, 22 deletions
diff --git a/src/modlistbypriorityproxy.cpp b/src/modlistbypriorityproxy.cpp
index eca7108c..4fd589a4 100644
--- a/src/modlistbypriorityproxy.cpp
+++ b/src/modlistbypriorityproxy.cpp
@@ -257,25 +257,29 @@ bool ModListByPriorityProxy::dropMimeData(const QMimeData* data, Qt::DropAction
else {
if (row >= 0) {
- MOBase::log::debug("row={}, name={}, expand={}, drop={}", row, m_Root.children[row]->mod->name(), m_dropExpanded, m_dropPosition);
if (!parent.isValid()) {
if (row < m_Root.children.size()) {
- sourceRow = m_Root.children[row]->index;
- if (row > 0
- && m_sortOrder == Qt::AscendingOrder
- && m_Root.children[row - 1]->mod->isSeparator()
- && !m_Root.children[row - 1]->children.empty()
- && m_dropExpanded
- && m_dropPosition == ModListView::DropPosition::BelowItem) {
+ if (m_sortOrder == Qt::AscendingOrder) {
+ sourceRow = m_Root.children[row]->index;
+ if (row > 0
+ && m_sortOrder == Qt::AscendingOrder
+ && m_Root.children[row - 1]->mod->isSeparator()
+ && !m_Root.children[row - 1]->children.empty()
+ && m_dropExpanded
+ && m_dropPosition == ModListView::DropPosition::BelowItem) {
sourceRow = m_Root.children[row - 1]->children[0]->index;
+ }
}
- else if (row > 0
- && m_sortOrder == Qt::DescendingOrder
- && m_Root.children[row]->mod->isSeparator()
- && !m_Root.children[row]->children.empty()
- && (!m_dropExpanded
- || m_dropPosition == ModListView::DropPosition::AboveItem)) {
- sourceRow = m_Root.children[row]->children.back()->index;
+ else {
+ sourceRow = m_Root.children[row - 1]->index;
+ if (row > 0
+ && m_sortOrder == Qt::DescendingOrder
+ && m_Root.children[row - 1]->mod->isSeparator()
+ && !m_Root.children[row - 1]->children.empty()
+ && (!m_dropExpanded
+ || m_dropPosition == ModListView::DropPosition::AboveItem)) {
+ sourceRow = m_Root.children[row - 1]->children.back()->index;
+ }
}
}
else {
@@ -285,12 +289,25 @@ bool ModListByPriorityProxy::dropMimeData(const QMimeData* data, Qt::DropAction
else {
auto* item = static_cast<TreeItem*>(parent.internalPointer());
- if (row < item->children.size()) {
- sourceRow = item->children[row]->index;
+ if (m_sortOrder == Qt::DescendingOrder
+ && row == 0 && m_dropPosition == ModListView::DropPosition::AboveItem) {
+ sourceRow = item->index;
}
- else if (parent.row() + 1 < m_Root.children.size()) {
- sourceRow = m_Root.children[parent.row() + 1]->index;
+ else {
+
+ if (m_sortOrder == Qt::DescendingOrder) {
+ row--;
+ }
+
+ if (row < item->children.size()) {
+ sourceRow = item->children[row]->index;
+ }
+ else if (parent.row() + 1 < m_Root.children.size()) {
+ sourceRow = m_Root.children[parent.row() + 1]->index;
+ }
}
+
+
}
}
else if (parent.isValid()) {
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index bc28490f..1077a833 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -18,6 +18,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/
#include "modlistsortproxy.h"
+#include "modlistbypriorityproxy.h"
#include "modlistdropinfo.h"
#include "modinfo.h"
#include "profile.h"
@@ -279,7 +280,6 @@ bool ModListSortProxy::filterMatchesModOr(ModInfo::Ptr info, bool enabled) const
bool ModListSortProxy::optionsMatchMod(ModInfo::Ptr info, bool) const
{
-
return true;
}
@@ -598,6 +598,11 @@ bool ModListSortProxy::filterAcceptsRow(int source_row, const QModelIndex &paren
}
}
+bool ModListSortProxy::sourceIsByPriorityProxy() const
+{
+ return dynamic_cast<ModListByPriorityProxy*>(sourceModel()) != nullptr;
+}
+
bool ModListSortProxy::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) const
{
ModListDropInfo dropInfo(data, *m_Organizer);
@@ -620,7 +625,7 @@ bool ModListSortProxy::canDropMimeData(const QMimeData* data, Qt::DropAction act
// in the regular model, when dropping between rows, the row-value passed to
// the sourceModel is inconsistent between ascending and descending ordering.
// This should fix that
- if (sortOrder() == Qt::DescendingOrder && row != -1) {
+ if (sortOrder() == Qt::DescendingOrder && row != -1 && !sourceIsByPriorityProxy()) {
--row;
}
@@ -645,7 +650,7 @@ bool ModListSortProxy::dropMimeData(const QMimeData *data, Qt::DropAction action
// in the regular model, when dropping between rows, the row-value passed to
// the sourceModel is inconsistent between ascending and descending ordering.
// This should fix that
- if (sortOrder() == Qt::DescendingOrder && row != -1) {
+ if (sortOrder() == Qt::DescendingOrder && row != -1 && !sourceIsByPriorityProxy()) {
--row;
}
diff --git a/src/modlistsortproxy.h b/src/modlistsortproxy.h
index 421c82cc..23be77ed 100644
--- a/src/modlistsortproxy.h
+++ b/src/modlistsortproxy.h
@@ -140,6 +140,10 @@ private:
bool filterMatchesModAnd(ModInfo::Ptr info, bool enabled) const;
bool filterMatchesModOr(ModInfo::Ptr info, bool enabled) const;
+ // check if the source model is the by-priority proxy
+ //
+ bool sourceIsByPriorityProxy() const;
+
private slots:
void aboutToChangeData();