]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewcontainer.cpp
If the users enters an URL that represents a file, open the file by the corresponding...
[dolphin.git] / src / dolphinviewcontainer.cpp
index 2ef6209bcf16b5a01f2c7f6fb731936d9030c69f..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,
@@ -176,11 +178,12 @@ DolphinViewContainer::~DolphinViewContainer()
 void DolphinViewContainer::setUrl(const KUrl& newUrl)
 {
     m_urlNavigator->setUrl(newUrl);
-
-    // Temporary disable the 'File'->'Create New...' menu until
-    // the write permissions can be checked in a fast way at
-    // DolphinViewContainer::slotDirListerCompleted().
-    m_mainWindow->newMenu()->menu()->setEnabled(false);
+    if (newUrl != m_urlNavigator->url()) {
+        // Temporary disable the 'File'->'Create New...' menu until
+        // the write permissions can be checked in a fast way at
+        // DolphinViewContainer::slotDirListerCompleted().
+        m_mainWindow->newMenu()->menu()->setEnabled(false);
+    }
 }
 
 const KUrl& DolphinViewContainer::url() const
@@ -424,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"