Skip to content

Commit

Permalink
Fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Oct 20, 2011
1 parent 847204e commit 188d733
Show file tree
Hide file tree
Showing 8 changed files with 416 additions and 415 deletions.
44 changes: 22 additions & 22 deletions src/app/qgslabelinggui.cpp
Expand Up @@ -47,7 +47,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
connect( btnBufferColor, SIGNAL( clicked() ), this, SLOT( changeBufferColor() ) );
connect( spinBufferSize, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ) );
connect( btnEngineSettings, SIGNAL( clicked() ), this, SLOT( showEngineConfigDialog() ) );
connect( btnExpression, SIGNAL(clicked()), this, SLOT( showExpressionDialog()));
connect( btnExpression, SIGNAL( clicked() ), this, SLOT( showExpressionDialog() ) );

// set placement methods page based on geometry type
switch ( layer->geometryType() )
Expand Down Expand Up @@ -83,8 +83,8 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
btnExpression->setEnabled( lyr.enabled );

//Add the current expression to the bottom of the list.
if (lyr.isExpression && !lyr.fieldName.isEmpty())
cboFieldName->addItem(lyr.fieldName);
if ( lyr.isExpression && !lyr.fieldName.isEmpty() )
cboFieldName->addItem( lyr.fieldName );

// placement
int distUnitIndex = lyr.distInMapUnits ? 1 : 0;
Expand Down Expand Up @@ -212,13 +212,13 @@ QgsLabelingGui::~QgsLabelingGui()

void QgsLabelingGui::apply()
{
QgsPalLayerSettings settings = layerSettings();
settings.writeToLayer( mLayer );
// trigger refresh
if ( mMapCanvas )
{
mMapCanvas->refresh();
}
QgsPalLayerSettings settings = layerSettings();
settings.writeToLayer( mLayer );
// trigger refresh
if ( mMapCanvas )
{
mMapCanvas->refresh();
}
}

QgsPalLayerSettings QgsLabelingGui::layerSettings()
Expand Down Expand Up @@ -494,20 +494,20 @@ void QgsLabelingGui::showEngineConfigDialog()

void QgsLabelingGui::showExpressionDialog()
{
//TODO extract this out to a dialog.
QgsExpressionBuilderDialog dlg( mLayer, cboFieldName->currentText() , this );
dlg.setWindowTitle( tr("Expression based label") );
if ( dlg.exec() == QDialog::Accepted )
//TODO extract this out to a dialog.
QgsExpressionBuilderDialog dlg( mLayer, cboFieldName->currentText() , this );
dlg.setWindowTitle( tr( "Expression based label" ) );
if ( dlg.exec() == QDialog::Accepted )
{
QString expression = dlg.expressionBuilder()->getExpressionString();
//Only add the expression if the user has entered some text.
if ( !expression.isEmpty() )
{
QString expression = dlg.expressionBuilder()->getExpressionString();
//Only add the expression if the user has entered some text.
if (!expression.isEmpty())
{
cboFieldName->addItem(expression);
cboFieldName->setCurrentIndex(cboFieldName->count() - 1);
}
cboFieldName->addItem( expression );
cboFieldName->setCurrentIndex( cboFieldName->count() - 1 );
}
}
}
}

