Projet

Général

Profil

Anomalie #56 » ui_catalogue.py

Christophe MASSE, 07/11/2014 10:10

 
1
# -*- coding:utf-8 -*-
2

    
3
import ConfigParser
4
import os.path
5
import doUI 
6
from qsphere_tools import *
7
from qsphere_objmaker import *
8
from importexport import *
9

    
10
from datetime import date
11
import datetime
12
from PyQt4 import QtCore, QtGui
13
from PyQt4 import QtCore, QtGui
14
from PyQt4.QtCore import * 
15
from PyQt4.QtGui import * 
16
from qgis.core import *
17
from qgis.gui import *
18

    
19
class Ui_Dialog_Metadata(object):
20
    def __init__(self, iface):
21
        self.iface = iface
22
    
23
    def setupUi(self, Dialog):
24
        Dialog.setObjectName("Dialog")
25
        Dialog.setAccessibleName("Dialog")
26
        MakeWindowIcon(self, "qsp.png")
27
        sizeW, sizeH = 1100, 660
28

    
29
        overrideLocale = QSettings().value("locale/overrideFlag", False)
30
        localeFullName = QLocale.system().name() if not overrideLocale else QSettings().value("locale/userLocale", "")
31
        self.Lang = "fr" if localeFullName[0:2]=="fr" else "en"
32
        self.TypeData = ("dataset", "whole dataset", "service")
33
        self.ListUnitsMesure = ["m", "km", "foot", "inch", "mile", "yard"]
34

    
35
        self.initDir = self.ToolTipLangue = ""
36
        self.ListOfConformities = LoadDefautValue(self, "file:/ressources/conformity_default.csv")
37
        self.ListOfRules, self.DicoListOfRules = LoadData(self, "file:/ressources/roles.csv", "roles")
38
        self.ListOfThesaurus , self.DateListOfThesaurus = LoadData(self, "file:/ressources/thesaurus.csv", "thesaurus")
39
        self.ListFormats = self.formats
40
        self.racWindowTitle = QtGui.QApplication.translate("QSphere","Information metadata : ", None, QtGui.QApplication.UnicodeUTF8)
41
        self.ListTypeDates = [QtGui.QApplication.translate("QSphere","Date of creation", None, QtGui.QApplication.UnicodeUTF8), \
42
                              QtGui.QApplication.translate("QSphere","Date of last revision", None, QtGui.QApplication.UnicodeUTF8), \
43
                              QtGui.QApplication.translate("QSphere","Date of publication", None, QtGui.QApplication.UnicodeUTF8),]
44
        self.ListDegres = [QtGui.QApplication.translate("QSphere","Conformant", None, QtGui.QApplication.UnicodeUTF8), \
45
                           QtGui.QApplication.translate("QSphere","Not conformant", None, QtGui.QApplication.UnicodeUTF8), \
46
                           QtGui.QApplication.translate("QSphere","Not evaluated", None, QtGui.QApplication.UnicodeUTF8)]
47
        
48
        Dialog.setMinimumSize(QtCore.QSize(sizeW-30, sizeH))
49
        Dialog.setMaximumSize(QtCore.QSize(sizeW-30, sizeH))
50
        Dialog.resize(QtCore.QSize(QtCore.QRect(0,0,sizeW-30,sizeH).size()).expandedTo(Dialog.minimumSizeHint()))
51
        Dialog.setWindowTitle(self.racWindowTitle) 
52
        
53
        self.tabWidget = QtGui.QTabWidget(Dialog)
54
        self.tabWidget.setObjectName("tabWidget")
55
        self.tabWidget.setGeometry(QtCore.QRect(280, 10, 780, 620)) 
56

    
57
        myPathIconvRightArrow = getThemeIcon("rightarrow.png")
58
        myPathIconvLeftArrow = getThemeIcon("leftarrow.png")
59
        self.tabWidget.setStyleSheet(
60
            """QTabBar::tab:selected {color: #5D5D5D;background-color: rgb(255,255,255);}"""
61
            """QTabBar::tab:!selected {color: rgb(255,255,255);background-color: #5D5D5D;border-bottom-color: #5D5D5D;}"""
62
            """QTabWidget:pane {margin: 1px,1px,1px,1px;background-color: rgb(255,255,255);}"""
63
            """QTabBar::tab {border: 0px solid rgb(0,149,48);border-bottom-color: rgb(255,255,255);border-top-left-radius: 0px;border-top-right-radius: 0px;height: 0px;width: 170px;background-color: rgb(255,255,255);}"""
64
            """QTabWidget{background-color: rgb(255,255,255);font: 75 10pt "Arial Rounded MT Bold";}"""
65
            """QTabWidget::tab-bar {left: 5px; bottom: -1px;background-color: rgb(0,0,0); } """
66
            """QTabBar::scroller {width: 0px;}"""
67
        )
68
        self.tabWidget.setTabPosition(QtGui.QTabWidget.South) 
69
        self.tabWidget.setTabShape(QtGui.QTabWidget.Rounded)
70
        self.tabWidget.setUsesScrollButtons(True)
71

    
72
        zTitle = (QtGui.QApplication.translate("QSphere","Identification", None, QtGui.QApplication.UnicodeUTF8), \
73
                   QtGui.QApplication.translate("QSphere","Classification & Keywords", None, QtGui.QApplication.UnicodeUTF8), \
74
                   QtGui.QApplication.translate("QSphere","Geographic", None, QtGui.QApplication.UnicodeUTF8), \
75
                   QtGui.QApplication.translate("QSphere","Temporal", None, QtGui.QApplication.UnicodeUTF8), \
76
                   QtGui.QApplication.translate("QSphere","Quality, Validity and Conformity", None, QtGui.QApplication.UnicodeUTF8), \
77
                   QtGui.QApplication.translate("QSphere","Constraints", None, QtGui.QApplication.UnicodeUTF8), \
78
                   QtGui.QApplication.translate("QSphere","Responsible party", None, QtGui.QApplication.UnicodeUTF8), \
79
                   QtGui.QApplication.translate("QSphere","Metadata", None, QtGui.QApplication.UnicodeUTF8), \
80
                   QtGui.QApplication.translate("QSphere","QGIS metadata", None, QtGui.QApplication.UnicodeUTF8),
81
                  )
82

    
83
        zIcons = ("identification.png", "classification.png", "location.png", "temporality.png", "quality.png", "rights_and_uses.png", "responsible.png", "metadata.png", "qgis.png")
84

    
85
        zToolTip = (QtGui.QApplication.translate("QSphere","Identification data (title, abstract,\ntype, encoding ...)", None, QtGui.QApplication.UnicodeUTF8), \
86
                   QtGui.QApplication.translate("QSphere","Classification & Keywords", None, QtGui.QApplication.UnicodeUTF8), \
87
                   QtGui.QApplication.translate("QSphere","Geographical location", None, QtGui.QApplication.UnicodeUTF8), \
88
                   QtGui.QApplication.translate("QSphere","Dates temporal referencing", None, QtGui.QApplication.UnicodeUTF8), \
89
                   QtGui.QApplication.translate("QSphere","Quality, Validity and Conformity", None, QtGui.QApplication.UnicodeUTF8), \
90
                   QtGui.QApplication.translate("QSphere","Access and uses", None, QtGui.QApplication.UnicodeUTF8), \
91
                   QtGui.QApplication.translate("QSphere","Responsible party", None, QtGui.QApplication.UnicodeUTF8), \
92
                   QtGui.QApplication.translate("QSphere","Metadata", None, QtGui.QApplication.UnicodeUTF8), \
93
                   QtGui.QApplication.translate("QSphere","Metadata by QGIS", None, QtGui.QApplication.UnicodeUTF8),
94
                  )
95

    
96
        SizeLabelW, SizeLabelH = 60, 25
97
        self.SizeWW, self.SizeWH = 200, 25
98
        self.EmpriseLat, self.EmpriseLong = 180, 360
99

    
100
        self.listWidget = QListWidget(Dialog)
101
        self.listWidget.setGeometry(QtCore.QRect(10, 10, 280, 620))
102
        self.listWidget.setObjectName("listWidget")
103
        self.listWidget.setStyleSheet("* { background-color:#5D5D5D; padding: 4px ; color:rgb(255,255,255)}"
104
                                      "QListWidget::item:selected {color: #5D5D5D;background-color: rgb(255,255,255);  padding: 12px;}")
105
        self.listWidget.setIconSize(QSize(42, 42))             
106

    
107
        self.listeOnglets = QComboBox(Dialog)
108
        self.listeOnglets.setToolTip(QtGui.QApplication.translate("QSphere","List of tabs", None, QtGui.QApplication.UnicodeUTF8)) 
109
        self.listeOnglets.setGeometry(QtCore.QRect(510, sizeH-30, 190, SizeLabelH))
110
        self.listeOnglets.setObjectName("listeOnglets")        
111
        
112
        zScroll = {}
113
        for i in range(1,len(zTitle)+1):
114
            zIcon = getThemeIcon(zIcons[i-1])
115
            zItem =  QListWidgetItem(QIcon(zIcon),zTitle[i-1],self.listWidget)
116
            zItem.setToolTip(zToolTip[i-1])
117

    
118
            zTab = QtGui.QWidget(Dialog)
119
            zTab.setObjectName("tab%s" % (i))
120
            zTab.setAccessibleName(zTitle[i-1])
121
            
122
            self.tabWidget.addTab(zTab, zTitle[i-1])
123
            self.tabWidget.setTabToolTip(i-1, zToolTip[i-1])
124
            self.listeOnglets.addItem(zTitle[i-1])
125
            makeTABWidgets(self, zTab, i, SizeLabelW, SizeLabelH, self.SizeWW, self.SizeWH)
126

    
127
        self.barInfo = QgsMessageBar(Dialog)
128
        self.barInfo.setSizePolicy( QSizePolicy.Minimum, QSizePolicy.Fixed )
129
        self.barInfo.setGeometry(QtCore.QRect(0, 0, sizeW-10, 50))
130

    
131

    
132
        self.langs_gui = QLabel(self)
133
        self.langs_gui.setGeometry(QtCore.QRect(11, 540, 278, 15))
134
        myDefPathIcon = getThemeIcon("langs_gui.png")
135
        carIcon = QtGui.QImage(myDefPathIcon) 
136
        self.langs_gui.setPixmap(QtGui.QPixmap.fromImage(carIcon))
137
        self.langs_gui.setToolTip(QtGui.QApplication.translate("QSphere","Langs for the GUI", None, QtGui.QApplication.UnicodeUTF8))
138
        
139

    
140
        self.progressBar = QProgressBar(self)
141
        self.progressBar.setProperty("value", 0)
142
        self.progressBar.setAlignment(QtCore.Qt.AlignCenter)
143
        self.progressBar.setTextVisible(True)
144
        self.progressBar.setObjectName("progressBar")
145
        self.progressBar.setStyleSheet(
146
             """QProgressBar {border: 2px solid grey; border-radius: 5px; text-align: center;}"""
147
             """QProgressBar::chunk {background-color: #6C96C6; width: 20px;}"""
148
        )
149
        self.progressBar.setVisible(False)
150
        self.progressBar.setGeometry(QtCore.QRect(20, 585, 260, 15))
151
        self.progressBar.setValue(0)
152

    
153
        self.LblComboLayers = QLabel(Dialog)
154
        self.LblComboLayers.setGeometry(QtCore.QRect(10, sizeH-25, 150, SizeLabelH))
155
        self.LblComboLayers.setAlignment(Qt.AlignRight)
156
        self.LblComboLayers.setObjectName("LblComboLayers")
157
        self.LblComboLayers.setText(QtGui.QApplication.translate("QSphere","Query a layer : ", None, QtGui.QApplication.UnicodeUTF8)) 
158

    
159
        self.ComboLayers = QtGui.QComboBox(Dialog)
160
        self.ComboLayers.setGeometry(QtCore.QRect(170, sizeH-30, 250, SizeLabelH))
161
        self.ComboLayers.setObjectName("ComboLayers")
162
        self.ComboLayers.setAccessibleName("ComboLayers")
163

    
164
        self.modelLayers = QtGui.QStandardItemModel()
165
        MakeListLayer(self, self.modelLayers, self.ComboLayers)
166
        self.GetMetaData()
167

    
168
        zIcon = getThemeIcon("new.png")
169
        zToolTip = QtGui.QApplication.translate("QSphere","New sheet", None, QtGui.QApplication.UnicodeUTF8)
170
        self.NewButton = MyPushButton(self) 
171
        self.NewButton.initPushButton(24, 24, 750, sizeH-30, "NewButton", "", zToolTip, True, zIcon, 24, 24, True)
172

    
173
        zIcon = getThemeIcon("open.png")
174
        zToolTip = QtGui.QApplication.translate("QSphere","Load Data ...", None, QtGui.QApplication.UnicodeUTF8)
175
        self.LoadButton = MyPushButton(self) 
176
        self.LoadButton.initPushButton(24, 24, 780, sizeH-30, "LoadButton", "", zToolTip, True, zIcon, 24, 24, True)
177

    
178
        zIcon = getThemeIcon("save.png")
179
        zToolTip = QtGui.QApplication.translate("QSphere","Save the current sheet QSphere", None, QtGui.QApplication.UnicodeUTF8)
180
        self.SaveButton = MyPushButton(self) 
181
        self.SaveButton.initPushButton(24, 24, 820, sizeH-30, "SaveButton", "", zToolTip, True, zIcon, 24, 24, True)
182

    
183
        zIcon = getThemeIcon("saveas.png")
184
        zToolTip = QtGui.QApplication.translate("QSphere","Save AS the current sheet QSphere", None, QtGui.QApplication.UnicodeUTF8)
185
        self.SaveAsButton = MyPushButton(self) 
186
        self.SaveAsButton.initPushButton(24, 24, 850, sizeH-30, "SaveAsButton", "", zToolTip, True, zIcon, 24, 24, True)
187

    
188
        zIcon = getThemeIcon("export.png")
189
        zToolTip = QtGui.QApplication.translate("QSphere","Export record QSphere in XML File", None, QtGui.QApplication.UnicodeUTF8)
190
        self.XMLButton = MyPushButton(self) 
191
        self.XMLButton.initPushButton(24, 24, 880, sizeH-30, "XMLButton", "", zToolTip, True, zIcon, 24, 24, True)
192

    
193
        zIcon = getThemeIcon("help.png")
194
        zToolTip = QtGui.QApplication.translate("QSphere","Call the help page", None, QtGui.QApplication.UnicodeUTF8)
195
        self.HelpButton = MyPushButton(self) 
196
        self.HelpButton.initPushButton(24, 24, 920, sizeH-30, "HelpButton", "", zToolTip, True, zIcon, 24, 24, True)
197

    
198
        self.CloseButton = MyButton(self)
199
        zText = QtGui.QApplication.translate("QSphere","Close", None, QtGui.QApplication.UnicodeUTF8)
200
        zToolTip = QtGui.QApplication.translate("QSphere","Close the dialog box", None, QtGui.QApplication.UnicodeUTF8)
201
        self.CloseButton.initButton(100, SizeLabelH, 960, sizeH-30, "CloseButton", zText, zToolTip , True, True) 
202

    
203
        self.leftB = QToolButton(Dialog)
204
        self.leftB.setToolTip(QtGui.QApplication.translate("QSphere","Previous tab", None, QtGui.QApplication.UnicodeUTF8)) 
205
        self.leftB.setGeometry(QtCore.QRect(480, sizeH-30, SizeLabelH, SizeLabelH))
206
        self.leftB.setStyleSheet( """QToolButton { qproperty-icon: url("""+myPathIconvLeftArrow+""");}"""
207
                                  """QToolButton:pressed { qproperty-icon: url("""+myPathIconvLeftArrow+""");}"""
208
                                  """QToolButton:hover { qproperty-icon: url("""+myPathIconvLeftArrow+""");}"""
209
                                 )
210
        self.leftB.setObjectName("leftB")
211

    
212
        self.rightB = QToolButton(Dialog)
213
        self.rightB.setToolTip(QtGui.QApplication.translate("QSphere","Next tab", None, QtGui.QApplication.UnicodeUTF8))
214
        self.rightB.setGeometry(QtCore.QRect(705, sizeH-30, SizeLabelH, SizeLabelH))
215
        self.rightB.setStyleSheet( """QToolButton { qproperty-icon: url("""+myPathIconvRightArrow+""");}"""
216
                                  """QToolButton:pressed { qproperty-icon: url("""+myPathIconvRightArrow+""");}"""
217
                                  """QToolButton:hover { qproperty-icon: url("""+myPathIconvRightArrow+""");}"""
218
                                 )
219
        self.rightB.setObjectName("rightB")
220
        
221
        QtCore.QObject.connect(self.NewButton,QtCore.SIGNAL("clicked()"),self.NewSheet)
222
        self.contextMnuLoadData()
223
        QtCore.QObject.connect(self.SaveAsButton,QtCore.SIGNAL("clicked()"),self.SaveAsDataQSP)
224
        QtCore.QObject.connect(self.SaveButton,QtCore.SIGNAL("clicked()"),self.SaveDataQSP)
225

    
226
        self.contextMnuSaveXML()
227
        
228
        QtCore.QObject.connect(self.HelpButton, QtCore.SIGNAL("clicked()"), self.GetHelpFile)
229
        QtCore.QObject.connect(self.CloseButton,QtCore.SIGNAL("clicked()"),self.close)
230
        QtCore.QObject.connect(self.rightB, SIGNAL("clicked()"), self.fixeTABPLUS)
231
        QtCore.QObject.connect(self.leftB, SIGNAL("clicked()"), self.fixeTABMOINS)
232
        QtCore.QObject.connect(self.ComboLayers,QtCore.SIGNAL("currentIndexChanged(QString)"), self.GetMetaData)
