dirLister->openUrl(baseUrl, false, true);
}
+void DolphinColumnView::showColumn(const KUrl& url)
+{
+ if (!m_columns[0]->url().isParentOf(url)) {
+ // the URL is no child URL of the column view, hence do nothing
+ return;
+ }
+
+ int columnIndex = 0;
+ foreach (ColumnWidget* column, m_columns) {
+ if (column->url() == url) {
+ // the column represents already the requested URL, hence activate it
+ requestActivation(column);
+ return;
+ } else if (!column->url().isParentOf(url)) {
+ // the column is no parent of the requested URL, hence
+ // just delete all remaining columns
+ if (columnIndex > 0) {
+ setActiveColumnIndex(columnIndex - 1);
+ deleteInactiveChildColumns();
+ break;
+ }
+ }
+ ++columnIndex;
+ }
+
+ // Create missing columns. Assuming that the path is "/home/peter/Temp/" and
+ // the target path is "/home/peter/Temp/a/b/c/", then the columns "a", "b" and
+ // "c" will be created.
+ const int lastIndex = m_columns.count() - 1;
+ Q_ASSERT(lastIndex >= 0);
+
+ const KUrl& activeUrl = m_columns[lastIndex]->url();
+ Q_ASSERT(activeUrl.isParentOf(url));
+ Q_ASSERT(activeUrl != url);
+
+ QString path = activeUrl.url(KUrl::AddTrailingSlash);
+ const QString targetPath = url.url(KUrl::AddTrailingSlash);
+ int slashIndex = path.count('/');
+ bool hasSubPath = (slashIndex >= 0);
+ while (hasSubPath) {
+ const QString subPath = targetPath.section('/', slashIndex, slashIndex);
+ if (subPath.isEmpty()) {
+ hasSubPath = false;
+ } else {
+ path += subPath + '/';
+ ++slashIndex;
+
+ const QModelIndex dirIndex = m_dolphinModel->indexForUrl(KUrl(path));
+ if (dirIndex.isValid()) {
+ triggerItem(m_proxyModel->mapFromSource(dirIndex));
+ }
+ }
+ }
+}
+
bool DolphinColumnView::isIndexHidden(const QModelIndex& index) const
{
Q_UNUSED(index);
layoutColumns();
}
-void DolphinColumnView::showColumn(const KUrl& url)
-{
- if (!m_columns[0]->url().isParentOf(url)) {
- // the URL is no child URL of the column view, hence do nothing
- return;
- }
-
- int columnIndex = 0;
- foreach (ColumnWidget* column, m_columns) {
- if (column->url() == url) {
- // the column represents already the requested URL, hence activate it
- requestActivation(column);
- return;
- } else if (!column->url().isParentOf(url)) {
- // the column is no parent of the requested URL, hence
- // just delete all remaining columns
- if (columnIndex > 0) {
- setActiveColumnIndex(columnIndex - 1);
- deleteInactiveChildColumns();
- break;
- }
- }
- ++columnIndex;
- }
-
- // Create missing columns. Assuming that the path is "/home/peter/Temp/" and
- // the target path is "/home/peter/Temp/a/b/c/", then the columns "a", "b" and
- // "c" will be created.
- const int lastIndex = m_columns.count() - 1;
- Q_ASSERT(lastIndex >= 0);
-
- const KUrl& activeUrl = m_columns[lastIndex]->url();
- Q_ASSERT(activeUrl.isParentOf(url));
- Q_ASSERT(activeUrl != url);
-
- QString path = activeUrl.url(KUrl::AddTrailingSlash);
- const QString targetPath = url.url(KUrl::AddTrailingSlash);
- int slashIndex = path.count('/');
- bool hasSubPath = (slashIndex >= 0);
- while (hasSubPath) {
- const QString subPath = targetPath.section('/', slashIndex, slashIndex);
- if (subPath.isEmpty()) {
- hasSubPath = false;
- } else {
- path += subPath + '/';
- ++slashIndex;
-
- const QModelIndex dirIndex = m_dolphinModel->indexForUrl(KUrl(path));
- if (dirIndex.isValid()) {
- triggerItem(m_proxyModel->mapFromSource(dirIndex));
- }
- }
- }
-}
-
void DolphinColumnView::updateDecorationSize()
{
ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
*/
void reload();
+public slots:
+ /**
+ * Shows the column which represents the URL \a url. If the column
+ * is already shown, it gets activated, otherwise it will be created.
+ */
+ void showColumn(const KUrl& url);
+
protected:
virtual bool isIndexHidden(const QModelIndex& index) const;
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
*/
void moveContentHorizontally(int x);
- /**
- * Shows the column which represents the URL \a url. If the column
- * is already shown, it gets activated, otherwise it will be created.
- */
- void showColumn(const KUrl& url);
-
/**
* Updates the size of the decoration dependent on the
* icon size of the ColumnModeSettings. The controller
m_fileItemDelegate(0),
m_dolphinModel(dolphinModel),
m_dirLister(dirLister),
- m_proxyModel(proxyModel)
+ m_proxyModel(proxyModel),
+ m_rootUrl(url)
{
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();
return;
}
+ const KUrl oldRootUrl = rootUrl();
m_controller->setUrl(url); // emits urlChanged, which we forward
- applyViewProperties(url);
+ const bool restoreColumnView = !isColumnViewActive()
+ && m_rootUrl.isParentOf(url)
+ && (m_rootUrl != url);
+ if (restoreColumnView) {
+ applyViewProperties(m_rootUrl);
+ startDirLister(m_rootUrl);
+ Q_ASSERT(itemView() == m_columnView);
+ m_columnView->showColumn(url);
+ } else {
+ applyViewProperties(url);
+ startDirLister(url);
+ }
- startDirLister(url);
itemView()->setFocus();
+
+ const KUrl newRootUrl = rootUrl();
+ if (newRootUrl != oldRootUrl) {
+ emit rootUrlChanged(newRootUrl);
+ }
}
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 errorMessage(const QString& msg);
+ /**
+ * Is emitted if the root URL of the view has been changed
+ * to \a url (see also DolphinView::rootUrl()).
+ */
+ void rootUrlChanged(const KUrl& url);
+
protected:
/** @see QWidget::mouseReleaseEvent */
virtual void mouseReleaseEvent(QMouseEvent* event);
DolphinSortFilterProxyModel* m_proxyModel;
QList<CutItem> m_cutItemsCache;
+
+ KUrl m_rootUrl;
};
#endif // DOLPHINVIEW_H
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_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
- m_view, SLOT(setUrl(const KUrl&)));
+ this, SLOT(restoreView(const KUrl&)));
m_statusBar = new DolphinStatusBar(this, url);
connect(m_view, SIGNAL(urlChanged(const KUrl&)),
setActive(true);
}
+void DolphinViewContainer::restoreView(const KUrl& url)
+{
+ m_view->setRootUrl(m_urlNavigator->savedRootUrl());
+ m_view->setUrl(url);
+}
+
void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
{
// Prefer the local path over the URL.
*/
void activate();
+ /**
+ * Restores the current view to show \a url and assures
+ * that the root URL of the view is respected.
+ */
+ void restoreView(const KUrl& url);
+
private:
/**
* Returns the default text of the status bar, if no item is