示例#1
0
    def view_av(self, x):
        """ View an audio or video file. Edit the memo. Edit the transcribed file.
        Added try block in case VLC bindings do not work.
        """

        try:
            ui = DialogViewAV(self.settings, self.source[x])
            #ui.exec_()  # this dialog does not display well on Windows 10 so trying .show()
            self.dialogList.append(ui)
            ui.show()
            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"))
            # easy way to update transcribed files
            self.load_file_data()
        except Exception as e:
            logger.debug(e)
            print(e)
            QtWidgets.QMessageBox.warning(None, 'view av error', str(e),
                                          QtWidgets.QMessageBox.Ok)
            return
示例#2
0
    def view_av(self, x):
        """ View an audio or video file. Edit the memo. Edit the transcribed file.
        Added try block in case VLC bindings do not work.
        Uses a non-modal dialog.
        """

        try:
            ui = DialogViewAV(self.settings, self.source[x])
            #ui.exec_()  # this dialog does not display well on Windows 10 so trying .show()
            self.dialogList.append(ui)
            ui.show()
            # try and update file data here
            self.load_file_data()
            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"))
        except Exception as e:
            logger.debug(e)
            print(e)
            QtWidgets.QMessageBox.warning(None, 'view av error', str(e),
                                          QtWidgets.QMessageBox.Ok)
            return
示例#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 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)
示例#5
0
    def view_av(self, x):
        """ View an audio or video file. Edit the memo. Edit the transcribed file.
        """

        ui = DialogViewAV(self.settings, self.source[x])
        #ui.exec_()  # this dialog does not display well on Windows 10 so trying .show()
        self.dialogList.append(ui)
        ui.show()
        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"))
        # easy way to update transcribed files
        self.load_file_data()
示例#6
0
    def link_clicked(self, url):
        ''' View image or audio/video media in dialog. '''

        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
        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])
        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()
示例#7
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_()
示例#8
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_()
示例#9
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_()