From a3479085b6ccf9fddd5a870c2fdbdcdd7a4de093 Mon Sep 17 00:00:00 2001 From: tlaveille Date: Thu, 12 Feb 2026 10:04:28 +0100 Subject: [PATCH] system de favorit --- CenRa_FLUX/flux_editor.py | 122 +++++++++++--------------------------- CenRa_FLUX/metadata.txt | 4 +- plugins.xml | 6 +- 3 files changed, 38 insertions(+), 94 deletions(-) diff --git a/CenRa_FLUX/flux_editor.py b/CenRa_FLUX/flux_editor.py index c1aa3c3..15ca444 100644 --- a/CenRa_FLUX/flux_editor.py +++ b/CenRa_FLUX/flux_editor.py @@ -2,29 +2,16 @@ from __future__ import absolute_import # Import the PyQt and QGIS libraries -# from builtins import next from builtins import str -# from builtins import object from qgis.PyQt import QtCore, QtGui from qgis.PyQt.QtCore import QSettings from qgis.PyQt import QtWidgets -# from qgis.PyQt.QtWidgets import QDialog from qgis.PyQt.QtGui import QIcon -# from qgis.PyQt.QtCore import * - -# from qgis.core import QgsCoordinateReferenceSystem, QgsCoordinateTransform, QgsProject, QgsSettings from qgis.core import QgsDataSourceUri, QgsCoordinateReferenceSystem, QgsCoordinateTransform, QgsProject, QgsSettings, QgsApplication, QgsVectorLayer, QgsRasterLayer, QgsWkbTypes from qgis.PyQt.QtWidgets import ( QDialog, - # QAction, - # QDockWidget, - # QFileDialog, - # QInputDialog, - # QMenu, - # QToolButton, - # QTableWidget, QPushButton, QTableWidgetItem, QMessageBox, @@ -34,24 +21,15 @@ from .tools.SQLRequet import schemaname_list, schemaname_list_ref, schemaname_di from .tools.resources import ( load_ui, resources_path, - # send_issues, ) try: from .tools.PythonSQL import login_base except NameError: print('Pas de fichier PythonSQL') - -# from .issues import CenRa_Issues - -# from ast import literal_eval from qgis.utils import iface -# import os.path -# import os -# import webbrowser import psycopg2 import psycopg2.extras -# import base64 global DeBUG DeBUG = 0 @@ -113,12 +91,10 @@ class Flux_Editor(QDialog, EDITOR_CLASS): self.tableWidget_2.itemDoubleClicked.connect(self.suppression_flux) self.comboBox_2.currentIndexChanged.connect(self.bd_source) self.checkBox.hide() - # self.checkBox.stateChanged.connect(self.modeCarte) self.toolButton.clicked.connect(self.getCanevas) self.toolButton_2.clicked.connect(self.filtre_favorit) layout = QVBoxLayout() self.lineEdit.textChanged.connect(self.filtre_dynamique) - # self.viewer.textChanged.connect(self.NewTitle) layout.addWidget(self.lineEdit) self.viewer.hide() self.DeBUG.addItem('') @@ -165,14 +141,6 @@ class Flux_Editor(QDialog, EDITOR_CLASS): DeBUG = 0 self.DeBUG.hide() - """ - def NewTitle(self): - if self.viewer.title() != '': - Tsplit = ((self.viewer.title()).split('.')) - print(Tsplit[0], Tsplit[1]) - self.openPostGIS(Tsplit[0], Tsplit[1]) - """ - def bd_source(self): self.activateWindow() bd_origine = self.comboBox_2.currentText() @@ -185,7 +153,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS): """Run method that performs all the real work""" while self.tableWidget_2.rowCount() > 0: self.tableWidget_2.removeRow(self.tableWidget_2.rowCount() - 1) -# print(self.tableWidget_2.rowCount()) + global cur, con, dbtype dbtype = refdb con = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + dbtype + " user=" + user + " password=" + mdp) @@ -200,10 +168,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS): self.show() # Run the dialog event loop result = self.exec() - # See if OK was pressed if result: - # Do something useful here - delete the line containing pass and - # substitute with your code. pass def run_sig(self): @@ -216,19 +181,9 @@ class Flux_Editor(QDialog, EDITOR_CLASS): cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor) 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() - # Run the dialog event loop - # result = self.exec() - # See if OK was pressed - # if result: - # Do something useful here - delete the line containing pass and - # substitute with your code. - # pass def suppression_flux(self): self.tableWidget_2.removeRow(self.tableWidget_2.currentRow()) @@ -267,10 +222,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS): def initialisation_flux(self): self.tableWidget.clear() if NoSignals == 0: - # self.tableWidget.clear() - # print('Initiaisation de la connection a la DB: ' + dbtype) if dbtype == sigdb: - # self.toolButton.setEnabled(1) if self.comboBox.currentText() == 'toutes les catégories': custom_list = schemaname_list elif self.comboBox.currentText() == 'travaux': @@ -402,11 +354,9 @@ class Flux_Editor(QDialog, EDITOR_CLASS): self.tableWidget.setItem(i, 4, item) self.tableWidget.setCellWidget(i, 4, self.FavButton) - # if dbtype == sigdb: if (str(value[0]) + '.' + str(value[1])) in GrandUser: pass else: - # print(str(value[0]) + '.' + str(value[1]), 'bad') for j in range(self.tableWidget.columnCount()): self.tableWidget.item(i, j).setBackground(QtGui.QColor(187, 134, 192, 50)) self.tableWidget.item(i, j).setToolTip('Droit insuffisant pour ouvrire la couche !') @@ -427,6 +377,20 @@ class Flux_Editor(QDialog, EDITOR_CLASS): cur.execute(SQLProjectsQgis) list_projects_qgis = cur.fetchall() for Project in list_projects_qgis: + FavStatut = 0 + if (ProjectName[0] + '.' + Project[0]) not in FavList: + FAV = "mStarIconAdd.png" + FavStatut = 0 + else: + FAV = "mStarIconDel.png" + FavStatut = 1 + iconFav = QIcon() + iconFav.addPixmap(QtGui.QPixmap(resources_path('icons', FAV)), QIcon.Mode(0), QIcon.State(1)) + self.FavButton = QPushButton(iconFav, "") + self.FavButton.clicked.connect(self.AddOrDelToUserFav) + if dbtype == refdb: + self.FavButton.setEnabled(False) + self.tableWidget.setRowCount(i + 1) itemIcon = QTableWidgetItem() icon = QIcon() @@ -443,8 +407,9 @@ class Flux_Editor(QDialog, EDITOR_CLASS): item = QTableWidgetItem(Project[0]) self.tableWidget.setItem(i, 3, item) - item = QTableWidgetItem('FavIcon') + item = QTableWidgetItem(str(FavStatut)) self.tableWidget.setItem(i, 4, item) + self.tableWidget.setCellWidget(i, 4, self.FavButton) i = i + 1 @@ -462,8 +427,6 @@ class Flux_Editor(QDialog, EDITOR_CLASS): selected_row = 0 selected_items = self.tableWidget.selectedItems() - # Assuming you want to compare items in the first column for uniqueness - # svgTake = (selected_items[2].tableWidget().cellWidget(0,0)) new_item_text = selected_items[3].text() if not self.item_already_exists(new_item_text): @@ -480,6 +443,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS): self.tableWidget_2.setColumnWidth(2, 300) self.tableWidget_2.setColumnWidth(3, 300) self.tableWidget_2.setColumnWidth(4, 20) + self.tableWidget_2.setColumnHidden(4, True) def item_already_exists(self, new_item_text): # Assuming you want to compare items in the first column for uniqueness @@ -503,25 +467,6 @@ class Flux_Editor(QDialog, EDITOR_CLASS): if self.tableWidget_2.rowCount() <= 5: self.chargement_flux() - """ - def openPostGIS(self, schema, table): - uri = QgsDataSourceUri() - uri.setConnection(host, port, sigdb, user, mdp) - - if (schema + '.' + table) in LRasterList: - uri.setDataSource(schema, table, "rast") - uri.setKeyColumn('rid') - uri.setSrid('2154') - layer = QgsRasterLayer(uri.uri(), table, "postgresraster") - else: - uri.setDataSource(schema, table, "geom") - uri.setKeyColumn('gid') - uri.setSrid('2154') - layer = QgsVectorLayer(uri.uri(), table, "postgres") - # Ajout de la couche au canevas QGIS - QgsProject.instance().addMapLayer(layer) - """ - def chargement_flux(self): managerAU = QgsApplication.authManager() managerAU.availableAuthMethodConfigs().keys() @@ -536,9 +481,6 @@ class Flux_Editor(QDialog, EDITOR_CLASS): } return switcher.get(type, "nothing") - # def displayOnWindows(type, uri, name): - # p = [] - SQLloadRaster = """SELECT concat(r_table_schema,'.',r_table_name) from public.raster_columns; """ SQLextension = """SELECT count(extname) FROM pg_catalog.pg_extension WHERE extname LIKE 'postgis_raster';""" @@ -578,7 +520,6 @@ class Flux_Editor(QDialog, EDITOR_CLASS): 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 @@ -629,7 +570,6 @@ class Flux_Editor(QDialog, EDITOR_CLASS): self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !", "La couche «" + str(self.tableWidget_2.item(row, 1).text()) + ' ' + str(self.tableWidget_2.item(row, 2).text()) + "» ne ce trouve pas dans cette BD !", QMessageBox.StandardButton(0x00004000)) def combobox_custom(self): - # print('Chargement de la list pour la BD: ' + dbtype) global NoSignals NoSignals = 1 if dbtype == sigdb: @@ -660,14 +600,22 @@ class Flux_Editor(QDialog, EDITOR_CLASS): def filtre_favorit(self, filter_fav): if self.toolButton_2.text() == "0": self.toolButton_2.setText("1") - for i in range(self.tableWidget.rowCount()): - item = self.tableWidget.item(i, 4) - match = self.toolButton_2.text() not in item.text().lower() - self.tableWidget.setRowHidden(i, match) + self.toolButton_2.setDown(True) + if self.lineEdit.text() != 'Recherche par mots-clés': + self.filtre_dynamique(self.lineEdit.text()) + else: + for i in range(self.tableWidget.rowCount()): + item = self.tableWidget.item(i, 4) + match = self.toolButton_2.text() not in item.text().lower() + self.tableWidget.setRowHidden(i, match) elif self.toolButton_2.text() == "1": self.toolButton_2.setText("0") - for i in range(self.tableWidget.rowCount()): - self.tableWidget.setRowHidden(i, False) + self.toolButton_2.setDown(False) + if self.lineEdit.text() != 'Recherche par mots-clés': + self.filtre_dynamique(self.lineEdit.text()) + else: + for i in range(self.tableWidget.rowCount()): + self.tableWidget.setRowHidden(i, False) def filtre_dynamique(self, filter_text): if filter_text.find(' ') >= 0: @@ -750,7 +698,3 @@ class Flux_Editor(QDialog, EDITOR_CLASS): new_object = new_object + '[' + str(obj_X[1]) + ',' + str(obj_X[0]) + '],' new_object = new_object[:-1] + ']' return (new_object) - - # def popup(self): - # self.dialog = Popup() # +++ - self - # self.dialog.text_edit.show() diff --git a/CenRa_FLUX/metadata.txt b/CenRa_FLUX/metadata.txt index 6f9762f..7173c3a 100644 --- a/CenRa_FLUX/metadata.txt +++ b/CenRa_FLUX/metadata.txt @@ -7,7 +7,7 @@ name=CenRa_FLUX qgisMinimumVersion=3.0 supportsQt6=True description=Permet d'ouvrire une table dans la base PostGis -version=3.15 +version=3.16 author=Conservatoire d'Espaces Naturels de Rhône-Alpes email=si_besoin@cen-rhonealpes.fr @@ -32,7 +32,7 @@ icon=icon.png # experimental flag experimental=False -changelog=

