]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewcontainer.cpp
turn off the filter when closing the filterbar by CTRL+I
[dolphin.git] / src / dolphinviewcontainer.cpp
index 6e5385f5e4dd748bd9a890c79e0fa49b87ea4c8a..8b3def9f3a899b3ff126e9f5e8daa87b2a9329e4 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
@@ -211,6 +214,16 @@ bool DolphinViewContainer::isFilterBarVisible() const
     return m_filterBar->isVisible();
 }
 
+void DolphinViewContainer::showFilterBar(bool show)
+{
+    Q_ASSERT(m_filterBar != 0);
+    if (show) {
+        m_filterBar->show();
+    } else {
+        closeFilterBar();
+    }
+}
+
 bool DolphinViewContainer::isUrlEditable() const
 {
     return m_urlNavigator->isUrlEditable();
@@ -245,7 +258,7 @@ void DolphinViewContainer::slotDirListerCompleted()
     }
 
     updateStatusBar();
-    QTimer::singleShot(100, this, SLOT(restoreContentsPos()));
+    QMetaObject::invokeMethod(this, "restoreContentsPos", Qt::QueuedConnection);
 
     // Enable the 'File'->'Create New...' menu only if the directory
     // supports writing.
@@ -258,6 +271,10 @@ void DolphinViewContainer::slotDirListerCompleted()
         KonqFileItemCapabilities capabilities(KFileItemList() << item);
         createNew->setEnabled(capabilities.supportsWriting());
     }
+
+    if (isActive()) {
+        m_view->setFocus();
+    }
 }
 
 void DolphinViewContainer::showItemInfo(const KFileItem& item)
@@ -288,15 +305,10 @@ void DolphinViewContainer::closeFilterBar()
 {
     m_filterBar->hide();
     m_filterBar->clear();
+    m_view->setFocus();
     emit showFilterBarChanged(false);
 }
 
-void DolphinViewContainer::showFilterBar(bool show)
-{
-    Q_ASSERT(m_filterBar != 0);
-    m_filterBar->setVisible(show);
-}
-
 void DolphinViewContainer::updateStatusBar()
 {
     // As the item count information is less important
@@ -367,7 +379,7 @@ void DolphinViewContainer::restoreView(const KUrl& url)
             }
         } else {
             showErrorMessage(i18nc("@info:status",
-                                   "Protocol not supported by Dolphin, Konqueror has been launched"));        
+                                   "Protocol not supported by Dolphin, Konqueror has been launched"));
         }
         const QString command = app + ' ' + url.pathOrUrl();
         KRun::runCommand(command, app, app, this);
@@ -424,4 +436,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"