Skip to content

Commit 0083d25

Browse files
author
borysiasty
committed
the plugin installer update
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10345 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent bb679fb commit 0083d25

File tree

6 files changed

+593
-209
lines changed

6 files changed

+593
-209
lines changed

python/plugins/plugin_installer/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def name():
1414
return "Plugin Installer"
1515

1616
def version():
17-
return "Version 0.9.8"
17+
return "Version 0.9.11"
1818

1919
def description():
2020
return "Downloads and installs QGIS python plugins"
@@ -23,7 +23,7 @@ def qgisMinimumVersion():
2323
return "0.9"
2424

2525
def authorName():
26-
return "perrygeo, borysiasty"
26+
return "Matthew Perry, Borys Jurgiel"
2727

2828
def homepage():
2929
return "http://bwj.aster.net.pl/qgis/"

python/plugins/plugin_installer/installer_data.py

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"error_details" QString,
4444
"homepage" QString,
4545
"url" QString,
46+
"experimental" bool
4647
"filename" QString,
4748
"repository" QString,
4849
"localdir" QString,
@@ -79,9 +80,11 @@ def setIface(qgisIface):
7980
contribRepo = ("QGIS Contributed Repository", "http://pyqgis.org/repo/contributed","")
8081
authorRepos = [("Carson Farmer's Repository", "http://www.ftools.ca/cfarmerQgisRepo.xml", "http://www.ftools.ca/cfarmerQgisRepo_0.xx.xml"),
8182
("Borys Jurgiel's Repository", "http://bwj.aster.net.pl/qgis/plugins.xml", "http://bwj.aster.net.pl/qgis-oldapi/plugins.xml"),
82-
("Faunalia Repository", "http://faunalia.it/qgis/plugins.xml", "http://faunalia.it/qgis/1.x/plugins.xml")]
83-
84-
83+
("Faunalia Repository", "http://www.faunalia.it/qgis/plugins.xml", "http://faunalia.it/qgis/plugins.xml"),
84+
("Martin Dobias' Sandbox", "http://mapserver.sk/~wonder/qgis/plugins-sandbox.xml", ""),
85+
("Aaron Racicot's Repository", "http://qgisplugins.z-pulley.com", ""),
86+
("Barry Rowlingson's Repository", "http://www.maths.lancs.ac.uk/~rowlings/Qgis/Plugins/plugins.xml", ""),
87+
("GIS-Lab Repository", "http://gis-lab.info/programs/qgis/qgis-repo.xml", "")]
8588

8689

8790
# --- class QPHttp ----------------------------------------------------------------------- #
@@ -94,6 +97,8 @@ def __init__(self,*args):
9497
if settings.value("/proxyEnabled").toBool():
9598
self.proxy=QNetworkProxy()
9699
proxyType = settings.value( "/proxyType", QVariant(0)).toString()
100+
if len(args)>0 and settings.value("/proxyExcludedUrls").toString().contains(args[0]):
101+
proxyType = "NoProxy"
97102
if proxyType in ["1","Socks5Proxy"]: self.proxy.setType(QNetworkProxy.Socks5Proxy)
98103
elif proxyType in ["2","NoProxy"]: self.proxy.setType(QNetworkProxy.NoProxy)
99104
elif proxyType in ["3","HttpProxy"]: self.proxy.setType(QNetworkProxy.HttpProxy)
@@ -233,6 +238,48 @@ def setCheckingOnStart(self, state):
233238
settings.setValue(settingsGroup+"/checkOnStart", QVariant(state))
234239

235240

