Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/qgis/Quantum-GIS

  • Loading branch information
volaya committed Nov 15, 2012
2 parents 10a57ad + 7d0d5d3 commit 630275139212b3a8591d5a5f73a04c6697cfb8c9
@@ -583,9 +583,6 @@ void QgsApplication::initQgis()

// create map layer registry if doesn't exist
QgsMapLayerRegistry::instance();

// upgrade config options from older version
upgradeConfig();
}

void QgsApplication::exitQgis()
@@ -862,86 +859,4 @@ void QgsApplication::applyGdalSkippedDrivers()
GDALAllRegister(); //to update driver list and skip missing ones
}

void QgsApplication::upgradeConfig()
{
QSettings settings;

/* Due to changes in settings storage types for "scan items" and "scan zip" settings,
qgis-1.8 and qgis-1.9 have conficting values, so the keys have been renamed
Here we do a 1-time check to copy old setting to new setting
*/

// use a special settings key so we only check once
if ( ! settings.value( "/qgis/scanInBrowserUpgradeChecked", false ).toBool() )
{
QVariant v;
int i;
QString s;
bool ok;

// check if new setting is empty
if ( settings.value( "/qgis/scanItemsInBrowser2" ).isNull() )
{
v = settings.value( "/qgis/scanItemsInBrowser" );
i = v.toInt( &ok );
// check if value was defined in qgis-1.8 (as int)
if ( ! v.isNull() && ok )
{
// convert old setting to new setting
switch ( i )
{
case 0:
s = "contents";
break;
case 1:
s = "extension";
break;
default:
s = "";
break;
}
settings.setValue( "/qgis/scanItemsInBrowser2", s );
}
// check if value was defined in qgis-1.9 (as QString)
else if ( ! v.isNull() && !v.toString().isEmpty() )
{
s = v.toString();
settings.setValue( "/qgis/scanItemsInBrowser2", s );
}
}

if ( settings.value( "/qgis/scanZipInBrowser2" ).isNull() )
{
v = settings.value( "/qgis/scanZipInBrowser" );
i = v.toInt( & ok );
if ( ! v.isNull() && ok )
{
switch ( i )
{
case 0:
s = "No";
break;
case 1: // passthru removed, use basic instead
case 2:
s = "basic";
break;
case 3:
s = "full";
break;
default:
s = "";
break;
}
settings.setValue( "/qgis/scanZipInBrowser2", s );
}
else if ( ! v.isNull() && !v.toString().isEmpty() )
{
s = v.toString();
settings.setValue( "/qgis/scanZipInBrowser2", s );
}
}

settings.setValue( "/qgis/scanInBrowserUpgradeChecked", true );
}
}

@@ -270,10 +270,6 @@ class CORE_EXPORT QgsApplication: public QApplication
* @note added in 2.0 */
static void applyGdalSkippedDrivers();

/** upgrades config options from older version, called by initQGis
* @note added in 2.0 */
static void upgradeConfig();

signals:
//! @note not available in python bindings
void preNotify( QObject * receiver, QEvent * event, bool * done );
@@ -250,6 +250,18 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
}

QStringList wfsLayersId = wfsLayers();
QStringList typeNameList;
if ( aTypeName != "" )
{
QStringList typeNameSplit = aTypeName.split( "," );
foreach (const QString &str, typeNameSplit)
{
if ( str.contains( ":" ) )
typeNameList << str.section(":", 1, 1 );
else
typeNameList << str;
}
}

