コード例 #1
0
    def configurePlugin(self):
        if Settings.isPluginConfigured():
            prefs = PreferencesDialog(self.iface.mainWindow())
        else:
            prefs = PreferencesWizard(self.iface.mainWindow())

        ok = prefs.exec_() and prefs.preferences().projectsDir().exists()

        if ok:
            Settings.setUserFullName(prefs.preferences().userFullName())
            Settings.setUserInitials(prefs.preferences().userInitials())
            Settings.setUserOrganisation(prefs.preferences().userOrganisation())
            Settings.setProjectsFolder(prefs.preferences().projectsFolder())

            Settings.setServerUrl(prefs.server().url())
            Settings.setServerCredentials(prefs.server().user(), prefs.server().password())

            if prefs.globals().crs().authid():
                Application.setLayerDefaultCrs(prefs.globals().crs())
                Application.setProjectDefaultCrs(prefs.globals().crs())
            if prefs.globals().forceDefaultCrs():
                Application.setForceDefaultCrs()
            if prefs.globals().forceOtfTransform():
                Application.setForceOftTransfom()

            Snapping.setDefaultSnappingTolerance(prefs.globals().snappingTolerance())
            Snapping.setDefaultSnappingUnit(prefs.globals().snappingUnit())

            Application.setComposerFont(prefs.globals().font())

            Settings.setPluginConfigured()

        return ok
コード例 #2
0
    def __init__(self, plugin, view):
        QgsLayerTreeViewMenuProvider.__init__(self)
        self._plugin = plugin
        self._view = view

        # Default actions
        self._zoomGroup = self._view.defaultActions().actionZoomToGroup(
            self._plugin.mapCanvas())
        self._zoomLayer = self._view.defaultActions().actionZoomToLayer(
            self._plugin.mapCanvas())
        self._featureCount = self._view.defaultActions(
        ).actionShowFeatureCount(self._plugin.mapCanvas())
        self._remove = self._view.defaultActions().actionRemoveGroupOrLayer(
            self._plugin.mapCanvas())
        self._rename = self._view.defaultActions().actionRenameGroupOrLayer(
            self._plugin.mapCanvas())

        # Custom actions
        self._removeDrawings = QAction('Remove All Drawings', view)
        self._removeDrawings.triggered.connect(self._plugin.clearDrawings)

        self._openAttributes = QAction(
            Application.getThemeIcon('mActionOpenTable.svg'),
            plugin.tr('&Open Attribute Table'), view)
        self._openAttributes.triggered.connect(self._showAttributeTable)

        self._openProperties = QAction(plugin.tr('&Properties'), view)
        self._openProperties.triggered.connect(self._showLayerProperties)
コード例 #3
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def userInitials(cls):
     initials = Application.readEntry("ARK", "User/initials")
     if initials is None or initials == "":
         initials = ''
         for name in cls.userFullName().split(' '):
             initials += name[0]
     return initials
コード例 #4
0
    def initializePage(self, parent=None):
        self.registerField("forceDefaultCrs", self.wizard().forceCrsCheck)
        self.registerField("forceOtfTransform", self.wizard().forceOtfCheck)
        self.registerField("font", self.wizard().fontCombo)
        self.registerField("snappingTolerance",
                           self.wizard().snappingToleranceSpin)
        self.registerField("snappingUnit", self.wizard().snappingUnitCombo)

        self.wizard().crsWidget.setOptionVisible(
            QgsProjectionSelectionWidget.ProjectCrs, False)
        self.wizard().crsWidget.setOptionVisible(
            QgsProjectionSelectionWidget.DefaultCrs, True)
        self.wizard().crsWidget.setOptionVisible(
            QgsProjectionSelectionWidget.CurrentCrs, True)
        self.wizard().crsWidget.setCrs(Application.layerDefaultCrs())

        self.wizard().forceCrsCheck.setChecked(True)
        self.wizard().forceOtfCheck.setChecked(True)

        self.wizard().snappingToleranceSpin.setValue(10.0)

        self.wizard().snappingUnitCombo.addItem('Pixels', Snapping.Pixels)
        self.wizard().snappingUnitCombo.addItem('Layer Units',
                                                Snapping.LayerUnits)
        self.wizard().snappingUnitCombo.addItem('Project Units',
                                                Snapping.ProjectUnits)
        self.wizard().snappingUnitCombo.setCurrentIndex(0)
