Updates for Borys and added some missing files

git-svn-id: http://svn.osgeo.org/qgis/trunk@9310 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2008-09-12 22:19:54 +00:00
parent 9b5849d65b
commit 0715a13804
14 changed files with 272 additions and 69 deletions

View File

@ -2,30 +2,33 @@
# file or the ui change
SET(INSTALLER_FILES
dialog.py
fetchingbase.py
fetchingbase.ui
guibase.py
guibase.ui
gui.py
icon.xpm
__init__.py
installer_plugin.py
qgis_plugins.py
resources.py
repository_ui.py
repository_dialog.py
qgis-icon.png
installingbase.ui
fetchingbase.py
guibase.py
repositorybase.py
plugin_installer.png
unzip.py
installer_gui.py
installingbase.py
pluginerrorbase.ui
installer_data.py
repoConnected.png
guibase.ui
installer_gui.py
installer_plugin.py
installingbase.py
installingbase.ui
pluginerrorbase.py
repositorybase.ui
resources_rc.py
pluginerrorbase.ui
plugin_installer.png
PluginInstaller.png
qgis-icon.png
qgis_plugins.py
repoConnected.png
repoDisabled.png
repositorybase.py
repositorybase.ui
repository_dialog.py
repository_ui.py
repoUnavailable.png
resources.py
resources_rc.py
unzip.py
)
INSTALL(FILES ${INSTALLER_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/plugin_installer)

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -20,7 +20,7 @@ def author_name():
return "perrygeo, borysiasty"
def version():
return "Version 0.05.6"
return "Version 0.06.1"
def classFactory(iface):
from installer_plugin import InstallerPlugin

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'fetchingbase.ui'
#
# Created: Sun Sep 7 16:22:19 2008
# Created: Fri Sep 12 19:21:37 2008
# by: PyQt4 UI code generator 4.3
#
# WARNING! All changes made in this file will be lost!

View File

@ -0,0 +1,200 @@
<ui version="4.0" >
<author>Matthew Perry, Borys Jurgiel</author>
<class>QgsPluginInstallerFetchingDialog</class>
<widget class="QDialog" name="QgsPluginInstallerFetchingDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>521</width>
<height>332</height>
</rect>
</property>
<property name="windowTitle" >
<string>Fetching repositories</string>
</property>
<property name="windowIcon" >
<iconset resource="resources.qrc" >:/plugins/installer/qgis-icon.png</iconset>
</property>
<layout class="QGridLayout" >
<item row="1" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>249</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label1" >
<property name="text" >
<string>Overall progress:</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QProgressBar" name="progressBar" >
<property name="value" >
<number>24</number>
</property>
<property name="alignment" >
<set>Qt::AlignHCenter</set>
</property>
<property name="textDirection" >
<enum>QProgressBar::TopToBottom</enum>
</property>
<property name="format" >
<string/>
</property>
</widget>
</item>
<item row="4" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>248</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0" >
<layout class="QHBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>140</width>
<height>27</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonSkip" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy" >
<enum>Qt::NoFocus</enum>
</property>
<property name="text" >
<string>Abort fetching</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
<property name="default" >
<bool>false</bool>
</property>
<property name="flat" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>140</width>
<height>27</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0" >
<widget class="QTreeWidget" name="treeWidget" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="horizontalScrollBarPolicy" >
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="showDropIndicator" stdset="0" >
<bool>false</bool>
</property>
<property name="selectionMode" >
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="horizontalScrollMode" >
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="rootIsDecorated" >
<bool>false</bool>
</property>
<property name="itemsExpandable" >
<bool>false</bool>
</property>
<column>
<property name="text" >
<string>Repository</string>
</property>
</column>
<column>
<property name="text" >
<string>State</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="resources.qrc" />
</resources>
<connections>
<connection>
<sender>buttonSkip</sender>
<signal>clicked()</signal>
<receiver>QgsPluginInstallerFetchingDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>350</x>
<y>321</y>
</hint>
<hint type="destinationlabel" >
<x>250</x>
<y>76</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'guibase.ui'
#
# Created: Sun Sep 7 21:28:01 2008
# Created: Fri Sep 12 19:21:37 2008
# by: PyQt4 UI code generator 4.3
#
# WARNING! All changes made in this file will be lost!

View File

@ -229,7 +229,6 @@ class Repositories(QObject):
# ----------------------------------------- #
def xmlDownloaded(self,nr,state):
#print reposName, nr, state
if not self.httpId.has_key(nr):
return
reposName = self.httpId[nr]
@ -296,8 +295,8 @@ class Plugins(QObject):
# ----------------------------------------- #
def firstByName(self, name):
plugins = [i for i in self.mPlugins if self.mPlugins[i]["name"] == name]
def keyByUrl(self, name):
plugins = [i for i in self.mPlugins if self.mPlugins[i]["url"] == name]
if plugins:
return plugins[0]
return None
@ -420,6 +419,11 @@ class Plugins(QObject):
self.mPlugins[key] = plugin # add the plugin if not present yet or if is newer than existing one
# ----------------------------------------- #
def remove(self, key):
del self.mPlugins[key]
# ----------------------------------------- #
def updatePlugin(self, key, readOnly):
try:
@ -452,6 +456,11 @@ class Plugins(QObject):
desc = ""
auth = ""
homepage = ""
if readOnly:
path = QgsApplication.pkgDataPath()
else:
path = QgsApplication.qgisSettingsDirPath()
path = QDir.cleanPath(unicode(path,"utf-8") + "python/plugins/" + key)
normVer = self.normalizeVersion(QString(ver))
plugin = {
"name" : nam,
@ -461,7 +470,7 @@ class Plugins(QObject):
"desc_repo" : "",
"author" : auth,
"homepage" : homepage,
"url" : "",
"url" : path,
"filename" : "",
"status" : stat,
"repository" : "",
@ -478,10 +487,6 @@ class Plugins(QObject):
self.mPlugins[key]["name"] = plugin["name"] # local name has higher priority, except invalid plugins
self.mPlugins[key]["version_inst"] = plugin["version_inst"]
self.mPlugins[key]["desc_local"] = plugin["desc_local"]
if plugin["author"]:
self.mPlugins[key]["author"] = plugin["author"] #local author name has higher priority, if exists
if plugin["homepage"]:
self.mPlugins[key]["homepage"] = plugin["homepage"] # local homepage adress has higher priority, if exists
# set status
#
# installed available status
@ -509,7 +514,6 @@ class Plugins(QObject):
# ----------------------------------------- #
def getAllInstalled(self):
""" update the mPlugins dict with alredy installed plugins """
#print "getting list of installed plugins"
# first, try to add the read-only plugins...
try:
pluginDir = QDir.cleanPath(unicode(QgsApplication.pkgDataPath(),'utf-8') + "/python/plugins")
@ -537,7 +541,6 @@ class Plugins(QObject):
# ----------------------------------------- #
def markNews(self):
""" mark all new plugins as new """
#print "marking the new plugins"
settings = QSettings()
seenPlugins = settings.value(seenPluginGroup, QVariant(QStringList(self.mPlugins.keys()))).toStringList()
if len(seenPlugins) > 0:
@ -549,7 +552,6 @@ class Plugins(QObject):
# ----------------------------------------- #
def updateSeenPluginsList(self):
""" update the list of all seen plugins """
#print "updating the list of seen plugins"
settings = QSettings()
seenPlugins = settings.value(seenPluginGroup, QVariant(QStringList(self.mPlugins.keys()))).toStringList()
for i in self.mPlugins.keys():

View File

@ -15,7 +15,7 @@ Copyright (C) 2008 Borys Jurgiel
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import QgsApplication, QgsContextHelp
import sys
import sys, time
from fetchingbase import Ui_QgsPluginInstallerFetchingDialog
from installingbase import Ui_QgsPluginInstallerInstallingDialog
from repositorybase import Ui_QgsPluginInstallerRepositoryDetailsDialog
@ -24,6 +24,7 @@ from guibase import Ui_QgsPluginInstallerDialog
from installer_data import *
# --- common functions ------------------------------------------------------------------- #
def removeDir(path):
result = QString()
@ -44,11 +45,15 @@ def removeDir(path):
iterator = QDirIterator(path, fltr, QDirIterator.Subdirectories)
while iterator.hasNext():
item = iterator.next()
if QDir(item).rmpath("."):
if QDir().rmpath(item):
#print " Directory removing successfull: %s" % item
pass
if QFile(path).exists():
result = QCoreApplication.translate("QgsPluginInstaller","Failed to remove directory")+" "+path+" \n"+QCoreApplication.translate("QgsPluginInstaller","Check permissions or remove it manually")
# restore plugin directory if removed by QDir().rmpath()
pluginDir = unicode(QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins")
if not QDir(pluginDir).exists():
QDir().mkpath(pluginDir)
return result
# --- /common functions ------------------------------------------------------------------ #
@ -189,23 +194,18 @@ class QgsPluginInstallerInstallingDialog(QDialog, Ui_QgsPluginInstallerInstallin
# make sure that the parent directory exists
if not QDir(pluginDir).exists():
QDir(pluginDir).mkpath(".")
QDir().mkpath(pluginDir)
#print "Extracting to plugin directory (%s)" % pluginDir
#try:
un = unzip()
un.extract(tmpPath, pluginDir) # test extract. If fails, then exception will be raised and no removing occurs
#print "Removing old plugin files if exist"
removeDir(QDir.cleanPath(pluginDir+"/"+self.plugin["localdir"])) # remove old plugin if exists
un.extract(tmpPath, pluginDir) # final extract.
#except:
#self.mResult = self.tr("Failed to unzip file to ") + pluginDir + "\n" + self.tr("check permissions")
#self.reject()
#return
try:
un = unzip()
un.extract(tmpPath, pluginDir) # test extract. If fails, then exception will be raised and no removing occurs
#print "Removing old plugin files if exist"
removeDir(QDir.cleanPath(pluginDir+"/"+self.plugin["localdir"])) # remove old plugin if exists
un.extract(tmpPath, pluginDir) # final extract.
except:
self.mResult = self.tr("Failed to unzip file to ") + pluginDir + "\n" + self.tr("check permissions")
self.reject()
return
try:
#print "Cleaning: removing the zip file (%s)" % tmpPath
@ -414,13 +414,8 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog):
p["desc_local"] = self.tr("This plugin seems to be invalid or have unfulfilled dependencies")
p["desc_repo"] = self.tr("This plugin seems to be invalid or have unfulfilled dependencies\nIt has been installed, but can't be loaded")
if p["status"] == "orphan":
if p["read-only"]:
url = unicode(QgsApplication.pkgDataPath(),'utf-8') + "/python/plugins/" + p["localdir"]
else:
url = unicode(QgsApplication.qgisSettingsDirPath(),'utf-8') + "/python/plugins/" + p["localdir"]
repository = self.tr("only locally available")
else:
url = p["url"]
repository = p["repository"]
if not p["desc_local"]:
p["desc_local"] = p["desc_repo"]
@ -438,7 +433,7 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog):
else:
a.setToolTip(4,"")
a.setText(5,repository)
a.setToolTip(5,url)
a.setToolTip(5,p["url"])
# set fonts and colours
for i in [0,1,2,3,4,5]:
if p["status"] == "invalid":
@ -483,7 +478,7 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog):
item = self.treePlugins.currentItem()
if not item:
return
key = plugins.firstByName(item.text(1))
key = plugins.keyByUrl(item.toolTip(5))
if not key:
return
plugin = plugins.all()[key]
@ -501,7 +496,7 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog):
""" install currently selected plugin """
if not self.treePlugins.currentItem():
return
key = plugins.firstByName(self.treePlugins.currentItem().text(1))
key = plugins.keyByUrl(self.treePlugins.currentItem().toolTip(5))
plugin = plugins.all()[key]
if not plugin:
return
@ -547,7 +542,7 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog):
""" uninstall currently selected plugin """
if not self.treePlugins.currentItem():
return
key = plugins.firstByName(self.treePlugins.currentItem().text(1))
key = plugins.keyByUrl(self.treePlugins.currentItem().toolTip(5))
plugin = plugins.all()[key]
if not plugin:
return
@ -568,9 +563,12 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog):
exec ("del sys.modules[%s]" % plugin["localdir"])
except:
pass
plugins.setPluginData(key, "status", "not installed")
plugins.setPluginData(key, "version_inst", "")
plugins.setPluginData(key, "desc_local", "")
if plugin["status"] == "orphan":
plugins.remove(key)
else:
plugins.setPluginData(key, "status", "not installed")
plugins.setPluginData(key, "version_inst", "")
plugins.setPluginData(key, "desc_local", "")
self.populatePluginTree()
QApplication.restoreOverrideCursor()
QMessageBox.information(self, self.tr("QGIS Python Plugin Installer"), self.tr("Plugin uninstalled successfully"))

