75 changes: 38 additions & 37 deletions src/app/legend/qgsapplegendinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ void QgsAppLegendInterface::updateIndex( QModelIndex oldIndex, QModelIndex newIn

void QgsAppLegendInterface::setGroupExpanded( int groupIndex, bool expand )
{
QTreeWidgetItem * item = getItem (groupIndex);
if ( !item )
{
return;
}
QTreeWidgetItem * item = getItem( groupIndex );
if ( !item )
{
return;
}

item->setExpanded(expand);
item->setExpanded( expand );
}

void QgsAppLegendInterface::setGroupVisible( int groupIndex, bool visible )
Expand All @@ -82,29 +82,30 @@ void QgsAppLegendInterface::setGroupVisible( int groupIndex, bool visible )
return;
}

Qt::CheckState state = visible ? Qt::Checked : Qt::Unchecked;
getItem (groupIndex)->setCheckState( 0, state );
Qt::CheckState state = visible ? Qt::Checked : Qt::Unchecked;
getItem( groupIndex )->setCheckState( 0, state );
}

QTreeWidgetItem *QgsAppLegendInterface::getItem(int itemIndex)
QTreeWidgetItem *QgsAppLegendInterface::getItem( int itemIndex )
{
int itemCount = 0;
for (QTreeWidgetItem* theItem = mLegend->firstItem(); theItem; theItem = mLegend->nextItem( theItem ) )
{
QgsLegendItem* legendItem = dynamic_cast<QgsLegendItem *>( theItem );
if (legendItem->type() == QgsLegendItem::LEGEND_GROUP) {
if (itemCount == itemIndex)
{
return theItem;
}
else
{
itemCount = itemCount + 1;
}
}
}
int itemCount = 0;
for ( QTreeWidgetItem* theItem = mLegend->firstItem(); theItem; theItem = mLegend->nextItem( theItem ) )
{
QgsLegendItem* legendItem = dynamic_cast<QgsLegendItem *>( theItem );
if ( legendItem->type() == QgsLegendItem::LEGEND_GROUP )
{
if ( itemCount == itemIndex )
{
return theItem;
}
else
{
itemCount = itemCount + 1;
}
}
}

return NULL;
return NULL;
}

void QgsAppLegendInterface::setLayerVisible( QgsMapLayer * ml, bool visible )
Expand All @@ -128,24 +129,24 @@ QList< GroupLayerInfo > QgsAppLegendInterface::groupLayerRelationship()

bool QgsAppLegendInterface::groupExists( int groupIndex )
{
QTreeWidgetItem * item = getItem (groupIndex);
QgsLegendItem* legendItem = dynamic_cast<QgsLegendItem *>( item );
QTreeWidgetItem * item = getItem( groupIndex );
QgsLegendItem* legendItem = dynamic_cast<QgsLegendItem *>( item );

if ( !legendItem )
{
return false;
}
if ( !legendItem )
{
return false;
}

return legendItem->type() == QgsLegendItem::LEGEND_GROUP;
return legendItem->type() == QgsLegendItem::LEGEND_GROUP;
}

bool QgsAppLegendInterface::isGroupExpanded( int groupIndex )
{
QTreeWidgetItem * item = getItem (groupIndex);
if ( !item )
{
return false;
}
QTreeWidgetItem * item = getItem( groupIndex );
if ( !item )
{
return false;
}

return item->isExpanded();
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/legend/qgsapplegendinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class QgsAppLegendInterface : public QgsLegendInterface

//! Pointer to QgsLegend object
QgsLegend *mLegend;
QTreeWidgetItem *getItem(int itemIndex);
QTreeWidgetItem *getItem( int itemIndex );
};

#endif //QGSLEGENDAPPIFACE_H
45 changes: 6 additions & 39 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1467,16 +1467,11 @@ void QgisApp::createStatusBar()
mScaleEdit->setMaximumWidth( 100 );
mScaleEdit->setMaximumHeight( 20 );
mScaleEdit->setContentsMargins( 0, 0, 0, 0 );
// QRegExp validator( "\\d+\\.?\\d*:\\d+\\.?\\d*" );
QRegExp validator( "\\d+\\.?\\d*:\\d+\\.?\\d*|\\d+\\.?\\d*" );
mScaleEditValidator = new QRegExpValidator( validator, mScaleEdit );
mScaleEdit->setValidator( mScaleEditValidator );
mScaleEdit->setWhatsThis( tr( "Displays the current map scale" ) );
mScaleEdit->setToolTip( tr( "Current map scale (formatted as x:y)" ) );

statusBar()->addPermanentWidget( mScaleEdit, 0 );
connect( mScaleEdit, SIGNAL( currentIndexChanged( const QString & ) ), this, SLOT( userScale() ) );
connect( mScaleEdit->lineEdit(), SIGNAL( editingFinished() ), this, SLOT( userScale() ) );
connect( mScaleEdit, SIGNAL( scaleChanged() ), this, SLOT( userScale() ) );

//stop rendering status bar widget
mStopRenderButton = new QToolButton( statusBar() );
Expand Down Expand Up @@ -5249,15 +5244,10 @@ void QgisApp::showMouseCoordinate( const QgsPoint & p )

