forked from M-Labs/artiq
1
0
Fork 0

browser: save/restore rootIndex

This commit is contained in:
Robert Jördens 2016-04-20 10:37:02 +02:00
parent 0b1b99be8a
commit 5ebdd5c106
1 changed files with 7 additions and 3 deletions

View File

@ -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()),