2 changes: 1 addition & 1 deletion python/plugins/GdalTools/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name=GdalTools
description=Integrate GDAL tools into QGIS
category=Raster
version=1.2.29
qgisMinimumVersion=1.0
qgisMinimumVersion=2.0

author=Giuseppe Sucameli (Faunalia)
email=brush.tyler@gmail.com
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name=DB Manager
description=Manage your databases within QGis
category=Database
version=0.1.20
qgisMinimumVersion=1.5.0
qgisMinimumVersion=2.0

author=Giuseppe Sucameli
email=brush.tyler@gmail.com
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/fTools/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name=fTools
description=Tools for vector data analysis and management
category=Vector
version=0.6.2
qgisMinimumVersion=1.4.0
qgisMinimumVersion=2.0.0

author=Carson Farmer
email=carson.farmer@gmail.com
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/mapserver_export/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name=MapServer Export
description=Export a saved QGIS project file to a MapServer map file
category=Web
version=0.4.4
qgisMinimumVersion=1.0
qgisMinimumVersion=2.0

author=Gary E. Sherman
email=sherman@mrcc.com
Expand Down
18 changes: 0 additions & 18 deletions python/plugins/sextante/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,6 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

def name():
return "SEXTANTE"

def description():
return "SEXTANTE Geoprocessing Platform for QGIS"

def version():
return "1.0.9"

def icon():
return "images/toolbox.png"

def category():
return "Analysis"

def qgisMinimumVersion():
return "1.8"

def classFactory(iface):
from sextante.SextantePlugin import SextantePlugin
return SextantePlugin(iface)
2 changes: 1 addition & 1 deletion python/plugins/sextante/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name=SEXTANTE
description=SEXTANTE Geoprocessing Platform for QGIS
category=Analysis
version=1.1
qgisMinimumVersion=1.9
qgisMinimumVersion=2.0

author=Victor Olaya
email=volayaf@gmail.com
Expand Down
6 changes: 3 additions & 3 deletions python/pyplugin_installer/installer_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import qgis.utils
from qgis.core import *
from qgis.utils import iface
from version_compare import compareVersions, normalizeVersion
from version_compare import compareVersions, normalizeVersion, isCompatible

"""
Data structure:
Expand Down Expand Up @@ -487,7 +487,7 @@ def xmlDownloaded(self,nr,state):
if not qgisMaximumVersion: qgisMaximumVersion = qgisMinimumVersion[0] + ".99"
#if compatible, add the plugin to the list
if not pluginNodes.item(i).firstChildElement("disabled").text().strip().upper() in ["TRUE","YES"]:
if compareVersions(QGis.QGIS_VERSION, qgisMinimumVersion) < 2 and compareVersions(qgisMaximumVersion, QGis.QGIS_VERSION) < 2:
if isCompatible(QGis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion):
#add the plugin to the cache
plugins.addFromRepository(plugin)
# set state=2, even if the repo is empty
Expand Down Expand Up @@ -620,7 +620,7 @@ def pluginMetadata(fct):
qgisMaximumVersion = pluginMetadata("qgisMaximumVersion").strip()
if not qgisMaximumVersion: qgisMaximumVersion = qgisMinimumVersion[0] + ".999"
#if compatible, add the plugin to the list
if compareVersions(QGis.QGIS_VERSION, qgisMinimumVersion) == 2 or compareVersions(qgisMaximumVersion, QGis.QGIS_VERSION) == 2:
if not isCompatible(QGis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion):
error = "incompatible"
errorDetails = "%s - %s" % (qgisMinimumVersion, qgisMaximumVersion)

Expand Down
51 changes: 50 additions & 1 deletion python/pyplugin_installer/version_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def compareElements(s1,s2):

# ------------------------------------------------------------------------ #
def compareVersions(a,b):
""" Compare two version numbers. Return 0 if a==b or error, 1 if a<b and 2 if b>a """
""" Compare two version numbers. Return 0 if a==b or error, 1 if a>b and 2 if b>a """
if not a or not b:
return 0
a = normalizeVersion(a)
Expand Down Expand Up @@ -155,3 +155,52 @@ def compareVersions(a,b):
return 1
else:
return 2






## COMPARE CURRENT QGIS VERSION WITH qgisMinimumVersion AND qgisMaximumVersion """

