Revert "browser: simplify and fix state restore"

This reverts commit b00089c3d3.
This commit is contained in:
Robert Jördens 2016-04-20 10:38:35 +02:00
parent 1f92e034da
commit f09bfa258d
1 changed files with 10 additions and 6 deletions

View File

@ -115,9 +115,7 @@ class FilesDock(QtWidgets.QDockWidget):
self.datasets.init(rd) self.datasets.init(rd)
def select(self, path): def select(self, path):
idx = self.rt_model.index(path) idx = self.rt_model.index(os.path.dirname(path))
if not idx.isValid():
return
self.rt.expand(idx) self.rt.expand(idx)
self.rt.scrollTo(idx) self.rt.scrollTo(idx)
self.rt.setCurrentIndex(idx) self.rt.setCurrentIndex(idx)
@ -131,6 +129,12 @@ class FilesDock(QtWidgets.QDockWidget):
} }
def restore_state(self, state): def restore_state(self, state):
self.select(state["selected"]) selected = state.get("selected")
self.rt.header().restoreState(QtCore.QByteArray(state["header"])) if selected:
self.splitter.restoreState(QtCore.QByteArray(state["splitter"])) self.select(selected)
header = state.get("header")
if header:
self.rt.header().restoreState(QtCore.QByteArray(header))
splitter = state.get("splitter")
if splitter:
self.splitter.restoreState(QtCore.QByteArray(splitter))