void QgisApp::showScale( double theScale )
{
if ( theScale >= 1.0 )
mScaleEdit->setEditText( "1:" + QString::number( theScale, 'f', 0 ) );
else if ( theScale > 0.0 )
mScaleEdit->setEditText( QString::number( 1.0 / theScale, 'f', 0 ) + ":1" );
else
mScaleEdit->setEditText( tr( "Invalid scale" ) );

mOldScale = mScaleEdit->currentText();
// Why has MapCanvas the scale inverted?
mScaleEdit->setScale( 1.0 / theScale );

// Not sure if the lines below do anything meaningful /Homann
if ( mScaleEdit->width() > mScaleEdit->minimumWidth() )
{
mScaleEdit->setMinimumWidth( mScaleEdit->width() );
Expand All @@ -5266,31 +5256,8 @@ void QgisApp::showScale( double theScale )

void QgisApp::userScale()
{
if ( mOldScale == mScaleEdit->currentText() )
{
return;
}

QStringList parts = mScaleEdit->currentText().split( ':' );
if ( parts.size() == 2 )
{
bool leftOk, rightOk;
double leftSide = parts.at( 0 ).toDouble( &leftOk );
double rightSide = parts.at( 1 ).toDouble( &rightOk );
if ( leftSide > 0.0 && leftOk && rightOk )
{
mMapCanvas->zoomScale( rightSide / leftSide );
}
}
else
{
bool rightOk;
double rightSide = parts.at( 0 ).toDouble( &rightOk );
if ( rightOk )
{
mMapCanvas->zoomScale( rightSide );
}
}
// Why has MapCanvas the scale inverted?
mMapCanvas->zoomScale( 1.0 / mScaleEdit->scale() );
}

void QgisApp::userCenter()
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1236,8 +1236,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

bool cmpByText( QAction* a, QAction* b );

QString mOldScale;

//! the user has trusted the project macros
bool mTrustedMacros;

Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsdiagramproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
mDiagramPenColorButton->setColor( settingList.at( 0 ).penColor );
mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth );
mDiagramSizeSpinBox->setValue(( size.width() + size.height() ) / 2.0 );
mMinimumDiagramScaleLineEdit->setText( QString::number( settingList.at( 0 ).minScaleDenominator ) );
mMaximumDiagramScaleLineEdit->setText( QString::number( settingList.at( 0 ).maxScaleDenominator ) );
mMinimumDiagramScaleLineEdit->setText( QString::number( settingList.at( 0 ).minScaleDenominator, 'f' ) );
mMaximumDiagramScaleLineEdit->setText( QString::number( settingList.at( 0 ).maxScaleDenominator, 'f' ) );
mVisibilityGroupBox->setChecked( settingList.at( 0 ).minScaleDenominator != -1 &&
settingList.at( 0 ).maxScaleDenominator != -1 );
if ( settingList.at( 0 ).sizeType == QgsDiagramSettings::MM )
Expand Down Expand Up @@ -257,7 +257,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
if ( lidr )
{
mDiagramSizeSpinBox->setEnabled( false );
mValueLineEdit->setText( QString::number( lidr->upperValue() ) );
mValueLineEdit->setText( QString::number( lidr->upperValue(), 'f' ) );
mSizeSpinBox->setValue(( lidr->upperSize().width() + lidr->upperSize().height() ) / 2 );
mSizeAttributeComboBox->setCurrentIndex( mSizeAttributeComboBox->findData( lidr->classificationAttribute() ) );
}
Expand Down
19 changes: 13 additions & 6 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,17 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv

// set up the scale based layer visibility stuff....
chkUseScaleDependentRendering->setChecked( lyr->hasScaleBasedVisibility() );
leMinimumScale->setText( QString::number( lyr->minimumScale(), 'f' ) );
leMinimumScale->setValidator( new QDoubleValidator( 0, std::numeric_limits<float>::max(), 1000, this ) );
leMaximumScale->setText( QString::number( lyr->maximumScale(), 'f' ) );
leMaximumScale->setValidator( new QDoubleValidator( 0, std::numeric_limits<float>::max(), 1000, this ) );
bool projectScales = QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" );
if ( projectScales )
{
QStringList scalesList = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" );
cbMinimumScale->updateScales( scalesList );
cbMaximumScale->updateScales( scalesList );
}
cbMinimumScale->setScale( 1.0 / lyr->minimumScale() );
cbMaximumScale->setScale( 1.0 / lyr->maximumScale() );


leNoDataValue->setValidator( new QDoubleValidator( -std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), 1000, this ) );

// build GUI components
Expand Down Expand Up @@ -750,8 +757,8 @@ void QgsRasterLayerProperties::apply()

// set up the scale based layer visibility stuff....
mRasterLayer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
mRasterLayer->setMinimumScale( leMinimumScale->text().toFloat() );
mRasterLayer->setMaximumScale( leMaximumScale->text().toFloat() );
mRasterLayer->setMinimumScale( 1.0 / cbMinimumScale->scale() );
mRasterLayer->setMaximumScale( 1.0 / cbMaximumScale->scale() );

//update the legend pixmap
pixmapLegend->setPixmap( mRasterLayer->legendAsPixmap() );
Expand Down
17 changes: 11 additions & 6 deletions src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,15 @@ void QgsVectorLayerProperties::reset( void )

// set up the scale based layer visibility stuff....
chkUseScaleDependentRendering->setChecked( layer->hasScaleBasedVisibility() );
leMinimumScale->setText( QString::number( layer->minimumScale(), 'f' ) );
leMinimumScale->setValidator( new QDoubleValidator( 0, std::numeric_limits<float>::max(), 1000, this ) );
leMaximumScale->setText( QString::number( layer->maximumScale(), 'f' ) );
leMaximumScale->setValidator( new QDoubleValidator( 0, std::numeric_limits<float>::max(), 1000, this ) );
bool projectScales = QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" );
if ( projectScales )
{
QStringList scalesList = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" );
cbMinimumScale->updateScales( scalesList );
cbMaximumScale->updateScales( scalesList );
}
cbMinimumScale->setScale( 1.0 / layer->minimumScale() );
cbMaximumScale->setScale( 1.0 / layer->maximumScale() );

// symbology initialization
if ( legendtypecombobox->count() == 0 )
Expand Down Expand Up @@ -682,8 +687,8 @@ void QgsVectorLayerProperties::apply()

// set up the scale based layer visibility stuff....
layer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
layer->setMinimumScale( leMinimumScale->text().toFloat() );
layer->setMaximumScale( leMaximumScale->text().toFloat() );
layer->setMinimumScale( 1.0 / cbMinimumScale->scale() );
layer->setMaximumScale( 1.0 / cbMaximumScale->scale() );

// provider-specific options
if ( layer->dataProvider() )
Expand Down
9 changes: 7 additions & 2 deletions src/core/qgscoordinatereferencesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ typedef struct sqlite3 sqlite3;
//qgis includes
#include "qgis.h"

#ifdef DEBUG
typedef struct OGRSpatialReferenceHS *OGRSpatialReferenceH;
#else
typedef void *OGRSpatialReferenceH;
#endif

class QgsCoordinateReferenceSystem;
typedef void ( *CUSTOM_CRS_VALIDATION )( QgsCoordinateReferenceSystem* );


/** \ingroup core
* Class for storing a coordinate reference system (CRS)
*/
Expand Down Expand Up @@ -472,7 +477,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
//! Helper for sql-safe value quoting
static QString quotedValue( QString value );

void *mCRS;
OGRSpatialReferenceH mCRS;

bool loadFromDb( QString db, QString expression, QString value );

Expand Down
220 changes: 110 additions & 110 deletions src/core/qgsdiagramrendererv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,124 +32,124 @@ namespace pal { class Layer; }

