diff --git a/projectgenerator/gui/generate_project.py b/projectgenerator/gui/generate_project.py
index ce5c11eca..b2f85fb48 100644
--- a/projectgenerator/gui/generate_project.py
+++ b/projectgenerator/gui/generate_project.py
@@ -21,40 +21,49 @@ def __init__(self, parent=None):
self.buttonBox.addButton(QDialogButtonBox.Cancel)
self.buttonBox.addButton(self.tr('Create'), QDialogButtonBox.AcceptRole)
self.ili_file_browse_button.clicked.connect(make_file_selector(self.ili_file_line_edit, title=self.tr('Open Interlis Model'), file_filter=self.tr('Interlis Model File (*.ili)')))
+ self.type_combo_box.clear()
+ self.type_combo_box.addItem(self.tr('Interlis'), 'ili')
+ self.type_combo_box.addItem(self.tr('Postgis'), 'pg')
+ self.type_combo_box.currentIndexChanged.connect(self.type_changed)
self.restore_configuration()
def accepted(self):
- importer = iliimporter.Importer()
configuration = iliimporter.Configuration()
- configuration.ilifile = self.ili_file_line_edit.text()
configuration.host = self.pg_host_line_edit.text()
configuration.user = self.pg_user_line_edit.text()
configuration.database = self.pg_database_line_edit.text()
configuration.schema = self.pg_schema_line_edit.text()
configuration.password = self.pg_password_line_edit.text()
- importer.configuration = configuration
+ if self.type_combo_box.currentData() == 'ili':
+ configuration.ilifile = self.ili_file_line_edit.text()
- self.save_configuration(configuration)
+ importer = iliimporter.Importer()
- importer.stdout.connect(self.print_info)
- importer.stderr.connect(self.on_stderr)
- importer.process_started.connect(self.on_process_started)
- importer.process_finished.connect(self.on_process_finished)
- if importer.run() == iliimporter.Importer.SUCCESS:
- generator = Generator(configuration.uri)
- available_layers = generator.layers()
- relations = generator.relations(available_layers)
+ importer.configuration = configuration
- project = Project()
- project.layers = available_layers
- project.relations = relations
+ self.save_configuration(configuration)
- qgis_project = QgsProject.instance()
- project.layer_added.connect(self.print_info)
- project.create(None, qgis_project)
+ importer.stdout.connect(self.print_info)
+ importer.stderr.connect(self.on_stderr)
+ importer.process_started.connect(self.on_process_started)
+ importer.process_finished.connect(self.on_process_finished)
+ if importer.run() != iliimporter.Importer.SUCCESS:
+ return
+
+ generator = Generator(configuration.uri)
+ available_layers = generator.layers()
+ relations = generator.relations(available_layers)
+
+ project = Project()
+ project.layers = available_layers
+ project.relations = relations
+
+ qgis_project = QgsProject.instance()
+ project.layer_added.connect(self.print_info)
+ project.create(None, qgis_project)
def print_info(self, text):
self.txtStdout.append(text)
@@ -92,6 +101,7 @@ def save_configuration(self, configuration):
settings.setValue('QgsProjectGenerator/ili2pg/database', configuration.database)
settings.setValue('QgsProjectGenerator/ili2pg/schema', configuration.schema)
settings.setValue('QgsProjectGenerator/ili2pg/password', configuration.password)
+ settings.setValue('QgsProjectGenerator/importtype', self.type_combo_box.currentData())
def restore_configuration(self):
settings = QSettings()
@@ -102,6 +112,8 @@ def restore_configuration(self):
self.pg_database_line_edit.setText(settings.value('QgsProjectGenerator/ili2pg/database'))
self.pg_schema_line_edit.setText(settings.value('QgsProjectGenerator/ili2pg/schema'))
self.pg_password_line_edit.setText(settings.value('QgsProjectGenerator/ili2pg/password'))
+ self.type_combo_box.setCurrentIndex(self.type_combo_box.findData(settings.value('QgsProjectGenerator/importtype', 'pg')))
+ self.type_changed()
def disable(self):
self.pg_config.setEnabled(False)
@@ -111,4 +123,10 @@ def disable(self):
def enable(self):
self.pg_config.setEnabled(True)
self.ili_config.setEnabled(True)
- self.buttonBox.setEnabled(True)
\ No newline at end of file
+ self.buttonBox.setEnabled(True)
+
+ def type_changed(self):
+ if self.type_combo_box.currentData() == 'ili':
+ self.ili_config.show()
+ else:
+ self.ili_config.hide()
diff --git a/projectgenerator/libqgsprojectgen/dataobjects/project.py b/projectgenerator/libqgsprojectgen/dataobjects/project.py
index 45bd946a5..0bda743c2 100644
--- a/projectgenerator/libqgsprojectgen/dataobjects/project.py
+++ b/projectgenerator/libqgsprojectgen/dataobjects/project.py
@@ -53,17 +53,17 @@ def dump(self):
definition['relations'] = relations
return definition
-
def load(self, definition):
self.crs = definition['crs']
- self.layers=list()
+ self.layers = list()
for layer_definition in definition['layers']:
layer = Layer()
layer.load(layer_definition)
self.layers.append(layer)
+
def create(self, path, qgis_project):
for layer in self.layers:
qgis_layer = layer.create()
diff --git a/projectgenerator/ui/generate_project.ui b/projectgenerator/ui/generate_project.ui
index ebb5777c5..d84b76ade 100644
--- a/projectgenerator/ui/generate_project.ui
+++ b/projectgenerator/ui/generate_project.ui
@@ -6,7 +6,7 @@
0
0
- 800
+ 718
674
@@ -14,38 +14,11 @@
Import Interlis
- -
-
-
- false
-
-
-
-
- Interlis
-
-
- -
-
- Postgis
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
+
+ 0
+
-
@@ -206,10 +179,24 @@
+ -
+
+
-
+
+ Interlis
+
+
+ -
+
+ Postgis
+
+
+
+
- comboBox
+ type_combo_box
pg_host_line_edit
pg_user_line_edit
pg_database_line_edit