Exemple #1
0
    def init_gui(self):
        # Set integer validator for the port number
        int_validator = QIntValidator(1024, 49151)
        self.txtPort.setValidator(int_validator)

        # Load profiles
        self.load_profiles()

        # Set current profile in the combobox
        curr_profile = current_profile()
        if not curr_profile is None:
            GuiUtils.set_combo_current_index_by_text(self.cbo_profiles,
                                                     curr_profile.name)

        # Load current database connection properties
        self._load_db_conn_properties()

        # Load existing PostgreSQL connections
        self._load_qgis_pg_connections()

        # Load directory paths
        self._load_directory_paths()

        self.edtEntityRecords.setMaximum(MAX_LIMIT)
        self.edtEntityRecords.setValue(get_entity_browser_record_limit())

        # Debug logging
        lvl = debug_logging()
        if lvl:
            self.chk_logging.setCheckState(Qt.Checked)
        else:
            self.chk_logging.setCheckState(Qt.Unchecked)
Exemple #2
0
    def add_tool_buttons(self):
        """
        Add toolbar buttons of add, edit and delete buttons.
        :return: None
        :rtype: NoneType
        """
        tool_buttons = QToolBar()
        tool_buttons.setObjectName('form_toolbar')
        tool_buttons.setIconSize(QSize(16, 16))

        self.addSTR = QAction(GuiUtils.get_icon('add.png'),
                              QApplication.translate('ViewSTRWidget', 'Add'),
                              self)

        self.editSTR = QAction(GuiUtils.get_icon('edit.png'),
                               QApplication.translate('ViewSTRWidget', 'Edit'),
                               self)

        self.deleteSTR = QAction(
            GuiUtils.get_icon('remove.png'),
            QApplication.translate('ViewSTRWidget', 'Remove'), self)

        tool_buttons.addAction(self.addSTR)
        tool_buttons.addAction(self.editSTR)
        tool_buttons.addAction(self.deleteSTR)

        self.toolbarVBox.addWidget(tool_buttons)
Exemple #3
0
    def __init__(self, parent=None):
        """
        initailize class variables here
        """
        super(ProfileInstanceRecords, self).__init__(parent)
        self.setupUi(self)

        self.path = None
        self.instance_list = []
        self.relations = OrderedDict()
        self.parent_ids = {}
        self.importlogger = ImportLogger()
        self._notif_bar_str = NotificationBar(self.vlnotification)

        self.chk_all.setCheckState(Qt.Checked)
        self.entity_model = EntitiesModel()
        self.uuid_extractor = InstanceUUIDExtractor(self.path)
        self.btn_chang_dir.setIcon(GuiUtils.get_icon("open_file.png"))
        self.btn_refresh.setIcon(GuiUtils.get_icon("update.png"))

        self.chk_all.stateChanged.connect(self.change_check_state)
        # self.cbo_profile.currentIndexChanged.connect(self.current_profile_changed)
        self.btn_chang_dir.clicked.connect(self.on_directory_search)
        self.lst_widget.itemClicked.connect(self.user_selected_entities)
        self.btn_refresh.clicked.connect(self.update_files_with_custom_filter)

        self.buttonBox.button(QDialogButtonBox.Save).setText('Import')

        # self.load_config()
        self.init_file_path()
        self.current_profile_changed()
        self.change_check_state(self.chk_all.checkState())
        self.instance_dir()
Exemple #4
0
    def __init__(self, config, formatter=None, parent=None):
        QWidget.__init__(self, parent)
        EntitySearchItem.__init__(self, formatter)
        self.setupUi(self)

        self.tbSTRViewEntity.setTabIcon(0, GuiUtils.get_icon('filter.png'))
        self.tbSTRViewEntity.setTabIcon(1,
                                        GuiUtils.get_icon('period_blue.png'))

        self.config = config
        self.setConfigOptions()
        self.curr_profile = current_profile()
        self.social_tenure = self.curr_profile.social_tenure
        self.str_model = entity_model(self.social_tenure)
        # Model for storing display and actual mapping values
        self._completer_model = None
        self._proxy_completer_model = None

        # Hook up signals
        self.cboFilterCol.currentIndexChanged.connect(
            self._on_column_index_changed)
        self.init_validity_dates()
        self.validity_from_date.dateChanged.connect(self.set_minimum_to_date)
        self.validity.setDisabled(True)
        self.init_validity_checkbox()
