]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix regression: Open file if entering it in the URL-navigator
authorPeter Penz <peter.penz19@gmail.com>
Wed, 13 Jun 2012 13:15:54 +0000 (15:15 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 13 Jun 2012 13:18:21 +0000 (15:18 +0200)
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
src/dolphinviewcontainer.h
src/kitemviews/kfileitemmodel.cpp
src/kitemviews/kfileitemmodel.h
src/kitemviews/private/kfileitemmodeldirlister.cpp
src/kitemviews/private/kfileitemmodeldirlister.h
src/views/dolphinview.cpp
src/views/dolphinview.h

index 607cb33a7c9e85e44185499b581753f250f97f8f..31c82d60699c29a830e5a0b9d1b8bf24a3afa7ae 100644 (file)
@@ -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
index 59d73ec6c103e41a5d9af530cb1c1668b7a63dc0..fd52806d95e4d1009bffca89ccc294480ddd9098 100644 (file)
@@ -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
index eec90065a4e59447756db5461631897c197631df..f8302cfab4408ad4e9f8862e9c5bce2289d21bfb 100644 (file)
@@ -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();
index 64359df2cc93d4075a688b06e820fb90ce3cdcb3..d9bebdf02f1eec85ae55c7ea91735ece318a862d 100644 (file)
@@ -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);
index be0f9f77b8b8db8dca0540d8b91aa66942bce602..3d36386a953b23df9741f860c5de554ab223f679 100644 (file)
@@ -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);
+        }
     }
 }
 
index 1d58347f479647573c4c9a5a56bd054cbc4ea13b..688ee9c5ba3825075051b6603acc63b252fef047 100644 (file)
@@ -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);
 };
index e06aad6f26899f8116ee657923386336aa5e66d5..7cfb3fc41d258ef5af451c15eec26f8cb990b205 100644 (file)
@@ -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)),
index b2c4121a0f024ea8dab2a421312117fae41e64fb..1ad4d6c8229896389fb71a6199e997db1ae2f5af 100644 (file)
@@ -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