Skip to content
Permalink
Browse files

Plugin Installer - revert last changes in order to keep the stable gui

git-svn-id: http://svn.osgeo.org/qgis/branches/Version-1_0@10363 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
borysiasty
borysiasty committed Mar 21, 2009
1 parent 0e1f397 commit 2e727ea48fdbe6f59cdd37eb8e89156e7809f15c
@@ -14,7 +14,7 @@ def name():
return "Plugin Installer"

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

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

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

def homepage():
return "http://bwj.aster.net.pl/qgis/"
@@ -200,7 +200,7 @@ QgsPluginInstallerDialog::foo()
// def ChangeCheckingPolicy

// def addKnownRepositories
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." )
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!" )
tr( "QGIS Python Plugin Installer" )

// def addRepository
@@ -43,7 +43,6 @@
"error_details" QString,
"homepage" QString,
"url" QString,
"experimental" bool
"filename" QString,
"repository" QString,
"localdir" QString,
@@ -84,7 +83,7 @@ def setIface(qgisIface):
("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", "")]
("GIS-Lab Repository", "http://gis-lab.info/programs/qgis/qgis-repo.xml", "")]


# --- class QPHttp ----------------------------------------------------------------------- #
@@ -97,8 +96,6 @@ 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)
@@ -238,48 +235,6 @@ 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"""
@@ -376,19 +331,15 @@ 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().simplified(),
"desc_repo" : pluginNodes.item(i).firstChildElement("description").text().trimmed(),
"desc_local" : "",
"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,
"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(),
"filename" : fileName,
"status" : "not installed",
"error" : "",
@@ -397,14 +348,14 @@ def xmlDownloaded(self,nr,state):
"repository" : reposName,
"localdir" : name,
"read-only" : False}
qgisMinimumVersion = pluginNodes.item(i).firstChildElement("qgis_minimum_version").text().simplified()
qgisMinimumVersion = pluginNodes.item(i).firstChildElement("qgis_minimum_version").text().trimmed()
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().simplified()
qgisMaximumVersion = pluginNodes.item(i).firstChildElement("qgis_maximum_version").text().trimmed()
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]==qgisMinimumVersion[0] or name=="plugin_installer" or (qgisMinimumVersion!="0" and qgisMaximumVersion!="2"):
if QGIS_VER[0]=="0" or qgisMinimumVersion[0]=="1" or name=="plugin_installer":
plugins.addPlugin(plugin)
plugins.workarounds()
self.mRepositories[reposName]["state"] = 2
@@ -418,7 +369,6 @@ def xmlDownloaded(self,nr,state):
# is the checking done?
if not self.fetchingInProgress():
plugins.getAllInstalled()
self.saveCheckingOnStartLastDate()
self.emit(SIGNAL("checkingDone()"))
# --- /class Repositories ---------------------------------------------------------------- #

@@ -552,7 +502,6 @@ def updatePlugin(self, key, readOnly):
"author" : auth,
"homepage" : homepage,
"url" : path,
"experimental" : False,
"filename" : "",
"status" : "",
"error" : error,
@@ -572,7 +521,6 @@ 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
@@ -262,27 +262,15 @@ 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)
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)
# checkingOnStart checkbox
self.connect(self.checkUpdates, SIGNAL("stateChanged (int)"), self.ChangeCheckingPolicy)
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)
self.checkUpdates.setCheckState(Qt.Checked)
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.checkUpdates.setCheckState(Qt.Unchecked)
self.buttonEditRep.setEnabled(False)
self.buttonDeleteRep.setEnabled(False)

self.populateMostWidgets()


@@ -340,32 +328,13 @@ def populateMostWidgets(self):
for i in [0,1,2]:
self.treeRepositories.resizeColumnToContents(i)
self.comboFilter1.addItem(self.tr("orphans"))
# fill the status filter comboBox
# filling 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)


# ----------------------------------------- #
@@ -389,17 +358,14 @@ 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

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


# ----------------------------------------- #
def changeCheckingPolicy(self,policy):
""" the Checking On Start checkbox has been clicked """
if policy:
def ChangeCheckingPolicy(self,policy):
if policy == Qt.Checked:
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 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.")
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!")
if QMessageBox.question(self, self.tr("QGIS Python Plugin Installer"), message, QMessageBox.Ok, QMessageBox.Abort) == QMessageBox.Ok:
repositories.addKnownRepos()
# refresh lists and populate widgets
@@ -745,13 +687,13 @@ def addRepository(self):
if not dlg.exec_():
return
for i in repositories.all().values():
if dlg.editURL.text().trimmed() == i["url"]:
if dlg.editURL.text() == 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().trimmed()
reposURL = dlg.editURL.text()
if repositories.all().has_key(reposName):
reposName = reposName + "(2)"
# add to settings
@@ -787,7 +729,7 @@ def editRepository(self):
if not dlg.exec_():
return # nothing to do if cancelled
for i in repositories.all().values():
if dlg.editURL.text().trimmed() == i["url"] and dlg.editURL.text().trimmed() != repositories.all()[reposName]["url"]:
if dlg.editURL.text() == i["url"] and dlg.editURL.text() != 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
@@ -797,9 +739,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().trimmed()))
settings.setValue(newName+"/url", QVariant(dlg.editURL.text()))
settings.setValue(newName+"/enabled", QVariant(bool(dlg.checkBoxEnabled.checkState())))
if dlg.editURL.text().trimmed() == repositories.all()[reposName]["url"] and dlg.checkBoxEnabled.checkState() == checkState[repositories.all()[reposName]["enabled"]]:
if dlg.editURL.text() == 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

0 comments on commit 2e727ea

Please sign in to comment.
You can’t perform that action at this time.