Пример #1
0
    def link_clicked(self, position):
        """ View image or audio/video media in dialog.
        For A/V, added try block in case VLC bindings do not work.
        Also check existence of media, as particularly, linked files may have bad links. """

        cursor = self.ui.textBrowser.cursorForPosition(position)
        menu = QtWidgets.QMenu()
        menu.setStyleSheet("QMenu {font-size:" +
                           str(self.app.settings['fontsize']) + "pt} ")
        action_link = None
        for item in self.display_text_links:
            if cursor.position() >= item['pos0'] and cursor.position(
            ) <= item['pos1']:
                action_link = menu.addAction(_("Open"))
        action = menu.exec_(self.ui.textBrowser.mapToGlobal(position))
        if action is None:
            return

        for item in self.display_text_links:
            if cursor.position() >= item['pos0'] and cursor.position(
            ) <= item['pos1']:
                try:
                    ui = None
                    abs_path = ""
                    if item['mediapath'][:6] == "video:":
                        abs_path = item['mediapath'].split(':')[1]
                        if not os.path.exists(abs_path):
                            return
                        ui = DialogViewAV(self.app, item)
                    if item['mediapath'][:6] == "/video":
                        abs_path = self.app.project_path + item['mediapath']
                        if not os.path.exists(abs_path):
                            return
                        ui = DialogViewAV(self.app, item)
                    if item['mediapath'][:6] == "audio:":
                        abs_path = item['mediapath'].split(':')[1]
                        if not os.path.exists(abs_path):
                            return
                        ui = DialogViewAV(self.app, item)
                    if item['mediapath'][0:6] == "/audio":
                        abs_path = self.app.project_path + item['mediapath']
                        if not os.path.exists(abs_path):
                            return
                        ui = DialogViewAV(self.app, item)
                    if item['mediapath'][0:7] == "images:":
                        abs_path = item['mediapath'].split(':')[1]
                        if not os.path.exists(abs_path):
                            return
                        ui = DialogViewImage(self.app, item)
                    if item['mediapath'][0:7] == "/images":
                        abs_path = self.app.project_path + item['mediapath']
                        if not os.path.exists(abs_path):
                            return
                        ui = DialogViewImage(self.app, item)
                    ui.exec_()
                except Exception as e:
                    logger.debug(str(e))
                    print(e)
                    Message(self.app, 'view av/images error', str(e),
                            "warning").exec_()
Пример #2
0
    def view_image(self, x):
        ''' View an image file and edit the image memo. '''

        ui = DialogViewImage(self.settings, self.source[x])
        ui.exec_()
        memo = ui.ui.textEdit.toPlainText()
        if self.source[x]['memo'] != memo:
            self.source[x]['memo'] = memo
            cur = self.settings['conn'].cursor()
            cur.execute('update source set memo=? where id=?', (self.source[x]['memo'], self.source[x]['id']))
            self.settings['conn'].commit()
        if self.source[x]['memo'] == "":
            self.ui.tableWidget.setItem(x, self.MEMO_COLUMN, QtWidgets.QTableWidgetItem())
        else:
            self.ui.tableWidget.setItem(x, self.MEMO_COLUMN, QtWidgets.QTableWidgetItem("Yes"))
Пример #3
0
    def link_clicked(self, url):
        ''' View image or audio/video media in dialog.
        For A/V, added try block in case VLC bindings do not work.  '''

        x = -1
        for i in range(0, len(self.source)):
            if url.toString() == self.source[i]['mediapath']:
                x = i
        if x == -1:
            return
        ui = None
        try:
            if self.source[x]['mediapath'][:6] == "/video":
                ui = DialogViewAV(self.settings, self.source[x])
            if self.source[x]['mediapath'][:6] == "/audio":
                ui = DialogViewAV(self.settings, self.source[x])
        except Exception as e:
            logger.debug(str(e))
            print(e)
            QtWidgets.QMessageBox.warning(None, 'view av error', str(e), QtWidgets.QMessageBox.Ok)
            return
        if self.source[x]['mediapath'][:7] == "/images":
            ui = DialogViewImage(self.settings, self.source[x])
        ui.exec_()
        memo = ui.ui.textEdit.toPlainText()
        if self.source[x]['memo'] != memo:
            self.source[x]['memo'] = memo
            cur = self.settings['conn'].cursor()
            cur.execute('update source set memo=? where id=?', (self.source[x]['memo'], self.source[x]['id']))
            self.settings['conn'].commit()