233
        QtCore.QObject.connect(self.listeOnglets,QtCore.SIGNAL("currentIndexChanged(QString)"),self.fixeTAB)
234
        QtCore.QObject.connect(self.tabWidget, QtCore.SIGNAL("currentChanged(int)"), self.fixeONGLET)
235
        QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL("currentRowChanged(int)"), self.fixeONGLETL)
236
        
237
        QtCore.QMetaObject.connectSlotsByName(Dialog)
238
        self.DessCadre()
239
        self.tabWidget.setCurrentIndex(0)
240
        self.listWidget.setCurrentRow(0)
241
        self.fixeONGLET()
242
        self.CountLangues()
243

    
244

    
245
    def LoadGeoLocalisator(self):
246
        zObj = zObj = getWidget(self, "tableemprises")
247
        if zObj.currentRow()==-1 : zObj.selectRow(0)
248
        zEmprise = []
249
        for j in range(zObj.columnCount()-1): zEmprise.append(zObj.cellWidget(zObj.currentRow(),j).value())
250
        zUrl = "file:geolocalisator.html"
251
        d = doUI.DialogViewer(self.iface, zUrl, False, zEmprise)
252
        d.exec_()
253
        
254
    def contextMnuLoadData(self):
255
        contextMnu_LoadData = QMenu()
256
        
257
        menuIcon = getThemeIcon("loadqsp.png")
258
        zText = QtGui.QApplication.translate("QSphere","Load a sheet QSphere ...", None, QtGui.QApplication.UnicodeUTF8)
259
        self.loadQSP = QAction(QIcon(menuIcon), zText, self)
260
        contextMnu_LoadData.addAction(self.loadQSP)
261
        QObject.connect(self.loadQSP,SIGNAL("triggered()"),self.loadDataQSP)
262

    
263
        contextMnu_LoadData.addSeparator()
264
        
265
        menuIcon = getThemeIcon("loadxml.png")
266
        zText = QtGui.QApplication.translate("QSphere","Import Data from XML ISO 19139 ...", None, QtGui.QApplication.UnicodeUTF8)
267
        self.loadXML = QAction(QIcon(menuIcon), zText, self)
268
        contextMnu_LoadData.addAction(self.loadXML)
269
        QObject.connect(self.loadXML,SIGNAL("triggered()"),self.LoadDataFromXML)
270
        
271
        contextMnu_LoadData.addSeparator()
272

    
273
        menuIcon = getThemeIcon("viewxml.png")
274
        zText = QtGui.QApplication.translate("QSphere","View metadata XML ISO 19139 ...", None, QtGui.QApplication.UnicodeUTF8)
275
        self.viewXML = QAction(QIcon(menuIcon), zText, self)
276
        contextMnu_LoadData.addAction(self.viewXML)
277
        QObject.connect(self.viewXML,SIGNAL("triggered()"),self.ViewDataFromXML)
278

    
279
        self.LoadButton.setMenu(contextMnu_LoadData)
280
        
281
    def contextMnuSaveXML(self):
282
        contextMnu_XML = QMenu()
283
        
284
        menuIcon = getThemeIcon("iso.png")
285
        zText = QtGui.QApplication.translate("QSphere","Export in XML ISO 19139 current sheet QSphere ...", None, QtGui.QApplication.UnicodeUTF8)
286
        self.exportISO = QAction(QIcon(menuIcon), zText, self)
287
        contextMnu_XML.addAction(self.exportISO)
288
        QObject.connect(self.exportISO,SIGNAL("triggered()"),self.saveXMLIso)
289

    
290
        contextMnu_XML.addSeparator()
291
        
292
        menuIcon = getThemeIcon("exportcat.png")
293
        zText = QtGui.QApplication.translate("QSphere","Export in XML Fields Map for current sheet QSphere ...", None, QtGui.QApplication.UnicodeUTF8)
294
        self.exportCat = QAction(QIcon(menuIcon), zText, self)
295
        contextMnu_XML.addAction(self.exportCat)
296
        QObject.connect(self.exportCat,SIGNAL("triggered()"),self.saveXMLCat)
297

    
298
        self.XMLButton.setMenu(contextMnu_XML)
299

    
300
    def fixeONGLETL(self):
301
        self.listeOnglets.setCurrentIndex(self.listWidget.currentRow())
302
        self.tabWidget.setCurrentIndex(self.listWidget.currentRow())
303
        
304
    def fixeONGLET(self):
305
        self.listeOnglets.setCurrentIndex(self.tabWidget.currentIndex())
306
        self.listWidget.setCurrentRow(self.tabWidget.currentIndex())
307

    
308
    def fixeTAB(self):
309
        self.tabWidget.setCurrentIndex(self.listeOnglets.currentIndex())
310
        self.listWidget.setCurrentRow(self.listeOnglets.currentIndex())
311

    
312
    def fixeTABPLUS(self):
313
        if self.tabWidget.currentIndex() < (self.tabWidget.count()-1) :
314
           self.tabWidget.setCurrentIndex(self.tabWidget.currentIndex()+1)
315
           self.listeOnglets.setCurrentIndex(self.tabWidget.currentIndex())
316

    
317
    def fixeTABMOINS(self):
318
        if self.tabWidget.currentIndex() > 0 :
319
           self.tabWidget.setCurrentIndex(self.tabWidget.currentIndex()-1)
320
           self.listeOnglets.setCurrentIndex(self.tabWidget.currentIndex())
321

    
322
    def GetHelpFile(self):
323
        zLang = "fr" if self.langueTR == "fr" else "en"
324
        zUrl = "file:helpIHM_"+ zLang +".html"
325
        d = doUI.DialogViewer(self.iface, zUrl, False, [])
326
        d.exec_()
327

    
328
    def GetMetaData(self):
329
        zCRS, zLATN, zLATS, zLONO, zLONE = "EPSG:4326", 51.9, 41.36, -5.79, 9.56
330
        zCoherence = "{'TopologyLevelCode':'unknow', 'GeometricObjectTypeCode':'unknow'}"
331
        zIndex = self.tabWidget.currentIndex()
332

    
333
        zObjDico = getWidget(self, "tabledico")
334
        zObjDico.clearContents()
335
        while zObjDico.rowCount()> 0 : zObjDico.removeRow(0)
336
        
337
        if self.ComboLayers.currentIndex() > 0 :
338
           zLayer = GetLayerCombo(self, self.modelLayers, self.ComboLayers, True)
339
           if not zLayer : return            
340

    
341
           zTypoTopology = {QGis.Point: "{'TopologyLevelCode':'geometryOnly', 'GeometricObjectTypeCode':'point'}", QGis.Line : "{'TopologyLevelCode':'topology1D', 'GeometricObjectTypeCode':'curve'}", QGis.Polygon : "{'TopologyLevelCode':'abstract', 'GeometricObjectTypeCode':'surface'}"}
342
           zkey = zLayer.geometryType() 
343
           if zTypoTopology.has_key(zkey): zCoherence = zTypoTopology[zkey]
344
           
345
           zExtent = zLayer.extent()
346
           zTransform = DefzTransform(zLayer, 4326)
347

    
348
           MyPoint = zTransform.transform(QgsPoint(zExtent.xMinimum(), zExtent.yMaximum()))
349
           zLONO, zLATN = MyPoint.x(), MyPoint.y()
350

    
351
           MyPoint = zTransform.transform(QgsPoint(zExtent.xMaximum(), zExtent.yMinimum()))                                          
352
           zLONE, zLATS = MyPoint.x(), MyPoint.y()
353

    
354
           if IsCorrectLayer(zLayer, True) and zObjDico :
355
               zProvider = zLayer.dataProvider()
356
               zFields = zProvider.fields()
357
               i = 0
358
               DicoModel = QStandardItemModel()
359
               for j in range(len(zFields)):
360
                   zItemId = QTableWidgetItem()
361
                   zItemName = QTableWidgetItem()
362
                   zItemTypeName = QTableWidgetItem()
363
                   zItemLength = QTableWidgetItem()
364
                   zItemPrecision = QTableWidgetItem()
365
                   zItemComment = QTableWidgetItem()
366
                                     
367
                   zObjDico.insertRow(i)
368
                   
369
                   zItemId.setText("%s" % (i))
370
                   zObjDico.setItem(i,0,zItemId)
371
                   zObjDico.item( i, 0 ).setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
372
                   
373
                   zItemName.setText("%s" % (zFields[j].name()))
374
                   zObjDico.setItem(i,1,zItemName)
375
                   zObjDico.item( i, 1 ).setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
376
                   
377
                   zItemTypeName.setText("%s" %(zFields[j].typeName()))
378
                   zObjDico.setItem(i,2,zItemTypeName)
379
                   zObjDico.item( i, 2 ).setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
380
                   
381
                   zItemLength.setText("%s" %(zFields[j].length()))
382
                   zObjDico.setItem(i,3,zItemLength)
383
                   zObjDico.item( i, 3 ).setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
384
                   
385
                   zItemPrecision.setText("%s" %(zFields[j].precision()))
386
                   zObjDico.setItem(i,4,zItemPrecision)
387
                   zObjDico.item( i, 4 ).setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
388
                   
389
                   zItemComment.setText("%s" %(zFields[j].comment()))
390
                   zObjDico.setItem(i,5,zItemComment)
391
                   zObjDico.item( i, 5 ).setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
392

    
393
                   i+= 1
394

    
395

    
396
           zObj = getWidget(self, "tableemprises")
397
           if zObj :
398
                zIndexEmp = GetIndex(zObj)
399
           
400
                zItem = zObj.cellWidget(zIndexEmp,2)
401
                if zItem == None : return
402
                zItem.setValue(zLONO)
403
                XposD = int(zItem.value())+180
404

    
405
                zItem = zObj.cellWidget(zIndexEmp,3)
406
                zItem.setValue(zLONE)
407
                XposF = int(zItem.value())+180
408
                   
409
                zItem = zObj.cellWidget(zIndexEmp,0)
410
                zItem.setValue(zLATN)
411
                YposD = 90-int(zItem.value())
412

    
413
                zItem = zObj.cellWidget(zIndexEmp,1)
414
                zItem.setValue(zLATS)
415
                YposF = 90-int(zItem.value())
416

    
417
           SetTextWidget(self, "namelayer", zLayer.name(), False)
418
           SetTextWidget(self, "typelayer", FixeLayerType(self, zLayer.type()), False)
419
           SetTextWidget(self, "metadata", zLayer.metadata(), False)
420
           SetTextWidget(self, "scr", zLayer.crs().authid(), False)
421
           SetTextWidget(self, "coherence", zCoherence, False)
422

    
423
        self.listeOnglets.setCurrentIndex(zIndex)
424
        return
425

    
426
    def AddLine(self):
427
        zObjectName = "%s" % (self.sender().accessibleName())
428
        zSplit = zObjectName.split("_")
429
        zType = int(zSplit[1])
430
        zCible = zSplit[2]
431
        zObj = getWidget(self, zCible)
432
        if zObj == None : return
433
        if zType == 6 : self.MakeLine(zObj, True, False)
434
        elif zType == 8:
435
            zObject = zObj.children()[2]
436
            zRow = zObject.rowCount()
437
            zObject.insertRow(zRow)
438
            AddLineWidget(self, zObject, zRow,  0, 4, 0, -1)
439
        if zType == 6 :
440
           self.countItems(zCible, zObj)
441
           zObj.selectRow(zObj.rowCount()-1)
442
        elif zType == 8:
443
           self.countItems(zCible, zObject)
444
           zObject.selectRow(zObj.rowCount()-1) 
445
        zObj.setFocus()
446
           
447
    def MakeLine(self, zObj, zDrawResult, zReinit):
448
        zRow = zObj.rowCount()
449
        if zObj.accessibleName() == "tablescr" :
450
           zObj.insertRow(zRow) 
451
           AddLineWidget(self, zObj, zRow,  0, 0, 3, "4258")
452
           AddLineWidget(self, zObj, zRow,  1, 1, -1, "")
453
        elif zObj.accessibleName() == "tableformats" :
454
           zObj.insertRow(zRow) 
455
           AddLineWidget(self, zObj, zRow,  0, 0, 6, "") 
456
           AddLineWidget(self, zObj, zRow,  1, 1, -1, "")
457
           AddLineWidget(self, zObj, zRow,  2, -1, 0, "") 
458
        elif zObj.accessibleName() == "tableroles" :
459
           zObj.insertRow(zRow)
460
           zValue = 2 if zReinit else 6
461
           if zRow > 1 : zValue = 1
462
           AddLineWidget(self, zObj, zRow,  0, 2, 0, zValue)
463
           AddLineWidget(self, zObj, zRow,  1, -1, 0, "")
464
           AddLineWidget(self, zObj, zRow,  2, -1, 0, "")
465
           AddLineWidget(self, zObj, zRow,  3, 2, 5, self.indexCountry)
466
           AddLineWidget(self, zObj, zRow,  4, 0, 2, "")
467
           AddLineWidget(self, zObj, zRow,  5, -1, 0, "")
468
           AddLineWidget(self, zObj, zRow,  6, 0, 0, "")
469
           if zReinit :
470
              zRow = zObj.rowCount()
471
              zObj.insertRow(zRow)
472
              AddLineWidget(self, zObj, zRow,  0, 2, 0, 6)
473
              AddLineWidget(self, zObj, zRow,  1, -1, 0, "")
474
              AddLineWidget(self, zObj, zRow,  2, -1, 0, "")
475
              AddLineWidget(self, zObj, zRow,  3, 2, 5, self.indexCountry)              
476
              AddLineWidget(self, zObj, zRow,  4, 0, 2, "")
477
              AddLineWidget(self, zObj, zRow,  5, -1, 0, "")
478
              AddLineWidget(self, zObj, zRow,  6, 0, 0, "")               
479
        elif zObj.accessibleName() == "tablelocalisator" :
480
           zObj.insertRow(zRow) 
481
           AddLineWidget(self, zObj, zRow,  0, 0, 4, "") 
482
           AddLineWidget(self, zObj, zRow,  1, -1, 0, "")
483
        elif zObj.accessibleName() == "tableemprises" :
484
           zObj.insertRow(zRow) 
485
           for i in range(4): AddLineWidget(self, zObj, zRow,  i, 3, 0, -1)
486
           AddLineWidget(self, zObj, zRow,  4, 5, 0, "")
487
           zObj.setToolTip("%s" % (zRow))
488
           if zDrawResult : self.DessCadre()
489
        elif zObj.accessibleName() == "tableetenduetemporelle":
490
           if not zReinit : 
491
               zObj.insertRow(zRow) 
492
               AddLineWidget(self, zObj, zRow,  0, 0, 1, "")
493
        elif zObj.accessibleName() == "tabledatepubdata":
494
           zObj.insertRow(zRow) 
495
           AddLineWidget(self, zObj, zRow,  0, 0, 5, "")
496
        elif zObj.accessibleName() == "tablemotsclefso" :
497
           if not zReinit :
498
               zObj.insertRow(zRow)
499
               AddLineWidget(self, zObj, zRow,  0, 2, 1, 0)
500
               AddLineWidget(self, zObj, zRow,  1, 2, -1, (0,0))
501
        elif zObj.accessibleName() == "tablemotsclefsf" :
502
           if not zReinit :
503
               zObj.insertRow(zRow)
504
               AddLineWidget(self, zObj, zRow,  0, -1, 0, "")
505
               AddLineWidget(self, zObj, zRow,  1, 6, 0, "")
506
               AddLineWidget(self, zObj, zRow,  2, -1, 0, "")
507
               AddLineWidget(self, zObj, zRow,  3, 0, 5, "")
508
               AddLineWidget(self, zObj, zRow,  4, 2, 2, 0)
509
        elif zObj.accessibleName() == "tablespecifications" :
510
           if not zReinit : 
511
               zObj.insertRow(zRow)
512
               AddLineWidget(self, zObj, zRow,  0, -1, 0, "")
513
               AddLineWidget(self, zObj, zRow,  1, 0, 5, "")
514
               AddLineWidget(self, zObj, zRow,  2, 2, 2, 0)
515
               AddLineWidget(self, zObj, zRow,  3, 2, 3, 0)
516
           if zReinit : 
517
              for i in range(len(self.ListOfConformities)):
518
                  zObj.insertRow(zRow)
519
                  AddLineWidget(self, zObj, zRow,  0, -1, 0, "")
520
                  AddLineWidget(self, zObj, zRow,  1, 0, 5, "")
521
                  AddLineWidget(self, zObj, zRow,  2, 2, 2, 0)
522
                  AddLineWidget(self, zObj, zRow,  3, 2, 3, 0)
523
                  for j in range(4):
524
                      zItemEditLine = zObj.cellWidget(zRow, j)
525
                      if zItemEditLine.metaObject().className() in ("QLineEdit", "MySimpleWidgetLineEdit", "MyWidgetLineEdit"): zItemEditLine.setText(self.ListOfConformities[i][j])
526
                      elif zItemEditLine.metaObject().className() == "QComboBox":
527
                          try : zItemEditLine.setCurrentIndex(int(self.ListOfConformities[i][j]))
528
                          except : zItemEditLine.setCurrentIndex(0)
529
        elif zObj.accessibleName() == "tableechelles" :
530
              zObj.insertRow(zRow) 
531
              AddLineWidget(self, zObj, 0,  0, 4, 0, -1)
532
        self.countItems(zObj.accessibleName(), zObj)              
533

    
534

    
535
    def DelLine(self):
536
        zObject = "%s" % (self.sender().accessibleName())
537
        self.DelLineProcess(zObject)
538

    
539
    def DelLineProcess(self, zObject):
540
        if zObject == "" : return
541
        zSplit = zObject.split("_")
