598 "Mountain", |
599 "Mountain", |
599 "Pacific", |
600 "Pacific", |
600 "Samoa", |
601 "Samoa", |
601 ], |
602 ], |
602 } |
603 } |
603 |
604 |
604 def __init__(self, parent=None): |
605 def __init__(self, parent=None): |
605 """ |
606 """ |
606 Constructor |
607 Constructor |
607 |
608 |
608 @param parent reference to the parent widget |
609 @param parent reference to the parent widget |
609 @type QWidget |
610 @type QWidget |
610 """ |
611 """ |
611 super().__init__(parent) |
612 super().__init__(parent) |
612 self.setupUi(self) |
613 self.setupUi(self) |
613 |
614 |
614 self.buttonBox.button( |
615 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
615 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
616 |
616 |
|
617 self.regionCombo.addItems([" "] + sorted(self.Timezones.keys())) |
617 self.regionCombo.addItems([" "] + sorted(self.Timezones.keys())) |
618 |
618 |
619 def __updateOK(self): |
619 def __updateOK(self): |
620 """ |
620 """ |
621 Private method to update the OK button. |
621 Private method to update the OK button. |
622 """ |
622 """ |
623 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
623 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
624 bool(self.regionCombo.currentText()) and |
624 bool(self.regionCombo.currentText()) |
625 len(self.cityList.selectedItems()) == 1 |
625 and len(self.cityList.selectedItems()) == 1 |
626 ) |
626 ) |
627 |
627 |
628 @pyqtSlot(str) |
628 @pyqtSlot(str) |
629 def on_regionCombo_currentTextChanged(self, region): |
629 def on_regionCombo_currentTextChanged(self, region): |
630 """ |
630 """ |
631 Private slot handling the selection of a time zone region. |
631 Private slot handling the selection of a time zone region. |
632 |
632 |
633 @param region selected region |
633 @param region selected region |
634 @type str |
634 @type str |
635 """ |
635 """ |
636 self.cityList.clear() |
636 self.cityList.clear() |
637 if region in self.Timezones: |
637 if region in self.Timezones: |
638 self.cityList.addItems(sorted(self.Timezones[region])) |
638 self.cityList.addItems(sorted(self.Timezones[region])) |
639 |
639 |
640 self.__updateOK() |
640 self.__updateOK() |
641 |
641 |
642 @pyqtSlot() |
642 @pyqtSlot() |
643 def on_cityList_itemSelectionChanged(self): |
643 def on_cityList_itemSelectionChanged(self): |
644 """ |
644 """ |
645 Private slot handling a change of the city selection. |
645 Private slot handling a change of the city selection. |
646 """ |
646 """ |
647 self.__updateOK() |
647 self.__updateOK() |
648 |
648 |
649 def getData(self): |
649 def getData(self): |
650 """ |
650 """ |
651 Public method to retrieve the data. |
651 Public method to retrieve the data. |
652 |
652 |
653 @return selected time zone |
653 @return selected time zone |
654 @rtype str |
654 @rtype str |
655 """ |
655 """ |
656 if (self.regionCombo.currentText() and |
656 if self.regionCombo.currentText() and len(self.cityList.selectedItems()) == 1: |
657 len(self.cityList.selectedItems()) == 1): |
|
658 return "{0}/{1}".format( |
657 return "{0}/{1}".format( |
659 self.regionCombo.currentText(), |
658 self.regionCombo.currentText(), self.cityList.selectedItems()[0].text() |
660 self.cityList.selectedItems()[0].text() |
|
661 ) |
659 ) |
662 else: |
660 else: |
663 return "" |
661 return "" |
664 |
662 |
665 @staticmethod |
663 @staticmethod |
666 def getTimezone(parent=None): |
664 def getTimezone(parent=None): |
667 """ |
665 """ |
668 Public static method to select a time zone. |
666 Public static method to select a time zone. |
669 |
667 |
670 @param parent reference to the parent widget |
668 @param parent reference to the parent widget |
671 @type QWidget |
669 @type QWidget |
672 @return tuple of selected time zone and flag indicating the acceptance |
670 @return tuple of selected time zone and flag indicating the acceptance |
673 state |
671 state |
674 @rtype tuple of (str, bool) |
672 @rtype tuple of (str, bool) |