397 changes: 346 additions & 51 deletions doc/INSTALL.html

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions doc/TRANSLATORS

Large diffs are not rendered by default.

49 changes: 46 additions & 3 deletions doc/osx.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,45 @@ make
sudo make install
```

=== Optional Setup: ccache ===

Setup ccache to significantly speed up compile times after initial build.
(Switching git branches will again cause longer initial build times unless
separate build directories are used for each branch.)

Get the latest source release from here:

http://ccache.samba.org/

Double-click the source tarball to unpack, then, in Terminal.app, cd to the
source folder and:

```
./configure
make
sudo make install
```

After install, symbolically link compilers to /usr/local/bin/ccache.
(Note: this differs from instructions at http://ccache.samba.org/manual.html
Changing the /usr/bin:/usr/local/bin order in PATH is not recommended on OS X.

```
sudo mkdir /usr/local/bin/compilers && cd /usr/local/bin/compilers
sudo ln -s ../ccache gcc
sudo ln -s ../ccache g++
sudo ln -s ../ccache cc
sudo ln -s ../ccache c++
```

Add the following to the end of your ~/.bash_profile (and optionally ~/.bashrc)
to allow your login shell to discover the symbolically linked compilers before
/usr/bin compilers and to easily toggle using ccache off, by commenting out the
line and starting a new login session in Terminal.

```
export PATH=/usr/local/bin/compilers:$PATH
```

== Install development frameworks for QGIS dependencies ==

Expand Down Expand Up @@ -320,7 +359,7 @@ For 64-bit Qt (Qt Cocoa), use this configure line:
python2.6 configure.py -d /Library/Python/2.6/site-packages -b /usr/local/bin --use-arch x86_64
```

__Snow Leopard system Python__
__Lion system Python__

Similar to Snow Leopard, you should install outside the system Python path.
But you don't need the arch option:
Expand Down Expand Up @@ -542,6 +581,8 @@ cd build
cmake -D CMAKE_INSTALL_PREFIX=~/Applications \
-D CMAKE_BUILD_TYPE=MinSizeRel -D ENABLE_TESTS=FALSE \
-D WITH_INTERNAL_SPATIALITE=FALSE -D WITH_PYSPATIALITE=FALSE \
-D SPATIALINDEX_LIBRARY=/usr/local/lib/libspatialindex.dylib \
-D SPATIALINDEX_INCLUDE_DIR=/usr/local/include/spatialindex \
-D QWT_LIBRARY=/usr/local/qwt-5.2.2/lib/libqwt.dylib \
-D QWT_INCLUDE_DIR=/usr/local/qwt-5.2.2/include \
-D BISON_EXECUTABLE=/usr/local/bin/bison \
Expand All @@ -566,8 +607,10 @@ sudo chmod +x /usr/local/bin/python32
cmake -D CMAKE_INSTALL_PREFIX=~/Applications \
-D CMAKE_BUILD_TYPE=MinSizeRel -D ENABLE_TESTS=FALSE \
-D WITH_INTERNAL_SPATIALITE=FALSE -D WITH_PYSPATIALITE=FALSE \
-D QWT_LIBRARY=/usr/local/qwt-5.2.1-svn/lib/libqwt.dylib \
-D QWT_INCLUDE_DIR=/usr/local/qwt-5.2.1-svn/include \
-D SPATIALINDEX_LIBRARY=/usr/local/lib/libspatialindex.dylib \
-D SPATIALINDEX_INCLUDE_DIR=/usr/local/include/spatialindex \
-D QWT_LIBRARY=/usr/local/qwt-5.2.2/lib/libqwt.dylib \
-D QWT_INCLUDE_DIR=/usr/local/qwt-5.2.2/include \
-D BISON_EXECUTABLE=/usr/local/bin/bison \
-D CMAKE_OSX_ARCHITECTURES=i386 -D PYTHON_EXECUTABLE=/usr/local/bin/python32 \
..
Expand Down
2,286 changes: 1,216 additions & 1,070 deletions i18n/qgis_de.ts

Large diffs are not rendered by default.

3,872 changes: 2,259 additions & 1,613 deletions i18n/qgis_gl_ES.ts

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion images/icons/mac/browser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
FILE (GLOB ICONS *.icns)
INSTALL (FILES ${ICONS}
DESTINATION "${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/QGIS Browser.app/Contents/Resources")
# create alias now, so alias file gets correct icon
# create alias now, so alias file gets correct icon, delete first if it exists
SET (BROWSER_ALIAS "$ENV{DESTDIR}${QGIS_INSTALL_PREFIX}/QGIS Browser.app")
IF (EXISTS ${BROWSER_ALIAS})
FILE (REMOVE ${BROWSER_ALIAS})
ENDIF ()
INSTALL (CODE "EXECUTE_PROCESS(COMMAND osascript -e \"tell application \\\"Finder\\\" to make alias file to POSIX file \\\"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/QGIS Browser.app\\\" at POSIX file \\\"$ENV{DESTDIR}${QGIS_INSTALL_PREFIX}/\\\"\")")
8 changes: 8 additions & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<file>themes/default/mActionOptions.png</file>
<file>themes/default/mActionPan.png</file>
<file>themes/default/mActionPanToSelected.png</file>
<file>themes/default/mActionPanToSelected.svg</file>
<file>themes/default/mActionShowRasterCalculator.png</file>
<file>themes/default/mAction.png</file>
<file>themes/default/mActionProjectProperties.png</file>
Expand All @@ -131,6 +132,7 @@
<file>themes/default/mActionRemoveSelectedFeature.png</file>
<file>themes/default/mActionReshape.png</file>
<file>themes/default/mActionRotateLabel.png</file>
<file>themes/default/mActionRotateLabel.svg</file>
<file>themes/default/mActionRotatePointSymbols.png</file>
<file>themes/default/mActionSaveAsPDF.png</file>
<file>themes/default/mActionSaveAsSVG.png</file>
Expand All @@ -142,6 +144,7 @@
<file>themes/default/mActionSelectPan.png</file>
<file>themes/default/mActionSelect.png</file>
<file>themes/default/mActionSelectPolygon.png</file>
<file>themes/default/mActionSelectPolygon.svg</file>
<file>themes/default/mActionSelectRadius.png</file>
<file>themes/default/mActionSelectRectangle.png</file>
<file>themes/default/mActionShowAllLayers.png</file>
Expand All @@ -150,6 +153,7 @@
<file>themes/default/mActionShowPluginManager.png</file>
<file>themes/default/mActionSimplify.png</file>
<file>themes/default/mActionSplitFeatures.png</file>
<file>themes/default/mActionSplitFeatures.svg</file>
<file>themes/default/mActionTextAnnotation.png</file>
<file>themes/default/mActionToggleEditing.png</file>
<file>themes/default/mActionUndo.png</file>
Expand Down Expand Up @@ -319,12 +323,14 @@
<file>themes/gis/mActionOpenTable.png</file>
<file>themes/gis/mActionPan.png</file>
<file>themes/gis/mActionPanToSelected.png</file>
<file>themes/gis/mActionPanToSelected.svg</file>
<file>themes/gis/mActionShowRasterCalculator.png</file>
<file>themes/gis/mActionRaiseItems.png</file>
<file>themes/gis/mActionRedo.png</file>
<file>themes/gis/mActionRemoveLayer.png</file>
<file>themes/gis/mActionReshape.png</file>
<file>themes/gis/mActionRotateLabel.png</file>
<file>themes/gis/mActionRotateLabel.svg</file>
<file>themes/gis/mActionSaveAsPDF.png</file>
<file>themes/gis/mActionSaveAsSVG.png</file>
<file>themes/gis/mActionSaveEdits.png</file>
Expand All @@ -335,12 +341,14 @@
<file>themes/gis/mActionSelectPan.png</file>
<file>themes/gis/mActionSelect.png</file>
<file>themes/gis/mActionSelectPolygon.png</file>
<file>themes/gis/mActionSelectPolygon.svg</file>
<file>themes/gis/mActionSelectRadius.png</file>
<file>themes/gis/mActionSelectRectangle.png</file>
<file>themes/gis/mActionShowAllLayers.png</file>
<file>themes/gis/mActionShowBookmarks.png</file>
<file>themes/gis/mActionSimplify.png</file>
<file>themes/gis/mActionSplitFeatures.png</file>
<file>themes/gis/mActionSplitFeatures.svg</file>
<file>themes/gis/mActionTextAnnotation.png</file>
<file>themes/gis/mActionToggleEditing.png</file>
<file>themes/gis/mActionUndo.png</file>
Expand Down
76 changes: 76 additions & 0 deletions images/themes/default/mActionPanToSelected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions images/themes/default/mActionRotateLabel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions images/themes/default/mActionSelectPolygon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions images/themes/default/mActionSplitFeatures.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
606 changes: 606 additions & 0 deletions images/themes/gis/mActionPanToSelected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
604 changes: 604 additions & 0 deletions images/themes/gis/mActionRotateLabel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
585 changes: 585 additions & 0 deletions images/themes/gis/mActionSelectPolygon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
710 changes: 710 additions & 0 deletions images/themes/gis/mActionSplitFeatures.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions mac/cmake/1qt.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../sqldrivers")
IF (NOT EXISTS "${QPLUGDIR}/../sqldrivers/libqsqlite.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_PLUGINS_DIR@/sqldrivers/libqsqlite.dylib" "${QPLUGDIR}/../sqldrivers/libqsqlite.dylib")
ENDIF ()
EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../iconengines")
IF (NOT EXISTS "${QPLUGDIR}/../iconengines/libqsvgicon.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_PLUGINS_DIR@/iconengines/libqsvgicon.dylib" "${QPLUGDIR}/../iconengines/libqsvgicon.dylib")
ENDIF ()

# Qwt
# assumes shared libraries
Expand Down Expand Up @@ -184,6 +188,7 @@ FOREACH (QFW ${QTLISTQG})
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QPLUGDIR}/../codecs/libq${QC}codecs.dylib")
ENDFOREACH (QC)
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QPLUGDIR}/../sqldrivers/libqsqlite.dylib")
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QPLUGDIR}/../iconengines/libqsvgicon.dylib")
# qt fw
IF (@OSX_HAVE_LOADERPATH@)
SET (QFW_CHG_TO "${ATLOADER}/../../../${LIBPOST}")
Expand Down
235 changes: 125 additions & 110 deletions python/core/qgis.sip
Original file line number Diff line number Diff line change
Expand Up @@ -24,117 +24,132 @@ class QGis
#include <qgis.h>
%End

public:
// Version constants
//
// Version string
static const char* QGIS_VERSION;
// Version number used for comparing versions using the "Check QGIS Version" function
static const int QGIS_VERSION_INT;
// Release name
static const char* QGIS_RELEASE_NAME;
// The subversion version
static const char* QGIS_DEV_VERSION;

// Enumerations
//

//! Used for symbology operations
// Feature types
enum WkbType
{
WKBPoint = 1,
WKBLineString,
WKBPolygon,
WKBMultiPoint,
WKBMultiLineString,
WKBMultiPolygon,
WKBUnknown,
WKBPoint25D = 0x80000001,
WKBLineString25D,
WKBPolygon25D,
WKBMultiPoint25D,
WKBMultiLineString25D,
WKBMultiPolygon25D
};
enum GeometryType
{
Point,
Line,
Polygon,
UnknownGeometry
};

