correctif mineur
This commit is contained in:
+37
-22
@@ -103,7 +103,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
self.toolButton.setIcon(QtGui.QIcon(resources_path('ui', 'find.png')))
|
||||
self.comboBox_2.addItem("SIG")
|
||||
self.comboBox_2.addItem('REF')
|
||||
self.comboBox.currentIndexChanged.connect(self.initialisation_flux)
|
||||
|
||||
self.commandLinkButton.clicked.connect(self.selection_flux)
|
||||
self.tableWidget.itemDoubleClicked.connect(self.selection_flux)
|
||||
self.pushButton_2.clicked.connect(self.limite_flux)
|
||||
@@ -123,6 +123,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
self.DeBUG.addItem('01')
|
||||
self.DeBUG.addItem('0726')
|
||||
self.DeBUG.addItem('4269')
|
||||
self.comboBox.currentIndexChanged.connect(self.initialisation_flux)
|
||||
|
||||
self.DeBUG.currentIndexChanged.connect(self.SwitchDEBUG)
|
||||
self.DeBUG.hide()
|
||||
@@ -186,8 +187,8 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
dbtype = refdb
|
||||
con = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + dbtype + " user=" + user + " password=" + mdp)
|
||||
cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||||
self.initialisation_flux()
|
||||
self.combobox_custom()
|
||||
#self.initialisation_flux()
|
||||
# Create the dialog with elements (after translation) and keep reference
|
||||
# Only create GUI ONCE in callback, so that it will only load when the plugin is started
|
||||
if self.first_start is True:
|
||||
@@ -210,27 +211,27 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
dbtype = sigdb
|
||||
con = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + dbtype + " user=" + user + " password=" + mdp)
|
||||
cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||||
self.initialisation_flux()
|
||||
self.combobox_custom()
|
||||
#self.initialisation_flux()
|
||||
# Create the dialog with elements (after translation) and keep reference
|
||||
# Only create GUI ONCE in callback, so that it will only load when the plugin is started
|
||||
if self.first_start is True:
|
||||
self.first_start = False
|
||||
# show the dialog
|
||||
self.show()
|
||||
# self.show()
|
||||
# Run the dialog event loop
|
||||
result = self.exec()
|
||||
# result = self.exec()
|
||||
# See if OK was pressed
|
||||
if result:
|
||||
#if result:
|
||||
# Do something useful here - delete the line containing pass and
|
||||
# substitute with your code.
|
||||
pass
|
||||
# pass
|
||||
|
||||
def suppression_flux(self):
|
||||
self.tableWidget_2.removeRow(self.tableWidget_2.currentRow())
|
||||
|
||||
def initialisation_flux(self):
|
||||
print('run_time')
|
||||
print('run')
|
||||
if dbtype == sigdb:
|
||||
# self.toolButton.setEnabled(1)
|
||||
if self.comboBox.currentText() == 'toutes les catégories':
|
||||
@@ -240,13 +241,12 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
where schemaname like '""" + str(self.comboBox.currentText()) + """%' order by schemaname,tablename) UNION (SELECT schemaname,matviewname AS tablename FROM pg_catalog.pg_matviews where schemaname like '""" + str(self.comboBox.currentText()) + """%' order by schemaname,tablename) order by schemaname,tablename;"""
|
||||
else:
|
||||
custom_list = """(SELECT schemaname,tablename from pg_catalog.pg_tables
|
||||
where schemaname like '\\_""" + str(self.comboBox.currentText()) + """%' order by schemaname,tablename) UNION (SELECT schemaname,matviewname AS tablename FROM pg_catalog.pg_matviews where schemaname like '\\_""" + str(self.comboBox.currentText()) + """%' order by schemaname,tablename) order by schemaname,tablename;"""
|
||||
where schemaname like '\\_""" + str(self.comboBox.currentText()) + """%' order by schemaname,tablename) UNION (SELECT schemaname,matviewname AS tablename FROM pg_catalog.pg_matviews where schemaname like '\\_""" + str(self.comboBox.currentText()) + """%' order by schemaname,tablename) order by schemaname,tablename;"""
|
||||
else:
|
||||
if self.comboBox.currentText() == 'toutes les catégories':
|
||||
custom_list = schemaname_list_ref
|
||||
else:
|
||||
custom_list = """SELECT schemaname,tablename from pg_catalog.pg_tables
|
||||
where schemaname like '""" + str(self.comboBox.currentText()) + """' order by schemaname,tablename;"""
|
||||
custom_list = """SELECT schemaname, tablename from pg_catalog.pg_tables WHERE schemaname LIKE '""" + str(self.comboBox.currentText()) + """' AND tablename NOT LIKE 'qgis_projects' order by schemaname, tablename;"""
|
||||
cur.execute(custom_list)
|
||||
list_schema = cur.fetchall()
|
||||
|
||||
@@ -326,11 +326,14 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
self.tableWidget.setItem(i, 3, item)
|
||||
i = i + 1
|
||||
|
||||
SQLprojects = """SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE tablename LIKE 'qgis_projects'"""
|
||||
if self.comboBox.currentText() == 'toutes les catégories':
|
||||
SQLprojects = """SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE tablename LIKE 'qgis_projects'"""
|
||||
else:
|
||||
SQLprojects = """SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE tablename LIKE 'qgis_projects' AND schemaname LIKE '""" + str(self.comboBox.currentText()) + """';"""
|
||||
cur.execute(SQLprojects)
|
||||
list_projects = cur.fetchall()
|
||||
list_projects_qgis = []
|
||||
if len(list_projects) <= 1:
|
||||
if len(list_projects) >= 1:
|
||||
for ProjectName in list_projects:
|
||||
SQLProjectsQgis = """SELECT name, metadata, content FROM """ + '"' + ProjectName[0] + '"."' + ProjectName[1] + '"'
|
||||
cur.execute(SQLProjectsQgis)
|
||||
@@ -343,10 +346,10 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
itemIcon.setIcon(icon)
|
||||
self.tableWidget.setItem(i, 0, itemIcon)
|
||||
|
||||
item = QTableWidgetItem('QGIS')
|
||||
item = QTableWidgetItem('qgis')
|
||||
self.tableWidget.setItem(i, 1, item)
|
||||
|
||||
item = QTableWidgetItem('projet')
|
||||
item = QTableWidgetItem(ProjectName[0])
|
||||
self.tableWidget.setItem(i, 2, item)
|
||||
|
||||
item = QTableWidgetItem(Project[0])
|
||||
@@ -441,8 +444,17 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
# p = []
|
||||
|
||||
SQLloadRaster = """SELECT concat(r_table_schema,'.',r_table_name) from public.raster_columns; """
|
||||
cur.execute(SQLloadRaster)
|
||||
list_raster = cur.fetchall()
|
||||
SQLextension = """SELECT count(extname) FROM pg_catalog.pg_extension WHERE extname LIKE 'postgis_raster';"""
|
||||
|
||||
cur.execute(SQLextension)
|
||||
count_extension = cur.fetchall()[0][0]
|
||||
|
||||
if count_extension == 1:
|
||||
cur.execute(SQLloadRaster)
|
||||
list_raster = cur.fetchall()
|
||||
else:
|
||||
list_raster = []
|
||||
|
||||
RasterList = []
|
||||
for rasterFind in list_raster:
|
||||
RasterList.append(rasterFind[0])
|
||||
@@ -457,26 +469,28 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
if code == 'travaux' or code == 'agregation':
|
||||
schema = self.tableWidget_2.item(row, 2).text()
|
||||
table = self.tableWidget_2.item(row, 3).text()
|
||||
elif code == '00':
|
||||
table = self.tableWidget_2.item(row, 3).text()
|
||||
else:
|
||||
table = self.tableWidget_2.item(row, 3).text()
|
||||
table = schema + '_' + table
|
||||
elif dbtype == refdb:
|
||||
# code = self.tableWidget_2.item(row,1).text()
|
||||
code = self.tableWidget_2.item(row,1).text()
|
||||
schema = self.tableWidget_2.item(row, 2).text()
|
||||
table = self.tableWidget_2.item(row, 3).text()
|
||||
# .split("?", 1)[0]
|
||||
uri = QgsDataSourceUri()
|
||||
uri.setConnection(host, port, dbtype, user, mdp)
|
||||
|
||||
# nom du schéma à remplacer: "hydrographie" à supprimer et mettre "couches_collaboratives" lorsqu'on aura regroupé les couches à modifier dans un même schéma
|
||||
# nom du schéma à remplacer: "hydrographie" à supprimer et mettre "couches_collaboratives" lorsqu'on aura regroupé les couches à modifier dans un même
|
||||
if (schema + '.' + table) in RasterList:
|
||||
uri.setDataSource(schema, table, "rast")
|
||||
uri.setKeyColumn('rid')
|
||||
uri.setSrid('2154')
|
||||
layer = QgsRasterLayer(uri.uri(), table, "postgresraster")
|
||||
QgsProject.instance().addMapLayer(layer)
|
||||
elif code == 'QGIS':
|
||||
schema = '_' + self.tableWidget_2.item(row, 2).text()
|
||||
elif code == 'qgis':
|
||||
schema = self.tableWidget_2.item(row, 2).text()
|
||||
print(schema)
|
||||
table = self.tableWidget_2.item(row, 3).text()
|
||||
uri_project = 'postgresql://' + user + ':' + mdp + '@' + host + ':' + port + '?sslmode=disable&dbname=' + dbtype + "&schema=" + schema + '&project=' + table
|
||||
QgsProject.instance().read(uri_project)
|
||||
@@ -527,6 +541,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
self.comboBox.addItem('69')
|
||||
self.comboBox.addItem('agregation')
|
||||
self.comboBox.addItem('travaux')
|
||||
self.comboBox.addItem('qgis')
|
||||
self.comboBox.addItem('form')
|
||||
if dbtype == refdb:
|
||||
self.toolButton.setEnabled(0)
|
||||
|
||||
Reference in New Issue
Block a user