def __init__(self, model_node, project=None, parent_widget=None):
        '''
        @param project (OpusProject): Currently loaded project
        @param model_node (Element): template node to base the new model on
        @param parent_widget (QObject): parent object
        '''
        # parent window for the dialog box
        flags = Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMaximizeButtonHint
        QtGui.QDialog.__init__(self, parent_widget, flags)
        self.setupUi(self)

        self.model_node = copy.deepcopy(model_node)
        self.project = project

        self.fields_to_nodes = {}
        self.fields_to_data_methods = {}
        self.widgets = []

        QSP = QtGui.QSizePolicy  # temporary alias
        self.label_size_policy = QSP(QSP.Expanding, QSP.MinimumExpanding)
        self.widget_size_policy = QSP(QSP.Expanding, QSP.Maximum)
        self.description_size_policy = QSP(QSP.Fixed, QSP.Fixed)
        del QSP

        self._hide_name_warning()
        hide_widget_on_value_change(self.lbl_name_warning, self.le_model_name)

        self.le_model_name.setText('new_%s' % model_node.get('name'))
        self.le_model_name.selectAll()
        self.le_model_name.focusWidget()

        self.lbl_header.setText('Creating model from template: %s' %
                                self.model_node.get('name'))
        self._map_fields_to_nodes()
        self._generate_widgets()
    def __init__(self, parent_widget = None):
        QDialog.__init__(self, parent_widget)
        self.setupUi(self)
        self.original_variable = None
        self.variable = None
        self.validator = None
        self.callback = None
        def send_to_uc(): self.send_to_urbancanvas()
        def check_data(): self.check_variable(check = 'data')
        def check_syntax(): self.check_variable(check = 'syntax')
        self.connect(self.btnUrbanCanvas, SIGNAL("clicked()"), send_to_uc)
        self.connect(self.btnCheckData, SIGNAL("clicked()"), check_data)
        self.connect(self.btnCheckSyntax, SIGNAL("clicked()"), check_syntax)
        self.connect(self.buttonBox, SIGNAL('rejected()'), self.reject)

        self.frame_name_warning.setVisible(False)
        hide_widget_on_value_change(self.frame_name_warning, self.leVarName)

        self.group_settings.setVisible(False)
        self._toggle_settings()
        self.layout().update()
        qApp.processEvents(QEventLoop.AllEvents)

        # give instant feedback in the information label when settings are changed
        self.connect(self.rbUseBoth, SIGNAL('clicked()'), self._update_variable_info)
        self.connect(self.rbUseIndicator, SIGNAL('clicked()'), self._update_variable_info)
        self.connect(self.rbUseModel, SIGNAL('clicked()'), self._update_variable_info)
        self.connect(self.cboVarType, SIGNAL('currentIndexChanged(int)'),
                     lambda x: self._update_variable_info())
        self.connect(self.pb_change, SIGNAL("clicked()"), self._toggle_settings)
