427 if protocol in self.__minimumProtocols: |
427 if protocol in self.__minimumProtocols: |
428 itm = QTreeWidgetItem(self.protocolsList, [ |
428 itm = QTreeWidgetItem(self.protocolsList, [ |
429 host, |
429 host, |
430 self.__minimumProtocols[protocol] |
430 self.__minimumProtocols[protocol] |
431 ]) |
431 ]) |
432 itm.setData(1, Qt.UserRole, protocol) |
432 itm.setData(1, Qt.ItemDataRole.UserRole, protocol) |
433 |
433 |
434 self.__finalizeFingerprintsColumns() |
434 self.__finalizeFingerprintsColumns() |
435 self.__finalizeProtocolsColumns() |
435 self.__finalizeProtocolsColumns() |
436 |
436 |
437 @pyqtSlot() |
437 @pyqtSlot() |
521 def on_fpAddButton_clicked(self): |
521 def on_fpAddButton_clicked(self): |
522 """ |
522 """ |
523 Private slot to add a fingerprints entry. |
523 Private slot to add a fingerprints entry. |
524 """ |
524 """ |
525 dlg = HgUserConfigHostFingerprintDialog(self, version=self.__version) |
525 dlg = HgUserConfigHostFingerprintDialog(self, version=self.__version) |
526 if dlg.exec() == QDialog.Accepted: |
526 if dlg.exec() == QDialog.DialogCode.Accepted: |
527 host, fingerprint = dlg.getData() |
527 host, fingerprint = dlg.getData() |
528 itm = QTreeWidgetItem(self.fingerprintsList, [host, fingerprint]) |
528 itm = QTreeWidgetItem(self.fingerprintsList, [host, fingerprint]) |
529 self.__finalizeFingerprintsColumns() |
529 self.__finalizeFingerprintsColumns() |
530 self.fingerprintsList.setCurrentItem(itm) |
530 self.fingerprintsList.setCurrentItem(itm) |
531 self.fingerprintsList.scrollToItem(itm) |
531 self.fingerprintsList.scrollToItem(itm) |
558 if itm is not None: |
558 if itm is not None: |
559 host = itm.text(0) |
559 host = itm.text(0) |
560 fingerprint = itm.text(1) |
560 fingerprint = itm.text(1) |
561 dlg = HgUserConfigHostFingerprintDialog(self, host, fingerprint, |
561 dlg = HgUserConfigHostFingerprintDialog(self, host, fingerprint, |
562 version=self.__version) |
562 version=self.__version) |
563 if dlg.exec() == QDialog.Accepted: |
563 if dlg.exec() == QDialog.DialogCode.Accepted: |
564 host, fingerprint = dlg.getData() |
564 host, fingerprint = dlg.getData() |
565 itm.setText(0, host) |
565 itm.setText(0, host) |
566 itm.setText(1, fingerprint) |
566 itm.setText(1, fingerprint) |
567 self.__finalizeFingerprintsColumns() |
567 self.__finalizeFingerprintsColumns() |
568 self.fingerprintsList.scrollToItem(itm) |
568 self.fingerprintsList.scrollToItem(itm) |
571 """ |
571 """ |
572 Private method to resize and sort the host fingerprints columns. |
572 Private method to resize and sort the host fingerprints columns. |
573 """ |
573 """ |
574 for col in range(self.fingerprintsList.columnCount()): |
574 for col in range(self.fingerprintsList.columnCount()): |
575 self.fingerprintsList.resizeColumnToContents(col) |
575 self.fingerprintsList.resizeColumnToContents(col) |
576 self.fingerprintsList.sortItems(0, Qt.AscendingOrder) |
576 self.fingerprintsList.sortItems(0, Qt.SortOrder.AscendingOrder) |
577 |
577 |
578 def __updateFingerprintsButtons(self): |
578 def __updateFingerprintsButtons(self): |
579 """ |
579 """ |
580 Private slot to update the host fingerprints edit buttons. |
580 Private slot to update the host fingerprints edit buttons. |
581 """ |
581 """ |
606 """ |
606 """ |
607 minimumProtocols = {} |
607 minimumProtocols = {} |
608 for row in range(self.protocolsList.topLevelItemCount()): |
608 for row in range(self.protocolsList.topLevelItemCount()): |
609 itm = self.protocolsList.topLevelItem(row) |
609 itm = self.protocolsList.topLevelItem(row) |
610 host = itm.text(0) |
610 host = itm.text(0) |
611 minimumProtocol = itm.data(1, Qt.UserRole) |
611 minimumProtocol = itm.data(1, Qt.ItemDataRole.UserRole) |
612 minimumProtocols[host] = minimumProtocol |
612 minimumProtocols[host] = minimumProtocol |
613 return minimumProtocols |
613 return minimumProtocols |
614 |
614 |
615 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
615 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
616 def on_protocolsList_currentItemChanged(self, current, previous): |
616 def on_protocolsList_currentItemChanged(self, current, previous): |
629 """ |
629 """ |
630 Private slot to add a minimum protocol entry. |
630 Private slot to add a minimum protocol entry. |
631 """ |
631 """ |
632 dlg = HgUserConfigHostMinimumProtocolDialog(self.__minimumProtocols, |
632 dlg = HgUserConfigHostMinimumProtocolDialog(self.__minimumProtocols, |
633 self) |
633 self) |
634 if dlg.exec() == QDialog.Accepted: |
634 if dlg.exec() == QDialog.DialogCode.Accepted: |
635 host, protocol = dlg.getData() |
635 host, protocol = dlg.getData() |
636 itm = QTreeWidgetItem(self.protocolsList, [ |
636 itm = QTreeWidgetItem(self.protocolsList, [ |
637 host, |
637 host, |
638 self.__minimumProtocols[protocol] |
638 self.__minimumProtocols[protocol] |
639 ]) |
639 ]) |
640 itm.setData(1, Qt.UserRole, protocol) |
640 itm.setData(1, Qt.ItemDataRole.UserRole, protocol) |
641 self.__finalizeProtocolsColumns() |
641 self.__finalizeProtocolsColumns() |
642 self.protocolsList.setCurrentItem(itm) |
642 self.protocolsList.setCurrentItem(itm) |
643 self.protocolsList.scrollToItem(itm) |
643 self.protocolsList.scrollToItem(itm) |
644 |
644 |
645 @pyqtSlot() |
645 @pyqtSlot() |
667 Private slot to edit the current minimum protocol item. |
667 Private slot to edit the current minimum protocol item. |
668 """ |
668 """ |
669 itm = self.protocolsList.currentItem() |
669 itm = self.protocolsList.currentItem() |
670 if itm is not None: |
670 if itm is not None: |
671 host = itm.text(0) |
671 host = itm.text(0) |
672 protocol = itm.data(1, Qt.UserRole) |
672 protocol = itm.data(1, Qt.ItemDataRole.UserRole) |
673 dlg = HgUserConfigHostMinimumProtocolDialog( |
673 dlg = HgUserConfigHostMinimumProtocolDialog( |
674 self.__minimumProtocols, self, host, protocol) |
674 self.__minimumProtocols, self, host, protocol) |
675 if dlg.exec() == QDialog.Accepted: |
675 if dlg.exec() == QDialog.DialogCode.Accepted: |
676 host, protocol = dlg.getData() |
676 host, protocol = dlg.getData() |
677 itm.setText(0, host) |
677 itm.setText(0, host) |
678 itm.setText(1, self.__minimumProtocols[protocol]) |
678 itm.setText(1, self.__minimumProtocols[protocol]) |
679 itm.setData(1, Qt.UserRole, protocol) |
679 itm.setData(1, Qt.ItemDataRole.UserRole, protocol) |
680 self.__finalizeProtocolsColumns() |
680 self.__finalizeProtocolsColumns() |
681 self.protocolsList.scrollToItem(itm) |
681 self.protocolsList.scrollToItem(itm) |
682 |
682 |
683 def __finalizeProtocolsColumns(self): |
683 def __finalizeProtocolsColumns(self): |
684 """ |
684 """ |
685 Private method to resize and sort the host fingerprints columns. |
685 Private method to resize and sort the host fingerprints columns. |
686 """ |
686 """ |
687 for col in range(self.protocolsList.columnCount()): |
687 for col in range(self.protocolsList.columnCount()): |
688 self.protocolsList.resizeColumnToContents(col) |
688 self.protocolsList.resizeColumnToContents(col) |
689 self.protocolsList.sortItems(0, Qt.AscendingOrder) |
689 self.protocolsList.sortItems(0, Qt.SortOrder.AscendingOrder) |
690 |
690 |
691 def __updateProtocolsButtons(self): |
691 def __updateProtocolsButtons(self): |
692 """ |
692 """ |
693 Private slot to update the host minimum protocol edit buttons. |
693 Private slot to update the host minimum protocol edit buttons. |
694 """ |
694 """ |
717 yesDefault=True) |
717 yesDefault=True) |
718 if yes: |
718 if yes: |
719 self.writeUserConfig() |
719 self.writeUserConfig() |
720 |
720 |
721 self.__editor = MiniEditor(cfgFile, "Properties", self) |
721 self.__editor = MiniEditor(cfgFile, "Properties", self) |
722 self.__editor.setWindowModality(Qt.WindowModal) |
722 self.__editor.setWindowModality(Qt.WindowModality.WindowModal) |
723 self.__editor.installEventFilter(self) |
723 self.__editor.installEventFilter(self) |
724 self.__editor.show() |
724 self.__editor.show() |
725 |
725 |
726 def eventFilter(self, watched, event): |
726 def eventFilter(self, watched, event): |
727 """ |
727 """ |
732 @param event event to be handled |
732 @param event event to be handled |
733 @type QEvent |
733 @type QEvent |
734 @return flag indicating, if we handled the event |
734 @return flag indicating, if we handled the event |
735 @rtype bool |
735 @rtype bool |
736 """ |
736 """ |
737 if watched is self.__editor and event.type() == QEvent.Close: |
737 if watched is self.__editor and event.type() == QEvent.Type.Close: |
738 self.__editor.closeEvent(event) |
738 self.__editor.closeEvent(event) |
739 if event.isAccepted(): |
739 if event.isAccepted(): |
740 self.__clearDialog() |
740 self.__clearDialog() |
741 self.readUserConfig() |
741 self.readUserConfig() |
742 return True |
742 return True |