// TODO:
//static const char *qgisVectorGeometryType[];
//! description strings for feature types
//static const char *qgisFeatureTypes[];

/** Map units that qgis supports
* @note that QGIS < 1.4 api had only Meters, Feet, Degrees and UnknownUnit
*/
enum UnitType
{
Meters = 0,
Feet = 1,
Degrees = 2, //for 1.0 api backwards compatibility
DecimalDegrees = 2,
DegreesMinutesSeconds = 4,
DegreesDecimalMinutes = 5,
UnknownUnit = 3
} ;

//! User defined event types
enum UserEvent
{
// These first two are useful for threads to alert their parent data providers

//! The extents have been calculated by a provider of a layer
ProviderExtentCalcEvent = QgisEvent,

//! The row count has been calculated by a provider of a layer
ProviderCountCalcEvent
};

static const int DEFAULT_IDENTIFY_RADIUS;
public:
// Version constants
//
// Version string
static const char* QGIS_VERSION;
// Version number used for comparing versions using the "Check QGIS Version" function
static const int QGIS_VERSION_INT;
// Release name
static const char* QGIS_RELEASE_NAME;
// The development version
static const char* QGIS_DEV_VERSION;

// Enumerations
//

//! Used for symbology operations
// Feature types
enum WkbType
{
WKBUnknown = 0,
WKBPoint = 1,
WKBLineString,
WKBPolygon,
WKBMultiPoint,
WKBMultiLineString,
WKBMultiPolygon,
WKBNoGeometry = 100, //attributes only
WKBPoint25D = 0x80000001,
WKBLineString25D,
WKBPolygon25D,
WKBMultiPoint25D,
WKBMultiLineString25D,
WKBMultiPolygon25D,
};

enum GeometryType
{
Point,
Line,
Polygon,
UnknownGeometry,
NoGeometry
};

// TODO: String representation of geometry types (set in qgis.cpp)
// static const char *qgisVectorGeometryType[];

//! description strings for feature types
// static const char *qgisFeatureTypes[];

/** Map units that qgis supports
* @note that QGIS < 1.4 api had only Meters, Feet, Degrees and UnknownUnit
* @note and QGIS >1.8 returns to that
*/
enum UnitType
{
Meters = 0,
Feet = 1,
Degrees = 2, //for 1.0 api backwards compatibility
UnknownUnit = 3,

// for [1.4;1.8] api compatibility
DecimalDegrees = 2, // was 2
DegreesMinutesSeconds = 2, // was 4
DegreesDecimalMinutes = 2, // was 5
};

//! User defined event types
enum UserEvent
{
// These first two are useful for threads to alert their parent data providers

//! The extents have been calculated by a provider of a layer
ProviderExtentCalcEvent = QgisEvent,

//! The row count has been calculated by a provider of a layer
ProviderCountCalcEvent
};

static const double DEFAULT_IDENTIFY_RADIUS;
};


/** Wkt string that represents a geographic coord sys
* @note added in 1.8 to replace GEOWkt
*/
const QString GEOWKT;
/** Wkt string that represents a geographic coord sys
* @note deprecated in 1.8 due to violation of coding conventions (globals
* should be in all caps).
*/
const QString GEOWkt /Deprecated/;

/** PROJ4 string that represents a geographic coord sys */
const QString GEOPROJ4;
/** Magic number for a geographic coord sys in POSTGIS SRID */
const long GEOSRID;
/** Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id */
const long GEOCRS_ID;
/** Magic number for a geographic coord sys in EpsgCrsId ID format */
const long GEO_EPSG_CRS_ID;
/** The length of teh string "+proj=" */
const int PROJ_PREFIX_LEN;
/** The length of teh string "+ellps=" */
const int ELLPS_PREFIX_LEN;
/** The length of the string "+lat_1=" */
const int LAT_PREFIX_LEN;
/** Magick number that determins whether a projection srsid is a system (srs.db)
* or user (~/.qgis.qgis.db) defined projection. */
const int USER_CRS_START_ID;

//
// Constants for point symbols
//

/** Magic number that determines the minimum allowable point size for point symbols */
const float MINIMUM_POINT_SIZE;
/** Magic number that determines the minimum allowable point size for point symbols */
const float DEFAULT_POINT_SIZE;
const double DEFAULT_LINE_WIDTH;
/** Wkt string that represents a geographic coord sys
* @note added in 1.8 to replace GEOWkt
*/
const QString GEOWKT;

/** Wkt string that represents a geographic coord sys
* @note deprecated in 1.8 due to violation of coding conventions (globals
* should be in all caps).
*/
const QString GEOWkt /Deprecated/;

const QString PROJECT_SCALES;

/** PROJ4 string that represents a geographic coord sys */
const QString GEOPROJ4;
/** Magic number for a geographic coord sys in POSTGIS SRID */
const long GEOSRID;
/** Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id */
const long GEOCRS_ID;
/** Magic number for a geographic coord sys in EpsgCrsId ID format */
const long GEO_EPSG_CRS_ID;
/** Geographic coord sys from EPSG authority */
const QString GEO_EPSG_CRS_AUTHID;
/** The length of the string "+proj=" */
const int PROJ_PREFIX_LEN;
/** The length of the string "+ellps=" */
const int ELLPS_PREFIX_LEN;
/** The length of the string "+lat_1=" */
const int LAT_PREFIX_LEN;
/** Magick number that determines whether a projection crsid is a system (srs.db)
* or user (~/.qgis.qgis.db) defined projection. */
const int USER_CRS_START_ID;

//
// Constants for point symbols
//

/** Magic number that determines the minimum allowable point size for point symbols */
const double MINIMUM_POINT_SIZE;
/** Magic number that determines the default point size for point symbols */
const double DEFAULT_POINT_SIZE;
const double DEFAULT_LINE_WIDTH;

/** default snapping tolerance for segments (@note added in 1.8) */
const double DEFAULT_SEGMENT_EPSILON;

64 changes: 37 additions & 27 deletions python/core/qgsapplication.sip
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
* The theme search path usually will be pkgDataPath + "/themes/" + themName + "/"
* but plugin writers etc can use themeName() as a basis for searching
* for resources in their own datastores e.g. a Qt4 resource bundle.
* @Note A basic test will be carried out to ensure the theme search path
* based on the supplied theme name exists. If it does not the theme name will
* @note A basic test will be carried out to ensure the theme search path
* based on the supplied theme name exists. If it does not the theme name will
* be reverted to 'default'.
*/
static void setThemeName(const QString theThemeName);
static void setThemeName( const QString theThemeName );

/** Set the active theme to the specified theme.
* The theme name should be a single word e.g. 'default','classic'.
Expand Down Expand Up @@ -125,7 +125,8 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
static const QString translatorsFilePath();

//! Returns the path to the developer image directory.
static const QString developerPath();
//! @deprecated images are not provided anymore :-P
static const QString developerPath() /Deprecated/;

//! Returns the path to the help application.
static const QString helpAppPath();
Expand All @@ -138,7 +139,7 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)

//! Returns the path to the settings directory in user's home dir
static const QString qgisSettingsDirPath();

//! Returns the path to the user qgis.db file.
static const QString qgisUserDbFilePath();

Expand All @@ -151,12 +152,12 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
//! Returns the path to the srs.db file.
static const QString srsDbFilePath();

//! Returns the paths to the svg directories.
//! Returns the pathes to svg directories.
//! @note added in 1.4
static const QStringList svgPaths();

//! Returns the path to the applications svg paths
//! @deprecated use svgPaths()
//! Returns the paths to svg applications svg directory.
//! @deprecated since 1.4 - use svgPaths()
static const QString svgPath() /Deprecated/;

//! Returns the path to the application prefix directory.
Expand All @@ -169,16 +170,26 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
static const QString pkgDataPath();

//! Returns the path to the currently active theme directory.
static const QString activeThemePath();
static const QString activeThemePath();

//! Returns the path to the default theme directory.
static const QString defaultThemePath();
static const QString defaultThemePath();

//! Returns path to the desired icon file.
//! First it tries to use the active theme path, then default theme path
//! @note Added in 1.5
static QString iconPath( QString iconFile );

//! Helper to get a theme icon. It will fall back to the
//! default theme if the active theme does not have the required icon.
//! @note Added in 2.0
static QIcon getThemeIcon( const QString theName );

//! Helper to get a theme icon as a pixmap. It will fall back to the
//! default theme if the active theme does not have the required icon.
//! @note Added in 2.0
static QPixmap getThemePixmap( const QString theName );

//! Returns the path to user's style. Added in QGIS 1.4
static const QString userStyleV2Path();

Expand All @@ -194,23 +205,23 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
static const QString libexecPath();

//! Alters prefix path - used by 3rd party apps
static void setPrefixPath(const QString thePrefixPath, bool useDefaultPaths = FALSE);
static void setPrefixPath( const QString thePrefixPath, bool useDefaultPaths = false );

//! Alters plugin path - used by 3rd party apps
static void setPluginPath(const QString thePluginPath);
static void setPluginPath( const QString thePluginPath );

//! Alters pkg data path - used by 3rd party apps
static void setPkgDataPath(const QString thePkgDataPath);
static void setPkgDataPath( const QString thePkgDataPath );

//! Alters default svg paths - used by 3rd party apps. Added in QGIS 1.5
static void setDefaultSvgPaths( const QStringList& pathList );

//! loads providers
static void initQgis();

//! deletes provider registry and map layer registry
static void exitQgis();

/** constants for endian-ness */
enum endian_t
{
Expand All @@ -231,14 +242,14 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
*/
static QString reportStyleSheet();

/** Convenience function to get a summary of the paths used in this
/** Convenience function to get a summary of the paths used in this
* application instance useful for debugging mainly.*/
static QString showSettings();

/** Register OGR drivers ensuring this only happens once.
* This is a workaround for an issue with older gdal versions that
* caused duplicate driver name entries to appear in the list
* of registered drivers when QgsApplication::registerOgrDrivers was called multiple
* caused duplicate driver name entries to appear in the list
* of registered drivers when QgsApplication::registerOgrDrivers was called multiple
* times.
*/
static void registerOgrDrivers();
Expand All @@ -260,26 +271,25 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
@note added in 2.0 */
static QString buildOutputPath();

/** Sets the GDAL_SKIP environment variable to include the specified driver
/** Sets the GDAL_SKIP environment variable to include the specified driver
* and then calls GDALDriverManager::AutoSkipDrivers() to unregister it. The
* driver name should be the short format of the Gdal driver name e.g. GTiff.
* driver name should be the short format of the Gdal driver name e.g. GTIFF.
* @note added in 2.0
*/
static void skipGdalDriver( QString theDriver );

/** Sets the GDAL_SKIP environment variable to exclude the specified driver
/** Sets the GDAL_SKIP environment variable to exclude the specified driver
* and then calls GDALDriverManager::AutoSkipDrivers() to unregister it. The
* driver name should be the short format of the Gdal driver name e.g. GTiff.
* driver name should be the short format of the Gdal driver name e.g. GTIFF.
* @note added in 2.0
*/
static void restoreGdalDriver( QString theDriver );


/** Returns the list of gdal drivers that should be skipped (based on
* GDAL_SKIP environment variable)
* GDAL_SKIP environment variable)
* @note added in 2.0
*/
static QStringList skippedGdalDrivers( ) const ;
static QStringList skippedGdalDrivers( );

/** Apply the skipped drivers list to gdal
* @see skipGdalDriver
Expand Down
237 changes: 124 additions & 113 deletions python/core/qgsdatasourceuri.sip
Original file line number Diff line number Diff line change
Expand Up @@ -11,117 +11,128 @@ class QgsDataSourceURI
#include <qgsdatasourceuri.h>
%End

public:
//! \note enumeration added in version 1.1
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire };

//! default constructor
QgsDataSourceURI();

//! constructor which parses input URI
QgsDataSourceURI(QString uri);

//! connection info
QString connectionInfo() const;

//! complete uri
QString uri() const;

//! quoted table name
QString quotedTablename() const;

//! return complete encoded uri (generic mode)
// \note added in 1.9
QByteArray encodedUri() const;

//! set complete encoded uri (generic mode)
// \note added in 1.9
void setEncodedUri( const QByteArray & uri );

//! set complete encoded uri (generic mode)
// \note added in 1.9
void setEncodedUri( const QString & uri );

//! Set generic param (generic mode)
// \note if key exists, another is inserted
// \note added in 1.9
void setParam( const QString &key, const QString &value );
void setParam( const QString &key, const QStringList &value );

//! Remove generic param (generic mode)
// \note remove all occurrences of key, returns number of params removed
// \note added in 1.9
int removeParam( const QString &key );

//! Get generic param (generic mode)
// \note added in 1.9
QString param( const QString &key ) const;

//! Get multiple generic param (generic mode)
// \note added in 1.9
QStringList params( const QString &key ) const;

//! Test if param exists (generic mode)
// \note added in 1.9
bool hasParam( const QString &key ) const;

//! Set all connection related members at once
//! \note This optional sslmode parameter has been added in version 1.1
void setConnection(const QString& aHost,
const QString& aPort,
const QString& aDatabase,
const QString& aUsername,
const QString& aPassword,
SSLmode sslmode = SSLprefer );

//! Set all connection related members at once
//! \note added in 1.7
void setConnection(const QString& service,
const QString& aDatabase,
const QString& aUsername,
const QString& aPassword,
SSLmode sslmode = SSLprefer );

//! Set database
//! \note added in 1.4
void setDatabase( const QString &database );

//! Set all data source related members at once
void setDataSource(const QString& aSchema,
const QString& aTable,
const QString& aGeometryColumn,
const QString& aSql = QString(),
const QString& aKeyColumn = QString());

/** Removes password from uris
* @note this method was added in QGIS 1.1
*/
static QString removePassword( const QString& aUri);

QString username() const;
QString schema() const;
QString table() const;
QString sql() const;
QString geometryColumn() const;

//! set use Estimated Metadata
// added in 1.5
void setUseEstimatedMetadata( bool theFlag );
bool useEstimatedMetadata() const;

// added in 1.1
QString host() const;
QString database() const;
QString password() const;
QString port() const;
SSLmode sslMode() const;

// added in 1.7
QString service() const;

void setSql(QString sql);

// added in 1.2
QString keyColumn() const;
void setKeyColumn(QString column);
public:
//! \note enumeration added in version 1.1
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire };

