Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Plugin Installer update - prepare to merge with Plugin Manager
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10512 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
borysiasty committed Apr 9, 2009
1 parent d2e4498 commit af6275c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 10 deletions.
4 changes: 2 additions & 2 deletions python/plugins/plugin_installer/__init__.py
Expand Up @@ -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"
Expand All @@ -30,4 +30,4 @@ def homepage():

def classFactory(iface):
from installer_plugin import InstallerPlugin
return InstallerPlugin(iface)
return InstallerPlugin(iface)
38 changes: 36 additions & 2 deletions python/plugins/plugin_installer/installer_data.py
Expand Up @@ -87,6 +87,41 @@ def setIface(qgisIface):
("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):
Expand Down Expand Up @@ -664,8 +699,7 @@ def workarounds(self):





# public members:
history = History()
repositories = Repositories()
plugins = Plugins()
16 changes: 12 additions & 4 deletions python/plugins/plugin_installer/installer_gui.py
Expand Up @@ -592,11 +592,12 @@ def installPlugin(self):
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:")
Expand Down Expand Up @@ -634,6 +635,12 @@ def installPlugin(self):
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])
Expand Down Expand Up @@ -678,6 +685,7 @@ def uninstallPlugin(self):
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')


# ----------------------------------------- #
Expand Down
27 changes: 27 additions & 0 deletions python/plugins/plugin_installer/installer_plugin.py
Expand Up @@ -41,6 +41,9 @@ def setCurrentTheme(self, theThemeName):
# ----------------------------------------- #
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;
Expand Down Expand Up @@ -160,3 +163,27 @@ def run(self, parent = None):
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()
4 changes: 2 additions & 2 deletions python/plugins/plugin_installer/resources_rc.py
Expand Up @@ -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!

Expand Down

0 comments on commit af6275c

Please sign in to comment.