Commits

Boris Glimcher committed 30ef080

fixes #20

Comments (0)

Files changed (1)

         commitAction = menu.addAction(qtlib.geticon("menucommit"),_('Commit'))
         emailAction  = menu.addAction(qtlib.geticon("menulog"),_('Email'))
         addAction = menu.addAction(qtlib.geticon("fileadd"),_('Add'))
+        addModifiedAction = menu.addAction(qtlib.geticon("fileadd"),_('Add modified'))
         removeAction = menu.addAction(qtlib.geticon("filedelete"),_('Remove'))
         swapDevRev =  menu.addAction(qtlib.geticon("menusynch"),_('Swap responsibilities'))
         setMeAsReviewer = menu.addAction(qtlib.geticon("menublame"),_('Set me as reviewer'))
             self.onEmailButtonClicked()
         if action == addAction:
             self.onAddButtonClicked()
+        if action == addModifiedAction:
+            self.addModifiedAction()
         if action == removeAction:
             self.onRemoveButtonClicked()
         if action == swapDevRev:
             developer = self._qui.list_of_files.item(index.row(), self.FM_DEVELOPER)
             developer.setText(username)
 
+    def addModifiedAction(self):
+        if self.check_settings():
+            self.repo.bfstatus = True
+            self.repo.lfstatus = True
+            try:
+                stat = self.repo.status(ignored=True, unknown=True)
+            finally:
+                self.repo.bfstatus = False
+                self.repo.lfstatus = False
+            (modified, added, removed, deleted, unknown, ignored, clean) = stat  
+            
+            if not modified:
+              response = QMessageBox.warning(self, _('Warning'), _('No files were selected for ADD command'))
+              return
+
+            # get only modified files
+            message = QString('are you sure you want to add these modified files to CR?\n')
+            for path in modified:
+                message += QString("FILE -- %1\n").arg(path)
+                
+            # confirm dialog
+            response = QMessageBox.question(self, _('add to CR'), message,  QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
+            if response == QMessageBox.Yes:
+                # add files to CR manager
+                number_success_added = self.code_review.add_files([str(f) for f in modified])
+                response = QMessageBox.information(self, 'Success', '%d files were added to CR manager' % number_success_added )
+                
+            # refresh
+            self.refresh()        
+            
     @pyqtSlot()
     def onRefreshButtonClicked(self):
         # refresh
 
     @pyqtSlot()
     def onAddButtonClicked(self):
-
+        
         if self.check_settings():
             files = QFileDialog.getOpenFileNames(self, _('Choose files to add for CR...'), self._last_been_dir)