241+
# ----------------------------------------- #
242+
def checkingOnStartInterval(self):
243+
""" return checking for news and updates interval """
244+
settings = QSettings()
245+
(i, ok) = settings.value(settingsGroup+"/checkOnStartInterval").toInt()
246+
if i < 0 or not ok:
247+
i = 1
248+
# allowed values: 0,1,3,7,14,30 days
249+
interval = 0
250+
for j in [1,3,7,14,30]:
251+
if i >= j:
252+
interval = j
253+
return interval
254+
255+
256+
# ----------------------------------------- #
257+
def setCheckingOnStartInterval(self, interval):
258+
""" set checking for news and updates interval """
259+
settings = QSettings()
260+
settings.setValue(settingsGroup+"/checkOnStartInterval", QVariant(interval))
261+
262+
263+
# ----------------------------------------- #
264+
def saveCheckingOnStartLastDate(self):
265+
""" set today's date as the day of last checking """
266+
settings = QSettings()
267+
settings.setValue(settingsGroup+"/checkOnStartLastDate", QVariant(QDate.currentDate()))
268+
269+
270+
# ----------------------------------------- #
271+
def timeForChecking(self):
272+
""" determine whether it's the time for checking for news and updates now """
273+
if self.checkingOnStartInterval() == 0:
274+
return True
275+
settings = QSettings()
276+
interval = settings.value(settingsGroup+"/checkOnStartLastDate").toDate().daysTo(QDate.currentDate())
277+
if interval >= self.checkingOnStartInterval():
278+
return True
279+
else:
280+
return False
281+
282+
236283
# ----------------------------------------- #
237284
def load(self):
238285
""" populate the mRepositories dict"""
@@ -329,15 +376,19 @@ def xmlDownloaded(self,nr,state):
329376
fileName = QFileInfo(pluginNodes.item(i).firstChildElement("download_url").text().trimmed()).fileName()
330377
name = fileName.section(".", 0, 0)
331378
name = str(name)
379+
experimental = False
380+
if pluginNodes.item(i).firstChildElement("experimental").text().simplified().toUpper() in ["TRUE","YES"]:
381+
experimental = True
332382
plugin = {}
333383
plugin[name] = {
334384
"name" : pluginNodes.item(i).toElement().attribute("name"),
335385
"version_avail" : pluginNodes.item(i).toElement().attribute("version"),
336-
"desc_repo" : pluginNodes.item(i).firstChildElement("description").text().trimmed(),
386+
"desc_repo" : pluginNodes.item(i).firstChildElement("description").text().simplified(),
337387
"desc_local" : "",
338-
"author" : pluginNodes.item(i).firstChildElement("author_name").text().trimmed(),
339-
"homepage" : pluginNodes.item(i).firstChildElement("homepage").text().trimmed(),
340-
"url" : pluginNodes.item(i).firstChildElement("download_url").text().trimmed(),
388+
"author" : pluginNodes.item(i).firstChildElement("author_name").text().simplified(),
389+
"homepage" : pluginNodes.item(i).firstChildElement("homepage").text().simplified(),
390+
"url" : pluginNodes.item(i).firstChildElement("download_url").text().simplified(),
391+
"experimental" : experimental,
341392
"filename" : fileName,
342393
"status" : "not installed",
343394
"error" : "",
@@ -346,14 +397,14 @@ def xmlDownloaded(self,nr,state):
346397
"repository" : reposName,
347398
"localdir" : name,
348399
"read-only" : False}
349-
qgisMinimumVersion = pluginNodes.item(i).firstChildElement("qgis_minimum_version").text().trimmed()
400+
qgisMinimumVersion = pluginNodes.item(i).firstChildElement("qgis_minimum_version").text().simplified()
350401
if not qgisMinimumVersion: qgisMinimumVersion = "0"
351402
# please use the tag below only if really needed! (for example if plugin development is abandoned)
352-
qgisMaximumVersion = pluginNodes.item(i).firstChildElement("qgis_maximum_version").text().trimmed()
403+
qgisMaximumVersion = pluginNodes.item(i).firstChildElement("qgis_maximum_version").text().simplified()
353404
if not qgisMaximumVersion: qgisMaximumVersion = "2"
354405
#if compatible, add the plugin to the list
355406
if compareVersions(QGIS_VER, qgisMinimumVersion) < 2 and compareVersions(qgisMaximumVersion, QGIS_VER) < 2:
356-
if QGIS_VER[0]=="0" or qgisMinimumVersion[0]=="1" or name=="plugin_installer":
407+
if QGIS_VER[0]==qgisMinimumVersion[0] or name=="plugin_installer" or (qgisMinimumVersion!="0" and qgisMaximumVersion!="2"):
357408
plugins.addPlugin(plugin)
358409
plugins.workarounds()
359410
self.mRepositories[reposName]["state"] = 2
@@ -367,6 +418,7 @@ def xmlDownloaded(self,nr,state):
367418
# is the checking done?
368419
if not self.fetchingInProgress():
369420
plugins.getAllInstalled()
421+
self.saveCheckingOnStartLastDate()
370422
self.emit(SIGNAL("checkingDone()"))
371423
# --- /class Repositories ---------------------------------------------------------------- #
372424

@@ -500,6 +552,7 @@ def updatePlugin(self, key, readOnly):
500552
"author" : auth,
501553
"homepage" : homepage,
502554
"url" : path,
555+
"experimental" : False,
503556
"filename" : "",
504557
"status" : "",
505558
"error" : error,
@@ -519,6 +572,7 @@ def updatePlugin(self, key, readOnly):
519572
self.mPlugins[key]["name"] = plugin["name"] # local name has higher priority
520573
self.mPlugins[key]["version_inst"] = plugin["version_inst"]
521574
self.mPlugins[key]["desc_local"] = plugin["desc_local"]
575+
self.mPlugins[key]["experimental"] = False
522576
# set status
523577
#
524578
# installed available status