542
        zType = int(zSplit[1])
543
        zCible = zSplit[2]
544
        zObj = getWidget(self, zCible)
545
        zTitle = "Information"
546

    
547
        if zObj == None : return
548
        
549
        if zType !=8 :      
550
            if zObj.rowCount()==0 :
551
               zMsg = QtGui.QApplication.translate("QSphere","Nothing to delete.", None, QtGui.QApplication.UnicodeUTF8)
552
               SendMessage(self, zTitle , zMsg, QgsMessageBar.WARNING, 5)
553
               return
554

    
555
        if zCible == "tableroles" :
556
           zMinRow, zMsg = 2, QtGui.QApplication.translate("QSphere","Two reference information must be defined !", None, QtGui.QApplication.UnicodeUTF8) 
557
        else :
558
           if zCible in("tablemotsclefso", "tablemotsclefsf", "tableetenduetemporelle", "tablespecifications", "tableformats") : zMinRow, zMsg = 0, QtGui.QApplication.translate("QSphere","Information must be set at least !", None, QtGui.QApplication.UnicodeUTF8)
559
           else : zMinRow, zMsg = 1, QtGui.QApplication.translate("QSphere","Information must be set at least !", None, QtGui.QApplication.UnicodeUTF8)
560
        
561
        if zType == 8: zObj = zObj.children()[2]
562
        if zObj.rowCount() > zMinRow :
563
            zObj.removeRow(zObj.rowCount()-1)
564
            if zCible == "tableemprises":
565
               zObj.setToolTip("%s" % (zObj.rowCount()-1))
566
               self.DessCadre()
567
        else:
568
            zMsg = QtGui.QApplication.translate("QSphere","Can not delete the last line.\n", None, QtGui.QApplication.UnicodeUTF8)+zMsg
569
            SendMessage(self, zTitle , zMsg, QgsMessageBar.WARNING, 5)
570
        self.countItems(zCible, zObj)
571
        zObj.selectRow(zObj.rowCount()-1)
572
        zObj.setFocus()
573

    
574
    def saveXMLCat(self):
575
        zObj = getWidget(self,"tabledico")
576
        zTitle = "Information"
577
        if zObj.rowCount()==0 :
578
            zMsg =  QtGui.QApplication.translate("QSphere","No information for fields map.", None, QtGui.QApplication.UnicodeUTF8)
579
            zObj.setFocus()
580
            SendMessage(self, zTitle , "%s" % (zMsg), QgsMessageBar.WARNING, 2)
581
            return
582
        InitDir = os.path.dirname(__file__) if self.initDir == "" else self.initDir 
583
        fileName = QFileDialog.getSaveFileName(None, QtGui.QApplication.translate("QSphere","Export Fields Map from QSphere record in XML", None, QtGui.QApplication.UnicodeUTF8),InitDir,"*.xml") 
584
        if fileName!="":
585
           ExportCatToXML(self, fileName)
586
           zMsg =  QtGui.QApplication.translate("QSphere","The Field Map was exported as :\n", None, QtGui.QApplication.UnicodeUTF8) 
587
           SendMessage(self, zTitle , "%s%s" % (zMsg, fileName), QgsMessageBar.INFO, 5)
588
           
589
    def saveXMLIso(self):
590
        InitDir = os.path.dirname(__file__) if self.initDir == "" else self.initDir 
591
        fileName = QFileDialog.getSaveFileName(None, QtGui.QApplication.translate("QSphere","Export QSphere record in XML iso 19139", None, QtGui.QApplication.UnicodeUTF8),InitDir,"*.xml") 
592
        if fileName!="": 
593
           ExportToXML(self, fileName)
594
           zTitle = "Information"
595
           zMsg =  QtGui.QApplication.translate("QSphere","The metadata record was exported as :\n", None, QtGui.QApplication.UnicodeUTF8)
596
           SendMessage(self, zTitle , "%s%s" % (zMsg, fileName), QgsMessageBar.INFO, 5)
597

    
598
           d = doUI.DialogViewer(self.iface, "filexml:%s" % (fileName), True, []) 
599
           d.exec_()
600

    
601
    def reinitDateMDD(self, zObj):
602
        zDate = "%s" % (datetime.datetime.now())
603
        zDate = zDate.split(" ")[0]
604
        zEltsDate = zDate.split("-")
605
        zObj.setSelectedDate(QDate(int(zEltsDate[0]), int(zEltsDate[1]), int(zEltsDate[2])))
606

    
607
    def NewSheet(self):
608
        self.setWindowTitle(self.racWindowTitle)
609
        zIndex = self.tabWidget.currentIndex()
610
        zTabs = self.tabWidget.count()
611
        zObj = None
612

    
613
        mylang = QtCore.QLocale.languageToString( self.langue )
614
        for key in self.languesDico.keys():
615
            if self.languesDico[key]['english'] == mylang :
616
               mycodelang = self.languesDico[key]['bibliographic']
617
               break
618
        
619
        for i in range(zTabs):
620
            self.tabWidget.setCurrentIndex(i)
621
            zTab = self.tabWidget.currentWidget()
622
            zObjs = zTab.children()
623
            for j in range(len(zObjs)):
624
                zObj = zObjs[j]
625
                zClassObjName = "%s" % (zObj.metaObject().className())
626

    
627
                if zClassObjName=="MyButton" : pass
628
                elif zClassObjName=="QCalendarWidget" : self.reinitDateMDD(zObj)
629

    
630
                elif zClassObjName=="QTextEdit" :
631
                    if zObj.isEnabled(): zObj.setPlainText("")
632
                    else :
633
                        if zObj.accessibleName()== "coherence" : zObj.setPlainText("{'TopologyLevelCode':'unknow', 'GeometricObjectTypeCode':'unknow'}")
634
                    if zObj.accessibleName() == "licence" : zObj.setPlainText("%s" % (QtGui.QApplication.translate("QSphere","Open Licence", None, QtGui.QApplication.UnicodeUTF8)))
635
                elif zClassObjName in ("QLineEdit", "MySimpleWidgetLineEdit", "MyWidgetLineEdit") :
636
                    zObj.setText("") if zObj.accessibleName() != "identificator" else zObj.setText("%s-%s-%s" % (self.langueTR.upper(), datetime.datetime.now().year, getRandowId(self)))
637
                elif zClassObjName=="QComboBox" :
638
                    iIndex = 0
639
                    zObj.clear()
640
                    if zObj.accessibleName() == "typedata" : zObj.insertItems(0, self.listTypeRessources)
641
                    elif zObj.accessibleName()== "sysreftemp" :
642
                       zObj.insertItems(0, self.listTemporalSystem)
643
                       iIndex = 1
644
                    elif zObj.accessibleName()== "tablecarac" :
645
                       zObj.insertItems(0, self.listCodecs)
646
                       iIndex = self.listCodecs.index("utf8")
647
                    elif zObj.accessibleName()== "langmetada" :
648
                       iIndex = MakeListLangues(self, zObj, mylang)
649
                    zObj.setCurrentIndex(iIndex)
650

    
651
                elif zClassObjName=="QGroupBox" :
652
                    zChildren = zObj.children()
653
                    zChildren[0].setChecked(True)
654
                    zTable = zChildren[2]
655
                    if zTable.metaObject().className() == "QTableWidget" :
656
                        zTable.clearContents()
657
                        for j in range(zTable.rowCount()): zTable.removeRow(0)
658
                        self.MakeLine(zTable, False, True)
659
                    elif zTable.metaObject().className() == "QTableView" :
660
                        zLang = "fr" if self.langueTR == "fr" else "en"
661
                        SizezSubObjH, zCols, iLine = LoadFile(self, zTable, zTable.accessibleName(), "file:280:contraintes_%s.csv:1:0" % (zLang), 3, self.tableModel)
662
                        
663
                    if len(zChildren) > 3 :    
664
                        zCombo = zChildren[3]
665
                        zCombo.setCurrentIndex(0)
666
    
667
                elif zClassObjName=="QTableView" :
668
                     if zObj.objectName() == "tablelangues" :
669
                            for i in range(len(self.langs)):
670
                                zItem = zObj.model().item(i, 0)
671
                                language = self.langs[i]
672
                   
673
                     for k in range(zObj.model().rowCount()):
674
                         zItem = zObj.model().item(k, 0)
675
                         zItem.setCheckState(Qt.Unchecked)
676
                         if zObj.objectName() == "tablelangues" and zItem.text().startswith(self.langueTR): zItem.setCheckState(Qt.Checked)
677

    
678
                elif zClassObjName=="QTableWidget" :
679
                    zObj.clearContents()
680
                    for j in range(zObj.rowCount()): zObj.removeRow(0)
681
                    self.MakeLine(zObj, False, True)
682
                    if zObj.objectName() == "tableemprises" : self.DessCadre()
683
                    
684
        self.CountLangues()
685
        self.listeOnglets.setCurrentIndex(zIndex)
686
        
687

    
688
    def SaveAsDataQSP(self):
689
        InitDir = os.path.dirname(__file__) if self.initDir == "" else self.initDir 
690
        fileName = QFileDialog.getSaveFileName(None, QtGui.QApplication.translate("QSphere","Save as a file QSPHERE", None, QtGui.QApplication.UnicodeUTF8),InitDir,"*.qsp")
691
        self.MakeSaveQSP(fileName, False)
692
           
693
    def SaveDataQSP(self):
694
        if self.windowTitle() != self.racWindowTitle :
695
            fileName = self.windowTitle().replace(self.racWindowTitle, "")
696
            self.MakeSaveQSP(fileName, True)
697
        else : self.SaveAsDataQSP()    
698

    
699
    def MakeSaveQSP(self, fileName, zSendMsg):
700
           if fileName=="":
701
               zTitle = "Error"
702
               zMsg =  QtGui.QApplication.translate("QSphere","No File destination to record the metadata !", None, QtGui.QApplication.UnicodeUTF8)
703
               UseCase = QgsMessageBar.WARNING
704
               if zSendMsg : SendMessage(self, zTitle , zMsg, UseCase, 5)
705
           else :    
706
               SaveQSP(self, fileName)
707
               zTitle = "Information"
708
               zMsg =  QtGui.QApplication.translate("QSphere","The metadata record was exported as :\n", None, QtGui.QApplication.UnicodeUTF8)
709
               UseCase = QgsMessageBar.INFO
710
               SendMessage(self, zTitle , "%s%s" % (zMsg, fileName), UseCase, 5)
711
           if fileName!="": self.initDir = os.path.dirname(fileName)    
712

    
713
    def ViewDataFromXML(self):
714
        InitDir = os.path.dirname(__file__) if self.initDir == "" else self.initDir
715
        fileName = QFileDialog.getOpenFileName(None, QtGui.QApplication.translate("QSphere","View a file XML ISO 19139", None, QtGui.QApplication.UnicodeUTF8),InitDir,"*.xml")
716
        if fileName!="" :
717
           d = doUI.DialogViewer(self.iface, "filexml:%s" % (fileName), True, []) 
718
           d.exec_()
719
         
720
    def LoadDataFromXML(self):
721
        zIndex = self.tabWidget.currentIndex()
722
        import xml.etree.ElementTree as ET
723
        InitDir = os.path.dirname(__file__) if self.initDir == "" else self.initDir
724
        fileName = QFileDialog.getOpenFileName(None, QtGui.QApplication.translate("QSphere","Load a file XML ISO 19139", None, QtGui.QApplication.UnicodeUTF8),InitDir,"*.xml")
725
        if fileName!="" :
726

    
727
            self.NewSheet()
728
            
729
            tree = ET.parse(fileName)
730
            root = tree.getroot()
731
            if root.tag != '{http://www.isotc211.org/2005/gmd}MD_Metadata':
732
               zMsg = QtGui.QApplication.translate("QSphere","XML document does not appear to be ISO (not gmd:MD_Metadata found) !", None, QtGui.QApplication.UnicodeUTF8)
733
               SendMessage(self, "information" , zMsg, QgsMessageBar.WARNING, 5) 
734
               return
735
            
736
            from xmlISOparser import *
737
            self.listImportCategories = []
738
            myISO = xmlISOparser(fileName, None, 'MEDDE', self.langueTR) 
739
            myISO.createISOdataStructure()
740
            
741
            zorderkeys = ("intitule", "resume", "typedata", "tablelocalisator", "identificator", "tablelangues", "tableformats", "tablecarac", \
742
                          "tablecategories", "tablemotsclefsf", "tablescr", "tableemprises", "tableetenduetemporelle", "groups:dates", \
743
                          "genealogie", "coherence", "grouperesolutionscale", "tablespecifications", "groupedroits", "licence", "tableroles:1", "tableroles:2", "tableroles:3", \
744
                          "datemetada", "langmetada")
745
            
746
            zWidgetValues = {"intitule": myISO.title , "resume" : myISO.abstract, "typedata": myISO.typedata, "tablelocalisator" : myISO.localisators, \
747
                             "identificator" : myISO.fileIdentifier, "tablelangues" : myISO.languesjdd, "tableformats" : myISO.formatsjdd, "tablecarac": myISO.tablecarac,  \
748
                             "tablecategories" : myISO.categories, "tablemotsclefsf" : myISO.keywordsF, \
749
                             "tablescr" : myISO.scr, "tableemprises" : myISO.boundingboxcoordinates, \
750
                             "tableetenduetemporelle" : myISO.timeperiodes, "groups:dates" : myISO.dates, \
751
                             "genealogie" : myISO.genealogie, "coherence" : myISO.coherence, "grouperesolutionscale" : myISO.scalesEC, \
752
                             "tablespecifications": myISO.conformities, "groupedroits" : myISO.accessconstraints, "licence" : myISO.legalconstraints, \
753
                             "tableroles:1" : myISO.pointsofcontactMDD, "tableroles:2" : myISO.pointsofcontact, "tableroles:3" : myISO.pointsofcontactCust, \
754
                             "datemetada" : (myISO.datemdd, myISO.datetmdd ), "langmetada" : myISO.languemdd
755
                             }
756

    
757
            self.tabWidget.setVisible(False)
758
            self.progressBar.setVisible(True)
759
            zBounds, i = len(zorderkeys), 0
760
            for i in range(zBounds):
761
                key = zorderkeys[i]
762
                self.UpdateWidget(key, zWidgetValues[key], myISO)
763
                self.progressBar.setValue(int(100 * i/zBounds))
764
                i+= 1
765
            self.initDir = os.path.dirname(fileName)
766

    
767
        self.CountLangues()        
768
        self.listeOnglets.setCurrentIndex(zIndex)
769
        self.progressBar.setValue(0)
770
        self.tabWidget.setVisible(True)
771
        self.progressBar.setVisible(False)
772

    
773
    def UpdateWidget(self, zkeyWidget, zIsoXML, myISO):
774
        if not (zIsoXML) : return
775
        
776
        if zkeyWidget.startswith("groups:"):
777
           zGroupTarget = zkeyWidget.split(":")[1]
778
           zGroups = {"dates": {"c" : "datecredata", "r" : "daterevdata", "p" : "tabledatepubdata"}}
779
           zGroup = zGroups[zGroupTarget]
780

    
781
           if zGroupTarget == "dates" :
782
               zObj = getWidget(self, "tabledatepubdata")
783
               self.cleanAllObj(zObj, True)
784
               i=0
785
               for elt in zIsoXML :
786
                   if type(elt) == dict :
787
                       #TOTO 2.6.1
788
                       if elt.has_key('type'): return
789
                       if elt['type'] == "" : return
790
                       #TOTO 2.6.1
791
                       zType = elt['type'][0:1]
792
                       zObj = getWidget(self, zGroup[zType])
793
                       if zType in ("c", "r") : 
794
                           zEltsDate = elt['date'].split("-")
795
                           zObj.setSelectedDate(QDate(int(zEltsDate[0]), int(zEltsDate[1]), int(zEltsDate[2]) ))
796
                       elif zType == "p" :
797
                            self.MakeLine(zObj, True, False)
798
                            zObj.cellWidget(i, 0).setText(elt['date'])
799
                            i+= 1
800
        elif zkeyWidget == "coherence" : self.UpdateCoherence(zkeyWidget, zIsoXML)                     
801
        elif zkeyWidget == "tablespecifications" : self.UpdateTableSpecifications(zkeyWidget, zIsoXML)                    
802
        elif zkeyWidget == "tablemotsclefsf" : self.UpdateTableKeywordsF(zkeyWidget, zIsoXML, myISO)
803
        elif zkeyWidget == "tableetenduetemporelle": self.UpdateEtenduesTemporelles(zkeyWidget, zIsoXML, myISO)
804
        elif zkeyWidget == "groupedroits": self.UpdateEtenduesRights(zkeyWidget, zIsoXML, myISO)
805
        elif zkeyWidget.find("tableroles:")!=-1 : self.UpdateTableRoles(zkeyWidget, zIsoXML)
806
        elif zkeyWidget == "grouperesolutionscale":
807
            if (myISO.scalesEC[0]==[]) and (myISO.scalesUM[0]==[]): return
808
            zObj = getWidget(self, zkeyWidget)
809
            zChildren = zObj.children()
810

    
811
            if (myISO.scalesUM[0]!=[]) :
812
                zChildren[1].setChecked(True)
813
                zInfos = myISO.scalesUM[0]
814
                try : zUnits = myISO.UnitsScalesUM[0][0]['uom']
815
                except : zUnits = "m" 
816
                zChildren[3].setEnabled(True)
817
                zIndex = self.ListUnitsMesure.index(zUnits) if zUnits in (self.ListUnitsMesure) else 0
818
                zChildren[3].setCurrentIndex(zIndex) 
819
            else :
820
                zChildren[0].setChecked(True)
821
                zInfos = myISO.scalesEC[0]
