]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Stat URLs before opening them to make sure they are actually dirs we can list. Otherw...
authorSebastian Trueg <sebastian@trueg.de>
Mon, 15 Mar 2010 09:55:51 +0000 (09:55 +0000)
committerSebastian Trueg <sebastian@trueg.de>
Mon, 15 Mar 2010 09:55:51 +0000 (09:55 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1103520

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h

index d358ad7330b2d6becfef992ccc41c233e026c7cb..da4cab597fc475fc510aef0038d23a39703d233e 100644 (file)
@@ -121,7 +121,8 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_actionHandler(0),
     m_remoteEncoding(0),
     m_settingsDialog(0),
     m_actionHandler(0),
     m_remoteEncoding(0),
     m_settingsDialog(0),
-    m_captionStatJob(0)
+    m_captionStatJob(0),
+    m_lastHandleUrlStatJob(0)
 {
     setObjectName("Dolphin#");
 
 {
     setObjectName("Dolphin#");
 
@@ -1132,7 +1133,28 @@ void DolphinMainWindow::showSearchOptions()
 
 void DolphinMainWindow::handleUrl(const KUrl& url)
 {
 
 void DolphinMainWindow::handleUrl(const KUrl& url)
 {
-    if (KProtocolManager::supportsListing(url)) {
+    delete m_lastHandleUrlStatJob;
+    m_lastHandleUrlStatJob = 0;
+
+    if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) {
+        activeViewContainer()->setUrl(url);
+    } else if (KProtocolManager::supportsListing(url)) {
+        // stat the URL to see if it is a dir or not
+        m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
+        connect(m_lastHandleUrlStatJob, SIGNAL(result(KJob*)),
+                this, SLOT(slotHandleUrlStatFinished(KJob*)));
+
+    } else {
+        new KRun(url, this);
+    }
+}
+
+void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
+{
+    m_lastHandleUrlStatJob = 0;
+    const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
+    const KUrl url = static_cast<KIO::StatJob*>(job)->url();
+    if ( entry.isDir() ) {
         activeViewContainer()->setUrl(url);
     } else {
         new KRun(url, this);
         activeViewContainer()->setUrl(url);
     } else {
         new KRun(url, this);
index 6c2089fcf10b73aeb18863494f6b10dedb528f4e..7479c05b14f7836afbc8b6a9a1158ca6af82c3a3 100644 (file)
@@ -423,6 +423,12 @@ private slots:
      */
     void handleUrl(const KUrl& url);
 
      */
     void handleUrl(const KUrl& url);
 
+    /**
+     * handleUrl() can trigger a stat job to see if the url can actually
+     * be listed.
+     */
+    void slotHandleUrlStatFinished(KJob* job);
+
     /**
      * setUrlAsCaption() will trigger a stat job which reports its result in
      * this slot.
     /**
      * setUrlAsCaption() will trigger a stat job which reports its result in
      * this slot.
@@ -555,6 +561,7 @@ private:
     QPointer<DolphinSettingsDialog> m_settingsDialog;
 
     KJob* m_captionStatJob;
     QPointer<DolphinSettingsDialog> m_settingsDialog;
 
     KJob* m_captionStatJob;
+    KJob* m_lastHandleUrlStatJob;
 };
 
 inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const
 };
 
 inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const