//! default constructor
QgsDataSourceURI();

//! constructor which parses input URI
QgsDataSourceURI( QString uri );

//! return connection part of URI
QString connectionInfo() const;

//! return complete uri
QString uri() const;

//! return complete encoded uri (generic mode)
// \note added in 1.9
QByteArray encodedUri() const;

//! set complete encoded uri (generic mode)
// \note added in 1.9
void setEncodedUri( const QString & uri );

//! quoted table name
QString quotedTablename() const;

//! Set generic param (generic mode)
// \note if key exists, another is inserted
// \note added in 1.9
void setParam( const QString &key, const QString &value );
void setParamList( const QString &key, const QStringList &value );
%MethodCode
sipCpp->setParam( *a0, *a1 );
%End

//! Get generic param (generic mode)
// \note added in 1.9
QString param( const QString &key ) const;

//! Get multiple generic param (generic mode)
// \note added in 1.9
QStringList params( const QString &key ) const;

//! Test if param exists (generic mode)
// \note added in 1.9
bool hasParam( const QString &key ) const;

//! Set all connection related members at once
//! \note This optional sslmode parameter has been added in version 1.1
void setConnection( const QString& aHost,
const QString& aPort,
const QString& aDatabase,
const QString& aUsername,
const QString& aPassword,
SSLmode sslmode = SSLprefer );

//! Set all connection related members at once (for the service case)
//! \note This optional sslmode parameter has been added in version 1.7
void setConnection( const QString& aService,
const QString& aDatabase,
const QString& aUsername,
const QString& aPassword,
SSLmode sslmode = SSLprefer );

//! Set database
// \note added in 1.4
void setDatabase( const QString &database );

//! Set all data source related members at once
void setDataSource( const QString& aSchema,
const QString& aTable,
const QString& aGeometryColumn,
const QString& aSql = QString(),
const QString& aKeyColumn = QString() );

//! set username
// added in 1.5
void setUsername( QString username );

//! set password
// added in 1.5
void setPassword( QString password );

//! Removes password element from uris
static QString removePassword( const QString& aUri );

QString username() const;
QString schema() const;
QString table() const;
QString sql() const;
QString geometryColumn() const;

//! set use Estimated Metadata
// added in 1.5
void setUseEstimatedMetadata( bool theFlag );
bool useEstimatedMetadata() const;

void disableSelectAtId( bool theFlag );
bool selectAtIdDisabled() const;

void clearSchema();
void setSql( QString sql );

// added in version 1.1
QString host() const;
QString database() const;
QString port() const;
QString password() const;
SSLmode sslMode() const;

// added in 1.7
QString service() const;

// added in version 1.2
QString keyColumn() const;
void setKeyColumn( QString column );

// added in 1.9
QGis::WkbType wkbType() const;
void setWkbType( QGis::WkbType type );

QString srid() const;
void setSrid( QString srid );
};
214 changes: 111 additions & 103 deletions python/core/qgsgeometry.sip

Large diffs are not rendered by default.

147 changes: 76 additions & 71 deletions python/core/qgspoint.sip
Original file line number Diff line number Diff line change
Expand Up @@ -8,89 +8,94 @@ class QgsPoint
#include <QString>
%End


public:
public:
/// Default constructor
QgsPoint();

/*! Create a point from another point */
QgsPoint(const QgsPoint& p);

/*! Create a point from x,y coordinates
* @param x x coordinate
* @param y y coordinate
*/
QgsPoint(double x, double y);

~QgsPoint();

/*! Sets the x value of the point
* @param x x coordinate
*/
void setX(double x);

/*! Sets the y value of the point
* @param y y coordinate
*/
void setY(double y);
QgsPoint();

/*! Sets the x and y value of the point */
void set(double x, double y);
/*! Create a point from another point */
QgsPoint(const QgsPoint& p);

/*! Create a point from x,y coordinates
* @param x x coordinate
* @param y y coordinate
*/
QgsPoint( double x, double y );

~QgsPoint();

/*! Sets the x value of the point
* @param x x coordinate
*/
void setX( double x );

/*! Sets the y value of the point
* @param y y coordinate
*/
void setY( double y );

/*! Get the x value of the point
* @return x coordinate
*/
double x() const;
/*! Sets the x and y value of the point */
void set( double x, double y );

/*! Get the y value of the point
* @return y coordinate
*/
double y() const;
/*! Get the x value of the point
* @return x coordinate
*/
double x() const;

//! String representation of the point (x,y)
QString toString() const;
/*! Get the y value of the point
* @return y coordinate
*/
double y() const;

//! As above but with precision for string representaiton of a point
QString toString(int thePrecision) const;

/** Return a string representation as degrees minutes seconds.
* Its up to the calling function to ensure that this point can
* be meaningfully represented in this form.
* @note added in QGIS 1.4
*/
QString toDegreesMinutesSeconds( int thePrecision ) const;
//! String representation of the point (x,y)
QString toString() const;


/*! Return the well known text representation for the point.
* The wkt is created without an SRID.
* @return Well known text in the form POINT(x y)
*/
QString wellKnownText();
//! As above but with precision for string representation of a point
QString toString( int thePrecision ) const;

/** Return a string representation as degrees minutes seconds.
* Its up to the calling function to ensure that this point can
* be meaningfully represented in this form.
* @note added in QGIS 1.4
*/
QString toDegreesMinutesSeconds( int thePrecision ) const;

/** Return a string representation as degrees minutes.
* Its up to the calling function to ensure that this point can
* be meaningfully represented in this form.
* @note added in QGIS 1.9
*/
QString toDegreesMinutes( int thePrecision ) const;


/*! Return the well known text representation for the point.
* The wkt is created without an SRID.
* @return Well known text in the form POINT(x y)
*/
QString wellKnownText() const;

/**Returns the squared distance between this point and x,y*/
double sqrDist(double x, double y) const;
/**Returns the squared distance between this point and x,y*/
double sqrDist( double x, double y ) const;

/**Returns the squared distance between this and other point*/
double sqrDist(const QgsPoint& other);
/**Returns the squared distance between this and other point*/
double sqrDist( const QgsPoint& other ) const;

/**Returns the minimum distance between this point and a segment
/**Returns the minimum distance between this point and a segment
@note added in QGIS 1.5*/
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPoint& minDistPoint /Out/) const;
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPoint& minDistPoint /Out/, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;

/**Calculates azimut between this point and other one (clockwise in degree, starting from north)
@note: this function has been added in version 1.7*/
double azimuth( const QgsPoint& other );
/**Calculates azimut between this point and other one (clockwise in degree, starting from north)
@note: this function has been added in version 1.7*/
double azimuth( const QgsPoint& other );

//! equality operator
bool operator==( const QgsPoint &other );

//! Inequality operator
bool operator!=( const QgsPoint &other ) const;

//! Multiply x and y by the given value
void multiply( const double& scalar );

//! equality operator
bool operator==(const QgsPoint &other);

//! Inequality operator
bool operator!=(const QgsPoint &other);

//! Multiply x and y by the given value
void multiply(const double& scalar);


SIP_PYOBJECT __repr__();
%MethodCode
QString str = "(" + QString::number(sipCpp->x()) + "," + QString::number(sipCpp->y()) + ")";
Expand Down Expand Up @@ -118,5 +123,5 @@ public:



}; // class QgsPOint
}; // class QgsPoint

7 changes: 3 additions & 4 deletions python/plugins/db_manager/db_plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,21 @@ def info(self):
from .info_model import DatabaseInfo
return DatabaseInfo(self)


def sqlResultModel(self, sql, parent):
from .data_model import SqlResultModel
return SqlResultModel(self, sql, parent)


def toSqlLayer(self, sql, geomCol, uniqueCol, layerName="QueryLayer", layerType=None):
def toSqlLayer(self, sql, geomCol, uniqueCol, layerName="QueryLayer", layerType=None, avoidSelectById=False):
from qgis.core import QgsMapLayer, QgsVectorLayer, QgsRasterLayer
uri = self.uri()
uri.setDataSource("", u"(%s\n)" % sql, geomCol, QString(), uniqueCol)
if avoidSelectById:
uri.disableSelectAtId( True )
provider = self.dbplugin().providerName()
if layerType == QgsMapLayer.RasterLayer:
return QgsRasterLayer(uri.uri(), layerName, provider)
return QgsVectorLayer(uri.uri(), layerName, provider)


