Skip to content

Commit

Permalink
the plugin installer update
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/Version-1_0@10346 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
borysiasty committed Mar 20, 2009
1 parent 0641eea commit 83fd64e
Show file tree
Hide file tree
Showing 6 changed files with 593 additions and 209 deletions.
4 changes: 2 additions & 2 deletions python/plugins/plugin_installer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def name():
return "Plugin Installer"

def version():
return "Version 0.9.8"
return "Version 0.9.11"

def description():
return "Downloads and installs QGIS python plugins"
Expand All @@ -23,7 +23,7 @@ def qgisMinimumVersion():
return "0.9"

def authorName():
return "perrygeo, borysiasty"
return "Matthew Perry, Borys Jurgiel"

def homepage():
return "http://bwj.aster.net.pl/qgis/"
Expand Down
74 changes: 64 additions & 10 deletions python/plugins/plugin_installer/installer_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"error_details" QString,
"homepage" QString,
"url" QString,
"experimental" bool
"filename" QString,
"repository" QString,
"localdir" QString,
Expand Down Expand Up @@ -79,9 +80,11 @@ def setIface(qgisIface):
contribRepo = ("QGIS Contributed Repository", "http://pyqgis.org/repo/contributed","")
authorRepos = [("Carson Farmer's Repository", "http://www.ftools.ca/cfarmerQgisRepo.xml", "http://www.ftools.ca/cfarmerQgisRepo_0.xx.xml"),
("Borys Jurgiel's Repository", "http://bwj.aster.net.pl/qgis/plugins.xml", "http://bwj.aster.net.pl/qgis-oldapi/plugins.xml"),
("Faunalia Repository", "http://faunalia.it/qgis/plugins.xml", "http://faunalia.it/qgis/1.x/plugins.xml")]


("Faunalia Repository", "http://www.faunalia.it/qgis/plugins.xml", "http://faunalia.it/qgis/plugins.xml"),
("Martin Dobias' Sandbox", "http://mapserver.sk/~wonder/qgis/plugins-sandbox.xml", ""),
("Aaron Racicot's Repository", "http://qgisplugins.z-pulley.com", ""),
("Barry Rowlingson's Repository", "http://www.maths.lancs.ac.uk/~rowlings/Qgis/Plugins/plugins.xml", ""),
("GIS-Lab Repository", "http://gis-lab.info/programs/qgis/qgis-repo.xml", "")]


# --- class QPHttp ----------------------------------------------------------------------- #
Expand All @@ -94,6 +97,8 @@ def __init__(self,*args):
if settings.value("/proxyEnabled").toBool():
self.proxy=QNetworkProxy()
proxyType = settings.value( "/proxyType", QVariant(0)).toString()
if len(args)>0 and settings.value("/proxyExcludedUrls").toString().contains(args[0]):
proxyType = "NoProxy"
if proxyType in ["1","Socks5Proxy"]: self.proxy.setType(QNetworkProxy.Socks5Proxy)
elif proxyType in ["2","NoProxy"]: self.proxy.setType(QNetworkProxy.NoProxy)
elif proxyType in ["3","HttpProxy"]: self.proxy.setType(QNetworkProxy.HttpProxy)
Expand Down Expand Up @@ -233,6 +238,48 @@ def setCheckingOnStart(self, state):
settings.setValue(settingsGroup+"/checkOnStart", QVariant(state))


# ----------------------------------------- #
def checkingOnStartInterval(self):
""" return checking for news and updates interval """
settings = QSettings()
(i, ok) = settings.value(settingsGroup+"/checkOnStartInterval").toInt()
if i < 0 or not ok:
i = 1
# allowed values: 0,1,3,7,14,30 days
interval = 0
for j in [1,3,7,14,30]:
if i >= j:
interval = j
return interval


# ----------------------------------------- #
def setCheckingOnStartInterval(self, interval):
""" set checking for news and updates interval """
settings = QSettings()
settings.setValue(settingsGroup+"/checkOnStartInterval", QVariant(interval))


# ----------------------------------------- #
def saveCheckingOnStartLastDate(self):
""" set today's date as the day of last checking """
settings = QSettings()
settings.setValue(settingsGroup+"/checkOnStartLastDate", QVariant(QDate.currentDate()))


