|
|
|
@ -16,14 +16,15 @@ from ArtNet.gui.dialogs.tag_select_dialog.tag_select_dialog import TagSelectDial
|
|
|
|
|
from ArtNet.gui.dockers.presence.presence_dock import PresenceDocker
|
|
|
|
|
from ArtNet.gui.dialogs.category_modify_dialog.category_mod_dialog import CategoryModDialog
|
|
|
|
|
from ArtNet.gui.dialogs.tag_import_dialog.tag_imp_dialog import TagImportDialog
|
|
|
|
|
from ArtNet.gui.dialogs.link_input_dialog.link_dialog import LinkInputDialog
|
|
|
|
|
|
|
|
|
|
from ArtNet.web.link_generator import LinkGenerator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
|
|
|
|
|
UNKNOWN_TITLE = "-Title Unknown-"
|
|
|
|
|
UNKNOWN_PRESENCE = "(Not in Database)"
|
|
|
|
|
UNKNOWN_LINK = "No Source Available"
|
|
|
|
|
|
|
|
|
|
def __init__(self, main):
|
|
|
|
|
super().__init__(main)
|
|
|
|
@ -72,7 +73,9 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
self.ui.import_button.clicked.connect(self.on_import_tags_clicked)
|
|
|
|
|
self.ui.prev_unknown_image_button.clicked.connect(self.on_prev_unknown_image_clicked)
|
|
|
|
|
self.ui.next_unknown_image_button.clicked.connect(self.on_next_unknown_image_clicked)
|
|
|
|
|
self.ui.collections_button.clicked.connect(self.on_collection_button_clicked)
|
|
|
|
|
self.ui.delete_button.clicked.connect(self.on_delete_image_clicked)
|
|
|
|
|
self.ui.link_button.clicked.connect(self.on_source_link_button_clicked)
|
|
|
|
|
|
|
|
|
|
self.ui.link_label.linkActivated.connect(self.on_link_label_activated)
|
|
|
|
|
self.ui.image_author_label.linkActivated.connect(self.on_image_author_label_activated)
|
|
|
|
@ -81,12 +84,10 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
|
|
|
|
|
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.link_label.setText(ImporterWindow.UNKNOWN_LINK)
|
|
|
|
|
self.ui.image_file_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
|
|
|
|
self.set_image_title_link()
|
|
|
|
|
|
|
|
|
|
self.ui.description_edit.setReadOnly(False)
|
|
|
|
|
|
|
|
|
@ -155,9 +156,9 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
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"], desc=image_data["description"])
|
|
|
|
|
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"])
|
|
|
|
|
|
|
|
|
|
self.set_temporary_status_message("Saved {0} ({1}) to ArtNet DB!"
|
|
|
|
|
.format(image_data["title"], image_data["ID"]), 5000)
|
|
|
|
@ -320,14 +321,14 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
|
|
|
|
|
return self.main.db_connection.search_fuzzy_categories(search)
|
|
|
|
|
|
|
|
|
|
def get_image_link_from_line(self) -> str:
|
|
|
|
|
def get_image_link_from_label(self) -> str:
|
|
|
|
|
"""
|
|
|
|
|
Gets the image link from the QLineEdit if it is a valid link.
|
|
|
|
|
Gets the image link from the label if it is a valid link.
|
|
|
|
|
|
|
|
|
|
Otherwise an empty string
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
return self.ui.link_line.text()
|
|
|
|
|
return self.ui.link_label.text()
|
|
|
|
|
|
|
|
|
|
def set_presence_label_text(self, presences: list):
|
|
|
|
|
"""
|
|
|
|
@ -335,7 +336,6 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
:param presences:
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
links = []
|
|
|
|
|
s = ""
|
|
|
|
|
for name, domain in presences:
|
|
|
|
|
full_data = self.get_presence(name, domain)
|
|
|
|
@ -355,24 +355,24 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
s = s[:-1]
|
|
|
|
|
self.ui.image_author_label.setText(s)
|
|
|
|
|
|
|
|
|
|
def set_image_title_link(self) -> str:
|
|
|
|
|
def set_image_title_link(self, link: str) -> str:
|
|
|
|
|
"""
|
|
|
|
|
Sets the Image title to a link if there is link data given for this image.
|
|
|
|
|
:return:
|
|
|
|
|
:return: Returns the result that has been set to see if a successful link was constructed
|
|
|
|
|
"""
|
|
|
|
|
self.ui.link_label.setText("No Source Available")
|
|
|
|
|
link = self.ui.link_line.text()
|
|
|
|
|
self.ui.link_label.setText(ImporterWindow.UNKNOWN_LINK)
|
|
|
|
|
|
|
|
|
|
if validators.url(link):
|
|
|
|
|
self.curr_link = link
|
|
|
|
|
self.data_changed = True
|
|
|
|
|
hyperlink = "<a href=\"{0}\">{1}</a>".format(link, "Source")
|
|
|
|
|
self.ui.link_label.setText(hyperlink)
|
|
|
|
|
self.ui.link_label.setToolTip(link)
|
|
|
|
|
return link
|
|
|
|
|
elif len(link) == 0:
|
|
|
|
|
return ""
|
|
|
|
|
else:
|
|
|
|
|
self.ui.link_label.setText("No Source Available")
|
|
|
|
|
self.ui.link_label.setText(ImporterWindow.UNKNOWN_LINK)
|
|
|
|
|
self.set_temporary_status_message("Invalid link \"{0}\" detected!".format(link), 5000)
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
@ -421,11 +421,11 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
item = QStandardItem(tag)
|
|
|
|
|
flags = Qt.ItemIsEnabled
|
|
|
|
|
|
|
|
|
|
if tag not in self.curr_imply_tags+self.curr_tag_aliases and tag not in self.curr_tags:
|
|
|
|
|
if tag not in self.curr_imply_tags + self.curr_tag_aliases and tag not in self.curr_tags:
|
|
|
|
|
# new tag and not implied yet
|
|
|
|
|
item.setData(Qt.Unchecked, Qt.CheckStateRole)
|
|
|
|
|
flags |= Qt.ItemIsUserCheckable
|
|
|
|
|
if self.curr_tags is not None and tag in (self.curr_tags+self.curr_imply_tags+self.curr_tag_aliases):
|
|
|
|
|
if self.curr_tags is not None and tag in (self.curr_tags + self.curr_imply_tags + self.curr_tag_aliases):
|
|
|
|
|
# already selected, implied or aliased tags
|
|
|
|
|
item.setCheckState(Qt.Checked)
|
|
|
|
|
item.setFlags(flags)
|
|
|
|
@ -472,7 +472,7 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
|
|
|
|
|
self.set_implied_list(implied_tags)
|
|
|
|
|
self.curr_tag_aliases = list()
|
|
|
|
|
for tag in tags+implied_tags:
|
|
|
|
|
for tag in tags + implied_tags:
|
|
|
|
|
self.curr_tag_aliases += self.main.db_connection.get_tag_aliases_by_name(tag)
|
|
|
|
|
|
|
|
|
|
self.data_changed = True
|
|
|
|
@ -520,7 +520,7 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
|
|
|
|
|
file_ending = relative_path.split(".")[-1]
|
|
|
|
|
if self.__showing_video: # remove old video from image layout
|
|
|
|
|
#self.ui.image_frame.layout().removeWidget(self.__video)
|
|
|
|
|
# self.ui.image_frame.layout().removeWidget(self.__video)
|
|
|
|
|
self.__video.hide()
|
|
|
|
|
self.ui.image_label.show()
|
|
|
|
|
if self.__showing_text: # remove text are from image layout
|
|
|
|
@ -576,10 +576,9 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
self.ui.image_label.setAlignment(Qt.AlignCenter)
|
|
|
|
|
self.ui.image_title_line.setText(image_title)
|
|
|
|
|
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_title_link(link)
|
|
|
|
|
self.set_image_id_spinbox()
|
|
|
|
|
|
|
|
|
|
self.data_changed = False # reset any triggered change detection
|
|
|
|
@ -591,7 +590,7 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
"""
|
|
|
|
|
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.main.known_image_amount / len(self.main.all_images), 5)}%)")
|
|
|
|
|
|
|
|
|
|
def set_image_id_spinbox(self):
|
|
|
|
|
"""
|
|
|
|
@ -599,7 +598,7 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
self.ui.imageNumberSpinBox.setMinimum(0)
|
|
|
|
|
self.ui.imageNumberSpinBox.setMaximum(len(self.main.all_images)-1)
|
|
|
|
|
self.ui.imageNumberSpinBox.setMaximum(len(self.main.all_images) - 1)
|
|
|
|
|
self.ui.imageNumberSpinBox.setValue(self.main.curr_image_index)
|
|
|
|
|
|
|
|
|
|
def __image_resize(self):
|
|
|
|
@ -613,7 +612,7 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
size = QSize(min(rect.width(), rect.height()), min(rect.width(), rect.height()))
|
|
|
|
|
if type(self.__pixmap) != QMovie: # using QVideoWidget?
|
|
|
|
|
pass
|
|
|
|
|
#self.__player.setScaledSize(size)
|
|
|
|
|
# self.__player.setScaledSize(size)
|
|
|
|
|
else:
|
|
|
|
|
self.__pixmap.setScaledSize(size)
|
|
|
|
|
return
|
|
|
|
@ -688,22 +687,22 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
|
|
|
|
|
def on_save_clicked(self):
|
|
|
|
|
logging.info("Clicked Save!")
|
|
|
|
|
self.set_image_title_link()
|
|
|
|
|
self.save_changes()
|
|
|
|
|
|
|
|
|
|
def on_import_tags_clicked(self):
|
|
|
|
|
logging.info("Clicked Import!")
|
|
|
|
|
dialog = TagImportDialog(self)
|
|
|
|
|
if len(self.get_image_link_from_line()) == 0 or self.get_image_link_from_line() == '(Unknown)':
|
|
|
|
|
if len(self.get_image_link_from_label()) == 0 \
|
|
|
|
|
or self.get_image_link_from_label() == ImporterWindow.UNKNOWN_LINK:
|
|
|
|
|
url = LinkGenerator.get_instance().construct_link(self.curr_file_name,
|
|
|
|
|
LinkGenerator.get_instance()
|
|
|
|
|
.predict_domain(self.curr_file_name))
|
|
|
|
|
self.ui.link_line.setText(url) # Update no link to the predicted link
|
|
|
|
|
self.set_image_title_link(url) # Update no link to the predicted link
|
|
|
|
|
else:
|
|
|
|
|
url = self.get_image_link_from_line()
|
|
|
|
|
url = self.get_image_link_from_label()
|
|
|
|
|
|
|
|
|
|
r = self.main.scrape_tags(self.curr_file_name, url=url,
|
|
|
|
|
art_ID=self.curr_art_id)
|
|
|
|
|
art_ID=self.curr_art_id)
|
|
|
|
|
|
|
|
|
|
if r is None:
|
|
|
|
|
msg = QtWidgets.QMessageBox()
|
|
|
|
@ -713,8 +712,7 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
msg.exec_()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self.ui.link_line.setText(url)
|
|
|
|
|
self.set_image_title_link()
|
|
|
|
|
self.set_image_title_link(url)
|
|
|
|
|
tags, artists = r
|
|
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
@ -788,12 +786,12 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
self.presence_docker = PresenceDocker(self)
|
|
|
|
|
self.ui.presence_docker_layout.addWidget(self.presence_docker)
|
|
|
|
|
self.presence_docker.set_selected_presences_list(self.get_current_presences())
|
|
|
|
|
self.ui.presence_docker_button.setText(">")
|
|
|
|
|
self.ui.presence_docker_button.setArrowType(Qt.RightArrow)
|
|
|
|
|
self.presence_docker_open = True
|
|
|
|
|
else:
|
|
|
|
|
logging.info("Closed presence docker!")
|
|
|
|
|
self.presence_docker.setParent(None)
|
|
|
|
|
self.ui.presence_docker_button.setText("<")
|
|
|
|
|
self.ui.presence_docker_button.setArrowType(Qt.LeftArrow)
|
|
|
|
|
|
|
|
|
|
self.presence_docker.destroy()
|
|
|
|
|
self.presence_docker = None
|
|
|
|
@ -822,8 +820,8 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
if len(db_data.keys()) == 0:
|
|
|
|
|
return
|
|
|
|
|
self.main.change_db_connection(host=db_data["host"], port=db_data["port"],
|
|
|
|
|
user=db_data["user"], password=db_data["password"],
|
|
|
|
|
database=db_data["database"])
|
|
|
|
|
user=db_data["user"], password=db_data["password"],
|
|
|
|
|
database=db_data["database"])
|
|
|
|
|
|
|
|
|
|
def on_tag_creation_clicked(self):
|
|
|
|
|
logging.info("Clicked Tag Creation!")
|
|
|
|
@ -839,8 +837,8 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
.format(tag_data["name"]))
|
|
|
|
|
return
|
|
|
|
|
self.main.db_connection.create_tag(name=tag_data["name"], description=tag_data["description"],
|
|
|
|
|
aliases=tag_data["aliases"], implications=tag_data["implications"],
|
|
|
|
|
category=tag_data["category"])
|
|
|
|
|
aliases=tag_data["aliases"], implications=tag_data["implications"],
|
|
|
|
|
category=tag_data["category"])
|
|
|
|
|
self.on_tag_search_change()
|
|
|
|
|
|
|
|
|
|
def on_tag_deletion_clicked(self):
|
|
|
|
@ -889,8 +887,8 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
"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"],
|
|
|
|
|
aliases=tag_data["aliases"], implications=tag_data["implications"],
|
|
|
|
|
category=tag_data["category"])
|
|
|
|
|
aliases=tag_data["aliases"], implications=tag_data["implications"],
|
|
|
|
|
category=tag_data["category"])
|
|
|
|
|
self.on_tag_search_change()
|
|
|
|
|
return tag_data
|
|
|
|
|
|
|
|
|
@ -924,9 +922,10 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
tag_data["old_tag_name"] = None
|
|
|
|
|
|
|
|
|
|
self.main.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])
|
|
|
|
|
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])
|
|
|
|
|
self.on_tag_search_change()
|
|
|
|
|
|
|
|
|
|
def on_tag_search_item_changed(self, item: QStandardItem):
|
|
|
|
@ -976,9 +975,6 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
|
|
|
|
|
self.main.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()
|
|
|
|
|
logging.info("Previous unknown image clicked!")
|
|
|
|
@ -1057,3 +1053,22 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
def on_browser_clicked(self):
|
|
|
|
|
logging.debug("Clicked on open ArtNet browser!")
|
|
|
|
|
self.main.switch_to_browser()
|
|
|
|
|
|
|
|
|
|
def on_source_link_button_clicked(self):
|
|
|
|
|
logging.debug("Clicked on link button!")
|
|
|
|
|
dialog = LinkInputDialog(self, self.curr_link)
|
|
|
|
|
link = dialog.exec_()
|
|
|
|
|
|
|
|
|
|
if link is None: # dialog was cancelled
|
|
|
|
|
logging.debug("Cancelled link dialog.")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
logging.info(f"Setting source link to \"{link}\"")
|
|
|
|
|
self.set_image_title_link(link)
|
|
|
|
|
|
|
|
|
|
def on_collection_button_clicked(self):
|
|
|
|
|
logging.debug("Clicked on collection button!")
|
|
|
|
|
QtWidgets.QMessageBox.information(self, "Not Implemented", "This feature has not been implemented yet!")
|
|
|
|
|
# TODO open dialog with collection selection and buttons for edit, creation and deletion
|
|
|
|
|
# TODO allow editing of the rank string
|
|
|
|
|
# TODO make collection inspectable (a list of all entries with their rank string would suffice)
|
|
|
|
|