|
|
|
@ -1,4 +1,6 @@
|
|
|
|
|
import validators, os
|
|
|
|
|
import validators
|
|
|
|
|
import os
|
|
|
|
|
import platform
|
|
|
|
|
import logging
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
@ -48,7 +50,7 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
self.curr_file_name: str = None
|
|
|
|
|
self.curr_presences: list = list()
|
|
|
|
|
self.curr_tags: list = list()
|
|
|
|
|
self.curr_imply_tags: list = list()
|
|
|
|
|
self.curr_implied_tags: list = list()
|
|
|
|
|
self.curr_tag_aliases: list = list()
|
|
|
|
|
|
|
|
|
|
self.__data_changed: bool = False
|
|
|
|
@ -79,6 +81,7 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
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_file_label.linkActivated.connect(self.on_link_file_label_activated)
|
|
|
|
|
self.ui.image_author_label.linkActivated.connect(self.on_image_author_label_activated)
|
|
|
|
|
|
|
|
|
|
self.ui.presence_docker_button.clicked.connect(self.toggle_presence_docker)
|
|
|
|
@ -88,7 +91,6 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
self.ui.description_edit.textChanged.connect(self.on_description_change)
|
|
|
|
|
|
|
|
|
|
self.ui.link_label.setText(ImporterWindow.UNKNOWN_LINK)
|
|
|
|
|
self.ui.image_file_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
|
|
|
|
|
|
|
|
|
self.ui.description_edit.setReadOnly(False)
|
|
|
|
|
|
|
|
|
@ -330,9 +332,9 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
result = re.match('[ a-zA-Z<=>"]*((https|http)://[a-zA-Z0-9]+\.[a-zA-Z0-9]+/[a-zA-Z0-9/]+)',
|
|
|
|
|
self.ui.link_label.text()).groups()
|
|
|
|
|
self.ui.link_label.text())
|
|
|
|
|
if result is not None:
|
|
|
|
|
result = result[0]
|
|
|
|
|
result = result.groups()[0]
|
|
|
|
|
else:
|
|
|
|
|
result = ""
|
|
|
|
|
return result
|
|
|
|
@ -472,16 +474,6 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
item_model.itemChanged.connect(self.on_tag_item_changed)
|
|
|
|
|
self.ui.tag_list.setModel(item_model)
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
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.data_changed = True
|
|
|
|
|
|
|
|
|
|
def set_implied_list(self, tags: list):
|
|
|
|
@ -516,6 +508,7 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
:param art_ID:
|
|
|
|
|
:param link:
|
|
|
|
|
:param file_name:
|
|
|
|
|
:param description:
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
self.curr_art_id = art_ID
|
|
|
|
@ -583,7 +576,11 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
self.ui.image_label.setAlignment(Qt.AlignCenter)
|
|
|
|
|
self.ui.image_title_line.setText(image_title)
|
|
|
|
|
self.update_window_title()
|
|
|
|
|
self.ui.image_file_label.setText(file_name)
|
|
|
|
|
|
|
|
|
|
self.ui.image_file_label.setText("<a href=\"{0}\" style=\"color: white; text-decoration: none\">{1}</a>"
|
|
|
|
|
.format(f"file:///{full_path[:-1 * len(self.curr_file_name)]}",
|
|
|
|
|
file_name))
|
|
|
|
|
self.ui.image_file_label.setToolTip(relative_path)
|
|
|
|
|
self.ui.description_edit.setText(description)
|
|
|
|
|
self.set_image_title_link(link)
|
|
|
|
|
self.set_image_id_spinbox()
|
|
|
|
@ -826,9 +823,12 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
db_data: dict = dialog.exec_()
|
|
|
|
|
if len(db_data.keys()) == 0:
|
|
|
|
|
return
|
|
|
|
|
try:
|
|
|
|
|
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"])
|
|
|
|
|
except ValueError as e: # details were wrong (probably)
|
|
|
|
|
QtWidgets.QMessageBox.warning(self, "Wrong Credentials?", f"Error: {e}")
|
|
|
|
|
|
|
|
|
|
def on_tag_creation_clicked(self):
|
|
|
|
|
logging.info("Clicked Tag Creation!")
|
|
|
|
@ -1054,6 +1054,10 @@ class ImporterWindow(ArtnetMainWindow):
|
|
|
|
|
logging.debug(f"Image author link activated! {link}")
|
|
|
|
|
QDesktopServices.openUrl(QUrl(link))
|
|
|
|
|
|
|
|
|
|
def on_link_file_label_activated(self, link: str):
|
|
|
|
|
logging.debug(f"File label link activated! {link}")
|
|
|
|
|
QDesktopServices.openUrl(QUrl(link))
|
|
|
|
|
|
|
|
|
|
def on_description_change(self):
|
|
|
|
|
self.data_changed = True
|
|
|
|
|
|
|
|
|
|