remember scrollbar position for visited directories
authorLukas Hrazky <lukkash@email.cz>
Sun, 22 Aug 2010 20:45:03 +0000 (22:45 +0200)
committerLukas Hrazky <lukkash@email.cz>
Sun, 22 Aug 2010 20:45:03 +0000 (22:45 +0200)
Signed-off-by: Lukas Hrazky <lukkash@email.cz>

src/filelist.cpp
src/filelist.h

index fe281b8..3cbe475 100644 (file)
@@ -20,6 +20,7 @@
 #include <QProcess>
 #include <QUrl>
 #include <QEvent>
+#include <QScrollBar>
 
 #include <hildon-mime.h>
 #include <dbus/dbus.h>
@@ -65,8 +66,10 @@ bool FileList::changePath(QString path) {
     path = unwindPath(path);
     QDir dir(fileSystemModel->rootPath());
     if (dir.cd(path)) {
+        scrollBarPosition[fileSystemModel->rootPath()] = verticalScrollBar()->value();
         setRootIndex(fileSystemModel->setRootPath(dir.absolutePath()));
         clearSelection();
+        verticalScrollBar()->setValue(scrollBarPosition[dir.absolutePath()]);
         emit pathChanged(fileSystemModel->rootPath());
         return true;
     }
index ec51cbc..8fd54ac 100644 (file)
@@ -49,6 +49,8 @@ protected:
     void mousePressEvent(QMouseEvent *event);
     virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event = 0) const;
 
+    QMap<QString, int> scrollBarPosition;
+
 private slots:
     void activateItem(QModelIndex index);
 };