Ejemplo n.º 3
0
    def __init__(self, parent_widget = None):
        QDialog.__init__(self, parent_widget)
        self.setupUi(self)
        self.original_variable = None
        self.variable = None
        self.validator = None
        self.callback = None
        def send_to_uc(): self.send_to_urbancanvas()
        def check_data(): self.check_variable(check = 'data')
        def check_syntax(): self.check_variable(check = 'syntax')
        self.connect(self.btnUrbanCanvas, SIGNAL("clicked()"), send_to_uc)
        self.connect(self.btnCheckData, SIGNAL("clicked()"), check_data)
        self.connect(self.btnCheckSyntax, SIGNAL("clicked()"), check_syntax)
        self.connect(self.buttonBox, SIGNAL('rejected()'), self.reject)

        self.frame_name_warning.setVisible(False)
        hide_widget_on_value_change(self.frame_name_warning, self.leVarName)

        self.group_settings.setVisible(False)
        self._toggle_settings()
        self.layout().update()
        qApp.processEvents(QEventLoop.AllEvents)

        # give instant feedback in the information label when settings are changed
        self.connect(self.rbUseBoth, SIGNAL('clicked()'), self._update_variable_info)
        self.connect(self.rbUseIndicator, SIGNAL('clicked()'), self._update_variable_info)
        self.connect(self.rbUseModel, SIGNAL('clicked()'), self._update_variable_info)
        self.connect(self.cboVarType, SIGNAL('currentIndexChanged(int)'),
                     lambda x: self._update_variable_info())
        self.connect(self.pb_change, SIGNAL("clicked()"), self._toggle_settings)
    def __init__(self, model_node, project = None, parent_widget = None):
        '''
        @param project (OpusProject): Currently loaded project
        @param model_node (Element): template node to base the new model on
        @param parent_widget (QObject): parent object
        '''
        # parent window for the dialog box
        flags = Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMaximizeButtonHint
        QtGui.QDialog.__init__(self, parent_widget, flags)
        self.setupUi(self)

        self.model_node = copy.deepcopy(model_node)
        self.project = project

        self.fields_to_nodes = {}
        self.fields_to_data_methods = {}
        self.widgets = []

        QSP = QtGui.QSizePolicy # temporary alias
        self.label_size_policy = QSP(QSP.Expanding, QSP.MinimumExpanding)
        self.widget_size_policy = QSP(QSP.Expanding, QSP.Maximum)
        self.description_size_policy = QSP(QSP.Fixed, QSP.Fixed)
        del QSP

        self._hide_name_warning()
        hide_widget_on_value_change(self.lbl_name_warning, self.le_model_name)

        self.le_model_name.setText('new_%s' % model_node.get('name'))
        self.le_model_name.selectAll()
        self.le_model_name.focusWidget()

        self.lbl_header.setText('Creating model from template: %s' % self.model_node.get('name'))
        self._map_fields_to_nodes()
        self._generate_widgets()
    def __init__(self, project, parent_widget = None):
        QtGui.QDialog.__init__(self, parent_widget)
        self.setupUi(self)


        self.project = project
        self.submodel_node = None # the submodel that we are editing (a copy of actual submodel node)
        self.active_variables_node = None
        self.selector_table_model = VariableSelectorTableModel(project)

        self.tree_structure_editor.header().setStretchLastSection(True)
        self.tree_structure_editor.header().setMinimumWidth(50)

        self.frame_name_warning.setVisible(False)
        self.pb_remove_variable.setVisible(False)
        # hide the name warning when the user edit the name
        hide_widget_on_value_change(self.lbl_name_warning, self.le_name)

        S = QtCore.SIGNAL # temporarily use a shorter name for all the connections below

        self.connect(self.selector_table_model, S('layoutChanged()'), self._selector_model_column_resize)
        signal = S("currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)")
        self.connect(self.tree_structure_selector, signal, self._change_structure_node)
        signal = S('currentIndexChanged(int)')
        self.connect(self.cbo_dataset_filter, signal, self._update_available_variables)

        # Setup Variable Selector Table
        self.table_selected_variables.setModel(self.selector_table_model)
        self.table_selected_variables.horizontalHeader().setStretchLastSection(True)
        self.table_selected_variables.verticalHeader().hide()
        self.table_selected_variables.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        signal = S("customContextMenuRequested(const QPoint &)")
        self.connect(self.table_selected_variables, signal, self._right_click_variables)

        f_create_nest = lambda x = 'nest': self.tree_structure_editor.create_structure_node(x)
        f_create_equation = lambda x = 'equation': self.tree_structure_editor.create_structure_node(x)
        self.connect(self.pb_create_nest, S('released()'), f_create_nest)
        self.connect(self.pb_create_equation, S('released()'), f_create_equation)

        self.connect(self.buttonBox, S('rejected()'), self.reject)
        self.connect(self.buttonBox, S('accepted()'), self.validate_submodel_and_accept)
        # the label "OK" can be confusing when switching between the structure
        # editor and the variable selector. Some users clicked "OK" to confirm the structure changes
        # Therefore we set a more explicit label.
        self.buttonBox.button(self.buttonBox.Ok).setText('Save and Close')

        signal = S('structure_changed')
        self.connect(self.tree_structure_editor, signal, self._update_submodel_structure_trees)
        signal = S('clicked()')
        self.connect(self.pb_update_model_structure, signal, self.update_model_nested_structure)
