Пример #1
0
 def __init__(self, mode, uuid=None, new_uuid=None, onlyClassified=False):
     super().__init__()
     self.mode = mode
     self.local_cn = get_local_connection()
     self.remote_cn = get_remote_connection()
     self.new_uuid = new_uuid
     self.uuid = uuid
     self.d = self.draw_progress_dialog()
     self.onlyClassified = onlyClassified
Пример #2
0
def updateDefinition(uuid, definition, oc):
    remote_sql = QSqlQuery(get_remote_connection())
    if oc:
        remote_sql.prepare(update_definition_query_OC)
    else:
        remote_sql.prepare(update_definition_query)
    remote_sql.bindValue(":uuid", uuid.__str__())
    remote_sql.bindValue(":definition", definition.__str__())
    if remote_sql.exec_():
        return True
    else:
        return False
Пример #3
0
def checkTerminExists(uuid, oc):
    remote_sql = QSqlQuery(get_remote_connection())
    if oc:
        remote_sql.prepare(get_definition_query_OC)
    else:
        remote_sql.prepare(get_definition_query)
    remote_sql.bindValue(":uuid", uuid.__str__())
    if remote_sql.exec_():
        if remote_sql.next():
            return True
        else:
            return False
    else:
        return False
Пример #4
0
def getDefinition(uuid, oc):
    remote_sql = QSqlQuery(get_remote_connection())
    if oc:
        remote_sql.prepare(get_definition_query_OC)
    else:
        remote_sql.prepare(get_definition_query)
    remote_sql.bindValue(":uuid", uuid.__str__())
    if remote_sql.exec_():
        if remote_sql.next():
            definition = remote_sql.value(0).__str__()
            definition = definition.replace(' ', ' ')
            definition = definition.replace(' </A>', '</A> ')
            fs = re.findall(r'<[Aa][^>]*> ', definition)
            for f in fs:
                new_f = f.strip()
                definition = definition.replace(f, new_f)
            return definition
        else:
            return None
    else:
        return None
Пример #5
0
 def fill_fields(self):
     query = QSqlQuery(get_remote_connection())
     if self.onlyClassified:
         query.prepare(get_name_and_short_def_query_OC)
     else:
         query.prepare(get_name_and_short_def_query)
     query.bindValue(':uuid', self.uuid)
     if query.exec_():
         if query.next():
             self.mainWordLabel.setText('Ссылка на термин: <b>' + query.value(0) + "</b>")
             short_def = remove_all_tags(query.value(1))
             if len(query.value(1)) < 299:
                 self.definitionLabel.setText("Определение: " + short_def)
             else:
                 self.definitionLabel.setText("Определение: " + short_def + '...')
         else:
             self.mainWordLabel.setText('Термин не найден')
             self.definitionLabel.setText("Возможно термин, на который ведет данная ссылка был удален или"
                                          " Вы подключились к другой БД. Пожалуйста, обновите список терминов.")
     else:
         print(query.lastError().text())
         print(query.lastQuery())
Пример #6
0
    def __init__(self):
        super().__init__()

        self.insert_link_attempts = 0

        self.RefreshThread = None

        self.local_cn = get_local_connection()
        self.remote_cn = get_remote_connection()
        self.setupUi(self)

        self.onlyClassified = False
        self.onlyClassifiedCheck.clicked.connect(self.switchOnlyClassified)

        self.terminNameLabel.setWordWrap(True)

        self.root = QTreeWidgetItem(self.terminsTreeWidget, ['description'])
        self.terminsTreeWidget.setRootIndex(
            self.terminsTreeWidget.indexFromItem(self.root))
        self.refreshTerminsListBtn.clicked.connect(self.refresh_termins_list)
        self.statusbar.showMessage('Версия программы: ' + Config.VERSION, -1)

        self.terminsPerPageComboBos.currentIndexChanged.connect(
            partial(self.show_termins_in_list, 1))
        self.searchLineEdit.textChanged.connect(
            partial(self.show_termins_in_list, 1))
        self.showLinkedCheck.clicked.connect(
            partial(self.show_termins_in_list, 1))

        self.root_brokenlinks = QTreeWidgetItem(self.brokenLinksTree,
                                                ['description'])
        self.brokenLinksTree.setRootIndex(
            self.brokenLinksTree.indexFromItem(self.root_brokenlinks))

        self.brokenlinksComboBox.currentIndexChanged.connect(
            partial(self.show_brokenlinks_in_list, 1))
        self.brokenlinksSearhLine.textChanged.connect(
            partial(self.show_brokenlinks_in_list, 1))

        self.show_termins_in_list(1)
        self.show_brokenlinks_in_list(1)

        self.brokenLinksTree.itemClicked.connect(
            self.brokenLinksTree_itemClicked)
        # self.terminsTreeWidget.itemClicked.connect(self.termin_tree_itemClicked)
        self.terminsTreeWidget.itemSelectionChanged.connect(
            self.termin_tree_itemClicked)

        self.refreshTerminListAction.triggered.connect(
            self.refresh_termins_list)
        self.clearTerminsListAction.triggered.connect(self.clear_termins_list)

        self.insertLinkBtn.clicked.connect(self.insert_link)

        self.saveBtn.clicked.connect(self.saveToDB)
        self.continueBtn.clicked.connect(self.saveAndContimue)
        self.passBtn.clicked.connect(self.passTerminBtn)

        self.currentPage = 1
        self.current_uuid = None

        self.decomposeLinksCheck.clicked.connect(
            partial(self.textEdit.decompose_deleted_link),
            self.decomposeLinksCheck.isChecked())

        self.BLD = None  # BrokenLinksDeleter
        self.brokenLinkOkBtn.clicked.connect(self.brockenlink_ok_btn)
        self.deleteAllBrokenBtn.clicked.connect(self.delete_All_Broken_Btn)
        self.seectReplacementBrokenLinkBtn.clicked.connect(
            self.select_link_for_replace)
        self.brokenLinksNewUuid = None

        self.settingsAction.triggered.connect(self.openSettings)
Пример #7
0
 def reconnect(self):
     print("RECON")
     self.remote_cn = get_remote_connection()