Exemple #1
0
class ImpactEditor(QDialog, MapperMixin):
    '''
    Dialog for specifying VODP impact.
    '''

    #See EntityBrowser base class for details on implementation.
    recordSelected = pyqtSignal(int)

    def __init__(self, parent=None, state=None, dataModel=Impact):
        QDialog.__init__(self, parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        MapperMixin.__init__(self, dataModel)

        self.resize(300, 200)
        self.setWindowTitle(
            QApplication.translate("ImpactEditor", "Project Impact Editor"))
        self.gridLayout = QGridLayout(self)
        self.gridLayout.setMargin(10)

        self.vlNotification = QVBoxLayout()
        self.vlNotification.setMargin(0)
        self.gridLayout.addLayout(self.vlNotification, 0, 0, 1, 2)

        #Add vertical layout for the notification bar
        self.setNotificationLayout(self.vlNotification)

        self.lblImpact = QLabel(self)
        self.lblImpact.setText(
            QApplication.translate("ImpactEditor", "Socio-Economic Impact"))
        self.gridLayout.addWidget(self.lblImpact, 1, 0, 1, 1)

        self.cboImpact = ComboBoxWithOther(self)
        self.cboImpact.lineEdit().setMaxLength(30)
        self.gridLayout.addWidget(self.cboImpact, 1, 1, 1, 1)

        self.lblRank = QLabel(self)
        self.lblRank.setText(QApplication.translate("ImpactEditor", "Rank"))
        self.gridLayout.addWidget(self.lblRank, 2, 0, 1, 1)

        self.cboRank = QComboBox(self)
        self.cboRank.setMinimumSize(QSize(0, 30))
        self.gridLayout.addWidget(self.cboRank, 2, 1, 1, 1)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Save)
        self.gridLayout.addWidget(self.buttonBox, 3, 0, 1, 2)

        #Load combobox options
        loadComboSelections(self.cboImpact.comboBox(),
                            CheckSocioEconomicImpact)
        self.cboRank.addItem("")
        self.cboRank.addItem(
            QApplication.translate("ImpactEditor", "3 (Highest)"), 3)
        self.cboRank.addItem("2", 2)
        self.cboRank.addItem(
            QApplication.translate("ImpactEditor", "1 (Lowest)"), 1)

        #Configure mappings
        self.addMapping("itemID",self.cboImpact.comboBox(),True, \
                        pseudoname=QApplication.translate("ImpactEditor","Priority Service"))
        self.addMapping("OtherItem", self.cboImpact.lineEdit())
        self.addMapping("Rank", self.cboRank, True)

        #Connect signals
        self.connect(self.buttonBox, SIGNAL("accepted()"), self.submit)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.cancel)

    def setCellFormatters(self, formattermapping):
        '''
        Not implemented.
        '''
        pass

    def preSaveUpdate(self):
        '''
        Base class override for validating if Other option has been specified and value entered.
        '''
        isValid, msg = self.cboImpact.validate()
        if not isValid:
            self._notifBar.clear()
            self._notifBar.insertErrorNotification(msg)

        return isValid

    def postSaveUpdate(self, dbmodel):
        '''
        Base class override for sending the record select signal to receivers
        and clear input controls.
        '''
        self.recordSelected.emit(dbmodel.id)
