From: Peter Penz Date: Tue, 9 Oct 2007 21:10:17 +0000 (+0000) Subject: column view fixes: X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/1d4cfd16fd5ceb8f37400d4890807e3c56619971 column view fixes: * 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 --- diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp index fac35a0be..e8b75c532 100644 --- a/src/dolphincolumnview.cpp +++ b/src/dolphincolumnview.cpp @@ -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(); } diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp index 3b38b6cd5..380573629 100644 --- a/src/dolphincolumnwidget.cpp +++ b/src/dolphincolumnwidget.cpp @@ -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); diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp index 7a6d56637..2a9e8423d 100644 --- a/src/dolphincontroller.cpp +++ b/src/dolphincontroller.cpp @@ -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(); diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h index 118b945f0..c48a0340f 100644 --- a/src/dolphincontroller.h +++ b/src/dolphincontroller.h @@ -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. diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 51dbb708c..8361ceb06 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -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);