157 self.__actionsMenu.aboutToShow.connect(self.__showActionsMenu) |
158 self.__actionsMenu.aboutToShow.connect(self.__showActionsMenu) |
158 |
159 |
159 self.__commitAct = self.__actionsMenu.addAction( |
160 self.__commitAct = self.__actionsMenu.addAction( |
160 UI.PixmapCache.getIcon("vcsCommit"), |
161 UI.PixmapCache.getIcon("vcsCommit"), |
161 self.tr("Commit"), self.__commit) |
162 self.tr("Commit"), self.__commit) |
162 self.__commitAct.setToolTip(self.tr("Commit the selected changes")) |
163 self.__commitAct.setToolTip(self.tr( |
|
164 "Commit the selected changes")) |
163 self.__commitSelectAct = self.__actionsMenu.addAction( |
165 self.__commitSelectAct = self.__actionsMenu.addAction( |
164 self.tr("Select all for commit"), self.__commitSelectAll) |
166 self.tr("Select all for commit"), self.__commitSelectAll) |
165 self.__commitDeselectAct = self.__actionsMenu.addAction( |
167 self.__commitDeselectAct = self.__actionsMenu.addAction( |
166 self.tr("Unselect all from commit"), self.__commitDeselectAll) |
168 self.tr("Unselect all from commit"), self.__commitDeselectAll) |
167 |
169 |
168 self.__actionsMenu.addSeparator() |
170 self.__actionsMenu.addSeparator() |
169 |
171 |
170 self.__addAct = self.__actionsMenu.addAction( |
172 self.__addAct = self.__actionsMenu.addAction( |
171 UI.PixmapCache.getIcon("vcsAdd"), |
173 UI.PixmapCache.getIcon("vcsAdd"), |
172 self.tr("Add"), self.__addUntracked) |
174 self.tr("Add"), self.__addUntracked) |
|
175 self.__addAct.setToolTip(self.tr( |
|
176 "Add the selected, untracked entries")) |
|
177 self.__addAllAct = self.__actionsMenu.addAction( |
|
178 self.tr("Add All"), self.__addAllUntracked) |
|
179 self.__addAllAct.setToolTip(self.tr( |
|
180 "Add all untracked entries")) |
173 |
181 |
174 self.__actionsMenu.addSeparator() |
182 self.__actionsMenu.addSeparator() |
175 |
183 |
176 self.__diffAct = self.__actionsMenu.addAction( |
184 self.__diffAct = self.__actionsMenu.addAction( |
177 UI.PixmapCache.getIcon("vcsDiff"), |
185 UI.PixmapCache.getIcon("vcsDiff"), |
183 UI.PixmapCache.getIcon("vcsSbsDiff"), |
191 UI.PixmapCache.getIcon("vcsSbsDiff"), |
184 self.tr("Differences Side-By-Side"), self.__sbsDiff) |
192 self.tr("Differences Side-By-Side"), self.__sbsDiff) |
185 self.__sbsDiffAct.setToolTip(self.tr( |
193 self.__sbsDiffAct.setToolTip(self.tr( |
186 "Shows the differences of the selected entry side-by-side in" |
194 "Shows the differences of the selected entry side-by-side in" |
187 " a separate dialog")) |
195 " a separate dialog")) |
|
196 self.__diffAllAct = self.__actionsMenu.addAction( |
|
197 self.tr("All Differences"), self.__diffAll) |
|
198 self.__diffAllAct.setToolTip(self.tr( |
|
199 "Shows the differences of all entries in a separate dialog")) |
188 |
200 |
189 self.__actionsMenu.addSeparator() |
201 self.__actionsMenu.addSeparator() |
190 |
202 |
191 self.__revertAct = self.__actionsMenu.addAction( |
203 self.__revertAct = self.__actionsMenu.addAction( |
192 UI.PixmapCache.getIcon("vcsRevert"), |
204 UI.PixmapCache.getIcon("vcsRevert"), |
209 self.__editAct = self.__actionsMenu.addAction( |
221 self.__editAct = self.__actionsMenu.addAction( |
210 UI.PixmapCache.getIcon("open"), |
222 UI.PixmapCache.getIcon("open"), |
211 self.tr("Edit Conflict"), self.__editConflict) |
223 self.tr("Edit Conflict"), self.__editConflict) |
212 self.__editAct.setToolTip(self.tr( |
224 self.__editAct.setToolTip(self.tr( |
213 "Edit the selected conflicting file")) |
225 "Edit the selected conflicting file")) |
214 # TODO: add menu entry for 'Conflict Resolved' |
226 self.__resolvedAct = self.__actionsMenu.addAction( |
|
227 UI.PixmapCache.getIcon("vcsResolved"), |
|
228 self.tr("Conflict Resolved"), self.__conflictResolved) |
|
229 self.__resolvedAct.setToolTip(self.tr( |
|
230 "Mark the selected conflicting file as resolved")) |
215 |
231 |
216 self.__actionsButton.setMenu(self.__actionsMenu) |
232 self.__actionsButton.setMenu(self.__actionsMenu) |
217 |
233 |
218 @pyqtSlot() |
234 @pyqtSlot() |
219 def __projectOpened(self): |
235 def __projectOpened(self): |
399 Private slot to deselect all entries from commit. |
415 Private slot to deselect all entries from commit. |
400 """ |
416 """ |
401 self.__setCheckMark(False) |
417 self.__setCheckMark(False) |
402 |
418 |
403 @pyqtSlot() |
419 @pyqtSlot() |
404 def __addUntracked(self): |
420 def __addUntracked(self, allItems=False): |
405 """ |
421 """ |
406 Private slot to add the selected untracked entries. |
422 Private slot to add the selected untracked entries. |
407 """ |
423 |
408 projectPath = self.__project.getProjectPath() |
424 @param allItems flag indicating to show the differences of all files |
409 |
425 (defaults to False) |
410 names = [os.path.join(projectPath, itm.text()) |
426 @type bool (optional) |
411 for itm in self.__getUnversionedItems()] |
427 """ |
|
428 projectPath = self.__project.getProjectPath() |
|
429 |
|
430 names = [ |
|
431 os.path.join(projectPath, itm.text()) |
|
432 for itm in self.__getUnversionedItems() |
|
433 ] if allItems else [ |
|
434 os.path.join(projectPath, itm.text()) |
|
435 for itm in self.__getSelectedUnversionedItems() |
|
436 ] |
412 |
437 |
413 if not names: |
438 if not names: |
414 EricMessageBox.information( |
439 EricMessageBox.information( |
415 self, |
440 self, |
416 self.tr("Add"), |
441 self.tr("Add"), |
420 |
445 |
421 vcs = self.__project.getVcs() |
446 vcs = self.__project.getVcs() |
422 vcs and vcs.vcsAdd(names) |
447 vcs and vcs.vcsAdd(names) |
423 self.__reload() |
448 self.__reload() |
424 |
449 |
|
450 @pyqtSlot(QListWidgetItem) |
|
451 def __itemDoubleClicked(self, itm): |
|
452 """ |
|
453 Private slot to handle double clicking an item. |
|
454 |
|
455 @param itm reference to the double clicked item |
|
456 @type QListWidgetItem |
|
457 """ |
|
458 projectPath = self.__project.getProjectPath() |
|
459 |
|
460 if itm.data(self.StatusDataRole) in "MZ": |
|
461 # modified and conflicting items |
|
462 name = os.path.join(projectPath, itm.text()) |
|
463 vcs = self.__project.getVcs() |
|
464 vcs and vcs.vcsDiff(name) |
|
465 |
425 ########################################################################### |
466 ########################################################################### |
426 ## Menu handling methods |
467 ## Menu handling methods |
427 ########################################################################### |
468 ########################################################################### |
428 |
469 |
429 def __showActionsMenu(self): |
470 def __showActionsMenu(self): |
430 """ |
471 """ |
431 Private slot to prepare the actions button menu before it is shown. |
472 Private slot to prepare the actions button menu before it is shown. |
432 """ |
473 """ |
433 modified = len(self.__getSelectedModifiedItems()) |
474 modified = len(self.__getSelectedModifiedItems()) |
434 unversioned = len(self.__getUnversionedItems()) |
475 allModified = len(self.__getModifiedItems()) |
|
476 unversioned = len(self.__getSelectedUnversionedItems()) |
|
477 allUnversioned = len(self.__getUnversionedItems()) |
435 missing = len(self.__getMissingItems()) |
478 missing = len(self.__getMissingItems()) |
436 commitable = len(self.__getCommitableItems()) |
479 commitable = len(self.__getCommitableItems()) |
437 commitableUnselected = len(self.__getCommitableUnselectedItems()) |
480 commitableUnselected = len(self.__getCommitableUnselectedItems()) |
438 conflicting = len(self.__getSelectedConflictingItems()) |
481 conflicting = len(self.__getSelectedConflictingItems()) |
439 |
482 |
440 self.__addAct.setEnabled(unversioned) |
483 self.__addAct.setEnabled(unversioned) |
|
484 self.__addAllAct.setEnabled(allUnversioned) |
441 self.__diffAct.setEnabled(modified) |
485 self.__diffAct.setEnabled(modified) |
442 self.__sbsDiffAct.setEnabled(modified == 1) |
486 self.__sbsDiffAct.setEnabled(modified == 1) |
|
487 self.__diffAllAct.setEnabled(allModified) |
443 self.__revertAct.setEnabled(modified) |
488 self.__revertAct.setEnabled(modified) |
444 self.__forgetAct.setEnabled(missing) |
489 self.__forgetAct.setEnabled(missing) |
445 self.__restoreAct.setEnabled(missing) |
490 self.__restoreAct.setEnabled(missing) |
446 self.__commitAct.setEnabled(commitable) |
491 self.__commitAct.setEnabled(commitable) |
447 self.__commitSelectAct.setEnabled(commitableUnselected) |
492 self.__commitSelectAct.setEnabled(commitableUnselected) |
448 self.__commitDeselectAct.setEnabled(commitable) |
493 self.__commitDeselectAct.setEnabled(commitable) |
449 self.__editAct.setEnabled(conflicting == 1) |
494 self.__editAct.setEnabled(conflicting == 1) |
|
495 self.__resolvedAct.setEnabled(conflicting) |
450 |
496 |
451 def __getCommitableItems(self): |
497 def __getCommitableItems(self): |
452 """ |
498 """ |
453 Private method to retrieve all entries the user wants to commit. |
499 Private method to retrieve all entries the user wants to commit. |
454 |
500 |
539 """ |
600 """ |
540 return [itm for itm in self.__statusList.selectedItems() |
601 return [itm for itm in self.__statusList.selectedItems() |
541 if itm.data(self.StatusDataRole) == "Z"] |
602 if itm.data(self.StatusDataRole) == "Z"] |
542 |
603 |
543 @pyqtSlot() |
604 @pyqtSlot() |
544 def __diff(self): |
605 def __addAllUntracked(self): |
545 """ |
606 """ |
546 Private slot to handle the Diff action menu entry. |
607 Private slot to handle the Add All action menu entry. |
|
608 """ |
|
609 self.__addUntracked(allItems=True) |
|
610 |
|
611 @pyqtSlot() |
|
612 def __diff(self, allItems=False): |
|
613 """ |
|
614 Private slot to handle the Differences action menu entry. |
|
615 |
|
616 @param allItems flag indicating to show the differences of all files |
|
617 (defaults to False) |
|
618 @type bool (optional) |
|
619 """ |
|
620 projectPath = self.__project.getProjectPath() |
|
621 |
|
622 names = [ |
|
623 os.path.join(projectPath, itm.text()) |
|
624 for itm in self.__getModifiedItems() |
|
625 ] if allItems else [ |
|
626 os.path.join(projectPath, itm.text()) |
|
627 for itm in self.__getSelectedModifiedItems() |
|
628 ] |
|
629 if not names: |
|
630 EricMessageBox.information( |
|
631 self, |
|
632 self.tr("Differences"), |
|
633 self.tr("""There are no uncommitted changes""" |
|
634 """ available/selected.""")) |
|
635 return |
|
636 |
|
637 vcs = self.__project.getVcs() |
|
638 vcs and vcs.vcsDiff(names) |
|
639 |
|
640 @pyqtSlot() |
|
641 def __diffAll(self): |
|
642 """ |
|
643 Private slot to handle the All Differences action menu entry. |
|
644 """ |
|
645 self.__diff(allItems=True) |
|
646 |
|
647 @pyqtSlot() |
|
648 def __sbsDiff(self): |
|
649 """ |
|
650 Private slot to handle the Side-By-Side Differences action menu entry. |
547 """ |
651 """ |
548 projectPath = self.__project.getProjectPath() |
652 projectPath = self.__project.getProjectPath() |
549 |
653 |
550 names = [os.path.join(projectPath, itm.text()) |
654 names = [os.path.join(projectPath, itm.text()) |
551 for itm in self.__getSelectedModifiedItems()] |
655 for itm in self.__getSelectedModifiedItems()] |
552 if not names: |
656 if not names: |
553 EricMessageBox.information( |
657 EricMessageBox.information( |
554 self, |
658 self, |
555 self.tr("Differences"), |
659 self.tr("Differences Side-By-Side"), |
556 self.tr("""There are no uncommitted changes""" |
660 self.tr("""There are no uncommitted changes""" |
557 """ available/selected.""")) |
661 """ available/selected.""")) |
558 return |
662 return |
|
663 elif len(names) > 1: |
|
664 EricMessageBox.information( |
|
665 self, |
|
666 self.tr("Differences Side-By-Side"), |
|
667 self.tr("""Only one file with uncommitted changes""" |
|
668 """ must be selected.""")) |
|
669 return |
559 |
670 |
560 vcs = self.__project.getVcs() |
671 vcs = self.__project.getVcs() |
561 vcs and vcs.vcsDiff(names) |
672 vcs and vcs.vcsSbsDiff(names[0]) |
562 |
673 |
563 @pyqtSlot() |
674 @pyqtSlot() |
564 def __sbsDiff(self): |
675 def __revert(self): |
565 """ |
676 """ |
566 Private slot to handle the Side-By-Side Diff action menu entry. |
677 Private slot to handle the Revert action menu entry. |
567 """ |
678 """ |
568 projectPath = self.__project.getProjectPath() |
679 projectPath = self.__project.getProjectPath() |
569 |
680 |
570 names = [os.path.join(projectPath, itm.text()) |
681 names = [os.path.join(projectPath, itm.text()) |
571 for itm in self.__getSelectedModifiedItems()] |
682 for itm in self.__getSelectedModifiedItems()] |
572 if not names: |
683 if not names: |
573 EricMessageBox.information( |
684 EricMessageBox.information( |
574 self, |
685 self, |
575 self.tr("Differences Side-By-Side"), |
|
576 self.tr("""There are no uncommitted changes""" |
|
577 """ available/selected.""")) |
|
578 return |
|
579 elif len(names) > 1: |
|
580 EricMessageBox.information( |
|
581 self, |
|
582 self.tr("Differences Side-By-Side"), |
|
583 self.tr("""Only one file with uncommitted changes""" |
|
584 """ must be selected.""")) |
|
585 return |
|
586 |
|
587 vcs = self.__project.getVcs() |
|
588 vcs and vcs.vcsSbsDiff(names[0]) |
|
589 |
|
590 def __revert(self): |
|
591 """ |
|
592 Private slot to handle the Revert action menu entry. |
|
593 """ |
|
594 projectPath = self.__project.getProjectPath() |
|
595 |
|
596 names = [os.path.join(projectPath, itm.text()) |
|
597 for itm in self.__getSelectedModifiedItems()] |
|
598 if not names: |
|
599 EricMessageBox.information( |
|
600 self, |
|
601 self.tr("Revert"), |
686 self.tr("Revert"), |
602 self.tr("""There are no uncommitted changes""" |
687 self.tr("""There are no uncommitted changes""" |
603 """ available/selected.""")) |
688 """ available/selected.""")) |
604 return |
689 return |
605 |
690 |
606 vcs = self.__project.getVcs() |
691 vcs = self.__project.getVcs() |
607 vcs and vcs.vcsRevert(names) |
692 vcs and vcs.vcsRevert(names) |
608 self.__reload() |
693 self.__reload() |
609 |
694 |
|
695 @pyqtSlot() |
610 def __forgetMissing(self): |
696 def __forgetMissing(self): |
611 """ |
697 """ |
612 Private slot to handle the Forget action menu entry. |
698 Private slot to handle the Forget action menu entry. |
613 """ |
699 """ |
614 projectPath = self.__project.getProjectPath() |
700 projectPath = self.__project.getProjectPath() |
645 |
732 |
646 vcs = self.__project.getVcs() |
733 vcs = self.__project.getVcs() |
647 vcs and vcs.vcsRevert(names) |
734 vcs and vcs.vcsRevert(names) |
648 self.__reload() |
735 self.__reload() |
649 |
736 |
|
737 @pyqtSlot() |
650 def __editConflict(self): |
738 def __editConflict(self): |
651 """ |
739 """ |
652 Private slot to handle the Edit Conflict action menu entry. |
740 Private slot to handle the Edit Conflict action menu entry. |
653 """ |
741 """ |
654 projectPath = self.__project.getProjectPath() |
742 projectPath = self.__project.getProjectPath() |
655 |
743 |
656 itm = self.__getSelectedConflictingItems()[0] |
744 itm = self.__getSelectedConflictingItems()[0] |
657 filename = os.path.join(projectPath, itm.text()) |
745 filename = os.path.join(projectPath, itm.text()) |
658 if Utilities.MimeTypes.isTextFile(filename): |
746 if Utilities.MimeTypes.isTextFile(filename): |
659 self.__vm.getEditor(filename) |
747 self.__vm.getEditor(filename) |
|
748 |
|
749 @pyqtSlot() |
|
750 def __conflictResolved(self): |
|
751 """ |
|
752 Private slot to handle the Conflict Resolved action menu entry. |
|
753 """ |
|
754 projectPath = self.__project.getProjectPath() |
|
755 |
|
756 names = [os.path.join(projectPath, itm.text()) |
|
757 for itm in self.__getSelectedConflictingItems()] |
|
758 if not names: |
|
759 EricMessageBox.information( |
|
760 self, |
|
761 self.tr("Conflict Resolved"), |
|
762 self.tr("""There are no conflicting entries""" |
|
763 """ available/selected.""")) |
|
764 return |
|
765 |
|
766 vcs = self.__project.getVcs() |
|
767 vcs and vcs.vcsResolved(names) |
|
768 self.__reload() |