class CORE_EXPORT QgsDiagramLayerSettings
{
public:
//avoid inclusion of QgsPalLabeling
enum Placement
{
AroundPoint = 0, // Point / Polygon
OverPoint, // Point / Polygon
Line, // Line / Polygon
Curved, // Line
Horizontal, // Polygon
Free // Polygon
};

enum LinePlacementFlags
{
OnLine = 1,
AboveLine = 2,
BelowLine = 4,
MapOrientation = 8
};

QgsDiagramLayerSettings()
: placement( AroundPoint )
, placementFlags( OnLine )
, priority( 5 )
, obstacle( false )
, dist( 0.0 )
, renderer( 0 )
, palLayer( 0 )
, ct( 0 )
, xform( 0 )
, xPosColumn( -1 )
, yPosColumn( -1 )
{
}

//pal placement properties
Placement placement;
LinePlacementFlags placementFlags;
int priority; // 0 = low, 10 = high
bool obstacle; // whether it's an obstacle
double dist; // distance from the feature (in mm)
QgsDiagramRendererV2* renderer;

//assigned when layer gets prepared
pal::Layer* palLayer;
const QgsCoordinateTransform* ct;
const QgsMapToPixel* xform;
QList<QgsPalGeometry*> geometries;

int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
public:
//avoid inclusion of QgsPalLabeling
enum Placement
{
AroundPoint = 0, // Point / Polygon
OverPoint, // Point / Polygon
Line, // Line / Polygon
Curved, // Line
Horizontal, // Polygon
Free // Polygon
};

enum LinePlacementFlags
{
OnLine = 1,
AboveLine = 2,
BelowLine = 4,
MapOrientation = 8
};

QgsDiagramLayerSettings()
: placement( AroundPoint )
, placementFlags( OnLine )
, priority( 5 )
, obstacle( false )
, dist( 0.0 )
, renderer( 0 )
, palLayer( 0 )
, ct( 0 )
, xform( 0 )
, xPosColumn( -1 )
, yPosColumn( -1 )
{
}

//pal placement properties
Placement placement;
LinePlacementFlags placementFlags;
int priority; // 0 = low, 10 = high
bool obstacle; // whether it's an obstacle
double dist; // distance from the feature (in mm)
QgsDiagramRendererV2* renderer;

//assigned when layer gets prepared
pal::Layer* palLayer;
const QgsCoordinateTransform* ct;
const QgsMapToPixel* xform;
QList<QgsPalGeometry*> geometries;

int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
};

//diagram settings for rendering
class CORE_EXPORT QgsDiagramSettings
{
public:
enum SizeType
{
MM,
MapUnits
};

enum LabelPlacementMethod
{
Height,
XHeight
};

//! Orientation of histogram
enum DiagramOrientation
{
Up,
Down,
Left,
Right
};

QgsDiagramSettings(): sizeType( MM ), minScaleDenominator( -1 ), maxScaleDenominator( -1 )
{}
QFont font;
QList< QColor > categoryColors;
QList< int > categoryIndices;
QSizeF size; //size
SizeType sizeType; //mm or map units
QColor backgroundColor;
QColor penColor;
double penWidth;
LabelPlacementMethod labelPlacementMethod;
DiagramOrientation diagramOrientation;
double barWidth;
int transparency; // 0 - 100
bool scaleByArea;

//scale range (-1 if no lower / upper bound )
double minScaleDenominator;
double maxScaleDenominator;

//! Scale diagrams smaller than mMinimumSize to mMinimumSize
double minimumSize;

void readXML( const QDomElement& elem );
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
public:
enum SizeType
{
MM,
MapUnits
};

enum LabelPlacementMethod
{
Height,
XHeight
};

//! Orientation of histogram
enum DiagramOrientation
{
Up,
Down,
Left,
Right
};

QgsDiagramSettings(): sizeType( MM ), minScaleDenominator( -1 ), maxScaleDenominator( -1 )
{}
QFont font;
QList< QColor > categoryColors;
QList< int > categoryIndices;
QSizeF size; //size
SizeType sizeType; //mm or map units
QColor backgroundColor;
QColor penColor;
double penWidth;
LabelPlacementMethod labelPlacementMethod;
DiagramOrientation diagramOrientation;
double barWidth;
int transparency; // 0 - 100
bool scaleByArea;

//scale range (-1 if no lower / upper bound )
double minScaleDenominator;
double maxScaleDenominator;

//! Scale diagrams smaller than mMinimumSize to mMinimumSize
double minimumSize;

void readXML( const QDomElement& elem );
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
};

//additional diagram settings for interpolated size rendering
class CORE_EXPORT QgsDiagramInterpolationSettings
{
public:
QSizeF lowerSize;
QSizeF upperSize;
double lowerValue;
double upperValue;
/**Index of the classification attribute*/
int classificationAttribute;
public:
QSizeF lowerSize;
QSizeF upperSize;
double lowerValue;
double upperValue;
/**Index of the classification attribute*/
int classificationAttribute;
};

/**Returns diagram settings for a feature*/
Expand Down Expand Up @@ -206,7 +206,7 @@ class CORE_EXPORT QgsDiagramRendererV2
};

/**Renders the diagrams for all features with the same settings*/
class CORE_EXPORT QgsSingleCategoryDiagramRenderer: public QgsDiagramRendererV2
class CORE_EXPORT QgsSingleCategoryDiagramRenderer : public QgsDiagramRendererV2
{
public:
QgsSingleCategoryDiagramRenderer();
Expand All @@ -232,7 +232,7 @@ class CORE_EXPORT QgsSingleCategoryDiagramRenderer: public QgsDiagramRendererV2
QgsDiagramSettings mSettings;
};

class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer: public QgsDiagramRendererV2
class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer : public QgsDiagramRendererV2
{
public:
QgsLinearlyInterpolatedDiagramRenderer();
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
.arg( ml->extent().toString() )
);

