|
|
@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from typing import List
|
|
|
|
from PyQt5 import QtWidgets
|
|
|
|
from PyQt5 import QtWidgets
|
|
|
|
from PyQt5.QtGui import QStandardItemModel, QStandardItem
|
|
|
|
from PyQt5.QtGui import QStandardItemModel, QStandardItem
|
|
|
|
from PyQt5.QtCore import Qt
|
|
|
|
from PyQt5.QtCore import Qt
|
|
|
@ -47,12 +49,12 @@ class TagModifyDialog(QtWidgets.QDialog):
|
|
|
|
item_model = QStandardItemModel(self.ui.tag_alias_search_list)
|
|
|
|
item_model = QStandardItemModel(self.ui.tag_alias_search_list)
|
|
|
|
|
|
|
|
|
|
|
|
for tag in aliases:
|
|
|
|
for tag in aliases:
|
|
|
|
tag = tag[0].strip()
|
|
|
|
if tag["name"] == self.ui.tag_name_line.text():
|
|
|
|
if tag == self.ui.tag_name_line.text():
|
|
|
|
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
item = QStandardItem(tag)
|
|
|
|
item = QStandardItem(tag["name"])
|
|
|
|
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
|
|
|
|
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
|
|
|
|
item.setData(Qt.Unchecked, Qt.CheckStateRole)
|
|
|
|
item.setData(Qt.Unchecked, Qt.CheckStateRole)
|
|
|
|
|
|
|
|
item.setData(tag, Qt.UserRole)
|
|
|
|
|
|
|
|
|
|
|
|
if set_checked:
|
|
|
|
if set_checked:
|
|
|
|
item.setCheckState(Qt.Checked)
|
|
|
|
item.setCheckState(Qt.Checked)
|
|
|
@ -72,12 +74,13 @@ class TagModifyDialog(QtWidgets.QDialog):
|
|
|
|
item_model = QStandardItemModel(self.ui.tag_implication_search_list)
|
|
|
|
item_model = QStandardItemModel(self.ui.tag_implication_search_list)
|
|
|
|
|
|
|
|
|
|
|
|
for tag in implications:
|
|
|
|
for tag in implications:
|
|
|
|
tag = tag[0].strip()
|
|
|
|
if tag["name"] == self.ui.tag_name_line.text():
|
|
|
|
if tag == self.ui.tag_name_line.text():
|
|
|
|
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
item = QStandardItem(tag)
|
|
|
|
item = QStandardItem(tag["name"])
|
|
|
|
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
|
|
|
|
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
|
|
|
|
item.setData(Qt.Unchecked, Qt.CheckStateRole)
|
|
|
|
item.setData(Qt.Unchecked, Qt.CheckStateRole)
|
|
|
|
|
|
|
|
item.setData(tag, Qt.UserRole)
|
|
|
|
|
|
|
|
|
|
|
|
if set_checked:
|
|
|
|
if set_checked:
|
|
|
|
item.setCheckState(Qt.Checked)
|
|
|
|
item.setCheckState(Qt.Checked)
|
|
|
|
|
|
|
|
|
|
|
@ -119,12 +122,12 @@ class TagModifyDialog(QtWidgets.QDialog):
|
|
|
|
item_model = QStandardItemModel(self.ui.tag_alias_selection_list)
|
|
|
|
item_model = QStandardItemModel(self.ui.tag_alias_selection_list)
|
|
|
|
|
|
|
|
|
|
|
|
for tag in aliases:
|
|
|
|
for tag in aliases:
|
|
|
|
tag = tag.strip()
|
|
|
|
if tag["name"] == self.ui.tag_name_line.text():
|
|
|
|
if tag == self.ui.tag_name_line.text():
|
|
|
|
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
item = QStandardItem(tag)
|
|
|
|
item = QStandardItem(tag["name"])
|
|
|
|
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
|
|
|
|
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
|
|
|
|
item.setData(Qt.Unchecked, Qt.CheckStateRole)
|
|
|
|
item.setData(Qt.Unchecked, Qt.CheckStateRole)
|
|
|
|
|
|
|
|
item.setData(tag, Qt.UserRole)
|
|
|
|
|
|
|
|
|
|
|
|
if set_checked:
|
|
|
|
if set_checked:
|
|
|
|
item.setCheckState(Qt.Checked)
|
|
|
|
item.setCheckState(Qt.Checked)
|
|
|
@ -134,7 +137,7 @@ class TagModifyDialog(QtWidgets.QDialog):
|
|
|
|
item_model.itemChanged.connect(self.on_selected_alias_tag_item_changed)
|
|
|
|
item_model.itemChanged.connect(self.on_selected_alias_tag_item_changed)
|
|
|
|
self.ui.tag_alias_selection_list.setModel(item_model)
|
|
|
|
self.ui.tag_alias_selection_list.setModel(item_model)
|
|
|
|
|
|
|
|
|
|
|
|
def set_selected_implicated_tags(self, implications: list, set_checked: bool=False):
|
|
|
|
def set_selected_implicated_tags(self, implications: List[dict], set_checked: bool=False):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Set the tags in the search result list to tags
|
|
|
|
Set the tags in the search result list to tags
|
|
|
|
:param implications:
|
|
|
|
:param implications:
|
|
|
@ -144,12 +147,12 @@ class TagModifyDialog(QtWidgets.QDialog):
|
|
|
|
item_model = QStandardItemModel(self.ui.tag_implication_search_list)
|
|
|
|
item_model = QStandardItemModel(self.ui.tag_implication_search_list)
|
|
|
|
|
|
|
|
|
|
|
|
for tag in implications:
|
|
|
|
for tag in implications:
|
|
|
|
tag = tag.strip()
|
|
|
|
if tag["name"] == self.ui.tag_name_line.text():
|
|
|
|
if tag == self.ui.tag_name_line.text():
|
|
|
|
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
item = QStandardItem(tag)
|
|
|
|
item = QStandardItem(tag["name"])
|
|
|
|
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
|
|
|
|
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
|
|
|
|
item.setData(Qt.Unchecked, Qt.CheckStateRole)
|
|
|
|
item.setData(Qt.Unchecked, Qt.CheckStateRole)
|
|
|
|
|
|
|
|
item.setData(tag, Qt.UserRole)
|
|
|
|
if set_checked:
|
|
|
|
if set_checked:
|
|
|
|
item.setCheckState(Qt.Checked)
|
|
|
|
item.setCheckState(Qt.Checked)
|
|
|
|
|
|
|
|
|
|
|
@ -184,13 +187,14 @@ class TagModifyDialog(QtWidgets.QDialog):
|
|
|
|
self.set_search_implicated_tags(tags)
|
|
|
|
self.set_search_implicated_tags(tags)
|
|
|
|
|
|
|
|
|
|
|
|
def on_search_implicated_tag_item_changed(self, item: QStandardItem):
|
|
|
|
def on_search_implicated_tag_item_changed(self, item: QStandardItem):
|
|
|
|
|
|
|
|
logging.debug(f"Implication \"{item.text()}\" was clicked with data: "+str(item.data(Qt.UserRole)))
|
|
|
|
if item.checkState() == Qt.Checked:
|
|
|
|
if item.checkState() == Qt.Checked:
|
|
|
|
if self.implication_selection is None:
|
|
|
|
if self.implication_selection is None:
|
|
|
|
self.implication_selection = []
|
|
|
|
self.implication_selection = []
|
|
|
|
self.implication_selection.append(item.text())
|
|
|
|
self.implication_selection.append(item.data(Qt.UserRole))
|
|
|
|
elif item.checkState() == Qt.Unchecked:
|
|
|
|
elif item.checkState() == Qt.Unchecked:
|
|
|
|
if item.text() in self.implication_selection:
|
|
|
|
if item.text() in [x["name"] for x in self.implication_selection]:
|
|
|
|
self.implication_selection.remove(item.text())
|
|
|
|
self.implication_selection.remove(item.data(Qt.UserRole))
|
|
|
|
|
|
|
|
|
|
|
|
self.set_selected_implicated_tags(self.implication_selection, set_checked=True)
|
|
|
|
self.set_selected_implicated_tags(self.implication_selection, set_checked=True)
|
|
|
|
|
|
|
|
|
|
|
@ -198,17 +202,17 @@ class TagModifyDialog(QtWidgets.QDialog):
|
|
|
|
if item.checkState() == Qt.Checked:
|
|
|
|
if item.checkState() == Qt.Checked:
|
|
|
|
if self.alias_selection is None:
|
|
|
|
if self.alias_selection is None:
|
|
|
|
self.alias_selection = []
|
|
|
|
self.alias_selection = []
|
|
|
|
self.alias_selection.append(item.text())
|
|
|
|
self.alias_selection.append(item.data(Qt.UserRole))
|
|
|
|
elif item.checkState() == Qt.Unchecked:
|
|
|
|
elif item.checkState() == Qt.Unchecked:
|
|
|
|
if item.text() in self.alias_selection:
|
|
|
|
if item.text() in [x["name"] for x in self.alias_selection]:
|
|
|
|
self.alias_selection.remove(item.text())
|
|
|
|
self.alias_selection.remove(item.data(Qt.UserRole))
|
|
|
|
|
|
|
|
|
|
|
|
self.set_selected_alias_tags(self.alias_selection, set_checked=True)
|
|
|
|
self.set_selected_alias_tags(self.alias_selection, set_checked=True)
|
|
|
|
|
|
|
|
|
|
|
|
def on_selected_implicated_tag_item_changed(self, item: QStandardItem):
|
|
|
|
def on_selected_implicated_tag_item_changed(self, item: QStandardItem):
|
|
|
|
if self.implication_selection is None:
|
|
|
|
if self.implication_selection is None:
|
|
|
|
self.implication_selection = []
|
|
|
|
self.implication_selection = []
|
|
|
|
self.implication_selection.remove(item.text())
|
|
|
|
self.implication_selection.remove(item.data(Qt.UserRole))
|
|
|
|
self.set_selected_implicated_tags(self.implication_selection, set_checked=True)
|
|
|
|
self.set_selected_implicated_tags(self.implication_selection, set_checked=True)
|
|
|
|
|
|
|
|
|
|
|
|
if self.tag_implication_search_result is not None:
|
|
|
|
if self.tag_implication_search_result is not None:
|
|
|
@ -217,7 +221,7 @@ class TagModifyDialog(QtWidgets.QDialog):
|
|
|
|
def on_selected_alias_tag_item_changed(self, item: QStandardItem):
|
|
|
|
def on_selected_alias_tag_item_changed(self, item: QStandardItem):
|
|
|
|
if self.alias_selection is None:
|
|
|
|
if self.alias_selection is None:
|
|
|
|
self.alias_selection = []
|
|
|
|
self.alias_selection = []
|
|
|
|
self.alias_selection.remove(item.text())
|
|
|
|
self.alias_selection.remove(item.data(Qt.UserRole))
|
|
|
|
self.set_selected_alias_tags(self.alias_selection, set_checked=True)
|
|
|
|
self.set_selected_alias_tags(self.alias_selection, set_checked=True)
|
|
|
|
|
|
|
|
|
|
|
|
self.set_search_alias_tags(self.tag_alias_search_result)
|
|
|
|
self.set_search_alias_tags(self.tag_alias_search_result)
|
|
|
|