def __init__(self, all_lab_results):
        """

        """
        self.all_lab_results = all_lab_results
        super(MetadataFilter, self).__init__()

        self.update_selection_button = qgis.PyQt.QtWidgets.QPushButton(
            'Update selection')
        self.button_layout = RowEntry()
        self.button_layout.layout.addWidget(self.update_selection_button)

        self.show_only_selected_checkbox = qgis.PyQt.QtWidgets.QCheckBox(
            'Show only selected rows')
        self.button_layout.layout.addWidget(self.show_only_selected_checkbox)

        self.layout.addWidget(self.button_layout.widget)

        self.label = qgis.PyQt.QtWidgets.QLabel()
        self.label_layout = RowEntry()
        self.label_layout.layout.addWidget(self.label)

        self.buttonSave = qgis.PyQt.QtWidgets.QPushButton(
            'Save metadata table to file')
        self.buttonSave.setToolTip(
            ru(
                QCoreApplication.translate(
                    'Interlab4Import',
                    'save the metadata table into a csv file for examination in another application'
                )))
        self.label_layout.layout.addWidget(self.buttonSave)

        self.layout.addWidget(self.label_layout.widget)

        self.table = qgis.PyQt.QtWidgets.QTableWidget()
        self.table.setSelectionBehavior(
            qgis.PyQt.QtWidgets.QAbstractItemView.SelectRows)
        self.table.sizePolicy().setVerticalPolicy(
            qgis.PyQt.QtWidgets.QSizePolicy.MinimumExpanding)
        self.table.sizePolicy().setVerticalStretch(2)
        self.table.setSelectionMode(
            qgis.PyQt.QtWidgets.QAbstractItemView.ExtendedSelection)
        self.table.setSelectionBehavior(
            qgis.PyQt.QtWidgets.QAbstractItemView.SelectRows)
        self.table.horizontalHeader().setStretchLastSection(True)
        self.table.setSortingEnabled(True)

        self.table.itemSelectionChanged.connect(self.update_nr_of_selected)

        self.table_items = {}

        self.update_table(all_lab_results)
        self.update_nr_of_selected()
        self.layout.addWidget(self.table)
Exemplo n.º 2
0
    def __init__(self, tables_columns, file_header=None):
        super(ImportTableChooser, self).__init__()
        self.tables_columns = tables_columns
        self.file_header = file_header
        self.columns = []
        self.numeric_datatypes = db_utils.numeric_datatypes()

        chooser = RowEntry()

        self.label = qgis.PyQt.QtWidgets.QLabel(ru(QCoreApplication.translate('ImportTableChooser', 'Import to table')))
        self.__import_method = qgis.PyQt.QtWidgets.QComboBox()
        self.__import_method.addItem('')
        self.__import_method.addItems(sorted(list(tables_columns.keys()), key=lambda s: s.lower()))

        self.__import_method.currentIndexChanged.connect( self.choose_method)

        for widget in [self.label, self.__import_method]:
            chooser.layout.addWidget(widget)
        chooser.layout.insertStretch(-1, 5)

        self.layout.addWidget(chooser.widget)

        self.specific_info_widget = VRowEntry()
        self.specific_info_widget.layout.addWidget(get_line())
        self.specific_table_info = qgis.PyQt.QtWidgets.QLabel()
        self.specific_info_widget.layout.addWidget(self.specific_table_info)
        self.specific_info_widget.layout.addWidget(get_line())

        self.layout.addWidget(self.specific_info_widget.widget)
Exemplo n.º 3
0
    def __init__(self, all_lab_results, connect):
        """

        """
        self.all_lab_results = all_lab_results
        super(MetadataFilter, self).__init__()
        self.connect = connect

        self.update_selection_button = PyQt4.QtGui.QPushButton(
            u'Update selection')
        self.button_layout = RowEntry()
        self.button_layout.layout.addWidget(self.update_selection_button)

        self.show_only_selected_checkbox = PyQt4.QtGui.QCheckBox(
            u'Show only selected rows')
        self.button_layout.layout.addWidget(self.show_only_selected_checkbox)

        self.layout.addWidget(self.button_layout.widget)

        self.label = PyQt4.QtGui.QLabel()
        self.layout.addWidget(self.label)

        self.table = PyQt4.QtGui.QTableWidget()
        self.table.setSelectionBehavior(
            PyQt4.QtGui.QAbstractItemView.SelectRows)
        self.table.sizePolicy().setVerticalPolicy(
            PyQt4.QtGui.QSizePolicy.MinimumExpanding)
        self.table.sizePolicy().setVerticalStretch(2)
        self.table.setSelectionMode(
            PyQt4.QtGui.QAbstractItemView.ExtendedSelection)
        self.table.setSelectionBehavior(
            PyQt4.QtGui.QAbstractItemView.SelectRows)
        self.table.horizontalHeader().setStretchLastSection(True)
        self.table.setSortingEnabled(True)

        self.connect(self.table, PyQt4.QtCore.SIGNAL("itemSelectionChanged()"),
                     self.update_nr_of_selected)

        self.table_items = {}

        self.update_table(all_lab_results)
        self.update_nr_of_selected()
        self.layout.addWidget(self.table)
