Commit d6099968 authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

API change: Use QSharedPointer<GeoDataStyle> instead of GeoDataStyle(*)

Fixes lots of memory leaks that previously existed due to unclear
ownership semantics. Most noticable in vector tile rendering when lots
of documents are created/deleted.

Please review / test for potential regressions.
parent d27226e8
......@@ -176,15 +176,15 @@ void ClickOnThat::initiateGame()
d->m_selectPinDocument = new GeoDataDocument;
GeoDataPlacemark *pinPlacemark = new GeoDataPlacemark;
GeoDataStyle pinStyle;
pinStyle.setId("answer");
GeoDataStyle::Ptr pinStyle(new GeoDataStyle);
pinStyle->setId("answer");
GeoDataIconStyle iconStyle;
iconStyle.setIconPath( MarbleDirs::path("bitmaps/target.png") );
pinStyle.setIconStyle( iconStyle );
pinStyle->setIconStyle( iconStyle );
GeoDataStyleMap styleMap;
styleMap.setId("default-map");
styleMap.insert( "normal", QString("#").append( pinStyle.id()) );
styleMap.insert( "normal", QString("#").append( pinStyle->id()) );
d->m_selectPinDocument->addStyle( pinStyle );
d->m_selectPinDocument->addStyleMap( styleMap );
......@@ -256,8 +256,8 @@ void ClickOnThat::updateSelectPin(bool result, const GeoDataCoordinates &clicked
iconPath = iconPath.append("/MapTackRoundHeadRed.png");
}
GeoDataStyle style = d->m_selectPinDocument->style("answer");
style.iconStyle().setIconPath( iconPath );
GeoDataStyle::Ptr style = d->m_selectPinDocument->style("answer");
style->iconStyle().setIconPath( iconPath );
d->m_selectPinDocument->addStyle( style );
QVector<GeoDataPlacemark*> placemarkList = d->m_selectPinDocument->placemarkList();
......
......@@ -223,7 +223,7 @@ void BookmarkManagerDialogPrivate::editBookmark()
bookmark->setName( dialog->name() );
bookmark->setDescription( dialog->description() );
bookmark->setCoordinate( dialog->coordinates() );
GeoDataStyle *newStyle = new GeoDataStyle( *bookmark->style() );
GeoDataStyle::Ptr newStyle(new GeoDataStyle( *bookmark->style() ));
newStyle->iconStyle().setIconPath( dialog->iconLink() );
bookmark->setStyle( newStyle );
if ( bookmark->lookAt() ) {
......
......@@ -251,7 +251,7 @@ GeoDataPlacemark EditBookmarkDialog::bookmark() const
GeoDataPlacemark bookmark;
bookmark.setName( name() );
bookmark.setDescription( description() );
GeoDataStyle *newStyle = new GeoDataStyle( *bookmark.style() );
GeoDataStyle::Ptr newStyle(new GeoDataStyle( *bookmark.style() ));
newStyle->iconStyle().setIconPath( iconLink() );
bookmark.setStyle( newStyle );
//allow for HTML in the description
......
......@@ -336,7 +336,7 @@ void EditPlacemarkDialog::updateTextAnnotation()
if ( !d->m_header->iconLink().isEmpty() ) {
QFileInfo fileInfo( d->m_header->iconLink() );
GeoDataStyle *newStyle = new GeoDataStyle( *d->m_placemark->style() );
GeoDataStyle::Ptr newStyle(new GeoDataStyle( *d->m_placemark->style() ));
if ( fileInfo.exists() ) {
newStyle->iconStyle().setIconPath( d->m_header->iconLink() );
}
......@@ -352,7 +352,7 @@ void EditPlacemarkDialog::updateTextAnnotation()
if ( !suitableTag.isEmpty() ) {
GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::osmVisualCategory( suitableTag );
d->m_placemark->setVisualCategory( category );
d->m_placemark->setStyle( 0 );
d->m_placemark->setStyle(GeoDataStyle::Ptr());
}
}
......@@ -480,7 +480,7 @@ void EditPlacemarkDialog::restoreInitial( int result )
}
if ( *d->m_placemark->style() != d->m_initialStyle ) {
d->m_placemark->setStyle( new GeoDataStyle( d->m_initialStyle ) );
d->m_placemark->setStyle( GeoDataStyle::Ptr(new GeoDataStyle( d->m_initialStyle )) );
}
if( d->m_placemark->isVisible() != d->m_initialIsPlacemarkVisible ) {
......
......@@ -39,7 +39,7 @@ class FileLoaderPrivate
{
public:
FileLoaderPrivate( FileLoader* parent, const PluginManager *pluginManager, bool recenter,
const QString& file, const QString& property, const GeoDataStyle* style, DocumentRole role )
const QString& file, const QString& property, const GeoDataStyle::Ptr &style, DocumentRole role )
: q( parent),
m_runner( pluginManager ),
m_recenter( recenter ),
......@@ -63,7 +63,6 @@ public:
m_recenter( false ),
m_filepath ( file ),
m_contents ( contents ),
m_style( 0 ),
m_documentRole ( role ),
m_styleMap( 0 ),
m_document( 0 )
......@@ -72,7 +71,6 @@ public:
~FileLoaderPrivate()
{
delete m_style;
delete m_styleMap;
}
......@@ -89,7 +87,7 @@ public:
QString m_filepath;
QString m_contents;
QString m_property;
const GeoDataStyle *const m_style;
GeoDataStyle::Ptr m_style;
DocumentRole m_documentRole;
GeoDataStyleMap* m_styleMap;
GeoDataDocument *m_document;
......@@ -97,7 +95,7 @@ public:
};
FileLoader::FileLoader( QObject* parent, const PluginManager *pluginManager, bool recenter,
const QString& file, const QString& property, const GeoDataStyle* style, DocumentRole role )
const QString& file, const QString& property, const GeoDataStyle::Ptr &style, DocumentRole role )
: QThread( parent ),
d( new FileLoaderPrivate( this, pluginManager, recenter, file, property, style, role ) )
{
......@@ -219,7 +217,7 @@ void FileLoaderPrivate::documentParsed( GeoDataDocument* doc, const QString& err
doc->setProperty( m_property );
if( m_style ) {
doc->addStyleMap( *m_styleMap );
doc->addStyle( *m_style );
doc->addStyle( m_style );
}
createFilterProperties( doc );
......
......@@ -26,8 +26,8 @@ class FileLoader : public QThread
{
Q_OBJECT
public:
FileLoader( QObject* parent, const PluginManager *pluginManager, bool recenter,
const QString& file, const QString& property, const GeoDataStyle* style, DocumentRole role );
FileLoader(QObject* parent, const PluginManager *pluginManager, bool recenter,
const QString& file, const QString& property, const GeoDataStyle::Ptr &style, DocumentRole role );
FileLoader( QObject* parent, const PluginManager *pluginManager,
const QString& contents, const QString& name, DocumentRole role );
virtual ~FileLoader();
......
......@@ -78,7 +78,7 @@ FileManager::~FileManager()
delete d;
}
void FileManager::addFile( const QString& filepath, const QString& property, const GeoDataStyle* style, DocumentRole role, bool recenter )
void FileManager::addFile( const QString& filepath, const QString& property, const GeoDataStyle::Ptr &style, DocumentRole role, bool recenter )
{
if( d->m_fileItemHash.contains( filepath ) ) {
return; // already loaded
......
......@@ -54,7 +54,7 @@ class FileManager : public QObject
/**
* Loads a new file into the manager.
*/
void addFile( const QString &fileName, const QString &property, const GeoDataStyle* style, DocumentRole role, bool recenter = false );
void addFile(const QString &fileName, const QString &property, const GeoDataStyle::Ptr &style, DocumentRole role, bool recenter = false );
/**
......
......@@ -48,24 +48,24 @@ public:
// Stores the items which have been clicked;
QList<GeoGraphicsItem*> m_selectedItems;
GeoDataStyle *highlightStyle(const GeoDataDocument *document, const GeoDataStyleMap &styleMap);
GeoDataStyle::Ptr highlightStyle(const GeoDataDocument *document, const GeoDataStyleMap &styleMap);
void selectItem( GeoGraphicsItem *item );
void applyHighlightStyle( GeoGraphicsItem *item, GeoDataStyle *style );
void applyHighlightStyle(GeoGraphicsItem *item, const GeoDataStyle::Ptr &style );
};
GeoDataStyle *GeoGraphicsScenePrivate::highlightStyle( const GeoDataDocument *document,
GeoDataStyle::Ptr GeoGraphicsScenePrivate::highlightStyle( const GeoDataDocument *document,
const GeoDataStyleMap &styleMap )
{
// @todo Consider QUrl parsing when external styles are suppported
QString highlightStyleId = styleMap.value("highlight");
highlightStyleId.remove('#');
if ( !highlightStyleId.isEmpty() ) {
GeoDataStyle *highlightStyle = new GeoDataStyle( document->style(highlightStyleId) );
GeoDataStyle::Ptr highlightStyle(new GeoDataStyle( *document->style(highlightStyleId) ));
return highlightStyle;
}
else {
return 0;
return GeoDataStyle::Ptr();
}
}
......@@ -74,7 +74,7 @@ void GeoGraphicsScenePrivate::selectItem( GeoGraphicsItem* item )
m_selectedItems.append( item );
}
void GeoGraphicsScenePrivate::applyHighlightStyle(GeoGraphicsItem* item, GeoDataStyle* highlightStyle )
void GeoGraphicsScenePrivate::applyHighlightStyle(GeoGraphicsItem* item, const GeoDataStyle::Ptr &highlightStyle )
{
item->setHighlightStyle( highlightStyle );
item->setHighlighted( true );
......@@ -190,7 +190,7 @@ void GeoGraphicsScene::applyHighlight( const QVector< GeoDataPlacemark* > &selec
styleUrl.remove('#');
if ( !styleUrl.isEmpty() ) {
GeoDataStyleMap const &styleMap = doc->styleMap( styleUrl );
GeoDataStyle *style = d->highlightStyle( doc, styleMap );
GeoDataStyle::Ptr style = d->highlightStyle( doc, styleMap );
if ( style ) {
d->selectItem( item );
d->applyHighlightStyle( item, style );
......@@ -205,7 +205,7 @@ void GeoGraphicsScene::applyHighlight( const QVector< GeoDataPlacemark* > &selec
*/
else {
foreach ( const GeoDataStyleMap &styleMap, doc->styleMaps() ) {
GeoDataStyle *style = d->highlightStyle( doc, styleMap );
GeoDataStyle::Ptr style = d->highlightStyle( doc, styleMap );
if ( style ) {
d->selectItem( item );
d->applyHighlightStyle( item, style );
......
......@@ -135,7 +135,7 @@ class MarbleModelPrivate
* load of parsing the data file again.
* @see assignFillColors()
*/
void assignNewStyle( const QString &filePath, const GeoDataStyle &style );
void assignNewStyle(const QString &filePath, const GeoDataStyle::Ptr &style );
/**
* @brief Assigns each placemark an inline
......@@ -338,7 +338,7 @@ void MarbleModel::setMapTheme( GeoSceneDocument *document )
QStringList fileList;
QStringList propertyList;
QList<const GeoDataStyle*> styleList;
QList<GeoDataStyle::Ptr> styleList;
bool skip = false;
bool sourceFileMatch = false;
......@@ -378,7 +378,7 @@ void MarbleModel::setMapTheme( GeoSceneDocument *document )
QString property = data->property();
QPen pen = data->pen();
QBrush brush = data->brush();
GeoDataStyle* style = 0;
GeoDataStyle::Ptr style;
/**
* data->colors() are the colorMap values from dgml file. If this is not
......@@ -394,7 +394,7 @@ void MarbleModel::setMapTheme( GeoSceneDocument *document )
lineStyle.setWidth( pen.width() );
GeoDataPolyStyle polyStyle( brush.color() );
polyStyle.setFill( true );
style = new GeoDataStyle;
style = GeoDataStyle::Ptr(new GeoDataStyle);
style->setLineStyle( lineStyle );
style->setPolyStyle( polyStyle );
style->setId( "default" );
......@@ -407,9 +407,8 @@ void MarbleModel::setMapTheme( GeoSceneDocument *document )
currentDatasets.removeAt( datasetIndex );
if ( style ) {
qDebug() << "setMapThemeId-> color: " << style->polyStyle().color() << " file: " << filename;
d->assignNewStyle( filename, *style );
delete style;
style = 0;
d->assignNewStyle( filename, style );
style = GeoDataStyle::Ptr();
}
else {
d->assignFillColors( data->sourceFile() );
......@@ -445,37 +444,37 @@ void MarbleModelPrivate::addHighlightStyle(GeoDataDocument* doc)
QColor highlightBrushColor = m_mapTheme->map()->highlightBrushColor();
QColor highlightPenColor = m_mapTheme->map()->highlightPenColor();
GeoDataStyle highlightStyle;
highlightStyle.setId("highlight");
GeoDataStyle::Ptr highlightStyle(new GeoDataStyle);
highlightStyle->setId("highlight");
if ( highlightBrushColor.isValid() ) {
GeoDataPolyStyle highlightPolyStyle;
highlightPolyStyle.setColor( highlightBrushColor );
highlightPolyStyle.setFill( true );
highlightStyle.setPolyStyle( highlightPolyStyle );
highlightStyle->setPolyStyle( highlightPolyStyle );
}
if ( highlightPenColor.isValid() ) {
GeoDataLineStyle highlightLineStyle( highlightPenColor );
highlightStyle.setLineStyle( highlightLineStyle );
highlightStyle->setLineStyle( highlightLineStyle );
}
if ( highlightBrushColor.isValid()
|| highlightPenColor.isValid() )
{
GeoDataStyleMap styleMap = doc->styleMap("default-map");
styleMap.insert( "highlight", QString("#").append(highlightStyle.id()) );
styleMap.insert( "highlight", QString("#").append(highlightStyle->id()) );
doc->addStyle( highlightStyle );
doc->addStyleMap( styleMap );
}
}
}
void MarbleModelPrivate::assignNewStyle( const QString &filePath, const GeoDataStyle &style )
void MarbleModelPrivate::assignNewStyle( const QString &filePath, const GeoDataStyle::Ptr &style )
{
GeoDataDocument *doc = m_fileManager.at( filePath );
Q_ASSERT( doc );
GeoDataStyleMap styleMap;
styleMap.setId("default-map");
styleMap.insert( "normal", QString("#").append(style.id()) );
styleMap.insert( "normal", QString("#").append(style->id()) );
doc->addStyleMap( styleMap );
doc->addStyle( style );
......@@ -780,8 +779,7 @@ void MarbleModel::setLegend( QTextDocument * legend )
void MarbleModel::addGeoDataFile( const QString& filename )
{
GeoDataStyle* dummyStyle = new GeoDataStyle;
d->m_fileManager.addFile( filename, filename, dummyStyle, UserDocument, true );
d->m_fileManager.addFile( filename, filename, GeoDataStyle::Ptr(), UserDocument, true );
}
void MarbleModel::addGeoDataString( const QString& data, const QString& key )
......@@ -835,7 +833,7 @@ void MarbleModelPrivate::assignFillColors( const QString &filePath ) {
for ( ; it != itEnd; ++it ) {
GeoDataPlacemark *placemark = dynamic_cast<GeoDataPlacemark*>( *it );
if ( placemark ) {
GeoDataStyle *style = new GeoDataStyle;
GeoDataStyle::Ptr style(new GeoDataStyle);
style->setId( QString("normal") );
style->setLineStyle( lineStyle );
quint8 colorIndex = placemark->style()->polyStyle().colorIndex();
......@@ -861,15 +859,15 @@ void MarbleModelPrivate::assignFillColors( const QString &filePath ) {
}
}
else {
GeoDataStyle style;
GeoDataStyle::Ptr style(new GeoDataStyle);
GeoDataPolyStyle polyStyle( brush.color() );
polyStyle.setFill( true );
style.setLineStyle( lineStyle );
style.setPolyStyle( polyStyle );
style.setId( "default" );
style->setLineStyle( lineStyle );
style->setPolyStyle( polyStyle );
style->setId( "default" );
GeoDataStyleMap styleMap;
styleMap.setId("default-map");
styleMap.insert( "normal", QString("#").append(style.id()) );
styleMap.insert( "normal", QString("#").append(style->id()) );
doc->addStyle( style );
doc->addStyleMap( styleMap );
......
......@@ -143,7 +143,7 @@ QVariant MarblePlacemarkModel::data( const QModelIndex &index, int role ) const
} else if ( role == CoordinateRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->coordinate() );
} else if ( role == StyleRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->style() );
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->style().data() );
} else if ( role == GmtRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->extendedData().value("gmt").value() );
} else if ( role == DstRole ) {
......
......@@ -284,7 +284,7 @@ int PlacemarkLayout::maxLabelHeight() const
QModelIndex index = m_placemarkModel.index( i, 0 );
const GeoDataPlacemark *placemark = dynamic_cast<GeoDataPlacemark*>(qvariant_cast<GeoDataObject*>(index.data( MarblePlacemarkModel::ObjectPointerRole ) ));
if ( placemark ) {
const GeoDataStyle* style = placemark->style();
GeoDataStyle::ConstPtr style = placemark->style();
QFont labelFont = style->labelStyle().scaledFont();
int textHeight = QFontMetrics( labelFont ).height();
if ( textHeight > maxLabelHeight )
......@@ -585,7 +585,7 @@ bool PlacemarkLayout::layoutPlacemark( const GeoDataPlacemark *placemark, qreal
// Find out whether the area around the placemark is covered already.
// If there's not enough space free don't add a VisiblePlacemark here.
const GeoDataStyle* style = placemark->style();
GeoDataStyle::ConstPtr style = placemark->style();
QRectF labelRect;
if( !placemark->name().isEmpty() ) {
......@@ -646,7 +646,7 @@ GeoDataCoordinates PlacemarkLayout::placemarkIconCoordinates( const GeoDataPlace
return GeoDataCoordinates();
}
QRectF PlacemarkLayout::roomForLabel( const GeoDataStyle * style,
QRectF PlacemarkLayout::roomForLabel( const GeoDataStyle::ConstPtr &style,
const qreal x, const qreal y,
const QString &labelText ) const
{
......
......@@ -26,6 +26,7 @@
#include <QSortFilterProxyModel>
#include "GeoDataFeature.h"
#include <GeoDataStyle.h>
class QAbstractItemModel;
class QItemSelectionModel;
......@@ -37,7 +38,6 @@ namespace Marble
class GeoDataCoordinates;
class GeoDataPlacemark;
class GeoDataStyle;
class GeoPainter;
class MarbleClock;
class PlacemarkPainter;
......@@ -123,7 +123,7 @@ class PlacemarkLayout : public QObject
*/
GeoDataCoordinates placemarkIconCoordinates( const GeoDataPlacemark *placemark ) const;
QRectF roomForLabel( const GeoDataStyle * style,
QRectF roomForLabel(const GeoDataStyle::ConstPtr &style,
const qreal x, const qreal y,
const QString &labelText ) const;
......
......@@ -153,18 +153,18 @@ PositionTracking::PositionTracking( GeoDataTreeModel *model )
d->m_currentTrackPlacemark->setGeometry(d->m_trackSegments);
d->m_currentTrackPlacemark->setName("Current Track");
GeoDataStyle style;
GeoDataStyle::Ptr style(new GeoDataStyle);
GeoDataLineStyle lineStyle;
QColor transparentRed = Oxygen::brickRed4;
transparentRed.setAlpha( 200 );
lineStyle.setColor( transparentRed );
lineStyle.setWidth( 4 );
style.setLineStyle(lineStyle);
style.setId("track");
style->setLineStyle(lineStyle);
style->setId("track");
GeoDataStyleMap styleMap;
styleMap.setId("map-track");
styleMap.insert("normal", QString("#").append(style.id()));
styleMap.insert("normal", QString("#").append(style->id()));
d->m_document.addStyleMap(styleMap);
d->m_document.addStyle(style);
d->m_document.append( d->m_currentTrackPlacemark );
......@@ -267,7 +267,7 @@ bool PositionTracking::saveTrack( const QString& fileName )
QFileInfo fileInfo( fileName );
QString name = fileInfo.baseName();
document->setName( name );
foreach( const GeoDataStyle &style, d->m_document.styles() ) {
foreach( const GeoDataStyle::Ptr &style, d->m_document.styles() ) {
document->addStyle( style );
}
foreach( const GeoDataStyleMap &map, d->m_document.styleMaps() ) {
......
......@@ -471,7 +471,7 @@ void TourWidgetPrivate::addPlacemark()
placemark->setBalloonVisible( true );
GeoDataStyle *newStyle = new GeoDataStyle( *placemark->style() );
newStyle->iconStyle().setIconPath( MarbleDirs::path("bitmaps/redflag_22.png") );
placemark->setStyle( newStyle );
placemark->setStyle( GeoDataStyle::Ptr(newStyle) );
document->append( placemark );
......
......@@ -28,7 +28,7 @@ VisiblePlacemark::VisiblePlacemark( const GeoDataPlacemark *placemark )
: m_placemark( placemark ),
m_selected( false )
{
const GeoDataStyle *style = m_placemark->style();
GeoDataStyle::ConstPtr style = m_placemark->style();
const RemoteIconLoader *remoteLoader = style->iconStyle().remoteIconLoader();
QObject::connect( remoteLoader, SIGNAL(iconReady()),
this, SLOT(setSymbolPixmap()) );
......@@ -110,7 +110,7 @@ const QPixmap& VisiblePlacemark::labelPixmap() const
void VisiblePlacemark::setSymbolPixmap()
{
const GeoDataStyle *style = m_placemark->style();
GeoDataStyle::ConstPtr style = m_placemark->style();
if ( style ) {
m_symbolPixmap = QPixmap::fromImage( style->iconStyle().scaledIcon() );
......@@ -133,7 +133,7 @@ void VisiblePlacemark::setLabelRect( const QRectF& labelRect )
void VisiblePlacemark::drawLabelPixmap()
{
const GeoDataStyle* style = m_placemark->style();
GeoDataStyle::ConstPtr style = m_placemark->style();
QString labelName = m_placemark->name();
if ( labelName.isEmpty() || style->labelStyle().color() == QColor(Qt::transparent) ) {
......
......@@ -62,15 +62,34 @@ const GeoDataDocumentPrivate* GeoDataDocument::p() const
bool GeoDataDocument::operator==( const GeoDataDocument &other ) const
{
return GeoDataContainer::equals(other) &&
p()->m_styleHash == other.p()->m_styleHash &&
p()->m_styleMapHash == other.p()->m_styleMapHash &&
p()->m_schemaHash == other.p()->m_schemaHash &&
p()->m_filename == other.p()->m_filename &&
p()->m_baseUri == other.p()->m_baseUri &&
p()->m_networkLinkControl == other.p()->m_networkLinkControl &&
p()->m_property == other.p()->m_property &&
p()->m_documentRole == other.p()->m_documentRole;
if (!GeoDataContainer::equals(other)) {
return false;
}
if (!(p()->m_styleHash.size() == other.p()->m_styleHash.size() &&
p()->m_styleMapHash == other.p()->m_styleMapHash &&
p()->m_schemaHash == other.p()->m_schemaHash &&
p()->m_filename == other.p()->m_filename &&
p()->m_baseUri == other.p()->m_baseUri &&
p()->m_networkLinkControl == other.p()->m_networkLinkControl &&
p()->m_property == other.p()->m_property &&
p()->m_documentRole == other.p()->m_documentRole)) {
return false;
}
auto iter = p()->m_styleHash.constBegin();
auto const end = p()->m_styleHash.constEnd();
for (; iter != end; ++iter) {
if (!other.p()->m_styleHash.contains(iter.key())) {
return false;
}
if (*iter.value() != *other.p()->m_styleHash[iter.key()]) {
return false;
}
}
return true;
}
bool GeoDataDocument::operator!=( const GeoDataDocument &other ) const
......@@ -131,11 +150,11 @@ void GeoDataDocument::setNetworkLinkControl( const GeoDataNetworkLinkControl &ne
p()->m_networkLinkControl = networkLinkControl;
}
void GeoDataDocument::addStyle( const GeoDataStyle& style )
void GeoDataDocument::addStyle( const GeoDataStyle::Ptr &style )
{
detach();
p()->m_styleHash.insert( style.id(), style );
p()->m_styleHash[ style.id() ].setParent( this );
p()->m_styleHash.insert( style->id(), style );
p()->m_styleHash[ style->id() ]->setParent( this );
}
void GeoDataDocument::removeStyle( const QString& styleId )
......@@ -144,7 +163,7 @@ void GeoDataDocument::removeStyle( const QString& styleId )
p()->m_styleHash.remove( styleId );
}
GeoDataStyle& GeoDataDocument::style( const QString& styleId )
GeoDataStyle::Ptr GeoDataDocument::style( const QString& styleId )
{
/*
* FIXME: m_styleHash always should contain at least default
......@@ -153,13 +172,24 @@ GeoDataStyle& GeoDataDocument::style( const QString& styleId )
return p()->m_styleHash[ styleId ];
}
GeoDataStyle GeoDataDocument::style( const QString &styleId ) const
GeoDataStyle::ConstPtr GeoDataDocument::style( const QString &styleId ) const
{
return p()->m_styleHash.value( styleId );
}
QList<GeoDataStyle> GeoDataDocument::styles() const
QList<GeoDataStyle::ConstPtr> GeoDataDocument::styles() const
{
QList<GeoDataStyle::ConstPtr> result;
foreach(auto const & style, p()->m_styleHash.values()) {
result << style;
}
return result;
}
QList<GeoDataStyle::Ptr> GeoDataDocument::styles()
{
detach();
return p()->m_styleHash.values();
}
......@@ -227,11 +257,11 @@ void GeoDataDocument::pack( QDataStream& stream ) const
stream << p()->m_styleHash.size();
for( QMap<QString, GeoDataStyle>::const_iterator iterator
for( QMap<QString, GeoDataStyle::