def __createTableView__(self, pageLayout): self.tableViewComposite = CompositeWidget(self, layout=QVBoxLayout()) datasource_page = self.wizard().page(self.datasource_page_id) model = CheckStateProxySortFilterModel(self) model.setSourceModel(datasource_page.getDatasourceModel()) model.setDynamicSortFilter(True) self.filesTableView = FilesTableView(self.tableViewComposite, model=model, onClickedAction=self.onClickedAction, wizardButtons=(QWizard.NextButton,), wizard_handler=self.wizard, sorting=True) self.filesTableView.setColumnHidden(0, True) self.filePreviewButton = PushButtonWidget(self.tableViewComposite, i18n="datasource.file.preview.button", i18n_def="File preview", enabled=False, clicked_handler=self.filePreviewAction) self.separatorWidget = GlobalSeparatorWidget(self.tableViewComposite, separatorHandler=self.__separatorHandler__, globalHandler=self.__globalSeparatorHandler__, enabled=False) self.__createHeaderPreviewGroup__() self.__activity__ = ActivityWidget(self) self.__timeUnitsGroup__ = self.__createTimeUnitsGroup__()
def __init__(self, parent, **params): super(DockWidgetWidget, self).__init__(nvl(params.get('title', None), ''), parent) if params.get('not_add_widget_to_parent_layout', None) == None: params['not_add_widget_to_parent_layout'] = True prepareWidget(parent=parent, widget=self, **params) self.params = Params(**params) if self.params.use_scroll_area == None: self.params.use_scroll_area = True if not self.params.dock_widget_location_changed == None: self.connect(self, DOCK_WIDGET_LOCATION_CHANGED_SIGNAL, self.__dock_widget_location_changed__) self.setObjectName(self.__class__.__name__) self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea) layout = nvl(self.params.layout, QVBoxLayout()) if hasattr(layout, 'setMargin'): layout.setMargin(0) self.scrollArea = None if self.params.use_scroll_area: self.scrollArea = QScrollArea(self) self.dockComposite = CompositeWidget( self, layout=layout, not_add_widget_to_parent_layout=True) if self.params.use_scroll_area: self.scrollArea.setWidget(self.dockComposite) self.scrollArea.setWidgetResizable(True) self.setWidget(self.scrollArea) else: self.setWidget(self.dockComposite)
def __createFilePreview__(self, parent, filename): composite = CompositeWidget(parent) layout = QVBoxLayout() composite.setLayout(layout) informationLabel = LabelWidget(composite) layout.addWidget(informationLabel) preview = PlainTextEditWidget(composite, readonly=True) layout.addWidget(preview) file_ = QFile(filename) if file_.open(QFile.ReadOnly): preview.insertPlainText(QString(file_.readAll())) preview.moveCursor(QTextCursor.Start) informationLabel.setText('Lines # ' + str(preview.document().lineCount())) file_.close() return composite
def __createFilesOperationsComposite__(self, parent): filesOperations = CompositeWidget(parent, layout=QHBoxLayout()) self.filePreviewButton = PushButtonWidget( filesOperations, i18n="datasource.file.preview.button", i18n_def="File preview", stretch_after_widget=1, clicked_handler=self.filePreviewAction, enabled_precheck_handler=self.enabledPrecheckHandler) self.selectAllButton = PushButtonWidget( filesOperations, i18n="datasource.accept.select.all.button", i18n_def="Select all", enabled=False, clicked_handler=self.__select_all_handler__, enabled_precheck_handler=self.enabledPrecheckHandler) self.unselectAllButton = PushButtonWidget( filesOperations, i18n="datasource.accept.unselect.all.button", i18n_def="Unselect all", enabled=False, clicked_handler=self.__unselect_all_handler__, enabled_precheck_handler=self.enabledPrecheckHandler)
def __createFilePreview__(self, parent, filename): composite = CompositeWidget(parent) layout = QVBoxLayout() composite.setLayout(layout) informationLabel = LabelWidget(composite) layout.addWidget(informationLabel) preview = PlainTextEditWidget(composite, readonly=True) layout.addWidget(preview) file_ = QFile(filename) if file_.open(QFile.ReadOnly): preview.insertPlainText(QString(file_.readAll())) preview.moveCursor(QTextCursor.Start) informationLabel.setText('Lines # ' + str(preview.document().lineCount())) file_.close() return composite
def __init__(self, parent, **params): get_or_put(params, 'layout', QVBoxLayout()) get_or_put(params, 'i18n_def', 'Miscellaneous') super(MiscellaneousWidget, self).__init__(parent, **params) LabelWidget(self, i18n_def='Data window shift: 1') self.params = Params(**params) self.params.data_accessor.addListener( self, __MiscellaneousVectorListener__(self)) self.__window_size__ = __DataWindowSizeWidget__( self, self.params.data_accessor) self.__unitsWidget__ = TimeUnitsWidget( self, i18n_def='Units', default_unit=self.params.data_accessor.signal_x_unit, change_unit_handler=self.changeUnit, layout=QHBoxLayout()) self.__unitsWidget__.addUnit(OrderUnit) self.__use_parameters__ = CompositeWidget(self, layout=QHBoxLayout()) self.__use_buffer__ = CheckBoxWidget(self.__use_parameters__, i18n_def='Use buffer', checked=True) self.__use_identity_line__ = CheckBoxWidget( self.__use_parameters__, i18n_def='Use identity line', checked=True) self.__sample_step__ = __SampleStepWidget__(self, self.params.data_accessor) self.__stepper_size__ = __StepperSizeWidget__( self, self.params.data_accessor)
def __init__(self, parent, data_accessor): super(__StepperSizeWidget__, self).__init__(parent, layout=QVBoxLayout()) self.data_accessor = data_accessor info_group = CompositeWidget(self, layout=QHBoxLayout()) LabelWidget(info_group, i18n_def='Stepper size:') self.__size_value__ = LabelWidget(info_group, i18n_def='<value>') self.__unit_value__ = LabelWidget(info_group, i18n_def='') self.__size_slider__ = SliderWidget( self, orientation=Qt.Horizontal, sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed), value_changed_handler=self.__value_changed__) self.__size_slider__.setTickPosition(QSlider.TicksBelow) self.setValueInUnit(self.data_accessor.signal_x_unit) self.setUnit(self.data_accessor.signal_x_unit) self.__unitsWidget__ = TimeUnitsWidget( self, i18n_def='Units', default_unit=self.data_accessor.signal_x_unit, change_unit_handler=self.changeUnit, layout=QHBoxLayout()) self.__unitsWidget__.addUnit(OrderUnit)
def __createButtons__(self): buttons_composite = CompositeWidget(self, layout=QHBoxLayout()) PushButtonWidget(buttons_composite, i18n_def="Select all", clicked_handler=self.__select_all_handler__) PushButtonWidget(buttons_composite, i18n_def="Unselect all", clicked_handler=self.__unselect_all_handler__)
def __init__(self, parent, **params): super(TachogramPlotSummaryCompositeWidget, self).__init__(parent, **params) set_temporary_settings_id(self) self.params = Params(**params) self.addToolBar( OperationalToolBarWidget(self, excluded_buttons=[CloseToolButton])) self.addToolBar(PoincareToolBarWidget(self, reload_button=True)) self.__central_widget__ = CompositeWidget( self, not_add_widget_to_parent_layout=True) layout = QVBoxLayout() self.__central_widget__.setLayout(layout) self.setCentralWidget(self.__central_widget__) self.__file_specifications__ = [] self.__selected_files_specifications_handler__ = None SignalDispatcher.addSignalSubscriber(self, CLOSE_TACHOGRAM_PLOT_SIGNAL, self.__removeFileSpecification__)
def __init__(self, parent, **params): super(TachogramPlotSummaryCompositeWidget, self).__init__(parent, **params) set_temporary_settings_id(self) self.params = Params(**params) self.addToolBar(OperationalToolBarWidget(self, excluded_buttons=[CloseToolButton])) self.addToolBar(PoincareToolBarWidget(self, reload_button=True)) self.__central_widget__ = CompositeWidget(self, not_add_widget_to_parent_layout=True) layout = QVBoxLayout() self.__central_widget__.setLayout(layout) self.setCentralWidget(self.__central_widget__) self.__file_specifications__ = [] self.__selected_files_specifications_handler__ = None SignalDispatcher.addSignalSubscriber(self, CLOSE_TACHOGRAM_PLOT_SIGNAL, self.__removeFileSpecification__)
def __create_oper_buttons__(self): buttons_composite = CompositeWidget(self, layout=QHBoxLayout()) self.__select_all__ = PushButtonWidget(buttons_composite, i18n_def="Select all", clicked_handler=self.__select_all_handler__, enabled=False) self.__unselect_all__ = PushButtonWidget(buttons_composite, i18n_def="Unselect all", clicked_handler=self.__unselect_all_handler__, enabled=False) self.__clear__ = PushButtonWidget(buttons_composite, i18n_def="Clear", clicked_handler=self.__clear_handler__, enabled=False)
def __createButtons__(self): buttons_composite = CompositeWidget(self, layout=QHBoxLayout()) self.__calculate_button__ = PushButtonWidget( buttons_composite, i18n_def="Calculate statistics", clicked_handler=self.__calculate_statistics_handler__) self.__enabled_calculation_button__(False) self.__save_outcomes_button__ = CheckBoxWidget( buttons_composite, i18n_def="Save outcomes", enabled=False) #if parameter save_outcomes_fixed_state is not None #then it's equal to checked state of save outcomes button #and this state couldn't be change later by a user if self.params.save_outcomes_fixed_state: self.__save_outcomes_button__.setChecked( self.params.save_outcomes_fixed_state)
def __createFileConstraintsComposite__(self, parent): fileConstraintsComposite = CompositeWidget(parent, layout=QHBoxLayout()) self.chooseRootDirButton = PushButtonWidget( fileConstraintsComposite, i18n="datasource.datasource.choose.root.dir.button", i18n_def="Choose root dir", clicked_handler=self.chooseRootDirAction) LabelWidget(fileConstraintsComposite, i18n="datasource.root.dir.label", i18n_def="Root dir:") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) self.rootDirLabel = LabelWidget(fileConstraintsComposite, i18n="datasource.root.dir.label", i18n_def="[Not set]", sizePolicy=sizePolicy, stretch_after_widget=1) LabelWidget(fileConstraintsComposite, i18n="datasource.file.name.filter.label", i18n_def="Files name filter") self.filesExtension = LineEditWidget( fileConstraintsComposite, maxLength=15, width=get_width_of_n_letters(14), text="*", enabled_precheck_handler=self.enabledPrecheckHandler) self.recursively = CheckBoxWidget( fileConstraintsComposite, i18n="datasource.search.files.recursively.label", i18n_def="Search files recursively", clicked_handler=self.reload, enabled_precheck_handler=self.enabledPrecheckHandler) self.onlyKnownTypes = CheckBoxWidget( fileConstraintsComposite, i18n="datasource.only.known.types.checkbox", i18n_def="Only known types", checked=True, clicked_handler=self.reload, enabled_precheck_handler=self.enabledPrecheckHandler)
def __init__(self, parent, data_accessor): super(__SampleStepWidget__, self).__init__(parent, layout=QVBoxLayout()) self.data_accessor = data_accessor info_group = CompositeWidget(self, layout=QHBoxLayout()) LabelWidget(info_group, i18n_def='Sample step:') self.__step_value__ = LabelWidget(info_group, i18n_def='<value>') self.__unit_value__ = LabelWidget(info_group, i18n_def='') self.__step_slider__ = SliderWidget( self, orientation=Qt.Horizontal, sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed), value_changed_handler=self.__value_changed__) self.__step_slider__.setTickPosition(QSlider.TicksBelow) self.setValueInSignalUnit() self.setUnit()
def __init__(self, parent, **params): super(ActivityDockWidget, self).__init__(parent, title=params.get('title', 'Activities'), **params) self.setObjectName("ActivityDockWidget") self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea) layout = QVBoxLayout() layout.setMargin(0) # no margin for internal layout self.dockComposite = CompositeWidget( self, layout=layout, not_add_widget_to_parent_layout=True) self.listWidget = ListWidgetWidget( self.dockComposite, list_item_double_clicked_handler=self.__list_item_handler__, selectionMode=QAbstractItemView.MultiSelection, sizePolicy=QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) for activity in ActivityManager.getActivities(PLUGIN_ACTIVITY_TYPE): if activity: ListWidgetItemWidget(self.listWidget, text=activity.label, data=activity) self.clearAll = PushButtonWidget(self.dockComposite, i18n="clear.all.activity.button", i18n_def="Clear all activities", clicked_handler=self.__clear_list__) self.setWidget(self.dockComposite) parent.addDockWidget(Qt.RightDockWidgetArea, self) SignalDispatcher.addSignalSubscriber(self, ADD_ACTIVITY_SIGNAL, self.__add_activity__) SignalDispatcher.addSignalSubscriber(self, CLEAR_ACTIVITIES_SIGNAL, self.__clear_list__)
def __create_misc_buttons__(self): buttons_composite = CompositeWidget(self, layout=QHBoxLayout()) self.__plain_view__ = PushButtonWidget(buttons_composite, i18n_def="Plain view", clicked_handler=self.__plain_view_handler__, enabled=False)
class TachogramPlotSummaryCompositeWidget(MainWindowWidget): """ initial tachogram plot window used to take operations on the whole group of tachogram plots """ def __init__(self, parent, **params): super(TachogramPlotSummaryCompositeWidget, self).__init__(parent, **params) set_temporary_settings_id(self) self.params = Params(**params) self.addToolBar(OperationalToolBarWidget(self, excluded_buttons=[CloseToolButton])) self.addToolBar(PoincareToolBarWidget(self, reload_button=True)) self.__central_widget__ = CompositeWidget(self, not_add_widget_to_parent_layout=True) layout = QVBoxLayout() self.__central_widget__.setLayout(layout) self.setCentralWidget(self.__central_widget__) self.__file_specifications__ = [] self.__selected_files_specifications_handler__ = None SignalDispatcher.addSignalSubscriber(self, CLOSE_TACHOGRAM_PLOT_SIGNAL, self.__removeFileSpecification__) def toolbar_maximum_handler(self): SignalDispatcher.broadcastSignal(MAXIMIZE_TACHOGRAM_PLOT_SIGNAL) def toolbar_restore_handler(self): SignalDispatcher.broadcastSignal(RESTORE_TACHOGRAM_PLOT_SIGNAL) def toolbar_close_handler(self): SignalDispatcher.broadcastSignal(CLOSE_TACHOGRAM_PLOT_SIGNAL, self) def addFileSpecification(self, _file_specification): if self.__file_specifications__.count(_file_specification) == 0: self.__file_specifications__.append(_file_specification) def reload_poincare_settings_handler(self): """ handler call by PoincareToolBarWidget toolbar reloads poincare plot settings widget """ if hasattr(self, "__poincare_settings__"): self.removeDockWidget(self.__poincare_settings__) self.layout().removeWidget(self.__poincare_settings__) self.__poincare_settings__.deleteLater() delattr(self, "__poincare_settings__") if hasattr(self, "__poincare_datasources_table__"): self.layout().removeWidget(self.__poincare_datasources_table__) self.__poincare_datasources_table__.deleteLater() delattr(self, "__poincare_datasources_table__") self.show_poincare_settings_handler() def show_poincare_settings_handler(self): """ handler call by PoincareToolBarWidget toolbar """ if self.__selected_files_specifications_handler__: selected_files_specifications = self.__selected_files_specifications_handler__() if len(selected_files_specifications) > 0: for file_specification in selected_files_specifications: self.addFileSpecification(file_specification) if len(self.__file_specifications__) == 0: InformationWindow(message="No data sources selected !") return if not hasattr(self, "__poincare_settings__"): # to convert data accessor objects based on file specification # objects to inform a user about progression special kind of # progress bar is used data_accessors_group_converter = FilesSpecificationsToDataAccessorsGroupConverter( self, self.__file_specifications__ ) data_vectors_accessor_group = data_accessors_group_converter.data_vectors_accessors_group self.__poincare_settings__ = PoincarePlotSettingsDockWidget( self, data_vectors_accessor_group=data_vectors_accessor_group, output_file_listener=self.__output_file_listener__, # save outcomes button in PoincarePlotSettingsDockWidget # have to be in fixed check state save_outcomes_fixed_state=True, ) self.__poincare_settings__.show() if not hasattr(self, "__poincare_datasources_table__"): self.__poincare_datasources_table__ = PoincarePlotDatasourcesTableWidget( self.__central_widget__, data_accessors=data_vectors_accessor_group.data_vectors_accessors ) # @IgnorePep8 self.__poincare_datasources_table__.show() def __output_file_listener__(self, _filename): if not hasattr(self, "__outcome_files_tracker__"): self.__outcome_files_tracker__ = OutcomeFilesTrackerDockWidget(self) self.__outcome_files_tracker__.show() self.__outcome_files_tracker__.appendFile(_filename) if hasattr(self, "__poincare_datasources_table__"): self.__poincare_datasources_table__.checkMarkFile(_filename) def setSelectedFilesSpecificationsHandler(self, _selected_files_specifications_handler): self.__selected_files_specifications_handler__ = _selected_files_specifications_handler def __removeFileSpecification__(self, _tachogram_plot_tab): """ method is invoked when tachogram plot is closed to remove corresponding position from self.__file_specifications__ """ if widgets_have_the_same_parent(self, _tachogram_plot_tab, TACHOGRAM_PLOT_TAB_ITEM_WIDGET_OBJECT_NAME): if self.__file_specifications__.count(_tachogram_plot_tab.file_specification) > 0: del self.__file_specifications__[ self.__file_specifications__.index(_tachogram_plot_tab.file_specification) ]
class TachogramPlotSummaryCompositeWidget(MainWindowWidget): """ initial tachogram plot window used to take operations on the whole group of tachogram plots """ def __init__(self, parent, **params): super(TachogramPlotSummaryCompositeWidget, self).__init__(parent, **params) set_temporary_settings_id(self) self.params = Params(**params) self.addToolBar( OperationalToolBarWidget(self, excluded_buttons=[CloseToolButton])) self.addToolBar(PoincareToolBarWidget(self, reload_button=True)) self.__central_widget__ = CompositeWidget( self, not_add_widget_to_parent_layout=True) layout = QVBoxLayout() self.__central_widget__.setLayout(layout) self.setCentralWidget(self.__central_widget__) self.__file_specifications__ = [] self.__selected_files_specifications_handler__ = None SignalDispatcher.addSignalSubscriber(self, CLOSE_TACHOGRAM_PLOT_SIGNAL, self.__removeFileSpecification__) def toolbar_maximum_handler(self): SignalDispatcher.broadcastSignal(MAXIMIZE_TACHOGRAM_PLOT_SIGNAL) def toolbar_restore_handler(self): SignalDispatcher.broadcastSignal(RESTORE_TACHOGRAM_PLOT_SIGNAL) def toolbar_close_handler(self): SignalDispatcher.broadcastSignal(CLOSE_TACHOGRAM_PLOT_SIGNAL, self) def addFileSpecification(self, _file_specification): if self.__file_specifications__.count(_file_specification) == 0: self.__file_specifications__.append(_file_specification) def reload_poincare_settings_handler(self): """ handler call by PoincareToolBarWidget toolbar reloads poincare plot settings widget """ if hasattr(self, '__poincare_settings__'): self.removeDockWidget(self.__poincare_settings__) self.layout().removeWidget(self.__poincare_settings__) self.__poincare_settings__.deleteLater() delattr(self, '__poincare_settings__') if hasattr(self, '__poincare_datasources_table__'): self.layout().removeWidget(self.__poincare_datasources_table__) self.__poincare_datasources_table__.deleteLater() delattr(self, '__poincare_datasources_table__') self.show_poincare_settings_handler() def show_poincare_settings_handler(self): """ handler call by PoincareToolBarWidget toolbar """ if self.__selected_files_specifications_handler__: selected_files_specifications = \ self.__selected_files_specifications_handler__() if len(selected_files_specifications) > 0: for file_specification in selected_files_specifications: self.addFileSpecification(file_specification) if len(self.__file_specifications__) == 0: InformationWindow(message='No data sources selected !') return if not hasattr(self, '__poincare_settings__'): #to convert data accessor objects based on file specification #objects to inform a user about progression special kind of #progress bar is used data_accessors_group_converter = \ FilesSpecificationsToDataAccessorsGroupConverter( self, self.__file_specifications__) data_vectors_accessor_group = \ data_accessors_group_converter.data_vectors_accessors_group self.__poincare_settings__ = PoincarePlotSettingsDockWidget( self, data_vectors_accessor_group=data_vectors_accessor_group, output_file_listener=self.__output_file_listener__, #save outcomes button in PoincarePlotSettingsDockWidget #have to be in fixed check state save_outcomes_fixed_state=True) self.__poincare_settings__.show() if not hasattr(self, '__poincare_datasources_table__'): self.__poincare_datasources_table__ = \ PoincarePlotDatasourcesTableWidget(self.__central_widget__, data_accessors=data_vectors_accessor_group.data_vectors_accessors) # @IgnorePep8 self.__poincare_datasources_table__.show() def __output_file_listener__(self, _filename): if not hasattr(self, '__outcome_files_tracker__'): self.__outcome_files_tracker__ = OutcomeFilesTrackerDockWidget( self) self.__outcome_files_tracker__.show() self.__outcome_files_tracker__.appendFile(_filename) if hasattr(self, '__poincare_datasources_table__'): self.__poincare_datasources_table__.checkMarkFile(_filename) def setSelectedFilesSpecificationsHandler( self, _selected_files_specifications_handler): self.__selected_files_specifications_handler__ = \ _selected_files_specifications_handler def __removeFileSpecification__(self, _tachogram_plot_tab): """ method is invoked when tachogram plot is closed to remove corresponding position from self.__file_specifications__ """ if widgets_have_the_same_parent( self, _tachogram_plot_tab, TACHOGRAM_PLOT_TAB_ITEM_WIDGET_OBJECT_NAME): if self.__file_specifications__.count( _tachogram_plot_tab.file_specification) > 0: del self.__file_specifications__[ self.__file_specifications__.index( _tachogram_plot_tab.file_specification)]