forked from M-Labs/artiq
browser: simplify and fix state restore
This commit is contained in:
parent
89f92a6131
commit
b00089c3d3
|
@ -115,7 +115,9 @@ 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(os.path.dirname(path))
|
idx = self.rt_model.index(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)
|
||||||
|
@ -129,12 +131,6 @@ class FilesDock(QtWidgets.QDockWidget):
|
||||||
}
|
}
|
||||||
|
|
||||||
def restore_state(self, state):
|
def restore_state(self, state):
|
||||||
selected = state.get("selected")
|
self.select(state["selected"])
|
||||||
if selected:
|
self.rt.header().restoreState(QtCore.QByteArray(state["header"]))
|
||||||
self.select(selected)
|
self.splitter.restoreState(QtCore.QByteArray(state["splitter"]))
|
||||||
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))
|
|
||||||
|
|
Loading…
Reference in New Issue