Exemple #5
0
 def set_current_spatial_field(self, spatial_field):
     """
     Selects the current spatial field column in the combo of available
     spatial columns.
     :param spatial_field: Name of the spatial field to select.
     :type spatial_field: str
     """
     GuiUtils.set_combo_current_index_by_text(self.cboSpatialFields, spatial_field)
Exemple #6
0
 def set_referenced_table(self, referenced_table: str):
     """
     Selects the specified table in the referenced table combobox.
     :param referenced_table: Name of the referenced table.
     :type: str
     """
     if self.category() == 'View':
         GuiUtils.set_combo_index_by_data(self.cboReferencedTable,
                                          referenced_table)
Exemple #7
0
    def set_from_item(self):
        # Load referenced table editor with item configuration settings.
        photo_props = LinkedTableProps(linked_table=self._item.linked_table(),
                                       source_field=self._item.source_field(),
                                       linked_field=self._item.linked_field())

        self.ref_table.set_properties(photo_props)

        GuiUtils.set_combo_current_index_by_text(self.cbo_document_type,
                                                 self._item.document_type())
Exemple #8
0
    def __init__(self, iface):
        QDialog.__init__(self, iface.mainWindow())
        self.setupUi(self)

        QgsGui.enableAutoGeometryRestore(self)

        self.btn_composer_out_folder.setIcon(
            GuiUtils.get_icon('open_file.png'))
        self.btn_template_folder.setIcon(GuiUtils.get_icon('open_file.png'))
        self.btn_supporting_docs.setIcon(GuiUtils.get_icon('open_file.png'))

        self.iface = iface

        self.notif_bar = NotificationBar(self.vlNotification, 6000)
        self._apply_btn = self.buttonBox.button(QDialogButtonBox.Apply)
        self._reg_config = RegistryConfig()
        self._db_config = DatabaseConfig()

        version = version_from_metadata()
        #upgrade_label_text = self.label_9.text().replace(
        #'1.4', version.strip()
        #)
        #self.label_9.setText(upgrade_label_text)

        # Connect signals
        self._apply_btn.clicked.connect(self.apply_settings)
        self.buttonBox.accepted.connect(self.on_accept)
        self.chk_pg_connections.toggled.connect(self._on_use_pg_connections)
        self.cbo_pg_connections.currentIndexChanged.connect(
            self._on_pg_profile_changed)
        self.btn_db_conn_clear.clicked.connect(self.clear_properties)
        self.btn_test_db_connection.clicked.connect(self._on_test_connection)
        self.btn_supporting_docs.clicked.connect(
            self._on_choose_supporting_docs_path)
        self.btn_template_folder.clicked.connect(
            self._on_choose_doc_designer_template_path)
        self.btn_composer_out_folder.clicked.connect(
            self._on_choose_doc_generator_output_path)

        self._config = StdmConfiguration.instance()
        self._default_style_sheet = self.txtRepoLocation.styleSheet()

        #self.upgradeButton.toggled.connect(self.manage_upgrade)
        #self.manage_upgrade()

        self.init_gui()

        self.profile_entity_widget = None
        self.cache = None
        self.sort_record_widget = None

        self.tabWidget.setCurrentIndex(0)
        self.btnAdd.clicked.connect(self.add_sorting_column)
        self.init_sorting_widgets(self.cbo_profiles.currentText())
        self.cbo_profiles.currentIndexChanged.connect(self.profile_changed)
Exemple #9
0
    def _load_legend_positions(self):
        from stdm.composer.chart_configuration import legend_positions

        self.cbo_legend_pos.clear()
        for k, v in legend_positions.items():
            self.cbo_legend_pos.addItem(k, v)

        # Select 'Automatic' option
        GuiUtils.set_combo_current_index_by_text(
            self.cbo_legend_pos,
            QApplication.translate("ChartConfiguration", "Automatic"))
Exemple #10
0
    def set_configuration(self, configuration):
        self._changed_blocked = True
        GuiUtils.set_combo_current_index_by_text(self.cbo_x_field,
                                                 configuration.x_field())
        self.txt_x_label.setText(configuration.x_label())
        self.txt_y_label.setText(configuration.y_label())

        # Set barvalue configurations
        for bar_cfg in configuration.value_configurations():
            self.add_value_configuration(bar_cfg)
        self._changed_blocked = False