コード例 #5
0
    def initializePage(self, parent=None):
        self.registerField("forceDefaultCrs", self.wizard().forceCrsCheck)
        self.registerField("forceOtfTransform", self.wizard().forceOtfCheck)
        self.registerField("font", self.wizard().fontCombo)
        self.registerField("snappingTolerance", self.wizard().snappingToleranceSpin)
        self.registerField("snappingUnit", self.wizard().snappingUnitCombo)

        self.wizard().crsWidget.setOptionVisible(QgsProjectionSelectionWidget.ProjectCrs, False)
        self.wizard().crsWidget.setOptionVisible(QgsProjectionSelectionWidget.DefaultCrs, True)
        self.wizard().crsWidget.setOptionVisible(QgsProjectionSelectionWidget.CurrentCrs, True)
        self.wizard().crsWidget.setCrs(Application.layerDefaultCrs())

        self.wizard().forceCrsCheck.setChecked(True)
        self.wizard().forceOtfCheck.setChecked(True)

        self.wizard().snappingToleranceSpin.setValue(10.0)

        self.wizard().snappingUnitCombo.addItem('Pixels', Snapping.Pixels)
        self.wizard().snappingUnitCombo.addItem('Layer Units', Snapping.LayerUnits)
        self.wizard().snappingUnitCombo.addItem('Project Units', Snapping.ProjectUnits)
        self.wizard().snappingUnitCombo.setCurrentIndex(0)
コード例 #6
0
    def initializePage(self):
        self.registerField("projectName*", self.wizard().projectNameEdit)
        self.registerField("siteCode", self.wizard().siteCodeEdit)
        self.registerField("locationEasting", self.wizard().locationEastingEdit)
        self.registerField("locationNorthing", self.wizard().locationNorthingEdit)
        self.registerField("siteRadius", self.wizard().siteRadiusSpin)

        self.crs = Application.projectDefaultCrs()
        self.wizard().crsWidget.setCrs(self.crs)
        self.wizard().crsWidget.setOptionVisible(QgsProjectionSelectionWidget.LayerCrs, False)
        self.wizard().crsWidget.setOptionVisible(QgsProjectionSelectionWidget.ProjectCrs, True)
        self.wizard().crsWidget.setOptionVisible(QgsProjectionSelectionWidget.CurrentCrs, False)
        self.wizard().crsWidget.setOptionVisible(QgsProjectionSelectionWidget.DefaultCrs, False)
        self.wizard().crsWidget.setOptionVisible(QgsProjectionSelectionWidget.RecentCrs, True)
        self.wizard().crsWidget.crsChanged.connect(self._crsChanged)

        url = self.field("arkUrl")
        if url is None or url == "":
            self.registerField("projectCode*", self.wizard().projectCodeCombo.lineEdit())
            return

        self.registerField("projectCode*", self.wizard().projectCodeCombo)
        self.wizard().projectCodeCombo.setMaxVisibleItems(10)
        self.wizard().projectCodeCombo.setInsertPolicy(QComboBox.NoInsert)
        self.wizard().projectNameEdit.setEnabled(False)
        self.wizard().siteCodeEdit.setEnabled(False)
        self.wizard().locationEastingEdit.setEnabled(False)
        self.wizard().locationNorthingEdit.setEnabled(False)
        self.wizard().projectCodeCombo.currentIndexChanged.connect(self._updateArkProject)

        user = self.field("arkUser")
        password = self.field("arkPassword")
        self.ark = Ark(url, user, password)
        projects = self.ark.getProjectList()
        self.wizard().projectCodeCombo.setMaxCount(len(projects))
        for key in utils.natsorted(projects.keys()):
            self.wizard().projectCodeCombo.addItem(projects[key], key)
コード例 #7
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def serverUser():
     return Application.readEntry("ARK", "Server/user")
コード例 #8
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def setUserOrganisation(organisation):
     Application.setEntry("ARK", "User/organisation", organisation)
