Exemplo n.º 1
0
    def _init_checkbox(self):
        all_attr_list = attribute_handler.get_all_attributes()
        if self.service_id:
            self.checked_dict = self._get_service_attribute()
        row = 0
        column = 0
        model = QtGui.QStandardItemModel()
        for attr in all_attr_list:
            item = QtGui.QStandardItem(attr[1])

            if attr[3] == Attribute.required():
                # 如果是必填,则默认勾选,同时不允许修改
                item.setCheckState(Qt.Checked)
                item.setFlags(QtCore.Qt.NoItemFlags)
            else:
                item.setFlags(QtCore.Qt.ItemIsUserCheckable
                              | QtCore.Qt.ItemIsEnabled)
                # 如果该属性已经关联了服务项目,则默认勾选
                if attr[0] not in self.checked_dict:
                    item.setCheckState(Qt.Unchecked)
                else:
                    item.setCheckState(Qt.Checked)

            self.checkbox_dict[attr[0]] = item

            model.setItem(row, column, item)
            # 表格中每行显示5条记录
            column += 1
            if column >= 5:
                row += 1
                column = 0

        self.tableView.horizontalHeader().setStretchLastSection(True)
        self.tableView.setModel(model)
Exemplo n.º 2
0
def add_all_required_attribute(service_id):
    required_attributes = attribute_handler.get_all_attributes()
    item = ServiceItem()
    item.create_time(time_utils.get_now())
    item.create_op(config.login_user_info[0])
    for attr in required_attributes:
        item.attribute_name(attr[1])
        item.attribute_id(attr[0])
        service_handler.add_service_attribute(item)
Exemplo n.º 3
0
    def _init_table(self):
        record = attribute_handler.get_all_attributes()

        table_utils.set_table_content(self.tableView, record, self.table_title)
        self.tableView.setColumnHidden(0, True)
        self.tableView.setColumnHidden(3, True)