def gui_run(self, gui_context): """This method is called inside the GUI thread, by default it executes the :meth:`model_run` in the Model thread. :param gui_context: the context available in the *GUI thread*, of type :class:`GuiContext` """ from camelot.view.controls.progress_dialog import ProgressDialog progress_dialog = None # only create a progress dialog if there is none yet, or if the # existing dialog was canceled LOGGER.debug('action gui run started') if gui_context.progress_dialog and gui_context.progress_dialog.wasCanceled( ): gui_context.progress_dialog = None if gui_context.progress_dialog == None: LOGGER.debug('create new progress dialog') progress_dialog = ProgressDialog(unicode(self.verbose_name)) gui_context.progress_dialog = progress_dialog #progress_dialog.show() super(Action, self).gui_run(gui_context) # only close the progress dialog if it was created here if progress_dialog != None: progress_dialog.close() gui_context.progress_dialog = None LOGGER.debug('gui run finished')
def delete_selected_rows(self): assert object_thread( self ) logger.debug( 'delete selected rows called' ) confirmed = True rows = set( index.row() for index in self.selectedIndexes() ) if not rows: return if self._admin.get_delete_mode()=='on_confirm': if QtGui.QMessageBox.question(self, _('Please confirm'), unicode(self._admin.get_delete_message(None)), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No: confirmed = False if confirmed: # # if there is an open editor on a row that will be deleted, there # might be an assertion failure in QT, or the data of the editor # might be pushed to the row that replaces the deleted one # progress_dialog = ProgressDialog(_('Removing')) self.model().rows_removed_signal.connect( progress_dialog.finished ) self.model().exception_signal.connect( progress_dialog.exception ) self.close_editor() self.model().remove_rows( set( rows ) ) progress_dialog.exec_()
def gui_run( self, gui_context ): """This method is called inside the GUI thread, by default it executes the :meth:`model_run` in the Model thread. :param gui_context: the context available in the *GUI thread*, of type :class:`GuiContext` """ from camelot.view.controls.progress_dialog import ProgressDialog progress_dialog = None # only create a progress dialog if there is none yet, or if the # existing dialog was canceled LOGGER.debug( 'action gui run started' ) if gui_context.progress_dialog and gui_context.progress_dialog.wasCanceled(): gui_context.progress_dialog = None if gui_context.progress_dialog == None: LOGGER.debug( 'create new progress dialog' ) progress_dialog = ProgressDialog( unicode( self.verbose_name ) ) gui_context.progress_dialog = progress_dialog #progress_dialog.show() super(Action, self).gui_run( gui_context ) # only close the progress dialog if it was created here if progress_dialog != None: progress_dialog.close() gui_context.progress_dialog = None LOGGER.debug( 'gui run finished' )
def delete_selected_rows(self): logger.debug("delete selected rows called") confirmation_message = self._admin.get_confirm_delete() confirmed = True rows = set(index.row() for index in self.selectedIndexes()) if not rows: return if confirmation_message: if ( QtGui.QMessageBox.question( self, _("Please confirm"), unicode(confirmation_message), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No, ) == QtGui.QMessageBox.No ): confirmed = False if confirmed: # # if there is an open editor on a row that will be deleted, there # might be an assertion failure in QT # progress_dialog = ProgressDialog(_("Removing")) self.model().rows_removed_signal.connect(progress_dialog.finished) self.model().exception_signal.connect(progress_dialog.exception) self.close_editor() self.model().remove_rows(set(rows)) progress_dialog.exec_()
def is_connection_valid(self): profilename, info = self.collect_info() mt = SignalSlotModelThread(lambda:None) mt.start() progress = ProgressDialog(_('Verifying database settings')) mt.post(lambda:self.test_connection( info ), progress.finished, progress.exception) progress.exec_() return self._connection_valid
def is_connection_valid(self): profilename, info = self.collect_info() mt = SignalSlotModelThread(lambda: None) mt.start() progress = ProgressDialog(_('Verifying database settings')) mt.post(lambda: self.test_connection(info), progress.finished, progress.exception) progress.exec_() return self._connection_valid
def is_connection_valid(self): info = self.collect_info() mt = SignalSlotModelThread(lambda: None) mt.start() progress = ProgressDialog(_("Verifying database settings")) mt.post( lambda: self.test_connection(info["dialect"], info["host"], info["user"], info["pass"], info["database"]), progress.finished, progress.exception, ) progress.exec_() return self._connection_valid
def test_update_progress( self ): from camelot.view.controls.progress_dialog import ProgressDialog update_progress = action_steps.UpdateProgress( 20, 100, _('Importing data') ) self.assertTrue( unicode( update_progress ) ) # give the gui context a progress dialog, so it can be updated self.gui_context.progress_dialog = ProgressDialog('Progress') update_progress.gui_run( self.gui_context ) # now press the cancel button self.gui_context.progress_dialog.cancel() with self.assertRaises( CancelRequest ): update_progress.gui_run( self.gui_context )
def delete_selected_rows(self): logger.debug('delete selected rows called') confirmation_message = self._admin.get_confirm_delete() confirmed = True rows = set(index.row() for index in self.selectedIndexes()) if not rows: return if confirmation_message: if QtGui.QMessageBox.question( self, _('Please confirm'), unicode(confirmation_message), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No: confirmed = False if confirmed: # # if there is an open editor on a row that will be deleted, there # might be an assertion failure in QT # progress_dialog = ProgressDialog(_('Removing')) self.model().rows_removed_signal.connect(progress_dialog.finished) self.model().exception_signal.connect(progress_dialog.exception) self.close_editor() self.model().remove_rows(set(rows)) progress_dialog.exec_()