From: Peter Penz Date: Sat, 10 Feb 2007 21:29:29 +0000 (+0000) Subject: restore the x- and y-position of the view if the current view is part of the history X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/64ef4394f97af721d364390ba00338b3a4006488 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 --- 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);