Exemple #1
0
    def _add_entry(self):
        self._table_widget.blockSignals(True)

        # insert new row
        self._table_widget.insertRow(self._table_widget.rowCount() - 1)

        # move key and value items up
        self._table_widget.setItem(
            self._table_widget.rowCount() - 2, 0,
            self._table_widget.takeItem(self._table_widget.rowCount() - 1, 0))
        self._table_widget.setItem(
            self._table_widget.rowCount() - 2, 1,
            self._table_widget.takeItem(self._table_widget.rowCount() - 1, 1))
        self._table_widget.setItem(self._table_widget.rowCount() - 1, 0,
                                   QTableWidgetItem())
        self._table_widget.setItem(self._table_widget.rowCount() - 1, 1,
                                   QTableWidgetItem())

        # add 'remove' button
        item = QTableWidgetItem()
        item.setFlags(Qt.NoItemFlags)
        self._table_widget.setItem(self._table_widget.rowCount() - 2, 2, item)
        self._table_widget.setCellWidget(
            self._table_widget.rowCount() - 2, 2,
            self._create_cell_push_button(
                '', lambda: self._table_widget.removeRow(item.row()),
                QIcon.fromTheme('list-remove')))

        self._table_widget.blockSignals(False)
Exemple #2
0
 def _add_parameter(self, param):
     key = QTableWidgetItem(param.key)
     key.setFlags(key.flags() & ~Qt.ItemIsEditable)
     row = self.skill_params_table.rowCount()
     self.skill_params_table.insertRow(row)
     #row = row-1
     self.skill_params_table.setItem(row, 0, key)
     if param.dataTypeIs(bool):
         cbox = QCheckBox()
         if param.hasSpecifiedDefault():
             cbox.setChecked(param.default)
         self.skill_params_table.setCellWidget(row, 1, cbox)
     elif param.dataTypeIs(Element):
         combobox = QComboBox()
         self.skill_params_table.setCellWidget(row, 1, combobox)
         matches = self._wmi.resolve_elements(param.default)
         if param.paramTypeIs(ParamTypes.Optional):
             combobox.addItem("", None)
         for e in matches:
             combobox.addItem(e.printState(), e._id)
     else:
         lineedit = QLineEdit()
         if param.isSpecified():
             lineedit.setText(str(param.value))
         self.skill_params_table.setCellWidget(row, 1, lineedit)
Exemple #3
0
    def _add_relations_table_row(self, relation, editable_src=False, editable_dst=False):
        src = QTableWidgetItem(utils.ontology_type2name(relation['src']))
        rel = QTableWidgetItem(utils.ontology_type2name(relation['type']))
        dst = QTableWidgetItem(utils.ontology_type2name(relation['dst']))

        src.id = relation['src']
        rel.id = relation['type']
        dst.id = relation['dst']

        src.setTextAlignment(Qt.AlignRight)
        rel.setTextAlignment(Qt.AlignHCenter)
        dst.setTextAlignment(Qt.AlignLeft)

        if not editable_src:
            src.setFlags(src.flags() & ~Qt.ItemIsEditable)
        rel.setFlags(rel.flags() & ~Qt.ItemIsEditable)
        if not editable_dst:
            dst.setFlags(dst.flags() & ~Qt.ItemIsEditable)

        self.wm_relations_widget.insertRow(self.wm_relations_widget.rowCount())
        # self.wm_relations_widget.setSpan(self.wm_relations_widget.rowCount()-1, 0, 1, 3)
        self.wm_relations_widget.setItem(self.wm_relations_widget.rowCount() - 1, 0, src)
        self.wm_relations_widget.setItem(self.wm_relations_widget.rowCount() - 1, 1, rel)
        self.wm_relations_widget.setItem(self.wm_relations_widget.rowCount() - 1, 2, dst)
Exemple #4
0
    def _add_properties_table_row(self, prop, editable_key=False, editable_value=True):
        key = QTableWidgetItem(utils.ontology_type2name(prop.key))
        if not editable_key:
            key.setFlags(key.flags() & ~Qt.ItemIsEditable)
        value = prop.values if prop.isList() else prop.value
        if prop.dataTypeIs(float):
            val = QTableWidgetItem(format(value, '.4f') if value is not None else '')
        else:
            val = QTableWidgetItem(str(value) if value is not None else '')
        if not editable_value:
            val.setFlags(val.flags() & ~Qt.ItemIsEditable)

        if prop.dataTypeIs(bool):
            val.setText('')
            val.setFlags(val.flags() & ~Qt.ItemIsEditable)
            val.setCheckState(Qt.Checked if prop.value else Qt.Unchecked)
        # if isinstance(prop.dataType(), bool):
        #     val.setCheckState(prop.value)

        key.id = val.id = prop.key

        self.wm_properties_widget.insertRow(self.wm_properties_widget.rowCount())
        self.wm_properties_widget.setItem(self.wm_properties_widget.rowCount() - 1, 0, key)
        self.wm_properties_widget.setItem(self.wm_properties_widget.rowCount() - 1, 1, val)