def _onOptionsOpen(self, filepath):
        logging.debug('controller: optionsOpen')
        if not self.canOpenOptions(filepath):
            raise IOError('Options is already opened')

        self._options_reader_thread = _OptionsReaderWrapperThread(filepath)
        func = lambda ops, f = filepath: self._onOptionsOpenReady(ops, f)
        self._options_reader_thread.resultReady.connect(func)
        self._options_reader_thread.progressUpdated.connect(self.optionsOpenProgress)
        self._options_reader_thread.exceptionRaised.connect(self.optionsOpenException)
        self._options_reader_thread.start()
    def _onOptionsReload(self, uid):
        logging.debug('controller: optionsReload')
        filepath = self._options_filepath.get(uid)
        if filepath is None:
            return

        self._options_reader_thread = _OptionsReaderWrapperThread(filepath)
        func = lambda ops, u = uid: self._onOptionsReloadReady(uid, ops)
        self._options_reader_thread.resultReady.connect(func)
        self._options_reader_thread.progressUpdated.connect(self.optionsOpenProgress)
        self._options_reader_thread.exceptionRaised.connect(self.optionsOpenException)
        self._options_reader_thread.start()
    def _onOpen(self):
        settings = get_settings()
        curdir = getattr(settings.gui, 'opendir', os.getcwd())

        filepath, namefilter = \
            QFileDialog.getOpenFileName(self, "Open", curdir,
                                        'Options [*.xml] (*.xml)')

        if not filepath or not namefilter:
            return
        settings.gui.opendir = os.path.dirname(filepath)

        if not filepath.endswith('.xml'):
            filepath += '.xml'

        self._options_reader_thread = _OptionsReaderWrapperThread(filepath)
        self._dlg_progress.canceled.connect(self._onDialogProgressCancel)
        self._options_reader_thread.resultReady.connect(self._onOpened)
        self._options_reader_thread.progressUpdated.connect(self._onDialogProgressProgress)
        self._options_reader_thread.exceptionRaised.connect(self._onDialogProgressException)
        self._options_reader_thread.start()

        self._dlg_progress.reset()
        self._dlg_progress.show()