python/plugins/plugin_installer/installer_gui.py

Lines changed: 75 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,27 @@ def __init__(self, parent, fl):
262262
self.connect(self.buttonAddRep, SIGNAL("clicked()"), self.addRepository)
263263
self.connect(self.buttonEditRep, SIGNAL("clicked()"), self.editRepository)
264264
self.connect(self.buttonDeleteRep, SIGNAL("clicked()"), self.deleteRepository)
265-
# checkingOnStart checkbox
266-
self.connect(self.checkUpdates, SIGNAL("stateChanged (int)"), self.ChangeCheckingPolicy)
267-
if repositories.checkingOnStart():
268-
self.checkUpdates.setCheckState(Qt.Checked)
269-
else:
270-
self.checkUpdates.setCheckState(Qt.Unchecked)
271265
self.buttonEditRep.setEnabled(False)
272266
self.buttonDeleteRep.setEnabled(False)
273-
267+
# configuration widgets
268+
self.connect(self.checkUpdates, SIGNAL("toggled (bool)"), self.changeCheckingPolicy)
269+
self.connect(self.comboInterval, SIGNAL("currentIndexChanged (int)"), self.changeCheckingInterval)
270+
self.connect(self.radioPluginType0, SIGNAL("toggled (bool)"), self.changePluginPolicy)
271+
self.connect(self.radioPluginType1, SIGNAL("toggled (bool)"), self.changePluginPolicy)
272+
self.connect(self.radioPluginType2, SIGNAL("toggled (bool)"), self.changePluginPolicy)
273+
if repositories.checkingOnStart():
274+
self.checkUpdates.setChecked(Qt.Checked)
275+
else:
276+
self.checkUpdates.setChecked(Qt.Unchecked)
277+
interval = repositories.checkingOnStartInterval()
278+
intervals = [0,1,3,7,14,30] # days
279+
if intervals.count(interval):
280+
index = intervals.index(interval)
281+
else:
282+
index = 1
283+
if QGIS_VER[0] == "0":
284+
self.label_2.setText("<b>Note: This functionality requires QGIS 1.0</b>")
285+
self.comboInterval.setCurrentIndex(index)
274286
self.populateMostWidgets()
275287

276288

@@ -328,13 +340,32 @@ def populateMostWidgets(self):
328340
for i in [0,1,2]:
329341
self.treeRepositories.resizeColumnToContents(i)
330342
self.comboFilter1.addItem(self.tr("orphans"))
331-
# filling the status filter comboBox
343+
# fill the status filter comboBox
332344
self.comboFilter2.clear()
333345
self.comboFilter2.addItem(self.tr("any status"))
334346
self.comboFilter2.addItem(self.tr("not installed", "plural"))
335347
self.comboFilter2.addItem(self.tr("installed", "plural"))
336348
if plugins.isThereAnythingNew():
337349
self.comboFilter2.addItem(self.tr("upgradeable and news"))
350+
#set configuration widgets (dependent on the repository list)
351+
if len(repositories.all()) == 1 or QGIS_VER[0] == "0":
352+
self.radioPluginType0.setEnabled(False)
353+
self.radioPluginType1.setEnabled(False)
354+
self.radioPluginType2.setEnabled(False)
355+
else:
356+
self.radioPluginType0.setEnabled(True)
357+
self.radioPluginType1.setEnabled(True)
358+
self.radioPluginType2.setEnabled(True)
359+
settings = QSettings()
360+
(i, ok) = settings.value(settingsGroup+"/allowedPluginType", QVariant(2)).toInt()
361+
if QGIS_VER[0] == "0":
362+
self.radioPluginType1.setChecked(Qt.Checked)
363+
elif i == 1 or len(repositories.all()) == 1:
364+
self.radioPluginType0.setChecked(Qt.Checked)
365+
elif i == 3:
366+
self.radioPluginType2.setChecked(Qt.Checked)
367+
else:
368+
self.radioPluginType1.setChecked(Qt.Checked)
338369

339370

