Skip to content

Commit

Permalink
indentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Oct 19, 2014
1 parent c81a27e commit 8d3654b
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
inputFields = layer.pendingFields()
fieldIdxs = []
fields = fields.split(',')
for f in fields:
idx = inputFields.indexFromName(f)
for f in fields:
idx = inputFields.indexFromName(f)
if idx == -1:
raise GeoAlgorithmExecutionException('Field not found:' + f)
fieldIdxs.append(idx)
Expand All @@ -24,12 +24,12 @@
nFeats = len(feats)
counts = defaultdict(int)
for i, feat in enumerate(feats):
progress.setPercentage(int(100 * i / nFeats))
progress.setPercentage(int(100 * i / nFeats))
attrs = feat.attributes()
clazz = tuple([attrs[idx] for idx in fieldIdxs])
print clazz
counts[clazz] += 1

for c in counts:
for c in counts:
writer.addRecord(list(c) + [counts[c]])

2 changes: 1 addition & 1 deletion src/app/composer/qgscomposermapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QgsComposerItemBaseWidget( 0, composerMap ), mComposerMap( composerMap )
{
setupUi( this );

mLabel->setText( tr( "Map %1" ).arg( composerMap->id() ) );

//add widget for general composer item properties
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsfeatureaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class APP_EXPORT QgsFeatureAction : public QAction
*
* @return true if feature was added if showModal is true. If showModal is false, returns true in every case
*/
bool addFeature(const QgsAttributeMap& defaultAttributes = QgsAttributeMap() , bool showModal = true );
bool addFeature( const QgsAttributeMap& defaultAttributes = QgsAttributeMap() , bool showModal = true );

private slots:
void onFeatureSaved( const QgsFeature& feature );
Expand Down
18 changes: 9 additions & 9 deletions src/app/qgsfieldsproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ QTreeWidgetItem *QgsFieldsProperties::loadAttributeEditorTreeItem( QgsAttributeE

const QgsAttributeEditorContainer* container = dynamic_cast<const QgsAttributeEditorContainer*>( widgetDef );

Q_FOREACH( QgsAttributeEditorElement* wdg, container->children() )
Q_FOREACH ( QgsAttributeEditorElement* wdg, container->children() )
{
loadAttributeEditorTreeItem( wdg, newWidget );
}
Expand All @@ -187,7 +187,7 @@ void QgsFieldsProperties::loadAttributeEditorTree()
mDesignerTree->setAcceptDrops( true );
mDesignerTree->setDragDropMode( QAbstractItemView::DragDrop );

Q_FOREACH( QgsAttributeEditorElement* wdg, mLayer->attributeEditorElements() )
Q_FOREACH ( QgsAttributeEditorElement* wdg, mLayer->attributeEditorElements() )
{
loadAttributeEditorTreeItem( wdg, mDesignerTree->invisibleRootItem() );
}
Expand Down Expand Up @@ -272,7 +272,7 @@ void QgsFieldsProperties::loadRelations()

int idx = 0;

Q_FOREACH( const QgsRelation& relation, relations )
Q_FOREACH ( const QgsRelation& relation, relations )
{
mRelationsList->insertRow( idx );

Expand Down Expand Up @@ -310,7 +310,7 @@ void QgsFieldsProperties::on_mAddItemButton_clicked()
if ( parent->data( 0, DesignerTreeRole ).value<DesignerTreeItemData>().type() != DesignerTreeItemData::Container )
return;

Q_FOREACH( QTableWidgetItem* item, listItems )
Q_FOREACH ( QTableWidgetItem* item, listItems )
{
if ( item->column() == 0 ) // Information is in the first column
mDesignerTree->addItem( parent , item->data( DesignerTreeRole ).value<DesignerTreeItemData>() );
Expand Down Expand Up @@ -409,7 +409,7 @@ void QgsFieldsProperties::attributeTypeDialog()
int index = -1;
int row = -1;

Q_FOREACH( QTableWidgetItem* wdg, mIndexedWidgets )
Q_FOREACH ( QTableWidgetItem* wdg, mIndexedWidgets )
{
cfg = wdg->data( FieldConfigRole ).value<FieldConfig>();
if ( cfg.mButton == pb )
Expand Down Expand Up @@ -542,7 +542,7 @@ void QgsFieldsProperties::on_mDeleteAttributeButton_clicked()
{
QSet<int> providerFields;
QSet<int> expressionFields;
Q_FOREACH( QTableWidgetItem* item, mFieldsList->selectedItems() )
Q_FOREACH ( QTableWidgetItem* item, mFieldsList->selectedItems() )
{
if ( item->column() == 0 )
{
Expand Down Expand Up @@ -588,7 +588,7 @@ void QgsFieldsProperties::updateButtons()
mDeleteAttributeButton->setEnabled( mFieldsList->selectedItems().count() > 0 );

// and only if all selected items have their origin in an expression
Q_FOREACH( QTableWidgetItem* item, mFieldsList->selectedItems() )
Q_FOREACH ( QTableWidgetItem* item, mFieldsList->selectedItems() )
{
if ( item->column() == 0 )
{
Expand Down Expand Up @@ -841,7 +841,7 @@ QMimeData* QgsFieldsProperties::DragList::mimeData( const QList<QTableWidgetItem
QByteArray encoded;
QDataStream stream( &encoded, QIODevice::WriteOnly );

Q_FOREACH( const QTableWidgetItem* item, items )
Q_FOREACH ( const QTableWidgetItem* item, items )
{
// Relevant information is always in the UserRole of the first column
if ( item && item->column() == 0 )
Expand Down Expand Up @@ -1011,7 +1011,7 @@ QMimeData* QgsFieldsProperties::DesignerTree::mimeData( const QList<QTreeWidgetI
QByteArray encoded;
QDataStream stream( &encoded, QIODevice::WriteOnly );

Q_FOREACH( const QTreeWidgetItem* item, items )
Q_FOREACH ( const QTreeWidgetItem* item, items )
{
if ( item )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptooladdfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ class APP_EXPORT QgsMapToolAddFeature : public QgsMapToolCapture
virtual ~QgsMapToolAddFeature();
void canvasReleaseEvent( QMouseEvent * e );

bool addFeature(QgsVectorLayer *vlayer, QgsFeature *f , bool showModal = true );
bool addFeature( QgsVectorLayer *vlayer, QgsFeature *f , bool showModal = true );
void activate();
};
2 changes: 1 addition & 1 deletion src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ QDomDocument QgsMapLayer::asLayerDefinition( QList<QgsMapLayer *> layers, QStrin
foreach ( QgsMapLayer* layer, layers )
{
QDomElement layerelm = doc.createElement( "maplayer" );
layer->writeLayerXML( layerelm, doc, relativeBasePath );
layer->writeLayerXML( layerelm, doc, relativeBasePath );
layerelm.removeChild( layerelm.firstChildElement( "id" ) );
layerselm.appendChild( layerelm );
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,7 @@ bool QgsVectorLayer::deleteAttributes( QList<int> attrs )

qSort( attrs.begin(), attrs.end(), qGreater<int>() );

Q_FOREACH( int attr, attrs )
Q_FOREACH ( int attr, attrs )
{
if ( deleteAttribute( attr ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ void QgsRasterInterface::cumulativeCut( int theBandNo,

//get band stats to specify real histogram min/max (fix #9793 Byte bands)
QgsRasterBandStats stats = bandStatistics( theBandNo, QgsRasterBandStats::Min, theExtent, theSampleSize );
if( stats.maximumValue < stats.minimumValue )
if ( stats.maximumValue < stats.minimumValue )
return;

// for byte bands make sure bin count == actual range
Expand Down
42 changes: 21 additions & 21 deletions src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ void QgsRendererRangeV2::toSld( QDomDocument &doc, QDomElement &element, QgsStri

///////////

int QgsRendererRangeV2LabelFormat::MaxPrecision=15;
int QgsRendererRangeV2LabelFormat::MinPrecision=-6;
int QgsRendererRangeV2LabelFormat::MaxPrecision = 15;
int QgsRendererRangeV2LabelFormat::MinPrecision = -6;

QgsRendererRangeV2LabelFormat::QgsRendererRangeV2LabelFormat():
mFormat( " %1 - %2 " ),
Expand All @@ -179,13 +179,13 @@ QgsRendererRangeV2LabelFormat::QgsRendererRangeV2LabelFormat():
mNumberScale( 1.0 ),
mNumberSuffix( "" ),
mReTrailingZeroes( "[.,]?0*$" ),
mReNegativeZero("^\\-0(?:[.,]0*)?$")
mReNegativeZero( "^\\-0(?:[.,]0*)?$" )
{
}

QgsRendererRangeV2LabelFormat::QgsRendererRangeV2LabelFormat( QString format, int precision, bool trimTrailingZeroes ):
mReTrailingZeroes( "[.,]?0*$" ),
mReNegativeZero("^\\-0(?:[.,]0*)?$")
mReNegativeZero( "^\\-0(?:[.,]0*)?$" )
{
setFormat( format );
setPrecision( precision );
Expand All @@ -212,13 +212,13 @@ void QgsRendererRangeV2LabelFormat::setPrecision( int precision )
if ( precision < MinPrecision ) precision = MinPrecision;
if ( precision > MaxPrecision ) precision = MaxPrecision;
mPrecision = precision;
mNumberScale=1.0;
mNumberSuffix="";
while( precision < 0 )
mNumberScale = 1.0;
mNumberSuffix = "";
while ( precision < 0 )
{
precision++;
mNumberScale /= 10.0;
mNumberSuffix.append('0');
mNumberSuffix.append( '0' );
}
}

Expand All @@ -229,29 +229,29 @@ QString QgsRendererRangeV2LabelFormat::labelForRange( const QgsRendererRangeV2 &

QString QgsRendererRangeV2LabelFormat::formatNumber( double value ) const
{
if( mPrecision > 0 )
if ( mPrecision > 0 )
{
QString valueStr=QString::number( value, 'f', mPrecision );
if( mTrimTrailingZeroes ) valueStr=valueStr.replace(mReTrailingZeroes,"");
if( mReNegativeZero.exactMatch(valueStr)) valueStr=valueStr.mid(1);
QString valueStr = QString::number( value, 'f', mPrecision );
if ( mTrimTrailingZeroes ) valueStr = valueStr.replace( mReTrailingZeroes, "" );
if ( mReNegativeZero.exactMatch( valueStr ) ) valueStr = valueStr.mid( 1 );
return valueStr;
}
else
{
QString valueStr=QString::number( value*mNumberScale, 'f', 0 );
if( valueStr == "-0" ) valueStr="0";
if( valueStr != "0" ) valueStr=valueStr+mNumberSuffix;
QString valueStr = QString::number( value * mNumberScale, 'f', 0 );
if ( valueStr == "-0" ) valueStr = "0";
if ( valueStr != "0" ) valueStr = valueStr + mNumberSuffix;
return valueStr;
}
}

QString QgsRendererRangeV2LabelFormat::labelForRange( double lower, double upper ) const
{
QString lowerStr=formatNumber(lower);
QString upperStr=formatNumber(upper);
QString lowerStr = formatNumber( lower );
QString upperStr = formatNumber( upper );

QString legend(mFormat);
return legend.replace( "%1",lowerStr).replace("%2",upperStr );
QString legend( mFormat );
return legend.replace( "%1", lowerStr ).replace( "%2", upperStr );
}

void QgsRendererRangeV2LabelFormat::setFromDomElement( QDomElement &element )
Expand All @@ -261,7 +261,7 @@ void QgsRendererRangeV2LabelFormat::setFromDomElement( QDomElement &element )
element.attribute( "separator", " - " ) + "%2" +
element.attribute( "suffix", " " )
);
setPrecision( element.attribute( "decimalplaces", "4" ).toInt());
setPrecision( element.attribute( "decimalplaces", "4" ).toInt() );
mTrimTrailingZeroes = element.attribute( "trimtrailingzeroes", "false" ) == "true";
}

Expand Down Expand Up @@ -1113,7 +1113,7 @@ QgsFeatureRendererV2* QgsGraduatedSymbolRendererV2::create( QDomElement& element
double upperValue = rangeElem.attribute( "upper" ).toDouble();
QString symbolName = rangeElem.attribute( "symbol" );
QString label = rangeElem.attribute( "label" );
bool render=rangeElem.attribute("render","true") != "false";
bool render = rangeElem.attribute( "render", "true" ) != "false";
if ( symbolMap.contains( symbolName ) )
{
QgsSymbolV2* symbol = symbolMap.take( symbolName );
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsvectorcolorrampv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

static QColor _interpolate( QColor c1, QColor c2, double value )
{
if ( qIsNaN(value) ) value = 1;
if ( qIsNaN( value ) ) value = 1;
int r = ( int )( c1.red() + value * ( c2.red() - c1.red() ) );
int g = ( int )( c1.green() + value * ( c2.green() - c1.green() ) );
int b = ( int )( c1.blue() + value * ( c2.blue() - c1.blue() ) );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgscredentialdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void QgsCredentialDialog::requestCredentials( QString realm, QString *username,

QApplication::restoreOverrideCursor();

if( activeWindow )
if ( activeWindow )
activeWindow->raise();

if ( *ok )
Expand Down
20 changes: 10 additions & 10 deletions src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ QVariant QgsGraduatedSymbolRendererV2Model::data( const QModelIndex &index, int
switch ( index.column() )
{
case 1:
{
int decimalPlaces=mRenderer->labelFormat().precision()+2;
if( decimalPlaces < 0 ) decimalPlaces=0;
return QString::number( range.lowerValue(), 'f', decimalPlaces ) + " - " + QString::number( range.upperValue(), 'f', decimalPlaces );
}
{
int decimalPlaces = mRenderer->labelFormat().precision() + 2;
if ( decimalPlaces < 0 ) decimalPlaces = 0;
return QString::number( range.lowerValue(), 'f', decimalPlaces ) + " - " + QString::number( range.upperValue(), 'f', decimalPlaces );
}
case 2: return range.label();
default: return QVariant();
}
Expand All @@ -149,7 +149,7 @@ QVariant QgsGraduatedSymbolRendererV2Model::data( const QModelIndex &index, int
{
switch ( index.column() )
{
// case 1: return rangeStr;
// case 1: return rangeStr;
case 2: return range.label();
default: return QVariant();
}
Expand Down Expand Up @@ -399,8 +399,8 @@ QgsGraduatedSymbolRendererV2Widget::QgsGraduatedSymbolRendererV2Widget( QgsVecto

cboGraduatedColorRamp->populate( mStyle );

spinPrecision->setMinimum( QgsRendererRangeV2LabelFormat::MinPrecision);
spinPrecision->setMaximum( QgsRendererRangeV2LabelFormat::MaxPrecision);
spinPrecision->setMinimum( QgsRendererRangeV2LabelFormat::MinPrecision );
spinPrecision->setMaximum( QgsRendererRangeV2LabelFormat::MaxPrecision );

// set project default color ramp
QString defaultColorRamp = QgsProject::instance()->readEntry( "DefaultStyles", "/ColorRamp", "" );
Expand Down Expand Up @@ -743,8 +743,8 @@ void QgsGraduatedSymbolRendererV2Widget::changeRange( int rangeIdx )
const QgsRendererRangeV2& range = mRenderer->ranges()[rangeIdx];
// Add arbitrary 2 to number of decimal places to retain a bit extra.
// Ensures users can see if legend is not completely honest!
int decimalPlaces = mRenderer->labelFormat().precision()+2;
if( decimalPlaces < 0 ) decimalPlaces=0;
int decimalPlaces = mRenderer->labelFormat().precision() + 2;
if ( decimalPlaces < 0 ) decimalPlaces = 0;
dialog.setLowerValue( QString::number( range.lowerValue(), 'f', decimalPlaces ) );
dialog.setUpperValue( QString::number( range.upperValue(), 'f', decimalPlaces ) );

Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgswmsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ QImage* QgsWMSServer::getLegendGraphics()
{
QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer( layerId );
QgsLayerTreeLayer *layer = rootGroup.addLayer( ml );
if( !ml->title().isEmpty() )
if ( !ml->title().isEmpty() )
layer->setLayerName( ml->title() );
}
QgsLayerTreeModel legendModel( &rootGroup );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause )
}

switch ( mSource->mPrimaryKeyType )
{
{
case pktOid:
query += delim + "oid";
delim = ",";
Expand Down
20 changes: 10 additions & 10 deletions tests/src/python/test_qgsgraduatedsymbolrendererv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@

import qgis
from utilities import (
unittest,
unittest,
TestCase,
getQgisTestApp,
)
from qgis.core import (
QgsGraduatedSymbolRendererV2,
QgsRendererRangeV2,
QgsGraduatedSymbolRendererV2,
QgsRendererRangeV2,
QgsRendererRangeV2LabelFormat,
QgsMarkerSymbolV2,
QgsMarkerSymbolV2,
QgsVectorGradientColorRampV2,
QgsVectorLayer,
QgsFeature,
QgsGeometry,
QgsVectorLayer,
QgsFeature,
QgsGeometry,
QgsPoint,
QgsSymbolV2,
QgsSymbolLayerV2Utils,
Expand Down Expand Up @@ -237,7 +237,7 @@ def testQgsRendererRangeV2LabelFormat_2(self):
"Number format error {0}:{1}:{2} => {3}".format(
precision,trim,value,result))

# Label tests - label format, expected result.
# Label tests - label format, expected result.
# Labels will be evaluated with lower=1.23 upper=2.34, precision=2
ltests=(
("%1 - %2","1.23 - 2.34"),
Expand Down Expand Up @@ -342,8 +342,8 @@ def testQgsGraduatedSymbolRendererV2_1(self):
renderer.setScaleMethod(sm)
self.assertEqual(str(sm),str(renderer.scaleMethod()),
"Get/set renderer scale method")



def testQgsGraduatedSymbolRendererV2_2(self):
"""Test QgsGraduatedSymbolRendererV2: Adding /removing/editing classes """
Expand Down

0 comments on commit 8d3654b

Please sign in to comment.