Skip to content

Commit

Permalink
new fix for #1162 restoring lost qml features
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@9747 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 7, 2008
1 parent e7f90b4 commit 270fe71
Show file tree
Hide file tree
Showing 34 changed files with 552 additions and 523 deletions.
2 changes: 1 addition & 1 deletion python/core/qgsmaplayer.sip
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsrasterlayer.sip
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgssymbol.sip
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsvectorlayer.sip
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposeritem.cpp
Expand Up @@ -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() )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposeritem.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposeritemgroup.cpp
Expand Up @@ -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...
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposeritemgroup.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerlabel.cpp
Expand Up @@ -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() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerlabel.h
Expand Up @@ -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
Expand Down
70 changes: 35 additions & 35 deletions src/core/composer/qgscomposerlegend.cpp
Expand Up @@ -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 );
}
}
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerlegend.h
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/core/composer/qgscomposermap.cpp
Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposermap.h
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/core/composer/qgscomposerpicture.cpp
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerpicture.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerscalebar.cpp
Expand Up @@ -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() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerscalebar.h
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/core/composer/qgslegendmodel.cpp
Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgslegendmodel.h
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/core/qgsattributeaction.cpp
Expand Up @@ -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() )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsattributeaction.h
Expand Up @@ -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:

Expand Down

0 comments on commit 270fe71

Please sign in to comment.