class PriorityServiceEditor(QDialog, MapperMixin):
    """
    Dialog for specifying a farmer's priority.
    """

    # See EntityBrowser base class for details on implementation.
    recordSelected = pyqtSignal(int)

    def __init__(self, parent=None, state=None, dataModel=Priority):
        QDialog.__init__(self, parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        MapperMixin.__init__(self, dataModel)

        self.resize(290, 200)
        self.setWindowTitle(QApplication.translate("PriorityServiceEditor", "Priority Service Editor"))
        self.gridLayout = QGridLayout(self)
        self.gridLayout.setMargin(10)

        self.vlNotification = QVBoxLayout()
        self.vlNotification.setMargin(0)
        self.gridLayout.addLayout(self.vlNotification, 0, 0, 1, 2)

        # Add vertical layout for the notification bar
        self.setNotificationLayout(self.vlNotification)

        self.lblPService = QLabel(self)
        self.lblPService.setText(QApplication.translate("PriorityServiceEditor", "Service"))
        self.gridLayout.addWidget(self.lblPService, 1, 0, 1, 1)

        self.cboPService = ComboBoxWithOther(self)
        self.cboPService.lineEdit().setMaxLength(30)
        self.gridLayout.addWidget(self.cboPService, 1, 1, 1, 1)

        self.lblRank = QLabel(self)
        self.lblRank.setText(QApplication.translate("PriorityServiceEditor", "Rank"))
        self.gridLayout.addWidget(self.lblRank, 2, 0, 1, 1)

        self.cboRank = QComboBox(self)
        self.cboRank.setMinimumSize(QSize(0, 30))
        self.gridLayout.addWidget(self.cboRank, 2, 1, 1, 1)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Save)
        self.gridLayout.addWidget(self.buttonBox, 3, 0, 1, 2)

        # Load combobox options
        loadComboSelections(self.cboPService.comboBox(), CheckInputService)
        self.cboRank.addItem("")
        self.cboRank.addItem(QApplication.translate("PriorityServiceEditor", "3 (Highest)"), 3)
        self.cboRank.addItem("2", 2)
        self.cboRank.addItem(QApplication.translate("PriorityServiceEditor", "1 (Lowest)"), 1)

        # Configure mappings
        self.addMapping(
            "itemID",
            self.cboPService.comboBox(),
            True,
            pseudoname=QApplication.translate("PriorityServiceEditor", "Priority Service"),
        )
        self.addMapping("OtherItem", self.cboPService.lineEdit())
        self.addMapping("Rank", self.cboRank, True)

        # Connect signals
        self.connect(self.buttonBox, SIGNAL("accepted()"), self.submit)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.cancel)

    def setCellFormatters(self, formattermapping):
        """
        Not implemented.
        """
        pass

    def preSaveUpdate(self):
        """
        Base class override for validating if Other option has been specified and value entered.
        """
        isValid, msg = self.cboPService.validate()
        if not isValid:
            self._notifBar.clear()
            self._notifBar.insertErrorNotification(msg)

        return isValid

    def postSaveUpdate(self, dbmodel):
        """
        Base class override for sending the record select signal to receivers
        and clear input controls.
        """
        self.recordSelected.emit(dbmodel.id)

    # class ImpactEditor(QDialog,MapperMixin):
    #     '''
    #     Dialog for specifying VODP impact.
    #     '''
    #
    #     #See EntityBrowser base class for details on implementation.
    #     recordSelected = pyqtSignal(int)
    #
    #     def __init__(self,parent=None, state = None, dataModel=Impact):
    #         QDialog.__init__(self,parent)
    #         self.setAttribute(Qt.WA_DeleteOnClose)
    #         MapperMixin.__init__(self, dataModel)
    #
    #         self.resize(300,200)
    #         self.setWindowTitle(QApplication.translate("ImpactEditor","Project Impact Editor"))
    #         self.gridLayout = QGridLayout(self)
    #         self.gridLayout.setMargin(10)
    #
    #         self.vlNotification = QVBoxLayout()
    #         self.vlNotification.setMargin(0)
    #         self.gridLayout.addLayout(self.vlNotification,0,0,1,2)
    #
    #         #Add vertical layout for the notification bar
    #         self.setNotificationLayout(self.vlNotification)
    #
    #         self.lblImpact = QLabel(self)
    #         self.lblImpact.setText(QApplication.translate("ImpactEditor","Socio-Economic Impact"))
    #         self.gridLayout.addWidget(self.lblImpact,1,0,1,1)
    #
    #         self.cboImpact = ComboBoxWithOther(self)
    #         self.cboImpact.lineEdit().setMaxLength(30)
    #         self.gridLayout.addWidget(self.cboImpact,1,1,1,1)
    #
    #         self.lblRank = QLabel(self)
    #         self.lblRank.setText(QApplication.translate("ImpactEditor","Rank"))
    #         self.gridLayout.addWidget(self.lblRank,2,0,1,1)
    #
    #         self.cboRank = QComboBox(self)
    #         self.cboRank.setMinimumSize(QSize(0, 30))
    #         self.gridLayout.addWidget(self.cboRank,2,1,1,1)
    #
    #         self.buttonBox = QDialogButtonBox(self)
    #         self.buttonBox.setOrientation(Qt.Horizontal)
    #         self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Save)
    #         self.gridLayout.addWidget(self.buttonBox,3,0,1,2)
    #
    #         #Load combobox options
    #         loadComboSelections(self.cboImpact.comboBox(),CheckSocioEconomicImpact)
    #         self.cboRank.addItem("")
    #         self.cboRank.addItem(QApplication.translate("ImpactEditor","3 (Highest)"), 3)
    #         self.cboRank.addItem("2", 2)
    #         self.cboRank.addItem(QApplication.translate("ImpactEditor","1 (Lowest)"), 1)
    #
    #         #Configure mappings
    #         self.addMapping("itemID",self.cboImpact.comboBox(),True, \
    #                         pseudoname=QApplication.translate("ImpactEditor","Priority Service"))
    #         self.addMapping("OtherItem",self.cboImpact.lineEdit())
    #         self.addMapping("Rank",self.cboRank,True)
    #
    #         #Connect signals
    #         self.connect(self.buttonBox, SIGNAL("accepted()"),self.submit)
    #         self.connect(self.buttonBox, SIGNAL("rejected()"),self.cancel)

    def setCellFormatters(self, formattermapping):
        """
        Not implemented.
        """
        pass

    def preSaveUpdate(self):
        """
        Base class override for validating if Other option has been specified and value entered.
        """
        isValid, msg = self.cboImpact.validate()
        if not isValid:
            self._notifBar.clear()
            self._notifBar.insertErrorNotification(msg)

        return isValid

    def postSaveUpdate(self, dbmodel):
        """
        Base class override for sending the record select signal to receivers
        and clear input controls.
        """
        self.recordSelected.emit(dbmodel.id)
