Skip to content
Permalink
Browse files

indentation update

  • Loading branch information
jef-n committed Oct 19, 2014
1 parent c81a27e commit 8d3654baa79bee1e4f0e776cd26253946d26aa3c
@@ -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)
@@ -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]])

@@ -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
@@ -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 );
@@ -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 );
}
@@ -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() );
}
@@ -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 );

@@ -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>() );
@@ -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 )
@@ -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 )
{
@@ -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 )
{
@@ -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 )
@@ -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 )
{
@@ -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();
};
@@ -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 );
}
@@ -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 ) )
{
@@ -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
@@ -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 " ),
@@ -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 );
@@ -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' );
}
}

@@ -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 )
@@ -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";
}

@@ -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 );
@@ -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() ) );
@@ -73,7 +73,7 @@ void QgsCredentialDialog::requestCredentials( QString realm, QString *username,

QApplication::restoreOverrideCursor();

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

if ( *ok )
@@ -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();
}
@@ -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();
}
@@ -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", "" );
@@ -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 ) );

@@ -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 );
@@ -330,7 +330,7 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause )
}

switch ( mSource->mPrimaryKeyType )
{
{
case pktOid:
query += delim + "oid";
delim = ",";
@@ -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,
@@ -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"),
@@ -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 """

0 comments on commit 8d3654b

Please sign in to comment.
You can’t perform that action at this time.