コード例 #9
0
ファイル: data_dock.py プロジェクト: lparchaeology/ArkPlan
    def initGui(self, iface, location, menuAction):
        super(DataDock, self).initGui(iface, location, menuAction)

        for key in sorted(Config.classCodes.keys()):
            classCode = Config.classCodes[key]
            self.widget.classCodeCombo.addItem(classCode['label'], classCode['class'])

        self._showItemAction = QAction(QIcon(':/plugins/ark/filter/showContext.png'), self.tr(u'Show Item'), self)
        self._showItemAction.triggered.connect(self.showItemSelected)
        self.toolbar.addAction(self._showItemAction)

        self._zoomItemAction = QAction(QIcon(':/plugins/ark/plan/zoomToItem.svg'), "Zoom to item", self)
        self._zoomItemAction.triggered.connect(self.zoomItemSelected)
        self.toolbar.addAction(self._zoomItemAction)

        self._filterItemAction = QAction(QIcon(':/plugins/ark/filter/filter.png'), "Filter item", self)
        self._filterItemAction.triggered.connect(self.filterItemSelected)
        self.toolbar.addAction(self._filterItemAction)

        self._loadItemDrawingsAction = QAction(QIcon(':/plugins/ark/plan/loadDrawings.svg'), "Load Drawings", self)
        self._loadItemDrawingsAction.triggered.connect(self.loadDrawingsSelected)
        self.toolbar.addAction(self._loadItemDrawingsAction)

        self._editItemAction = QAction(Application.getThemeIcon('mActionToggleEditing.svg'), "Edit Item", self)
        self._editItemAction.triggered.connect(self.editItemSelected)
        self.toolbar.addAction(self._editItemAction)

        self.toolbar.addSeparator()
        self._settingsTool = ActionSettingsTool(self)
        self._settingsTool.mapActionChanged.connect(self.mapActionChanged)
        self._settingsTool.filterActionChanged.connect(self.filterActionChanged)
        self._settingsTool.drawingActionChanged.connect(self.drawingActionChanged)
        self.toolbar.addWidget(self._settingsTool)

        self.toolbar2.setVisible(True)

        self._loadDataAction = QAction(QIcon(':/plugins/ark/data/loadData.svg'), "Load Data", self)
        self._loadDataAction.triggered.connect(self.loadDataSelected)
        self.toolbar2.addAction(self._loadDataAction)

        self._refreshDataAction = QAction(QIcon(':/plugins/ark/data/refreshData.svg'), "Refresh Data", self)
        self._refreshDataAction.triggered.connect(self.refreshDataSelected)
        self.toolbar2.addAction(self._refreshDataAction)

        self._firstItemAction = QAction(QIcon(':/plugins/ark/data/goFirstItem.svg'), "Go to first item", self)
        self._firstItemAction.triggered.connect(self.firstItemSelected)
        self.toolbar2.addAction(self._firstItemAction)

        self._previousItemAction = QAction(QIcon(':/plugins/ark/data/goPrevItem.svg'), "Go to previous item", self)
        self._previousItemAction.triggered.connect(self.prevItemSelected)
        self.toolbar2.addAction(self._previousItemAction)

        self._openItemAction = QAction(QIcon(':/plugins/ark/data/openData.svg'), "Open item in ARK", self)
        self._openItemAction.triggered.connect(self.openItemData)
        self.toolbar2.addAction(self._openItemAction)

        self._nextItemAction = QAction(QIcon(':/plugins/ark/data/goNextItem.svg'), "Go to next item", self)
        self._nextItemAction.triggered.connect(self.nextItemSelected)
        self.toolbar2.addAction(self._nextItemAction)

        self._lastItemAction = QAction(QIcon(':/plugins/ark/data/goLastItem.svg'), "Go to last item", self)
        self._lastItemAction.triggered.connect(self.lastItemSelected)
        self.toolbar2.addAction(self._lastItemAction)

        self.setItemNavEnabled(False)

        self.widget.siteCodeCombo.currentIndexChanged.connect(self._itemChanged)
        self.widget.classCodeCombo.currentIndexChanged.connect(self._itemChanged)
        self.widget.itemIdSpin.editingFinished.connect(self._itemChanged)

        if QWK_AVAILABLE:
            self.widget.itemDataView.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
            self.widget.itemDataView.linkClicked.connect(self._linkClicked)
コード例 #10
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def userOrganisation():
     return Application.readEntry("ARK", "User/organisation")
コード例 #11
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def setUserFullName(fullName):
     Application.setEntry("ARK", "User/fullName", fullName)