def splitVersion(s):
""" split string into 2 or 3 numerical segments """
if not s or type(s) not in [str, unicode]:
return None
l = unicode(s).split('.')
for c in l:
if not c.isnumeric():
return None
if int(c)>999:
return None
if len(l) not in [2,3]:
return None
return l


def isCompatible(curVer, minVer, maxVer=None):
""" Compare current QGIS version with qgisMinVersion and qgisMaxVersion """
minVer = splitVersion(minVer)
maxVer = splitVersion(maxVer)
curVer = splitVersion( curVer.split("-")[0] )

if not minVer or not curVer:
return False

if not maxVer:
maxVer = [minVer[0], "999", "999"]

if len(minVer)<3:
minVer += ["0"]

if len(curVer)<3:
curVer += ["0"]

if len(maxVer)<3:
maxVer += ["999"]

minVer = "%03d%03d%03d" % ( int(minVer[0]), int(minVer[1]), int(minVer[2]) )
maxVer = "%03d%03d%03d" % ( int(maxVer[0]), int(maxVer[1]), int(maxVer[2]) )
curVer = "%03d%03d%03d" % ( int(curVer[0]), int(curVer[1]), int(curVer[2]) )

return ( minVer <= curVer and maxVer >= curVer)
33 changes: 14 additions & 19 deletions src/app/qgspluginregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,11 @@ bool QgsPluginRegistry::checkQgisVersion( QString minVersion, QString maxVersion
}

// Parse qgisMaxVersion. Must be in form x.y.z or just x.y
int maxVerMajor, maxVerMinor, maxVerBugfix = 0;
int maxVerMajor, maxVerMinor, maxVerBugfix = 999;
if ( maxVersion.isEmpty() || maxVersion == "__error__" )
{
maxVerMajor = minVerMajor;
maxVerMinor = 999;
maxVerBugfix = 999;
}
else
{
Expand Down Expand Up @@ -253,23 +252,19 @@ bool QgsPluginRegistry::checkQgisVersion( QString minVersion, QString maxVersion
int qgisMinor = qgisVersionParts.at( 1 ).toInt();
int qgisBugfix = qgisVersionParts.at( 2 ).toInt();

// first check major version
if ( minVerMajor > qgisMajor || maxVerMajor < qgisMajor )
return false;
if ( minVerMajor < qgisMajor || maxVerMajor > qgisMajor )
return true;
// if same, check minor version
if ( minVerMinor > qgisMinor || maxVerMinor < qgisMinor )
return false;
if ( minVerMinor < qgisMinor || maxVerMinor > qgisMinor )
return true;

// if still same, check bugfix version (lower range only)
if ( minVerBugfix > qgisBugfix )
return false;

// looks like min or max version is the same as our version - that's fine
return true;
// build strings with trailing zeroes
QString minVer = QString( "%1%2%3" ).arg( minVerMajor, 3, 10, QChar( '0' ) )
.arg( minVerMinor, 3, 10, QChar( '0' ) )
.arg( minVerBugfix, 3, 10, QChar( '0' ) );
QString maxVer = QString( "%1%2%3" ).arg( maxVerMajor, 3, 10, QChar( '0' ) )
.arg( maxVerMinor, 3, 10, QChar( '0' ) )
.arg( maxVerBugfix, 3, 10, QChar( '0' ) );
QString curVer = QString( "%1%2%3" ).arg( qgisMajor, 3, 10, QChar( '0' ) )
.arg( qgisMinor, 3, 10, QChar( '0' ) )
.arg( qgisBugfix, 3, 10, QChar( '0' ) );

// compare
return ( minVer <= curVer && maxVer >= curVer);
}


Expand Down