From b00089c3d3ffc784940cebb627e5c52f8af7c3ca Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 20 Apr 2016 12:07:08 +0800 Subject: [PATCH] browser: simplify and fix state restore --- artiq/browser/files.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/artiq/browser/files.py b/artiq/browser/files.py index 8fc2467cd..51e034f2c 100644 --- a/artiq/browser/files.py +++ b/artiq/browser/files.py @@ -115,7 +115,9 @@ class FilesDock(QtWidgets.QDockWidget): self.datasets.init(rd) def select(self, path): - idx = self.rt_model.index(os.path.dirname(path)) + idx = self.rt_model.index(path) + if not idx.isValid(): + return self.rt.expand(idx) self.rt.scrollTo(idx) self.rt.setCurrentIndex(idx) @@ -129,12 +131,6 @@ class FilesDock(QtWidgets.QDockWidget): } def restore_state(self, state): - selected = state.get("selected") - if selected: - 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)) + self.select(state["selected"]) + self.rt.header().restoreState(QtCore.QByteArray(state["header"])) + self.splitter.restoreState(QtCore.QByteArray(state["splitter"]))