Exemple #11
0
    def setupUi(self):
        self.setObjectName("mirrormap")

        gridLayout = QGridLayout(self)
        gridLayout.setContentsMargins(0, 0, gridLayout.verticalSpacing(),
                                      gridLayout.verticalSpacing())

        self.canvas = QgsMapCanvas(self)
        self.canvas.setCanvasColor(QColor(255, 255, 255))
        settings = QSettings()
        gridLayout.addWidget(self.canvas, 0, 0, 1, 5)

        self.addLayerBtn = QToolButton(self)
        # self.addLayerBtn.setToolButtonStyle( Qt.ToolButtonTextBesideIcon )
        # self.addLayerBtn.setText("Add current layer")
        self.addLayerBtn.setIcon(GuiUtils.get_icon("add.png"))

        self.addLayerBtn.clicked.connect(self.tool_add_layer)
        gridLayout.addWidget(self.addLayerBtn, 1, 0, 1, 1)

        self.delLayerBtn = QToolButton(self)
        # self.delLayerBtn.setToolButtonStyle( Qt.ToolButtonTextBesideIcon )
        # self.delLayerBtn.setText("Remove current layer")
        self.delLayerBtn.setIcon(GuiUtils.get_icon("remove.png"))
        self.delLayerBtn.clicked.connect(self.tool_remove_layer)
        gridLayout.addWidget(self.delLayerBtn, 1, 1, 1, 1)

        self.renderCheck = QCheckBox("Render", self)
        self.renderCheck.toggled.connect(self.toggleRender)
        self.renderCheck.setChecked(True)
        gridLayout.addWidget(self.renderCheck, 1, 2, 1, 1)

        self.scaleFactorLabel = QLabel(self)
        self.scaleFactorLabel.setText("Scale factor:")
        self.scaleFactorLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        gridLayout.addWidget(self.scaleFactorLabel, 1, 3, 1, 1)
        self.scaleFactor = QDoubleSpinBox(self)
        self.scaleFactor.setMinimum(0.0)
        self.scaleFactor.setMaximum(1000.0)
        self.scaleFactor.setDecimals(3)
        self.scaleFactor.setValue(1)
        self.scaleFactor.setObjectName("scaleFactor")
        self.scaleFactor.setSingleStep(.05)
        gridLayout.addWidget(self.scaleFactor, 1, 4, 1, 1)
        self.scaleFactor.valueChanged.connect(self.onExtentsChanged)

        # Add a default pan tool
        self.toolPan = QgsMapToolPan(self.canvas)
        self.canvas.setMapTool(self.toolPan)

        self.scaleFactor.valueChanged.connect(self.onExtentsChanged)
        self.set_iface(self.iface)
Exemple #12
0
    def _setup_str_tab(self, is_party_unit: bool):
        """
        Creates the STR relationship tab
        """
        from stdm.ui.feature_details import DetailsTreeView

        layout = QVBoxLayout()
        hl = QHBoxLayout()

        add_btn = QToolButton(self)
        add_btn.setText(self.tr('Create STR'))
        add_btn.setIcon(GuiUtils.get_icon('add.png'))
        hl.addWidget(add_btn)
        add_btn.clicked.connect(self._create_str)

        edit_btn = QToolButton(self)
        edit_btn.setText(self.tr('Edit'))
        edit_btn.setIcon(GuiUtils.get_icon('edit.png'))
        edit_btn.setDisabled(True)
        hl.addWidget(edit_btn)

        view_document_btn = QToolButton(self)
        view_document_btn.setText(self.tr('View Supporting Documents'))
        view_document_btn.setIcon(GuiUtils.get_icon('document.png'))
        view_document_btn.setDisabled(True)
        hl.addWidget(view_document_btn)

        hl.addStretch()
        layout.addLayout(hl)

        self.details_tree_view = DetailsTreeView(
            parent=self,
            plugin=self.plugin,
            edit_button=edit_btn,
            view_document_button=view_document_btn)
        self.details_tree_view.activate_feature_details(
            True, follow_layer_selection=False)
        self.details_tree_view.model.clear()

        if is_party_unit:
            self.details_tree_view.search_party(self.entity,
                                                [self.ent_model.id])
        else:
            self.details_tree_view.search_spatial_unit(self.entity,
                                                       [self.ent_model.id])

        layout.addWidget(self.details_tree_view)
        w = QWidget()
        w.setLayout(layout)

        self.entity_tab_widget.addTab(w, self.tr('STR'))
