1
1
# -*- coding: utf-8 -*-
2
- """
3
- Copyright (C) 2008 Matthew Perry
2
+ """ "
3
+ Copyright (C) 2007- 2008 Matthew Perry
4
4
Copyright (C) 2008 Borys Jurgiel
5
5
6
6
/***************************************************************************
11
11
* (at your option) any later version. *
12
12
* *
13
13
***************************************************************************/
14
- """
14
+
15
+ This file contains some additional quote marks (for example in the lines 2 and 20), they are
16
+ for compatibility with lupdate, which doesn't properly recognize the comments in Python.
17
+ The use of lupdate instead of pylupdate is forced by integration with rest of QGIS files,
18
+ which are written mainly in C++. After editing this file make sure that lupdate and pylupdate
19
+ find the same number of strings and balance the quotemarks if doesn't.
20
+ " """
21
+
22
+
15
23
from PyQt4 .QtCore import *
16
24
from PyQt4 .QtGui import *
17
25
from qgis .core import QgsApplication , QgsContextHelp
@@ -30,7 +38,7 @@ def removeDir(path):
30
38
result = QString ()
31
39
if not QFile (path ).exists ():
32
40
result = QCoreApplication .translate ("QgsPluginInstaller" ,"Plugin directory doesn't exist: " ) + path
33
- elif QFile (path ).remove (): # if it's only link, just remove it without resolving.
41
+ elif QFile (path ).remove (): # if it is only link, just remove it without resolving.
34
42
#print " Link removing successfull: %s" % path
35
43
pass
36
44
else :
@@ -62,6 +70,9 @@ def removeDir(path):
62
70
63
71
64
72
# --- class QgsPluginInstallerFetchingDialog --------------------------------------------------------------- #
73
+ """ " C++ style header for compability with lupdate
74
+ QgsPluginInstallerFetchingDialog::foo(){
75
+ " """
65
76
class QgsPluginInstallerFetchingDialog (QDialog , Ui_QgsPluginInstallerFetchingDialog ):
66
77
# ----------------------------------------- #
67
78
def __init__ (self , parent ):
@@ -86,7 +97,7 @@ def __init__(self, parent):
86
97
87
98
# ----------------------------------------- #
88
99
def displayState (self ,key ,state ,state2 = None ):
89
- messages = [self .tr ("Done " ),self .tr ("Resolving host name..." ),self .tr ("Connecting..." ),self .tr ("Host connected. Sending request..." ),self .tr ("Downloading data..." ),self .tr ("Idle" ),self .tr ("Closing connection..." ),self .tr ("Error" )]
100
+ messages = [self .tr ("Success " ),self .tr ("Resolving host name..." ),self .tr ("Connecting..." ),self .tr ("Host connected. Sending request..." ),self .tr ("Downloading data..." ),self .tr ("Idle" ),self .tr ("Closing connection..." ),self .tr ("Error" )]
90
101
message = messages [state ]
91
102
if state2 :
92
103
message += " (%s%%)" % state2
@@ -107,13 +118,17 @@ def repositoryFetched(self, repoName):
107
118
self .displayState (repoName ,7 )
108
119
if not repositories .fetchingInProgress ():
109
120
self .close ()
121
+ # } - C++ style footer for compability with lupdate
110
122
# --- /class QgsPluginInstallerFetchingDialog -------------------------------------------------------------- #
111
123
112
124
113
125
114
126
115
127
116
128
# --- class QgsPluginInstallerRepositoryDialog ------------------------------------------------------------- #
129
+ """ " C++ style header for compability with lupdate
130
+ QgsPluginInstallerRepositoryDialog::foo(){
131
+ " """
117
132
class QgsPluginInstallerRepositoryDialog (QDialog , Ui_QgsPluginInstallerRepositoryDetailsDialog ):
118
133
# ----------------------------------------- #
119
134
def __init__ (self , parent = None ):
@@ -128,13 +143,17 @@ def __init__(self, parent=None):
128
143
def textChanged (self , string ):
129
144
enable = (self .editName .text ().count () > 0 and self .editURL .text ().count () > 0 )
130
145
self .buttonBox .button (QDialogButtonBox .Ok ).setEnabled (enable )
146
+ # } - C++ style footer for compability with lupdate
131
147
# --- /class QgsPluginInstallerRepositoryDialog ------------------------------------------------------------ #
132
148
133
149
134
150
135
151
136
152
137
153
# --- class QgsPluginInstallerInstallingDialog --------------------------------------------------------------- #
154
+ """ " C++ style header for compability with lupdate
155
+ QgsPluginInstallerInstallingDialog::foo(){
156
+ " """
138
157
class QgsPluginInstallerInstallingDialog (QDialog , Ui_QgsPluginInstallerInstallingDialog ):
139
158
# ----------------------------------------- #
140
159
def __init__ (self , parent , plugin ):
@@ -148,13 +167,13 @@ def __init__(self, parent, plugin):
148
167
self .connect (self .buttonBox , SIGNAL ("clicked(QAbstractButton*)" ), self .abort )
149
168
150
169
url = QUrl (plugin ["url" ])
151
- path = QString (url .toPercentEncoding (url .path (), "!$&'()*+,;=:@/ " ))
170
+ path = QString (url .toPercentEncoding (url .path (), "!$&'()*+,;=:/@ " ))
152
171
fileName = plugin ["filename" ]
153
172
#print "Retrieving from %s" % path
154
173
tmpDir = QDir .tempPath ()
155
174
tmpPath = QDir .cleanPath (tmpDir + "/" + fileName )
156
175
self .file = QFile (tmpPath )
157
- self .http = QHttp (url .host ())
176
+ self .http = QPHttp (url .host ())
158
177
self .connect (self .http , SIGNAL ("stateChanged ( int )" ), self .stateChanged )
159
178
self .connect (self .http , SIGNAL ("dataReadProgress ( int , int )" ), self .readProgress )
160
179
self .connect (self .http , SIGNAL ("requestFinished (int, bool)" ), self .requestFinished )
@@ -195,6 +214,10 @@ def requestFinished(self, requestId, state):
195
214
# make sure that the parent directory exists
196
215
if not QDir (pluginDir ).exists ():
197
216
QDir ().mkpath (pluginDir )
217
+
218
+ # if the target directory already exists as a link, remove the link without resolving:
219
+ QFile (pluginDir + QString (QDir .separator ())+ self .plugin ["localdir" ]).remove ()
220
+
198
221
#print "Extracting to plugin directory (%s)" % pluginDir
199
222
try :
200
223
un = unzip ()
@@ -221,28 +244,37 @@ def abort(self):
221
244
self .http .abort ()
222
245
self .mResult = self .tr ("Aborted by user" )
223
246
self .reject ()
247
+ # } - C++ style footer for compability with lupdate
224
248
# --- /class QgsPluginInstallerPluginErrorDialog ------------------------------------------------------------- #
225
249
226
250
227
251
228
252
229
253
230
254
# --- class QgsPluginInstallerPluginErrorDialog -------------------------------------------------------------- #
255
+ """ " C++ style header for compability with lupdate
256
+ QgsPluginInstallerPluginErrorDialog::foo(){
257
+ " """
231
258
class QgsPluginInstallerPluginErrorDialog (QDialog , Ui_QgsPluginInstallerPluginErrorDialog ):
232
259
# ----------------------------------------- #
233
260
def __init__ (self , parent , errorMessage ):
234
261
QDialog .__init__ (self , parent )
235
262
self .setupUi (self )
236
263
if not errorMessage :
237
- errorMessage = self .tr ("No error message received. Try to restart QGIS and ensure the plugin isn't installed under different name. If it is, contact the plugin author and submit this issue, please." )
264
+ errorMessage = self .tr ("No error message received. Try to restart QGIS and ensure the plugin isn't installed under a different name. If it is, contact the plugin author and submit this issue, please." )
238
265
self .textBrowser .setText (errorMessage )
266
+ # } - C++ style footer for compability with lupdate
239
267
# --- /class QgsPluginInstallerPluginErrorDialog ------------------------------------------------------------- #
240
268
241
269
242
270
243
271
244
272
273
+
245
274
# --- class QgsPluginInstallerDialog ------------------------------------------------------------------------- #
275
+ """ " C++ style header for compability with lupdate
276
+ QgsPluginInstallerDialog::foo(){
277
+ " """
246
278
class QgsPluginInstallerDialog (QDialog , Ui_QgsPluginInstallerDialog ):
247
279
# ----------------------------------------- #
248
280
def __init__ (self , parent , fl ):
@@ -296,6 +328,8 @@ def getAllAvailablePlugins(self):
296
328
for key in repositories .allUnavailable ():
297
329
QMessageBox .warning (self , self .tr ("QGIS Python Plugin Installer" ), self .tr ("Error reading repository: " ) + key + "\n " + repositories .all ()[key ]["error" ])
298
330
331
+ plugins .getAllInstalled ()
332
+
299
333
300
334
# ----------------------------------------- #
301
335
def populateMostWidgets (self ):
@@ -331,8 +365,8 @@ def populateMostWidgets(self):
331
365
# filling the status filter comboBox
332
366
self .comboFilter2 .clear ()
333
367
self .comboFilter2 .addItem (self .tr ("any status" ))
334
- self .comboFilter2 .addItem (self .tr ("not installed" ))
335
- self .comboFilter2 .addItem (self .tr ("installed" ))
368
+ self .comboFilter2 .addItem (self .tr ("not installed" , "plural" ))
369
+ self .comboFilter2 .addItem (self .tr ("installed" , "plural" ))
336
370
if plugins .isThereAnythingNew ():
337
371
self .comboFilter2 .addItem (self .tr ("upgradeable and news" ))
338
372
@@ -376,22 +410,22 @@ def populatePluginTree(self):
376
410
"installed" : self .tr ("This plugin is installed" ),
377
411
"upgradeable" : self .tr ("This plugin is installed, but there is an updated version available" ),
378
412
"orphan" : self .tr ("This plugin is installed, but I can't find it in any enabled repository" ),
379
- "new" : self .tr ("This plugin is not installed and is seen first time" ),
413
+ "new" : self .tr ("This plugin is not installed and is seen for the first time" ),
380
414
"newer" : self .tr ("This plugin is installed and is newer than its version available in a repository" ),
381
415
"invalid" : self .tr ("This plugin seems to be invalid or have unfulfilled dependencies\n It has been installed, but can't be loaded" )}
382
- status = {"not installed" : self .tr ("not installed" ),
383
- "installed" : self .tr ("installed" ),
384
- "upgradeable" : self .tr ("upgradeable" ),
385
- "orphan" : self .tr ("installed" ),
386
- "new" : self .tr ("new!" ),
387
- "newer" : self .tr ("installed" ),
388
- "invalid" : self .tr ("invalid" )}
416
+ status = {"not installed" : self .tr ("not installed" , "singular" ),
417
+ "installed" : self .tr ("installed" , "singular" ),
418
+ "upgradeable" : self .tr ("upgradeable" , "singular" ),
419
+ "orphan" : self .tr ("installed" , "singular" ),
420
+ "new" : self .tr ("new!" , "singular" ),
421
+ "newer" : self .tr ("installed" , "singular" ),
422
+ "invalid" : self .tr ("invalid" , "singular" )}
389
423
order = ["invalid" ,"upgradeable" ,"new" ,"not installed" ,"installed" ,"orphan" ,"newer" ]
390
424
def addItem (p ):
391
425
if self .filterCheck (p ):
392
426
statusTip = descrip [p ["status" ]]
393
427
if p ["read-only" ]:
394
- statusTip += "\n " + self .tr ("Note that it's installed in the read-only location and you can't uninstall it" )
428
+ statusTip += "\n " + self .tr ("Note that it's a core plugin and I can't uninstall it" )
395
429
if p ["status" ] == "upgradeable" :
396
430
ver = p ["version_inst" ] + " -> " + p ["version_avail" ]
397
431
elif p ["status" ] == "newer" :
@@ -405,15 +439,15 @@ def addItem(p):
405
439
elif p ["status" ] in ["not installed" , "new" ]:
406
440
vd = self .tr ("available version" ) + ": " + p ["version_avail" ]
407
441
elif p ["status" ] == "installed" :
408
- vd = self .tr ("installed version" ) + ": " + p ["version_inst" ] + "\n " + self .tr ("That's the newest available version. " )
442
+ vd = self .tr ("installed version" ) + ": " + p ["version_inst" ] + "\n " + self .tr ("That's the newest available version" )
409
443
elif p ["status" ] == "orphan" :
410
- vd = self .tr ("installed version" ) + ": " + p ["version_inst" ] + "\n " + self .tr ("There is no version available for download. " )
444
+ vd = self .tr ("installed version" ) + ": " + p ["version_inst" ] + "\n " + self .tr ("There is no version available for download" )
411
445
else :
412
446
vd = ""
413
447
if p ["status" ] == "invalid" :
414
448
p ["desc_local" ] = self .tr ("This plugin seems to be invalid or have unfulfilled dependencies" )
415
449
p ["desc_repo" ] = self .tr ("This plugin seems to be invalid or have unfulfilled dependencies\n It has been installed, but can't be loaded" )
416
- if p ["status" ] == "orphan" :
450
+ if not p ["repository" ] :
417
451
repository = self .tr ("only locally available" )
418
452
else :
419
453
repository = p ["repository" ]
@@ -467,7 +501,7 @@ def treeClicked(self):
467
501
""" the pluginsTree has been clicked """
468
502
buttons = {"not installed" :(True ,False ,self .tr ("Install plugin" )),
469
503
"installed" :(True ,True ,self .tr ("Reinstall plugin" )),
470
- "upgradeable" :(True ,True ,self .tr ("Upgrade plugin" , )),
504
+ "upgradeable" :(True ,True ,self .tr ("Upgrade plugin" )),
471
505
"orphan" :(False ,True ,self .tr ("Install/upgrade plugin" )),
472
506
"new" :(True , False ,self .tr ("Install plugin" )),
473
507
"newer" :(True ,True ,self .tr ("Downgrade plugin" )),
@@ -528,11 +562,9 @@ def installPlugin(self):
528
562
if result :
529
563
QMessageBox .warning (self , self .tr ("Plugin uninstall failed" ), result )
530
564
plugins .updatePlugin (key , False )
531
- self .populateMostWidgets ()
532
565
self .populatePluginTree ()
533
566
return
534
567
plugins .updatePlugin (key , False )
535
- self .populateMostWidgets ()
536
568
self .populatePluginTree ()
537
569
QMessageBox .information (self , infoString [0 ], infoString [1 ])
538
570
@@ -546,7 +578,6 @@ def uninstallPlugin(self):
546
578
plugin = plugins .all ()[key ]
547
579
if not plugin :
548
580
return
549
-
550
581
warning = self .tr ("Are you sure you want to uninstall the plugin " ) + plugin ["name" ] + "?"
551
582
if plugin ["status" ] == "orphan" :
552
583
warning += "\n \n " + self .tr ("Warning: this plugin isn't available in any accessible repository!" )
@@ -563,7 +594,7 @@ def uninstallPlugin(self):
563
594
exec ("del sys.modules[%s]" % plugin ["localdir" ])
564
595
except :
565
596
pass
566
- if plugin ["status" ] == "orphan" :
597
+ if not plugin ["repository" ] :
567
598
plugins .remove (key )
568
599
else :
569
600
plugins .setPluginData (key , "status" , "not installed" )
@@ -586,9 +617,8 @@ def ChangeCheckingPolicy(self,policy):
586
617
def addKnownRepositories (self ):
587
618
""" update list of known repositories - in the future it will be replaced with an online fetching """
588
619
#print "add known repositories"
589
- message = "You are going to add some plugin repositories neither authorized nor supported by the QGIS team, however provided by folks associated with us.\n "
590
- message += "Plugin authors generally make efforts to make their works useful and safe, but we can't assume any responsibility for them. FEEL WARNED!"
591
- if QMessageBox .question (self , self .tr ("QGIS Python Plugin Installer" ), self .tr (message ), QMessageBox .Ok , QMessageBox .Abort ) == QMessageBox .Ok :
620
+ message = self .tr ("You are going to add some plugin repositories neither authorized nor supported by the QGIS team, however provided by folks associated with us. Plugin authors generally make efforts to make their works useful and safe, but we can't assume any responsibility for them. FEEL WARNED!" )
621
+ if QMessageBox .question (self , self .tr ("QGIS Python Plugin Installer" ), message , QMessageBox .Ok , QMessageBox .Abort ) == QMessageBox .Ok :
592
622
repositories .addKnownRepos ()
593
623
# refresh lists and populate widgets
594
624
QApplication .setOverrideCursor (Qt .WaitCursor )
@@ -704,4 +734,5 @@ def reject(self):
704
734
""" update the list of seen plugins before exit (both 'done' and 'x' buttons emit 'reject' signal) """
705
735
plugins .updateSeenPluginsList ()
706
736
QDialog .reject (self )
737
+ # } - C++ style footer for compability with lupdate
707
738
# --- /class QgsPluginInstallerDialog ------------------------------------------------------------------------ #
0 commit comments