┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dolphincolumnview.cpp4
-rw-r--r--src/dolphincolumnwidget.cpp2
-rw-r--r--src/dolphincontroller.cpp7
-rw-r--r--src/dolphincontroller.h25
-rw-r--r--src/dolphinview.cpp17
5 files changed, 44 insertions, 11 deletions
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,11 +76,26 @@ 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
* menu should be opened. The abstract Dolphin view itself
@@ -216,6 +233,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.
* @param pos Position relative to the view widget where the
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);