if ( !ml->hasScaleBasedVisibility() || ( ml->minimumScale() < mScale && mScale < ml->maximumScale() ) || mOverview )
if ( !ml->hasScaleBasedVisibility() || ( ml->minimumScale() <= mScale && mScale < ml->maximumScale() ) || mOverview )
{
connect( ml, SIGNAL( drawingProgress( int, int ) ), this, SLOT( onDrawingProgress( int, int ) ) );

Expand Down
28 changes: 14 additions & 14 deletions src/core/qgsmaprenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ class QgsDiagramLayerSettings;

class CORE_EXPORT QgsLabelPosition
{
public:
QgsLabelPosition( int id, double r, const QVector< QgsPoint >& corners, const QgsRectangle& rect, double w, double h, const QString& layer, bool upside_down, bool diagram = false, bool pinned = false ):
featureId( id ), rotation( r ), cornerPoints( corners ), labelRect( rect ), width( w ), height( h ), layerID( layer ), upsideDown( upside_down ), isDiagram( diagram ), isPinned( pinned ) {}
QgsLabelPosition(): featureId( -1 ), rotation( 0 ), labelRect( QgsRectangle() ), width( 0 ), height( 0 ), layerID( "" ), upsideDown( false ), isDiagram( false ), isPinned( false ) {}
int featureId;
double rotation;
QVector< QgsPoint > cornerPoints;
QgsRectangle labelRect;
double width;
double height;
QString layerID;
bool upsideDown;
bool isDiagram;
bool isPinned;
public:
QgsLabelPosition( int id, double r, const QVector< QgsPoint >& corners, const QgsRectangle& rect, double w, double h, const QString& layer, bool upside_down, bool diagram = false, bool pinned = false ):
featureId( id ), rotation( r ), cornerPoints( corners ), labelRect( rect ), width( w ), height( h ), layerID( layer ), upsideDown( upside_down ), isDiagram( diagram ), isPinned( pinned ) {}
QgsLabelPosition(): featureId( -1 ), rotation( 0 ), labelRect( QgsRectangle() ), width( 0 ), height( 0 ), layerID( "" ), upsideDown( false ), isDiagram( false ), isPinned( false ) {}
int featureId;
double rotation;
QVector< QgsPoint > cornerPoints;
QgsRectangle labelRect;
double width;
double height;
QString layerID;
bool upsideDown;
bool isDiagram;
bool isPinned;
};

/** Labeling engine interface.
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsmultibandcolorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ void * QgsMultiBandColorRenderer::readBlock( int bandNo, QgsRectangle const & e
if ( !bandData[*bandIt] )
{
// We should free the alloced mem from block().
QgsDebugMsg("No input band" );
QgsDebugMsg( "No input band" );
bandIt--;
for ( ; bandIt != bands.constBegin(); bandIt-- )
{
VSIFree( bandData[*bandIt] );
VSIFree( bandData[*bandIt] );
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgspalettedrasterrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void * QgsPalettedRasterRenderer::readBlock( int bandNo, QgsRectangle const & e
void* rasterData = mInput->block( bandNo, extent, width, height );
if ( ! rasterData )
{
QgsDebugMsg("No raster data!" );
QgsDebugMsg( "No raster data!" );
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgssinglebandcolordatarenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void * QgsSingleBandColorDataRenderer::readBlock( int bandNo, QgsRectangle cons
void* rasterData = mInput->block( bandNo, extent, width, height );
if ( ! rasterData )
{
QgsDebugMsg("No raster data!" );
QgsDebugMsg( "No raster data!" );
return 0;
}

Expand Down
127 changes: 126 additions & 1 deletion src/gui/qgsscalecombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
***************************************************************************/

#include "qgis.h"
#include "qgslogger.h"
#include "qgsscalecombobox.h"

#include <QAbstractItemView>
#include <QLocale>
#include <QSettings>
#include <QLineEdit>

QgsScaleComboBox::QgsScaleComboBox( QWidget* parent ) : QComboBox( parent )
{
Expand All @@ -28,6 +31,9 @@ QgsScaleComboBox::QgsScaleComboBox( QWidget* parent ) : QComboBox( parent )
setEditable( true );
setInsertPolicy( QComboBox::NoInsert );
setCompleter( 0 );
connect( this, SIGNAL( activated( const QString & ) ), this, SLOT( fixupScale() ) );
connect( lineEdit(), SIGNAL( editingFinished() ), this, SLOT( fixupScale() ) );
fixupScale();
}

QgsScaleComboBox::~QgsScaleComboBox()
Expand Down Expand Up @@ -60,7 +66,7 @@ void QgsScaleComboBox::updateScales( const QStringList &scales )
blockSignals( true );
clear();
addItems( myScalesList );
setEditText( oldScale );
setScaleString( oldScale );
blockSignals( false );
}

Expand Down Expand Up @@ -94,3 +100,122 @@ void QgsScaleComboBox::showPopup()
view()->setCurrentIndex( model()->index( idx, 0 ) );
blockSignals( false );
}

//! Function to read the selected scale as text
// @note added in 2.0
QString QgsScaleComboBox::scaleString()
{
return toString( mScale );
}

//! Function to set the selected scale from text
// @note added in 2.0
bool QgsScaleComboBox::setScaleString( QString scaleTxt )
{
bool ok;
double newScale = toDouble( scaleTxt, &ok );
if ( ! ok )
{
return false;
}
else
{
mScale = newScale;
setEditText( toString( mScale ) );
clearFocus();
return true;
}
}

//! Function to read the selected scale as double
// @note added in 2.0
double QgsScaleComboBox::scale()
{
return mScale;
}

//! Function to set the selected scale from double
// @note added in 2.0
void QgsScaleComboBox::setScale( double scale )
{
setScaleString( toString( scale ) );
}

//! Slot called when QComboBox has changed
void QgsScaleComboBox::fixupScale()
{
double newScale;
double oldScale = mScale;
bool ok;
QStringList txtList;

// QgsDebugMsg( QString( "entered with oldScale: %1" ).arg( oldScale ) );
newScale = toDouble( currentText(), &ok );
if ( ok )
{
// Valid string representation
if ( newScale != oldScale )
{
// Scale has change, update.
// QgsDebugMsg( QString( "New scale OK!: %1" ).arg( newScale ) );
mScale = newScale;
setScale( mScale );
emit scaleChanged();
}
}
else
{
// Invalid string representation
// Reset to the old
setScale( mScale );
}
}

QString QgsScaleComboBox::toString( double scale )
{
if ( scale > 1 )
{
return QString( "%1:1" ).arg( qRound( scale ) );
}
else
{
return QString( "1:%1" ).arg( qRound( 1.0 / scale ) );
}
}