void QgsLabelingGui::updateUi()
{
Expand Down
22 changes: 11 additions & 11 deletions src/core/qgsexpression.cpp
Expand Up @@ -375,9 +375,9 @@ typedef QgsExpression::FunctionDef FnDef;
FnDef QgsExpression::BuiltinFunctions[] =
{
// math
FnDef( "sqrt", 1, fcnSqrt, "Math"),
FnDef( "sqrt", 1, fcnSqrt, "Math" ),
FnDef( "sin", 1, fcnSin, "Math" ),
FnDef( "cos", 1, fcnCos, "Math"),
FnDef( "cos", 1, fcnCos, "Math" ),
FnDef( "tan", 1, fcnTan, "Math" ),
FnDef( "asin", 1, fcnAsin, "Math" ),
FnDef( "acos", 1, fcnAcos, "Math" ),
Expand All @@ -393,15 +393,15 @@ FnDef QgsExpression::BuiltinFunctions[] =
FnDef( "tostring", 1, fcnToString, "Conversions" ),
// string manipulation
FnDef( "lower", 1, fcnLower, "String", "<b>Convert to lower case</b> "\
"<br> Converts a string to lower case letters. " \
"<br> <i>Usage:</i><br>lower('HELLO WORLD') will return 'hello world'"),
"<br> Converts a string to lower case letters. " \
"<br> <i>Usage:</i><br>lower('HELLO WORLD') will return 'hello world'" ),
FnDef( "upper", 1, fcnUpper, "String" , "<b>Convert to upper case</b> "\
"<br> Converts a string to upper case letters. " \
"<br> <i>Usage:</i><br>upper('hello world') will return 'HELLO WORLD'"),
"<br> Converts a string to upper case letters. " \
"<br> <i>Usage:</i><br>upper('hello world') will return 'HELLO WORLD'" ),
FnDef( "length", 1, fcnLength, "String", "<b>Length of string</b> "\
"<br> Returns the legnth of a string. " \
"<br> <i>Usage:</i><br>length('hello') will return 5"),
FnDef( "replace", 3, fcnReplace, "String", "<b>Replace a section of a string.</b> "),
"<br> Returns the legnth of a string. " \
"<br> <i>Usage:</i><br>length('hello') will return 5" ),
FnDef( "replace", 3, fcnReplace, "String", "<b>Replace a section of a string.</b> " ),
FnDef( "regexp_replace", 3, fcnRegexpReplace, "String" ),
FnDef( "substr", 3, fcnSubstr, "String" ),
// geometry accessors
Expand All @@ -414,7 +414,7 @@ FnDef QgsExpression::BuiltinFunctions[] =
FnDef( "$y", 0, fcnY, "Geometry", "" , true ),
// special columns
FnDef( "$rownum", 0, fcnRowNumber, "Record" ),
FnDef( "$id", 0, fcnFeatureId, "Record")
FnDef( "$id", 0, fcnFeatureId, "Record" )
};


Expand All @@ -436,7 +436,7 @@ int QgsExpression::functionIndex( QString name )

int QgsExpression::functionCount()
{
return ( sizeof( BuiltinFunctions ) / sizeof( FunctionDef) );
return ( sizeof( BuiltinFunctions ) / sizeof( FunctionDef ) );
}


Expand Down
80 changes: 40 additions & 40 deletions src/core/qgspallabeling.cpp
Expand Up @@ -211,11 +211,11 @@ QgsPalLayerSettings::~QgsPalLayerSettings()

QgsExpression* QgsPalLayerSettings::getLabelExpression()
{
if (expression == NULL)
{
expression = new QgsExpression( fieldName );
}
return expression;
if ( expression == NULL )
{
expression = new QgsExpression( fieldName );
}
return expression;
}

static QColor _readColor( QgsVectorLayer* layer, QString property )
Expand Down Expand Up @@ -303,7 +303,7 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )
return; // there's no information available

fieldName = layer->customProperty( "labeling/fieldName" ).toString();
isExpression = layer->customProperty( "labeling/isExpression").toBool();
isExpression = layer->customProperty( "labeling/isExpression" ).toBool();
placement = ( Placement ) layer->customProperty( "labeling/placement" ).toInt();
placementFlags = layer->customProperty( "labeling/placementFlags" ).toUInt();
QString fontFamily = layer->customProperty( "labeling/fontFamily" ).toString();
Expand Down Expand Up @@ -462,42 +462,42 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
labelY = qAbs( ptSize.y() - ptZero.y() );
}

