]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix files not being highlighted if directory of file is already open
authorAlexander Saoutkin <a.saoutkin@gmail.com>
Sun, 1 Mar 2020 16:31:02 +0000 (16:31 +0000)
committerAlexander Saoutkin <a.saoutkin@gmail.com>
Sun, 1 Mar 2020 17:17:20 +0000 (17:17 +0000)
Summary:
In DolphinTabWidget::openFiles it assumes openDirectories will open new tabs, so it
only marks the URL selection for the newly opened tabs. This assumption is incorrect
 as Dolphin might reuse tabs when the folder is already open.

Even then, markUrlsAsSelected does nothing when the folder is already opened.
The selection seems to only be used when the folder finishes loading, calls made after
that only change a variable without updating the actual selection.

A call to DolphinView::updateViewState() is required to restore the intended behaviour, so long as DolphinView::clearSelection() has been called on the relevant tab, otherwise updateViewState() is a no-op.

BUG: 417230
FIXED-IN: 19.12.3

Test Plan:
1. In any application that has an "open containing folder" select that option
2. and then do the same for another file in the same folder

Reviewers: broulik

Reviewed By: broulik

Subscribers: kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D27389

src/dolphintabwidget.cpp
src/views/dolphinview.h

index 9ecc14427a7f944844a465c79d6a5a63b76f259e..39a734b17b5c82d867abb20e786cd9094b596dfa 100644 (file)
@@ -206,6 +206,10 @@ void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView)
             } else {
                 tabPage->secondaryViewContainer()->setActive(true);
             }
+            // BUG: 147230
+            // Required for updateViewState() call in openFiles() to work as expected
+            // If there is a selection, updateViewState() calls are effectively a no-op
+            tabPage->activeViewContainer()->view()->clearSelection();
             continue;
         }
         if (splitView && (it != dirs.constEnd())) {
@@ -239,10 +243,14 @@ void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView)
     // Select the files. Although the files can be split between several
     // tabs, there is no need to split 'files' accordingly, as
     // the DolphinView will just ignore invalid selections.
-    for (int i = oldTabCount; i < tabCount; ++i) {
+    for (int i = 0; i < tabCount; ++i) {
         DolphinTabPage* tabPage = tabPageAt(i);
         tabPage->markUrlsAsSelected(files);
         tabPage->markUrlAsCurrent(files.first());
+        if (i < oldTabCount) {
+            // Force selection of file if directory was already open, BUG: 417230
+            tabPage->activeViewContainer()->view()->updateViewState();
+        }
     }
 }
 
index 538e00e83ef5aebc47104b7d582d2b97ef23afb2..60ecb2a9520c1ad083424a618d3adbc1e9d348aa 100644 (file)
@@ -381,6 +381,12 @@ public slots:
 
     void stopLoading();
 
+    /**
+     * Applies the state that has been restored by restoreViewState()
+     * to the view.
+     */
+    void updateViewState();
+
     /** Activates the view if the item list container gets focus. */
     bool eventFilter(QObject* watched, QEvent* event) override;
 
@@ -702,12 +708,6 @@ private slots:
      */
     void slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
 
-    /**
-     * Applies the state that has been restored by restoreViewState()
-     * to the view.
-     */
-    void updateViewState();
-
     /**
      * Calculates the number of currently shown files into
      * \a fileCount and the number of folders into \a folderCount.