コード例 #12
0
    def initGui(self, iface, location, menuAction):
        super(DataDock, self).initGui(iface, location, menuAction)

        for key in sorted(Config.classCodes.keys()):
            classCode = Config.classCodes[key]
            self.widget.classCodeCombo.addItem(classCode['label'],
                                               classCode['class'])

        self._showItemAction = QAction(
            QIcon(':/plugins/ark/filter/showContext.png'),
            self.tr(u'Show Item'), self)
        self._showItemAction.triggered.connect(self.showItemSelected)
        self.toolbar.addAction(self._showItemAction)

        self._zoomItemAction = QAction(
            QIcon(':/plugins/ark/plan/zoomToItem.svg'), "Zoom to item", self)
        self._zoomItemAction.triggered.connect(self.zoomItemSelected)
        self.toolbar.addAction(self._zoomItemAction)

        self._filterItemAction = QAction(
            QIcon(':/plugins/ark/filter/filter.png'), "Filter item", self)
        self._filterItemAction.triggered.connect(self.filterItemSelected)
        self.toolbar.addAction(self._filterItemAction)

        self._loadItemDrawingsAction = QAction(
            QIcon(':/plugins/ark/plan/loadDrawings.svg'), "Load Drawings",
            self)
        self._loadItemDrawingsAction.triggered.connect(
            self.loadDrawingsSelected)
        self.toolbar.addAction(self._loadItemDrawingsAction)

        self._editItemAction = QAction(
            Application.getThemeIcon('mActionToggleEditing.svg'), "Edit Item",
            self)
        self._editItemAction.triggered.connect(self.editItemSelected)
        self.toolbar.addAction(self._editItemAction)

        self.toolbar.addSeparator()
        self._settingsTool = ActionSettingsTool(self)
        self._settingsTool.mapActionChanged.connect(self.mapActionChanged)
        self._settingsTool.filterActionChanged.connect(
            self.filterActionChanged)
        self._settingsTool.drawingActionChanged.connect(
            self.drawingActionChanged)
        self.toolbar.addWidget(self._settingsTool)

        self.toolbar2.setVisible(True)

        self._loadDataAction = QAction(
            QIcon(':/plugins/ark/data/loadData.svg'), "Load Data", self)
        self._loadDataAction.triggered.connect(self.loadDataSelected)
        self.toolbar2.addAction(self._loadDataAction)

        self._refreshDataAction = QAction(
            QIcon(':/plugins/ark/data/refreshData.svg'), "Refresh Data", self)
        self._refreshDataAction.triggered.connect(self.refreshDataSelected)
        self.toolbar2.addAction(self._refreshDataAction)

        self._firstItemAction = QAction(
            QIcon(':/plugins/ark/data/goFirstItem.svg'), "Go to first item",
            self)
        self._firstItemAction.triggered.connect(self.firstItemSelected)
        self.toolbar2.addAction(self._firstItemAction)

        self._previousItemAction = QAction(
            QIcon(':/plugins/ark/data/goPrevItem.svg'), "Go to previous item",
            self)
        self._previousItemAction.triggered.connect(self.prevItemSelected)
        self.toolbar2.addAction(self._previousItemAction)

        self._openItemAction = QAction(
            QIcon(':/plugins/ark/data/openData.svg'), "Open item in ARK", self)
        self._openItemAction.triggered.connect(self.openItemData)
        self.toolbar2.addAction(self._openItemAction)

        self._nextItemAction = QAction(
            QIcon(':/plugins/ark/data/goNextItem.svg'), "Go to next item",
            self)
        self._nextItemAction.triggered.connect(self.nextItemSelected)
        self.toolbar2.addAction(self._nextItemAction)

        self._lastItemAction = QAction(
            QIcon(':/plugins/ark/data/goLastItem.svg'), "Go to last item",
            self)
        self._lastItemAction.triggered.connect(self.lastItemSelected)
        self.toolbar2.addAction(self._lastItemAction)

        self.setItemNavEnabled(False)

        self.widget.siteCodeCombo.currentIndexChanged.connect(
            self._itemChanged)
        self.widget.classCodeCombo.currentIndexChanged.connect(
            self._itemChanged)
        self.widget.itemIdSpin.editingFinished.connect(self._itemChanged)

        if QWK_AVAILABLE:
            self.widget.itemDataView.page().setLinkDelegationPolicy(
                QWebPage.DelegateAllLinks)
            self.widget.itemDataView.linkClicked.connect(self._linkClicked)
コード例 #13
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def isPluginConfigured():
     return Application.readEntry("ARK", "configured", False)
コード例 #14
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def setPluginConfigured():
     Application.setEntry("ARK", "configured", True)
コード例 #15
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def setServerUrl(url):
     Application.setEntry("ARK", "Server/url", url)
コード例 #16
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def serverUrl():
     return Application.readEntry("ARK", "Server/url")