CenRa_FLUX:


10/02/2026 - Version 3.15:

- Sauvegarde la recherche.


08/12/2025 - Version 3.14:

- message d'erreur pour les drois de couche sur la DB.


08/12/2025 - Version 3.13:

- Detection des droit utilisateur.


25/09/2025 - Version 3.12:

- version +1.


25/09/2025 - Version 3.11:

- Correctife sur les code 00.


24/09/2025 - Version 3.10:

- Erreur sur l ouverture des couche raster.


24/09/2025 - Version 3.9:

- bugfix lier aux extention pgsql.


09/09/2025 - Version 3.8:

- Bug REF fix.


05/09/2025 - Version 3.7:

- Ouverture de projet QGIS contenue dans la base de donnees.


30/07/2025 - Version 3.6:

- Correctife de bug.


29/07/2025 - Version 3.5:

- Bug fix sur les donnee raster.


23/07/2025 - Version 3.4:

- Ouverture raster dans la base SIG.


23/07/2025 - Version 3.3:

- Optimisation des chargement.


22/07/2025 - Version 3.2:

- Visualisation des format raster et vecteur dans REF.


21/07/2025 - Version 3.1:

- Bug fix pour l'ouverture de plus de 5 couches.


19/05/2025 - Version 3.0:

- Compatible PyQt5 et PyQt6.


