@ -7,7 +7,9 @@ from PyQt5.QtGui import QPixmap, QResizeEvent, QKeyEvent, QStandardItemModel, QS
 
		
	
		
			
				from  PyQt5  import  QtMultimedia  
		
	
		
			
				from  PyQt5 . QtMultimediaWidgets  import  QVideoWidget  
		
	
		
			
				
 
		
	
		
			
				from  ArtNet . gui . windows . picture_importer  import  Ui_MainWindow  
		
	
		
			
				from  ArtNet . gui . windows . importer . picture_importer  import  Ui_MainWindow  
		
	
		
			
				from  ArtNet . gui . windows . artnet_mainwindow  import  ArtnetMainWindow  
		
	
		
			
				
 
		
	
		
			
				from  ArtNet . gui . dialogs . db_connection_dialog . db_dialog  import  DBDialog  
		
	
		
			
				from  ArtNet . gui . dialogs . tag_modify_dialog . tag_mod_dialog  import  TagModifyDialog  
		
	
		
			
				from  ArtNet . gui . dialogs . tag_select_dialog . tag_select_dialog  import  TagSelectDialog  
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -18,15 +20,13 @@ from ArtNet.gui.dialogs.tag_import_dialog.tag_imp_dialog import TagImportDialog
 
		
	
		
			
				from  ArtNet . web . link_generator  import  LinkGenerator  
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				class  Window( QtWidgets . Q  MainWindow) :  
		
	
		
			
				class  ImporterWindow( Artnet  MainWindow) :  
		
	
		
			
				
 
		
	
		
			
				    UNKNOWN_TITLE  =  " -Title Unknown- " 
 
		
	
		
			
				    UNKNOWN_PRESENCE  =  " (Not in Database) " 
 
		
	
		
			
				
 
		
	
		
			
				    def  __init__ ( self ,  main ) : 
 
		
	
		
			
				        super ( Window ,  self ) . __init__ ( ) 
 
		
	
		
			
				
 
		
	
		
			
				        self . __main  =  main 
 
		
	
		
			
				        super ( ) . __init__ ( main ) 
 
		
	
		
			
				
 
		
	
		
			
				        self . __pixmap :  QPixmap  =  None 
 
		
	
		
			
				        self . __video :  QVideoWidget  =  None 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -49,7 +49,6 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        self . curr_imply_tags :  list  =  list ( ) 
 
		
	
		
			
				        self . curr_tag_aliases :  list  =  list ( ) 
 
		
	
		
			
				
 
		
	
		
			
				        self . setting_up_data :  bool  =  True 
 
		
	
		
			
				        self . __data_changed :  bool  =  False 
 
		
	
		
			
				
 
		
	
		
			
				        self . ui  =  Ui_MainWindow ( ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -63,6 +62,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        self . ui . actionDelete_a_Tag . triggered . connect ( self . on_tag_deletion_clicked ) 
 
		
	
		
			
				        self . ui . actionCreate_New_Category_2 . triggered . connect ( self . on_category_creation_clicked ) 
 
		
	
		
			
				        self . ui . actionDelete_a_Category_2 . triggered . connect ( self . on_category_deletion_clicked ) 
 
		
	
		
			
				        self . ui . actionArtNet_Browser . triggered . connect ( self . on_browser_clicked ) 
 
		
	
		
			
				
 
		
	
		
			
				        self . ui . imageNumberSpinBox . valueChanged . connect ( self . on_image_id_spinbox_changed ) 
 
		
	
		
			
				
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -93,22 +93,6 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        self . on_tag_search_change ( ) 
 
		
	
		
			
				        self . center ( ) 
 
		
	
		
			
				
 
		
	
		
			
				    @property 
 
		
	
		
			
				    def  data_changed ( self ) : 
 
		
	
		
			
				        return  self . __data_changed 
 
		
	
		
			
				
 
		
	
		
			
				    @data_changed.setter 
 
		
	
		
			
				    def  data_changed ( self ,  v :  bool ) : 
 
		
	
		
			
				        self . __data_changed  =  v 
 
		
	
		
			
				
 
		
	
		
			
				        if  self . curr_image_title  is  None : 
 
		
	
		
			
				            return 
 
		
	
		
			
				        if  "  (Not in Database) "  in  self . curr_image_title  and  v  and  not  self . setting_up_data : 
 
		
	
		
			
				            self . curr_image_title  =  self . curr_image_title . replace ( "  (Not in Database) " ,  " " ) 
 
		
	
		
			
				            self . setting_up_data  =  True 
 
		
	
		
			
				            self . ui . image_title_line . setText ( self . curr_image_title ) 
 
		
	
		
			
				            self . setting_up_data  =  False 
 
		
	
		
			
				
 
		
	
		
			
				    def  center ( self ) : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        Centers  the  window  in  the  middle  of  the  screen 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -143,7 +127,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        """ 
 
		
	
		
			
				        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  ==  . UNKNOWN_TITLE : 
 
		
	
		
			
				        if  new_title  ==  self . curr_file_name  or  len ( new_title )  ==  0  or  new_title  ==  Importer Window. UNKNOWN_TITLE : 
 
		
	
		
			
				            new_title  =  None 
 
		
	
		
			
				        if  new_description  is  None  or  len ( new_description )  ==  0 : 
 
		
	
		
			
				            new_description  =  None 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -156,12 +140,12 @@ 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 . . get_md5_of_image ( self . curr_art_path ) , 
 
		
	
		
			
				            " description " :  new_description , 
 
		
	
		
			
				        } 
 
		
	
		
			
				
 
		
	
		
			
				        for  presence  in  self . curr_presences : 
 
		
	
		
			
				            if  presence [ - 1 ]  ==  . UNKNOWN_PRESENCE : 
 
		
	
		
			
				            if  presence [ - 1 ]  ==  Importer Window. UNKNOWN_PRESENCE : 
 
		
	
		
			
				                msg  =  QtWidgets . QMessageBox ( ) 
 
		
	
		
			
				                msg . setWindowTitle ( " Invalid Presence Domain " ) 
 
		
	
		
			
				                msg . setInformativeText ( " You ' ve tried to save with a not working presence entry!  "  + 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -170,7 +154,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				                msg . exec_ ( ) 
 
		
	
		
			
				                return  False 
 
		
	
		
			
				
 
		
	
		
			
				        self . __ main. db_connection . save_image ( ID = image_data [ " ID " ] ,  title = image_data [ " title " ] , 
 
		
	
		
			
				        self . . 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 " ] ,  desc = image_data [ " description " ] ) 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -201,7 +185,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        """ 
 
		
	
		
			
				        if  len ( name )  ==  0  or  len ( domain )  ==  0  or  artist  is  None : 
 
		
	
		
			
				            return 
 
		
	
		
			
				        self . __ main. db_connection . save_presence ( name = name ,  domain = domain ,  artist_ID = artist [ 0 ] ,  link = link ) 
 
		
	
		
			
				        self . . db_connection . save_presence ( name = name ,  domain = domain ,  artist_ID = artist [ 0 ] ,  link = link ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_authors ( self ,  presence_name :  str ,  presence_domain :  str )  - >  list : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -210,7 +194,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  presence_domain : 
 
		
	
		
			
				        : return :  a  list  of  tuples  of  ( presence_name ,  presence_domain ) 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        return  self . __ main. db_connection . search_fuzzy_presence ( presence_name ,  presence_domain ,  all_if_empty = True ) 
 
		
	
		
			
				        return  self . . db_connection . search_fuzzy_presence ( presence_name ,  presence_domain ,  all_if_empty = True ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  create_artist ( self ,  ID :  int ,  description :  str ) : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -219,7 +203,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  description : 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        self . __ main. db_connection . save_artist ( ID ,  description ) 
 
		
	
		
			
				        self . . db_connection . save_artist ( ID ,  description ) 
 
		
	
		
			
				        self . set_temporary_status_message ( " Created Artist  {0} ! " . format ( description ) ,  3000 ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_artists ( self ,  search :  str )  - >  list : 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -235,7 +219,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				            ID_int  =  None 
 
		
	
		
			
				            description  =  search 
 
		
	
		
			
				
 
		
	
		
			
				        return  self . __ main. db_connection . search_fuzzy_artists ( ID_int ,  description ) 
 
		
	
		
			
				        return  self . . db_connection . search_fuzzy_artists ( ID_int ,  description ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_artist ( self ,  id :  int )  - >  list : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -243,7 +227,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  id : 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        return  self . __ main. db_connection . get_artist ( id ) 
 
		
	
		
			
				        return  self . . db_connection . get_artist ( id ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  remove_artist ( self ,  id :  int ) : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -251,7 +235,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  id : 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        self . __ main. db_connection . remove_artist ( id ) 
 
		
	
		
			
				        self . . db_connection . remove_artist ( id ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_artist_presences ( self ,  id :  int )  - >  list : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -259,14 +243,14 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  id : 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        return  self . __ main. db_connection . get_artist_presences ( id ) 
 
		
	
		
			
				        return  self . . db_connection . get_artist_presences ( id ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_all_artists ( self )  - >  list : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        Queries  the  database  for  a  list  of  all  available  arists  ( not  presences ) . 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        return  self . __ main. db_connection . get_all_artists ( ) 
 
		
	
		
			
				        return  self . . db_connection . get_all_artists ( ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_presence ( self ,  name :  str ,  domain :  str ) : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -275,7 +259,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  domain : 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        result  =  self . __ main. db_connection . get_presence ( name ,  domain ) 
 
		
	
		
			
				        result  =  self . . db_connection . get_presence ( name ,  domain ) 
 
		
	
		
			
				
 
		
	
		
			
				        return  result  if  len ( result )  !=  0  else  None 
 
		
	
		
			
				
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -286,7 +270,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  domain : 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        self . __ main. db_connection . remove_presence ( name ,  domain ) 
 
		
	
		
			
				        self . . db_connection . remove_presence ( name ,  domain ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_presences_art ( self ,  name :  str ,  domain :  str ) : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -295,7 +279,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  domain : 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        return  self . __ main. db_connection . get_presences_art ( name ,  domain ) 
 
		
	
		
			
				        return  self . . db_connection . get_presences_art ( name ,  domain ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_current_presences ( self )  - >  list : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -311,10 +295,10 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        """ 
 
		
	
		
			
				        if  len ( presences )  >  1 : 
 
		
	
		
			
				            for  name ,  domain  in  presences : 
 
		
	
		
			
				                if  domain  ==  . UNKNOWN_PRESENCE : 
 
		
	
		
			
				                if  domain  ==  Importer Window. UNKNOWN_PRESENCE : 
 
		
	
		
			
				                    presences . remove ( ( name ,  domain ) ) 
 
		
	
		
			
				        elif  len ( presences )  ==  0 : 
 
		
	
		
			
				            presences  =  [ ( self . curr_art_path . split ( " / " ) [ 0 ] ,  . UNKNOWN_PRESENCE ) ] 
 
		
	
		
			
				            presences  =  [ ( self . curr_art_path . split ( " / " ) [ 0 ] ,  Importer Window. UNKNOWN_PRESENCE ) ] 
 
		
	
		
			
				        self . curr_presences  =  presences 
 
		
	
		
			
				
 
		
	
		
			
				        if  self . curr_presences  is  not  None : 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -332,9 +316,9 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        if  all_if_empty  and  len ( search )  ==  0 : 
 
		
	
		
			
				            return  self . __ main. db_connection . get_all_categories ( ) 
 
		
	
		
			
				            return  self . . db_connection . get_all_categories ( ) 
 
		
	
		
			
				
 
		
	
		
			
				        return  self . __ main. db_connection . search_fuzzy_categories ( search ) 
 
		
	
		
			
				        return  self . . db_connection . search_fuzzy_categories ( search ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_image_link_from_line ( self )  - >  str : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -398,7 +382,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  name : 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        return  self . __ main. db_connection . get_tag_by_name ( name ) 
 
		
	
		
			
				        return  self . . db_connection . get_tag_by_name ( name ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_tag_aliases ( self ,  name :  str )  - >  list : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -408,7 +392,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  name : 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        return  self . __ main. db_connection . get_tag_aliases_by_name ( name ) 
 
		
	
		
			
				        return  self . . db_connection . get_tag_aliases_by_name ( name ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_tag_implications ( self ,  name :  str )  - >  list : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -416,14 +400,14 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : param  name : 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        return  self . __ main. db_connection . get_tag_implications ( name ) 
 
		
	
		
			
				        return  self . . db_connection . get_tag_implications ( name ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  get_tag_search_result ( self ,  name :  str )  - >  list : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        Query  a  search  for  tags  to  the  DB  that  are  like  name 
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        return  self . __ main. db_connection . search_fuzzy_tag ( name ,  all_if_empty = True ) 
 
		
	
		
			
				        return  self . . db_connection . search_fuzzy_tag ( name ,  all_if_empty = True ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  set_tag_search_result_list ( self ,  tags :  list ) : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -484,12 +468,12 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        implied_tags  =  [ ] 
 
		
	
		
			
				        for  x  in  self . curr_tags : 
 
		
	
		
			
				            # collect all implied tags into a list 
 
		
	
		
			
				            implied_tags  + =  self . __ main. db_connection . get_all_tag_implications_by_name ( x ) 
 
		
	
		
			
				            implied_tags  + =  self . . db_connection . get_all_tag_implications_by_name ( x ) 
 
		
	
		
			
				
 
		
	
		
			
				        self . set_implied_list ( implied_tags ) 
 
		
	
		
			
				        self . curr_tag_aliases  =  list ( ) 
 
		
	
		
			
				        for  tag  in  tags + implied_tags : 
 
		
	
		
			
				            self . curr_tag_aliases  + =  self . __ main. db_connection . get_tag_aliases_by_name ( tag ) 
 
		
	
		
			
				            self . curr_tag_aliases  + =  self . . db_connection . get_tag_aliases_by_name ( tag ) 
 
		
	
		
			
				
 
		
	
		
			
				        self . data_changed  =  True 
 
		
	
		
			
				
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -607,7 +591,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        """ 
 
		
	
		
			
				        image_title  =  self . ui . image_title_line . text ( ) 
 
		
	
		
			
				        self . setWindowTitle ( self . main_title  +  "  -  "  +  image_title 
 
		
	
		
			
				                            +  f "  ( { round ( self . __ main. known_image_amount / len ( self . __ main. all_images ) ,  5 ) } %) " ) 
 
		
	
		
			
				                            +  f "  ( { round ( self . . known_image_amount / len ( self . . all_images ) ,  5 ) } %) " ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  set_image_id_spinbox ( self ) : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -615,8 +599,8 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        : return : 
 
		
	
		
			
				        """ 
 
		
	
		
			
				        self . ui . imageNumberSpinBox . setMinimum ( 0 ) 
 
		
	
		
			
				        self . ui . imageNumberSpinBox . setMaximum ( len ( self . __ main. all_images ) - 1 ) 
 
		
	
		
			
				        self . ui . imageNumberSpinBox . setValue ( self . __ main. curr_image_index ) 
 
		
	
		
			
				        self . ui . imageNumberSpinBox . setMaximum ( len ( self . . all_images ) - 1 ) 
 
		
	
		
			
				        self . ui . imageNumberSpinBox . setValue ( self . . curr_image_index ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  __image_resize ( self ) : 
 
		
	
		
			
				        """ 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -645,7 +629,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        self . __image_resize ( ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  keyPressEvent ( self ,  a0 :  QKeyEvent )  - >  None : 
 
		
	
		
			
				        super ( ,  self ) . keyPressEvent ( a0 ) 
 
		
	
		
			
				        super ( Importer Window,  self ) . keyPressEvent ( a0 ) 
 
		
	
		
			
				        if  a0 . key ( )  ==  Qt . Key_Left : 
 
		
	
		
			
				            self . on_previous_clicked ( ) 
 
		
	
		
			
				        elif  a0 . key ( )  ==  Qt . Key_Right : 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -718,7 +702,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        else : 
 
		
	
		
			
				            url  =  self . get_image_link_from_line ( ) 
 
		
	
		
			
				
 
		
	
		
			
				        r  =  self . __ main. scrape_tags ( self . curr_file_name ,  url = url , 
 
		
	
		
			
				        r  =  self . . scrape_tags ( self . curr_file_name ,  url = url , 
 
		
	
		
			
				                                    art_ID = self . curr_art_id ) 
 
		
	
		
			
				
 
		
	
		
			
				        if  r  is  None : 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -735,7 +719,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				
 
		
	
		
			
				        i  =  0 
 
		
	
		
			
				        while  i  <  len ( tags ) :   # workaround for an issue with altering lists during iteration 
 
		
	
		
			
				            r  =  self . __ main. db_connection . get_tag_by_name ( tags [ i ] ) 
 
		
	
		
			
				            r  =  self . . db_connection . get_tag_by_name ( tags [ i ] ) 
 
		
	
		
			
				            if  len ( r )  >  0 : 
 
		
	
		
			
				                self . curr_tags . append ( tags [ i ] ) 
 
		
	
		
			
				                self . data_changed  =  True 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -762,7 +746,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				            self . set_tag_list ( self . curr_tags ) 
 
		
	
		
			
				            return 
 
		
	
		
			
				
 
		
	
		
			
				        self . __ main. import_tags ( result ) 
 
		
	
		
			
				        self . . import_tags ( result ) 
 
		
	
		
			
				        self . set_tag_list ( self . curr_tags ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_next_clicked ( self ) : 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -770,10 +754,10 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        if  not  self . check_save_changes ( ) : 
 
		
	
		
			
				            return 
 
		
	
		
			
				
 
		
	
		
			
				        self . __ main. curr_image_index  + =  1 
 
		
	
		
			
				        if  self . __ main. curr_image_index  > =  len ( self . __ main. all_images ) : 
 
		
	
		
			
				            self . __ main. curr_image_index  =  0 
 
		
	
		
			
				        self . __ main. refresh_shown_image ( ) 
 
		
	
		
			
				        self . . curr_image_index  + =  1 
 
		
	
		
			
				        if  self . . curr_image_index  > =  len ( self . . all_images ) : 
 
		
	
		
			
				            self . . curr_image_index  =  0 
 
		
	
		
			
				        self . . refresh_shown_image ( ) 
 
		
	
		
			
				
 
		
	
		
			
				        if  self . presence_docker_open : 
 
		
	
		
			
				            self . toggle_presence_docker ( ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -788,11 +772,11 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        if  not  self . check_save_changes ( ) : 
 
		
	
		
			
				            return 
 
		
	
		
			
				
 
		
	
		
			
				        self . __ main. curr_image_index  - =  1 
 
		
	
		
			
				        if  self . __ main. curr_image_index  <  0 : 
 
		
	
		
			
				            self . __ main. curr_image_index  + =  len ( self . __ main. all_images ) 
 
		
	
		
			
				        self . . curr_image_index  - =  1 
 
		
	
		
			
				        if  self . . curr_image_index  <  0 : 
 
		
	
		
			
				            self . . curr_image_index  + =  len ( self . . all_images ) 
 
		
	
		
			
				
 
		
	
		
			
				        self . __ main. refresh_shown_image ( ) 
 
		
	
		
			
				        self . . refresh_shown_image ( ) 
 
		
	
		
			
				
 
		
	
		
			
				        if  self . presence_docker_open : 
 
		
	
		
			
				            self . toggle_presence_docker ( ) 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -822,12 +806,12 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        dialog . setOptions ( QtWidgets . QFileDialog . ShowDirsOnly ) 
 
		
	
		
			
				
 
		
	
		
			
				        directory  =  dialog . getExistingDirectory ( ) 
 
		
	
		
			
				        self . __ main. change_root ( directory ) 
 
		
	
		
			
				        self . . change_root ( directory ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_db_connection_change_clicked ( self ) : 
 
		
	
		
			
				        logging . info ( " Clicked db connection change! " ) 
 
		
	
		
			
				        dialog  =  DBDialog ( self ) 
 
		
	
		
			
				        prev_db_data  =  self . __ main. get_db_connection_details ( ) 
 
		
	
		
			
				        prev_db_data  =  self . . get_db_connection_details ( ) 
 
		
	
		
			
				        dialog . ui . user_line_edit . setText ( prev_db_data [ " user " ] ) 
 
		
	
		
			
				        dialog . ui . password_line_edit . setText ( prev_db_data [ " password " ] ) 
 
		
	
		
			
				        dialog . ui . host_line_edit . setText ( prev_db_data [ " host " ] ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -837,7 +821,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        db_data :  dict  =  dialog . exec_ ( ) 
 
		
	
		
			
				        if  len ( db_data . keys ( ) )  ==  0 : 
 
		
	
		
			
				            return 
 
		
	
		
			
				        self . __ main. change_db_connection ( host = db_data [ " host " ] ,  port = db_data [ " port " ] , 
 
		
	
		
			
				        self . . change_db_connection ( host = db_data [ " host " ] ,  port = db_data [ " port " ] , 
 
		
	
		
			
				                                         user = db_data [ " user " ] ,  password = db_data [ " password " ] , 
 
		
	
		
			
				                                         database = db_data [ " database " ] ) 
 
		
	
		
			
				
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -854,7 +838,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				            QtWidgets . QMessageBox . information ( self ,  " Duplicate Tag " ,  " The tag  \" {0} \"  already exists in the db! " 
 
		
	
		
			
				                                              . format ( tag_data [ " name " ] ) ) 
 
		
	
		
			
				            return 
 
		
	
		
			
				        self . __ main. db_connection . create_tag ( name = tag_data [ " name " ] ,  description = tag_data [ " description " ] , 
 
		
	
		
			
				        self . . db_connection . create_tag ( name = tag_data [ " name " ] ,  description = tag_data [ " description " ] , 
 
		
	
		
			
				                                             aliases = tag_data [ " aliases " ] ,  implications = tag_data [ " implications " ] , 
 
		
	
		
			
				                                             category = tag_data [ " category " ] ) 
 
		
	
		
			
				        self . on_tag_search_change ( ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -875,7 +859,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        if  confirmation_reply  ==  QtWidgets . QMessageBox . No : 
 
		
	
		
			
				            return 
 
		
	
		
			
				
 
		
	
		
			
				        self . __ main. db_connection . remove_tag_by_name ( tag [ " name " ] ) 
 
		
	
		
			
				        self . . db_connection . remove_tag_by_name ( tag [ " name " ] ) 
 
		
	
		
			
				        self . on_tag_search_change ( ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  force_edit_tag_dialog ( self ,  name :  str ) : 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -891,7 +875,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        edit_dialog . set_all_categories ( ) 
 
		
	
		
			
				
 
		
	
		
			
				        tag_data  =  edit_dialog . exec_ ( ) 
 
		
	
		
			
				        logging . debug ( " Got Tag data " ,  tag_data ) 
 
		
	
		
			
				        logging . debug ( f" Got Tag data:  { tag_data } "  ) 
 
		
	
		
			
				        if  tag_data  is  None  or  len ( tag_data . keys ( ) )  ==  0 : 
 
		
	
		
			
				            return  None 
 
		
	
		
			
				        if  len ( tag_data [ " category " ] )  ==  0 : 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -904,7 +888,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				            QtWidgets . QMessageBox . information ( self ,  " Tag already exists " , 
 
		
	
		
			
				                                              " The Tag  \" {0} \"  you wanted to create already exists! Skipping... " ) 
 
		
	
		
			
				        else : 
 
		
	
		
			
				            self . __ main. db_connection . create_tag ( name = tag_data [ " name " ] ,  description = tag_data [ " description " ] , 
 
		
	
		
			
				            self . . db_connection . create_tag ( name = tag_data [ " name " ] ,  description = tag_data [ " description " ] , 
 
		
	
		
			
				                                                 aliases = tag_data [ " aliases " ] ,  implications = tag_data [ " implications " ] , 
 
		
	
		
			
				                                                 category = tag_data [ " category " ] ) 
 
		
	
		
			
				        self . on_tag_search_change ( ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -918,8 +902,8 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        if  tag  is  None  or  len ( tag )  ==  0 : 
 
		
	
		
			
				            return 
 
		
	
		
			
				
 
		
	
		
			
				        tag [ ' aliases ' ]  =  self . __ main. db_connection . get_tag_aliases_by_name ( tag [ " name " ] ) 
 
		
	
		
			
				        tag [ ' implications ' ]  =  self . __ main. db_connection . get_tag_implications ( tag [ " name " ] ) 
 
		
	
		
			
				        tag [ ' aliases ' ]  =  self . . db_connection . get_tag_aliases_by_name ( tag [ " name " ] ) 
 
		
	
		
			
				        tag [ ' implications ' ]  =  self . . db_connection . get_tag_implications ( tag [ " name " ] ) 
 
		
	
		
			
				
 
		
	
		
			
				        edit_dialog  =  TagModifyDialog ( self ,  create_tag = False ) 
 
		
	
		
			
				        edit_dialog . ui . tag_name_line . setText ( tag [ " name " ] ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -928,7 +912,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        edit_dialog . alias_selection  =  tag [ " aliases " ] 
 
		
	
		
			
				        edit_dialog . set_selected_implicated_tags ( tag [ " implications " ] ,  set_checked = True ) 
 
		
	
		
			
				        edit_dialog . implication_selection  =  tag [ " implications " ] 
 
		
	
		
			
				        edit_dialog . category_selection  =  self . __ main. db_connection . get_category_by_ID ( tag [ " category_id " ] ) [ 1 ] 
 
		
	
		
			
				        edit_dialog . category_selection  =  self . . db_connection . get_category_by_ID ( tag [ " category_id " ] ) [ 1 ] 
 
		
	
		
			
				        edit_dialog . set_all_categories ( ) 
 
		
	
		
			
				
 
		
	
		
			
				        tag_data  =  edit_dialog . exec_ ( ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -939,10 +923,10 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        if  " old_tag_name "  not  in  tag_data . keys ( ) : 
 
		
	
		
			
				            tag_data [ " old_tag_name " ]  =  None 
 
		
	
		
			
				
 
		
	
		
			
				        self . __ main. db_connection . edit_tag ( tag_id = tag [ " ID " ] , 
 
		
	
		
			
				        self . . db_connection . edit_tag ( tag_id = tag [ " ID " ] , 
 
		
	
		
			
				                                           name = tag_data [ " name " ] ,  description = tag_data [ " description " ] , 
 
		
	
		
			
				                                           aliases = tag_data [ " aliases " ] ,  implications = tag_data [ " implications " ] , 
 
		
	
		
			
				                                           category_id = self . __ main. db_connection . get_category_by_name ( tag_data [ " category " ] ) [ 0 ] ) 
 
		
	
		
			
				                                           category_id = self . . db_connection . get_category_by_name ( tag_data [ " category " ] ) [ 0 ] ) 
 
		
	
		
			
				        self . on_tag_search_change ( ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_tag_search_item_changed ( self ,  item :  QStandardItem ) : 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -966,7 +950,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				                raise  Exception ( " Something went terribly wrong! " ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_tag_search_change ( self ) : 
 
		
	
		
			
				        tags  =  self . __ main. db_connection . search_fuzzy_tag ( self . ui . tag_search_bar . text ( ) ,  all_if_empty = True ) 
 
		
	
		
			
				        tags  =  self . . db_connection . search_fuzzy_tag ( self . ui . tag_search_bar . text ( ) ,  all_if_empty = True ) 
 
		
	
		
			
				
 
		
	
		
			
				        result  =  [ ] 
 
		
	
		
			
				        for  tag_name ,  tag_desc ,  tag_category  in  tags : 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -981,7 +965,7 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        if  data  is  None : 
 
		
	
		
			
				            return 
 
		
	
		
			
				
 
		
	
		
			
				        self . __ main. db_connection . save_category ( data [ " name " ] ) 
 
		
	
		
			
				        self . . db_connection . save_category ( data [ " name " ] ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_category_deletion_clicked ( self ) : 
 
		
	
		
			
				        dialog  =  CategoryModDialog ( self ,  delete_category = True ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -990,34 +974,34 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				        if  data  is  None : 
 
		
	
		
			
				            return 
 
		
	
		
			
				
 
		
	
		
			
				        self . __ main. db_connection . remove_category ( data [ " name " ] ) 
 
		
	
		
			
				        self . . db_connection . remove_category ( data [ " name " ] ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_link_line_change ( self ) : 
 
		
	
		
			
				        self . data_changed  =  True 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_prev_unknown_image_clicked ( self ) : 
 
		
	
		
			
				        unknown_image_index  =  self . __ main. get_prev_unknown_image ( ) 
 
		
	
		
			
				        unknown_image_index  =  self . . get_prev_unknown_image ( ) 
 
		
	
		
			
				        logging . info ( " Previous unknown image clicked! " ) 
 
		
	
		
			
				
 
		
	
		
			
				        result  =  QtWidgets . QMessageBox . question ( self ,  " Switch Image? " , 
 
		
	
		
			
				                                                " Do you really want to skip to image # {1}   \" {0} \" ? " 
 
		
	
		
			
				                                                . format ( self . __ main. all_images [ unknown_image_index ] , 
 
		
	
		
			
				                                                . format ( self . . all_images [ unknown_image_index ] , 
 
		
	
		
			
				                                                        unknown_image_index ) ) 
 
		
	
		
			
				        if  result  ==  QtWidgets . QMessageBox . Yes : 
 
		
	
		
			
				            self . __ main. curr_image_index  =  unknown_image_index 
 
		
	
		
			
				            self . __ main. refresh_shown_image ( ) 
 
		
	
		
			
				            self . . curr_image_index  =  unknown_image_index 
 
		
	
		
			
				            self . . refresh_shown_image ( ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_next_unknown_image_clicked ( self ) : 
 
		
	
		
			
				        unknown_image_index  =  self . __ main. get_next_unknown_image ( ) 
 
		
	
		
			
				        unknown_image_index  =  self . . get_next_unknown_image ( ) 
 
		
	
		
			
				        logging . info ( " Next unknown image clicked! " ) 
 
		
	
		
			
				
 
		
	
		
			
				        result  =  QtWidgets . QMessageBox . question ( self ,  " Switch Image? " , 
 
		
	
		
			
				                                                " Do you really want to skip to image # {1}   \" {0} \" ? " 
 
		
	
		
			
				                                                . format ( self . __ main. all_images [ unknown_image_index ] , 
 
		
	
		
			
				                                                . format ( self . . all_images [ unknown_image_index ] , 
 
		
	
		
			
				                                                        unknown_image_index ) ) 
 
		
	
		
			
				        if  result  ==  QtWidgets . QMessageBox . Yes : 
 
		
	
		
			
				            self . __ main. curr_image_index  =  unknown_image_index 
 
		
	
		
			
				            self . __ main. refresh_shown_image ( ) 
 
		
	
		
			
				            self . . curr_image_index  =  unknown_image_index 
 
		
	
		
			
				            self . . refresh_shown_image ( ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_image_id_spinbox_changed ( self ,  v :  int ) : 
 
		
	
		
			
				        if  self . __tmp_imageid_spinbox  ==  v : 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -1027,22 +1011,22 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				                                                    . format ( self . __main . all_images [ v ] , 
 
		
	
		
			
				                                                            v ) ) 
 
		
	
		
			
				            if  result  ==  QtWidgets . QMessageBox . Yes : 
 
		
	
		
			
				                self . __ main. curr_image_index  =  v 
 
		
	
		
			
				                self . __ main. refresh_shown_image ( ) 
 
		
	
		
			
				                self . . curr_image_index  =  v 
 
		
	
		
			
				                self . . refresh_shown_image ( ) 
 
		
	
		
			
				
 
		
	
		
			
				        self . __tmp_imageid_spinbox :  int  =  v 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_delete_image_clicked ( self ) : 
 
		
	
		
			
				        logging . info ( " Delete clicked! " ) 
 
		
	
		
			
				        art_hash  =  self . __ main. get_md5_of_image ( self . curr_art_path ) 
 
		
	
		
			
				        if  self . __ main. db_connection . get_art_by_hash ( art_hash )  is  not  None : 
 
		
	
		
			
				        art_hash  =  self . . get_md5_of_image ( self . curr_art_path ) 
 
		
	
		
			
				        if  self . . db_connection . get_art_by_hash ( art_hash )  is  not  None : 
 
		
	
		
			
				            logging . debug ( " Delete on known image " ) 
 
		
	
		
			
				            confirm_result  =  QtWidgets . QMessageBox . question ( self ,  " Delete data? " ,  " Do you really wish to delete all  " 
 
		
	
		
			
				                                                                                  " data from the DB about this image? " ) 
 
		
	
		
			
				
 
		
	
		
			
				            if  confirm_result  ==  QtWidgets . QMessageBox . Yes : 
 
		
	
		
			
				                logging . info ( f " deleting image data of  \" { self . curr_image_title } \" " ) 
 
		
	
		
			
				                self . __ main. db_connection . remove_image ( art_hash ) 
 
		
	
		
			
				                self . . db_connection . remove_image ( art_hash ) 
 
		
	
		
			
				            else : 
 
		
	
		
			
				                return 
 
		
	
		
			
				
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -1053,19 +1037,23 @@ class Window(QtWidgets.QMainWindow):
 
		
	
		
			
				
 
		
	
		
			
				            if  confirm_result  ==  QtWidgets . QMessageBox . Yes : 
 
		
	
		
			
				                logging . info ( f " deleting image file  { self . curr_art_path } " ) 
 
		
	
		
			
				                self . __ main. delete_image ( self . curr_art_path ) 
 
		
	
		
			
				                self . . delete_image ( self . curr_art_path ) 
 
		
	
		
			
				            else : 
 
		
	
		
			
				                return 
 
		
	
		
			
				
 
		
	
		
			
				        self . __ main. refresh_shown_image ( ) 
 
		
	
		
			
				        self . . refresh_shown_image ( ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_link_label_activated ( self ,  link :  str ) : 
 
		
	
		
			
				        logging . debug ( " Source link activated! " ,  link ) 
 
		
	
		
			
				        logging . debug ( f" Source link activated!  { link } "  ) 
 
		
	
		
			
				        QDesktopServices . openUrl ( QUrl ( link ) ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_image_author_label_activated ( self ,  link :  str ) : 
 
		
	
		
			
				        logging . debug ( " Image author link activated! " ,  link ) 
 
		
	
		
			
				        logging . debug ( f" Image author link activated!  { link } "  ) 
 
		
	
		
			
				        QDesktopServices . openUrl ( QUrl ( link ) ) 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_description_change ( self ) : 
 
		
	
		
			
				        self . data_changed  =  True 
 
		
	
		
			
				
 
		
	
		
			
				    def  on_browser_clicked ( self ) : 
 
		
	
		
			
				        logging . debug ( " Clicked on open ArtNet browser! " ) 
 
		
	
		
			
				        self . main . switch_to_browser ( )