View File

@ -33,14 +33,14 @@ class InstallerPlugin:
# ----------------------------------------- #
def initGui(self):
""" create action that will start plugin window and then add it to menu """
self.action = QAction(QIcon(":/plugins/installer/PluginInstaller.png"), QCoreApplication.translate("QgsPluginInstaller","Plugin Installer..."), self.mainWindow())
self.action = QAction(QIcon(":/plugins/installer/PluginInstaller.png"), QCoreApplication.translate("QgsPluginInstaller","Fetch Python Plugins..."), self.mainWindow())
self.action.setWhatsThis(QCoreApplication.translate("QgsPluginInstaller","Install more plugins from remote repositories"))
self.action.setStatusTip(QCoreApplication.translate("QgsPluginInstaller","Install more plugins from remote repositories"))
if str(QGis.qgisVersion)[0] == "0":
nextAction = self.mainWindow().menuBar().actions()[4].menu().actions()[1]
self.mainWindow().menuBar().actions()[4].menu().insertAction(nextAction,self.action)
else:
nextAction = self.iface.actionPluginSeparator1()
nextAction = self.iface.actionManagePlugins() #actionPluginSeparator1()
self.iface.pluginMenu().insertAction(nextAction,self.action)
QObject.connect(self.action, SIGNAL("activated()"), self.run)
self.statusLabel = None

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'installingbase.ui'
#
# Created: Sun Sep 7 16:22:38 2008
# Created: Fri Sep 12 19:21:37 2008
# by: PyQt4 UI code generator 4.3
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'pluginerrorbase.ui'
#
# Created: Sun Sep 7 16:22:47 2008
# Created: Fri Sep 12 19:21:37 2008
# by: PyQt4 UI code generator 4.3
#
# WARNING! All changes made in this file will be lost!

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'repositorybase.ui'
#
# Created: Tue Sep 9 00:09:51 2008
# Created: Fri Sep 12 19:21:37 2008
# by: PyQt4 UI code generator 4.3
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Resource object code
#
# Created: ?r. wrz 3 18:43:47 2008
# Created: pt. wrz 12 19:21:37 2008
# by: The Resource Compiler for PyQt (Qt v4.3.2)
#
# WARNING! All changes made in this file will be lost!