Skip to content

Commit

Permalink
Changed symbols() from std::list to QList for all renderers
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6863 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Apr 2, 2007
1 parent e34d6a4 commit b234fab
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 59 deletions.
10 changes: 5 additions & 5 deletions src/app/composer/qgscomposervectorlegend.cpp
Expand Up @@ -241,7 +241,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
std::vector<int> groupLayers; // vector of layers
std::vector<int> itemHeights; // maximum item sizes
std::vector<QString> itemLabels; // item labels
unsigned int sectionItemsCount = 0;
int sectionItemsCount = 0;
QString sectionTitle;

for ( int j = nlayers - 1; j >= 0; j-- ) {
Expand All @@ -261,7 +261,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
if ( (group > 0 && group2 == group) || ( group == 0 && j == i ) ) {
groupLayers.push_back(j);

std::list<QgsSymbol*> symbols = renderer->symbols();
QList<QgsSymbol*> symbols = renderer->symbols();

if ( sectionTitle.length() == 0 ) {
sectionTitle = layer2->name();
Expand All @@ -281,7 +281,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
double scale = map->symbolScale() * mComposition->scale();

int icnt = 0;
for ( std::list<QgsSymbol*>::iterator it = symbols.begin(); it != symbols.end(); ++it ) {
for ( QList<QgsSymbol*>::iterator it = symbols.begin(); it != symbols.end(); ++it ) {

QgsSymbol* sym = (*it);

Expand Down Expand Up @@ -343,10 +343,10 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
const QgsRenderer *renderer = vector->renderer();

// Symbol
std::list<QgsSymbol*> symbols = renderer->symbols();
QList<QgsSymbol*> symbols = renderer->symbols();

int icnt = 0;
for ( std::list<QgsSymbol*>::iterator it = symbols.begin(); it != symbols.end(); ++it ) {
for ( QList<QgsSymbol*>::iterator it = symbols.begin(); it != symbols.end(); ++it ) {
localHeight += mSymbolSpace;

int symbolHeight = itemHeights[icnt];
Expand Down
4 changes: 2 additions & 2 deletions src/app/legend/qgslegendlayer.cpp
Expand Up @@ -313,9 +313,9 @@ void QgsLegendLayer::vectorLayerSymbology(const QgsVectorLayer* layer)
//add the new items
QString lw, uv, label;
const QgsRenderer* renderer = layer->renderer();
const std::list<QgsSymbol*> sym = renderer->symbols();
const QList<QgsSymbol*> sym = renderer->symbols();

for(std::list<QgsSymbol*>::const_iterator it=sym.begin(); it!=sym.end(); ++it)
for(QList<QgsSymbol*>::const_iterator it=sym.begin(); it!=sym.end(); ++it)
{
QImage img;
if((*it)->type() == QGis::Point)
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsgraduatedsymboldialog.cpp
Expand Up @@ -74,7 +74,7 @@ QgsGraduatedSymbolDialog::QgsGraduatedSymbolDialog(QgsVectorLayer * layer): QDia

if (renderer)
{
std::list < QgsSymbol * >list = renderer->symbols();
QList < QgsSymbol * >list = renderer->symbols();

//display the classification field
QString classfield="";
Expand All @@ -90,7 +90,7 @@ QgsGraduatedSymbolDialog::QgsGraduatedSymbolDialog(QgsVectorLayer * layer): QDia

numberofclassesspinbox->setValue(list.size());
//fill the items of the renderer into mValues
for(std::list<QgsSymbol*>::iterator it=list.begin();it!=list.end();++it)
for(QList<QgsSymbol*>::iterator it=list.begin();it!=list.end();++it)
{
//todo: make an assignment operator and a copy constructor for QgsSymbol
QString classbreak=(*it)->lowerValue()+" - "+(*it)->upperValue();
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsuniquevaluedialog.cpp
Expand Up @@ -61,9 +61,9 @@ QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVect
int classattr = *iter;
mClassificationComboBox->setCurrentItem(classattr);

const std::list<QgsSymbol*> list = renderer->symbols();
const QList<QgsSymbol*> list = renderer->symbols();
//fill the items of the renderer into mValues
for(std::list<QgsSymbol*>::const_iterator iter=list.begin();iter!=list.end();++iter)
for(QList<QgsSymbol*>::const_iterator iter=list.begin();iter!=list.end();++iter)
{
QgsSymbol* symbol=(*iter);
QString symbolvalue=symbol->lowerValue();
Expand Down
8 changes: 4 additions & 4 deletions src/core/renderer/qgscontinuouscolorrenderer.cpp
Expand Up @@ -255,11 +255,11 @@ bool QgsContinuousColorRenderer::writeXML( QDomNode & layer_node, QDomDocument &
return returnval;
}

const std::list<QgsSymbol*> QgsContinuousColorRenderer::symbols() const
const QList<QgsSymbol*> QgsContinuousColorRenderer::symbols() const
{
std::list<QgsSymbol*> list;
list.push_back(mMinimumSymbol);
list.push_back(mMaximumSymbol);
QList<QgsSymbol*> list;
list.append(mMinimumSymbol);
list.append(mMaximumSymbol);
return list;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/renderer/qgscontinuouscolorrenderer.h
Expand Up @@ -67,7 +67,7 @@ class CORE_EXPORT QgsContinuousColorRenderer: public QgsRenderer
/**Returns the renderers name*/
QString name() const;
/**Return symbology items*/
const std::list<QgsSymbol*> symbols() const;
const QList<QgsSymbol*> symbols() const;
QgsRenderer* clone() const;
protected:
/**Number of the classification field (it must be a numerical field)*/
Expand Down
16 changes: 8 additions & 8 deletions src/core/renderer/qgsgraduatedsymbolrenderer.cpp
Expand Up @@ -39,8 +39,8 @@ QgsGraduatedSymbolRenderer::QgsGraduatedSymbolRenderer(const QgsGraduatedSymbolR
{
mVectorType = other.mVectorType;
mClassificationField = other.mClassificationField;
const std::list<QgsSymbol*> s = other.symbols();
for(std::list<QgsSymbol*>::const_iterator it=s.begin(); it!=s.end(); ++it)
const QList<QgsSymbol*> s = other.symbols();
for(QList<QgsSymbol*>::const_iterator it=s.begin(); it!=s.end(); ++it)
{
addSymbol(new QgsSymbol(**it));
}
Expand All @@ -53,8 +53,8 @@ QgsGraduatedSymbolRenderer& QgsGraduatedSymbolRenderer::operator=(const QgsGradu
mVectorType = other.mVectorType;
mClassificationField = other.mClassificationField;
removeSymbols();
const std::list<QgsSymbol*> s = other.symbols();
for(std::list<QgsSymbol*>::const_iterator it=s.begin(); it!=s.end(); ++it)
const QList<QgsSymbol*> s = other.symbols();
for(QList<QgsSymbol*>::const_iterator it=s.begin(); it!=s.end(); ++it)
{
addSymbol(new QgsSymbol(**it));
}
Expand All @@ -68,15 +68,15 @@ QgsGraduatedSymbolRenderer::~QgsGraduatedSymbolRenderer()

}

const std::list<QgsSymbol*> QgsGraduatedSymbolRenderer::symbols() const
const QList<QgsSymbol*> QgsGraduatedSymbolRenderer::symbols() const
{
return mSymbols;
}

void QgsGraduatedSymbolRenderer::removeSymbols()
{
//free the memory first
for (std::list < QgsSymbol * >::iterator it = mSymbols.begin(); it != mSymbols.end(); ++it)
for (QList<QgsSymbol*>::iterator it = mSymbols.begin(); it != mSymbols.end(); ++it)
{
delete *it;
}
Expand Down Expand Up @@ -149,7 +149,7 @@ QgsSymbol* QgsGraduatedSymbolRenderer::symbolForFeature(const QgsFeature* f)
const QgsAttributeMap& attrs = f->attributeMap();
double value = attrs[mClassificationField].toDouble();

std::list < QgsSymbol* >::iterator it;
QList<QgsSymbol*>::iterator it;
//find the first render item which contains the feature
for (it = mSymbols.begin(); it != mSymbols.end(); ++it)
{
Expand Down Expand Up @@ -208,7 +208,7 @@ bool QgsGraduatedSymbolRenderer::writeXML( QDomNode & layer_node, QDomDocument &
QDomText classificationfieldtxt=document.createTextNode(QString::number(mClassificationField));
classificationfield.appendChild(classificationfieldtxt);
graduatedsymbol.appendChild(classificationfield);
for(std::list<QgsSymbol*>::const_iterator it=mSymbols.begin();it!=mSymbols.end();++it)
for (QList<QgsSymbol*>::const_iterator it = mSymbols.begin(); it != mSymbols.end(); ++it)
{
if(!(*it)->writeXML(graduatedsymbol,document))
{
Expand Down
6 changes: 2 additions & 4 deletions src/core/renderer/qgsgraduatedsymbolrenderer.h
Expand Up @@ -19,8 +19,6 @@
#ifndef QGSGRADUATEDSYMBOLRENDERER_H
#define QGSGRADUATEDSYMBOLRENDERER_H

#include <list>

#include "qgsrenderer.h"

class QgsVectorLayer;
Expand Down Expand Up @@ -65,14 +63,14 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer: public QgsRenderer
/**Returns the renderers name*/
QString name() const;
/**Returns the symbols of the items*/
const std::list<QgsSymbol*> symbols() const;
const QList<QgsSymbol*> symbols() const;
/**Returns a copy of the renderer (a deep copy on the heap)*/
QgsRenderer* clone() const;
protected:
/**Index of the classification field (it must be a numerical field)*/
int mClassificationField;
/**List holding the symbols for the individual classes*/
std::list<QgsSymbol*> mSymbols;
QList<QgsSymbol*> mSymbols;
QgsSymbol* symbolForFeature(const QgsFeature* f);

};
Expand Down
5 changes: 1 addition & 4 deletions src/core/renderer/qgsrenderer.h
Expand Up @@ -28,9 +28,6 @@ class QColor;

#include "qgis.h"

#include <list>

class QgsRenderItem;
class QgsSymbol;

typedef QList<int> QgsAttributeList;
Expand Down Expand Up @@ -69,7 +66,7 @@ class CORE_EXPORT QgsRenderer
/**Returns the renderers name*/
virtual QString name() const=0;
/**Return symbology items*/
virtual const std::list<QgsSymbol*> symbols() const=0;
virtual const QList<QgsSymbol*> symbols() const=0;
/**Returns a copy of the renderer (a deep copy on the heap)*/
virtual QgsRenderer* clone() const=0;
/** Change selection color */
Expand Down
6 changes: 3 additions & 3 deletions src/core/renderer/qgssinglesymbolrenderer.cpp
Expand Up @@ -164,10 +164,10 @@ QString QgsSingleSymbolRenderer::name() const
return "Single Symbol";
}

const std::list<QgsSymbol*> QgsSingleSymbolRenderer::symbols() const
const QList<QgsSymbol*> QgsSingleSymbolRenderer::symbols() const
{
std::list<QgsSymbol*> list;
list.push_back(mSymbol);
QList<QgsSymbol*> list;
list.append(mSymbol);
return list;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/renderer/qgssinglesymbolrenderer.h
Expand Up @@ -52,7 +52,7 @@ class CORE_EXPORT QgsSingleSymbolRenderer: public QgsRenderer
/**Returns the renderers name*/
virtual QString name() const;
/**Returns a list containing mSymbol*/
const std::list<QgsSymbol*> symbols() const;
const QList<QgsSymbol*> symbols() const;
/**Returns a deep copy of this renderer*/
QgsRenderer* clone() const;
protected:
Expand Down
40 changes: 20 additions & 20 deletions src/core/renderer/qgsuniquevaluerenderer.cpp
Expand Up @@ -36,11 +36,11 @@ QgsUniqueValueRenderer::QgsUniqueValueRenderer(const QgsUniqueValueRenderer& oth
{
mVectorType = other.mVectorType;
mClassificationField = other.mClassificationField;
std::map<QString, QgsSymbol*> s = other.mSymbols;
for(std::map<QString, QgsSymbol*>::iterator it=s.begin(); it!=s.end(); ++it)
QMap<QString, QgsSymbol*> s = other.mSymbols;
for(QMap<QString, QgsSymbol*>::iterator it=s.begin(); it!=s.end(); ++it)
{
QgsSymbol* s = new QgsSymbol(*(it->second));
insertValue(it->first, s);
QgsSymbol* s = new QgsSymbol(* it.value());
insertValue(it.key(), s);
}
}

Expand All @@ -51,36 +51,36 @@ QgsUniqueValueRenderer& QgsUniqueValueRenderer::operator=(const QgsUniqueValueRe
mVectorType = other.mVectorType;
mClassificationField = other.mClassificationField;
clearValues();
for(std::map<QString, QgsSymbol*>::iterator it=mSymbols.begin(); it!=mSymbols.end(); ++it)
for(QMap<QString, QgsSymbol*>::iterator it=mSymbols.begin(); it!=mSymbols.end(); ++it)
{
QgsSymbol* s = new QgsSymbol(*(it->second));
insertValue(it->first, s);
QgsSymbol* s = new QgsSymbol(*it.value());
insertValue(it.key(), s);
}
}
return *this;
}

QgsUniqueValueRenderer::~QgsUniqueValueRenderer()
{
for(std::map<QString,QgsSymbol*>::iterator it=mSymbols.begin();it!=mSymbols.end();++it)
for(QMap<QString,QgsSymbol*>::iterator it=mSymbols.begin();it!=mSymbols.end();++it)
{
delete it->second;
delete it.value();
}
}

const std::list<QgsSymbol*> QgsUniqueValueRenderer::symbols() const
const QList<QgsSymbol*> QgsUniqueValueRenderer::symbols() const
{
std::list <QgsSymbol*> symbollist;
for(std::map<QString, QgsSymbol*>::const_iterator it = mSymbols.begin(); it!=mSymbols.end(); ++it)
QList <QgsSymbol*> symbollist;
for(QMap<QString, QgsSymbol*>::const_iterator it = mSymbols.begin(); it!=mSymbols.end(); ++it)
{
symbollist.push_back(it->second);
symbollist.append(it.value());
}
return symbollist;
}

void QgsUniqueValueRenderer::insertValue(QString name, QgsSymbol* symbol)
{
mSymbols.insert(std::make_pair(name, symbol));
mSymbols.insert(name, symbol);
}

void QgsUniqueValueRenderer::setClassificationField(int field)
Expand Down Expand Up @@ -155,14 +155,14 @@ QgsSymbol* QgsUniqueValueRenderer::symbolForFeature(const QgsFeature* f)
const QgsAttributeMap& attrs = f->attributeMap();
QString value = attrs[mClassificationField].toString();

std::map<QString,QgsSymbol*>::iterator it=mSymbols.find(value);
QMap<QString,QgsSymbol*>::iterator it=mSymbols.find(value);
if(it == mSymbols.end())
{
return 0;
}
else
{
return it->second;
return it.value();
}
}

Expand All @@ -186,9 +186,9 @@ void QgsUniqueValueRenderer::readXML(const QDomNode& rnode, QgsVectorLayer& vl)

void QgsUniqueValueRenderer::clearValues()
{
for(std::map<QString,QgsSymbol*>::iterator it=mSymbols.begin();it!=mSymbols.end();++it)
for(QMap<QString,QgsSymbol*>::iterator it=mSymbols.begin();it!=mSymbols.end();++it)
{
delete it->second;
delete it.value();
}
mSymbols.clear();
}
Expand All @@ -214,9 +214,9 @@ bool QgsUniqueValueRenderer::writeXML( QDomNode & layer_node, QDomDocument & doc
QDomText classificationfieldtxt=document.createTextNode(QString::number(mClassificationField));
classificationfield.appendChild(classificationfieldtxt);
uniquevalue.appendChild(classificationfield);
for(std::map<QString,QgsSymbol*>::const_iterator it=mSymbols.begin();it!=mSymbols.end();++it)
for(QMap<QString,QgsSymbol*>::const_iterator it=mSymbols.begin();it!=mSymbols.end();++it)
{
if(!(it->second)->writeXML(uniquevalue,document))
if(!(it.value()->writeXML(uniquevalue,document)))
{
returnval=false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/renderer/qgsuniquevaluerenderer.h
Expand Up @@ -19,7 +19,7 @@
#define QGSUNIQUEVALUERENDERER_H

#include "qgsrenderer.h"
#include <map>
#include <QMap>

class CORE_EXPORT QgsUniqueValueRenderer: public QgsRenderer
{
Expand Down Expand Up @@ -54,13 +54,13 @@ class CORE_EXPORT QgsUniqueValueRenderer: public QgsRenderer
/**Returns the index of the classification field*/
int classificationField();
/**Return symbology items*/
const std::list<QgsSymbol*> symbols() const;
const QList<QgsSymbol*> symbols() const;
QgsRenderer* clone() const;
protected:
/**Field index used for classification*/
int mClassificationField;
/**Symbols for the unique values*/
std::map<QString, QgsSymbol*> mSymbols;
QMap<QString, QgsSymbol*> mSymbols;
/**Returns the symbol for a feature or 0 if there isn't any*/
QgsSymbol* symbolForFeature(const QgsFeature* f);
};
Expand Down

0 comments on commit b234fab

Please sign in to comment.