Exemple #3
0
class HouseholdSavingsEditor(QDialog, MapperMixin):
    '''
    Dialog for specifying household saving option.
    '''

    #See EntityBrowser base class for details on implementation.
    recordSelected = pyqtSignal(int)

    def __init__(self, parent=None, state=None, dataModel=HouseholdSaving):
        QDialog.__init__(self, parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        MapperMixin.__init__(self, dataModel)

        self.resize(290, 175)
        self.setWindowTitle(
            QApplication.translate("HouseholdSavingEditor",
                                   "Household Saving Editor"))
        self.gridLayout = QGridLayout(self)

        self.vlNotification = QVBoxLayout()
        self.vlNotification.setMargin(0)
        self.gridLayout.addLayout(self.vlNotification, 0, 0, 1, 2)

        #Add vertical layout for the notification bar
        self.setNotificationLayout(self.vlNotification)

        self.lblSavingsOption = QLabel(self)
        self.lblSavingsOption.setText(
            QApplication.translate("HouseholdIncomeEditor", "Savings Option"))
        self.gridLayout.addWidget(self.lblSavingsOption, 1, 0, 1, 1)
        self.cboSavingsOption = ComboBoxWithOther(self)
        self.cboSavingsOption.setMinimumSize(QSize(0, 30))
        self.gridLayout.addWidget(self.cboSavingsOption, 1, 1, 1, 1)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Save)
        self.gridLayout.addWidget(self.buttonBox, 3, 0, 1, 2)

        #Load saving options
        loadComboSelections(self.cboSavingsOption.comboBox(),
                            CheckSavingsOption)

        #Configure mappings
        self.addMapping("OptionID",self.cboSavingsOption.comboBox(),True, \
                        pseudoname=QApplication.translate("HouseholdSavingEditor","Saving option type"))
        self.addMapping("OtherOption", self.cboSavingsOption.lineEdit())

        #Connect signals
        self.connect(self.buttonBox, SIGNAL("accepted()"), self.submit)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.cancel)

    def setCellFormatters(self, formattermapping):
        '''
        Not implemented.
        '''
        pass

    def preSaveUpdate(self):
        '''
        Base class override for validating if Other option has been specified and value entered.
        '''
        isValid, msg = self.cboSavingsOption.validate()
        if not isValid:
            self._notifBar.clear()
            self._notifBar.insertErrorNotification(msg)

        return isValid

    def postSaveUpdate(self, dbmodel):
        '''
        Base class override for sending the record select signal to receivers.
        '''
        self.recordSelected.emit(dbmodel.id)
class HouseholdSavingsEditor(QDialog, MapperMixin):
    """
    Dialog for specifying household saving option.
    """

    # See EntityBrowser base class for details on implementation.
    recordSelected = pyqtSignal(int)

    def __init__(self, parent=None, state=None, dataModel=HouseholdSaving):
        QDialog.__init__(self, parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        MapperMixin.__init__(self, dataModel)

        self.resize(290, 175)
        self.setWindowTitle(QApplication.translate("HouseholdSavingEditor", "Household Saving Editor"))
        self.gridLayout = QGridLayout(self)

        self.vlNotification = QVBoxLayout()
        self.vlNotification.setMargin(0)
        self.gridLayout.addLayout(self.vlNotification, 0, 0, 1, 2)

        # Add vertical layout for the notification bar
        self.setNotificationLayout(self.vlNotification)

        self.lblSavingsOption = QLabel(self)
        self.lblSavingsOption.setText(QApplication.translate("HouseholdIncomeEditor", "Savings Option"))
        self.gridLayout.addWidget(self.lblSavingsOption, 1, 0, 1, 1)
        self.cboSavingsOption = ComboBoxWithOther(self)
        self.cboSavingsOption.setMinimumSize(QSize(0, 30))
        self.gridLayout.addWidget(self.cboSavingsOption, 1, 1, 1, 1)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Save)
        self.gridLayout.addWidget(self.buttonBox, 3, 0, 1, 2)

        # Load saving options
        loadComboSelections(self.cboSavingsOption.comboBox(), CheckSavingsOption)

        # Configure mappings
        self.addMapping(
            "OptionID",
            self.cboSavingsOption.comboBox(),
            True,
            pseudoname=QApplication.translate("HouseholdSavingEditor", "Saving option type"),
        )
        self.addMapping("OtherOption", self.cboSavingsOption.lineEdit())

        # Connect signals
        self.connect(self.buttonBox, SIGNAL("accepted()"), self.submit)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.cancel)

    def setCellFormatters(self, formattermapping):
        """
        Not implemented.
        """
        pass

    def preSaveUpdate(self):
        """
        Base class override for validating if Other option has been specified and value entered.
        """
        isValid, msg = self.cboSavingsOption.validate()
        if not isValid:
            self._notifBar.clear()
            self._notifBar.insertErrorNotification(msg)

        return isValid

    def postSaveUpdate(self, dbmodel):
        """
        Base class override for sending the record select signal to receivers.
        """
        self.recordSelected.emit(dbmodel.id)