]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewcontainer.cpp
Save the view states in addition to the view urls and splitter state in DolphinTabPage.
[dolphin.git] / src / dolphinviewcontainer.cpp
index 1e9e79ae7a8d800e980baeb8afee3db3bae2c151..2a45152bd056fda049d929209c03d31b250c5e8f 100644 (file)
@@ -98,6 +98,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
 
     m_searchBox = new DolphinSearchBox(this);
     m_searchBox->hide();
+    connect(m_searchBox, SIGNAL(activated()), this, SLOT(activate()));
     connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox()));
     connect(m_searchBox, SIGNAL(searchRequest()), this, SLOT(startSearching()));
     connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
@@ -124,6 +125,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
     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_view, SIGNAL(activated()),                        this, SLOT(activate()));
 
     connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(KUrl)),
             this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(KUrl)));
@@ -195,6 +197,7 @@ KUrl DolphinViewContainer::url() const
 
 void DolphinViewContainer::setActive(bool active)
 {
+    m_searchBox->setActive(active);
     m_urlNavigator->setActive(active);
     m_view->setActive(active);
 
@@ -312,36 +315,18 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled)
     m_urlNavigator->setVisible(!enabled);
 
     if (enabled) {
-        KUrl url = m_urlNavigator->locationUrl();
-        m_searchBox->setText(QString());
-        m_searchBox->setReadOnly(isSearchUrl(url), url);
-
-        // Remember the most recent non-search URL as search path
-        // of the search-box, so that it can be restored
-        // when switching back to the URL navigator.
-        int index = m_urlNavigator->historyIndex();
-        const int historySize = m_urlNavigator->historySize();
-        while (isSearchUrl(url) && (index < historySize)) {
-            ++index;
-            url = m_urlNavigator->locationUrl(index);
-        }
-
-        if (!isSearchUrl(url)) {
-            m_searchBox->setSearchPath(url);
-        }
+        const KUrl& locationUrl = m_urlNavigator->locationUrl();
+        m_searchBox->fromSearchUrl(locationUrl);
     } else {
         m_view->setViewPropertiesContext(QString());
 
         // Restore the URL for the URL navigator. If Dolphin has been
         // started with a search-URL, the home URL is used as fallback.
-        const KUrl url = m_searchBox->searchPath();
-        if (url.isValid() && !url.isEmpty()) {
-            if (isSearchUrl(url)) {
-                m_urlNavigator->goHome();
-            } else {
-                m_urlNavigator->setLocationUrl(url);
-            }
+        KUrl url = m_searchBox->searchPath();
+        if (url.isEmpty() || !url.isValid() || isSearchUrl(url)) {
+            url = GeneralSettings::self()->homeUrl();
         }
+        m_urlNavigator->setLocationUrl(url);
     }
 }
 
@@ -453,7 +438,7 @@ void DolphinViewContainer::slotDirectoryLoadingCompleted()
     }
 
     if (isSearchUrl(url()) && m_view->itemsCount() == 0) {
-        // The dir lister has been completed on a Nepomuk-URI and no items have been found. Instead
+        // The dir lister has been completed on a Baloo-URI and no items have been found. Instead
         // of showing the default status bar information ("0 items") a more helpful information is given:
         m_statusBar->setText(i18nc("@info:status", "No items found."));
     } else {
@@ -506,8 +491,7 @@ void DolphinViewContainer::showItemInfo(const KFileItem& item)
     if (item.isNull()) {
         m_statusBar->resetToDefaultText();
     } else {
-        const QString text = item.isDir() ? item.text() : item.getStatusBarInfo();
-        m_statusBar->setText(text);
+        m_statusBar->setText(item.getStatusBarInfo());
     }
 }
 
@@ -707,7 +691,7 @@ void DolphinViewContainer::showErrorMessage(const QString& msg)
 bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
 {
     const QString protocol = url.protocol();
-    return protocol.contains("search") || (protocol == QLatin1String("nepomuk"));
+    return protocol.contains("search");
 }
 
 void DolphinViewContainer::saveViewState()