foreach ( const QDomElement &elem, mProjectLayerElements )
{
@@ -258,7 +270,11 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
{
QgsMapLayer *mLayer = createLayerFromElement( elem );
QgsVectorLayer* layer = dynamic_cast<QgsVectorLayer*>( mLayer );
if ( layer && wfsLayersId.contains( layer->id() ) && ( aTypeName == "" || layer->name() == aTypeName ) )

QString typeName = layer->name();
typeName = typeName.replace( QString( " " ), QString( "_" ) );

if ( layer && wfsLayersId.contains( layer->id() ) && ( aTypeName == "" || typeNameList.contains( typeName ) ) )
{
//do a select with searchRect and go through all the features
QgsVectorDataProvider* provider = layer->dataProvider();
@@ -270,9 +286,6 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
//hidden attributes for this layer
const QSet<QString>& layerExcludedAttributes = layer->excludeAttributesWFS();

QString typeName = layer->name();
typeName = typeName.replace( QString( " " ), QString( "_" ) );

//xsd:element
QDomElement elementElem = doc.createElement( "element"/*xsd:element*/ );
elementElem.setAttribute( "name", typeName );
@@ -284,18 +284,42 @@ QDomDocument QgsWFSServer::describeFeatureType()
importElement.setAttribute( "schemaLocation", "http://schemas.opengis.net/gml/2.1.2/feature.xsd" );
schemaElement.appendChild( importElement );

//read TYPENAME
QString typeName;
QMap<QString, QString>::const_iterator type_name_it = mParameterMap.find( "TYPENAME" );
if ( type_name_it != mParameterMap.end() )
//defining typename
QString typeName = "";

QDomDocument queryDoc;
QString errorMsg;
if ( queryDoc.setContent( mParameterMap.value( "REQUEST_BODY" ), true, &errorMsg ) )
{
typeName = type_name_it.value();
//read doc
QDomElement queryDocElem = queryDoc.documentElement();
QDomNodeList docChildNodes = queryDocElem.childNodes();
if ( docChildNodes.size() )
{
for ( int i = 0; i < docChildNodes.size(); i++ )
{
QDomElement docChildElem = docChildNodes.at( i ).toElement();
if ( docChildElem.tagName() == "TypeName" )
{
if ( typeName == "" )
typeName = docChildElem.text();
else
typeName += "," + docChildElem.text();
}
}
}
mConfigParser->describeFeatureType( typeName, schemaElement, doc );
}
else
{
typeName = "";
//read TYPENAME
QMap<QString, QString>::const_iterator type_name_it = mParameterMap.find( "TYPENAME" );
if ( type_name_it != mParameterMap.end() )
{
typeName = type_name_it.value();
}
mConfigParser->describeFeatureType( typeName, schemaElement, doc );
}
mConfigParser->describeFeatureType( typeName, schemaElement, doc );
return doc;
}

@@ -42,7 +42,7 @@ class TestQgsDataItem: public QObject

private:
QgsDirectoryItem* mDirItem;
int mScanItemsSetting;
QString mScanItemsSetting;
bool isValidDirItem( QgsDirectoryItem *item );
};

@@ -62,7 +62,7 @@ void TestQgsDataItem::initTestCase()
QCoreApplication::setApplicationName( "QGIS-TEST" );
// save current scanItemsSetting value
QSettings settings;
mScanItemsSetting = settings.value( "/qgis/scanItemsInBrowser2", 0 ).toInt();
mScanItemsSetting = settings.value( "/qgis/scanItemsInBrowser2", QVariant( "" ) ).toString();

//create a directory item that will be used in all tests...
mDirItem = new QgsDirectoryItem( 0, "Test", TEST_DATA_DIR );
@@ -94,9 +94,11 @@ void TestQgsDataItem::testValid()
void TestQgsDataItem::testDirItemChildren()
{
QSettings settings;
for ( int iSetting = 0 ; iSetting <= 1 ; iSetting++ )
QStringList tmpSettings;
tmpSettings << "" << "contents" << "extension";
foreach ( QString tmpSetting, tmpSettings )
{
settings.setValue( "/qgis/scanItemsInBrowser2", iSetting );
settings.setValue( "/qgis/scanItemsInBrowser2", tmpSetting );
QgsDirectoryItem* dirItem = new QgsDirectoryItem( 0, "Test", TEST_DATA_DIR );
QVERIFY( isValidDirItem( dirItem ) );

@@ -112,9 +114,9 @@ void TestQgsDataItem::testDirItemChildren()
QFileInfo info( layerItem->path() );
QString lFile = info.fileName();
QString lProvider = layerItem->providerKey();
QString errStr = QString( "layer #%1 - %2 provider = %3 iSetting = %4" ).arg( i ).arg( lFile ).arg( lProvider ).arg( iSetting );
QString errStr = QString( "layer #%1 - %2 provider = %3 tmpSetting = %4" ).arg( i ).arg( lFile ).arg( lProvider ).arg( tmpSetting );

QgsDebugMsg( QString( "testing child name=%1 provider=%2 path=%3" ).arg( layerItem->name() ).arg( lProvider ).arg( lFile ) );
QgsDebugMsg( QString( "testing child name=%1 provider=%2 path=%3 tmpSetting = %4" ).arg( layerItem->name() ).arg( lProvider ).arg( lFile ).arg( tmpSetting ) );

if ( lFile == "landsat.tif" )
{
@@ -139,7 +141,7 @@ void TestQgsDataItem::testDirItemChildren()

// test layerName() does not include extension for gdal and ogr items (bug #5621)
QString lName = layerItem->layerName();
errStr = QString( "layer #%1 - %2 lName = %3 iSetting = %4" ).arg( i ).arg( lFile ).arg( lName ).arg( iSetting );
errStr = QString( "layer #%1 - %2 lName = %3 tmpSetting = %4" ).arg( i ).arg( lFile ).arg( lName ).arg( tmpSetting );

if ( lFile == "landsat.tif" )
{
@@ -274,8 +274,8 @@ void TestZipLayer::initTestCase()
// save current zipSetting value
QSettings settings;
mSettingsKey = "/qgis/scanZipInBrowser2";
mScanZipSetting = settings.value( mSettingsKey, "basic" ).toString();
mScanZipSettings << "basic" << "full";
mScanZipSetting = settings.value( mSettingsKey, "" ).toString();
mScanZipSettings << "" << "basic" << "full";
}

void TestZipLayer::cleanupTestCase()
@@ -28,8 +28,8 @@
from utilities import (unitTestDataPath,
getQgisTestApp,
TestCase,
unittest
#expectedFailure
unittest,
expectedFailure
)
from qgscompositionchecker import QgsCompositionChecker

@@ -100,7 +100,7 @@ def testGrid(self):
self.mComposerMap.setGridEnabled(False)
self.mComposerMap.setShowGridAnnotation(False)

assert myTestResult[0] == True, myMessage
assert myTestResult == True, myMessage

def testOverviewMap(self):
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
@@ -127,28 +127,31 @@ def testOverviewMap(self):
assert myTestResult == True, myMessage


def testuniqueId(self, mComposerMap, mComposition):
# Fails because addItemsFromXML has been commented out in sip
@expectedFailure
def testuniqueId(self):
doc = QDomDocument()
documentElement = doc.createElement('ComposerItemClipboard')
mComposerMap.writeXML(documentElement, doc)
mComposition.addItemsFromXML(documentElement, doc, 0, False)
self.mComposition.writeXML(documentElement, doc)
self.mComposition.addItemsFromXML(documentElement, doc, 0, False)

#test if both composer maps have different ids
newMap = QgsComposerMap()
mapList = mComposition.composerMapItems()
mapList = self.mComposition.composerMapItems()

for mapIt in mapList:
if mapIt != mComposerMap:
if mapIt != self.mComposerMap:
newMap = mapIt
break

oldId = mComposerMap.id()
oldId = self.mComposerMap.id()
newId = newMap.id()

mComposition.removeComposerItem(newMap)
self.mComposition.removeComposerItem(newMap)
myMessage = 'old: %s new: %s' % (oldId, newId)
assert oldId != newId, myMessage

@expectedFailure
def testZebraStyle(self):
self.mComposerMap.setGridFrameStyle(QgsComposerMap.Zebra)
self.mComposerMap.setGridEnabled(True)
@@ -179,8 +179,8 @@ def testUnion(self):
def testAsWktCoordinates(self):
"""Test that we can get a proper wkt representation fo the rect"""
rect1 = QgsRectangle( 0.0, 0.0, 5.0, 5.0)
myExpectedWkt = ('0.0000000000000000 0.0000000000000000, '
'5.0000000000000000 5.0000000000000000')
myExpectedWkt = ('0.0 0.0, '
'5.0 5.0')
myWkt = rect1.asWktCoordinates()
myMessage = ('Expected: %s\nGot: %s\n' %
(myExpectedWkt, myWkt))
@@ -189,11 +189,11 @@ def testAsWktCoordinates(self):
def testAsWktPolygon(self):
"""Test that we can get a proper rect wkt polygon representation for rect"""
rect1 = QgsRectangle( 0.0, 0.0, 5.0, 5.0)
myExpectedWkt = ('POLYGON((0.0000000000000000 0.0000000000000000, '
'5.0000000000000000 0.0000000000000000, '
'5.0000000000000000 5.0000000000000000, '
'0.0000000000000000 5.0000000000000000, '
'0.0000000000000000 0.0000000000000000))')
myExpectedWkt = ('POLYGON((0.0 0.0, '
'5.0 0.0, '
'5.0 5.0, '
'0.0 5.0, '
'0.0 0.0))')
myWkt = rect1.asWktPolygon()
myMessage = ('Expected: %s\nGot: %s\n' %
(myExpectedWkt, myWkt))
@@ -28,7 +28,7 @@
getQgisTestApp,
TestCase,
unittest,
#expectedFailure
expectedFailure
)
QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()

@@ -37,7 +37,9 @@ class TestQgsVectorLayer(TestCase):

mMemoryLayer = None

def setUp(self):
@expectedFailure
def testWrite(self):
"""Check we can write a vector file."""
self.mMemoryLayer = QgsVectorLayer(
('Point?crs=epsg:4326&field=name:string(20)&'
'field=age:integer&field=size:double&index=yes'),
@@ -57,10 +59,6 @@ def setUp(self):
assert myResult == True
assert len(myFeatures) > 0


def testWrite(self):
"""Check we can write a vector file."""

myFileName = os.path.join(str(QDir.tempPath()), 'writetest.shp')
print myFileName
# Explicitly giving all options, not really needed but nice for clarity

0 comments on commit 6302751

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