822
                zChildren[3].setEnabled(False)
823

    
824
            zChildren[2].clearContents()
825
            for j in range(zChildren[2].rowCount()): zChildren[2].removeRow(0)
826
            for j in range(len(zInfos)):
827
                zChildren[2].insertRow(j)
828
                zValue = float(zInfos[j]) if convertSTR(zInfos[j], "float") else 0.0
829
                AddLineWidget(self, zChildren[2], j,  0, 4, 0, zValue)
830
     
831
        else :
832
            zObj = getWidget(self, zkeyWidget)
833
            if zObj.metaObject().className() == "QLineEdit" :
834
                if (zIsoXML[0])!= []: zObj.setText(zIsoXML[0][0])
835
                
836
            elif zObj.metaObject().className() == "QCalendarWidget" :
837
                 zDate = ""
838
                 for elt in zIsoXML :
839
                     if elt[0]!=[] : zDate = elt[0][0]
840
                     
841
                 if zDate != "":
842
                     sep = ""    
843
                     if zDate.find("T")!=-1 : sep = "T" 
844
                     elif zDate.find(" ")!=-1 : sep = " "
845
                     if sep!="" : zDate = zDate.split(sep)[0] 
846
                     zEltsDate = zDate.split("-")
847
                     try : zObj.setSelectedDate(QDate(int(zEltsDate[0]), int(zEltsDate[1]), int(zEltsDate[2])))
848
                     except : self.reinitDateMDD(zObj)
849
             
850
            elif zObj.metaObject().className() == "QTextEdit" :
851
                if (zIsoXML[0])!= []: zObj.setPlainText(zIsoXML[0][0])
852
                
853
            elif zObj.metaObject().className() == "QTableView" :
854
                   if zObj.accessibleName() == "tablecategories": refcol, zIsoXML[0] = 1, [item.capitalize() for item in zIsoXML[0]]
855
                   elif zObj.accessibleName() == "tablelangues": refcol, zIsoXML[0] = 0, [item.lower() for item in zIsoXML[0]]
856
                   else : refcol = 0
857
                   for i in range(zObj.model().rowCount()):
858
                       if zObj.model().item(i, refcol).text() in zIsoXML[0]:
859
                          zObj.model().item(i, 0).setCheckState(Qt.Checked)
860
                          self.listImportCategories.append(zObj.model().item(i, refcol).text())
861
                       else : zObj.model().item(i, 0).setCheckState(Qt.Unchecked)
862
                       
863
            elif zObj.metaObject().className() == "QComboBox" :
864
                 #TOTO 2.6.1
865
                 try : zValue = zIsoXML[0][0]
866
                 except : zValue = zIsoXML[0]
867
                 if zValue == [] : return
868
                 #TOTO 2.6.1
869
                 if zObj.accessibleName() == "tablecarac" :
870
                     if zValue != None :
871
                         if zValue.find("MD_CharacterSetCode_")!=-1: zValue = zValue.replace("MD_CharacterSetCode_","")
872
                     else : zValue == "None"    
873
                     zIndex = self.listCodecs.index(zValue) if zValue in (self.listCodecs) else 0
874
                     zObj.setCurrentIndex(zIndex)
875
                 if zObj.accessibleName() == "typedata" :
876
                     zIndex = self.listTypeRessources.index(zValue) if zValue in (self.listTypeRessources) else 0
877
                     zObj.setCurrentIndex(zIndex)
878
                     
879
            elif zObj.metaObject().className() == "QTableWidget" :
880
                 self.cleanAllObj(zObj, True)
881
                 zRows = len(zIsoXML)
882
                 if zObj.accessibleName() == "tablescr" :zRows = len(zIsoXML[0])
883
                 for i in range(zRows):
884
                     if zObj.accessibleName() == "tableemprises":
885
                         if type(zIsoXML[i])==dict:
886
                             self.MakeLine(zObj, True, False)
887
                             zObj.cellWidget(i, 0).setValue(float(zIsoXML[i]['north']))
888
                             zObj.cellWidget(i, 1).setValue(float(zIsoXML[i]['south']))
889
                             zObj.cellWidget(i, 2).setValue(float(zIsoXML[i]['west']))
890
                             zObj.cellWidget(i, 3).setValue(float(zIsoXML[i]['east']))
891
                     elif  zObj.accessibleName() == "tableformats":
892
                         if type(zIsoXML[i])==dict:
893
                             self.MakeLine(zObj, True, False)
894
                             zObj.cellWidget(i, 0).setText("%s" % (zIsoXML[i]['name']))
895
                             zObj.cellWidget(i, 2).setText("%s" % (zIsoXML[i]['version']))
896
                         elif type(zIsoXML[i])== list :
897
                             self.UpdateTableFormats(zObj, zIsoXML[i])
898
                             return
899
                     elif zObj.accessibleName() == "tablelocalisator" :
900
                         if type(zIsoXML[i])== dict :
901
                             self.MakeLine(zObj, True, False)
902
                             zObj.cellWidget(i, 0).setText("%s" % (zIsoXML[i]['url']))
903
                             zObj.cellWidget(i, 1).setText("%s" % (zIsoXML[i]['name']))
904
                         else :
905
                             self.MakeLine(zObj, True, False)
906
                             try : zObj.cellWidget(i, 0).setText("%s" % (zIsoXML[0][i]))
907
                             except : pass
908
                     elif zObj.accessibleName() == "tablescr" :
909
                         self.MakeLine(zObj, True, False)
910
                         zObj.cellWidget(i, 0).setText("%s" % (zIsoXML[0][i]))
911

    
912
                 if zObj.accessibleName() == "tableemprises":
913
                    zObj.setToolTip("%s" % (zObj.rowCount()-1))
914
                    self.DessCadre()
915

    
916
    def UpdateTableFormats(self, zObj, zList):
917
        for k in range(len(zList)):
918
            self.MakeLine(zObj, True, False)
919
            zObj.cellWidget(k, 0).setText("%s" % (zList[k]))
920

    
921
    def UpdateCoherence(self, zkeyWidget, zIsoXML):
922
        zObj = getWidget(self, zkeyWidget)
923
        import ast
924
        try : mydict = ast.literal_eval("%s" % (zIsoXML))
925
        except : mydict = None
926
       
927
        if mydict!= None :
928
           if type(mydict)== dict :
929
               if mydict.has_key('TopologyLevelCode') and mydict.has_key('GeometricObjectTypeCode'): zObj.setPlainText("{'TopologyLevelCode':'%s', 'GeometricObjectTypeCode':'%s'}" % (mydict['TopologyLevelCode'],mydict['GeometricObjectTypeCode']))
930
               else : zObj.setPlainText("{'TopologyLevelCode':'unknow', 'GeometricObjectTypeCode':'unknow'}")
931
           elif type(mydict)== list :
932
               if len(mydict)== 2 and type(mydict[0])==list and type(mydict[1])==list:
933
                  try : zTopologyLevelCode = mydict[0][0]
934
                  except : zTopologyLevelCode = 'unknow'
935
                  try : zGeometricObjectTypeCode = mydict[1][0]
936
                  except: zGeometricObjectTypeCode = 'unknow'
937
                  zObj.setPlainText("{'TopologyLevelCode':'%s', 'GeometricObjectTypeCode':'%s'}" % (zTopologyLevelCode, zGeometricObjectTypeCode)) 
938
               else : zObj.setPlainText("{'TopologyLevelCode':'unknow', 'GeometricObjectTypeCode':'unknow'}")
939
        else : zObj.setPlainText("{'TopologyLevelCode':'unknow', 'GeometricObjectTypeCode':'unknow'}")
940
        
941

    
942
    def UpdateEtenduesRights(self, zkeyWidget, zIsoXML, myISO):
943
        if type(zIsoXML[0])==list:
944
            if zIsoXML[0]==[]: return
945
            if zIsoXML[0][0] == "otherRestrictions" : #or != ""
946
                counter=0
947
                zObj = getWidget(self, zkeyWidget)
948
                zConstraints = myISO.otherconstraints[0]
949
                zChild = zObj.children()[2]
950
                zModel = zChild.model()
951
                for j in range(len(zConstraints)):
952
                    zCond, zIndex = self.isContraintsIn(zConstraints[j], zModel)
953
                    if zCond :
954
                       zChild.model().item(zIndex, 0).setCheckState(Qt.Checked)
955
                       counter+= 1
956
                if counter > 0 : zObj.children()[1].setChecked(True)
957

    
958
    def isContraintsIn(self, zContraintText, zModel):
959
        zCond, zIndex = False, -1
960
        #First, check the model ...
961
        for i in range(zModel.rowCount()):
962
            if zContraintText.find(zModel.item(i, 0).text())!=-1 or  zContraintText.find(zModel.item(i, 1).text())!=-1  : return True, i
963
        #Second test, on list INSPIRE
964
        listContraints = ("(a) the confidentiality of the proceedings of public authorities, where such confidentiality is provided for by law.", \
965
                          "(b) international relations, public security or national defence.", \
966
                          "(c) the course of justice, the ability of any person to receive a fair trial or the ability of a public authority to conduct an enquiry of a criminal or disciplinary nature", \
967
                          "(d) the confidentiality of commercial or industrial information, where such confidentiality is provided for by national or Community law to protect a legitimate economic interest, including  the  public  interest  in  maintaining  statistical confidentiality and tax secrecy.", \
968
                          "(e) intellectual property rights", \
969
                          "(f) the confidentiality of personal data and/or files relating to a natural person where that person has not consented to the disclosure of  the information to the public, where such confidentiality is provided for by national or Community law.", \
970
                          "(g) the interests or protection of any person who supplied the information requested on a voluntary basis without being under, or capable of being put under, a legal obligation to do so, unless that person has consented to the release of the information concerned.", \
971
                          "(h) the protection of the environment to which such information relates, such as the location of rare species.")
972
        for i in range(len(listContraints)):
973
            if listContraints[i].find(zContraintText)!=-1 or zContraintText.find(listContraints[i])!=-1 : return True, i
974
        return zCond, zIndex
975

    
976

    
977
    def UpdateTableSpecifications(self, zkeyWidget, zIsoXML):
978
        zDim = len(zIsoXML)
979
        zObj = getWidget(self, zkeyWidget)
980
        if not zObj : return
981
        self.cleanAllObj(zObj, True)
982
        for i in range(zDim):
983
            if zIsoXML[i]==[]:pass
984
            else :
985
                if type(zIsoXML[i])==dict:
986
                    self.MakeLine(zObj, True, False)
987
                    zObj.cellWidget(i, 0).setText(zIsoXML[i]['text'])
988
                    zObj.cellWidget(i, 1).setText(zIsoXML[i]['date'])
989
                    zIndex = ("creation","revision","publication").index(zIsoXML[i]['typedate'].lower())
990
                    if zIndex == -1 : zIndex = 0
991
                    zObj.cellWidget(i, 2).setCurrentIndex(zIndex)
992

    
993
                    if type(zIsoXML[i]['conformity'])== str :
994
                       zIndex = 0 if zIsoXML[i]['conformity'].lower() == 'true' else 1 
995
                    else : zIndex = 2                
996
                    zObj.cellWidget(i, 3).setCurrentIndex(zIndex)
997
        
998

    
999
    def UpdateEtenduesTemporelles(self, zkeyWidget, zIsoXML, myISO):
1000
        zObj = getWidget(self, zkeyWidget)
1001
        if not zObj : return
1002
        self.cleanAllObj(zObj, True)
1003
        if type(zIsoXML[0])== dict :
1004
           zDim = len(zIsoXML) 
1005
           for i in range(zDim):
1006
               self.MakeLine(zObj, True, False)
1007
               zLine = zObj.rowCount()-1
1008
               zObj.cellWidget(zLine, 0).setText("%s %s" % (zIsoXML[i]['start'], zIsoXML[i]['end']))
1009
        else :
1010
           if len(zIsoXML[0])>0: 
1011
              for i in range(0, len(zIsoXML[0]), 2):
1012
                   self.MakeLine(zObj, True, False)
1013
                   zLine = zObj.rowCount()-1
1014
                   zObj.cellWidget(zLine, 0).setText("%s %s" % (zIsoXML[0][i], zIsoXML[0][i+1]))
1015

    
1016

    
1017
    def UpdateTableKeywordsF(self, zkeyWidget, zIsoXML, myISO):
1018
        zDim = len(zIsoXML)
1019
        zObj = getWidget(self, zkeyWidget)
1020
        if not zObj : return
1021
        
1022
        if zIsoXML == 'None' :
1023
           zIsoXML = myISO.keywordsFNC
1024
           zDim = len(zIsoXML[0])
1025

    
1026
           for i in range(zDim):
1027
               if type(zIsoXML[0]) == list:
1028
                 if zIsoXML[0][i]!="" and zIsoXML[0][i].capitalize() not in (self.listImportCategories) :
1029
                    self.MakeLine(zObj, True, False)
1030
                    zLine = zObj.rowCount()-1
1031

    
1032
                    zObj.cellWidget(zLine, 0).setText("%s" % (zIsoXML[0][i]))
1033
                    zObj.cellWidget(zLine, 1).setChecked(False)
1034
                    
1035
                    for k in range(2,5):
1036
                        zItemEditLine = zObj.cellWidget(zLine, k)
1037
                        try : zItemEditLine.setEnabled(False)
1038
                        except : pass
1039

    
1040
        else :
1041
            zkeys = {'keyword':0,'thesaurus':2,'date':3,'typedate':4}
1042
            for i in range(zDim):
1043
                if type(zIsoXML[i])== dict :
1044
                   if zIsoXML[i]['keyword'].capitalize() not in (self.listImportCategories): 
1045
                       self.MakeLine(zObj, True, False)
1046
                       zLine = zObj.rowCount()-1
1047

    
1048
                       for key in zIsoXML[i] :
1049
                           ikey = zkeys[key]
1050
                           if zObj.cellWidget(zLine, ikey).metaObject().className() == "QComboBox" :
1051
                              zIndex = ("creation","revision","publication").index(zIsoXML[i][key])
1052
                              if zIndex == -1 : zIndex = 0
1053
                              zObj.cellWidget(zLine, ikey).setCurrentIndex(zIndex)
1054
                           else : zObj.cellWidget(zLine, ikey).setText("%s" % (zIsoXML[i][key]))
1055
                      
1056
              
1057

    
1058
    def UpdateTableRoles(self, zkeyWidget, zIsoXML):
1059
         zDim = len(zIsoXML)
1060
         zkeyWidget = zkeyWidget.split(":")[0]
1061
         zObj = getWidget(self, zkeyWidget)
1062
         if not zObj : return
1063

    
1064
         zkeys = {'ville': 5, 'name': 1, 'pays': 3, 'adresse': 2, 'codepostal': 4, 'mail': 6, 'role': 0}
1065
         zinvkeys = {0: 'role', 1: 'name', 2: 'adresse', 3: 'pays', 4 : 'codepostal', 5: 'ville', 6: 'mail'}
1066
         
1067
         for i in range(zDim):
1068
             if type(zIsoXML[i])== dict :
1069
                 if zIsoXML[i]['role'] == None : break
1070
                 if zIsoXML[i]['role'].lower() == "owner" : zLine = 0
1071
                 elif  zIsoXML[i]['role'].lower() == "pointofcontact" : zLine = 1
1072
                 else : 
1073
                      self.MakeLine(zObj, True, False)
1074
                      zLine = zObj.rowCount()-1
1075
                 for key in zIsoXML[i] :
1076
                     ikey = zkeys[key]
1077
                     if zObj.cellWidget(zLine, ikey).metaObject().className() == "QComboBox" :
1078
                         if key == "role":
1079
                             zIndexes = [keyitem for keyitem, value in self.DicoListOfRules.items() if value == zIsoXML[i][key]] 
1080
                             if zIndexes!=[] : zIndex = zIndexes[0]  
1081
                         else : zIndex = zObj.cellWidget(zLine, ikey).findText(zIsoXML[i][key].capitalize())
1082
                         if zIndex == -1 : zIndex = 0
1083
                         zObj.cellWidget(zLine, ikey).setCurrentIndex(zIndex) 
1084
                     else : zObj.cellWidget(zLine, ikey).setText("%s" % (zIsoXML[i][key]))
1085
                     ikey+= 1
1086
                     
1087
             elif type(zIsoXML[i])== list :
1088
                 if zIsoXML[0] == [] : break
1089
                 if zIsoXML[0][0] == None: break
1090
                 if zIsoXML[0][0].lower()=="owner": zLine = 0
1091
                 elif  zIsoXML[0][0].lower() == "pointofcontact" : zLine = 1
1092
                 else : 
1093
                      self.MakeLine(zObj, True, False)
1094
                      zLine = zObj.rowCount()-1
1095
                 for j in range(zDim):
1096
                     if zIsoXML[j]!=[] :
1097
                         if zObj.cellWidget(zLine, j).metaObject().className() == "QComboBox" :
1098
                                 zIndex = 0
1099
                                 if zinvkeys[j] == "role":
1100
                                     zIndexes = [keyitem for keyitem, value in self.DicoListOfRules.items() if value == zIsoXML[j][0]] 
1101
                                     if zIndexes!=[] : zIndex = zIndexes[0]  
1102
                                 else : zIndex = zObj.cellWidget(zLine, j).findText(zIsoXML[j][0].capitalize())
1103
                                 if zIndex == -1 : zIndex = 0
1104
                                 zObj.cellWidget(zLine, j).setCurrentIndex(zIndex)
1105
                         else : zObj.cellWidget(zLine, j).setText("%s" % (zIsoXML[j][0]))
1106
                 break
1107
            
1108
    def loadDataQSP(self):
1109
        InitDir = os.path.dirname(__file__) if self.initDir == "" else self.initDir
