]> cloud.milkyroute.net Git - dolphin.git/commitdiff
If the users enters an URL that represents a file, open the file by the corresponding...
authorPeter Penz <peter.penz19@gmail.com>
Fri, 12 Dec 2008 19:44:28 +0000 (19:44 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 12 Dec 2008 19:44:28 +0000 (19:44 +0000)
BUG: 165877

svn path=/trunk/KDE/kdebase/apps/; revision=896189

src/dolphindirlister.cpp
src/dolphindirlister.h
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h

index 8da962b18ad9c5f5e3859ea30ee3674982957983..63320b5280db8985d190622e99587b9113471554 100644 (file)
@@ -32,7 +32,11 @@ DolphinDirLister::~DolphinDirLister()
 
 void DolphinDirLister::handleError(KIO::Job* job)
 {
-    emit errorMessage(job->errorString());
+    if (job->error() == KIO::ERR_IS_FILE) {
+        emit urlIsFileError(url());
+    } else {
+        emit errorMessage(job->errorString());
+    }
 }
 
 #include "dolphindirlister.moc"
index 26eb760184e481cefc9e20560785c503d6bc9103..b615f63ba3d83ca2e96578642a053b110fac59bf 100644 (file)
@@ -41,6 +41,9 @@ 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. */
+    void urlIsFileError(const KUrl& url);
+
 protected:
     virtual void handleError(KIO::Job* job);
 };
index c75553c4bab4874f1e3074a5722d8b5dc413b93b..371eef654182d774d4e9b60f3e7c87c1ac1ebd90 100644 (file)
@@ -117,6 +117,8 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
             this, SLOT(showInfoMessage(const QString&)));
     connect(m_dirLister, SIGNAL(errorMessage(const QString&)),
             this, SLOT(showErrorMessage(const QString&)));
+    connect(m_dirLister, SIGNAL(urlIsFileError(const KUrl&)),
+            this, SLOT(openFile(const KUrl&)));
 
     m_view = new DolphinView(this,
                              url,
@@ -425,4 +427,13 @@ void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
     item.run();
 }
 
+void DolphinViewContainer::openFile(const KUrl& url)
+{
+    // Using m_dolphinModel for getting the file item instance is not possible
+    // here: openFile() is triggered by an error of the directory lister
+    // job, so the file item must be received "manually".
+    const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
+    slotItemTriggered(item);
+}
+
 #include "dolphinviewcontainer.moc"
index 15a0ae6a896b8153a30a95b7b0c418b68e0319aa..d2adb5ed7f33e45e7cce2b1ce6acaaa90256fb36 100644 (file)
@@ -142,10 +142,19 @@ private slots:
     void slotDirListerCompleted();
 
     /**
-     * Handles clicking on an item
+     * 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
+     * gets started by the corresponding application.
      */
     void slotItemTriggered(const KFileItem& item);
 
+    /**
+     * Opens a the file \a url by opening the corresponding application.
+     * Is connected with the signal urlIsFile() from DolphinDirLister and will
+     * get invoked if the user manually has entered a file into the URL navigator.
+     */
+    void openFile(const KUrl& url);
+
     /**
      * Shows the information for the item \a item inside the statusbar. If the
      * item is null, the default statusbar information is shown.