# ----------------------------------------- #
def timeForChecking(self):
""" determine whether it's the time for checking for news and updates now """
if self.checkingOnStartInterval() == 0:
return True
settings = QSettings()
interval = settings.value(settingsGroup+"/checkOnStartLastDate").toDate().daysTo(QDate.currentDate())
if interval >= self.checkingOnStartInterval():
return True
else:
return False


# ----------------------------------------- #
def load(self):
""" populate the mRepositories dict"""
Expand Down Expand Up @@ -329,15 +376,19 @@ def xmlDownloaded(self,nr,state):
fileName = QFileInfo(pluginNodes.item(i).firstChildElement("download_url").text().trimmed()).fileName()
name = fileName.section(".", 0, 0)
name = str(name)
experimental = False
if pluginNodes.item(i).firstChildElement("experimental").text().simplified().toUpper() in ["TRUE","YES"]:
experimental = True
plugin = {}
plugin[name] = {
"name" : pluginNodes.item(i).toElement().attribute("name"),
"version_avail" : pluginNodes.item(i).toElement().attribute("version"),
"desc_repo" : pluginNodes.item(i).firstChildElement("description").text().trimmed(),
"desc_repo" : pluginNodes.item(i).firstChildElement("description").text().simplified(),
"desc_local" : "",
"author" : pluginNodes.item(i).firstChildElement("author_name").text().trimmed(),
"homepage" : pluginNodes.item(i).firstChildElement("homepage").text().trimmed(),
"url" : pluginNodes.item(i).firstChildElement("download_url").text().trimmed(),
"author" : pluginNodes.item(i).firstChildElement("author_name").text().simplified(),
"homepage" : pluginNodes.item(i).firstChildElement("homepage").text().simplified(),
"url" : pluginNodes.item(i).firstChildElement("download_url").text().simplified(),
"experimental" : experimental,
"filename" : fileName,
"status" : "not installed",
"error" : "",
Expand All @@ -346,14 +397,14 @@ def xmlDownloaded(self,nr,state):
"repository" : reposName,
"localdir" : name,
"read-only" : False}
qgisMinimumVersion = pluginNodes.item(i).firstChildElement("qgis_minimum_version").text().trimmed()
qgisMinimumVersion = pluginNodes.item(i).firstChildElement("qgis_minimum_version").text().simplified()
if not qgisMinimumVersion: qgisMinimumVersion = "0"
# please use the tag below only if really needed! (for example if plugin development is abandoned)
qgisMaximumVersion = pluginNodes.item(i).firstChildElement("qgis_maximum_version").text().trimmed()
qgisMaximumVersion = pluginNodes.item(i).firstChildElement("qgis_maximum_version").text().simplified()
if not qgisMaximumVersion: qgisMaximumVersion = "2"
#if compatible, add the plugin to the list
if compareVersions(QGIS_VER, qgisMinimumVersion) < 2 and compareVersions(qgisMaximumVersion, QGIS_VER) < 2:
if QGIS_VER[0]=="0" or qgisMinimumVersion[0]=="1" or name=="plugin_installer":
if QGIS_VER[0]==qgisMinimumVersion[0] or name=="plugin_installer" or (qgisMinimumVersion!="0" and qgisMaximumVersion!="2"):
plugins.addPlugin(plugin)
plugins.workarounds()
self.mRepositories[reposName]["state"] = 2
Expand All @@ -367,6 +418,7 @@ def xmlDownloaded(self,nr,state):
# is the checking done?
if not self.fetchingInProgress():
plugins.getAllInstalled()
self.saveCheckingOnStartLastDate()
self.emit(SIGNAL("checkingDone()"))
# --- /class Repositories ---------------------------------------------------------------- #