340371
# ----------------------------------------- #
@@ -358,14 +389,17 @@ def filterCheck(self,plugin):
358389
return False
359390
if self.comboFilter2.currentIndex() == 3 and not plugin["status"] in ["upgradeable","new"]:
360391
return False
392+
if self.radioPluginType0.isChecked() and plugin["repository"] != officialRepo[0] and plugin["status"] in ["not installed","new"]:
393+
return False
394+
if self.radioPluginType1.isChecked() and plugin["experimental"] and plugin["status"] in ["not installed","new"]:
395+
return False
361396
if self.lineFilter.text() == "":
362397
return True
363398
else:
364399
for i in ["name","version_inst","version_avail","desc_repo","desc_local","author","status","repository"]:
365400
item = QString(plugin[i]) #.toUpper()
366401
if item != None:
367402
if item.contains(self.lineFilter.text(), Qt.CaseInsensitive):
368-
#if item.find(self.lineFilter.text().toUpper()) > -1:
369403
return True
370404
return False
371405

@@ -658,17 +692,41 @@ def repositoryTreeClicked(self):
658692

659693

660694
# ----------------------------------------- #
661-
def ChangeCheckingPolicy(self,policy):
662-
if policy == Qt.Checked:
695+
def changeCheckingPolicy(self,policy):
696+
""" the Checking On Start checkbox has been clicked """
697+
if policy:
663698
repositories.setCheckingOnStart(True)
664699
else:
665700
repositories.setCheckingOnStart(False)
666701

667702

703+
# ----------------------------------------- #
704+
def changeCheckingInterval(self,interval):
705+
""" the Checking on start interval combobox has been clicked """
706+
intervals = [0,1,3,7,14,30]
707+
repositories.setCheckingOnStartInterval(intervals[interval])
708+
709+
710+
# ----------------------------------------- #
711+
def changePluginPolicy(self, state):
712+
""" one of the plugin type radiobuttons has been clicked """
713+
if not state: # radio button released
714+
return
715+
if self.radioPluginType0.isChecked():
716+
i = 1
717+
elif self.radioPluginType1.isChecked():
718+
i = 2
719+
else:
720+
i = 3
721+
settings = QSettings()
722+
settings.setValue(settingsGroup+"/allowedPluginType", QVariant(i))
723+
self.populatePluginTree()
724+
725+
668726
# ----------------------------------------- #
669727
def addKnownRepositories(self):
670728
""" update list of known repositories - in the future it will be replaced with an online fetching """
671-
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!")
729+
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.")
672730
if QMessageBox.question(self, self.tr("QGIS Python Plugin Installer"), message, QMessageBox.Ok, QMessageBox.Abort) == QMessageBox.Ok:
673731
repositories.addKnownRepos()
674732
# refresh lists and populate widgets
@@ -687,13 +745,13 @@ def addRepository(self):
687745
if not dlg.exec_():
688746
return
689747
for i in repositories.all().values():
690-
if dlg.editURL.text() == i["url"]:
748+
if dlg.editURL.text().trimmed() == i["url"]:
691749
QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Unable to add another repository with the same URL!"))
692750
return
693751
settings = QSettings()
694752
settings.beginGroup(self.reposGroup)
695753
reposName = dlg.editName.text()
696-
reposURL = dlg.editURL.text()
754+
reposURL = dlg.editURL.text().trimmed()
697755
if repositories.all().has_key(reposName):
698756
reposName = reposName + "(2)"
699757
# add to settings
@@ -729,7 +787,7 @@ def editRepository(self):
729787
if not dlg.exec_():
730788
return # nothing to do if cancelled
731789
for i in repositories.all().values():
732-
if dlg.editURL.text() == i["url"] and dlg.editURL.text() != repositories.all()[reposName]["url"]:
790+
if dlg.editURL.text().trimmed() == i["url"] and dlg.editURL.text().trimmed() != repositories.all()[reposName]["url"]:
733791
QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Unable to add another repository with the same URL!"))
734792
return
735793
# delete old repo from QSettings and create new one
@@ -739,9 +797,9 @@ def editRepository(self):
739797
newName = dlg.editName.text()
740798
if repositories.all().has_key(newName) and newName != reposName:
741799
newName = newName + "(2)"
742-
settings.setValue(newName+"/url", QVariant(dlg.editURL.text()))
800+
settings.setValue(newName+"/url", QVariant(dlg.editURL.text().trimmed()))
743801
settings.setValue(newName+"/enabled", QVariant(bool(dlg.checkBoxEnabled.checkState())))
744-
if dlg.editURL.text() == repositories.all()[reposName]["url"] and dlg.checkBoxEnabled.checkState() == checkState[repositories.all()[reposName]["enabled"]]:
802+
if dlg.editURL.text().trimmed() == repositories.all()[reposName]["url"] and dlg.checkBoxEnabled.checkState() == checkState[repositories.all()[reposName]["enabled"]]:
745803
repositories.rename(reposName, newName)
746804
self.populateMostWidgets()
747805
return # nothing else to do if only repository name was changed

0 commit comments

Comments
 (0)