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);
return m_controller->url();
}
-void DolphinView::setRootUrl(const KUrl& url)
-{
- m_rootUrl = url;
-}
-
KUrl DolphinView::rootUrl() const
{
return isColumnViewActive() ? m_dirLister->url() : url();
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);
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)
*/
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
*/
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
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 */
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&)));
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)
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
*/
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