double QgsScaleComboBox::toDouble( QString scaleString, bool * returnOk )
{
bool ok = false;
QString scaleTxt( scaleString );

double scale = QLocale::system().toDouble( scaleTxt, &ok );
if ( ok )
{
// Create a text version and set that text and rescan
// Idea is to get the same rounding.
scaleTxt = toString( scale );
}
// It is now either X:Y or not valid
ok = false;
QStringList txtList = scaleTxt.split( ':' );
if ( 2 == txtList.size() )
{
bool okX = false;
bool okY = false;
int x = QLocale::system().toInt( txtList[ 0 ], &okX );
int y = QLocale::system().toInt( txtList[ 1 ], &okY );
if ( okX && okY )
{
// Scale is fraction of x and y
scale = ( double )x / ( double )y;
ok = true;
}
}

// Set up optional return flag
if ( returnOk )
{
*returnOk = ok;
}
return scale;
}
33 changes: 33 additions & 0 deletions src/gui/qgsscalecombobox.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,45 @@ class GUI_EXPORT QgsScaleComboBox : public QComboBox
public:
QgsScaleComboBox( QWidget* parent = 0 );
virtual ~QgsScaleComboBox();
//! Function to read the selected scale as text
// @note added in 2.0
QString scaleString();
//! Function to set the selected scale from text
// @note added in 2.0
bool setScaleString( QString scaleTxt );
//! Function to read the selected scale as double
// @note added in 2.0
double scale();
//! Function to set the selected scale from double
// @note added in 2.0
void setScale( double scale );

//! Helper function to convert a double to scale string
// Performs rounding, so an exact representation is not to
// be expected.
// @note added in 2.0
static QString toString( double scale );
//! Helper function to convert a scale string to double
// @note added in 2.0
static double toDouble( QString scaleString, bool *ok = NULL );

signals:
//! Signal is emitted when *user* has finished editing/selecting a new scale.
// @note added in 2.0
void scaleChanged();

public slots:
void updateScales( const QStringList &scales = QStringList() );


protected:
void showPopup();

private slots:
void fixupScale();

private:
double mScale;
};

#endif // QGSSCALECOMBOBOX_H
2 changes: 1 addition & 1 deletion src/mapserver/qgsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
QMap< QString, QMap< int, QString > > aliasInfo = layerAliasInfo();
QMap< QString, QSet<QString> > hiddenAttrs = hiddenAttributes();

foreach( const QDomElement &elem, mProjectLayerElements )
foreach ( const QDomElement &elem, mProjectLayerElements )
{
QString type = elem.attribute( "type" );
if ( type == "vector" )
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgssldparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class QgsSLDParser: public QgsConfigParser
void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;

void featureTypeList( QDomElement &, QDomDocument & ) const {};

void describeFeatureType( const QString& aTypeName, QDomElement& parentElement, QDomDocument& doc ) const {};

/**Returns number of layers in configuration*/
Expand Down
10 changes: 5 additions & 5 deletions src/mapserver/qgswfsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ QDomDocument QgsWFSServer::describeFeatureType()
{
typeName = "";
}
mConfigParser->describeFeatureType( typeName, schemaElement, doc);
mConfigParser->describeFeatureType( typeName, schemaElement, doc );
return doc;
}

