Skip to content
Permalink
Browse files

new fix for #1162 restoring lost qml features

git-svn-id: http://svn.osgeo.org/qgis/trunk@9747 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Dec 7, 2008
1 parent e7f90b4 commit 270fe71f759eeb79ffe437f1a433cc480b191ed1
Showing with 552 additions and 523 deletions.
  1. +1 −1 python/core/qgsmaplayer.sip
  2. +1 −1 python/core/qgsrasterlayer.sip
  3. +2 −2 python/core/qgssymbol.sip
  4. +1 −1 python/core/qgsvectorlayer.sip
  5. +1 −1 src/core/composer/qgscomposeritem.cpp
  6. +2 −2 src/core/composer/qgscomposeritem.h
  7. +1 −1 src/core/composer/qgscomposeritemgroup.cpp
  8. +1 −1 src/core/composer/qgscomposeritemgroup.h
  9. +1 −1 src/core/composer/qgscomposerlabel.cpp
  10. +1 −1 src/core/composer/qgscomposerlabel.h
  11. +35 −35 src/core/composer/qgscomposerlegend.cpp
  12. +1 −1 src/core/composer/qgscomposerlegend.h
  13. +4 −1 src/core/composer/qgscomposermap.cpp
  14. +1 −1 src/core/composer/qgscomposermap.h
  15. +5 −5 src/core/composer/qgscomposerpicture.cpp
  16. +1 −1 src/core/composer/qgscomposerpicture.h
  17. +1 −1 src/core/composer/qgscomposerscalebar.cpp
  18. +1 −1 src/core/composer/qgscomposerscalebar.h
  19. +3 −3 src/core/composer/qgslegendmodel.cpp
  20. +1 −1 src/core/composer/qgslegendmodel.h
  21. +3 −1 src/core/qgsattributeaction.cpp
  22. +1 −1 src/core/qgsattributeaction.h
  23. +10 −10 src/core/qgsgeometry.cpp
  24. +168 −151 src/core/qgslabel.cpp
  25. +14 −7 src/core/qgslabel.h
  26. +187 −189 src/core/qgsvectorlayer.cpp
  27. +5 −3 src/core/qgsvectorlayer.h
  28. +6 −6 src/core/raster/qgsrasterlayer.cpp
  29. +9 −9 src/core/renderer/qgscontinuouscolorrenderer.cpp
  30. +6 −8 src/core/renderer/qgsgraduatedsymbolrenderer.cpp
  31. +3 −3 src/core/renderer/qgssinglesymbolrenderer.cpp
  32. +3 −3 src/core/renderer/qgsuniquevaluerenderer.cpp
  33. +59 −68 src/core/symbology/qgssymbol.cpp
  34. +13 −2 src/core/symbology/qgssymbol.h
@@ -142,7 +142,7 @@ public:

@returns true if successful
*/
bool writeXML(QDomNode & layer_node, QDomDocument & document);
bool writeXML(QDomNode & layer_node, QDomDocument & document) const;

/** Read the symbology for the current layer from the Dom node supplied.
* @param QDomNode node that will contain the symbology definition for this layer.
@@ -489,7 +489,7 @@ public:
bool readXml( QDomNode & layer_node );

/** \brief Write the symbology for the layer into the docment provided */
bool writeSymbology( QDomNode&, QDomDocument& doc, QString& errorMessage ) const;
bool writeSymbology( QDomNode&, QDomDocument& doc, QString& errorMessage );

/** \brief Write layer specific state to project file Dom node */
bool writeXml( QDomNode & layer_node, QDomDocument & doc );
@@ -70,10 +70,10 @@ class QgsSymbol

/**Writes the contents of the symbol to a configuration file
@ return true in case of success*/
virtual bool writeXML( QDomNode & item, QDomDocument & document ) const;
virtual bool writeXML( QDomNode & item, QDomDocument & document, const QgsVectorLayer *vl ) const;
/**Reads the contents of the symbol from a configuration file
@ return true in case of success*/
virtual bool readXML( QDomNode & symbol );
virtual bool readXML( QDomNode & symbol, const QgsVectorLayer *vl );
/**Returns if this symbol is point/ line or polygon*/
QGis::GeometryType type() const;

@@ -127,7 +127,7 @@ public:
* @param errorMessage reference to string that will be updated with any error messages
* @return true in case of success.
*/
bool writeSymbology(QDomNode&, QDomDocument& doc, QString& errorMessage) const;
bool writeSymbology(QDomNode&, QDomDocument& doc, QString& errorMessage);

/**
* Number of features in the layer. This is necessary if features are
@@ -92,7 +92,7 @@ bool QgsComposerItem::readSettings( void ) { return true; }

bool QgsComposerItem::removeSettings( void ) { return true; }

bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc )
bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) const
{
if ( itemElem.isNull() )
{
@@ -89,10 +89,10 @@ class CORE_EXPORT QgsComposerItem: public QGraphicsRectItem
* @param node is Dom node corresponding to 'Composer' tag
* @param temp write template file
*/
virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) = 0;
virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0;

