From e9463ffe2ac110193cac4c25fcba887249f52b3c Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 13 Jun 2012 15:15:54 +0200 Subject: [PATCH] Fix regression: Open file if entering it in the URL-navigator The regression has been introduced when hiding the DolphinDirLister inside KFileItemModel. Now the signal urlIsFileError() gets forwarded to the container again where the file will be opened. BUG: 301757 FIXED-IN: 4.9.0 --- src/dolphinviewcontainer.cpp | 7 +++++++ src/dolphinviewcontainer.h | 6 ++++++ src/kitemviews/kfileitemmodel.cpp | 1 + src/kitemviews/kfileitemmodel.h | 6 ++++++ src/kitemviews/private/kfileitemmodeldirlister.cpp | 12 ++++++++---- src/kitemviews/private/kfileitemmodeldirlister.h | 6 ++++++ src/views/dolphinview.cpp | 1 + src/views/dolphinview.h | 6 ++++++ 8 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 607cb33a7..31c82d606 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -110,6 +110,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotViewUrlAboutToBeChanged(KUrl))); connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString))); + connect(m_view, SIGNAL(urlIsFileError(KUrl)), this, SLOT(slotUrlIsFileError(KUrl))); connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(KUrl))); @@ -423,6 +424,12 @@ void DolphinViewContainer::slotDirectoryLoadingCompleted() } } +void DolphinViewContainer::slotUrlIsFileError(const KUrl& url) +{ + const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); + slotItemActivated(item); +} + void DolphinViewContainer::slotItemActivated(const KFileItem& item) { // It is possible to activate items on inactive views by diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 59d73ec6c..fd52806d9 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -188,6 +188,12 @@ private slots: */ void slotDirectoryLoadingCompleted(); + /** + * Is called if the URL set by DolphinView::setUrl() represents + * a file and not a directory. Takes care to activate the file. + */ + void slotUrlIsFileError(const KUrl& url); + /** * Handles clicking on an item. If the item is a directory, the * directory is opened in the view. If the item is a file, the file diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index eec90065a..f8302cfab 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -72,6 +72,7 @@ KFileItemModel::KFileItemModel(QObject* parent) : connect(m_dirLister, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString))); connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SIGNAL(directoryRedirection(KUrl,KUrl))); + connect(m_dirLister, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl))); // Apply default roles that should be determined resetRoles(); diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index 64359df2c..d9bebdf02 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -244,6 +244,12 @@ signals: */ void directoryRedirection(const KUrl& oldUrl, const KUrl& newUrl); + /** + * Is emitted when the URL passed by KFileItemModel::setUrl() represents a file. + * In this case no signal errorMessage() will be emitted. + */ + void urlIsFileError(const KUrl& url); + protected: virtual void onGroupedSortingChanged(bool current); virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous); diff --git a/src/kitemviews/private/kfileitemmodeldirlister.cpp b/src/kitemviews/private/kfileitemmodeldirlister.cpp index be0f9f77b..3d36386a9 100644 --- a/src/kitemviews/private/kfileitemmodeldirlister.cpp +++ b/src/kitemviews/private/kfileitemmodeldirlister.cpp @@ -33,11 +33,15 @@ KFileItemModelDirLister::~KFileItemModelDirLister() void KFileItemModelDirLister::handleError(KIO::Job* job) { - const QString errorString = job->errorString(); - if (errorString.isEmpty()) { - emit errorMessage(i18nc("@info:status", "Unknown error.")); + if (job->error() == KIO::ERR_IS_FILE) { + emit urlIsFileError(url()); } else { - emit errorMessage(errorString); + const QString errorString = job->errorString(); + if (errorString.isEmpty()) { + emit errorMessage(i18nc("@info:status", "Unknown error.")); + } else { + emit errorMessage(errorString); + } } } diff --git a/src/kitemviews/private/kfileitemmodeldirlister.h b/src/kitemviews/private/kfileitemmodeldirlister.h index 1d58347f4..688ee9c5b 100644 --- a/src/kitemviews/private/kfileitemmodeldirlister.h +++ b/src/kitemviews/private/kfileitemmodeldirlister.h @@ -40,6 +40,12 @@ signals: /** Is emitted whenever an error has occurred. */ void errorMessage(const QString& msg); + /** + * Is emitted when the URL of the directory lister represents a file. + * In this case no signal errorMessage() will be emitted. + */ + void urlIsFileError(const KUrl& url); + protected: virtual void handleError(KIO::Job* job); }; diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index e06aad6f2..7cfb3fc41 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -160,6 +160,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : connect(m_model, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString))); connect(m_model, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); connect(m_model, SIGNAL(directoryRedirection(KUrl,KUrl)), this, SLOT(slotDirectoryRedirection(KUrl,KUrl))); + connect(m_model, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl))); m_view->installEventFilter(this); connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index b2c4121a0..1ad4d6c82 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -493,6 +493,12 @@ signals: */ void redirection(const KUrl& oldUrl, const KUrl& newUrl); + /** + * Is emitted when the URL set by DolphinView::setUrl() represents a file. + * In this case no signal errorMessage() will be emitted. + */ + void urlIsFileError(const KUrl& url); + /** * Is emitted when the write state of the folder has been changed. The application * should disable all actions like "Create New..." that depend on the write -- 2.47.3