def registerAllActions(self, mainWindow):
self.registerDatabaseActions(mainWindow)
self.registerSubPluginActions(mainWindow)
Expand Down
1 change: 0 additions & 1 deletion python/plugins/db_manager/db_plugins/postgis/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ def tableTriggersFactory(self, row, table):
def tableRulesFactory(self, row, table):
return PGTableRule(row, table)


def info(self):
from .info_model import PGTableInfo
return PGTableInfo(self)
Expand Down
4 changes: 1 addition & 3 deletions python/plugins/db_manager/dlg_sql_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def loadAsLayerToggled(self, checked):
self.loadAsLayerGroup.setChecked( checked )
self.loadAsLayerWidget.setVisible( checked )


def getSql(self):
# If the selection obtained from an editor spans a line break,
# the text will contain a Unicode U+2029 paragraph separator
Expand Down Expand Up @@ -132,7 +131,6 @@ def executeSql(self):
self.update()
QApplication.restoreOverrideCursor()


def loadSqlLayer(self):
uniqueFieldName = self.uniqueCombo.currentText()
geomFieldName = self.geomCombo.currentText()
Expand Down Expand Up @@ -165,7 +163,7 @@ def loadSqlLayer(self):
newLayerName = u"%s_%d" % (layerName, index)

# create the layer
layer = self.db.toSqlLayer(query, geomFieldName, uniqueFieldName, newLayerName, layerType)
layer = self.db.toSqlLayer(query, geomFieldName, uniqueFieldName, newLayerName, layerType, self.avoidSelectById.isChecked())
if layer.isValid():
QgsMapLayerRegistry.instance().addMapLayer(layer, True)

Expand Down
55 changes: 41 additions & 14 deletions python/plugins/db_manager/ui/DlgSqlWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>738</width>
<width>747</width>
<height>525</height>
</rect>
</property>
Expand All @@ -19,7 +19,7 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
Expand Down Expand Up @@ -81,7 +81,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
Expand All @@ -107,6 +107,16 @@
</widget>
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="loadAsLayerGroup">
<property name="sizePolicy">
Expand Down Expand Up @@ -286,19 +296,19 @@ columns</string>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="avoidSelectById">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Avoid selecting feature by id. Sometimes - especially when running expensive queries/views - fetching the data sequentially instead of fetching features by id can be much quicker.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Avoid selecting by feature id</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand All @@ -315,5 +325,22 @@ columns</string>
<tabstop>viewResult</tabstop>
</tabstops>
<resources/>
<connections/>
<connections>
<connection>
<sender>loadAsLayerGroup</sender>
<signal>toggled(bool)</signal>
<receiver>avoidSelectById</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>88</x>
<y>351</y>
</hint>
<hint type="destinationlabel">
<x>142</x>
<y>451</y>
</hint>
</hints>
</connection>
</connections>
</ui>
2 changes: 1 addition & 1 deletion python/plugins/fTools/tools/doMergeShapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def accept( self ):
outFile = QFile( self.outFileName )
if outFile.exists():
if not QgsVectorFileWriter.deleteShapeFile( self.outFileName ):
QMessageBox.warning( self, self.tr( "Delete error" ), self.tr( "Can't delete file %1" ).arg( outFileName ) )
QMessageBox.warning( self, self.tr( "Delete error" ), self.tr( "Can't delete file %1" ).arg( self.outFileName ) )
return

if self.inEncoding == None:
Expand Down
13 changes: 13 additions & 0 deletions resources/function_help/title-de_DE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h3>Funktion title()</h3>
Wandelt alle Worte einer Zeichenkette in Kleinbuchstaben mit groĂźem Anfangsbuchstaben um.

<p><h4>Syntax</h4>
title(<i>zeichenkette</i>)</p>

<p><h4>Argumente</h4>
<!-- List args for functions here-->
<i> zeichenkette</i> &rarr; ist eine Zeichenkette. Die Zeichenkette, deren Worte in Kleinbuchstaben mit groĂźem Anfangsbuchstaben umgewandelt werden.</p>

<p><h4>Beispiel</h4>
<!-- Show example of function.-->
title('hello WOrld') &rarr; 'Hello World'</p>
14 changes: 14 additions & 0 deletions resources/function_help/title_en_US
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<h3>title() function</h3>
Converts all words of a string to title case (all words lower case with leading
capital letter).

<p><h4>Syntax</h4>
title(<i>string</i>)</p>

<p><h4>Arguments</h4>
<!-- List args for functions here-->
<i> string</i> &rarr; is string. The string to convert to title case.</p>

<p><h4>Example</h4>
<!-- Show example of function.-->
upper('hello WOrld') &rarr; 'Hello World'</p>
2 changes: 1 addition & 1 deletion scripts/prepare-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set -e
if [ -d .svn ]; then
MODIFIED=$(svn status | sed -ne "s/^[MA] *//p")
elif [ -d .git ]; then
MODIFIED=$(git status | sed -rne "s/^# (modified|new file): *//p" | sort -u)
MODIFIED=$(git status --porcelain| sed -ne "s/^ *[MA] *//p" | sort -u)
else
echo No working copy
exit 1
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/vector/qgsgeometryanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
eventLayer->select( eventLayer->pendingAllAttributesList(), QgsRectangle(), false, false );
QgsGeometry* lrsGeom = 0;
QgsFeature lineFeature;
double measure1, measure2;
double measure1, measure2 = 0.0;

