forked from M-Labs/artiq
browser: save/restore rootIndex
This commit is contained in:
parent
0b1b99be8a
commit
5ebdd5c106
|
@ -144,6 +144,8 @@ class FilesDock(QtWidgets.QDockWidget):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return
|
return
|
||||||
idx = self.model.index(path)
|
idx = self.model.index(path)
|
||||||
|
if not idx.isValid():
|
||||||
|
return
|
||||||
self.rl.setRootIndex(idx)
|
self.rl.setRootIndex(idx)
|
||||||
|
|
||||||
def scroll_when_loaded(p):
|
def scroll_when_loaded(p):
|
||||||
|
@ -163,12 +165,14 @@ class FilesDock(QtWidgets.QDockWidget):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return
|
return
|
||||||
self.select_dir(os.path.dirname(path))
|
self.select_dir(os.path.dirname(path))
|
||||||
self.rl.setCurrentIndex(self.model.index(path))
|
idx = self.model.index(path)
|
||||||
|
if not idx.isValid():
|
||||||
|
return
|
||||||
|
self.rl.setCurrentIndex(idx)
|
||||||
|
|
||||||
def save_state(self):
|
def save_state(self):
|
||||||
return {
|
return {
|
||||||
"dir": self.model.filePath(self.rt.model().mapToSource(
|
"dir": self.model.filePath(self.rl.rootIndex()),
|
||||||
self.rt.currentIndex())),
|
|
||||||
"file": self.model.filePath(self.rl.currentIndex()),
|
"file": self.model.filePath(self.rl.currentIndex()),
|
||||||
"header": bytes(self.rt.header().saveState()),
|
"header": bytes(self.rt.header().saveState()),
|
||||||
"splitter": bytes(self.splitter.saveState()),
|
"splitter": bytes(self.splitter.saveState()),
|
||||||
|
|
Loading…
Reference in New Issue