]> cloud.milkyroute.net Git - dolphin.git/commitdiff
further root URL handling cleanups
authorPeter Penz <peter.penz19@gmail.com>
Tue, 25 Sep 2007 09:02:29 +0000 (09:02 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 25 Sep 2007 09:02:29 +0000 (09:02 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=716789

src/dolphinview.cpp
src/dolphinview.h
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h

index 9541f5abbe3bfc08bec88ae215e606f42bedfefa..91a41b531b664e53c74878c774da1441bf60cdc6 100644 (file)
@@ -71,8 +71,7 @@ DolphinView::DolphinView(QWidget* parent,
     m_fileItemDelegate(0),
     m_dolphinModel(dolphinModel),
     m_dirLister(dirLister),
-    m_proxyModel(proxyModel),
-    m_rootUrl(url)
+    m_proxyModel(proxyModel)
 {
     setFocusPolicy(Qt::StrongFocus);
     m_topLayout = new QVBoxLayout(this);
@@ -122,11 +121,6 @@ const KUrl& DolphinView::url() const
     return m_controller->url();
 }
 
-void DolphinView::setRootUrl(const KUrl& url)
-{
-    m_rootUrl = url;
-}
-
 KUrl DolphinView::rootUrl() const
 {
     return isColumnViewActive() ? m_dirLister->url() : url();
@@ -414,24 +408,23 @@ void DolphinView::refresh()
     updateViewportColor();
 }
 
-void DolphinView::setUrl(const KUrl& url)
+void DolphinView::updateView(const KUrl& url, const KUrl& rootUrl)
 {
     if (m_controller->url() == url) {
         return;
     }
 
     const bool restoreColumnView = !isColumnViewActive()
-                                    && !m_rootUrl.isEmpty()
-                                    && m_rootUrl.isParentOf(url)
-                                    && (m_rootUrl != url);
+                                    && !rootUrl.isEmpty()
+                                    && !rootUrl.equals(url, KUrl::CompareWithoutTrailingSlash)
+                                    && rootUrl.isParentOf(url);
 
-    const KUrl oldRootUrl = rootUrl();
     m_controller->setUrl(url); // emits urlChanged, which we forward
 
     if (restoreColumnView) {
-        applyViewProperties(m_rootUrl);
+        applyViewProperties(rootUrl);
         Q_ASSERT(itemView() == m_columnView);
-        startDirLister(m_rootUrl);
+        startDirLister(rootUrl);
         m_columnView->showColumn(url);
     } else {
         applyViewProperties(url);
@@ -440,10 +433,12 @@ void DolphinView::setUrl(const KUrl& url)
 
     itemView()->setFocus();
 
-    const KUrl newRootUrl = rootUrl();
-    if (newRootUrl != oldRootUrl) {
-        emit rootUrlChanged(newRootUrl);
-    }
+    emit startedPathLoading(url);
+}
+
+void DolphinView::setUrl(const KUrl& url)
+{
+    updateView(url, KUrl());
 }
 
 void DolphinView::mouseReleaseEvent(QMouseEvent* event)
index 3f5b9f596798d445b7f20ac511a406e685d2610b..99a5233e9ebab43d25f9120d71cd0738ac9d72fe 100644 (file)
@@ -136,11 +136,6 @@ public:
      */
     const KUrl& url() const;
 
-    /**
-     * Sets the root URL of the view (see also DolphinView::rootUrl())
-     */
-    void setRootUrl(const KUrl& url);
-
     /**
      * Returns the root URL of the view, which is defined as the first
      * visible path of DolphinView::url(). Usually the root URL is
@@ -299,6 +294,16 @@ public:
      */
     void refresh();
 
+    /**
+     * Changes the directory of the view to \a url. If \a rootUrl is empty, the view
+     * properties from \a url are used for adjusting the view mode and the other properties.
+     * If \a rootUrl is not empty, the view properties from the root URL are considered
+     * instead. Specifying a root URL is only required if a view having a different root URL
+     * (e. g. the column view) should be restored. Usually using DolphinView::setUrl()
+     * is enough for changing the current URL.
+     */
+    void updateView(const KUrl& url, const KUrl& rootUrl);
+
 public slots:
     /**
      * Changes the directory to \a url. If the current directory is equal to
@@ -394,10 +399,12 @@ signals:
     void errorMessage(const QString& msg);
 
     /**
-     * Is emitted if the root URL of the view has been changed
-     * to \a url (see also DolphinView::rootUrl()).
+     * Is emitted after DolphinView::setUrl() has been invoked and
+     * the path \a url is currently loaded. If this signal is emitted,
+     * it is assured that the view contains already the correct root
+     * URL and property settings.
      */
-    void rootUrlChanged(const KUrl& url);
+    void startedPathLoading(const KUrl& url);
 
 protected:
     /** @see QWidget::mouseReleaseEvent */
index d54ec1e93949af92ec8b459ac7654ad21dc0447d..5194646f670804a4e3847391688bfc749353a03a 100644 (file)
@@ -136,8 +136,8 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
             this, SLOT(showInfoMessage(const QString&)));
     connect(m_view, SIGNAL(itemTriggered(KFileItem)),
             this, SLOT(slotItemTriggered(KFileItem)));
-    connect(m_view, SIGNAL(rootUrlChanged(const KUrl&)),
-            m_urlNavigator, SLOT(saveRootUrl(const KUrl&)));
+    connect(m_view, SIGNAL(startedPathLoading(const KUrl&)),
+            this, SLOT(saveRootUrl(const KUrl&)));
 
     connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
             this, SLOT(restoreView(const KUrl&)));
@@ -495,8 +495,13 @@ void DolphinViewContainer::activate()
 
 void DolphinViewContainer::restoreView(const KUrl& url)
 {
-    m_view->setRootUrl(m_urlNavigator->savedRootUrl());
-    m_view->setUrl(url);
+    m_view->updateView(url, m_urlNavigator->savedRootUrl());
+}
+
+void DolphinViewContainer::saveRootUrl(const KUrl& url)
+{
+    Q_UNUSED(url);
+    m_urlNavigator->saveRootUrl(m_view->rootUrl());
 }
 
 void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
@@ -506,7 +511,6 @@ void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
     KUrl url = item.mostLocalUrl(isLocal);
 
     if (item.isDir()) {
-        m_view->setRootUrl(KUrl());  // the root URL is unknown
         m_view->setUrl(url);
     } else if (item.isFile()) {
         // allow to browse through ZIP and tar files
index b7cb4ca5be30787359a034694a57751ce8b40382..3cfa907c7e64a1a74034f25386f181964cedc9dd 100644 (file)
@@ -207,6 +207,12 @@ private slots:
      */
     void restoreView(const KUrl& url);
 
+    /**
+     * Saves the root URL of the current URL \a url
+     * into the URL navigator.
+     */
+    void saveRootUrl(const KUrl& url);
+
 private:
     /**
      * Returns the default text of the status bar, if no item is