@ -81,11 +81,14 @@ class Window(QtWidgets.QMainWindow):
self . ui . tag_search_bar . textChanged . connect ( self . on_tag_search_change )
self . ui . image_title_line . textChanged . connect ( self . on_image_title_change )
self . ui . link_line . textChanged . connect ( self . on_link_line_change )
self . ui . description_edit . textChanged . connect ( self . on_description_change )
self . ui . link_label . setText ( " No Source Available " )
self . ui . image_file_label . setTextInteractionFlags ( Qt . TextSelectableByMouse )
self . set_image_title_link ( )
self . ui . description_edit . setReadOnly ( False )
self . on_tag_search_change ( )
self . center ( )
@ -138,8 +141,13 @@ class Window(QtWidgets.QMainWindow):
: return :
"""
new_title = self . curr_image_title
new_description = self . ui . description_edit . toPlainText ( ) . strip ( )
if new_title == self . curr_file_name or len ( new_title ) == 0 or new_title == Window . UNKNOWN_TITLE :
new_title = None
if new_description is None or len ( new_description ) == 0 :
new_description = None
else :
new_description = new_description . strip ( )
image_data = {
" ID " : self . curr_art_id ,
" title " : new_title ,
@ -147,7 +155,8 @@ class Window(QtWidgets.QMainWindow):
" path " : self . curr_art_path ,
" tags " : self . curr_tags ,
" link " : self . curr_link ,
" md5_hash " : self . __main . get_md5_of_image ( self . curr_art_path )
" md5_hash " : self . __main . get_md5_of_image ( self . curr_art_path ) ,
" description " : new_description ,
}
for presence in self . curr_presences :
@ -163,7 +172,7 @@ class Window(QtWidgets.QMainWindow):
self . __main . db_connection . save_image ( ID = image_data [ " ID " ] , title = image_data [ " title " ] ,
authors = image_data [ " authors " ] , path = image_data [ " path " ] ,
tags = image_data [ " tags " ] , link = image_data [ " link " ] ,
md5_hash = image_data [ " md5_hash " ] )
md5_hash = image_data [ " md5_hash " ] , desc = image_data [ " description " ] )
self . set_temporary_status_message ( " Saved {0} ( {1} ) to ArtNet DB! "
. format ( image_data [ " title " ] , image_data [ " ID " ] ) , 5000 )
@ -193,15 +202,6 @@ class Window(QtWidgets.QMainWindow):
return
self . __main . db_connection . save_presence ( name = name , domain = domain , artist_ID = artist [ 0 ] , link = link )
def remove_presence ( self , name : str , domain : str ) :
"""
Remove the presence from the DB
: param name :
: param domain :
: return :
"""
self . __main . db_connection . remove_presence ( name , domain )
def get_authors ( self , presence_name : str , presence_domain : str ) - > list :
"""
Query a search for the authors fitting the given strings
@ -449,6 +449,12 @@ class Window(QtWidgets.QMainWindow):
item_model . itemChanged . connect ( self . on_tag_search_item_changed )
self . ui . search_result_list . setModel ( item_model )
def set_description_text ( self , text : str ) :
"""
Set the text for the description field
"""
self . ui . description_edit . setText ( text )
def set_tag_list ( self , tags : list , set_checked : bool = True , no_implication : bool = False ) :
"""
Set the tags in the tag list to this .
@ -508,7 +514,7 @@ class Window(QtWidgets.QMainWindow):
self . data_changed = True
def display_image ( self , image_title : str , image_authors : list , full_path : str , relative_path : str , art_ID : int ,
link : str , file_name : str ):
link : str , file_name : str , description : str ):
"""
Display an image in the central widget
: param image_authors :
@ -587,9 +593,12 @@ class Window(QtWidgets.QMainWindow):
self . update_window_title ( )
self . ui . link_line . setText ( link )
self . ui . image_file_label . setText ( file_name )
self . ui . description_edit . setText ( description )
self . set_image_title_link ( )
self . set_image_id_spinbox ( )
self . data_changed = False # reset any triggered change detection
def update_window_title ( self ) :
"""
Update the title of the window with the newest image title as given in text field
@ -1055,3 +1064,6 @@ class Window(QtWidgets.QMainWindow):
def on_image_author_label_activated ( self , link : str ) :
print ( " Image author link activated! " , link )
QDesktopServices . openUrl ( QUrl ( link ) )
def on_description_change ( self ) :
self . data_changed = True