Skip to content

Commit 7db2c91

Browse files
author
borysiasty
committed
Plugin Installer update: Files and classes renamed to better meet the QGIS coding standard
git-svn-id: http://svn.osgeo.org/qgis/trunk@9631 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e151de8 commit 7db2c91

14 files changed

+281
-252
lines changed

python/plugins/plugin_installer/CMakeLists.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#TODO: Need to configure cmake to run pyrcc4 and pyuic4 as required when the resource
22
# file or the ui change
33
SET(INSTALLER_FILES
4-
fetchingbase.py
5-
fetchingbase.ui
6-
guibase.py
7-
guibase.ui
84
__init__.py
95
installer_data.py
106
installer_gui.py
117
installer_plugin.py
12-
installingbase.py
13-
installingbase.ui
14-
pluginerrorbase.py
15-
pluginerrorbase.ui
168
plugin_installer.png
179
qgis-icon.png
10+
qgsplugininstallerbase.py
11+
qgsplugininstallerbase.ui
12+
qgsplugininstallerfetchingbase.py
13+
qgsplugininstallerfetchingbase.ui
14+
qgsplugininstallerinstallingbase.py
15+
qgsplugininstallerinstallingbase.ui
16+
qgsplugininstallerpluginerrorbase.py
17+
qgsplugininstallerpluginerrorbase.ui
18+
qgsplugininstallerrepositorybase.py
19+
qgsplugininstallerrepositorybase.ui
1820
repoConnected.png
1921
repoDisabled.png
20-
repositorybase.py
21-
repositorybase.ui
2222
repoUnavailable.png
2323
resources.qrc
2424
resources_rc.py

python/plugins/plugin_installer/i18n.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ file: installer_gui.py
6262
--------------------*/
6363

6464
// common functions
65-
translate("QgsPluginInstaller","Plugin directory doesn't exist:")
65+
translate("QgsPluginInstaller","Nothing to remove! Plugin directory doesn't exist:")
6666
translate("QgsPluginInstaller","Failed to remove the directory:")
6767
translate("QgsPluginInstaller","Check permissions or remove it manually")
6868

@@ -92,8 +92,7 @@ QgsPluginInstallerInstallingDialog::foo()
9292
tr("Error")
9393

9494
// def requestFinished
95-
tr("Failed to unzip file to the following directory:")
96-
tr("Check permissions")
95+
tr("Failed to unzip the plugin package. Probably it's broken or missing from the repository. You may also want to make sure that you have write permission to the plugin directory:")
9796

9897
// def abort
9998
tr("Aborted by user")
@@ -103,7 +102,7 @@ QgsPluginInstallerInstallingDialog::foo()
103102
QgsPluginInstallerPluginErrorDialog::foo()
104103
{
105104
// def __init__
106-
tr("No error message received. Try to restart Quantum GIS and ensure the plugin isn't installed under a different name. If it is, contact the plugin author and submit this issue, please.")
105+
tr("no error message received")
107106
}
108107

109108
QgsPluginInstallerDialog::foo()
@@ -174,7 +173,11 @@ QgsPluginInstallerDialog::foo()
174173
tr("Install/upgrade plugin")
175174

176175
// def installPlugin
176+
tr("QGIS Python Plugin Installer")
177+
tr("Are you sure you want to downgrade the plugin to the latest available version? The installed one is newer!")
177178
tr("Plugin installation failed")
179+
tr("Plugin has disappeared")
180+
tr("The plugin seems to have been installed but I don't know where. Probably the plugin package contained a wrong named directory.\nPlease search the list of installed plugins. I'm nearly sure you'll find the plugin there, but I just can't determine which of them it is. It also means that I won't be able to determine if this plugin is installed and inform you about available updates. However the plugin may work. Please contact the plugin author and submit this issue.")
178181
tr("Plugin installed successfully")
179182
tr("Python plugin installed.\nYou have to enable it in the Plugin Manager.")
180183
tr("Plugin installed successfully")

python/plugins/plugin_installer/installer_data.py

-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ def updatePlugin(self, key, readOnly):
463463
# same same "installed"
464464
# less greater "upgradeable"
465465
# greater less "newer"
466-
467466
if not self.mPlugins[key]["version_avail"]:
468467
self.mPlugins[key]["status"] = "orphan"
469468
elif self.mPlugins[key]["error"] == "broken":

python/plugins/plugin_installer/installer_gui.py

+68-41
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
from PyQt4.QtGui import *
1919
from qgis.core import QgsApplication, QgsContextHelp
2020
import sys, time
21-
from fetchingbase import Ui_QgsPluginInstallerFetchingDialog
22-
from installingbase import Ui_QgsPluginInstallerInstallingDialog
23-
from repositorybase import Ui_QgsPluginInstallerRepositoryDetailsDialog
24-
from pluginerrorbase import Ui_QgsPluginInstallerPluginErrorDialog
25-
from guibase import Ui_QgsPluginInstallerDialog
21+
from qgsplugininstallerfetchingbase import Ui_QgsPluginInstallerFetchingDialogBase
22+
from qgsplugininstallerinstallingbase import Ui_QgsPluginInstallerInstallingDialogBase
23+
from qgsplugininstallerrepositorybase import Ui_QgsPluginInstallerRepositoryDetailsDialogBase
24+
from qgsplugininstallerpluginerrorbase import Ui_QgsPluginInstallerPluginErrorDialogBase
25+
from qgsplugininstallerbase import Ui_QgsPluginInstallerDialogBase
2626
from installer_data import *
2727

2828

@@ -31,7 +31,7 @@
3131
def removeDir(path):
3232
result = QString()
3333
if not QFile(path).exists():
34-
result = QCoreApplication.translate("QgsPluginInstaller","Plugin directory doesn't exist:")+"\n"+path
34+
result = QCoreApplication.translate("QgsPluginInstaller","Nothing to remove! Plugin directory doesn't exist:")+"\n"+path
3535
elif QFile(path).remove(): # if it is only link, just remove it without resolving.
3636
#print " Link removing successfull: %s" % path
3737
pass
@@ -51,7 +51,7 @@ def removeDir(path):
5151
#print " Directory removing successfull: %s" % item
5252
pass
5353
if QFile(path).exists():
54-
result = QCoreApplication.translate("QgsPluginInstaller","Failed to remove the directory:")+" "+path+"\n"+QCoreApplication.translate("QgsPluginInstaller","Check permissions or remove it manually")
54+
result = QCoreApplication.translate("QgsPluginInstaller","Failed to remove the directory:")+"\n"+path+"\n"+QCoreApplication.translate("QgsPluginInstaller","Check permissions or remove it manually")
5555
# restore plugin directory if removed by QDir().rmpath()
5656
pluginDir = unicode(QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins")
5757
if not QDir(pluginDir).exists():
@@ -64,7 +64,7 @@ def removeDir(path):
6464

6565

6666
# --- class QgsPluginInstallerFetchingDialog --------------------------------------------------------------- #
67-
class QgsPluginInstallerFetchingDialog(QDialog, Ui_QgsPluginInstallerFetchingDialog):
67+
class QgsPluginInstallerFetchingDialog(QDialog, Ui_QgsPluginInstallerFetchingDialogBase):
6868
# ----------------------------------------- #
6969
def __init__(self, parent):
7070
QDialog.__init__(self, parent)
@@ -116,7 +116,7 @@ def repositoryFetched(self, repoName):
116116

117117

118118
# --- class QgsPluginInstallerRepositoryDialog ------------------------------------------------------------- #
119-
class QgsPluginInstallerRepositoryDialog(QDialog, Ui_QgsPluginInstallerRepositoryDetailsDialog):
119+
class QgsPluginInstallerRepositoryDialog(QDialog, Ui_QgsPluginInstallerRepositoryDetailsDialogBase):
120120
# ----------------------------------------- #
121121
def __init__(self, parent=None):
122122
QDialog.__init__(self, parent)
@@ -137,7 +137,7 @@ def textChanged(self, string):
137137

138138

139139
# --- class QgsPluginInstallerInstallingDialog --------------------------------------------------------------- #
140-
class QgsPluginInstallerInstallingDialog(QDialog, Ui_QgsPluginInstallerInstallingDialog):
140+
class QgsPluginInstallerInstallingDialog(QDialog, Ui_QgsPluginInstallerInstallingDialogBase):
141141
# ----------------------------------------- #
142142
def __init__(self, parent, plugin):
143143
QDialog.__init__(self, parent)
@@ -209,7 +209,7 @@ def requestFinished(self, requestId, state):
209209
removeDir(QDir.cleanPath(pluginDir+"/"+self.plugin["localdir"])) # remove old plugin if exists
210210
un.extract(tmpPath, pluginDir) # final extract.
211211
except:
212-
self.mResult = self.tr("Failed to unzip file to the following directory:") + "\n" + pluginDir + "\n" + self.tr("Check permissions")
212+
self.mResult = self.tr("Failed to unzip the plugin package. Probably it's broken or missing from the repository. You may also want to make sure that you have write permission to the plugin directory:") + "\n" + pluginDir
213213
self.reject()
214214
return
215215

@@ -234,13 +234,13 @@ def abort(self):
234234

235235

236236
# --- class QgsPluginInstallerPluginErrorDialog -------------------------------------------------------------- #
237-
class QgsPluginInstallerPluginErrorDialog(QDialog, Ui_QgsPluginInstallerPluginErrorDialog):
237+
class QgsPluginInstallerPluginErrorDialog(QDialog, Ui_QgsPluginInstallerPluginErrorDialogBase):
238238
# ----------------------------------------- #
239239
def __init__(self, parent, errorMessage):
240240
QDialog.__init__(self, parent)
241241
self.setupUi(self)
242242
if not errorMessage:
243-
errorMessage = self.tr("No error message received. Try to restart Quantum GIS and ensure the plugin isn't installed under a different name. If it is, contact the plugin author and submit this issue, please.")
243+
errorMessage = self.tr("no error message received")
244244
self.textBrowser.setText(errorMessage)
245245
# --- /class QgsPluginInstallerPluginErrorDialog ------------------------------------------------------------- #
246246

@@ -250,7 +250,7 @@ def __init__(self, parent, errorMessage):
250250

251251

252252
# --- class QgsPluginInstallerDialog ------------------------------------------------------------------------- #
253-
class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog):
253+
class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialogBase):
254254
# ----------------------------------------- #
255255
def __init__(self, parent, fl):
256256
QDialog.__init__(self, parent, fl)
@@ -260,8 +260,9 @@ def __init__(self, parent, fl):
260260
self.connect(self.lineFilter, SIGNAL("textChanged (QString)"), self.filterChanged)
261261
self.connect(self.comboFilter1, SIGNAL("currentIndexChanged (int)"), self.filterChanged)
262262
self.connect(self.comboFilter2, SIGNAL("currentIndexChanged (int)"), self.filterChanged)
263-
# grab the click on the treePlugins
264-
self.connect(self.treePlugins, SIGNAL("itemSelectionChanged()"), self.treeClicked)
263+
# grab clicks on trees
264+
self.connect(self.treePlugins, SIGNAL("itemSelectionChanged()"), self.pluginTreeClicked)
265+
self.connect(self.treeRepositories, SIGNAL("itemSelectionChanged()"), self.repositoryTreeClicked)
265266
# buttons
266267
self.connect(self.buttonInstall, SIGNAL("clicked()"), self.installPlugin)
267268
self.connect(self.buttonUninstall, SIGNAL("clicked()"), self.uninstallPlugin)
@@ -279,6 +280,8 @@ def __init__(self, parent, fl):
279280
self.checkUpdates.setCheckState(Qt.Checked)
280281
else:
281282
self.checkUpdates.setCheckState(Qt.Unchecked)
283+
self.buttonEditRep.setEnabled(False)
284+
self.buttonDeleteRep.setEnabled(False)
282285