/**Writes parameter that are not subclass specific in document. Usually called from writeXML methods of subclasses*/
bool _writeXML( QDomElement& itemElem, QDomDocument& doc );
bool _writeXML( QDomElement& itemElem, QDomDocument& doc ) const;

/** sets state from Dom document
* @param itemElem is Dom node corresponding to item tag
@@ -164,7 +164,7 @@ void QgsComposerItemGroup::drawFrame( QPainter* p )
}
}

bool QgsComposerItemGroup::writeXML( QDomElement& elem, QDomDocument & doc )
bool QgsComposerItemGroup::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
return true; //soon...
}
@@ -45,7 +45,7 @@ class CORE_EXPORT QgsComposerItemGroup: public QObject, public QgsComposerItem
* @param elem is Dom element corresponding to 'Composer' tag
* @param temp write template file
*/
bool writeXML( QDomElement& elem, QDomDocument & doc );
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;

/** sets state from Dom document
* @param itemElem is Dom node corresponding to item tag
@@ -80,7 +80,7 @@ QFont QgsComposerLabel::font() const
return mFont;
}

bool QgsComposerLabel::writeXML( QDomElement& elem, QDomDocument & doc )
bool QgsComposerLabel::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
if ( elem.isNull() )
{
@@ -45,7 +45,7 @@ class CORE_EXPORT QgsComposerLabel: public QgsComposerItem
* @param node is Dom node corresponding to 'Composer' tag
* @param temp write template file
*/
bool writeXML( QDomElement& elem, QDomDocument & doc );
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;

/** sets state from Dom document
* @param node is Dom node corresponding to 'ComposerLabel' tag
@@ -95,38 +95,38 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
//draw only visible layer items
QgsMapRenderer* theMapRenderer = mComposition->mapRenderer();
QStringList visibleLayerIds;
if(theMapRenderer)
{
visibleLayerIds = theMapRenderer->layerSet();
}
if ( theMapRenderer )
{
visibleLayerIds = theMapRenderer->layerSet();
}


for ( int i = 0; i < numLayerItems; ++i )
{
currentLayerItem = rootItem->child( i );
if ( currentLayerItem )
{
QString currentLayerId = currentLayerItem->data().toString();
if(visibleLayerIds.contains(currentLayerId))
{
//Let the user omit the layer title item by having an empty layer title string
if(!currentLayerItem->text().isEmpty())
{
currentYCoordinate += mLayerSpace;
currentYCoordinate += fontAscentMillimeters( mLayerFont );

//draw layer Item
if ( painter )
{
drawText( painter, mBoxSpace, currentYCoordinate, currentLayerItem->text(), mLayerFont );
}
}

maxXCoord = std::max( maxXCoord, 2 * mBoxSpace + textWidthMillimeters( mLayerFont, currentLayerItem->text() ) );

//and child items
drawLayerChildItems( painter, currentLayerItem, currentYCoordinate, maxXCoord );
}
if ( visibleLayerIds.contains( currentLayerId ) )
{
//Let the user omit the layer title item by having an empty layer title string
if ( !currentLayerItem->text().isEmpty() )
{
currentYCoordinate += mLayerSpace;
currentYCoordinate += fontAscentMillimeters( mLayerFont );

//draw layer Item
if ( painter )
{
drawText( painter, mBoxSpace, currentYCoordinate, currentLayerItem->text(), mLayerFont );
}
}

maxXCoord = std::max( maxXCoord, 2 * mBoxSpace + textWidthMillimeters( mLayerFont, currentLayerItem->text() ) );

//and child items
drawLayerChildItems( painter, currentLayerItem, currentYCoordinate, maxXCoord );
}
}
}

@@ -148,15 +148,15 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
size.setWidth( maxXCoord );

//adjust box if width or height is to small
if(painter && currentYCoordinate > rect().width())
{
setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), currentYCoordinate));
}
if(painter && maxXCoord > rect().height())
{
setSceneRect( QRectF( transform().dx(), transform().dy(), maxXCoord, rect().height()));
}
if ( painter && currentYCoordinate > rect().width() )
{
setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), currentYCoordinate ) );
}
if ( painter && maxXCoord > rect().height() )
{
setSceneRect( QRectF( transform().dx(), transform().dy(), maxXCoord, rect().height() ) );
}

return size;
}

@@ -402,7 +402,7 @@ void QgsComposerLegend::updateLegend()
update();
}

bool QgsComposerLegend::writeXML( QDomElement& elem, QDomDocument & doc )
bool QgsComposerLegend::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
if ( elem.isNull() )
{
@@ -85,7 +85,7 @@ class CORE_EXPORT QgsComposerLegend: public QObject, public QgsComposerItem
* @param elem is Dom element corresponding to 'Composer' tag
* @param temp write template file
*/
bool writeXML( QDomElement& elem, QDomDocument & doc );
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;

