[multimedia/amarok] /: Fix shift multiselection in albums context applet

Tuomas Nurmi <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 991234ba0126fefecd74bc2b3d0f2f6d36dfa7dc by Tuomas Nurmi.
Committed on 29/07/2026 at 20:08.
Pushed by nurmi into branch 'master'.

Fix shift multiselection in albums context applet

I really don't understand how (if?) QML TreeView / ItemSelectionModel is
supposed to work. Selection model's currentIndex doesn't do anything that feels
even remotely sensible, so just save manually the previously clicked row number
and use that when shift-selecting. Works well enough.

M  +1    -0    ChangeLog
M  +4    -5    src/context/applets/albums/package/contents/ui/main.qml

https://invent.kde.org/multimedia/amarok/-/commit/991234ba0126fefecd74bc2b3d0f2f6d36dfa7dc

diff --git a/ChangeLog b/ChangeLog
index efc64ee270..264a1c8b3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@ VERSION 3.3.4 UNRELEASED
   CHANGES:
 
   BUGFIXES:
+   * Fix shift-selecting multiple tracks in albums context applet
 
 VERSION 3.3.3
   FEATURES:
diff --git a/src/context/applets/albums/package/contents/ui/main.qml b/src/context/applets/albums/package/contents/ui/main.qml
index 53c0e4919d..0d910fa6e8 100644
--- a/src/context/applets/albums/package/contents/ui/main.qml
+++ b/src/context/applets/albums/package/contents/ui/main.qml
@@ -36,6 +36,7 @@ AmarokQml.Applet {
             id: selectionModel
             model: AlbumsEngine.model
         }
+        property int previousSelectedRow
         TapHandler {
             acceptedButtons: Qt.LeftButton
             onSingleTapped: {
@@ -88,12 +89,9 @@ AmarokQml.Applet {
                             selectionModel.select(treeIndex, ItemSelectionModel.Toggle)
                         break;
                         case Qt.ShiftModifier:
-                            if(selectionModel.currentIndex.row >= 0 )
+                            for(let i=Math.min(row, treeView.previousSelectedRow); i<Math.max(row, treeView.previousSelectedRow) + 1; i++)
                             {
-                                for(let i=Math.min(row, selectionModel.currentIndex.row); i<Math.max(row, selectionModel.currentIndex.row); i++)
-                                {
-                                    selectionModel.select(treeView.index(i, column), ItemSelectionModel.Select)
-                                }
+                                selectionModel.select(treeView.index(i, column), ItemSelectionModel.Select)
                             }
                             selectionModel.setCurrentIndex(treeIndex, ItemSelectionModel.NoUpdate)
                         break;
@@ -103,6 +101,7 @@ AmarokQml.Applet {
                             selectionModel.setCurrentIndex(treeIndex, ItemSelectionModel.NoUpdate)
                         break;
                     }
+                    treeView.previousSelectedRow = row
                 }
             }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.