283286
self.populateMostWidgets()
284287

@@ -498,17 +501,19 @@ def addItem(p):
498501

499502

500503
# ----------------------------------------- #
501-
def treeClicked(self):
504+
def pluginTreeClicked(self):
502505
""" the pluginsTree has been clicked """
503506
buttons={"not installed":(True,False,self.tr("Install plugin")),
504507
"installed":(True,True,self.tr("Reinstall plugin")),
505508
"upgradeable":(True,True,self.tr("Upgrade plugin")),
506509
"orphan":(False,True,self.tr("Install/upgrade plugin")),
507-
"new":(True, False,self.tr("Install plugin")),
510+
"new":(True,False,self.tr("Install plugin")),
508511
"newer":(True,True,self.tr("Downgrade plugin"))}
509512
self.buttonInstall.setEnabled(False)
510513
self.buttonInstall.setText(self.tr("Install/upgrade plugin"))
511514
self.buttonUninstall.setEnabled(False)
515+
if not self.treePlugins.selectedItems():
516+
return
512517
item = self.treePlugins.currentItem()
513518
if not item:
514519
return
@@ -535,36 +540,47 @@ def installPlugin(self):
535540
if not plugin:
536541
return
537542

543+
if plugin["status"] == "newer":
544+
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Are you sure you want to downgrade the plugin to the latest available version? The installed one is newer!"), QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
545+
return
546+
538547
dlg = QgsPluginInstallerInstallingDialog(self,plugin)
539548
dlg.exec_()
540549

