Skip to content

Commit b9fba82

Browse files
author
wonder
committed
Changed symbols() from std::list to QList for all renderers
git-svn-id: http://svn.osgeo.org/qgis/trunk@6863 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5f75690 commit b9fba82

13 files changed

+54
-59
lines changed

src/app/composer/qgscomposervectorlegend.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
241241
std::vector<int> groupLayers; // vector of layers
242242
std::vector<int> itemHeights; // maximum item sizes
243243
std::vector<QString> itemLabels; // item labels
244-
unsigned int sectionItemsCount = 0;
244+
int sectionItemsCount = 0;
245245
QString sectionTitle;
246246

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

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

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

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

286286
QgsSymbol* sym = (*it);
287287

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

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

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

352352
int symbolHeight = itemHeights[icnt];

src/app/legend/qgslegendlayer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ void QgsLegendLayer::vectorLayerSymbology(const QgsVectorLayer* layer)
313313
//add the new items
314314
QString lw, uv, label;
315315
const QgsRenderer* renderer = layer->renderer();
316-
const std::list<QgsSymbol*> sym = renderer->symbols();
316+
const QList<QgsSymbol*> sym = renderer->symbols();
317317

318-
for(std::list<QgsSymbol*>::const_iterator it=sym.begin(); it!=sym.end(); ++it)
318+
for(QList<QgsSymbol*>::const_iterator it=sym.begin(); it!=sym.end(); ++it)
319319
{
320320
QImage img;
321321
if((*it)->type() == QGis::Point)

src/app/qgsgraduatedsymboldialog.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ QgsGraduatedSymbolDialog::QgsGraduatedSymbolDialog(QgsVectorLayer * layer): QDia
7474

7575
if (renderer)
7676
{
77-
std::list < QgsSymbol * >list = renderer->symbols();
77+
QList < QgsSymbol * >list = renderer->symbols();
7878

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

9191
numberofclassesspinbox->setValue(list.size());
9292
//fill the items of the renderer into mValues
93-
for(std::list<QgsSymbol*>::iterator it=list.begin();it!=list.end();++it)
93+
for(QList<QgsSymbol*>::iterator it=list.begin();it!=list.end();++it)
9494
{
9595
//todo: make an assignment operator and a copy constructor for QgsSymbol
9696
QString classbreak=(*it)->lowerValue()+" - "+(*it)->upperValue();

src/app/qgsuniquevaluedialog.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVect
6161
int classattr = *iter;
6262
mClassificationComboBox->setCurrentItem(classattr);
6363

64-
const std::list<QgsSymbol*> list = renderer->symbols();
64+
const QList<QgsSymbol*> list = renderer->symbols();
6565
//fill the items of the renderer into mValues
66-
for(std::list<QgsSymbol*>::const_iterator iter=list.begin();iter!=list.end();++iter)
66+
for(QList<QgsSymbol*>::const_iterator iter=list.begin();iter!=list.end();++iter)
6767
{
6868
QgsSymbol* symbol=(*iter);
6969
QString symbolvalue=symbol->lowerValue();

src/core/renderer/qgscontinuouscolorrenderer.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ bool QgsContinuousColorRenderer::writeXML( QDomNode & layer_node, QDomDocument &
255255
return returnval;
256256
}
257257

258-
const std::list<QgsSymbol*> QgsContinuousColorRenderer::symbols() const
258+
const QList<QgsSymbol*> QgsContinuousColorRenderer::symbols() const
259259
{
260-
std::list<QgsSymbol*> list;
261-
list.push_back(mMinimumSymbol);
262-
list.push_back(mMaximumSymbol);
260+
QList<QgsSymbol*> list;
261+
list.append(mMinimumSymbol);
262+
list.append(mMaximumSymbol);
263263
return list;
264264
}
265265

src/core/renderer/qgscontinuouscolorrenderer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class CORE_EXPORT QgsContinuousColorRenderer: public QgsRenderer
6767
/**Returns the renderers name*/
6868
QString name() const;
6969
/**Return symbology items*/
70-
const std::list<QgsSymbol*> symbols() const;
70+
const QList<QgsSymbol*> symbols() const;
7171
QgsRenderer* clone() const;
7272
protected:
7373
/**Number of the classification field (it must be a numerical field)*/

src/core/renderer/qgsgraduatedsymbolrenderer.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ QgsGraduatedSymbolRenderer::QgsGraduatedSymbolRenderer(const QgsGraduatedSymbolR
3939
{
4040
mVectorType = other.mVectorType;
4141
mClassificationField = other.mClassificationField;
42-
const std::list<QgsSymbol*> s = other.symbols();
43-
for(std::list<QgsSymbol*>::const_iterator it=s.begin(); it!=s.end(); ++it)
42+
const QList<QgsSymbol*> s = other.symbols();
43+
for(QList<QgsSymbol*>::const_iterator it=s.begin(); it!=s.end(); ++it)
4444
{
4545
addSymbol(new QgsSymbol(**it));
4646
}
@@ -53,8 +53,8 @@ QgsGraduatedSymbolRenderer& QgsGraduatedSymbolRenderer::operator=(const QgsGradu
5353
mVectorType = other.mVectorType;
5454
mClassificationField = other.mClassificationField;
5555
removeSymbols();
56-
const std::list<QgsSymbol*> s = other.symbols();
57-
for(std::list<QgsSymbol*>::const_iterator it=s.begin(); it!=s.end(); ++it)
56+
const QList<QgsSymbol*> s = other.symbols();
57+
for(QList<QgsSymbol*>::const_iterator it=s.begin(); it!=s.end(); ++it)
5858
{
5959
addSymbol(new QgsSymbol(**it));
6060
}
@@ -68,15 +68,15 @@ QgsGraduatedSymbolRenderer::~QgsGraduatedSymbolRenderer()
6868

6969
}
7070

71-
const std::list<QgsSymbol*> QgsGraduatedSymbolRenderer::symbols() const
71+
const QList<QgsSymbol*> QgsGraduatedSymbolRenderer::symbols() const
7272
{
7373
return mSymbols;
7474
}
7575

7676
void QgsGraduatedSymbolRenderer::removeSymbols()
7777
{
7878
//free the memory first
79-
for (std::list < QgsSymbol * >::iterator it = mSymbols.begin(); it != mSymbols.end(); ++it)
79+
for (QList<QgsSymbol*>::iterator it = mSymbols.begin(); it != mSymbols.end(); ++it)
8080
{
8181
delete *it;
8282
}
@@ -149,7 +149,7 @@ QgsSymbol* QgsGraduatedSymbolRenderer::symbolForFeature(const QgsFeature* f)
149149
const QgsAttributeMap& attrs = f->attributeMap();
150150
double value = attrs[mClassificationField].toDouble();
151151

152-
std::list < QgsSymbol* >::iterator it;
152+
QList<QgsSymbol*>::iterator it;
153153
//find the first render item which contains the feature
154154
for (it = mSymbols.begin(); it != mSymbols.end(); ++it)
155155
{
@@ -208,7 +208,7 @@ bool QgsGraduatedSymbolRenderer::writeXML( QDomNode & layer_node, QDomDocument &
208208
QDomText classificationfieldtxt=document.createTextNode(QString::number(mClassificationField));
209209
classificationfield.appendChild(classificationfieldtxt);
210210
graduatedsymbol.appendChild(classificationfield);
211-
for(std::list<QgsSymbol*>::const_iterator it=mSymbols.begin();it!=mSymbols.end();++it)
211+
for (QList<QgsSymbol*>::const_iterator it = mSymbols.begin(); it != mSymbols.end(); ++it)
212212
{
213213
if(!(*it)->writeXML(graduatedsymbol,document))
214214
{

src/core/renderer/qgsgraduatedsymbolrenderer.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#ifndef QGSGRADUATEDSYMBOLRENDERER_H
2020
#define QGSGRADUATEDSYMBOLRENDERER_H
2121

22-
#include <list>
23-
2422
#include "qgsrenderer.h"
2523

2624
class QgsVectorLayer;
@@ -65,14 +63,14 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer: public QgsRenderer
6563
/**Returns the renderers name*/
6664
QString name() const;
6765
/**Returns the symbols of the items*/
68-
const std::list<QgsSymbol*> symbols() const;
66+
const QList<QgsSymbol*> symbols() const;
6967
/**Returns a copy of the renderer (a deep copy on the heap)*/
7068
QgsRenderer* clone() const;
7169
protected:
7270
/**Index of the classification field (it must be a numerical field)*/
7371
int mClassificationField;
7472
/**List holding the symbols for the individual classes*/
75-
std::list<QgsSymbol*> mSymbols;
73+
QList<QgsSymbol*> mSymbols;
7674
QgsSymbol* symbolForFeature(const QgsFeature* f);
7775

7876
};

src/core/renderer/qgsrenderer.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ class QColor;
2828

2929
#include "qgis.h"
3030

31-
#include <list>
32-
33-
class QgsRenderItem;
3431
class QgsSymbol;
3532

3633
typedef QList<int> QgsAttributeList;
@@ -69,7 +66,7 @@ class CORE_EXPORT QgsRenderer
6966
/**Returns the renderers name*/
7067
virtual QString name() const=0;
7168
/**Return symbology items*/
72-
virtual const std::list<QgsSymbol*> symbols() const=0;
69+
virtual const QList<QgsSymbol*> symbols() const=0;
7370
/**Returns a copy of the renderer (a deep copy on the heap)*/
7471
virtual QgsRenderer* clone() const=0;
7572
/** Change selection color */

src/core/renderer/qgssinglesymbolrenderer.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ QString QgsSingleSymbolRenderer::name() const
164164
return "Single Symbol";
165165
}
166166

167-
const std::list<QgsSymbol*> QgsSingleSymbolRenderer::symbols() const
167+
const QList<QgsSymbol*> QgsSingleSymbolRenderer::symbols() const
168168
{
169-
std::list<QgsSymbol*> list;
170-
list.push_back(mSymbol);
169+
QList<QgsSymbol*> list;
170+
list.append(mSymbol);
171171
return list;
172172
}
173173

src/core/renderer/qgssinglesymbolrenderer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class CORE_EXPORT QgsSingleSymbolRenderer: public QgsRenderer
5252
/**Returns the renderers name*/
5353
virtual QString name() const;
5454
/**Returns a list containing mSymbol*/
55-
const std::list<QgsSymbol*> symbols() const;
55+
const QList<QgsSymbol*> symbols() const;
5656
/**Returns a deep copy of this renderer*/
5757
QgsRenderer* clone() const;
5858
protected:

src/core/renderer/qgsuniquevaluerenderer.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ QgsUniqueValueRenderer::QgsUniqueValueRenderer(const QgsUniqueValueRenderer& oth
3636
{
3737
mVectorType = other.mVectorType;
3838
mClassificationField = other.mClassificationField;
39-
std::map<QString, QgsSymbol*> s = other.mSymbols;
40-
for(std::map<QString, QgsSymbol*>::iterator it=s.begin(); it!=s.end(); ++it)
39+
QMap<QString, QgsSymbol*> s = other.mSymbols;
40+
for(QMap<QString, QgsSymbol*>::iterator it=s.begin(); it!=s.end(); ++it)
4141
{
42-
QgsSymbol* s = new QgsSymbol(*(it->second));
43-
insertValue(it->first, s);
42+
QgsSymbol* s = new QgsSymbol(* it.value());
43+
insertValue(it.key(), s);
4444
}
4545
}
4646

@@ -51,36 +51,36 @@ QgsUniqueValueRenderer& QgsUniqueValueRenderer::operator=(const QgsUniqueValueRe
5151
mVectorType = other.mVectorType;
5252
mClassificationField = other.mClassificationField;
5353
clearValues();
54-
for(std::map<QString, QgsSymbol*>::iterator it=mSymbols.begin(); it!=mSymbols.end(); ++it)
54+
for(QMap<QString, QgsSymbol*>::iterator it=mSymbols.begin(); it!=mSymbols.end(); ++it)
5555
{
56-
QgsSymbol* s = new QgsSymbol(*(it->second));
57-
insertValue(it->first, s);
56+
QgsSymbol* s = new QgsSymbol(*it.value());
57+
insertValue(it.key(), s);
5858
}
5959
}
6060
return *this;
6161
}
6262

6363
QgsUniqueValueRenderer::~QgsUniqueValueRenderer()
6464
{
65-
for(std::map<QString,QgsSymbol*>::iterator it=mSymbols.begin();it!=mSymbols.end();++it)
65+
for(QMap<QString,QgsSymbol*>::iterator it=mSymbols.begin();it!=mSymbols.end();++it)
6666
{
67-
delete it->second;
67+
delete it.value();
6868
}
6969
}
7070

71-
const std::list<QgsSymbol*> QgsUniqueValueRenderer::symbols() const
71+
const QList<QgsSymbol*> QgsUniqueValueRenderer::symbols() const
7272
{
73-
std::list <QgsSymbol*> symbollist;
74-
for(std::map<QString, QgsSymbol*>::const_iterator it = mSymbols.begin(); it!=mSymbols.end(); ++it)
73+
QList <QgsSymbol*> symbollist;
74+
for(QMap<QString, QgsSymbol*>::const_iterator it = mSymbols.begin(); it!=mSymbols.end(); ++it)
7575
{
76-
symbollist.push_back(it->second);
76+
symbollist.append(it.value());
7777
}
7878
return symbollist;
7979
}
8080

8181
void QgsUniqueValueRenderer::insertValue(QString name, QgsSymbol* symbol)
8282
{
83-
mSymbols.insert(std::make_pair(name, symbol));
83+
mSymbols.insert(name, symbol);
8484
}
8585

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

158-
std::map<QString,QgsSymbol*>::iterator it=mSymbols.find(value);
158+
QMap<QString,QgsSymbol*>::iterator it=mSymbols.find(value);
159159
if(it == mSymbols.end())
160160
{
161161
return 0;
162162
}
163163
else
164164
{
165-
return it->second;
165+
return it.value();
166166
}
167167
}
168168

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

187187
void QgsUniqueValueRenderer::clearValues()
188188
{
189-
for(std::map<QString,QgsSymbol*>::iterator it=mSymbols.begin();it!=mSymbols.end();++it)
189+
for(QMap<QString,QgsSymbol*>::iterator it=mSymbols.begin();it!=mSymbols.end();++it)
190190
{
191-
delete it->second;
191+
delete it.value();
192192
}
193193
mSymbols.clear();
194194
}
@@ -214,9 +214,9 @@ bool QgsUniqueValueRenderer::writeXML( QDomNode & layer_node, QDomDocument & doc
214214
QDomText classificationfieldtxt=document.createTextNode(QString::number(mClassificationField));
215215
classificationfield.appendChild(classificationfieldtxt);
216216
uniquevalue.appendChild(classificationfield);
217-
for(std::map<QString,QgsSymbol*>::const_iterator it=mSymbols.begin();it!=mSymbols.end();++it)
217+
for(QMap<QString,QgsSymbol*>::const_iterator it=mSymbols.begin();it!=mSymbols.end();++it)
218218
{
219-
if(!(it->second)->writeXML(uniquevalue,document))
219+
if(!(it.value()->writeXML(uniquevalue,document)))
220220
{
221221
returnval=false;
222222
}

src/core/renderer/qgsuniquevaluerenderer.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define QGSUNIQUEVALUERENDERER_H
2020

2121
#include "qgsrenderer.h"
22-
#include <map>
22+
#include <QMap>
2323

2424
class CORE_EXPORT QgsUniqueValueRenderer: public QgsRenderer
2525
{
@@ -54,13 +54,13 @@ class CORE_EXPORT QgsUniqueValueRenderer: public QgsRenderer
5454
/**Returns the index of the classification field*/
5555
int classificationField();
5656
/**Return symbology items*/
57-
const std::list<QgsSymbol*> symbols() const;
57+
const QList<QgsSymbol*> symbols() const;
5858
QgsRenderer* clone() const;
5959
protected:
6060
/**Field index used for classification*/
6161
int mClassificationField;
6262
/**Symbols for the unique values*/
63-
std::map<QString, QgsSymbol*> mSymbols;
63+
QMap<QString, QgsSymbol*> mSymbols;
6464
/**Returns the symbol for a feature or 0 if there isn't any*/
6565
QgsSymbol* symbolForFeature(const QgsFeature* f);
6666
};

0 commit comments

Comments
 (0)