1110
        fileName = QFileDialog.getOpenFileName(None, QtGui.QApplication.translate("QSphere","Load a file QSPHERE", None, QtGui.QApplication.UnicodeUTF8),InitDir,"*.qsp") 
1111
        if fileName!="" :
1112
           zIndex = self.tabWidget.currentIndex()
1113
           self.NewSheet()
1114
           LoadQSP(self, fileName)
1115
           self.initDir = os.path.dirname(fileName)
1116
           self.CountLangues()
1117
           self.listeOnglets.setCurrentIndex(zIndex)
1118
           
1119

    
1120
    def ChangeOptionScale(self):
1121
        zIndex = self.tabWidget.currentIndex()
1122
        self.sender().parent().children()[3].setEnabled(self.sender().parent().children()[1].isChecked())
1123
        if self.sender().parent().children()[0].isChecked():
1124
           ztoolTip = "%s" % (self.sender().parent().children()[0].toolTip())
1125
           cible = 1 
1126
        else :
1127
           ztoolTip = "%s" % (self.sender().parent().children()[1].toolTip()),
1128
           cible = 0 
1129
        valuesObj = None
1130
        if ztoolTip.find("|")!=-1: valuesObj = ztoolTip.split("|")
1131
        else:
1132
            if is_number_float(ztoolTip): valObj = float(ztoolTip)
1133
            else : valObj = 0.0
1134
        
1135
        zObject = self.sender().parent().children()[2] 
1136
        zRow = zObject.rowCount()
1137
        valuesObjsave = ""
1138
        for i in range(zRow):
1139
            Obj = zObject.cellWidget(i, 0)
1140
            #TOTO 2.6.1
1141
            #valuesObjsave+= str(Obj.value()) if valuesObjsave == "" else "|" + str(Obj.value())
1142
            zSepa = "" if valuesObjsave == "" else "|"
1143
            valuesObjsave+= "%s%s" % (zSepa, Obj.value())
1144
            
1145
            if self.sender().parent().children()[0].isChecked(): PropertiesDoubleSpinBox(self, Obj, 0, 0, 10000000, 1000)
1146
            else: PropertiesDoubleSpinBox(self, Obj, 4, 0, 1000, 10)
1147
            
1148
            if valuesObj == None : Obj.setValue(valObj)
1149
            else :
1150
                if i <= (len(valuesObj)-1): Obj.setValue(float(valuesObj[i]))
1151
                else : Obj.setValue(float(valuesObj[len(valuesObj)-1]))
1152

    
1153
        if valuesObjsave!= "" : self.sender().parent().children()[cible].setToolTip("%s" % (valuesObjsave))
1154
        self.listeOnglets.setCurrentIndex(zIndex)
1155
            
1156
    def ChangeOptionRights(self): self.sender().parent().children()[2].setEnabled(self.sender().parent().children()[1].isChecked())
1157

    
1158
    def ChangeButtonIcon(self, zButton, zIcon, zSizeWIcon, zSizeHIcon):
1159
        zIcon = getThemeIcon(zIcon)
1160
        zButton.setIcon(QIcon(zIcon))
1161
        zButton.setIconSize(QSize(zSizeWIcon, zSizeHIcon))
1162

    
1163
    def goToLocalisator(self):
1164
        zObj = getWidget(self, "tablelocalisator")
1165
        if zObj.currentRow()==-1: zObj.selectRow(0)
1166
        zWidget = zObj.cellWidget(zObj.currentRow(),0)
1167
        if zWidget.styleSheet()== "background-color:#AEEE00;" :
1168
           zUrl = zWidget.text()
1169
           d = doUI.DialogViewer(self.iface, zUrl, False, [])
1170
           d.exec_()
1171
        else :
1172
           zTitle = QtGui.QApplication.translate("QSphere", "Warning" , None, QtGui.QApplication.UnicodeUTF8) 
1173
           zMsg = QtGui.QApplication.translate("QSphere"," The URL you entered is incomplete or invalid! Please correct the line : ", None, QtGui.QApplication.UnicodeUTF8)
1174
           try : SendMessage(self, zTitle, "%s%s" % (zMsg, zObj.currentRow()), QgsMessageBar.WARNING, 2)
1175
           except : pass
1176

    
1177
    def AfficheHelp(self):
1178
        zChange = False
1179
        self.ChangeButtonIcon(self.sender(),"infoactivate.png", 24, 24)   
1180
        zUrl = "%s" % (self.sender().accessibleDescription())
1181
        d = doUI.DialogViewer(self.iface, zUrl, False, [])
1182
        d.exec_()
1183
        self.ChangeButtonIcon(self.sender(),"info.png", 24, 24)
1184

    
1185
    def AfficheRessources(self):
1186
        zUrl = "%s" % (self.sender().toolTip()) 
1187
        d = doUI.DialogViewer(self.iface, zUrl, False, [])
1188
        d.exec_()
1189

    
1190
    def CallSelectorConformityInfos(self):
1191
        zObj = getWidget(self, "coherence")
1192
        dialog = TopologyDialog(zObj.toPlainText())
1193
        MakeWindowIcon(dialog, "qsp.png")
1194
        if dialog.exec_(): zObj.setPlainText("%s" % (dialog.infosTopology()))
1195
        
1196
    def CallQgsProjectionSelector(self):
1197
         zObj = getWidget(self, "tablescr")
1198
         zIndex = int(self.sender().accessibleName().split("_")[2])
1199
         zItemEditLine = zObj.cellWidget(zIndex,0)
1200
         dialog = SRSDialog()
1201
         MakeWindowIcon(dialog, "qsp.png")
1202
         dialog.setWindowTitle(QtGui.QApplication.translate("QSphere","Coordinate Reference System Selector", None, QtGui.QApplication.UnicodeUTF8))
1203
         if dialog.exec_(): zItemEditLine.setText("%s" % (dialog.epsg()))
1204
         
1205
    def CallFormatSelector(self):
1206
        zObj = getWidget(self, "tableformats")
1207
        zIndex = int(self.sender().accessibleName().split("_")[2])
1208
        zItemEditLine = zObj.cellWidget(zIndex,0)
1209
        dialog = FormatDialog(self.ListFormats)
1210
        MakeWindowIcon(dialog, "qsp.png")
1211
        if dialog.exec_(): zItemEditLine.setText("%s" % (dialog.format()))
1212

    
1213
    def CheckInfosRoles(self):
1214
        zObj = self.sender()
1215
        zObjParent = getWidget(self, "tableroles")
1216
        if zObj.currentIndex() in (2,6) and zObjParent.rowCount()>2 :
1217
           zTitle = QtGui.QApplication.translate("QSphere", "Warning" , None, QtGui.QApplication.UnicodeUTF8) 
1218
           zMsg = QtGui.QApplication.translate("QSphere"," One owner or PointOfContact ! Please ...", None, QtGui.QApplication.UnicodeUTF8)
1219
           try : SendMessage(self, zTitle, zMsg, QgsMessageBar.WARNING, 2)
1220
           except : pass
1221
           zObj.setCurrentIndex(1)
1222

    
1223
    def ChangePatternZipPostalCode(self):
1224
        if self.sender().accessibleName() == "" : return
1225
        zNameObjRac = self.sender().accessibleName().split("_")[0]
1226
        zRowCombo = int(self.sender().accessibleName().split("_")[2])
1227
        zObj = getWidget(self, zNameObjRac)
1228
        if zObj != None :
1229
            zObjWidget = zObj.cellWidget(zRowCombo, 4)
1230
            if zObjWidget==None: return
1231
            zKeyTarget = self.sender().currentText()
1232
            if self.listCountriesCode.has_key(zKeyTarget):
1233
                zObjWidget.setInputMask("")
1234
                zObjWidget.setInputMask(self.listCountriesCode[zKeyTarget][1])
1235
                zObjWidget.regex = QRegExp(r"%s" % (self.listCountriesCode[zKeyTarget][0]), Qt.CaseSensitive)
1236
            else :
1237
                zObjWidget.setInputMask("")
1238
                zObjWidget.setInputMask("XXXxxxxxxx;X")
1239
                zObjWidget.regex = QRegExp(r"(^+[a-zA-Z_0-9\s]{3,10}$)", Qt.CaseSensitive)                
1240

    
1241

    
1242
    def LoadListOfValues(self):
1243
        if self.sender().accessibleName() == "" : return
1244
        zNameObjRac = self.sender().accessibleName().split("_")[0]
1245
        zRowCombo = int(self.sender().accessibleName().split("_")[2])
1246
        zIndexThesaurus = self.sender().currentIndex()
1247
        zObj = getWidget(self, zNameObjRac)
1248
        if zObj != None :
1249
            zObjWidget = zObj.cellWidget(zRowCombo, 1)
1250
            if zObjWidget :
1251
               zObjWidget.clear()
1252
               SizeW, zCols, iLine = LoadFile(self, zObjWidget, "", "file:200:thesaurus_%s" % (zIndexThesaurus)+".csv:0:0", 1, None)
1253

    
1254
    def FixeToolTipCalendar(self):
1255
        zObjCalendar = getWidget(self, "%s" % (self.sender().accessibleName()))
1256
        zToolTip = MakeToolTipCalendar(self, zObjCalendar)
1257

    
1258
    def ChangeAccessibility(self, checked):
1259
        if self.sender()==None or self.sender().objectName()=="": return
1260
        else:
1261
           zNameObj = "%s" % (self.sender().accessibleName())
1262
           zObj = getWidget(self, "tablemotsclefsf")
1263
           if zNameObj.find("tablemotsclefsf_action_")!=-1: zIndexLine = int(zNameObj.split("_")[2])
1264
           else: zIndexLine = GetIndex(zObj)
1265

    
1266
           for i in range(2,5):
1267
               zItemEditLine = zObj.cellWidget(zIndexLine, i)
1268
               try : zItemEditLine.setEnabled(checked)
1269
               except : pass
1270

    
1271

    
1272
    def SelectKeyWord(self, item):
1273
        zObj = getWidget(self, "tablecategories")
1274
        zItem = zObj.model().item(item.row(), 1)
1275
        zObjTarget = getWidget(self, "tablemotsclefso")
1276

    
1277
        if item.checkState() == Qt.Checked : 
1278
            self.MakeLine(zObjTarget, True, False)
1279
            zItemTarget = zObjTarget.cellWidget(zObjTarget.rowCount()-1, 1)
1280
            for i in range(zItemTarget.count()):
1281
                zEltList = zItemTarget.itemText(i)
1282
                if zEltList == zItem.text():
1283
                   zItemTarget.setCurrentIndex(i)
1284
                   break
1285
        else:
1286
            for line in range(zObjTarget.rowCount()):
1287
                zItemTarget = zObjTarget.cellWidget(line, 1)
1288
                if zItemTarget == None : break
1289
                if zItemTarget.currentText() == zItem.text():
1290
                   zObjTarget.removeRow(line)
1291
                   break
1292
        self.countItems("tablemotsclefso", zObjTarget)
1293

    
1294
    def majItemLangues(self, item): self.CountLangues()
1295
        
1296
    def CountLangues(self):
1297
        zObjLabel = getWidget(self, "Lbltablelangues")
1298
        if not zObjLabel : return
1299
        zObj = getWidget(self, "tablelangues")
1300
        if not zObj : return
1301
        zRows, counter, listlangues = zObj.model().rowCount(), 0, ""
1302
        for i in range(zRows):
1303
            if zObj.model().item(i, 0).checkState()== Qt.Checked:
1304
                counter+= 1
1305
                zNewline = "<br>" if counter % 4 == 0 else ""
1306
                listlangues+= "<b>%s</b> %s" % (zObj.model().item(i, 0).text(), zNewline)
1307
        zRacLabel = QtGui.QApplication.translate("QSphere","Language(s) for the resource : ", None, QtGui.QApplication.UnicodeUTF8)
1308
        zObjLabel.setText("(<b><u>%s</u></b>) %s<br>%s" % (counter, zRacLabel, listlangues))
1309

    
1310
    def countItems(self, zCible, zObj):
1311
        zObjLabel = getWidget(self, "Lbl%s" % (zCible))
1312
        if zObjLabel : zObjLabel.setText("(<b><u>%s</u></b>) %s" % (zObj.rowCount(), zObjLabel.accessibleDescription()))  
1313

    
1314
    def cleanAllObj(self, zObj, doCount):
1315
        if not zObj : return
1316
        zObj.clearContents()
1317
        for i in range(zObj.rowCount()): zObj.removeRow(0)
1318
        if doCount : self.countItems(zObj.accessibleName(), zObj)        
1319

    
1320

    
1321
    def doDessCadre(self, currentRow, currentColumn, previousRow, previousColumn):
1322
        if currentRow!= previousRow : self.DessCadre()
1323
                    
1324
    def DessCadre(self):
1325
        zBorneLong = int(self.EmpriseLong/2)
1326
        zBorneLat = int(self.EmpriseLat/2)
1327
        zIndexEmp = -1
1328
        
1329
        if self.sender()==None or self.sender().objectName()=="":
1330
           zObj = getWidget(self, "tableemprises")
1331
           zIndexEmp = GetIndex(zObj)
1332
        else:
1333
           zNameObj = "%s" % (self.sender().accessibleName())
1334
           zObj = getWidget(self, "tableemprises")
1335
           if zNameObj.find("tableemprises_")!=-1: zIndexEmp = int(zNameObj.split("_")[2])
1336
           else: zIndexEmp = GetIndex(zObj)
1337

    
1338
        if zIndexEmp == -1: return
1339
        zItem = zObj.cellWidget(zIndexEmp,0)        
1340
        if zItem == None : return
1341
       
1342
        zItem = zObj.cellWidget(zIndexEmp,2)
1343
        XposD = int(zItem.value())+ zBorneLong
1344

    
1345
        zItem = zObj.cellWidget(zIndexEmp,3)
1346
        XposF = int(zItem.value())+zBorneLong
1347
       
1348
        zItem = zObj.cellWidget(zIndexEmp,0)
1349
        YposD = zBorneLat-int(zItem.value())
1350

    
1351
        zItem = zObj.cellWidget(zIndexEmp,1)
1352
        YposF = zBorneLat-int(zItem.value())
1353

    
1354
        self.zCadre.setGeometry(QtCore.QRect(XposD, YposD, (XposF-XposD), (YposF - YposD)))
1355
        self.zMireH.setGeometry(QtCore.QRect(XposD + int((XposF-XposD)/2), 0, 1, self.EmpriseLat)) 
1356
        self.zMireW.setGeometry(QtCore.QRect(0, YposD - int((YposD-YposF)/2), self.EmpriseLong, 1))
1357

    
1358

    
1359
def makeTABWidgets(self, tab, zIndex, SizeLabelW, SizeLabelH, SizeWW, SizeWH):
1360
        refSizeWW, refSizeWH = SizeWW, SizeWH
1361
        zLang = "fr" if self.langueTR == "fr" else "en" 
