Commits

Martin Rieser  committed f424a00

open diff dialog, local file to last reviewed file version. ContextMenu extended.

  • Participants
  • Parent commits 842ab46

Comments (0)

Files changed (1)

File hgcr-gui-qt.py

 
     ## actions ##
     def onContextMenuTriggered(self,position):
+        
+        #TODO There must be a better way to find out, that only one line is selected
+        i =0
+        selectionModel = self._qui.list_of_files.selectionModel()
+        for index in selectionModel.selectedRows():
+            i = i+1
+            selectedRowIndes = index.row()
+    
         menu = QMenu()
+        if(i==1):
+            diffAction = menu.addAction(qtlib.geticon(""),_('Diff'))
+            editAction = menu.addAction(qtlib.geticon("filemodify"),_('Edit'))
+        
         doneAction = menu.addAction(qtlib.geticon("settings_user"),_('Done'))
         #commitAction = menu.addAction(qtlib.geticon("menucommit"),_('Commit'))
         emailAction  = menu.addAction(qtlib.geticon("menulog"),_('Email'))
         setMeAsReviewer = menu.addAction(qtlib.geticon("menublame"),_('Set me as reviewer'))
         setMeAsDeveloper = menu.addAction(qtlib.geticon("hg"),_('Set me as developer'))
         
-        #add action, only possible if only one file is selected
-        #TODO There must be a better way to find out, that only one line is selected
-        i =0
-        selectionModel = self._qui.list_of_files.selectionModel()
-        for index in selectionModel.selectedRows():
-            i = i+1
-            selectedRowIndes = index.row()
         if(i==1):
-            editAction = menu.addAction(qtlib.geticon("filemodify"),_('Edit'))
             historyAction = menu.addAction(qtlib.geticon("menurevisiongraph"),_('History'))
-        
+            
         action = menu.exec_(self._qui.list_of_files.mapToGlobal(position+ QPoint(+30, +15)))
         
         #deside what should be done, depending on the selected menu item
             self.editFileDlg(file_item)
         if i==1 and action == historyAction:
             self.onHistoryButtonClicked()
+        if i==1 and action == diffAction:
+            # get file path item
+            file_item = self._qui.list_of_files.item(selectedRowIndes, self.FM_PATH)
+            # get rev of last reviewed version
+            file_revision = self._qui.list_of_files.item(selectedRowIndes, self.FM_REVISION)
+            #try to open diff dialog
+            self.diffFileDlg(file_item,file_revision)
     
     def swapDeveloperReviewer(self):
         selectionModel = self._qui.list_of_files.selectionModel()
         """
 
         # get file path item
-        file_item = self._qui.list_of_files.item(QModelIndex.row(), self.FM_PATH)
+        file_item = self._qui.list_of_files.item(QModelIndex.row(), self.FM_PATH)        
         self.editFileDlg(file_item)
-       
+        
+    
+    def diffFileDlg(self,file_item,file_revision):
+        
+        #show diff between local file and last reviewed file        
+        if file_revision.text()=='null':
+           response = QMessageBox.warning(self, _('Error'), _('This file was never reviewed!'))
+           return
+        
+        rev = int(file_revision.text())   
+        paths = [str(file_item.text())]
+        opts = dict(rev=['rev(%d)' % rev])
+        from tortoisehg.hgqt import visdiff
+        dlg = visdiff.visualdiff(self.repo.ui, self.repo, paths, opts)
+        if dlg:
+            dlg.exec_()
+            dlg.deleteLater()
     
     def editFileDlg(self,file_item):
         
-         # get absolute path
+        # get absolute path
         file_path = self.repo.wjoin(str(file_item.text()))
 
         self.ui.status('editing file: %s\n' % (file_path,))