]> cloud.milkyroute.net Git - dolphin.git/commitdiff
* Assure that the URL navigator is synchronized with the active column.
authorPeter Penz <peter.penz19@gmail.com>
Tue, 26 Jan 2010 08:27:42 +0000 (08:27 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 26 Jan 2010 08:27:42 +0000 (08:27 +0000)
* Removed obsolete triggerUrlChangeRequest() method + signal in the DolphinController. This is not needed anymore because of the refactored column view.

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

src/dolphincolumnview.cpp
src/dolphincolumnviewcontainer.cpp
src/dolphincolumnviewcontainer.h
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphinviewcontainer.cpp

index ee3d852785f299fecba7f9ca33b6acffcab99db0..3437de4990cfb408dc44e94029ef887ba3376592 100644 (file)
@@ -334,13 +334,7 @@ void DolphinColumnView::keyPressEvent(QKeyEvent* event)
 
 void DolphinColumnView::contextMenuEvent(QContextMenuEvent* event)
 {
-    if (!m_active) {
-        m_container->requestActivation(this);
-        Q_ASSERT(m_container->m_controller->itemView() == this);
-        m_container->m_controller->triggerUrlChangeRequest(m_url);
-    }
-    Q_ASSERT(m_active);
-
+    requestActivation();
     QListView::contextMenuEvent(event);
     m_container->m_controller->triggerContextMenuRequest(event->pos());
 }
@@ -390,11 +384,8 @@ void DolphinColumnView::slotEntered(const QModelIndex& index)
 
 void DolphinColumnView::requestActivation()
 {
-    m_container->m_controller->setItemView(this);
-    m_container->m_controller->requestActivation();
     if (!m_active) {
         m_container->requestActivation(this);
-        m_container->m_controller->triggerUrlChangeRequest(m_url);
         selectionModel()->clear();
     }
 }
index 3e067d413d26b2399c316661b9358c5836eed19d..83940711758ab976876c02dd10e8f7b66635831f 100644 (file)
@@ -30,6 +30,7 @@
 #include <QPoint>
 #include <QScrollBar>
 #include <QTimeLine>
+#include <QTimer>
 
 DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
                                                        DolphinController* controller) :
@@ -41,7 +42,8 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
     m_columns(),
     m_emptyViewport(0),
     m_animation(0),
-    m_dragSource(0)
+    m_dragSource(0),
+    m_activeUrlTimer(0)
 {
     Q_ASSERT(controller != 0);
 
@@ -59,6 +61,12 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
     m_animation = new QTimeLine(500, this);
     connect(m_animation, SIGNAL(frameChanged(int)), horizontalScrollBar(), SLOT(setValue(int)));
 
+    m_activeUrlTimer = new QTimer(this);
+    m_activeUrlTimer->setSingleShot(true);
+    m_activeUrlTimer->setInterval(200);
+    connect(m_activeUrlTimer, SIGNAL(timeout()),
+            this, SLOT(updateActiveUrl()));
+
     DolphinColumnView* column = new DolphinColumnView(viewport(), this, m_controller->url());
     m_columns.append(column);
     setActiveColumnIndex(0);
@@ -67,6 +75,7 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
     m_emptyViewport->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
 
     updateColumnsBackground(true);
+
 }
 
 DolphinColumnViewContainer::~DolphinColumnViewContainer()
@@ -233,6 +242,12 @@ void DolphinColumnViewContainer::updateColumnsBackground(bool active)
     }
 }
 
+void DolphinColumnViewContainer::updateActiveUrl()
+{
+    const KUrl activeUrl = m_columns[m_index]->url();
+    m_controller->setUrl(activeUrl);
+}
+
 void DolphinColumnViewContainer::setActiveColumnIndex(int index)
 {
     if ((m_index == index) || (index < 0) || (index >= m_columns.count())) {
@@ -248,6 +263,7 @@ void DolphinColumnViewContainer::setActiveColumnIndex(int index)
     m_columns[m_index]->setActive(true);
 
     assureVisibleActiveColumn();
+    m_activeUrlTimer->start(); // calls slot updateActiveUrl()
 }
 
 void DolphinColumnViewContainer::layoutColumns()
index 626cd98a19e2981a2ec55ca3631c1f1f6d683e21..c1975ac08773311b474666f90892b820a3fec439 100644 (file)
@@ -32,6 +32,7 @@ class DolphinColumnView;
 class DolphinController;
 class QFrame;
 class QTimeLine;
+class QTimer;
 
 /**
  * @brief Represents a container for columns represented as instances
@@ -77,6 +78,14 @@ private slots:
      */
     void updateColumnsBackground(bool active);
 
+    /**
+     * Tells the Dolphin controller to update the active URL
+     * to m_activeUrl. The slot is called asynchronously with a
+     * small delay, as this prevents a flickering when a directory
+     * from an inactive column gets selected.
+     */
+    void updateActiveUrl();
+
 private:
     /**
      * Deactivates the currently active column and activates
@@ -127,6 +136,8 @@ private:
     QTimeLine* m_animation;
     QAbstractItemView* m_dragSource;
 
+    QTimer* m_activeUrlTimer;
+
     friend class DolphinColumnView;
 };
 
index caa0aa74faec9ca6b43eac62eb9f4349725b41db..b61c126b519452b473e9563cd5da6aae0f395c06 100644 (file)
@@ -75,13 +75,6 @@ void DolphinController::setItemView(QAbstractItemView* view)
     }
 }
 
-void DolphinController::triggerUrlChangeRequest(const KUrl& url)
-{
-    if (m_url != url) {
-        emit requestUrlChange(url);
-    }
-}
-
 void DolphinController::triggerContextMenuRequest(const QPoint& pos,
                                                   const QList<QAction*>& customActions)
 {
index d1eba97a1dadea557b4eff6c4066b047c087b6a4..397215bfba43413165968802665c90e7f797459f 100644 (file)
@@ -30,9 +30,6 @@ class DolphinView;
 class KUrl;
 class QPoint;
 
-// TODO: get rid of all the state duplications in the controller and allow read access
-// to the Dolphin view for all view implementations
-
 /**
  * @brief Acts as mediator between the abstract Dolphin view and the view
  *        implementations.
@@ -52,7 +49,6 @@ class QPoint;
  * The communication of the view implementations to the abstract view is done by:
  * - triggerContextMenuRequest()
  * - requestActivation()
- * - triggerUrlChangeRequest()
  * - indicateDroppedUrls()
  * - indicateSortingChange()
  * - indicateSortOrderChanged()
@@ -111,16 +107,6 @@ public:
 
     QAbstractItemView* itemView() 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
@@ -299,12 +285,6 @@ 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 53b1c75293d05b103eef6d7787261cc4d1fc64b0..8f4427cb9dec8a451b8a4221f742ea7924320a87 100644 (file)
@@ -85,8 +85,6 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
             this, SLOT(dropUrls(const KUrl&, QDropEvent*)));
     connect(m_urlNavigator, SIGNAL(activated()),
             this, SLOT(activate()));
-    //connect(m_urlNavigator, SIGNAL(tabRequested(const KUrl&)),
-    //        this,
     connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
             this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));