09/04/2025 - Version 2.9:

- Correctif bug en TT.


09/04/2025 - Version 2.8:

- Optimisation pour le TT.


07/04/2025 - Version 2.7:

- mode debug.


03/04/2025 - Version 2.6:

- Mise a jour de securite.


20/03/2025 - Version 2.5:

- Visualisation distincte des couches ne se trouvant pas dans l'antenne.


13/02/2025 - Version 2.4:

- Ajoute redimensionnement et déplacement mollette.


05/02/2025 - Version 2.3:

- Bouton de visualisation des couches se trouvent uniquement dans le canva de la carte.


07/01/2025 - Version 2.2:

- ByPass du certif ssl ci erreur.


22/10/2024 - Version 2.1:

- Correctif de bug.
- Evolution de la limit de 3 à 5.


22/10/2024 - Version 2.0:

- Reformatage du code.


03/10/2024 - Version 1.14:

- Remonte la fênetre dans la pille.

13/09/2024 - Version 1.13:

- MAJ sur le lien du changelog
- Bug-fix: Ouvre MultiPolygone et Polygon séparément.


10/09/2024 - Version 1.11:

- Ouverture de table contenant plusieurs géométries.


26/08/2024 - Version 1.10:

- Ajoute d'un changelog et vérification de mise à jour.

