Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Nov 15, 2012
2 parents 10a57ad + 7d0d5d3 commit 6302751
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 132 deletions.
85 changes: 0 additions & 85 deletions src/core/qgsapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 );
}
}

4 changes: 0 additions & 4 deletions src/core/qgsapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
21 changes: 17 additions & 4 deletions src/mapserver/qgsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -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();
Expand All @@ -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 );
Expand Down
38 changes: 31 additions & 7 deletions src/mapserver/qgswfsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
16 changes: 9 additions & 7 deletions tests/src/core/testqgsdataitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TestQgsDataItem: public QObject

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

Expand All @@ -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 );
Expand Down Expand Up @@ -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 ) );

Expand All @@ -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" )
{
Expand All @@ -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" )
{
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testziplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
23 changes: 13 additions & 10 deletions tests/src/python/test_qgscomposermap.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
from utilities import (unitTestDataPath,
getQgisTestApp,
TestCase,
unittest
#expectedFailure
unittest,
expectedFailure
)
from qgscompositionchecker import QgsCompositionChecker

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions tests/src/python/test_qgsrectangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
10 changes: 4 additions & 6 deletions tests/src/python/test_qgsvectorfilewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
getQgisTestApp,
TestCase,
unittest,
#expectedFailure
expectedFailure
)
QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()

Expand All @@ -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'),
Expand All @@ -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
Expand Down

0 comments on commit 6302751

Please sign in to comment.