Steve Borho avatar Steve Borho committed bbd25e9

shelve: preserve patch/wdir selection through refresh

Comments (0)

Files changed (1)

tortoisehg/hgqt/shelve.py

         self.refreshAction = a = QAction(_('Refresh'), self)
         a.setIcon(qtlib.geticon('reload'))
         a.setShortcut(QKeySequence.Refresh)
-        a.triggered.connect(self.refresh)
+        a.triggered.connect(self.refreshCombos)
         self.rbar.addAction(self.refreshAction)
         self.actionNew = a = QAction(_('New Shelf'), self)
         a.setIcon(qtlib.geticon('document-new'))
 
     @pyqtSlot()
     def refreshCombos(self):
-        # TODO: preserve selection through refresh
+        ushelvea = self.comboa.currentText()
+        ushelveb = self.combob.currentText()
         self.comboa.clear()
         self.combob.clear()
         shelves = [hglib.tounicode(s) for s in self.repo.thgshelves()]
         patches = shelves + patches
         self.comboa.addItems([self.wdir] + patches)
         self.combob.addItems(patches)
+        if ushelvea == self.wdir:
+            self.comboa.setCurrentIndex(0)
+        elif ushelvea in patches:
+            self.comboa.setCurrentIndex(1 + patches.index(ushelvea))
+        if ushelveb in patches:
+            self.combob.setCurrentIndex(patches.index(ushelveb))
         if not patches:
             self.delShelfButtonB.setEnabled(False)
             self.browseb.setContext(patchctx('', self.repo, None))
         self.delShelfButtonB.setEnabled(rev.startswith(self.repo.shelfdir))
         self.browseb.setContext(self.repo.changectx(rev))
 
-    def refresh(self):
-        self.browsea.refresh()
-        self.browseb.refresh()
-        self.refreshCombos()
-
     def linkSplitters(self, pos, index):
         if self.browsea.splitter.sizes()[0] != pos:
             self.browsea.splitter.moveSplitter(pos, index)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.