Пример #4
0
    def select_file(self):
        ''' When open file button is pressed a dialog of filenames is presented to the user.
        The selected file is then used to view and for assigning text portions to cases

        Start with clear selection to save confusion of loading file text and not having it
        highlighted for a currently selected case '''

        self.ui.tableWidget.clearSelection()
        self.case_text = []
        ui = DialogSelectFile(self.source, _("Select file to view"), "single")
        ok = ui.exec_()
        if not ok:
            return
        # selected_file is dictionary with id and name
        self.selected_file = ui.get_selected()
        if self.selected_file['fulltext'] is not None:
            chars = str(len(self.selected_file['fulltext']))
            self.ui.label_filename.setText("File: " + self.selected_file['name'] + " [chars: " + chars + "]")
            self.ui.textBrowser.setText(self.selected_file['fulltext'])
            self.caseTextViewed = []
            self.unlight()
            self.highlight()
        else:
            self.ui.textBrowser.setText("")
            ui = DialogViewImage(self.settings, self.selected_file)
            ui.exec_()
            memo = ui.ui.textEdit.toPlainText()
            if self.selected_file['memo'] != memo:
                self.selected_file['memo'] = memo
                cur = self.settings['conn'].cursor()
                cur.execute('update source set memo=? where id=?',
                    (self.selected_file['memo'], self.selected_file['id']))
                self.settings['conn'].commit()
Пример #5
0
    def link_clicked(self, position):
        """ View image or audio/video media in dialog.
        For A/V, added try block in case VLC bindings do not work.  """

        cursor = self.ui.textBrowser.cursorForPosition(position)
        menu = QtWidgets.QMenu()
        menu.setStyleSheet("QMenu {font-size:" +
                           str(self.app.settings['fontsize']) + "pt} ")
        action_link = None
        for item in self.display_text_links:
            if cursor.position() >= item['pos0'] and cursor.position(
            ) <= item['pos1']:
                action_link = menu.addAction(_("Open"))
        action = menu.exec_(self.ui.textBrowser.mapToGlobal(position))
        if action is None:
            return

        for item in self.display_text_links:
            if cursor.position() >= item['pos0'] and cursor.position(
            ) <= item['pos1']:
                try:
                    ui = None
                    if item['mediapath'][:6] == "/video":
                        ui = DialogViewAV(self.app, item)
                    if item['mediapath'][:6] == "/audio":
                        ui = DialogViewAV(self.app, item)
                    if item['mediapath'][:7] == "/images":
                        ui = DialogViewImage(self.app, item)
                    ui.exec_()
                except Exception as e:
                    logger.debug(str(e))
                    print(e)
                    QtWidgets.QMessageBox.warning(None, 'view av/images error',
                                                  str(e),
                                                  QtWidgets.QMessageBox.Ok)
Пример #6
0
    def image_link_clicked(self, url):
        ''' View image in dialog. '''

        x = -1
        for i in range(0, len(self.source)):
            if url.toString() == self.source[i]['imagepath']:
                x = i
        if x == -1:
            return
        ui = DialogViewImage(self.settings, self.source[x])
        ui.exec_()
        memo = ui.ui.textEdit.toPlainText()
        if self.source[x]['memo'] != memo:
            self.source[x]['memo'] = memo
            cur = self.settings['conn'].cursor()
            cur.execute('update source set memo=? where id=?',
                        (self.source[x]['memo'], self.source[x]['id']))
            self.settings['conn'].commit()
Пример #7
0
    def view_file(self):
        """ View text file in text browser. """

        index_list = self.ui.tableWidget.selectionModel().selectedIndexes()
        index = None
        if len(index_list) > 0:
            index = index_list[0].row()
        if index is None:
            return
        self.ui.textBrowser.setText("")
        self.ui.tableWidget.selectRow(index)
        self.selected_text_file = None
        # a fulltext source is displaysed if filltext is present
        # if the mediapath is None, this represents an A/V transcribed file
        self.ui.label_file.setText(_("Displayed file: ") + self.allfiles[index][NAME])
        if self.allfiles[index][FULLTEXT] != "" and self.allfiles[index][FULLTEXT] is not None:
            self.selected_text_file = self.allfiles[index]
            self.ui.textBrowser.setText(self.allfiles[index][FULLTEXT])
            self.load_case_text()
            self.unlight()
            self.highlight()
            return
        # need the data as a dictionary to view images and audio/video
        dictionary = {'name': self.allfiles[index][NAME], 'mediapath': self.allfiles[index][MEDIAPATH],
                      'owner': self.allfiles[index][OWNER], 'id': self.allfiles[index][0], 'date': self.allfiles[index][DATE],
                      'memo': self.allfiles[index][MEMO], 'fulltext': self.allfiles[index][FULLTEXT]}
        # the mediapath will be None for a .transcribed empty text media entry, so need to check for this
        if self.allfiles[index][MEDIAPATH] is not None and self.allfiles[index][MEDIAPATH][:6] == "/video":
            ui = DialogViewAV(self.app, dictionary)
            ui.exec_()
        if self.allfiles[index][MEDIAPATH] is not None and self.allfiles[index][MEDIAPATH][:6] == "/audio":
            ui = DialogViewAV(self.app, dictionary)
            ui.exec_()
        if self.allfiles[index][MEDIAPATH] is not None and self.allfiles[index][MEDIAPATH][:7] == "/images":
            # Requires {name, mediapath, owner, id, date, memo, fulltext}
            ui = DialogViewImage(self.app, dictionary)
            ui.exec_()
