Exemple #1
0
 def modifyAction(self):
     index = self.view.selectionModel().currentIndex()
     item = self.model.itemData(index)
     if item:
         dialog = VariantDataDialog(self.model.species, item, self.tax)
         if dialog.exec() == QDialog.Accepted:
             self.model.setItemData(index, dialog.value)
 def modifyAction(self):
     index = self.view.selectionModel().currentIndex()
     item = self.model.itemData(index)
     if item:
         dialog = VariantDataDialog(self.model.species, item, self.tax)
         if dialog.exec() == QDialog.Accepted:
             self.model.setItemData(index, dialog.value)
    def addAction(self):
        # first show relevant information, if necessary
        if self.model.new:
            information = VariantHintDialog()
            information.exec()

        # TODO
        index = self.model.last if self.model.current > -1 else QModelIndex()
        last = self.model.current if self.model.current > -1 else Fence.TYPE
        length = self.model.length
        count = self.model.count

        dialog = VariantDataDialog(self.model.species, tax=self.tax, last=last, index=index, count=count, length=length)
        if dialog.exec() == QDialog.Accepted:
            values = dialog.value
            item = VariantItem(values[TreeModel.NameRole], values[TreeModel.ProtectionRole].TYPE)
            setattr(item, "color", values[TreeModel.ColorRole])
            setattr(item, "plant", values[TreeModel.PlantRole])
            setattr(item, "protection", values[TreeModel.ProtectionRole])
            self.model.insertItem(item)

            # TODO
            self.model.count = dialog.count
            self.model.length = dialog.length

        # modify the create button
        if self.model.current == -1:
            buttonText = QApplication.translate("EnhancedTreeWidget", "Add protection type")       # Schutz anlegen
        elif self.model.current == Fence.TYPE:
            buttonText = QApplication.translate("EnhancedTreeWidget", "Add Fence")             # Zaun anlegen
        else:
            buttonText = QApplication.translate("EnhancedTreeWidget", "Add Tree Shelter")     # Wuchshülle anlegen

        self.addButton.setText(buttonText)
Exemple #4
0
    def addAction(self):
        # first show relevant information, if necessary
        if self.model.new:
            information = VariantHintDialog()
            information.exec()

        # TODO
        index = self.model.last if self.model.current > -1 else QModelIndex()
        last = self.model.current if self.model.current > -1 else Fence.TYPE
        length = self.model.length
        count = self.model.count

        dialog = VariantDataDialog(self.model.species,
                                   tax=self.tax,
                                   last=last,
                                   index=index,
                                   count=count,
                                   length=length)
        if dialog.exec() == QDialog.Accepted:
            values = dialog.value
            item = VariantItem(values[TreeModel.NameRole],
                               values[TreeModel.ProtectionRole].TYPE)
            setattr(item, "color", values[TreeModel.ColorRole])
            setattr(item, "plant", values[TreeModel.PlantRole])
            setattr(item, "protection", values[TreeModel.ProtectionRole])
            self.model.insertItem(item)

            # TODO
            self.model.count = dialog.count
            self.model.length = dialog.length

        # modify the create button
        if self.model.current == -1:
            buttonText = QApplication.translate(
                "EnhancedTreeWidget", "Add protection type")  # Schutz anlegen
        elif self.model.current == Fence.TYPE:
            buttonText = QApplication.translate("EnhancedTreeWidget",
                                                "Add Fence")  # Zaun anlegen
        else:
            buttonText = QApplication.translate(
                "EnhancedTreeWidget", "Add Tree Shelter")  # Wuchshülle anlegen

        self.addButton.setText(buttonText)