Example #1
0
    def __init__(self, connect):
        """
        This one should contain:

        Two widgets and two layouts (separate classes.

        Widget 1 contains the comboboxes and fields for producing the parameter names.

            part 1: parameter names
                option 1:
                less flexible. Choosing a table and a pre-created list of parameters/units will appear using select distinct parameter, unit from ...
                option 2:
                choosing table, then column, then distinct parameter, then table, column and distinct unit.
                This could create bad combinations of parameters and units. and takes up more space.
                Maybe these could be set using a separate pop-up dialog.

                qlineedit: final_parameter_name. This is the one that really matters. The other fields are only for help
                qcombobox: inputtype?
                qcombobox: color?

            part 2: obsids.
                obsidnames (obsid.suffix)
                sublocation-names (obsid.suffix.groupname)
                This, two qlineedits, obsid-suffix, and sublocation-suffix. (Which can be unequal or equal.

        Widget 2 contains all the obsids which will be under the first widget.

        Maybe a vertical splitter can be used to hide parts.

        QCombobox

        """
        #Widget list:

        self._input_type = import_fieldlogger.default_combobox(editable=True)
        self._hint = PyQt4.QtGui.QLineEdit()
        self._location_suffix = PyQt4.QtGui.QLineEdit()
        self._sublocation_suffix = PyQt4.QtGui.QLineEdit()
        self._final_parameter_name = PyQt4.QtGui.QLineEdit()
        self.obsid_list = CopyPasteDeleteableQListWidget()
        self.paste_from_selection_button = PyQt4.QtGui.QPushButton(u'Paste obs_points selection')
        #------------------------------------------------------------------------
        self._input_type.addItems([u'numberDecimal|numberSigned', u'numberDecimal', u'numberSigned', u'text'])
        self._input_type.setToolTip(u'(mandatory)\nDecides the keyboard layout in the Fieldlogger app.')
        self._hint.setToolTip(u'(optional)\nHint given to the Fieldlogger user for the parameter. Ex: "depth to water"')
        #-------------------------------------------------------------------------------------

        self._location_suffix.setToolTip(u'(optional)\nFieldlogger NAME = obsid.SUFFIX\nUseful for separating projects or databases\nex: suffix = 1234 --> obsid.1234')
        self._sublocation_suffix.setToolTip(u'(optional)\nFieldlogger sub-location = obsid.SUFFIX\nUseful for separating parameters into groups for the user.\nParameters sharing the same sub-location will be shown together\n ex: suffix 1234.quality --> obsid.1234.quality')
        self._final_parameter_name.setToolTip(u'(mandatory)\nFieldlogger parameter name. Ex: parameter.unit')
        #-------------------------------------------------------------------------------------
        self.obsid_list.setSelectionMode(PyQt4.QtGui.QAbstractItemView.ExtendedSelection)
        connect(self.paste_from_selection_button, PyQt4.QtCore.SIGNAL("clicked()"),
                         lambda : self.obsid_list.paste_data(utils.get_selected_features_as_tuple('obs_points')))
        connect(self._location_suffix, PyQt4.QtCore.SIGNAL("textChanged(const QString&)"),
                         lambda : self.set_sublocation_suffix(self.location_suffix))
Example #2
0
    def __init__(self, tables_columns_org, connect):

        tables_columns = {}
        for table, columns_tuple in tables_columns_org.iteritems():
            for column in columns_tuple:
                tables_columns.setdefault(table, []).append(column[1])

        self.layout = PyQt4.QtGui.QVBoxLayout()
        self.widget = PyQt4.QtGui.QWidget()
        self.widget.setLayout(self.layout)

        #Widget list
        self._parameter_table = import_fieldlogger.default_combobox(editable=False)
        self._parameter_columns = import_fieldlogger.default_combobox(editable=False)
        self._distinct_parameter = import_fieldlogger.default_combobox(editable=True)
        self._unit_table = import_fieldlogger.default_combobox(editable=False)
        self._unit_columns = import_fieldlogger.default_combobox(editable=False)
        self._distinct_unit = import_fieldlogger.default_combobox(editable=True)
        self._combined_name = PyQt4.QtGui.QLineEdit()

        # ------------------------------------------------------------------------------------
        self._parameter_table.addItems(sorted(tables_columns.keys()))
        connect(self._parameter_table, PyQt4.QtCore.SIGNAL("activated(int)"),
                     lambda: self.replace_items(self._parameter_columns, tables_columns.get(self.parameter_table, [])))
        connect(self._parameter_columns, PyQt4.QtCore.SIGNAL("activated(int)"),
                     lambda: self.replace_items(self._distinct_parameter, self.get_distinct_values(self.parameter_table, self.parameter_columns)))

        self._unit_table.addItems(sorted(tables_columns.keys()))
        connect(self._unit_table, PyQt4.QtCore.SIGNAL("activated(int)"),
                     lambda: self.replace_items(self._unit_columns, tables_columns.get(self.unit_table, [])))
        connect(self._unit_columns, PyQt4.QtCore.SIGNAL("activated(int)"),
                     lambda: self.replace_items(self._distinct_unit, self.get_distinct_values(self.unit_table, self.unit_columns)))

        connect(self._distinct_parameter, PyQt4.QtCore.SIGNAL("editTextChanged(const QString&)"),
                     lambda: self._combined_name.setText(u'.'.join([self.distinct_parameter, self.distinct_unit]) if self.distinct_parameter and self.distinct_unit else None))
        connect(self._distinct_unit, PyQt4.QtCore.SIGNAL("editTextChanged(const QString&)"),
                     lambda: self._combined_name.setText(u'.'.join([self.distinct_parameter, self.distinct_unit]) if self.distinct_parameter and self.distinct_unit else None))
        #------------------------------------------------------------------------------------
        self._combined_name.setToolTip(u'Copy value using ctrl+v, ctrl+c to parameter name.')
        #------------------------------------------------------------------------------------
        #Add widgets to layout
        for widget in [PyQt4.QtGui.QLabel(u'Parameter and\nunit browser:'),
                       PyQt4.QtGui.QLabel(u'Parameter table'),
                       self._parameter_table,
                       PyQt4.QtGui.QLabel(u'Column'),
                       self._parameter_columns,
                       PyQt4.QtGui.QLabel(u'Name'),
                       self._distinct_parameter,
                       PyQt4.QtGui.QLabel(u'Unit table'),
                       self._unit_table,
                       PyQt4.QtGui.QLabel(u'Column'),
                       self._unit_columns,
                       PyQt4.QtGui.QLabel(u'Name'),
                       self._distinct_unit,
                       PyQt4.QtGui.QLabel(u'Combined name'),
                       self._combined_name]:
            self.layout.addWidget(widget)

        add_line(self.layout)