@ -499,18 +499,20 @@ class ImporterWindow(ArtnetMainWindow):
: param tags :
: param tags :
: return :
: return :
"""
"""
tags . sort ( )
tags . sort ( key = lambda x : x [ " name " ] )
item_model = QStandardItemModel ( self . ui . search_result_list )
item_model = QStandardItemModel ( self . ui . search_result_list )
for tag in tags :
for tag in tags :
item = QStandardItem ( tag )
tag_name = tag [ " name " ]
item = QStandardItem ( tag_name )
flags = Qt . ItemIsEnabled
flags = Qt . ItemIsEnabled
if tag not in self . curr_implied_tags :
if tag _name not in self . curr_implied_tags :
# new tag and not implied yet
# new tag and not implied yet
item . setData ( Qt . Unchecked , Qt . CheckStateRole )
item . setData ( Qt . Unchecked , Qt . CheckStateRole )
item . setToolTip ( f " Tag ID: { tag [ ' id ' ] } \n \n " + tag [ " description " ] + f " \n Category: { tag [ ' category ' ] } " )
flags | = Qt . ItemIsUserCheckable
flags | = Qt . ItemIsUserCheckable
if self . curr_tags is not None and tag in ( self . curr_tags + self . curr_implied_tags + self . curr_tag_aliases ) :
if self . curr_tags is not None and tag _name in ( self . curr_tags + self . curr_implied_tags + self . curr_tag_aliases ) :
# already selected, implied or aliased tags
# already selected, implied or aliased tags
item . setCheckState ( Qt . Checked )
item . setCheckState ( Qt . Checked )
item . setFlags ( flags )
item . setFlags ( flags )
@ -534,28 +536,30 @@ class ImporterWindow(ArtnetMainWindow):
: param no_implication : not used
: param no_implication : not used
: return :
: return :
"""
"""
tags . sort ( )
tags . sort ( key = lambda x : x [ " name " ] )
self . curr_tags = tags
self . curr_tags = tags
item_model = QStandardItemModel ( self . ui . tag_list )
item_model = QStandardItemModel ( self . ui . tag_list )
implied_tags = [ ]
implied_tags = [ ]
for x in self . curr_tags :
for x in self . curr_tags :
# collect all implied tags into a list
# collect all implied tags into a list
implied_tags + = self . main . db_connection . get_all_tag_implications_by_name ( x )
implied_tags + = self . main . db_connection . get_all_tag_implications_by_name ( x [" name " ] )
self . set_implied_list ( implied_tags )
self . set_implied_list ( implied_tags )
for tag in tags :
for tag in tags :
item = QStandardItem ( tag )
tag_name = tag [ " name " ]
item = QStandardItem ( tag_name )
flags = Qt . ItemIsEnabled
flags = Qt . ItemIsEnabled
if tag not in self . curr_implied_tags :
if tag _name not in self . curr_implied_tags :
# new tag and not implied yet
# new tag and not implied yet
item . setData ( Qt . Unchecked , Qt . CheckStateRole )
item . setData ( Qt . Unchecked , Qt . CheckStateRole )
item . setToolTip ( f " Tag ID: { tag [ ' id ' ] } \n \n " + tag [ " description " ] + f " \n Category: { tag [ ' category ' ] } " )
flags | = Qt . ItemIsUserCheckable
flags | = Qt . ItemIsUserCheckable
if set_checked :
if set_checked :
if tag not in self . curr_implied_tags :
if tag _name not in self . curr_implied_tags :
item . setCheckState ( Qt . Checked )
item . setCheckState ( Qt . Checked )
else :
else :
item . setCheckState ( Qt . Unchecked )
item . setCheckState ( Qt . Unchecked )
@ -578,11 +582,13 @@ class ImporterWindow(ArtnetMainWindow):
item_model = QStandardItemModel ( self . ui . implied_tag_list )
item_model = QStandardItemModel ( self . ui . implied_tag_list )
done = [ ]
done = [ ]
for tag in tags :
for tag in tags :
if tag in done :
tag_name = tag [ " name " ]
if tag_name in done :
continue
continue
else :
else :
done . append ( tag )
done . append ( tag_name )
item = QStandardItem ( tag )
item = QStandardItem ( tag_name )
item . setToolTip ( f " Tag ID: { tag [ ' id ' ] } \n \n " + tag [ " description " ] + f " \n Category: { tag [ ' category ' ] } " )
item_model . appendRow ( item )
item_model . appendRow ( item )
self . ui . implied_tag_list . setModel ( item_model )
self . ui . implied_tag_list . setModel ( item_model )
@ -1081,7 +1087,7 @@ class ImporterWindow(ArtnetMainWindow):
result = [ ]
result = [ ]
for tag_name , tag_desc , tag_category , tag_id in tags :
for tag_name , tag_desc , tag_category , tag_id in tags :
result . append ( tag_name )
result . append ( { " name " : tag_name , " description " : tag_desc , " category " : tag_category , " id " : tag_id } )
self . set_tag_search_result_list ( result )
self . set_tag_search_result_list ( result )