def tag_save(self):
tag_id = self.tag_id_line_edit.text()
tag_name = self.tag_name_line_edit.text()
tag_description = self.tag_description_text_edit.toPlainText()
if tag_name == '' or tag_description == '':
QMessageBox.warning(self, 'tag editor', 'tag name and description can\'t be empty')
else:
if len(tag_name) > 8:
QMessageBox.warning(self, 'tag editor', 'tag name is not greater than 8 characters')
else:
if tag_id:
self.tag.name = tag_name
self.tag.description = tag_description
self.db_helper.update_tag()
QMessageBox.information(self, 'tag editor', 'tag update success')#todo ??????
else:
tag = self.db_helper.query_tag_by_name(tag_name)
if tag is None:
tag = self.db_helper.insert_tag(tag_name, tag_description)
self.tag_id_line_edit.setText(str(tag.id))
self.tag = tag
QMessageBox.information(self, 'tag editor', 'tag insert success')#todo ??????
else:
QMessageBox.warning(self, 'tag editor', 'tag has existed')
评论列表
文章目录