/** sets state from Dom document
* @param itemElem is Dom node corresponding to item tag
@@ -466,7 +466,7 @@ void QgsComposerMap::connectUpdateSlot()
}
}

bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc )
bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
if ( elem.isNull() )
{
@@ -497,8 +497,11 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc )
extentElem.setAttribute( "ymax", QString::number( mExtent.yMaximum() ) );
composerMapElem.appendChild( extentElem );

#if 0
// why is saving the map changing anything about the cache?
mCacheUpdated = false;
mNumCachedLayers = 0;
#endif

elem.appendChild( composerMapElem );
return _writeXML( composerMapElem, doc );
@@ -125,7 +125,7 @@ class CORE_EXPORT QgsComposerMap : /*public QWidget, private Ui::QgsComposerMapB
* @param elem is Dom element corresponding to 'Composer' tag
* @param temp write template file
*/
bool writeXML( QDomElement& elem, QDomDocument & doc );
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;

/** sets state from Dom document
* @param itemElem is Dom node corresponding to 'ComposerMap' tag
@@ -137,10 +137,10 @@ void QgsComposerPicture::setPictureFile( const QString& path )
}
}

if(mMode != Unknown) //make sure we start with a new QImage
{
setSceneRect(QRectF(transform().dx(), transform().dy(), rect().width(), rect().height()));
}
if ( mMode != Unknown ) //make sure we start with a new QImage
{
setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), rect().height() ) );
}
emit settingsChanged();
}

@@ -202,7 +202,7 @@ QString QgsComposerPicture::pictureFile() const
return mSourceFile.fileName();
}

bool QgsComposerPicture::writeXML( QDomElement& elem, QDomDocument & doc )
bool QgsComposerPicture::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
if ( elem.isNull() )
{
@@ -51,7 +51,7 @@ class CORE_EXPORT QgsComposerPicture: public QObject, public QgsComposerItem
* @param node is Dom node corresponding to 'Composer' tag
* @param temp write template file
*/
bool writeXML( QDomElement& elem, QDomDocument & doc );
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;

/** sets state from Dom document
* @param itemElem is Dom node corresponding to item tag
@@ -264,7 +264,7 @@ void QgsComposerScaleBar::setFont( const QFont& font )
update();
}

bool QgsComposerScaleBar::writeXML( QDomElement& elem, QDomDocument & doc )
bool QgsComposerScaleBar::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
if ( elem.isNull() )
{
@@ -106,7 +106,7 @@ class CORE_EXPORT QgsComposerScaleBar: public QObject, public QgsComposerItem
* @param elem is Dom element corresponding to 'Composer' tag
* @param temp write template file
*/
bool writeXML( QDomElement& elem, QDomDocument & doc );
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;

/** sets state from Dom document
* @param itemElem is Dom node corresponding to item tag
@@ -479,7 +479,7 @@ QStandardItem* QgsLegendModel::itemFromSymbol( QgsSymbol* s )
return currentSymbolItem;
}

bool QgsLegendModel::writeXML( QDomElement& composerLegendElem, QDomDocument& doc )
bool QgsLegendModel::writeXML( QDomElement& composerLegendElem, QDomDocument& doc ) const
{
if ( composerLegendElem.isNull() )
{
@@ -518,7 +518,7 @@ bool QgsLegendModel::writeXML( QDomElement& composerLegendElem, QDomDocument& do
{
QDomElement vectorClassElem = doc.createElement( "VectorClassificationItem" );
vectorClassElem.setAttribute( "text", currentClassificationItem->text() );
symbol->writeXML( vectorClassElem, doc );
symbol->writeXML( vectorClassElem, doc, 0 );
newLayerItem.appendChild( vectorClassElem );
continue;
}
@@ -601,7 +601,7 @@ bool QgsLegendModel::readXML( const QDomElement& legendModelElem, const QDomDocu
{
QgsSymbol* symbol = new QgsSymbol( vectorLayer->geometryType() );
QDomNode symbolNode = symbolNodeList.at( 0 );
symbol->readXML( symbolNode );
symbol->readXML( symbolNode, vectorLayer );
childItem->setData( QVariant::fromValue(( void* )symbol ) );

//add icon
@@ -49,7 +49,7 @@ class CORE_EXPORT QgsLegendModel: public QStandardItemModel
void updateVectorClassificationItem( QStandardItem* classificationItem, QgsSymbol* symbol, QString itemText );
void updateRasterClassificationItem( QStandardItem* classificationItem );

bool writeXML( QDomElement& composerLegendElem, QDomDocument& doc );
bool writeXML( QDomElement& composerLegendElem, QDomDocument& doc ) const;
bool readXML( const QDomElement& legendModelElem, const QDomDocument& doc );

public slots:
@@ -135,8 +135,10 @@ bool QgsAttributeAction::writeXML( QDomNode& layer_node, QDomDocument& doc ) con
return true;
}

bool QgsAttributeAction::readXML( QDomNode& layer_node )
bool QgsAttributeAction::readXML( const QDomNode& layer_node )
{
mActions.clear();

QDomNode aaNode = layer_node.namedItem( "attributeactions" );

if ( !aaNode.isNull() )
@@ -121,7 +121,7 @@ class CORE_EXPORT QgsAttributeAction
bool writeXML( QDomNode& layer_node, QDomDocument& doc ) const;

//! Reads the actions in in XML format
bool readXML( QDomNode& layer_node );
bool readXML( const QDomNode& layer_node );

private:

0 comments on commit 270fe71

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