void QgsPalLayerSettings::registerFeature(QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context )
void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context )
{
QString labelText;
// Check to see if we are a expression string.
if (isExpression)
if ( isExpression )
{
QgsExpression* exp = getLabelExpression();
if ( exp->hasParserError() )
{
QgsDebugMsg("PASER HAS ERROR:" + exp->parserErrorString());
QgsDebugMsg( "PASER HAS ERROR:" + exp->parserErrorString() );
return;
}
QVariant result = exp->evaluate(&f,layer->dataProvider()->fields());
QgsDebugMsg("VALUE = " + result.toString());
if (exp->hasEvalError())
QVariant result = exp->evaluate( &f, layer->dataProvider()->fields() );
QgsDebugMsg( "VALUE = " + result.toString() );
if ( exp->hasEvalError() )
{
QgsDebugMsg("Expression Label Error = " + exp->evalErrorString());
return;
QgsDebugMsg( "Expression Label Error = " + exp->evalErrorString() );
return;
}
labelText = result.toString();
}
else if ( formatNumbers == true && ( f.attributeMap()[fieldIndex].type() == QVariant::Int ||
f.attributeMap()[fieldIndex].type() == QVariant::Double ) )
{
QString numberFormat;
double d = f.attributeMap()[fieldIndex].toDouble();
if ( d > 0 && plusSign == true )
{
numberFormat.append( "+" );
}
numberFormat.append( "%1" );
labelText = numberFormat.arg( d, 0, 'f', decimals );
QString numberFormat;
double d = f.attributeMap()[fieldIndex].toDouble();
if ( d > 0 && plusSign == true )
{
numberFormat.append( "+" );
}
numberFormat.append( "%1" );
labelText = numberFormat.arg( d, 0, 'f', decimals );
}
else
{
labelText = f.attributeMap()[fieldIndex].toString();
labelText = f.attributeMap()[fieldIndex].toString();
}

double labelX, labelY; // will receive label size
Expand Down Expand Up @@ -774,7 +774,7 @@ bool QgsPalLabeling::willUseLayer( QgsVectorLayer* layer )

int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices, QgsRenderContext& ctx )
{
QgsDebugMsg("PREPARE LAYER");
QgsDebugMsg( "PREPARE LAYER" );
Q_ASSERT( mMapRenderer != NULL );

// start with a temporary settings class, find out labeling info
Expand All @@ -786,25 +786,25 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices,


int fldIndex ;
if(lyrTmp.isExpression)
if ( lyrTmp.isExpression )
{
if (lyrTmp.fieldName.isEmpty())
return 0;
QgsExpression exp( lyrTmp.fieldName );
foreach(QString name, exp.referencedColumns() )
{
QgsDebugMsg("REFERENCED COLUMN = " + name );
fldIndex = layer->fieldNameIndex( name );
attrIndices.insert(fldIndex);
}
if ( lyrTmp.fieldName.isEmpty() )
return 0;
QgsExpression exp( lyrTmp.fieldName );
foreach( QString name, exp.referencedColumns() )
{
QgsDebugMsg( "REFERENCED COLUMN = " + name );
fldIndex = layer->fieldNameIndex( name );
attrIndices.insert( fldIndex );
}
}
else
{
// If we aren't an expression, we check to see if we can find the column.
fldIndex = layer->fieldNameIndex( lyrTmp.fieldName );
if ( fldIndex == -1)
return 0;
attrIndices.insert( fldIndex );
// If we aren't an expression, we check to see if we can find the column.
fldIndex = layer->fieldNameIndex( lyrTmp.fieldName );
if ( fldIndex == -1 )
return 0;
attrIndices.insert( fldIndex );
}

//add indices of data defined fields
Expand Down Expand Up @@ -897,7 +897,7 @@ int QgsPalLabeling::addDiagramLayer( QgsVectorLayer* layer, QgsDiagramLayerSetti
void QgsPalLabeling::registerFeature( QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context )
{
QgsPalLayerSettings& lyr = mActiveLayers[layer];
lyr.registerFeature(layer, f, context );
lyr.registerFeature( layer, f, context );
}

void QgsPalLabeling::registerDiagramFeature( QgsVectorLayer* layer, QgsFeature& feat, const QgsRenderContext& context )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspallabeling.h
Expand Up @@ -138,7 +138,7 @@ class CORE_EXPORT QgsPalLayerSettings
void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY );

// implementation of register feature hook
void registerFeature(QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context );
void registerFeature( QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context );

void readFromLayer( QgsVectorLayer* layer );
void writeToLayer( QgsVectorLayer* layer );
Expand Down
32 changes: 16 additions & 16 deletions src/gui/qgsexpressionbuilderdialog.cpp
Expand Up @@ -16,37 +16,37 @@
#include "qgsexpressionbuilderdialog.h"
#include <QSettings>

QgsExpressionBuilderDialog::QgsExpressionBuilderDialog( QgsVectorLayer* layer, QString startText, QWidget* parent)
:QDialog( parent )
QgsExpressionBuilderDialog::QgsExpressionBuilderDialog( QgsVectorLayer* layer, QString startText, QWidget* parent )
: QDialog( parent )
{
setupUi( this );
setupUi( this );

QPushButton* okButuon = buttonBox->button(QDialogButtonBox::Ok);
connect(builder, SIGNAL(expressionParsed(bool)), okButuon, SLOT(setEnabled(bool)));
QPushButton* okButuon = buttonBox->button( QDialogButtonBox::Ok );
connect( builder, SIGNAL( expressionParsed( bool ) ), okButuon, SLOT( setEnabled( bool ) ) );

builder->setLayer( layer );
builder->setExpressionString(startText);
builder->loadFieldNames();
builder->setLayer( layer );
builder->setExpressionString( startText );
builder->loadFieldNames();

QSettings settings;
restoreGeometry( settings.value( "/Windows/ExpressionBuilderDialog/geometry" ).toByteArray() );
QSettings settings;
restoreGeometry( settings.value( "/Windows/ExpressionBuilderDialog/geometry" ).toByteArray() );
}

QgsExpressionBuilderWidget* QgsExpressionBuilderDialog::expressionBuilder()
{
return builder;
return builder;
}

void QgsExpressionBuilderDialog::setExpressionText( QString text )
{
builder->setExpressionString( text );
builder->setExpressionString( text );
}

void QgsExpressionBuilderDialog::closeEvent( QCloseEvent *event )
{
QDialog::closeEvent( event );
QDialog::closeEvent( event );

// TODO Work out why this is not working yet.
QSettings settings;
settings.setValue( "/Windows/ExpressionBuilderDialog/geometry", saveGeometry() );
// TODO Work out why this is not working yet.
QSettings settings;
settings.setValue( "/Windows/ExpressionBuilderDialog/geometry", saveGeometry() );
}
22 changes: 11 additions & 11 deletions src/gui/qgsexpressionbuilderdialog.h
Expand Up @@ -21,20 +21,20 @@

class QgsExpressionBuilderDialog : public QDialog, private Ui::QgsExpressionBuilderDialogBase
{
public:
QgsExpressionBuilderDialog( QgsVectorLayer* layer, QString startText = "", QWidget* parent = NULL);
public:
QgsExpressionBuilderDialog( QgsVectorLayer* layer, QString startText = "", QWidget* parent = NULL );

/** The builder widget that is used by the dialog */
QgsExpressionBuilderWidget* expressionBuilder();
/** The builder widget that is used by the dialog */
QgsExpressionBuilderWidget* expressionBuilder();

void setExpressionText( QString text );
void setExpressionText( QString text );

protected:
/**
* Handle closing of the window
* @param event unused
*/
void closeEvent( QCloseEvent * event );
protected:
/**
* Handle closing of the window
* @param event unused
*/
void closeEvent( QCloseEvent * event );
};

#endif

0 comments on commit 188d733

Please sign in to comment.