コード例 #17
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def setProjectsFolder(path):
     Application.setEntry("ARK", "projectsFolder", path)
コード例 #18
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def projectsFolder():
     return Application.readEntry("ARK", "projectsFolder", "")
コード例 #19
0
 def __init__(self):
     self.item = Item()
     self.action = FilterType.Include
     self.color = Application.highlightLineColor()
     self._viewIdx = -1
コード例 #20
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def serverPassword():
     return Application.readEntry("ARK", "Server/password")
コード例 #21
0
    def __init__(self, parent=None):
        super(FilterClauseWidget, self).__init__(parent)
        self.setupUi(self)

        self._filterIndex = -1
        self._filterType = FilterType.Include
        self._filterActionStatus = -1
        self._siteCode = ''

        self._addIcon = QIcon(':/plugins/ark/filter/addFilter.svg')
        self._addAction = QAction(self._addIcon, 'Add filter', self)
        self._addAction.setStatusTip('Add filter')
        self._addAction.triggered.connect(self._addFilterClicked)

        self._removeIcon = QIcon(':/plugins/ark/filter/removeFilter.svg')
        self._removeAction = QAction(self._removeIcon, 'Remove filter', self)
        self._removeAction.setStatusTip('Remove filter')
        self._removeAction.triggered.connect(self._removeFilterClicked)

        self.setFilterAction(FilterWidgetAction.AddFilter)

        self._includeIcon = QIcon(':/plugins/ark/filter/includeFilter.png')
        self._includeAction = QAction(self._includeIcon, 'Include', self)
        self._includeAction.setStatusTip('Include items in selection')
        self._includeAction.setCheckable(True)
        self._includeAction.triggered.connect(self._includeFilterChecked)

        self._excludeIcon = QIcon(':/plugins/ark/filter/excludeFilter.png')
        self._excludeAction = QAction(self._excludeIcon, 'Exclude', self)
        self._excludeAction.setStatusTip('Exclude items from selection')
        self._excludeAction.setCheckable(True)
        self._excludeAction.triggered.connect(self._excludeFilterChecked)

        self._selectIcon = QIcon(':/plugins/ark/filter/selectFilter.svg')
        self._selectAction = QAction(self._selectIcon, 'Select', self)
        self._selectAction.setStatusTip('Select items')
        self._selectAction.setCheckable(True)
        self._selectAction.triggered.connect(self._selectFilterChecked)

        self._highlightIcon = QIcon(':/plugins/ark/filter/highlightFilter.svg')
        self._highlightAction = QAction(self._highlightIcon, 'Highlight', self)
        self._highlightAction.setStatusTip('Highlight items')
        self._highlightAction.setCheckable(True)
        self._highlightAction.triggered.connect(self._highlightFilterChecked)

        self._typeActionGroup = QActionGroup(self)
        self._typeActionGroup.addAction(self._includeAction)
        self._typeActionGroup.addAction(self._excludeAction)
        self._typeActionGroup.addAction(self._selectAction)
        self._typeActionGroup.addAction(self._highlightAction)

        self._colorTool = QgsColorButtonV2(self)
        self._colorTool.setAllowAlpha(True)
        self._colorTool.setColorDialogTitle('Choose Highlight Color')
        self._colorTool.setContext('Choose Highlight Color')
        self._colorTool.setDefaultColor(Application.highlightFillColor())
        self._colorTool.setToDefaultColor()
        self._colorTool.colorChanged.connect(self._colorChanged)
        self._colorAction = QWidgetAction(self)
        self._colorAction.setDefaultWidget(self._colorTool)

        self._typeMenu = QMenu(self)
        self._typeMenu.addActions(self._typeActionGroup.actions())
        self._typeMenu.addSeparator()
        self._typeMenu.addAction(self._colorAction)
        self.filterTypeTool.setMenu(self._typeMenu)

        self._setFilterType(FilterType.Include)
コード例 #22
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def setServerCredentials(user, password):
     Application.setEntry("ARK", "Server/user", user)
     Application.setEntry("ARK", "Server/password", password)
コード例 #23
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def userFullName():
     name = Application.readEntry("ARK", "User/fullName")
     if name is None or name == '':
         name = QgsApplication.userFullName()
     return name
コード例 #24
0
ファイル: settings.py プロジェクト: lparchaeology/ArkPlan
 def setUserInitials(initials):
     Application.setEntry("ARK", "User/initials", initials)