예제 #1
0
    def __init__(self, view):
        """ Basic item delegate that returns the views default item delegate or depending
            on the item type column: an appropriate custom render setting item delegate.

        :param modules.itemview.treeview.KnechtTreeView view: View we replace delegates in
        """
        super(OutputDirButton, self).__init__(view)
        self.file_dlg = FileDialog()
예제 #2
0
    def convert_image_directory(self):
        img_dir = FileDialog.open_dir(self.ui, None)

        if not img_dir or not path_exists(img_dir):
            self.ui.msg(
                _('Zu konvertierendes Verzeichnis ist nicht erreichbar.'),
                8000)
            return

        img_dir = Path(img_dir)
        out_dir = img_dir / 'converted'

        try:
            out_dir.mkdir(exist_ok=True)
        except Exception as e:
            self.ui.msg(
                _('Konnte Bild Konvertierung Ausgabeverzeichnis nicht erstellen.'
                  ), 8000)
            LOGGER.warning(e)

        img_converter = KnechtImage(self)
        img_converter.conversion_result.connect(self._conversion_result)

        if img_converter.convert_directory(img_dir, out_dir):
            self.ui.msg(
                _('Bildkonvertierung gestartet.<br /><i>{}</i>').format(
                    img_dir), 5000)
        else:
            self.ui.msg(
                _('Bildkonvertierung konnte nicht gestartet werden. Keine konvertierbaren Dateien gefunden.'
                  ), 10000)
예제 #3
0
    def open_xml(self, file: str = None) -> None:
        self.enable_menus(False)

        if not file:
            file = FileDialog.open(self.ui, None, 'xml')

        if not file:
            LOGGER.info('Open Xml File dialog canceled.')
            self.enable_menus(True)
            return

        # Check if the file is already opened
        file = Path(file)
        if self.view_mgr.file_mgr.already_open(file):
            LOGGER.info('File already open.')
            self.enable_menus(True)
            return

        # Update treeview progress
        view = self.view_mgr.current_view()
        view.progress_msg.msg(_('Daten werden gelesen'))
        view.progress_msg.show_progress()

        self.load_save_mgr.open(file)
        self.enable_menus(True)
예제 #4
0
    def save_as_xml(self, file: Path = None):
        if not self.view_mgr.current_tab_is_document_tab():
            return

        self.enable_menus(False)

        if not file:
            current_dir = Path(KnechtSettings.app['current_path'])
            file, file_type = FileDialog.save(self.ui,
                                              current_dir,
                                              file_key='xml')

        if not file:
            LOGGER.info('Save Xml File dialog canceled.')
            self.enable_menus(True)
            return

        file = Path(file)
        view = self.view_mgr.current_view()

        result, error = self.load_save_mgr.save(file, view)

        if result:
            LOGGER.debug('File saved: %s', file.as_posix())
            self.view_mgr.tab_view_saved(file)
            self.ui.msg(
                _('Datei gespeichert:{0}{1:.3}s').format(
                    f'\n{file.name}\n', self.load_save_mgr.last_progress_time))
        else:
            self._save_aborted(error, file)

        self.enable_menus(True)
예제 #5
0
    def open_xlsx(self, file: Path = None, pos_file: Path = None):
        if not file:
            file = FileDialog.open(self.ui, None, 'xlsx')

        if not file:
            LOGGER.info('Open Xlsx File dialog canceled.')
            return

        xl_dialog = ExcelImportDialog(self.ui, Path(file), pos_file)
        xl_dialog.destroyed.connect(self._report_destroyed)
        xl_dialog.finished.connect(self.xlsx_result)

        # Create V Plus Import tab
        GenericTabWidget(self.ui, xl_dialog)
예제 #6
0
class OutputDirButton(KnechtValueDelegate):
    def __init__(self, view):
        """ Basic item delegate that returns the views default item delegate or depending
            on the item type column: an appropriate custom render setting item delegate.

        :param modules.itemview.treeview.KnechtTreeView view: View we replace delegates in
        """
        super(OutputDirButton, self).__init__(view)
        self.file_dlg = FileDialog()

    def create_editor(self, parent, option, index):
        editor = QPushButton(parent)
        editor.setIcon(IconRsc.get_icon('folder'))
        editor.index = index
        editor.output_dir = ''
        editor.pressed.connect(self.set_file_path)
        return editor

    def set_file_path(self):
        editor = self.sender()
        current_dir = editor.index.siblingAtColumn(Kg.VALUE).data(
            Qt.DisplayRole)
        if not os.path.exists(current_dir):
            current_dir = None

        output_dir = self.file_dlg.open_existing_directory(
            directory=current_dir)

        if output_dir:
            """
            We do not call the setModelData method and therefore need to create our undo command ourself
            """
            undo_cmd = ItemEditUndoCommand(current_dir,
                                           output_dir,
                                           editor.index,
                                           editing_done=False)
            self.view.undo_stack.push(undo_cmd)
            self.view.undo_stack.setActive(True)

    @staticmethod
    def set_editor_data(editor, index):
        pass

    @staticmethod
    def set_model_data(editor, model, index):
        pass
예제 #7
0
    def open_session_file(self, file: str = None):
        if not file:
            file = FileDialog.open(self.ui, None, 'rksession')

        if not file:
            # File dialog canceled
            return

        if not self.restart_session():
            return

        result = self.session.load(Path(file))

        if result:
            self.ui.msg(_('Wizard Session geladen.'))
        else:
            self.ui.msg(_('Fehler beim Laden der Wizard Session Datei.'))
예제 #8
0
    def save_session_file(self, file: str = None):
        if not file:
            file, file_type = FileDialog.save(
                self.ui, Path(KnechtSettings.app['current_path']), 'rksession')

        if not file:
            # File dialog canceled
            return

        result = self.session.save(Path(file))

        if result:
            self.ui.msg(_('Wizard Session gespeichert.'))
            # Add recent file entry
            KnechtSettings.add_recent_file(file, 'rksession')
        else:
            self.ui.msg(_('Fehler beim Speichern der Wizard Session.'))