Skip to content

Commit

Permalink
Merge pull request #3930 from nyalldawson/rename_qgsproject
Browse files Browse the repository at this point in the history
Rename QgsProperty to QgsProjectProperty
  • Loading branch information
nyalldawson authored Jan 3, 2017
2 parents d12c41f + 48e7299 commit 06baa97
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 267 deletions.
7 changes: 7 additions & 0 deletions doc/api_break.dox
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes}
<tr><td>QgsMultiLineStringV2<td>QgsMultiLineString
<tr><td>QgsMultiSurfaceV2<td>QgsMultiSurface
<tr><td>QgsPointSequenceV2<td>QgsPointSequence
<tr><td>QgsProperty<td>QgsProjectProperty
<tr><td>QgsPropertyKey<td>QgsProjectPropertyKey
<tr><td>QgsPropertyValue<td>QgsProjectPropertyValue
<tr><td>QgsRandomColorsV2<td>QgsRandomColorRamp
<tr><td>QgsRendererCategoryV2<td>QgsRendererCategory
<tr><td>QgsRendererRangeV2<td>QgsRendererRange
Expand Down Expand Up @@ -1360,6 +1363,10 @@ QgsProject {#qgis_api_break_3_0_QgsProject}
- dirty( bool b ) was removed. Use setDirty() instead.
- clearProperties() was removed. Use clear() instead.

QgsProjectPropertyValue {#qgis_api_break_3_0_QgsProjectPropertyValue}
-----------------------

- The unused count() and entryList() methods were removed.

QgsRaster {#qgis_api_break_3_0_QgsRaster}
---------
Expand Down
41 changes: 17 additions & 24 deletions python/core/qgsprojectproperty.sip
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class QgsProperty
class QgsProjectProperty
{
%TypeHeaderCode
#include <qgsprojectproperty.h>
%End

public:
QgsProperty();
virtual ~QgsProperty();
QgsProjectProperty();
virtual ~QgsProjectProperty();

/** Dumps out the keys and values
*
Expand Down Expand Up @@ -34,7 +34,7 @@ class QgsProperty
*
* Used for restoring properties from project file
*/
virtual bool readXml( QDomNode & keyNode ) = 0;
virtual bool readXml( const QDomNode& keyNode ) = 0;

/**
* adds property hierarchy to given Dom element
Expand Down Expand Up @@ -63,16 +63,16 @@ class QgsProperty
}; // class QgsProperty


class QgsPropertyValue : QgsProperty
class QgsProjectPropertyValue : QgsProjectProperty
{
%TypeHeaderCode
#include <qgsprojectproperty.h>
%End

public:
QgsPropertyValue();
QgsPropertyValue( const QVariant &value );
virtual ~QgsPropertyValue();
QgsProjectPropertyValue();
QgsProjectPropertyValue( const QVariant &value );
virtual ~QgsProjectPropertyValue();

/** Returns true if is a QgsPropertyKey */
virtual bool isKey() const;
Expand All @@ -91,30 +91,23 @@ class QgsPropertyValue : QgsProperty

void dump( int tabs = 0 ) const;

bool readXml( QDomNode & keyNode );
bool readXml( const QDomNode& keyNode );

bool writeXml( const QString & nodeName,
QDomElement & element,
QDomDocument & document );

int count() const;

/** Return keys that do not contain other keys
* Since QgsPropertyValue isn't a key, don't do anything.
*/
void entryList( QStringList & keyName, QStringList & entries ) const;

};

class QgsPropertyKey : QgsProperty
class QgsProjectPropertyKey : QgsProjectProperty
{
%TypeHeaderCode
#include <qgsprojectproperty.h>
%End

public:
QgsPropertyKey( const QString& name = QString() );
virtual ~QgsPropertyKey();
QgsProjectPropertyKey( const QString& name = QString() );
virtual ~QgsProjectPropertyKey();

/**
* The name of the property is used as identifier.
Expand All @@ -133,7 +126,7 @@ class QgsPropertyKey : QgsProperty


/// add the given property key
QgsPropertyKey * addKey( const QString & keyName );
QgsProjectPropertyKey * addKey( const QString & keyName );

/// remove the given key
void removeKey( const QString & keyName );
Expand All @@ -143,19 +136,19 @@ class QgsPropertyKey : QgsProperty
* @param value is the value to set
* @return pointer to property value
*/
QgsPropertyValue * setValue( const QString & name, const QVariant & value );
QgsProjectPropertyValue * setValue( const QString & name, const QVariant & value );

/** Set the value associated with this key
*
* @note that the single value node associated with each key is always
* stored keyed by the current key name
*/
QgsPropertyValue * setValue( const QVariant & value );
QgsProjectPropertyValue * setValue( const QVariant & value );


void dump( int tabs = 0 ) const;

bool readXml( QDomNode & keyNode );
bool readXml( const QDomNode& keyNode );

bool writeXml( const QString &nodeName, QDomElement & element, QDomDocument & document );

Expand Down Expand Up @@ -189,5 +182,5 @@ class QgsPropertyKey : QgsProperty
/// delete any sub-nodes
virtual void clearKeys();

QgsProperty * find( QString & propertyName );
QgsProjectProperty * find( QString & propertyName );
}; // class QgsPropertyKey
70 changes: 35 additions & 35 deletions src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ QStringList makeKeyTokens_( const QString& scope, const QString& key )
@param scope scope of key
@param key keyname
@param rootProperty is likely to be the top level QgsPropertyKey in QgsProject:e:Imp.
@param rootProperty is likely to be the top level QgsProjectPropertyKey in QgsProject:e:Imp.
@return null if not found, otherwise located Property
*/
QgsProperty* findKey_( const QString& scope,
const QString& key,
QgsPropertyKey& rootProperty )
QgsProjectProperty* findKey_( const QString& scope,
const QString& key,
QgsProjectPropertyKey& rootProperty )
{
QgsPropertyKey* currentProperty = &rootProperty;
QgsProperty* nextProperty; // link to next property down hiearchy
QgsProjectPropertyKey* currentProperty = &rootProperty;
QgsProjectProperty* nextProperty; // link to next property down hiearchy

QStringList keySequence = makeKeyTokens_( scope, key );

Expand Down Expand Up @@ -144,7 +144,7 @@ QgsProperty* findKey_( const QString& scope,
{
if ( nextProperty->isKey() )
{
currentProperty = static_cast<QgsPropertyKey*>( nextProperty );
currentProperty = static_cast<QgsProjectPropertyKey*>( nextProperty );
}
else if ( nextProperty->isValue() && 1 == keySequence.count() )
{
Expand All @@ -156,7 +156,7 @@ QgsProperty* findKey_( const QString& scope,
}
else
{
// QgsPropertyValue not Key, so return null
// QgsProjectPropertyValue not Key, so return null
return nullptr;
}
}
Expand Down Expand Up @@ -185,17 +185,17 @@ QgsProperty* findKey_( const QString& scope,
@param rootProperty is the property from which to start adding
@param value the value associated with the key
*/
QgsProperty *addKey_( const QString& scope,
const QString& key,
QgsPropertyKey* rootProperty,
const QVariant& value )
QgsProjectProperty *addKey_( const QString& scope,
const QString& key,
QgsProjectPropertyKey* rootProperty,
const QVariant& value )
{
QStringList keySequence = makeKeyTokens_( scope, key );

// cursor through property key/value hierarchy
QgsPropertyKey *currentProperty = rootProperty;
QgsProperty *nextProperty; // link to next property down hiearchy
QgsPropertyKey* newPropertyKey;
QgsProjectPropertyKey *currentProperty = rootProperty;
QgsProjectProperty *nextProperty; // link to next property down hiearchy
QgsProjectPropertyKey* newPropertyKey;

while ( ! keySequence.isEmpty() )
{
Expand Down Expand Up @@ -223,13 +223,13 @@ QgsProperty *addKey_( const QString& scope,
}
else if (( nextProperty = currentProperty->find( keySequence.first() ) ) )
{
currentProperty = dynamic_cast<QgsPropertyKey*>( nextProperty );
currentProperty = dynamic_cast<QgsProjectPropertyKey*>( nextProperty );

if ( currentProperty )
{
continue;
}
else // QgsPropertyValue not Key, so return null
else // QgsProjectPropertyValue not Key, so return null
{
return nullptr;
}
Expand All @@ -256,12 +256,12 @@ QgsProperty *addKey_( const QString& scope,

void removeKey_( const QString& scope,
const QString& key,
QgsPropertyKey &rootProperty )
QgsProjectPropertyKey &rootProperty )
{
QgsPropertyKey *currentProperty = &rootProperty;
QgsProjectPropertyKey *currentProperty = &rootProperty;

QgsProperty *nextProperty = nullptr; // link to next property down hiearchy
QgsPropertyKey *previousQgsPropertyKey = nullptr; // link to previous property up hiearchy
QgsProjectProperty *nextProperty = nullptr; // link to next property down hiearchy
QgsProjectPropertyKey *previousQgsPropertyKey = nullptr; // link to previous property up hiearchy

QStringList keySequence = makeKeyTokens_( scope, key );

Expand Down Expand Up @@ -290,13 +290,13 @@ void removeKey_( const QString& scope,
else if (( nextProperty = currentProperty->find( keySequence.first() ) ) )
{
previousQgsPropertyKey = currentProperty;
currentProperty = dynamic_cast<QgsPropertyKey*>( nextProperty );
currentProperty = dynamic_cast<QgsProjectPropertyKey*>( nextProperty );

if ( currentProperty )
{
continue;
}
else // QgsPropertyValue not Key, so return null
else // QgsProjectPropertyValue not Key, so return null
{
return;
}
Expand Down Expand Up @@ -475,7 +475,7 @@ void QgsProject::clear()
}

// basically a debugging tool to dump property list values
void dump_( const QgsPropertyKey& topQgsPropertyKey )
void dump_( const QgsProjectPropertyKey& topQgsPropertyKey )
{
QgsDebugMsg( "current properties:" );
topQgsPropertyKey.dump();
Expand Down Expand Up @@ -509,10 +509,10 @@ scope. "layers" is a list containing three string values.
\endcode
@param doc xml document
@param project_properties should be the top QgsPropertyKey node.
@param project_properties should be the top QgsProjectPropertyKey node.
*/
void _getProperties( const QDomDocument& doc, QgsPropertyKey& project_properties )
void _getProperties( const QDomDocument& doc, QgsProjectPropertyKey& project_properties )
{
QDomNodeList properties = doc.elementsByTagName( QStringLiteral( "properties" ) );

Expand Down Expand Up @@ -1397,7 +1397,7 @@ QStringList QgsProject::readListEntry( const QString& scope,
const QStringList& def,
bool* ok ) const
{
QgsProperty* property = findKey_( scope, key, mProperties );
QgsProjectProperty* property = findKey_( scope, key, mProperties );

QVariant value;

Expand All @@ -1424,7 +1424,7 @@ QString QgsProject::readEntry( const QString& scope,
const QString& def,
bool* ok ) const
{
QgsProperty *property = findKey_( scope, key, mProperties );
QgsProjectProperty *property = findKey_( scope, key, mProperties );

QVariant value;

Expand All @@ -1446,7 +1446,7 @@ QString QgsProject::readEntry( const QString& scope,
int QgsProject::readNumEntry( const QString& scope, const QString &key, int def,
bool* ok ) const
{
QgsProperty *property = findKey_( scope, key, mProperties );
QgsProjectProperty *property = findKey_( scope, key, mProperties );

QVariant value;

Expand Down Expand Up @@ -1474,7 +1474,7 @@ double QgsProject::readDoubleEntry( const QString& scope, const QString& key,
double def,
bool* ok ) const
{
QgsProperty *property = findKey_( scope, key, mProperties );
QgsProjectProperty *property = findKey_( scope, key, mProperties );
if ( property )
{
QVariant value = property->value();
Expand All @@ -1493,7 +1493,7 @@ double QgsProject::readDoubleEntry( const QString& scope, const QString& key,
bool QgsProject::readBoolEntry( const QString& scope, const QString &key, bool def,
bool* ok ) const
{
QgsProperty *property = findKey_( scope, key, mProperties );
QgsProjectProperty *property = findKey_( scope, key, mProperties );

if ( property )
{
Expand Down Expand Up @@ -1523,13 +1523,13 @@ bool QgsProject::removeEntry( const QString& scope, const QString& key )

QStringList QgsProject::entryList( const QString& scope, const QString& key ) const
{
QgsProperty *foundProperty = findKey_( scope, key, mProperties );
QgsProjectProperty *foundProperty = findKey_( scope, key, mProperties );

QStringList entries;

if ( foundProperty )
{
QgsPropertyKey *propertyKey = dynamic_cast<QgsPropertyKey*>( foundProperty );
QgsProjectPropertyKey *propertyKey = dynamic_cast<QgsProjectPropertyKey*>( foundProperty );

if ( propertyKey )
{ propertyKey->entryList( entries ); }
Expand All @@ -1540,13 +1540,13 @@ QStringList QgsProject::entryList( const QString& scope, const QString& key ) co

QStringList QgsProject::subkeyList( const QString& scope, const QString& key ) const
{
QgsProperty *foundProperty = findKey_( scope, key, mProperties );
QgsProjectProperty *foundProperty = findKey_( scope, key, mProperties );

QStringList entries;

if ( foundProperty )
{
QgsPropertyKey *propertyKey = dynamic_cast<QgsPropertyKey*>( foundProperty );
QgsProjectPropertyKey *propertyKey = dynamic_cast<QgsProjectPropertyKey*>( foundProperty );

if ( propertyKey )
{ propertyKey->subkeyList( entries ); }
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
QVariantMap mCustomVariables;

QFile mFile; // current physical project file
mutable QgsPropertyKey mProperties; // property hierarchy, TODO: this shouldn't be mutable
mutable QgsProjectPropertyKey mProperties; // property hierarchy, TODO: this shouldn't be mutable
QString mTitle; // project title
bool mAutoTransaction; // transaction grouped editing
bool mEvaluateDefaultValues; // evaluate default values immediately
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsprojectfiletransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void QgsProjectFileTransform::transform1100to1200()
for ( int i = 0; i < tolList.childNodes().count(); i++ )
units << QStringLiteral( "0" );

QgsPropertyValue value( units );
QgsProjectPropertyValue value( units );
value.writeXml( QStringLiteral( "LayerSnappingToleranceUnitList" ), digitizing, mDom );
}

Expand Down
Loading

0 comments on commit 06baa97

Please sign in to comment.