Пример #8
0
    def view_file(self):
        """ View text file in qtext browser, or open image or media file.
         Check media file link works, as media may have moved. """

        index_list = self.ui.tableWidget.selectionModel().selectedIndexes()
        index = None
        if len(index_list) > 0:
            index = index_list[0].row()
        if index is None:
            return
        self.ui.textBrowser.setText("")
        self.ui.tableWidget.selectRow(index)
        self.selected_text_file = None
        # a fulltext source is displayed if filltext is present
        # if the mediapath is None, this represents an A/V transcribed file
        self.ui.label_file.setText(
            _("Displayed file: ") + self.allfiles[index][NAME])
        if self.allfiles[index][FULLTEXT] != "" and self.allfiles[index][
                FULLTEXT] is not None:
            self.selected_text_file = self.allfiles[index]
            self.ui.textBrowser.setText(self.allfiles[index][FULLTEXT])
            self.load_case_text()
            self.unlight()
            self.highlight()
            return
        # need the data as a dictionary to view images and audio/video
        dictionary = {
            'name': self.allfiles[index][NAME],
            'mediapath': self.allfiles[index][MEDIAPATH],
            'owner': self.allfiles[index][OWNER],
            'id': self.allfiles[index][0],
            'date': self.allfiles[index][DATE],
            'memo': self.allfiles[index][MEMO],
            'fulltext': self.allfiles[index][FULLTEXT]
        }
        # Mediapath will be None for a .transcribed empty text media entry, and 'docs:' for a linked text document
        if self.allfiles[index][MEDIAPATH] is None or self.allfiles[index][
                MEDIAPATH][0:5] == 'docs:':
            return
        # Added checks to test for media presence
        if self.allfiles[index][MEDIAPATH][:6] in ("/video", "video:"):
            if self.allfiles[index][MEDIAPATH][:6] == "video:":
                abs_path = self.allfiles[index][MEDIAPATH].split(':')[1]
                if not os.path.exists(abs_path):
                    return
            if self.allfiles[index][MEDIAPATH][:6] == "/video":
                abs_path = self.app.project_path + self.allfiles[index][
                    MEDIAPATH]
                if not os.path.exists(abs_path):
                    return
            ui = DialogViewAV(self.app, dictionary)
            ui.exec_()
        if self.allfiles[index][MEDIAPATH][:6] in ("/audio", "audio:"):
            if self.allfiles[index][MEDIAPATH][0:6] == "audio:":
                abs_path = self.allfiles[index][MEDIAPATH].split(':')[1]
                if not os.path.exists(abs_path):
                    return
            if self.allfiles[index][MEDIAPATH][0:6] == "/audio":
                abs_path = self.app.project_path + self.allfiles[index][
                    MEDIAPATH]
                if not os.path.exists(abs_path):
                    return
            ui = DialogViewAV(self.app, dictionary)
            ui.exec_()
        if self.allfiles[index][MEDIAPATH][:7] in ("/images", "images:"):
            if self.allfiles[index][MEDIAPATH][0:7] == "images:":
                abs_path = self.allfiles[index][MEDIAPATH].split(':')[1]
                if not os.path.exists(abs_path):
                    return
            if self.allfiles[index][MEDIAPATH][0:7] == "/images":
                abs_path = self.app.project_path + self.allfiles[index][
                    MEDIAPATH]
                if not os.path.exists(abs_path):
                    return
            # Requires {name, mediapath, owner, id, date, memo, fulltext}
            ui = DialogViewImage(self.app, dictionary)
            ui.exec_()