diff options
| -rw-r--r-- | src/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/dolphindetailsview.cpp | 46 | ||||
| -rw-r--r-- | src/dolphindetailsview.h | 27 | ||||
| -rw-r--r-- | src/dolphindetailsviewexpander.cpp | 94 | ||||
| -rw-r--r-- | src/dolphindetailsviewexpander.h | 77 | ||||
| -rw-r--r-- | src/dolphinpart.cpp | 12 | ||||
| -rw-r--r-- | src/dolphinpart.h | 3 | ||||
| -rw-r--r-- | src/dolphinview.cpp | 142 | ||||
| -rw-r--r-- | src/dolphinview.h | 35 | ||||
| -rw-r--r-- | src/dolphinviewcontainer.cpp | 13 | ||||
| -rw-r--r-- | src/dolphinviewcontainer.h | 6 |
11 files changed, 428 insertions, 28 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c2c2064a0..6b3c95f0d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,7 @@ set(dolphinprivate_LIB_SRCS dolphinviewactionhandler.cpp dolphinviewautoscroller.cpp dolphinremoteencoding.cpp + dolphindetailsviewexpander.cpp draganddrophelper.cpp folderexpander.cpp renamedialog.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 9d32dd247..bc1598541 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -57,6 +57,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, m_controller(controller), m_extensionsFactory(0), m_expandableFoldersAction(0), + m_expandedUrls(), m_font(), m_decorationSize(), m_band() @@ -151,6 +152,9 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, connect(m_expandableFoldersAction, SIGNAL(toggled(bool)), this, SLOT(setFoldersExpandable(bool))); + connect(this, SIGNAL(expanded(const QModelIndex&)), this, SLOT(slotExpanded(const QModelIndex&))); + connect(this, SIGNAL(collapsed(const QModelIndex&)), this, SLOT(slotCollapsed(const QModelIndex&))); + updateDecorationSize(view->showPreview()); m_extensionsFactory = new ViewExtensionsFactory(this, controller); @@ -162,6 +166,11 @@ DolphinDetailsView::~DolphinDetailsView() { } +QSet<KUrl> DolphinDetailsView::expandedUrls() const +{ + return m_expandedUrls; +} + bool DolphinDetailsView::event(QEvent* event) { if (event->type() == QEvent::Polish) { @@ -867,6 +876,43 @@ void DolphinDetailsView::setFoldersExpandable(bool expandable) setItemsExpandable(expandable); } +void DolphinDetailsView::slotExpanded(const QModelIndex& index) +{ + KFileItem item = m_controller->itemForIndex(index); + if (!item.isNull()) { + m_expandedUrls.insert(item.url()); + } +} + +void DolphinDetailsView::slotCollapsed(const QModelIndex& index) +{ + KFileItem item = m_controller->itemForIndex(index); + if (!item.isNull()) { + m_expandedUrls.remove(item.url()); + } +} + +void DolphinDetailsView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) +{ + removeExpandedIndexes(parent, start, end); + QTreeView::rowsAboutToBeRemoved(parent, start, end); +} + +void DolphinDetailsView::removeExpandedIndexes(const QModelIndex& parent, int start, int end) +{ + if (m_expandedUrls.isEmpty()) { + return; + } + + for (int row = start; row <= end; row++) { + const QModelIndex index = model()->index(row, 0, parent); + if (isExpanded(index)) { + slotCollapsed(index); + removeExpandedIndexes(index, 0, model()->rowCount(index) - 1); + } + } +} + void DolphinDetailsView::updateDecorationSize(bool showPreview) { DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); diff --git a/src/dolphindetailsview.h b/src/dolphindetailsview.h index e0f34d349..f9a795560 100644 --- a/src/dolphindetailsview.h +++ b/src/dolphindetailsview.h @@ -47,6 +47,11 @@ public: DolphinSortFilterProxyModel* model); virtual ~DolphinDetailsView(); + /** + * Returns a set containing the URLs of all expanded items. + */ + QSet<KUrl> expandedUrls() const; + protected: virtual bool event(QEvent* event); virtual QStyleOptionViewItem viewOptions() const; @@ -169,8 +174,24 @@ private slots: */ void setFoldersExpandable(bool expandable); + /** + * These slots update the list of expanded items. + */ + void slotExpanded(const QModelIndex& index); + void slotCollapsed(const QModelIndex& index); + +protected slots: + + virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); + private: /** + * Removes the URLs corresponding to the children of \a index in the rows + * between \a start and \a end inclusive from the set of expanded URLs. + */ + void removeExpandedIndexes(const QModelIndex& parent, int start, int end); + + /** * Updates the size of the decoration dependent on the * icon size of the DetailsModeSettings. The controller * will get informed about possible zoom in/zoom out @@ -203,6 +224,12 @@ private: ViewExtensionsFactory* m_extensionsFactory; QAction* m_expandableFoldersAction; + // A set containing the URLs of all currently expanded folders. + // We cannot use a QSet<QModelIndex> because a QModelIndex is not guaranteed to remain valid over time. + // Also a QSet<QPersistentModelIndex> does not work as expected because it is not guaranteed that + // subsequent expand/collapse events of the same file item will yield the same QPersistentModelIndex. + QSet<KUrl> m_expandedUrls; + QFont m_font; QSize m_decorationSize; diff --git a/src/dolphindetailsviewexpander.cpp b/src/dolphindetailsviewexpander.cpp new file mode 100644 index 000000000..cfab3bf12 --- /dev/null +++ b/src/dolphindetailsviewexpander.cpp @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2009 by Frank Reininghaus ([email protected]) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "dolphindetailsviewexpander.h" + +#include "dolphindetailsview.h" +#include "dolphinmodel.h" +#include "dolphinsortfilterproxymodel.h" + +#include <kdirlister.h> +#include <kdirmodel.h> + +DolphinDetailsViewExpander::DolphinDetailsViewExpander(DolphinDetailsView* parent, + const QSet<KUrl>& urlsToExpand) : + QObject(parent), + m_detailsView(parent), + m_dirLister(0), + m_dolphinModel(0), + m_proxyModel(0) +{ + Q_ASSERT(parent != 0); + + m_proxyModel = qobject_cast<const DolphinSortFilterProxyModel*>(parent->model()); + Q_ASSERT(m_proxyModel != 0); + + m_dolphinModel = qobject_cast<const DolphinModel*>(m_proxyModel->sourceModel()); + Q_ASSERT(m_dolphinModel != 0); + + m_dirLister = m_dolphinModel->dirLister(); + Q_ASSERT(m_dirLister != 0); + + if(!urlsToExpand.isEmpty()) { + // The URLs must be sorted. E.g. /home/user/ cannot be expanded before /home/ + // because it is not known to the dir model before. + m_urlsToExpand = urlsToExpand.toList(); + qSort(m_urlsToExpand); + + // The dir lister must have completed the folder listing before a subfolder can be expanded. + connect(m_dirLister, SIGNAL(completed()), this, SLOT(slotDirListerCompleted())); + } + else { + // There is nothing to expand - destroy this object + deleteLater(); + } +} + +DolphinDetailsViewExpander::~DolphinDetailsViewExpander() +{ +} + +void DolphinDetailsViewExpander::stop() +{ + disconnect(m_dirLister, SIGNAL(completed()), this, SLOT(slotDirListerCompleted())); + deleteLater(); +} + +void DolphinDetailsViewExpander::slotDirListerCompleted() +{ + QModelIndex dirIndex; + + while(!m_urlsToExpand.isEmpty() && !dirIndex.isValid()) { + const KUrl url = m_urlsToExpand.takeFirst(); + dirIndex = m_dolphinModel->indexForUrl(url); + } + + if(dirIndex.isValid()) { + // A valid model index was found. Note that only one item is expanded in each call of this slot + // because expanding any item will trigger KDirLister::openUrl(...) via KDirModel::fetchMore(...), + // and we can only continue when the dir lister is done. + const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex); + m_detailsView->expand(proxyIndex); + } + + if(m_urlsToExpand.isEmpty()) { + emit completed(); + stop(); + } +} diff --git a/src/dolphindetailsviewexpander.h b/src/dolphindetailsviewexpander.h new file mode 100644 index 000000000..b4dc2fc72 --- /dev/null +++ b/src/dolphindetailsviewexpander.h @@ -0,0 +1,77 @@ +/*************************************************************************** + * Copyright (C) 2009 by Frank Reininghaus ([email protected]) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#ifndef DOLPHINDETAILSVIEWEXPANDER_H +#define DOLPHINDETAILSVIEWEXPANDER_H + +#include <QObject> +#include <QSet> +#include <QList> + +class DolphinDetailsView; +class KUrl; +class KDirLister; +class DolphinModel; +class DolphinSortFilterProxyModel; + +/** + * @brief Expands a given set of subfolders in collaboration with the dir lister and the dir model. + * + * Note that only one subfolder can be expanded at a time. Each expansion triggers KDirLister::openUrl(...), + * and further expansions can only be done the next time the dir lister emits its completed() signal. + */ +class DolphinDetailsViewExpander : public QObject +{ + Q_OBJECT + +public: + explicit DolphinDetailsViewExpander(DolphinDetailsView* parent, + const QSet<KUrl>& urlsToExpand); + + virtual ~DolphinDetailsViewExpander(); + + /** + * Stops the expansion and deletes the object via deleteLater(). + */ + void stop(); + +private slots: + /** + * This slot is invoked every time the dir lister has completed a listing. + * It expands the first URL from the list m_urlsToExpand that can be found in the dir model. + * If the list is empty, stop() is called. + */ + void slotDirListerCompleted(); + +signals: + /** + * Is emitted when the expander has finished expanding URLs in the details view. + */ + void completed(); + +private: + QList<KUrl> m_urlsToExpand; + + DolphinDetailsView* m_detailsView; + const KDirLister* m_dirLister; + const DolphinModel* m_dolphinModel; + const DolphinSortFilterProxyModel* m_proxyModel; +}; + +#endif diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 34569eeb5..43d6fd137 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -446,6 +446,18 @@ void DolphinPart::slotRequestUrlChange(const KUrl& url) //// +void DolphinPartBrowserExtension::restoreState(QDataStream &stream) +{ + KParts::BrowserExtension::restoreState(stream); + m_part->view()->restoreState(stream); +} + +void DolphinPartBrowserExtension::saveState(QDataStream &stream) +{ + KParts::BrowserExtension::saveState(stream); + m_part->view()->saveState(stream); +} + void DolphinPartBrowserExtension::cut() { m_part->view()->cutSelectedItems(); diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 977252035..28199ea2a 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -225,6 +225,9 @@ public: DolphinPartBrowserExtension( DolphinPart* part ) : KParts::BrowserExtension( part ), m_part(part) {} + virtual void restoreState(QDataStream &stream); + virtual void saveState(QDataStream &stream); + public Q_SLOTS: void cut(); void copy(); diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 034b81d3f..2d95be828 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -64,6 +64,7 @@ #include "settings/dolphinsettings.h" #include "viewproperties.h" #include "zoomlevelinfo.h" +#include "dolphindetailsviewexpander.h" /** * Helper function for sorting items with qSort() in @@ -94,6 +95,7 @@ DolphinView::DolphinView(QWidget* parent, m_selectionChangedTimer(0), m_rootUrl(), m_activeItemUrl(), + m_restoredContentsPosition(), m_createdItemUrl(), m_selectedItems(), m_newFileNames() @@ -369,8 +371,18 @@ void DolphinView::setContentsPosition(int x, int y) m_loadingDirectory = false; } +void DolphinView::setRestoredContentsPosition(const QPoint& pos) +{ + // TODO: This function is called by DolphinViewContainer. + // If it makes use of DolphinView::restoreState(...) to restore the + // view state in KDE 4.5, this function can be removed. + m_restoredContentsPosition = pos; +} + QPoint DolphinView::contentsPosition() const { + // TODO: If DolphinViewContainer uses DolphinView::saveState(...) to save the + // view state in KDE 4.5, this code can be moved to DolphinView::saveState. QAbstractItemView* view = m_viewAccessor.itemView(); Q_ASSERT(view != 0); const int x = view->horizontalScrollBar()->value(); @@ -1049,6 +1061,8 @@ bool DolphinView::isTabsForFilesEnabled() const void DolphinView::activateItem(const KUrl& url) { + // TODO: If DolphinViewContainer uses DolphinView::restoreState(...) to restore the + // view state in KDE 4.5, this function can be removed. m_activeItemUrl = url; } @@ -1057,6 +1071,53 @@ bool DolphinView::itemsExpandable() const return m_viewAccessor.itemsExpandable(); } +void DolphinView::restoreState(QDataStream &stream) +{ + // current item + stream >> m_activeItemUrl; + + // view position + stream >> m_restoredContentsPosition; + + // expanded folders (only relevant for the details view - will be ignored by the view in other view modes) + QSet<KUrl> urlsToExpand; + stream >> urlsToExpand; + const DolphinDetailsViewExpander* expander = m_viewAccessor.setExpandedUrls(urlsToExpand); + + if (expander) { + m_expanderActive = true; + connect (expander, SIGNAL(completed()), this, SLOT(slotLoadingCompleted())); + } + else { + m_expanderActive = false; + } +} + +void DolphinView::saveState(QDataStream &stream) +{ + // current item + KFileItem currentItem; + const QAbstractItemView* view = m_viewAccessor.itemView(); + + if(view) { + const QModelIndex proxyIndex = view->currentIndex(); + const QModelIndex dirModelIndex = m_viewAccessor.proxyModel()->mapToSource(proxyIndex); + currentItem = m_viewAccessor.dirModel()->itemForIndex(dirModelIndex); + } + + KUrl currentUrl; + if (!currentItem.isNull()) + currentUrl = currentItem.url(); + + stream << currentUrl; + + // view position + stream << contentsPosition(); + + // expanded folders (only relevant for the details view - the set will be empty in other view modes) + stream << m_viewAccessor.expandedUrls(); +} + void DolphinView::observeCreatedItem(const KUrl& url) { m_createdItemUrl = url; @@ -1085,6 +1146,11 @@ void DolphinView::restoreSelection() void DolphinView::emitContentsMoved() { + // TODO: If DolphinViewContainer uses DolphinView::saveState(...) to save the + // view state in KDE 4.5, the contentsMoved signal might not be needed anymore, + // depending on how the implementation is done. + // In that case, the code in contentsPosition() can be moved to saveState(). + // only emit the contents moved signal if no directory loading is ongoing // (this would reset the contents position always to (0, 0)) if (!m_loadingDirectory) { @@ -1120,19 +1186,8 @@ void DolphinView::slotRequestUrlChange(const KUrl& url) void DolphinView::slotDirListerCompleted() { - if (!m_activeItemUrl.isEmpty()) { - // assure that the current item remains visible - const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForUrl(m_activeItemUrl); - if (dirIndex.isValid()) { - const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex); - QAbstractItemView* view = m_viewAccessor.itemView(); - const bool clearSelection = !hasSelection(); - view->setCurrentIndex(proxyIndex); - if (clearSelection) { - view->clearSelection(); - } - m_activeItemUrl.clear(); - } + if (!m_expanderActive) { + slotLoadingCompleted(); } if (!m_newFileNames.isEmpty()) { @@ -1154,6 +1209,31 @@ void DolphinView::slotDirListerCompleted() } } +void DolphinView::slotLoadingCompleted() +{ + m_expanderActive = false; + m_loadingDirectory = false; + + if (!m_activeItemUrl.isEmpty()) { + // assure that the current item remains visible + const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForUrl(m_activeItemUrl); + if (dirIndex.isValid()) { + const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex); + QAbstractItemView* view = m_viewAccessor.itemView(); + const bool clearSelection = !hasSelection(); + view->setCurrentIndex(proxyIndex); + if (clearSelection) { + view->clearSelection(); + } + m_activeItemUrl.clear(); + } + } + + // Restore the contents position. This has to be done using a Qt::QueuedConnection + // because the view might not be in its final state yet. + QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection); +} + void DolphinView::slotRefreshItems() { if (m_assureVisibleCurrentIndex) { @@ -1175,6 +1255,7 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload) } m_loadingDirectory = true; + m_expanderActive = false; if (reload) { m_selectedItems = selectedItems(); @@ -1442,6 +1523,11 @@ void DolphinView::ViewAccessor::prepareUrlChange(const KUrl& url) if (m_columnsContainer != 0) { m_columnsContainer->showColumn(url); } + + if(!m_detailsViewExpander.isNull()) { + // Stop expanding items in the current folder + m_detailsViewExpander->stop(); + } } QAbstractItemView* DolphinView::ViewAccessor::itemView() const @@ -1489,6 +1575,28 @@ bool DolphinView::ViewAccessor::itemsExpandable() const return (m_detailsView != 0) && m_detailsView->itemsExpandable(); } + +QSet<KUrl> DolphinView::ViewAccessor::expandedUrls() const +{ + if(m_detailsView != 0) { + return m_detailsView->expandedUrls(); + } + else { + return QSet<KUrl>(); + } +} + +const DolphinDetailsViewExpander* DolphinView::ViewAccessor::setExpandedUrls(const QSet<KUrl>& urlsToExpand) +{ + if((m_detailsView != 0) && m_detailsView->itemsExpandable() && !urlsToExpand.isEmpty()) { + m_detailsViewExpander = new DolphinDetailsViewExpander(m_detailsView, urlsToExpand); + return m_detailsViewExpander; + } + else { + return 0; + } +} + bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const { // the details view requires no reloading of the directory, as it maps @@ -1520,4 +1628,12 @@ void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl) m_controller->redirectToUrl(newUrl); // #186947 } +void DolphinView::restoreContentsPosition() +{ + if (!m_restoredContentsPosition.isNull()) { + setContentsPosition(m_restoredContentsPosition.x(), m_restoredContentsPosition.y()); + m_restoredContentsPosition = QPoint(); + } +} + #include "dolphinview.moc" diff --git a/src/dolphinview.h b/src/dolphinview.h index 03154f950..7ee7cd02e 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -54,6 +54,7 @@ class KActionCollection; class KDirLister; class KUrl; class ViewProperties; +class DolphinDetailsViewExpander; /** * @short Represents a view for the directory content. @@ -225,6 +226,13 @@ public: */ void setContentsPosition(int x, int y); + /** + * Sets the upper left position of the view content + * to (x,y) after the directory loading is finished. + * This is useful when going back or forward in history. + */ + void setRestoredContentsPosition(const QPoint& pos); + /** Returns the upper left position of the view content. */ QPoint contentsPosition() const; @@ -356,6 +364,17 @@ public: */ bool itemsExpandable() const; + /** + * Restores the view state (current item, contents position, details view expansion state) + */ + void restoreState(QDataStream &stream); + + /** + * Saves the view state (current item, contents position, details view expansion state) + */ + void saveState(QDataStream &stream); + + public slots: /** * Changes the directory to \a url. If the current directory is equal to @@ -669,6 +688,12 @@ private slots: void slotDirListerCompleted(); /** + * Invoked when the loading of the directory is finished. + * Restores the active item and the scroll position if possible. + */ + void slotLoadingCompleted(); + + /** * Is invoked when the KDirLister indicates refreshed items. */ void slotRefreshItems(); @@ -699,6 +724,11 @@ private slots: */ void slotRedirection(const KUrl& oldUrl, const KUrl& newUrl); + /** + * Restores the contents position, if history information about the old position is available. + */ + void restoreContentsPosition(); + private: void loadDirectory(const KUrl& url, bool reload = false); @@ -784,6 +814,8 @@ private: bool supportsCategorizedSorting() const; bool itemsExpandable() const; + QSet<KUrl> expandedUrls() const; + const DolphinDetailsViewExpander* setExpandedUrls(const QSet<KUrl>& urlsToExpand); /** * Returns true, if a reloading of the items is required @@ -802,6 +834,7 @@ private: DolphinColumnViewContainer* m_columnsContainer; DolphinSortFilterProxyModel* m_proxyModel; QAbstractItemView* m_dragSource; + QPointer<DolphinDetailsViewExpander> m_detailsViewExpander; }; bool m_active : 1; @@ -812,6 +845,7 @@ private: bool m_isContextMenuOpen : 1; // TODO: workaround for Qt-issue 207192 bool m_ignoreViewProperties : 1; bool m_assureVisibleCurrentIndex : 1; + bool m_expanderActive : 1; Mode m_mode; @@ -826,6 +860,7 @@ private: KUrl m_rootUrl; KUrl m_activeItemUrl; + QPoint m_restoredContentsPosition; KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu KFileItemList m_selectedItems; // this is used for making the View to remember selections after F5 diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 5639d9bf2..ece22f4c0 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -314,7 +314,6 @@ void DolphinViewContainer::slotDirListerCompleted() } else { updateStatusBar(); } - QMetaObject::invokeMethod(this, "restoreContentsPos", Qt::QueuedConnection); // Enable the 'File'->'Create New...' menu only if the directory // supports writing. @@ -387,17 +386,11 @@ void DolphinViewContainer::openContextMenu(const KFileItem& item, void DolphinViewContainer::saveContentsPos(int x, int y) { + // TODO: If DolphinViewContainer uses DolphinView::saveState(...) to save the + // view state in KDE 4.5, this funciton can be removed. m_urlNavigator->savePosition(x, y); } -void DolphinViewContainer::restoreContentsPos() -{ - if (!url().isEmpty()) { - const QPoint pos = m_urlNavigator->savedPosition(); - m_view->setContentsPosition(pos.x(), pos.y()); - } -} - void DolphinViewContainer::activate() { setActive(true); @@ -484,6 +477,8 @@ void DolphinViewContainer::slotHistoryChanged() // the previous directory as active item: const KUrl url = m_urlNavigator->historyUrl(index - 1); m_view->activateItem(url); + QPoint pos = m_urlNavigator->savedPosition(); + m_view->setRestoredContentsPosition(pos); } } diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 6d4b9b1a4..8dc4b0443 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -207,12 +207,6 @@ private slots: void saveContentsPos(int x, int y); /** - * Restores the contents position of the view, if the view - * is part of the history. - */ - void restoreContentsPos(); - - /** * Marks the view container as active * (see DolphinViewContainer::setActive()). */ |