Exemplo n.º 4
0
    def __init__(self, tables_columns, connect, file_header=None):
        super(ImportTableChooser, self).__init__()
        self.connect = connect
        self.tables_columns = tables_columns
        self.file_header = file_header
        self.columns = []
        self.numeric_datatypes = db_utils.numeric_datatypes()

        chooser = RowEntry()

        self.label = PyQt4.QtGui.QLabel(
            ru(
                QCoreApplication.translate(u'ImportTableChooser',
                                           'Import to table')))
        self.__import_method = PyQt4.QtGui.QComboBox()
        self.__import_method.addItem(u'')
        self.__import_method.addItems(
            sorted(tables_columns.keys(), key=lambda s: s.lower()))

        self.connect(
            self.__import_method,
            PyQt4.QtCore.SIGNAL("currentIndexChanged(const QString&)"),
            self.choose_method)

        for widget in [self.label, self.__import_method]:
            chooser.layout.addWidget(widget)

        self.layout.addWidget(chooser.widget)

        self.specific_info_widget = VRowEntry()
        self.specific_info_widget.layout.addWidget(get_line())
        self.specific_table_info = PyQt4.QtGui.QLabel()
        self.specific_info_widget.layout.addWidget(self.specific_table_info)
        self.specific_info_widget.layout.addWidget(get_line())

        self.layout.addWidget(self.specific_info_widget.widget)

        self.layout.insertStretch(-1, 4)
Exemplo n.º 5
0
    def __init__(self, tables_columns_info, file_header, numeric_datatypes):
        self.tables_columns_info = tables_columns_info
        self.obsids_from_selection = None
        self.file_header = file_header

        self.db_column = tables_columns_info[1]
        self.column_type = tables_columns_info[2]
        self.notnull = int(tables_columns_info[3])
        pk = int(tables_columns_info[5])
        concatted_info = ', '.join([_x for _x in [self.column_type, 'not null' if self.notnull else False,
                                      'primary key' if pk else False] if _x])
        label = qgis.PyQt.QtWidgets.QLabel(' '.join(['Column ', self.db_column, '({})'.format(concatted_info)]))

        self.column_widgets = [label]
        self._all_widgets = [label]

        self.combobox = qgis.PyQt.QtWidgets.QComboBox()
        self.combobox.setEditable(True)
        self.combobox.addItem('')
        self.combobox.addItems(sorted(self.file_header, key=lambda s: s.lower()))

        if self.db_column == 'obsid':
            self.obsids_from_selection = qgis.PyQt.QtWidgets.QCheckBox(ru(QCoreApplication.translate('ColumnEntry', 'Obsid from qgis selection')))
            self.obsids_from_selection.setToolTip(ru(QCoreApplication.translate('ColumnEntry', 'Select 1 obsid from obs_points or obs_lines attribute table or map.')))
            self.obsids_from_selection.clicked.connect(lambda x: self.obsids_from_selection_checked())

            self.obsid_widget = RowEntry()
            self.obsid_widget.layout.addWidget(self.obsids_from_selection)
            self.obsid_widget.layout.addWidget(self.combobox)

            self._all_widgets.extend([self.obsids_from_selection, self.combobox, self.obsid_widget.widget])

            self.column_widgets.append(self.obsid_widget.widget)
        else:
            self.column_widgets.append(self.combobox)
            self._all_widgets.extend(self.column_widgets)

        self.static_checkbox = qgis.PyQt.QtWidgets.QCheckBox()
        self.static_checkbox.setToolTip(ru(QCoreApplication.translate('ColumnEntry', 'The supplied string will be written to the current column name for all\nimported rows instead of being read from file column.')))
        self.column_widgets.append(self.static_checkbox)
        self._all_widgets.append(self.static_checkbox)

        self._factor = qgis.PyQt.QtWidgets.QLineEdit()
        self._factor.setText('1')
        self._factor.setToolTip(ru(QCoreApplication.translate('ColumnEntry', 'Multiply each imported value in the column with a factor.')))
        self._factor.setFixedWidth(40)
        self.column_widgets.append(self._factor)
        self._all_widgets.append(self._factor)

        if self.column_type not in numeric_datatypes:
            self._factor.setVisible(False)

        self._ignore_not_null_checkbox = qgis.PyQt.QtWidgets.QCheckBox()
        self._ignore_not_null_checkbox.setToolTip(ru(QCoreApplication.translate('ColumnEntry', 'Ignores not null warning and try to import anyway. Check when importing to Postgres SERIAL PRIMARY KEY columns.')))
        self._ignore_not_null_checkbox.setChecked(False)
        self.column_widgets.append(self._ignore_not_null_checkbox)
        self._all_widgets.append(self._ignore_not_null_checkbox)

        self.static_checkbox.clicked.connect(lambda x: self.static_checkbox_checked())

        #This line prefills the columns if the header names matches the database column names
        self.file_column_name = self.db_column