Ejemplo n.º 6
0
    def __init__(self, old_name, taken_names, parent_widget):
        '''
        If accepted, the changed name is stored in self.accepted_name.
        @param old_name (str) the name to change from
        @param parent_widget (QWidget) parent widget for dialog
        '''
        QDialog.__init__(self, parent_widget)
        self.setupUi(self)

        self.accepted_name = ''
        self.taken_names = map(lambda x: x.strip(), taken_names)

        self.lbl_name_warning.setVisible(False)
        hide_widget_on_value_change(self.lbl_name_warning, self.leName)

        self.leName.setText(old_name.strip())
        self.leName.setFocus()
        self.leName.selectAll()

        self.setModal(True)
Ejemplo n.º 7
0
    def __init__(self, old_name, taken_names, parent_widget):
        '''
        If accepted, the changed name is stored in self.accepted_name.
        @param old_name (str) the name to change from
        @param parent_widget (QWidget) parent widget for dialog
        '''
        QDialog.__init__(self, parent_widget)
        self.setupUi(self)

        self.accepted_name = ''
        self.taken_names = map(lambda x: x.strip(), taken_names)

        self.lbl_name_warning.setVisible(False)
        hide_widget_on_value_change(self.lbl_name_warning, self.leName)

        self.leName.setText(old_name.strip())
        self.leName.setFocus()
        self.leName.selectAll()

        self.setModal(True)
Ejemplo n.º 8
0
    def __init__(self, project, parent_widget=None):
        QtGui.QDialog.__init__(self, parent_widget)
        self.setupUi(self)

        self.project = project
        self.submodel_node = None  # the submodel that we are editing (a copy of actual submodel node)
        self.active_variables_node = None
        self.selector_table_model = VariableSelectorTableModel(project)

        self.tree_structure_editor.header().setStretchLastSection(True)
        self.tree_structure_editor.header().setMinimumWidth(50)

        self.frame_name_warning.setVisible(False)
        self.pb_remove_variable.setVisible(False)
        # hide the name warning when the user edit the name
        hide_widget_on_value_change(self.lbl_name_warning, self.le_name)

        S = QtCore.SIGNAL  # temporarily use a shorter name for all the connections below

        self.connect(self.selector_table_model, S('layoutChanged()'),
                     self._selector_model_column_resize)
        signal = S("currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)")
        self.connect(self.tree_structure_selector, signal,
                     self._change_structure_node)
        signal = S('currentIndexChanged(int)')
        self.connect(self.cbo_dataset_filter, signal,
                     self._update_available_variables)

        # Setup Variable Selector Table
        self.table_selected_variables.setModel(self.selector_table_model)
        self.table_selected_variables.horizontalHeader().setStretchLastSection(
            True)
        self.table_selected_variables.verticalHeader().hide()
        self.table_selected_variables.setContextMenuPolicy(
            QtCore.Qt.CustomContextMenu)
        signal = S("customContextMenuRequested(const QPoint &)")
        self.connect(self.table_selected_variables, signal,
                     self._right_click_variables)

        f_create_nest = lambda x='nest': self.tree_structure_editor.create_structure_node(
            x)
        f_create_equation = lambda x='equation': self.tree_structure_editor.create_structure_node(
            x)
        self.connect(self.pb_create_nest, S('released()'), f_create_nest)
        self.connect(self.pb_create_equation, S('released()'),
                     f_create_equation)

        self.connect(self.buttonBox, S('rejected()'), self.reject)
        self.connect(self.buttonBox, S('accepted()'),
                     self.validate_submodel_and_accept)
        # the label "OK" can be confusing when switching between the structure
        # editor and the variable selector. Some users clicked "OK" to confirm the structure changes
        # Therefore we set a more explicit label.
        self.buttonBox.button(self.buttonBox.Ok).setText('Save and Close')

        signal = S('structure_changed')
        self.connect(self.tree_structure_editor, signal,
                     self._update_submodel_structure_trees)
        signal = S('clicked()')
        self.connect(self.pb_update_model_structure, signal,
                     self.update_model_nested_structure)