Expand Down Expand Up @@ -500,6 +552,7 @@ def updatePlugin(self, key, readOnly):
"author" : auth,
"homepage" : homepage,
"url" : path,
"experimental" : False,
"filename" : "",
"status" : "",
"error" : error,
Expand All @@ -519,6 +572,7 @@ def updatePlugin(self, key, readOnly):
self.mPlugins[key]["name"] = plugin["name"] # local name has higher priority
self.mPlugins[key]["version_inst"] = plugin["version_inst"]
self.mPlugins[key]["desc_local"] = plugin["desc_local"]
self.mPlugins[key]["experimental"] = False
# set status
#
# installed available status
Expand Down
92 changes: 75 additions & 17 deletions python/plugins/plugin_installer/installer_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,27 @@ def __init__(self, parent, fl):
self.connect(self.buttonAddRep, SIGNAL("clicked()"), self.addRepository)
self.connect(self.buttonEditRep, SIGNAL("clicked()"), self.editRepository)
self.connect(self.buttonDeleteRep, SIGNAL("clicked()"), self.deleteRepository)
# checkingOnStart checkbox
self.connect(self.checkUpdates, SIGNAL("stateChanged (int)"), self.ChangeCheckingPolicy)
if repositories.checkingOnStart():
self.checkUpdates.setCheckState(Qt.Checked)
else:
self.checkUpdates.setCheckState(Qt.Unchecked)
self.buttonEditRep.setEnabled(False)
self.buttonDeleteRep.setEnabled(False)

# configuration widgets
self.connect(self.checkUpdates, SIGNAL("toggled (bool)"), self.changeCheckingPolicy)
self.connect(self.comboInterval, SIGNAL("currentIndexChanged (int)"), self.changeCheckingInterval)
self.connect(self.radioPluginType0, SIGNAL("toggled (bool)"), self.changePluginPolicy)
self.connect(self.radioPluginType1, SIGNAL("toggled (bool)"), self.changePluginPolicy)
self.connect(self.radioPluginType2, SIGNAL("toggled (bool)"), self.changePluginPolicy)
if repositories.checkingOnStart():
self.checkUpdates.setChecked(Qt.Checked)
else:
self.checkUpdates.setChecked(Qt.Unchecked)
interval = repositories.checkingOnStartInterval()
intervals = [0,1,3,7,14,30] # days
if intervals.count(interval):
index = intervals.index(interval)
else:
index = 1
if QGIS_VER[0] == "0":
self.label_2.setText("<b>Note: This functionality requires QGIS 1.0</b>")
self.comboInterval.setCurrentIndex(index)
self.populateMostWidgets()


Expand Down Expand Up @@ -328,13 +340,32 @@ def populateMostWidgets(self):
for i in [0,1,2]:
self.treeRepositories.resizeColumnToContents(i)
self.comboFilter1.addItem(self.tr("orphans"))
# filling the status filter comboBox
# fill the status filter comboBox
self.comboFilter2.clear()
self.comboFilter2.addItem(self.tr("any status"))
self.comboFilter2.addItem(self.tr("not installed", "plural"))
self.comboFilter2.addItem(self.tr("installed", "plural"))
if plugins.isThereAnythingNew():
self.comboFilter2.addItem(self.tr("upgradeable and news"))
#set configuration widgets (dependent on the repository list)
if len(repositories.all()) == 1 or QGIS_VER[0] == "0":
self.radioPluginType0.setEnabled(False)
self.radioPluginType1.setEnabled(False)
self.radioPluginType2.setEnabled(False)
else:
self.radioPluginType0.setEnabled(True)
self.radioPluginType1.setEnabled(True)
self.radioPluginType2.setEnabled(True)
settings = QSettings()
(i, ok) = settings.value(settingsGroup+"/allowedPluginType", QVariant(2)).toInt()
if QGIS_VER[0] == "0":
self.radioPluginType1.setChecked(Qt.Checked)
elif i == 1 or len(repositories.all()) == 1:
self.radioPluginType0.setChecked(Qt.Checked)
elif i == 3:
self.radioPluginType2.setChecked(Qt.Checked)
else:
self.radioPluginType1.setChecked(Qt.Checked)


# ----------------------------------------- #
Expand All @@ -358,14 +389,17 @@ def filterCheck(self,plugin):
return False
if self.comboFilter2.currentIndex() == 3 and not plugin["status"] in ["upgradeable","new"]:
return False
if self.radioPluginType0.isChecked() and plugin["repository"] != officialRepo[0] and plugin["status"] in ["not installed","new"]:
return False
if self.radioPluginType1.isChecked() and plugin["experimental"] and plugin["status"] in ["not installed","new"]:
return False
if self.lineFilter.text() == "":
return True
else:
for i in ["name","version_inst","version_avail","desc_repo","desc_local","author","status","repository"]:
item = QString(plugin[i]) #.toUpper()
if item != None:
if item.contains(self.lineFilter.text(), Qt.CaseInsensitive):
#if item.find(self.lineFilter.text().toUpper()) > -1:
return True
return False

