Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package dolphin for openSUSE:Factory checked 
in at 2024-12-19 21:40:20
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/dolphin (Old)
 and      /work/SRC/openSUSE:Factory/.dolphin.new.29675 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "dolphin"

Thu Dec 19 21:40:20 2024 rev:128 rq:1232641 version:24.12.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/dolphin/dolphin.changes  2024-12-13 
22:26:13.963781281 +0100
+++ /work/SRC/openSUSE:Factory/.dolphin.new.29675/dolphin.changes       
2024-12-19 21:40:38.036689782 +0100
@@ -1,0 +2,13 @@
+Thu Dec 19 16:25:45 UTC 2024 - Christophe Marin <christo...@krop.fr>
+
+- Add upstream fixes:
+  * 0001-DolphinViewContainer-make-sure-searchbox-is-initiali.patch 
(kde#497021)
+  * 0001-dolphinview-Update-thumbnail-on-filename-change.patch (kde#497555)
+  * 0001-ViewProperties-Return-nullptr-if-viewPropertiesStrin.patch 
(kde#495878)
+
+-------------------------------------------------------------------
+Wed Dec 18 15:01:54 UTC 2024 - hui <sturm...@web.de>
+
+- Fix Desktopfile to start in super user mode as dbus-launch is no longer part 
of the basesystem (boo#1234692)
+
+-------------------------------------------------------------------

New:
----
  0001-DolphinViewContainer-make-sure-searchbox-is-initiali.patch
  0001-ViewProperties-Return-nullptr-if-viewPropertiesStrin.patch
  0001-dolphinview-Update-thumbnail-on-filename-change.patch

BETA DEBUG BEGIN:
  New:- Add upstream fixes:
  * 0001-DolphinViewContainer-make-sure-searchbox-is-initiali.patch (kde#497021)
  * 0001-dolphinview-Update-thumbnail-on-filename-change.patch (kde#497555)
  New:  * 0001-dolphinview-Update-thumbnail-on-filename-change.patch 
(kde#497555)
  * 0001-ViewProperties-Return-nullptr-if-viewPropertiesStrin.patch (kde#495878)
  New:  * 0001-DolphinViewContainer-make-sure-searchbox-is-initiali.patch 
(kde#497021)
  * 0001-dolphinview-Update-thumbnail-on-filename-change.patch (kde#497555)
  * 0001-ViewProperties-Return-nullptr-if-viewPropertiesStrin.patch (kde#495878)
BETA DEBUG END:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ dolphin.spec ++++++
--- /var/tmp/diff_new_pack.j1Po98/_old  2024-12-19 21:40:39.068732558 +0100
+++ /var/tmp/diff_new_pack.j1Po98/_new  2024-12-19 21:40:39.068732558 +0100
@@ -36,6 +36,10 @@
 Patch0:         dolphin-go_up.diff
 # PATCH-FIX-OPENSUSE
 Patch1:         0001-Revert-Disallow-executing-Dolphin-as-root-on-Linux.patch
+# PATCH-FIX-UPSTREAM
+Patch2:         0001-DolphinViewContainer-make-sure-searchbox-is-initiali.patch
+Patch3:         0001-dolphinview-Update-thumbnail-on-filename-change.patch
+Patch4:         0001-ViewProperties-Return-nullptr-if-viewPropertiesStrin.patch
 BuildRequires:  kf6-extra-cmake-modules >= %{kf6_version}
 BuildRequires:  qt6-gui-private-devel >= %{qt6_version}
 BuildRequires:  systemd-rpm-macros

++++++ 0001-DolphinViewContainer-make-sure-searchbox-is-initiali.patch ++++++
>From edfd598446cfd6d4348a3bfecd72b5665eef5bfc Mon Sep 17 00:00:00 2001
From: Akseli Lahtinen <akse...@akselmo.dev>
Date: Mon, 16 Dec 2024 12:26:38 +0000
Subject: [PATCH] DolphinViewContainer: make sure searchbox is initialized
 before setSearchPath

If searchBox is not initialized, it can't be updated properly
with setSearchPath due to some buttons not existing.
There is also just no need to update it if it's not initialized.

Make sure we check for it's initialized during setting the search path.

BUG:497021


(cherry picked from commit 37b081331e19b8b10bc80b8aecc4ff43de2474c0)

fa289230 DolphinViewContainer: make sure searchbox is visible before 
setSearchPath
d0260e60 Check the initialization in setSearchPath

Co-authored-by: Akseli Lahtinen <akse...@akselmo.dev>
---
 src/search/dolphinsearchbox.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index 56e6543e7..ee425501d 100644
--- a/src/search/dolphinsearchbox.cpp
+++ b/src/search/dolphinsearchbox.cpp
@@ -74,7 +74,7 @@ QString DolphinSearchBox::text() const
 
 void DolphinSearchBox::setSearchPath(const QUrl &url)
 {
-    if (url == m_searchPath) {
+    if (url == m_searchPath || !m_initialized) {
         return;
     }
 
-- 
2.47.1


++++++ 0001-ViewProperties-Return-nullptr-if-viewPropertiesStrin.patch ++++++
>From 86609f89358243c08ebe4de8498a0fa6dff8370e Mon Sep 17 00:00:00 2001
From: Akseli Lahtinen <akse...@akselmo.dev>
Date: Mon, 16 Dec 2024 20:52:51 +0000
Subject: [PATCH] ViewProperties: Return nullptr if viewPropertiesString is
 empty

If viewPropertiesString is empty, return a nullptr.
This will later used in the stack by the defaultProperties call.

In defaultProperties, if we can't find the global directory,
create new one with a tempfile. If tempfiles can't be created,
use default instead.

This will ensure that view settings are saved and loaded correctly
if user has separate view properties per folder.

This will also add an unit test, where we create a global directory,
modify it and make sure the changes are reflected in the unmodified
folder.

BUG:495878


(cherry picked from commit 8d155558e980197b4dc2180660ea9bc61a23f3d3)

97d9a70c ViewProperties: Return nullptr if viewPropertiesString is empty
60a3da35 Create lambda for creating temporary files

Co-authored-by: Akseli Lahtinen <akse...@akselmo.dev>
---
 src/tests/viewpropertiestest.cpp | 75 +++++++++++++++++++++++++++++---
 src/views/viewproperties.cpp     | 59 ++++++++++++++++---------
 2 files changed, 108 insertions(+), 26 deletions(-)

diff --git a/src/tests/viewpropertiestest.cpp b/src/tests/viewpropertiestest.cpp
index 9c2c9466b..e4d434383 100644
--- a/src/tests/viewpropertiestest.cpp
+++ b/src/tests/viewpropertiestest.cpp
@@ -28,6 +28,7 @@ private Q_SLOTS:
     void testParamMigrationToFileAttr();
     void testParamMigrationToFileAttrKeepDirectory();
     void testExtendedAttributeFull();
+    void testUseAsDefaultViewSettings();
 
 private:
     bool m_globalViewProps;
@@ -37,6 +38,9 @@ private:
 void ViewPropertiesTest::initTestCase()
 {
     QStandardPaths::setTestModeEnabled(true);
+
+    
GeneralSettings::self()->setViewPropsTimestamp(QDateTime::currentDateTime());
+    QVERIFY(GeneralSettings::self()->save());
 }
 
 void ViewPropertiesTest::init()
@@ -82,28 +86,30 @@ void ViewPropertiesTest::testReadOnlyBehavior()
 
 void ViewPropertiesTest::testReadOnlyDirectory()
 {
-    auto localFolder = m_testDir->url().toLocalFile();
-    QString dotDirectoryFile = localFolder + "/.directory";
+    const QUrl testDirUrl = m_testDir->url();
+    const QString localFolder = testDirUrl.toLocalFile();
+    const QString dotDirectoryFile = localFolder + "/.directory";
     QVERIFY(!QFile::exists(dotDirectoryFile));
 
     // restrict write permissions
     QVERIFY(QFile(localFolder).setPermissions(QFileDevice::ReadOwner));
 
-    QScopedPointer<ViewProperties> props(new ViewProperties(m_testDir->url()));
+    QScopedPointer<ViewProperties> props(new ViewProperties(testDirUrl));
+    const QString destinationDir = 
props->destinationDir(QStringLiteral("local")) + localFolder;
+
     QVERIFY(props->isAutoSaveEnabled());
     props->setSortRole("someNewSortRole");
     props.reset();
 
-    const auto destinationDir = props->destinationDir(QStringLiteral("local")) 
+ localFolder;
     qDebug() << destinationDir;
     QVERIFY(QDir(destinationDir).exists());
 
     QVERIFY(!QFile::exists(dotDirectoryFile));
     KFileMetaData::UserMetaData metadata(localFolder);
-    auto viewProperties = 
metadata.attribute(QStringLiteral("kde.fm.viewproperties#1"));
+    const QString viewProperties = 
metadata.attribute(QStringLiteral("kde.fm.viewproperties#1"));
     QVERIFY(viewProperties.isEmpty());
 
-    props.reset(new ViewProperties(m_testDir->url()));
+    props.reset(new ViewProperties(testDirUrl));
     QVERIFY(props->isAutoSaveEnabled());
     QCOMPARE(props->sortRole(), "someNewSortRole");
     props.reset();
@@ -276,6 +282,63 @@ void ViewPropertiesTest::testExtendedAttributeFull()
     }
 }
 
+void ViewPropertiesTest::testUseAsDefaultViewSettings()
+{
+    // Create new test directory for this test to make sure the settings are 
defaults
+    auto testDir = new TestDir(QDir::homePath() + "/.viewPropertiesTest-");
+    auto cleanupTestDir = qScopeGuard([testDir] {
+        delete testDir;
+    });
+
+    // Create a global viewproperties folder
+    QUrl globalPropertiesPath =
+        
QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation).append("/view_properties/").append(QStringLiteral("global")));
+    QVERIFY(QDir().mkpath(globalPropertiesPath.toLocalFile()));
+    auto cleanupGlobalDir = qScopeGuard([globalPropertiesPath] {
+        QDir().rmdir(globalPropertiesPath.toLocalFile());
+    });
+    ViewProperties globalProps(globalPropertiesPath);
+
+    // Check that theres no .directory file and metadata is supported
+    QString dotDirectoryFile = testDir->url().toLocalFile() + "/.directory";
+    QVERIFY(!QFile::exists(dotDirectoryFile));
+    KFileMetaData::UserMetaData testDirMetadata(testDir->url().toLocalFile());
+    KFileMetaData::UserMetaData 
globalDirMetadata(globalPropertiesPath.toLocalFile());
+    if (!testDirMetadata.isSupported()) {
+        QSKIP("need extended attribute/filesystem metadata to be usefull");
+    }
+
+    const auto newDefaultViewMode = DolphinView::Mode::DetailsView;
+
+    // Equivalent of useAsDefault in ViewPropertiesDialog
+    // This sets the DetailsView as default viewMode
+    GeneralSettings::setGlobalViewProps(true);
+    globalProps.setViewMode(newDefaultViewMode);
+    globalProps.setDirProperties(globalProps);
+    globalProps.save();
+    GeneralSettings::setGlobalViewProps(false);
+
+    // Load default data
+    QScopedPointer<ViewProperties> globalDirProperties(new 
ViewProperties(globalPropertiesPath));
+    auto defaultData = globalDirProperties.data();
+
+    // Load testdir data
+    QScopedPointer<ViewProperties> testDirProperties(new 
ViewProperties(testDir->url()));
+    auto testData = testDirProperties.data();
+
+    // Make sure globalDirProperties are not empty, so they will be used
+    auto globalDirPropString = 
globalDirMetadata.attribute(QStringLiteral("kde.fm.viewproperties#1"));
+    QVERIFY(!globalDirPropString.isEmpty());
+
+    // Make sure testDirProperties is empty, so default values are used for it
+    auto testDirPropString = 
testDirMetadata.attribute(QStringLiteral("kde.fm.viewproperties#1"));
+    QVERIFY(testDirPropString.isEmpty());
+
+    // Compare that default and new folder viewMode is the new default
+    QCOMPARE(defaultData->viewMode(), newDefaultViewMode);
+    QCOMPARE(testData->viewMode(), defaultData->viewMode());
+}
+
 QTEST_GUILESS_MAIN(ViewPropertiesTest)
 
 #include "viewpropertiestest.moc"
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp
index 0536e028d..7e589019a 100644
--- a/src/views/viewproperties.cpp
+++ b/src/views/viewproperties.cpp
@@ -42,19 +42,26 @@ ViewPropertySettings *ViewProperties::loadProperties(const 
QString &folderPath)
         return new 
ViewPropertySettings(KSharedConfig::openConfig(settingsFile, 
KConfig::SimpleConfig));
     }
 
-    QTemporaryFile tempFile;
-    tempFile.setAutoRemove(false);
-    if (!tempFile.open()) {
-        qCWarning(DolphinDebug) << "Could not open temp file";
-        return nullptr;
-    }
+    auto createTempFile = []() -> QTemporaryFile * {
+        QTemporaryFile *tempFile = new QTemporaryFile;
+        tempFile->setAutoRemove(false);
+        if (!tempFile->open()) {
+            qCWarning(DolphinDebug) << "Could not open temp file";
+            return nullptr;
+        }
+        return tempFile;
+    };
 
     if (QFile::exists(settingsFile)) {
         // copy settings to tempfile to load them separately
-        QFile::remove(tempFile.fileName());
-        QFile::copy(settingsFile, tempFile.fileName());
+        const QTemporaryFile *tempFile = createTempFile();
+        if (!tempFile) {
+            return nullptr;
+        }
+        QFile::remove(tempFile->fileName());
+        QFile::copy(settingsFile, tempFile->fileName());
 
-        auto config = KConfig(tempFile.fileName(), KConfig::SimpleConfig);
+        auto config = KConfig(tempFile->fileName(), KConfig::SimpleConfig);
         // ignore settings that are outside of dolphin scope
         if (config.hasGroup("Dolphin") || config.hasGroup("Settings")) {
             const auto groupList = config.groupList();
@@ -63,25 +70,30 @@ ViewPropertySettings *ViewProperties::loadProperties(const 
QString &folderPath)
                     config.deleteGroup(group);
                 }
             }
-            return new 
ViewPropertySettings(KSharedConfig::openConfig(tempFile.fileName(), 
KConfig::SimpleConfig));
+            return new 
ViewPropertySettings(KSharedConfig::openConfig(tempFile->fileName(), 
KConfig::SimpleConfig));
 
         } else if (!config.groupList().isEmpty()) {
             // clear temp file content
-            QFile::remove(tempFile.fileName());
+            QFile::remove(tempFile->fileName());
         }
     }
 
     // load from metadata
     const QString viewPropertiesString = 
metadata.attribute(QStringLiteral("kde.fm.viewproperties#1"));
-    if (!viewPropertiesString.isEmpty()) {
-        // load view properties from xattr to temp file then loads into 
ViewPropertySettings
-        // clear the temp file
-        QFile outputFile(tempFile.fileName());
-        outputFile.open(QIODevice::WriteOnly);
-        outputFile.write(viewPropertiesString.toUtf8());
-        outputFile.close();
+    if (viewPropertiesString.isEmpty()) {
+        return nullptr;
+    }
+    // load view properties from xattr to temp file then loads into 
ViewPropertySettings
+    // clear the temp file
+    const QTemporaryFile *tempFile = createTempFile();
+    if (!tempFile) {
+        return nullptr;
     }
-    return new 
ViewPropertySettings(KSharedConfig::openConfig(tempFile.fileName(), 
KConfig::SimpleConfig));
+    QFile outputFile(tempFile->fileName());
+    outputFile.open(QIODevice::WriteOnly);
+    outputFile.write(viewPropertiesString.toUtf8());
+    outputFile.close();
+    return new 
ViewPropertySettings(KSharedConfig::openConfig(tempFile->fileName(), 
KConfig::SimpleConfig));
 }
 
 ViewPropertySettings *ViewProperties::defaultProperties() const
@@ -89,7 +101,14 @@ ViewPropertySettings *ViewProperties::defaultProperties() 
const
     auto props = loadProperties(destinationDir(QStringLiteral("global")));
     if (props == nullptr) {
         qCWarning(DolphinDebug) << "Could not load default global 
viewproperties";
-        props = new ViewPropertySettings;
+        QTemporaryFile tempFile;
+        tempFile.setAutoRemove(false);
+        if (!tempFile.open()) {
+            qCWarning(DolphinDebug) << "Could not open temp file";
+            props = new ViewPropertySettings;
+        } else {
+            props = new 
ViewPropertySettings(KSharedConfig::openConfig(tempFile.fileName(), 
KConfig::SimpleConfig));
+        }
     }
 
     return props;
-- 
2.47.1


++++++ 0001-dolphinview-Update-thumbnail-on-filename-change.patch ++++++
>From 0fe6544079a23769e8f19ee2f09b5c149f404d5a Mon Sep 17 00:00:00 2001
From: Akseli Lahtinen <akse...@akselmo.dev>
Date: Thu, 19 Dec 2024 10:04:16 +0000
Subject: [PATCH] dolphinview: Update thumbnail on filename change

If filename of an item was updated previously, it would modify the model
before the file was actually changed. This led to the model calling
a signal that would try to run a previewjob, but since the filename
is not actually changed yet on disk, it would fail.

This patch moves the model updating after copyjob. Copyjob
will take care of the file renaming if there is already existing file.
We just need to update the model correctly after the job has succeeded.

BUG:497555

(cherry picked from commit eca160ae5a2dbd5590e4bae22cddde488dbacf74)
---
 src/kitemviews/kfileitemlistview.h            |  1 +
 src/kitemviews/kfileitemmodelrolesupdater.cpp |  1 +
 src/kitemviews/kfileitemmodelrolesupdater.h   |  3 ++
 src/kitemviews/kitemlistview.h                |  2 +
 src/tests/dolphinmainwindowtest.cpp           | 49 +++++++++++++++++++
 src/views/dolphinview.cpp                     | 25 +++-------
 6 files changed, 64 insertions(+), 17 deletions(-)

diff --git a/src/kitemviews/kfileitemlistview.h 
b/src/kitemviews/kfileitemlistview.h
index 4c48c52ab..d6ffd3d0f 100644
--- a/src/kitemviews/kfileitemlistview.h
+++ b/src/kitemviews/kfileitemlistview.h
@@ -136,6 +136,7 @@ private:
     QTimer *m_updateIconSizeTimer;
 
     friend class KFileItemListViewTest; // For unit testing
+    friend class DolphinMainWindowTest; // For unit testing
 };
 
 #endif
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp 
b/src/kitemviews/kfileitemmodelrolesupdater.cpp
index ac14ed795..8811401b0 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -575,6 +575,7 @@ void KFileItemModelRolesUpdater::slotGotPreview(const 
KFileItem &item, const QPi
     disconnect(m_model, &KFileItemModel::itemsChanged, this, 
&KFileItemModelRolesUpdater::slotItemsChanged);
     m_model->setData(index, data);
     connect(m_model, &KFileItemModel::itemsChanged, this, 
&KFileItemModelRolesUpdater::slotItemsChanged);
+    Q_EMIT previewJobFinished(); // For unit testing
 
     m_finishedItems.insert(item);
 }
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h 
b/src/kitemviews/kfileitemmodelrolesupdater.h
index aa9ca5fc0..cba5b21a8 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.h
+++ b/src/kitemviews/kfileitemmodelrolesupdater.h
@@ -178,6 +178,9 @@ public:
      */
     void setHoverSequenceState(const QUrl &itemUrl, int seqIdx);
 
+Q_SIGNALS:
+    void previewJobFinished(); // For unit testing
+
 private Q_SLOTS:
     void slotItemsInserted(const KItemRangeList &itemRanges);
     void slotItemsRemoved(const KItemRangeList &itemRanges);
diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h
index 7be08302c..30ce4d871 100644
--- a/src/kitemviews/kitemlistview.h
+++ b/src/kitemviews/kitemlistview.h
@@ -794,6 +794,8 @@ private:
     friend class KItemListControllerTest;
     friend class KItemListViewAccessible;
     friend class KItemListDelegateAccessible;
+
+    friend class DolphinMainWindowTest;
 };
 
 /**
diff --git a/src/tests/dolphinmainwindowtest.cpp 
b/src/tests/dolphinmainwindowtest.cpp
index a57632a1d..8fd2a5ecb 100644
--- a/src/tests/dolphinmainwindowtest.cpp
+++ b/src/tests/dolphinmainwindowtest.cpp
@@ -10,10 +10,12 @@
 #include "dolphintabwidget.h"
 #include "dolphinviewcontainer.h"
 #include "kitemviews/kfileitemmodel.h"
+#include "kitemviews/kfileitemmodelrolesupdater.h"
 #include "kitemviews/kitemlistcontainer.h"
 #include "kitemviews/kitemlistcontroller.h"
 #include "kitemviews/kitemlistselectionmanager.h"
 #include "testdir.h"
+#include "views/dolphinitemlistview.h"
 
 #include <KActionCollection>
 #include <KConfig>
@@ -55,6 +57,7 @@ private Q_SLOTS:
     void testOpenFiles();
     void testAccessibilityAncestorTree();
     void testAutoSaveSession();
+    void testThumbnailAfterRename();
     void cleanupTestCase();
 
 private:
@@ -836,6 +839,52 @@ void DolphinMainWindowTest::testAutoSaveSession()
     m_mainWindow->setSessionAutoSaveEnabled(false);
 }
 
+void DolphinMainWindowTest::testThumbnailAfterRename()
+{
+    // Create testdir and red square jpg for testing
+    QScopedPointer<TestDir> testDir{new TestDir()};
+    QImage testImage(256, 256, QImage::Format_Mono);
+    testImage.setColorCount(1);
+    testImage.setColor(0, qRgba(255, 0, 0, 255)); // Index #0 = Red
+    for (short x = 0; x < 256; ++x) {
+        for (short y = 0; y < 256; ++y) {
+            testImage.setPixel(x, y, 0);
+        }
+    }
+    testImage.save(testDir.data()->path() + "/a.jpg");
+
+    // Open dir and show it
+    m_mainWindow->openDirectories({testDir->url()}, false);
+    DolphinView *view = m_mainWindow->activeViewContainer()->view();
+    // Prepare signal spies
+    QSignalSpy viewDirectoryLoadingCompletedSpy(view, 
&DolphinView::directoryLoadingCompleted);
+    QSignalSpy itemsChangedSpy(view->m_model, &KFileItemModel::itemsChanged);
+    QSignalSpy modelDirectoryLoadingCompletedSpy(view->m_model, 
&KFileItemModel::directoryLoadingCompleted);
+    QSignalSpy previewUpdatedSpy(view->m_view->m_modelRolesUpdater, 
&KFileItemModelRolesUpdater::previewJobFinished);
+    // Show window and check that our preview has been updated, then wait for 
it to appear
+    m_mainWindow->show();
+    QVERIFY(viewDirectoryLoadingCompletedSpy.wait());
+    QVERIFY(previewUpdatedSpy.wait());
+    QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data()));
+    QVERIFY(m_mainWindow->isVisible());
+    QTest::qWait(500); // we need to wait for the file widgets to become 
visible
+
+    // Set image selected and rename it to b.jpg, make sure editing role is 
working
+    view->markUrlsAsSelected({QUrl(testDir->url().toString() + "/a.jpg")});
+    view->updateViewState();
+    view->renameSelectedItems();
+    QVERIFY(view->m_view->m_editingRole);
+    QTest::keyClick(QApplication::focusWidget(), Qt::Key_B);
+    QTest::keyClick(QApplication::focusWidget(), Qt::Key_Enter);
+    QVERIFY(itemsChangedSpy.wait()); // Make sure that rename worked
+
+    // Check that preview gets updated and filename is correct
+    QVERIFY(previewUpdatedSpy.wait());
+    QVERIFY(!view->m_view->m_editingRole);
+    QCOMPARE(view->m_model->fileItem(0).name(), "b.jpg");
+    QCOMPARE(view->m_model->count(), 1);
+}
+
 void DolphinMainWindowTest::cleanupTestCase()
 {
     m_mainWindow->showNormal();
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 6da285a87..3c097d14a 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -1888,15 +1888,18 @@ void DolphinView::selectNextItem()
 
 void DolphinView::slotRenamingResult(KJob *job)
 {
-    if (job->error()) {
+    // Change model data after renaming has succeeded. On failure we do 
nothing.
+    // If there is already an item with the newUrl, the copyjob will open a 
dialog for it, and
+    // KFileItemModel will update the data when the dir lister signals that 
the file name has changed.
+    if (!job->error()) {
         KIO::CopyJob *copyJob = qobject_cast<KIO::CopyJob *>(job);
         Q_ASSERT(copyJob);
         const QUrl newUrl = copyJob->destUrl();
+        const QUrl oldUrl = copyJob->srcUrls().at(0);
         const int index = m_model->index(newUrl);
-        if (index >= 0) {
+        if (m_model->index(oldUrl) == index) {
             QHash<QByteArray, QVariant> data;
-            const QUrl oldUrl = copyJob->srcUrls().at(0);
-            data.insert("text", oldUrl.fileName());
+            data.insert("text", newUrl.fileName());
             m_model->setData(index, data);
         }
     }
@@ -2031,24 +2034,12 @@ void DolphinView::slotRoleEditingFinished(int index, 
const QByteArray &role, con
             }
 #endif
 
-            const bool newNameExistsAlready = (m_model->index(newUrl) >= 0);
-            if (!newNameExistsAlready && m_model->index(oldUrl) == index) {
-                // Only change the data in the model if no item with the new 
name
-                // is in the model yet. If there is an item with the new name
-                // already, calling KIO::CopyJob will open a dialog
-                // asking for a new name, and KFileItemModel will update the
-                // data when the dir lister signals that the file name has 
changed.
-                QHash<QByteArray, QVariant> data;
-                data.insert(role, retVal.newName);
-                m_model->setData(index, data);
-            }
-
             KIO::Job *job = KIO::moveAs(oldUrl, newUrl);
             KJobWidgets::setWindow(job, this);
             
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, 
newUrl, job);
             job->uiDelegate()->setAutoErrorHandlingEnabled(true);
 
-            if (!newNameExistsAlready) {
+            if (m_model->index(newUrl) < 0) {
                 forceUrlsSelection(newUrl, {newUrl});
                 updateSelectionState();
 
-- 
2.47.1




++++++ dolphinsu.desktop ++++++
--- /var/tmp/diff_new_pack.j1Po98/_old  2024-12-19 21:40:39.160736372 +0100
+++ /var/tmp/diff_new_pack.j1Po98/_new  2024-12-19 21:40:39.164736537 +0100
@@ -1,6 +1,6 @@
 [Desktop Entry]
 Name=File Manager - Super User Mode
-Exec=dbus-launch dolphin -qwindowtitle "%c" "%u"
+Exec=/usr/bin/xdg-su -c dolphin
 Icon=system-file-manager
 Type=Application
 X-DocPath=dolphin/index.html

Reply via email to