Exemplo n.º 6
0
    def __init__(self, tables_columns_info, file_header, connect,
                 numeric_datatypes):
        self.tables_columns_info = tables_columns_info
        self.connect = connect
        self.obsids_from_selection = None
        self.file_header = file_header

        self.db_column = tables_columns_info[1]
        self.column_type = tables_columns_info[2]
        self.notnull = int(tables_columns_info[3])
        pk = int(tables_columns_info[5])
        concatted_info = u', '.join([
            _x for _x in [
                self.column_type, u'not null' if self.notnull else False,
                u'primary key' if pk else False
            ] if _x
        ])
        label = PyQt4.QtGui.QLabel(u' '.join(
            [u'Column ', self.db_column, u'({})'.format(concatted_info)]))

        self.column_widgets = [label]
        self._all_widgets = [label]

        self.combobox = PyQt4.QtGui.QComboBox()
        self.combobox.setEditable(True)
        self.combobox.addItem(u'')
        self.combobox.addItems(
            sorted(self.file_header, key=lambda s: s.lower()))

        if self.db_column == u'obsid':
            self.obsids_from_selection = PyQt4.QtGui.QCheckBox(
                ru(
                    QCoreApplication.translate(u'ColumnEntry',
                                               u'Obsid from qgis selection')))
            self.obsids_from_selection.setToolTip(
                ru(
                    QCoreApplication.translate(
                        u'ColumnEntry',
                        u'Select 1 obsid from obs_points or obs_lines attribute table or map.'
                    )))
            self.connect(self.obsids_from_selection,
                         PyQt4.QtCore.SIGNAL("clicked()"),
                         self.obsids_from_selection_checked)

            self.obsid_widget = RowEntry()
            self.obsid_widget.layout.addWidget(self.obsids_from_selection)
            self.obsid_widget.layout.addWidget(self.combobox)

            self._all_widgets.extend([
                self.obsids_from_selection, self.combobox,
                self.obsid_widget.widget
            ])

            self.column_widgets.append(self.obsid_widget.widget)
        else:
            self.column_widgets.append(self.combobox)
            self._all_widgets.extend(self.column_widgets)

        self.static_checkbox = PyQt4.QtGui.QCheckBox()
        self.static_checkbox.setToolTip(
            ru(
                QCoreApplication.translate(
                    u'ColumnEntry',
                    u'The supplied string will be written to the current column name for all\nimported rows instead of being read from file column.'
                )))
        self.column_widgets.append(self.static_checkbox)
        self._all_widgets.append(self.static_checkbox)

        self._factor = PyQt4.QtGui.QLineEdit()
        self._factor.setText(u'1')
        self._factor.setToolTip(
            ru(
                QCoreApplication.translate(
                    u'ColumnEntry',
                    u'Multiply each imported value in the column with a factor.'
                )))
        self._factor.setFixedWidth(40)
        self.column_widgets.append(self._factor)
        self._all_widgets.append(self._factor)

        if self.column_type not in numeric_datatypes:
            self._factor.setVisible(False)

        self.connect(self.static_checkbox, PyQt4.QtCore.SIGNAL("clicked()"),
                     self.static_checkbox_checked)

        #This line prefills the columns if the header names matches the database column names
        self.file_column_name = self.db_column