int nEventFeatures = eventLayer->pendingFeatureCount();
int featureCounter = 0;
Expand Down Expand Up @@ -1271,7 +1271,7 @@ unsigned char* QgsGeometryAnalyzer::locateBetweenWkbString( unsigned char* ptr,
{
int* nPoints = ( int* ) ptr;
ptr += sizeof( int );
double prevx, prevy, prevz;
double prevx = 0.0, prevy = 0.0, prevz = 0.0;
double *x, *y, *z;
QgsPolyline currentLine;

Expand Down Expand Up @@ -1323,7 +1323,7 @@ unsigned char* QgsGeometryAnalyzer::locateAlongWkbString( unsigned char* ptr, Qg
{
int* nPoints = ( int* ) ptr;
ptr += sizeof( int );
double prevx, prevy, prevz;
double prevx = 0.0, prevy = 0.0, prevz = 0.0;
double *x, *y, *z;

QgsPoint pt1, pt2;
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void QgsComposer::setIconSizes( int size )

//Change all current icon sizes.
QList<QToolBar *> toolbars = findChildren<QToolBar *>();
foreach( QToolBar * toolbar, toolbars )
foreach ( QToolBar * toolbar, toolbars )
{
toolbar->setIconSize( QSize( size, size ) );
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/legend/qgslayerorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void QgsLayerOrder::refreshLayerList()
{
clear();

foreach( QgsLegendLayer *layer, mLegend->legendLayers() )
foreach ( QgsLegendLayer *layer, mLegend->legendLayers() )
{
QListWidgetItem *item = new QListWidgetItem( layer->layer()->name() );
item->setData( 1, QString::number( layer->drawingOrder() ) );
Expand Down Expand Up @@ -234,7 +234,7 @@ void QgsLayerOrder::mouseReleaseEvent( QMouseEvent * e )

setCursor( QCursor( Qt::ArrowCursor ) );

foreach( QListWidgetItem *item, mItemsBeingMoved )
foreach ( QListWidgetItem *item, mItemsBeingMoved )
{
if ( mInsertRow >= count() )
{
Expand Down
46 changes: 23 additions & 23 deletions src/app/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static QString getUniqueGroupName( QString prefix, QStringList groups )
match.replaceInStrings( prefix, QString( "" ) );
// find the maximum
int max = 0;
foreach( QString m, match )
foreach ( QString m, match )
{
if ( m.toInt() > max )
max = m.toInt();
Expand Down Expand Up @@ -286,7 +286,7 @@ void QgsLegend::removeGroup( int groupIndex )
void QgsLegend::removeLayers( QStringList theLayers )
{
QgsDebugMsg( "Entering." );
foreach( const QString &myId, theLayers )
foreach ( const QString &myId, theLayers )
{
bool invLayerRemoved = false;

Expand Down Expand Up @@ -364,7 +364,7 @@ void QgsLegend::mouseMoveEvent( QMouseEvent * e )
QgsDebugMsg( "layers prior to move: " + mLayersPriorToMove.join( ", " ) );

// record which items were selected and hide them
foreach( QTreeWidgetItem * item, selectedItems() )
foreach ( QTreeWidgetItem * item, selectedItems() )
{
//prevent to drag out content under groups that are embedded from other
//project files.
Expand All @@ -377,7 +377,7 @@ void QgsLegend::mouseMoveEvent( QMouseEvent * e )
}

// remove and unhide items, whose parent is already to be moved
foreach( QTreeWidgetItem * item, mItemsBeingMoved )
foreach ( QTreeWidgetItem * item, mItemsBeingMoved )
{
QTreeWidgetItem *parent = item->parent();

Expand Down Expand Up @@ -433,7 +433,7 @@ void QgsLegend::mouseMoveEvent( QMouseEvent * e )
showItem( "layer/group" , item );

int line_x = visualItemRect( item ).left();
int line_y;
int line_y = 0;
if ( layer )
{
QTreeWidgetItem *lastItem = item->childCount() > 0 && item->isExpanded() ? item->child( item->childCount() - 1 ) : item;
Expand Down Expand Up @@ -556,7 +556,7 @@ void QgsLegend::mouseReleaseEvent( QMouseEvent * e )
hideLine();

// unhide
foreach( QTreeWidgetItem * item, mItemsBeingMoved )
foreach ( QTreeWidgetItem * item, mItemsBeingMoved )
{
item->setHidden( false );
}
Expand All @@ -574,7 +574,7 @@ void QgsLegend::mouseReleaseEvent( QMouseEvent * e )

showItem( "prev sibling", mDropTarget );

foreach( QTreeWidgetItem * item, mItemsBeingMoved )
foreach ( QTreeWidgetItem * item, mItemsBeingMoved )
{
moveItem( item, mDropTarget );
mDropTarget = item;
Expand All @@ -601,7 +601,7 @@ void QgsLegend::mouseReleaseEvent( QMouseEvent * e )
{
showItem( "drop after", mDropTarget );

foreach( QTreeWidgetItem * item, mItemsBeingMoved )
foreach ( QTreeWidgetItem * item, mItemsBeingMoved )
{
moveItem( item, mDropTarget );
mDropTarget = item;
Expand All @@ -612,7 +612,7 @@ void QgsLegend::mouseReleaseEvent( QMouseEvent * e )
{
showItem( "insert into", mDropTarget );

foreach( QTreeWidgetItem * item, mItemsBeingMoved )
foreach ( QTreeWidgetItem * item, mItemsBeingMoved )
{
insertItem( item, mDropTarget );
}
Expand Down Expand Up @@ -968,7 +968,7 @@ void QgsLegend::addLayers( QList<QgsMapLayer *> theLayerList )
!mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
// Verify if all layers have the same CRS
foreach( QgsMapLayer *l, layers() )
foreach ( QgsMapLayer *l, layers() )
{
if ( myPreviousCrs != l->crs() )
{
Expand Down Expand Up @@ -1040,7 +1040,7 @@ QList<QgsMapLayer *> QgsLegend::selectedLayers()
{
QList<QgsMapLayer *> layers;

foreach( QTreeWidgetItem * item, selectedItems() )
foreach ( QTreeWidgetItem * item, selectedItems() )
{
QgsLegendLayer *ll = dynamic_cast<QgsLegendLayer *>( item );
if ( ll )
Expand Down Expand Up @@ -1087,7 +1087,7 @@ QList<QgsLegendLayer *> QgsLegend::legendLayers()

QList< QgsLegendLayer * > ls;

foreach( int o, items.uniqueKeys() )
foreach ( int o, items.uniqueKeys() )
{
QgsDebugMsgLevel( QString( "o=%1" ).arg( o ), 3 );
QList< QgsLegendLayer *> values = items.values( o );
Expand All @@ -1106,7 +1106,7 @@ QList<QgsMapLayer *> QgsLegend::layers()
{
QList<QgsMapLayer *> ls;

foreach( QgsLegendLayer *l, legendLayers() )
foreach ( QgsLegendLayer *l, legendLayers() )
{
ls << l->layer();
}
Expand All @@ -1118,7 +1118,7 @@ QList<QgsMapCanvasLayer> QgsLegend::canvasLayers()
{
QList<QgsMapCanvasLayer> ls;

foreach( QgsLegendLayer *l, legendLayers() )
foreach ( QgsLegendLayer *l, legendLayers() )
{
ls << l->canvasLayer();
}
Expand Down Expand Up @@ -1234,7 +1234,7 @@ void QgsLegend::setGroupCRS( QgsLegendGroup *lg, const QgsCoordinateReferenceSys
return;
}

foreach( QgsLegendLayer *cl, lg->legendLayers() )
foreach ( QgsLegendLayer *cl, lg->legendLayers() )
{
if ( cl )
{
Expand Down Expand Up @@ -1310,7 +1310,7 @@ bool QgsLegend::writeXML( QDomNode &legendnode, QDomDocument &document )

bool QgsLegend::writeXML( QList<QTreeWidgetItem *> items, QDomNode &node, QDomDocument &document )
{
foreach( QTreeWidgetItem * currentItem, items )
foreach ( QTreeWidgetItem * currentItem, items )
{
QgsLegendItem *item = dynamic_cast<QgsLegendItem *>( currentItem );
if ( !item )
Expand Down Expand Up @@ -2002,7 +2002,7 @@ QStringList QgsLegend::layerIDs()

#ifdef QGISDEBUG
QgsDebugMsg( "QgsLegend::layerIDs()" );
foreach( QString id, layers )
foreach ( QString id, layers )
{
QgsDebugMsg( id );
}
Expand Down Expand Up @@ -2119,7 +2119,7 @@ void QgsLegend::handleItemChange( QTreeWidgetItem* item, int column )

if ( item->isSelected() )
{
foreach( QTreeWidgetItem * i, selectedItems() )
foreach ( QTreeWidgetItem * i, selectedItems() )
{
if ( i != item )
{
Expand Down Expand Up @@ -2449,7 +2449,7 @@ void QgsLegend::removeSelectedLayers()
// Turn off rendering to improve speed.
mMapCanvas->freeze();

foreach( QTreeWidgetItem * item, selectedItems() )
foreach ( QTreeWidgetItem * item, selectedItems() )
{
QgsLegendGroup* lg = dynamic_cast<QgsLegendGroup *>( item );
if ( lg )
Expand All @@ -2476,7 +2476,7 @@ void QgsLegend::setCRSForSelectedLayers( const QgsCoordinateReferenceSystem &crs
// Turn off rendering to improve speed.
mMapCanvas->freeze();

foreach( QTreeWidgetItem * item, selectedItems() )
foreach ( QTreeWidgetItem * item, selectedItems() )
{
QgsLegendGroup* lg = dynamic_cast<QgsLegendGroup *>( item );
if ( lg )
Expand Down Expand Up @@ -2564,7 +2564,7 @@ void QgsLegend::groupSelectedLayers()
blockSignals( true );

QTreeWidgetItem * parent = 0;
foreach( QTreeWidgetItem* item, selectedItems() )
foreach ( QTreeWidgetItem* item, selectedItems() )
{
parent = item->parent();
}
Expand All @@ -2585,7 +2585,7 @@ void QgsLegend::groupSelectedLayers()
QList< QModelIndex > oldIndexes;
QList< QTreeWidgetItem* > selected;

foreach( QTreeWidgetItem * item, selectedItems() )
foreach ( QTreeWidgetItem * item, selectedItems() )
{
QgsLegendLayer* layer = dynamic_cast<QgsLegendLayer *>( item );
if ( layer )
Expand All @@ -2594,7 +2594,7 @@ void QgsLegend::groupSelectedLayers()
selected.append( item );
}
}
foreach( QTreeWidgetItem * item, selected )
foreach ( QTreeWidgetItem * item, selected )
{
insertItem( item, group );
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/legend/qgslegendgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Qt::CheckState QgsLegendGroup::pendingCheckState()
return Qt::PartiallyChecked;

Qt::CheckState theState = elements[0]->checkState( 0 );
foreach( QgsLegendItem * li, elements )
foreach ( QgsLegendItem * li, elements )
{
if ( theState != li->checkState( 0 ) )
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,13 @@ void QgsMapToolNodeTool::deactivate()
void QgsMapToolNodeTool::removeRubberBands()
{
// cleanup rubberbands and list
foreach( QgsRubberBand *rb, mRubberBands )
foreach ( QgsRubberBand *rb, mRubberBands )
{
delete rb;
}
mRubberBands.clear();

foreach( QgsRubberBand *rb, mTopologyRubberBand )
foreach ( QgsRubberBand *rb, mTopologyRubberBand )
{
delete rb;
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/nodetool/qgsselectedfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void QgsSelectedFeature::validationFinished()
void QgsSelectedFeature::deleteSelectedVertexes()
{
int nSelected = 0;
foreach( QgsVertexEntry *entry, mVertexMap )
foreach ( QgsVertexEntry *entry, mVertexMap )
{
if ( entry->isSelected() )
nSelected++;
Expand Down Expand Up @@ -303,7 +303,7 @@ void QgsSelectedFeature::deleteSelectedVertexes()
void QgsSelectedFeature::moveSelectedVertexes( const QgsVector &v )
{
int nUpdates = 0;
foreach( QgsVertexEntry *entry, mVertexMap )
foreach ( QgsVertexEntry *entry, mVertexMap )
{
if ( entry->isSelected() )
nUpdates++;
Expand Down Expand Up @@ -370,7 +370,7 @@ void QgsSelectedFeature::replaceVertexMap()

void QgsSelectedFeature::deleteVertexMap()
{
foreach( QgsVertexEntry *entry, mVertexMap )
foreach ( QgsVertexEntry *entry, mVertexMap )
{
delete entry;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/ogr/qgsogrsublayersdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ QList<int> QgsOGRSublayersDialog::getSelectionIndexes()

void QgsOGRSublayersDialog::populateLayerTable( QStringList theList, QString delim )
{
foreach( QString item, theList )
foreach ( QString item, theList )
{
layersTable->addTopLevelItem( new QTreeWidgetItem( item.split( delim ) ) );
}
Expand Down
63 changes: 36 additions & 27 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ void QgisApp::dropEvent( QDropEvent *event )
if ( QgsMimeDataUtils::isUriList( event->mimeData() ) )
{
QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( event->mimeData() );
foreach( const QgsMimeDataUtils::Uri& u, lst )
foreach ( const QgsMimeDataUtils::Uri& u, lst )
{
if ( u.layerType == "vector" )
{
Expand Down Expand Up @@ -1103,7 +1103,7 @@ void QgisApp::setFontSize( int fontSize )
{
setStyleSheet( QString( "font-size: %1pt; " ).arg( fontSize ) );

foreach( QgsComposer *c, mPrintComposers )
foreach ( QgsComposer *c, mPrintComposers )
{
c->setFontSize( fontSize );
}
Expand Down Expand Up @@ -1241,7 +1241,7 @@ void QgisApp::createToolBars()

QList<QAction*> toolbarMenuActions;
// Set action names so that they can be used in customization
foreach( QToolBar *toolBar, toolbarMenuToolBars )
foreach ( QToolBar *toolBar, toolbarMenuToolBars )
{
toolBar->toggleViewAction()->setObjectName( "mActionToggle" + toolBar->objectName().mid( 1 ) );
toolbarMenuActions << toolBar->toggleViewAction();
Expand Down Expand Up @@ -1489,12 +1489,12 @@ void QgisApp::setIconSizes( int size )

//Change all current icon sizes.
QList<QToolBar *> toolbars = findChildren<QToolBar *>();
foreach( QToolBar * toolbar, toolbars )
foreach ( QToolBar * toolbar, toolbars )
{
toolbar->setIconSize( QSize( size, size ) );
}

foreach( QgsComposer *c, mPrintComposers )
foreach ( QgsComposer *c, mPrintComposers )
{
c->setIconSizes( size );
}
Expand Down Expand Up @@ -1575,7 +1575,7 @@ void QgisApp::setTheme( QString theThemeName )
mActionAddFeature->setIcon( QgsApplication::getThemeIcon( "/mActionCapturePoint.png" ) );
mActionMoveFeature->setIcon( QgsApplication::getThemeIcon( "/mActionMoveFeature.png" ) );
mActionReshapeFeatures->setIcon( QgsApplication::getThemeIcon( "/mActionReshape.png" ) );
mActionSplitFeatures->setIcon( QgsApplication::getThemeIcon( "/mActionSplitFeatures.png" ) );
mActionSplitFeatures->setIcon( QgsApplication::getThemeIcon( "/mActionSplitFeatures.svg" ) );
mActionDeleteSelected->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteSelected.png" ) );
mActionNodeTool->setIcon( QgsApplication::getThemeIcon( "/mActionNodeTool.png" ) );
mActionSimplifyFeature->setIcon( QgsApplication::getThemeIcon( "/mActionSimplify.png" ) );
Expand All @@ -1597,6 +1597,7 @@ void QgisApp::setTheme( QString theThemeName )
mActionTouch->setIcon( QgsApplication::getThemeIcon( "/mActionTouch.png" ) );
#endif
mActionPan->setIcon( QgsApplication::getThemeIcon( "/mActionPan.png" ) );
mActionPanToSelected->setIcon( QgsApplication::getThemeIcon( "/mActionPanToSelected.svg" ) );
mActionZoomLast->setIcon( QgsApplication::getThemeIcon( "/mActionZoomLast.png" ) );
mActionZoomNext->setIcon( QgsApplication::getThemeIcon( "/mActionZoomNext.png" ) );
mActionZoomToLayer->setIcon( QgsApplication::getThemeIcon( "/mActionZoomToLayer.png" ) );
Expand All @@ -1605,7 +1606,7 @@ void QgisApp::setTheme( QString theThemeName )
mActionFeatureAction->setIcon( QgsApplication::getThemeIcon( "/mAction.png" ) );
mActionSelect->setIcon( QgsApplication::getThemeIcon( "/mActionSelect.png" ) );
mActionSelectRectangle->setIcon( QgsApplication::getThemeIcon( "/mActionSelectRectangle.png" ) );
mActionSelectPolygon->setIcon( QgsApplication::getThemeIcon( "/mActionSelectPolygon.png" ) );
mActionSelectPolygon->setIcon( QgsApplication::getThemeIcon( "/mActionSelectPolygon.svg" ) );
mActionSelectFreehand->setIcon( QgsApplication::getThemeIcon( "/mActionSelectFreehand.png" ) );
mActionSelectRadius->setIcon( QgsApplication::getThemeIcon( "/mActionSelectRadius.png" ) );
mActionDeselectAll->setIcon( QgsApplication::getThemeIcon( "/mActionDeselectAll.png" ) );
Expand All @@ -1628,7 +1629,7 @@ void QgisApp::setTheme( QString theThemeName )
mActionShowFrozenLabels->setIcon( QgsApplication::getThemeIcon( "/mActionShowFrozenLabels.png" ) );
mActionFreezeLabels->setIcon( QgsApplication::getThemeIcon( "/mActionFreezeLabels.png" ) );
mActionMoveLabel->setIcon( QgsApplication::getThemeIcon( "/mActionMoveLabel.png" ) );
mActionRotateLabel->setIcon( QgsApplication::getThemeIcon( "/mActionRotateLabel.png" ) );
mActionRotateLabel->setIcon( QgsApplication::getThemeIcon( "/mActionRotateLabel.svg" ) );
mActionChangeLabelProperties->setIcon( QgsApplication::getThemeIcon( "/mActionChangeLabelProperties.png" ) );
mActionDecorationCopyright->setIcon( QgsApplication::getThemeIcon( "/plugins/copyright_label.png" ) );
mActionDecorationNorthArrow->setIcon( QgsApplication::getThemeIcon( "/plugins/north_arrow.png" ) );
Expand Down Expand Up @@ -2064,15 +2065,15 @@ void QgisApp::createDecorations()

void QgisApp::renderDecorationItems( QPainter *p )
{
foreach( QgsDecorationItem* item, mDecorationItems )
foreach ( QgsDecorationItem* item, mDecorationItems )
{
item->render( p );
}
}

void QgisApp::projectReadDecorationItems()
{
foreach( QgsDecorationItem* item, mDecorationItems )
foreach ( QgsDecorationItem* item, mDecorationItems )
{
item->projectRead( );
}
Expand Down Expand Up @@ -2149,7 +2150,7 @@ void QgisApp::updateProjectFromTemplates()
mProjectFromTemplateMenu->clear();

// Add entries
foreach( QString templateFile, templateFiles )
foreach ( QString templateFile, templateFiles )
{
mProjectFromTemplateMenu->addAction( templateFile );
}
Expand Down Expand Up @@ -2305,7 +2306,7 @@ void QgisApp::addVectorLayer()
bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QString& enc, const QString dataSourceType )
{
QList<QgsMapLayer *> myList;
foreach( QString src, theLayerQStringList )
foreach ( QString src, theLayerQStringList )
{
src = src.trimmed();
QString base;
Expand Down Expand Up @@ -2487,15 +2488,15 @@ bool QgisApp::askUserForZipItemLayers( QString path )

if ( chooseSublayersDialog.exec() )
{
foreach( int i, chooseSublayersDialog.getSelectionIndexes() )
foreach ( int i, chooseSublayersDialog.getSelectionIndexes() )
{
childItems << zipItem->children()[i];
}
}
}

// add childItems
foreach( QgsDataItem* item, childItems )
foreach ( QgsDataItem* item, childItems )
{
QgsLayerItem *layerItem = dynamic_cast<QgsLayerItem *>( item );
QgsDebugMsg( QString( "item path=%1 provider=" ).arg( item->path() ).arg( layerItem->providerKey() ) );
Expand Down Expand Up @@ -2572,7 +2573,7 @@ void QgisApp::askUserForGDALSublayers( QgsRasterLayer *layer )

if ( chooseSublayersDialog.exec() )
{
foreach( int i, chooseSublayersDialog.getSelectionIndexes() )
foreach ( int i, chooseSublayersDialog.getSelectionIndexes() )
{
QgsRasterLayer *rlayer = new QgsRasterLayer( sublayers[i], names[i] );
if ( rlayer && rlayer->isValid() )
Expand Down Expand Up @@ -2735,7 +2736,7 @@ void QgisApp::addDatabaseLayers( QStringList const & layerPathList, QString cons

QApplication::setOverrideCursor( Qt::WaitCursor );

foreach( QString layerPath, layerPathList )
foreach ( QString layerPath, layerPathList )
{
// create the layer
QgsDataSourceURI uri( layerPath );
Expand Down Expand Up @@ -4396,7 +4397,7 @@ void QgisApp::mergeAttributesOfSelectedFeatures()

const QgsAttributeMap &merged = d.mergedAttributesMap();

foreach( QgsFeatureId fid, vl->selectedFeaturesIds() )
foreach ( QgsFeatureId fid, vl->selectedFeaturesIds() )
{
for ( QgsAttributeMap::const_iterator it = merged.begin(); it != merged.end(); it++ )
{
Expand Down Expand Up @@ -4712,7 +4713,7 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
const QgsAttributeMap &srcMap = f.attributeMap();
QgsAttributeMap dstMap;

foreach( int src, srcMap.keys() )
foreach ( int src, srcMap.keys() )
{
int dst = remap.value( src, -1 );
if ( dst < 0 )
Expand Down Expand Up @@ -4848,7 +4849,7 @@ void QgisApp::saveEdits()
if ( mMapCanvas && mMapCanvas->isDrawing() )
return;

foreach( QgsMapLayer * layer, mMapLegend->selectedLayers() )
foreach ( QgsMapLayer * layer, mMapLegend->selectedLayers() )
{
saveEdits( layer );
}
Expand Down Expand Up @@ -5024,14 +5025,22 @@ void QgisApp::showMouseCoordinate( const QgsPoint & p )
}
else
{
if ( mMapCanvas->mapUnits() == QGis::DegreesMinutesSeconds )
if ( mMapCanvas->mapUnits() == QGis::Degrees )
{
mCoordsEdit->setText( p.toDegreesMinutesSeconds( mMousePrecisionDecimalPlaces ) );
QString format = QgsProject::instance()->readEntry( "PositionPrecision", "/DegreeFormat", "D" );

if ( format == "DM" )
mCoordsEdit->setText( p.toDegreesMinutes( mMousePrecisionDecimalPlaces ) );
else if ( format == "DMS" )
mCoordsEdit->setText( p.toDegreesMinutesSeconds( mMousePrecisionDecimalPlaces ) );
else
mCoordsEdit->setText( p.toString( mMousePrecisionDecimalPlaces ) );
}
else
{
mCoordsEdit->setText( p.toString( mMousePrecisionDecimalPlaces ) );
}

if ( mCoordsEdit->width() > mCoordsEdit->minimumWidth() )
{
mCoordsEdit->setMinimumWidth( mCoordsEdit->width() );
Expand Down Expand Up @@ -5122,7 +5131,7 @@ void QgisApp::isInOverview()

void QgisApp::removingLayers( QStringList theLayers )
{
foreach( const QString &layerId, theLayers )
foreach ( const QString &layerId, theLayers )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer*>(
QgsMapLayerRegistry::instance()->mapLayer( layerId ) );
Expand Down Expand Up @@ -5150,7 +5159,7 @@ void QgisApp::removeLayer()
return;
}

foreach( QgsMapLayer * layer, mMapLegend->selectedLayers() )
foreach ( QgsMapLayer * layer, mMapLegend->selectedLayers() )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer*>( layer );
if ( vlayer && vlayer->isEditable() && !toggleEditing( vlayer, true ) )
Expand Down Expand Up @@ -7614,7 +7623,7 @@ void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors
bool otherError = false;
static QSet<QSslError::SslError> ignoreErrors;

foreach( QSslError error, errors )
foreach ( QSslError error, errors )
{
QgsDebugMsg( QString( "SSL error %1: %2" ).arg( error.error() ).arg( error.errorString() ) );

Expand All @@ -7631,7 +7640,7 @@ void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors
msg,
QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Ok )
{
foreach( QSslError error, errors )
foreach ( QSslError error, errors )
{
ignoreErrors << error.error();
}
Expand Down Expand Up @@ -7780,13 +7789,13 @@ QMenu* QgisApp::createPopupMenu()
}

qSort( panels.begin(), panels.end(), cmpByText_ );
foreach( QAction* a, panels )
foreach ( QAction* a, panels )
{
menu->addAction( a );
}
menu->addSeparator();
qSort( toolbars.begin(), toolbars.end(), cmpByText_ );
foreach( QAction* a, toolbars )
foreach ( QAction* a, toolbars )
{
menu->addAction( a );
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
mpWidgets << myWidget;
}

foreach( QLineEdit *le, mDialog->findChildren<QLineEdit*>() )
foreach ( QLineEdit *le, mDialog->findChildren<QLineEdit*>() )
{
if ( !le->objectName().startsWith( "expr_" ) )
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
mToggleEditingButton->setEnabled( canChangeAttributes && !mLayer->isReadOnly() );

mSaveEditsButton->setEnabled( canChangeAttributes && mLayer->isEditable() );
mOpenFieldCalculator->setEnabled( canChangeAttributes && mLayer->isEditable() );
mOpenFieldCalculator->setEnabled(( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
mDeleteSelectedButton->setEnabled( canDeleteFeatures && mLayer->isEditable() );
mAddAttribute->setEnabled( canAddAttributes && mLayer->isEditable() );
mRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );
Expand Down Expand Up @@ -674,7 +674,7 @@ void QgsAttributeTableDialog::editingToggled()
bool canAddAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes;
bool canDeleteAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteAttributes;
bool canAddFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddFeatures;
mOpenFieldCalculator->setEnabled( canChangeAttributes && mLayer->isEditable() );
mOpenFieldCalculator->setEnabled(( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
mDeleteSelectedButton->setEnabled( canDeleteFeatures && mLayer->isEditable() );
mAddAttribute->setEnabled( canAddAttributes && mLayer->isEditable() );
mRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsattributetypedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl )
connect( tableWidget, SIGNAL( cellChanged( int, int ) ), this, SLOT( vCellChanged( int, int ) ) );

valueRelationLayer->clear();
foreach( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
foreach ( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
{
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( l );
if ( vl )
Expand Down Expand Up @@ -631,7 +631,7 @@ void QgsAttributeTypeDialog::updateLayerColumns( int idx )
if ( !vl )
return;

foreach( const QgsField &f, vl->pendingFields() )
foreach ( const QgsField &f, vl->pendingFields() )
{
valueRelationKeyColumn->addItem( f.name() );
valueRelationValueColumn->addItem( f.name() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributetypeloaddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void QgsAttributeTypeLoadDialog::previewButtonPushed()
void QgsAttributeTypeLoadDialog::fillLayerList()
{
layerComboBox->clear();
foreach( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
foreach ( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
{
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( l );
if ( vl )
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsbookmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void QgsBookmarks::addClicked()
void QgsBookmarks::deleteClicked()
{
QList<int> rows;
foreach( const QModelIndex &idx, lstBookmarks->selectionModel()->selectedIndexes() )
foreach ( const QModelIndex &idx, lstBookmarks->selectionModel()->selectedIndexes() )
{
if ( idx.column() == 1 )
{
Expand All @@ -185,7 +185,7 @@ void QgsBookmarks::deleteClicked()
return;

int i = 0;
foreach( int row, rows )
foreach ( int row, rows )
{
lstBookmarks->model()->removeRow( row - i );
i++;
Expand Down
22 changes: 11 additions & 11 deletions src/app/qgscustomization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ bool QgsCustomizationDialog::catchOn( )

void QgsCustomization::addTreeItemActions( QTreeWidgetItem* parentItem, const QList<QAction*>& actions )
{
foreach( QAction* action, actions )
foreach ( QAction* action, actions )
{
if ( action->menu() )
{
Expand Down Expand Up @@ -498,7 +498,7 @@ void QgsCustomization::createTreeItemMenus( )
QTreeWidgetItem *topItem = new QTreeWidgetItem( data );

QMenuBar* menubar = QgisApp::instance()->menuBar();
foreach( QObject* obj, menubar->children() )
foreach ( QObject* obj, menubar->children() )
{
if ( obj->inherits( "QMenu" ) )
{
Expand All @@ -518,7 +518,7 @@ void QgsCustomization::createTreeItemToolbars( )
QTreeWidgetItem *topItem = new QTreeWidgetItem( data );

QMainWindow* mw = QgisApp::instance();
foreach( QObject* obj, mw->children() )
foreach ( QObject* obj, mw->children() )
{
if ( obj->inherits( "QToolBar" ) )
{
Expand All @@ -544,7 +544,7 @@ void QgsCustomization::createTreeItemDocks( )
QTreeWidgetItem *topItem = new QTreeWidgetItem( data );

QMainWindow* mw = QgisApp::instance();
foreach( QObject* obj, mw->children() )
foreach ( QObject* obj, mw->children() )
{
if ( obj->inherits( "QDockWidget" ) )
{
Expand All @@ -570,7 +570,7 @@ void QgsCustomization::createTreeItemStatus( )
topItem->setCheckState( 0, Qt::Checked );

QStatusBar* sb = QgisApp::instance()->statusBar();
foreach( QObject* obj, sb->children() )
foreach ( QObject* obj, sb->children() )
{
if ( obj->inherits( "QWidget" ) && !obj->objectName().isEmpty() )
{
Expand Down Expand Up @@ -628,7 +628,7 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu )

// hide menus and menu actions

foreach( QObject* obj, menubar->children() )
foreach ( QObject* obj, menubar->children() )
{
if ( obj->inherits( "QMenu" ) )
{
Expand All @@ -650,7 +650,7 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu )
// remove toolbars, toolbar actions

mSettings.beginGroup( "Customization/Toolbars" );
foreach( QObject* obj, mw->children() )
foreach ( QObject* obj, mw->children() )
{
if ( obj->inherits( "QToolBar" ) )
{
Expand All @@ -666,7 +666,7 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu )
{
mSettings.beginGroup( tb->objectName() );
// hide individual toolbar actions
foreach( QAction* action, tb->actions() )
foreach ( QAction* action, tb->actions() )
{
if ( action->objectName().isEmpty() )
{
Expand All @@ -686,7 +686,7 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu )
// remove dock widgets

mSettings.beginGroup( "Customization/Docks" );
foreach( QObject* obj, mw->children() )
foreach ( QObject* obj, mw->children() )
{
if ( obj->inherits( "QDockWidget" ) )
{
Expand All @@ -707,7 +707,7 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu )
mSettings.beginGroup( "Customization/StatusBar" );

QStatusBar* sb = mw->statusBar();
foreach( QObject* obj, sb->children() )
foreach ( QObject* obj, sb->children() )
{
if ( obj->inherits( "QWidget" ) )
{
Expand Down Expand Up @@ -737,7 +737,7 @@ void QgsCustomization::updateMenu( QMenu* menu, QSettings& settings )
{
settings.beginGroup( menu->objectName() );
// hide individual menu actions and call recursively on visible submenus
foreach( QAction* action, menu->actions() )
foreach ( QAction* action, menu->actions() )
{
QString objName = ( action->menu() ? action->menu()->objectName() : action->objectName() );
if ( objName.isEmpty() )
Expand Down
56 changes: 37 additions & 19 deletions src/app/qgsfieldcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,42 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl )
mOutputFieldWidthSpinBox->setValue( 10 );
mOutputFieldPrecisionSpinBox->setValue( 3 );

// disable creation of new fields if not supported by data provider
if ( !( vl->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes ) )
mUpdateExistingGroupBox->setEnabled( vl->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues );
mNewFieldGroupBox->setEnabled( vl->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes );

Q_ASSERT( mNewFieldGroupBox->isEnabled() || mUpdateExistingGroupBox->isEnabled() );

if ( mNewFieldGroupBox->isEnabled() )
{
mNewFieldGroupBox->setChecked( true );
}
else
{
mNewFieldGroupBox->setToolTip( tr( "Not available for layer" ) );
mUpdateExistingGroupBox->setChecked( true );
mUpdateExistingGroupBox->setCheckable( false );
mNewFieldGroupBox->setChecked( false );
mNewFieldGroupBox->setTitle( mNewFieldGroupBox->title() + tr( " (not supported by provider)" ) );
}

if ( vl->selectedFeaturesIds().size() > 0 )
if ( mUpdateExistingGroupBox->isEnabled() )
{
mOnlyUpdateSelectedCheckBox->setChecked( true );
mUpdateExistingGroupBox->setChecked( !mNewFieldGroupBox->isEnabled() );
}
else
{
mUpdateExistingGroupBox->setToolTip( tr( "Not available for layer" ) );
mNewFieldGroupBox->setChecked( true );
mNewFieldGroupBox->setCheckable( false );
}

mOnlyUpdateSelectedCheckBox->setChecked( vl->selectedFeaturesIds().size() > 0 );
}

QgsFieldCalculator::~QgsFieldCalculator()
{

}

void QgsFieldCalculator::accept()
{

QString calcString = builder->expressionText();
QgsExpression exp( calcString );

Expand All @@ -79,7 +93,7 @@ void QgsFieldCalculator::accept()
mVectorLayer->beginEditCommand( "Field calculator" );

//update existing field
if ( mUpdateExistingGroupBox->isChecked() )
if ( mUpdateExistingGroupBox->isChecked() || !mNewFieldGroupBox->isEnabled() )
{
QMap<QString, int>::const_iterator fieldIt = mFieldMap.find( mExistingFieldComboBox->currentText() );
if ( fieldIt != mFieldMap.end() )
Expand Down Expand Up @@ -128,7 +142,7 @@ void QgsFieldCalculator::accept()
bool calculationSuccess = true;
QString error;

bool onlySelected = ( mOnlyUpdateSelectedCheckBox->isChecked() );
bool onlySelected = mOnlyUpdateSelectedCheckBox->isChecked();
QgsFeatureIds selectedIds = mVectorLayer->selectedFeaturesIds();

// block layerModified signals (that would trigger table update)
Expand Down Expand Up @@ -269,18 +283,22 @@ void QgsFieldCalculator::populateFields()
void QgsFieldCalculator::setOkButtonState()
{
QPushButton* okButton = mButtonBox->button( QDialogButtonBox::Ok );
okButton->setToolTip( "" );

bool emptyFieldName = mOutputFieldNameLineEdit->text().isEmpty();
bool expressionValid = builder->isExpressionValid();

if ( emptyFieldName )
if (( mNewFieldGroupBox->isChecked() || !mUpdateExistingGroupBox->isEnabled() )
&& mOutputFieldNameLineEdit->text().isEmpty() )
{
okButton->setToolTip( tr( "Please enter a field name" ) );
okButton->setEnabled( false );
return;
}

if ( !expressionValid )
if ( !builder->isExpressionValid() )
{
okButton->setToolTip( okButton->toolTip() + tr( "\n The expression is invalid see (more info) for details" ) );
okButton->setEnabled( false );
return;
}

bool okEnabled = ( !emptyFieldName || mUpdateExistingGroupBox->isChecked() ) && expressionValid;

okButton->setEnabled( okEnabled );
okButton->setToolTip( "" );
okButton->setEnabled( true );
}
4 changes: 2 additions & 2 deletions src/app/qgshandlebadlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void QgsHandleBadLayers::selectionChanged()

mRows.clear();

foreach( QTableWidgetItem *item, mLayerList->selectedItems() )
foreach ( QTableWidgetItem *item, mLayerList->selectedItems() )
{
if ( item->column() != 0 )
continue;
Expand Down Expand Up @@ -246,7 +246,7 @@ void QgsHandleBadLayers::browseClicked()
return;
}

foreach( int i, mRows )
foreach ( int i, mRows )
{
QTableWidgetItem *fileItem = mLayerList->item( i, 3 );

Expand Down
18 changes: 15 additions & 3 deletions src/app/qgsidentifyresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <QMenuBar>
#include <QPushButton>
#include <QWebView>
#include <QDesktopServices>
#include <QMessageBox>

#include "qgslogger.h"

Expand Down Expand Up @@ -277,6 +279,8 @@ void QgsIdentifyResults::addFeature( QgsRasterLayer *layer,

QWebView *wv = new QWebView( attrItem->treeWidget() );
wv->setHtml( attributes.begin().value() );
wv->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
connect( wv, SIGNAL( linkClicked( const QUrl & ) ), this, SLOT( openUrl( const QUrl & ) ) );
attrItem->treeWidget()->setItemWidget( attrItem, 1, wv );
}
else
Expand Down Expand Up @@ -502,7 +506,7 @@ void QgsIdentifyResults::expandColumnsToFit()

void QgsIdentifyResults::clearHighlights()
{
foreach( QgsHighlight *h, mHighlights )
foreach ( QgsHighlight *h, mHighlights )
{
delete h;
}
Expand All @@ -524,7 +528,7 @@ void QgsIdentifyResults::clear()
void QgsIdentifyResults::activate()
{
#if 0
foreach( QgsRubberBand *rb, mRubberBands )
foreach ( QgsRubberBand *rb, mRubberBands )
{
rb->show();
}
Expand All @@ -540,7 +544,7 @@ void QgsIdentifyResults::activate()
void QgsIdentifyResults::deactivate()
{
#if 0
foreach( QgsRubberBand *rb, mRubberBands )
foreach ( QgsRubberBand *rb, mRubberBands )
{
rb->hide();
}
Expand Down Expand Up @@ -980,3 +984,11 @@ void QgsIdentifyResults::copyFeatureAttributes()
QgsDebugMsg( QString( "set clipboard: %1" ).arg( text ) );
clipboard->setText( text );
}

void QgsIdentifyResults::openUrl( const QUrl &url )
{
if ( !QDesktopServices::openUrl( url ) )
{
QMessageBox::warning( this, tr( "Could not open url" ), tr( "Could not open URL '%1'" ).arg( url.toString() ) );
}
}
2 changes: 2 additions & 0 deletions src/app/qgsidentifyresults.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

void openUrl( const QUrl &url );

private:
QMenu *mActionPopup;
QMap<QTreeWidgetItem *, QgsHighlight * > mHighlights;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void QgsMapToolCapture::canvasMoveEvent( QMouseEvent * e )
while ( !mSnappingMarkers.isEmpty() )
delete mSnappingMarkers.takeFirst();

foreach( const QgsSnappingResult &r, snapResults )
foreach ( const QgsSnappingResult &r, snapResults )
{
QgsVertexMarker *m = new QgsVertexMarker( mCanvas );
m->setIconType( QgsVertexMarker::ICON_CROSS );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolfeatureaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bool QgsMapToolFeatureAction::doAction( QgsVectorLayer *layer, int x, int y )
if ( featList.size() == 0 )
return false;

foreach( QgsFeature feat, featList )
foreach ( QgsFeature feat, featList )
{
int actionIdx = layer->actions()->defaultAction();

Expand Down
21 changes: 14 additions & 7 deletions src/app/qgsmaptoolfreezelabels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void QgsMapToolFreezeLabels::highlightFrozenLabels()
void QgsMapToolFreezeLabels::removeFrozenHighlights()
{
QApplication::setOverrideCursor( Qt::BusyCursor );
foreach( QgsHighlight *h, mHighlights )
foreach ( QgsHighlight *h, mHighlights )
{
delete h;
}
Expand All @@ -257,8 +257,8 @@ void QgsMapToolFreezeLabels::freezeThawLabels( const QgsRectangle& ext, QMouseEv
{

bool doThaw = e->modifiers() & Qt::ShiftModifier ? true : false;
bool toggleThawOrFreeze = e->modifiers() & Qt::AltModifier ? true : false;
bool doHide = e->modifiers() & Qt::ControlModifier ? true : false;
bool toggleThawOrFreeze = e->modifiers() & Qt::ControlModifier ? true : false;
bool doHide = ( doThaw && toggleThawOrFreeze );

// get list of all drawn labels from all layers within, or touching, chosen extent
bool labelChanged = false;
Expand Down Expand Up @@ -432,16 +432,23 @@ bool QgsMapToolFreezeLabels::freezeThawLabel( QgsVectorLayer* vlayer,
if ( freeze )
{

QgsPoint labelpoint = labelpos.cornerPoints.at( 0 );
// QgsPoint labelpoint = labelpos.cornerPoints.at( 0 );

double labelX = labelpoint.x();
double labelY = labelpoint.y();
QgsPoint referencePoint;
if ( !rotationPoint( referencePoint, true ) )
{
referencePoint.setX( mCurrentLabelPos.labelRect.xMinimum() );
referencePoint.setY( mCurrentLabelPos.labelRect.yMinimum() );
}

double labelX = referencePoint.x();
double labelY = referencePoint.y();
double labelR = labelpos.rotation * 180 / M_PI;

// transform back to layer crs, if on-fly on
if ( mRender->hasCrsTransformEnabled() )
{
QgsPoint transformedPoint = mRender->mapToLayerCoordinates( vlayer, labelpoint );
QgsPoint transformedPoint = mRender->mapToLayerCoordinates( vlayer, referencePoint );
labelX = transformedPoint.x();
labelY = transformedPoint.y();
}
Expand Down
77 changes: 71 additions & 6 deletions src/app/qgsmaptoollabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,14 @@ QFont QgsMapToolLabel::labelFontCurrentFeature()
QMap< QgsPalLayerSettings::DataDefinedProperties, int >::const_iterator sizeIt = ddProperties.find( QgsPalLayerSettings::Size );
if ( sizeIt != ddProperties.constEnd() )
{
font.setPointSizeF( attributes[*sizeIt].toDouble() );
if ( layerSettings.fontSizeInMapUnits )
{
font.setPixelSize( layerSettings.sizeToPixel( attributes[*sizeIt].toDouble(), QgsRenderContext() ) );
}
else
{
font.setPointSizeF( attributes[*sizeIt].toDouble() );
}
}

//family
Expand Down Expand Up @@ -273,15 +280,15 @@ QFont QgsMapToolLabel::labelFontCurrentFeature()
return font;
}

bool QgsMapToolLabel::rotationPoint( QgsPoint& pos )
bool QgsMapToolLabel::rotationPoint( QgsPoint& pos, bool ignoreUpsideDown )
{
QVector<QgsPoint> cornerPoints = mCurrentLabelPos.cornerPoints;
if ( cornerPoints.size() < 4 )
{
return false;
}

if ( mCurrentLabelPos.upsideDown )
if ( mCurrentLabelPos.upsideDown && !ignoreUpsideDown )
{
pos = mCurrentLabelPos.cornerPoints.at( 2 );
}
Expand Down Expand Up @@ -336,7 +343,7 @@ bool QgsMapToolLabel::rotationPoint( QgsPoint& pos )
}
else
{
double descentRatio = labelFontMetrics.descent() / labelFontMetrics.height();
double descentRatio = 1 / labelFontMetrics.ascent() / labelFontMetrics.height();
if ( valiString.compare( "Base", Qt::CaseInsensitive ) == 0 )
{
ydiff = labelSizeY * descentRatio;
Expand All @@ -351,7 +358,7 @@ bool QgsMapToolLabel::rotationPoint( QgsPoint& pos )
double angle = mCurrentLabelPos.rotation;
double xd = xdiff * cos( angle ) - ydiff * sin( angle );
double yd = xdiff * sin( angle ) + ydiff * cos( angle );
if ( mCurrentLabelPos.upsideDown )
if ( mCurrentLabelPos.upsideDown && !ignoreUpsideDown )
{
pos.setX( pos.x() - xd );
pos.setY( pos.y() - yd );
Expand Down Expand Up @@ -399,7 +406,65 @@ bool QgsMapToolLabel::dataDefinedPosition( QgsVectorLayer* vlayer, int featureId
return true;
}

bool QgsMapToolLabel:: diagramMoveable( const QgsMapLayer* ml, int& xCol, int& yCol ) const
bool QgsMapToolLabel::layerIsRotatable( const QgsMapLayer* layer, int& rotationCol ) const
{
const QgsVectorLayer* vlayer = dynamic_cast<const QgsVectorLayer*>( layer );
if ( !vlayer || !vlayer->isEditable() )
{
return false;
}

QVariant rotation = layer->customProperty( "labeling/dataDefinedProperty14" );
if ( !rotation.isValid() )
{
return false;
}

bool rotationOk;
rotationCol = rotation.toInt( &rotationOk );
if ( !rotationOk )
{
return false;
}
return true;
}

bool QgsMapToolLabel::dataDefinedRotation( QgsVectorLayer* vlayer, int featureId, double& rotation, bool& rotationSuccess )
{
rotationSuccess = false;
if ( !vlayer )
{
return false;
}

int rotationCol;
if ( !layerIsRotatable( vlayer, rotationCol ) )
{
return false;
}

QgsFeature f;
if ( !vlayer->featureAtId( featureId, f, false, true ) )
{
return false;
}

QgsAttributeMap attributes = f.attributeMap();

//test, if data defined x- and y- values are not null. Otherwise, the position is determined by PAL and the rotation cannot be fixed
int xCol, yCol;
double x, y;
bool xSuccess, ySuccess;
if ( !dataDefinedPosition( vlayer, featureId, x, xSuccess, y, ySuccess, xCol, yCol ) || !xSuccess || !ySuccess )
{
return false;
}

rotation = attributes[rotationCol].toDouble( &rotationSuccess );
return true;
}

bool QgsMapToolLabel::diagramMoveable( const QgsMapLayer* ml, int& xCol, int& yCol ) const
{
const QgsVectorLayer* vlayer = dynamic_cast<const QgsVectorLayer*>( ml );
if ( vlayer && vlayer->diagramRenderer() )
Expand Down
18 changes: 16 additions & 2 deletions src/app/qgsmaptoollabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class QgsMapToolLabel: public QgsMapTool
@param yCol out: index of the attribute for data defined y coordinate
@return true if layer fields set up and exist*/
bool layerCanFreeze( const QgsMapLayer* ml, int& xCol, int& yCol ) const;
/**Checks if labels in a layer can be rotated
@param rotationCol out: attribute column for data defined label rotation*/
bool layerIsRotatable( const QgsMapLayer* layer, int& rotationCol ) const;

protected:
QgsRubberBand* mLabelRubberBand;
Expand All @@ -63,8 +66,9 @@ class QgsMapToolLabel: public QgsMapTool
bool labelAtPosition( QMouseEvent* e, QgsLabelPosition& p );

/**Finds out rotation point of current label position
@param ignoreUpsideDown treat label as right-side-up
@return true in case of success*/
bool rotationPoint( QgsPoint& pos );
bool rotationPoint( QgsPoint& pos, bool ignoreUpsideDown = false );

/**Creates label / feature / fixpoint rubber bands for the current label position*/
void createRubberBands();
Expand All @@ -90,7 +94,8 @@ class QgsMapToolLabel: public QgsMapTool
QFont labelFontCurrentFeature();

/**Get data defined position of a feature
@param layerId layer identification string
@param vlayer vector layer
@param featureId feature identification integer
@param x out: data defined x-coordinate
@param xSuccess out: false if attribute value is NULL
@param y out: data defined y-coordinate
Expand All @@ -100,6 +105,15 @@ class QgsMapToolLabel: public QgsMapTool
@return false if layer does not have data defined label position enabled*/
bool dataDefinedPosition( QgsVectorLayer* vlayer, int featureId, double& x, bool& xSuccess, double& y, bool& ySuccess, int& xCol, int& yCol ) const;

/**Returns data defined rotation of a feature.
@param vlayer vector layer
@param featureId feature identification integer
@param rotation out: rotation value
@param rotationSuccess out: false if rotation value is NULL
@return true if data defined rotation is enabled on the layer
*/
bool dataDefinedRotation( QgsVectorLayer* vlayer, int featureId, double& rotation, bool& rotationSuccess );

private:
QgsPalLayerSettings mInvalidLabelSettings;
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolmovefeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void QgsMapToolMoveFeature::canvasReleaseEvent( QMouseEvent * e )
double dx = stopPointLayerCoords.x() - startPointLayerCoords.x();
double dy = stopPointLayerCoords.y() - startPointLayerCoords.y();
vlayer->beginEditCommand( tr( "Feature moved" ) );
foreach( QgsFeatureId id, mMovedFeatures )
foreach ( QgsFeatureId id, mMovedFeatures )
{
vlayer->translateFeature( id, dx, dy );
}
Expand Down
22 changes: 21 additions & 1 deletion src/app/qgsmaptoolmovelabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void QgsMapToolMoveLabel::canvasPressEvent( QMouseEvent * e )
{
mStartPointMapCoords = toMapCoordinates( e->pos() );
QgsPoint referencePoint;
if ( !rotationPoint( referencePoint ) )
if ( !rotationPoint( referencePoint, true ) )
{
referencePoint.setX( mCurrentLabelPos.labelRect.xMinimum() );
referencePoint.setY( mCurrentLabelPos.labelRect.yMinimum() );
Expand Down Expand Up @@ -152,6 +152,26 @@ void QgsMapToolMoveLabel::canvasReleaseEvent( QMouseEvent * e )
vlayer->beginEditCommand( tr( "Label moved" ) );
vlayer->changeAttributeValue( mCurrentLabelPos.featureId, xCol, xPosNew, false );
vlayer->changeAttributeValue( mCurrentLabelPos.featureId, yCol, yPosNew, false );

// set rotation to that of label, if data-defined and no rotation set yet
// handle case of initially set rotation column fields of 0 instead of NULL
// must come after setting x and y positions
int rCol;
if ( !mCurrentLabelPos.isDiagram && !mCurrentLabelPos.isFrozen
&& layerIsRotatable( vlayer, rCol ) )
{
double labelRot = 0;
double defRot;
bool rSuccess;
if ( dataDefinedRotation( vlayer, mCurrentLabelPos.featureId, defRot, rSuccess ) )
{
labelRot = mCurrentLabelPos.rotation * 180 / M_PI;
if ( !rSuccess || ( rSuccess && defRot != labelRot ) )
{
vlayer->changeAttributeValue( mCurrentLabelPos.featureId, rCol, labelRot, false );
}
}
}
vlayer->endEditCommand();

mCanvas->refresh();
Expand Down
Loading