Plugin Installer update - prepare to merge with Plugin Manager

git-svn-id: http://svn.osgeo.org/qgis/trunk@10512 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
borysiasty 2009-04-09 00:19:51 +00:00
parent 0e882933b0
commit e104beb3bf
5 changed files with 79 additions and 10 deletions

View File

@ -14,7 +14,7 @@ def name():
return "Plugin Installer"
def version():
return "Version 0.9.12"
return "Version 0.9.14"
def description():
return "Downloads and installs QGIS python plugins"
@ -30,4 +30,4 @@ def homepage():
def classFactory(iface):
from installer_plugin import InstallerPlugin
return InstallerPlugin(iface)
return InstallerPlugin(iface)

View File

@ -87,6 +87,41 @@ authorRepos = [("Carson Farmer's Repository", "http://www.ftools.ca/cfarmerQgis
("GIS-Lab Repository", "http://gis-lab.info/programs/qgis/qgis-repo.xml", "")]
# --- class History ----------------------------------------------------------------------- #
class History(dict):
""" Dictionary for keeping changes made duging the session - will be used to complete the (un/re)loading """
# ----------------------------------------- #
def markChange(self, plugin, change):
""" mark the status change: A-added, D-deleted, R-reinstalled """
if change == "A" and self.get(plugin) == "D": # installation right after uninstallation
self.__setitem__(plugin, "R")
elif change == "A": # any other installation
self.__setitem__(plugin, "A")
elif change == "D" and self.get(plugin) == "A": # uninstallation right after installation
self.pop(plugin)
elif change == "D": # any other uninstallation
self.__setitem__(plugin, "D")
elif change == "R" and self.get(plugin) == "A": # reinstallation right after installation
self.__setitem__(plugin, "A")
elif change == "R": # any other reinstallation
self.__setitem__(plugin, "R")
# ----------------------------------------- #
def toList(self, change):
""" return a list of plugins matching the given change """
result = []
for i in self.items():
if i[1] == change:
result += [i[0]]
return result
# --- /class History ---------------------------------------------------------------------- #
# --- class QPHttp ----------------------------------------------------------------------- #
# --- It's a temporary workaround for broken proxy handling in Qt ------------------------- #
class QPHttp(QHttp):
@ -664,8 +699,7 @@ class Plugins(QObject):
# public members:
history = History()
repositories = Repositories()
plugins = Plugins()

View File

@ -592,11 +592,12 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialogBase):
plugin = plugins.all()[key]
if not plugin["error"]:
if previousStatus in ["not installed", "new"]:
infoString = (self.tr("Plugin installed successfully"),
self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
if QGIS_VER[0:3] == "1.1":
infoString = (self.tr("QGIS Python Plugin Installer"), self.tr("Plugin installed successfully"))
else:
infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
else:
infoString = (self.tr("Plugin reinstalled successfully"),
self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))
infoString = (self.tr("Plugin reinstalled successfully"), self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))
else:
if plugin["error"] == "incompatible":
message = self.tr("The plugin is designed for a newer version of Quantum GIS. The minimum required version is:")
@ -634,6 +635,12 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialogBase):
pass
if not plugin["repository"]:
plugins.remove(key)
if plugins.all().has_key(key) and not plugins.all()[key]["status"] in ["not installed", "new"]:
if previousStatus in ["not installed", "new"]:
history.markChange(key,'A')
else:
history.markChange(key,'R')
self.populatePluginTree()
if infoString[0]:
QMessageBox.information(self, infoString[0], infoString[1])
@ -678,6 +685,7 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialogBase):
plugins.setPluginData(key, "error_details", "")
self.populatePluginTree()
QMessageBox.information(self, self.tr("Plugin uninstalled successfully"), self.tr("Python plugin uninstalled. Note that you may need to restart Quantum GIS in order to remove it completely."))
history.markChange(key,'D')
# ----------------------------------------- #

View File

@ -41,6 +41,9 @@ class InstallerPlugin():
# ----------------------------------------- #
def getThemeIcon(self, theName):
""" get the icon from the best available theme """
if not QGIS_MAJOR_VER: # QGIS 0.x
return QIcon(":/plugins/installer/" + theName)
myCurThemePath = QgsApplication.activeThemePath() + "/plugins/" + theName;
myDefThemePath = QgsApplication.defaultThemePath() + "/plugins/" + theName;
myQrcPath = ":/plugins/installer/" + theName;
@ -160,3 +163,27 @@ class InstallerPlugin():
flags = Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMaximizeButtonHint
self.guiDlg = QgsPluginInstallerDialog(parent,flags)
self.guiDlg.show()
# ----------------------------------------- #
def newlyInstalledPlugins(self):
""" return the list of newly installed plugins for further loading """
return history.toList("A")
# ----------------------------------------- #
def newlyUninstalledPlugins(self):
""" return the list of newly uninstalled plugins for further unloading """
return history.toList("D")
# ----------------------------------------- #
def newlyReinstalledPlugins(self):
""" return the list of newly reinstalled plugins for further reloading """
return history.toList("R")
# ----------------------------------------- #
def resetNewlyProcessedPlugins(self):
""" clear the dict of newly processed plugins """
history.clear()

View File

@ -2,8 +2,8 @@
# Resource object code
#
# Created: sob. wrz 13 00:34:16 2008
# by: The Resource Compiler for PyQt (Qt v4.3.2)
# Created: wt. mar 24 00:35:11 2009
# by: The Resource Compiler for PyQt (Qt v4.4.3)
#
# WARNING! All changes made in this file will be lost!