Expand Down Expand Up @@ -511,7 +511,7 @@ void QgsWFSServer::startGetFeature( QgsRequestHandler& request, const QString& f
if ( format == "GeoJSON" )
{
fcString = "{\"type\": \"FeatureCollection\",\n";
fcString += " \"bbox\": [ "+ QString::number( rect->xMinimum(), 'f' ) +", "+ QString::number( rect->yMinimum(), 'f' ) +", "+ QString::number( rect->xMaximum(), 'f' ) +", "+ QString::number( rect->yMaximum(), 'f' ) +"],\n";
fcString += " \"bbox\": [ " + QString::number( rect->xMinimum(), 'f' ) + ", " + QString::number( rect->yMinimum(), 'f' ) + ", " + QString::number( rect->xMaximum(), 'f' ) + ", " + QString::number( rect->yMaximum(), 'f' ) + "],\n";
fcString += " \"features\": [\n";
result = fcString.toUtf8();
request.startGetFeatureResponse( &result, format );
Expand Down Expand Up @@ -599,7 +599,7 @@ void QgsWFSServer::startGetFeature( QgsRequestHandler& request, const QString& f
fcString += " xmlns=\"http://www.opengis.net/wfs\"";
fcString += " xmlns:wfs=\"http://www.opengis.net/wfs\"";
fcString += " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
fcString += " xsi:schemaLocation=\"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://www.opengis.net/gml "+ hrefString.replace( "&", "&amp;" ) +"\"";
fcString += " xsi:schemaLocation=\"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://www.opengis.net/gml " + hrefString.replace( "&", "&amp;" ) + "\"";
fcString += " xmlns:ogc=\"http://www.opengis.net/ogc\"";
fcString += " xmlns:gml=\"http://www.opengis.net/gml\"";
fcString += " xmlns:ows=\"http://www.opengis.net/ows\"";
Expand Down Expand Up @@ -691,7 +691,7 @@ QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, QgsCoordinateRefer
{
QgsRectangle box = geom->boundingBox();

fStr += " \"bbox\": [ "+ QString::number( box.xMinimum(), 'f' ) +", "+ QString::number( box.yMinimum(), 'f' ) +", "+ QString::number( box.xMaximum(), 'f' ) +", "+ QString::number( box.yMaximum(), 'f' ) +"],\n";
fStr += " \"bbox\": [ " + QString::number( box.xMinimum(), 'f' ) + ", " + QString::number( box.yMinimum(), 'f' ) + ", " + QString::number( box.xMaximum(), 'f' ) + ", " + QString::number( box.yMaximum(), 'f' ) + "],\n";

fStr += " \"geometry\": ";
fStr += geom->exportToGeoJSON();
Expand Down Expand Up @@ -1020,7 +1020,7 @@ QDomElement QgsWFSServer::createCoordinateElem( const QVector<QgsPoint> points,
{
coordString += " ";
}
coordString += QString::number( pointIt->x(), 'f');
coordString += QString::number( pointIt->x(), 'f' );
coordString += ",";
coordString += QString::number( pointIt->y(), 'f' );
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/georeferencer/qgsgcplistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void QgsGCPListModel::updateModel()
// interested in the residual in this direction
if ( mGeorefTransform->transformWorldToRaster( p->mapCoords(), dst ) )
{
dX = ( dst.x() - pixel.x() );
dX = ( dst.x() - pixel.x() );
dY = -( dst.y() - pixel.y() );
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/plugins/georeferencer/qgsgeorefplugingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,10 @@ void QgsGeorefPluginGui::showGeorefConfigDialog()
// Histogram stretch slots
void QgsGeorefPluginGui::fullHistogramStretch()
{
mLayer->setContrastEnhancementAlgorithm( "StretchToMinimumMaximum" );
mLayer->setMinimumMaximumUsingDataset();
mLayer->setCacheImage( NULL );
mCanvas->refresh();
mLayer->setContrastEnhancementAlgorithm( "StretchToMinimumMaximum" );
mLayer->setMinimumMaximumUsingDataset();
mLayer->setCacheImage( NULL );
mCanvas->refresh();
}

void QgsGeorefPluginGui::localHistogramStretch()
Expand Down Expand Up @@ -863,11 +863,11 @@ void QgsGeorefPluginGui::createActions()
// Histogram stretch
mActionLocalHistogramStretch->setIcon( getThemeIcon( "/mActionLocalHistogramStretch.png" ) );
connect( mActionLocalHistogramStretch, SIGNAL( triggered() ), this, SLOT( localHistogramStretch() ) );
mActionLocalHistogramStretch->setEnabled(false);
mActionLocalHistogramStretch->setEnabled( false );

mActionFullHistogramStretch->setIcon( getThemeIcon( "/mActionFullHistogramStretch.png" ) );
connect( mActionFullHistogramStretch, SIGNAL( triggered() ), this, SLOT( fullHistogramStretch() ) );
mActionFullHistogramStretch->setEnabled(false);
mActionFullHistogramStretch->setEnabled( false );

// Help actions
mActionHelp = new QAction( tr( "Help" ), this );
Expand Down Expand Up @@ -1041,7 +1041,7 @@ void QgsGeorefPluginGui::createStatusBar()
statusBar()->addPermanentWidget( mCoordsLabel, 0 );

mEPSG = createBaseLabelStatus();
mEPSG->setText("EPSG:");
mEPSG->setText( "EPSG:" );
statusBar()->addPermanentWidget( mEPSG, 0 );
}

Expand Down Expand Up @@ -1121,8 +1121,8 @@ void QgsGeorefPluginGui::addRaster( QString file )

mAgainAddRaster = false;

mActionLocalHistogramStretch->setEnabled(true);
mActionFullHistogramStretch->setEnabled(true);
mActionLocalHistogramStretch->setEnabled( true );
mActionFullHistogramStretch->setEnabled( true );

// Status Bar
if ( mGeorefTransform.hasCrs() )
Expand All @@ -1133,8 +1133,8 @@ void QgsGeorefPluginGui::addRaster( QString file )
}
else
{
mEPSG->setText( tr("None") );
mEPSG->setToolTip( tr("Coordinate of image(column/line)") );
mEPSG->setText( tr( "None" ) );
mEPSG->setToolTip( tr( "Coordinate of image(column/line)" ) );
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/plugins/georeferencer/qgsgeoreftransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void QgsGeorefTransform::selectTransformParametrisation( TransformParametrisatio

void QgsGeorefTransform::setRasterChangeCoords( const QString &fileRaster )
{
mRasterChangeCoords.setRaster( fileRaster );
mRasterChangeCoords.setRaster( fileRaster );
}

bool QgsGeorefTransform::providesAccurateInverseTransformation() const
Expand Down Expand Up @@ -210,13 +210,13 @@ bool QgsGeorefTransform::updateParametersFromGCPs( const std::vector<QgsPoint> &
}
if ( mRasterChangeCoords.hasCrs() )
{
std::vector<QgsPoint> pixelCoordsCorrect = mRasterChangeCoords.getPixelCoords(pixelCoords);
mParametersInitialized = mGeorefTransformImplementation->updateParametersFromGCPs( mapCoords, pixelCoordsCorrect );
pixelCoordsCorrect.clear();
std::vector<QgsPoint> pixelCoordsCorrect = mRasterChangeCoords.getPixelCoords( pixelCoords );
mParametersInitialized = mGeorefTransformImplementation->updateParametersFromGCPs( mapCoords, pixelCoordsCorrect );
pixelCoordsCorrect.clear();
}
else
{
mParametersInitialized = mGeorefTransformImplementation->updateParametersFromGCPs( mapCoords, pixelCoords );
mParametersInitialized = mGeorefTransformImplementation->updateParametersFromGCPs( mapCoords, pixelCoords );
}
return mParametersInitialized;
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/georeferencer/qgsgeoreftransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ class QgsGeorefTransform : public QgsGeorefTransformInterface
bool hasCrs() const { return mRasterChangeCoords.hasCrs(); }

//! \returns Coordinates of image
QgsPoint toColumnLine(const QgsPoint &pntMap) { return mRasterChangeCoords.toColumnLine( pntMap ); }
QgsPoint toColumnLine( const QgsPoint &pntMap ) { return mRasterChangeCoords.toColumnLine( pntMap ); }

//! \returns Bounding box of image(transform to coordinate of Map or Image )
QgsRectangle getBoundingBox(const QgsRectangle &rect, bool toPixel) { return mRasterChangeCoords.getBoundingBox( rect, toPixel); }
QgsRectangle getBoundingBox( const QgsRectangle &rect, bool toPixel ) { return mRasterChangeCoords.getBoundingBox( rect, toPixel ); }

//! \brief The transform parametrisation currently in use.
TransformParametrisation transformParametrisation() const;
Expand Down
68 changes: 34 additions & 34 deletions src/plugins/georeferencer/qgsrasterchangecoords.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,64 +28,64 @@

QgsRasterChangeCoords::QgsRasterChangeCoords()
{
mHasCrs = false;
mHasCrs = false;
}

void QgsRasterChangeCoords::setRaster( const QString &fileRaster )
{
GDALAllRegister();
GDALDatasetH hDS = GDALOpen( TO8F( fileRaster ), GA_ReadOnly );
double adfGeoTransform[6];
if( GDALGetProjectionRef( hDS ) != NULL && GDALGetGeoTransform(hDS, adfGeoTransform) == CE_None)
GDALAllRegister();
GDALDatasetH hDS = GDALOpen( TO8F( fileRaster ), GA_ReadOnly );
double adfGeoTransform[6];
if ( GDALGetProjectionRef( hDS ) != NULL && GDALGetGeoTransform( hDS, adfGeoTransform ) == CE_None )
//if ( false )
{
mHasCrs = true;
mUL_X = adfGeoTransform[0];
mUL_Y = adfGeoTransform[3];
mResX = adfGeoTransform[1];
mResY = adfGeoTransform[5];
}
else
{
mHasCrs = false;
}
GDALClose( hDS );
{
mHasCrs = true;
mUL_X = adfGeoTransform[0];
mUL_Y = adfGeoTransform[3];
mResX = adfGeoTransform[1];
mResY = adfGeoTransform[5];
}
else
{
mHasCrs = false;
}
GDALClose( hDS );
}

std::vector<QgsPoint> QgsRasterChangeCoords::getPixelCoords(const std::vector<QgsPoint> &mapCoords)
std::vector<QgsPoint> QgsRasterChangeCoords::getPixelCoords( const std::vector<QgsPoint> &mapCoords )
{
const int size = mapCoords.size();
std::vector<QgsPoint> pixelCoords( size );
for ( int i = 0; i < size; i++ )
{
pixelCoords[i] = toColumnLine( mapCoords.at( i ) );
}
return pixelCoords;
const int size = mapCoords.size();
std::vector<QgsPoint> pixelCoords( size );
for ( int i = 0; i < size; i++ )
{
pixelCoords[i] = toColumnLine( mapCoords.at( i ) );
}
return pixelCoords;
}

QgsRectangle QgsRasterChangeCoords::getBoundingBox(const QgsRectangle &rect, bool toPixel)
QgsRectangle QgsRasterChangeCoords::getBoundingBox( const QgsRectangle &rect, bool toPixel )
{
QgsRectangle rectReturn;
QgsPoint p1( rect.xMinimum(), rect.yMinimum() );
QgsPoint p2( rect.xMaximum(), rect.yMaximum() );
QgsPoint ( QgsRasterChangeCoords::* func )( const QgsPoint & );
QgsPoint( QgsRasterChangeCoords::* func )( const QgsPoint & );

func = toPixel ? &QgsRasterChangeCoords::toColumnLine : &QgsRasterChangeCoords::toXY;
rectReturn.set( ( this->*func ) (p1), ( this->*func )(p2) );
rectReturn.set(( this->*func )( p1 ), ( this->*func )( p2 ) );

return rectReturn;
}

QgsPoint QgsRasterChangeCoords::toColumnLine(const QgsPoint &pntMap)
QgsPoint QgsRasterChangeCoords::toColumnLine( const QgsPoint &pntMap )
{
double col = ( pntMap.x() - mUL_X ) / mResX;
double line = ( mUL_Y - pntMap.y() ) / mResY;
return QgsPoint(col, line);
double col = ( pntMap.x() - mUL_X ) / mResX;
double line = ( mUL_Y - pntMap.y() ) / mResY;
return QgsPoint( col, line );
}

QgsPoint QgsRasterChangeCoords::toXY(const QgsPoint &pntPixel)
QgsPoint QgsRasterChangeCoords::toXY( const QgsPoint &pntPixel )
{
double x = mUL_X + ( pntPixel.x() * mResX );
double y = mUL_Y + ( pntPixel.y() * -mResY );
return QgsPoint(x, y);
return QgsPoint( x, y );
}
8 changes: 4 additions & 4 deletions src/plugins/georeferencer/qgsrasterchangecoords.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class QgsRasterChangeCoords
QgsRasterChangeCoords( );
void setRaster( const QString &fileRaster );
bool hasCrs() const { return mHasCrs; }
std::vector<QgsPoint> getPixelCoords(const std::vector<QgsPoint> &mapCoords);
QgsRectangle getBoundingBox(const QgsRectangle &rect, bool toPixel);
QgsPoint toColumnLine(const QgsPoint &pntMap);
QgsPoint toXY(const QgsPoint &pntPixel);
std::vector<QgsPoint> getPixelCoords( const std::vector<QgsPoint> &mapCoords );
QgsRectangle getBoundingBox( const QgsRectangle &rect, bool toPixel );
QgsPoint toColumnLine( const QgsPoint &pntMap );
QgsPoint toXY( const QgsPoint &pntPixel );

private:
bool mHasCrs;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ bool QgsPostgresProvider::loadFields()
QString attnum = tresult.PQgetvalue( 0, 0 );
formattedFieldType = tresult.PQgetvalue( 0, 1 );

if( !attnum.isEmpty() )
if ( !attnum.isEmpty() )
{
sql = QString( "SELECT description FROM pg_description WHERE objoid=%1 AND objsubid=%2" )
.arg( tableoid ).arg( attnum );
Expand Down
12 changes: 6 additions & 6 deletions src/ui/qgsrasterlayerpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Maximum</string>
<string>Less than:</string>
</property>
</widget>
</item>
Expand All @@ -599,15 +599,15 @@
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Minimum</string>
<string>More than or equal to:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="leMaximumScale"/>
<widget class="QgsScaleComboBox" name="cbMaximumScale"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leMinimumScale"/>
<widget class="QgsScaleComboBox" name="cbMinimumScale"/>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -1052,8 +1052,8 @@ p, li { white-space: pre-wrap; }
<tabstop>tableTransparency</tabstop>
<tabstop>leDisplayName</tabstop>
<tabstop>leLayerSource</tabstop>
<tabstop>leMinimumScale</tabstop>
<tabstop>leMaximumScale</tabstop>
<tabstop>cbMinimumScale</tabstop>
<tabstop>cbMaximumScale</tabstop>
<tabstop>leSpatialRefSys</tabstop>
<tabstop>pbnChangeSpatialRefSys</tabstop>
<tabstop>tePyramidDescription</tabstop>
Expand Down
12 changes: 6 additions & 6 deletions src/ui/qgsvectorlayerpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -492,22 +492,22 @@
<item row="0" column="2">
<widget class="QLabel" name="textLabel1_2_2">
<property name="text">
<string>Maximum</string>
<string>Less than:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Minimum</string>
<string>More than or equal to:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leMinimumScale"/>
<widget class="QgsScaleComboBox" name="cbMinimumScale"/>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="leMaximumScale"/>
<widget class="QgsScaleComboBox" name="cbMaximumScale"/>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -968,8 +968,8 @@
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>pbnIndex</tabstop>
<tabstop>leMinimumScale</tabstop>
<tabstop>leMaximumScale</tabstop>
<tabstop>cbMinimumScale</tabstop>
<tabstop>cbMaximumScale</tabstop>
<tabstop>txtSubsetSQL</tabstop>
<tabstop>pbnQueryBuilder</tabstop>
</tabstops>
Expand Down
8 changes: 4 additions & 4 deletions tests/src/core/testqgsdiagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class TestQgsDiagram: public QObject
QString myPointsFileName = mTestDataDir + "points.shp";
QFileInfo myPointFileInfo( myPointsFileName );
mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(),
myPointFileInfo.completeBaseName(), "ogr" );
myPointFileInfo.completeBaseName(), "ogr" );

// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayers(
Expand Down Expand Up @@ -159,14 +159,14 @@ class TestQgsDiagram: public QObject
dls.placement = QgsDiagramLayerSettings::OverPoint;
dls.renderer = dr;

dynamic_cast<QgsPalLabeling*> (mMapRenderer->labelingEngine())->setShowingAllLabels( true );
dynamic_cast<QgsPalLabeling*>( mMapRenderer->labelingEngine() )->setShowingAllLabels( true );

mPointsLayer->setDiagramLayerSettings( dls );

mComposerMap->setNewExtent( QgsRectangle( -122, -79, -70, 47 ) );
QgsCompositionChecker checker( "Composer map render", mComposition, QString( QString( TEST_DATA_DIR )
+ QDir::separator() + "control_images" + QDir::separator() + "expected_diagram" + QDir::separator()
+ "expected_piediagram.png" ) );
+ QDir::separator() + "control_images" + QDir::separator() + "expected_diagram" + QDir::separator()
+ "expected_piediagram.png" ) );

QVERIFY( checker.testComposition() );

Expand Down
1 change: 1 addition & 0 deletions tests/src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ ADD_QGIS_TEST(zoomtest testqgsmaptoolzoom.cpp)

ADD_QGIS_TEST(histogramtest testqgsrasterhistogram.cpp)
ADD_QGIS_TEST(projectionissues testprojectionissues.cpp)
ADD_QGIS_TEST(scalecombobox testqgsscalecombobox.cpp)

6 changes: 3 additions & 3 deletions tests/src/gui/testprojectionissues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TestProjectionIssues: public QObject
void cleanupTestCase();// will be called after the last testfunction was executed.
void init();// will be called before each testfunction is executed.
void cleanup();// will be called after every testfunction.
void issue5895();// test for #5895
void issue5895();// test for #5895
private:
QgsRasterLayer* mRasterLayer;
QgsMapCanvas* mMapCanvas;
Expand All @@ -50,8 +50,8 @@ void TestProjectionIssues::initTestCase()
// Set to WGS84
QgsCoordinateReferenceSystem sourceCRS;
sourceCRS.createFromId( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
mRasterLayer->setCrs( sourceCRS, false);
mRasterLayer->setCrs( sourceCRS, false );

QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 );
mRasterLayer->setRenderer( rasterRenderer );

Expand Down
133 changes: 133 additions & 0 deletions tests/src/gui/testqgsscalecombobox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/***************************************************************************
testqgsscalecombobox.cpp
---------------------------
begin : September 2012
copyright : (C) 2012 by Magnus Homann
email : magnus at homann dot se
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsapplication.h"
#include "qgslogger.h"
#include "qgsscalecombobox.h"
#include <QObject>
#include <QLineEdit>
#include <QComboBox>
#include <QSignalSpy>
#include <QtTest>

class TestQgsScaleComboBox: public QObject
{
Q_OBJECT;
private slots:
void initTestCase();// will be called before the first testfunction is executed.
void cleanupTestCase();// will be called after the last testfunction was executed.
void init();// will be called before each testfunction is executed.
void cleanup();// will be called after every testfunction.
void basic();
void slot_test();
private:
QgsScaleComboBox *s;
};

void TestQgsScaleComboBox::initTestCase()
{
QgsApplication::init();
QgsApplication::initQgis();

// Create a combobox, and init with predefined scales.
s = new QgsScaleComboBox();
QgsDebugMsg( QString( "Initial scale is %1" ).arg( s->scaleString() ) );
};

void TestQgsScaleComboBox::cleanupTestCase()
{
delete s;
};

void TestQgsScaleComboBox::init()
{
};

void TestQgsScaleComboBox::basic()
{
QLineEdit *l = s->lineEdit();

// Testing conversion from "1:nnn".
l->setText( "" );
QTest::keyClicks( l, "1:2345" );
QTest::keyClick( l, Qt::Key_Return );
QCOMPARE( s->scaleString(), QString( "1:2345" ) );
QCOMPARE( s->scale(), (( double ) 1.0 / ( double ) 2345.0 ) );

// Testing conversion from number to "1:x"
l->setText( "" );
QTest::keyClicks( l, QLocale::system().toString( 0.02 ) );
QTest::keyClick( l, Qt::Key_Return );
QCOMPARE( s->scaleString(), QString( "1:50" ) );
QCOMPARE( s->scale(), ( double ) 0.02 );

// Testing conversion from number to "x:1"
l->setText( "" );
QTest::keyClicks( l, QLocale::system().toString( 42 ) );
QTest::keyClick( l, Qt::Key_Return );
QCOMPARE( s->scaleString(), QString( "42:1" ) );
QCOMPARE( s->scale(), ( double ) 42 );

// Testing rounding and conversion from illegal

l->setText( "" );
QTest::keyClicks( l, QLocale::system().toString( 0.24 ) );
QTest::keyClick( l, Qt::Key_Return );

l->setText( "" );
QTest::keyClicks( l, "1:x:2" );
QTest::keyClick( l, Qt::Key_Return );
QCOMPARE( s->scaleString(), QString( "1:4" ) );
QCOMPARE( s->scale(), ( double ) 0.25 );

// Test setting programatically
s->setScale(( double ) 0.19 );
QCOMPARE( s->scaleString(), QString( "1:5" ) );
QCOMPARE( s->scale(), ( double ) 0.2 );

// Test setting programatically
s->setScaleString( QString( "1:240" ) );
QCOMPARE( s->scaleString(), QString( "1:240" ) );
QCOMPARE( s->scale(), ( double ) 1.0 / ( double ) 240.0 );

// Test setting programatically illegal string
s->setScaleString( QString( "1:2.4" ) );
QCOMPARE( s->scaleString(), QString( "1:240" ) );
QCOMPARE( s->scale(), ( double ) 1.0 / ( double ) 240.0 );

};

void TestQgsScaleComboBox::slot_test()
{
QLineEdit *l = s->lineEdit();
l->setText( "" );

QSignalSpy spyScaleChanged( s, SIGNAL( scaleChanged() ) );
QSignalSpy spyFixup( l, SIGNAL( editingFinished() ) );

QTest::keyClicks( l, QLocale::system().toString( 0.02 ) );
QTest::keyClick( l, Qt::Key_Return );
QCOMPARE( spyFixup.count(), 2 ); // Qt emits twice!?
QCOMPARE( spyScaleChanged.count(), 1 );
}

void TestQgsScaleComboBox::cleanup()
{
};

QTEST_MAIN( TestQgsScaleComboBox )
#include "moc_testqgsscalecombobox.cxx"