Plugin PyQt5 and PyQt6 compatible & CenRa_Copie bug fix

This commit is contained in:
2025-05-19 14:00:58 +02:00
parent 3b0758ea5c
commit 3ef37aa696
37 changed files with 434 additions and 321 deletions
+5 -3
View File
@@ -24,8 +24,10 @@ pyperclip()
from .copie_editor import Copie_Editor
from .about_form import AboutDialog
from PyQt5.QtCore import *
try:
from PyQt5.QtCore import *
except:
from PyQt6.QtCore import *
class PgCopie:
def __init__(self):
""" Constructor. """
@@ -78,7 +80,7 @@ class PgCopie:
About dialog
"""
dialog = AboutDialog(iface)
dialog.exec_()
dialog.exec()
def open_help():
""" Open the online help. """
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
+18 -6
View File
@@ -9,9 +9,15 @@ import qgis
from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog
from qgis.PyQt.QtGui import QIcon
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5 import QtGui
try:
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5 import QtGui
except:
from PyQt6.QtCore import *
from PyQt6.QtGui import *
from PyQt6 import QtGui
from qgis.core import *
from qgis.core import QgsDataSourceUri
import os
@@ -114,7 +120,7 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
# show the dialog
self.show()
# Run the dialog event loop
result = self.exec_()
result = self.exec()
# See if OK was pressed
if result:
#******************************debut script*********************************
@@ -163,7 +169,6 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
else :
SQL_table = "CREATE TABLE " + schema + "." + tablename + " AS SELECT * FROM " + source_schema + "." + source_tablename
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_sequence_01 = "CREATE SEQUENCE " + schema + "." + tablename + "_gid_seq" + " INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;"
SQL_sequence_02 = "ALTER TABLE " + schema + "." + tablename + " ALTER COLUMN gid SET DEFAULT nextval(\'" + schema + "." + tablename + "_gid_seq\'::regclass);"
@@ -174,7 +179,7 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
cur.execute(SQL_table)
cur.execute(SQL_pkey)
@@ -183,6 +188,13 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
cur.execute(SQL_sequence_03)
cur.execute(SQL_sequence_04)
RETURNE = "SELECT pg_get_serial_sequence('"+schema + "."+ tablename+"','gid')"
cur.execute(RETURNE)
sequence_name = cur.fetchone()[0]
print(sequence_name)
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+sequence_name+" TO grp_qgis;"
cur.execute(SQL_GRANT_TABLE)
if layer.wkbType() == QgsWkbTypes.PointGeometry :
cur.execute(SQL_trigger_coordonnees)
+1
View File
@@ -9,6 +9,7 @@
[general]
name=CenRA_COPIE
qgisMinimumVersion=3.0
supportsQt6=True
description=Permet la copie d'une table dans une base PostGis
version=2.5
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
+3 -18
View File
@@ -29,9 +29,6 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
@@ -41,7 +38,7 @@
<x>0</x>
<y>0</y>
<width>453</width>
<height>547</height>
<height>570</height>
</rect>
</property>
<widget class="QGroupBox" name="groupBox">
@@ -56,7 +53,7 @@
<property name="title">
<string>DevLog</string>
</property>
<widget class="QWebView" name="viewer" native="true">
<widget class="QTextBrowser" name="viewer">
<property name="geometry">
<rect>
<x>10</x>
@@ -65,11 +62,6 @@
<height>511</height>
</rect>
</property>
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</widget>
</widget>
@@ -78,19 +70,12 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::NoButton</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>