Exemple #13
0
    def action(self):
        tb_act = QAction(
            GuiUtils.get_icon("composer_table.png"),
            QApplication.translate("TableConfig", "Add attribute table"),
            self.mainWindow())

        return tb_act
Exemple #14
0
    def action(self):
        qrcode_act = QAction(
            GuiUtils.get_icon("qrcode.png"),
            QApplication.translate("QRCodeConfig", "Add QR Code"),
            self.mainWindow())

        return qrcode_act
Exemple #15
0
    def action(self):
        dataLabelAct = QAction(
            GuiUtils.get_icon("db_field.png"),
            QApplication.translate("DataLabelConfig", "Add data label"),
            self.mainWindow())

        return dataLabelAct
Exemple #16
0
    def assignCols(self):
        # Load source and target columns respectively
        srcCols = self._source_columns()

        for c in srcCols:
            srcItem = QListWidgetItem(c, self.lstSrcFields)
            srcItem.setCheckState(Qt.Unchecked)
            srcItem.setIcon(GuiUtils.get_icon("column.png"))
            self.lstSrcFields.addItem(srcItem)

        # Destination Columns
        tabIndex = int(self.field("tabIndex"))
        self.targetTab = self.destCheckedItem.text()
        targetCols = table_column_names(self.targetTab, False, True)

        # Remove geometry columns in the target columns list
        for gc in self.geomcols:
            colIndex = getIndex(targetCols, gc)
            if colIndex != -1:
                targetCols.remove(gc)

        # Remove 'id' column if there
        id_idx = getIndex(targetCols, 'id')
        if id_idx != -1:
            targetCols.remove('id')

        self._add_target_table_columns(targetCols)
    def __init__(self, parent=None, **kwargs):
        super(ImageExportSettings, self).__init__(parent)
        self.setupUi(self)

        self.btn_path.setIcon(GuiUtils.get_icon('open_file.png'))

        self._image_tr = self.tr('Image')

        self.notif_bar = NotificationBar(self.vl_notification, 6000)

        # Connect signals
        self.btn_path.clicked.connect(self._on_choose_image_path)
        self.buttonBox.accepted.connect(self.on_accept)
        self.sb_resolution.valueChanged.connect(self._on_resolution_changed)

        # Set color button defaults
        self._default_color = Qt.white
        self.btn_color.setDefaultColor(self._default_color)
        self.btn_color.setColor(self._default_color)
        self.btn_color.setAllowOpacity(True)

        self.path = kwargs.get('image_path', '')
        self.resolution = kwargs.get('resolution', '96')
        self.background_color = kwargs.get('background', Qt.transparent)

        self._update_controls()
Exemple #18
0
    def loadColumns(self, table):
        # Load textual and spatial (if available) columns
        # Get spatial columns first
        spColumns = table_column_names(table, True, creation_order=True)
        self.cboSpatialCols_2.clear()
        self.cboSpatialCols_2.addItems(spColumns)

        # Textual Columns
        self.lstSrcCols_2.clear()
        self.allCols = table_column_names(table, creation_order=True)

        for sc in spColumns:
            colIndex = getIndex(self.allCols, sc)
            if colIndex != -1:
                self.allCols.remove(sc)

        for col in self.allCols:
            if ' ' in col:
                col = '"{}"'.format(col)

            tabItem = QListWidgetItem(col, self.lstSrcCols_2)
            tabItem.setCheckState(Qt.Unchecked)
            tabItem.setIcon(GuiUtils.get_icon("column.png"))
            self.lstSrcCols_2.addItem(tabItem)

        if len(spColumns) > 0:
            self.cboSpatialCols_2.setEnabled(True)
    def __init__(self, parent, source_cols, dest_table, dest_col, src_col):
        QDialog.__init__(self, parent)
        self.setupUi(self)

        self.btn_source_doc_folder.setIcon(GuiUtils.get_icon('open_file.png'))

        TranslatorDialogBase.__init__(self, source_cols, dest_table, dest_col,
                                      src_col)

        self._notif_bar = NotificationBar(self.vlNotification)

        # Assert if the entity supports documents
        self._assert_entity_supports_documents()

        # Set the source document directory
        self.source_document_directory = None

        # Document type name
        self._document_type_name = self._dest_col

        # Document type ID
        self._document_type_id = None

        # Set document type ID
        self._set_document_type_id()

        # Connect slots
        self.btn_source_doc_folder.clicked.connect(
            self._load_source_document_directory_selector)