+changelog=

CenRa_FLUX:


11/02/2026 - Version 3.16:

- Creation de favori et visualisation.


10/02/2026 - Version 3.15:

- Sauvegarde la recherche.


08/12/2025 - Version 3.14:

- message d'erreur pour les drois de couche sur la DB.


08/12/2025 - Version 3.13:

- Detection des droit utilisateur.


25/09/2025 - Version 3.12:

- version +1.


25/09/2025 - Version 3.11:

- Correctife sur les code 00.


24/09/2025 - Version 3.10:

- Erreur sur l ouverture des couche raster.


24/09/2025 - Version 3.9:

- bugfix lier aux extention pgsql.


09/09/2025 - Version 3.8:

- Bug REF fix.


05/09/2025 - Version 3.7:

- Ouverture de projet QGIS contenue dans la base de donnees.


30/07/2025 - Version 3.6:

- Correctife de bug.


29/07/2025 - Version 3.5:

- Bug fix sur les donnee raster.


23/07/2025 - Version 3.4:

- Ouverture raster dans la base SIG.


23/07/2025 - Version 3.3:

- Optimisation des chargement.


22/07/2025 - Version 3.2:

- Visualisation des format raster et vecteur dans REF.


21/07/2025 - Version 3.1:

- Bug fix pour l'ouverture de plus de 5 couches.


19/05/2025 - Version 3.0:

- Compatible PyQt5 et PyQt6.


09/04/2025 - Version 2.9:

- Correctif bug en TT.


09/04/2025 - Version 2.8:

- Optimisation pour le TT.


07/04/2025 - Version 2.7:

- mode debug.


03/04/2025 - Version 2.6:

- Mise a jour de securite.


20/03/2025 - Version 2.5:

- Visualisation distincte des couches ne se trouvant pas dans l'antenne.


13/02/2025 - Version 2.4:

- Ajoute redimensionnement et déplacement mollette.


05/02/2025 - Version 2.3:

- Bouton de visualisation des couches se trouvent uniquement dans le canva de la carte.


07/01/2025 - Version 2.2:

- ByPass du certif ssl ci erreur.


22/10/2024 - Version 2.1:

- Correctif de bug.
- Evolution de la limit de 3 à 5.


22/10/2024 - Version 2.0:

- Reformatage du code.


03/10/2024 - Version 1.14:

- Remonte la fênetre dans la pille.

13/09/2024 - Version 1.13:

- MAJ sur le lien du changelog
- Bug-fix: Ouvre MultiPolygone et Polygon séparément.


10/09/2024 - Version 1.11:

- Ouverture de table contenant plusieurs géométries.


26/08/2024 - Version 1.10:

- Ajoute d'un changelog et vérification de mise à jour.

# deprecated flag (applies to the whole plugin, not just a single version) deprecated=False diff --git a/plugins.xml b/plugins.xml index d06c287..ec1b586 100644 --- a/plugins.xml +++ b/plugins.xml @@ -50,9 +50,9 @@ cenra,sicen - + Depot pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub. - 3.15 + 3.16 3.16 https://plateformesig.cenra-outils.org/ CenRa_FLUX.zip @@ -61,7 +61,7 @@ https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_FLUX.zip CEN-Rhone-Alpes 2024-02-06 - 2026-02-10 + 2026-02-11 False False cenra,flux