예제 #1
0
    def configure(self):
        wizard = ProjectWizard(self._plugin.iface.mainWindow())

        ok = wizard.exec_()

        if ok:

            if wizard.newProject():
                if Project.exists():
                    Project.write()
                Project.clear()
                projectFolderPath = os.path.join(wizard.projectFolder(), 'project')
                if not QDir(projectFolderPath).mkpath('.'):
                    return False
                projectFilePath = os.path.join(projectFolderPath, wizard.projectFilename() + '.qgs')
                Project.setFileName(projectFilePath)

            Settings.setProjectCode(wizard.project().projectCode())
            Settings.setProjectName(wizard.project().projectName())
            Settings.setSiteCode(wizard.project().siteCode())
            if not Project.title():
                Project.setTitle(wizard.project().projectCode() + ' - ' + wizard.project().projectName())

            self._initialised = Project.write()
            if self._initialised:

                # We always want the site collection
                self._addCollection('site')
                self.collection('site').loadCollection()
                # Add the Site Location if entered
                location = wizard.projectLocation()
                if not location.isEmpty():
                    siteCode = wizard.project().siteCode() if wizard.project().siteCode() else wizard.project().projectCode()
                    item = Item(siteCode, 'site', siteCode)
                    source = Source('other', item)
                    audit = Audit(Settings.userFullName(), utils.timestamp())
                    itemFeature = ItemFeature(item, 'loc', None, source, 'New Project Wizard', audit)
                    layer = self.collection('site').layer('points')
                    feature = QgsFeature(layer.pendingFields(), 0)
                    feature.setGeometry(QgsGeometry(location))
                    attributes = itemFeature.toFeature(feature)
                    layers.addFeatures([feature], layer)

                # Temp load of other collection, later do on demand
                self._addCollection('plan')
                self.collection('plan').loadCollection()
                self._addCollection('section')
                self.collection('section').loadCollection()
                self._addCollection('grid')
                self.collection('grid').loadCollection()

                # self._configureDrawing('context')
                # self._configureDrawing('plan')
                # self._configureDrawing('section')

                Settings.setProjectConfigured()

        return ok
예제 #2
0
    def accept(self):
        # Settings tab settings
        Settings.setSiteCode(self.siteCodeEdit.text())
        Settings.setStylePath(self.styleFolderCheck.isChecked(), self.styleFolderEdit.text())
        Settings.setArkUrl(self.arkUrlEdit.text())
        Settings.setLogUpdates(self.logUpdatesCheck.isChecked())

        # Drawings tab settings
        Settings.setDrawingPath(
            'context', self.contextDrawingFolderCheck.isChecked(), self.contextDrawingFolderEdit.text())
        Settings.setDrawingPath('plan', self.planDrawingFolderCheck.isChecked(), self.planDrawingFolderEdit.text())
        Settings.setDrawingPath(
            'section', self.sectionDrawingFolderCheck.isChecked(), self.sectionDrawingFolderEdit.text())
        Settings.setUseGeorefFolder(self.georefFolderCheck.isChecked())
        Settings.setDrawingTransparency(self.drawingTransparencySpin.value())

        return super(SettingsDialog, self).accept()