Exemple #20
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.setupUi(self)

        self.btn_add_value_field.setIcon(GuiUtils.get_icon('add.png'))
        self.btn_reset_value_fields.setIcon(GuiUtils.get_icon('reset.png'))

        self._value_config_widgets = OrderedDict()

        # Connect signals
        self.btn_add_value_field.clicked.connect(
            self.on_add_value_config_widget)
        self.tb_value_config.tabCloseRequested.connect(
            self._on_tab_close_requested)
        self.btn_reset_value_fields.clicked.connect(self.clear)
Exemple #21
0
    def action(self):
        saveTemplateAct = QAction(
            GuiUtils.get_icon("save_tb.png"),
            QApplication.translate("SaveTemplateConfig",
                                   "Save document template"),
            self.mainWindow())

        return saveTemplateAct
Exemple #22
0
    def action(self):
        manageTemplatesAct = QAction(
            GuiUtils.get_icon("manage_templates.png"),
            QApplication.translate("ManageTemplatesConfig",
                                   "Manage document templates"),
            self.mainWindow())

        return manageTemplatesAct
Exemple #23
0
    def action(self):
        openTemplateAct = QAction(
            GuiUtils.get_icon("open_file.png"),
            QApplication.translate("OpenTemplateConfig",
                                   "Open document template"),
            self.mainWindow())

        return openTemplateAct
Exemple #24
0
    def __init__(self, column, parent, host):
        # Use a different pixmap
        px = GuiUtils.get_icon_pixmap('hierarchy.png')
        kwargs = {}
        kwargs['parent'] = parent
        kwargs['pixmap'] = px
        kwargs['host'] = host

        ForeignKeyLineEdit.__init__(self, column, **kwargs)
Exemple #25
0
    def __init__(self, parent=None, file_identifier=""):
        QMdiSubWindow.__init__(self, parent)
        self.setWindowIcon(GuiUtils.get_icon("photo.png"))
        self._file_identifier = file_identifier
        self._view_widget = None
        self.mdi_area = parent

        self.doc_width = None
        self.doc_height = None
Exemple #26
0
 def loadSourceTables(self):
     # Load all STDM tables
     self.lstSrcTab.clear()
     # tables = pg_tables()
     tables = profile_user_tables(self.curr_profile, True, True, sort=True)
     for t in tables.keys():
         tabItem = QListWidgetItem(t, self.lstSrcTab)
         tabItem.setIcon(GuiUtils.get_icon("table.png"))
         self.lstSrcTab.addItem(tabItem)
Exemple #27
0
 def initDialog(self):
     # Fetch references
     logoPixMap = GuiUtils.get_icon_pixmap("un_habitat.jpg")
     self.lblLogo.setPixmap(logoPixMap)
     dirP = os.path.dirname(__file__)
     normPath = str(dirP) + '\stdm\summary.txt'
     # absPath=os.path.join(str(dir),'\stdm\summary.txt')
     aboutStream = open(os.path.normpath(normPath))
     about = aboutStream.read()
Exemple #28
0
    def __init__(self, parent, entity=None, dependencies=None):
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self.label.setPixmap(GuiUtils.get_icon_pixmap('warning_large.png'))

        self.entity = entity
        self.dependencies = dependencies

        self.init_gui()
Exemple #29
0
    def setMessage(self, message, notificationType, stylesheet, font_color):
        '''
        Set display properties
        '''
        # Background color
        if notificationType == ERROR:
            # Set icon resource and frame background color
            notifPixMap = GuiUtils.get_icon_pixmap("remove.png")
        elif notificationType == SUCCESS:
            notifPixMap = GuiUtils.get_icon_pixmap("success.png")
        elif notificationType == INFORMATION:
            notifPixMap = GuiUtils.get_icon_pixmap("info_small.png")
        elif notificationType == WARNING:
            notifPixMap = GuiUtils.get_icon_pixmap("warning.png")

        self.lblNotifIcon.setPixmap(notifPixMap)
        self.lblNotifMessage.setText(message)
        self.frame.setStyleSheet(stylesheet)
        self.lblNotifMessage.setStyleSheet(font_color)
Exemple #30
0
    def _add_entity(self, entity):
        # Add entity item to view
        item = QStandardItem(
            GuiUtils.get_icon('table.png'),
            entity.short_name
        )
        item.setCheckable(True)
        item.setCheckState(Qt.Unchecked)

        self._model.appendRow(item)