Expand Down Expand Up @@ -658,17 +692,41 @@ def repositoryTreeClicked(self):


# ----------------------------------------- #
def ChangeCheckingPolicy(self,policy):
if policy == Qt.Checked:
def changeCheckingPolicy(self,policy):
""" the Checking On Start checkbox has been clicked """
if policy:
repositories.setCheckingOnStart(True)
else:
repositories.setCheckingOnStart(False)


# ----------------------------------------- #
def changeCheckingInterval(self,interval):
""" the Checking on start interval combobox has been clicked """
intervals = [0,1,3,7,14,30]
repositories.setCheckingOnStartInterval(intervals[interval])


# ----------------------------------------- #
def changePluginPolicy(self, state):
""" one of the plugin type radiobuttons has been clicked """
if not state: # radio button released
return
if self.radioPluginType0.isChecked():
i = 1
elif self.radioPluginType1.isChecked():
i = 2
else:
i = 3
settings = QSettings()
settings.setValue(settingsGroup+"/allowedPluginType", QVariant(i))
self.populatePluginTree()


# ----------------------------------------- #
def addKnownRepositories(self):
""" update list of known repositories - in the future it will be replaced with an online fetching """
message = self.tr("You are going to add some plugin repositories neither authorized nor supported by the Quantum GIS 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!")
message = self.tr("You are about to add several plugin repositories that are neither authorized nor supported by the Quantum GIS team. Plugin authors generally make efforts to ensure that their work is useful and safe, however, we can assume no responsibility for them.")
if QMessageBox.question(self, self.tr("QGIS Python Plugin Installer"), message, QMessageBox.Ok, QMessageBox.Abort) == QMessageBox.Ok:
repositories.addKnownRepos()
# refresh lists and populate widgets
Expand All @@ -687,13 +745,13 @@ def addRepository(self):
if not dlg.exec_():
return
for i in repositories.all().values():
if dlg.editURL.text() == i["url"]:
if dlg.editURL.text().trimmed() == i["url"]:
QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Unable to add another repository with the same URL!"))
return
settings = QSettings()
settings.beginGroup(self.reposGroup)
reposName = dlg.editName.text()
reposURL = dlg.editURL.text()
reposURL = dlg.editURL.text().trimmed()
if repositories.all().has_key(reposName):
reposName = reposName + "(2)"
# add to settings
Expand Down Expand Up @@ -729,7 +787,7 @@ def editRepository(self):
if not dlg.exec_():
return # nothing to do if cancelled
for i in repositories.all().values():
if dlg.editURL.text() == i["url"] and dlg.editURL.text() != repositories.all()[reposName]["url"]:
if dlg.editURL.text().trimmed() == i["url"] and dlg.editURL.text().trimmed() != repositories.all()[reposName]["url"]:
QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Unable to add another repository with the same URL!"))
return
# delete old repo from QSettings and create new one
Expand All @@ -739,9 +797,9 @@ def editRepository(self):
newName = dlg.editName.text()
if repositories.all().has_key(newName) and newName != reposName:
newName = newName + "(2)"
settings.setValue(newName+"/url", QVariant(dlg.editURL.text()))
settings.setValue(newName+"/url", QVariant(dlg.editURL.text().trimmed()))
settings.setValue(newName+"/enabled", QVariant(bool(dlg.checkBoxEnabled.checkState())))
if dlg.editURL.text() == repositories.all()[reposName]["url"] and dlg.checkBoxEnabled.checkState() == checkState[repositories.all()[reposName]["enabled"]]:
if dlg.editURL.text().trimmed() == repositories.all()[reposName]["url"] and dlg.checkBoxEnabled.checkState() == checkState[repositories.all()[reposName]["enabled"]]:
repositories.rename(reposName, newName)
self.populateMostWidgets()
return # nothing else to do if only repository name was changed
Expand Down
Loading

0 comments on commit 83fd64e

Please sign in to comment.