1362

    
1363
        zTitles = (QtGui.QApplication.translate("QSphere","Data identification : ", None, QtGui.QApplication.UnicodeUTF8), \
1364
                   QtGui.QApplication.translate("QSphere","Title : ", None, QtGui.QApplication.UnicodeUTF8), \
1365
                   QtGui.QApplication.translate("QSphere","Abstract : ", None, QtGui.QApplication.UnicodeUTF8), \
1366
                   QtGui.QApplication.translate("QSphere","Resource type : ", None, QtGui.QApplication.UnicodeUTF8), \
1367
                   QtGui.QApplication.translate("QSphere","Locator (s) for the resource : ", None, QtGui.QApplication.UnicodeUTF8), \
1368
                   QtGui.QApplication.translate("QSphere","Resource Identifier : ", None, QtGui.QApplication.UnicodeUTF8), \
1369
                   QtGui.QApplication.translate("QSphere","Language(s) for the resource : ", None, QtGui.QApplication.UnicodeUTF8), \
1370
                   QtGui.QApplication.translate("QSphere","Format(s) : ", None, QtGui.QApplication.UnicodeUTF8), \
1371
                   QtGui.QApplication.translate("QSphere","Encoding : ", None, QtGui.QApplication.UnicodeUTF8), \
1372
                   QtGui.QApplication.translate("QSphere","Classification of spatial data and services : ", None, QtGui.QApplication.UnicodeUTF8), \
1373
                   QtGui.QApplication.translate("QSphere","Thematic categories : ", None, QtGui.QApplication.UnicodeUTF8), \
1374
                   QtGui.QApplication.translate("QSphere","Keywords : ", None, QtGui.QApplication.UnicodeUTF8), \
1375
                   QtGui.QApplication.translate("QSphere","Keywords from INSPIRE<br>Data themes & repositories : ", None, QtGui.QApplication.UnicodeUTF8), \
1376
                   QtGui.QApplication.translate("QSphere","<i>Free</i> keywords : ", None, QtGui.QApplication.UnicodeUTF8), \
1377
                   "", \
1378
                   QtGui.QApplication.translate("QSphere","Location : ", None, QtGui.QApplication.UnicodeUTF8), \
1379
                   QtGui.QApplication.translate("QSphere","Bouding box : ", None, QtGui.QApplication.UnicodeUTF8), \
1380
                   "", \
1381
                   QtGui.QApplication.translate("QSphere","Coordinate reference system(s) : ", None, QtGui.QApplication.UnicodeUTF8), \
1382
                   QtGui.QApplication.translate("QSphere","SRS : ", None, QtGui.QApplication.UnicodeUTF8), \
1383
                   QtGui.QApplication.translate("QSphere","Temporal informations : ", None, QtGui.QApplication.UnicodeUTF8), \
1384
                   QtGui.QApplication.translate("QSphere","Temporal extent : ", None, QtGui.QApplication.UnicodeUTF8), \
1385
                   QtGui.QApplication.translate("QSphere","Date of publication : ", None, QtGui.QApplication.UnicodeUTF8), \
1386
                   QtGui.QApplication.translate("QSphere","Date of creation : ", None, QtGui.QApplication.UnicodeUTF8), \
1387
                   QtGui.QApplication.translate("QSphere","Date of the last revision : ", None, QtGui.QApplication.UnicodeUTF8), \
1388
                   QtGui.QApplication.translate("QSphere","Temporal reference system : ", None, QtGui.QApplication.UnicodeUTF8), \
1389
                   QtGui.QApplication.translate("QSphere","Quality & validity : ", None, QtGui.QApplication.UnicodeUTF8), \
1390
                   QtGui.QApplication.translate("QSphere","Lineage : ", None, QtGui.QApplication.UnicodeUTF8), \
1391
                   QtGui.QApplication.translate("QSphere","Lineage for the data : ", None, QtGui.QApplication.UnicodeUTF8), \
1392
                   QtGui.QApplication.translate("QSphere","Spatial resolution : ", None, QtGui.QApplication.UnicodeUTF8), \
1393
                   QtGui.QApplication.translate("QSphere","Equivalent scale : ", None, QtGui.QApplication.UnicodeUTF8), \
1394
                   QtGui.QApplication.translate("QSphere","Topological consistency : ", None, QtGui.QApplication.UnicodeUTF8), \
1395
                   QtGui.QApplication.translate("QSphere","Compliance : ", None, QtGui.QApplication.UnicodeUTF8), \
1396
                   QtGui.QApplication.translate("QSphere","Compliance specifications : ", None, QtGui.QApplication.UnicodeUTF8), \
1397
                   QtGui.QApplication.translate("QSphere","Constraint related to access and use : ", None, QtGui.QApplication.UnicodeUTF8), \
1398
                   QtGui.QApplication.translate("QSphere","Conditions applying...\nto access and use : ", None, QtGui.QApplication.UnicodeUTF8), \
1399
                   QtGui.QApplication.translate("QSphere","Conditions licensing applying...\nto access and use : ", None, QtGui.QApplication.UnicodeUTF8), \
1400
                   QtGui.QApplication.translate("QSphere","Responsible party : ", None, QtGui.QApplication.UnicodeUTF8), \
1401
                   "", \
1402
                   QtGui.QApplication.translate("QSphere","Informations about Metadata : ", None, QtGui.QApplication.UnicodeUTF8), \
1403
                   QtGui.QApplication.translate("QSphere","Metadata date : ", None, QtGui.QApplication.UnicodeUTF8), \
1404
                   QtGui.QApplication.translate("QSphere","Metadata language : ", None, QtGui.QApplication.UnicodeUTF8), \
1405
                   QtGui.QApplication.translate("QSphere","Additional Information QGIS QSPHERE : ", None, QtGui.QApplication.UnicodeUTF8), \
1406
                   QtGui.QApplication.translate("QSphere","Name layer : ", None, QtGui.QApplication.UnicodeUTF8), \
1407
                   QtGui.QApplication.translate("QSphere","Type layer : ", None, QtGui.QApplication.UnicodeUTF8), \
1408
                   "", \
1409
                   "", \
1410
                   ""                   
1411
                   )