541550
if dlg.result():
542551
infoString = (self.tr("Plugin installation failed"), dlg.result())
543552
else:
544-
try:
545-
exec ("sys.path_importer_cache.clear()")
546-
exec ("del sys.modules[%s]" % plugin["localdir"]) # remove old version if exist
547-
except:
548-
pass
549-
try:
550-
exec ("import %s" % plugin["localdir"])
551-
exec ("reload (%s)" % plugin["localdir"])
552-
if plugin["status"] == "not installed" or plugin["status"] == "new":
553-
infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nYou have to enable it in the Plugin Manager."))
554-
else:
555-
infoString = (self.tr("Plugin installed successfully"),self.tr("Python plugin reinstalled.\nYou have to restart Quantum GIS to reload it."))
556-
except Exception, error:
557-
dlg = QgsPluginInstallerPluginErrorDialog(self,error.message)
558-
dlg.exec_()
559-
if dlg.result():
560-
pluginDir = unicode(QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins/"+ str(plugin["localdir"]))
561-
result = removeDir(pluginDir)
562-
if result:
563-
QMessageBox.warning(self, self.tr("Plugin uninstall failed"), result)
553+
path = QDir.cleanPath(QgsApplication.qgisSettingsDirPath() + "/python/plugins/" + key)
554+
if not QDir(path).exists():
555+
infoString = (self.tr("Plugin has disappeared"), self.tr("The plugin seems to have been installed but I don't know where. Probably the plugin package contained a wrong named directory.\nPlease search the list of installed plugins. I'm nearly sure you'll find the plugin there, but I just can't determine which of them it is. It also means that I won't be able to determine if this plugin is installed and inform you about available updates. However the plugin may work. Please contact the plugin author and submit this issue."))
556+
QApplication.setOverrideCursor(Qt.WaitCursor)
557+
self.getAllAvailablePlugins()
558+
QApplication.restoreOverrideCursor()
559+
else:
560+
try:
561+
exec ("sys.path_importer_cache.clear()")
562+
exec ("del sys.modules[%s]" % plugin["localdir"]) # remove old version if exist
563+
except:
564+
pass
565+
try:
566+
exec ("import %s" % plugin["localdir"])
567+
exec ("reload (%s)" % plugin["localdir"])
568+
if plugin["status"] == "not installed" or plugin["status"] == "new":
569+
infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nYou have to enable it in the Plugin Manager."))
570+
else:
571+
infoString = (self.tr("Plugin installed successfully"),self.tr("Python plugin reinstalled.\nYou have to restart Quantum GIS to reload it."))
572+
except Exception, error:
573+
dlg = QgsPluginInstallerPluginErrorDialog(self,error.message)
574+
dlg.exec_()
575+
if dlg.result():
576+
pluginDir = unicode(QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins/"+ str(plugin["localdir"]))
577+
result = removeDir(pluginDir)
578+
if result:
579+
QMessageBox.warning(self, self.tr("Plugin uninstall failed"), result)
580+
plugins.updatePlugin(key, False)
581+
self.populatePluginTree()
582+
return
564583
plugins.updatePlugin(key, False)
565-
self.populatePluginTree()
566-
return
567-
plugins.updatePlugin(key, False)
568584
self.populatePluginTree()
569585
QMessageBox.information(self, infoString[0], infoString[1])
570586

@@ -605,6 +621,17 @@ def uninstallPlugin(self):
605621
QMessageBox.information(self, self.tr("QGIS Python Plugin Installer"), self.tr("Plugin uninstalled successfully"))
606622

607623

624+
# ----------------------------------------- #
625+
def repositoryTreeClicked(self):
626+
""" the repositoryTree has been clicked """
627+
if self.treeRepositories.selectedItems():
628+
self.buttonEditRep.setEnabled(True)
629+
self.buttonDeleteRep.setEnabled(True)
630+
else:
631+
self.buttonEditRep.setEnabled(False)
632+
self.buttonDeleteRep.setEnabled(False)
633+
634+
608635
# ----------------------------------------- #
609636
def ChangeCheckingPolicy(self,policy):
610637
if policy == Qt.Checked:

0 commit comments

Comments
 (0)