From a7fdf14196a1232f0e6baa0a58086f604954221b Mon Sep 17 00:00:00 2001
From: alex-z <blackslayer4@gmail.com>
Date: Mon, 11 Sep 2023 16:19:42 +0200
Subject: [PATCH] Display correct conflict part in multiple conflicts
 resolution dialog.

Signed-off-by: alex-z <blackslayer4@gmail.com>
---
 src/gui/ConflictDelegate.qml       | 20 ++++++++++----------
 src/gui/ResolveConflictsDialog.qml |  8 ++++----
 src/gui/syncconflictsmodel.cpp     |  4 ++--
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/gui/ConflictDelegate.qml b/src/gui/ConflictDelegate.qml
index ff6b48eb00e71..915173507233a 100644
--- a/src/gui/ConflictDelegate.qml
+++ b/src/gui/ConflictDelegate.qml
@@ -57,14 +57,14 @@ Item {
             Layout.fillWidth: true
             Layout.fillHeight: true
 
-            itemSelected: root.existingSelected
-            itemPreviewUrl: root.existingPreviewUrl
+            itemSelected: root.conflictSelected
+            itemPreviewUrl: root.conflictPreviewUrl
             itemVersionLabel: qsTr('Local version')
-            itemDateLabel: root.existingDate
-            itemFileSizeLabel: root.existingSize
+            itemDateLabel: root.conflictDate
+            itemFileSizeLabel: root.conflictSize
 
             onSelectedChanged: function() {
-                model.existingSelected = itemSelected
+                model.conflictSelected = itemSelected
             }
         }
 
@@ -72,14 +72,14 @@ Item {
             Layout.fillWidth: true
             Layout.fillHeight: true
 
-            itemSelected: root.conflictSelected
-            itemPreviewUrl: root.conflictPreviewUrl
+            itemSelected: root.existingSelected
+            itemPreviewUrl: root.existingPreviewUrl
             itemVersionLabel: qsTr('Server version')
-            itemDateLabel: root.conflictDate
-            itemFileSizeLabel: root.conflictSize
+            itemDateLabel: root.existingDate
+            itemFileSizeLabel: root.existingSize
 
             onSelectedChanged: function() {
-                model.conflictSelected = itemSelected
+                model.existingSelected = itemSelected
             }
         }
     }
diff --git a/src/gui/ResolveConflictsDialog.qml b/src/gui/ResolveConflictsDialog.qml
index 799a11034d663..823c4d0b25db8 100644
--- a/src/gui/ResolveConflictsDialog.qml
+++ b/src/gui/ResolveConflictsDialog.qml
@@ -101,9 +101,9 @@ ApplicationWindow {
 
                 font.pixelSize: Style.fontPixelSizeResolveConflictsDialog
 
-                checked: realModel.allExistingsSelected
+                checked: realModel.allConflictingSelected
                 onToggled: function() {
-                    realModel.selectAllExisting(checked)
+                    realModel.selectAllConflicting(checked)
                 }
             }
 
@@ -119,9 +119,9 @@ ApplicationWindow {
 
                 font.pixelSize: Style.fontPixelSizeResolveConflictsDialog
 
-                checked: realModel.allConflictingSelected
+                checked: realModel.allExistingsSelected
                 onToggled: function() {
-                    realModel.selectAllConflicting(checked)
+                    realModel.selectAllExisting(checked)
                 }
             }
         }
diff --git a/src/gui/syncconflictsmodel.cpp b/src/gui/syncconflictsmodel.cpp
index 3d455d8729269..2ddbf0225786d 100644
--- a/src/gui/syncconflictsmodel.cpp
+++ b/src/gui/syncconflictsmodel.cpp
@@ -327,9 +327,9 @@ ConflictSolver::Solution SyncConflictsModel::ConflictInfo::solution() const
     if (mConflictSelected == ConflictSolution::SolutionSelected && mExistingSelected == ConflictSolution::SolutionSelected) {
         result = ConflictSolver::KeepBothVersions;
     } else if (mConflictSelected == ConflictSolution::SolutionDeselected && mExistingSelected == ConflictSolution::SolutionSelected) {
-        result = ConflictSolver::KeepLocalVersion;
-    } else if (mConflictSelected == ConflictSolution::SolutionSelected && mExistingSelected == ConflictSolution::SolutionDeselected) {
         result = ConflictSolver::KeepRemoteVersion;
+    } else if (mConflictSelected == ConflictSolution::SolutionSelected && mExistingSelected == ConflictSolution::SolutionDeselected) {
+        result = ConflictSolver::KeepLocalVersion;
     }
 
     return result;