1412
        zToolTips = (QtGui.QApplication.translate("QSphere","Data identification ", None, QtGui.QApplication.UnicodeUTF8), \
1413
                     QtGui.QApplication.translate("QSphere","Title of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1414
                     QtGui.QApplication.translate("QSphere","Abstract of the dataset describing the resource ", None, QtGui.QApplication.UnicodeUTF8), \
1415
                     QtGui.QApplication.translate("QSphere","Resource type ", None, QtGui.QApplication.UnicodeUTF8), \
1416
                     QtGui.QApplication.translate("QSphere","Link(s) for the resource ", None, QtGui.QApplication.UnicodeUTF8), \
1417
                     QtGui.QApplication.translate("QSphere","Identifier for the resource ", None, QtGui.QApplication.UnicodeUTF8), \
1418
                     QtGui.QApplication.translate("QSphere","List of language(s) for the resource : ", None, QtGui.QApplication.UnicodeUTF8), \
1419
                     QtGui.QApplication.translate("QSphere","Different formats of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1420
                     QtGui.QApplication.translate("QSphere","Character encoding of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1421
                     QtGui.QApplication.translate("QSphere","Data classification and mapping services ", None, QtGui.QApplication.UnicodeUTF8), \
1422
                     QtGui.QApplication.translate("QSphere","Thematic categories\n(INSPIRE Annexes - INSPIRE Themes - ISO classes ) ", None, QtGui.QApplication.UnicodeUTF8), \
1423
                     QtGui.QApplication.translate("QSphere","Keywords ", None, QtGui.QApplication.UnicodeUTF8), \
1424
                     QtGui.QApplication.translate("QSphere","List of keywords required (INSPIRE Themes) ", None, QtGui.QApplication.UnicodeUTF8), \
1425
                     QtGui.QApplication.translate("QSphere","List of optional keywords (INSPIRE Themes) ", None, QtGui.QApplication.UnicodeUTF8), \
1426
                     QtGui.QApplication.translate("QSphere","Search with GeoVOC", None, QtGui.QApplication.UnicodeUTF8), \
1427
                     QtGui.QApplication.translate("QSphere","Information for the location (data required) ", None, QtGui.QApplication.UnicodeUTF8), \
1428
                     QtGui.QApplication.translate("QSphere","Information for the location (Bouding box) ", None, QtGui.QApplication.UnicodeUTF8), \
1429
                     QtGui.QApplication.translate("QSphere","List of the extents of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1430
                     QtGui.QApplication.translate("QSphere","Information about coordinate reference system(s) (data required) ", None, QtGui.QApplication.UnicodeUTF8), \
1431
                     QtGui.QApplication.translate("QSphere","List of reference system(s) of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1432
                     QtGui.QApplication.translate("QSphere","Temporal informations ", None, QtGui.QApplication.UnicodeUTF8), \
1433
                     QtGui.QApplication.translate("QSphere","Information about temporal extent (optional data)", None, QtGui.QApplication.UnicodeUTF8), \
1434
                     QtGui.QApplication.translate("QSphere","Date of publication of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1435
                     QtGui.QApplication.translate("QSphere","Date of creation of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1436
                     QtGui.QApplication.translate("QSphere","Date of the last revision of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1437
                     QtGui.QApplication.translate("QSphere","Temporal reference system ", None, QtGui.QApplication.UnicodeUTF8), \
1438
                     QtGui.QApplication.translate("QSphere","Quality & validity", None, QtGui.QApplication.UnicodeUTF8), \
1439
                     QtGui.QApplication.translate("QSphere","Lineage of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1440
                     QtGui.QApplication.translate("QSphere","Lineage of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1441
                     QtGui.QApplication.translate("QSphere","Spatial resolution of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1442
                     QtGui.QApplication.translate("QSphere","Equivalent scale of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1443
                     QtGui.QApplication.translate("QSphere","Topological consistency of spatial data sets and services (data not required) ", None, QtGui.QApplication.UnicodeUTF8), \
1444
                     QtGui.QApplication.translate("QSphere","Compliance of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1445
                     QtGui.QApplication.translate("QSphere","List of compliance specifications of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1446
                     QtGui.QApplication.translate("QSphere","Constraint related to access and use ", None, QtGui.QApplication.UnicodeUTF8), \
1447
                     QtGui.QApplication.translate("QSphere","Conditions applying to access and use ", None, QtGui.QApplication.UnicodeUTF8), \
1448
                     QtGui.QApplication.translate("QSphere","Licensing conditions applying to access and use ", None, QtGui.QApplication.UnicodeUTF8), \
1449
                     QtGui.QApplication.translate("QSphere","Organisations reponsible for the etablishment, management, maintenance and distribution of spatial data sets and services ", None, QtGui.QApplication.UnicodeUTF8), \
1450
                     QtGui.QApplication.translate("QSphere","Responsible party role ", None, QtGui.QApplication.UnicodeUTF8), \
1451
                     QtGui.QApplication.translate("QSphere","Informations about Metadata ", None, QtGui.QApplication.UnicodeUTF8), \
1452
                     QtGui.QApplication.translate("QSphere","Metadata date ", None, QtGui.QApplication.UnicodeUTF8), \
1453
                     QtGui.QApplication.translate("QSphere","Metadata language ", None, QtGui.QApplication.UnicodeUTF8), \
1454
                     QtGui.QApplication.translate("QSphere","Metadata language ", None, QtGui.QApplication.UnicodeUTF8), \
1455
                     QtGui.QApplication.translate("QSphere","Name Layer ", None, QtGui.QApplication.UnicodeUTF8), \
1456
                     QtGui.QApplication.translate("QSphere","Type Layer ", None, QtGui.QApplication.UnicodeUTF8), \
1457
                     QtGui.QApplication.translate("QSphere","Generic metadata QGIS for geographical layer (vector or raster) ", None, QtGui.QApplication.UnicodeUTF8), \
1458
                     QtGui.QApplication.translate("QSphere","Fields for the query layer (vector) ", None, QtGui.QApplication.UnicodeUTF8), \
1459
                     QtGui.QApplication.translate("QSphere","QSphere resources ", None, QtGui.QApplication.UnicodeUTF8)                     
1460
                     )
1461

    
1462
        if zIndex == 1 :
1463
            Widgets = {"A_TITLE" : (0,0,"title", zTitles[0], zToolTips[0], -1, (), "", True, False),
1464
                       "B_Intitule" : (self.width()-530,0,"intitule", zTitles[1], zToolTips[1], 5, (),"file:intitule.html", True, False),
1465
                       "C_Resume" : (self.width()-530,100, "resume", zTitles[2], zToolTips[2], 0, (), "file:resume.html", True, False),
1466
                       "D_Type" : (self.width()-530, 0, "typedata", zTitles[3], zToolTips[3], 1, self.listTypeRessources,"file:type_ressource.html", True, False),
1467
                       "E_Localisator" : (self.width()-530, 15, "tablelocalisator", zTitles[4], zToolTips[4], 6, (), "file:localisateur.html", True, False),
1468
                       "F_Identificator" : (300, 0, "identificator", zTitles[5], zToolTips[5], 5, (), "file:identificateur.html", True, False),
1469
                       "G2_lang" : (0, 0, "tablelangues", zTitles[6], zToolTips[6], 3, "txt:", "file:langue.html", True, False),
1470
                       "H_format" : (220, 0, "tableformats", zTitles[7], zToolTips[7], 6, (), "file:format_fichier.html", True, True),
1471
                       "I_carac" : (120, 0, "tablecarac", zTitles[8], zToolTips[8], 1, self.listCodecs, "file:encodage.html", True, True) 
1472
                      }
1473
        elif zIndex == 2 :
1474
             Widgets = {"A_TITLE" : (0, 0,"title", zTitles[9], zToolTips[9], -1, (), "", True, False),
1475
                        "B_Categorie" : (0, 180,"tablecategories", zTitles[10], zToolTips[10], 3, "file:300:categories_thematiques.csv:1:0", "file:categorie_thematique.html", True, False),
1476
                        "C_TITLE" : (0, 0,"title", zTitles[11], zToolTips[11], -1, (), "", True, False),
1477
                        "D_MotsClefsO" : (self.width()-530, 11,"tablemotsclefso", zTitles[12], zToolTips[12], 6, (), u"file:mots_clefs.html#mot_cle_obligatoire", True, False),
1478
                        "E_MotsClefsF" : (self.width()-530, 11,"tablemotsclefsf", zTitles[13], zToolTips[13], 6, (), u"file:mots_clefs.html#mots_cles_complementaires_facultatifs", True, False),
1479
                        "F_Ressources" : (120, 0,"resscatthegorie", zTitles[14], zToolTips[14], 11, (), "http://geocat.fr/index.php?", True, False)
1480
                      }
1481
   
1482
        elif zIndex == 3 :
1483
             Widgets = {"A_TITLE" : (0, 0, "title", zTitles[15], zToolTips[15], -1, (), "", True, False),
1484
                        "B_TITLE" : (0, 0,"title", zTitles[16], zToolTips[16], -2, (), "", True, False),
1485
                        "C_TableSCR" :(self.width()-530, 20,"tableemprises", zTitles[17], zToolTips[17], 6, (), "file:emprise.html", True, False),
1486
                        "D_TITLE" : (0, 0,"title",  zTitles[18], zToolTips[18], -2, (), "", True, False),
1487
                        "E_TableScr" :(self.width()-905, 0,"tablescr", zTitles[19], zToolTips[19], 6, "EPSG:4258", "file:systeme_de_reference.html", True, False)
1488
                       }
1489

    
1490
             zMap = QLabel(tab)
1491
             zMap.setMinimumSize(QtCore.QSize(360, 180))
1492
             zMap.setMaximumSize(QtCore.QSize(360, 180))
1493
             zMap.setGeometry(QtCore.QRect(415, 310, 360, 180))
1494
             myDefPathIcon = getLangIcon("world.png")
1495
             carIcon = QtGui.QImage(myDefPathIcon) 
1496
             zMap.setPixmap(QtGui.QPixmap.fromImage(carIcon))
1497

    
1498
             self.zCadre = MyLabel(zMap)
1499
             self.zMireH = MyLabel(zMap)
1500
             self.zMireW = MyLabel(zMap)
1501

    
1502
        elif zIndex == 4 : 
1503
            Widgets = {"A_TITLE" : (0, 0,"title", zTitles[20], zToolTips[20], -1, (), "", True, False),
1504
                       "B_Etendue" : (160, 15,"tableetenduetemporelle", zTitles[21], zToolTips[21], 6, (), "file:etendue_temporelle.html#6.1.Etendue temporelle", True, True),
1505
                       "C_DatePub" : (120, 15, "tabledatepubdata", zTitles[22], zToolTips[22], 6, (), "file:dates_reference.html#6.2.1.Date de publication", True, False),
1506
                       "D_DateCre" : (0, 0, "datecredata", zTitles[23], zToolTips[23], 4, (), u"file:dates_reference.html#date_de_creation", True, False),
1507
                       "E_DateRev" : (0, 0, "daterevdata", zTitles[24], zToolTips[24], 4, (), u"file:dates_reference.html#date_de_derniere_revision", True, False),
1508
                       "F_SysRefTemp" : (0, 0, "sysreftemp", zTitles[25], zToolTips[25], 1, self.listTemporalSystem, "file:systeme_de_reference_temporel.html", True, False) 
1509
                      }
1510
        elif zIndex == 5 :
1511
            Widgets = {"A_TITLE" : (0, 0,"title", zTitles[26], zToolTips[26], -1, (), "", True, False),
1512
                       "B_TITLE" : (0, 0,"title", zTitles[27], zToolTips[27], -2, (), "", True, False),
1513
                       "C_Genealogie" : (self.width()-530, 100,"genealogie", zTitles[28], zToolTips[28], 0, (), "file:genealogie.html", True, False),
1514
                       "D_TITLE" : (0, 0,"title", zTitles[29], zToolTips[29], -2, (), "", True, False),
1515
                       "E_Echelle" : (400, 160, "grouperesolutionscale", zTitles[30], zToolTips[30], 8, ((zTitles[30]+" 1/","resolution_scale",25000.00),(QtGui.QApplication.translate("QSphere","Equivalent scale in unit of measure ", None, QtGui.QApplication.UnicodeUTF8),"resolution_pixel",2.0)), "file:resolution_spatiale.html", True, False),
1516
                       "F_Coherence" : (self.width()-530, 0,"coherence", zTitles[31], zToolTips[31], 0, "{'TopologyLevelCode':'unknow', 'GeometricObjectTypeCode':'unknow'}", "file:coherence_topologique.html", False, False),
1517
                       "G_TITLE" : (0, 0,"title", zTitles[32], zToolTips[32], -1, (), "", True, False),
1518
                       "H_Conformite" : (self.width()-530, 15,"tablespecifications", zTitles[33], zToolTips[33], 6, (), "file:conformite_specifications.html", True, False)
1519
                      }
1520

    
1521

    
1522
        elif zIndex == 6 :
1523
            Widgets = {"A_TITLE" : (0, 0,"title", zTitles[34], zToolTips[34], -1, (), "", True, False),
1524
                       "B_droits" : (self.width()-530, self.height()-160,"groupedroits", zTitles[35], zToolTips[35], 8, \
1525
                                     ((QtGui.QApplication.translate("QSphere","No restriction for public access in INSPIRE", None, QtGui.QApplication.UnicodeUTF8),"norestriction_droits",25000.00), \
1526
                                      (QtGui.QApplication.translate("QSphere","With restriction for public access in INSPIRE (Directive 2007/2/CE)", None, QtGui.QApplication.UnicodeUTF8),"restriction_droits",2.0)), "file:contraintes.html", True, False), \
1527
                       "C_Licence" : (self.width()-530, 40,"licence", zTitles[36], zToolTips[36], 0, "%s" % ((QtGui.QApplication.translate("QSphere","Open Licence", None, QtGui.QApplication.UnicodeUTF8))), "file:licence.html", True, False)
1528
                      }
1529
        #+1    
1530
        elif zIndex == 7 : 
1531
            Widgets = {"A_TITLE" : (0, 0,"title", zTitles[37], zToolTips[37], -1, (), "", True, False),
1532
                       "B_TableRole" :(self.width()-530, 40,"tableroles", zTitles[38], zToolTips[38], 6, (), "file:organisme_responsable.html", True, False)
1533
                      }
1534
            
1535
        elif zIndex == 8 : 
1536
            Widgets = {"A_TITLE" : (0, 0,"title", zTitles[39], zToolTips[39], -1, (), "", True, False),
1537
                       "B_DateMetadata" : (0, 0, "datemetada", zTitles[40], zToolTips[40], 4, (), "file:date_metadonnee.html", True, False),
1538
                       "C_LangMetadata" : (80, 0, "langmetada", zTitles[41], zToolTips[41], 1, self.languesDico, "file:langue_metadonnee.html", True, False) 
1539
                      }
1540
        elif zIndex == 9 :
1541
            Widgets = {"A_TITLE" : (0, 0,"title", zTitles[42], zToolTips[42], -1, (), "", True, False),
1542
                       "B_NameLayer" : (self.width()-530,0,"namelayer", zTitles[43], zToolTips[43], 5, (),"file:catalogue_attributaire.html", False, False),
1543
                       "C_TypeLayer" : (200,0,"typelayer", zTitles[44], zToolTips[44], 5, (),"file:catalogue_attributaire.html", False, False),
1544
                       "D_Metadata" : (self.width()-530, 150,"metadata", zTitles[45], zToolTips[45], 0, (), "file:catalogue_attributaire.html", True, False),
1545
                       "E_TableDico" :(self.width()-530, 35,"tabledico", zTitles[46], zToolTips[46], 6, (), "file:catalogue_attributaire.html", True, False),
1546
                       "F_Ressources" : (120, 0,"ressicons", zTitles[47], zToolTips[47], 11, (), "file:ressources_qsphere.html", True, False)
1547
                      }
1548
        else : return
1549
        
1550
        posX, posY = 200, 10
1551
         
1552
        zListitems = ShortDic(Widgets)
1553
        for j in range(len(zListitems)):    
1554
            key = zListitems[j]
1555
            ListPropertiesObj = Widgets[key]
1556
            SizeWW =  ListPropertiesObj[0] if ListPropertiesObj[0] != 0 else refSizeWW
1557
            SizeWH =  ListPropertiesObj[1] if ListPropertiesObj[1] != 0 else refSizeWH
1558
            nameObj, txtObj, tooltipObj = ListPropertiesObj[2], ListPropertiesObj[3], ListPropertiesObj[4]
1559
            typeObj, valObj, UrlObj = ListPropertiesObj[5], ListPropertiesObj[6], ListPropertiesObj[7]
1560
            isEnabled, isVertical = ListPropertiesObj[8], ListPropertiesObj[9]
1561
            corPosY = makeWidget(self, tab, txtObj, nameObj, typeObj, tooltipObj, valObj, posX, posY, SizeWW, SizeWH, refSizeWH, UrlObj, isEnabled, isVertical)
1562
            if isVertical : posX+= SizeWW + 200
1563
            else:
1564
               posY+= 30 if corPosY == 0 else corPosY
1565
               posX = 200
1566
            
1567

    
1568
def makeWidget(self, tab, txtObj, nameObj, typeObj, tooltipObj, valObj, posX, posY, SizeW, SizeH, SizeRefH,  zUrl, zEnable, zVerticalObj):
1569
        lblObj = QLabel(tab)
1570
        lblObj.setObjectName("Lbl"+nameObj)
1571
        lblObj.setAccessibleName("Lbl"+nameObj)
1572
        corPosY = 0
1573

    
1574
        if typeObj in( -1, -2) :
1575
            lblObj.setGeometry(QtCore.QRect(10,posY+5,self.width(),SizeH))
1576
            if typeObj == -1 :
1577
                lblObj.setAlignment(Qt.AlignLeft)
1578
                lblObj.setStyleSheet("QLabel { background-color : #5D5D5D; color : white; }")
1579
                txtObj = ">> %s" % (txtObj)
1580
            else :
1581
                lblObj.setAlignment(Qt.AlignCenter)
1582
                lblObj.setStyleSheet("QLabel { background-color : #CCCCCC; color : black; }")
1583
            lblObj.setText(txtObj)
1584
            corPosY = SizeH+10 
1585
        else :
1586
            if nameObj=="tablelangues" : lblObj.setGeometry(QtCore.QRect(posX-165,posY+5,165, SizeH*4))
1587
            else : lblObj.setGeometry(QtCore.QRect(posX-165,posY+5,165,self.SizeWH*2))
1588
            lblObj.setAlignment(Qt.AlignRight)
1589
            lblObj.setText(txtObj)
1590
            lblObj.setAccessibleDescription(txtObj)
1591
        
1592
        if typeObj == 0: 
1593
            Obj = QTextEdit(tab) 
1594
            Obj.setAcceptRichText(False)
1595
            Obj.setReadOnly(False)
1596
            Obj.setTabChangesFocus(True)
1597
            #TOTO 2.6.1
1598
            Obj.setWordWrapMode(QTextOption.WordWrap)# .NoWrap)
1599
            zType = "%s" % (type(valObj))
1600
            if zType == "<type 'str'>" : Obj.setText("%s" % (valObj))
1601
            corPosY = SizeH+10   
1602
                
1603
        elif typeObj == 1:
1604
            Obj = QComboBox(tab)
1605
            itemtarget = 0 if nameObj != "sysreftemp" else 1
1606
            if type(valObj) == str :
1607
               if valObj.find("file:")!=-1 :
1608
                   SizeW, zCols, iLine = LoadFile(self, Obj, nameObj, valObj, typeObj, None)
1609
               else :
1610
                   Obj.addItem("%s" % (valObj))
1611
                   SizeW = int(SizeW / 2)
1612
            elif type(valObj) == tuple :
1613
               Obj.insertItems (0, valObj)
1614
               SizeW = int(SizeW / 2)
1615
            elif type(valObj) == dict :    
1616
                myelts = ShortDic(valObj)
1617
                if nameObj == "langmetada" : 
1618
                    mylang = QtCore.QLocale.languageToString(self.langue)
1619
                    itemtarget = MakeListLangues(self, Obj, mylang)
1620
            elif type(valObj) == list :
1621
                if nameObj == "tablecarac" :
1622
                    valObj.sort()
1623
                    Obj.insertItems (0, valObj)
1624
                    itemtarget = valObj.index("utf8")
1625
            Obj.setCurrentIndex(itemtarget)
1626

    
1627
        
1628
        elif typeObj == 3:
1629
            self.tableModel = QStandardItemModel(self)
1630
            Obj = QTableView(tab)
1631
            if self.SizeWW == SizeW : SizeW =  self.width()-posX - 330
1632
            iLine, zCols = 0, 1
1633

    
1634
            if type(valObj) == str :
1635
                if valObj.startswith("file:"): 
1636
                   SizeHOld = SizeH
1637
                   SizeH, zCols, iLine = LoadFile(self, Obj, nameObj, valObj, typeObj, self.tableModel)
1638
                   if SizeHOld != SizeRefH: SizeH = SizeHOld
1639
                elif valObj.startswith("txt:"):
1640
                   data_icons = os.path.dirname(__file__).replace("\\","/") +"/ressources/images/"
1641
                   zCols, i = 2, 0
1642
                   mylans = ShortDic(self.languesDico)
1643
                   mylang = QtCore.QLocale.languageToString( self.langue )
1644
                   for elt in mylans :
1645
                        if len(elt)==3 :
1646
                            language_codeiso = elt
1647
                            language_name = self.languesDico[elt]['french']
1648
                            for j in range(zCols):
1649
                                zIcon = QIcon(data_icons+language_codeiso+".png")
1650
                                item = QStandardItem() if j == 0 else QStandardItem(zIcon, "")
1651
                                zText = language_codeiso if j == 0 else language_name
1652
                                item.setText(zText)
1653
                                if j == 0 :
1654
                                   item.setCheckable(True)
1655
                                   item.setCheckState(Qt.Unchecked)
1656
                                   if  nameObj == "tablelangues" and self.languesDico[elt]['english'] == mylang : item.setCheckState(Qt.Checked)
1657
                                item.setEditable(False)    
1658
                                self.tableModel.setItem(i,j,item)
1659
                            i+= 1
1660
                SizeH = SizeH + 70
1661

    
1662
   
1663
            elif type(valObj) == list :
1664
                #This case not active in current version - keep and save
1665
                zCols = 2
1666
                for i in range(len(valObj)):
1667
                    language = valObj[i]
1668
                    language_name = QtCore.QLocale.languageToString( language ) 
1669
                    language_codeiso = QtCore.QLocale( language ).name().split("_")[0]
1670
                    language_index_target = QtCore.QLocale.languageToString( language ) 
1671
           
1672
                    for j in range(zCols):
1673
                        item = QStandardItem()
1674
                        zText = language_codeiso if j == 0 else language_name
1675
                        if j == 0 :
1676
                            item.setCheckable(True)
1677
                            item.setCheckState(Qt.Unchecked)
1678
                            if self.languageindex == language_index_target: item.setCheckState(Qt.Checked)
1679
                        item.setEditable(False)    
1680
                        item.setText(zText)
1681
                        self.tableModel.setItem(i,j,item)
1682
                SizeH = SizeH + 70
1683
                
1684
            else :
1685
                #This case not active in current version - keep and save
1686
                for i in range(len(valObj)):
1687
                    if type(valObj[i]) == str :
1688
                        item = QStandardItem()
1689
                        item.setCheckable(True)
1690
                        item.setCheckState(Qt.Unchecked)
1691
                        zText = "%s" % (valObj[i][j])
1692
                        item.setText(zText)
1693
                        item.setEditable(False)
1694
                        self.tableModel.setItem(iLine,0,item)
1695
                        
1696
                    elif type(valObj[i]) == tuple :
1697
                        zCols = len(valObj[i])
1698
                        for j in range(len(valObj[i])):
1699
                            item = QStandardItem() 
1700
                            zText = "%s" % (valObj[i][j])
1701
                            item.setText(zText)                            
1702
                            if j == 0 :
1703
                                item.setCheckable(True)
1704
                                item.setCheckState(Qt.Unchecked)
1705
                                #This case not active in current version - keep and save
1706
                                #old sample flag language - keep and save
1707
                                if nameObj == "tablelangues" and item.text().startswith(self.langueTR): item.setCheckState(Qt.Checked)
1708
                            item.setEditable(False)    
1709
                            self.tableModel.setItem(iLine,j,item)
1710
                      
1711
                    iLine+= 1
1712
                SizeH = SizeH * (iLine+1) + 30
1713

    
1714
            for i in range(zCols): Obj.setColumnWidth(i, int(SizeW/zCols)-10)
1715
            Obj.horizontalHeader().setDefaultSectionSize(int(SizeW/zCols)-10)
1716
            if nameObj == "tabledroits" : Obj.verticalHeader().setDefaultSectionSize(60)
1717
            Obj.horizontalHeader().setVisible(False) 
1718
            Obj.verticalHeader().setVisible(False) 
1719
            Obj.setModel(self.tableModel)
1720

    
1721
            if nameObj=="tablelangues": QtCore.QObject.connect(Obj.model(),QtCore.SIGNAL("itemChanged(QStandardItem*)"),self.majItemLangues)
1722
            
1723
            corPosY =  SizeH + 10
1724

    
1725

    
1726
        elif typeObj == 4:    
1727
            Obj = QCalendarWidget(tab)
1728
            Obj.setStyleSheet("""QMenu { font-size:14px; width: 150px; left: 16px; background-color:qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #cccccc, stop: 1 #5D5D5D);}"""
1729
                              """QToolButton {icon-size: 20px, 20px;background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #cccccc, stop: 1 #5D5D5D); height: 20px; width: 200px;}"""
1730
                              """QAbstractItemView {selection-background-color: rgb(255, 174, 0);}"""
1731
                              """QToolButton::menu-arrow {}"""
1732
                              """QToolButton::menu-button {}"""
1733
                              """QToolButton::menu-indicator{width: 5px;}"""
1734
                              """QToolButton::menu-indicator:pressed,"""
1735
                              """QToolButton::menu-indicator:open{top:10px; left: 20px;}"""
1736
                              """QListView {background-color:white;}"""
1737
                              """subcontrol-position: top right; width:50px; border-image: url(icons:arrow_up_n.png);}"""
1738
                              """border-width: 1px; width:25px;}"""
1739
                              )
1740
       
1741

    
1742
            Obj.setGridVisible(True)
1743
            Obj.showToday()
1744
            QtCore.QObject.connect(Obj,QtCore.SIGNAL("selectionChanged()"),self.FixeToolTipCalendar)
1745
            tooltipObj = MakeToolTipCalendar(self, Obj)
1746
            SizeH = 170 
1747
            corPosY = SizeH + 10 
1748
            SizeW = SizeW + 35
1749

    
1750
        elif typeObj in(5, 50):
1751
            if typeObj == 5 : Obj = QLineEdit(tab)
1752
            elif typeObj == 50 :
1753
                 Obj = MyWidgetLineEdit(tab)
1754
                 zText = valObj.split(":")
1755
                 Obj.initType(int(zText[0]))
1756
                 if int(zText[0])== 1: Obj.setInputMask("9999-99-99 9999-99-99;X")
1757
                 elif int(zText[0])== 2: Obj.setInputMask("99999;X")
1758
                 elif int(zText[0])== 5: Obj.setInputMask("9999-99-99;X")
1759
                 valObj = zText[1]
1760
                 Obj.setAlignment(Qt.AlignCenter)
1761
                 QtCore.QObject.connect(Obj,QtCore.SIGNAL("textChanged(const QString &)"),Obj.VerifExpReg)
1762
            Obj.setText("") if nameObj != "identificator" else Obj.setText("%s-%s-%s" % (self.langueTR.upper(), datetime.datetime.now().year, getRandowId(self)))
1763

    
1764

    
1765
        elif typeObj == 6 : 
1766
            if nameObj == "tableroles" : zCols = 7
1767
            elif nameObj in ("tableemprises", "tablemotsclefsf") : zCols = 5
1768
            elif nameObj == "tablespecifications" : zCols = 4
1769
            elif nameObj == "tableformats"  : zCols = 3
1770
            elif nameObj in ("tablemotsclefso", "tablescr", "tablelocalisator") : zCols = 2 
1771
            elif nameObj in ("tabledatepubdata", "tableetenduetemporelle") : zCols = 1 
1772
            else : zCols = 6 
1773

    
1774
            Obj = QTableWidget(0, zCols, tab)
1775
            Obj.setObjectName(nameObj)
1776
            Obj.setAccessibleName(nameObj)
1777

    
1778
            if nameObj == "tablescr" :
1779
                zDim = (120, 40)
1780
                for i in range(len(zDim)): Obj.setColumnWidth(i, zDim[i])
1781
                zListHeaders = (QtGui.QApplication.translate("QSphere","Selected SRS", None, QtGui.QApplication.UnicodeUTF8),"") 
1782

    
1783
            elif nameObj == "tableetenduetemporelle" :
1784
                Obj.setColumnWidth(0, 140)
1785
                zListHeaders = (QtGui.QApplication.translate("QSphere"," Start <-> End ", None, QtGui.QApplication.UnicodeUTF8),"") 
1786

    
1787
            elif nameObj == "tabledatepubdata" :
1788
                Obj.setColumnWidth(0, 100)
1789
                zListHeaders = ("date","")
1790

    
1791
            elif nameObj == "tabledico" : 
1792
                zDim = (50, 150, 70, 60, 50, 150)
1793
                for i in range(len(zDim)): Obj.setColumnWidth(i, zDim[i])
1794
                zListHeaders = ("Id", \
1795
                                QtGui.QApplication.translate("QSphere","Name", None, QtGui.QApplication.UnicodeUTF8), \
1796
                                "Type", \
1797
                                QtGui.QApplication.translate("QSphere","Length", None, QtGui.QApplication.UnicodeUTF8), \
1798
                                QtGui.QApplication.translate("QSphere","Precision", None, QtGui.QApplication.UnicodeUTF8), \
1799
                                QtGui.QApplication.translate("QSphere","Comment", None, QtGui.QApplication.UnicodeUTF8)) 
1800

    
1801
            elif nameObj == "tablemotsclefso" :
1802
                zDim = (200, 300)
1803
                for i in range(len(zDim)): Obj.setColumnWidth(i, zDim[i])
1804
                zListHeaders = (QtGui.QApplication.translate("QSphere","Thematic", None, QtGui.QApplication.UnicodeUTF8), \
1805
                                QtGui.QApplication.translate("QSphere","Keyword", None, QtGui.QApplication.UnicodeUTF8)) 
1806

    
1807
            elif nameObj == "tableformats" :
1808
                zDim = (80, 40, 80)
1809
                for i in range(len(zDim)): Obj.setColumnWidth(i, zDim[i])
1810
                zListHeaders = ("Format", "", "Version")
1811
                SizeH = 10
1812

    
1813
            elif nameObj == "tablemotsclefsf" :
1814
                zDim = (150, 25, 140, 80, 90)
1815
                for i in range(len(zDim)): Obj.setColumnWidth(i, zDim[i])
1816
                zListHeaders = (QtGui.QApplication.translate("QSphere","Keyword", None, QtGui.QApplication.UnicodeUTF8), \
1817
                                "", \
1818
                                QtGui.QApplication.translate("QSphere","Controlled vocabulary ", None, QtGui.QApplication.UnicodeUTF8), \
1819
                                QtGui.QApplication.translate("QSphere","Date", None, QtGui.QApplication.UnicodeUTF8), \
1820
                                QtGui.QApplication.translate("QSphere","Date type", None, QtGui.QApplication.UnicodeUTF8)) 
1821

    
1822
            elif nameObj == "tablespecifications" :
1823
                zDim = (240, 80, 100, 100)
1824
                for i in range(len(zDim)): Obj.setColumnWidth(i, zDim[i])
1825
                zListHeaders = (QtGui.QApplication.translate("QSphere","Specification", None, QtGui.QApplication.UnicodeUTF8), \
1826
                                QtGui.QApplication.translate("QSphere","Date", None, QtGui.QApplication.UnicodeUTF8), \
1827
                                QtGui.QApplication.translate("QSphere","Date type", None, QtGui.QApplication.UnicodeUTF8), \
1828
                                QtGui.QApplication.translate("QSphere","Class", None, QtGui.QApplication.UnicodeUTF8)) 
1829

    
1830
 
1831
            elif nameObj == "tablelocalisator" :
1832
                zDim = (190, 200)
1833
                for i in range(len(zDim)): Obj.setColumnWidth(i, zDim[i])
1834
                zListHeaders = (QtGui.QApplication.translate("QSphere","URL", None, QtGui.QApplication.UnicodeUTF8), \
1835
                                QtGui.QApplication.translate("QSphere","Name", None, QtGui.QApplication.UnicodeUTF8)) 
1836

    
1837
            elif nameObj == "tableemprises" :
1838
                zDim = (140, 140, 140, 140, 80)
1839
                for i in range(len(zDim)): Obj.setColumnWidth(i, zDim[i])
1840
                zListHeaders = (QtGui.QApplication.translate("QSphere","North lat.", None, QtGui.QApplication.UnicodeUTF8), \
1841
                                QtGui.QApplication.translate("QSphere","South lat.", None, QtGui.QApplication.UnicodeUTF8), \
1842
                                QtGui.QApplication.translate("QSphere","West long.", None, QtGui.QApplication.UnicodeUTF8), \
1843
                                QtGui.QApplication.translate("QSphere","East long.", None, QtGui.QApplication.UnicodeUTF8), \
1844
                                QtGui.QApplication.translate("QSphere","Extent", None, QtGui.QApplication.UnicodeUTF8))
1845
                QtCore.QObject.connect(Obj, QtCore.SIGNAL("currentCellChanged(int, int, int, int )"), self.doDessCadre)
1846
                
1847

    
1848
            elif nameObj == "tableroles" :
1849
                zDim = (160, 100, 140, 60, 60, 80, 200)
1850
                for i in range(len(zDim)): Obj.setColumnWidth(i, zDim[i])
1851
                zListHeaders = (QtGui.QApplication.translate("QSphere","Role", None, QtGui.QApplication.UnicodeUTF8), \
1852
                                QtGui.QApplication.translate("QSphere","Organization name", None, QtGui.QApplication.UnicodeUTF8), \
1853
                                QtGui.QApplication.translate("QSphere","Address", None, QtGui.QApplication.UnicodeUTF8), \
1854
                                QtGui.QApplication.translate("QSphere","Country", None, QtGui.QApplication.UnicodeUTF8), \
1855
                                QtGui.QApplication.translate("QSphere","Zip code", None, QtGui.QApplication.UnicodeUTF8), \
1856
                                QtGui.QApplication.translate("QSphere","City", None, QtGui.QApplication.UnicodeUTF8), \
1857
                                QtGui.QApplication.translate("QSphere","E-mail", None, QtGui.QApplication.UnicodeUTF8)) 
1858

    
1859
     
1860
            self.MakeLine(Obj, False, True) 
1861
            Obj.setHorizontalHeaderLabels(zListHeaders)              
1862
            Obj.verticalHeader().setVisible(False)
1863
            SizeH = (SizeH * 7) + 30
1864
            corPosY = posY + SizeH if nameObj not in("tabledico", "tableformats", "tablelocalisator", "tableemprises", "tablemotsclefso", "tablemotsclefsf") else SizeH + 10
1865

    
1866
        elif typeObj == 8:
1867
            Obj = QGroupBox(tab)
1868
            yypos = 5
1869
            for i in range(len(valObj)):
1870
                zProps = valObj[i]
1871
                zRadioButton = QRadioButton(Obj)
1872
                zRadioButton.setObjectName(zProps[1])
1873
                zRadioButton.setAccessibleName(zProps[1])
1874
                zRadioButton.setText("%s" % (zProps[0]))
1875
                if nameObj == "grouperesolutionscale" : zToolTip = "%s" % (zProps[2])
1876
                else : zToolTip = QtGui.QApplication.translate("QSphere","Constraints", None, QtGui.QApplication.UnicodeUTF8)
1877
                #TOTO 2.6.1
1878
                #zRadioButton.setToolTip(str(zProps[2])) if nameObj == "grouperesolutionscale" else zRadioButton.setToolTip(QtGui.QApplication.translate("QSphere","Constraints", None, QtGui.QApplication.UnicodeUTF8))
1879
                zRadioButton.setToolTip(zToolTip)
1880
                zRadioButton.setGeometry(QtCore.QRect(5,yypos,540,25))
1881
                if i == 0 :  zRadioButton.setChecked(True)
1882
                if nameObj == "grouperesolutionscale" : QtCore.QObject.connect(zRadioButton, QtCore.SIGNAL("clicked()"), self.ChangeOptionScale)
1883
                elif nameObj == "groupedroits" : QtCore.QObject.connect(zRadioButton, QtCore.SIGNAL("toggled(bool)"), self.ChangeOptionRights)
1884
                yypos+= 25
1885
                
1886
            if nameObj == "grouperesolutionscale": 
1887
               zSubObj = QTableWidget(1,1, Obj)
1888
               zSubObj.setObjectName("tableechelles")
1889
               zSubObj.setAccessibleName("tableechelles")
1890
               zSubObj.horizontalHeader().setVisible(False)
1891
               zSubObj.verticalHeader().setVisible(False)
1892
               zSubObj.setGeometry(QtCore.QRect(240,0,140,SizeH-10))
1893
               AddLineWidget(self, zSubObj, 0,  0, 4, 0, -1)
1894
            elif nameObj == "groupedroits":
1895
               self.tableModel = QStandardItemModel(self)
1896
               zSubObj = QTableView(Obj)
1897
               zNameTable = "table%s" % (nameObj)
1898
               zSubObj.setObjectName(zNameTable)
1899
               zSubObj.setAccessibleName(zNameTable)
1900
               iLine, zCols = 0, 1
1901

    
1902
               zLang = "fr" if self.langueTR == "fr" else "en"
1903
               SizezSubObjH, zCols, iLine = LoadFile(self, zSubObj, zNameTable, "file:280:contraintes_%s.csv:1:0" % (zLang), 3, self.tableModel)
1904
               zSubObj.setGeometry(QtCore.QRect(10,60, (SizeW-20), SizeH-70))
1905
               
1906
               for i in range(zCols): zSubObj.setColumnWidth(i, int((SizeW-20)/zCols)-10)
1907
               zSubObj.horizontalHeader().setDefaultSectionSize(int((SizeW-20)/zCols)-10)
1908
               zSubObj.verticalHeader().setDefaultSectionSize(60)
1909
               zSubObj.horizontalHeader().setVisible(False) 
1910
               zSubObj.verticalHeader().setVisible(False) 
1911
               zSubObj.setModel(self.tableModel)
1912
               zSubObj.setEnabled(False)
1913

    
1914

    
1915
            if nameObj == "grouperesolutionscale": 
1916
                zChildInfo = QComboBox(Obj)
1917
                zChildInfo.addItems(self.ListUnitsMesure) #["m", "km", "foot", "inch", "mile", "yard"])
1918
                zChildInfo.setGeometry(QtCore.QRect(100,60, 80,25))
1919
                zChildInfo.setEnabled(False)
1920
            corPosY = SizeH + 10
1921

    
1922
      
1923
        if typeObj == 11:
1924
           Obj = QCommandLinkButton(tab)
1925
           Obj.setText(tooltipObj)
1926
           Obj.setToolTip(zUrl)
1927
           QtCore.QObject.connect(Obj,QtCore.SIGNAL("clicked()"),self.AfficheRessources)
1928
           SizeW = 1.5 * SizeW
1929
           SizeH = 1.5 * SizeH
1930

    
1931

    
1932
        if typeObj != -1 and  typeObj != -2 :
1933
            if txtObj == "" and typeObj != 11:
1934
               posX = 20
1935
               SizeW+= 180
1936

    
1937
            Obj.setGeometry(QtCore.QRect(posX,posY,SizeW, SizeH))
1938
            if typeObj != 11 : Obj.setToolTip(tooltipObj)
1939
            Obj.setObjectName(nameObj)
1940
            Obj.setAccessibleName(nameObj)
1941
            Obj.setAccessibleDescription("Informations blocs XML INSPIRE")
1942
            Obj.setEnabled(zEnable)
1943

    
1944
            if typeObj != 11 :
1945
                if nameObj == "coherence" and typeObj == 0 :
1946
                   zBut = MyButton(tab)
1947
                   zToolTip = QtGui.QApplication.translate("QSphere","Call the topology conformity dialog box", None, QtGui.QApplication.UnicodeUTF8) 
1948
                   zBut.initButton(35, 25, (posX + SizeW - 35), posY, "topo_"+nameObj, "...", zToolTip, True, True) 
1949
                   QtCore.QObject.connect(zBut,QtCore.SIGNAL("clicked()"),self.CallSelectorConformityInfos)
1950

    
1951
                zBut = MyPushButton(tab)
1952
                zIcon = getThemeIcon("info.png")
1953
                zBut.initPushButton(24, 24, (posX + SizeW + 5), posY, "help_%s" % (nameObj), "", QtGui.QApplication.translate("QSphere","Get informations for this topic", None, QtGui.QApplication.UnicodeUTF8), True, zIcon, 24, 24, True)
1954
                zBut.setAccessibleDescription(zUrl)
1955
                QtCore.QObject.connect(zBut,QtCore.SIGNAL("clicked()"),self.AfficheHelp)
1956

    
1957
            if typeObj in(6, 8, 9) and not nameObj in ("tabledico", "groupedroits") :
1958

    
1959
               if nameObj == "tablelocalisator" :
1960
                   zBut = MyPushButton(tab)
1961
                   zIcon = getThemeIcon("localisator.png")
1962
                   zToolTip = QtGui.QApplication.translate("QSphere","View the localisator", None, QtGui.QApplication.UnicodeUTF8) 
1963
                   zBut.initPushButton(24, 24, (posX + SizeW + 5), posY + 30, "URL_%s_%s" % (typeObj, nameObj), "", zToolTip, True, zIcon, 24, 24, True) 
1964
                   QtCore.QObject.connect(zBut,QtCore.SIGNAL("clicked()"),self.goToLocalisator)
1965
                   posY+= 30 
1966

    
1967
                   
1968
               zBut = MyPushButton(tab)
1969
               zIcon = getThemeIcon("addline.png")
1970
               zToolTip = QtGui.QApplication.translate("QSphere","Add a item", None, QtGui.QApplication.UnicodeUTF8) 
1971
               zBut.initPushButton(24, 24, (posX + SizeW + 5), posY + 30, "Ajouter_%s_%s" % (typeObj, nameObj), "", zToolTip, True, zIcon, 24, 24, True) 
1972
               QtCore.QObject.connect(zBut,QtCore.SIGNAL("clicked()"),self.AddLine)
1973

    
1974
               zBut = MyPushButton(tab)
1975
               zIcon = getThemeIcon("delline.png")
1976
               zToolTip = QtGui.QApplication.translate("QSphere","Delete the last item", None, QtGui.QApplication.UnicodeUTF8) 
1977
               zBut.initPushButton(24, 24, (posX + SizeW + 5), posY + 60, "Effacer_%s_%s" % (typeObj, nameObj), "", zToolTip, True, zIcon, 24, 24, True) 
1978
               QtCore.QObject.connect(zBut,QtCore.SIGNAL("clicked()"),self.DelLine)
1979

    
1980
            if nameObj == "scr" :
1981
               zBut = MyButton(tab)
1982
               zToolTip = QtGui.QApplication.translate("QSphere","Call the QGIS SRS dialog box", None, QtGui.QApplication.UnicodeUTF8) 
1983
               zBut.initButton(25, 25, (posX + SizeW + 35), posY, "prj_%s" % (nameObj), "...", zToolTip, True, True) 
1984
               QtCore.QObject.connect(zBut,QtCore.SIGNAL("clicked()"),self.CallQgsProjectionSelector)
1985
                
1986
        if zVerticalObj : corPosY = 0
1987
        if nameObj == "tableemprises" : Obj.setToolTip("0")
1988
        return corPosY
1989
    
1990

    
1991

    
1992
#========================================================
1993
# FUNCTIONS CONSTRUCT LIST LAYERS / EXTRACT INFOS LAYERS
1994
#========================================================
1995
def MakeListLayer(self, zModel, zCombo):
1996
    nLayers = self.iface.legendInterface().layers()
1997
    Name_layer = QtGui.QStandardItem(QtGui.QApplication.translate("QSphere","No layer", None, QtGui.QApplication.UnicodeUTF8))
1998
    ID_layer = QtGui.QStandardItem("-1")
1999
    zModel.appendRow([Name_layer, ID_layer]) 
2000
    for i in range(0, len(nLayers)):
2001
        zLayer = nLayers[i]
2002
        if zLayer.isValid():
2003
           Name_layer = QtGui.QStandardItem("%s" % (zLayer.name()))
2004
           ID_layer = QtGui.QStandardItem("%s" % (zLayer.id()))
2005
           zModel.appendRow([Name_layer, ID_layer])               
2006
    view = QtGui.QTreeView()
2007
    view.header().hide()
2008
    view.setRootIsDecorated(False)
2009

    
2010
    zCombo.setView(view)
2011
    zCombo.setModel(zModel)
2012
    zCombo.show()
2013
    zCombo.setCurrentIndex(0)          
2014

    
2015
def GetLayerCombo(self, zModel, zCombo, zInLegend):
2016
    zLayer = None
2017
    if zCombo.currentIndex()== 0 : return
2018
    zText = zModel.item(zCombo.currentIndex(),1).text()
2019
    if zInLegend : tLayers = self.iface.legendInterface().layers()
2020
    nLayers = len(tLayers) if zInLegend  else  self.iface.mapCanvas().layerCount()
2021
    for i in range(0, nLayers):
2022
        zLayer = tLayers[i] if zInLegend else self.iface.mapCanvas().layer(i)
2023
        #if str(zLayer.id()) == str(zText): break
2024
        #TOTO 2.6.1
2025
        zId = "%s" % (zLayer.id())
2026
        if zId == zText: break
2027
    return zLayer
2028

    
2029

    
2030
def DefzTransform(zLayer, zProj4Dest):
2031
    destinationCRS = QgsCoordinateReferenceSystem()
2032
    destinationCRS.createFromId(zProj4Dest)
2033
    sourceCRS = zLayer.crs()
2034
    zTransform = QgsCoordinateTransform()
2035
    zTransform.setSourceCrs(sourceCRS)
2036
    zTransform.setDestCRS(destinationCRS)
2037
    return zTransform
2038

    
2039

    
2040
def LoadData(self, zFile, zType):
2041
    zPath = os.path.dirname(__file__)
2042
    zPath = zPath.replace("\\","/")
2043
    zFileCSV = zPath +zFile.replace("file:","")
2044
    zListData = [] 
2045
    zMListData = {} 
2046
    i=0
2047
    
2048
    if os.path.exists(zFileCSV) :
2049
       f = open(zFileCSV, "r")
2050
       while 1:
2051
             zText = f.readline()
2052
             if zText == "" : break
2053
             if zText.find(";")!=-1 :
2054
                zValue = zText.split(";")
2055
                zVal = zValue[1].replace("\"","").rstrip()
2056
                zListData.append("%s" % (zVal))
2057
                zMListData[i]= zValue[0].replace("\"","").rstrip()
2058
             else:
2059
                zVal = zText.replace("\"","").rstrip()
2060
                zListData.append("%s" (zVal))
2061
             i+= 1
2062
       f.close()
2063
    else:
2064
       if zType == "roles":
2065
           zItem0 = QtGui.QApplication.translate("QSphere","Owner", None, QtGui.QApplication.UnicodeUTF8)
2066
           zItem1 = QtGui.QApplication.translate("QSphere","Point of contact", None, QtGui.QApplication.UnicodeUTF8)
2067
           zListData = [zItem0, zItem1]
2068
           zMListData[0]="owner"
2069
           zMListData[1]="pointOfContact"
2070
       elif zType == "langues" :
2071
           zItem0 = QtGui.QApplication.translate("QSphere","French", None, QtGui.QApplication.UnicodeUTF8)
2072
           zListData = [zItem0, zItem0]
2073
           zMListData[0]="fra"
2074
           zMListData[1]="fre"
2075
       elif zType == "thesaurus":
2076
           zListData = ["GEMET INSPIRE Themes"]
2077
           zMListData[0]="2008-06-01"
2078
           
2079
    return zListData, zMListData
2080

    
2081
def LoadDefautValue(self, zFile):       
2082
    zPath = os.path.dirname(__file__)
2083
    zPath = zPath.replace("\\","/")
2084
    zFileCSV = zPath +zFile.replace("file:","")
2085
    zMListData = {}
2086
    i=0
2087

    
2088
    if os.path.exists(zFileCSV) :
2089
           f = open(zFileCSV, "r")
2090
           while 1:
2091
                 zText = f.readline()
2092
                 if zText == "" : break
2093
                 if zText.find(";")!=-1 :
2094
                    zValue = zText.split(";")
2095
                    zListData = []
2096
                    for j in range(len(zValue)):
2097
                        zVal = zValue[j].replace("\"","").rstrip()
2098
                        zListData.append("%s" % (zVal))
2099
                    zMListData[i] = zListData
2100
                 else:
2101
                    zListData = []
2102
                    zVal = zText.replace("\"","").rstrip()
2103
                    zListData.append("%s" % (zVal))
2104
                    zMListData[0] = zListData
2105
                 i+= 1
2106
           f.close()
2107
    return zMListData 
2108
   
2109

    
2110

    
(2-2/5)