-
Notifications
You must be signed in to change notification settings - Fork 1
/
plume_ui.py
1548 lines (1419 loc) · 83.7 KB
/
plume_ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# (c) Didier LECLERC 2020 CMSIG MTE-MCTRCT/SG/SNUM/UNI/DRC Site de Rouen
# créé sept 2021
# **************************************************************************
# copyright : (C) 2021 by DL
# **************************************************************************
from PyQt5 import QtCore, QtGui, QtWidgets, QtQuick
from PyQt5.QtCore import *
from PyQt5.QtWidgets import (QAction, QMenu , QMenuBar, QToolBar, QApplication, QMessageBox, QFileDialog, QPlainTextEdit, QDialog, QStyle,
QDockWidget, QTreeView, QGridLayout, QHBoxLayout, QTabWidget, QWidget, QDesktopWidget, QSizePolicy, QLayout, QVBoxLayout,
QTreeWidget, QTreeWidgetItem, QTreeWidgetItemIterator, QStyleFactory, QStyle, QSpacerItem)
from PyQt5.QtGui import QIcon, QStandardItem, QStandardItemModel
from html import escape
from . import bibli_plume
from .bibli_plume import *
#
from . import bibli_gene_objets
from .bibli_gene_objets import *
#
from . import docolorbloc
from . import doabout
from . import doimportcsw
from . import docreatetemplate
from qgis.core import *
from qgis.gui import *
from qgis.PyQt.QtCore import QUrl
import qgis
import os
import subprocess
import time
import sys
import traceback
from contextlib import contextmanager
import psycopg2
from plume.pg import queries
from plume.rdf.metagraph import copy_metagraph
from plume.pg.template import LocalTemplatesCollection
from plume.config import (VALUEDEFAUTFILEHELP, VALUEDEFAUTFILEHELPPDF, VALUEDEFAUTFILEHELPHTML, LIBURLCSWDEFAUT, URLCSWDEFAUT, URLCSWIDDEFAUT)
class Ui_Dialog_plume(object):
def __init__(self):
self.iface = qgis.utils.iface
self.firstOpen = True
self.firstOpenConnect = True
@contextmanager
def safe_pg_connection(self) :
if not getattr(self, 'mConnectEnCours', False) or self.mConnectEnCours.closed:
self.getAllFromUri()
try:
yield
except psycopg2.Error as err :
self.layerBeforeClicked = ("", "")
saveinitializingDisplay("write", self.layerBeforeClicked)
bibli_plume.breakExecuteSql(self)
if err.diag:
zTitre = QtWidgets.QApplication.translate("plume_ui", "PLUME : Warning", None)
zMess = err.diag.message_primary
displayMess(self.Dialog, (2 if self.Dialog.displayMessage else 1), zTitre, zMess, Qgis.Warning, self.Dialog.durationBarInfo)
except NoReturnSql as err_NoReturnSql :
self.layerBeforeClicked = ("", "")
saveinitializingDisplay("write", self.layerBeforeClicked)
bibli_plume.breakExecuteSql(self)
zTitre = QtWidgets.QApplication.translate("plume_ui", "PLUME : Warning", None)
zMess = str(err_NoReturnSql.mMess)
displayMess(self.Dialog, (2 if self.Dialog.displayMessage else 1), zTitre, zMess, Qgis.Warning, self.Dialog.durationBarInfo)
except Exception as err_Exception :
self.layerBeforeClicked = ("", "")
saveinitializingDisplay("write", self.layerBeforeClicked)
bibli_plume.breakExecuteSql(self)
zTitre = QtWidgets.QApplication.translate("plume_ui", "PLUME : Warning", None)
zMess = str(err_Exception) + "\n" + str(traceback.format_tb(Exception.__traceback__))
displayMess(self.Dialog, (2 if self.Dialog.displayMessage else 1), zTitre, zMess, Qgis.Warning, self.Dialog.durationBarInfo)
finally:
if getattr(self, 'mConnectEnCours', False) : self.mConnectEnCours.close()
def setupUi(self, Dialog, _dicTooltipExiste):
self.Dialog = Dialog
Dialog.setObjectName("Dialog")
self.zMessError_Transaction = "FIN TRANSACTION"
self._dicTooltipExiste = _dicTooltipExiste
#--
mDic_LH = bibli_plume.returnAndSaveDialogParam(self, "Load")
self.mDic_LH = mDic_LH
#--
self.lScreenDialog, self.hScreenDialog = int(self.mDic_LH["dialogLargeur"]), int(self.mDic_LH["dialogHauteur"])
self.displayMessage = False if self.mDic_LH["displayMessage"] == 'dialogTitle' else True #Qmessage box (dialogBox) ou barre de progression (dialogTitle)
self.fileHelp = VALUEDEFAUTFILEHELP #Type Fichier Help
self.fileHelpPdf = VALUEDEFAUTFILEHELPPDF #Fichier Help PDF
self.fileHelpHtml = VALUEDEFAUTFILEHELPHTML #Fichier Help HTML
self.durationBarInfo = int(self.mDic_LH["durationBarInfo"]) #durée d'affichage des messages d'information
self.ihm = self.mDic_LH["ihm"] #window/dock
self.versionPlumeBibli = self.mDic_LH["versionPlumeBibli"] #version Plume des bibliothèques
#---
self.colorDefaut = self.mDic_LH["defaut"] #Color QGroupBox
self.colorQGroupBox = self.mDic_LH["QGroupBox"] #Color QGroupBox
self.colorQGroupBoxGroupOfProperties = self.mDic_LH["QGroupBoxGroupOfProperties"] #Color QGroupBox
self.colorQGroupBoxGroupOfValues = self.mDic_LH["QGroupBoxGroupOfValues"] #Color QGroupBox
self.colorQGroupBoxTranslationGroup = self.mDic_LH["QGroupBoxTranslationGroup"] #Color QGroupBox
self.colorQTabWidget = self.mDic_LH["QTabWidget"] #Color QTabWidget
self.labelBackGround = self.mDic_LH["QLabelBackGround"] #Fond Qlabel
#---
self.margeQToolButton = 40
self.margeQMenu = 50
self.editStyle = self.mDic_LH["QEdit"] #style saisie
self.epaiQGroupBox = self.mDic_LH["QGroupBoxEpaisseur"] #épaisseur QGroupBox
self.lineQGroupBox = self.mDic_LH["QGroupBoxLine"] #trait QGroupBox
self.policeQGroupBox = self.mDic_LH["QGroupBoxPolice"] #Police QGroupBox
self.policeQTabWidget = self.mDic_LH["QTabWidgetPolice"] #Police QTabWidget
#---
self.libUrlCswDefaut = LIBURLCSWDEFAUT #libellé de l'Url par defaut
self.urlCswDefaut = URLCSWDEFAUT #l'Url par defaut
self.urlCswIdDefaut = URLCSWIDDEFAUT #l'Id de l'Url par defaut
self.urlCsw = self.mDic_LH["urlCsw"] #Liste des urlcsw sauvegardées
# for geometry
self.geomColor = self.mDic_LH["geomColor"]
self.geomEpaisseur = self.mDic_LH["geomEpaisseur"]
self.geomPoint = self.mDic_LH["geomPoint"]
self.geomPointEpaisseur = self.mDic_LH["geomPointEpaisseur"]
self.geomZoom = True if self.mDic_LH["geomZoom"] == "true" else False
self.geomPrecision = int(self.mDic_LH["geomPrecision"])
#-
#tooltip
self.activeTooltip = True if mDic_LH["activeTooltip"] == "true" else False
self.activeTooltipWithtitle = True if mDic_LH["activeTooltipWithtitle"] == "true" else False
self.activeTooltipLogo = True if mDic_LH["activeTooltipLogo"] == "true" else False
self.activeTooltipCadre = True if mDic_LH["activeTooltipCadre"] == "true" else False
self.activeTooltipColor = True if mDic_LH["activeTooltipColor"] == "true" else False
self.activeTooltipColorText = mDic_LH["activeTooltipColorText"]
self.activeTooltipColorBackground = mDic_LH["activeTooltipColorBackground"]
self.activeZoneNonSaisie = True if self.mDic_LH["activeZoneNonSaisie"] == "true" else False
# For the Dock AsgardMenu Gestion des toolTip
self.asgardMenuDock = mDic_LH["asgardMenuDock"]
#-
mDicType = ["ICON_CROSS", "ICON_X", "ICON_BOX", "ICON_CIRCLE", "ICON_FULL_BOX" , "ICON_DIAMOND" , "ICON_FULL_DIAMOND"]
mDicTypeObj = [QgsRubberBand.ICON_X, QgsRubberBand.ICON_CROSS, QgsRubberBand.ICON_BOX, QgsRubberBand.ICON_CIRCLE, QgsRubberBand.ICON_FULL_BOX, QgsRubberBand.ICON_DIAMOND, QgsRubberBand.ICON_FULL_DIAMOND]
self.mDicTypeObj = dict(zip(mDicType, mDicTypeObj)) # For bibli_plume_tools_map
_pathIconsUser = QgsApplication.qgisSettingsDirPath().replace("\\","/") + "plume/icons/buttons"
createFolder(_pathIconsUser)
#-
#Management Click before open IHM
if self.mDic_LH["layerBeforeClickedWho"] == "qgis" :
self.layerBeforeClicked = (bibli_plume.returnIfExisteInLegendeInterface(self, self.mDic_LH["layerBeforeClicked"]), self.mDic_LH["layerBeforeClickedWho"], self.mDic_LH["layerBeforeClickedBrowser"]) # Couche mémorisée avant ouverture et de l'origine
elif self.mDic_LH["layerBeforeClickedWho"] == "postgres" :
self.layerBeforeClicked = (bibli_plume.returnIfExisteInBrowser(self, self.mDic_LH["layerBeforeClicked"]), self.mDic_LH["layerBeforeClickedWho"], self.mDic_LH["layerBeforeClickedBrowser"]) # Couche mémorisée avant ouverture et de l'origine
else :
self.layerBeforeClicked = ('', '')
#Cas ou l'instance sauvegardé dans le QGIS3.INI n'a plus de correspondance
if self.layerBeforeClicked[0] is None : self.layerBeforeClicked = ('', '')
#Cas ou l'instance sauvegardé dans le QGIS3.INI n'a plus de correspondance
# for geometry
# liste des Paramétres UTILISATEURS
bibli_plume.listUserParam(self)
# liste des Paramétres UTILISATEURS
#for test param user
"""
l = [ self.language,self.initTranslation,self.langList,self.geoideJSON,self.preferedTemplate,self.enforcePreferedTemplate,\
self.readHideBlank,self.readHideUnlisted,self.editHideUnlisted,self.readOnlyCurrentLanguage,\
self.editOnlyCurrentLanguage,self.labelLengthLimit,self.valueLengthLimit,self.textEditRowSpan ]
print(l)
"""
#for test param user
#---
_pathIcons = os.path.dirname(__file__) + "/icons/misc"
_iconSourcesBlank = _pathIcons + "/blank.svg"
_pathIcons = os.path.dirname(__file__) + "/icons/general"
_iconSourcesRead = _pathIcons + "/read.svg"
_iconSourcesEmpty = _pathIcons + "/empty.svg"
_iconSourcesExport = _pathIcons + "/export.svg"
_iconSourcesImport = _pathIcons + "/import.svg"
_iconSourcesCopy = _pathIcons + "/copy_all.svg"
_iconSourcesPaste = _pathIcons + "/paste_all.svg"
_iconSourcesSave = _pathIcons + "/save.svg"
_iconSourcesTemplate = _pathIcons + "/template.svg"
_iconSourcesTranslation = _pathIcons + "/translation.svg"
_iconSourcesParam = _pathIcons + "/configuration.svg"
_iconSourcesInterrogation = _pathIcons + "/info.svg"
_iconSourcesVerrou = _pathIcons + "/verrou.svg"
_pathIconsQComboBox = os.path.dirname(__file__) + "/icons/buttons"
_iconQComboBox = _pathIconsQComboBox + "/drop_down_arrow.svg"
self._iconQComboBox = _iconQComboBox.replace("\\","/")
# For menu contex QGroupBox
self._iconSourcesCopy, self._iconSourcesPaste = _iconSourcesCopy, _iconSourcesPaste
_iconSourcesPaste = _pathIcons + "/paste_all.svg"
self.listIconToolBar = [ _iconSourcesRead, _iconSourcesSave, _iconSourcesEmpty, _iconSourcesExport, _iconSourcesImport, _iconSourcesCopy, _iconSourcesPaste, _iconSourcesTemplate, _iconSourcesTranslation, _iconSourcesParam, _iconSourcesInterrogation, _iconSourcesVerrou, _iconSourcesBlank ]
#--------
Dialog.resize(QtCore.QSize(QtCore.QRect(0,0, self.lScreenDialog, self.hScreenDialog).size()).expandedTo(Dialog.minimumSizeHint()))
self.messWindowTitle = QtWidgets.QApplication.translate("plume_ui", "PLUGIN METADATA (Metadata storage in PostGreSQL)", None) + " (" + str(bibli_plume.returnVersion()) + ")"
Dialog.setWindowTitle(self.messWindowTitle)
Dialog.setWindowModality(Qt.WindowModal)
Dialog.setWindowFlags(Qt.WindowMaximizeButtonHint | Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint)
_pathIcons = os.path.dirname(__file__) + "/icons/logo"
iconSource = _pathIcons + "/plume.svg"
iconSourceTooltip = _pathIcons + "/plume.svg"
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(iconSource), QtGui.QIcon.Normal, QtGui.QIcon.Off)
Dialog.setWindowIcon(icon)
#Affiche info si MAJ version
self.barInfo = QgsMessageBar(self.iface.mainWindow())
self.barInfo.setSizePolicy( QSizePolicy.Minimum, QSizePolicy.Fixed )
self.barInfo.setGeometry(10,25, self.iface.mainWindow().width()-30, 30)
#==========================
#Zone Onglets
self.tabWidget = QTabWidget(Dialog)
self.tabWidget.setObjectName("tabWidget")
x, y = 10, 50
larg, haut = self.lScreenDialog -20, (self.hScreenDialog - 60 )
self.tabWidget.setGeometry(QtCore.QRect(x, y, larg , haut))
self.tabWidget.setStyleSheet("QTabWidget::pane {border: 2px solid " + self.colorQTabWidget + "; font-family:" + self.policeQGroupBox +"; } \
QTabBar::tab {border: 1px solid " + self.colorQTabWidget + "; border-bottom-color: none; font-family:" + self.policeQGroupBox +";\
border-top-left-radius: 6px;border-top-right-radius: 6px; \
} \
QTabBar::tab:selected {background: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5, stop: 0 " + self.colorQTabWidget + ", stop: 1 white);} \
")
self.tabWidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
tab_widget_Onglet = QWidget()
tab_widget_Onglet.setObjectName("Informations")
labelTabOnglet = " Informations "
self.tabWidget.addTab(tab_widget_Onglet, labelTabOnglet)
QtCore.QMetaObject.connectSlotsByName(Dialog)
#==========================
#==========================
#First Open
if self.firstOpen :
bibli_plume.afficheNoConnections(self, "first")
self.listeResizeIhm = [] # For resizeIhm
#First Open
#==========================
#=====================================================
# Window Versus Dock
if self.ihm in ["dockTrue", "dockFalse"] :
monDock = MONDOCK(self.Dialog)
self.monDock = monDock
# Window Versus Dock
#----
self.mode = "read" #Intiialise les autres instances
self.verrouLayer = False #Verrouillage de la couche
self.nameVerrouLayer = None #Couche verrouillée
#----
#=====================================================
#--- Icons Actions ---- Edit, Empty, Export, Import, Save, Template, Traslation -----
self.createToolBar(*self.listIconToolBar)
#------------
if self.ihm in ["dockTrue", "dockFalse"] : self.mMenuBarDialogLine1.show()
if self.ihm in ["dockTrue", "dockFalse"] : self.mMenuBarDialogLine2.show()
#==========================
self.retranslateUi(Dialog)
#==========================
#Interactions avec les différents canaux de communication
self.gestionInteractionConnections()
#==========================
#Active Tooltip
self._myExploBrowser = MyExploBrowser(self.navigateur.findChildren(QTreeView)[0], self._dicTooltipExiste, self.activeTooltip, self.activeTooltipColorText, self.activeTooltipColorBackground, self.langList, iconSourceTooltip, self.activeTooltipLogo, self.activeTooltipCadre, self.activeTooltipColor, self.activeTooltipWithtitle)
self._myExploBrowser2 = MyExploBrowser(self.navigateur2.findChildren(QTreeView)[0], self._dicTooltipExiste, self.activeTooltip, self.activeTooltipColorText, self.activeTooltipColorBackground, self.langList, iconSourceTooltip, self.activeTooltipLogo, self.activeTooltipCadre, self.activeTooltipColor, self.activeTooltipWithtitle)
if self.navigateurasgardMenuDock != None : self._myExploBrowserAsgardMenu = MyExploBrowserAsgardMenu(self.navigateurasgardMenuDock.findChild(QTreeView), self._dicTooltipExiste, self.activeTooltip, self.activeTooltipColorText, self.activeTooltipColorBackground, self.langList, iconSourceTooltip, self.activeTooltipLogo, self.activeTooltipCadre, self.activeTooltipColor, self.activeTooltipWithtitle)
#==========================
#Instanciation des "shape, template, vocabulary, mode"
self.translation = bibli_plume.returnObjetTranslation(self)
#==========================
#Management Click before open IHM
if self.layerBeforeClicked[0] != "" :
if self.layerBeforeClicked[1] == "qgis" :
self.retrieveInfoLayerQgis(None)
elif self.layerBeforeClicked[1] == "postgres" :
self.retrieveInfoLayerQgis(self.layerBeforeClicked[0])
else :
if not self.verrouLayer : bibli_plume.initIhmNoConnection(self)
#Management Click before open IHM
#= Fin setupUi
#==========================
# == Gestion des actions de boutons de la barre de menu
def clickButtonsActions(self):
# == Gestion Context ==
with self.safe_pg_connection() :
# If suppression d'une couche active pour les métadonnées affichées
if not bibli_plume.gestionErreurExisteLegendeInterface(self) : return
# If suppression d'une couche active pour les métadonnées affichées
mItemLine1 = self.mMenuBarDialogLine1.sender().objectName()
mItemLine2 = self.mMenuBarDialogLine2.sender().objectName()
#**********************
if mItemLine1 == "Edition" :
#Interroge l'utilisateur si modifications
if self.mode == "edit" and self.zoneConfirmMessage :
if self.mDicObjetsInstancies.modified or bibli_plume.ifChangeValues(self.mDicObjetsInstancies) :
if QMessageBox.question(None, "Confirmation", QtWidgets.QApplication.translate("plume_ui", "If you continue, unsaved changes will be lost."),QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel :
self.plumeEdit.setChecked(False if self.plumeEdit.isChecked() else True)
return
#Si vous poursuivez, les modifications non enregistrées seront perdues.
if self.mode == None or self.mode == "read" :
self.mode = "edit"
elif self.mode == "edit" :
self.mode = "read"
else :
self.mode = "read"
#-
if self.saveMetaGraph :
self.oldMetagraph = self.metagraph
else :
self.metagraph = self.oldMetagraph
self.saveMetaGraph = False
# For mode Edit
if self.mode == "edit" :
if self.nameVerrouLayer == None : self.nameVerrouLayer = self.layer
self.verrouLayer = True
else :
self.iface.setActiveLayer(self.nameVerrouLayer)
self.nameVerrouLayer = None
self.verrouLayer = False
#**********************
elif mItemLine1 == "Save" :
bibli_plume.saveMetaIhm(self, self.schema, self.table)
self.saveMetaGraph = True
#**********************
elif mItemLine2 == "Empty" :
if self.saveMetaGraph :
self.oldMetagraph = self.metagraph
else :
self.metagraph = self.oldMetagraph
self.saveMetaGraph = False
#-
old_metagraph = self.metagraph
self.metagraph = copy_metagraph(None, old_metagraph)
#**********************
elif mItemLine2 == "Copy" :
self.copyMetagraph = self.metagraph
if self.copyMetagraph != None :
mTextToolTip = QtWidgets.QApplication.translate("plume_main", "Paste the metadata card of ") + "<b>" + str(self.schema) + "." + str(self.table) + "</b> Alt+Maj+V"
else :
mTextToolTip = QtWidgets.QApplication.translate("plume_main", "Paste the saved metadata card.")
self.copyMetagraphTooltip = mTextToolTip
self.plumePaste.setToolTip(mTextToolTip)
#**********************
elif mItemLine2 == "Paste" :
if self.copyMetagraph != None :
src_metagraph, old_metagraph = self.copyMetagraph, self.metagraph
_metagraph = copy_metagraph(src_metagraph, old_metagraph)
self.metagraph = _metagraph
#**********************
elif mItemLine2 == "plumeImportFile" :
if self.saveMetaGraph :
self.oldMetagraph = self.metagraph
else :
self.metagraph = self.oldMetagraph
self.saveMetaGraph = False
#-
metagraph = bibli_plume.importObjetMetagraph(self)
if metagraph != None : self.metagraph = metagraph
#**********************
elif mItemLine2 == "plumeImportFileInspire" :
if self.saveMetaGraph :
self.oldMetagraph = self.metagraph
else :
self.metagraph = self.oldMetagraph
self.saveMetaGraph = False
#-
metagraph = bibli_plume.importObjetMetagraphInspire(self)
if metagraph != None : self.metagraph = metagraph
#**********************
elif mItemLine1 == "Traduction" :
#Interroge l'utilisateur si modifications
if self.mode == "edit" and self.zoneConfirmMessage :
if self.mDicObjetsInstancies.modified or bibli_plume.ifChangeValues(self.mDicObjetsInstancies) :
if QMessageBox.question(None, "Confirmation", QtWidgets.QApplication.translate("plume_ui", "If you continue, unsaved changes will be lost."),QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel :
self.plumeTranslation.setChecked(False if self.plumeTranslation.isChecked() else True)
return
#Si vous poursuivez, les modifications non enregistrées seront perdues.
self.translation = (False if self.translation else True)
#**********************
elif QtWidgets.QApplication.translate("plume_ui", mItemLine2) == "Verrouillage" :
self.verrouLayer = (False if self.verrouLayer else True)
self.nameVerrouLayer = (self.layer if self.verrouLayer else None)
self.plumeVerrou.setChecked(True if self.verrouLayer else False)
#**********************
#*** commun
if mItemLine1 in ["Edition", "Save", "Empty", "plumeImportFile", "plumeImportFileInspire", "Paste", "Traduction"] or mItemLine2 in ["Edition", "Save", "Empty", "plumeImportFile", "plumeImportFileInspire", "Paste", "Traduction"] :
bibli_plume.saveObjetTranslation(self.translation)
self.generationALaVolee(bibli_plume.returnObjetsMeta(self))
#-
self.displayToolBar(*self.listIconToolBar)
return
# == Gestion des actions de boutons de la barre de menu
#==========================
#==========================
# == Gestion des actions du bouton EXPORT de la barre de menu
def clickButtonsExportActions(self):
# If suppression d'une couche active pour les métadonnées affichées
if not bibli_plume.gestionErreurExisteLegendeInterface(self) : return
# If suppression d'une couche active pour les métadonnées affichées
mItemExport = self.mMenuBarDialogLine2.sender().objectName()
exportObjetMetagraph(self, self.schema, self.table, mItemExport, self.metagraph.available_export_formats(no_duplicate=True, format=mItemExport))
return
# == Gestion des actions du bouton EXPORT de la barre de menu
#==========================
#==========================
# == Gestion des actions du bouton TEMPLATE de la barre de menu
def clickButtonsTemplateActions(self):
# == Gestion Context ==
with self.safe_pg_connection() :
# If suppression d'une couche active pour les métadonnées affichées
if not bibli_plume.gestionErreurExisteLegendeInterface(self) : return
# If suppression d'une couche active pour les métadonnées affichées
#Interroge l'utilisateur si modifications
if self.mode == "edit" and self.zoneConfirmMessage :
if self.mDicObjetsInstancies.modified or bibli_plume.ifChangeValues(self.mDicObjetsInstancies) :
if QMessageBox.question(None, "Confirmation", QtWidgets.QApplication.translate("plume_ui", "If you continue, unsaved changes will be lost."),QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel :
self.plumeTemplate.setText(self.plumeTemplate.text())
return
#Si vous poursuivez, les modifications non enregistrées seront perdues.
mItemTemplates = self.mMenuBarDialogLine1.sender().objectName()
"""
#Lecture existence Extension METADATA
_mContinue = True
#if not hasattr(self, 'mConnectEnCours') :
# if not self.instalMetadata : _mContinue = False
"""
if mItemTemplates == "Aucun" :
self.template = None
else :
#-
if self.instalMetadata :
# Choix du modèle
bibli_plume.generationTemplateAndTabs(self, mItemTemplates)
else :
self.template = self.templates_collection.get(mItemTemplates) if mItemTemplates else None
#-
# Génération à la volée
self.generationALaVolee(bibli_plume.returnObjetsMeta(self))
# MAJ ICON FLAGS
self.majQmenuModeleIconFlag(mItemTemplates)
#
self.majButtonTemplate(self.plumeTemplate, mItemTemplates, int(len(mItemTemplates)))
# MAJ ICON FLAGS
return
# == Gestion des actions du bouton TEMPLATE de la barre de menu
#==========================
#==========================
# == Gestion des actions du bouton Changement des langues
def clickButtonsChoiceLanguages(self):
# == Gestion Context ==
with self.safe_pg_connection() :
# If suppression d'une couche active pour les métadonnées affichées
if not bibli_plume.gestionErreurExisteLegendeInterface(self) : return
# If suppression d'une couche active pour les métadonnées affichées
#Interroge l'utilisateur si modifications
if self.mode == "edit" and self.zoneConfirmMessage :
if self.mDicObjetsInstancies.modified or bibli_plume.ifChangeValues(self.mDicObjetsInstancies) :
if QMessageBox.question(None, "Confirmation", QtWidgets.QApplication.translate("plume_ui", "If you continue, unsaved changes will be lost."),QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel :
self.plumeChoiceLang.setText(self.plumeChoiceLang.text())
return
#Si vous poursuivez, les modifications non enregistrées seront perdues.
mItemLine1 = self.mMenuBarDialogLine1.sender().objectName()
# MAJ ICON FLAGS
self.majQmenuModeleIconFlagChoiceLang(mItemLine1)
#un peu de robustesse car théo gérer dans le lecture du Qgis3.ini
if mItemLine1 == "" :
self.language, mItemLine1 = "fr", "fr"
else:
self.language = mItemLine1
if mItemLine1 not in self.langList : self.langList.append(mItemLine1)
#un peu de robustesse car théo gérer dans le lecture du Qgis3.ini
self.plumeChoiceLang.setText(mItemLine1)
lenQTool = self.plumeChoiceLang.fontMetrics().size(Qt.TextSingleLine, mItemLine1).width()
mDicUserSettings = {}
mSettings = QgsSettings()
mSettings.beginGroup("PLUME")
mSettings.beginGroup("UserSettings")
#Ajouter si autre param
mDicUserSettings["language"] = mItemLine1
mDicUserSettings["langList"] = self.langList
#----
for key, value in mDicUserSettings.items():
mSettings.setValue(key, value)
#======================
mSettings.endGroup()
mSettings.endGroup()
#----
#Regénération du dictionnaire
self.generationALaVolee(bibli_plume.returnObjetsMeta(self))
#-
self.displayToolBar(*self.listIconToolBar)
return
# == Gestion des actions du bouton Changement des langues
#==========================
#==================================================
#AJOUT 30 JANVIER 2022
def menuContextuelQGroupBox(self, _keyObjet, _mObjetGroupBox, point):
_menuGroupBox = QMenu()
_menuGroupBox.setStyleSheet("QMenu { font-family:" + self.policeQGroupBox +"; width:120px; border-style:" + self.editStyle + "; border-width: 0px;}")
#-------
menuIcon = returnIcon(self._iconSourcesPaste)
_menuActionQGroupBoxCopier = QAction(QIcon(menuIcon), "Copier le bloc.", _menuGroupBox)
_menuGroupBox.addAction(_menuActionQGroupBoxCopier)
_menuActionQGroupBoxCopier.triggered.connect(lambda : self.actionFonctionQGroupBox(_keyObjet, "copierQGroupBox"))
#-------
menuIcon = returnIcon(self._iconSourcesCopy)
_menuActionQGroupBoxColler = QAction(QIcon(menuIcon), "Coller le bloc.", _menuGroupBox)
_menuGroupBox.addAction(_menuActionQGroupBoxColler)
_menuActionQGroupBoxColler.triggered.connect(lambda : self.actionFonctionQGroupBox(_keyObjet, "collerQGroupBox"))
#-------
_menuGroupBox.exec_(_mObjetGroupBox.mapToGlobal(point))
return
#**********************
def actionFonctionQGroupBox(self,_keyObjet, mAction):
print(str(_keyObjet))
if mAction == "copierQGroupBox" :
print("copierQGroupBox")
elif mAction == "collerQGroupBox" :
print("collerQGroupBox")
return
#AJOUT 30 JANVIER 2022
#==================================================
#==========================
#Génération à la volée
#Dict des objets instanciés
def generationALaVolee(self, _dict):
# Nettoyage
for comptElemTab in range(self.tabWidget.count()) :
self.tabWidget.removeTab(0)
#== For Create premier onglet Générale
tab_widget_Onglet = QWidget()
tab_widget_Onglet.setObjectName("Informations")
labelTabOnglet = " Informations "
self.tabWidget.addTab(tab_widget_Onglet, labelTabOnglet)
#== For Create premier onglet Générale
# Nettoyage
#--
self.mDicObjetsInstancies = _dict
self.mFirstColor = True
self.dic_geoToolsShow = {} # For visualisation sur BBOX, Centroid and geometry
#Supprime si l'objet existe l'affichage du rubberBand et desactive le process QgsMapTool
try :
for k, v in self.dic_objetMap.items() :
try :
qgis.utils.iface.mapCanvas().unsetMapTool(self.dic_objetMap[k])
self.dic_objetMap[k].rubberBand.hide()
except :
pass
except :
pass
#Supprime si l'objet existe l'affichage du rubberBand
self.dic_objetMap = {} # For visualisation sur BBOX, Centroid and geometry
#*****************************
# ** BEFORE SAISIE ** Mode automatique calcul des Métadonnées
# Lorsque la clé correspond à un widget de saisie, le calcul doit avoir lieu avant la saisie de la valeur dans le widget
# Il s’agit là aussi de boucler sur les clés du dictionnaire de widgets pour exécuter les calculs
for key, value in _dict.items_to_compute():
action_mObjetQToolButton_ComputeButton(self, key, value, 'BEFORE')
#*****************************
#--
for key, value in _dict.items() :
if _dict[key]['main widget type'] != None :
#Génération à la volée des objets
bibli_gene_objets.generationObjets(self, key, value)
self.mFirstColor = False
#--
# Nettoyage
for comptElemTab in range(self.tabWidget.count()) :
if self.tabWidget.tabText(comptElemTab) == " Informations " :
self.tabWidget.removeTab(comptElemTab)
# For Réaffichage du dimensionnement
bibli_plume.resizeIhm(self, self.Dialog.width(), self.Dialog.height())
#--------------------------
self.tabWidget.setCurrentIndex(0)
#--
#Génération à la volée
#==========================
#---------------------------
#---------------------------
# == Gestion des INTERACTIONS
def gestionInteractionConnections(self):
_mCommentPlume = "Attention !! des métadonnées sont gérées pour cette couche !"
self.db = None
self.schema = None
self.table = None
self.comment = None
#Interaction avec le gestionnaire de couche de QGIS
iface.layerTreeView().clicked.connect(lambda : self.retrieveInfoLayerQgis(None))
# Interaction avec le navigateur de QGIS
self.mNav1, self.mNav2, self.mNavAsgardMenu = 'Browser', 'Browser2', self.asgardMenuDock
#1
self.navigateur = iface.mainWindow().findChild(QDockWidget, self.mNav1)
self.navigateurTreeView = self.navigateur.findChild(QTreeView)
self.navigateurTreeView.setObjectName(self.mNav1)
self.navigateurTreeView.clicked.connect(self.retrieveInfoLayerBrowser)
#2
self.navigateur2 = iface.mainWindow().findChild(QDockWidget, self.mNav2)
self.navigateurTreeView2 = self.navigateur2.findChild(QTreeView)
self.navigateurTreeView2.setObjectName(self.mNav2)
self.navigateurTreeView2.clicked.connect(self.retrieveInfoLayerBrowser)
#3
if len(iface.mainWindow().findChildren(QWidget, self.mNavAsgardMenu)) > 0 :
self.navigateurasgardMenuDock = iface.mainWindow().findChildren(QWidget, self.mNavAsgardMenu)[0]
self.navigateurasgardMenuDockTreeView = self.navigateurasgardMenuDock.findChild(QTreeView)
self.navigateurasgardMenuDockTreeView.setObjectName(self.mNavAsgardMenu)
else :
self.navigateurasgardMenuDock = None
return
#---------------------------
def retrieveInfoLayerQgis(self, _layerBeforeClicked = None) :
#-
#Management Click before open IHM
if _layerBeforeClicked != None :
self.layer = _layerBeforeClicked #Management Click before open IHM
else :
if self.verrouLayer :
return
else :
self.layer = iface.activeLayer()
#-
if self.layer:
if self.layer.dataProvider().name() == 'postgres':
# == Gestion Context ==
with self.safe_pg_connection() :
#self.getAllFromUri()
self.messWindowTitle = "Plume | " + self.returnSchemaTableGeom(self.layer)[0] + "." + self.returnSchemaTableGeom(self.layer)[1] + " (" + self.returnSchemaTableGeom(self.layer)[2] + ")"
#--
bibli_plume.afficheNoConnections(self, "hide")
#-
self.comment = bibli_plume.returnObjetComment(self, self.schema, self.table)
self.metagraph = bibli_plume.returnObjetMetagraph(self, self.comment)
self.oldMetagraph = self.metagraph
self.saveMetaGraph = False
self.columns = bibli_plume.returnObjetColumns(self, self.schema, self.table)
self.data = bibli_plume.returnObjetData(self)
self.mode = "read"
self.loadLayer = self.ifLayerLoad(self.layer)
#-
self.displayToolBar(*self.listIconToolBar)
#-
if self.instalMetadata :
#-
tpl_labelDefaut = bibli_plume.returnObjetTpl_label(self, None)
if tpl_labelDefaut :
self.template = bibli_plume.generationTemplateAndTabs(self, tpl_labelDefaut)
else :
self.template = None
else :
tpl_labelDefaut = bibli_plume.returnObjetTpl_label(self, "LOCAL")
self.template = self.templates_collection[tpl_labelDefaut] if tpl_labelDefaut else None
#-
self.createQmenuModele(self._mObjetQMenu, self.templateLabels)
self.majQmenuModeleIconFlag(tpl_labelDefaut)
#
self.majButtonTemplate(self.plumeTemplate, "Aucun" if tpl_labelDefaut == None else tpl_labelDefaut, int(len("Aucun" if tpl_labelDefaut == None else tpl_labelDefaut)))
#-
self.layerQgisBrowserOther = "QGIS"
#-
self.generationALaVolee(bibli_plume.returnObjetsMeta(self))
#-
self.layerBeforeClicked = (self.layer, "qgis")
bibli_plume.saveinitializingDisplay("write", self.layerBeforeClicked)
else :
if not self.verrouLayer : bibli_plume.initIhmNoConnection(self)
return
#---------------------------
def retrieveInfoLayerBrowser(self, index):
#-
mNav = self.sender().objectName()
# DL
#issu code JD Lomenede
# copyright : (C) 2020 by JD Lomenede for # self.proxy_model = self.navigateurTreeView.model() = self.model = iface.browserModel() = item = self.model.dataItem(self.proxy_model.mapToSource(index)) #
if mNav == self.mNav1 :
self.proxy_model = self.navigateurTreeView.model()
elif mNav == self.mNav2 :
self.proxy_model = self.navigateurTreeView2.model()
elif mNav == self.mNavAsgardMenu and self.navigateurasgardMenuDock != None :
self.proxy_model = self.navigateurasgardMenuDockTreeView.model()
# DL
self.modelDefaut = iface.browserModel()
self.model = iface.browserModel()
item = self.model.dataItem(self.proxy_model.mapToSource(index))
#issu code JD Lomenede
if isinstance(item, QgsLayerItem) :
if self.ifVectorPostgres(item) :
if self.verrouLayer :
return
else :
self.layer = QgsVectorLayer(item.uri(), item.name(), 'postgres')
# == Gestion Context ==
with self.safe_pg_connection() :
#self.getAllFromUri()
self.messWindowTitle = "Plume | " + self.returnSchemaTableGeom(self.layer)[0] + "." + self.returnSchemaTableGeom(self.layer)[1] + " (" + self.returnSchemaTableGeom(self.layer)[2] + ")"
#--
bibli_plume.afficheNoConnections(self, "hide")
#-
self.comment = bibli_plume.returnObjetComment(self, self.schema, self.table)
self.metagraph = bibli_plume.returnObjetMetagraph(self, self.comment)
self.oldMetagraph = self.metagraph
self.saveMetaGraph = False
self.columns = bibli_plume.returnObjetColumns(self, self.schema, self.table)
self.data = bibli_plume.returnObjetData(self)
self.mode = "read"
self.loadLayer = self.ifLayerLoad(self.layer)
#-
self.displayToolBar(*self.listIconToolBar)
#-
if self.instalMetadata :
#-
tpl_labelDefaut = bibli_plume.returnObjetTpl_label(self, None)
if tpl_labelDefaut :
self.template = bibli_plume.generationTemplateAndTabs(self, tpl_labelDefaut)
else :
self.template = None
else :
tpl_labelDefaut = bibli_plume.returnObjetTpl_label(self, "LOCAL")
self.template = self.templates_collection[tpl_labelDefaut] if tpl_labelDefaut else None
#-
self.createQmenuModele(self._mObjetQMenu, self.templateLabels)
self.majQmenuModeleIconFlag(tpl_labelDefaut)
#
self.majButtonTemplate(self.plumeTemplate, "Aucun" if tpl_labelDefaut == None else tpl_labelDefaut, int(len("Aucun" if tpl_labelDefaut == None else tpl_labelDefaut)))
#-
self.layerQgisBrowserOther = "BROWSER"
#-
self.generationALaVolee(bibli_plume.returnObjetsMeta(self))
#-
self.layerBeforeClicked = (self.layer, "postgres")
bibli_plume.saveinitializingDisplay("write", self.layerBeforeClicked, index, mNav)
else :
if not self.verrouLayer : bibli_plume.initIhmNoConnection(self)
else :
if not self.verrouLayer : bibli_plume.initIhmNoConnection(self)
return
#---------------------------
def getAllFromUri(self):
# ex : Projet fermé
try :
if not getattr(self, 'layer', False) :
bibli_plume.breakExecuteSql(self)
return
except :
bibli_plume.breakExecuteSql(self)
return
uri = QgsDataSourceUri(self.layer.source())
self.schema, self.table, self.geom = uri.schema(), uri.table(), uri.geometryColumn()
#-
self.uri, self.mConfigConnection, self.username, self.password = uri, uri.connectionInfo(), uri.username() or "", uri.password() or ""
self.connectBaseOKorKO = self.connectBase()
#-
if self.connectBaseOKorKO[0] :
pass
else :
zTitre = QtWidgets.QApplication.translate("plume_ui", "PLUME : Warning", None)
zMess = QtWidgets.QApplication.translate("plume_ui", "Authentication problem", None)
bibli_plume.displayMess(self.Dialog, (2 if self.Dialog.displayMessage else 1), zTitre, zMess, Qgis.Warning, self.Dialog.durationBarInfo)
#===Existence de l'extension Postgis
self.postgis_exists = self.if_postgis_exists()
#===Existence de l'extension Postgis
return
#----------------------
def ifVectorPostgres(self, item) : return True if item.providerKey() == 'postgres' else False
#----------------------
def returnSchemaTableGeom(self, mLayer) :
try :
uri = QgsDataSourceUri(self.layer.source())
_schema, _table, _geom = uri.schema(), uri.table(), uri.geometryColumn()
except :
_schema, _table, _geom = "", "", ""
return (_schema, _table, _geom)
#----------------------
def ifLayerLoad(self, mLayer) :
mIfLayerLoad = False
for elemLayer in QgsProject.instance().mapLayers().values():
if mLayer.id() == elemLayer.id() :
mIfLayerLoad = True
break
return mIfLayerLoad
#----------------------
def connectBase(self) :
return self.mTestConnect(self.mConfigConnection, self.uri)
#----------------------
def mTestConnect(self, mConfigConnection, uri) :
retUser, retPassword, mTestConnect, okConnect = self.username, self.password, True, False
mMessAuth = QtWidgets.QApplication.translate("plume_ui", "Authentication problem, check your password in particular.", None)
connInfoUri = uri.connectionInfo()
while mTestConnect :
try :
mConnectEnCours = psycopg2.connect(uri.connectionInfo(), application_name="PLUME")
mTestConnect, okConnect = False, True
except :
(retSuccess, retUser, retPassword) = QgsCredentials.instance().get(connInfoUri, retUser, retPassword, mMessAuth)
if not retSuccess : #Annuler
mTestConnect, okConnect = False, False
else :
uri.setUsername(retUser) if retUser else ''
uri.setPassword(retPassword) if retPassword else ''
#--------
if okConnect :
QgsCredentials.instance().put(connInfoUri, retUser, retPassword)
self.mConnectEnCours = mConnectEnCours
return True, self.mConnectEnCours, mConfigConnection
else :
return False, None, ""
# == Gestion des INTERACTIONS
#---------------------------
#---------------------------
#==========================
def closeEvent(self, event):
try :
self.navigateurTreeView.clicked.disconnect(self.retrieveInfoLayerBrowser)
except:
pass
try :
self.navigateurTreeView2.clicked.disconnect(self.retrieveInfoLayerBrowser)
except:
pass
try :
iface.layerTreeView().clicked.disconnect(self.retrieveInfoLayerQgis)
except:
pass
#==========================
def resizeEvent(self, event):
if self.firstOpen :
self.firstOpen = False
#else :
bibli_plume.resizeIhm(self, self.Dialog.width(), self.Dialog.height())
#==========================
def clickParamDisplayMessage(self):
mDicAutre = {}
mSettings = QgsSettings()
mSettings.beginGroup("PLUME")
mSettings.beginGroup("Generale")
mDicAutre["displayMessage"] = "dialogBox"
for key, value in mDicAutre.items():
if not mSettings.contains(key) :
mSettings.setValue(key, value)
else :
mDicAutre[key] = 'dialogBox' if self.paramDisplayMessage.isChecked() else 'dialogTitle'
#--
for key, value in mDicAutre.items():
mSettings.setValue(key, value)
mSettings.endGroup()
mSettings.endGroup()
#--
self.displayMessage = self.paramDisplayMessage.isChecked() #Qmessage box (dialogBox) ou barre de progression (dialogTitle)
return
#==========================
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(self.messWindowTitle)
#==========================
def clickColorDialog(self):
d = docolorbloc.Dialog(self)
d.exec_()
return
#==========================
def clickImportCSW(self):
d = doimportcsw.Dialog(self)
d.exec_()
return
#==========================
def clickCreateTemplate(self):
with self.safe_pg_connection() :
d = docreatetemplate.Dialog(self)
d.exec_()
return
#==========================
def clickAbout(self):
d = doabout.Dialog()
d.exec_()
return
#==========================
def if_postgis_exists(self) :
mKeySql = queries.query_exists_extension('postgis')
r, zMessError_Code, zMessError_Erreur, zMessError_Diag = executeSql(self, self.mConnectEnCours, mKeySql, optionRetour = "fetchone")
return r
#==========================
# == Gestion des actions de boutons de la barre de menu
def displayToolBar(self, _iconSourcesRead, _iconSourcesEmpty, _iconSourcesExport, _iconSourcesImport, _iconSourcesSave, _iconSourcesCopy, _iconSourcesPaste, _iconSourcesTemplate, _iconSourcesTranslation, _iconSourcesParam, _iconSourcesInterrogation, _iconSourcesVerrou, _iconSourcesBlank):
#-- Désactivation
self.plumeEdit.setEnabled(False)
self.plumeSave.setEnabled(False)
self.plumeEmpty.setEnabled(False)
self.plumeExport.setEnabled(False)
self.plumeImport.setEnabled(False)
self.plumeCopy.setEnabled(False)
self.plumePaste.setEnabled(False)
self.plumeTemplate.setEnabled(False)
self.plumeTranslation.setEnabled(False)
self.plumeChoiceLang.setEnabled(False)
self.plumeVerrou.setEnabled(False)
self.plumeVerrou.setChecked(False)
#Permet d'afficher si ifActivateRightsToManageModels = True
self.mIfActivateRightsToManageModels = bibli_plume.ifActivateRightsToManageModels(self)
self.paramColor.setVisible(False if self.mIfActivateRightsToManageModels else True)
self.paramColorModele.setVisible(True if self.mIfActivateRightsToManageModels else False)
#====================
#====================
#--QToolButton TEMPLATE
if hasattr(self, 'mConnectEnCours') :
#Lecture existence Extension METADATA
mKeySql = queries.query_plume_pg_check()
r, zMessError_Code, zMessError_Erreur, zMessError_Diag = executeSql(self, self.mConnectEnCours, mKeySql, optionRetour = "fetchall")
result = r[0]
self.instalMetadata = False
#Information si not installe
if not result[0]:
if not result[3]:
pb = "L'extension PlumePg n'est pas disponible sur le serveur cible."
elif not result[2]:
pb = "L'extension PlumePg n'est pas installée sur la base cible."
elif result[5]:
pb = 'Votre rôle de connexion ne dispose pas du privilège ' \
'SELECT sur {} {}.'.format(
'la table' if len(result[5]) == 1 else 'les tables',
', '.join(result[5]))
elif result[4]:
pb = 'Votre rôle de connexion ne dispose pas du privilège ' \
'USAGE sur {} {}.'.format(
'le schéma' if len(result[4]) == 1 else 'les schémas',
', '.join(result[4]))
else:
pb = 'Votre version de Plume est incompatible avec PlumePg < {} ou ≥ {}' \
' (version base cible : PlumePg {}).'.format(result[1][0],
result[1][1], result[2])
if r[0][0] :
self.instalMetadata = True
self.plumeTemplate.setEnabled(True)
#MenuQToolButton