From 64ef4394f97af721d364390ba00338b3a4006488 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 10 Feb 2007 21:29:29 +0000 Subject: [PATCH] restore the x- and y-position of the view if the current view is part of the history svn path=/trunk/playground/utils/dolphin/; revision=632370 --- src/dolphinview.cpp | 21 +++++++++++++++++++-- src/dolphinview.h | 6 ++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 9b2286c87..2b4546751 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -319,12 +319,12 @@ DolphinStatusBar* DolphinView::statusBar() const int DolphinView::contentsX() const { - return 0; //scrollView()->contentsX(); + return itemView()->horizontalScrollBar()->value(); } int DolphinView::contentsY() const { - return 0; //scrollView()->contentsY(); + return itemView()->verticalScrollBar()->value(); } void DolphinView::refreshSettings() @@ -668,6 +668,23 @@ void DolphinView::updateItemCount() } updateStatusBar(); + + QTimer::singleShot(0, this, SLOT(restoreContentsPos())); +} + +void DolphinView::restoreContentsPos() +{ + int index = 0; + const QLinkedList history = urlHistory(index); + if (!history.isEmpty()) { + QAbstractItemView* view = itemView(); + // TODO: view->setCurrentItem(history[index].currentFileName()); + + QLinkedList::const_iterator it = history.begin(); + it += index; + view->horizontalScrollBar()->setValue((*it).contentsX()); + view->verticalScrollBar()->setValue((*it).contentsY()); + } } void DolphinView::showInfoMessage(const QString& msg) diff --git a/src/dolphinview.h b/src/dolphinview.h index dbd6622d7..4b740e655 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -406,6 +406,12 @@ private slots: */ void updateItemCount(); + /** + * Restores the x- and y-position of the contents if the + * current view is part of the history. + */ + void restoreContentsPos(); + /** Shows the information \a msg inside the statusbar. */ void showInfoMessage(const QString& msg); -- 2.47.3