]> cloud.milkyroute.net Git - dolphin.git/commitdiff
column view fixes:
authorPeter Penz <peter.penz19@gmail.com>
Tue, 9 Oct 2007 21:10:17 +0000 (21:10 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 9 Oct 2007 21:10:17 +0000 (21:10 +0000)
* assure that the history does not get messed up when changing the focus to an existing column
* fix issue that the status bar does not get updated when the focus is changed between the columns

svn path=/trunk/KDE/kdebase/apps/; revision=723519

src/dolphincolumnview.cpp
src/dolphincolumnwidget.cpp
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphinview.cpp

index fac35a0be1c224530a69857ae906a9c3f1a01a6f..e8b75c532f0122b5a7efbfbfc0ab800a5163334b 100644 (file)
@@ -263,12 +263,14 @@ QModelIndex DolphinColumnView::moveCursor(CursorAction cursorAction, Qt::Keyboar
     case MoveLeft:
         if (m_index > 0) {
             setActiveColumnIndex(m_index - 1);
+            m_controller->triggerUrlChangeRequest(activeColumn()->url());
         }
         break;
 
     case MoveRight:
         if (m_index < m_columns.count() - 1) {
             setActiveColumnIndex(m_index + 1);
+            m_controller->triggerUrlChangeRequest(m_columns[m_index]->url());
         }
         break;
 
@@ -426,8 +428,6 @@ void DolphinColumnView::setActiveColumnIndex(int index)
     m_index = index;
     m_columns[m_index]->setActive(true);
 
-    m_controller->setUrl(m_columns[m_index]->url());
-
     assureVisibleActiveColumn();
 }
 
index 3b38b6cd59e48bd78037be06eaa1a1e3d7579611..38057362929eba3a8793a7b99b2842177f038d18 100644 (file)
@@ -268,6 +268,7 @@ void DolphinColumnWidget::mousePressEvent(QMouseEvent* event)
     m_view->m_controller->requestActivation();
     if (!m_active) {
         m_view->requestActivation(this);
+        m_view->m_controller->triggerUrlChangeRequest(m_url);
     }
 
     QListView::mousePressEvent(event);
@@ -291,6 +292,7 @@ void DolphinColumnWidget::contextMenuEvent(QContextMenuEvent* event)
 {
     if (!m_active) {
         m_view->requestActivation(this);
+        m_view->m_controller->triggerUrlChangeRequest(m_url);
     }
 
     QListView::contextMenuEvent(event);
index 7a6d566375762b15aa51accc4ab8f05ec110e3c8..2a9e8423d3873cd6238abcb237ee82b93bece176 100644 (file)
@@ -44,6 +44,13 @@ void DolphinController::setUrl(const KUrl& url)
     }
 }
 
+void DolphinController::triggerUrlChangeRequest(const KUrl& url)
+{
+    if (m_url != url) {
+        emit requestUrlChange(url);
+    }
+}
+
 void DolphinController::triggerContextMenuRequest(const QPoint& pos)
 {
     emit activated();
index 118b945f029228fd29a96ace7ac1de0f766a7360..c48a0340f503227aab6fa5f12cc7cdb537f4ddb2 100644 (file)
@@ -49,6 +49,7 @@ class QWidget;
  * The communication of the view implementations to the abstract view is done by:
  * - triggerContextMenuRequest()
  * - requestActivation()
+ * - triggerUrlChangeRequest()
  * - indicateDroppedUrls()
  * - indicateSortingChange()
  * - indicateSortOrderChanged()
@@ -59,6 +60,7 @@ class QWidget;
  * - emitViewportEntered()
  *
  * The communication of the abstract view to the view implementations is done by:
+ * - setUrl()
  * - setShowHiddenFiles()
  * - setShowPreview()
  * - setAdditionalInfoCount()
@@ -74,10 +76,25 @@ public:
     explicit DolphinController(QObject* parent);
     virtual ~DolphinController();
 
-    /** Sets the URL to \a url and emits the signal urlChanged(). */
+    /**
+     * Sets the URL to \a url and emits the signal urlChanged() if
+     * \a url is different for the current URL. This method should
+     * be invoked by the abstract Dolphin view whenever the current
+     * URL has been changed.
+     */
     void setUrl(const KUrl& url);
     const KUrl& url() const;
 
+    /**
+     * Allows a view implementation to request an URL change to \a url.
+     * The signal requestUrlChange() is emitted and the abstract Dolphin view
+     * will assure that the URL of the Dolphin Controller will be updated
+     * later. Invoking this method makes only sense if the view implementation
+     * shows a hierarchy of URLs and allows to change the URL within
+     * the view (e. g. this is the case in the column view).
+     */
+    void triggerUrlChangeRequest(const KUrl& url);
+
     /**
      * Requests a context menu for the position \a pos. This method
      * should be invoked by the view implementation when a context
@@ -215,6 +232,12 @@ signals:
      */
     void urlChanged(const KUrl& url);
 
+    /**
+     * Is emitted if the view implementation requests a changing of the current
+     * URL to \a url (see triggerUrlChangeRequest()).
+     */
+    void requestUrlChange(const KUrl& url);
+
     /**
      * Is emitted if a context menu should be opened (see triggerContextMenuRequest()).
      * The abstract Dolphin view connects to this signal and will open the context menu.
index 51dbb708caeb8fdaf972ada0b5a2f2b9a9d53d81..8361ceb068b2710755b82b5429ebf8c7fea6e9fd 100644 (file)
@@ -88,8 +88,16 @@ DolphinView::DolphinView(QWidget* parent,
 
     m_controller = new DolphinController(this);
     m_controller->setUrl(url);
+
+    // Receiver of the DolphinView signal 'urlChanged()' don't need
+    // to care whether the internal controller changed the URL already or whether
+    // the controller just requested an URL change and will be updated later.
+    // In both cases the URL has been changed:
     connect(m_controller, SIGNAL(urlChanged(const KUrl&)),
             this, SIGNAL(urlChanged(const KUrl&)));
+    connect(m_controller, SIGNAL(requestUrlChange(const KUrl&)),
+            this, SIGNAL(urlChanged(const KUrl&)));
+
     connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
             this, SLOT(openContextMenu(const QPoint&)));
     connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const QModelIndex&, QWidget*)),
@@ -466,18 +474,11 @@ void DolphinView::updateView(const KUrl& url, const KUrl& rootUrl)
         return;
     }
 
-    const bool restoreColumnView =  !rootUrl.isEmpty()
-                                    && !rootUrl.equals(url, KUrl::CompareWithoutTrailingSlash)
-                                    && rootUrl.isParentOf(url);
-
     m_controller->setUrl(url); // emits urlChanged, which we forward
 
-    if (restoreColumnView) {
+    if (!rootUrl.isEmpty() && rootUrl.isParentOf(url)) {
         applyViewProperties(rootUrl);
         loadDirectory(rootUrl);
-        // Restoring the column view relies on the URL-history. It might be possible
-        // that the view properties have been changed or deleted in the meantime, so
-        // it cannot be asserted that really a column view has been created:
         if (itemView() == m_columnView) {
             m_columnView->setRootUrl(rootUrl);
             m_columnView->showColumn(url);