Open QGIS project from psql
This commit is contained in:
parent
9ad5baa4ed
commit
2236123050
@ -119,16 +119,34 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
layout.addWidget(self.lineEdit)
|
layout.addWidget(self.lineEdit)
|
||||||
self.viewer.hide()
|
self.viewer.hide()
|
||||||
self.DeBUG.addItem('')
|
self.DeBUG.addItem('')
|
||||||
|
self.DeBUG.addItem('Dev')
|
||||||
self.DeBUG.addItem('01')
|
self.DeBUG.addItem('01')
|
||||||
self.DeBUG.addItem('0726')
|
self.DeBUG.addItem('0726')
|
||||||
self.DeBUG.addItem('4269')
|
self.DeBUG.addItem('4269')
|
||||||
|
|
||||||
|
self.DeBUG.currentIndexChanged.connect(self.SwitchDEBUG)
|
||||||
self.DeBUG.hide()
|
self.DeBUG.hide()
|
||||||
|
|
||||||
def raise_(self):
|
def raise_(self):
|
||||||
"""Run method that performs all the real work"""
|
"""Run method that performs all the real work"""
|
||||||
self.bd_source()
|
self.bd_source()
|
||||||
|
|
||||||
|
def SwitchDEBUG(self):
|
||||||
|
try:
|
||||||
|
global user, mdp, host, port, dbname, sigdb, refdb
|
||||||
|
account = login_base(self.DeBUG.currentText())
|
||||||
|
user = account[0]
|
||||||
|
mdp = account[1]
|
||||||
|
host = account[2]
|
||||||
|
port = account[3]
|
||||||
|
dbname = account[4]
|
||||||
|
sigdb = account[5]
|
||||||
|
refdb = account[6]
|
||||||
|
self.bd_source()
|
||||||
|
|
||||||
|
except NameError:
|
||||||
|
print('Fails to switch DB for account')
|
||||||
|
|
||||||
def ModeDeBUG(self):
|
def ModeDeBUG(self):
|
||||||
self.DeBUG.show()
|
self.DeBUG.show()
|
||||||
|
|
||||||
@ -212,6 +230,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.tableWidget_2.removeRow(self.tableWidget_2.currentRow())
|
self.tableWidget_2.removeRow(self.tableWidget_2.currentRow())
|
||||||
|
|
||||||
def initialisation_flux(self):
|
def initialisation_flux(self):
|
||||||
|
print('run_time')
|
||||||
if dbtype == sigdb:
|
if dbtype == sigdb:
|
||||||
# self.toolButton.setEnabled(1)
|
# self.toolButton.setEnabled(1)
|
||||||
if self.comboBox.currentText() == 'toutes les catégories':
|
if self.comboBox.currentText() == 'toutes les catégories':
|
||||||
@ -246,6 +265,16 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
else:
|
else:
|
||||||
RasterList = []
|
RasterList = []
|
||||||
|
|
||||||
|
SQLprojects = """SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE tablename LIKE 'qgis_projects'"""
|
||||||
|
cur.execute(SQLprojects)
|
||||||
|
list_projects = cur.fetchall()
|
||||||
|
list_projects_qgis = []
|
||||||
|
if len(list_projects) <= 1:
|
||||||
|
for ProjectName in list_projects:
|
||||||
|
SQLProjectsQgis = """SELECT name, metadata, content FROM """ + '"' + ProjectName[0] + '"."' + ProjectName[1] + '"'
|
||||||
|
cur.execute(SQLProjectsQgis)
|
||||||
|
list_projects_qgis.append(cur.fetchall())
|
||||||
|
|
||||||
self.tableWidget.setRowCount(len(list_schema))
|
self.tableWidget.setRowCount(len(list_schema))
|
||||||
self.tableWidget.setColumnCount(4)
|
self.tableWidget.setColumnCount(4)
|
||||||
i = 0
|
i = 0
|
||||||
@ -296,6 +325,35 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
item = QTableWidgetItem(table_name)
|
item = QTableWidgetItem(table_name)
|
||||||
self.tableWidget.setItem(i, 3, item)
|
self.tableWidget.setItem(i, 3, item)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
|
SQLprojects = """SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE tablename LIKE 'qgis_projects'"""
|
||||||
|
cur.execute(SQLprojects)
|
||||||
|
list_projects = cur.fetchall()
|
||||||
|
list_projects_qgis = []
|
||||||
|
if len(list_projects) <= 1:
|
||||||
|
for ProjectName in list_projects:
|
||||||
|
SQLProjectsQgis = """SELECT name, metadata, content FROM """ + '"' + ProjectName[0] + '"."' + ProjectName[1] + '"'
|
||||||
|
cur.execute(SQLProjectsQgis)
|
||||||
|
list_projects_qgis = cur.fetchall()
|
||||||
|
for Project in list_projects_qgis:
|
||||||
|
self.tableWidget.setRowCount(i + 1)
|
||||||
|
itemIcon = QTableWidgetItem()
|
||||||
|
icon = QIcon()
|
||||||
|
icon.addPixmap(QtGui.QPixmap(resources_path('icons', 'mIconQgis.svg')), QIcon.Mode(0), QIcon.State(1))
|
||||||
|
itemIcon.setIcon(icon)
|
||||||
|
self.tableWidget.setItem(i, 0, itemIcon)
|
||||||
|
|
||||||
|
item = QTableWidgetItem('QGIS')
|
||||||
|
self.tableWidget.setItem(i, 1, item)
|
||||||
|
|
||||||
|
item = QTableWidgetItem('projet')
|
||||||
|
self.tableWidget.setItem(i, 2, item)
|
||||||
|
|
||||||
|
item = QTableWidgetItem(Project[0])
|
||||||
|
self.tableWidget.setItem(i, 3, item)
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
|
||||||
self.tableWidget.setColumnWidth(0, 20)
|
self.tableWidget.setColumnWidth(0, 20)
|
||||||
self.tableWidget.setColumnWidth(1, 70)
|
self.tableWidget.setColumnWidth(1, 70)
|
||||||
self.tableWidget.setColumnWidth(2, 300)
|
self.tableWidget.setColumnWidth(2, 300)
|
||||||
@ -417,6 +475,11 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
uri.setSrid('2154')
|
uri.setSrid('2154')
|
||||||
layer = QgsRasterLayer(uri.uri(), table, "postgresraster")
|
layer = QgsRasterLayer(uri.uri(), table, "postgresraster")
|
||||||
QgsProject.instance().addMapLayer(layer)
|
QgsProject.instance().addMapLayer(layer)
|
||||||
|
elif code == 'QGIS':
|
||||||
|
schema = '_' + self.tableWidget_2.item(row, 2).text()
|
||||||
|
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)
|
||||||
else:
|
else:
|
||||||
uri.setDataSource(schema, table, "geom")
|
uri.setDataSource(schema, table, "geom")
|
||||||
uri.setKeyColumn('gid')
|
uri.setKeyColumn('gid')
|
||||||
|
|||||||
24
CenRa_FLUX/tools/icons/mIconQgis.svg
Normal file
24
CenRa_FLUX/tools/icons/mIconQgis.svg
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
width="128px" height="128px" viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
|
||||||
|
<polygon fill="#EE7913" points="68.613,69.625 86.891,69.625 71.697,54.625 52.613,54.625 52.613,72.746 68.613,88.548 "/>
|
||||||
|
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="402.5244" y1="-220.8706" x2="400.6479" y2="-97.5023" gradientTransform="matrix(1 0 0 -1 -300.5195 -92.5547)">
|
||||||
|
<stop offset="0" style="stop-color:#589632"/>
|
||||||
|
<stop offset="1" style="stop-color:#93B023"/>
|
||||||
|
</linearGradient>
|
||||||
|
<polygon fill="url(#SVGID_1_)" points="126.613,109.057 94.488,77.625 76.613,77.625 76.613,96.033 107.143,126.625
|
||||||
|
126.613,126.625 "/>
|
||||||
|
<polygon fill="#F0E64A" points="76.613,77.625 94.488,77.625 86.891,69.625 68.613,69.625 68.613,88.548 76.613,96.033 "/>
|
||||||
|
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="365.4619" y1="-221.1455" x2="363.5923" y2="-98.227" gradientTransform="matrix(1 0 0 -1 -300.5195 -92.5547)">
|
||||||
|
<stop offset="0" style="stop-color:#589632"/>
|
||||||
|
<stop offset="1" style="stop-color:#93B023"/>
|
||||||
|
</linearGradient>
|
||||||
|
<path fill="url(#SVGID_2_)" d="M68.923,101.552c-1.165,0.242-1.769,0.157-4.685,0.157c-20.866,0-38.612-17.158-38.612-39.406
|
||||||
|
c0-22.248,17.551-39.027,38.612-39.027s37.833,16.78,37.833,39.027c0,3.619-0.451,7.099-1.284,10.398L120.1,92.012
|
||||||
|
c4.979-8.726,7.765-18.869,7.765-29.857c0-34.289-27.363-59.963-64.016-59.963C27.363,2.191,0,27.696,0,62.154
|
||||||
|
c0,34.625,27.363,60.638,63.848,60.638c9.417,0,16.069-1.469,23.042-3.761L68.923,101.552z"/>
|
||||||
|
<polygon opacity="0.15" fill="#FFFFFF" enable-background="new " points="53.083,54.625 71.697,54.625 126.613,109.057
|
||||||
|
126.613,126.625 "/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.0 KiB |
Loading…
x
Reference in New Issue
Block a user