diff options
| author | Peter Penz <[email protected]> | 2007-09-24 13:50:31 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2007-09-24 13:50:31 +0000 |
| commit | 772a55aafc2e558302d042eb65026b9b50302ccc (patch) | |
| tree | 5101245b249850864d5c82c243c75cd7043de129 /src/dolphincolumnview.cpp | |
| parent | f78bac99094a9fe485d7ca8dac93654a807430f0 (diff) | |
Restore the root URL when navigating through the history (this is important for views like the column view where the root URL might differ from the current URL).
svn path=/trunk/KDE/kdebase/apps/; revision=716310
Diffstat (limited to 'src/dolphincolumnview.cpp')
| -rw-r--r-- | src/dolphincolumnview.cpp | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp index 7a1e41331..a89ab1848 100644 --- a/src/dolphincolumnview.cpp +++ b/src/dolphincolumnview.cpp @@ -497,6 +497,61 @@ void DolphinColumnView::reload() 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); @@ -647,61 +702,6 @@ void DolphinColumnView::moveContentHorizontally(int x) 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(); |
