diff --git a/.tx/config b/.tx/config index e7dd5b303fa..4bfd8d6858f 100644 --- a/.tx/config +++ b/.tx/config @@ -13,6 +13,7 @@ trans.cs = i18n/qgis_cs.ts trans.da = i18n/qgis_da.ts trans.de = i18n/qgis_de.ts trans.el = i18n/qgis_el.ts +trans.eo = i18n/qgis_eo.ts trans.es = i18n/qgis_es.ts trans.et = i18n/qgis_et.ts trans.eu = i18n/qgis_eu.ts diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ab1d46d358..3899cb3dc41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -564,32 +564,15 @@ IF(COMMAND cmake_policy) ENDIF(COMMAND cmake_policy) IF (WIN32) - SET(DLLIMPORT "__declspec(dllimport)") - SET(DLLEXPORT "__declspec(dllexport)") -ELSE (WIN32) - IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - SET(DLLEXPORT "__attribute__ ((visibility (\\\"default\\\")))") - ELSE() - SET(DLLEXPORT "") - ENDIF() - IF(PEDANTIC AND NOT APPLE) SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined") ENDIF(PEDANTIC AND NOT APPLE) - ENDIF(WIN32) -ADD_DEFINITIONS("-DCORE_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("-DGUI_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("-DPYTHON_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("-DANALYSIS_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("-DAPP_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("-DCUSTOMWIDGETS_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("-DSERVER_EXPORT=${DLLIMPORT}") - SET(CMAKE_CXX_VISIBILITY_PRESET hidden) +INCLUDE(GenerateExportHeader) ############################################################# # user-changeable settings which can be used to customize diff --git a/INSTALL b/INSTALL index 2cf22094dfa..8ec81eb5c6f 100644 --- a/INSTALL +++ b/INSTALL @@ -1,10 +1,10 @@ QGIS Building QGIS from source - step by step -Monday November 07, 2016 +Monday January 09, 2017 -Last Updated: Monday November 07, 2016 -Last Change : Monday November 07, 2016 +Last Updated: Monday January 09, 2017 +Last Change : Monday January 09, 2017 1. Introduction @@ -87,7 +87,7 @@ source directory. 2. Overview =========== -QGIS, like a number of major projects (eg. KDE 4.0), uses CMake +QGIS, like a number of major projects (e.g., KDE 4.0), uses CMake (http://www.cmake.org) for building from source. Following a summary of the required dependencies for building: @@ -100,14 +100,17 @@ Required build tools: Required build dependencies: -- Qt >= 4.8.0 +- Qt >= 5.3.0 - Proj >= 4.4.x - GEOS >= 3.4 - Sqlite3 >= 3.0.0 -- GDAL/OGR >= 1.4.x +- SpatiaLite +- libspatialindex +- GDAL/OGR >= 2.0 - Qwt >= 5.0 & (< 6.1 with internal QwtPolar) - expat >= 1.95 - QScintilla2 +- QCA Optional dependencies: @@ -118,14 +121,14 @@ Optional dependencies: - for georeferencer - GSL >= 1.8 - for postgis support and SPIT plugin - PostgreSQL >= 8.0.x - for gps plugin - gpsbabel -- for mapserver export and PyQGIS - Python >= 2.3 (2.5+ preferred) -- for python support - SIP >= 4.12, PyQt >= 4.8.3 must match Qt version, Qscintilla2 +- for mapserver export and PyQGIS - Python >= 3.3 +- for python support - SIP >= 4.12, PyQt >= 5.3 must match Qt version, Qscintilla2 - for qgis mapserver - FastCGI - for oracle provider - Oracle OCI library Indirect dependencies: -Some proprietary formats (eg. ECW and MrSid) supported by GDAL require +Some proprietary formats (e.g., ECW and MrSid) supported by GDAL require proprietary third party libraries. QGIS doesn't need any of those itself to build, but will only support those formats if GDAL is built accordingly. Refer to http://gdal.org/formats_list.html ff. for instructions how to include @@ -262,27 +265,55 @@ interactive dialog. Now on with the build: - make - make install + make -jX -It may take a little while to build depending on your platform. +where X is the number of available cores. Depending on your platform, +this can speed up the build time considerably. + +Then you can directly run from the build directory: + + ./output/bin/qgis + +Another option is to install to your system: + + make install After that you can try to run QGIS: $HOME/apps/bin/qgis If all has worked properly the QGIS application should start up and appear -on your screen. If you get the error message "error while loading shared libraries", +on your screen. If you get the error message "error while loading shared libraries", execute this command in your shell. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HOME}/apps/lib/ +Optionally, if you already know what aspects you want in your custom build +then you can skip the interactive ccmake .. part by using the cmake -D +option for each aspect, e.g.: + + cmake -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX=${HOME}/apps .. + +Also, if you want to speed your build times, you can easily do it with ninja, +an alternative to make with similar build options. + +For example, to configure your build you can do either one of: + + ccmake -G Ninja .. + + cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX=${HOME}/apps .. + +Build and install with ninja: + + ninja (uses all cores by default; also supports the above described -jX option) + ninja install + 3.8. Building Debian packages ============================= Instead of creating a personal installation as in the previous step you can -also create debian package. This is done from the QGIS root directory, where +also create debian package. This is done from the QGIS root directory, where you'll find a debian directory. First you need to install the debian packaging tools once: diff --git a/NEWS b/NEWS index 756fcec52af..70118c47c1a 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ QGIS News Change history for the QGIS Project -Monday November 07, 2016 +Monday January 09, 2017 ------------------------------------------------------------------------ @@ -39,12 +39,12 @@ Monday November 07, 2016 ------------------------------------------------------------------------ -Last Updated: Monday November 07, 2016 -Last Change : Wednesday July 27, 2016 +Last Updated: Monday January 09, 2017 +Last Change : Sunday January 01, 2017 1. What's new in Version 2.16 'Nødebo'? - ======================================== + ======================================= This release has following new features: @@ -814,7 +814,7 @@ changed so we will just provide a bullet list of key new features here. - Optionally re-use entered attribute values for next digitized feature. - Allow merging/assigning attribute values to a set of features.- - - Allow OGR 'save as' without attributes (for eg. DGN/DXF). + - Allow OGR 'save as' without attributes (e.g., DGN/DXF). 14.7. Api and Developer Centric @@ -908,7 +908,7 @@ as' option, you can now specify OGR creation options. 15.3. Labeling (New generation only) - ===================================== + ==================================== - Data defined label position in labeling-ng. - Line wrapping, data defined font and buffer settings for labeling-ng. @@ -1055,7 +1055,7 @@ we recommend that you use a copy of QGIS from our Long Term Support (LTS)1.0.x release series. In all other cases we recommend that you use this version. This release includes around 200 bug fixes, nearly 30 new features and has had -a lot of love and attention poured in to it to take our favourite desktop GIS +a lot of love and attention poured in to it to take our favorite desktop GIS application another step on the road to GIS nirvana! So much has happened in the 3 months since our last release that it is impossible to document everything here. Instead we will just highlight a couple of important new diff --git a/ci/travis/linux/after_script.sh b/ci/travis/linux/after_script.sh index a3a0dabdfe3..d636b486556 100755 --- a/ci/travis/linux/after_script.sh +++ b/ci/travis/linux/after_script.sh @@ -13,4 +13,6 @@ # # ########################################################################### +ccache -s + [ -r /tmp/ctest-important.log ] && cat /tmp/ctest-important.log diff --git a/ci/travis/linux/install.sh b/ci/travis/linux/install.sh index 344607830e7..48a0b377580 100755 --- a/ci/travis/linux/install.sh +++ b/ci/travis/linux/install.sh @@ -20,6 +20,7 @@ ln -s ${HOME}/osgeo4travis/bin/ccache ${HOME}/osgeo4travis/bin/clang++-${LLVM_VE ln -s ${HOME}/osgeo4travis/bin/ccache ${HOME}/osgeo4travis/bin/clang-${LLVM_VERSION} ccache -s +ccache -z export CXX="clang++-${LLVM_VERSION}" export CC="clang-${LLVM_VERSION}" @@ -38,21 +39,39 @@ CLANG_WARNINGS="" # Include this line for debug reasons # -DCMAKE_BUILD_TYPE=RelWithDebInfo \ # -cmake \ - -DCMAKE_PREFIX_PATH=/home/travis/osgeo4travis \ - -DWITH_STAGED_PLUGINS=ON \ - -DWITH_GRASS=ON \ - -DWITH_GRASS7=ON \ - -DGRASS_PREFIX7=/home/travis/osgeo4travis/grass-7.0.4 \ - -DSUPPRESS_QT_WARNINGS=ON \ - -DENABLE_MODELTEST=ON \ - -DENABLE_PGTEST=ON \ - -DWITH_QSPATIALITE=ON \ - -DWITH_QWTPOLAR=OFF \ - -DWITH_APIDOC=ON \ - -DWITH_ASTYLE=ON \ - -DWITH_SERVER=ON \ - -DWITH_INTERNAL_YAML=OFF \ - -DDISABLE_DEPRECATED=ON \ - -DCXX_EXTRA_FLAGS="$CLANG_WARNINGS" \ - .. +CMAKE_FLAGS=" + -DCMAKE_PREFIX_PATH=/home/travis/osgeo4travis + -DWITH_STAGED_PLUGINS=ON + -DWITH_GRASS=ON + -DWITH_GRASS7=ON + -DGRASS_PREFIX7=/home/travis/osgeo4travis/grass-7.0.4 + -DSUPPRESS_QT_WARNINGS=ON + -DENABLE_MODELTEST=ON + -DENABLE_PGTEST=ON + -DWITH_QSPATIALITE=ON + -DWITH_QWTPOLAR=OFF + -DWITH_APIDOC=ON + -DWITH_ASTYLE=ON + -DWITH_INTERNAL_YAML=OFF + -DDISABLE_DEPRECATED=ON + -DCXX_EXTRA_FLAGS=${CLANG_WARNINGS} + " + +# The following options trigger a minimalized build to +# reduce the travis build time so we don't time out and +# have a chance of slowly filling the ccache. +if [ "$CACHE_WARMING" = true ] ; then + CMAKE_FLAGS=" + ${CMAKE_FLAGS} + -DWITH_DESKTOP=OFF + -DWITH_SERVER=OFF + " +else + CMAKE_FLAGS=" + ${CMAKE_FLAGS} + -DWITH_DESKTOP=ON + -DWITH_SERVER=ON + " +fi + +cmake $CMAKE_FLAGS .. diff --git a/ci/travis/linux/script.sh b/ci/travis/linux/script.sh index 977e70b84f3..95a6836ff34 100755 --- a/ci/travis/linux/script.sh +++ b/ci/travis/linux/script.sh @@ -18,6 +18,7 @@ export PATH=${HOME}/osgeo4travis/bin:${HOME}/osgeo4travis/sbin:${HOME}/OTB-5.6.0 export LD_LIBRARY_PATH=${HOME}/osgeo4travis/lib export CTEST_PARALLEL_LEVEL=1 export CCACHE_TEMPDIR=/tmp +ccache -M 2G DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -25,5 +26,11 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export OTB_APPLICATION_PATH=${HOME}/OTB-5.6.0-Linux64/lib/otb/applications export LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so -xvfb-run ctest -V -E "qgis_filedownloader|qgis_openstreetmaptest|qgis_wcsprovidertest|PyQgsWFSProviderGUI|qgis_ziplayertest|$(cat ${DIR}/blacklist.txt | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure # xvfb-run ctest -V -E "qgis_openstreetmaptest|qgis_wcsprovidertest" -S ./qgis-test-travis.ctest --output-on-failure +if [ "$CACHE_WARMING" = true ] ; then + echo "WARNING: CACHE WARMING IS ACTIVE. SET CACHE_WARMING=false TO GET MEANINGFUL RESULTS." + xvfb-run ctest -V -R NOTESTS -S ./qgis-test-travis.ctest --output-on-failure + false +else + xvfb-run ctest -V -E "qgis_filedownloader|qgis_openstreetmaptest|qgis_wcsprovidertest|PyQgsWFSProviderGUI|qgis_ziplayertest|$(cat ${DIR}/blacklist.txt | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure +fi diff --git a/cmake/FindGDAL.cmake b/cmake/FindGDAL.cmake index 617cdf9f843..b4b90e4e1a9 100644 --- a/cmake/FindGDAL.cmake +++ b/cmake/FindGDAL.cmake @@ -61,13 +61,9 @@ ELSE(WIN32) ENDIF (NOT GDAL_VERSION) STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" GDAL_VERSION_MAJOR "${GDAL_VERSION}") STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" GDAL_VERSION_MINOR "${GDAL_VERSION}") - IF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION EQUAL 1 AND GDAL_VERSION_MINOR LESS 4)) - MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 1.4.0 or higher.") - ENDIF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION EQUAL 1 AND GDAL_VERSION_MINOR LESS 4)) - - IF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 11)) - MESSAGE (WARNING "GDAL version is too old (${GDAL_VERSION}) to support GeoPackage. 1.11.0 or higher is recommended.") - ENDIF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 11)) + IF (GDAL_VERSION_MAJOR LESS 2) + MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 2.0 or higher.") + ENDIF (GDAL_VERSION_MAJOR LESS 2) ENDIF (GDAL_LIBRARY) SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE) @@ -105,14 +101,10 @@ ELSE(WIN32) # check for gdal version # version 1.2.5 is known NOT to be supported (missing CPL_STDCALL macro) - # According to INSTALL, 1.4.0+ is required - IF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 4)) - MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 1.4.0 or higher.") - ENDIF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 4)) - - IF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 11)) - MESSAGE (WARNING "GDAL version is too old (${GDAL_VERSION}) to support GeoPackage. 1.11.0 or higher is recommended.") - ENDIF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 11)) + # According to INSTALL, 2.0+ is required + IF (GDAL_VERSION_MAJOR LESS 2) + MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 2.0 or higher.") + ENDIF (GDAL_VERSION_MAJOR LESS 2) # set INCLUDE_DIR to prefix+include EXEC_PROGRAM(${GDAL_CONFIG} diff --git a/cmake/FindGRASS.cmake b/cmake/FindGRASS.cmake index d09ec59ccbf..64cfebbe27f 100644 --- a/cmake/FindGRASS.cmake +++ b/cmake/FindGRASS.cmake @@ -167,7 +167,7 @@ IF (UNIX) IF (GRASS_FIND_VERSION EQUAL 6) LIST(APPEND GRASS_PATHS /usr/lib64/grass64 /usr/lib/grass64) ELSEIF (GRASS_FIND_VERSION EQUAL 7) - LIST(APPEND GRASS_PATHS /usr/lib64/grass70 /usr/lib/grass70 /usr/lib64/grass71 /usr/lib/grass71) + LIST(APPEND GRASS_PATHS /usr/lib64/grass70 /usr/lib/grass70 /usr/lib64/grass71 /usr/lib/grass71 /usr/lib64/grass72 /usr/lib/grass72) ENDIF () ENDIF (UNIX) @@ -181,6 +181,7 @@ IF (APPLE) LIST(APPEND GRASS_PATHS /Applications/GRASS-7.0.app/Contents/MacOS /Applications/GRASS-7.1.app/Contents/MacOS + /Applications/GRASS-7.2.app/Contents/MacOS ) ENDIF () LIST(APPEND GRASS_PATHS /Applications/GRASS.app/Contents/Resources) diff --git a/cmake/QCAMacros.cmake b/cmake/QCAMacros.cmake index 5df3611e91e..486c6a869b3 100644 --- a/cmake/QCAMacros.cmake +++ b/cmake/QCAMacros.cmake @@ -92,7 +92,7 @@ function(FIND_QCATOOL TOOL_REQUIRED) $ENV{OSGEO4W_ROOT}/bin ) else() - find_program(QCATOOL_EXECUTABLE NAMES qcatool qcatool2) + find_program(QCATOOL_EXECUTABLE NAMES qcatool qcatool2 qcatool-qt5) endif() if(NOT QCATOOL_EXECUTABLE) diff --git a/cmake/Txt2Tags.cmake b/cmake/Txt2Tags.cmake index c2afedb827c..7b216f87d0e 100644 --- a/cmake/Txt2Tags.cmake +++ b/cmake/Txt2Tags.cmake @@ -42,7 +42,7 @@ MACRO(ADD_TXT2TAGS_FILES _sources) ADD_CUSTOM_COMMAND( OUTPUT ${_out} COMMAND ${TXT2TAGS_EXECUTABLE} - ARGS -o${_out} -t txt ${_in} + ARGS --encoding=utf-8 -o${_out} -t txt ${_in} DEPENDS ${_in} COMMENT "Building ${_out} from ${_in}" ) diff --git a/cmake_templates/Doxyfile.in b/cmake_templates/Doxyfile.in index 42a41571f01..3b1fb1e6bb3 100644 --- a/cmake_templates/Doxyfile.in +++ b/cmake_templates/Doxyfile.in @@ -1448,7 +1448,7 @@ DOT_NUM_THREADS = 0 # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need +# font does not include all possible Unicode characters however, so when you need # these (or just want a differently looking font) you can specify the font name # using DOT_FONTNAME. You need need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the diff --git a/debian/qgis.install b/debian/qgis.install index d17e9b75dec..3c2521bc80a 100644 --- a/debian/qgis.install +++ b/debian/qgis.install @@ -1,8 +1,6 @@ usr/lib/qgis/plugins/libgeorefplugin.so usr/lib/qgis/plugins/libgpsimporterplugin.so -usr/lib/qgis/plugins/libinterpolationplugin.so usr/lib/qgis/plugins/libcoordinatecaptureplugin.so -usr/lib/qgis/plugins/liboracleplugin.so usr/lib/qgis/plugins/libevis.so usr/lib/qgis/plugins/libspatialqueryplugin.so usr/lib/qgis/plugins/libofflineeditingplugin.so diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index c1802517118..b6b34e6b3c3 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -53,6 +53,7 @@ IF(WITH_APIDOC) ${CMAKE_SOURCE_DIR}/src/core/diagram ${CMAKE_SOURCE_DIR}/src/core/dxf ${CMAKE_SOURCE_DIR}/src/core/effects + ${CMAKE_SOURCE_DIR}/src/core/fieldformatter ${CMAKE_SOURCE_DIR}/src/core/geometry ${CMAKE_SOURCE_DIR}/src/core/gps ${CMAKE_SOURCE_DIR}/src/core/layertree diff --git a/doc/INSTALL.html b/doc/INSTALL.html index 8216371302f..cf1d14ad466 100644 --- a/doc/INSTALL.html +++ b/doc/INSTALL.html @@ -77,13 +77,13 @@ label{ background-color: #FFFFCC;

-Last Updated: Monday November 07, 2016 -Last Change : Monday November 07, 2016 +Last Updated: Monday January 09, 2017 +Last Change : Monday January 09, 2017

@@ -186,7 +186,7 @@ source directory.

2. Overview

-QGIS, like a number of major projects (eg. KDE 4.0), uses CMake +QGIS, like a number of major projects (e.g., KDE 4.0), uses CMake (http://www.cmake.org) for building from source.

@@ -207,14 +207,17 @@ Required build dependencies:

@@ -229,8 +232,8 @@ Optional dependencies:

  • for georeferencer - GSL >= 1.8
  • for postgis support and SPIT plugin - PostgreSQL >= 8.0.x
  • for gps plugin - gpsbabel -
  • for mapserver export and PyQGIS - Python >= 2.3 (2.5+ preferred) -
  • for python support - SIP >= 4.12, PyQt >= 4.8.3 must match Qt version, Qscintilla2 +
  • for mapserver export and PyQGIS - Python >= 3.3 +
  • for python support - SIP >= 4.12, PyQt >= 5.3 must match Qt version, Qscintilla2
  • for qgis mapserver - FastCGI
  • for oracle provider - Oracle OCI library @@ -239,7 +242,7 @@ Optional dependencies: Indirect dependencies:

    -Some proprietary formats (eg. ECW and MrSid) supported by GDAL require +Some proprietary formats (e.g., ECW and MrSid) supported by GDAL require proprietary third party libraries. QGIS doesn't need any of those itself to build, but will only support those formats if GDAL is built accordingly. Refer to http://gdal.org/formats_list.html ff. for instructions how to include @@ -434,13 +437,29 @@ Now on with the build:

    -make
    -make install
    +make -jX
     

    -It may take a little while to build depending on your platform. +where X is the number of available cores. Depending on your platform, +this can speed up the build time considerably.

    +

    +Then you can directly run from the build directory: +

    + +
    +./output/bin/qgis
    +
    + +

    +Another option is to install to your system: +

    + +
    +make install
    +
    +

    After that you can try to run QGIS:

    @@ -451,7 +470,7 @@ $HOME/apps/bin/qgis

    If all has worked properly the QGIS application should start up and appear -on your screen. If you get the error message "error while loading shared libraries", +on your screen. If you get the error message "error while loading shared libraries", execute this command in your shell.

    @@ -459,12 +478,47 @@ execute this command in your shell. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HOME}/apps/lib/
  • +

    +Optionally, if you already know what aspects you want in your custom build +then you can skip the interactive ccmake .. part by using the cmake -D +option for each aspect, e.g.: +

    + +
    +cmake -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX=${HOME}/apps ..
    +
    + +

    +Also, if you want to speed your build times, you can easily do it with ninja, +an alternative to make with similar build options. +

    +

    +For example, to configure your build you can do either one of: +

    + +
    +ccmake -G Ninja ..
    +
    + +
    +cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX=${HOME}/apps ..
    +
    + +

    +Build and install with ninja: +

    + +
    +ninja (uses all cores by default; also supports the above described -jX option)
    +ninja install
    +
    +

    3.8. Building Debian packages

    Instead of creating a personal installation as in the previous step you can -also create debian package. This is done from the QGIS root directory, where +also create debian package. This is done from the QGIS root directory, where you'll find a debian directory.

    @@ -549,7 +603,7 @@ subdirectory called `build` or `build-qt5` in it.

    3.10.1. Install build dependencies

    -apt-get install git build-essential cmake flex bison pyqt5-dev qttools5-dev qtpositioning5-dev libqt5svg5-dev libqt5webkit5-dev  libqt5gui5 libqt5scripttools5 qtscript5-dev libqca-qt5-2-dev grass-dev libgeos-dev libgdal-dev libqt5xmlpatterns5-dev libqt5scintilla2-dev pyqt5.qsci-dev python3-pyqt5.qsci libgsl-dev txt2tags libproj-dev libqwt-qt5-dev libspatialindex-dev pyqt5-dev-tools qttools5-dev-tools qt5-default python3-future python3-pyqt5.qtsql python3-psycopg2
    +apt-get install git build-essential cmake flex bison pyqt5-dev qttools5-dev qtpositioning5-dev libqt5svg5-dev libqt5webkit5-dev  libqt5gui5 libqt5scripttools5 qtscript5-dev libqca-qt5-2-dev grass-dev libgeos-dev libgdal-dev libqt5xmlpatterns5-dev libqt5scintilla2-dev pyqt5.qsci-dev python3-pyqt5.qsci libgsl-dev txt2tags libproj-dev libqwt-qt5-dev libspatialindex-dev pyqt5-dev-tools qttools5-dev-tools qt5-default python3-future python3-pyqt5.qtsql python3-psycopg2 python3-sip-dev
     

    diff --git a/doc/INSTALL.t2t b/doc/INSTALL.t2t index 92222b1a629..7f75b29c0c9 100644 --- a/doc/INSTALL.t2t +++ b/doc/INSTALL.t2t @@ -50,14 +50,8 @@ Building QGIS from source - step by step %apply vim formatting to the whole document as it screws up some formatting %rather apply it selectively to paragraphs where needed. -% To generate the text version of this document: -% txt2tags -t txt -o INSTALL INSTALL.t2t -% To generate the mediawiki version of this document: -% txt2tags -t wiki --no-enum-title -o INSTALL.wiki INSTALL.t2t -% To generate the html version of this document: -% txt2tags -t html -o INSTALL.html INSTALL.t2t -% To generate the LaTeX version of this document: -% txt2tags -t tex -o INSTALL.tex INSTALL.t2t; pdflatex INSTALL.tex +% To generate output fies from this document: +% cmake --build $YOURBUILDDIR --target t2tdoc % End of comments % ------------------- diff --git a/doc/TRANSLATORS b/doc/TRANSLATORS index 94b0e4ef353..51c9f23a8c0 100644 --- a/doc/TRANSLATORS +++ b/doc/TRANSLATORS @@ -37,4 +37,5 @@ Arabic

    51.4
    Ichaouia Amine, Hosham Munier Latvian
    50.9
    Maris Nartiss, Pēteris Brūns Slovak
    44.8
    Lubos Balazovic, Jana Kormanikova, Ivan Mincik -Croatian
    40.4
    Zoran Jankovic +Croatian
    40.4
    Zoran Jankovic +Esperanto
    36.3
    Augustin Roche, Nikolay Korotkiy diff --git a/doc/api_break.dox b/doc/api_break.dox index 462de32ad16..4b91bbc8db9 100644 --- a/doc/api_break.dox +++ b/doc/api_break.dox @@ -115,6 +115,9 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes} QgsMultiLineStringV2QgsMultiLineString QgsMultiSurfaceV2QgsMultiSurface QgsPointSequenceV2QgsPointSequence +QgsPropertyQgsProjectProperty +QgsPropertyKeyQgsProjectPropertyKey +QgsPropertyValueQgsProjectPropertyValue QgsRandomColorsV2QgsRandomColorRamp QgsRendererCategoryV2QgsRendererCategory QgsRendererRangeV2QgsRendererRange @@ -202,6 +205,7 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes} QgsApplicationuserStyleV2PathuserStylePath QgsComposerShapesetUseSymbolV2setUseSymbol QgsIFeatureSelectionManagerselectedFeaturesIdsselectedFeatureIds +QgsMapLayercapitaliseLayerNamecapitalizeLayerName QgsSymbolLayerUtilscreateSymbolLayerV2ListFromSldcreateSymbolLayerListFromSld QgsVectorLayereditorWidgetV2ConfigeditorWidgetConfig QgsVectorLayereditorWidgetV2TexteditorWidgetText @@ -258,6 +262,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat - QgsMapLayerRegistry. Its functionality has been moved to QgsProject. - QgsMapRenderer. It has been replaced by QgsMapRendererJob with subclasses and QgsMapSettings. - QgsPseudoColorShader. This shader has been broken for some time and was replaced by QgsSingleBandPseudoColorRenderer. +- QgsProjectBadLayerGuiHandler was removed. It was unused in QGIS code and barely useful. Implement your own QgsProjectBadLayerHandler subclass if needed. - QgsRendererV2DataDefinedMenus was removed. Use QgsDataDefinedButton instead. - QgsLegacyHelpers. - QgsProviderCountCalcEvent and QgsProviderExtentCalcEvent. These classes were unused in QGIS core and unmaintained. @@ -309,7 +314,7 @@ Data Providers {#qgis_api_break_3_0_DataProviders} Qgis {#qgis_api_break_3_0_Qgis} ---- -- The QGis class was renamed to Qgis for capitalisation consistency with other class names +- The QGis class was renamed to Qgis for capitalization consistency with other class names - permissiveToDouble() and permissiveToInt() where moved out of the QGis class and renamed to qgsPermissiveToDouble() and qgsPermissiveToInt() - The constants DEFAULT_IDENTIFY_RADIUS and MINIMUM_POINT_SIZE were removed @@ -475,6 +480,12 @@ QgsColorRampShader {#qgis_api_break_3_0_QgsColorRampShader} ------------------ - maximumColorCacheSize() and setMaximumColorCacheSize() were no longer used and are removed. +- ColorRamp_TYPE enum was renamed to Type, and its value names decapitalized + +QgsColorSchemeRegistry {#qgis_api_break_3_0_QgsColorSchemeRegistry} +---------------------- + +- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::colorSchemeRegistry() to access an application-wide registry. QgsComposerArrow {#qgis_api_break_3_0_QgsComposerArrow} @@ -604,6 +615,7 @@ QgsComposerTableV2 {#qgis_api_break_3_0_QgsComposerTableV2} QgsComposition {#qgis_api_break_3_0_QgsComposition} -------------- +- constructor requires QgsProject instance as the second argument - addItemsFromXML() has been renamed to addItemsFromXml() - Constructor with QgsMapRenderer parameter has been removed. Use the variant with QgsMapSettings parameter. - mapRenderer() has been removed. Use mapSettings() instead. @@ -680,6 +692,13 @@ QgsCptCitySelectionItem {#qgis_api_break_3_0_QgsCptCitySelectionItem} - parseXML() has been renamed to parseXml() + +QgsCustomLayerOrderWidget {#qgis_api_break_3_0_QgsCustomLayerOrderWidget} +------------------------- + +- the signature of the visibilityChanged() signal is changed to visibilityChanged( QgsLayerTreeNode *node ) + + QgsCRSCache {#qgis_api_break_3_0_QgsCRSCache} ----------- @@ -726,6 +745,12 @@ QgsDataItem {#qgis_api_break_3_0_QgsDataItem} - emitBeginInsertItems(), emitEndInsertItems(), emitBeginRemoveItems(), emitEndRemoveItems(), emitDataChanged(), emitStateChanged() have been removed. - Favourites was renamed to Favorites +QgsDataItemProviderRegistry {#qgis_api_break_3_0_QgsDataItemProviderRegistry} +--------------------------- + +- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::dataItemProviderRegistry() to access an application-wide registry. + + QgsDataProvider {#qgis_api_break_3_0_QgsDataProvider} --------------- @@ -756,11 +781,15 @@ Use renderDiagram( const QgsFeature& feature, QgsRenderContext& c, const QgsDiag - The deprecated diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ) method has been removed. Use diagramSize( const QgsFeature& feature, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ) instead. +QgsDiagramInterpolationSettings {#qgis_api_break_3_0_QgsDiagramInterpolationSettings} +------------------------------- +- The classificationAttribute member variable was removed, and has been replaced by the classificationField variable which stores the string name. + QgsDiagramRenderer {#qgis_api_break_3_0_QgsDiagramRenderer} ------------------ - - xform, fields were no longer required and are removed. +- referencedFields() no longer takes a QgsFields argument. QgsDiagramLayerSettings {#qgis_api_break_3_0_QgsDiagramLayerSettings} @@ -771,7 +800,15 @@ be returned in place of a null pointer. - setCoordinateTransform() now takes a QgsCoordinateTransform object, not a pointer. Use an invalid QgsCoordinateTransform in place of a null pointer. - The ct member has been removed. Use coordinateTransform() and setCoordinateTransform() instead. - +- The LinePlacementFlags enum was renamed to LinePlacementFlag +- The placement member variable was removed, and getPlacement() was renamed to placement() +- The placementFlags member variable was removed +- The priority member variable was removed, and getPriority() was renamed to priority() +- The zIndex member variable was removed, and getZIndex() was renamed to zIndex() +- The obstacle member variable was removed. setIsObstacle() and isObstacle() should be used instead. +- The dist member variable was removed. setDistance() and distance() should be used instead. +- The renderer member variable was removed, and getRenderer() was renamed to renderer() +- The showAll member variable was removed. setShowAllDiagrams() and showAllDiagrams() should be used instead. QgsDiagramSettings {#qgis_api_break_3_0_QgsDiagramSettings} ------------------ @@ -851,6 +888,12 @@ QgsExpression::Function {#qgis_api_break_3_0_QgsExpression_Function} - `QgsExpression::Function::helptext()` has been renamed to `helpText()` +QgsExpressionContextUtils {#qgis_api_break_3_0_QgsExpressionContextUtils} +------------------------- + +- projectScope(), setProjectVariable() and setProjectVariables() require pointer to QgsProject as the first argument. + + QgsFeature {#qgis_api_break_3_0_QgsFeature} ---------- @@ -923,6 +966,7 @@ method to determine if a geometry is valid. - static bool compare( const QgsPolygon& p1, const QgsPolygon& p2, double epsilon ) has been renamed to comparePolygons - static bool compare( const QgsMultiPolygon& p1, const QgsMultiPolygon& p2, double epsilon ) has been renamed to compareMultiPolygons - smoothLine and smoothPolygon are no longer public API (use smooth() instead) +- avoidIntersections() got an extra argument: list of layers to include in the operation (previously read from active QgsProject) QgsGeometryAnalyzer {#qgis_api_break_3_0_QgsGeometryAnalyzer} @@ -985,6 +1029,11 @@ QgsEditorWidgetFactory {#qgis_api_break_3_0_QgsEditorWidgetFactory} - `alignmentFlag` has been removed. Use QgsFieldFormatter::representValue() instead - `createCache` has been removed. Use QgsFieldFormatter::representValue() instead +QgsGPSConnectionRegistry {#qgis_api_break_3_0_QgsGPSConnectionRegistry} +------------------------ + +- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::gpsConnectionRegistry() to access an application-wide registry. + QgsGraduatedRenderer {#qgis_api_break_3_0_QgsGraduatedRenderer} -------------------- @@ -1041,12 +1090,16 @@ QgsLayerTreeGroup {#qgis_api_break_3_0_QgsLayerTreeGroup} ----------------- - readChildrenFromXML() has been renamed to readChildrenFromXml() - +- isVisible() is moved to QgsLayerTreeNode +- setVisible() is replaced by QgsLayerTreeNode::setItemVisibilityChecked() +- protected methods updateVisibilityFromChildren() and updateChildVisibility() removed QgsLayerTreeLayer {#qgis_api_break_3_0_QgsLayerTreeLayer} ----------------- - setLayerName(), layerName() were renamed to setName(), name() +- isVisible() is moved to QgsLayerTreeNode +- setVisible() is replaced by QgsLayerTreeNode::setItemVisibilityChecked() QgsLayerTreeModel {#qgis_api_break_3_0_QgsLayerTreeMode} @@ -1072,7 +1125,7 @@ QgsLayerTreeNode {#qgis_api_break_3_0_QgsLayerTreeNode} - readCommonXML() has been renamed to readCommonXml() - writeCommonXML() has been renamed to writeCommonXml() - +- the signature of the visibilityChanged() signal is changed to visibilityChanged( QgsLayerTreeNode *node ) QgsLimitedRandomColorRampDialog {#qgis_api_break_3_0_QgsLimitedRandomRampDialog} ------------------------------- @@ -1082,6 +1135,13 @@ and the new ramp can be retrieved after executing the dialog by calling ramp(). - Some internal methods which were previously public or protected were made private. +QgsLinearlyInterpolatedDiagramRenderer {#qgis_api_break_3_0_QgsLinearlyInterpolatedDiagramRenderer} +-------------------------------------- + +- The classificationAttribute() and setClassificationAttribute() methods were replace by +classificationField() and setClassificationField() which use the field names instead of field +indexes. + QgsMapCanvas {#qgis_api_break_3_0_QgsMapCanvas} ------------ @@ -1129,6 +1189,7 @@ screenUpdateRequested() were removed. These members have had no effect for a num - drawLabels() method was removed. It used old deprecated labeling. Replaced by labeling based on PAL library, see QgsLabelingEngine. - readLayerXML() was renamed to readLayerXml() - writeLayerXML() was renamed to writeLayerXml() +- capitaliseLayerName() was renamed to capitalizeLayerName() QgsMapLayerRegistry {#qgis_api_break_3_0_QgsMapLayerRegistry} @@ -1207,6 +1268,12 @@ QgsMarkerSymbolLayer {#qgis_api_break_3_0_QgsMarkerSymbolLayer} - bounds() is now pure virtual and must be implemented in all subclasses. +QgsMessageLog {#qgis_api_break_3_0_QgsMessageLog} +--------------------------- + +- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::messageLog() to access an application-wide log. + + QgsMimeDataUtils {#qgis_api_break_3_0_QgsMimeDataUtils} ---------------- @@ -1257,6 +1324,11 @@ QgsNumericSortTreeWidgetItem {#qgis_api_break_3_0_QgsNumericSortTreeWidge has improved sort capabilities including the ability to set custom sort values for items and for forcing certain items to always sort on top. +QgsPaintEffectRegistry {#qgis_api_break_3_0_QgsPaintEffectRegistry} +---------------------- + +- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::paintEffectRegistry() to access an application-wide registry. + QgsPalettedRasterRenderer {#qgis_api_break_3_0_QgsPalettedRasterRenderer} ------------------------- @@ -1299,6 +1371,12 @@ QgsPluginLayer {#qgis_api_break_3_0_QgsPluginLayer} - createMapRenderer(): default implementation (which called plugin's draw() method) has been removed. Plugin layers must implement createMapRenderer(). +QgsPluginLayerRegistry {#qgis_api_break_3_0_QgsPluginLayerRegistry} +---------------------- + +- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::pluginLayerRegistry() to access an application-wide registry. + + QgsPointDisplacementRenderer {#qgis_api_break_3_0_QgsPointDisplacementRenderer} ---------------------------- @@ -1323,8 +1401,16 @@ QgsProject {#qgis_api_break_3_0_QgsProject} - title( const QString & title ) was removed. Use setTitle() instead. - dirty( bool b ) was removed. Use setDirty() instead. - clearProperties() was removed. Use clear() instead. +- read( QDomNode& layerNode ) was renamed to readLayer( const QDomNode& layerNode ). +- read( const QFileInfo& file ) was replaced by read( const QString& filename ). +- write( const QFileInfo& file ) was replaced by write( const QString& filename ). +QgsProjectPropertyValue {#qgis_api_break_3_0_QgsProjectPropertyValue} +----------------------- + +- The unused count() and entryList() methods were removed. + QgsRaster {#qgis_api_break_3_0_QgsRaster} --------- @@ -1404,6 +1490,12 @@ be returned instead of a null pointer if no transformation is required. - setCoordinateTransform() now takes a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should be used instead of a null pointer if no transformation is required. +QgsRendererRegistry {#qgis_api_break_3_0_QgsRendererRegistry} +---------------------- + +- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::rendererRegistry() to access an application-wide registry. + + QgsRendererWidget {#qgis_api_break_3_0_QgsRendererWidget} ----------------- @@ -1465,6 +1557,7 @@ QgsSingleSymbolRendererWidget {#qgis_api_break_3_0_QgsSingleSymbolRendere ----------------------------- - sizeScaleFieldChanged() and scaleMethodChanged() were removed. These settings are no longer exposed in the widget's GUI. +- The Mode enum was removed. QgsSnapper {#qgis_api_break_3_0_QgsSnapper} @@ -1484,6 +1577,7 @@ QgsSublayersDialog {#qgis_api_break_3_0_QgsSublayersDialog} QgsSvgCache {#qgis_api_break_3_0_QgsSvgCache} ----------- +- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::svgCache() to access an application-wide cache. - containsParamsV2() was removed. Use containsParamsV3() instead. QgsStyle (renamed from QgsStyleV2) {#qgis_api_break_3_0_QgsStyle} @@ -1517,6 +1611,11 @@ the variant which takes QgsSymbolRenderContext instead. - evaluateDataDefinedProperty( const QString& property, const QgsFeature* feature ) was removed. Use the variant which takes QgsSymbolRenderContext instead. - expression() was removed. Use getDataDefinedProperty or evaluateDataDefinedProperty instead. +QgsSymbolLayerRegistry {#qgis_api_break_3_0_QgsSymbolLayerRegistry} +---------------------- + +- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::symbolLayerRegistry() to access an application-wide registry. + QgsSymbolLayerWidget {#qgis_api_break_3_0_QgsSymbolLayerWidget} -------------------- diff --git a/doc/api_custom.css b/doc/api_custom.css index cab4de68b88..4b5bc31fd6d 100644 --- a/doc/api_custom.css +++ b/doc/api_custom.css @@ -177,6 +177,12 @@ div.header { width: 80%; } +#main-nav { + width: 80%; + margin-left: auto; + margin-right: auto; +} + div.qindex, div.navpath { width: 80%; margin-left: auto; diff --git a/doc/build.sh b/doc/build.sh deleted file mode 100755 index 7ce44bf6f12..00000000000 --- a/doc/build.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -########################################################################### -# build.sh -# --------------------- -# Date : November 2010 -# Copyright : (C) 2010 by Tim Sutton -# Email : tim at kartoza dot com -########################################################################### -# # -# 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. # -# # -########################################################################### - -txt2tags -o ../INSTALL -t txt INSTALL.t2t -txt2tags -o INSTALL.html -t html INSTALL.t2t -txt2tags -o INSTALL.tex -t tex INSTALL.t2t -pdflatex INSTALL.tex -mv INSTALL.pdf .. diff --git a/doc/linux.t2t b/doc/linux.t2t index 32ee2b661c6..a0534c83aa6 100644 --- a/doc/linux.t2t +++ b/doc/linux.t2t @@ -135,8 +135,8 @@ Now on with the build: make -jX ``` -where X is the number of available cores. Without the -j option -it may take a little while to build depending on your platform. +where X is the number of available cores. Depending on your platform, +this can speed up the build time considerably. Then you can directly run from the build directory: @@ -164,6 +164,33 @@ execute this command in your shell. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HOME}/apps/lib/ ``` +Optionally, if you already know what aspects you want in your custom build +then you can skip the interactive ccmake .. part by using the cmake -D +option for each aspect, e.g.: + +``` +cmake -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX=${HOME}/apps .. +``` + +Also, if you want to speed your build times, you can easily do it with ninja, +an alternative to make with similar build options. + +For example, to configure your build you can do either one of: + +``` +ccmake -G Ninja .. +``` + +``` +cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX=${HOME}/apps .. +``` + +Build and install with ninja: + +``` +ninja (uses all cores by default; also supports the above described -jX option) +ninja install +``` == Building Debian packages == diff --git a/doc/news.html b/doc/news.html index 3c593af9463..ff35f350d8c 100644 --- a/doc/news.html +++ b/doc/news.html @@ -174,7 +174,7 @@ This release has following new features:
  • Map Composer: Parameterized svg support for composer svg images
  • Map Composer: Easier use of HTML in labels
  • Map Composer: Relative links in composer labels -
  • Map Composer: Georeference outputs (eg PDF) from composer +
  • Map Composer: Georeference outputs (e.g., PDF) from composer
  • Map Composer: Composer maps now auto-update with presets
  • Analysis tools: Named parameters in expressions
  • Analysis tools: More distance units @@ -935,7 +935,7 @@ changed so we will just provide a bullet list of key new features here. diff --git a/doc/news.t2t b/doc/news.t2t index deedb690d69..baaebab125b 100644 --- a/doc/news.t2t +++ b/doc/news.t2t @@ -795,7 +795,7 @@ changed so we will just provide a bullet list of key new features here. - Optionally re-use entered attribute values for next digitized feature. - Allow merging/assigning attribute values to a set of features.- - - Allow OGR 'save as' without attributes (for eg. DGN/DXF). + - Allow OGR 'save as' without attributes (e.g., DGN/DXF). - - @@ -1023,7 +1023,7 @@ release series. In all other cases we recommend that you use this version. This release includes around 200 bug fixes, nearly 30 new features and has had -a lot of love and attention poured in to it to take our favourite desktop GIS +a lot of love and attention poured in to it to take our favorite desktop GIS application another step on the road to GIS nirvana! So much has happened in the 3 months since our last release that it is impossible to document everything here. Instead we will just highlight a couple of important new diff --git a/doc/overview.t2t b/doc/overview.t2t index 85d3b671fd3..a8db9d0076d 100644 --- a/doc/overview.t2t +++ b/doc/overview.t2t @@ -1,7 +1,7 @@ = Overview = -QGIS, like a number of major projects (eg. KDE 4.0), uses CMake +QGIS, like a number of major projects (e.g., KDE 4.0), uses CMake (http://www.cmake.org) for building from source. Following a summary of the required dependencies for building: @@ -15,14 +15,17 @@ Required build tools: Required build dependencies: -- Qt >= 4.8.0 +- Qt >= 5.3.0 - Proj >= 4.4.x - GEOS >= 3.4 - Sqlite3 >= 3.0.0 -- GDAL/OGR >= 1.4.x +- SpatiaLite +- libspatialindex +- GDAL/OGR >= 2.0 - Qwt >= 5.0 & (< 6.1 with internal QwtPolar) - expat >= 1.95 - QScintilla2 +- QCA - Optional dependencies: @@ -34,15 +37,15 @@ Optional dependencies: - for georeferencer - GSL >= 1.8 - for postgis support and SPIT plugin - PostgreSQL >= 8.0.x - for gps plugin - gpsbabel -- for mapserver export and PyQGIS - Python >= 2.3 (2.5+ preferred) -- for python support - SIP >= 4.12, PyQt >= 4.8.3 must match Qt version, Qscintilla2 +- for mapserver export and PyQGIS - Python >= 3.3 +- for python support - SIP >= 4.12, PyQt >= 5.3 must match Qt version, Qscintilla2 - for qgis mapserver - FastCGI - for oracle provider - Oracle OCI library - Indirect dependencies: -Some proprietary formats (eg. ECW and MrSid) supported by GDAL require +Some proprietary formats (e.g., ECW and MrSid) supported by GDAL require proprietary third party libraries. QGIS doesn't need any of those itself to build, but will only support those formats if GDAL is built accordingly. Refer to http://gdal.org/formats_list.html ff. for instructions how to include diff --git a/images/flags/eo.png b/images/flags/eo.png new file mode 100644 index 00000000000..9db4dbc988e Binary files /dev/null and b/images/flags/eo.png differ diff --git a/images/images.qrc b/images/images.qrc index 126d281cf16..3f2c0667c87 100644 --- a/images/images.qrc +++ b/images/images.qrc @@ -8,6 +8,7 @@ flags/de.png flags/en_GB.png flags/en_US.png + flags/eo.png flags/es.png flags/fa.png flags/fi.png @@ -109,6 +110,7 @@ themes/default/mActionEditNodesItem.svg themes/default/mActionEditHelpContent.svg themes/default/mActionIncreaseFont.svg + themes/default/mActionInterfaceCustomization.svg themes/default/mActionDecreaseFont.svg themes/default/mActionAddNodesItem.svg themes/default/mActionAddPolygon.svg @@ -210,9 +212,9 @@ themes/default/mActionIncreaseContrast.svg themes/default/mActionInOverview.svg themes/default/mActionInvertSelection.svg + themes/default/mActionKeyboardShortcuts.svg themes/default/mActionLabel.svg themes/default/mActionLabeling.svg - themes/default/mActionDiagramProperties.svg themes/default/mActionLocalCumulativeCutStretch.svg themes/default/mActionLocalHistogramStretch.svg themes/default/mActionLowerItems.svg @@ -343,7 +345,6 @@ themes/default/mIconExpand.png themes/default/mIconExpandSmall.svg themes/default/mIconExpression.svg - themes/default/mIconExpressionEditorOpen.svg themes/default/mIconExpressionFilter.svg themes/default/mIconExpressionPreview.svg themes/default/mIconExpressionSelect.svg diff --git a/images/splash/splash.png b/images/splash/splash.png index a6bdb6f7c89..1126559633c 100644 Binary files a/images/splash/splash.png and b/images/splash/splash.png differ diff --git a/images/themes/default/mActionDiagramProperties.svg b/images/themes/default/mActionDiagramProperties.svg deleted file mode 100644 index 8d6d3b9d296..00000000000 --- a/images/themes/default/mActionDiagramProperties.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/images/themes/default/mActionInterfaceCustomization.svg b/images/themes/default/mActionInterfaceCustomization.svg new file mode 100644 index 00000000000..13c73aa6dfe --- /dev/null +++ b/images/themes/default/mActionInterfaceCustomization.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/themes/default/mActionKeyboardShortcuts.svg b/images/themes/default/mActionKeyboardShortcuts.svg new file mode 100644 index 00000000000..b05a1b331d4 --- /dev/null +++ b/images/themes/default/mActionKeyboardShortcuts.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/themes/default/mActionOptions.svg b/images/themes/default/mActionOptions.svg index a056038acb3..abfb64dc4a1 100644 --- a/images/themes/default/mActionOptions.svg +++ b/images/themes/default/mActionOptions.svg @@ -1,24 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/images/themes/default/mIconExpressionEditorOpen.svg b/images/themes/default/mIconExpressionEditorOpen.svg deleted file mode 100644 index 6d076f5a247..00000000000 --- a/images/themes/default/mIconExpressionEditorOpen.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/ms-windows/osgeo4w/package-nightly.cmd b/ms-windows/osgeo4w/package-nightly.cmd index 042b7703ef5..83822a76586 100644 --- a/ms-windows/osgeo4w/package-nightly.cmd +++ b/ms-windows/osgeo4w/package-nightly.cmd @@ -91,10 +91,10 @@ set CMAKE_OPT=^ -D CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS=TRUE :cmake -for /f "usebackq tokens=1" %%a in (`%OSGEO4W_ROOT%\bin\grass70 --config path`) do set GRASS70_PATH=%%a -for %%i in ("%GRASS70_PATH%") do set GRASS70_VERSION=%%~nxi -set GRASS70_VERSION=%GRASS70_VERSION:grass-=% -set GRASS_VERSIONS=%GRASS6_VERSION% %GRASS70_VERSION% +for /f "usebackq tokens=1" %%a in (`%OSGEO4W_ROOT%\bin\grass72 --config path`) do set GRASS72_PATH=%%a +for %%i in ("%GRASS72_PATH%") do set GRASS72_VERSION=%%~nxi +set GRASS72_VERSION=%GRASS72_VERSION:grass-=% +set GRASS_VERSIONS=%GRASS6_VERSION% %GRASS72_VERSION% set PYTHONPATH= path %PF86%\CMake\bin;%PATH%;c:\cygwin\bin @@ -168,7 +168,7 @@ cmake -G Ninja ^ -D WITH_GRASS6=TRUE ^ -D WITH_GRASS7=TRUE ^ -D GRASS_PREFIX=%O4W_ROOT%/apps/grass/grass-%GRASS6_VERSION% ^ - -D GRASS_PREFIX7=%GRASS70_PATH:\=/% ^ + -D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^ -D WITH_GLOBE=TRUE ^ -D WITH_TOUCH=TRUE ^ -D WITH_ORACLE=TRUE ^ diff --git a/ms-windows/osgeo4w/package.cmd b/ms-windows/osgeo4w/package.cmd index af4a81220b2..6739372257a 100644 --- a/ms-windows/osgeo4w/package.cmd +++ b/ms-windows/osgeo4w/package.cmd @@ -85,10 +85,10 @@ set CMAKE_OPT=^ -D CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS=TRUE :cmake -for /f "usebackq tokens=1" %%a in (`%OSGEO4W_ROOT%\bin\grass70 --config path`) do set GRASS70_PATH=%%a -for %%i in ("%GRASS70_PATH%") do set GRASS70_VERSION=%%~nxi -set GRASS70_VERSION=%GRASS70_VERSION:grass-=% -set GRASS_VERSIONS=%GRASS6_VERSION% %GRASS70_VERSION% +for /f "usebackq tokens=1" %%a in (`%OSGEO4W_ROOT%\bin\grass72 --config path`) do set GRASS72_PATH=%%a +for %%i in ("%GRASS72_PATH%") do set GRASS72_VERSION=%%~nxi +set GRASS72_VERSION=%GRASS72_VERSION:grass-=% +set GRASS_VERSIONS=%GRASS6_VERSION% %GRASS72_VERSION% set PYTHONPATH= path %PF86%\CMake\bin;%PATH%;c:\cygwin\bin @@ -159,7 +159,7 @@ cmake -G Ninja ^ -D WITH_GRASS6=TRUE ^ -D WITH_GRASS7=TRUE ^ -D GRASS_PREFIX=%O4W_ROOT%/apps/grass/grass-%GRASS6_VERSION% ^ - -D GRASS_PREFIX7=%GRASS70_PATH:\=/% ^ + -D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^ -D WITH_GLOBE=TRUE ^ -D WITH_TOUCH=TRUE ^ -D WITH_ORACLE=TRUE ^ @@ -385,9 +385,7 @@ tar -C %OSGEO4W_ROOT% -cjf %ARCH%/release/qgis/%PACKAGENAME%/%PACKAGENAME%-%VERS "apps/%PACKAGENAME%/plugins/evis.dll" ^ "apps/%PACKAGENAME%/plugins/georefplugin.dll" ^ "apps/%PACKAGENAME%/plugins/gpsimporterplugin.dll" ^ - "apps/%PACKAGENAME%/plugins/interpolationplugin.dll" ^ "apps/%PACKAGENAME%/plugins/offlineeditingplugin.dll" ^ - "apps/%PACKAGENAME%/plugins/oracleplugin.dll" ^ "apps/%PACKAGENAME%/plugins/spatialqueryplugin.dll" ^ "apps/%PACKAGENAME%/plugins/topolplugin.dll" ^ "apps/%PACKAGENAME%/plugins/geometrycheckerplugin.dll" ^ diff --git a/ms-windows/plugins.nsh b/ms-windows/plugins.nsh index 9f49e9c9eb1..8b1962db9f9 100644 --- a/ms-windows/plugins.nsh +++ b/ms-windows/plugins.nsh @@ -14,9 +14,7 @@ WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "georefplugin" "true WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "globeplugin" "false" WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "gpsimporterplugin" "true" WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "grassplugin" "true" -WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "interpolationplugin" "true" WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "offlineeditingplugin" "true" -WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "oracleplugin" "true" WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "spatialqueryplugin" "true" WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "topolplugin" "true" diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 100a95505d9..b3124450962 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -120,6 +120,8 @@ INCLUDE_DIRECTORIES( sip_helpers ${CMAKE_BINARY_DIR} # qgsconfig.h, qgsversion.h + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/analysis ) IF(NOT ANDROID) diff --git a/python/PyQt/CMakeLists.txt b/python/PyQt/CMakeLists.txt index 0a38790b51f..b87541ee17b 100644 --- a/python/PyQt/CMakeLists.txt +++ b/python/PyQt/CMakeLists.txt @@ -15,6 +15,7 @@ SET(PYQT_COMPAT_FILES QtTest.py QtSvg.py Qsci.py + Qt.py uic/__init__.py uic/pyuic.py uic/properties.py diff --git a/python/console/console_editor.py b/python/console/console_editor.py index 65a67350fda..259a444d04b 100644 --- a/python/console/console_editor.py +++ b/python/console/console_editor.py @@ -531,10 +531,10 @@ class Editor(QsciScintilla): try: ## set creationflags for running command without shell window if sys.platform.startswith('win'): - p = subprocess.Popen(['python', filename], shell=False, stdin=subprocess.PIPE, + p = subprocess.Popen(['python3', filename], shell=False, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, creationflags=0x08000000) else: - p = subprocess.Popen(['python', filename], shell=False, stdin=subprocess.PIPE, + p = subprocess.Popen(['python3', filename], shell=False, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE) out, _traceback = p.communicate() diff --git a/python/core/__init__.py b/python/core/__init__.py index 24de54644a6..c93d67c2d6e 100644 --- a/python/core/__init__.py +++ b/python/core/__init__.py @@ -246,7 +246,7 @@ def fromFunction(description, function, *args, on_finished=None, flags=QgsTask.A task = QgsTask.fromFunction('my task', calculate, on_finished=calculation_finished) - QgsTaskManager.instance().addTask(task) + QgsApplication.taskManager().addTask(task) """ diff --git a/python/core/composer/qgscomposerattributetablev2.sip b/python/core/composer/qgscomposerattributetablev2.sip index 211b28b963e..118f68bac11 100644 --- a/python/core/composer/qgscomposerattributetablev2.sip +++ b/python/core/composer/qgscomposerattributetablev2.sip @@ -76,7 +76,7 @@ class QgsComposerAttributeTableV2 : QgsComposerTableV2 */ ContentSource source() const; - /** Returns the source layer for the table, considering the table source mode. Eg, + /** Returns the source layer for the table, considering the table source mode. For example, * if the table is set to atlas feature mode, then the source layer will be the * atlas coverage layer. If the table is set to layer attributes mode, then * the source layer will be the user specified vector layer. diff --git a/python/core/composer/qgscomposeritem.sip b/python/core/composer/qgscomposeritem.sip index ea35e74cd6e..03ec8843cf0 100644 --- a/python/core/composer/qgscomposeritem.sip +++ b/python/core/composer/qgscomposeritem.sip @@ -416,7 +416,7 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem */ void setTransparency( const int transparency ); - /** Returns whether effects (eg blend modes) are enabled for the item + /** Returns whether effects (e.g., blend modes) are enabled for the item * @returns true if effects are enabled * @see setEffectsEnabled * @see transparency @@ -424,7 +424,7 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem */ bool effectsEnabled() const; - /** Sets whether effects (eg blend modes) are enabled for the item + /** Sets whether effects (e.g., blend modes) are enabled for the item * @param effectsEnabled set to true to enable effects * @see effectsEnabled * @see setTransparency @@ -508,7 +508,7 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem /** Sets visibility for item. * @param visible set to true to show item, false to hide item * @note QGraphicsItem::setVisible should not be called directly - * on a QgsComposerItem, as some item types (eg groups) need to override + * on a QgsComposerItem, as some item types (e.g., groups) need to override * the visibility toggle. * @note added in version 2.5 */ diff --git a/python/core/composer/qgscomposermapitem.sip b/python/core/composer/qgscomposermapitem.sip index dc3bc7fec3c..a294b65b428 100644 --- a/python/core/composer/qgscomposermapitem.sip +++ b/python/core/composer/qgscomposermapitem.sip @@ -1,6 +1,6 @@ /** \ingroup core * \class QgsComposerMapItem - * \brief An item which is drawn inside a QgsComposerMap, eg a grid or map overview. + * \brief An item which is drawn inside a QgsComposerMap, e.g., a grid or map overview. */ class QgsComposerMapItem : QgsComposerObject { diff --git a/python/core/composer/qgscomposermultiframe.sip b/python/core/composer/qgscomposermultiframe.sip index b2eaf3903df..93fcb0e7158 100644 --- a/python/core/composer/qgscomposermultiframe.sip +++ b/python/core/composer/qgscomposermultiframe.sip @@ -205,7 +205,7 @@ class QgsComposerMultiFrame: QgsComposerObject /** Creates a new frame and adds it to the multi frame and composition. * @param currentFrame an existing QgsComposerFrame from which to copy the size - * and general frame properties (eg frame style, background, rendering settings). + * and general frame properties (e.g., frame style, background, rendering settings). * @param pos position of top-left corner of the new frame * @param size size of the new frame * @returns new QgsComposerFrame diff --git a/python/core/composer/qgscomposition.sip b/python/core/composer/qgscomposition.sip index 8f0c9d1446e..c2ea6866aa5 100644 --- a/python/core/composer/qgscomposition.sip +++ b/python/core/composer/qgscomposition.sip @@ -40,7 +40,7 @@ class QgsComposition : QGraphicsScene, QgsExpressionContextGenerator Landscape }; - explicit QgsComposition( const QgsMapSettings& mapSettings ); + explicit QgsComposition( const QgsMapSettings& mapSettings, QgsProject* project ); /** Composition atlas modes*/ enum AtlasMode @@ -52,6 +52,14 @@ class QgsComposition : QGraphicsScene, QgsExpressionContextGenerator ~QgsComposition(); + /** + * The project associated with the composition. Used to get access to layers, map themes, + * relations and various other bits. It is never null. + * + * \note Added in QGIS 3.0 + */ + QgsProject* project() const; + /** Changes size of paper item. * @param width page width in mm * @param height page height in mm @@ -732,7 +740,7 @@ class QgsComposition : QGraphicsScene, QgsExpressionContextGenerator /** Calculates the bounds of all non-gui items in the composition. Ignores snap lines and mouse handles. * @param ignorePages set to true to ignore page items - * @param margin optional marginal (in percent, eg 0.05 = 5% ) to add around items + * @param margin optional marginal (in percent, e.g., 0.05 = 5% ) to add around items */ QRectF compositionBounds( bool ignorePages = false, double margin = 0.0 ) const; diff --git a/python/core/effects/qgscoloreffect.sip b/python/core/effects/qgscoloreffect.sip index 6510e9eea00..0ce87edebd2 100644 --- a/python/core/effects/qgscoloreffect.sip +++ b/python/core/effects/qgscoloreffect.sip @@ -1,6 +1,6 @@ /** \ingroup core * \class QgsColorEffect - * \brief A paint effect which alters the colors (eg brightness, contrast) in a + * \brief A paint effect which alters the colors (e.g., brightness, contrast) in a * source picture. * * \note Added in version 2.9 diff --git a/python/core/effects/qgspainteffect.sip b/python/core/effects/qgspainteffect.sip index 7e524e51646..abaa64f7a5d 100644 --- a/python/core/effects/qgspainteffect.sip +++ b/python/core/effects/qgspainteffect.sip @@ -245,7 +245,7 @@ class QgsPaintEffect * * The draw source effect can be used to draw an unaltered copy of the original source * picture. Minor changes like lowering the opacity and applying a blend mode are - * supported, however these changes will force the resultant output to be rasterised. + * supported, however these changes will force the resultant output to be rasterized. * If no alterations are performed then the original picture will be rendered as a vector. * * \note Added in version 2.9 diff --git a/python/core/effects/qgspainteffectregistry.sip b/python/core/effects/qgspainteffectregistry.sip index 0ad19f2f063..a960b108e32 100644 --- a/python/core/effects/qgspainteffectregistry.sip +++ b/python/core/effects/qgspainteffectregistry.sip @@ -67,9 +67,8 @@ class QgsPaintEffectRegistry public: - /** Returns a reference to the singleton instance of the paint effect registry. - */ - static QgsPaintEffectRegistry* instance(); + QgsPaintEffectRegistry(); + ~QgsPaintEffectRegistry(); /** Returns the metadata for a specific effect. * @param name unique string name for paint effect class @@ -120,10 +119,6 @@ class QgsPaintEffectRegistry */ static bool isDefaultStack( QgsPaintEffect* effect ); - protected: - QgsPaintEffectRegistry(); - ~QgsPaintEffectRegistry(); - private: QgsPaintEffectRegistry( const QgsPaintEffectRegistry& rh ); }; diff --git a/python/core/geometry/qgsabstractgeometry.sip b/python/core/geometry/qgsabstractgeometry.sip index a48605dc5f8..f87a0a98a07 100644 --- a/python/core/geometry/qgsabstractgeometry.sip +++ b/python/core/geometry/qgsabstractgeometry.sip @@ -398,7 +398,7 @@ class QgsAbstractGeometry */ virtual QgsRectangle calculateBoundingBox() const; - /** Clears any cached parameters associated with the geometry, eg bounding boxes + /** Clears any cached parameters associated with the geometry, e.g., bounding boxes */ virtual void clearCache() const; }; diff --git a/python/core/geometry/qgscurve.sip b/python/core/geometry/qgscurve.sip index 4e36af3710e..d1b6a37824b 100644 --- a/python/core/geometry/qgscurve.sip +++ b/python/core/geometry/qgscurve.sip @@ -54,8 +54,7 @@ class QgsCurve: public QgsAbstractGeometry */ virtual int numPoints() const = 0; - /** Calculates the area of the curve. Derived classes should override this - * to return the correct area of the curve. + /** Sums up the area of the curve by iterating over the vertices (shoelace formula). */ virtual void sumUpArea( double& sum ) const = 0; diff --git a/python/core/geometry/qgsgeometry.sip b/python/core/geometry/qgsgeometry.sip index ae8cc4d41e1..40eb6ce543f 100644 --- a/python/core/geometry/qgsgeometry.sip +++ b/python/core/geometry/qgsgeometry.sip @@ -551,7 +551,7 @@ class QgsGeometry /** * Returns a point guaranteed to lie on the surface of a geometry. While the centroid() - * of a geometry may be located outside of the geometry itself (eg for concave shapes), + * of a geometry may be located outside of the geometry itself (e.g., for concave shapes), * the point on surface will always be inside the geometry. * @see centroid() * @see poleOfInaccessibility() @@ -741,10 +741,11 @@ class QgsGeometry * 1 if geometry is not of polygon type, * 2 if avoid intersection would change the geometry type, * 3 other error during intersection removal + * @param avoidIntersectionsLayers list of layers to check for intersections * @param ignoreFeatures possibility to give a list of features where intersections should be ignored (not available in python bindings) * @note added in 1.5 */ - int avoidIntersections(); + int avoidIntersections( const QList& avoidIntersectionsLayers ); class Error { @@ -892,7 +893,7 @@ class QgsGeometry * @param iterations number of smoothing iterations to run. More iterations results * in a smoother geometry * @param offset fraction of line to create new vertices along, between 0 and 1.0 - * eg the default value of 0.25 will create new vertices 25% and 75% along each line segment + * For example, the default value of 0.25 will create new vertices 25% and 75% along each line segment * of the geometry for each iteration. Smaller values result in "tighter" smoothing. * @param minimumDistance minimum segment length to apply smoothing to * @param maxAngle maximum angle at node (0-180) at which smoothing will be applied diff --git a/python/core/geometry/qgspointv2.sip b/python/core/geometry/qgspointv2.sip index b858efbcf91..ec86363b4c8 100644 --- a/python/core/geometry/qgspointv2.sip +++ b/python/core/geometry/qgspointv2.sip @@ -25,7 +25,7 @@ class QgsPointV2: public QgsAbstractGeometry */ explicit QgsPointV2( QPointF p ); - /** Construct a point with a specified type (eg PointZ, PointM) and initial x, y, z, and m values. + /** Construct a point with a specified type (e.g., PointZ, PointM) and initial x, y, z, and m values. * @param type point type * @param x x-coordinate of point * @param y y-coordinate of point @@ -140,8 +140,8 @@ class QgsPointV2: public QgsAbstractGeometry /** * Returns the distance between this point and a specified x, y coordinate. In certain - * cases it may be more appropriate to call the faster distanceSquared() method, eg - * when comparing distances. + * cases it may be more appropriate to call the faster distanceSquared() method, + * e.g., when comparing distances. * @note added in QGIS 3.0 * @see distanceSquared() */ @@ -149,8 +149,8 @@ class QgsPointV2: public QgsAbstractGeometry /** * Returns the 2D distance between this point and another point. In certain - * cases it may be more appropriate to call the faster distanceSquared() method, eg - * when comparing distances. + * cases it may be more appropriate to call the faster distanceSquared() method, + * e.g., when comparing distances. * @note added in QGIS 3.0 */ double distance( const QgsPointV2& other ) const; diff --git a/python/core/geometry/qgswkbtypes.sip b/python/core/geometry/qgswkbtypes.sip index 03ebdb0c101..cdee98bb23b 100644 --- a/python/core/geometry/qgswkbtypes.sip +++ b/python/core/geometry/qgswkbtypes.sip @@ -75,14 +75,14 @@ class QgsWkbTypes NullGeometry }; - /** Returns the single type for a WKB type. Eg, for MultiPolygon WKB types the single type would be Polygon. + /** Returns the single type for a WKB type. For example, for MultiPolygon WKB types the single type would be Polygon. * @see isSingleType() * @see multiType() * @see flatType() */ static Type singleType( Type type ); - /** Returns the multi type for a WKB type. Eg, for Polygon WKB types the multi type would be MultiPolygon. + /** Returns the multi type for a WKB type. For example, for Polygon WKB types the multi type would be MultiPolygon. * @see isMultiType() * @see singleType() * @see flatType() @@ -90,7 +90,7 @@ class QgsWkbTypes static Type multiType( Type type ); /** Returns the flat type for a WKB type. This is the WKB type minus any Z or M dimensions. - * Eg, for PolygonZM WKB types the single type would be Polygon. + * For example, for PolygonZM WKB types the single type would be Polygon. * @see singleType() * @see multiType() */ @@ -137,12 +137,12 @@ class QgsWkbTypes */ static int coordDimensions( Type type ); - /** Returns the geometry type for a WKB type, eg both MultiPolygon and CurvePolygon would have a + /** Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a * PolygonGeometry geometry type. */ static GeometryType geometryType( Type type ); - /** Returns a display string type for a WKB type, eg the geometry name used in WKT geometry representations. + /** Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representations. */ static QString displayString( Type type ); diff --git a/python/core/gps/qgsgpsconnectionregistry.sip b/python/core/gps/qgsgpsconnectionregistry.sip index 947a7d52721..ec9ed67bedd 100644 --- a/python/core/gps/qgsgpsconnectionregistry.sip +++ b/python/core/gps/qgsgpsconnectionregistry.sip @@ -6,7 +6,7 @@ class QgsGPSConnectionRegistry #include %End public: - static QgsGPSConnectionRegistry* instance(); + QgsGPSConnectionRegistry(); ~QgsGPSConnectionRegistry(); /** Inserts a connection into the registry. The connection is owned by the registry class until it is unregistered again*/ @@ -16,9 +16,6 @@ class QgsGPSConnectionRegistry QList< QgsGPSConnection *> connectionList() const; - protected: - QgsGPSConnectionRegistry(); - private: QgsGPSConnectionRegistry( const QgsGPSConnectionRegistry& rh ); diff --git a/python/core/layertree/qgslayertreegroup.sip b/python/core/layertree/qgslayertreegroup.sip index 5784c7025b5..e1659407010 100644 --- a/python/core/layertree/qgslayertreegroup.sip +++ b/python/core/layertree/qgslayertreegroup.sip @@ -71,11 +71,6 @@ class QgsLayerTreeGroup : QgsLayerTreeNode //! Return a clone of the group. The children are cloned too. virtual QgsLayerTreeGroup* clone() const /Factory/; - //! Return the check state of the group node - Qt::CheckState isVisible() const; - //! Set check state of the group node - will also update children - void setVisible( Qt::CheckState state ); - //! Return whether the group is mutually exclusive (only one child can be checked at a time) //! @note added in 2.12 bool isMutuallyExclusive() const; @@ -86,14 +81,10 @@ class QgsLayerTreeGroup : QgsLayerTreeNode void setIsMutuallyExclusive( bool enabled, int initialChildIndex = -1 ); protected slots: - void layerDestroyed(); void nodeVisibilityChanged( QgsLayerTreeNode* node ); protected: - //! Set check state of this group from its children - void updateVisibilityFromChildren(); - //! Set check state of children (when this group's check state changes) - if not mutually exclusive - void updateChildVisibility(); + //! Set check state of children - if mutually exclusive void updateChildVisibilityMutuallyExclusive(); diff --git a/python/core/layertree/qgslayertreelayer.sip b/python/core/layertree/qgslayertreelayer.sip index 944ab65c4bc..058a85c036c 100644 --- a/python/core/layertree/qgslayertreelayer.sip +++ b/python/core/layertree/qgslayertreelayer.sip @@ -38,9 +38,6 @@ class QgsLayerTreeLayer : QgsLayerTreeNode //! @note added in 3.0 void setName( const QString& n ); - Qt::CheckState isVisible() const; - void setVisible( Qt::CheckState visible ); - static QgsLayerTreeLayer* readXml( QDomElement& element ) /Factory/; virtual void writeXml( QDomElement& parentElement ); diff --git a/python/core/layertree/qgslayertreemodel.sip b/python/core/layertree/qgslayertreemodel.sip index 7f8ac99b1bc..bab15b39367 100644 --- a/python/core/layertree/qgslayertreemodel.sip +++ b/python/core/layertree/qgslayertreemodel.sip @@ -61,6 +61,7 @@ class QgsLayerTreeModel : QAbstractItemModel AllowNodeRename, //!< Allow renaming of groups and layers AllowNodeChangeVisibility, //!< Allow user to set node visibility with a check box AllowLegendChangeState, //!< Allow check boxes for legend nodes (if supported by layer's legend) + ActionHierarchical, //!< Check/uncheck action has consequences on children (or parents for leaf node) }; typedef QFlags Flags; diff --git a/python/core/layertree/qgslayertreenode.sip b/python/core/layertree/qgslayertreenode.sip index dd8bc08956a..620c7389a1e 100644 --- a/python/core/layertree/qgslayertreenode.sip +++ b/python/core/layertree/qgslayertreenode.sip @@ -94,6 +94,34 @@ class QgsLayerTreeNode : QObject //! Create a copy of the node. Returns new instance virtual QgsLayerTreeNode *clone() const = 0 /Factory/; + //! Returns whether a node is really visible (ie checked and all its ancestors checked as well) + //! @note added in 3.0 + bool isVisible() const; + + //! Returns whether a node is checked (independantly of its ancestors or children) + //! @note added in 3.0 + bool itemVisibilityChecked() const; + + //! Check or uncheck a node (independantly of its ancestors or children) + //! @note added in 3.0 + void setItemVisibilityChecked( bool checked ); + + //! Check or uncheck a node and all its children (taking into account exclusion rules) + //! @note added in 3.0 + virtual void setItemVisibilityCheckedRecursive( bool checked ); + + //! Check or uncheck a node and all its parents + //! @note added in 3.0 + void setItemVisibilityCheckedParentRecursive( bool checked ); + + //! Return whether this node is checked and all its children. + //! @note added in 3.0 + bool isItemVisibilityCheckedRecursive() const; + + //! Return whether this node is unchecked and all its children. + //! @note added in 3.0 + bool isItemVisibilityUncheckedRecursive() const; + //! Return whether the node should be shown as expanded or collapsed in GUI bool isExpanded() const; //! Set whether the node should be shown as expanded or collapsed in GUI @@ -121,7 +149,7 @@ class QgsLayerTreeNode : QObject //! Emitted when one or more nodes has been removed from a node within the tree void removedChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo ); //! Emitted when check state of a node within the tree has been changed - void visibilityChanged( QgsLayerTreeNode *node, Qt::CheckState state ); + void visibilityChanged( QgsLayerTreeNode *node ); //! Emitted when a custom property of a node within the tree has been changed or removed void customPropertyChanged( QgsLayerTreeNode *node, const QString& key ); //! Emitted when the collapsed/expanded state of a node within the tree has been changed diff --git a/python/core/qgis.sip b/python/core/qgis.sip index bba97ecac7c..e7523b616cf 100644 --- a/python/core/qgis.sip +++ b/python/core/qgis.sip @@ -104,7 +104,7 @@ class Qgis static double SCALE_PRECISION; }; -/** Converts a string to a double in a permissive way, eg allowing for incorrect +/** Converts a string to a double in a permissive way, e.g., allowing for incorrect * numbers of digits between thousand separators * @param string string to convert * @param ok will be set to true if conversion was successful @@ -114,7 +114,7 @@ class Qgis */ double qgsPermissiveToDouble( QString string, bool& ok ); -/** Converts a string to an integer in a permissive way, eg allowing for incorrect +/** Converts a string to an integer in a permissive way, e.g., allowing for incorrect * numbers of digits between thousand separators * @param string string to convert * @param ok will be set to true if conversion was successful diff --git a/python/core/qgsapplication.sip b/python/core/qgsapplication.sip index 4d31ac1f077..9b08c802a1f 100644 --- a/python/core/qgsapplication.sip +++ b/python/core/qgsapplication.sip @@ -248,7 +248,7 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv) */ static QString osName(); - /** Returns the QGIS platform name, eg "desktop" or "server". + /** Returns the QGIS platform name, e.g., "desktop" or "server". * @note added in QGIS 2.14 * @see osName() */ @@ -381,6 +381,62 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv) */ static QgsTaskManager* taskManager(); + /** + * Returns the application's color scheme registry, used for managing color schemes. + * @note added in QGIS 3.0 + */ + static QgsColorSchemeRegistry* colorSchemeRegistry(); + + /** + * Returns the application's paint effect registry, used for managing paint effects. + * @note added in QGIS 3.0 + */ + static QgsPaintEffectRegistry* paintEffectRegistry(); + + /** + * Returns the application's renderer registry, used for managing vector layer renderers. + * @note added in QGIS 3.0 + */ + static QgsRendererRegistry* rendererRegistry(); + + /** + * Returns the application's data item provider registry, which keeps a list of data item + * providers that may add items to the browser tree. + * @note added in QGIS 3.0 + */ + static QgsDataItemProviderRegistry* dataItemProviderRegistry(); + + /** + * Returns the application's SVG cache, used for caching SVG images and handling parameter replacement + * within SVG files. + * @note added in QGIS 3.0 + */ + static QgsSvgCache* svgCache(); + + /** + * Returns the application's symbol layer registry, used for managing symbol layers. + * @note added in QGIS 3.0 + */ + static QgsSymbolLayerRegistry* symbolLayerRegistry(); + + /** + * Returns the application's GPS connection registry, used for managing GPS connections. + * @note added in QGIS 3.0 + */ + static QgsGPSConnectionRegistry* gpsConnectionRegistry(); + + /** + * Returns the application's plugin layer registry, used for managing plugin layer types. + * @note added in QGIS 3.0 + */ + static QgsPluginLayerRegistry* pluginLayerRegistry(); + + /** + * Returns the application's message log. + * @note added in QGIS 3.0 + */ + static QgsMessageLog* messageLog(); + %If(ANDROID) //dummy method to workaround sip generation issue issue bool x11EventFilter ( XEvent * event ); @@ -406,24 +462,13 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv) static QgsFieldFormatterRegistry* fieldFormatterRegistry(); static QString nullRepresentation(); static void setNullRepresentation( const QString& nullRepresentation ); - public slots: - - /** Causes the application instance to emit the settingsChanged() signal. This should - * be called whenever global, application-wide settings are altered to advise listeners - * that they may need to update their state. - * @see settingsChanged() - * @note added in QGIS 3.0 - */ - void emitSettingsChanged(); - + static QVariantMap customVariables(); + static void setCustomVariables( const QVariantMap& customVariables ); + static void setCustomVariable( const QString& name, const QVariant& value ); signals: //! @note not available in python bindings // void preNotify( QObject * receiver, QEvent * event, bool * done ); - /** Emitted whenever any global, application-wide settings are changed. - * @note added in QGIS 3.0 - * @see emitSettingsChanged() - */ - void settingsChanged(); + void customVariablesChanged(); void nullRepresentationChanged(); }; diff --git a/python/core/qgscolorramp.sip b/python/core/qgscolorramp.sip index a47ea78199e..b69acd30704 100644 --- a/python/core/qgscolorramp.sip +++ b/python/core/qgscolorramp.sip @@ -183,12 +183,12 @@ class QgsGradientColorRamp : QgsColorRamp */ QgsGradientStopsList stops() const; - /** Returns any additional info attached to the gradient ramp (eg authorship notes) + /** Returns any additional info attached to the gradient ramp (e.g., authorship notes) * @see setInfo() */ QgsStringMap info() const; - /** Sets additional info to attach to the gradient ramp (eg authorship notes) + /** Sets additional info to attach to the gradient ramp (e.g., authorship notes) * @param info map of string info to attach * @see info() */ diff --git a/python/core/qgscolorschemeregistry.sip b/python/core/qgscolorschemeregistry.sip index d1b70c8a4f3..bd15d0d8f4b 100644 --- a/python/core/qgscolorschemeregistry.sip +++ b/python/core/qgscolorschemeregistry.sip @@ -14,10 +14,6 @@ class QgsColorSchemeRegistry %End public: - /** Returns the global instance pointer, creating the object on the first call. - */ - static QgsColorSchemeRegistry * instance(); - /** Constructor for an empty color scheme registry */ QgsColorSchemeRegistry(); diff --git a/python/core/qgscoordinatereferencesystem.sip b/python/core/qgscoordinatereferencesystem.sip index 8173e47bc30..e8d551ab32d 100644 --- a/python/core/qgscoordinatereferencesystem.sip +++ b/python/core/qgscoordinatereferencesystem.sip @@ -129,9 +129,9 @@ * Caveats * ======= * - * There are two different flavours of WKT: one is defined by OGC, the other is the standard + * There are two different flavors of WKT: one is defined by OGC, the other is the standard * used by ESRI. They look very similar, but they are not the same. QGIS is able to consume - * both flavours. + * both flavors. * * \see QgsCoordinateTransform */ @@ -186,7 +186,7 @@ class QgsCoordinateReferenceSystem // static creators /** Creates a CRS from a given OGC WMS-format Coordinate Reference System string. - * @param ogcCrs OGR compliant CRS definition, eg "EPSG:4326" + * @param ogcCrs OGR compliant CRS definition, e.g., "EPSG:4326" * @returns matching CRS, or an invalid CRS if string could not be matched * @note added in QGIS 3.0 * @see createFromOgcWmsCrs() @@ -416,9 +416,9 @@ class QgsCoordinateReferenceSystem /** Returns the authority identifier for the CRS. * - * The identifier includes both the authority (eg EPSG) and the CRS number (eg 4326). + * The identifier includes both the authority (e.g., EPSG) and the CRS number (e.g., 4326). * This is the best method to use when showing a very short CRS identifier to a user, - * eg "EPSG:4326". + * e.g., "EPSG:4326". * * If CRS object is a custom CRS (not found in database), the method will return * internal QGIS CRS ID with "QGIS" authority, for example "QGIS:100005" @@ -427,7 +427,7 @@ class QgsCoordinateReferenceSystem */ QString authid() const; - /** Returns the descriptive name of the CRS, eg "WGS 84" or "GDA 94 / Vicgrid94". In most + /** Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94". In most * cases this is the best method to use when showing a friendly identifier for the CRS to a * user. * @returns descriptive name of the CRS @@ -472,7 +472,7 @@ class QgsCoordinateReferenceSystem */ bool isGeographic() const; - /** Returns whether axis is inverted (eg. for WMS 1.3) for the CRS. + /** Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS. * @returns true if CRS axis is inverted */ bool hasAxisInverted() const; diff --git a/python/core/qgsdataitemproviderregistry.sip b/python/core/qgsdataitemproviderregistry.sip index 28e087ac879..419beb421de 100644 --- a/python/core/qgsdataitemproviderregistry.sip +++ b/python/core/qgsdataitemproviderregistry.sip @@ -11,8 +11,7 @@ class QgsDataItemProviderRegistry #include %End public: - static QgsDataItemProviderRegistry * instance(); - + QgsDataItemProviderRegistry(); ~QgsDataItemProviderRegistry(); //! Get list of available providers @@ -25,7 +24,7 @@ class QgsDataItemProviderRegistry void removeProvider( QgsDataItemProvider* provider ); private: - QgsDataItemProviderRegistry(); + QgsDataItemProviderRegistry( const QgsDataItemProviderRegistry& rh ); }; diff --git a/python/core/qgsdatetimestatisticalsummary.sip b/python/core/qgsdatetimestatisticalsummary.sip index 23cb010e56d..a98ac561f70 100644 --- a/python/core/qgsdatetimestatisticalsummary.sip +++ b/python/core/qgsdatetimestatisticalsummary.sip @@ -37,13 +37,13 @@ class QgsDateTimeStatisticalSummary QgsDateTimeStatisticalSummary( QgsDateTimeStatisticalSummary::Statistics stats = All ); /** Returns flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg count). + * are always calculated (e.g., count). * @see setStatistics */ Statistics statistics() const; /** Sets flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg count). + * are always calculated (e.g., count). * @param stats flags for statistics to calculate * @see statistics */ diff --git a/python/core/qgsdiagramrenderer.sip b/python/core/qgsdiagramrenderer.sip index d803ab1a9cb..47fe2966e48 100644 --- a/python/core/qgsdiagramrenderer.sip +++ b/python/core/qgsdiagramrenderer.sip @@ -25,13 +25,14 @@ class QgsDiagramLayerSettings }; //! Line placement flags for controlling line based placements - enum LinePlacementFlags + enum LinePlacementFlag { OnLine, AboveLine, BelowLine, MapOrientation, }; + typedef QFlags LinePlacementFlags; QgsDiagramLayerSettings(); @@ -44,8 +45,7 @@ class QgsDiagramLayerSettings * @see setPlacement() * @note added in QGIS 2.16 */ - //TODO QGIS 3.0 - rename getter to placement() - Placement getPlacement() const; + Placement placement() const; /** Sets the diagram placement. * @param value placement value @@ -54,16 +54,12 @@ class QgsDiagramLayerSettings */ void setPlacement( Placement value ); - //! Diagram placement - //TODO QGIS 3.0 - make private, rename to mPlacement - Placement placement; - /** Returns the diagram placement flags. These are only used if the diagram placement * is set to a line type. * @see setLinePlacementFlags() * @note added in QGIS 2.16 */ - unsigned int linePlacementFlags() const; + LinePlacementFlags linePlacementFlags() const; /** Sets the the diagram placement flags. These are only used if the diagram placement * is set to a line type. @@ -71,11 +67,7 @@ class QgsDiagramLayerSettings * @see getPlacement() * @note added in QGIS 2.16 */ - void setLinePlacementFlags( unsigned int flags ); - - //! Diagram placement flags - // TODO QGIS 3.0 - make private, rename to mPlacementFlags, use QFlags - unsigned int placementFlags; + void setLinePlacementFlags( LinePlacementFlags flags ); /** Returns the diagram priority. * @returns diagram priority, where 0 = low and 10 = high @@ -84,8 +76,7 @@ class QgsDiagramLayerSettings * @see setPriority() * @note added in QGIS 2.16 */ - //TODO QGIS 3.0 - rename getter to priority() - int getPriority() const; + int priority() const; /** Sets the diagram priority. * @param value priority, where 0 = low and 10 = high @@ -94,12 +85,6 @@ class QgsDiagramLayerSettings */ void setPriority( int value ); - //! Placement priority, where 0 = low and 10 = high - //! @note placement priority is shared with labeling, so diagrams with a high priority may displace labels - //! and vice-versa - // TODO QGIS 3.0 - make private, rename to mPriority - int priority; - /** Returns the diagram z-index. Diagrams (or labels) with a higher z-index are drawn over diagrams * with a lower z-index. * @note z-index ordering is shared with labeling, so diagrams with a high z-index may be drawn over labels @@ -107,8 +92,7 @@ class QgsDiagramLayerSettings * @see setZIndex() * @note added in QGIS 2.16 */ - //TODO QGIS 3.0 - rename getter to zIndex() - double getZIndex() const; + double zIndex() const; /** Sets the diagram z-index. Diagrams (or labels) with a higher z-index are drawn over diagrams * with a lower z-index. @@ -118,10 +102,6 @@ class QgsDiagramLayerSettings */ void setZIndex( double index ); - //! Z-index of diagrams, where diagrams with a higher z-index are drawn on top of diagrams with a lower z-index - // TODO QGIS 3.0 - rename to mZIndex, make private - double zIndex; - /** Returns whether the feature associated with a diagram acts as an obstacle for other labels or diagrams. * @see setIsObstacle() * @note added in QGIS 2.16 @@ -135,10 +115,6 @@ class QgsDiagramLayerSettings */ void setIsObstacle( bool isObstacle ); - //! Whether associated feature acts as an obstacle for other labels or diagrams - // TODO QGIS 3.0 - rename to mObstacle, make private - bool obstacle; - /** Returns the distance between the diagram and the feature (in mm). * @see setDistance() * @note added in QGIS 2.16 @@ -152,35 +128,25 @@ class QgsDiagramLayerSettings */ void setDistance( double distance ); - //! Distance between diagram and the feature (in mm) - // TODO QGIS 3.0 - make private, rename to mDistance - double dist; + /** Returns the diagram renderer associated with the layer. + * @see setRenderer() + * @note added in QGIS 2.16 + */ + QgsDiagramRenderer* renderer(); /** Returns the diagram renderer associated with the layer. * @see setRenderer() * @note added in QGIS 2.16 */ - // TODO QGIS 3.0 - rename to renderer() - QgsDiagramRenderer* getRenderer(); - - /** Returns the diagram renderer associated with the layer. - * @see setRenderer() - * @note added in QGIS 2.16 - */ - // TODO QGIS 3.0 - rename to renderer() - //const QgsDiagramRenderer* getRenderer() const; + //const QgsDiagramRenderer* renderer() const; /** Sets the diagram renderer associated with the layer. * @param diagramRenderer diagram renderer. Ownership is transferred to the object. - * @see getRenderer() + * @see renderer() * @note added in QGIS 2.16 */ void setRenderer( QgsDiagramRenderer* diagramRenderer /Transfer/ ); - //! Associated diagram renderer. Owned by this object. - // TODO QGIS 3.0 - make private, rename to mRenderer - QgsDiagramRenderer* renderer; - /** Returns the coordinate transform associated with the layer, or an * invalid transform if no transformation is required. * @see setCoordinateTransform() @@ -214,10 +180,6 @@ class QgsDiagramLayerSettings */ void setShowAllDiagrams( bool showAllDiagrams ); - //! Whether to show all diagrams, including overlapping diagrams - // TODO QGIS 3.0 - make private, rename to mShowAll - bool showAll; - void readXml( const QDomElement& elem, const QgsVectorLayer* layer ); void writeXml( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const; @@ -329,8 +291,8 @@ class QgsDiagramInterpolationSettings QSizeF upperSize; double lowerValue; double upperValue; - /** Index of the classification attribute*/ - int classificationAttribute; + //! Name of the field for classification + QString classificationField; QString classificationAttributeExpression; bool classificationAttributeIsExpression; }; @@ -368,8 +330,7 @@ class QgsDiagramRenderer * @param fields layer fields * @note added in QGIS 2.16 */ - //TODO QGIS 3.0 - remove need for fields parameter - virtual QSet< QString > referencedFields( const QgsExpressionContext& context = QgsExpressionContext(), const QgsFields& fields = QgsFields() ) const; + virtual QSet< QString > referencedFields( const QgsExpressionContext& context = QgsExpressionContext() ) const; void renderDiagram( const QgsFeature& feature, QgsRenderContext& c, QPointF pos ); @@ -511,7 +472,7 @@ class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRenderer QList diagramAttributes() const; - virtual QSet< QString > referencedFields( const QgsExpressionContext& context = QgsExpressionContext(), const QgsFields& fields = QgsFields() ) const; + virtual QSet< QString > referencedFields( const QgsExpressionContext& context = QgsExpressionContext() ) const; QString rendererName() const; @@ -527,8 +488,19 @@ class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRenderer void setUpperSize( QSizeF s ); QSizeF upperSize() const; - int classificationAttribute() const; - void setClassificationAttribute( int index ); + /** + * Returns the field name used for interpolating the diagram size. + * @see setClassificationField() + * @note added in QGIS 3.0 + */ + QString classificationField() const; + + /** + * Sets the field name used for interpolating the diagram size. + * @see classificationField() + * @note added in QGIS 3.0 + */ + void setClassificationField( const QString& field ); QString classificationAttributeExpression() const; void setClassificationAttributeExpression( const QString& expression ); diff --git a/python/core/qgsdistancearea.sip b/python/core/qgsdistancearea.sip index 75de9cfded7..e20b580f578 100644 --- a/python/core/qgsdistancearea.sip +++ b/python/core/qgsdistancearea.sip @@ -167,7 +167,7 @@ class QgsDistanceArea * @param distance distance to format * @param decimals number of decimal places to show * @param unit unit of distance - * @param keepBaseUnit set to false to allow conversion of large distances to more suitable units, eg meters to + * @param keepBaseUnit set to false to allow conversion of large distances to more suitable units, e.g., meters to * kilometers * @returns formatted distance string * @note added in QGIS 2.16 @@ -179,7 +179,7 @@ class QgsDistanceArea * @param area area to format * @param decimals number of decimal places to show * @param unit unit of area - * @param keepBaseUnit set to false to allow conversion of large areas to more suitable units, eg square meters to + * @param keepBaseUnit set to false to allow conversion of large areas to more suitable units, e.g., square meters to * square kilometers * @returns formatted area string * @note added in QGIS 2.14 diff --git a/python/core/qgsexpression.sip b/python/core/qgsexpression.sip index e69086ad51e..2d904b1f8c2 100644 --- a/python/core/qgsexpression.sip +++ b/python/core/qgsexpression.sip @@ -140,21 +140,21 @@ class QgsExpression */ void setGeomCalculator( const QgsDistanceArea* calc ); - /** Returns the desired distance units for calculations involving geomCalculator(), eg "$length" and "$perimeter". + /** Returns the desired distance units for calculations involving geomCalculator(), e.g., "$length" and "$perimeter". * @note distances are only converted when a geomCalculator() has been set * @note added in QGIS 2.14 * @see setDistanceUnits() */ QgsUnitTypes::DistanceUnit distanceUnits() const; - /** Sets the desired distance units for calculations involving geomCalculator(), eg "$length" and "$perimeter". + /** Sets the desired distance units for calculations involving geomCalculator(), e.g., "$length" and "$perimeter". * @note distances are only converted when a geomCalculator() has been set * @note added in QGIS 2.14 * @see distanceUnits() */ void setDistanceUnits( QgsUnitTypes::DistanceUnit unit ); - /** Returns the desired areal units for calculations involving geomCalculator(), eg "$area". + /** Returns the desired areal units for calculations involving geomCalculator(), e.g., "$area". * @note areas are only converted when a geomCalculator() has been set * @note added in QGIS 2.14 * @see setAreaUnits() @@ -162,7 +162,7 @@ class QgsExpression */ QgsUnitTypes::AreaUnit areaUnits() const; - /** Sets the desired areal units for calculations involving geomCalculator(), eg "$area". + /** Sets the desired areal units for calculations involving geomCalculator(), e.g., "$area". * @note areas are only converted when a geomCalculator() has been set * @note added in QGIS 2.14 * @see areaUnits() @@ -362,7 +362,7 @@ class QgsExpression virtual bool usesGeometry( const QgsExpression::NodeFunction* node ) const; /** Returns a list of possible aliases for the function. These include - * other permissible names for the function, eg deprecated names. + * other permissible names for the function, e.g., deprecated names. * @return list of known aliases * @note added in QGIS 2.9 */ @@ -835,7 +835,7 @@ class QgsExpression static QString group( const QString& group ); /** Formats an expression result for friendly display to the user. Truncates the result to a sensible - * length, and presents text representations of non numeric/text types (eg geometries and features). + * length, and presents text representations of non numeric/text types (e.g., geometries and features). * @param value expression result to format * @returns formatted string, may contain HTML formatting characters * @note added in QGIS 2.14 diff --git a/python/core/qgsexpressioncontext.sip b/python/core/qgsexpressioncontext.sip index 8aece97fac6..538dfadbddd 100644 --- a/python/core/qgsexpressioncontext.sip +++ b/python/core/qgsexpressioncontext.sip @@ -217,6 +217,12 @@ class QgsExpressionContext QgsExpressionContext(); + /** Initializes the context with given list of scopes. + * Ownership of the scopes is transferred to the stack. + * @note added in QGIS 3.0 + */ + explicit QgsExpressionContext( const QList& scopes /Transfer/ ); + /** Copy constructor */ QgsExpressionContext( const QgsExpressionContext& other ); @@ -359,6 +365,14 @@ class QgsExpressionContext */ void appendScope( QgsExpressionContextScope* scope /Transfer/ ); + /** Appends a list of scopes to the end of the context. This scopes will override + * any matching variables or functions provided by existing scopes within the + * context. Ownership of the scopes is transferred to the stack. + * @param scopes scopes to append to context + * @note added in QGIS 3.0 + */ + void appendScopes( const QList& scopes /Transfer/ ); + /** * Removes the last scope from the expression context and return it. */ @@ -466,7 +480,7 @@ class QgsExpressionContext /** \ingroup core * \class QgsExpressionContextUtils * \brief Contains utilities for working with QgsExpressionContext objects, including methods - * for creating scopes for specific uses (eg project scopes, layer scopes). + * for creating scopes for specific uses (e.g., project scopes, layer scopes). * \note added in QGIS 2.12 */ @@ -482,52 +496,22 @@ class QgsExpressionContextUtils * @see setGlobalVariable() */ static QgsExpressionContextScope* globalScope() /Factory/; - - /** Sets a global context variable. This variable will be contained within scopes retrieved via - * globalScope(). - * @param name variable name - * @param value variable value - * @see setGlobalVariable() - * @see globalScope() - */ static void setGlobalVariable( const QString& name, const QVariant& value ); - - /** Sets all global context variables. Existing global variables will be removed and replaced - * with the variables specified. - * @param variables new set of global variables - * @see setGlobalVariable() - * @see globalScope() - */ - static void setGlobalVariables( const QgsStringMap& variables ); - - /** Creates a new scope which contains variables and functions relating to the current QGIS project. - * For instance, project path and title, and variables specified through the project properties. - * @see setProjectVariable() - */ - static QgsExpressionContextScope* projectScope() /Factory/; - - /** Sets a project context variable. This variable will be contained within scopes retrieved via - * projectScope(). - * @param name variable name - * @param value variable value - * @see setProjectVariables() - * @see projectScope() - */ - static void setProjectVariable( const QString& name, const QVariant& value ); - - /** Sets all project context variables. Existing project variables will be removed and replaced - * with the variables specified. - * @param variables new set of project variables - * @see setProjectVariable() - * @see projectScope() - */ - static void setProjectVariables( const QgsStringMap& variables ); + static void setGlobalVariables( const QVariantMap& variables ); + static QgsExpressionContextScope* projectScope( const QgsProject* project ) /Factory/; + static void setProjectVariable( QgsProject* project, const QString& name, const QVariant& value ); + static void setProjectVariables( QgsProject* project, const QVariantMap& variables ); /** Creates a new scope which contains variables and functions relating to a QgsMapLayer. * For instance, layer name, id and fields. */ static QgsExpressionContextScope* layerScope( const QgsMapLayer *layer ) /Factory/; + /** Creates a list of three scopes: global, layer's project and layer. + * @note added in QGIS 3.0 + */ + static QList globalProjectLayerScopes( const QgsMapLayer* layer ) /Factory/; + /** Sets a layer context variable. This variable will be contained within scopes retrieved via * layerScope(). * @param layer map layer @@ -537,15 +521,7 @@ class QgsExpressionContextUtils * @see layerScope() */ static void setLayerVariable( QgsMapLayer* layer, const QString& name, const QVariant& value ); - - /** Sets all layer context variables. Existing layer variables will be removed and replaced - * with the variables specified. - * @param layer map layer - * @param variables new set of layer variables - * @see setLayerVariable() - * @see layerScope() - */ - static void setLayerVariables( QgsMapLayer* layer, const QgsStringMap& variables ); + static void setLayerVariables( QgsMapLayer* layer, const QVariantMap& variables ); /** Creates a new scope which contains variables and functions relating to a QgsMapSettings object. * For instance, map scale and rotation. @@ -575,26 +551,8 @@ class QgsExpressionContextUtils * @see compositionScope() */ static void setCompositionVariable( QgsComposition* composition, const QString& name, const QVariant& value ); - - /** Sets all composition context variables. Existing composition variables will be removed and replaced - * with the variables specified. - * @param composition target composition - * @param variables new set of layer variables - * @see setCompositionVariable() - * @see compositionScope() - */ - static void setCompositionVariables( QgsComposition* composition, const QgsStringMap& variables ); - - /** Creates a new scope which contains variables and functions relating to a QgsAtlasComposition. - * For instance, current page name and number. - * @param atlas source atlas. If null, a set of default atlas variables will be added to the scope. - */ + static void setCompositionVariables( QgsComposition* composition, const QVariantMap& variables ); static QgsExpressionContextScope* atlasScope( const QgsAtlasComposition* atlas ) /Factory/; - - /** Creates a new scope which contains variables and functions relating to a QgsComposerItem. - * For instance, item size and position. - * @param composerItem source composer item - */ static QgsExpressionContextScope* composerItemScope( const QgsComposerItem *composerItem ) /Factory/; /** Sets a composer item context variable. This variable will be contained within scopes retrieved via @@ -606,20 +564,7 @@ class QgsExpressionContextUtils * @see composerItemScope() */ static void setComposerItemVariable( QgsComposerItem* composerItem, const QString& name, const QVariant& value ); - - /** Sets all composition context variables. Existing compositoin variables will be removed and replaced - * with the variables specified. - * @param composerItem target composer item - * @param variables new set of layer variables - * @see setComposerItemVariable() - * @see composerItemScope() - */ - static void setComposerItemVariables( QgsComposerItem* composerItem, const QgsStringMap& variables ); - - /** Helper function for creating an expression context which contains just a feature and fields - * collection. Generally this method should not be used as the created context does not include - * standard scopes such as the global and project scopes. - */ + static void setComposerItemVariables( QgsComposerItem* composerItem, const QVariantMap& variables ); static QgsExpressionContext createFeatureBasedContext( const QgsFeature& feature, const QgsFields& fields ); /** Registers all known core functions provided by QgsExpressionContextScope objects. diff --git a/python/core/qgsfield.sip b/python/core/qgsfield.sip index 564860805ed..bd8fa596a47 100644 --- a/python/core/qgsfield.sip +++ b/python/core/qgsfield.sip @@ -18,12 +18,12 @@ class QgsField /** Constructor. Constructs a new QgsField object. * @param name Field name * @param type Field variant type, currently supported: String / Int / Double - * @param typeName Field type (eg. char, varchar, text, int, serial, double). + * @param typeName Field type (e.g., char, varchar, text, int, serial, double). * Field types are usually unique to the source and are stored exactly * as returned from the data store. * @param len Field length * @param prec Field precision. Usually decimal places but may also be - * used in conjunction with other fields types (eg. variable character fields) + * used in conjunction with other fields types (e.g., variable character fields) * @param comment Comment for the field * @param subType If the field is a collection, its element's type. When * all the elements don't need to have the same type, leave diff --git a/python/core/qgsfontutils.sip b/python/core/qgsfontutils.sip index 2bc1f7a9a7f..8cc07cda462 100644 --- a/python/core/qgsfontutils.sip +++ b/python/core/qgsfontutils.sip @@ -115,9 +115,9 @@ class QgsFontUtils * @param font QFont to convert * @param pointToPixelMultiplier scaling factor to apply to convert point sizes to pixel font sizes. * The CSS returned by this function will always use pixels for font sizes, so this parameter - * should be set to a suitable value to convert point sizes to pixels (eg taking into account + * should be set to a suitable value to convert point sizes to pixels (e.g., taking into account * desination DPI) - * @returns partial CSS string, eg "font-family: Comic Sans; font-size: 12px;" + * @returns partial CSS string, e.g., "font-family: Comic Sans; font-size: 12px;" * @note added in QGIS 2.16 */ static QString asCSS( const QFont& font, double pointToPixelMultiplier = 1.0 ); diff --git a/python/core/qgsmaplayer.sip b/python/core/qgsmaplayer.sip index 6c31d509ede..34350d8f7fb 100644 --- a/python/core/qgsmaplayer.sip +++ b/python/core/qgsmaplayer.sip @@ -395,8 +395,8 @@ class QgsMapLayer : QObject /** Sets layer's spatial reference system */ void setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSignal = true ); - /** A convenience function to (un)capitalise the layer name */ - static QString capitaliseLayerName( const QString& name ); + /** A convenience function to (un)capitalize the layer name */ + static QString capitalizeLayerName( const QString& name ); /** Retrieve the style URI for this layer * (either as a .qml file on disk or as a diff --git a/python/core/qgsmessagelog.sip b/python/core/qgsmessagelog.sip index 358800cb00e..52ab8d42718 100644 --- a/python/core/qgsmessagelog.sip +++ b/python/core/qgsmessagelog.sip @@ -5,7 +5,7 @@ class QgsMessageLog : QObject %End public: - static QgsMessageLog *instance(); + QgsMessageLog(); enum MessageLevel { @@ -20,8 +20,6 @@ class QgsMessageLog : QObject signals: void messageReceived( const QString& message, const QString& tag, MessageLevel level ); - private: - QgsMessageLog(); }; diff --git a/python/core/qgspallabeling.sip b/python/core/qgspallabeling.sip index ad52f0fcb06..b764c25ab1d 100644 --- a/python/core/qgspallabeling.sip +++ b/python/core/qgspallabeling.sip @@ -128,7 +128,7 @@ class QgsPalLayerSettings Curved, /** Arranges candidates following the curvature of a line feature. Applies to line layers only.*/ Horizontal, /**< Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only.*/ Free, /**< Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the polygon's orientation. Applies to polygon layers only.*/ - OrderedPositionsAroundPoint, /**< Candidates are placed in predefined positions around a point. Peference is given to positions with greatest cartographic appeal, eg top right, bottom right, etc. Applies to point layers only.*/ + OrderedPositionsAroundPoint, /**< Candidates are placed in predefined positions around a point. Preference is given to positions with greatest cartographic appeal, e.g., top right, bottom right, etc. Applies to point layers only.*/ PerimeterCurved, /** Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.*/ }; @@ -173,7 +173,7 @@ class QgsPalLayerSettings respects the direction of the line feature, so a line from right to left labels will have labels placed placed above the line feature. */ MapOrientation, /**< Signifies that the AboveLine and BelowLine flags should respect the map's orientation rather - than the feature's orientation. Eg, AboveLine will always result in label's being placed + than the feature's orientation. For example, AboveLine will always result in label's being placed above a line, regardless of the line's direction. */ }; @@ -209,7 +209,7 @@ class QgsPalLayerSettings MultiLeft, MultiCenter, MultiRight, - MultiFollowPlacement /*!< Alignment follows placement of label, eg labels to the left of a feature + MultiFollowPlacement /*!< Alignment follows placement of label, e.g., labels to the left of a feature will be drawn with right alignment*/ }; @@ -366,7 +366,7 @@ class QgsPalLayerSettings QString fieldName; - /** Is this label made from a expression string eg FieldName || 'mm' + /** Is this label made from a expression string, e.g., FieldName || 'mm' */ bool isExpression; @@ -408,7 +408,7 @@ class QgsPalLayerSettings bool centroidInside; // whether centroid-point calculated must be inside polygon /** Ordered list of predefined label positions for points. Positions earlier - * in the list will be prioritised over later positions. Only used when the placement + * in the list will be prioritized over later positions. Only used when the placement * is set to QgsPalLayerSettings::OrderedPositionsAroundPoint. * @note not available in Python bindings */ @@ -487,7 +487,7 @@ class QgsPalLayerSettings * @param labelFeature if using QgsLabelingEngine, this will receive the label feature. Not available * in Python bindings. * @param obstacleGeometry optional obstacle geometry, if a different geometry to the feature's geometry - * should be used as an obstacle for labels (eg, if the feature has been rendered with an offset point + * should be used as an obstacle for labels (e.g., if the feature has been rendered with an offset point * symbol, the obstacle geometry should represent the bounds of the offset symbol). If not set, * the feature's original geometry will be used as an obstacle for labels. Not available * in Python bindings. @@ -569,13 +569,13 @@ class QgsPalLayerSettings */ // QMap > dataDefinedNames() const; - /** Returns the label text formatting settings, eg font settings, buffer settings, etc. + /** Returns the label text formatting settings, e.g., font settings, buffer settings, etc. * @see setFormat() * @note added in QGIS 3.0 */ const QgsTextFormat& format() const; - /** Sets the label text formatting settings, eg font settings, buffer settings, etc. + /** Sets the label text formatting settings, e.g., font settings, buffer settings, etc. * @param format label text format * @see format() * @note added in QGIS 3.0 @@ -727,7 +727,7 @@ class QgsPalLabeling /** Splits a text string to a list of graphemes, which are the smallest allowable character * divisions in the string. This accounts for scripts were individual characters are not - * allowed to be split apart (eg Arabic and Indic based scripts) + * allowed to be split apart (e.g., Arabic and Indic based scripts) * @param text string to split * @returns list of graphemes * @note added in QGIS 2.10 diff --git a/python/core/qgspluginlayerregistry.sip b/python/core/qgspluginlayerregistry.sip index b33567dd96d..d1b6c004bca 100644 --- a/python/core/qgspluginlayerregistry.sip +++ b/python/core/qgspluginlayerregistry.sip @@ -37,8 +37,7 @@ class QgsPluginLayerRegistry public: - /** Means of accessing canonical single instance */ - static QgsPluginLayerRegistry* instance(); + QgsPluginLayerRegistry(); ~QgsPluginLayerRegistry(); @@ -62,8 +61,6 @@ class QgsPluginLayerRegistry private: - /** Private since instance() creates it */ - QgsPluginLayerRegistry(); QgsPluginLayerRegistry( const QgsPluginLayerRegistry& rh ); }; diff --git a/python/core/qgspoint.sip b/python/core/qgspoint.sip index f4f2dbeb805..7d2c3305877 100644 --- a/python/core/qgspoint.sip +++ b/python/core/qgspoint.sip @@ -185,10 +185,10 @@ class QgsPoint * Its up to the calling function to ensure that this point can * be meaningfully represented in this form. * @param thePrecision number of decimal points to use for seconds - * @param useSuffix set to true to include a direction suffix (eg 'N'), + * @param useSuffix set to true to include a direction suffix (e.g., 'N'), * set to false to use a "-" prefix for west and south coordinates * @param padded set to true to force minutes and seconds to use two decimals, - * eg, '05' instead of '5'. + * e.g., '05' instead of '5'. */ QString toDegreesMinutesSeconds( int thePrecision, const bool useSuffix = true, const bool padded = false ) const; @@ -196,10 +196,10 @@ class QgsPoint * Its up to the calling function to ensure that this point can * be meaningfully represented in this form. * @param thePrecision number of decimal points to use for minutes - * @param useSuffix set to true to include a direction suffix (eg 'N'), + * @param useSuffix set to true to include a direction suffix (e.g., 'N'), * set to false to use a "-" prefix for west and south coordinates * @param padded set to true to force minutes to use two decimals, - * eg, '05' instead of '5'. + * e.g., '05' instead of '5'. */ QString toDegreesMinutes( int thePrecision, const bool useSuffix = true, const bool padded = false ) const; diff --git a/python/core/qgsproject.sip b/python/core/qgsproject.sip index 118d370c010..324275cd0a6 100644 --- a/python/core/qgsproject.sip +++ b/python/core/qgsproject.sip @@ -86,7 +86,7 @@ class QgsProject : QObject, QgsExpressionContextGenerator void setCrs( const QgsCoordinateReferenceSystem& crs ); /** - * Returns a proj string representing the project's ellipsoid setting, eg "WGS84". + * Returns a proj string representing the project's ellipsoid setting, e.g., "WGS84". * @see setEllipsoid() * @see crs() * @note added in QGIS 2.18 @@ -94,7 +94,7 @@ class QgsProject : QObject, QgsExpressionContextGenerator QString ellipsoid() const; /** - * Sets the project's ellipsoid from a proj string representation, eg "WGS84". + * Sets the project's ellipsoid from a proj string representation, e.g., "WGS84". * @see ellipsoid() * @see setCrs() * @note added in QGIS 2.18 @@ -106,52 +106,37 @@ class QgsProject : QObject, QgsExpressionContextGenerator */ void clear(); - /** Reads a project file. - * @param file name of project file to read - * @note Any current plug-in state is erased - * @note Calling read() performs the following operations: - * - * - Gets the extents - * - Creates maplayers - * - Registers maplayers - * - * @note it's presumed that the caller has already reset the map canvas, map registry, and legend + /** Reads given project file from the given file. + * @param filename name of project file to read + * @returns true if project file has been read successfully */ - bool read( const QFileInfo& file ); + bool read( const QString& filename ); - /** Reads the current project file. - * @note Any current plug-in state is erased - * @note Calling read() performs the following operations: - * - * - Gets the extents - * - Creates maplayers - * - Registers maplayers - * - * @note it's presumed that the caller has already reset the map canvas, map registry, and legend + /** Reads the project from its currently associated file (see fileName() ). + * @returns true if project file has been read successfully */ bool read(); /** Reads the layer described in the associated DOM node. + * + * @note This method is mainly for use by QgsProjectBadLayerHandler subclasses + * that may fix definition of bad layers with the user's help in GUI. Calling + * this method with corrected DOM node adds the layer back to the project. * * @param layerNode represents a QgsProject DOM node that encodes a specific layer. - * - * QgsProject raises an exception when one of the QgsProject::read() - * implementations fails. Since the read()s are invoked from qgisapp, - * then qgisapp handles the exception. It prompts the user for the new - * location of the data, if any. If there is a new location, the DOM - * node associated with the layer has its datasource tag corrected. - * Then that node is passed to this member function to be re-opened. - * */ - bool read( QDomNode& layerNode ); + bool readLayer( const QDomNode& layerNode ); - /** Writes the project to a file. - * @param file destination file + /** + * Writes the project to a file. + * @param filename destination file * @note calling this implicitly sets the project's filename (see setFileName() ) * @note isDirty() will be set to false if project is successfully written * @returns true if project was written successfully + * + * \note Added in QGIS 3.0 */ - bool write( const QFileInfo& file ); + bool write( const QString& filename ); /** Writes the project to its current associated file (see fileName() ). * @note isDirty() will be set to false if project is successfully written @@ -411,33 +396,16 @@ class QgsProject : QObject, QgsExpressionContextGenerator * * @note Added in QGIS 3.0 */ - QStringList avoidIntersectionsList() const; + QList avoidIntersectionsLayers() const; /** * A list of layers with which intersections should be avoided. * * @note Added in QGIS 3.0 */ - void setAvoidIntersectionsList( const QStringList& avoidIntersectionsList ); - - /** - * A map of custom project variables. - * To get all available variables including generated ones - * use QgsExpressionContextUtils::projectScope() instead. - */ - QgsStringMap variables() const; - - /** - * A map of custom project variables. - * Be careful not to set generated variables. - */ - void setVariables( const QgsStringMap& variables ); - - // - // Functionality from QgsMapLayerRegistry - // - - //! Returns the number of registered layers. + void setAvoidIntersectionsLayers( const QList& layers ); + QVariantMap customVariables() const; + void setCustomVariables( const QVariantMap& customVariables ); int count() const; /** Retrieve a pointer to a registered layer by layer ID. @@ -660,7 +628,7 @@ class QgsProject : QObject, QgsExpressionContextGenerator /** Emitted whenever the expression variables stored in the project have been changed. * @note added in QGIS 3.0 */ - void variablesChanged(); + void customVariablesChanged(); /** * Emitted whenever a new transaction group has been created or a @@ -678,11 +646,11 @@ class QgsProject : QObject, QgsExpressionContextGenerator void topologicalEditingChanged(); /** - * Emitted whenever avoidIntersectionsList has changed. + * Emitted whenever avoidIntersectionsLayers has changed. * * @note Added in QGIS 3.0 */ - void avoidIntersectionsListChanged(); + void avoidIntersectionsLayersChanged(); /** * Emitted when the map theme collection changes. diff --git a/python/core/qgsprojectbadlayerhandler.sip b/python/core/qgsprojectbadlayerhandler.sip index da5de2bdc76..128cb4761be 100644 --- a/python/core/qgsprojectbadlayerhandler.sip +++ b/python/core/qgsprojectbadlayerhandler.sip @@ -32,7 +32,6 @@ class QgsProjectBadLayerHandler * log. * * @note Added in QGIS 3.0 - * @see QgsProjectBadLayerGuiHandler */ virtual void handleBadLayers( const QList& layers ); virtual ~QgsProjectBadLayerHandler(); diff --git a/python/core/qgsprojectproperty.sip b/python/core/qgsprojectproperty.sip index 3fe03c6efac..28159706efc 100644 --- a/python/core/qgsprojectproperty.sip +++ b/python/core/qgsprojectproperty.sip @@ -1,12 +1,12 @@ -class QgsProperty +class QgsProjectProperty { %TypeHeaderCode #include %End public: - QgsProperty(); - virtual ~QgsProperty(); + QgsProjectProperty(); + virtual ~QgsProjectProperty(); /** Dumps out the keys and values * @@ -34,7 +34,7 @@ class QgsProperty * * Used for restoring properties from project file */ - virtual bool readXml( QDomNode & keyNode ) = 0; + virtual bool readXml( const QDomNode& keyNode ) = 0; /** * adds property hierarchy to given Dom element @@ -63,16 +63,16 @@ class QgsProperty }; // class QgsProperty -class QgsPropertyValue : QgsProperty +class QgsProjectPropertyValue : QgsProjectProperty { %TypeHeaderCode #include %End public: - QgsPropertyValue(); - QgsPropertyValue( const QVariant &value ); - virtual ~QgsPropertyValue(); + QgsProjectPropertyValue(); + QgsProjectPropertyValue( const QVariant &value ); + virtual ~QgsProjectPropertyValue(); /** Returns true if is a QgsPropertyKey */ virtual bool isKey() const; @@ -91,30 +91,23 @@ class QgsPropertyValue : QgsProperty void dump( int tabs = 0 ) const; - bool readXml( QDomNode & keyNode ); + bool readXml( const QDomNode& keyNode ); bool writeXml( const QString & nodeName, QDomElement & element, QDomDocument & document ); - int count() const; - - /** Return keys that do not contain other keys - * Since QgsPropertyValue isn't a key, don't do anything. - */ - void entryList( QStringList & keyName, QStringList & entries ) const; - }; -class QgsPropertyKey : QgsProperty +class QgsProjectPropertyKey : QgsProjectProperty { %TypeHeaderCode #include %End public: - QgsPropertyKey( const QString& name = QString() ); - virtual ~QgsPropertyKey(); + QgsProjectPropertyKey( const QString& name = QString() ); + virtual ~QgsProjectPropertyKey(); /** * The name of the property is used as identifier. @@ -133,7 +126,7 @@ class QgsPropertyKey : QgsProperty /// add the given property key - QgsPropertyKey * addKey( const QString & keyName ); + QgsProjectPropertyKey * addKey( const QString & keyName ); /// remove the given key void removeKey( const QString & keyName ); @@ -143,19 +136,19 @@ class QgsPropertyKey : QgsProperty * @param value is the value to set * @return pointer to property value */ - QgsPropertyValue * setValue( const QString & name, const QVariant & value ); + QgsProjectPropertyValue * setValue( const QString & name, const QVariant & value ); /** Set the value associated with this key * * @note that the single value node associated with each key is always * stored keyed by the current key name */ - QgsPropertyValue * setValue( const QVariant & value ); + QgsProjectPropertyValue * setValue( const QVariant & value ); void dump( int tabs = 0 ) const; - bool readXml( QDomNode & keyNode ); + bool readXml( const QDomNode& keyNode ); bool writeXml( const QString &nodeName, QDomElement & element, QDomDocument & document ); @@ -189,5 +182,5 @@ class QgsPropertyKey : QgsProperty /// delete any sub-nodes virtual void clearKeys(); - QgsProperty * find( QString & propertyName ); + QgsProjectProperty * find( QString & propertyName ); }; // class QgsPropertyKey diff --git a/python/core/qgssnappingutils.sip b/python/core/qgssnappingutils.sip index 4dcaff53494..8048001177c 100644 --- a/python/core/qgssnappingutils.sip +++ b/python/core/qgssnappingutils.sip @@ -47,7 +47,8 @@ class QgsSnappingUtils : QObject { IndexAlwaysFull, //!< For all layers build index of full extent. Uses more memory, but queries are faster. IndexNeverFull, //!< For all layers only create temporary indexes of small extent. Low memory usage, slower queries. - IndexHybrid //!< For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and memory usage. + IndexHybrid, //!< For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and memory usage. + IndexExtent //!< For all layer build index of extent given in map settings }; /** Set a strategy for indexing geometry data - determines how fast and memory consuming the data structures will be */ diff --git a/python/core/qgsstatisticalsummary.sip b/python/core/qgsstatisticalsummary.sip index 1c6b66846eb..90610cfa873 100644 --- a/python/core/qgsstatisticalsummary.sip +++ b/python/core/qgsstatisticalsummary.sip @@ -49,13 +49,13 @@ class QgsStatisticalSummary virtual ~QgsStatisticalSummary(); /** Returns flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg sum, min and max). + * are always calculated (e.g., sum, min and max). * @see setStatistics */ QgsStatisticalSummary::Statistics statistics() const; /** Sets flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg sum, min and max). + * are always calculated (e.g., sum, min and max). * @param stats flags for statistics to calculate * @see statistics */ diff --git a/python/core/qgsstringstatisticalsummary.sip b/python/core/qgsstringstatisticalsummary.sip index 20e48a36d63..b9946e033e1 100644 --- a/python/core/qgsstringstatisticalsummary.sip +++ b/python/core/qgsstringstatisticalsummary.sip @@ -42,13 +42,13 @@ class QgsStringStatisticalSummary QgsStringStatisticalSummary( QgsStringStatisticalSummary::Statistics stats = All ); /** Returns flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg count). + * are always calculated (e.g., count). * @see setStatistics */ Statistics statistics() const; /** Sets flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg count). + * are always calculated (e.g., count). * @param stats flags for statistics to calculate * @see statistics */ diff --git a/python/core/qgsstringutils.sip b/python/core/qgsstringutils.sip index 02eeb194c84..7eb990825f3 100644 --- a/python/core/qgsstringutils.sip +++ b/python/core/qgsstringutils.sip @@ -152,7 +152,7 @@ class QgsStringUtils static int levenshteinDistance( const QString &string1, const QString &string2, bool caseSensitive = false ); /** Returns the longest common substring between two strings. This substring is the longest - * string that is a substring of the two input strings. Eg, the longest common substring + * string that is a substring of the two input strings. For example, the longest common substring * of "ABABC" and "BABCA" is "ABC". * @param string1 first string * @param string2 second string @@ -178,7 +178,7 @@ class QgsStringUtils */ static QString soundex( const QString &string ); - /** Returns a string with any URL (eg http(s)/ftp) and mailto: text converted to valid HTML + /** Returns a string with any URL (e.g., http(s)/ftp) and mailto: text converted to valid HTML * links. * @param string string to insert links into * @param foundLinks if specified, will be set to true if any links were inserted into the string diff --git a/python/core/qgstaskmanager.sip b/python/core/qgstaskmanager.sip index 215c74191ee..c77d92178ad 100644 --- a/python/core/qgstaskmanager.sip +++ b/python/core/qgstaskmanager.sip @@ -181,7 +181,7 @@ class QgsTask : QObject /** * Will be emitted by task if it has terminated for any reason - * other then completion (eg when a task has been cancelled or encountered + * other then completion (e.g., when a task has been cancelled or encountered * an internal error). * @note derived classes should not emit this signal directly, it will automatically * be emitted diff --git a/python/core/qgstextrenderer.sip b/python/core/qgstextrenderer.sip index 8e102fa1f05..ca6ee8b8d29 100644 --- a/python/core/qgstextrenderer.sip +++ b/python/core/qgstextrenderer.sip @@ -215,12 +215,12 @@ class QgsTextBackgroundSettings */ void setEnabled( bool enabled ); - /** Returns the type of background shape (eg square, ellipse, SVG). + /** Returns the type of background shape (e.g., square, ellipse, SVG). * @see setType() */ ShapeType type() const; - /** Sets the type of background shape to draw (eg square, ellipse, SVG). + /** Sets the type of background shape to draw (e.g., square, ellipse, SVG). * @param type shape type * @see type() */ @@ -238,14 +238,14 @@ class QgsTextBackgroundSettings */ void setSvgFile( const QString& file ); - /** Returns the method used to determine the size of the background shape (eg fixed size or buffer + /** Returns the method used to determine the size of the background shape (e.g., fixed size or buffer * around text). * @see setSizeType() * @see size() */ SizeType sizeType() const; - /** Sets the method used to determine the size of the background shape (eg fixed size or buffer + /** Sets the method used to determine the size of the background shape (e.g., fixed size or buffer * around text). * @param type size method * @see sizeType() @@ -253,8 +253,8 @@ class QgsTextBackgroundSettings */ void setSizeType( SizeType type ); - /** Returns the size of the background shape. The meaning of the size depends on the current sizeType() - * eg, for size types of QgsTextBackgroundSettings::SizeFixed the size will represent the actual width and + /** Returns the size of the background shape. The meaning of the size depends on the current sizeType(), + * e.g., for size types of QgsTextBackgroundSettings::SizeFixed the size will represent the actual width and * height of the shape, for QgsTextBackgroundSettings::SizeBuffer the size will represent the horizontal * and vertical margins to add to the text when calculating the size of the shape. * @see setSize() @@ -262,8 +262,8 @@ class QgsTextBackgroundSettings */ QSizeF size() const; - /** Sets the size of the background shape. The meaning of the size depends on the current sizeType() - * eg, for size types of QgsTextBackgroundSettings::SizeFixed the size will represent the actual width and + /** Sets the size of the background shape. The meaning of the size depends on the current sizeType(), + * e.g., for size types of QgsTextBackgroundSettings::SizeFixed the size will represent the actual width and * height of the shape, for QgsTextBackgroundSettings::SizeBuffer the size will represent the horizontal * and vertical margins to add to the text when calculating the size of the shape. * @param size QSizeF representing horizontal and vertical size components for shape @@ -589,14 +589,14 @@ class QgsTextShadowSettings void setEnabled( bool enabled ); /** Returns the placement for the drop shadow. The placement determines - * both the z-order stacking position for the shadow and the what shape (eg text, + * both the z-order stacking position for the shadow and the what shape (e.g., text, * background shape) is used for casting the shadow. * @see setShadowPlacement() */ QgsTextShadowSettings::ShadowPlacement shadowPlacement() const; /** Sets the placement for the drop shadow. The placement determines - * both the z-order stacking position for the shadow and the what shape (eg text, + * both the z-order stacking position for the shadow and the what shape (e.g., text, * background shape) is used for casting the shadow. * @param placement shadow placement * @see shadowPlacement() @@ -874,14 +874,14 @@ class QgsTextFormat */ void setFont( const QFont& font ); - /** Returns the named style for the font used for rendering text (eg "bold"). + /** Returns the named style for the font used for rendering text (e.g., "bold"). * @see setNamedStyle() * @see font() */ QString namedStyle() const; /** Sets the named style for the font used for rendering text. - * @param style named style, eg "bold" + * @param style named style, e.g., "bold" * @see namedStyle() * @see setFont() */ @@ -1115,7 +1115,7 @@ class QgsTextRenderer * @param context render context * @param format text format * @param part component of text to draw. Note that Shadow parts cannot be drawn - * individually and instead are drawn with their associated part (eg drawn together + * individually and instead are drawn with their associated part (e.g., drawn together * with the text or background parts) * @param drawAsOutlines set to false to render text as text. This allows outputs to * formats like SVG to maintain text as text objects, but at the cost of degraded diff --git a/python/core/qgsunittypes.sip b/python/core/qgsunittypes.sip index 7ddfca4e026..9b1c408fef7 100644 --- a/python/core/qgsunittypes.sip +++ b/python/core/qgsunittypes.sip @@ -30,7 +30,7 @@ class QgsUnitTypes enum DistanceUnitType { Standard, /*!< unit is a standard measurement unit */ - Geographic, /*!< unit is a geographic (eg degree based) unit */ + Geographic, /*!< unit is a geographic (e.g., degree based) unit */ UnknownType, /*!< unknown unit type */ }; @@ -67,8 +67,8 @@ class QgsUnitTypes RenderMillimeters, //!< millimeters RenderMapUnits, //!< map units RenderPixels, //!< pixels - RenderPercentage, //!< percentage of another measurement (eg canvas size, feature size) - RenderPoints, //! points (eg for font sizes) + RenderPercentage, //!< percentage of another measurement (e.g., canvas size, feature size) + RenderPoints, //! points (e.g., for font sizes) RenderUnknownUnit, //!< mixed or unknown units }; @@ -153,7 +153,7 @@ class QgsUnitTypes */ static double fromUnitToUnitFactor( AreaUnit fromUnit, AreaUnit toUnit ); - /** Converts a distance unit to its corresponding area unit, eg meters to square meters + /** Converts a distance unit to its corresponding area unit, e.g., meters to square meters * @param distanceUnit distance unit to convert * @return matching areal unit */ diff --git a/python/core/qgsvectordataprovider.sip b/python/core/qgsvectordataprovider.sip index 9b3fb86f1d5..b948a131806 100644 --- a/python/core/qgsvectordataprovider.sip +++ b/python/core/qgsvectordataprovider.sip @@ -49,6 +49,8 @@ class QgsVectorDataProvider : QgsDataProvider ChangeFeatures, /** Supports renaming attributes (fields). Added in QGIS 2.16 */ RenameAttributes, + //! Supports fast truncation of the layer (removing all features). Added in QGIS 3.0 + FastTruncate, }; typedef QFlags Capabilities; @@ -191,11 +193,21 @@ class QgsVectorDataProvider : QgsDataProvider virtual bool addFeatures( QList &flist /In,Out/ ); /** - * Deletes one or more features + * Deletes one or more features from the provider. This requires the DeleteFeatures capability. * @param id list containing feature ids to delete * @return true in case of success and false in case of failure + * @see truncate() */ - virtual bool deleteFeatures( const QSet &id ); + virtual bool deleteFeatures( const QgsFeatureIds &id ); + + /** + * Removes all features from the layer. This requires either the FastTruncate or DeleteFeatures capability. + * Providers with the FastTruncate capability will use an optimised method to truncate the layer. + * @returns true in case of success and false in case of failure. + * @note added in QGIS 3.0 + * @see deleteFeatures() + */ + virtual bool truncate(); /** * Adds new attributes @@ -241,8 +253,8 @@ class QgsVectorDataProvider : QgsDataProvider * Returns any literal default values which are present at the provider for a specified * field index. Important - this should ONLY be called when creating an attribute to insert * directly into the database. Do not call this method for non-feature creation or modification, - * eg when validating an attribute or to compare it against an existing value, as calling it - * can cause changes to the underlying data source (eg Postgres provider where the default value + * e.g., when validating an attribute or to compare it against an existing value, as calling it + * can cause changes to the underlying data source (e.g., Postgres provider where the default value * is calculated as a result of a sequence). It is recommended that you instead use the methods * in QgsVectorLayerUtils such as QgsVectorLayerUtils::createFeature() * so that default value handling and validation is automatically carried out. @@ -253,7 +265,7 @@ class QgsVectorDataProvider : QgsDataProvider /** * Returns any default value clauses which are present at the provider for a specified * field index. These clauses are usually SQL fragments which must be evaluated by the - * provider, eg sequence values. + * provider, e.g., sequence values. * @see defaultValue() * @note added in QGIS 3.0 */ @@ -268,7 +280,7 @@ class QgsVectorDataProvider : QgsDataProvider QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const; /** - * Returns true if a constraint check should be skipped for a specified field (eg if + * Returns true if a constraint check should be skipped for a specified field (e.g., if * the value returned by defaultValue() is trusted implicitly. An optional attribute value can be * passed which can help refine the skip constraint check. * @note added in QGIS 3.0 diff --git a/python/core/qgsvectorlayer.sip b/python/core/qgsvectorlayer.sip index ad03a11095b..14756c550ff 100644 --- a/python/core/qgsvectorlayer.sip +++ b/python/core/qgsvectorlayer.sip @@ -352,7 +352,7 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator * @param path The path or url of the parameter. Typically this encodes * parameters used by the data provider as url query items. * @param baseName The name used to represent the layer in the legend - * @param providerLib The name of the data provider, eg "memory", "postgres" + * @param providerLib The name of the data provider, e.g., "memory", "postgres" * @param loadDefaultStyleFlag whether to load the default style * */ diff --git a/python/core/qgsvectorlayerutils.sip b/python/core/qgsvectorlayerutils.sip index 1420179d669..c58d9dee99a 100644 --- a/python/core/qgsvectorlayerutils.sip +++ b/python/core/qgsvectorlayerutils.sip @@ -38,7 +38,7 @@ class QgsVectorLayerUtils /** * Creates a new feature ready for insertion into a layer. Default values and constraints - * (eg unique constraints) will automatically be handled. An optional attribute map can be + * (e.g., unique constraints) will automatically be handled. An optional attribute map can be * passed for the new feature to copy as many attribute values as possible from the map, * assuming that they respect the layer's constraints. Note that the created feature is not * automatically inserted into the layer. diff --git a/python/core/raster/qgscolorrampshader.sip b/python/core/raster/qgscolorrampshader.sip index fbbec6feab7..cdd93b81635 100644 --- a/python/core/raster/qgscolorrampshader.sip +++ b/python/core/raster/qgscolorrampshader.sip @@ -5,7 +5,31 @@ class QgsColorRampShader : QgsRasterShaderFunction %End public: - QgsColorRampShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0 ); + //! Supported methods for color interpolation. + enum Type + { + Interpolated, //!< Interpolates the color between two class breaks linearly. + Discrete, //!< Assigns the color of the higher class for every pixel between two class breaks. + Exact //!< Assigns the color of the exact matching value in the color ramp item list + }; + + //! Classification modes used to create the color ramp shader + enum ClassificationMode + { + Continuous = 1, //!< Uses breaks from color palette + EqualInterval = 2, //!< Uses equal interval + Quantile = 3 //!< Uses quantile (i.e. equal pixel) count + }; + + /** Creates a new color ramp shader. + * @param theMinimumValue minimum value for the raster shader + * @param theMaximumValue maximum value for the raster shader + * @param theType interpolation type used + * @param theClassificationMode method used to classify the color ramp shader + * @param theColorRamp vector color ramp used to classify the color ramp shader + * @returns new QgsColorRampShader + */ + QgsColorRampShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0, QgsColorRamp* theColorRamp = nullptr, Type theType = Interpolated, ClassificationMode theClassificationMode = Continuous ); ~QgsColorRampShader(); @@ -28,19 +52,11 @@ class QgsColorRampShader : QgsRasterShaderFunction bool operator<( const QgsColorRampShader::ColorRampItem& other ) const; }; - /** Supported methods for color interpolation. */ - enum ColorRamp_TYPE - { - INTERPOLATED, //!< Interpolates the color between two class breaks linearly. - DISCRETE, //!< Assigns the color of the higher class for every pixel between two class breaks. - EXACT //!< Assigns the color of the exact matching value in the color ramp item list - }; - /** \brief Get the custom colormap*/ QList colorRampItemList() const; /** \brief Get the color ramp type */ - QgsColorRampShader::ColorRamp_TYPE colorRampType() const; + Type colorRampType() const; /** Get the source color ramp * @note added in QGIS 3.0 @@ -61,11 +77,27 @@ class QgsColorRampShader : QgsRasterShaderFunction void setColorRampItemList( const QList& theList ); //TODO: sort on set /** \brief Set the color ramp type*/ - void setColorRampType( QgsColorRampShader::ColorRamp_TYPE theColorRampType ); + void setColorRampType( QgsColorRampShader::Type theColorRampType ); /** \brief Set the color ramp type*/ void setColorRampType( const QString& theType ); + /** Classify color ramp shader + * @param classes number of classes + * @param band raster band used in classification (only used in quantile mode) + * @param extent extent used in classification (only used in quantile mode) + * @param input raster input used in classification (only used in quantile mode) + */ + void classifyColorRamp( const int classes = 0, const int band = -1, const QgsRectangle& extent = QgsRectangle(), QgsRasterInterface* input = nullptr ); + + /** Classify color ramp shader + * @param band raster band used in classification (only used in quantile mode) + * @param extent extent used in classification (only used in quantile mode) + * @param input raster input used in classification (only used in quantile mode) + */ + void classifyColorRamp( const int band = -1, const QgsRectangle& extent = QgsRectangle(), QgsRasterInterface* input = nullptr ) /PyName=classifyColorRampV2/; + + /** \brief Generates and new RGB value based on one input value */ bool shade( double, int* /Out/, int* /Out/, int* /Out/, int* /Out/ ); @@ -74,6 +106,12 @@ class QgsColorRampShader : QgsRasterShaderFunction void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const; + //! Sets classification mode + void setClassificationMode( ClassificationMode classificationMode ); + + //! Returns the classification mode + ClassificationMode classificationMode() const; + /** Sets whether the shader should not render values out of range. * @param clip set to true to clip values which are out of range. * @see clip() diff --git a/python/core/raster/qgsrasterinterface.sip b/python/core/raster/qgsrasterinterface.sip index 895af7f49c9..ae9864a56b5 100644 --- a/python/core/raster/qgsrasterinterface.sip +++ b/python/core/raster/qgsrasterinterface.sip @@ -211,7 +211,7 @@ class QgsRasterInterface /** \brief Get histogram. Histograms are cached in providers. * @param theBandNo The band (number). - * @param theBinCount Number of bins (intervals,buckets). If 0, the number of bins is decided automaticaly according to data type, raster size etc. + * @param theBinCount Number of bins (intervals,buckets). If 0, the number of bins is decided automatically according to data type, raster size etc. * @param theMinimum Minimum value, if NaN, raster minimum value will be used. * @param theMaximum Maximum value, if NaN, raster minimum value will be used. * @param theExtent Extent used to calc histogram, if empty, whole raster extent is used. diff --git a/python/core/raster/qgssinglebandpseudocolorrenderer.sip b/python/core/raster/qgssinglebandpseudocolorrenderer.sip index a2b2e20132f..295d3f12b53 100644 --- a/python/core/raster/qgssinglebandpseudocolorrenderer.sip +++ b/python/core/raster/qgssinglebandpseudocolorrenderer.sip @@ -4,6 +4,7 @@ class QgsSingleBandPseudoColorRenderer: QgsRasterRenderer #include "qgssinglebandpseudocolorrenderer.h" %End public: + /** Note: takes ownership of QgsRasterShader*/ QgsSingleBandPseudoColorRenderer( QgsRasterDataProvider* provider, int band, QgsRasterShader* shader /Transfer/ ); ~QgsSingleBandPseudoColorRenderer(); @@ -15,10 +16,22 @@ class QgsSingleBandPseudoColorRenderer: QgsRasterRenderer /** Takes ownership of the shader*/ void setShader( QgsRasterShader* shader /Transfer/ ); + QgsRasterShader* shader(); + //! @note available in python as constShader const QgsRasterShader* shader() const /PyName=constShader/; + /** Creates a color ramp shader + * @param colorRamp vector color ramp + * @param colorRampType type of color ramp shader + * @param classificationMode classification mode + * @param classes number of classes + * @param clip clip out of range values + * @param extent extent used in classification (only used in quantile mode) + */ + void createShader( QgsColorRamp* colorRamp = nullptr, QgsColorRampShader::Type colorRampType = QgsColorRampShader::Interpolated, QgsColorRampShader::ClassificationMode classificationMode = QgsColorRampShader::Continuous, int classes = 0, bool clip = false, const QgsRectangle& extent = QgsRectangle() ); + void writeXml( QDomDocument& doc, QDomElement& parentElem ) const; void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const; diff --git a/python/core/symbology-ng/qgsfillsymbollayer.sip b/python/core/symbology-ng/qgsfillsymbollayer.sip index 2914a524b6f..ef1f4120fc2 100644 --- a/python/core/symbology-ng/qgsfillsymbollayer.sip +++ b/python/core/symbology-ng/qgsfillsymbollayer.sip @@ -174,7 +174,7 @@ class QgsGradientFillSymbolLayer : QgsFillSymbolLayer double estimateMaxBleed() const; - /** Type of gradient, eg linear or radial*/ + /** Type of gradient, e.g., linear or radial*/ GradientType gradientType() const; void setGradientType( GradientType gradientType ); diff --git a/python/core/symbology-ng/qgsmarkersymbollayer.sip b/python/core/symbology-ng/qgsmarkersymbollayer.sip index 31e81eca077..cd924ae1b35 100644 --- a/python/core/symbology-ng/qgsmarkersymbollayer.sip +++ b/python/core/symbology-ng/qgsmarkersymbollayer.sip @@ -218,7 +218,7 @@ class QgsSimpleMarkerSymbolLayer : QgsSimpleMarkerSymbolLayerBase */ void setBorderColor( const QColor& color ); - /** Returns the marker's outline style (eg solid, dashed, etc) + /** Returns the marker's outline style (e.g., solid, dashed, etc) * @note added in 2.4 * @see setOutlineStyle() * @see borderColor() @@ -226,7 +226,7 @@ class QgsSimpleMarkerSymbolLayer : QgsSimpleMarkerSymbolLayerBase */ Qt::PenStyle outlineStyle() const; - /** Sets the marker's outline style (eg solid, dashed, etc) + /** Sets the marker's outline style (e.g., solid, dashed, etc) * @param outlineStyle style * @note added in 2.4 * @see outlineStyle() @@ -235,7 +235,7 @@ class QgsSimpleMarkerSymbolLayer : QgsSimpleMarkerSymbolLayerBase */ void setOutlineStyle( Qt::PenStyle outlineStyle ); - /** Returns the marker's outline join style (eg miter, bevel, etc). + /** Returns the marker's outline join style (e.g., miter, bevel, etc). * @note added in 2.16 * @see setPenJoinStyle() * @see borderColor() @@ -243,7 +243,7 @@ class QgsSimpleMarkerSymbolLayer : QgsSimpleMarkerSymbolLayerBase */ Qt::PenJoinStyle penJoinStyle() const; - /** Sets the marker's outline join style (eg miter, bevel, etc). + /** Sets the marker's outline join style (e.g., miter, bevel, etc). * @param style join style * @note added in 2.16 * @see penJoinStyle() diff --git a/python/core/symbology-ng/qgspointdistancerenderer.sip b/python/core/symbology-ng/qgspointdistancerenderer.sip index 40aa1a05830..49b88dd8bd2 100644 --- a/python/core/symbology-ng/qgspointdistancerenderer.sip +++ b/python/core/symbology-ng/qgspointdistancerenderer.sip @@ -1,6 +1,6 @@ /** \class QgsPointDistanceRenderer * \ingroup core - * An abstract base class for distance based point renderers (eg clusterer and displacement renderers). + * An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers). * QgsPointDistanceRenderer handles calculation of point clusters using a distance based threshold. * Subclasses must implement drawGroup() to handle the rendering of individual point clusters * in the desired style. diff --git a/python/core/symbology-ng/qgsrendererregistry.sip b/python/core/symbology-ng/qgsrendererregistry.sip index 3e4c41f2848..b45c5e477b2 100644 --- a/python/core/symbology-ng/qgsrendererregistry.sip +++ b/python/core/symbology-ng/qgsrendererregistry.sip @@ -100,13 +100,13 @@ class QgsRendererRegistry public: - //! Returns a pointer to the QgsRendererRegistry singleton - static QgsRendererRegistry* instance(); + QgsRendererRegistry(); + ~QgsRendererRegistry(); //! Adds a renderer to the registry. Takes ownership of the metadata object. //! @param metadata renderer metadata //! @returns true if renderer was added successfully, or false if renderer could not - //! be added (eg a renderer with a duplicate name already exists) + //! be added (e.g., a renderer with a duplicate name already exists) bool addRenderer( QgsRendererAbstractMetadata* metadata /Transfer/ ); //! Removes a renderer from registry. @@ -128,11 +128,6 @@ class QgsRendererRegistry //! @note added in QGIS 2.16 QStringList renderersList( const QgsVectorLayer* layer ) const; - protected: - //! protected constructor - QgsRendererRegistry(); - ~QgsRendererRegistry(); - private: QgsRendererRegistry( const QgsRendererRegistry& rh ); //QgsRendererRegistry& operator=( const QgsRendererRegistry& rh ); diff --git a/python/core/symbology-ng/qgssvgcache.sip b/python/core/symbology-ng/qgssvgcache.sip index 61f0b30d22c..0325fb69776 100644 --- a/python/core/symbology-ng/qgssvgcache.sip +++ b/python/core/symbology-ng/qgssvgcache.sip @@ -65,7 +65,8 @@ class QgsSvgCache : QObject public: - static QgsSvgCache* instance(); + QgsSvgCache( QObject * parent /TransferThis/ = 0 ); + ~QgsSvgCache(); /** Get SVG as QImage. @@ -151,8 +152,6 @@ class QgsSvgCache : QObject void statusChanged( const QString& theStatusQString ); protected: - //! protected constructor - QgsSvgCache( QObject * parent /TransferThis/ = 0 ); /** Creates new cache entry and returns pointer to it * @param file Absolute or relative path to SVG file. If the path is relative the file is searched by QgsSymbolLayerUtils::symbolNameToPath() in SVG paths. diff --git a/python/core/symbology-ng/qgssymbol.sip b/python/core/symbology-ng/qgssymbol.sip index dd94d48a0b9..65459519976 100644 --- a/python/core/symbology-ng/qgssymbol.sip +++ b/python/core/symbology-ng/qgssymbol.sip @@ -155,7 +155,7 @@ class QgsSymbol void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; /** Returns the units to use for sizes and widths within the symbol. Individual - * symbol layer definitions will interpret this in different ways, eg a marker symbol + * symbol layer definitions will interpret this in different ways, e.g., a marker symbol * may use it to specify the units for the marker size, while a line symbol * may use it to specify the units for the line width. * @returns output unit, or QgsUnitTypes::RenderUnknownUnit if the symbol contains mixed units @@ -164,7 +164,7 @@ class QgsSymbol QgsUnitTypes::RenderUnit outputUnit() const; /** Sets the units to use for sizes and widths within the symbol. Individual - * symbol definitions will interpret this in different ways, eg a marker symbol + * symbol definitions will interpret this in different ways, e.g., a marker symbol * may use it to specify the units for the marker size, while a line symbol * may use it to specify the units for the line width. * @param unit output units diff --git a/python/core/symbology-ng/qgssymbollayer.sip b/python/core/symbology-ng/qgssymbollayer.sip index 3df37061fe9..b9c8bf85d42 100644 --- a/python/core/symbology-ng/qgssymbollayer.sip +++ b/python/core/symbology-ng/qgssymbollayer.sip @@ -148,13 +148,13 @@ class QgsSymbolLayer bool isLocked() const; /** Returns the estimated maximum distance which the layer style will bleed outside - the drawn shape. Eg, polygons drawn with an outline will draw half the width + the drawn shape. For example, polygons drawn with an outline will draw half the width of the outline outside of the polygon. This amount is estimated, since it may be affected by data defined symbology rules.*/ virtual double estimateMaxBleed() const; /** Sets the units to use for sizes and widths within the symbol layer. Individual - * symbol layer subclasses will interpret this in different ways, eg a marker symbol + * symbol layer subclasses will interpret this in different ways, e.g., a marker symbol * layer may use it to specify the units for the marker size, while a line symbol * layer may use it to specify the units for the line width. * @param unit output units @@ -163,7 +163,7 @@ class QgsSymbolLayer virtual void setOutputUnit( QgsUnitTypes::RenderUnit unit ); /** Returns the units to use for sizes and widths within the symbol layer. Individual - * symbol layer subclasses will interpret this in different ways, eg a marker symbol + * symbol layer subclasses will interpret this in different ways, e.g., a marker symbol * layer may use it to specify the units for the marker size, while a line symbol * layer may use it to specify the units for the line width. * @returns output unit, or QgsUnitTypes::RenderUnknownUnit if the symbol layer contains mixed units diff --git a/python/core/symbology-ng/qgssymbollayerregistry.sip b/python/core/symbology-ng/qgssymbollayerregistry.sip index ceefc6914b2..40371e520cd 100644 --- a/python/core/symbology-ng/qgssymbollayerregistry.sip +++ b/python/core/symbology-ng/qgssymbollayerregistry.sip @@ -54,8 +54,8 @@ class QgsSymbolLayerRegistry public: - //! return the single instance of this class (instantiate it if not exists) - static QgsSymbolLayerRegistry* instance(); + QgsSymbolLayerRegistry(); + ~QgsSymbolLayerRegistry(); //! return metadata for specified symbol layer. Returns NULL if not found QgsSymbolLayerAbstractMetadata* symbolLayerMetadata( const QString& name ) const; @@ -75,10 +75,6 @@ class QgsSymbolLayerRegistry //! create a new instance of symbol layer for specified symbol type with default settings static QgsSymbolLayer* defaultSymbolLayer( QgsSymbol::SymbolType type ) /Factory/; - protected: - QgsSymbolLayerRegistry(); - ~QgsSymbolLayerRegistry(); - private: QgsSymbolLayerRegistry( const QgsSymbolLayerRegistry& rh ); diff --git a/python/gui/editorwidgets/core/qgssearchwidgetwrapper.sip b/python/gui/editorwidgets/core/qgssearchwidgetwrapper.sip index 6e1f1fa459e..714ba4b01be 100644 --- a/python/gui/editorwidgets/core/qgssearchwidgetwrapper.sip +++ b/python/gui/editorwidgets/core/qgssearchwidgetwrapper.sip @@ -82,13 +82,13 @@ class QgsSearchWidgetWrapper : QgsWidgetWrapper }; typedef QFlags FilterFlags; - /** Returns a list of exclusive filter flags, which cannot be combined with other flags (eg EqualTo/NotEqualTo) + /** Returns a list of exclusive filter flags, which cannot be combined with other flags (e.g., EqualTo/NotEqualTo) * @note added in QGIS 2.16 * @see nonExclusiveFilterFlags() */ static QList< QgsSearchWidgetWrapper::FilterFlag > exclusiveFilterFlags(); - /** Returns a list of non-exclusive filter flags, which can be combined with other flags (eg CaseInsensitive) + /** Returns a list of non-exclusive filter flags, which can be combined with other flags (e.g., CaseInsensitive) * @note added in QGIS 2.16 * @see exclusiveFilterFlags() */ diff --git a/python/gui/gui.sip b/python/gui/gui.sip index d6645fddfd6..e3a0275b8e0 100644 --- a/python/gui/gui.sip +++ b/python/gui/gui.sip @@ -75,6 +75,7 @@ %Include qgsfieldmodel.sip %Include qgsfieldproxymodel.sip %Include qgsfieldvalidator.sip +%Include qgsfieldvalueslineedit.sip %Include qgsfiledropedit.sip %Include qgsfilewidget.sip %Include qgsfiledownloader.sip @@ -139,7 +140,6 @@ %Include qgspluginmanagerinterface.sip %Include qgspresetcolorrampdialog.sip %Include qgsprevieweffect.sip -%Include qgsprojectbadlayerguihandler.sip %Include qgsprojectionselectionwidget.sip %Include qgsprojectionselector.sip %Include qgsquerybuilder.sip diff --git a/python/gui/layertree/qgscustomlayerorderwidget.sip b/python/gui/layertree/qgscustomlayerorderwidget.sip index 84250a0cfe2..56b0b816a76 100644 --- a/python/gui/layertree/qgscustomlayerorderwidget.sip +++ b/python/gui/layertree/qgscustomlayerorderwidget.sip @@ -20,7 +20,8 @@ class QgsCustomLayerOrderWidget : QWidget protected slots: void bridgeHasCustomLayerOrderChanged( bool state ); void bridgeCustomLayerOrderChanged( const QStringList& order ); - void nodeVisibilityChanged( QgsLayerTreeNode* node, Qt::CheckState state ); + //! Slot triggered when the ivsibility of a node changes + void nodeVisibilityChanged( QgsLayerTreeNode* node ); void modelUpdated(); }; diff --git a/python/gui/layertree/qgslayertreeviewdefaultactions.sip b/python/gui/layertree/qgslayertreeviewdefaultactions.sip index 19d0912819e..e5e9c65aabf 100644 --- a/python/gui/layertree/qgslayertreeviewdefaultactions.sip +++ b/python/gui/layertree/qgslayertreeviewdefaultactions.sip @@ -20,6 +20,15 @@ class QgsLayerTreeViewDefaultActions : QObject QAction* actionRenameGroupOrLayer( QObject* parent = 0 ) /Factory/; QAction* actionShowFeatureCount( QObject* parent = 0 ) /Factory/; + //! Action to check a group and all its children + QAction* actionCheckAndAllChildren( QObject* parent = nullptr ); + + //! Action to uncheck a group and all its children + QAction* actionUncheckAndAllChildren( QObject* parent = nullptr ); + + //! Action to check a group and all its parents + QAction* actionCheckAndAllParents( QObject* parent = nullptr ); + QAction* actionZoomToLayer( QgsMapCanvas* canvas, QObject* parent = 0 ) /Factory/; QAction* actionZoomToGroup( QgsMapCanvas* canvas, QObject* parent = 0 ) /Factory/; // TODO: zoom to selected diff --git a/python/gui/qgisinterface.sip b/python/gui/qgisinterface.sip index d77f758e436..6449fff3bb0 100644 --- a/python/gui/qgisinterface.sip +++ b/python/gui/qgisinterface.sip @@ -483,6 +483,11 @@ class QgisInterface : QObject virtual QAction *actionHideAllLayers() = 0; virtual QAction *actionShowAllLayers() = 0; virtual QAction *actionHideSelectedLayers() = 0; + /** + * Returns the Hide Deselected Layers action. + * @note added in QGIS 3.0 + */ + virtual QAction *actionHideDeselectedLayers() = 0; virtual QAction *actionShowSelectedLayers() = 0; // Plugin menu actions diff --git a/python/gui/qgsattributedialog.sip b/python/gui/qgsattributedialog.sip index 3d458eb058c..e1746d04bf5 100644 --- a/python/gui/qgsattributedialog.sip +++ b/python/gui/qgsattributedialog.sip @@ -48,7 +48,7 @@ class QgsAttributeDialog : QDialog /** * Toggles the form mode. - * @param mode form mode. Eg if set to QgsAttributeForm::AddFeatureMode, the dialog will be editable even with an invalid feature and + * @param mode form mode. For example, if set to QgsAttributeForm::AddFeatureMode, the dialog will be editable even with an invalid feature and * will add a new feature when the form is accepted. */ void setMode( QgsAttributeForm::Mode mode ); diff --git a/python/gui/qgsattributeform.sip b/python/gui/qgsattributeform.sip index 73a23026914..12a4d75a0ff 100644 --- a/python/gui/qgsattributeform.sip +++ b/python/gui/qgsattributeform.sip @@ -164,6 +164,12 @@ class QgsAttributeForm : QWidget */ void closed(); + /** + * Emitted when the user chooses to zoom to a filtered set of features. + * @note added in QGIS 3.0 + */ + void zoomToFeatures( const QString& filter ); + public slots: /** * Call this to change the content of a given attribute. Will update the editor(s) related to this field. diff --git a/python/gui/qgsattributeformeditorwidget.sip b/python/gui/qgsattributeformeditorwidget.sip index 55873b2f521..cc85331551e 100644 --- a/python/gui/qgsattributeformeditorwidget.sip +++ b/python/gui/qgsattributeformeditorwidget.sip @@ -42,7 +42,7 @@ class QgsAttributeFormEditorWidget : QWidget const QgsAttributeEditorContext &context = QgsAttributeEditorContext() ); /** Sets the current mode for the widget. The widget will adapt its state and visible widgets to - * reflect the updated mode. Eg, showing multi edit tool buttons if the mode is set to MultiEditMode. + * reflect the updated mode. For example, showing multi edit tool buttons if the mode is set to MultiEditMode. * @param mode widget mode * @see mode() */ diff --git a/python/gui/qgscolorwidgets.sip b/python/gui/qgscolorwidgets.sip index bc375c017af..60c46434197 100644 --- a/python/gui/qgscolorwidgets.sip +++ b/python/gui/qgscolorwidgets.sip @@ -1,9 +1,9 @@ /** \ingroup gui * \class QgsColorWidget * A base class for interactive color widgets. Widgets can either allow setting a single component of - * a color (eg the red or green components), or an entire color. The QgsColorWidget also keeps track of + * a color (e.g., the red or green components), or an entire color. The QgsColorWidget also keeps track of * any explicitly set hue for the color, so that this information is not lost when the widget is - * set to a color with an ambiguous hue (eg black or white shades). + * set to a color with an ambiguous hue (e.g., black or white shades). * \note Added in version 2.5 */ @@ -112,7 +112,7 @@ class QgsColorWidget : QWidget int componentRange( const ColorComponent component ) const; /** Returns the value of a component of the widget's current color. This method correctly - * handles hue values when the color has an ambiguous hue (eg black or white shades) + * handles hue values when the color has an ambiguous hue (e.g., black or white shades) * @param component color component to return * @returns value of color component, or -1 if widget has an invalid color set * @see hue @@ -120,7 +120,7 @@ class QgsColorWidget : QWidget int componentValue( const ColorComponent component ) const; /** Returns the hue for the widget. This may differ from the hue for the QColor returned by color(), - * as QColor returns a hue of -1 if the color's hue is ambiguous (eg, if the saturation is zero). + * as QColor returns a hue of -1 if the color's hue is ambiguous (e.g., if the saturation is zero). * @returns explicitly set hue for widget */ int hue() const; @@ -288,7 +288,7 @@ class QgsColorBox : QgsColorWidget /** \ingroup gui * \class QgsColorRampWidget * A color ramp widget. This widget consists of an interactive box filled with a color which varies along - * its length by a single color component (eg, varying saturation from 0 to 100%). + * its length by a single color component (e.g., varying saturation from 0 to 100%). * \note Added in version 2.5 */ diff --git a/python/gui/qgsexpressionbuilderwidget.sip b/python/gui/qgsexpressionbuilderwidget.sip index c49502cf0cf..d1e2f86d1e3 100644 --- a/python/gui/qgsexpressionbuilderwidget.sip +++ b/python/gui/qgsexpressionbuilderwidget.sip @@ -36,7 +36,7 @@ class QgsExpressionItem : QStandardItem */ void setHelpText( const QString& helpText ); - /** Get the type of expression item eg header, field, ExpressionNode. + /** Get the type of expression item, e.g., header, field, ExpressionNode. * * @return The QgsExpressionItem::ItemType */ diff --git a/python/gui/qgsexpressionselectiondialog.sip b/python/gui/qgsexpressionselectiondialog.sip index 77e24028091..4d0e2ce96ab 100644 --- a/python/gui/qgsexpressionselectiondialog.sip +++ b/python/gui/qgsexpressionselectiondialog.sip @@ -35,12 +35,18 @@ class QgsExpressionSelectionDialog : QDialog */ void setGeomCalculator( const QgsDistanceArea & da ); - public slots: - void on_mActionSelect_triggered(); - void on_mActionAddToSelection_triggered(); - void on_mActionRemoveFromSelection_triggered(); - void on_mActionSelectIntersect_triggered(); - void on_mPbnClose_clicked(); + /** Sets the message bar to display feedback from the dialog. This is used when zooming to + * features to display the count of selected features. + * @param messageBar target message bar + * @note added in QGIS 3.0 + */ + void setMessageBar( QgsMessageBar* messageBar ); + + /** + * Sets a map canvas associated with the dialog. + * @note added in QGIS 3.0 + */ + void setMapCanvas( QgsMapCanvas* canvas ); protected: /** diff --git a/python/gui/qgsfieldvalueslineedit.sip b/python/gui/qgsfieldvalueslineedit.sip new file mode 100644 index 00000000000..203068ff1a8 --- /dev/null +++ b/python/gui/qgsfieldvalueslineedit.sip @@ -0,0 +1,59 @@ +/** \class QgsFieldValuesLineEdit + * \ingroup gui + * A line edit with an autocompleter which takes unique values from a vector layer's fields. + * The autocompleter is populated from the vector layer in the background to ensure responsive + * interaction with the widget. + * \note added in QGIS 3.0 + */ +class QgsFieldValuesLineEdit: QgsFilterLineEdit +{ +%TypeHeaderCode +#include +%End + public: + + /** Constructor for QgsFieldValuesLineEdit + * @param parent parent widget + */ + QgsFieldValuesLineEdit( QWidget *parent /TransferThis/ = nullptr ); + + virtual ~QgsFieldValuesLineEdit(); + + /** Sets the layer containing the field that values will be shown from. + * @param layer vector layer + * @see layer() + * @see setAttributeIndex() + */ + void setLayer( QgsVectorLayer* layer ); + + /** Returns the layer containing the field that values will be shown from. + * @see setLayer() + * @see attributeIndex() + */ + QgsVectorLayer* layer() const; + + /** Sets the attribute index for the field containing values to show in the widget. + * @param index index of attribute + * @see attributeIndex() + * @see setLayer() + */ + void setAttributeIndex( int index ); + + /** Returns the attribute index for the field containing values shown in the widget. + * @see setAttributeIndex() + * @see layer() + */ + int attributeIndex() const; + + signals: + + /** Emitted when the layer associated with the widget changes. + * @param layer vector layer + */ + void layerChanged( QgsVectorLayer* layer ); + + /** Emitted when the field associated with the widget changes. + * @param index new attribute index for field + */ + void attributeIndexChanged( int index ); +}; diff --git a/python/gui/qgsfloatingwidget.sip b/python/gui/qgsfloatingwidget.sip index ad9f7820332..6e406d5f003 100644 --- a/python/gui/qgsfloatingwidget.sip +++ b/python/gui/qgsfloatingwidget.sip @@ -73,6 +73,17 @@ class QgsFloatingWidget : QWidget */ void setAnchorWidgetPoint( AnchorPoint point ); + signals: + + //! Emitted when the anchor widget changes + void anchorWidgetChanged( QWidget* widget ); + + //! Emitted when the anchor point changes + void anchorPointChanged( AnchorPoint point ); + + //! Emitted when the anchor widget point changes + void anchorWidgetPointChanged( AnchorPoint point ); + protected: void showEvent( QShowEvent* e ); virtual void paintEvent( QPaintEvent* e ); diff --git a/python/gui/qgsmapcanvas.sip b/python/gui/qgsmapcanvas.sip index 9fbe3b72f3e..703f323229d 100644 --- a/python/gui/qgsmapcanvas.sip +++ b/python/gui/qgsmapcanvas.sip @@ -231,6 +231,10 @@ class QgsMapCanvas : QGraphicsView //! Zooms in/out with a given center void zoomWithCenter( int x, int y, bool zoomIn ); + //! Zooms to feature extent. Adds a small margin around the extent + //! and does a pan if rect is empty (point extent) + void zoomToFeatureExtent( QgsRectangle& rect ); + //! Returns whether the scale is locked, so zooming can be performed using magnication. //! @note added in 2.16 //! @see setScaleLocked() @@ -518,10 +522,6 @@ class QgsMapCanvas : QGraphicsView //! called when panning is in action, reset indicates end of panning void moveCanvasContents( bool reset = false ); - //! Zooms to feature extent. Adds a small margin around the extent - //! and does a pan if rect is empty (point extent) - void zoomToFeatureExtent( QgsRectangle& rect ); - //! called on resize or changed extent to notify canvas items to change their rectangle void updateCanvasItemPositions(); diff --git a/python/gui/qgspanelwidget.sip b/python/gui/qgspanelwidget.sip index dfa12e34052..4a422916db0 100644 --- a/python/gui/qgspanelwidget.sip +++ b/python/gui/qgspanelwidget.sip @@ -90,7 +90,7 @@ class QgsPanelWidget : public QWidget * @note This argument is normally raised with emit panelAccepted(this) * so that callers can retrive the widget easier in calling code. * @note this is emitted only when this panel is accepted, and is not emitted for - * child panels. Eg, if this panel opens a second stacked panel, then this panel + * child panels. For example, if this panel opens a second stacked panel, then this panel * will not emit panelAccepted when the second panel is accepted. */ void panelAccepted( QgsPanelWidget* panel ); diff --git a/python/gui/qgsprojectbadlayerguihandler.sip b/python/gui/qgsprojectbadlayerguihandler.sip deleted file mode 100644 index 0a50bb0a606..00000000000 --- a/python/gui/qgsprojectbadlayerguihandler.sip +++ /dev/null @@ -1,47 +0,0 @@ - -/** \ingroup gui - Handler for missing layers within project. - - Gives user a chance to select path to the missing layers. - */ -class QgsProjectBadLayerGuiHandler : QObject, QgsProjectBadLayerHandler -{ -%TypeHeaderCode -#include -%End - - public: - QgsProjectBadLayerGuiHandler(); - - /** Implementation of the handler */ - virtual void handleBadLayers( const QList& layers ); - - /** Flag to store the Ignore button press of MessageBox used by QgsLegend */ - static bool mIgnore; - - protected: - /** This is used to locate files that have moved or otherwise are missing */ - bool findMissingFile( const QString& fileFilters, QDomNode& layerNode ); - - /** - * Find relocated data source for the given layer - * - * This QDom object represents a QgsProject node that maps to a specific layer. - * - * @param fileFilters file filters to use - * @param constLayerNode QDom node containing layer project information - * - * @todo - * - * XXX Only implemented for file based layers. It will need to be extended for - * XXX other data source types such as databases. - */ - bool findLayer( const QString& fileFilters, const QDomNode& constLayerNode ); - - /** - * Find relocated data sources for given layers - * These QDom objects represent QgsProject nodes that map to specific layers. - */ - void findLayers( const QString& fileFilters, const QList& layerNodes ); - -}; diff --git a/python/gui/qgsrasterformatsaveoptionswidget.sip b/python/gui/qgsrasterformatsaveoptionswidget.sip index 9ed1f7bc299..dcd372a64db 100644 --- a/python/gui/qgsrasterformatsaveoptionswidget.sip +++ b/python/gui/qgsrasterformatsaveoptionswidget.sip @@ -21,19 +21,70 @@ class QgsRasterFormatSaveOptionsWidget : QWidget const QString& provider = "gdal" ); ~QgsRasterFormatSaveOptionsWidget(); + /** + * Set output raster format, it is used to determine list + * of available options + */ void setFormat( const QString& format ); + + /** + * Set provider key, , it is used to determine list + * of available options + */ void setProvider( const QString& provider ); + + /** + * Set output raster layer + */ void setRasterLayer( QgsRasterLayer* rasterLayer ); + + /** + * Set output raster file name + */ void setRasterFileName( const QString& file ); + + /** + * Returns list of selected options + * @see setOptions() + */ QStringList options() const; + + /** + * Populate widget with user-defined options. String should contain + * key=value pairs separated by spaces, e.g. "TILED=YES TFW=YES" + * @see options() + * @note added in QGIS 3.0 + */ + void setOptions( const QString& options ); + + /** + * Set widget look and feel + */ void setType( QgsRasterFormatSaveOptionsWidget::Type type = Default ); + + /** + * Set pyramids format to use + */ void setPyramidsFormat( QgsRaster::RasterPyramidsFormat format ); public slots: void apply(); + + /** + * Opens window with options desctiption for given provider + * and output format + */ void helpOptions(); + + /** + * Validates options correctness + */ QString validateOptions( bool gui = true, bool reportOk = true ); + + /** + * Reloads profiles list from QGIS settings + */ void updateProfiles(); private slots: diff --git a/python/gui/qgsshortcutsmanager.sip b/python/gui/qgsshortcutsmanager.sip index a35c40c4580..a6a6b6d7fbb 100644 --- a/python/gui/qgsshortcutsmanager.sip +++ b/python/gui/qgsshortcutsmanager.sip @@ -18,7 +18,7 @@ class QgsShortcutsManager: QObject /** Constructor for QgsShortcutsManager. * @param parent parent object - * @param settingsRoot root QSettings path for storing settings, eg "/myplugin/shortcuts". Leave + * @param settingsRoot root QSettings path for storing settings, e.g., "/myplugin/shortcuts". Leave * as the default value to store settings alongside built in QGIS shortcuts, but care must be * taken to not register actions which conflict with the built in QGIS actions. */ diff --git a/python/gui/qgsvariableeditorwidget.sip b/python/gui/qgsvariableeditorwidget.sip index 1d8ea909e5b..f7b22bc3bd5 100644 --- a/python/gui/qgsvariableeditorwidget.sip +++ b/python/gui/qgsvariableeditorwidget.sip @@ -56,7 +56,7 @@ class QgsVariableEditorWidget : QWidget QgsExpressionContextScope* editableScope() const; /** Sets the setting group for the widget. QgsVariableEditorWidget widgets with - * the same setting group will synchronise their settings, eg the size + * the same setting group will synchronise their settings, e.g., the size * of columns in the tree widget. * @param group setting group * @see settingGroup() @@ -64,18 +64,13 @@ class QgsVariableEditorWidget : QWidget void setSettingGroup( const QString &group ); /** Returns the setting group for the widget. QgsVariableEditorWidget widgets with - * the same setting group will synchronise their settings, eg the size + * the same setting group will synchronise their settings, e.g., the size * of columns in the tree widget. * @returns setting group name * @see setSettingGroup() */ QString settingGroup() const; - - /** Returns a map variables set within the editable scope. Read only variables are not - * returned. This method can be used to retrieve the variables edited an added by - * users via the widget. - */ - QgsStringMap variablesInActiveScope() const; + QVariantMap variablesInActiveScope() const; signals: diff --git a/python/gui/raster/qgssinglebandpseudocolorrendererwidget.sip b/python/gui/raster/qgssinglebandpseudocolorrendererwidget.sip index 457b9764168..26e08029116 100644 --- a/python/gui/raster/qgssinglebandpseudocolorrendererwidget.sip +++ b/python/gui/raster/qgssinglebandpseudocolorrendererwidget.sip @@ -5,12 +5,6 @@ class QgsSingleBandPseudoColorRendererWidget : QgsRasterRendererWidget %End public: - enum Mode - { - Continuous, // Using breaks from color palette - EqualInterval, - Quantile, - }; QgsSingleBandPseudoColorRendererWidget( QgsRasterLayer* layer, const QgsRectangle &extent = QgsRectangle() ); ~QgsSingleBandPseudoColorRendererWidget(); diff --git a/python/gui/symbology-ng/qgslayerpropertieswidget.sip b/python/gui/symbology-ng/qgslayerpropertieswidget.sip index 83c4bcd69c8..4dafa18d934 100644 --- a/python/gui/symbology-ng/qgslayerpropertieswidget.sip +++ b/python/gui/symbology-ng/qgslayerpropertieswidget.sip @@ -7,14 +7,14 @@ class QgsLayerPropertiesWidget : QgsPanelWidget, QgsExpressionContextGenerator public: QgsLayerPropertiesWidget( QgsSymbolLayer* layer, const QgsSymbol* symbol, const QgsVectorLayer* vl, QWidget* parent /TransferThis/ = NULL ); - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ diff --git a/python/gui/symbology-ng/qgsrendererwidget.sip b/python/gui/symbology-ng/qgsrendererwidget.sip index 6da12f17437..1e782c6bee4 100644 --- a/python/gui/symbology-ng/qgsrendererwidget.sip +++ b/python/gui/symbology-ng/qgsrendererwidget.sip @@ -15,14 +15,14 @@ class QgsRendererWidget : QgsPanelWidget //! show a dialog with renderer's symbol level settings void showSymbolLevelsDialog( QgsFeatureRenderer* r ); - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ @@ -98,14 +98,14 @@ class QgsDataDefinedValueDialog : QDialog QgsDataDefinedValueDialog( const QList& symbolList, QgsVectorLayer * layer, const QString & label ); virtual ~QgsDataDefinedValueDialog(); - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ diff --git a/python/gui/symbology-ng/qgssymbollayerwidget.sip b/python/gui/symbology-ng/qgssymbollayerwidget.sip index 3cb73e39217..8834e7224fb 100644 --- a/python/gui/symbology-ng/qgssymbollayerwidget.sip +++ b/python/gui/symbology-ng/qgssymbollayerwidget.sip @@ -11,14 +11,14 @@ class QgsSymbolLayerWidget : QWidget virtual void setSymbolLayer( QgsSymbolLayer* layer ) = 0; virtual QgsSymbolLayer* symbolLayer() = 0; - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ diff --git a/python/gui/symbology-ng/qgssymbolselectordialog.sip b/python/gui/symbology-ng/qgssymbolselectordialog.sip index ec0a04ebd7c..defe6c2cdef 100644 --- a/python/gui/symbology-ng/qgssymbolselectordialog.sip +++ b/python/gui/symbology-ng/qgssymbolselectordialog.sip @@ -10,14 +10,14 @@ class QgsSymbolSelectorWidget : QgsPanelWidget //! return menu for "advanced" button - create it if doesn't exist and show the advanced button QMenu* advancedMenu(); - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ @@ -89,14 +89,14 @@ class QgsSymbolSelectorDialog : QDialog //! return menu for "advanced" button - create it if doesn't exist and show the advanced button QMenu* advancedMenu(); - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ diff --git a/python/gui/symbology-ng/qgssymbolslistwidget.sip b/python/gui/symbology-ng/qgssymbolslistwidget.sip index d7a7051a939..e5e1e534c10 100644 --- a/python/gui/symbology-ng/qgssymbolslistwidget.sip +++ b/python/gui/symbology-ng/qgssymbolslistwidget.sip @@ -6,14 +6,14 @@ class QgsSymbolsListWidget : QWidget public: QgsSymbolsListWidget( QgsSymbol* symbol, QgsStyle* style, QMenu* menu, QWidget* parent /TransferThis/ = 0, const QgsVectorLayer * layer = 0 ); - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ diff --git a/python/gui/symbology-ng/qgssymbolwidgetcontext.sip b/python/gui/symbology-ng/qgssymbolwidgetcontext.sip index dd270bf100b..9a9f7f277f2 100644 --- a/python/gui/symbology-ng/qgssymbolwidgetcontext.sip +++ b/python/gui/symbology-ng/qgssymbolwidgetcontext.sip @@ -1,7 +1,7 @@ /** \ingroup gui * \class QgsSymbolWidgetContext - * Contains settings which reflect the context in which a symbol (or renderer) widget is shown, eg the + * Contains settings which reflect the context in which a symbol (or renderer) widget is shown, e.g., the * map canvas and relevant expression contexts. * * \note added in QGIS 3.0 @@ -57,5 +57,11 @@ * @see setAdditionalExpressionContextScopes() */ QList< QgsExpressionContextScope > additionalExpressionContextScopes() const; + + /** Returns list of scopes: global, project, atlas, map, layer. + * Ownership is transferred to the caller. + * @note added in QGIS 3.0 + */ + QList globalProjectAtlasMapLayerScopes( const QgsMapLayer* layer ) const /Factory/; }; diff --git a/python/plugins/CMakeLists.txt b/python/plugins/CMakeLists.txt index f096755e8cc..7a3adc7af7d 100644 --- a/python/plugins/CMakeLists.txt +++ b/python/plugins/CMakeLists.txt @@ -49,7 +49,6 @@ MACRO (PLUGIN_INSTALL plugin subdir ) ENDFOREACH(file) ENDMACRO (PLUGIN_INSTALL) -ADD_SUBDIRECTORY(GdalTools) ADD_SUBDIRECTORY(db_manager) ADD_SUBDIRECTORY(processing) ADD_SUBDIRECTORY(MetaSearch) diff --git a/python/plugins/GdalTools/CMakeLists.txt b/python/plugins/GdalTools/CMakeLists.txt deleted file mode 100644 index 728670a727e..00000000000 --- a/python/plugins/GdalTools/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -FILE(GLOB INSTALLER_FILES *.py) -SET(INSTALLER_FILES ${INSTALLER_FILES}) - -FILE(GLOB UI_FILES *.ui) -PYQT_WRAP_UI(PYUI_FILES ${UI_FILES}) -PYQT_ADD_RESOURCES(PYRC_FILES resources.qrc) -#ADD_CUSTOM_TARGET(gdaltools ALL DEPENDS ${PYUI_FILES} ${PYRC_FILES}) - -SET(INSTALLER_FILES ${INSTALLER_FILES} ${PYUI_FILES} ${PYRC_FILES}) - -#INSTALL(FILES ${INSTALLER_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/GdalTools) -PLUGIN_INSTALL(GdalTools . ${INSTALLER_FILES} __init__.py metadata.txt) - -ADD_SUBDIRECTORY(tools) -ADD_SUBDIRECTORY(icons) diff --git a/python/plugins/GdalTools/GdalTools.py b/python/plugins/GdalTools/GdalTools.py deleted file mode 100644 index 827b49258db..00000000000 --- a/python/plugins/GdalTools/GdalTools.py +++ /dev/null @@ -1,421 +0,0 @@ -# -*- coding: utf-8 -*- -""" -/*************************************************************************** -Name : GdalTools -Description : Integrate gdal tools into qgis -Date : 17/Sep/09 -copyright : (C) 2009 by Lorenzo Masini (Faunalia) -email : lorenxo86@gmail.com - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ -""" -from builtins import str -from builtins import object -# Import the PyQt and QGIS libraries -from qgis.PyQt.QtCore import QCoreApplication, QSettings, QLocale, QFileInfo, QTranslator -from qgis.PyQt.QtWidgets import QMessageBox, QMenu, QAction -from qgis.PyQt.QtGui import QIcon -from qgis.core import Qgis, QgsWkbTypes -import qgis.utils - -# are all dependencies satisfied? -valid = True - -# Import required modules -req_mods = {"osgeo": "osgeo [python-gdal]"} -try: - from osgeo import gdal # NOQA - from osgeo import ogr # NOQA -except ImportError as e: - valid = False - - # if the plugin is shipped with Qgis catch the exception and - # display an error message - import os.path - qgisUserPluginPath = qgis.utils.home_plugin_path - if not os.path.dirname(__file__).startswith(qgisUserPluginPath): - title = QCoreApplication.translate("GdalTools", "Plugin error") - message = QCoreApplication.translate("GdalTools", u'Unable to load {0} plugin. \nThe required "{1}" module is missing. \nInstall it and try again.') - import qgis.utils - QMessageBox.warning(qgis.utils.iface.mainWindow(), title, message.format("GdalTools", req_mods["osgeo"])) - else: - # if a module is missing show a more friendly module's name - error_str = e.args[0] - error_mod = error_str.replace("No module named ", "") - if error_mod in req_mods: - error_str = error_str.replace(error_mod, req_mods[error_mod]) - raise ImportError(error_str) - - -class GdalTools(object): - - def __init__(self, iface): - if not valid: - return - - # Save reference to the QGIS interface - self.iface = iface - try: - self.QgisVersion = str(Qgis.QGIS_VERSION_INT) - except: - self.QgisVersion = str(Qgis.qgisVersion)[0] - - if Qgis.QGIS_VERSION[0:3] < "1.5": - # For i18n support - userPluginPath = qgis.utils.home_plugin_path + "/GdalTools" - systemPluginPath = qgis.utils.sys_plugin_path + "/GdalTools" - - overrideLocale = QSettings().value("locale/overrideFlag", False, type=bool) - if not overrideLocale: - localeFullName = QLocale.system().name() - else: - localeFullName = QSettings().value("locale/userLocale", "", type=str) - - if QFileInfo(userPluginPath).exists(): - translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm" - else: - translationPath = systemPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm" - - self.localePath = translationPath - if QFileInfo(self.localePath).exists(): - self.translator = QTranslator() - self.translator.load(self.localePath) - QCoreApplication.installTranslator(self.translator) - - # The list of actions added to menus, so we can remove them when unloading the plugin - self._menuActions = [] - - def initGui(self): - if not valid: - return - if int(self.QgisVersion) < 1: - QMessageBox.warning( - self.iface.getMainWindow(), "Gdal Tools", - QCoreApplication.translate("GdalTools", "QGIS version detected: ") + str(self.QgisVersion) + ".xx\n" - + QCoreApplication.translate("GdalTools", "This version of Gdal Tools requires at least QGIS version 1.0.0\nPlugin will not be enabled.")) - return None - - from .tools.GdalTools_utils import GdalConfig, LayerRegistry - self.GdalVersionNum = GdalConfig.versionNum() - LayerRegistry.setIface(self.iface) - - # find the Raster menu - rasterMenu = None - menu_bar = self.iface.mainWindow().menuBar() - actions = menu_bar.actions() - - rasterText = QCoreApplication.translate("QgisApp", "&Raster") - - for a in actions: - if a.menu() is not None and a.menu().title() == rasterText: - rasterMenu = a.menu() - break - - if rasterMenu is None: - # no Raster menu, create and insert it before the Help menu - self.menu = QMenu(rasterText, self.iface.mainWindow()) - lastAction = actions[len(actions) - 1] - menu_bar.insertMenu(lastAction, self.menu) - else: - self.menu = rasterMenu - self._menuActions.append(self.menu.addSeparator()) - - # projections menu (Warp (Reproject), Assign projection) - self.projectionsMenu = QMenu(QCoreApplication.translate("GdalTools", "Projections"), self.iface.mainWindow()) - self.projectionsMenu.setObjectName("projectionsMenu") - - self.warp = QAction(QIcon(":/icons/warp.png"), QCoreApplication.translate("GdalTools", "Warp (Reproject)..."), self.iface.mainWindow()) - self.warp.setObjectName("warp") - self.warp.setStatusTip(QCoreApplication.translate("GdalTools", "Warp an image into a new coordinate system")) - self.warp.triggered.connect(self.doWarp) - - self.projection = QAction(QIcon(":icons/projection-add.png"), QCoreApplication.translate("GdalTools", "Assign Projection..."), self.iface.mainWindow()) - self.projection.setObjectName("projection") - self.projection.setStatusTip(QCoreApplication.translate("GdalTools", "Add projection info to the raster")) - self.projection.triggered.connect(self.doProjection) - - self.extractProj = QAction(QIcon(":icons/projection-export.png"), QCoreApplication.translate("GdalTools", "Extract Projection..."), self.iface.mainWindow()) - self.extractProj.setObjectName("extractProj") - self.extractProj.setStatusTip(QCoreApplication.translate("GdalTools", "Extract projection information from raster(s)")) - self.extractProj.triggered.connect(self.doExtractProj) - - self.projectionsMenu.addActions([self.warp, self.projection, self.extractProj]) - - # conversion menu (Rasterize (Vector to raster), Polygonize (Raster to vector), Translate, RGB to PCT, PCT to RGB) - self.conversionMenu = QMenu(QCoreApplication.translate("GdalTools", "Conversion"), self.iface.mainWindow()) - self.conversionMenu.setObjectName("conversionMenu") - - if self.GdalVersionNum >= 1300: - self.rasterize = QAction(QIcon(":/icons/rasterize.png"), QCoreApplication.translate("GdalTools", "Rasterize (Vector to Raster)..."), self.iface.mainWindow()) - self.rasterize.setObjectName("rasterize") - self.rasterize.setStatusTip(QCoreApplication.translate("GdalTools", "Burns vector geometries into a raster")) - self.rasterize.triggered.connect(self.doRasterize) - self.conversionMenu.addAction(self.rasterize) - - if self.GdalVersionNum >= 1600: - self.polygonize = QAction(QIcon(":/icons/polygonize.png"), QCoreApplication.translate("GdalTools", "Polygonize (Raster to Vector)..."), self.iface.mainWindow()) - self.polygonize.setObjectName("polygonize") - self.polygonize.setStatusTip(QCoreApplication.translate("GdalTools", "Produces a polygon feature layer from a raster")) - self.polygonize.triggered.connect(self.doPolygonize) - self.conversionMenu.addAction(self.polygonize) - - self.translate = QAction(QIcon(":/icons/translate.png"), QCoreApplication.translate("GdalTools", "Translate (Convert Format)..."), self.iface.mainWindow()) - self.translate.setObjectName("translate") - self.translate.setStatusTip(QCoreApplication.translate("GdalTools", "Converts raster data between different formats")) - self.translate.triggered.connect(self.doTranslate) - - self.paletted = QAction(QIcon(":icons/24-to-8-bits.png"), QCoreApplication.translate("GdalTools", "RGB to PCT..."), self.iface.mainWindow()) - self.paletted.setObjectName("paletted") - self.paletted.setStatusTip(QCoreApplication.translate("GdalTools", "Convert a 24bit RGB image to 8bit paletted")) - self.paletted.triggered.connect(self.doPaletted) - - self.rgb = QAction(QIcon(":icons/8-to-24-bits.png"), QCoreApplication.translate("GdalTools", "PCT to RGB..."), self.iface.mainWindow()) - self.rgb.setObjectName("rgb") - self.rgb.setStatusTip(QCoreApplication.translate("GdalTools", "Convert an 8bit paletted image to 24bit RGB")) - self.rgb.triggered.connect(self.doRGB) - - self.conversionMenu.addActions([self.translate, self.paletted, self.rgb]) - - # extraction menu (Clipper, Contour) - self.extractionMenu = QMenu(QCoreApplication.translate("GdalTools", "Extraction"), self.iface.mainWindow()) - self.extractionMenu.setObjectName("extractionMenu") - - if self.GdalVersionNum >= 1600: - self.contour = QAction(QIcon(":/icons/contour.png"), QCoreApplication.translate("GdalTools", "Contour..."), self.iface.mainWindow()) - self.contour.setObjectName("contour") - self.contour.setStatusTip(QCoreApplication.translate("GdalTools", "Builds vector contour lines from a DEM")) - self.contour.triggered.connect(self.doContour) - self.extractionMenu.addAction(self.contour) - - self.clipper = QAction(QIcon(":icons/raster-clip.png"), QCoreApplication.translate("GdalTools", "Clipper..."), self.iface.mainWindow()) - self.clipper.setObjectName("clipper") - #self.clipper.setStatusTip( QCoreApplication.translate( "GdalTools", "Converts raster data between different formats") ) - self.clipper.triggered.connect(self.doClipper) - - self.extractionMenu.addActions([self.clipper]) - - # analysis menu (DEM (Terrain model), Grid (Interpolation), Near black, Proximity (Raster distance), Sieve) - self.analysisMenu = QMenu(QCoreApplication.translate("GdalTools", "Analysis"), self.iface.mainWindow()) - self.analysisMenu.setObjectName("analysisMenu") - - if self.GdalVersionNum >= 1600: - self.sieve = QAction(QIcon(":/icons/sieve.png"), QCoreApplication.translate("GdalTools", "Sieve..."), self.iface.mainWindow()) - self.sieve.setObjectName("sieve") - self.sieve.setStatusTip(QCoreApplication.translate("GdalTools", "Removes small raster polygons")) - self.sieve.triggered.connect(self.doSieve) - self.analysisMenu.addAction(self.sieve) - - if self.GdalVersionNum >= 1500: - self.nearBlack = QAction(QIcon(":/icons/nearblack.png"), QCoreApplication.translate("GdalTools", "Near Black..."), self.iface.mainWindow()) - self.nearBlack.setObjectName("nearBlack") - self.nearBlack.setStatusTip(QCoreApplication.translate("GdalTools", "Convert nearly black/white borders to exact value")) - self.nearBlack.triggered.connect(self.doNearBlack) - self.analysisMenu.addAction(self.nearBlack) - - if self.GdalVersionNum >= 1700: - self.fillNodata = QAction(QIcon(":/icons/fillnodata.png"), QCoreApplication.translate("GdalTools", "Fill nodata..."), self.iface.mainWindow()) - self.fillNodata.setObjectName("fillNodata") - self.fillNodata.setStatusTip(QCoreApplication.translate("GdalTools", "Fill raster regions by interpolation from edges")) - self.fillNodata.triggered.connect(self.doFillNodata) - self.analysisMenu.addAction(self.fillNodata) - - if self.GdalVersionNum >= 1600: - self.proximity = QAction(QIcon(":/icons/proximity.png"), QCoreApplication.translate("GdalTools", "Proximity (Raster Distance)..."), self.iface.mainWindow()) - self.proximity.setObjectName("proximity") - self.proximity.setStatusTip(QCoreApplication.translate("GdalTools", "Produces a raster proximity map")) - self.proximity.triggered.connect(self.doProximity) - self.analysisMenu.addAction(self.proximity) - - if self.GdalVersionNum >= 1500: - self.grid = QAction(QIcon(":/icons/grid.png"), QCoreApplication.translate("GdalTools", "Grid (Interpolation)..."), self.iface.mainWindow()) - self.grid.setObjectName("grid") - self.grid.setStatusTip(QCoreApplication.translate("GdalTools", "Create raster from the scattered data")) - self.grid.triggered.connect(self.doGrid) - self.analysisMenu.addAction(self.grid) - - if self.GdalVersionNum >= 1700: - self.dem = QAction(QIcon(":icons/dem.png"), QCoreApplication.translate("GdalTools", "DEM (Terrain Models)..."), self.iface.mainWindow()) - self.dem.setObjectName("dem") - self.dem.setStatusTip(QCoreApplication.translate("GdalTools", "Tool to analyze and visualize DEMs")) - self.dem.triggered.connect(self.doDEM) - self.analysisMenu.addAction(self.dem) - - #self.analysisMenu.addActions( [ ] ) - - # miscellaneous menu (Build overviews (Pyramids), Tile index, Information, Merge, Build Virtual Raster (Catalog)) - self.miscellaneousMenu = QMenu(QCoreApplication.translate("GdalTools", "Miscellaneous"), self.iface.mainWindow()) - self.miscellaneousMenu.setObjectName("miscellaneousMenu") - - if self.GdalVersionNum >= 1600: - self.buildVRT = QAction(QIcon(":/icons/vrt.png"), QCoreApplication.translate("GdalTools", "Build Virtual Raster (Catalog)..."), self.iface.mainWindow()) - self.buildVRT.setObjectName("buildVRT") - self.buildVRT.setStatusTip(QCoreApplication.translate("GdalTools", "Builds a VRT from a list of datasets")) - self.buildVRT.triggered.connect(self.doBuildVRT) - self.miscellaneousMenu.addAction(self.buildVRT) - - self.merge = QAction(QIcon(":/icons/merge.png"), QCoreApplication.translate("GdalTools", "Merge..."), self.iface.mainWindow()) - self.merge.setObjectName("merge") - self.merge.setStatusTip(QCoreApplication.translate("GdalTools", "Build a quick mosaic from a set of images")) - self.merge.triggered.connect(self.doMerge) - - self.info = QAction(QIcon(":/icons/raster-info.png"), QCoreApplication.translate("GdalTools", "Information..."), self.iface.mainWindow()) - self.info.setObjectName("info") - self.info.setStatusTip(QCoreApplication.translate("GdalTools", "Lists information about raster dataset")) - self.info.triggered.connect(self.doInfo) - - self.overview = QAction(QIcon(":icons/raster-overview.png"), QCoreApplication.translate("GdalTools", "Build Overviews (Pyramids)..."), self.iface.mainWindow()) - self.overview.setObjectName("overview") - self.overview.setStatusTip(QCoreApplication.translate("GdalTools", "Builds or rebuilds overview images")) - self.overview.triggered.connect(self.doOverview) - - self.tileindex = QAction(QIcon(":icons/tiles.png"), QCoreApplication.translate("GdalTools", "Tile Index..."), self.iface.mainWindow()) - self.tileindex.setObjectName("tileindex") - self.tileindex.setStatusTip(QCoreApplication.translate("GdalTools", "Build a shapefile as a raster tileindex")) - self.tileindex.triggered.connect(self.doTileIndex) - - self.miscellaneousMenu.addActions([self.merge, self.info, self.overview, self.tileindex]) - - self._menuActions.append(self.menu.addMenu(self.projectionsMenu)) - self._menuActions.append(self.menu.addMenu(self.conversionMenu)) - self._menuActions.append(self.menu.addMenu(self.extractionMenu)) - - if not self.analysisMenu.isEmpty(): - self._menuActions.append(self.menu.addMenu(self.analysisMenu)) - - self._menuActions.append(self.menu.addMenu(self.miscellaneousMenu)) - - self.settings = QAction(QCoreApplication.translate("GdalTools", "GdalTools Settings..."), self.iface.mainWindow()) - self.settings.setObjectName("settings") - self.settings.setStatusTip(QCoreApplication.translate("GdalTools", "Various settings for Gdal Tools")) - self.settings.triggered.connect(self.doSettings) - self.menu.addAction(self.settings) - self._menuActions.append(self.settings) - - def unload(self): - if not valid: - return - for a in self._menuActions: - self.menu.removeAction(a) - - def doBuildVRT(self): - from .tools.doBuildVRT import GdalToolsDialog as BuildVRT - d = BuildVRT(self.iface) - self.runToolDialog(d) - - def doContour(self): - from .tools.doContour import GdalToolsDialog as Contour - d = Contour(self.iface) - self.runToolDialog(d) - - def doRasterize(self): - from .tools.doRasterize import GdalToolsDialog as Rasterize - d = Rasterize(self.iface) - self.runToolDialog(d) - - def doPolygonize(self): - from .tools.doPolygonize import GdalToolsDialog as Polygonize - d = Polygonize(self.iface) - self.runToolDialog(d) - - def doMerge(self): - from .tools.doMerge import GdalToolsDialog as Merge - d = Merge(self.iface) - self.runToolDialog(d) - - def doSieve(self): - from .tools.doSieve import GdalToolsDialog as Sieve - d = Sieve(self.iface) - self.runToolDialog(d) - - def doProximity(self): - from .tools.doProximity import GdalToolsDialog as Proximity - d = Proximity(self.iface) - self.runToolDialog(d) - - def doNearBlack(self): - from .tools.doNearBlack import GdalToolsDialog as NearBlack - d = NearBlack(self.iface) - self.runToolDialog(d) - - def doFillNodata(self): - from .tools.doFillNodata import GdalToolsDialog as FillNodata - d = FillNodata(self.iface) - self.runToolDialog(d) - - def doWarp(self): - from .tools.doWarp import GdalToolsDialog as Warp - d = Warp(self.iface) - self.runToolDialog(d) - - def doGrid(self): - from .tools.doGrid import GdalToolsDialog as Grid - d = Grid(self.iface) - self.runToolDialog(d) - - def doTranslate(self): - from .tools.doTranslate import GdalToolsDialog as Translate - d = Translate(self.iface) - self.runToolDialog(d) - - def doInfo(self): - from .tools.doInfo import GdalToolsDialog as Info - d = Info(self.iface) - self.runToolDialog(d) - - def doProjection(self): - from .tools.doProjection import GdalToolsDialog as Projection - d = Projection(self.iface) - self.runToolDialog(d) - - def doOverview(self): - from .tools.doOverview import GdalToolsDialog as Overview - d = Overview(self.iface) - self.runToolDialog(d) - - def doClipper(self): - from .tools.doClipper import GdalToolsDialog as Clipper - d = Clipper(self.iface) - self.runToolDialog(d) - - def doPaletted(self): - from .tools.doRgbPct import GdalToolsDialog as RgbPct - d = RgbPct(self.iface) - self.runToolDialog(d) - - def doRGB(self): - from .tools.doPctRgb import GdalToolsDialog as PctRgb - d = PctRgb(self.iface) - self.runToolDialog(d) - - def doTileIndex(self): - from .tools.doTileIndex import GdalToolsDialog as TileIndex - d = TileIndex(self.iface) - self.runToolDialog(d) - - def doExtractProj(self): - from .tools.doExtractProj import GdalToolsDialog as ExtractProj - d = ExtractProj(self.iface) - d.exec_() - - def doDEM(self): - from .tools.doDEM import GdalToolsDialog as DEM - d = DEM(self.iface) - self.runToolDialog(d) - - def runToolDialog(self, dlg): - dlg.show_() - dlg.exec_() - del dlg - - def doSettings(self): - from .tools.doSettings import GdalToolsSettingsDialog as Settings - d = Settings(self.iface) - d.exec_() diff --git a/python/plugins/GdalTools/LICENSE b/python/plugins/GdalTools/LICENSE deleted file mode 100644 index cba047e0f4a..00000000000 --- a/python/plugins/GdalTools/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2009 Faunalia - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - diff --git a/python/plugins/GdalTools/__init__.py b/python/plugins/GdalTools/__init__.py deleted file mode 100644 index 0da88a213c7..00000000000 --- a/python/plugins/GdalTools/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -""" -/*************************************************************************** -Name : GdalTools -Description : Integrate gdal tools into qgis -Date : 17/Sep/09 -copyright : (C) 2009 by Lorenzo Masini and Giuseppe Sucameli (Faunalia) -email : lorenxo86@gmail.com - brush.tyler@gmail.com - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - This script initializes the plugin, making it known to QGIS. -""" - - -def classFactory(iface): - # load GdalTools class from file GdalTools - from .GdalTools import GdalTools - return GdalTools(iface) diff --git a/python/plugins/GdalTools/icons/24-to-8-bits.png b/python/plugins/GdalTools/icons/24-to-8-bits.png deleted file mode 100644 index d623b13781f..00000000000 Binary files a/python/plugins/GdalTools/icons/24-to-8-bits.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/8-to-24-bits.png b/python/plugins/GdalTools/icons/8-to-24-bits.png deleted file mode 100644 index 9880b620404..00000000000 Binary files a/python/plugins/GdalTools/icons/8-to-24-bits.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/CMakeLists.txt b/python/plugins/GdalTools/icons/CMakeLists.txt deleted file mode 100644 index e4b3dae446e..00000000000 --- a/python/plugins/GdalTools/icons/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -FILE(GLOB ICON_FILES *.png) -PLUGIN_INSTALL(GdalTools icons ${ICON_FILES}) diff --git a/python/plugins/GdalTools/icons/about.png b/python/plugins/GdalTools/icons/about.png deleted file mode 100644 index d60425f7ec6..00000000000 Binary files a/python/plugins/GdalTools/icons/about.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/contour.png b/python/plugins/GdalTools/icons/contour.png deleted file mode 100644 index 6e8df91bdd7..00000000000 Binary files a/python/plugins/GdalTools/icons/contour.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/dem.png b/python/plugins/GdalTools/icons/dem.png deleted file mode 100644 index 08ec6f46faa..00000000000 Binary files a/python/plugins/GdalTools/icons/dem.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/edit.png b/python/plugins/GdalTools/icons/edit.png deleted file mode 100644 index ade7a46daae..00000000000 Binary files a/python/plugins/GdalTools/icons/edit.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/fillnodata.png b/python/plugins/GdalTools/icons/fillnodata.png deleted file mode 100644 index 08ec6f46faa..00000000000 Binary files a/python/plugins/GdalTools/icons/fillnodata.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/grid.png b/python/plugins/GdalTools/icons/grid.png deleted file mode 100644 index 72958fa4411..00000000000 Binary files a/python/plugins/GdalTools/icons/grid.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/merge.png b/python/plugins/GdalTools/icons/merge.png deleted file mode 100644 index 62cd95c9b83..00000000000 Binary files a/python/plugins/GdalTools/icons/merge.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/nearblack.png b/python/plugins/GdalTools/icons/nearblack.png deleted file mode 100644 index d79cb0d6f91..00000000000 Binary files a/python/plugins/GdalTools/icons/nearblack.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/polygonize.png b/python/plugins/GdalTools/icons/polygonize.png deleted file mode 100644 index 1aab12120b8..00000000000 Binary files a/python/plugins/GdalTools/icons/polygonize.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/projection-add.png b/python/plugins/GdalTools/icons/projection-add.png deleted file mode 100644 index 5955dac9cba..00000000000 Binary files a/python/plugins/GdalTools/icons/projection-add.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/projection-export.png b/python/plugins/GdalTools/icons/projection-export.png deleted file mode 100644 index aed061ce214..00000000000 Binary files a/python/plugins/GdalTools/icons/projection-export.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/proximity.png b/python/plugins/GdalTools/icons/proximity.png deleted file mode 100644 index 3c85ef6efd0..00000000000 Binary files a/python/plugins/GdalTools/icons/proximity.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/raster-clip.png b/python/plugins/GdalTools/icons/raster-clip.png deleted file mode 100644 index f26b04c22b7..00000000000 Binary files a/python/plugins/GdalTools/icons/raster-clip.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/raster-info.png b/python/plugins/GdalTools/icons/raster-info.png deleted file mode 100644 index de5cb4e4be0..00000000000 Binary files a/python/plugins/GdalTools/icons/raster-info.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/raster-overview.png b/python/plugins/GdalTools/icons/raster-overview.png deleted file mode 100644 index 909803648df..00000000000 Binary files a/python/plugins/GdalTools/icons/raster-overview.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/raster-rgb.png b/python/plugins/GdalTools/icons/raster-rgb.png deleted file mode 100644 index 08ec6f46faa..00000000000 Binary files a/python/plugins/GdalTools/icons/raster-rgb.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/rasterize.png b/python/plugins/GdalTools/icons/rasterize.png deleted file mode 100644 index d04d3d72d21..00000000000 Binary files a/python/plugins/GdalTools/icons/rasterize.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/reset.png b/python/plugins/GdalTools/icons/reset.png deleted file mode 100644 index 3fa8db76996..00000000000 Binary files a/python/plugins/GdalTools/icons/reset.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/sieve.png b/python/plugins/GdalTools/icons/sieve.png deleted file mode 100644 index 6f307e2b97e..00000000000 Binary files a/python/plugins/GdalTools/icons/sieve.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/tiles.png b/python/plugins/GdalTools/icons/tiles.png deleted file mode 100644 index ecc36553293..00000000000 Binary files a/python/plugins/GdalTools/icons/tiles.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/tooltip.png b/python/plugins/GdalTools/icons/tooltip.png deleted file mode 100644 index 3603b95aa9d..00000000000 Binary files a/python/plugins/GdalTools/icons/tooltip.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/translate.png b/python/plugins/GdalTools/icons/translate.png deleted file mode 100644 index a54c2c3918d..00000000000 Binary files a/python/plugins/GdalTools/icons/translate.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/vrt.png b/python/plugins/GdalTools/icons/vrt.png deleted file mode 100644 index 62b6229c80f..00000000000 Binary files a/python/plugins/GdalTools/icons/vrt.png and /dev/null differ diff --git a/python/plugins/GdalTools/icons/warp.png b/python/plugins/GdalTools/icons/warp.png deleted file mode 100644 index 21420a28e4d..00000000000 Binary files a/python/plugins/GdalTools/icons/warp.png and /dev/null differ diff --git a/python/plugins/GdalTools/metadata.txt b/python/plugins/GdalTools/metadata.txt deleted file mode 100644 index d0d172c24fa..00000000000 --- a/python/plugins/GdalTools/metadata.txt +++ /dev/null @@ -1,13 +0,0 @@ -[general] -name=GdalTools -description=Integrate GDAL tools into QGIS -category=Raster -version=1.2.29 -qgisMinimumVersion=2.0 - -author=Giuseppe Sucameli (Faunalia) -email=brush.tyler@gmail.com - -icon=icons/raster-info.png - -class_name=GdalTools diff --git a/python/plugins/GdalTools/resources.qrc b/python/plugins/GdalTools/resources.qrc deleted file mode 100644 index 1deefc2093e..00000000000 --- a/python/plugins/GdalTools/resources.qrc +++ /dev/null @@ -1,30 +0,0 @@ - - - icons/contour.png - icons/merge.png - icons/polygonize.png - icons/rasterize.png - icons/sieve.png - icons/vrt.png - icons/warp.png - icons/proximity.png - icons/nearblack.png - icons/grid.png - icons/translate.png - icons/raster-info.png - icons/projection-add.png - icons/raster-overview.png - icons/raster-clip.png - icons/raster-rgb.png - icons/tiles.png - icons/about.png - icons/dem.png - icons/projection-export.png - icons/fillnodata.png - icons/24-to-8-bits.png - icons/8-to-24-bits.png - icons/edit.png - icons/reset.png - icons/tooltip.png - - diff --git a/python/plugins/GdalTools/tools/CMakeLists.txt b/python/plugins/GdalTools/tools/CMakeLists.txt deleted file mode 100644 index 59409186ef2..00000000000 --- a/python/plugins/GdalTools/tools/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -FILE(GLOB PY_FILES *.py) -FILE(GLOB UI_FILES *.ui) -FILE(GLOB COLOR_CONFIG_FILES terrain.txt) - -PYQT_WRAP_UI(PYUI_FILES ${UI_FILES}) - -PLUGIN_INSTALL(GdalTools tools ${PY_FILES} ${PYUI_FILES} ${COLOR_CONFIG_FILES}) - diff --git a/python/plugins/GdalTools/tools/GdalTools_utils.py b/python/plugins/GdalTools/tools/GdalTools_utils.py deleted file mode 100644 index 81d23e60b4d..00000000000 --- a/python/plugins/GdalTools/tools/GdalTools_utils.py +++ /dev/null @@ -1,985 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - GdalTools_utils.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import filter -from builtins import map -from builtins import str -from builtins import range -from builtins import object - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -# Utility functions -# ------------------------------------------------- -# getLastUsedDir() -# setLastUsedDir( QString *file_or_dir path ) -# ------------------------------------------------- - -from qgis.PyQt.QtCore import QObject, QSettings, QFileInfo, QDir, QCoreApplication, pyqtSignal -from qgis.PyQt.QtWidgets import QFileDialog - -from qgis.core import QgsApplication, QgsRectangle, QgsProviderRegistry, QgsLogger, QgsProject -from qgis.gui import QgsEncodingFileDialog - -from osgeo import gdal, ogr, osr - -import os -# to know the os -import platform -import sys -import string -import re - -# Escapes arguments and return them joined in a string - - -def escapeAndJoin(strList): - joined = '' - for s in strList: - if s.find(" ") is not -1: - escaped = '"' + s.replace('\\', '\\\\').replace('"', '\\"') + '"' - else: - escaped = s - joined += escaped + " " - return joined.strip() - -# Retrieves last used dir from persistent settings - - -def getLastUsedDir(): - settings = QSettings() - lastProjectDir = settings.value("/UI/lastProjectDir", u".", type=str) - return settings.value("/GdalTools/lastUsedDir", lastProjectDir, type=str) - -# Stores last used dir in persistent settings - - -def setLastUsedDir(filePath): - settings = QSettings() - fileInfo = QFileInfo(filePath) - if fileInfo.isDir(): - dirPath = fileInfo.filePath() - else: - dirPath = fileInfo.path() - settings.setValue("/GdalTools/lastUsedDir", dirPath) - -# Retrieves GDAL binaries location - - -def getGdalBinPath(): - settings = QSettings() - return settings.value("/GdalTools/gdalPath", u"", type=str) - -# Stores GDAL binaries location - - -def setGdalBinPath(path): - settings = QSettings() - settings.setValue("/GdalTools/gdalPath", path) - -# Retrieves GDAL python modules location - - -def getGdalPymodPath(): - settings = QSettings() - return settings.value("/GdalTools/gdalPymodPath", u"", type=str) - -# Stores GDAL python modules location - - -def setGdalPymodPath(path): - settings = QSettings() - settings.setValue("/GdalTools/gdalPymodPath", path) - -# Retrieves GDAL help files location - - -def getHelpPath(): - settings = QSettings() - return settings.value("/GdalTools/helpPath", u"", type=str) - -# Stores GDAL help files location - - -def setHelpPath(path): - settings = QSettings() - settings.setValue("/GdalTools/helpPath", path) - -# Retrieves last used encoding from persistent settings - - -def getLastUsedEncoding(): - settings = QSettings() - return settings.value("/UI/encoding", u"System", type=str) - -# Stores last used encoding in persistent settings - - -def setLastUsedEncoding(encoding): - settings = QSettings() - settings.setValue("/UI/encoding", encoding) - - -def getRasterExtensions(): - formats = FileFilter.allRastersFilter().split(";;") - extensions = [] - for f in formats: - if string.find(f, "*.bt") is not -1 or string.find(f, "*.mpr") is not -1: # Binary Terrain or ILWIS - continue - extensions.extend(FileFilter.getFilterExtensions(f)) - return extensions - - -def getVectorExtensions(): - formats = FileFilter.allVectorsFilter().split(";;") - extensions = [] - for f in formats: - extensions.extend(FileFilter.getFilterExtensions(f)) - return extensions - - -class LayerRegistry(QObject): - layersChanged = pyqtSignal() - - _instance = None - _iface = None - - @staticmethod - def instance(): - if LayerRegistry._instance is None: - LayerRegistry._instance = LayerRegistry() - return LayerRegistry._instance - - @staticmethod - def setIface(iface): - LayerRegistry._iface = iface - - layers = [] - - def __init__(self): - QObject.__init__(self) - if LayerRegistry._instance is not None: - return - - LayerRegistry.layers = self.getAllLayers() - LayerRegistry._instance = self - QgsProject.instance().removeAll.connect(self.removeAllLayers) - QgsProject.instance().layerWasAdded.connect(self.layerAdded) - QgsProject.instance().layerWillBeRemoved.connect(self.removeLayer) - - def getAllLayers(self): - return list(node.layer() for node in QgsProject.instance().layerTreeRoot().findLayers()) - - def layerAdded(self, layer): - LayerRegistry.layers.append(layer) - self.layersChanged.emit() - - def removeLayer(self, layerId): - LayerRegistry.layers = [x for x in LayerRegistry.layers if x.id() != layerId] - self.layersChanged.emit() - - def removeAllLayers(self): - LayerRegistry.layers = [] - self.layersChanged.emit() - - @classmethod - def isRaster(self, layer): - # only gdal raster layers - if layer.type() != layer.RasterLayer: - return False - if layer.providerType() != 'gdal': - return False - return True - - def getRasterLayers(self): - return list(filter(self.isRaster, LayerRegistry.layers)) - - @classmethod - def isVector(self, layer): - if layer.type() != layer.VectorLayer: - return False - if layer.providerType() != 'ogr': - return False - return True - - def getVectorLayers(self): - return list(filter(self.isVector, LayerRegistry.layers)) - - -def getRasterFiles(path, recursive=False): - rasters = [] - if not QFileInfo(path).exists(): - return rasters - - # TODO remove *.aux.xml - _filter = getRasterExtensions() - workDir = QDir(path) - workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot) - workDir.setNameFilters(_filter) - files = workDir.entryList() - for f in files: - rasters.append(path + "/" + f) - - if recursive: - for myRoot, myDirs, myFiles in os.walk(str(path)): - for dir in myDirs: - workDir = QDir(myRoot + "/" + dir) - workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot) - workDir.setNameFilters(_filter) - workFiles = workDir.entryList() - for f in workFiles: - rasters.append(myRoot + "/" + dir + "/" + f) - - return rasters - - -def fillRasterOutputFormat(aFilter=None, filename=None): - shortName = '' - - if aFilter is not None: - supportedRasters = GdalConfig.getSupportedRasters() - filterName = re.sub('^.*\] ', '', FileFilter.getFilterName(aFilter)) - if filterName is supportedRasters: - return supportedRasters[filterName]["SHORTNAME"] - - shortName = GdalConfig.SupportedRasters.long2ShortName(filterName) - - if shortName == '' and filename is not None: - shortName = GdalConfig.SupportedRasters.filename2ShortName(filename) - - if shortName == '': - shortName = "GTiff" - - return shortName - - -def fillVectorOutputFormat(aFilter=None, filename=None): - shortName = '' - - if aFilter is not None: - supportedVectors = GdalConfig.getSupportedVectors() - filterName = re.sub('^.*\] ', '', FileFilter.getFilterName(aFilter)) - if filterName in supportedVectors: - return supportedVectors[filterName]["SHORTNAME"] - - pass # shortName = GdalConfig.SupportedVectors.long2ShortName(filterName) - - if shortName == '' and filename is not None: - pass # shortName = GdalConfig.SupportedVectors.filename2ShortName(filename) - - if shortName == '': - shortName = "ESRI Shapefile" - - return shortName - - -class UnsupportedOGRFormat(Exception): - - def __init__(self): - msg = QCoreApplication.translate("GdalTools", "The selected file is not a supported OGR format") - Exception.__init__(self, msg) - - -def getVectorFields(vectorFile): - hds = ogr.Open(str(vectorFile).encode('utf8')) - if hds is None: - raise UnsupportedOGRFormat() - - fields = [] - names = [] - - layer = hds.GetLayer(0) - defn = layer.GetLayerDefn() - - for i in range(defn.GetFieldCount()): - fieldDefn = defn.GetFieldDefn(i) - fieldType = fieldDefn.GetType() - if fieldType == 0 or fieldType == 2: - fields.append(fieldDefn) - names.append(fieldDefn.GetName()) - - return (fields, names) - -# get raster SRS if possible - - -def getRasterSRS(parent, fileName): - ds = gdal.Open(fileName) - if ds is None: - return '' - - proj = ds.GetProjectionRef() - if proj is None: - return '' - - sr = osr.SpatialReference() - if sr.ImportFromWkt(proj) != gdal.CE_None: - return '' - - name = sr.GetAuthorityName(None) - code = sr.GetAuthorityCode(None) - if name is not None and code is not None: - return '%s:%s' % (name, code) - - return '' - -# get raster extent using python API - replaces old method which parsed gdalinfo output - - -def getRasterExtent(parent, fileName): - ds = gdal.Open(fileName) - if ds is None: - return - - x = ds.RasterXSize - y = ds.RasterYSize - - gt = ds.GetGeoTransform() - if gt is None: - xUL = 0 - yUL = 0 - xLR = x - yLR = y - else: - xUL = gt[0] - yUL = gt[3] - xLR = gt[0] + gt[1] * x + gt[2] * y - yLR = gt[3] + gt[4] * x + gt[5] * y - - return QgsRectangle(xUL, yLR, xLR, yUL) - - -# get raster resolution - -def getRasterResolution(fileName): - ds = gdal.Open(fileName) - if ds is None: - return - - gt = ds.GetGeoTransform() - - if gt is None: - return - else: - xRes = abs(gt[1]) - yRes = abs(gt[5]) - return (xRes, yRes) - -# This class is used to replace the QFileDialog class. -# Its static methods are used in place of the respective QFileDialog ones to: -# 1. set the last used directory -# 2. append the selected extension to the file name -# 3. bypass the following bug: -# when you use the 'filter' argument, the dialog is enlarged up to the longest filter length, -# so sometimes the dialog excedes the screen width - - -class FileDialog(object): - - @classmethod - def getDialog(self, parent=None, caption='', acceptMode=QFileDialog.AcceptOpen, fileMode=QFileDialog.ExistingFile, filter='', selectedFilter=None, useEncoding=False): - if useEncoding: - dialog = QgsEncodingFileDialog(parent, caption, getLastUsedDir(), filter, getLastUsedEncoding()) - else: - dialog = QFileDialog(parent, caption, getLastUsedDir(), filter) - dialog.setFileMode(fileMode) - dialog.setAcceptMode(acceptMode) - - if selectedFilter is not None: - dialog.selectNameFilter(selectedFilter[0]) - - if not dialog.exec_(): - if useEncoding: - return ('', None) - return '' - - # change the selected filter value - if selectedFilter is not None: - selectedFilter[0] = dialog.selectedNameFilter() - - # save the last used dir and return the selected files - files = dialog.selectedFiles() - if files != '': - setLastUsedDir(files[0]) - - if fileMode != QFileDialog.ExistingFiles: - files = files[0] - # append the extension if not already present - if fileMode == QFileDialog.AnyFile: - firstExt = None - for ext in FileFilter.getFilterExtensions(dialog.selectedNameFilter()): - if FileFilter.filenameMatchesFilterExt(files, ext): - firstExt = None - break - - if firstExt is None: - firstExt = ext - - if firstExt is not None: - if firstExt.startswith('*'): - files += firstExt[1:] - - if useEncoding: - encoding = dialog.encoding() - # encoding setted yet by QgsEncodingFileDialog - #setLastUsedEncoding(encoding) - return (files, encoding) - - return files - - @classmethod - def getOpenFileNames(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False): - if useEncoding: - return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFiles, filter, selectedFilter, useEncoding) - res, selected_filter = QFileDialog.getOpenFileNames(parent, caption, getLastUsedDir(), filter) - if len(res) > 0: - setLastUsedDir(res[-1]) - return res - - @classmethod - def getOpenFileName(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False): - if useEncoding: - return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFile, filter, selectedFilter, useEncoding) - res, selected_filter = QFileDialog.getOpenFileName(parent, caption, getLastUsedDir(), filter) - if res: - setLastUsedDir(res) - return res - - @classmethod - def getSaveFileName(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False): - if useEncoding: - return self.getDialog(parent, caption, QFileDialog.AcceptSave, QFileDialog.AnyFile, filter, selectedFilter, useEncoding) - res, filter = QFileDialog.getSaveFileName(parent, caption, getLastUsedDir(), filter) - if res: - setLastUsedDir(res) - return res - - @classmethod - def getExistingDirectory(self, parent=None, caption='', useEncoding=False): - if useEncoding: - return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.DirectoryOnly, '', None, useEncoding) - res = QFileDialog.getExistingDirectory(parent, caption, getLastUsedDir(), QFileDialog.ShowDirsOnly) - if res: - setLastUsedDir(res) - return res - - -class FileFilter(object): - - @classmethod - def getFilter(self, typeName): - settings = QSettings() - return settings.value("/GdalTools/" + typeName + "FileFilter", u"", type=str) - - @classmethod - def setFilter(self, typeName, aFilter): - settings = QSettings() - settings.setValue("/GdalTools/" + typeName + "FileFilter", aFilter) - - # stores the supported raster file filter - rastersFilter = '' - - # Retrieves the filter for supported raster files - @classmethod - def allRastersFilter(self): - if self.rastersFilter == '': - self.rastersFilter = QgsProviderRegistry.instance().fileRasterFilters() - - # workaround for Qgis < 1.5 (see #2376) - # removed as this is a core plugin Qgis >= 1.9 - - return self.rastersFilter - - # Retrieves the filter for supported raster files to save - # Skip *, *.zip and *.vrt and move tif to top - # TODO: only the formats with GDAL_DCAP_CREATE - @classmethod - def saveRastersFilter(self): - # move tif to top if available - available = self.allRastersFilter().split(";;") - - filters = [] - - for f in available: - if "*.tif" in f: - filters.append(f) - break - - for f in available: - if "*.tif" in f or "*.zip" in f or "(*)" in f: - continue - - filters.append(f) - - return ";;".join(filters) - - # Retrieves the last used filter for raster files - # Note: filter string is in a list - @classmethod - def lastUsedRasterFilter(self): - return [self.getFilter("lastRaster")] - - @classmethod - def setLastUsedRasterFilter(self, aFilter): - self.setFilter("lastRaster", aFilter[0]) - - # stores the supported vectors file filter - vectorsFilter = '' - - # Retrieves the filter for supported vector files - @classmethod - def allVectorsFilter(self): - if self.vectorsFilter == '': - self.vectorsFilter = QgsProviderRegistry.instance().fileVectorFilters() - return self.vectorsFilter - - # Retrieves the last used filter for vector files - # Note: filter string is in a list - @classmethod - def lastUsedVectorFilter(self): - return [self.getFilter("lastVector")] - - @classmethod - def setLastUsedVectorFilter(self, aFilter): - self.setFilter("lastVector", aFilter[0]) - - # Retrieves the extensions list from a filter string - @classmethod - def getFilterExtensions(self, aFilter): - extList = [] - # foreach format in filter string - for f in aFilter.split(";;"): - # gets the list of extensions from the filter - exts = re.sub('\).*$', '', re.sub('^.*\(', '', f)) - # if there is no extensions or the filter matches all, then return an empty list - # otherwise return the list of estensions - if exts != '' and exts != "*" and exts != "*.*": - extList.extend(exts.split(" ")) - return extList - - @classmethod - def getFilterName(self, aFilter): - if isinstance(aFilter, list): - if len(aFilter): - aFilter = aFilter[0] - else: - aFilter = "" - return string.strip(re.sub('\ \(.*$', '', aFilter)) - - @classmethod - def filenameMatchesFilterExt(self, fileName, ext): - return re.match('.' + str(ext), fileName) is not None - -# Retrieves gdal information - - -class GdalConfig(object): - # retrieves and return the installed gdal version - - @classmethod - def version(self): - return Version(gdal.VersionInfo("RELEASE_NAME")) - - @classmethod - def versionNum(self): - return int(gdal.VersionInfo("VERSION_NUM")) - - # store the supported rasters info - supportedRasters = None - - # retrieve the supported rasters info - @classmethod - def getSupportedRasters(self): - if self.supportedRasters is not None: - return self.supportedRasters - - # first get the GDAL driver manager - if gdal.GetDriverCount() == 0: - gdal.AllRegister() - - self.supportedRasters = dict() - jp2Driver = None - - # for each loaded GDAL driver - for i in range(gdal.GetDriverCount()): - driver = gdal.GetDriver(i) - - if driver is None: - QgsLogger.warning("unable to get driver " + str(i)) - continue - - # now we need to see if the driver is for something currently - # supported; if not, we give it a miss for the next driver - - longName = string.strip(re.sub('\(.*$', '', driver.LongName)) - shortName = string.strip(re.sub('\(.*$', '', driver.ShortName)) - extensions = '' - - description = driver.GetDescription() - glob = [] - - metadata = driver.GetMetadata() - if gdal.DMD_EXTENSION in metadata: - extensions = str(metadata[gdal.DMD_EXTENSION]) - - if longName != '': - if extensions != '': - # XXX add check for SDTS; in that case we want (*CATD.DDF) - - #TODO fix and test - #glob.append( QString("*." + extensions.replace("/", " *.")).split(" ")) - glob.append(string.split("*." + string.replace(extensions, "/", " *."), sep=(" "))) - - # Add only the first JP2 driver found to the filter list (it's the one GDAL uses) - if description == "JPEG2000" or description.startswith("JP2"): # JP2ECW, JP2KAK, JP2MrSID - if jp2Driver is not None: - continue # skip if already found a JP2 driver - jp2Driver = driver # first JP2 driver found - glob.append("*.j2k") # add alternate extension - elif description == "GTiff": - glob.append("*.tiff") - elif description == "JPEG": - glob.append("*.jpeg") - else: - # USGS DEMs use "*.dem" - if description.startswith("USGSDEM"): - glob.append("*.dem") - elif description.startswith("DTED"): - # DTED use "*.dt0" - glob.append("*.dt0") - elif description.startswith("MrSID"): - # MrSID use "*.sid" - glob.append("*.sid") - else: - continue - - self.supportedRasters[longName] = {'EXTENSIONS': glob, 'LONGNAME': longName, 'SHORTNAME': shortName, 'DESCRIPTION': description} - - return self.supportedRasters - - # store the supported vectors info - supportedVectors = None - - # retrieve the supported vectors info - @classmethod - def getSupportedVectors(self): - if self.supportedVectors is not None: - return self.supportedVectors - - # first get the OGR driver manager - QgsApplication.registerOgrDrivers() - - self.supportedVectors = dict() - - # for each loaded OGR driver - for i in range(ogr.GetDriverCount()): - driver = ogr.GetDriver(i) - - if driver is None: - QgsLogger.warning("unable to get driver " + str(i)) - continue - - driverName = driver.GetName() - longName = '' - glob = [] - - if driverName.startswith("AVCBin"): - pass # myDirectoryDrivers += "Arc/Info Binary Coverage,AVCBin" - elif driverName.startswith("AVCE00"): - longName = "Arc/Info ASCII Coverage" - glob.append("*.e00") - elif driverName.startswith("BNA"): - longName = "Atlas BNA" - glob.append("*.bna") - elif driverName.startswith("CSV"): - longName = "Comma Separated Value" - glob.append("*.csv") - elif driverName.startswith("DODS"): - pass # myProtocolDrivers += "DODS/OPeNDAP,DODS" - elif driverName.startswith("PGeo"): - pass # myDatabaseDrivers += "ESRI Personal GeoDatabase,PGeo" - - # on Windows add a pair to the dict for this driver - if platform.system() == "Windows": - longName = "ESRI Personal GeoDatabase" - glob.append("*.mdb") - elif driverName.startswith("SDE"): - pass # myDatabaseDrivers += "ESRI ArcSDE,SDE" - elif driverName.startswith("ESRI"): - longName = "ESRI Shapefiles" - glob.append("*.shp") - elif driverName.startswith("FMEObjects Gateway"): - longName = "FMEObjects Gateway" - glob.append("*.fdd") - elif driverName.startswith("GeoJSON"): - pass # myProtocolDrivers += "GeoJSON,GeoJSON" - longName = "GeoJSON" - glob.append("*.geojson") - elif driverName.startswith("GeoRSS"): - longName = "GeoRSS" - glob.append("*.xml") - elif driverName.startswith("GML"): - longName = "Geography Markup Language" - glob.append("*.gml") - elif driverName.startswith("GMT"): - longName = "GMT" - glob.append("*.gmt") - elif driverName.startswith("GPX"): - longName = "GPX" - glob.append("*.gpx") - elif driverName.startswith("GRASS"): - pass # myDirectoryDrivers += "Grass Vector,GRASS" - elif driverName.startswith("IDB"): - pass # myDatabaseDrivers += "Informix DataBlade,IDB" - elif driverName.startswith("Interlis 1"): - longName = "INTERLIS 1" - glob.append("*.itf") - glob.append("*.xml") - glob.append("*.ili") - elif driverName.startswith("Interlis 2"): - longName = "INTERLIS 2" - glob.append("*.itf") - glob.append("*.xml") - glob.append("*.ili") - elif driverName.startswith("INGRES"): - pass # myDatabaseDrivers += "INGRES,INGRES" - elif driverName.startswith("KML"): - longName = "KML" - glob.append("*.kml") - elif driverName.startswith("MapInfo File"): - longName = "Mapinfo File" - glob.append("*.mif") - glob.append("*.tab") - elif driverName.startswith("DGN"): - longName = "Microstation DGN" - glob.append("*.dgn") - elif driverName.startswith("MySQL"): - pass # myDatabaseDrivers += "MySQL,MySQL" - elif driverName.startswith("OCI"): - pass # myDatabaseDrivers += "Oracle Spatial,OCI" - elif driverName.startswith("ODBC"): - pass # myDatabaseDrivers += "ODBC,ODBC" - elif driverName.startswith("OGDI"): - pass # myDatabaseDrivers += "OGDI Vectors,OGDI" - elif driverName.startswith("PostgreSQL"): - pass # myDatabaseDrivers += "PostgreSQL,PostgreSQL" - elif driverName.startswith("S57"): - longName = "S-57 Base file" - glob.append("*.000") - elif driverName.startswith("SDTS"): - longName = "Spatial Data Transfer Standard" - glob.append("*catd.ddf") - elif driverName.startswith("SQLite"): - longName = "SQLite" - glob.append("*.sqlite") - elif driverName.startswith("UK .NTF"): - pass # myDirectoryDrivers += "UK. NTF,UK. NTF" - elif driverName.startswith("TIGER"): - pass # myDirectoryDrivers += "U.S. Census TIGER/Line,TIGER" - elif driverName.startswith("VRT"): - longName = "VRT - Virtual Datasource " - glob.append("*.vrt") - elif driverName.startswith("XPlane"): - longName = "X-Plane/Flighgear" - glob.append("apt.dat") - glob.append("nav.dat") - glob.append("fix.dat") - glob.append("awy.dat") - - longName = string.strip(longName) - - if longName == '': - continue - - self.supportedVectors[longName] = {'EXTENSIONS': glob, 'LONGNAME': longName, 'SHORTNAME': driverName} - - return self.supportedVectors - - class SupportedRasters(object): - dict_long2shortName = dict() - - # retrieve the raster format short name by long format name - @classmethod - def long2ShortName(self, longName): - if longName == '': - return '' - - if longName in self.dict_long2shortName: - return self.dict_long2shortName[longName] - - # first get the GDAL driver manager - if gdal.GetDriverCount() == 0: - gdal.AllRegister() - - shortName = '' - - # for each loaded GDAL driver - for i in range(gdal.GetDriverCount()): - driver = gdal.GetDriver(i) - if driver is None: - continue - - # if this is the driver we searched for then return its short name - if FileFilter.getFilterName(driver.LongName) == longName: - shortName = FileFilter.getFilterName(driver.ShortName) - self.dict_long2shortName[longName] = shortName - break - - return shortName - - # retrieve the raster format short name by using the file name extension - @classmethod - def filename2ShortName(self, fileName): - if fileName == '': - return '' - - shortName = '' - - # for each raster format search for the file extension - formats = FileFilter.allRastersFilter().split(";;") - for f in formats: - for ext in FileFilter.getFilterExtensions(f): - if FileFilter.filenameMatchesFilterExt(fileName, ext): - longName = FileFilter.getFilterName(f) - shortName = self.long2ShortName(longName) - break - - if not shortName == '': - break - - return shortName - -# class which allows creating version objects and compare them - - -class Version(object): - - def __init__(self, ver): - self.vers = ('0', '0', '0') - - if isinstance(ver, Version): - self.vers = ver.vers - elif isinstance(ver, tuple) or isinstance(ver, list): - self.vers = list(map(str, ver)) - elif isinstance(ver, str): - self.vers = self.string2vers(ver) - - @staticmethod - def string2vers(string): - vers = ['0', '0', '0'] - - nums = str(string).split(".") - - if len(nums) > 0: - vers[0] = nums[0] - if len(nums) > 1: - vers[1] = nums[1] - if len(nums) > 2: - vers[2] = nums[2] - - return (vers[0], vers[1], vers[2]) - - def __cmp__(self, other): - if not isinstance(other, Version): - other = Version(other) - - if self.vers > other.vers: - return 1 - if self.vers < other.vers: - return -1 - return 0 - - def __str__(self): - return ".".join(self.vers) - - -def setProcessEnvironment(process): - envvar_list = { - "PATH": getGdalBinPath(), - "PYTHONPATH": getGdalPymodPath(), - "GDAL_FILENAME_IS_UTF8": "NO" - } - - sep = os.pathsep - - for name, val in envvar_list.items(): - if val is None or val == "": - continue - - envval = os.getenv(name) - if envval is None or envval == "": - envval = str(val) - elif (platform.system() == "Windows" and val.lower() not in envval.lower().split(sep)) or \ - (platform.system() != "Windows" and val not in envval.split(sep)): - envval += "%s%s" % (sep, str(val)) - else: - envval = None - - if envval is not None: - os.putenv(name, envval) - - -def setMacOSXDefaultEnvironment(): - # fix bug #3170: many GDAL Tools don't work in OS X standalone - - if platform.system() != "Darwin": - return - - # QgsApplication.prefixPath() contains the path to qgis executable (i.e. .../Qgis.app/MacOS) - # get the path to Qgis application folder - qgis_app = u"%s/.." % QgsApplication.prefixPath() - qgis_app = QDir(qgis_app).absolutePath() - - qgis_bin = u"%s/bin" % QgsApplication.prefixPath() # path to Qgis bin folder - qgis_python = u"%s/Resources/python" % qgis_app # path to Qgis python folder - - # path to the GDAL framework within the Qgis application folder (Qgis standalone only) - qgis_standalone_gdal_path = u"%s/Frameworks/GDAL.framework" % qgis_app - - # path to the GDAL framework when installed as external framework - gdal_versionsplit = str(GdalConfig.version()).split('.') - gdal_base_path = u"/Library/Frameworks/GDAL.framework/Versions/%s.%s" % (gdal_versionsplit[0], gdal_versionsplit[1]) - - if os.path.exists(qgis_standalone_gdal_path): # qgis standalone - # GDAL executables are in the Qgis bin folder - if getGdalBinPath() == '': - setGdalBinPath(qgis_bin) - # GDAL pymods are in the Qgis python folder - if getGdalPymodPath() == '': - setGdalPymodPath(qgis_python) - # GDAL help is in the framework folder - if getHelpPath() == '': - setHelpPath(u"%s/Resources/doc" % qgis_standalone_gdal_path) - - elif os.path.exists(gdal_base_path): - # all GDAL parts are in the GDAL framework folder - if getGdalBinPath() == '': - setGdalBinPath(u"%s/Programs" % gdal_base_path) - if getGdalPymodPath() == '': - setGdalPymodPath(u"%s/Python/%s.%s/site-packages" % (gdal_base_path, sys.version_info[0], sys.version_info[1])) - if getHelpPath() == '': - setHelpPath(u"%s/Resources/doc" % gdal_base_path) - - -# setup the MacOSX path to both GDAL executables and python modules -if platform.system() == "Darwin": - setMacOSXDefaultEnvironment() diff --git a/python/plugins/GdalTools/tools/dialogAbout.ui b/python/plugins/GdalTools/tools/dialogAbout.ui deleted file mode 100644 index 4e2e6f0b5fe..00000000000 --- a/python/plugins/GdalTools/tools/dialogAbout.ui +++ /dev/null @@ -1,149 +0,0 @@ - - - GdalToolsAboutDialog - - - - 0 - 0 - 434 - 300 - - - - About Gdal Tools - - - - - - - 20 - 75 - true - - - - GDAL Tools - - - Qt::RichText - - - Qt::AlignCenter - - - - - - - Version x.x-xxxxxx - - - Qt::AlignCenter - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - true - - - QFrame::NoFrame - - - QFrame::Plain - - - true - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html> - - - Qt::TextSelectableByMouse - - - - - - - - - Web - - - - - - - Close - - - - - - - - - - - btnClose - clicked() - GdalToolsAboutDialog - reject() - - - 297 - 276 - - - 199 - 149 - - - - - diff --git a/python/plugins/GdalTools/tools/dialogBase.py b/python/plugins/GdalTools/tools/dialogBase.py deleted file mode 100644 index 1a0c7780b7b..00000000000 --- a/python/plugins/GdalTools/tools/dialogBase.py +++ /dev/null @@ -1,235 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - dialogBase.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import Qt, QProcess, QUrl, QIODevice, QCoreApplication, pyqtSignal -from qgis.PyQt.QtWidgets import QDialog, QDialogButtonBox, QMessageBox, QErrorMessage, QApplication -from qgis.PyQt.QtGui import QIcon, QDesktopServices - -# to know the os -import platform - -from .ui_dialogBase import Ui_GdalToolsDialog as Ui_Dialog -from . import GdalTools_utils as Utils -from .. import resources_rc # NOQA - -import string - - -class GdalToolsBaseDialog(QDialog, Ui_Dialog): - refreshArgs = pyqtSignal() - okClicked = pyqtSignal() - closeClicked = pyqtSignal() - helpClicked = pyqtSignal() - processError = pyqtSignal(QProcess.ProcessError) - processFinished = pyqtSignal(int, QProcess.ExitStatus) - finished = pyqtSignal(bool) - valuesChanged = pyqtSignal(list) - - def __init__(self, parent, iface, pluginBase, pluginName, pluginCommand): - QDialog.__init__(self, parent) - self.setAttribute(Qt.WA_DeleteOnClose) - self.iface = iface - - self.process = QProcess(self) - Utils.setProcessEnvironment(self.process) - self.process.error.connect(self.processError) - self.process.finished.connect(self.processFinished) - - self.setupUi(self) - self.arguments = [] - - self.editCmdBtn.setIcon(QIcon(":/icons/edit.png")) - self.editCmdBtn.toggled.connect(self.editCommand) - self.resetCmdBtn.setIcon(QIcon(":/icons/reset.png")) - self.resetCmdBtn.clicked.connect(self.resetCommand) - self.editCommand(False) - - self.buttonBox.rejected.connect(self.reject) - self.buttonBox.accepted.connect(self.accept) - self.buttonBox.helpRequested.connect(self.help) - - self.buttonBox.button(QDialogButtonBox.Ok).setDefault(True) - - self.plugin = pluginBase - self.valuesChanged.connect(self.handleRefreshArgs) - - self.pluginLayout.addWidget(self.plugin) - self.plugin.setFocus() - - self.setWindowTitle(pluginName) - self.setPluginCommand(pluginCommand) - - def setPluginCommand(self, cmd): - # on Windows replace the .py with .bat extension - if platform.system() == "Windows" and cmd[-3:] == ".py": - self.command = cmd[:-3] + ".bat" - else: - self.command = cmd - - if cmd[-3:] == ".py": - self.helpFileName = cmd[:-3] + ".html" - else: - self.helpFileName = cmd + ".html" - - def editCommand(self, enabled): - if not self.commandIsEnabled(): - return - self.editCmdBtn.setChecked(enabled) - self.resetCmdBtn.setEnabled(enabled) - self.textEditCommand.setReadOnly(not enabled) - self.controlsWidget.setEnabled(not enabled) - self.refreshArgs.emit() - - def resetCommand(self): - if not self.commandIsEditable(): - return - self.refreshArgs.emit() - - def commandIsEditable(self): - return self.commandIsEnabled() and self.editCmdBtn.isChecked() - - def setCommandViewerEnabled(self, enable): - if not enable: - self.editCommand(False) - self.commandWidget.setEnabled(enable) - - def commandIsEnabled(self): - return self.commandWidget.isEnabled() - - def reject(self): - if self.process.state() != QProcess.NotRunning: - ret = QMessageBox.warning(self, self.tr("Warning"), self.tr("The command is still running. \nDo you want terminate it anyway?"), QMessageBox.Yes | QMessageBox.No) - if ret == QMessageBox.No: - return - - self.process.error.disconnect(self.processError) - self.process.finished.disconnect(self.processFinished) - - self.closeClicked.emit() - - def accept(self): - self.okClicked.emit() - - def help(self): - self.helpClicked.emit() - - # show the online tool documentation in the default browser - def onHelp(self): - helpPath = Utils.getHelpPath() - if helpPath == '': - url = QUrl("http://www.gdal.org/" + self.helpFileName) - else: - url = QUrl.fromLocalFile(helpPath + '/' + self.helpFileName) - QDesktopServices.openUrl(url) - - # called when a value in the plugin widget interface changed - def handleRefreshArgs(self, args): - self.arguments = [str(a) for a in args] - - if not self.commandIsEnabled(): - self.textEditCommand.setPlainText(self.command) - else: - self.textEditCommand.setPlainText(self.command + " " + Utils.escapeAndJoin(self.arguments)) - - # enables the OK button - def enableRun(self, enable=True): - self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable) - - # start the command execution - def onRun(self): - self.enableRun(False) - self.setCursor(Qt.WaitCursor) - if not self.commandIsEditable(): - #print(self.command+' '+unicode(self.arguments)) - self.process.start(self.command, self.arguments, QIODevice.ReadOnly) - else: - self.process.start(self.textEditCommand.toPlainText(), QIODevice.ReadOnly) - - # stop the command execution - def stop(self): - self.enableRun(True) - self.setCursor(Qt.ArrowCursor) - self.process.kill() - - # called on closing the dialog, stop the process if it's running - def onClosing(self): - self.stop() - QDialog.reject(self) - - # called if an error occurs when the command has not already finished, shows the occurred error message - def onError(self, error): - if error == QProcess.FailedToStart: - msg = QCoreApplication.translate("GdalTools", "The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.") - elif error == QProcess.Crashed: - msg = QCoreApplication.translate("GdalTools", "The process crashed some time after starting successfully.") - else: - msg = QCoreApplication.translate("GdalTools", "An unknown error occurred.") - - QErrorMessage(self).showMessage(msg) - QApplication.processEvents() # give the user chance to see the message - - self.stop() - - # called when the command finished its execution, shows an error message if there's one - # and, if required, load the output file in canvas - def onFinished(self, exitCode, status): - if status == QProcess.CrashExit: - self.stop() - return - - if self.command.find("gdalinfo") != -1 and exitCode == 0: - self.finished.emit(self.loadCheckBox.isChecked()) - self.stop() - return - - # show the error message if there's one, otherwise show the process output message - msg = str(self.process.readAllStandardError()) - if msg == '': - outMessages = str(self.process.readAllStandardOutput()).splitlines() - - # make sure to not show the help - for m in outMessages: - m = string.strip(m) - if m == '': - continue - # TODO fix this - #if m.contains( QRegExp( "^(?:[Uu]sage:\\s)?" + QRegExp.escape(self.command) + "\\s" ) ): - # if msg.isEmpty(): - # msg = self.tr ( "Invalid parameters." ) - # break - #if m.contains( QRegExp( "0(?:\\.+[1-9]0{1,2})+" ) ): - # continue - - if msg: - msg += "\n" - msg += m - - QErrorMessage(self).showMessage(msg.replace("\n", "
    ")) - - if exitCode == 0: - self.finished.emit(self.loadCheckBox.isChecked()) - - self.stop() diff --git a/python/plugins/GdalTools/tools/dialogBase.ui b/python/plugins/GdalTools/tools/dialogBase.ui deleted file mode 100644 index 63b511ef8eb..00000000000 --- a/python/plugins/GdalTools/tools/dialogBase.ui +++ /dev/null @@ -1,124 +0,0 @@ - - - GdalToolsDialog - - - - 0 - 0 - 285 - 179 - - - - Dialog - - - - - - - 0 - - - - - - - - &Load into canvas when finished - - - true - - - - - - - - - - - 0 - - - 6 - - - - - - 0 - 0 - - - - true - - - - - - - - - Edit - - - Edit - - - true - - - - - - - false - - - Reset - - - Reset - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close|QDialogButtonBox::Help|QDialogButtonBox::Ok - - - - - - - buttonBox - - - - diff --git a/python/plugins/GdalTools/tools/dialogExtractProjection.ui b/python/plugins/GdalTools/tools/dialogExtractProjection.ui deleted file mode 100644 index e470b03b8b6..00000000000 --- a/python/plugins/GdalTools/tools/dialogExtractProjection.ui +++ /dev/null @@ -1,117 +0,0 @@ - - - GdalToolsDialog - - - - 0 - 0 - 400 - 192 - - - - Extract projection - - - - - - Batch mode (for processing whole directory) - - - - - - - - - &Input file - - - inSelector - - - - - - - - - - - - Recurse subdirectories - - - - - - - Create also prj file - - - - - - - 0 - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - - - buttonBox - accepted() - GdalToolsDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - GdalToolsDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - -
    diff --git a/python/plugins/GdalTools/tools/dialogSRS.py b/python/plugins/GdalTools/tools/dialogSRS.py deleted file mode 100644 index 2f1574f082b..00000000000 --- a/python/plugins/GdalTools/tools/dialogSRS.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - dialogSRS.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtWidgets import QDialog, QVBoxLayout, QDialogButtonBox -from qgis.gui import QgsProjectionSelector - - -class GdalToolsSRSDialog(QDialog): - - def __init__(self, title, parent=None): - QDialog.__init__(self, parent) - self.setWindowTitle(title) - - layout = QVBoxLayout() - self.selector = QgsProjectionSelector(self) - buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Close) - - layout.addWidget(self.selector) - layout.addWidget(buttonBox) - self.setLayout(layout) - - buttonBox.accepted.connect(self.accept) - buttonBox.rejected.connect(self.reject) - - def authid(self): - return str(self.selector.selectedAuthId()) - - def proj4string(self): - return self.selector.selectedProj4String() - - def getProjection(self): - if self.authid().upper().startswith("EPSG:"): - return self.authid() - - if self.selector.selectedProj4String(): - return self.proj4string() - - return '' diff --git a/python/plugins/GdalTools/tools/dialogSettings.ui b/python/plugins/GdalTools/tools/dialogSettings.ui deleted file mode 100644 index e92225c9b4d..00000000000 --- a/python/plugins/GdalTools/tools/dialogSettings.ui +++ /dev/null @@ -1,240 +0,0 @@ - - - GdalToolsSettingsDialog - - - - 0 - 0 - 371 - 341 - - - - Gdal Tools settings - - - - - - - - Path to the GDAL executables - - - - - - - - 0 - 0 - - - - ##tooltip icon## - - - - - - - - - - - - - - Browse - - - - - - - - - - - Path to the GDAL python modules - - - - - - - - 0 - 0 - - - - ##tooltip icon## - - - - - - - - - - - - - - Browse - - - - - - - - - - - GDAL help path - - - - - - - - 0 - 0 - - - - ##tooltip icon## - - - - - - - - - - - - - - Browse - - - - - - - - - false - - - GDAL data path - - - - - - - - - false - - - - - - - false - - - Browse - - - - - - - - - false - - - GDAL driver path - - - - - - - - - false - - - - - - - false - - - Browse - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - GdalToolsSettingsDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - GdalToolsSettingsDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/python/plugins/GdalTools/tools/doBuildVRT.py b/python/plugins/GdalTools/tools/doBuildVRT.py deleted file mode 100644 index a10db1ae065..00000000000 --- a/python/plugins/GdalTools/tools/doBuildVRT.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doBuildVRT.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QCoreApplication -from qgis.PyQt.QtWidgets import QWidget - -from .ui_widgetBuildVRT import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from .dialogSRS import GdalToolsSRSDialog as SRSDialog -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - self.resolutions = ("highest", "average", "lowest") - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdalbuildvrt") - - self.inSelector.setType(self.inSelector.FILE) - self.outSelector.setType(self.outSelector.FILE) - self.recurseCheck.hide() - self.visibleRasterLayers = [] - - self.setParamsStatus( - [ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.resolutionComboBox, "currentIndexChanged", self.resolutionCheck), - (self.noDataEdit, "textChanged", self.srcNoDataCheck, 1700), - (self.inputDirCheck, "stateChanged"), - (self.separateCheck, "stateChanged", None, 1700), - (self.targetSRSEdit, "textChanged", self.targetSRSCheck), - (self.allowProjDiffCheck, "stateChanged", None, 1700), - (self.recurseCheck, "stateChanged", self.inputDirCheck), - (self.inputSelLayersCheck, "stateChanged") - ] - ) - - self.inSelector.selectClicked.connect(self.fillInputFilesEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.inputDirCheck.stateChanged.connect(self.switchToolMode) - self.inputSelLayersCheck.stateChanged.connect(self.switchLayerMode) - self.iface.mapCanvas().layersChanged.connect(self.switchLayerMode) - self.selectTargetSRSButton.clicked.connect(self.fillTargetSRSEdit) - - def initialize(self): - # connect to mapCanvas.layerChanged() signal - self.iface.mapCanvas().layersChanged.connect(self.onVisibleLayersChanged) - self.onVisibleLayersChanged() - BasePluginWidget.initialize(self) - - def onClosing(self): - # disconnect from mapCanvas.layerChanged() signal - self.iface.mapCanvas().layersChanged.disconnect(self.onVisibleLayersChanged) - self.iface.mapCanvas().layersChanged.disconnect(self.switchLayerMode) - BasePluginWidget.onClosing(self) - - def onVisibleLayersChanged(self): - # refresh list of visible raster layers - self.visibleRasterLayers = [] - for layer in self.iface.mapCanvas().layers(): - if Utils.LayerRegistry.isRaster(layer): - self.visibleRasterLayers.append(layer.source()) - - # refresh the text in the command viewer - self.someValueChanged() - - def switchToolMode(self): - self.recurseCheck.setVisible(self.inputDirCheck.isChecked()) - self.inSelector.clear() - - if self.inputDirCheck.isChecked(): - self.inFileLabel = self.label.text() - self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory")) - - self.inSelector.selectClicked.disconnect(self.fillInputFilesEdit) - self.inSelector.selectClicked.connect(self.fillInputDir) - else: - self.label.setText(self.inFileLabel) - - self.inSelector.selectClicked.connect(self.fillInputFilesEdit) - self.inSelector.selectClicked.disconnect(self.fillInputDir) - - def switchLayerMode(self): - enableInputFiles = not self.inputSelLayersCheck.isChecked() - self.inputDirCheck.setEnabled(enableInputFiles) - self.inSelector.setEnabled(enableInputFiles) - self.recurseCheck.setEnabled(enableInputFiles) - - def fillInputFilesEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - files = Utils.FileDialog.getOpenFileNames(self, self.tr("Select the files for VRT"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if files == '': - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - self.inSelector.setFilename(",".join(files)) - - def fillOutputFileEdit(self): - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the VRT"), self.tr("VRT (*.vrt)")) - if outputFile == '': - return - self.outSelector.setFilename(outputFile) - - def fillInputDir(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files for VRT")) - if inputDir == '': - return - self.inSelector.setFilename(inputDir) - - def fillTargetSRSEdit(self): - dialog = SRSDialog("Select the target SRS", self) - if dialog.exec_(): - self.targetSRSEdit.setText(dialog.getProjection()) - - def getArguments(self): - arguments = [] - if self.resolutionCheck.isChecked() and self.resolutionComboBox.currentIndex() >= 0: - arguments.append("-resolution") - arguments.append(self.resolutions[self.resolutionComboBox.currentIndex()]) - if self.separateCheck.isChecked(): - arguments.append("-separate") - if self.srcNoDataCheck.isChecked(): - nodata = self.noDataEdit.text().strip() - if nodata: - arguments.append("-srcnodata") - arguments.append(nodata) - if self.targetSRSCheck.isChecked() and self.targetSRSEdit.text(): - arguments.append("-a_srs") - arguments.append(self.targetSRSEdit.text()) - if self.allowProjDiffCheck.isChecked(): - arguments.append("-allow_projection_difference") - arguments.append(self.getOutputFileName()) - if self.inputSelLayersCheck.isChecked(): - arguments.extend(self.visibleRasterLayers) - elif self.inputDirCheck.isChecked(): - arguments.extend(Utils.getRasterFiles(self.getInputFileName(), self.recurseCheck.isChecked())) - else: - arguments.extend(self.getInputFileName()) - return arguments - - def getOutputFileName(self): - return self.outSelector.filename() - - def getInputFileName(self): - if self.inputDirCheck.isChecked(): - return self.inSelector.filename() - return self.inSelector.filename().split(",") - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) diff --git a/python/plugins/GdalTools/tools/doClipper.py b/python/plugins/GdalTools/tools/doClipper.py deleted file mode 100644 index 59c4a002ee9..00000000000 --- a/python/plugins/GdalTools/tools/doClipper.py +++ /dev/null @@ -1,216 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doClipper.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtWidgets import QWidget -from qgis.core import Qgis, QgsWkbTypes - -from .ui_widgetClipper import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - self.canvas = self.iface.mapCanvas() - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdal_translate") - - self.outSelector.setType(self.outSelector.FILE) - self.extentSelector.setCanvas(self.canvas) - self.outputFormat = Utils.fillRasterOutputFormat() - - # set the default QDoubleSpinBoxes - self.xRes.setValue(12.5) - self.yRes.setValue(12.5) - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.noDataSpin, "valueChanged", self.noDataCheck, 1700), - (self.maskSelector, "filenameChanged", self.maskModeRadio, 1600), - (self.alphaBandCheck, "stateChanged"), - (self.cropToCutlineCheck, "stateChanged"), - ([self.xRes, self.yRes], "valueChanged", self.setResolutionRadio), - (self.extentSelector, ["selectionStarted", "newExtentDefined"], self.extentModeRadio), - (self.modeStackedWidget, "currentChanged") - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.maskSelector.selectClicked.connect(self.fillMaskFileEdit) - self.extentSelector.newExtentDefined.connect(self.extentChanged) - self.extentSelector.selectionStarted.connect(self.checkRun) - - self.extentModeRadio.toggled.connect(self.switchClippingMode) - self.keepResolutionRadio.toggled.connect(self.switchResolutionMode) - - def show_(self): - self.switchClippingMode() - self.switchResolutionMode() - BasePluginWidget.show_(self) - - def onClosing(self): - self.extentSelector.stop() - BasePluginWidget.onClosing(self) - - def switchClippingMode(self): - if self.extentModeRadio.isChecked(): - index = 0 - self.extentSelector.start() - else: - self.extentSelector.stop() - index = 1 - self.modeStackedWidget.setCurrentIndex(index) - self.checkRun() - - def switchResolutionMode(self): - if self.keepResolutionRadio.isChecked(): - self.resolutionWidget.hide() - else: - self.resolutionWidget.show() - - def checkRun(self): - if self.extentModeRadio.isChecked(): - enabler = self.extentSelector.isCoordsValid() - else: - enabler = not self.maskSelector.filename() == '' - self.base.enableRun(enabler) - - def extentChanged(self): - self.activateWindow() - self.raise_() - self.checkRun() - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - self.maskSelector.setLayers([x for x in Utils.LayerRegistry.instance().getVectorLayers() if x.geometryType() == QgsWkbTypes.PolygonGeometry]) - self.checkRun() - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Polygonize"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if inputFile == '': - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if outputFile == '': - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - - def fillMaskFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter() - maskFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the mask file"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter) - if maskFile == '': - return - Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter) - - self.maskSelector.setFilename(maskFile) - self.checkRun() - - def getArguments(self): - if not self.extentModeRadio.isChecked(): - return self.getArgsModeMask() - return self.getArgsModeExtent() - - def getArgsModeExtent(self): - self.base.setPluginCommand("gdal_translate") - inputFn = self.getInputFileName() - arguments = [] - if self.noDataCheck.isChecked(): - arguments.append("-a_nodata") - arguments.append(str(self.noDataSpin.value())) - if self.extentModeRadio.isChecked() and self.extentSelector.isCoordsValid(): - rect = self.extentSelector.getExtent() - if rect is not None and not inputFn == '': - arguments.append("-projwin") - arguments.append(str(rect.xMinimum())) - arguments.append(str(rect.yMaximum())) - arguments.append(str(rect.xMaximum())) - arguments.append(str(rect.yMinimum())) - outputFn = self.getOutputFileName() - if not outputFn == '': - arguments.append("-of") - arguments.append(self.outputFormat) - arguments.append(inputFn) - arguments.append(outputFn) - return arguments - - def getArgsModeMask(self): - self.base.setPluginCommand("gdalwarp") - inputFn = self.getInputFileName() - arguments = [] - if self.noDataCheck.isChecked(): - arguments.append("-dstnodata") - arguments.append(str(self.noDataSpin.value())) - if self.maskModeRadio.isChecked(): - mask = self.maskSelector.filename() - if not mask == '' and not inputFn == '': - arguments.append("-q") - arguments.append("-cutline") - arguments.append(mask) - if Utils.GdalConfig.versionNum() >= 1800: - if self.cropToCutlineCheck.isChecked(): - arguments.append("-crop_to_cutline") - if self.alphaBandCheck.isChecked(): - arguments.append("-dstalpha") - if self.keepResolutionRadio.isChecked(): - resolution = Utils.getRasterResolution(inputFn) - if resolution is not None: - arguments.append("-tr") - arguments.append(resolution[0]) - arguments.append(resolution[1]) - else: - arguments.append("-tr") - arguments.append(str(self.xRes.value())) - arguments.append(str(self.yRes.value())) - outputFn = self.getOutputFileName() - if not outputFn == '': - arguments.append("-of") - arguments.append(self.outputFormat) - arguments.append(inputFn) - arguments.append(outputFn) - return arguments - - def getOutputFileName(self): - return self.outSelector.filename() - - def getInputFileName(self): - return self.inSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) diff --git a/python/plugins/GdalTools/tools/doContour.py b/python/plugins/GdalTools/tools/doContour.py deleted file mode 100644 index 57290d4c4c9..00000000000 --- a/python/plugins/GdalTools/tools/doContour.py +++ /dev/null @@ -1,127 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doContour.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QDir -from qgis.PyQt.QtWidgets import QWidget, QApplication - -from .ui_widgetContour import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdal_contour") - - gdalVersion = Utils.GdalConfig.versionNum() - self.useDirAsOutput = gdalVersion < 1700 - if self.useDirAsOutput: - self.label_2.setText(QApplication.translate("GdalToolsWidget", "&Output directory for contour lines (shapefile)")) - - self.outSelector.setType(self.outSelector.FILE) - - self.outputFormat = Utils.fillVectorOutputFormat() - - # set the default QSpinBoxes value - self.intervalDSpinBox.setValue(10.0) - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.intervalDSpinBox, "valueChanged"), - (self.attributeEdit, "textChanged", self.attributeCheck) - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Contour"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - - def fillOutputFileEdit(self): - if not self.useDirAsOutput: - lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter() - outputFile, encoding = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the Contour output"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True) - else: - outputFile, encoding = Utils.FileDialog.getExistingDirectory(self, self.tr("Select where to save the Contour output"), True) - - if not outputFile: - return - - if not self.useDirAsOutput: - Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter) - - self.outputFormat = Utils.fillVectorOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - self.lastEncoding = encoding - - def getArguments(self): - arguments = [] - if self.attributeCheck.isChecked() and self.attributeEdit.text(): - arguments.append("-a") - arguments.append(self.attributeEdit.text()) - if True: # XXX in this moment the -i argument is not optional - arguments.append("-i") - arguments.append(str(self.intervalDSpinBox.value())) - - outputFn = self.getOutputFileName() - if outputFn: - arguments.append("-f") - arguments.append(self.outputFormat) - - arguments.append(self.getInputFileName()) - arguments.append(self.outSelector.filename()) - - return arguments - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - if self.useDirAsOutput: - if self.outSelector.filename(): - return self.outSelector.filename() + QDir.separator() + "contour.shp" - return self.outSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - vl = self.iface.addVectorLayer(fileInfo.filePath(), fileInfo.baseName(), "ogr") - if vl is not None and vl.isValid(): - if hasattr(self, 'lastEncoding'): - vl.setProviderEncoding(self.lastEncoding) diff --git a/python/plugins/GdalTools/tools/doDEM.py b/python/plugins/GdalTools/tools/doDEM.py deleted file mode 100644 index a0b69d6ece0..00000000000 --- a/python/plugins/GdalTools/tools/doDEM.py +++ /dev/null @@ -1,179 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doDEM.py - --------------------- - Date : March 2011 - Copyright : (C) 2011 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" - -__author__ = 'Giuseppe Sucameli' -__date__ = 'March 2011' -__copyright__ = '(C) 2011, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtWidgets import QWidget - -from .ui_widgetDEM import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - self.modes = ("hillshade", "slope", "aspect", "color-relief", "TRI", "TPI", "roughness") - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdaldem") - - self.outSelector.setType(self.outSelector.FILE) - self.configSelector.setType(self.configSelector.FILE) - - # set the default QSpinBoxes and QProgressBar value - self.bandSpin.setValue(1) - - self.hillshadeZFactorSpin.setValue(1) - self.hillshadeScaleSpin.setValue(1) - self.hillshadeAltitudeSpin.setValue(45.0) - self.hillshadeAzimuthSpin.setValue(315.0) - self.slopeScaleSpin.setValue(1) - - # set the default color configuration file to terrain - import os.path - colorConfigFile = os.path.join(os.path.dirname(__file__), "terrain.txt") - self.configSelector.setFilename(colorConfigFile) - - self.outputFormat = Utils.fillRasterOutputFormat() - self.creationOptionsWidget.setFormat(self.outputFormat) - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.computeEdgesCheck, "stateChanged", None, 1800), - (self.bandSpin, "valueChanged", self.bandCheck), - (self.algorithmCheck, "stateChanged", None, 1800), - (self.creationOptionsWidget, "optionsChanged"), - (self.creationOptionsGroupBox, "toggled"), - (self.modeCombo, "currentIndexChanged"), - ([self.hillshadeZFactorSpin, self.hillshadeScaleSpin, self.hillshadeAltitudeSpin, self.hillshadeAzimuthSpin], "valueChanged"), - (self.slopeScaleSpin, "valueChanged"), - (self.slopePercentCheck, "stateChanged"), - ([self.aspectTrigonometricCheck, self.aspectZeroForFlatCheck], "stateChanged"), - (self.configSelector, "filenameChanged"), - ([self.colorExactRadio, self.colorNearestRadio], "toggled", self.colorMatchGroupBox), - (self.colorAlphaCheck, "stateChanged") - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.configSelector.selectClicked.connect(self.fillColorConfigFileEdit) - self.modeCombo.currentIndexChanged.connect(self.showModeParams) - - def showModeParams(self, index): - self.stackedWidget.setVisible(index < 4) - self.algorithmCheck.setVisible(index < 3) - if index >= 3: - self.algorithmCheck.setChecked(False) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the file for DEM"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - self.getArguments() - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - self.creationOptionsWidget.setFormat(self.outputFormat) - - def fillColorConfigFileEdit(self): - configFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the color configuration file")) - if not configFile: - return - self.configSelector.setFilename(configFile) - - def getArguments(self): - mode = self.modes[self.modeCombo.currentIndex()] - arguments = [] - arguments.append(mode) - arguments.append(self.getInputFileName()) - if mode == "color-relief": - arguments.append(self.configSelector.filename()) - outputFn = self.getOutputFileName() - arguments.append(outputFn) - if mode == "hillshade": - arguments.extend(["-z", self.hillshadeZFactorSpin.value()]) - arguments.extend(["-s", self.hillshadeScaleSpin.value()]) - arguments.extend(["-az", self.hillshadeAzimuthSpin.value()]) - arguments.extend(["-alt", self.hillshadeAltitudeSpin.value()]) - elif mode == "slope": - if self.slopePercentCheck.isChecked(): - arguments.append("-p") - arguments.extend(["-s", self.slopeScaleSpin.value()]) - elif mode == "aspect": - if self.aspectTrigonometricCheck.isChecked(): - arguments.append("-trigonometric") - if self.aspectZeroForFlatCheck.isChecked(): - arguments.append("-zero_for_flat") - elif mode == "color-relief": - if self.colorAlphaCheck.isChecked(): - arguments.append("-alpha") - if self.colorMatchGroupBox.isChecked(): - if self.colorExactRadio.isChecked(): - arguments.append("-exact_color_entry") - elif self.colorNearestRadio.isChecked(): - arguments.append("-nearest_color_entry") - if self.algorithmCheck.isChecked(): - arguments.extend(["-alg", "ZevenbergenThorne"]) - if self.computeEdgesCheck.isChecked(): - arguments.append("-compute_edges") - if self.bandCheck.isChecked(): - arguments.extend(["-b", self.bandSpin.value()]) - if outputFn: - arguments.extend(["-of", self.outputFormat]) - if self.creationOptionsGroupBox.isChecked(): - for opt in self.creationOptionsWidget.options(): - arguments.extend(["-co", opt]) - # set creation options filename/layer for validation - if self.inSelector.layer(): - self.creationOptionsWidget.setRasterLayer(self.inSelector.layer()) - else: - self.creationOptionsWidget.setRasterFileName(self.getInputFileName()) - - return arguments - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - return self.outSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) diff --git a/python/plugins/GdalTools/tools/doExtractProj.py b/python/plugins/GdalTools/tools/doExtractProj.py deleted file mode 100644 index 33a54ad0230..00000000000 --- a/python/plugins/GdalTools/tools/doExtractProj.py +++ /dev/null @@ -1,228 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doExtractProj.py - --------------------- - Date : August 2011 - Copyright : (C) 2011 by Alexander Bruy - Email : alexander dot bruy at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Alexander Bruy' -__date__ = 'August 2011' -__copyright__ = '(C) 2011, Alexander Bruy' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import Qt, QCoreApplication, QThread, QMutex, pyqtSignal -from qgis.PyQt.QtWidgets import QDialog, QDialogButtonBox, QApplication, QMessageBox -from qgis.PyQt.QtGui import QCursor - -from .ui_dialogExtractProjection import Ui_GdalToolsDialog as Ui_Dialog -from . import GdalTools_utils as Utils - -import os.path - -req_mods = {"osgeo": "osgeo [python-gdal]"} -try: - from osgeo import gdal - from osgeo import osr -except ImportError as e: - error_str = e.args[0] - error_mod = error_str.replace("No module named ", "") - if error_mod in req_mods: - error_str = error_str.replace(error_mod, req_mods[error_mod]) - raise ImportError(error_str) - - -class GdalToolsDialog(QDialog, Ui_Dialog): - - def __init__(self, iface): - QDialog.__init__(self, iface.mainWindow()) - self.setupUi(self) - self.iface = iface - - self.inSelector.setType(self.inSelector.FILE) - - self.recurseCheck.hide() - - self.okButton = self.buttonBox.button(QDialogButtonBox.Ok) - self.cancelButton = self.buttonBox.button(QDialogButtonBox.Cancel) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.batchCheck.stateChanged.connect(self.switchToolMode) - - def switchToolMode(self): - self.recurseCheck.setVisible(self.batchCheck.isChecked()) - - self.inSelector.clear() - - if self.batchCheck.isChecked(): - self.inFileLabel = self.label.text() - self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory")) - - self.inSelector.selectClicked.disconnect(self.fillInputFileEdit) - self.inSelector.selectClicked.connect(self.fillInputDir) - else: - self.label.setText(self.inFileLabel) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.inSelector.selectClicked.disconnect(self.fillInputDir) - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the file to analyse"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - self.inSelector.setFilename(inputFile) - - def fillInputDir(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Assign projection")) - if not inputDir: - return - self.inSelector.setFilename(inputDir) - - def reject(self): - QDialog.reject(self) - - def accept(self): - self.inFiles = None - if self.batchCheck.isChecked(): - self.inFiles = Utils.getRasterFiles(self.inSelector.filename(), self.recurseCheck.isChecked()) - else: - self.inFiles = [self.inSelector.filename()] - - self.progressBar.setRange(0, len(self.inFiles)) - - QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) - self.okButton.setEnabled(False) - - self.extractor = ExtractThread(self.inFiles, self.prjCheck.isChecked()) - self.extractor.fileProcessed.connect(self.updateProgress) - self.extractor.processFinished.connect(self.processingFinished) - self.extractor.processInterrupted.connect(self.processingInterrupted) - - self.buttonBox.rejected.disconnect(self.reject) - self.buttonBox.rejected.connect(self.stopProcessing) - - self.extractor.start() - - def updateProgress(self): - self.progressBar.setValue(self.progressBar.value() + 1) - - def processingFinished(self): - self.stopProcessing() - QMessageBox.information(self, self.tr("Finished"), self.tr("Processing completed.")) - - def processingInterrupted(self): - self.restoreGui() - - def stopProcessing(self): - if self.extractor is not None: - self.extractor.stop() - self.extractor = None - - self.restoreGui() - - def restoreGui(self): - self.progressBar.setRange(0, 100) - self.progressBar.setValue(0) - - QApplication.restoreOverrideCursor() - - self.buttonBox.rejected.disconnect(self.stopProcessing) - self.buttonBox.rejected.connect(self.reject) - - self.okButton.setEnabled(True) - -# ---------------------------------------------------------------------- - - -def extractProjection(filename, createPrj): - raster = gdal.Open(str(filename)) - - crs = raster.GetProjection() - geotransform = raster.GetGeoTransform() - - raster = None - - outFileName = os.path.splitext(str(filename))[0] - - # create prj file requested and if projection available - if crs != "" and createPrj: - # convert CRS into ESRI format - tmp = osr.SpatialReference() - tmp.ImportFromWkt(crs) - tmp.MorphToESRI() - crs = tmp.ExportToWkt() - tmp = None - - prj = open(outFileName + '.prj', 'wt') - prj.write(crs) - prj.close() - - # create wld file - wld = open(outFileName + '.wld', 'wt') - wld.write("%0.8f\n" % geotransform[1]) - wld.write("%0.8f\n" % geotransform[4]) - wld.write("%0.8f\n" % geotransform[2]) - wld.write("%0.8f\n" % geotransform[5]) - wld.write("%0.8f\n" % (geotransform[0] + 0.5 * geotransform[1] + 0.5 * geotransform[2])) - wld.write("%0.8f\n" % (geotransform[3] + 0.5 * geotransform[4] + 0.5 * geotransform[5])) - wld.close() - - -class ExtractThread(QThread): - - fileProcessed = pyqtSignal() - processFinished = pyqtSignal() - processInterrupted = pyqtSignal() - - def __init__(self, files, needPrj): - QThread.__init__(self, QThread.currentThread()) - self.inFiles = files - self.needPrj = needPrj - - self.mutex = QMutex() - self.stopMe = 0 - - def run(self): - self.mutex.lock() - self.stopMe = 0 - self.mutex.unlock() - - interrupted = False - - for f in self.inFiles: - extractProjection(f, self.needPrj) - self.fileProcessed.emit() - - self.mutex.lock() - s = self.stopMe - self.mutex.unlock() - if s == 1: - interrupted = True - break - - if not interrupted: - self.processFinished.emit() - else: - self.processInterrupted.emit() - - def stop(self): - self.mutex.lock() - self.stopMe = 1 - self.mutex.unlock() - - QThread.wait(self) diff --git a/python/plugins/GdalTools/tools/doFillNodata.py b/python/plugins/GdalTools/tools/doFillNodata.py deleted file mode 100644 index 4fc54249774..00000000000 --- a/python/plugins/GdalTools/tools/doFillNodata.py +++ /dev/null @@ -1,237 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doFillNodata.py - --------------------- - Date : November 2011 - Copyright : (C) 2011 by Alexander Bruy - Email : alexander dot bruy at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Alexander Bruy' -__date__ = 'November 2011' -__copyright__ = '(C) 2011, Alexander Bruy' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import Qt, QCoreApplication, QDir -from qgis.PyQt.QtWidgets import QWidget - -from .ui_widgetFillNodata import Ui_GdalToolsWidget as Ui_Widget -from .widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget -from . import GdalTools_utils as Utils - -import re - - -class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BaseBatchWidget.__init__(self, self.iface, "gdal_fillnodata.py") - - self.inSelector.setType(self.inSelector.FILE_LAYER) - self.outSelector.setType(self.outSelector.FILE) - self.maskSelector.setType(self.maskSelector.FILE) - - self.progressBar.setValue(0) - self.progressBar.hide() - self.formatLabel.hide() - self.formatCombo.hide() - - self.outputFormat = Utils.fillRasterOutputFormat() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.maskSelector, "filenameChanged", self.maskCheck), - (self.distanceSpin, "valueChanged", self.distanceCheck), - (self.smoothSpin, "valueChanged", self.smoothCheck), - (self.bandSpin, "valueChanged", self.bandCheck), - (self.nomaskCheck, "stateChanged") - ]) - - self.inSelector.selectClicked.connect(self.fillInputFile) - self.outSelector.selectClicked.connect(self.fillOutputFile) - self.maskSelector.selectClicked.connect(self.fillMaskFile) - self.batchCheck.stateChanged.connect(self.switchToolMode) - - # add raster filters to combo - self.formatCombo.addItems(Utils.FileFilter.allRastersFilter().split(";;")) - - def switchToolMode(self): - self.setCommandViewerEnabled(not self.batchCheck.isChecked()) - self.progressBar.setVisible(self.batchCheck.isChecked()) - self.formatLabel.setVisible(self.batchCheck.isChecked()) - self.formatCombo.setVisible(self.batchCheck.isChecked()) - - self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER) - self.outSelector.clear() - - if self.batchCheck.isChecked(): - self.inFileLabel = self.label.text() - self.outFileLabel = self.label_1.text() - self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory")) - self.label_1.setText(QCoreApplication.translate("GdalTools", "&Output directory")) - - self.inSelector.selectClicked.disconnect(self.fillInputFile) - self.outSelector.selectClicked.disconnect(self.fillOutputFile) - - self.inSelector.selectClicked.connect(self. fillInputDir) - self.outSelector.selectClicked.connect(self.fillOutputDir) - else: - self.label.setText(self.inFileLabel) - self.label_1.setText(self.outFileLabel) - - self.inSelector.selectClicked.disconnect(self.fillInputDir) - self.outSelector.selectClicked.disconnect(self.fillOutputDir) - - self.inSelector.selectClicked.connect(self.fillInputFile) - self.outSelector.selectClicked.connect(self.fillOutputFile) - - def fillInputFile(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, - self.tr("Select the files to analyse"), - Utils.FileFilter.allRastersFilter(), - lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - self.inSelector.setFilename(inputFile) - - def fillOutputFile(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - - def fillMaskFile(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, - self.tr("Select the files to analyse"), - Utils.FileFilter.allRastersFilter(), - lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - self.maskSelector.setFilename(inputFile) - - def fillInputDir(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files")) - if not inputDir: - return - self.inSelector.setFilename(inputDir) - - def fillOutputDir(self): - outputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the output directory to save the results to")) - if not outputDir: - return - self.outSelector.setFilename(outputDir) - - def getArguments(self): - arguments = [] - maskFile = self.maskSelector.filename() - if self.distanceCheck.isChecked() and self.distanceSpin.value() != 0: - arguments.append("-md") - arguments.append(self.distanceSpin.text()) - if self.smoothCheck.isChecked() and self.smoothSpin.value() != 0: - arguments.append("-si") - arguments.append(str(self.smoothSpin.value())) - if self.bandCheck.isChecked() and self.bandSpin.value() != 0: - arguments.append("-b") - arguments.append(str(self.bandSpin.value())) - if self.maskCheck.isChecked() and maskFile: - arguments.append("-mask") - arguments.append(maskFile) - if self.nomaskCheck.isChecked(): - arguments.append("-nomask") - if self.isBatchEnabled(): - if self.formatCombo.currentIndex() != 0: - arguments.append("-of") - arguments.append(Utils.fillRasterOutputFormat(self.formatCombo.currentText())) - return arguments - else: - outputFn = self.getOutputFileName() - if outputFn: - arguments.append("-of") - arguments.append(self.outputFormat) - arguments.append(self.getInputFileName()) - arguments.append(outputFn) - return arguments - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - return self.outSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) - - def isBatchEnabled(self): - return self.batchCheck.isChecked() - - def setProgressRange(self, maximum): - self.progressBar.setRange(0, maximum) - - def updateProgress(self, index, total): - if index < total: - self.progressBar.setValue(index + 1) - else: - self.progressBar.setValue(0) - - def batchRun(self): - exts = re.sub('\).*$', '', re.sub('^.*\(', '', self.formatCombo.currentText())).split(" ") - if len(exts) > 0 and exts[0] != "*" and exts[0] != "*.*": - outExt = exts[0].replace("*", "") - else: - outExt = ".tif" - - self.base.enableRun(False) - self.base.setCursor(Qt.WaitCursor) - - inDir = self.getInputFileName() - outDir = self.getOutputFileName() - - extensions = Utils.getRasterExtensions() - workDir = QDir(inDir) - workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot) - workDir.setNameFilters(extensions) - files = workDir.entryList() - - self.inFiles = [] - self.outFiles = [] - - for f in files: - self.inFiles.append(inDir + "/" + f) - if outDir is not None: - outFile = re.sub("\.[a-zA-Z0-9]{2,4}", outExt, f) - self.outFiles.append(outDir + "/" + outFile) - - self.errors = [] - self.batchIndex = 0 - self.batchTotal = len(self.inFiles) - self.setProgressRange(self.batchTotal) - - self.runItem(self.batchIndex, self.batchTotal) diff --git a/python/plugins/GdalTools/tools/doGrid.py b/python/plugins/GdalTools/tools/doGrid.py deleted file mode 100644 index 43dd70ce0c1..00000000000 --- a/python/plugins/GdalTools/tools/doGrid.py +++ /dev/null @@ -1,213 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doGrid.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QFileInfo, QTextCodec -from qgis.PyQt.QtWidgets import QWidget, QErrorMessage - -from .ui_widgetGrid import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - self.canvas = self.iface.mapCanvas() - self.algorithm = ('invdist', 'average', 'nearest', 'datametrics') - self.datametrics = ('minimum', 'maximum', 'range') - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdal_grid") - - self.outSelector.setType(self.outSelector.FILE) - self.extentSelector.setCanvas(self.canvas) - #self.extentSelector.stop() - - # set the default QSpinBoxes and QProgressBar value - self.widthSpin.setValue(3000) - self.heightSpin.setValue(3000) - self.invdistPowerSpin.setValue(2.0) - - self.outputFormat = Utils.fillRasterOutputFormat() - self.lastEncoding = Utils.getLastUsedEncoding() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.zfieldCombo, "currentIndexChanged", self.zfieldCheck), - (self.algorithmCombo, "currentIndexChanged", self.algorithmCheck), - (self.stackedWidget, None, self.algorithmCheck), - ([self.invdistPowerSpin, self.invdistSmothingSpin, self.invdistRadius1Spin, self.invdistRadius2Spin, self.invdistAngleSpin, self.invdistNoDataSpin], "valueChanged"), - ([self.invdistMaxPointsSpin, self.invdistMinPointsSpin], "valueChanged"), - ([self.averageRadius1Spin, self.averageRadius2Spin, self.averageAngleSpin, self.averageNoDataSpin], "valueChanged"), - (self.averageMinPointsSpin, "valueChanged"), - ([self.nearestRadius1Spin, self.nearestRadius2Spin, self.nearestAngleSpin, self.nearestNoDataSpin], "valueChanged"), - (self.datametricsCombo, "currentIndexChanged"), - ([self.datametricsRadius1Spin, self.datametricsRadius2Spin, self.datametricsAngleSpin, self.datametricsNoDataSpin], "valueChanged"), - (self.datametricsMinPointsSpin, "valueChanged"), - (self.extentSelector, ["selectionStarted", "newExtentDefined"], self.extentGroup), - ([self.widthSpin, self.heightSpin], "valueChanged", self.resizeGroupBox) - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.inSelector.layerChanged.connect(self.fillFieldsCombo) - self.extentGroup.toggled.connect(self.onExtentCheckedChanged) - - def onClosing(self): - self.extentSelector.stop() - BasePluginWidget.onClosing(self) - - def onExtentCheckedChanged(self, enabled): - self.extentSelector.start() if enabled else self.extentSelector.stop() - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getVectorLayers()) - - def fillFieldsCombo(self): - if self.inSelector.layer() is None: - return - - self.lastEncoding = self.inSelector.layer().dataProvider().encoding() - self.loadFields(self.getInputFileName()) - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter() - inputFile, encoding = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Grid"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True) - if not inputFile: - return - Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - self.lastEncoding = encoding - - self.loadFields(inputFile) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - - def getArguments(self): - arguments = [] - if self.zfieldCheck.isChecked() and self.zfieldCombo.currentIndex() >= 0: - arguments.append("-zfield") - arguments.append(self.zfieldCombo.currentText()) - inputFn = self.getInputFileName() - if inputFn: - arguments.append("-l") - arguments.append(QFileInfo(inputFn).baseName()) - if self.extentGroup.isChecked(): - rect = self.extentSelector.getExtent() - if rect is not None: - arguments.append("-txe") - arguments.append(str(rect.xMinimum())) - arguments.append(str(rect.xMaximum())) - arguments.append("-tye") - arguments.append(str(rect.yMaximum())) - arguments.append(str(rect.yMinimum())) - if self.algorithmCheck.isChecked() and self.algorithmCombo.currentIndex() >= 0: - arguments.append("-a") - arguments.append(self.algorithmArguments(self.algorithmCombo.currentIndex())) - if self.resizeGroupBox.isChecked(): - arguments.append("-outsize") - arguments.append(str(self.widthSpin.value())) - arguments.append(str(self.heightSpin.value())) - outputFn = self.getOutputFileName() - if outputFn: - arguments.append("-of") - arguments.append(self.outputFormat) - arguments.append(inputFn) - arguments.append(outputFn) - return arguments - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - return self.outSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) - - def algorithmArguments(self, index): - algorithm = self.algorithm[index] - arguments = [] - if algorithm == "invdist": - arguments.append(algorithm) - arguments.append("power=" + str(self.invdistPowerSpin.value())) - arguments.append("smothing=" + str(self.invdistSmothingSpin.value())) - arguments.append("radius1=" + str(self.invdistRadius1Spin.value())) - arguments.append("radius2=" + str(self.invdistRadius2Spin.value())) - arguments.append("angle=" + str(self.invdistAngleSpin.value())) - arguments.append("max_points=" + str(self.invdistMaxPointsSpin.value())) - arguments.append("min_points=" + str(self.invdistMinPointsSpin.value())) - arguments.append("nodata=" + str(self.invdistNoDataSpin.value())) - elif algorithm == "average": - arguments.append(algorithm) - arguments.append("radius1=" + str(self.averageRadius1Spin.value())) - arguments.append("radius2=" + str(self.averageRadius2Spin.value())) - arguments.append("angle=" + str(self.averageAngleSpin.value())) - arguments.append("min_points=" + str(self.averageMinPointsSpin.value())) - arguments.append("nodata=" + str(self.averageNoDataSpin.value())) - elif algorithm == "nearest": - arguments.append(algorithm) - arguments.append("radius1=" + str(self.nearestRadius1Spin.value())) - arguments.append("radius2=" + str(self.nearestRadius2Spin.value())) - arguments.append("angle=" + str(self.nearestAngleSpin.value())) - arguments.append("nodata=" + str(self.nearestNoDataSpin.value())) - else: - arguments.append(self.datametrics[self.datametricsCombo.currentIndex()]) - arguments.append("radius1=" + str(self.datametricsRadius1Spin.value())) - arguments.append("radius2=" + str(self.datametricsRadius2Spin.value())) - arguments.append("angle=" + str(self.datametricsAngleSpin.value())) - arguments.append("min_points=" + str(self.datametricsMinPointsSpin.value())) - arguments.append("nodata=" + str(self.datametricsNoDataSpin.value())) - return ':'.join(arguments) - - def loadFields(self, vectorFile=''): - self.zfieldCombo.clear() - - if not vectorFile: - return - - try: - (fields, names) = Utils.getVectorFields(vectorFile) - except Utils.UnsupportedOGRFormat as e: - QErrorMessage(self).showMessage(e.args[0]) - self.inSelector.setLayer(None) - return - - ncodec = QTextCodec.codecForName(self.lastEncoding) - for name in names: - self.zfieldCombo.addItem(ncodec.toUnicode(name)) diff --git a/python/plugins/GdalTools/tools/doInfo.py b/python/plugins/GdalTools/tools/doInfo.py deleted file mode 100644 index 62bb8030001..00000000000 --- a/python/plugins/GdalTools/tools/doInfo.py +++ /dev/null @@ -1,136 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doInfo.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str -from builtins import range - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import Qt -from qgis.PyQt.QtWidgets import QWidget, QAction, QApplication, QMenu - -from .ui_widgetInfo import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - -import platform - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdalinfo") - - # we don't need load to canvas functionality - self.base.loadCheckBox.hide() - # make window large - self.base.resize(400, 360) - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.suppressGCPCheck, "stateChanged"), - (self.suppressMDCheck, "stateChanged") - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - - # helper actions for copying info output - self.copyLine = QAction(self.tr("Copy"), self) - self.copyLine.triggered.connect(self.doCopyLine) - self.copyAll = QAction(self.tr("Copy all"), self) - self.copyAll.triggered.connect(self.doCopyAll) - - def doCopyLine(self): - output = '' - items = self.rasterInfoList.selectedItems() - for r in items: - output += r.text() + "\n" - if output: - clipboard = QApplication.clipboard() - clipboard.setText(output) - - def doCopyAll(self): - output = '' - for r in range(self.rasterInfoList.count()): - output += self.rasterInfoList.item(r).text() + "\n" - if output: - clipboard = QApplication.clipboard() - clipboard.setText(output) - - def keyPressEvent(self, e): - if (e.modifiers() == Qt.ControlModifier or e.modifiers() == Qt.MetaModifier) and e.key() == Qt.Key_C: - items = '' - for r in range(self.rasterInfoList.count()): - items.append(self.rasterInfoList.item(r).text() + "\n") - if items: - clipboard = QApplication.clipboard() - clipboard.setText(items) - else: - QWidget.keyPressEvent(self, e) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def finished(self): - self.rasterInfoList.clear() - arr = str(self.base.process.readAllStandardOutput()).strip() - if platform.system() == "Windows": - #info = QString.fromLocal8Bit( arr ).strip().split( "\r\n" ) - # TODO test - info = arr.splitlines() - else: - info = arr.splitlines() - self.rasterInfoList.addItems(info) - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the file to analyse"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - - def getArguments(self): - arguments = [] - if self.suppressGCPCheck.isChecked(): - arguments.append("-nogcp") - if self.suppressMDCheck.isChecked(): - arguments.append("-nomd") - arguments.append(self.getInputFileName()) - return arguments - -# def getOutputFileName( self ): -# return self.inSelector.filename() - - def getInputFileName(self): - return self.inSelector.filename() - - def contextMenuEvent(self, event): - menu = QMenu(self) - menu.addAction(self.copyLine) - menu.addAction(self.copyAll) - menu.exec_(event.globalPos()) diff --git a/python/plugins/GdalTools/tools/doMerge.py b/python/plugins/GdalTools/tools/doMerge.py deleted file mode 100644 index da09dd444b8..00000000000 --- a/python/plugins/GdalTools/tools/doMerge.py +++ /dev/null @@ -1,199 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doMerge.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QCoreApplication -from qgis.PyQt.QtWidgets import QWidget, QMessageBox - -from .ui_widgetMerge import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdal_merge.py") - - self.inSelector.setType(self.inSelector.FILE) - self.outSelector.setType(self.outSelector.FILE) - self.recurseCheck.hide() - # use this for approx. previous UI - #self.creationOptionsWidget.setType(QgsRasterFormatSaveOptionsWidget.Table) - - self.outputFormat = Utils.fillRasterOutputFormat() - self.extent = None - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.noDataSpin, "valueChanged", self.noDataCheck), - (self.inputDirCheck, "stateChanged"), - (self.recurseCheck, "stateChanged", self.inputDirCheck), - (self.separateCheck, "stateChanged"), - (self.pctCheck, "stateChanged"), - (self.intersectCheck, "stateChanged"), - (self.creationOptionsWidget, "optionsChanged"), - (self.creationOptionsGroupBox, "toggled") - ]) - - self.inSelector.selectClicked.connect(self.fillInputFilesEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.intersectCheck.toggled.connect(self.refreshExtent) - self.inputDirCheck.stateChanged.connect(self.switchToolMode) - self.inSelector.filenameChanged.connect(self.refreshExtent) - - def switchToolMode(self): - self.recurseCheck.setVisible(self.inputDirCheck.isChecked()) - self.inSelector.clear() - - if self.inputDirCheck.isChecked(): - self.inFileLabel = self.label.text() - self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory")) - - self.inSelector.selectClicked.disconnect(self.fillInputFilesEdit) - self.inSelector.selectClicked.connect(self.fillInputDir) - else: - self.label.setText(self.inFileLabel) - - self.inSelector.selectClicked.connect(self.fillInputFilesEdit) - self.inSelector.selectClicked.disconnect(self.fillInputDir) - - def fillInputFilesEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - files = Utils.FileDialog.getOpenFileNames(self, self.tr("Select the files to Merge"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not files: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - self.inSelector.setFilename(files) - - def refreshExtent(self): - files = self.getInputFileNames() - self.intersectCheck.setEnabled(len(files) > 1) - - if not self.intersectCheck.isChecked(): - self.someValueChanged() - return - - if len(files) < 2: - self.intersectCheck.setChecked(False) - return - - self.extent = self.getIntersectedExtent(files) - - if self.extent is None: - QMessageBox.warning(self, self.tr("Error retrieving the extent"), self.tr('GDAL was unable to retrieve the extent from any file. \nThe "Use intersected extent" option will be unchecked.')) - self.intersectCheck.setChecked(False) - return - - elif self.extent.isEmpty(): - QMessageBox.warning(self, self.tr("Empty extent"), self.tr('The computed extent is empty. \nDisable the "Use intersected extent" option to have a nonempty output.')) - - self.someValueChanged() - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the Merge output"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - - def fillInputDir(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Merge")) - if not inputDir: - return - self.inSelector.setFilename(inputDir) - - def getArguments(self): - arguments = [] - if self.intersectCheck.isChecked(): - if self.extent is not None: - arguments.append("-ul_lr") - arguments.append(str(self.extent.xMinimum())) - arguments.append(str(self.extent.yMaximum())) - arguments.append(str(self.extent.xMaximum())) - arguments.append(str(self.extent.yMinimum())) - if self.noDataCheck.isChecked(): - arguments.append("-n") - arguments.append(str(self.noDataSpin.value())) - if Utils.GdalConfig.versionNum() >= 1900: - arguments.append("-a_nodata") - arguments.append(str(self.noDataSpin.value())) - if self.separateCheck.isChecked(): - arguments.append("-separate") - if self.pctCheck.isChecked(): - arguments.append("-pct") - if self.creationOptionsGroupBox.isChecked(): - for opt in self.creationOptionsWidget.options(): - arguments.append("-co") - arguments.append(opt) - outputFn = self.getOutputFileName() - if outputFn: - arguments.append("-of") - arguments.append(self.outputFormat) - arguments.append("-o") - arguments.append(outputFn) - arguments.extend(self.getInputFileNames()) - return arguments - - def getOutputFileName(self): - return self.outSelector.filename() - - def getInputFileName(self): - if self.inputDirCheck.isChecked(): - return self.inSelector.filename() - return self.inSelector.filename().split(",") - - def getInputFileNames(self): - if self.inputDirCheck.isChecked(): - return Utils.getRasterFiles(self.inSelector.filename(), self.recurseCheck.isChecked()) - return self.inSelector.filename().split(",") - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) - - def getIntersectedExtent(self, files): - res = None - for fileName in files: - if res is None: - res = Utils.getRasterExtent(self, fileName) - continue - - rect2 = Utils.getRasterExtent(self, fileName) - if rect2 is None: - continue - - res = res.intersect(rect2) - if res.isEmpty(): - break - - return res diff --git a/python/plugins/GdalTools/tools/doNearBlack.py b/python/plugins/GdalTools/tools/doNearBlack.py deleted file mode 100644 index f6218881faf..00000000000 --- a/python/plugins/GdalTools/tools/doNearBlack.py +++ /dev/null @@ -1,98 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doNearBlack.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtWidgets import QWidget - -from .ui_widgetNearBlack import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "nearblack") - - self.outSelector.setType(self.outSelector.FILE) - - # set the default QSpinBoxes value - self.nearSpin.setValue(15) - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.nearSpin, "valueChanged", self.nearCheck), - (self.whiteCheckBox, "stateChanged") - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Near Black"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outSelector.setFilename(outputFile) - - def getArguments(self): - arguments = [] - if self.whiteCheckBox.isChecked(): - arguments.append("-white") - if self.nearCheck.isChecked(): - arguments.append("-near") - arguments.append(str(self.nearSpin.value())) - arguments.append("-o") - arguments.append(self.getOutputFileName()) - arguments.append(self.getInputFileName()) - return arguments - - def getOutputFileName(self): - return self.outSelector.filename() - - def getInputFileName(self): - return self.inSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) diff --git a/python/plugins/GdalTools/tools/doOverview.py b/python/plugins/GdalTools/tools/doOverview.py deleted file mode 100644 index 949c02c06b6..00000000000 --- a/python/plugins/GdalTools/tools/doOverview.py +++ /dev/null @@ -1,199 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doOverview.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QCoreApplication -from qgis.PyQt.QtWidgets import QWidget -from qgis.core import QgsRaster - -from .ui_widgetOverview import Ui_GdalToolsWidget as Ui_Widget -from .widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - self.resampling_method = ('nearest', 'average', 'gauss', 'cubic', 'average_mp', 'average_magphase', 'mode') - - self.setupUi(self) - BaseBatchWidget.__init__(self, self.iface, "gdaladdo") - - # set the default QSpinBoxes and QProgressBar value - self.progressBar.setValue(0) - - self.progressBar.hide() - # we don't need load to canvas functionality - self.base.loadCheckBox.hide() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.cleanCheck, "stateChanged", None, 1700), - (self.mPyramidOptionsWidget, "overviewListChanged"), - (self.mPyramidOptionsWidget, "someValueChanged") - ]) - - self.inSelector.selectClicked.connect(self.fillInputFile) - self.batchCheck.stateChanged.connect(self.switchToolMode) - - self.init = False # workaround bug that pyramid options widgets are not initialized at first - - # make sure we get a command line when dialog appears - def show_(self): - BaseBatchWidget.show_(self) - self.someValueChanged() - - # switch to batch or normal mode - def switchToolMode(self): - self.setCommandViewerEnabled(not self.batchCheck.isChecked()) - self.progressBar.setVisible(self.batchCheck.isChecked()) - - self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER) - - if self.batchCheck.isChecked(): - self.inFileLabel = self.label.text() - self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory")) - - self.inSelector.selectClicked.disconnect(self.fillInputFile) - self.inSelector.selectClicked.connect(self.fillInputDir) - else: - self.label.setText(self.inFileLabel) - - self.inSelector.selectClicked.disconnect(self.fillInputDir) - self.inSelector.selectClicked.connect(self.fillInputFile) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def fillInputFile(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if inputFile == '': - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - - self.mPyramidOptionsWidget.setRasterLayer(None) - - def fillInputDir(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files")) - if inputDir == '': - return - - self.inSelector.setFilename(inputDir) - - def getArguments(self): - arguments = [] - - arguments.append("-r") - arguments.append(self.mPyramidOptionsWidget.resamplingMethod()) - - format = self.mPyramidOptionsWidget.pyramidsFormat() - if format == QgsRaster.PyramidsGTiff: - arguments.append("-ro") - elif format == QgsRaster.PyramidsErdas: - arguments.append("--config") - arguments.append("USE_RRD") - arguments.append("YES") - - for option in self.mPyramidOptionsWidget.configOptions(): - (k, v) = option.split("=") - arguments.append("--config") - arguments.append(str(k)) - arguments.append(str(v)) - - if self.cleanCheck.isChecked(): - arguments.append("-clean") - - # TODO fix batch enabled, argument order is wrong, levels not at end - if self.isBatchEnabled(): - return arguments - - arguments.append(self.getInputFileName()) - - if len(self.mPyramidOptionsWidget.overviewList()) > 0: - for level in self.mPyramidOptionsWidget.overviewList(): - arguments.append(str(level)) - - # set creation options filename/layer for validation - if self.init: - if self.isBatchEnabled(): - self.mPyramidOptionsWidget.setRasterLayer(None) - elif self.inSelector.layer(): - self.mPyramidOptionsWidget.setRasterLayer(self.inSelector.layer()) - else: - self.mPyramidOptionsWidget.setRasterFileName(self.getInputFileName()) - else: - self.init = True - - return arguments - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - return self.inSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) - - def getBatchArguments(self, inFile, outFile=None): - arguments = self.getArguments() - arguments.append(inFile) - if len(self.mPyramidOptionsWidget.overviewList()) == 0: - arguments.extend(["2", "4", "8", "16", "32"]) - else: - for level in self.mPyramidOptionsWidget.overviewList(): - arguments.append(str(level)) - return arguments - - def isBatchEnabled(self): - return self.batchCheck.isChecked() - - def onFinished(self, exitCode, status): - if not self.isBatchEnabled(): - from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget - BasePluginWidget.onFinished(self, exitCode, status) - return - - msg = str(self.base.process.readAllStandardError()) - if msg != '': - self.errors.append(">> " + self.inFiles[self.batchIndex] + "
    " + msg.replace("\n", "
    ")) - - self.base.process.close() - self.batchIndex += 1 - self.runItem(self.batchIndex, self.batchTotal) - - def setProgressRange(self, maximum): - self.progressBar.setRange(0, maximum) - - def updateProgress(self, index, total): - if index < total: - self.progressBar.setValue(index + 1) - else: - self.progressBar.setValue(0) diff --git a/python/plugins/GdalTools/tools/doPctRgb.py b/python/plugins/GdalTools/tools/doPctRgb.py deleted file mode 100644 index 5b2d7b51486..00000000000 --- a/python/plugins/GdalTools/tools/doPctRgb.py +++ /dev/null @@ -1,164 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doPctRgb.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QCoreApplication -from qgis.PyQt.QtWidgets import QWidget - -from .ui_widgetConvert import Ui_GdalToolsWidget as Ui_Widget -from .widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BaseBatchWidget.__init__(self, self.iface, "pct2rgb.py") - - # we use one widget for two tools - self.base.setWindowTitle(self.tr("Convert paletted image to RGB")) - - self.outSelector.setType(self.outSelector.FILE) - - # set the default QSpinBoxes and QProgressBar value - self.bandSpin.setValue(1) - self.progressBar.setValue(0) - - self.progressBar.hide() - self.outputFormat = Utils.fillRasterOutputFormat() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.colorsSpin, "valueChanged", self.colorsCheck, "-1"), # hide this option - (self.bandSpin, "valueChanged", self.bandCheck) - ]) - - self.inSelector.selectClicked.connect(self.fillInputFile) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.batchCheck.stateChanged.connect(self.switchToolMode) - - # switch to batch or normal mode - def switchToolMode(self): - self.setCommandViewerEnabled(not self.batchCheck.isChecked()) - self.progressBar.setVisible(self.batchCheck.isChecked()) - - self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER) - self.outSelector.clear() - - if self.batchCheck.isChecked(): - self.inFileLabel = self.label.text() - self.outFileLabel = self.label_2.text() - self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory")) - self.label_2.setText(QCoreApplication.translate("GdalTools", "&Output directory")) - - self.inSelector.selectClicked.disconnect(self.fillInputFile) - self.outSelector.selectClicked.disconnect(self.fillOutputFileEdit) - - self.inSelector.selectClicked.connect(self.fillInputDir) - self.outSelector.selectClicked.connect(self.fillOutputDir) - else: - self.label.setText(self.inFileLabel) - self.label_2.setText(self.outFileLabel) - - self.inSelector.selectClicked.disconnect(self.fillInputDir) - self.outSelector.selectClicked.disconnect(self.fillOutputDir) - - self.inSelector.selectClicked.connect(self.fillInputFile) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def fillInputFile(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for convert"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - self.inSelector.setFilename(inputFile) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - - def fillInputDir(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files for convert")) - if not inputDir: - return - self.inSelector.setFilename(inputDir) - - def fillOutputDir(self): - outputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the output directory to save the results to")) - if not outputDir: - return - self.outSelector.setFilename(outputDir) - - def getArguments(self): - arguments = [] - if self.bandCheck.isChecked(): - arguments.append("-b") - arguments.append(str(self.bandSpin.value())) - if self.isBatchEnabled(): - return arguments - - outputFn = self.getOutputFileName() - if outputFn: - arguments.append("-of") - arguments.append(self.outputFormat) - arguments.append(self.getInputFileName()) - arguments.append(outputFn) - return arguments - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - return self.outSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) - - def isBatchEnabled(self): - return self.batchCheck.isChecked() - - def setProgressRange(self, maximum): - self.progressBar.setRange(0, maximum) - - def updateProgress(self, index, total): - if index < total: - self.progressBar.setValue(index + 1) - else: - self.progressBar.setValue(0) diff --git a/python/plugins/GdalTools/tools/doPolygonize.py b/python/plugins/GdalTools/tools/doPolygonize.py deleted file mode 100644 index 55d563ef458..00000000000 --- a/python/plugins/GdalTools/tools/doPolygonize.py +++ /dev/null @@ -1,122 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doPolygonize.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QFileInfo -from qgis.PyQt.QtWidgets import QWidget - -from .ui_widgetPolygonize import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - self.resolutions = ("highest", "average", "lowest") - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdal_polygonize.py") - - self.outSelector.setType(self.outSelector.FILE) - self.outputFormat = Utils.fillVectorOutputFormat() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.maskSelector, "filenameChanged", self.maskCheck), - (self.fieldEdit, "textChanged", self.fieldCheck) - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.maskSelector.selectClicked.connect(self.fillMaskFileEdit) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - self.maskSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Polygonize"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter() - outputFile, encoding = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the Polygonize output"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True) - if not outputFile: - return - Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter) - - self.outputFormat = Utils.fillVectorOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - self.lastEncoding = encoding - - def fillMaskFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - maskFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Polygonize"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not maskFile(): - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.maskSelector.setFilename(maskFile) - - def getArguments(self): - arguments = [] - arguments.append(self.getInputFileName()) - outputFn = self.getOutputFileName() - maskFn = self.getMaskFileName() - if self.maskCheck.isChecked() and maskFn: - arguments.append("-mask") - arguments.append(maskFn) - if outputFn: - arguments.append("-f") - arguments.append(self.outputFormat) - arguments.append(outputFn) - if outputFn: - arguments.append(QFileInfo(outputFn).baseName()) - if (self.fieldCheck.isChecked() and self.fieldEdit.text()): - arguments.append(self.fieldEdit.text()) - return arguments - - def getOutputFileName(self): - return self.outSelector.filename() - - def getInputFileName(self): - return self.inSelector.filename() - - def getMaskFileName(self): - return self.maskSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - vl = self.iface.addVectorLayer(fileInfo.filePath(), fileInfo.baseName(), "ogr") - if vl is not None and vl.isValid(): - if hasattr(self, 'lastEncoding'): - vl.setProviderEncoding(self.lastEncoding) diff --git a/python/plugins/GdalTools/tools/doProjection.py b/python/plugins/GdalTools/tools/doProjection.py deleted file mode 100644 index ab26f27fcb3..00000000000 --- a/python/plugins/GdalTools/tools/doProjection.py +++ /dev/null @@ -1,191 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doProjection.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import Qt, QCoreApplication, QFile, QFileInfo -from qgis.PyQt.QtWidgets import QWidget, QMessageBox -from qgis.core import QgsProject, QgsMapLayer - -from .ui_widgetProjection import Ui_GdalToolsWidget as Ui_Widget -from .widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget -from .dialogSRS import GdalToolsSRSDialog as SRSDialog -from . import GdalTools_utils as Utils - -import re - - -class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BaseBatchWidget.__init__(self, self.iface, "gdal_translate") - - self.inSelector.setType(self.inSelector.FILE) - - # set the default QSpinBoxes and QProgressBar value - self.progressBar.setValue(0) - - self.progressBar.hide() - self.recurseCheck.hide() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.desiredSRSEdit, "textChanged") - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.selectDesiredSRSButton.clicked.connect(self.fillDesiredSRSEdit) - self.batchCheck.stateChanged.connect(self.switchToolMode) - self.recurseCheck.stateChanged.connect(self.enableRecurse) - - def switchToolMode(self): - self.setCommandViewerEnabled(not self.batchCheck.isChecked()) - self.progressBar.setVisible(self.batchCheck.isChecked()) - self.recurseCheck.setVisible(self.batchCheck.isChecked()) - - self.inSelector.clear() - - if self.batchCheck.isChecked(): - self.inFileLabel = self.label.text() - self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory")) - - self.inSelector.selectClicked.disconnect(self.fillInputFileEdit) - self.inSelector.selectClicked.connect(self.fillInputDir) - else: - self.label.setText(self.inFileLabel) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.inSelector.selectClicked.disconnect(self.fillInputDir) - - def enableRecurse(self): - if self.recurseCheck.isChecked(): - res = QMessageBox.warning(self, self.tr("Warning"), - self.tr("Warning: CRS information for all raster in subfolders will be rewritten. Are you sure?"), - QMessageBox.Yes | QMessageBox.No) - if res != QMessageBox.Yes: - self.recurseCheck.setCheckState(Qt.Unchecked) - return - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the file to analyse"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - self.inSelector.setFilename(inputFile) - - def fillInputDir(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Assign projection")) - if not inputDir: - return - self.inSelector.setFilename(inputDir) - - def fillDesiredSRSEdit(self): - dialog = SRSDialog("Select desired SRS", self) - if dialog.exec_(): - self.desiredSRSEdit.setText(dialog.getProjection()) - - def getArguments(self): - arguments = [] - if self.desiredSRSEdit.text(): - arguments.append("-a_srs") - arguments.append(self.desiredSRSEdit.text()) - if self.batchCheck.isChecked(): - return arguments - - inputFn = self.getInputFileName() - arguments.append(inputFn) - self.tempFile = inputFn - self.needOverwrite = False - if self.tempFile: - if self.tempFile.lower().endswith(".tif") or self.tempFile.lower().endswith(".tiff"): - self.tempFile = re.sub("\.[a-zA-Z]{2,4}$", ".tif", self.tempFile) + ".tmp" - self.needOverwrite = True - else: - self.tempFile = re.sub("\.[a-zA-Z]{2,4}$", ".tif", self.tempFile) - arguments.append(self.tempFile) - return arguments - - def finished(self): - outFn = self.getOutputFileName() - if self.needOverwrite: - oldFile = QFile(outFn) - newFile = QFile(self.tempFile) - if oldFile.remove(): - newFile.rename(outFn) - - fileInfo = QFileInfo(outFn) - if fileInfo.exists(): - if self.base.loadCheckBox.isChecked(): - self.addLayerIntoCanvas(fileInfo) - QMessageBox.information(self, self.tr("Finished"), self.tr("Processing completed.")) - else: - QMessageBox.warning(self, self.tr("Warning"), self.tr("{0} not created.").format(outFn)) - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - return self.inSelector.filename() - - def getBatchOutputFileName(self, fn): - # get GeoTiff - fn = re.sub(r'\.[a-zA-Z]{2,4}$', r'.tif', fn) - return BaseBatchWidget.getBatchOutputFileName(self, fn) - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) - - def checkLayer(self): - layerList = [] - - layerMap = QgsProject.instance().mapLayers() - for name, layer in layerMap.items(): - if layer.type() == QgsMapLayer.RasterLayer: - layerList.append(str(layer.source())) - - if str(self.inputFileEdit.text()) in layerList: - QMessageBox.warning(self, self.tr("Assign projection"), self.tr("This raster already found in map canvas")) - return - - self.onRun() - - def isBatchEnabled(self): - return self.batchCheck.isChecked() - - def isRecursiveScanEnabled(self): - return self.recurseCheck.isChecked() - - def setProgressRange(self, maximum): - self.progressBar.setRange(0, maximum) - - def updateProgress(self, index, total): - if index < total: - self.progressBar.setValue(index + 1) - else: - self.progressBar.setValue(0) diff --git a/python/plugins/GdalTools/tools/doProximity.py b/python/plugins/GdalTools/tools/doProximity.py deleted file mode 100644 index f64ecd4ed52..00000000000 --- a/python/plugins/GdalTools/tools/doProximity.py +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doProximity.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtWidgets import QWidget - -from .ui_widgetProximity import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdal_proximity.py") - - self.outSelector.setType(self.outSelector.FILE) - self.outputFormat = Utils.fillRasterOutputFormat() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.valuesEdit, "textChanged", self.valuesCheck), - (self.distUnitsCombo, "currentIndexChanged", self.distUnitsCheck), - (self.maxDistSpin, "valueChanged", self.maxDistCheck), - (self.noDataSpin, "valueChanged", self.noDataCheck), - (self.fixedBufValSpin, "valueChanged", self.fixedBufValCheck) - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry().getRasterLayers()) - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Proximity"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - - def getArguments(self): - arguments = [] - arguments.append(self.getInputFileName()) - outputFn = self.getOutputFileName() - arguments.append(outputFn) - if self.valuesCheck.isChecked(): - values = self.valuesEdit.text().split() - if values: - arguments.append("-values") - arguments.append(','.join(values)) - if self.distUnitsCheck.isChecked() and self.distUnitsCombo.currentIndex() >= 0: - arguments.append("-distunits") - arguments.append(self.distUnitsCombo.currentText()) - if self.maxDistCheck.isChecked(): - arguments.append("-maxdist") - arguments.append(str(self.maxDistSpin.value())) - if self.noDataCheck.isChecked(): - arguments.append("-nodata") - arguments.append(str(self.noDataSpin.value())) - if self.fixedBufValCheck.isChecked(): - arguments.append("-fixed-buf-val") - arguments.append(str(self.fixedBufValSpin.value())) - if outputFn: - arguments.append("-of") - arguments.append(self.outputFormat) - return arguments - - def getOutputFileName(self): - return self.outSelector.filename() - - def getInputFileName(self): - return self.inSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) diff --git a/python/plugins/GdalTools/tools/doRasterize.py b/python/plugins/GdalTools/tools/doRasterize.py deleted file mode 100644 index 9b88dabf2b5..00000000000 --- a/python/plugins/GdalTools/tools/doRasterize.py +++ /dev/null @@ -1,162 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doRasterize.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QFileInfo, QTextCodec -from qgis.PyQt.QtWidgets import QWidget, QMessageBox, QErrorMessage - -from .ui_widgetRasterize import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdal_rasterize") - - self.outSelector.setType(self.outSelector.FILE) - - # set the default QSpinBoxes and QProgressBar value - self.widthSpin.setValue(3000) - self.heightSpin.setValue(3000) - self.horizresSpin.setValue(1) - self.vertresSpin.setValue(1) - - self.lastEncoding = Utils.getLastUsedEncoding() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.attributeComboBox, "currentIndexChanged"), - ([self.widthSpin, self.heightSpin], "valueChanged"), - ([self.horizresSpin, self.vertresSpin], "valueChanged") - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.inSelector.layerChanged.connect(self.fillFieldsCombo) - self.radioSetSize.toggled.connect(self.someValueChanged) - self.radioSetResolution.toggled.connect(self.someValueChanged) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getVectorLayers()) - - def fillFieldsCombo(self): - if self.inSelector.layer() is None: - return - self.lastEncoding = self.inSelector.layer().dataProvider().encoding() - self.loadFields(self.getInputFileName()) - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter() - inputFile, encoding = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Rasterize"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True) - if not inputFile: - return - Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - self.lastEncoding = encoding - - self.loadFields(inputFile) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - - # rasterize supports output file creation for GDAL 1.8 - gdalVersion = Utils.GdalConfig.versionNum() - if gdalVersion >= 1800: - fileDialogFunc = Utils.FileDialog.getSaveFileName - filters = Utils.FileFilter.saveRastersFilter() - else: - fileDialogFunc = Utils.FileDialog.getOpenFileName - filters = Utils.FileFilter.allRastersFilter() - - outputFile = fileDialogFunc(self, self.tr("Select the raster file to save the results to"), filters, lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outSelector.setFilename(outputFile) - - # required either -ts or -tr to create the output file - if gdalVersion >= 1800: - if not QFileInfo(outputFile).exists(): - QMessageBox.information(self, self.tr("Output size or resolution required"), self.tr("The output file doesn't exist. You must set up the output size or resolution to create it.")) - self.radioSetSize.setChecked(True) - - def getArguments(self): - arguments = [] - if self.attributeComboBox.currentIndex() >= 0: - arguments.append("-a") - arguments.append(self.attributeComboBox.currentText()) - if self.radioSetSize.isChecked(): - arguments.append("-ts") - arguments.append(self.widthSpin.value()) - arguments.append(self.heightSpin.value()) - if self.radioSetResolution.isChecked(): - arguments.append("-tr") - arguments.append(self.horizresSpin.value()) - arguments.append(self.vertresSpin.value()) - inputFn = self.getInputFileName() - if inputFn: - arguments.append("-l") - arguments.append(QFileInfo(inputFn).baseName()) - arguments.append(inputFn) - arguments.append(self.getOutputFileName()) - return arguments - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - return self.outSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) - - def loadFields(self, vectorFile): - self.attributeComboBox.clear() - - if not vectorFile: - return - - try: - (fields, names) = Utils.getVectorFields(vectorFile) - except Utils.UnsupportedOGRFormat as e: - QErrorMessage(self).showMessage(e.args[0]) - self.inSelector.setLayer(None) - return - - # GDAL Python3 bindings return fields as str and not bytes - # so no recoding is needed. But this assumes that the underlying - # OGR driver always return a Unicode string. hum... - #ncodec = QTextCodec.codecForName(self.lastEncoding) - for name in names: - self.attributeComboBox.addItem(name) - #self.attributeComboBox.addItem(ncodec.toUnicode(name)) diff --git a/python/plugins/GdalTools/tools/doRgbPct.py b/python/plugins/GdalTools/tools/doRgbPct.py deleted file mode 100644 index 86c49f67169..00000000000 --- a/python/plugins/GdalTools/tools/doRgbPct.py +++ /dev/null @@ -1,161 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doRgbPct.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QCoreApplication -from qgis.PyQt.QtWidgets import QWidget - -from .ui_widgetConvert import Ui_GdalToolsWidget as Ui_Widget -from .widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BaseBatchWidget.__init__(self, self.iface, "rgb2pct.py") - - self.outSelector.setType(self.outSelector.FILE) - - # set the default QSpinBoxes and QProgressBar value - self.colorsSpin.setValue(2) - self.progressBar.setValue(0) - - self.progressBar.hide() - self.outputFormat = Utils.fillRasterOutputFormat() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.colorsSpin, "valueChanged", self.colorsCheck), - (self.bandSpin, "valueChanged", self.bandCheck, "-1") # hide this option - ]) - - self.inSelector.selectClicked.connect(self.fillInputFile) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.batchCheck.stateChanged.connect(self.switchToolMode) - - # switch to batch or normal mode - def switchToolMode(self): - self.setCommandViewerEnabled(not self.batchCheck.isChecked()) - self.progressBar.setVisible(self.batchCheck.isChecked()) - - self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER) - self.outSelector.clear() - - if self.batchCheck.isChecked(): - self.inFileLabel = self.label.text() - self.outFileLabel = self.label_2.text() - self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory")) - self.label_2.setText(QCoreApplication.translate("GdalTools", "&Output directory")) - - self.inSelector.selectClicked.disconnect(self.fillInputFile) - self.outSelector.selectClicked.disconnect(self.fillOutputFileEdit) - - self.inSelector.selectClicked.connect(self.fillInputDir) - self.outSelector.selectClicked.connect(self.fillOutputDir) - else: - self.label.setText(self.inFileLabel) - self.label_2.setText(self.outFileLabel) - - self.inSelector.selectClicked.disconnect(self.fillInputDir) - self.outSelector.selectClicked.disconnect(self.fillOutputDir) - - self.inSelector.selectClicked.connect(self.fillInputFile) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def fillInputFile(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for convert"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - self.inSelector.setFilename(inputFile) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - - def fillInputDir(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files for convert")) - if not inputDir: - return - self.inSelector.setFilename(inputDir) - - def fillOutputDir(self): - outputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the output directory to save the results to")) - if not outputDir: - return - self.outSelector.setFilename(outputDir) - - def getArguments(self): - arguments = [] - if self.colorsCheck.isChecked(): - arguments.append("-n") - arguments.append(str(self.colorsSpin.value())) - if self.isBatchEnabled(): - return arguments - - outputFn = self.getOutputFileName() - if outputFn: - arguments.append("-of") - arguments.append(self.outputFormat) - arguments.append(self.getInputFileName()) - arguments.append(outputFn) - return arguments - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - return self.outSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) - - def isBatchEnabled(self): - return self.batchCheck.isChecked() - - def setProgressRange(self, maximum): - self.progressBar.setRange(0, maximum) - - def updateProgress(self, index, total): - if index < total: - self.progressBar.setValue(index + 1) - else: - self.progressBar.setValue(0) diff --git a/python/plugins/GdalTools/tools/doSettings.py b/python/plugins/GdalTools/tools/doSettings.py deleted file mode 100644 index 8a5fe956157..00000000000 --- a/python/plugins/GdalTools/tools/doSettings.py +++ /dev/null @@ -1,95 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doSettings.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import Qt -from qgis.PyQt.QtWidgets import QDialog -from qgis.PyQt.QtGui import QPixmap - -from .ui_dialogSettings import Ui_GdalToolsSettingsDialog as Ui_Dialog -from . import GdalTools_utils as Utils - - -class GdalToolsSettingsDialog(QDialog, Ui_Dialog): - - def __init__(self, iface): - QDialog.__init__(self, iface.mainWindow()) - self.setAttribute(Qt.WA_DeleteOnClose) - self.iface = iface - self.setupUi(self) - - # binaries - self.leGdalBinPath.setText(Utils.getGdalBinPath()) - self.btnSetBinPath.clicked.connect(self.setBinPath) - self.bin_tooltip_label.setPixmap(QPixmap(':/icons/tooltip.png')) - self.bin_tooltip_label.setToolTip(self.tr(u"""\ -A list of colon-separated (Linux and MacOS) or -semicolon-separated (Windows) paths to both binaries -and python executables. - -MacOS users usually need to set it to something like -/Library/Frameworks/GDAL.framework/Versions/1.8/Programs""")) - - # python modules - self.leGdalPymodPath.setText(Utils.getGdalPymodPath()) - self.btnSetPymodPath.clicked.connect(self.setPymodPath) - self.pymod_tooltip_label.setPixmap(QPixmap(':/icons/tooltip.png')) - self.pymod_tooltip_label.setToolTip(self.tr(u"""\ -A list of colon-separated (Linux and MacOS) or -semicolon-separated (Windows) paths to python modules.""")) - - # help - self.leGdalHelpPath.setText(Utils.getHelpPath()) - self.btnSetHelpPath.clicked.connect(self.setHelpPath) - self.help_tooltip_label.setPixmap(QPixmap(':/icons/tooltip.png')) - self.help_tooltip_label.setToolTip(self.tr(u"""\ -Useful to open local GDAL documentation instead of online help -when pressing on the tool dialog's Help button.""")) - - def setBinPath(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select directory with GDAL executables")) - if not inputDir: - return - - self.leGdalBinPath.setText(inputDir) - - def setPymodPath(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select directory with GDAL python modules")) - if not inputDir: - return - - self.leGdalPymodPath.setText(inputDir) - - def setHelpPath(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select directory with the GDAL documentation")) - if not inputDir: - return - - self.leGdalHelpPath.setText(inputDir) - - def accept(self): - Utils.setGdalBinPath(self.leGdalBinPath.text()) - Utils.setGdalPymodPath(self.leGdalPymodPath.text()) - Utils.setHelpPath(self.leGdalHelpPath.text()) - QDialog.accept(self) diff --git a/python/plugins/GdalTools/tools/doSieve.py b/python/plugins/GdalTools/tools/doSieve.py deleted file mode 100644 index 39ef3760929..00000000000 --- a/python/plugins/GdalTools/tools/doSieve.py +++ /dev/null @@ -1,100 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doSieve.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtWidgets import QWidget - -from .ui_widgetSieve import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdal_sieve.py") - - self.outSelector.setType(self.outSelector.FILE) - self.outputFormat = Utils.fillRasterOutputFormat() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.thresholdSpin, "valueChanged", self.thresholdCheck), - (self.connectionsCombo, "currentIndexChanged", self.connectionsCheck) - ]) - - self.inSelector.selectClicked.connect(self.fillInputFileEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def fillInputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Sieve"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - - def getArguments(self): - arguments = [] - if self.thresholdCheck.isChecked(): - arguments.append("-st") - arguments.append(str(self.thresholdSpin.value())) - if self.connectionsCheck.isChecked() and self.connectionsCombo.currentIndex() >= 0: - arguments.append("-" + self.connectionsCombo.currentText()) - outputFn = self.getOutputFileName() - if outputFn: - arguments.append("-of") - arguments.append(self.outputFormat) - arguments.append(self.getInputFileName()) - arguments.append(outputFn) - return arguments - - def getOutputFileName(self): - return self.outSelector.filename() - - def getInputFileName(self): - return self.inSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) diff --git a/python/plugins/GdalTools/tools/doTileIndex.py b/python/plugins/GdalTools/tools/doTileIndex.py deleted file mode 100644 index 5c52e74f6bd..00000000000 --- a/python/plugins/GdalTools/tools/doTileIndex.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doTileIndex.py - --------------------- - Date : February 2011 - Copyright : (C) 2011 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" - -__author__ = 'Giuseppe Sucameli' -__date__ = 'February 2011' -__copyright__ = '(C) 2011, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtWidgets import QWidget - -from .ui_widgetTileIndex import Ui_GdalToolsWidget as Ui_Widget -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - - self.setupUi(self) - BasePluginWidget.__init__(self, self.iface, "gdaltindex") - - self.inSelector.setType(self.inSelector.FILE) - self.outSelector.setType(self.outSelector.FILE) - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - #( self.recurseCheck, "stateChanged" ), - (self.outSelector, "filenameChanged"), - (self.indexFieldEdit, "textChanged", self.indexFieldCheck), - (self.skipDifferentProjCheck, "stateChanged", None, 1500) - ]) - - self.inSelector.selectClicked.connect(self.fillInputDirEdit) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - - def fillInputDirEdit(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with raster files")) - if not inputDir: - return - self.inSelector.setFilename(inputDir) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter() - outputFile, encoding = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the TileIndex output"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True) - if not outputFile: - return - Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter) - - self.outputFormat = Utils.fillVectorOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - self.lastEncoding = encoding - - def getArguments(self): - arguments = [] - if self.indexFieldCheck.isChecked() and self.indexFieldEdit.text(): - arguments.append("-tileindex") - arguments.append(self.indexFieldEdit.text()) - if self.skipDifferentProjCheck.isChecked(): - arguments.append("-skip_different_projection") - arguments.append(self.getOutputFileName()) - arguments.extend(Utils.getRasterFiles(self.getInputFileName(), self.recurseCheck.isChecked())) - return arguments - - def getOutputFileName(self): - return self.outSelector.filename() - - def getInputFileName(self): - return self.inSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - vl = self.iface.addVectorLayer(fileInfo.filePath(), fileInfo.baseName(), "ogr") - if vl is not None and vl.isValid(): - if hasattr(self, 'lastEncoding'): - vl.setProviderEncoding(self.lastEncoding) diff --git a/python/plugins/GdalTools/tools/doTranslate.py b/python/plugins/GdalTools/tools/doTranslate.py deleted file mode 100644 index 8c697c3e562..00000000000 --- a/python/plugins/GdalTools/tools/doTranslate.py +++ /dev/null @@ -1,307 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doTranslate.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import Qt, QCoreApplication, QDir -from qgis.PyQt.QtWidgets import QWidget, QMessageBox - -from .ui_widgetTranslate import Ui_GdalToolsWidget as Ui_Widget -from .widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget -from .dialogSRS import GdalToolsSRSDialog as SRSDialog -from . import GdalTools_utils as Utils - -import re - - -class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - self.canvas = self.iface.mapCanvas() - self.expand_method = ('gray', 'rgb', 'rgba') - - self.setupUi(self) - BaseBatchWidget.__init__(self, self.iface, "gdal_translate") - - self.outSelector.setType(self.outSelector.FILE) - - # set the default QSpinBoxes and QProgressBar value - self.outsizeSpin.setValue(25) - self.progressBar.setValue(0) - - self.progressBar.hide() - self.formatLabel.hide() - self.formatCombo.hide() - - if Utils.GdalConfig.versionNum() < 1700: - index = self.expandCombo.findText('gray', Qt.MatchFixedString) - if index >= 0: - self.expandCombo.removeItem(index) - - self.outputFormat = Utils.fillRasterOutputFormat() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.targetSRSEdit, "textChanged", self.targetSRSCheck), - (self.selectTargetSRSButton, None, self.targetSRSCheck), - (self.creationOptionsWidget, "optionsChanged"), - (self.outsizeSpin, "valueChanged", self.outsizeCheck), - (self.nodataSpin, "valueChanged", self.nodataCheck), - (self.expandCombo, "currentIndexChanged", self.expandCheck, 1600), - (self.sdsCheck, "stateChanged"), - (self.srcwinEdit, "textChanged", self.srcwinCheck), - (self.prjwinEdit, "textChanged", self.prjwinCheck) - ]) - - #self.canvas.layersChanged.connect(self.fillInputLayerCombo) - self.inSelector.layerChanged.connect(self.fillTargetSRSEditDefault) - self.inSelector.selectClicked.connect(self.fillInputFile) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.selectTargetSRSButton.clicked.connect(self.fillTargetSRSEdit) - self.batchCheck.stateChanged.connect(self.switchToolMode) - - # add raster filters to combo - self.formatCombo.addItems(Utils.FileFilter.allRastersFilter().split(";;")) - - def switchToolMode(self): - self.setCommandViewerEnabled(not self.batchCheck.isChecked()) - self.progressBar.setVisible(self.batchCheck.isChecked()) - self.formatLabel.setVisible(self.batchCheck.isChecked()) - self.formatCombo.setVisible(self.batchCheck.isChecked()) - - self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER) - self.outSelector.clear() - - if self.batchCheck.isChecked(): - self.inFileLabel = self.label_3.text() - self.outFileLabel = self.label_2.text() - self.label_3.setText(QCoreApplication.translate("GdalTools", "&Input directory")) - self.label_2.setText(QCoreApplication.translate("GdalTools", "&Output directory")) - - self.inSelector.selectClicked.disconnect(self.fillInputFile) - self.outSelector.selectClicked.disconnect(self.fillOutputFileEdit) - - self.inSelector.selectClicked.connect(self. fillInputDir) - self.outSelector.selectClicked.connect(self.fillOutputDir) - else: - self.label_3.setText(self.inFileLabel) - self.label_2.setText(self.outFileLabel) - - self.inSelector.selectClicked.disconnect(self.fillInputDir) - self.outSelector.selectClicked.disconnect(self.fillOutputDir) - - self.inSelector.selectClicked.connect(self.fillInputFile) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - - def fillInputFile(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Translate"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.inSelector.setFilename(inputFile) - - # get SRS for target file if necessary and possible - self.refreshTargetSRS() - - def fillInputDir(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Translate")) - if not inputDir: - return - self.inSelector.setFilename(inputDir) - - filter = Utils.getRasterExtensions() - workDir = QDir(inputDir) - workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot) - workDir.setNameFilters(filter) - - # search for a valid SRS, then use it as default target SRS - srs = '' - for fname in workDir.entryList(): - fl = inputDir + "/" + fname - srs = Utils.getRasterSRS(self, fl) - if srs: - break - self.targetSRSEdit.setText(srs) - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - - def fillOutputDir(self): - outputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the output directory to save the results to")) - if not outputDir: - return - self.outSelector.setFilename(outputDir) - - def fillTargetSRSEditDefault(self): - if self.inSelector.layer() is None: - return - self.refreshTargetSRS() - - def refreshTargetSRS(self): - self.targetSRSEdit.setText(Utils.getRasterSRS(self, self.getInputFileName())) - - def fillTargetSRSEdit(self): - dialog = SRSDialog("Select the target SRS", self) - if dialog.exec_(): - self.targetSRSEdit.setText(dialog.getProjection()) - - def getArguments(self): - arguments = [] - if self.targetSRSCheck.isChecked() and self.targetSRSEdit.text(): - arguments.append("-a_srs") - arguments.append(self.targetSRSEdit.text()) - if self.creationOptionsGroupBox.isChecked(): - for opt in self.creationOptionsWidget.options(): - arguments.extend(["-co", opt]) - if self.outsizeCheck.isChecked() and self.outsizeSpin.value() != 100: - arguments.append("-outsize") - arguments.append(self.outsizeSpin.text()) - arguments.append(self.outsizeSpin.text()) - if self.expandCheck.isChecked(): - arguments.append("-expand") - arguments.append(self.expand_method[self.expandCombo.currentIndex()]) - if self.nodataCheck.isChecked(): - arguments.append("-a_nodata") - arguments.append(str(self.nodataSpin.value())) - if self.sdsCheck.isChecked(): - arguments.append("-sds") - if self.srcwinCheck.isChecked() and self.srcwinEdit.text(): - coordList = self.srcwinEdit.text().split() # split the string on whitespace(s) - if len(coordList) == 4 and coordList[3]: - try: - for x in coordList: - int(x) - except ValueError: - #print "Coordinates must be integer numbers." - QMessageBox.critical(self, self.tr("Translate - srcwin"), self.tr("Image coordinates (pixels) must be integer numbers.")) - else: - arguments.append("-srcwin") - for x in coordList: - arguments.append(x) - if self.prjwinCheck.isChecked() and self.prjwinEdit.text(): - coordList = self.prjwinEdit.text().split() # split the string on whitespace(s) - if len(coordList) == 4 and coordList[3]: - try: - for x in coordList: - float(x) - except ValueError: - #print "Coordinates must be integer numbers." - QMessageBox.critical(self, self.tr("Translate - prjwin"), self.tr("Image coordinates (geographic) must be numbers.")) - else: - arguments.append("-projwin") - for x in coordList: - arguments.append(x) - if self.isBatchEnabled(): - if self.formatCombo.currentIndex() != 0: - arguments.append("-of") - arguments.append(Utils.fillRasterOutputFormat(self.formatCombo.currentText())) - return arguments - else: - return arguments - - outputFn = self.getOutputFileName() - if outputFn: - arguments.append("-of") - arguments.append(self.outputFormat) - arguments.append(self.getInputFileName()) - arguments.append(outputFn) - - # set creation options filename/layer for validation - if self.inSelector.layer(): - self.creationOptionsWidget.setRasterLayer(self.inSelector.layer()) - else: - self.creationOptionsWidget.setRasterFileName(self.getInputFileName()) - - return arguments - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - return self.outSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) - - def isBatchEnabled(self): - return self.batchCheck.isChecked() - - def setProgressRange(self, maximum): - self.progressBar.setRange(0, maximum) - - def updateProgress(self, index, total): - if index < total: - self.progressBar.setValue(index + 1) - else: - self.progressBar.setValue(0) - - def batchRun(self): - exts = re.sub('\).*$', '', re.sub('^.*\(', '', self.formatCombo.currentText())).split(" ") - if len(exts) > 0 and exts[0] != "*" and exts[0] != "*.*": - outExt = exts[0].replace("*", "") - else: - outExt = ".tif" - - self.base.enableRun(False) - self.base.setCursor(Qt.WaitCursor) - - inDir = self.getInputFileName() - outDir = self.getOutputFileName() - - filter = Utils.getRasterExtensions() - workDir = QDir(inDir) - workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot) - workDir.setNameFilters(filter) - files = workDir.entryList() - - self.inFiles = [] - self.outFiles = [] - - for f in files: - self.inFiles.append(inDir + "/" + f) - if outDir is not None: - outFile = re.sub("\.[a-zA-Z0-9]{2,4}", outExt, f) - self.outFiles.append(outDir + "/" + outFile) - - self.errors = [] - self.batchIndex = 0 - self.batchTotal = len(self.inFiles) - self.setProgressRange(self.batchTotal) - - self.runItem(self.batchIndex, self.batchTotal) diff --git a/python/plugins/GdalTools/tools/doWarp.py b/python/plugins/GdalTools/tools/doWarp.py deleted file mode 100644 index 7e29879a63a..00000000000 --- a/python/plugins/GdalTools/tools/doWarp.py +++ /dev/null @@ -1,251 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - doWarp.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QCoreApplication, QDir -from qgis.PyQt.QtWidgets import QWidget -from qgis.core import Qgis, QgsWkbTypes - -from .ui_widgetWarp import Ui_GdalToolsWidget as Ui_Widget -from .widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget -from .dialogSRS import GdalToolsSRSDialog as SRSDialog -from . import GdalTools_utils as Utils - - -class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget): - - def __init__(self, iface): - QWidget.__init__(self) - self.iface = iface - self.resampling_method = ('near', 'bilinear', 'cubic', 'cubicspline', 'lanczos') - - self.setupUi(self) - BaseBatchWidget.__init__(self, self.iface, "gdalwarp") - - self.outSelector.setType(self.outSelector.FILE) - - # set the default QSpinBoxes and QProgressBar value - self.widthSpin.setValue(3000) - self.heightSpin.setValue(3000) - self.progressBar.setValue(0) - - self.progressBar.hide() - - self.outputFormat = Utils.fillRasterOutputFormat() - - self.setParamsStatus([ - (self.inSelector, "filenameChanged"), - (self.outSelector, "filenameChanged"), - (self.sourceSRSEdit, "textChanged", self.sourceSRSCheck), - (self.selectSourceSRSButton, None, self.sourceSRSCheck), - (self.targetSRSEdit, "textChanged", self.targetSRSCheck), - (self.selectTargetSRSButton, None, self.targetSRSCheck), - (self.resamplingCombo, "currentIndexChanged", self.resamplingCheck), - (self.cacheSpin, "valueChanged", self.cacheCheck), - ([self.widthSpin, self.heightSpin], "valueChanged", self.resizeGroupBox), - (self.multithreadCheck, "stateChanged"), - (self.noDataEdit, "textChanged", self.noDataCheck), - (self.maskSelector, "filenameChanged", self.maskCheck, 1600), - ]) - - self.inSelector.layerChanged.connect(self.fillSourceSRSEditDefault) - self.inSelector.selectClicked.connect(self.fillInputFile) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - self.selectSourceSRSButton.clicked.connect(self.fillSourceSRSEdit) - self.selectTargetSRSButton.clicked.connect(self.fillTargetSRSEdit) - self.maskSelector.selectClicked.connect(self.fillMaskFile) - self.batchCheck.stateChanged.connect(self.switchToolMode) - - # switch to batch or normal mode - def switchToolMode(self): - self.setCommandViewerEnabled(not self.batchCheck.isChecked()) - self.progressBar.setVisible(self.batchCheck.isChecked()) - - self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER) - self.outSelector.clear() - - if self.batchCheck.isChecked(): - self.inFileLabel = self.label.text() - self.outFileLabel = self.label_2.text() - self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory")) - self.label_2.setText(QCoreApplication.translate("GdalTools", "&Output directory")) - - self.inSelector.selectClicked.disconnect(self.fillInputFile) - self.outSelector.selectClicked.disconnect(self.fillOutputFileEdit) - - self.inSelector.selectClicked.connect(self.fillInputDir) - self.outSelector.selectClicked.connect(self.fillOutputDir) - else: - self.label.setText(self.inFileLabel) - self.label_2.setText(self.outFileLabel) - - self.inSelector.selectClicked.disconnect(self.fillInputDir) - self.outSelector.selectClicked.disconnect(self.fillOutputDir) - - self.inSelector.selectClicked.connect(self.fillInputFile) - self.outSelector.selectClicked.connect(self.fillOutputFileEdit) - - def onLayersChanged(self): - self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers()) - self.maskSelector.setLayers([x for x in Utils.LayerRegistry.instance().getVectorLayers() if x.geometryType() == QgsWkbTypes.PolygonGeometry]) - - def fillInputFile(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Warp"), Utils.FileFilter.allRastersFilter(), lastUsedFilter) - if not inputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - self.inSelector.setFilename(inputFile) - - # get SRS for source file if necessary and possible - self.refreshSourceSRS() - - def fillOutputFileEdit(self): - lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() - outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter) - if not outputFile: - return - Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter) - - self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile) - self.outSelector.setFilename(outputFile) - - def fillMaskFile(self): - lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter() - maskFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the mask file"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter) - if not maskFile: - return - Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter) - self.maskSelector.setFilename(maskFile) - - def fillInputDir(self): - inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Warp")) - if not inputDir: - return - - self.inSelector.setFilename(inputDir) - - filter = Utils.getRasterExtensions() - workDir = QDir(inputDir) - workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot) - workDir.setNameFilters(filter) - if len(workDir.entryList()) > 0: - fl = inputDir + "/" + workDir.entryList()[0] - self.sourceSRSEdit.setText(Utils.getRasterSRS(self, fl)) - - def fillOutputDir(self): - outputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the output directory to save the results to")) - if not outputDir: - return - self.outSelector.setFilename(outputDir) - - def fillSourceSRSEdit(self): - dialog = SRSDialog("Select the source SRS", self) - if dialog.exec_(): - self.sourceSRSEdit.setText(dialog.getProjection()) - - def fillSourceSRSEditDefault(self): - if self.inSelector.layer() is None: - return - self.refreshSourceSRS() - - def refreshSourceSRS(self): - crs = Utils.getRasterSRS(self, self.getInputFileName()) - self.sourceSRSEdit.setText(crs) - self.sourceSRSCheck.setChecked(crs != '') - - def fillTargetSRSEdit(self): - dialog = SRSDialog("Select the target SRS", self) - if dialog.exec_(): - self.targetSRSEdit.setText(dialog.getProjection()) - - def getArguments(self): - arguments = [] - if not self.isBatchEnabled(): - arguments.append("-overwrite") - if self.sourceSRSCheck.isChecked() and self.sourceSRSEdit.text(): - arguments.append("-s_srs") - arguments.append(self.sourceSRSEdit.text()) - if self.targetSRSCheck.isChecked() and self.targetSRSEdit.text(): - arguments.append("-t_srs") - arguments.append(self.targetSRSEdit.text()) - if self.resamplingCheck.isChecked() and self.resamplingCombo.currentIndex() >= 0: - arguments.append("-r") - arguments.append(self.resampling_method[self.resamplingCombo.currentIndex()]) - if self.cacheCheck.isChecked(): - arguments.append("-wm") - arguments.append(str(self.cacheSpin.value())) - if self.resizeGroupBox.isChecked(): - arguments.append("-ts") - arguments.append(str(self.widthSpin.value())) - arguments.append(str(self.heightSpin.value())) - if self.multithreadCheck.isChecked(): - arguments.append("-multi") - if self.noDataCheck.isChecked(): - nodata = self.noDataEdit.text().strip() - if nodata: - arguments.append("-dstnodata") - arguments.append(nodata) - if self.maskCheck.isChecked(): - mask = self.getMaskFileName() - if mask: - arguments.append("-q") - arguments.append("-cutline") - arguments.append(mask) - arguments.append("-dstalpha") - if self.isBatchEnabled(): - return arguments - - outputFn = self.getOutputFileName() - if outputFn: - arguments.append("-of") - arguments.append(self.outputFormat) - arguments.append(self.getInputFileName()) - arguments.append(outputFn) - return arguments - - def getInputFileName(self): - return self.inSelector.filename() - - def getOutputFileName(self): - return self.outSelector.filename() - - def getMaskFileName(self): - return self.maskSelector.filename() - - def addLayerIntoCanvas(self, fileInfo): - self.iface.addRasterLayer(fileInfo.filePath()) - - def isBatchEnabled(self): - return self.batchCheck.isChecked() - - def setProgressRange(self, maximum): - self.progressBar.setRange(0, maximum) - - def updateProgress(self, index, total): - if index < total: - self.progressBar.setValue(index + 1) - else: - self.progressBar.setValue(0) diff --git a/python/plugins/GdalTools/tools/extentSelector.py b/python/plugins/GdalTools/tools/extentSelector.py deleted file mode 100644 index 4a362fee0ef..00000000000 --- a/python/plugins/GdalTools/tools/extentSelector.py +++ /dev/null @@ -1,209 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - extentSelector.py - --------------------- - Date : December 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'December 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import pyqtSignal -from qgis.PyQt.QtWidgets import QWidget -from qgis.PyQt.QtGui import QColor -from qgis.core import QgsPoint, QgsRectangle, Qgis, QgsWkbTypes -from qgis.gui import QgsMapTool, QgsMapToolEmitPoint, QgsRubberBand - -from .ui_extentSelector import Ui_GdalToolsExtentSelector as Ui_ExtentSelector - - -class GdalToolsExtentSelector(QWidget, Ui_ExtentSelector): - selectionStarted = pyqtSignal() - selectionStopped = pyqtSignal() - selectionPaused = pyqtSignal() - newExtentDefined = pyqtSignal() - - def __init__(self, parent=None): - QWidget.__init__(self, parent) - self.canvas = None - self.tool = None - self.previousMapTool = None - self.isStarted = False - - self.setupUi(self) - - self.x1CoordEdit.textChanged.connect(self.coordsChanged) - self.x2CoordEdit.textChanged.connect(self.coordsChanged) - self.y1CoordEdit.textChanged.connect(self.coordsChanged) - self.y2CoordEdit.textChanged.connect(self.coordsChanged) - self.btnEnable.clicked.connect(self.start) - - def setCanvas(self, canvas): - self.canvas = canvas - self.tool = RectangleMapTool(self.canvas) - self.previousMapTool = self.canvas.mapTool() - self.tool.rectangleCreated.connect(self.fillCoords) - self.tool.deactivated.connect(self.pause) - - def stop(self): - if not self.isStarted: - return - self.isStarted = False - self.btnEnable.setVisible(False) - self.tool.reset() - self.canvas.unsetMapTool(self.tool) - if self.previousMapTool != self.tool: - self.canvas.setMapTool(self.previousMapTool) - #self.coordsChanged() - self.selectionStopped.emit() - - def start(self): - prevMapTool = self.canvas.mapTool() - if prevMapTool != self.tool: - self.previousMapTool = prevMapTool - self.canvas.setMapTool(self.tool) - self.isStarted = True - self.btnEnable.setVisible(False) - self.coordsChanged() - self.selectionStarted.emit() - - def pause(self): - if not self.isStarted: - return - - self.btnEnable.setVisible(True) - self.selectionPaused.emit() - - def setExtent(self, rect): - if self.tool.setRectangle(rect): - self.newExtentDefined.emit() - - def getExtent(self): - return self.tool.rectangle() - - def isCoordsValid(self): - try: - QgsPoint(float(self.x1CoordEdit.text()), float(self.y1CoordEdit.text())) - QgsPoint(float(self.x2CoordEdit.text()), float(self.y2CoordEdit.text())) - except ValueError: - return False - - return True - - def coordsChanged(self): - rect = None - if self.isCoordsValid(): - point1 = QgsPoint(float(self.x1CoordEdit.text()), float(self.y1CoordEdit.text())) - point2 = QgsPoint(float(self.x2CoordEdit.text()), float(self.y2CoordEdit.text())) - rect = QgsRectangle(point1, point2) - - self.setExtent(rect) - - def fillCoords(self): - rect = self.getExtent() - self.blockSignals(True) - if rect is not None: - self.x1CoordEdit.setText(str(rect.xMinimum())) - self.x2CoordEdit.setText(str(rect.xMaximum())) - self.y1CoordEdit.setText(str(rect.yMaximum())) - self.y2CoordEdit.setText(str(rect.yMinimum())) - else: - self.x1CoordEdit.clear() - self.x2CoordEdit.clear() - self.y1CoordEdit.clear() - self.y2CoordEdit.clear() - self.blockSignals(False) - self.newExtentDefined.emit() - - -class RectangleMapTool(QgsMapToolEmitPoint): - rectangleCreated = pyqtSignal() - - def __init__(self, canvas): - self.canvas = canvas - QgsMapToolEmitPoint.__init__(self, self.canvas) - - self.rubberBand = QgsRubberBand(self.canvas, QgsWkbTypes.PolygonGeometry) - self.rubberBand.setColor(QColor(255, 0, 0, 100)) - self.rubberBand.setWidth(2) - - self.reset() - - def reset(self): - self.startPoint = self.endPoint = None - self.isEmittingPoint = False - self.rubberBand.reset(QgsWkbTypes.PolygonGeometry) - - def canvasPressEvent(self, e): - self.startPoint = self.toMapCoordinates(e.pos()) - self.endPoint = self.startPoint - self.isEmittingPoint = True - - self.showRect(self.startPoint, self.endPoint) - - def canvasReleaseEvent(self, e): - self.isEmittingPoint = False - self.rectangleCreated.emit() - - def canvasMoveEvent(self, e): - if not self.isEmittingPoint: - return - - self.endPoint = self.toMapCoordinates(e.pos()) - self.showRect(self.startPoint, self.endPoint) - - def showRect(self, startPoint, endPoint): - self.rubberBand.reset(QgsWkbTypes.PolygonGeometry) - if startPoint.x() == endPoint.x() or startPoint.y() == endPoint.y(): - return - - point1 = QgsPoint(startPoint.x(), startPoint.y()) - point2 = QgsPoint(startPoint.x(), endPoint.y()) - point3 = QgsPoint(endPoint.x(), endPoint.y()) - point4 = QgsPoint(endPoint.x(), startPoint.y()) - - self.rubberBand.addPoint(point1, False) - self.rubberBand.addPoint(point2, False) - self.rubberBand.addPoint(point3, False) - self.rubberBand.addPoint(point4, True) # true to update canvas - self.rubberBand.show() - - def rectangle(self): - if self.startPoint is None or self.endPoint is None: - return None - elif self.startPoint.x() == self.endPoint.x() or self.startPoint.y() == self.endPoint.y(): - return None - - return QgsRectangle(self.startPoint, self.endPoint) - - def setRectangle(self, rect): - if rect == self.rectangle(): - return False - - if rect is None: - self.reset() - else: - self.startPoint = QgsPoint(rect.xMaximum(), rect.yMaximum()) - self.endPoint = QgsPoint(rect.xMinimum(), rect.yMinimum()) - self.showRect(self.startPoint, self.endPoint) - return True - - def deactivate(self): - QgsMapTool.deactivate(self) - self.deactivated.emit() diff --git a/python/plugins/GdalTools/tools/extentSelector.ui b/python/plugins/GdalTools/tools/extentSelector.ui deleted file mode 100644 index f8b95731ed1..00000000000 --- a/python/plugins/GdalTools/tools/extentSelector.ui +++ /dev/null @@ -1,105 +0,0 @@ - - - GdalToolsExtentSelector - - - - 0 - 0 - 343 - 134 - - - - - 0 - - - - - Select the extent by drag on canvas - - - - - - - or change the extent coordinates - - - - - - - - - - x - - - - - - - - - - x - - - - - - - - - - - - - - - - y - - - - - - - y - - - - - - - 2 - - - 20 - - - - - - - 1 - - - - - - - - - - Re-Enable - - - - - - - - diff --git a/python/plugins/GdalTools/tools/inOutSelector.py b/python/plugins/GdalTools/tools/inOutSelector.py deleted file mode 100644 index a4c1f3432f2..00000000000 --- a/python/plugins/GdalTools/tools/inOutSelector.py +++ /dev/null @@ -1,253 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - inOutSelector.py - --------------------- - Date : April 2011 - Copyright : (C) 2011 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import str - -__author__ = 'Giuseppe Sucameli' -__date__ = 'April 2011' -__copyright__ = '(C) 2011, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import Qt, pyqtSignal, pyqtProperty -from qgis.PyQt.QtWidgets import QWidget, QComboBox - -from qgis.core import QgsProject, QgsMapLayer - -from .ui_inOutSelector import Ui_GdalToolsInOutSelector - - -class GdalToolsInOutSelector(QWidget, Ui_GdalToolsInOutSelector): - FILE = 0x1 - LAYER = 0x2 - MULTIFILE = 0x4 # NOT IMPLEMENTED YET - - FILE_LAYER = 0x1 | 0x2 - FILES = 0x1 | 0x4 # NOT IMPLEMENTED YET - FILES_LAYER = 0x3 | 0x4 # NOT IMPLEMENTED YET - - selectClicked = pyqtSignal() - filenameChanged = pyqtSignal() - layerChanged = pyqtSignal() - - def __init__(self, parent=None, type=None): - QWidget.__init__(self, parent) - - self.setupUi(self) - self.setFocusPolicy(Qt.StrongFocus) - self.combo.setInsertPolicy(QComboBox.NoInsert) - - self.clear() - - self.typ = None - if type is None: - self.resetType() - else: - self.setType(type) - - self.selectBtn.clicked.connect(self.selectClicked) - self.fileEdit.textChanged.connect(self.textChanged) - self.combo.editTextChanged.connect(self.textChanged) - self.combo.currentIndexChanged.connect(self.indexChanged) - - def clear(self): - self.filenames = [] - self.fileEdit.clear() - self.clearComboState() - self.combo.clear() - - def textChanged(self): - if self.getType() & self.MULTIFILE: - self.filenames = self.fileEdit.text().split(",") - if self.getType() & self.LAYER: - index = self.combo.currentIndex() - if index >= 0: - text = self.combo.currentText() - if text != self.combo.itemText(index): - return self.setFilename(text) - self.filenameChanged.emit() - - def indexChanged(self): - self.layerChanged.emit() - self.filenameChanged.emit() - - def setType(self, type): - if type == self.typ: - return - - if type & self.MULTIFILE: # MULTITYPE IS NOT IMPLEMENTED YET - type = type & ~self.MULTIFILE - - self.typ = type - - self.selectBtn.setVisible(self.getType() & self.FILE) - self.combo.setVisible(self.getType() & self.LAYER) - self.fileEdit.setVisible(not (self.getType() & self.LAYER)) - self.combo.setEditable(self.getType() & self.FILE) - - if self.getType() & self.FILE: - self.setFocusProxy(self.selectBtn) - else: - self.setFocusProxy(self.combo) - - # send signals to refresh connected widgets - self.filenameChanged.emit() - self.layerChanged.emit() - - def getType(self): - return self.typ - - def resetType(self): - self.setType(self.FILE_LAYER) - - selectorType = pyqtProperty("int", getType, setType, resetType) - - def setFilename(self, fn=None): - self.blockSignals(True) - prevFn, prevLayer = self.filename(), self.layer() - - if isinstance(fn, QgsMapLayer): - fn = fn.source() - - elif isinstance(fn, str) or isinstance(fn, str): - fn = str(fn) - - # TODO test - elif isinstance(fn, list): - if len(fn) > 0: - if self.getType() & self.MULTIFILE: - self.filenames = fn - #fn = "".join( fn, "," ) - fn = ",".join(fn) - else: - fn = '' - - else: - fn = '' - - if not (self.getType() & self.LAYER): - self.fileEdit.setText(fn) - else: - self.combo.setCurrentIndex(-1) - self.combo.setEditText(fn) - - self.blockSignals(False) - if self.filename() != prevFn: - self.filenameChanged.emit() - if self.layer() != prevLayer: - self.layerChanged.emit() - - def setLayer(self, layer=None): - if not (self.getType() & self.LAYER): - return self.setFilename(layer) - - self.blockSignals(True) - prevFn, prevLayer = self.filename(), self.layer() - - if isinstance(layer, QgsMapLayer): - if self.combo.findData(layer.id()) >= 0: - index = self.combo.findData(layer.id()) - self.combo.setCurrentIndex(index) - else: - self.combo.setCurrentIndex(-1) - self.combo.setEditText(layer.source()) - - elif isinstance(layer, int) and layer >= 0 and layer < self.combo.count(): - self.combo.setCurrentIndex(layer) - - else: - self.combo.clearEditText() - self.combo.setCurrentIndex(-1) - - self.blockSignals(False) - if self.filename() != prevFn: - self.filenameChanged.emit() - if self.layer() != prevLayer: - self.layerChanged.emit() - - def setLayers(self, layers=None): - if layers is None or not hasattr(layers, '__iter__') or len(layers) <= 0: - self.combo.clear() - return - - self.blockSignals(True) - prevFn, prevLayer = self.filename(), self.layer() - self.saveComboState() - - self.combo.clear() - for l in layers: - self.combo.addItem(l.name(), l.id()) - - self.restoreComboState() - self.blockSignals(False) - if self.filename() != prevFn: - self.filenameChanged.emit() - if self.layer() != prevLayer: - self.layerChanged.emit() - - def clearComboState(self): - self.prevState = None - - def saveComboState(self): - index = self.combo.currentIndex() - text = self.combo.currentText() - layerID = self.combo.itemData(index) if index >= 0 else "" - self.prevState = (index, text, layerID) - - def restoreComboState(self): - if self.prevState is None: - return - index, text, layerID = self.prevState - - if index < 0: - if text == '' and self.combo.count() > 0: - index = 0 - - elif self.combo.findData(layerID) < 0: - index = -1 - text = "" - - else: - index = self.combo.findData(layerID) - - self.combo.setCurrentIndex(index) - if index >= 0: - text = self.combo.itemText(index) - self.combo.setEditText(text) - - def layer(self): - if self.getType() != self.FILE and self.combo.currentIndex() >= 0: - layerID = self.combo.itemData(self.combo.currentIndex()) - return QgsProject.instance().mapLayer(layerID) - return None - - def filename(self): - if not (self.getType() & self.LAYER): - if self.getType() & self.MULTIFILE: - return self.filenames - return self.fileEdit.text() - - if self.combo.currentIndex() < 0: - if self.getType() & self.MULTIFILE: - return self.filenames - return self.combo.currentText() - layer = self.layer() - if layer is not None: - return layer.source() - - return '' diff --git a/python/plugins/GdalTools/tools/inOutSelector.ui b/python/plugins/GdalTools/tools/inOutSelector.ui deleted file mode 100644 index 5055ed66d80..00000000000 --- a/python/plugins/GdalTools/tools/inOutSelector.ui +++ /dev/null @@ -1,54 +0,0 @@ - - - GdalToolsInOutSelector - - - - 0 - 0 - 294 - 28 - - - - - 0 - - - - - - 100 - 0 - - - - - - - - - 0 - 0 - - - - true - - - true - - - - - - - Select... - - - - - - - - diff --git a/python/plugins/GdalTools/tools/optionsTable.py b/python/plugins/GdalTools/tools/optionsTable.py deleted file mode 100644 index 43f109675c7..00000000000 --- a/python/plugins/GdalTools/tools/optionsTable.py +++ /dev/null @@ -1,82 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - optionsTable.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import range - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import pyqtSignal -from qgis.PyQt.QtWidgets import QWidget, QTableWidgetItem - -from .ui_optionsTable import Ui_GdalToolsOptionsTable as Ui_OptionsTable - - -class GdalToolsOptionsTable(QWidget, Ui_OptionsTable): - rowAdded = pyqtSignal(int) - rowRemoved = pyqtSignal() - - def __init__(self, parent=None): - QWidget.__init__(self, parent) - - self.setupUi(self) - - self.table.cellChanged.connect(self.cellValueChanged) - - self.table.itemSelectionChanged.connect(self.enableDeleteButton) - self.btnAdd.clicked.connect(self.addNewRow) - self.btnDel.clicked.connect(self.deleteRow) - - self.btnDel.setEnabled(False) - - def enableDeleteButton(self): - self.btnDel.setEnabled(self.table.currentRow() >= 0) - - def addNewRow(self): - self.table.insertRow(self.table.rowCount()) - # select the added row - newRow = self.table.rowCount() - 1 - item = QTableWidgetItem() - self.table.setItem(newRow, 0, item) - self.table.setCurrentItem(item) - self.rowAdded.emit(newRow) - - def deleteRow(self): - if self.table.currentRow() >= 0: - self.table.removeRow(self.table.currentRow()) - # select the previous row or the next one if there is no previous row - item = self.table.item(self.table.currentRow(), 0) - self.table.setCurrentItem(item) - self.rowRemoved.emit() - - def options(self): - options = [] - for row in range(0, self.table.rowCount()): - name = self.table.item(row, 0) - if not name: - continue - - value = self.table.item(row, 1) - if not value: - continue - - options.append(name.text() + "=" + value.text()) - return options diff --git a/python/plugins/GdalTools/tools/optionsTable.ui b/python/plugins/GdalTools/tools/optionsTable.ui deleted file mode 100644 index 37d88175c00..00000000000 --- a/python/plugins/GdalTools/tools/optionsTable.ui +++ /dev/null @@ -1,99 +0,0 @@ - - - GdalToolsOptionsTable - - - - 0 - 0 - 297 - 90 - - - - - 0 - - - - - - 0 - 0 - - - - - 0 - - - - - - 204 - 0 - - - - 30 - - - true - - - true - - - 30 - - - - Name - - - - - Value - - - - - - - - - - Add - - - - - - - Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - diff --git a/python/plugins/GdalTools/tools/terrain.txt b/python/plugins/GdalTools/tools/terrain.txt deleted file mode 100644 index 42ebdf498a6..00000000000 --- a/python/plugins/GdalTools/tools/terrain.txt +++ /dev/null @@ -1,18 +0,0 @@ --11000 0 0 0 --500 0 0 30 --100 0 0 200 --1 150 150 255 -0 0 120 0 -100 0 150 0 -270 90 165 90 -300 90 175 90 -500 50 180 50 -500 70 170 70 -1000 70 145 75 -1000 70 155 75 -2000 150 156 100 -2800 220 220 220 -3000 255 255 255 -8850 255 255 255 -nv white - diff --git a/python/plugins/GdalTools/tools/widgetBatchBase.py b/python/plugins/GdalTools/tools/widgetBatchBase.py deleted file mode 100644 index 938357aef39..00000000000 --- a/python/plugins/GdalTools/tools/widgetBatchBase.py +++ /dev/null @@ -1,163 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - widgetBatchBase.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import bytes - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import Qt, QFile, QFileInfo -from qgis.PyQt.QtWidgets import QMessageBox, QErrorMessage - -from .widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget -from . import GdalTools_utils as Utils - - -class GdalToolsBaseBatchWidget(BasePluginWidget): - - def __init__(self, iface, commandName): - BasePluginWidget.__init__(self, iface, commandName) - - def getBatchArguments(self, inFile, outFile=None): - arguments = [] - arguments.extend(self.getArguments()) - arguments.append(inFile) - if outFile is not None: - arguments.append(outFile) - return arguments - - def isBatchEnabled(self): - return False - - def isRecursiveScanEnabled(self): - return False - - def setProgressRange(self, maximum): - pass - - def updateProgress(self, value, maximum): - pass - - def getBatchOutputFileName(self, fn): - inDir = self.getInputFileName() - outDir = self.getOutputFileName() - - # if overwrites existent files - if outDir is None or outDir == inDir: - return fn + ".tmp" - - return outDir + fn[len(inDir):] - - def onRun(self): - if not self.isBatchEnabled(): - BasePluginWidget.onRun(self) - return - - self.batchRun() - - def batchRun(self): - self.inFiles = Utils.getRasterFiles(self.getInputFileName(), self.isRecursiveScanEnabled()) - if len(self.inFiles) == 0: - QMessageBox.warning(self, self.tr("Warning"), self.tr("No input files to process.")) - return - - self.outFiles = [] - for f in self.inFiles: - self.outFiles.append(self.getBatchOutputFileName(f)) - - self.base.enableRun(False) - self.base.setCursor(Qt.WaitCursor) - - self.errors = [] - self.batchIndex = 0 - self.batchTotal = len(self.inFiles) - self.setProgressRange(self.batchTotal) - - self.runItem(self.batchIndex, self.batchTotal) - - def runItem(self, index, total): - self.updateProgress(index, total) - - if index >= total: - self.batchFinished() - return - - outFile = None - if len(self.outFiles) > index: - outFile = self.outFiles[index] - - args = self.getBatchArguments(self.inFiles[index], outFile) - self.base.refreshArgs(args) - BasePluginWidget.onRun(self) - - def onFinished(self, exitCode, status): - if not self.isBatchEnabled(): - BasePluginWidget.onFinished(self, exitCode, status) - return - - msg = bytes.decode(bytes(self.base.process.readAllStandardError())) - if msg != '': - self.errors.append(">> " + self.inFiles[self.batchIndex] + "
    " + msg.replace("\n", "
    ")) - - self.base.process.close() - - # overwrite existent files - inDir = self.getInputFileName() - outDir = self.getOutputFileName() - if outDir is None or inDir == outDir: - oldFile = QFile(self.inFiles[self.batchIndex]) - newFile = QFile(self.outFiles[self.batchIndex]) - if oldFile.remove(): - newFile.rename(self.inFiles[self.batchIndex]) - - self.batchIndex += 1 - self.runItem(self.batchIndex, self.batchTotal) - - def batchFinished(self): - self.base.stop() - - if len(self.errors) > 0: - msg = u"Processing of the following files ended with error:

    " + "

    ".join(self.errors) - QErrorMessage(self).showMessage(msg) - - inDir = self.getInputFileName() - outDir = self.getOutputFileName() - if outDir is None or inDir == outDir: - self.outFiles = self.inFiles - - # load layers managing the render flag to avoid waste of time - canvas = self.iface.mapCanvas() - previousRenderFlag = canvas.renderFlag() - canvas.setRenderFlag(False) - notCreatedList = [] - for item in self.outFiles: - fileInfo = QFileInfo(item) - if fileInfo.exists(): - if self.base.loadCheckBox.isChecked(): - self.addLayerIntoCanvas(fileInfo) - else: - notCreatedList.append(item) - canvas.setRenderFlag(previousRenderFlag) - - if len(notCreatedList) == 0: - QMessageBox.information(self, self.tr("Finished"), self.tr("Operation completed.")) - else: - QMessageBox.warning(self, self.tr("Warning"), self.tr("The following files were not created: \n{0}").format(', '.join(notCreatedList))) diff --git a/python/plugins/GdalTools/tools/widgetBuildVRT.ui b/python/plugins/GdalTools/tools/widgetBuildVRT.ui deleted file mode 100644 index b78df2a4401..00000000000 --- a/python/plugins/GdalTools/tools/widgetBuildVRT.ui +++ /dev/null @@ -1,173 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 348 - 304 - - - - - 0 - 0 - - - - Build Virtual Raster (Catalog) - - - - - - QLayout::SetNoConstraint - - - - - Allow projection difference - - - - - - - &Output file - - - outSelector - - - - - - - - - - &Input files - - - inSelector - - - - - - - Se&parate - - - - - - - Choose input directory instead of files - - - - - - - - - - Target SRS - - - - - - - Use visible raster layers for input - - - - - - - &Resolution - - - - - - - - 0 - 0 - - - - 1 - - - - Highest - - - - - Average - - - - - Lowest - - - - - - - - &Source No Data - - - - - - - Recurse subdirectories - - - - - - - - - - - - Select - - - - - - - - - 0 - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetClipper.ui b/python/plugins/GdalTools/tools/widgetClipper.ui deleted file mode 100644 index 5d4b8e95664..00000000000 --- a/python/plugins/GdalTools/tools/widgetClipper.ui +++ /dev/null @@ -1,356 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 531 - 330 - - - - - 0 - 0 - - - - Clipper - - - - 9 - - - - - - - &Input file (raster) - - - inSelector - - - - - - - &Output file - - - outSelector - - - - - - - - - - - - - -100000 - - - 65000 - - - - - - - &No data value - - - - - - - - - Clipping mode - - - - 0 - - - - - 1 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Create an output alpha band - - - - - - - - - - - 0 - 0 - - - - Mask layer - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::LeftToRight - - - X Resolution - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 1 - - - 0.100000000000000 - - - 999999.000000000000000 - - - 0.100000000000000 - - - 12.500000000000000 - - - - - - - Y Resolution - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 1 - - - 0.100000000000000 - - - 999999.000000000000000 - - - 0.100000000000000 - - - 12.500000000000000 - - - - - - - - - - Set output file resolution - - - - - - - Keep resolution of input raster - - - true - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Crop the extent of the target dataset to the extent of the cutline - - - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Extent - - - true - - - - - - - Qt::LeftToRight - - - Mask layer - - - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    - - GdalToolsExtentSelector - QWidget -
    .extentSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetContour.ui b/python/plugins/GdalTools/tools/widgetContour.ui deleted file mode 100644 index 9ea66279f5f..00000000000 --- a/python/plugins/GdalTools/tools/widgetContour.ui +++ /dev/null @@ -1,144 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 520 - 163 - - - - - 0 - 0 - - - - Contour - - - - - - - - &Input file (raster) - - - inSelector - - - - - - - &Output file for contour lines (vector) - - - outSelector - - - - - - - I&nterval between contour lines - - - intervalDSpinBox - - - - - - - - 0 - 0 - - - - 3 - - - 2140000000.000000000000000 - - - - - - - - - &Attribute name - - - - - - - - 8 - - - - If not provided, no elevation attribute is attached. - - - 16 - - - - - - - - - - - ELEV - - - - - - - Qt::Vertical - - - QSizePolicy::Minimum - - - - 20 - 0 - - - - - - - - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetConvert.ui b/python/plugins/GdalTools/tools/widgetConvert.ui deleted file mode 100644 index 4a68ed7d18d..00000000000 --- a/python/plugins/GdalTools/tools/widgetConvert.ui +++ /dev/null @@ -1,109 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 356 - 191 - - - - - 0 - 0 - - - - Convert RGB image to paletted - - - - - - Batch mode (for processing whole directory) - - - - - - - - - &Input file - - - inSelector - - - - - - - &Output file - - - outSelector - - - - - - - Number of colors - - - - - - - 2 - - - 256 - - - - - - - 1 - - - 256 - - - - - - - Band to convert - - - - - - - - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetDEM.ui b/python/plugins/GdalTools/tools/widgetDEM.ui deleted file mode 100644 index 9b90cd25295..00000000000 --- a/python/plugins/GdalTools/tools/widgetDEM.ui +++ /dev/null @@ -1,478 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 478 - 404 - - - - - 0 - 0 - - - - DEM (Terrain models) - - - - 5 - - - - - - - &Input file (DEM raster) - - - inSelector - - - - - - - &Output file - - - outSelector - - - - - - - &Band - - - - - - - 1 - - - - - - - Compute &edges - - - - - - - Use Zevenbergen&&Thorne formula (instead of the Horn's one) - - - - - - - - - - - - - &Mode - - - modeCombo - - - - - - - - 0 - 0 - - - - 0 - - - - Hillshade - - - - - Slope - - - - - Aspect - - - - - Color relief - - - - - TRI (Terrain Ruggedness Index) - - - - - TPI (Topographic Position Index) - - - - - Roughness - - - - - - - - - - Mode Options - - - - 0 - - - 0 - - - - - 0 - - - - - - - Z factor (vertical exaggeration) - - - - - - - - 0 - 0 - - - - 2 - - - 100000000.0 - - - - - - - Scale (ratio of vert. units to horiz.) - - - - - - - - 0 - 0 - - - - 2 - - - 999999.000000000000000 - - - - - - - Azimuth of the light - - - - - - - - 0 - 0 - - - - 1 - - - 359.000000000000000 - - - - - - - Altitude of the light - - - - - - - - 0 - 0 - - - - 1 - - - 359.000000000000000 - - - - - - - - - - - Slope expressed as percent (instead of as degrees) - - - - - - - Scale (ratio of vert. units to horiz.) - - - - - - - - 0 - 0 - - - - 2 - - - 999999.000000000000000 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Return trigonometric angle (instead of azimuth) - - - - - - - Return 0 for flat (instead of -9999) - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Color configuration file - - - - - - - Matching mode - - - true - - - false - - - - - - Exact color (otherwise "0,0,0,0" RGBA) - - - true - - - true - - - - - - - Nearest color - - - - - - - - - - Add alpha channel - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - modeCombo - stackedWidget - - - - falsetrue - - true - - - &Creation Options - - - true - - - false - - - - 9 - - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    - - QgsCollapsibleGroupBox - QGroupBox -
    qgis.gui
    - 1 -
    - - QgsRasterFormatSaveOptionsWidget - QWidget -
    qgis.gui
    - 1 -
    -
    - - - - modeCombo - currentIndexChanged(int) - stackedWidget - setCurrentIndex(int) - - - 282 - 201 - - - 208 - 310 - - - - -
    diff --git a/python/plugins/GdalTools/tools/widgetFillNodata.ui b/python/plugins/GdalTools/tools/widgetFillNodata.ui deleted file mode 100644 index c63602a0f8e..00000000000 --- a/python/plugins/GdalTools/tools/widgetFillNodata.ui +++ /dev/null @@ -1,159 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 368 - 300 - - - - - 0 - 0 - - - - Fill Nodata - - - - - - Batch mode (for processing whole directory) - - - - - - - &Input Layer - - - inSelector - - - - - - - - - - &Output file - - - outSelector - - - - - - - - - - QFrame::NoFrame - - - Output format - - - - - - - - 0 - 0 - - - - - - - - Search distance - - - - - - - 1 - - - 1000000 - - - 100 - - - - - - - Smooth iterations - - - - - - - 0 - - - 0 - - - - - - - Band to operate on - - - - - - - 1 - - - - - - - Validity mask - - - - - - - - - - Do not use the default validity mask - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetGrid.ui b/python/plugins/GdalTools/tools/widgetGrid.ui deleted file mode 100644 index 5c2720ea375..00000000000 --- a/python/plugins/GdalTools/tools/widgetGrid.ui +++ /dev/null @@ -1,854 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 777 - 348 - - - - - 0 - 0 - - - - Grid (Interpolation) - - - - - - - - &Input file - - - inSelector - - - - - - - &Z Field - - - - - - - - - - &Output file - - - outSelector - - - - - - - &Algorithm - - - - - - - - Inverse distance to a power - - - - - Moving average - - - - - Nearest neighbor - - - - - Data metrics - - - - - - - - - - - - - - - - QFrame::NoFrame - - - 0 - - - - - - - Power - - - - - - - - 0 - 0 - - - - 1 - - - - - - - Smoothing - - - 30 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Radius1 - - - 30 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Radius2 - - - 30 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Max points - - - - - - - - 0 - 0 - - - - 65000 - - - - - - - Min points - - - 30 - - - - - - - - 0 - 0 - - - - 65000 - - - - - - - Angle - - - 30 - - - - - - - - 0 - 0 - - - - 1 - - - 359.000000000000000 - - - - - - - No data - - - 30 - - - - - - - - 0 - 0 - - - - 1 - - - -100000.000000000000000 - - - 65000.000000000000000 - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - - - - Radius1 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Radius2 - - - 40 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Angle - - - 40 - - - - - - - - 0 - 0 - - - - 1 - - - 359.000000000000000 - - - - - - - Min points - - - - - - - - 0 - 0 - - - - 65000 - - - - - - - No data - - - 40 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - - - - Radius1 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Radius2 - - - 40 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Angle - - - 40 - - - - - - - - 0 - 0 - - - - 1 - - - 359.000000000000000 - - - - - - - No data - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - - - - Metrics - - - - - - - - 0 - 0 - - - - - Minimum - - - - - Maximum - - - - - Range - - - - - - - - Radius1 - - - 40 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Radius2 - - - 40 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Angle - - - - - - - - 0 - 0 - - - - 1 - - - 359.000000000000000 - - - - - - - No data - - - 40 - - - - - - - - 0 - 0 - - - - 1 - - - 65000.000000000000000 - - - - - - - Min points - - - 40 - - - - - - - - 0 - 0 - - - - 65000 - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - - - - Resize - - - true - - - false - - - - - - - 0 - 0 - - - - Width - - - - - - - 999999 - - - - - - - - 0 - 0 - - - - Height - - - 40 - - - - - - - 999999 - - - - - - - - - - Extent - - - true - - - false - - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    - - GdalToolsExtentSelector - QWidget -
    .extentSelector
    - 1 -
    -
    - - - - algorithmCombo - currentIndexChanged(int) - stackedWidget - setCurrentIndex(int) - - - 159 - 129 - - - 159 - 290 - - - - -
    diff --git a/python/plugins/GdalTools/tools/widgetInfo.ui b/python/plugins/GdalTools/tools/widgetInfo.ui deleted file mode 100644 index d2012ac401e..00000000000 --- a/python/plugins/GdalTools/tools/widgetInfo.ui +++ /dev/null @@ -1,86 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 426 - 292 - - - - - 0 - 0 - - - - Info - - - - - - - - &Input file - - - inSelector - - - - - - - - - - - - Raster info - - - - - - - QAbstractItemView::NoEditTriggers - - - true - - - QAbstractItemView::ExtendedSelection - - - - - - - Suppress GCP printing - - - - - - - Suppress metadata printing - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetMerge.ui b/python/plugins/GdalTools/tools/widgetMerge.ui deleted file mode 100644 index 4ba15550a40..00000000000 --- a/python/plugins/GdalTools/tools/widgetMerge.ui +++ /dev/null @@ -1,159 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 371 - 284 - - - - - 0 - 0 - - - - Merge - - - - - - - - &Input files - - - inSelector - - - - - - - &Output file - - - outSelector - - - - - - - &No data value - - - - - - - -100000 - - - 65000 - - - - - - - - - - - - - Choose input directory instead of files - - - - - - - Recurse subdirectories - - - - - - - - - Place each input file into a separate band - - - - - - - false - - - Use intersected extent - - - - - - - Grab pseudocolor table from the first image - - - - - - - &Creation Options - - - true - - - false - - - false - - - true - - - - 9 - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    - - QgsRasterFormatSaveOptionsWidget - QWidget -
    qgis.gui
    - 1 -
    - - QgsCollapsibleGroupBox - QGroupBox -
    qgis.gui
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetNearBlack.ui b/python/plugins/GdalTools/tools/widgetNearBlack.ui deleted file mode 100644 index 9ce19fe48c2..00000000000 --- a/python/plugins/GdalTools/tools/widgetNearBlack.ui +++ /dev/null @@ -1,86 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 443 - 125 - - - - - 0 - 0 - - - - Near Black - - - - - - - - &Input file - - - inSelector - - - - - - - &Output file - - - outSelector - - - - - - - How &far from black (or white) - - - - - - - 255 - - - - - - - - - - - - - - - Search for nearly &white (255) pixels instead of black ones - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetOverview.ui b/python/plugins/GdalTools/tools/widgetOverview.ui deleted file mode 100644 index 5686648f826..00000000000 --- a/python/plugins/GdalTools/tools/widgetOverview.ui +++ /dev/null @@ -1,91 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 376 - 342 - - - - - 0 - 0 - - - - Build overviews (Pyramids) - - - - - - true - - - Batch mode (for processing whole directory) - - - - - - - - - &Input file - - - inSelector - - - - - - - - - - - - Remove all overviews. - - - Clean - - - - - - - - 0 - 1 - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    - - QgsRasterPyramidsOptionsWidget - QWidget -
    qgis.gui
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetPluginBase.py b/python/plugins/GdalTools/tools/widgetPluginBase.py deleted file mode 100644 index 77505e54335..00000000000 --- a/python/plugins/GdalTools/tools/widgetPluginBase.py +++ /dev/null @@ -1,210 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - widgetPluginBase.py - --------------------- - Date : June 2010 - Copyright : (C) 2010 by Giuseppe Sucameli - Email : brush dot tyler at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" -from builtins import object - -__author__ = 'Giuseppe Sucameli' -__date__ = 'June 2010' -__copyright__ = '(C) 2010, Giuseppe Sucameli' -# This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' - -from qgis.PyQt.QtCore import QFileInfo -from qgis.PyQt.QtWidgets import QWidget, QMessageBox, QAbstractButton, QGroupBox - -from .dialogBase import GdalToolsBaseDialog as BaseDialog -from . import GdalTools_utils as Utils - - -class GdalToolsBasePluginWidget(object): - - def __init__(self, iface, commandName): - self.iface = iface - self.initialized = False - self.base = BaseDialog(iface.mainWindow(), iface, self, self.windowTitle(), commandName) - - self.base.processError.connect(self.onError) - self.base.processFinished.connect(self.onFinished) - - self.base.okClicked.connect(self.onRun) - self.base.closeClicked.connect(self.onClosing) - self.base.helpClicked.connect(self.onHelp) - - self.base.finished.connect(self.finished) - self.base.refreshArgs.connect(self.someValueChanged) - - def someValueChanged(self): - if self.initialized: - self.base.valuesChanged.emit(self.getArguments()) - - def onLayersChanged(self): - pass - - def initialize(self): - if not self.initialized: - Utils.LayerRegistry.instance().layersChanged.connect(self.onLayersChanged) - self.onLayersChanged() - self.initialized = True - self.someValueChanged() - - def exec_(self): - self.initialize() - return self.base.exec_() - - def show_(self): - self.initialize() - return self.base.show() - - def setCommandViewerEnabled(self, enable): - self.base.setCommandViewerEnabled(enable) - self.someValueChanged() - - def onRun(self): - self.base.onRun() - - def onClosing(self): - Utils.LayerRegistry.instance().layersChanged.disconnect(self.onLayersChanged) - self.base.onClosing() - self.initialized = False - - def onHelp(self): - self.base.onHelp() - - def onFinished(self, exitCode, status): - self.base.onFinished(exitCode, status) - - def onError(self, error): - self.base.onError(error) - - def getArguments(self): - pass - - def getInputFileName(self): - pass - - def getOutputFileName(self): - pass - - def addLayerIntoCanvas(self, fileInfo): - pass - - def finished(self, load): - outFn = self.getOutputFileName() - if outFn is None: - return - - if outFn == '': - QMessageBox.warning(self, self.tr("Warning"), self.tr("No output file created.")) - return - - fileInfo = QFileInfo(outFn) - if fileInfo.exists(): - if load: - self.addLayerIntoCanvas(fileInfo) - QMessageBox.information(self, self.tr("Finished"), self.tr("Processing completed.")) - else: - #QMessageBox.warning(self, self.tr( "Warning" ), self.tr( "%1 not created." ).arg( outFn ) ) - QMessageBox.warning(self, self.tr("Warning"), self.tr("%s not created.") % outFn) - - # This method is useful to set up options for the command. It sets for each passed widget: - # 1. its passed signals to connect to the BasePluginWidget.someValueChanged() slot, - # 2. its enabler checkbox or enabled status, - # 3. its status as visible (hide) if the installed gdal version is greater or equal (lesser) then the passed version - # - # wdgts_sgnls_chk_ver_list: list of wdgts_sgnls_chk_ver - # wdgts_sgnls_chk_ver: tuple containing widgets, signals, enabler checkbox or enabled status, required version - def setParamsStatus(self, wdgts_sgnls_chk_ver_list): - if isinstance(wdgts_sgnls_chk_ver_list, list): - for wdgts_sgnls_chk_ver in wdgts_sgnls_chk_ver_list: - self.setParamsStatus(wdgts_sgnls_chk_ver) - return - - wdgts_sgnls_chk_ver = wdgts_sgnls_chk_ver_list - if not isinstance(wdgts_sgnls_chk_ver, tuple): - return - - if len(wdgts_sgnls_chk_ver) > 0: - wdgts = wdgts_sgnls_chk_ver[0] - else: - wdgts = None - - if len(wdgts_sgnls_chk_ver) > 1: - sgnls = wdgts_sgnls_chk_ver[1] - else: - sgnls = None - - if len(wdgts_sgnls_chk_ver) > 2: - chk = wdgts_sgnls_chk_ver[2] - else: - chk = None - - if len(wdgts_sgnls_chk_ver) > 3: - ver = wdgts_sgnls_chk_ver[3] - else: - ver = None - - if isinstance(wdgts, list): - for wdgt in wdgts: - self.setParamsStatus((wdgt, sgnls, chk, ver)) - return - - wdgt = wdgts - if not isinstance(wdgt, QWidget): - return - - # if check version fails, disable the widget then hide both it and its enabler checkbox - # new check for gdal 1.10, must update all widgets for this and then remove previous check - if ver is not None and isinstance(ver, int): - gdalVerNum = Utils.GdalConfig.versionNum() - if ver > gdalVerNum: - wdgt.setVisible(False) - if isinstance(chk, QWidget): - chk.setVisible(False) - chk.setChecked(False) - sgnls = None - chk = False - - elif ver is not None: - if not isinstance(ver, Utils.Version): - ver = Utils.Version(ver) - gdalVer = Utils.GdalConfig.version() - if ver < Utils.Version("0") or (gdalVer is not None and ver > gdalVer): - wdgt.setVisible(False) - if isinstance(chk, QWidget): - chk.setVisible(False) - chk.setChecked(False) - sgnls = None - chk = False - - # connects the passed signals to the BasePluginWidget.someValueChanged slot - if isinstance(sgnls, list): - for sgnl in sgnls: - self.setParamsStatus((wdgt, sgnl, chk)) - return - - sgnl = sgnls - if sgnl is not None: - getattr(wdgt, sgnl).connect(self.someValueChanged) - - # set the passed checkbox as widget enabler - if isinstance(chk, bool): - wdgt.setEnabled(chk) - if (isinstance(chk, QAbstractButton) or isinstance(chk, QGroupBox)) and chk.isCheckable(): - wdgt.setEnabled(chk.isChecked()) - chk.toggled.connect(wdgt.setEnabled) - chk.toggled.connect(self.someValueChanged) diff --git a/python/plugins/GdalTools/tools/widgetPolygonize.ui b/python/plugins/GdalTools/tools/widgetPolygonize.ui deleted file mode 100644 index bd7d1ce6ca6..00000000000 --- a/python/plugins/GdalTools/tools/widgetPolygonize.ui +++ /dev/null @@ -1,85 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 446 - 121 - - - - - 0 - 0 - - - - Polygonize (Raster to vector) - - - - - - &Input file (raster) - - - inSelector - - - - - - - - - - &Output file for polygons (shapefile) - - - outSelector - - - - - - - - - - &Field name - - - - - - - DN - - - - - - - Use mask - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetProjection.ui b/python/plugins/GdalTools/tools/widgetProjection.ui deleted file mode 100644 index 17afd435f05..00000000000 --- a/python/plugins/GdalTools/tools/widgetProjection.ui +++ /dev/null @@ -1,109 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 369 - 244 - - - - - 0 - 0 - - - - Assign projection - - - - - - Batch mode (for processing whole directory) - - - - - - - WARNING: current projection definition will be cleared - - - - - - - - - &Input file - - - inSelector - - - - - - - Recurse subdirectories - - - - - - - Desired SRS - - - - - - - Output will be: -- new GeoTiff if input file is not GeoTiff -- overwritten if input is GeoTiff - - - Qt::AutoText - - - - - - - - - - - - - - - Select... - - - - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetProximity.ui b/python/plugins/GdalTools/tools/widgetProximity.ui deleted file mode 100644 index 927d6c2d7ed..00000000000 --- a/python/plugins/GdalTools/tools/widgetProximity.ui +++ /dev/null @@ -1,148 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 327 - 229 - - - - - 0 - 0 - - - - Proximity (Raster distance) - - - - - - - - &Input file - - - inSelector - - - - - - - &Output file - - - outSelector - - - - - - - &Values - - - - - - - &Dist units - - - true - - - - - - - - GEO - - - - - PIXEL - - - - - - - - &Max dist - - - - - - - 65000 - - - - - - - &No data - - - - - - - -100000 - - - 65000 - - - - - - - &Fixed buf val - - - - - - - 65000 - - - - - - - 0 - - - - - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetRasterize.ui b/python/plugins/GdalTools/tools/widgetRasterize.ui deleted file mode 100644 index f98e30751b2..00000000000 --- a/python/plugins/GdalTools/tools/widgetRasterize.ui +++ /dev/null @@ -1,285 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 509 - 261 - - - - - 0 - 0 - - - - Rasterize (Vector to raster) - - - - - - - - &Input file (shapefile) - - - inSelector - - - - - - - &Attribute field - - - attributeComboBox - - - - - - - - 0 - 0 - - - - - - - - &Output file for rasterized vectors (raster) - - - outSelector - - - - - - - - - - - - - - - Keep existing raster size and resolution - - - true - - - - - - - Raster size in pixels - - - false - - - - - - - false - - - - 30 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Width - - - - - - - 999999 - - - - - - - - 0 - 0 - - - - Height - - - 40 - - - - - - - 999999 - - - - - - - - - - Raster resolution in map units per pixel - - - - - - - false - - - - 30 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Horizontal - - - - - - - 8 - - - 999999999.990000009536743 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Vertical - - - 40 - - - - - - - Qt::ImhNone - - - 8 - - - 999999999.990000009536743 - - - 1.000000000000000 - - - 2.000000000000000 - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - - - radioSetSize - toggled(bool) - widgetSize - setEnabled(bool) - - - 254 - 128 - - - 254 - 163 - - - - - radioSetResolution - toggled(bool) - widgetResolution - setEnabled(bool) - - - 254 - 198 - - - 254 - 233 - - - - -
    diff --git a/python/plugins/GdalTools/tools/widgetSieve.ui b/python/plugins/GdalTools/tools/widgetSieve.ui deleted file mode 100644 index 2867a0e180d..00000000000 --- a/python/plugins/GdalTools/tools/widgetSieve.ui +++ /dev/null @@ -1,100 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 365 - 129 - - - - - 0 - 0 - - - - Sieve - - - - - - - - &Input file - - - inSelector - - - - - - - &Output file - - - outSelector - - - - - - - &Threshold - - - - - - - 65000 - - - - - - - &Pixel connections - - - - - - - - 4 - - - - - 8 - - - - - - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetTileIndex.ui b/python/plugins/GdalTools/tools/widgetTileIndex.ui deleted file mode 100644 index 777e74248d0..00000000000 --- a/python/plugins/GdalTools/tools/widgetTileIndex.ui +++ /dev/null @@ -1,90 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 400 - 153 - - - - Raster tile index - - - - - - - - Input directory - - - inSelector - - - - - - - Recurse subdirectories - - - - - - - Output shapefile - - - outSelector - - - - - - - Tile index field - - - - - - - true - - - location - - - - - - - - - - - - - - - Skip files with different projection ref - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetTranslate.ui b/python/plugins/GdalTools/tools/widgetTranslate.ui deleted file mode 100644 index ad679d425c3..00000000000 --- a/python/plugins/GdalTools/tools/widgetTranslate.ui +++ /dev/null @@ -1,303 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 335 - 429 - - - - - 0 - 0 - - - - Translate (Convert format) - - - - - - Batch mode (for processing whole directory) - - - - - - - - - &Input Layer - - - inSelector - - - - - - - &Output file - - - outSelector - - - - - - - Output format - - - - - - - - 0 - 0 - - - - - - - - &Target SRS - - - - - - - - - - 100 - 0 - - - - - - - - Select... - - - - - - - - - - 100 - 16777215 - - - - Percentage to resize image. This will change pixel size/image resolution accordingly: 25% will create an image with pixels 4x larger. - - - Outsize - - - - - - - - 0 - 0 - - - - Percentage to resize image. This will change pixel size/image resolution accordingly: 25% will create an image with pixels 4x larger. - - - % - - - 1 - - - 1000 - - - - - - - Assign a specified nodata value to output bands. - - - No data - - - - - - - To expose a dataset with 1 band with a color table as a dataset with 3 (RGB) or 4 (RGBA) bands. -Useful for output drivers such as JPEG, JPEG2000, MrSID, ECW that don't support color indexed datasets. -The 'gray' value (from GDAL 1.7.0) enables to expand a dataset with a color table that only contains gray levels to a gray indexed dataset. - - - Expand - - - - - - - To expose a dataset with 1 band with a color table as a dataset with 3 (RGB) or 4 (RGBA) bands. -Useful for output drivers such as JPEG, JPEG2000, MrSID, ECW that don't support color indexed datasets. -The 'gray' value (from GDAL 1.7.0) enables to expand a dataset with a color table that only contains gray levels to a gray indexed dataset. - - - - Gray - - - - - RGB - - - - - RGBA - - - - - - - - Selects a subwindow from the source image for copying based on pixel/line location. (Enter Xoff Yoff Xsize Ysize) - - - Srcwin - - - - - - - Selects a subwindow from the source image for copying based on pixel/line location. (Enter Xoff Yoff Xsize Ysize) - - - - - - - Selects a subwindow from the source image for copying (like -srcwin) but with the corners given in georeferenced coordinates. (Enter ulx uly lrx lry) - - - Prjwin - - - - - - - Selects a subwindow from the source image for copying (like -srcwin) but with the corners given in georeferenced coordinates. (Enter ulx uly lrx lry) - - - - - - - Copy all subdatasets of this file to individual output files. Use with formats like HDF or OGDI that have subdatasets. - - - Sds - - - - - - - - 0 - 0 - - - - Assign a specified nodata value to output bands. - - - -999999999 - - - 999999999 - - - - - - - - - - - - - falsetrue - - &Creation Options - - - true - - - false - - - - 9 - - - 9 - - - - - - - - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    - - QgsCollapsibleGroupBox - QGroupBox -
    qgis.gui
    - 1 -
    - - QgsRasterFormatSaveOptionsWidget - QWidget -
    qgis.gui
    - 1 -
    -
    - - -
    diff --git a/python/plugins/GdalTools/tools/widgetWarp.ui b/python/plugins/GdalTools/tools/widgetWarp.ui deleted file mode 100644 index 6850da048bf..00000000000 --- a/python/plugins/GdalTools/tools/widgetWarp.ui +++ /dev/null @@ -1,276 +0,0 @@ - - - GdalToolsWidget - - - - 0 - 0 - 415 - 422 - - - - - 0 - 0 - - - - Warp (Reproject) - - - - - - Batch mode (for processing whole directory) - - - - - - - - - &Input file - - - inSelector - - - - - - - &Output file - - - outSelector - - - - - - - &Source SRS - - - - - - - - - - 100 - 0 - - - - - - - - Select... - - - - - - - - - &Target SRS - - - - - - - - - - 100 - 0 - - - - - - - - Select... - - - - - - - - - &Resampling method - - - - - - - - Near - - - - - Bilinear - - - - - Cubic - - - - - Cubic spline - - - - - Lanczos - - - - - - - - No data values - - - - - - - 0 - - - - - - - &Memory used for caching - - - - - - - MB - - - 20 - - - 1024 - - - - - - - Mask layer - - - - - - - - - - - - - - - - - - Resize - - - true - - - false - - - - - - - 0 - 0 - - - - Width - - - - - - - 999999 - - - - - - - - 0 - 0 - - - - Height - - - 40 - - - - - - - 999999 - - - - - - - - - - - - - Use m&ultithreaded warping implementation - - - - - - - - GdalToolsInOutSelector - QWidget -
    .inOutSelector
    - 1 -
    -
    - - -
    diff --git a/python/plugins/db_manager/db_plugins/data_model.py b/python/plugins/db_manager/db_plugins/data_model.py index 6ffc3f52232..de0ddd2208b 100644 --- a/python/plugins/db_manager/db_plugins/data_model.py +++ b/python/plugins/db_manager/db_plugins/data_model.py @@ -89,7 +89,7 @@ class BaseTableModel(QAbstractTableModel): # too much data to display, elide the string val = val[:300] try: - return str(val) # convert to unicode + return str(val) # convert to Unicode except UnicodeDecodeError: return str(val, 'utf-8', 'replace') # convert from utf8 and replace errors (if any) diff --git a/python/plugins/db_manager/db_plugins/plugin.py b/python/plugins/db_manager/db_plugins/plugin.py index f56a8d2fcc2..8da1344c75a 100644 --- a/python/plugins/db_manager/db_plugins/plugin.py +++ b/python/plugins/db_manager/db_plugins/plugin.py @@ -424,7 +424,7 @@ class Database(DbItemObject): QApplication.restoreOverrideCursor() try: if not isinstance(item, Table) or item.isView: - parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Select a table for editation."), + parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Select a table to edit."), QgsMessageBar.INFO, parent.iface.messageTimeout()) return from ..dlg_table_properties import DlgTableProperties diff --git a/python/plugins/db_manager/dlg_sql_layer_window.py b/python/plugins/db_manager/dlg_sql_layer_window.py index dc7bc22ad6a..e23901eafad 100644 --- a/python/plugins/db_manager/dlg_sql_layer_window.py +++ b/python/plugins/db_manager/dlg_sql_layer_window.py @@ -397,7 +397,7 @@ class DlgSqlLayerWindow(QWidget, Ui_Dialog): QApplication.restoreOverrideCursor() def setColumnCombos(self, cols, quotedCols): - # get sensible default columns. do this before sorting in case there's hints in the column order (eg, id is more likely to be first) + # get sensible default columns. do this before sorting in case there's hints in the column order (e.g., id is more likely to be first) try: defaultGeomCol = next(col for col in cols if col in ['geom', 'geometry', 'the_geom', 'way']) except: diff --git a/python/plugins/db_manager/dlg_sql_window.py b/python/plugins/db_manager/dlg_sql_window.py index c876d63e739..22a57d9618f 100644 --- a/python/plugins/db_manager/dlg_sql_window.py +++ b/python/plugins/db_manager/dlg_sql_window.py @@ -333,7 +333,7 @@ class DlgSqlWindow(QWidget, Ui_Dialog): QApplication.restoreOverrideCursor() def setColumnCombos(self, cols, quotedCols): - # get sensible default columns. do this before sorting in case there's hints in the column order (eg, id is more likely to be first) + # get sensible default columns. do this before sorting in case there's hints in the column order (e.g., id is more likely to be first) try: defaultGeomCol = next(col for col in cols if col in ['geom', 'geometry', 'the_geom', 'way']) except: diff --git a/python/plugins/processing/ProcessingPlugin.py b/python/plugins/processing/ProcessingPlugin.py index 459a52b39b6..add03335516 100644 --- a/python/plugins/processing/ProcessingPlugin.py +++ b/python/plugins/processing/ProcessingPlugin.py @@ -31,6 +31,7 @@ import inspect import os import sys +from qgis.core import QgsApplication from qgis.PyQt.QtCore import Qt, QCoreApplication, QDir from qgis.PyQt.QtWidgets import QMenu, QAction from qgis.PyQt.QtGui import QIcon @@ -71,13 +72,13 @@ class ProcessingPlugin(object): self.toolboxAction = self.toolbox.toggleViewAction() self.toolboxAction.setObjectName('toolboxAction') self.toolboxAction.setIcon( - QIcon(os.path.join(cmd_folder, 'images', 'alg.png'))) + QIcon(os.path.join(cmd_folder, 'images', 'alg.svg'))) self.toolboxAction.setText(self.tr('&Toolbox')) self.iface.registerMainWindowAction(self.toolboxAction, 'Ctrl+Alt+T') self.menu.addAction(self.toolboxAction) self.modelerAction = QAction( - QIcon(os.path.join(cmd_folder, 'images', 'model.png')), + QIcon(os.path.join(cmd_folder, 'images', 'model.svg')), self.tr('Graphical &Modeler...'), self.iface.mainWindow()) self.modelerAction.setObjectName('modelerAction') self.modelerAction.triggered.connect(self.openModeler) @@ -85,23 +86,15 @@ class ProcessingPlugin(object): self.menu.addAction(self.modelerAction) self.historyAction = QAction( - QIcon(os.path.join(cmd_folder, 'images', 'history.gif')), + QIcon(os.path.join(cmd_folder, 'images', 'history.svg')), self.tr('&History...'), self.iface.mainWindow()) self.historyAction.setObjectName('historyAction') self.historyAction.triggered.connect(self.openHistory) self.iface.registerMainWindowAction(self.historyAction, 'Ctrl+Alt+H') self.menu.addAction(self.historyAction) - self.configAction = QAction( - QIcon(os.path.join(cmd_folder, 'images', 'config.png')), - self.tr('&Options...'), self.iface.mainWindow()) - self.configAction.setObjectName('configAction') - self.configAction.triggered.connect(self.openConfig) - self.iface.registerMainWindowAction(self.configAction, 'Ctrl+Alt+C') - self.menu.addAction(self.configAction) - self.resultsAction = QAction( - QIcon(os.path.join(cmd_folder, 'images', 'results.png')), + QIcon(os.path.join(cmd_folder, 'images', 'results.svg')), self.tr('&Results Viewer...'), self.iface.mainWindow()) self.resultsAction.setObjectName('resultsAction') self.resultsAction.triggered.connect(self.openResults) @@ -113,7 +106,7 @@ class ProcessingPlugin(object): self.iface.firstRightStandardMenu().menuAction(), self.menu) self.commanderAction = QAction( - QIcon(os.path.join(cmd_folder, 'images', 'commander.png')), + QIcon(os.path.join(cmd_folder, 'images', 'commander.svg')), self.tr('&Commander'), self.iface.mainWindow()) self.commanderAction.setObjectName('commanderAction') self.commanderAction.triggered.connect(self.openCommander) @@ -121,6 +114,18 @@ class ProcessingPlugin(object): self.iface.registerMainWindowAction(self.commanderAction, self.tr('Ctrl+Alt+D')) + self.menu.addSeparator() + + self.configAction = QAction( + QIcon(QgsApplication.getThemeIcon('mActionOptions.svg')), + self.tr('&Options...'), self.iface.mainWindow()) + self.configAction.setObjectName('configAction') + self.configAction.setMenuRole(QAction.NoRole) + + self.configAction.triggered.connect(self.openConfig) + self.iface.registerMainWindowAction(self.configAction, 'Ctrl+Alt+C') + self.menu.addAction(self.configAction) + initializeMenus() createMenus() diff --git a/python/plugins/processing/algs/gdal/CMakeLists.txt b/python/plugins/processing/algs/gdal/CMakeLists.txt index 38228582859..3381dcf771f 100644 --- a/python/plugins/processing/algs/gdal/CMakeLists.txt +++ b/python/plugins/processing/algs/gdal/CMakeLists.txt @@ -1,3 +1,5 @@ FILE(GLOB PY_FILES *.py) +ADD_SUBDIRECTORY(ui) + PLUGIN_INSTALL(processing ./algs/gdal ${PY_FILES}) diff --git a/python/plugins/processing/algs/gdal/ClipByExtent.py b/python/plugins/processing/algs/gdal/ClipByExtent.py index 5f5394a8970..311a49bae45 100644 --- a/python/plugins/processing/algs/gdal/ClipByExtent.py +++ b/python/plugins/processing/algs/gdal/ClipByExtent.py @@ -32,13 +32,11 @@ from qgis.PyQt.QtGui import QIcon from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm -from processing.core.parameters import ParameterRaster -from processing.core.parameters import ParameterExtent -from processing.core.parameters import ParameterString +from processing.core.parameters import (ParameterRaster, + ParameterExtent, + ParameterString, + ParameterSelection) from processing.core.outputs import OutputRaster -from processing.core.parameters import ParameterSelection -from processing.core.parameters import ParameterNumber -from processing.core.parameters import ParameterBoolean from processing.algs.gdal.GdalUtils import GdalUtils @@ -51,18 +49,9 @@ class ClipByExtent(GdalAlgorithm): OUTPUT = 'OUTPUT' NO_DATA = 'NO_DATA' PROJWIN = 'PROJWIN' - EXTRA = 'EXTRA' + OPTIONS = 'OPTIONS' RTYPE = 'RTYPE' TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64'] - TILED = 'TILED' - COMPRESS = 'COMPRESS' - JPEGCOMPRESSION = 'JPEGCOMPRESSION' - PREDICTOR = 'PREDICTOR' - ZLEVEL = 'ZLEVEL' - BIGTIFF = 'BIGTIFF' - BIGTIFFTYPE = ['', 'YES', 'NO', 'IF_NEEDED', 'IF_SAFER'] - COMPRESSTYPE = ['NONE', 'JPEG', 'LZW', 'PACKBITS', 'DEFLATE'] - TFW = 'TFW' def getIcon(self): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-clip.png')) @@ -70,58 +59,31 @@ class ClipByExtent(GdalAlgorithm): def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Clip raster by extent') self.group, self.i18n_group = self.trAlgorithm('[GDAL] Extraction') - self.addParameter(ParameterRaster( - self.INPUT, self.tr('Input layer'), False)) + + self.addParameter(ParameterRaster(self.INPUT, self.tr('Input layer'))) self.addParameter(ParameterString(self.NO_DATA, self.tr("Nodata value, leave blank to take the nodata value from input"), - '', optional=True)) + '', + optional=True)) self.addParameter(ParameterExtent(self.PROJWIN, self.tr('Clipping extent'))) - - params = [] - params.append(ParameterSelection(self.RTYPE, - self.tr('Output raster type'), self.TYPE, 5)) - params.append(ParameterSelection(self.COMPRESS, - self.tr('GeoTIFF options. Compression type:'), self.COMPRESSTYPE, 4)) - params.append(ParameterNumber(self.JPEGCOMPRESSION, - self.tr('Set the JPEG compression level'), - 1, 100, 75)) - params.append(ParameterNumber(self.ZLEVEL, - self.tr('Set the DEFLATE compression level'), - 1, 9, 6)) - params.append(ParameterNumber(self.PREDICTOR, - self.tr('Set the predictor for LZW or DEFLATE compression'), - 1, 3, 1)) - params.append(ParameterBoolean(self.TILED, - self.tr('Create tiled output (only used for the GTiff format)'), False)) - params.append(ParameterSelection(self.BIGTIFF, - self.tr('Control whether the created file is a BigTIFF or a classic TIFF'), self.BIGTIFFTYPE, 0)) - params.append(ParameterBoolean(self.TFW, - self.tr('Force the generation of an associated ESRI world file (.tfw))'), False)) - params.append(ParameterString(self.EXTRA, - self.tr('Additional creation parameters'), '', optional=True)) - - for param in params: - param.isAdvanced = True - self.addParameter(param) + self.addParameter(ParameterString(self.OPTIONS, + self.tr('Additional creation options'), + optional=True, + metadata={'widget_wrapper': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'})) + self.addParameter(ParameterSelection(self.RTYPE, + self.tr('Output raster type'), + self.TYPE, 5)) self.addOutput(OutputRaster(self.OUTPUT, self.tr('Clipped (extent)'))) def getConsoleCommands(self): out = self.getOutputValue(self.OUTPUT) noData = self.getParameterValue(self.NO_DATA) + opts = self.getParameterValue(self.OPTIONS) + projwin = self.getParameterValue(self.PROJWIN) + if noData is not None: noData = str(noData) - projwin = str(self.getParameterValue(self.PROJWIN)) - extra = self.getParameterValue(self.EXTRA) - if extra is not None: - extra = str(extra) - jpegcompression = str(self.getParameterValue(self.JPEGCOMPRESSION)) - predictor = str(self.getParameterValue(self.PREDICTOR)) - zlevel = str(self.getParameterValue(self.ZLEVEL)) - tiled = str(self.getParameterValue(self.TILED)) - compress = self.COMPRESSTYPE[self.getParameterValue(self.COMPRESS)] - bigtiff = self.BIGTIFFTYPE[self.getParameterValue(self.BIGTIFF)] - tfw = str(self.getParameterValue(self.TFW)) arguments = [] arguments.append('-of') @@ -139,22 +101,9 @@ class ClipByExtent(GdalAlgorithm): arguments.append(regionCoords[1]) arguments.append(regionCoords[2]) - if extra and len(extra) > 0: - arguments.append(extra) - if GdalUtils.getFormatShortNameFromFilename(out) == "GTiff": - arguments.append("-co COMPRESS=" + compress) - if compress == 'JPEG': - arguments.append("-co JPEG_QUALITY=" + jpegcompression) - elif (compress == 'LZW') or (compress == 'DEFLATE'): - arguments.append("-co PREDICTOR=" + predictor) - if compress == 'DEFLATE': - arguments.append("-co ZLEVEL=" + zlevel) - if tiled == "True": - arguments.append("-co TILED=YES") - if tfw == "True": - arguments.append("-co TFW=YES") - if len(bigtiff) > 0: - arguments.append("-co BIGTIFF=" + bigtiff) + if opts: + arguments.append('-co') + arguments.append(opts) arguments.append(self.getParameterValue(self.INPUT)) arguments.append(out) diff --git a/python/plugins/processing/algs/gdal/ClipByMask.py b/python/plugins/processing/algs/gdal/ClipByMask.py index 5fc720c4f91..bf411de774e 100644 --- a/python/plugins/processing/algs/gdal/ClipByMask.py +++ b/python/plugins/processing/algs/gdal/ClipByMask.py @@ -32,12 +32,11 @@ from qgis.PyQt.QtGui import QIcon from osgeo import gdal -from processing.core.parameters import ParameterRaster -from processing.core.parameters import ParameterVector -from processing.core.parameters import ParameterBoolean -from processing.core.parameters import ParameterString -from processing.core.parameters import ParameterSelection -from processing.core.parameters import ParameterNumber +from processing.core.parameters import (ParameterRaster, + ParameterVector, + ParameterBoolean, + ParameterString, + ParameterSelection) from processing.core.outputs import OutputRaster @@ -59,18 +58,9 @@ class ClipByMask(GdalAlgorithm): ALPHA_BAND = 'ALPHA_BAND' CROP_TO_CUTLINE = 'CROP_TO_CUTLINE' KEEP_RESOLUTION = 'KEEP_RESOLUTION' - EXTRA = 'EXTRA' + OPTIONS = 'OPTIONS' RTYPE = 'RTYPE' TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64'] - TILED = 'TILED' - COMPRESS = 'COMPRESS' - JPEGCOMPRESSION = 'JPEGCOMPRESSION' - PREDICTOR = 'PREDICTOR' - ZLEVEL = 'ZLEVEL' - BIGTIFF = 'BIGTIFF' - BIGTIFFTYPE = ['', 'YES', 'NO', 'IF_NEEDED', 'IF_SAFER'] - COMPRESSTYPE = ['NONE', 'JPEG', 'LZW', 'PACKBITS', 'DEFLATE'] - TFW = 'TFW' def getIcon(self): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-clip.png')) @@ -78,6 +68,7 @@ class ClipByMask(GdalAlgorithm): def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Clip raster by mask layer') self.group, self.i18n_group = self.trAlgorithm('[GDAL] Extraction') + self.addParameter(ParameterRaster(self.INPUT, self.tr('Input layer'), False)) self.addParameter(ParameterVector(self.MASK, self.tr('Mask layer'), [dataobjects.TYPE_VECTOR_POLYGON])) @@ -85,38 +76,21 @@ class ClipByMask(GdalAlgorithm): self.tr("Nodata value, leave blank to take the nodata value from input"), '', optional=True)) self.addParameter(ParameterBoolean(self.ALPHA_BAND, - self.tr('Create and output alpha band'), False)) + self.tr('Create and output alpha band'), + False)) self.addParameter(ParameterBoolean(self.CROP_TO_CUTLINE, - self.tr('Crop the extent of the target dataset to the extent of the cutline'), True)) + self.tr('Crop the extent of the target dataset to the extent of the cutline'), + True)) self.addParameter(ParameterBoolean(self.KEEP_RESOLUTION, - self.tr('Keep resolution of output raster'), False)) - - params = [] - params.append(ParameterSelection(self.RTYPE, - self.tr('Output raster type'), self.TYPE, 5)) - params.append(ParameterSelection(self.COMPRESS, - self.tr('GeoTIFF options. Compression type:'), self.COMPRESSTYPE, 4)) - params.append(ParameterNumber(self.JPEGCOMPRESSION, - self.tr('Set the JPEG compression level'), - 1, 100, 75)) - params.append(ParameterNumber(self.ZLEVEL, - self.tr('Set the DEFLATE compression level'), - 1, 9, 6)) - params.append(ParameterNumber(self.PREDICTOR, - self.tr('Set the predictor for LZW or DEFLATE compression'), - 1, 3, 1)) - params.append(ParameterBoolean(self.TILED, - self.tr('Create tiled output (only used for the GTiff format)'), False)) - params.append(ParameterSelection(self.BIGTIFF, - self.tr('Control whether the created file is a BigTIFF or a classic TIFF'), self.BIGTIFFTYPE, 0)) - params.append(ParameterBoolean(self.TFW, - self.tr('Force the generation of an associated ESRI world file (.tfw))'), False)) - params.append(ParameterString(self.EXTRA, - self.tr('Additional creation parameters'), '', optional=True)) - - for param in params: - param.isAdvanced = True - self.addParameter(param) + self.tr('Keep resolution of output raster'), + False)) + self.addParameter(ParameterString(self.OPTIONS, + self.tr('Additional creation options'), + optional=True, + metadata={'widget_wrapper': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'})) + self.addParameter(ParameterSelection(self.RTYPE, + self.tr('Output raster type'), + self.TYPE, 5)) self.addOutput(OutputRaster(self.OUTPUT, self.tr('Clipped (mask)'))) @@ -127,21 +101,14 @@ class ClipByMask(GdalAlgorithm): self.getParameterValue(self.MASK)) ogrMask = ogrConnectionString(mask)[1:-1] noData = self.getParameterValue(self.NO_DATA) + opts = self.getParameterValue(self.OPTIONS) + if noData is not None: noData = str(noData) + addAlphaBand = self.getParameterValue(self.ALPHA_BAND) cropToCutline = self.getParameterValue(self.CROP_TO_CUTLINE) keepResolution = self.getParameterValue(self.KEEP_RESOLUTION) - extra = self.getParameterValue(self.EXTRA) - if extra is not None: - extra = str(extra) - jpegcompression = str(self.getParameterValue(self.JPEGCOMPRESSION)) - predictor = str(self.getParameterValue(self.PREDICTOR)) - zlevel = str(self.getParameterValue(self.ZLEVEL)) - tiled = str(self.getParameterValue(self.TILED)) - compress = self.COMPRESSTYPE[self.getParameterValue(self.COMPRESS)] - bigtiff = self.BIGTIFFTYPE[self.getParameterValue(self.BIGTIFF)] - tfw = str(self.getParameterValue(self.TFW)) arguments = [] arguments.append('-ot') @@ -174,24 +141,9 @@ class ClipByMask(GdalAlgorithm): if addAlphaBand: arguments.append('-dstalpha') - if extra and len(extra) > 0: - arguments.append(extra) - if GdalUtils.getFormatShortNameFromFilename(out) == "GTiff": - arguments.append("-co COMPRESS=" + compress) - if compress == 'JPEG': - arguments.append("-co JPEG_QUALITY=" + jpegcompression) - elif (compress == 'LZW') or (compress == 'DEFLATE'): - arguments.append("-co PREDICTOR=" + predictor) - if compress == 'DEFLATE': - arguments.append("-co ZLEVEL=" + zlevel) - if tiled == "True": - arguments.append("-co TILED=YES") - if tfw == "True": - arguments.append("-co TFW=YES") - if len(bigtiff) > 0: - arguments.append("-co BIGTIFF=" + bigtiff) - - arguments.append("-wo OPTIMIZE_SIZE=TRUE") + if opts: + arguments.append('-co') + arguments.append(opts) if GdalUtils.version() in [2010000, 2010100]: arguments.append("--config GDALWARP_IGNORE_BAD_CUTLINE YES") diff --git a/python/plugins/processing/algs/gdal/GdalAlgorithm.py b/python/plugins/processing/algs/gdal/GdalAlgorithm.py index 5df8012983f..2fda9a736ce 100644 --- a/python/plugins/processing/algs/gdal/GdalAlgorithm.py +++ b/python/plugins/processing/algs/gdal/GdalAlgorithm.py @@ -29,11 +29,12 @@ import os import re from qgis.PyQt.QtGui import QIcon +from qgis.PyQt.QtCore import QUrl from processing.core.GeoAlgorithm import GeoAlgorithm from processing.algs.gdal.GdalAlgorithmDialog import GdalAlgorithmDialog from processing.algs.gdal.GdalUtils import GdalUtils -from processing.tools import dataobjects +from processing.tools import dataobjects, system pluginPath = os.path.normpath(os.path.join( os.path.split(os.path.dirname(__file__))[0], os.pardir)) @@ -73,9 +74,18 @@ class GdalAlgorithm(GeoAlgorithm): GdalUtils.runGdal(commands, progress) def shortHelp(self): - return self._formatHelp('''This algorithm is based on the GDAL %s module. - For more info, see the
    module help - ''' % (self.commandName(), self.commandName())) + helpPath = GdalUtils.gdalHelpPath() + if helpPath == '': + return + + if os.path.exists(helpPath): + url = QUrl.fromLocalFile(os.path.join(helpPath, '{}.html'.format(self.commandName()))).toString() + else: + url = helpPath + '{}.html'.format(self.commandName()) + + return self._formatHelp('''This algorithm is based on the GDAL {} module. + For more info, see the module help + '''.format(self.commandName(), url)) def commandName(self): alg = self.getCopy() diff --git a/python/plugins/processing/algs/gdal/GdalOgrAlgorithmProvider.py b/python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py similarity index 88% rename from python/plugins/processing/algs/gdal/GdalOgrAlgorithmProvider.py rename to python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py index 20eb2fc836a..45fa358f1c7 100644 --- a/python/plugins/processing/algs/gdal/GdalOgrAlgorithmProvider.py +++ b/python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py @@ -29,6 +29,7 @@ import os from qgis.PyQt.QtGui import QIcon from processing.core.AlgorithmProvider import AlgorithmProvider +from processing.core.ProcessingConfig import ProcessingConfig, Setting from .GdalUtils import GdalUtils from .nearblack import nearblack @@ -86,7 +87,7 @@ pluginPath = os.path.normpath(os.path.join( os.path.split(os.path.dirname(__file__))[0], os.pardir)) -class GdalOgrAlgorithmProvider(AlgorithmProvider): +class GdalAlgorithmProvider(AlgorithmProvider): """This provider incorporates GDAL-based algorithms into the Processing framework. @@ -99,11 +100,24 @@ class GdalOgrAlgorithmProvider(AlgorithmProvider): AlgorithmProvider.__init__(self) self.createAlgsList() + def initializeSettings(self): + AlgorithmProvider.initializeSettings(self) + ProcessingConfig.addSetting(Setting( + self.getDescription(), + GdalUtils.GDAL_HELP_PATH, + self.tr('Location of GDAL docs'), + GdalUtils.gdalHelpPath())) + + def unload(self): + AlgorithmProvider.unload(self) + ProcessingConfig.removeSetting(GdalUtils.GDAL_HELP_PATH) + def getDescription(self): - return self.tr('GDAL/OGR') + version = GdalUtils.readableVersion() + return 'GDAL ({})'.format(version) def getName(self): - return 'gdalogr' + return 'gdal' def getIcon(self): return QIcon(os.path.join(pluginPath, 'images', 'gdal.svg')) diff --git a/python/plugins/processing/algs/gdal/GdalUtils.py b/python/plugins/processing/algs/gdal/GdalUtils.py index 162c8c81dcb..f2ebe456230 100644 --- a/python/plugins/processing/algs/gdal/GdalUtils.py +++ b/python/plugins/processing/algs/gdal/GdalUtils.py @@ -36,8 +36,10 @@ from osgeo import gdal from qgis.PyQt.QtCore import QSettings from qgis.core import QgsApplication, QgsVectorFileWriter +from processing.core.ProcessingConfig import ProcessingConfig from processing.core.ProcessingLog import ProcessingLog from processing.core.SilentProgress import SilentProgress +from processing.tools.system import isWindows, isMac try: from osgeo import gdal @@ -48,6 +50,8 @@ except: class GdalUtils(object): + GDAL_HELP_PATH = 'GDAL_HELP_PATH' + supportedRasters = None @staticmethod @@ -186,3 +190,25 @@ class GdalUtils(object): @staticmethod def version(): return int(gdal.VersionInfo('VERSION_NUM')) + + @staticmethod + def readableVersion(): + return gdal.VersionInfo('RELEASE_NAME') + + @staticmethod + def gdalHelpPath(): + helpPath = ProcessingConfig.getSetting(GdalUtils.GDAL_HELP_PATH) + + if helpPath is None: + if isWindows(): + pass + elif isMac(): + pass + else: + searchPaths = ['/usr/share/doc/libgdal-doc/gdal'] + for path in searchPaths: + if os.path.exists(path): + helpPath = os.path.abspath(path) + break + + return helpPath if helpPath is not None else 'http://www.gdal.org/' diff --git a/python/plugins/processing/algs/gdal/GridAverage.py b/python/plugins/processing/algs/gdal/GridAverage.py index 59cad977a92..c66ac026e0c 100644 --- a/python/plugins/processing/algs/gdal/GridAverage.py +++ b/python/plugins/processing/algs/gdal/GridAverage.py @@ -60,7 +60,7 @@ class GridAverage(GdalAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png')) def commandLineName(self): - return "gdalogr:gridaverage" + return "gdal:gridaverage" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Grid (Moving average)') diff --git a/python/plugins/processing/algs/gdal/GridDataMetrics.py b/python/plugins/processing/algs/gdal/GridDataMetrics.py index d38b20444c6..cf7be900dc8 100644 --- a/python/plugins/processing/algs/gdal/GridDataMetrics.py +++ b/python/plugins/processing/algs/gdal/GridDataMetrics.py @@ -65,7 +65,7 @@ class GridDataMetrics(GdalAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png')) def commandLineName(self): - return "gdalogr:griddatametrics" + return "gdal:griddatametrics" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Grid (Data metrics)') diff --git a/python/plugins/processing/algs/gdal/GridInvDist.py b/python/plugins/processing/algs/gdal/GridInvDist.py index 6b5440b80dc..07ebdfeba34 100644 --- a/python/plugins/processing/algs/gdal/GridInvDist.py +++ b/python/plugins/processing/algs/gdal/GridInvDist.py @@ -64,7 +64,7 @@ class GridInvDist(GdalAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png')) def commandLineName(self): - return "gdalogr:gridinvdist" + return "gdal:gridinvdist" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Grid (Inverse distance to a power)') diff --git a/python/plugins/processing/algs/gdal/GridNearest.py b/python/plugins/processing/algs/gdal/GridNearest.py index 1fb5645ff15..9f8f42b7dc6 100644 --- a/python/plugins/processing/algs/gdal/GridNearest.py +++ b/python/plugins/processing/algs/gdal/GridNearest.py @@ -60,7 +60,7 @@ class GridNearest(GdalAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png')) def commandLineName(self): - return "gdalogr:gridnearestneighbor" + return "gdal:gridnearestneighbor" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Grid (Nearest neighbor)') diff --git a/python/plugins/processing/algs/gdal/gdal2tiles.py b/python/plugins/processing/algs/gdal/gdal2tiles.py index f63c794628d..edd4c658c8e 100644 --- a/python/plugins/processing/algs/gdal/gdal2tiles.py +++ b/python/plugins/processing/algs/gdal/gdal2tiles.py @@ -61,7 +61,7 @@ class gdal2tiles(GdalAlgorithm): WEBVIEWERS = ['all', 'google', 'openlayers', 'leaflet', 'none'] def commandLineName(self): - return "gdalogr:gdal2tiles" + return "gdal:gdal2tiles" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('gdal2tiles') diff --git a/python/plugins/processing/algs/gdal/gdaladdo.py b/python/plugins/processing/algs/gdal/gdaladdo.py index 525573b6375..2e97a71e6d7 100644 --- a/python/plugins/processing/algs/gdal/gdaladdo.py +++ b/python/plugins/processing/algs/gdal/gdaladdo.py @@ -67,7 +67,7 @@ class gdaladdo(GdalAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-overview.png')) def commandLineName(self): - return "gdalogr:overviews" + return "gdal:overviews" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Build overviews (pyramids)') diff --git a/python/plugins/processing/algs/gdal/information.py b/python/plugins/processing/algs/gdal/information.py index da5a1489a2d..249bbd2d1ff 100644 --- a/python/plugins/processing/algs/gdal/information.py +++ b/python/plugins/processing/algs/gdal/information.py @@ -50,7 +50,7 @@ class information(GdalAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-info.png')) def commandLineName(self): - return "gdalorg:rasterinfo" + return "gdal:gdalinfo" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Information') diff --git a/python/plugins/processing/algs/gdal/merge.py b/python/plugins/processing/algs/gdal/merge.py index 5d3dc942bd5..ac8785608bd 100644 --- a/python/plugins/processing/algs/gdal/merge.py +++ b/python/plugins/processing/algs/gdal/merge.py @@ -30,12 +30,14 @@ import os from qgis.PyQt.QtGui import QIcon from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm +from processing.core.parameters import (ParameterBoolean, + ParameterString, + ParameterSelection, + ParameterMultipleInput) from processing.core.outputs import OutputRaster -from processing.core.parameters import ParameterBoolean -from processing.core.parameters import ParameterMultipleInput -from processing.core.parameters import ParameterSelection from processing.tools.system import isWindows from processing.tools import dataobjects + from processing.algs.gdal.GdalUtils import GdalUtils pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0] @@ -44,10 +46,11 @@ pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0] class merge(GdalAlgorithm): INPUT = 'INPUT' - OUTPUT = 'OUTPUT' + OPTIONS = 'OPTIONS' PCT = 'PCT' SEPARATE = 'SEPARATE' RTYPE = 'RTYPE' + OUTPUT = 'OUTPUT' TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64'] @@ -57,31 +60,44 @@ class merge(GdalAlgorithm): def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Merge') self.group, self.i18n_group = self.trAlgorithm('[GDAL] Miscellaneous') - self.addParameter(ParameterMultipleInput(merge.INPUT, - self.tr('Input layers'), dataobjects.TYPE_RASTER)) - self.addParameter(ParameterBoolean(merge.PCT, - self.tr('Grab pseudocolor table from first layer'), False)) - self.addParameter(ParameterBoolean(merge.SEPARATE, - self.tr('Place each input file into a separate band'), False)) + self.addParameter(ParameterMultipleInput(self.INPUT, + self.tr('Input layers'), + dataobjects.TYPE_RASTER)) + self.addParameter(ParameterString(self.OPTIONS, + self.tr('Additional creation options'), + optional=True, + metadata={'widget_wrapper': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'})) + self.addParameter(ParameterBoolean(self.PCT, + self.tr('Grab pseudocolor table from first layer'), + False)) + self.addParameter(ParameterBoolean(self.SEPARATE, + self.tr('Place each input file into a separate band'), + False)) self.addParameter(ParameterSelection(self.RTYPE, - self.tr('Output raster type'), self.TYPE, 5)) + self.tr('Output raster type'), + self.TYPE, 5)) - self.addOutput(OutputRaster(merge.OUTPUT, self.tr('Merged'))) + self.addOutput(OutputRaster(self.OUTPUT, self.tr('Merged'))) def getConsoleCommands(self): arguments = [] arguments.append('-ot') arguments.append(self.TYPE[self.getParameterValue(self.RTYPE)]) - if self.getParameterValue(merge.SEPARATE): + if self.getParameterValue(self.SEPARATE): arguments.append('-separate') - if self.getParameterValue(merge.PCT): + if self.getParameterValue(self.PCT): arguments.append('-pct') + opts = self.getParameterValue(self.OPTIONS) + if opts: + arguments.append('-co') + arguments.append(opts) + arguments.append('-o') - out = self.getOutputValue(merge.OUTPUT) + out = self.getOutputValue(self.OUTPUT) arguments.append(out) arguments.append('-of') arguments.append(GdalUtils.getFormatShortNameFromFilename(out)) - arguments.extend(self.getParameterValue(merge.INPUT).split(';')) + arguments.extend(self.getParameterValue(self.INPUT).split(';')) commands = [] if isWindows(): diff --git a/python/plugins/processing/algs/gdal/ogrinfo.py b/python/plugins/processing/algs/gdal/ogrinfo.py index 73c24e5d297..2d831a013e5 100644 --- a/python/plugins/processing/algs/gdal/ogrinfo.py +++ b/python/plugins/processing/algs/gdal/ogrinfo.py @@ -43,6 +43,9 @@ class OgrInfo(GdalAlgorithm): SUMMARY_ONLY = 'SUMMARY_ONLY' OUTPUT = 'OUTPUT' + def commandLineName(self): + return "gdal:ogrinfo" + def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Information') self.group, self.i18n_group = self.trAlgorithm('[OGR] Miscellaneous') diff --git a/python/plugins/processing/algs/gdal/polygonize.py b/python/plugins/processing/algs/gdal/polygonize.py index 92510c62a57..178a1ada4df 100644 --- a/python/plugins/processing/algs/gdal/polygonize.py +++ b/python/plugins/processing/algs/gdal/polygonize.py @@ -50,7 +50,7 @@ class polygonize(GdalAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'polygonize.png')) def commandLineName(self): - return "gdalogr:polygonize" + return "gdal:polygonize" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Polygonize (raster to vector)') diff --git a/python/plugins/processing/algs/gdal/proximity.py b/python/plugins/processing/algs/gdal/proximity.py index 892330ed9a4..5010f70dc4f 100644 --- a/python/plugins/processing/algs/gdal/proximity.py +++ b/python/plugins/processing/algs/gdal/proximity.py @@ -61,7 +61,7 @@ class proximity(GdalAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'proximity.png')) def commandLineName(self): - return "gdalogr:proximity" + return "gdal:proximity" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Proximity (raster distance)') diff --git a/python/plugins/processing/algs/gdal/rasterize.py b/python/plugins/processing/algs/gdal/rasterize.py index d2f2505f1d0..7779ad6e12d 100644 --- a/python/plugins/processing/algs/gdal/rasterize.py +++ b/python/plugins/processing/algs/gdal/rasterize.py @@ -30,13 +30,12 @@ import os from qgis.PyQt.QtGui import QIcon -from processing.core.parameters import ParameterVector -from processing.core.parameters import ParameterExtent -from processing.core.parameters import ParameterTableField -from processing.core.parameters import ParameterSelection -from processing.core.parameters import ParameterNumber -from processing.core.parameters import ParameterBoolean -from processing.core.parameters import ParameterString +from processing.core.parameters import (ParameterVector, + ParameterExtent, + ParameterTableField, + ParameterSelection, + ParameterNumber, + ParameterString) from processing.core.outputs import OutputRaster from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm @@ -54,31 +53,25 @@ class rasterize(GdalAlgorithm): DIMENSIONS = 'DIMENSIONS' WIDTH = 'WIDTH' HEIGHT = 'HEIGHT' - EXTRA = 'EXTRA' - RTYPE = 'RTYPE' - OUTPUT = 'OUTPUT' - TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64'] NO_DATA = 'NO_DATA' - TILED = 'TILED' - COMPRESS = 'COMPRESS' - JPEGCOMPRESSION = 'JPEGCOMPRESSION' - PREDICTOR = 'PREDICTOR' - ZLEVEL = 'ZLEVEL' - BIGTIFF = 'BIGTIFF' - BIGTIFFTYPE = ['', 'YES', 'NO', 'IF_NEEDED', 'IF_SAFER'] - COMPRESSTYPE = ['NONE', 'JPEG', 'LZW', 'PACKBITS', 'DEFLATE'] - TFW = 'TFW' + RTYPE = 'RTYPE' + OPTIONS = 'OPTIONS' + OUTPUT = 'OUTPUT' + + TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64'] + RAST_EXT = 'RAST_EXT' def getIcon(self): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'rasterize.png')) def commandLineName(self): - return "gdalogr:rasterize" + return "gdal:rasterize" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Rasterize (vector to raster)') self.group, self.i18n_group = self.trAlgorithm('[GDAL] Conversion') + self.addParameter(ParameterVector(self.INPUT, self.tr('Input layer'))) self.addParameter(ParameterTableField(self.FIELD, self.tr('Attribute field'), self.INPUT)) @@ -90,58 +83,32 @@ class rasterize(GdalAlgorithm): self.addParameter(ParameterNumber(self.HEIGHT, self.tr('Vertical'), 0.0, 99999999.999999, 100.0)) self.addParameter(ParameterExtent(self.RAST_EXT, self.tr('Raster extent'))) + self.addParameter(ParameterString(self.NO_DATA, + self.tr("Nodata value"), + '', optional=True)) - params = [] - params.append(ParameterSelection(self.RTYPE, self.tr('Raster type'), - self.TYPE, 5)) - params.append(ParameterString(self.NO_DATA, - self.tr("Nodata value"), - '', optional=True)) - params.append(ParameterSelection(self.COMPRESS, - self.tr('GeoTIFF options. Compression type:'), self.COMPRESSTYPE, 4)) - params.append(ParameterNumber(self.JPEGCOMPRESSION, - self.tr('Set the JPEG compression level'), - 1, 100, 75)) - params.append(ParameterNumber(self.ZLEVEL, - self.tr('Set the DEFLATE compression level'), - 1, 9, 6)) - params.append(ParameterNumber(self.PREDICTOR, - self.tr('Set the predictor for LZW or DEFLATE compression'), - 1, 3, 1)) - params.append(ParameterBoolean(self.TILED, - self.tr('Create tiled output (only used for the GTiff format)'), False)) - params.append(ParameterSelection(self.BIGTIFF, - self.tr('Control whether the created file is a BigTIFF or a classic TIFF'), self.BIGTIFFTYPE, 0)) - self.addParameter(ParameterBoolean(self.TFW, - self.tr('Force the generation of an associated ESRI world file (.tfw)'), False)) - params.append(ParameterString(self.EXTRA, - self.tr('Additional creation parameters'), '', optional=True)) - - for param in params: - param.isAdvanced = True - self.addParameter(param) + self.addParameter(ParameterString(self.OPTIONS, + self.tr('Additional creation options'), + optional=True, + metadata={'widget_wrapper': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'})) + self.addParameter(ParameterSelection(self.RTYPE, + self.tr('Raster type'), + self.TYPE, 5)) self.addOutput(OutputRaster(self.OUTPUT, self.tr('Rasterized'))) def getConsoleCommands(self): inLayer = self.getParameterValue(self.INPUT) - ogrLayer = ogrConnectionString(inLayer)[1:-1] noData = self.getParameterValue(self.NO_DATA) + rastext = str(self.getParameterValue(self.RAST_EXT)) + opts = self.getParameterValue(self.OPTIONS) + out = self.getOutputValue(self.OUTPUT) + + ogrLayer = ogrConnectionString(inLayer)[1:-1] + if noData is not None: noData = str(noData) - jpegcompression = str(self.getParameterValue(self.JPEGCOMPRESSION)) - predictor = str(self.getParameterValue(self.PREDICTOR)) - zlevel = str(self.getParameterValue(self.ZLEVEL)) - tiled = str(self.getParameterValue(self.TILED)) - compress = self.COMPRESSTYPE[self.getParameterValue(self.COMPRESS)] - bigtiff = self.BIGTIFFTYPE[self.getParameterValue(self.BIGTIFF)] - tfw = str(self.getParameterValue(self.TFW)) - out = self.getOutputValue(self.OUTPUT) - extra = self.getParameterValue(self.EXTRA) - if extra is not None: - extra = str(extra) - rastext = str(self.getParameterValue(self.RAST_EXT)) arguments = [] arguments.append('-a') @@ -181,26 +148,15 @@ class rasterize(GdalAlgorithm): arguments.append('-a_nodata') arguments.append(noData) - if (GdalUtils.getFormatShortNameFromFilename(out) == "GTiff"): - arguments.append("-co COMPRESS=" + compress) - if compress == 'JPEG': - arguments.append("-co JPEG_QUALITY=" + jpegcompression) - elif (compress == 'LZW') or (compress == 'DEFLATE'): - arguments.append("-co PREDICTOR=" + predictor) - if compress == 'DEFLATE': - arguments.append("-co ZLEVEL=" + zlevel) - if tiled == "True": - arguments.append("-co TILED=YES") - if tfw == "True": - arguments.append("-co TFW=YES") - if len(bigtiff) > 0: - arguments.append("-co BIGTIFF=" + bigtiff) - if extra and len(extra) > 0: - arguments.append(extra) + if opts: + arguments.append('-co') + arguments.append(opts) + arguments.append('-l') + print(ogrLayerName(inLayer)) arguments.append(ogrLayerName(inLayer)) arguments.append(ogrLayer) - arguments.append(str(self.getOutputValue(self.OUTPUT))) + arguments.append(out) return ['gdal_rasterize', GdalUtils.escapeAndJoin(arguments)] diff --git a/python/plugins/processing/algs/gdal/rasterize_over.py b/python/plugins/processing/algs/gdal/rasterize_over.py index e7bc4b686db..50ed8bc9428 100644 --- a/python/plugins/processing/algs/gdal/rasterize_over.py +++ b/python/plugins/processing/algs/gdal/rasterize_over.py @@ -52,7 +52,7 @@ class rasterize_over(GdalAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'rasterize.png')) def commandLineName(self): - return "gdalogr:rasterize_over" + return "gdal:rasterize_over" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Rasterize (write over existing raster)') @@ -64,9 +64,10 @@ class rasterize_over(GdalAlgorithm): self.tr('Existing raster layer'), False)) def getConsoleCommands(self): - inLayer = self.getParameterValue(self.INPUT) + inLayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT)) + inRasterLayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT_RASTER)) + ogrLayer = ogrConnectionString(inLayer)[1:-1] - inRasterLayer = self.getParameterValue(self.INPUT_RASTER) ogrRasterLayer = ogrConnectionString(inRasterLayer)[1:-1] arguments = [] diff --git a/python/plugins/processing/algs/gdal/retile.py b/python/plugins/processing/algs/gdal/retile.py index 25b157fb34d..b111af0a4c2 100644 --- a/python/plugins/processing/algs/gdal/retile.py +++ b/python/plugins/processing/algs/gdal/retile.py @@ -61,7 +61,7 @@ class retile(GdalAlgorithm): ALGO = ['near', 'bilinear', 'cubic', 'cubicspline', 'lanczos'] def commandLineName(self): - return "gdalogr:retile" + return "gdal:retile" def commandName(self): return "gdal_retile" diff --git a/python/plugins/processing/algs/gdal/translate.py b/python/plugins/processing/algs/gdal/translate.py index 6eca20be728..c5bf87a5f93 100644 --- a/python/plugins/processing/algs/gdal/translate.py +++ b/python/plugins/processing/algs/gdal/translate.py @@ -31,13 +31,13 @@ import os from qgis.PyQt.QtGui import QIcon from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm -from processing.core.parameters import ParameterString -from processing.core.parameters import ParameterRaster -from processing.core.parameters import ParameterNumber -from processing.core.parameters import ParameterBoolean -from processing.core.parameters import ParameterSelection -from processing.core.parameters import ParameterExtent -from processing.core.parameters import ParameterCrs +from processing.core.parameters import (ParameterRaster, + ParameterString, + ParameterNumber, + ParameterBoolean, + ParameterSelection, + ParameterExtent, + ParameterCrs) from processing.core.outputs import OutputRaster from processing.algs.gdal.GdalUtils import GdalUtils @@ -56,29 +56,21 @@ class translate(GdalAlgorithm): PROJWIN = 'PROJWIN' SRS = 'SRS' SDS = 'SDS' - EXTRA = 'EXTRA' RTYPE = 'RTYPE' + OPTIONS = 'OPTIONS' TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64'] - TILED = 'TILED' - COMPRESS = 'COMPRESS' - JPEGCOMPRESSION = 'JPEGCOMPRESSION' - PREDICTOR = 'PREDICTOR' - ZLEVEL = 'ZLEVEL' - BIGTIFF = 'BIGTIFF' - BIGTIFFTYPE = ['', 'YES', 'NO', 'IF_NEEDED', 'IF_SAFER'] - COMPRESSTYPE = ['NONE', 'JPEG', 'LZW', 'PACKBITS', 'DEFLATE'] - TFW = 'TFW' def getIcon(self): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'translate.png')) def commandLineName(self): - return "gdalogr:translate" + return "gdal:translate" def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Translate (convert format)') self.group, self.i18n_group = self.trAlgorithm('[GDAL] Conversion') - self.addParameter(ParameterRaster(self.INPUT, self.tr('Input layer'), False)) + + self.addParameter(ParameterRaster(self.INPUT, self.tr('Input layer'))) self.addParameter(ParameterNumber(self.OUTSIZE, self.tr('Set the size of the output file (In pixels or %)'), 1, None, 100)) @@ -97,32 +89,13 @@ class translate(GdalAlgorithm): self.tr('Copy all subdatasets of this file to individual output files'), False)) - params = [] - params.append(ParameterSelection(self.RTYPE, - self.tr('Output raster type'), self.TYPE, 5)) - params.append(ParameterSelection(self.COMPRESS, - self.tr('GeoTIFF options. Compression type:'), self.COMPRESSTYPE, 4)) - params.append(ParameterNumber(self.JPEGCOMPRESSION, - self.tr('Set the JPEG compression level'), - 1, 100, 75)) - params.append(ParameterNumber(self.ZLEVEL, - self.tr('Set the DEFLATE compression level'), - 1, 9, 6)) - params.append(ParameterNumber(self.PREDICTOR, - self.tr('Set the predictor for LZW or DEFLATE compression'), - 1, 3, 1)) - params.append(ParameterBoolean(self.TILED, - self.tr('Create tiled output (only used for the GTiff format)'), False)) - params.append(ParameterSelection(self.BIGTIFF, - self.tr('Control whether the created file is a BigTIFF or a classic TIFF'), self.BIGTIFFTYPE, 0)) - params.append(ParameterBoolean(self.TFW, - self.tr('Force the generation of an associated ESRI world file (.tfw))'), False)) - params.append(ParameterString(self.EXTRA, - self.tr('Additional creation parameters'), '', optional=True)) - - for param in params: - param.isAdvanced = True - self.addParameter(param) + self.addParameter(ParameterString(self.OPTIONS, + self.tr('Additional creation options'), + optional=True, + metadata={'widget_wrapper': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'})) + self.addParameter(ParameterSelection(self.RTYPE, + self.tr('Output raster type'), + self.TYPE, 5)) self.addOutput(OutputRaster(self.OUTPUT, self.tr('Converted'))) @@ -131,23 +104,15 @@ class translate(GdalAlgorithm): outsize = str(self.getParameterValue(self.OUTSIZE)) outsizePerc = str(self.getParameterValue(self.OUTSIZE_PERC)) noData = self.getParameterValue(self.NO_DATA) - if noData is not None: - noData = str(noData) expand = str(self.getParameterFromName( self.EXPAND).options[self.getParameterValue(self.EXPAND)]) projwin = str(self.getParameterValue(self.PROJWIN)) crsId = self.getParameterValue(self.SRS) sds = self.getParameterValue(self.SDS) - extra = self.getParameterValue(self.EXTRA) - if extra is not None: - extra = str(extra) - jpegcompression = str(self.getParameterValue(self.JPEGCOMPRESSION)) - predictor = str(self.getParameterValue(self.PREDICTOR)) - zlevel = str(self.getParameterValue(self.ZLEVEL)) - tiled = str(self.getParameterValue(self.TILED)) - compress = self.COMPRESSTYPE[self.getParameterValue(self.COMPRESS)] - bigtiff = self.BIGTIFFTYPE[self.getParameterValue(self.BIGTIFF)] - tfw = str(self.getParameterValue(self.TFW)) + opts = self.getParameterValue(self.OPTIONS) + + if noData is not None: + noData = str(noData) arguments = [] arguments.append('-of') @@ -185,22 +150,10 @@ class translate(GdalAlgorithm): arguments.append(str(crsId)) if sds: arguments.append('-sds') - if extra and len(extra) > 0: - arguments.append(extra) - if GdalUtils.getFormatShortNameFromFilename(out) == "GTiff": - arguments.append("-co COMPRESS=" + compress) - if compress == 'JPEG': - arguments.append("-co JPEG_QUALITY=" + jpegcompression) - elif (compress == 'LZW') or (compress == 'DEFLATE'): - arguments.append("-co PREDICTOR=" + predictor) - if compress == 'DEFLATE': - arguments.append("-co ZLEVEL=" + zlevel) - if tiled == "True": - arguments.append("-co TILED=YES") - if tfw == "True": - arguments.append("-co TFW=YES") - if len(bigtiff) > 0: - arguments.append("-co BIGTIFF=" + bigtiff) + + if opts: + arguments.append('-co') + arguments.append(opts) arguments.append(self.getParameterValue(self.INPUT)) arguments.append(out) diff --git a/python/plugins/processing/algs/gdal/ui/CMakeLists.txt b/python/plugins/processing/algs/gdal/ui/CMakeLists.txt new file mode 100644 index 00000000000..0d137a1f926 --- /dev/null +++ b/python/plugins/processing/algs/gdal/ui/CMakeLists.txt @@ -0,0 +1,4 @@ +FILE(GLOB PY_FILES *.py) +FILE(GLOB UI_FILES *.ui) + +PLUGIN_INSTALL(processing ./algs/gdal/ui ${PY_FILES} ${UI_FILES}) diff --git a/python/plugins/processing/algs/gdal/ui/RasterOptionsWidget.py b/python/plugins/processing/algs/gdal/ui/RasterOptionsWidget.py new file mode 100644 index 00000000000..1648f023b5f --- /dev/null +++ b/python/plugins/processing/algs/gdal/ui/RasterOptionsWidget.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + RasterOptionsWidget.py + --------------------- + Date : December 2016 + Copyright : (C) 2016 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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. * +* * +*************************************************************************** +""" + +__author__ = 'Alexander Bruy' +__date__ = 'December 2016' +__copyright__ = '(C) 2016, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +from qgis.PyQt.QtWidgets import QLineEdit, QComboBox +from qgis.gui import QgsRasterFormatSaveOptionsWidget + +from processing.core.parameters import ParameterString +from processing.core.outputs import OutputString +from processing.gui.wrappers import WidgetWrapper, DIALOG_MODELER, DIALOG_BATCH + + +class RasterOptionsWidgetWrapper(WidgetWrapper): + + def createWidget(self): + if self.dialogType == DIALOG_MODELER: + widget = QComboBox() + widget.setEditable(True) + strings = self.dialog.getAvailableValuesOfType(ParameterString, OutputString) + options = [(self.dialog.resolveValueDescription(s), s) for s in strings] + for desc, val in options: + widget.addItem(desc, val) + widget.setEditText(self.param.default or '') + return widget + elif self.dialogType == DIALOG_BATCH: + widget = QLineEdit() + if self.param.default: + widget.setText(self.param.default) + else: + return QgsRasterFormatSaveOptionsWidget() + + def setValue(self, value): + if value is None: + value = '' + + if self.dialogType == DIALOG_MODELER: + self.setComboValue(value) + elif self.dialogType == DIALOG_BATCH: + self.widget.setText(value) + else: + self.widget.setValue(value) + + def value(self): + if self.dialogType == DIALOG_MODELER: + return self.comboValue() + elif self.dialogType == DIALOG_BATCH: + return self.widget.text() + else: + return ' '.join(self.widget.options()) diff --git a/python/plugins/GdalTools/tools/__init__.py b/python/plugins/processing/algs/gdal/ui/__init__.py similarity index 100% rename from python/plugins/GdalTools/tools/__init__.py rename to python/plugins/processing/algs/gdal/ui/__init__.py diff --git a/python/plugins/processing/algs/gdal/warp.py b/python/plugins/processing/algs/gdal/warp.py index f38b39fbeb5..23e531393dd 100644 --- a/python/plugins/processing/algs/gdal/warp.py +++ b/python/plugins/processing/algs/gdal/warp.py @@ -31,13 +31,13 @@ import os from qgis.PyQt.QtGui import QIcon from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm -from processing.core.parameters import ParameterRaster -from processing.core.parameters import ParameterExtent -from processing.core.parameters import ParameterSelection -from processing.core.parameters import ParameterCrs -from processing.core.parameters import ParameterNumber -from processing.core.parameters import ParameterString -from processing.core.parameters import ParameterBoolean +from processing.core.parameters import (ParameterRaster, + ParameterExtent, + ParameterSelection, + ParameterCrs, + ParameterNumber, + ParameterString, + ParameterBoolean) from processing.core.outputs import OutputRaster from processing.algs.gdal.GdalUtils import GdalUtils @@ -51,23 +51,15 @@ class warp(GdalAlgorithm): SOURCE_SRS = 'SOURCE_SRS' DEST_SRS = 'DEST_SRS' METHOD = 'METHOD' - METHOD_OPTIONS = ['near', 'bilinear', 'cubic', 'cubicspline', 'lanczos'] TR = 'TR' NO_DATA = 'NO_DATA' - EXTRA = 'EXTRA' - RTYPE = 'RTYPE' - TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64'] - TILED = 'TILED' - COMPRESS = 'COMPRESS' - JPEGCOMPRESSION = 'JPEGCOMPRESSION' - PREDICTOR = 'PREDICTOR' - ZLEVEL = 'ZLEVEL' - BIGTIFF = 'BIGTIFF' - BIGTIFFTYPE = ['', 'YES', 'NO', 'IF_NEEDED', 'IF_SAFER'] - COMPRESSTYPE = ['NONE', 'JPEG', 'LZW', 'PACKBITS', 'DEFLATE'] - TFW = 'TFW' RAST_EXT = 'RAST_EXT' EXT_CRS = 'EXT_CRS' + RTYPE = 'RTYPE' + OPTIONS = 'OPTIONS' + + METHOD_OPTIONS = ['near', 'bilinear', 'cubic', 'cubicspline', 'lanczos'] + TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64'] def getIcon(self): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'warp.png')) @@ -75,12 +67,16 @@ class warp(GdalAlgorithm): def defineCharacteristics(self): self.name, self.i18n_name = self.trAlgorithm('Warp (reproject)') self.group, self.i18n_group = self.trAlgorithm('[GDAL] Projections') + self.tags = self.tr('transform,reproject,crs,srs') self.addParameter(ParameterRaster(self.INPUT, self.tr('Input layer'), False)) self.addParameter(ParameterCrs(self.SOURCE_SRS, - self.tr('Source SRS'), '', optional=True)) + self.tr('Source SRS'), + '', + optional=True)) self.addParameter(ParameterCrs(self.DEST_SRS, - self.tr('Destination SRS'), 'EPSG:4326')) + self.tr('Destination SRS'), + 'EPSG:4326')) self.addParameter(ParameterString(self.NO_DATA, self.tr("Nodata value, leave blank to take the nodata value from input"), '', optional=True)) @@ -88,58 +84,37 @@ class warp(GdalAlgorithm): self.tr('Output file resolution in target georeferenced units (leave 0 for no change)'), 0.0, None, 0.0)) self.addParameter(ParameterSelection(self.METHOD, - self.tr('Resampling method'), self.METHOD_OPTIONS)) - self.addParameter(ParameterExtent(self.RAST_EXT, self.tr('Raster extent'), optional=True)) + self.tr('Resampling method'), + self.METHOD_OPTIONS)) + self.addParameter(ParameterExtent(self.RAST_EXT, + self.tr('Raster extent'), + optional=True)) if GdalUtils.version() >= 2000000: self.addParameter(ParameterCrs(self.EXT_CRS, self.tr('CRS of the raster extent, leave blank for using Destination SRS'), optional=True)) - params = [] - params.append(ParameterSelection(self.RTYPE, - self.tr('Output raster type'), self.TYPE, 5)) - params.append(ParameterSelection(self.COMPRESS, - self.tr('GeoTIFF options. Compression type:'), self.COMPRESSTYPE, 4)) - params.append(ParameterNumber(self.JPEGCOMPRESSION, - self.tr('Set the JPEG compression level'), - 1, 100, 75)) - params.append(ParameterNumber(self.ZLEVEL, - self.tr('Set the DEFLATE compression level'), - 1, 9, 6)) - params.append(ParameterNumber(self.PREDICTOR, - self.tr('Set the predictor for LZW or DEFLATE compression'), - 1, 3, 1)) - params.append(ParameterBoolean(self.TILED, - self.tr('Create tiled output (only used for the GTiff format)'), False)) - params.append(ParameterSelection(self.BIGTIFF, - self.tr('Control whether the created file is a BigTIFF or a classic TIFF'), self.BIGTIFFTYPE, 0)) - params.append(ParameterBoolean(self.TFW, - self.tr('Force the generation of an associated ESRI world file (.tfw))'), False)) - params.append(ParameterString(self.EXTRA, - self.tr('Additional creation parameters'), '', optional=True)) - - for param in params: - param.isAdvanced = True - self.addParameter(param) + self.addParameter(ParameterString(self.OPTIONS, + self.tr('Additional creation options'), + optional=True, + metadata={'widget_wrapper': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'})) + self.addParameter(ParameterSelection(self.RTYPE, + self.tr('Output raster type'), + self.TYPE, 5)) self.addOutput(OutputRaster(self.OUTPUT, self.tr('Reprojected'))) def getConsoleCommands(self): - noData = self.getParameterValue(self.NO_DATA) - if noData is not None: - noData = str(noData) srccrs = self.getParameterValue(self.SOURCE_SRS) dstcrs = self.getParameterValue(self.DEST_SRS) - jpegcompression = str(self.getParameterValue(self.JPEGCOMPRESSION)) - predictor = str(self.getParameterValue(self.PREDICTOR)) - zlevel = str(self.getParameterValue(self.ZLEVEL)) - tiled = str(self.getParameterValue(self.TILED)) - compress = self.COMPRESSTYPE[self.getParameterValue(self.COMPRESS)] - bigtiff = self.BIGTIFFTYPE[self.getParameterValue(self.BIGTIFF)] - tfw = str(self.getParameterValue(self.TFW)) rastext = self.getParameterValue(self.RAST_EXT) rastext_crs = self.getParameterValue(self.EXT_CRS) + opts = self.getParameterValue(self.OPTIONS) + noData = self.getParameterValue(self.NO_DATA) + + if noData is not None: + noData = str(noData) arguments = [] arguments.append('-ot') @@ -153,19 +128,20 @@ class warp(GdalAlgorithm): if noData: arguments.append('-dstnodata') arguments.append(noData) + arguments.append('-r') arguments.append( self.METHOD_OPTIONS[self.getParameterValue(self.METHOD)]) + arguments.append('-of') out = self.getOutputValue(self.OUTPUT) arguments.append(GdalUtils.getFormatShortNameFromFilename(out)) + if self.getParameterValue(self.TR) != 0: arguments.append('-tr') arguments.append(str(self.getParameterValue(self.TR))) arguments.append(str(self.getParameterValue(self.TR))) - extra = self.getParameterValue(self.EXTRA) - if extra is not None: - extra = str(extra) + if rastext: regionCoords = rastext.split(',') if len(regionCoords) >= 4: @@ -180,24 +156,9 @@ class warp(GdalAlgorithm): arguments.append('-te_srs') arguments.append(rastext_crs) - if extra and len(extra) > 0: - arguments.append(extra) - if GdalUtils.getFormatShortNameFromFilename(out) == "GTiff": - arguments.append("-co COMPRESS=" + compress) - if compress == 'JPEG': - arguments.append("-co JPEG_QUALITY=" + jpegcompression) - elif (compress == 'LZW') or (compress == 'DEFLATE'): - arguments.append("-co PREDICTOR=" + predictor) - if compress == 'DEFLATE': - arguments.append("-co ZLEVEL=" + zlevel) - if tiled == "True": - arguments.append("-co TILED=YES") - if tfw == "True": - arguments.append("-co TFW=YES") - if len(bigtiff) > 0: - arguments.append("-co BIGTIFF=" + bigtiff) - - arguments.append("-wo OPTIMIZE_SIZE=TRUE") + if opts: + arguments.append('-co') + arguments.append(opts) if GdalUtils.version() in [2010000, 2010100]: arguments.append("--config GDALWARP_IGNORE_BAD_CUTLINE YES") diff --git a/python/plugins/processing/algs/grass7/Grass7Algorithm.py b/python/plugins/processing/algs/grass7/Grass7Algorithm.py index 9def6636041..b0601d769e2 100644 --- a/python/plugins/processing/algs/grass7/Grass7Algorithm.py +++ b/python/plugins/processing/algs/grass7/Grass7Algorithm.py @@ -106,34 +106,14 @@ class Grass7Algorithm(GeoAlgorithm): return self._icon def help(self): - localDoc = None - html = self.grass7Name + '.html' - if system.isWindows(): - # For MS-Windows, use the configured GRASS7 path - localPath = os.path.join(Grass7Utils.grassPath(), 'docs/html', html) - if os.path.exists(localPath): - localDoc = os.path.abspath(localPath) - elif system.isMac(): - # For MacOSX official package - localPath = os.path.join('/Applications/GRASS-7.0.app/Contents/MacOS/docs/html', html) - if os.path.exists(localPath): - localDoc = os.path.abspath(localPath) + helpPath = Grass7Utils.grassHelpPath() + if helpPath == '': + return False, None + + if os.path.exists(helpPath): + return False, QUrl.fromLocalFile(os.path.join(helpPath, '{}.html'.format(self.grass7Name))).toString() else: - # For GNU/Linux distributions - searchPaths = ['/usr/share/doc/grass-doc/html', '/opt/grass/docs/html', - '/usr/share/doc/grass/docs/html'] - for path in searchPaths: - localPath = os.path.join(path, html) - if os.path.exists(localPath): - localDoc = os.path.abspath(localPath) - - # Found the local documentation - if localDoc: - localDoc = QUrl.fromLocalFile(localDoc).toString() - return False, localDoc - - # Return the URL if local doc is not found - return False, 'http://grass.osgeo.org/grass70/manuals/' + self.grass7Name + '.html' + return False, helpPath + '{}.html'.format(self.grass7Name) def getParameterDescriptions(self): descs = {} diff --git a/python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py b/python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py index c81537dc65b..c616343fba5 100644 --- a/python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py +++ b/python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py @@ -61,6 +61,11 @@ class Grass7AlgorithmProvider(AlgorithmProvider): self.getDescription(), Grass7Utils.GRASS_LOG_CONSOLE, self.tr('Log console output'), False)) + ProcessingConfig.addSetting(Setting( + self.getDescription(), + Grass7Utils.GRASS_HELP_PATH, + self.tr('Location of GRASS docs'), + Grass7Utils.grassHelpPath())) def unload(self): AlgorithmProvider.unload(self) @@ -68,6 +73,7 @@ class Grass7AlgorithmProvider(AlgorithmProvider): ProcessingConfig.removeSetting(Grass7Utils.GRASS_FOLDER) ProcessingConfig.removeSetting(Grass7Utils.GRASS_LOG_COMMANDS) ProcessingConfig.removeSetting(Grass7Utils.GRASS_LOG_CONSOLE) + ProcessingConfig.removeSetting(Grass7Utils.GRASS_HELP_PATH) def createAlgsList(self): self.preloadedAlgs = [] @@ -92,10 +98,11 @@ class Grass7AlgorithmProvider(AlgorithmProvider): self.algs = self.preloadedAlgs def getDescription(self): - return self.tr('GRASS GIS 7 commands') + version = Grass7Utils.installedVersion() + return 'GRASS GIS ({})'.format(version) if version is not None else "GRASS GIS" def getName(self): - return 'grass70' + return 'grass7' def getIcon(self): return QIcon(os.path.join(pluginPath, 'images', 'grass.svg')) diff --git a/python/plugins/processing/algs/grass7/Grass7Utils.py b/python/plugins/processing/algs/grass7/Grass7Utils.py index b3eb2db5a40..fb9c66144e5 100644 --- a/python/plugins/processing/algs/grass7/Grass7Utils.py +++ b/python/plugins/processing/algs/grass7/Grass7Utils.py @@ -35,6 +35,7 @@ from qgis.core import QgsApplication from qgis.PyQt.QtCore import QCoreApplication from processing.core.ProcessingConfig import ProcessingConfig from processing.core.ProcessingLog import ProcessingLog +from processing.core.SilentProgress import SilentProgress from processing.tools.system import userFolder, isWindows, isMac, tempFolder, mkdir from processing.tests.TestData import points @@ -49,6 +50,7 @@ class Grass7Utils(object): GRASS_FOLDER = 'GRASS7_FOLDER' GRASS_LOG_COMMANDS = 'GRASS7_LOG_COMMANDS' GRASS_LOG_CONSOLE = 'GRASS7_LOG_CONSOLE' + GRASS_HELP_PATH = 'GRASS_HELP_PATH' sessionRunning = False sessionLayers = {} @@ -56,6 +58,8 @@ class Grass7Utils(object): isGrass7Installed = False + version = None + @staticmethod def grassBatchJobFilename(): '''This is used in Linux. This is the batch job that we assign to @@ -74,11 +78,39 @@ class Grass7Utils(object): filename = os.path.join(userFolder(), filename) return filename + #~ @staticmethod + #~ def installedVersion(): + #~ out = Grass7Utils.executeGrass7("grass -v") + #~ # FIXME: I do not know if this should be removed or let the user enter it + #~ # or something like that... This is just a temporary thing + #~ return '7.0.0' + @staticmethod - def getGrassVersion(): - # FIXME: I do not know if this should be removed or let the user enter it - # or something like that... This is just a temporary thing - return '7.0.0' + def installedVersion(run=False): + if Grass7Utils.isGrass7Installed and not run: + return Grass7Utils.version + + if Grass7Utils.grassPath() is None: + return None + commands = ["grass70 -v"] + with subprocess.Popen( + commands, + shell=True, + stdout=subprocess.PIPE, + stdin=subprocess.DEVNULL, + stderr=subprocess.STDOUT, + universal_newlines=True, + ) as proc: + try: + lines = proc.stdout.readlines() + for line in lines: + if "GRASS GIS " in line: + Grass7Utils.version = line.split(" ")[-1].strip() + break + except: + pass + + return Grass7Utils.version @staticmethod def grassPath(): @@ -140,7 +172,7 @@ class Grass7Utils(object): output.write('if "%GRASS_ADDON_PATH%"=="" set PATH=%WINGISBASE%\\bin;%WINGISBASE%\\lib;%PATH%\n') output.write('if not "%GRASS_ADDON_PATH%"=="" set PATH=%WINGISBASE%\\bin;%WINGISBASE%\\lib;%GRASS_ADDON_PATH%;%PATH%\n') output.write('\n') - output.write('set GRASS_VERSION=' + Grass7Utils.getGrassVersion() + '\n') + output.write('set GRASS_VERSION=' + Grass7Utils.installedVersion() + '\n') output.write('if not "%LANG%"=="" goto langset\n') output.write('FOR /F "usebackq delims==" %%i IN (`"%WINGISBASE%\\etc\\winlocale"`) DO @set LANG=%%i\n') output.write(':langset\n') @@ -395,3 +427,27 @@ class Grass7Utils(object): except TypeError: # Python 3 output.write(command + '\n') + + @staticmethod + def grassHelpPath(): + helpPath = ProcessingConfig.getSetting(Grass7Utils.GRASS_HELP_PATH) + + if helpPath is None: + if isWindows(): + localPath = os.path.join(Grass7Utils.grassPath(), 'docs/html') + if os.path.exists(localPath): + helpPath = os.path.abspath(localPath) + elif isMac(): + localPath = '/Applications/GRASS-7.0.app/Contents/MacOS/docs/html' + if os.path.exists(localPath): + helpPath = os.path.abspath(localPath) + else: + searchPaths = ['/usr/share/doc/grass-doc/html', + '/opt/grass/docs/html', + '/usr/share/doc/grass/docs/html'] + for path in searchPaths: + if os.path.exists(path): + helpPath = os.path.abspath(path) + break + + return helpPath if helpPath is not None else 'http://grass.osgeo.org/grass70/manuals/' diff --git a/python/plugins/processing/algs/help/qgis.yaml b/python/plugins/processing/algs/help/qgis.yaml index 37d89d4aec0..188f45bc7e9 100644 --- a/python/plugins/processing/algs/help/qgis.yaml +++ b/python/plugins/processing/algs/help/qgis.yaml @@ -93,7 +93,7 @@ qgis:createattributeindex: > Creates an index to speed up queries made against a field in a table. Support for index creation is dependent on the layer's data provider and the field type. qgis:createconstantrasterlayer: > - Given an input raster layer an a value, this algorithm generates a new layer with the same extent and cellsize as the input one, and all cells with the specified value. + Given an input raster layer an a value, this algorithm generates a new layer with the same extent and cell size as the input one, and all cells with the specified value. qgis:creategridlines: This algorithm creates a line vector layer with a grid covering a given extent. @@ -114,6 +114,9 @@ qgis:createpointsalonglines: > Start and end points can be defined, so the first and last point do not fall on the line first and last node. Start and end points are defined as distances, mesaureed from the first and last nodes of the lines, in the units of the projection used by the lines layer. +qgis:createspatialindex: > + Creates an index to speed up access to the features in a layer based on their spatial location. Support for spatial index creation is dependent on the layer's data provider. + qgis:delaunaytriangulation: > This algorithm creates a polygon layer with the delaunay triangulation corresponding to a points layer. @@ -190,9 +193,9 @@ qgis:extractnodes: > qgis:extractspecificnodes: > This algorithm takes a line or polygon layer and generates a point layer with points representing specific nodes in the input lines or polygons. For instance, this algorithm can be used to extract the first or last nodes in the geometry. The attributes associated to each point are the same ones associated to the line or polygon that the point belongs to. - The node indices parameter accepts a comma separated string specifying the indices of the nodes to extract. The first node corresponds to an index of 0, the second node has an index of 1, etc. Negative indices can be used to find nodes at the end of the geometry, eg an index of -1 corresponds to the last node, -2 corresponds to the second last node, etc. + The node indices parameter accepts a comma separated string specifying the indices of the nodes to extract. The first node corresponds to an index of 0, the second node has an index of 1, etc. Negative indices can be used to find nodes at the end of the geometry, e.g., an index of -1 corresponds to the last node, -2 corresponds to the second last node, etc. - Additional fields are added to the nodes indicating the specific node position (eg 0, -1, etc), the original node index, distance along the original geometry and bisector angle of node for the original geometry. + Additional fields are added to the nodes indicating the specific node position (e.g., 0, -1, etc), the original node index, distance along the original geometry and bisector angle of node for the original geometry. qgis:fieldcalculator: > This algorithm computes a new vector layer with the same features of the input layer, but with an additional attribute. The values of this new attribute are computed from each feature using a mathematical formula, based on te properties and attributes of the feature. @@ -501,7 +504,7 @@ qgis:smoothgeometry: > The offset parameter controls how "tightly" the smoothed geometries follow the original geometries. Smaller values results in a tighter fit, and larger values will create a looser fit. - The maximum angle parameter can be used to prevent smoothing of nodes with large angles. Any node where the angle of the segments to either side is larger then this will not be smoothed. Eg setting the maximum angle to 90 degrees or lower would preserve right angles in the geometry. + The maximum angle parameter can be used to prevent smoothing of nodes with large angles. Any node where the angle of the segments to either side is larger then this will not be smoothed. For example, setting the maximum angle to 90 degrees or lower would preserve right angles in the geometry. qgis:snapgeometriestolayer: > This algorithm snaps the geometries in a layer to the geometries in another layer. A tolerance is specified in layer units to control how close vertices need to be to the reference layer geometries before they are snapped. Snapping occurs to both vertices and edges, but snapping to a vertex is preferred. Vertices will be inserted or removed as required to make the geometries match the reference geometries. @@ -537,6 +540,11 @@ qgis:texttofloat: > qgis:translate: > This algorithm moves the geometries within a layer, by offsetting them with a specified x and y displacement. +qgis:truncatetable: > + This algorithm truncates a layer, by deleting all features from within the layer. + + Warning - this algorithm modifies the layer in place, and deleted features cannot be restored! + qgis:union: > This algorithm creates a layer containing all the features from both input layers. In the case of polygon layers, separate features are created for overlapping and non-overlapping features. The attribute table of the union layer contains attribute values from the respective input layer for non-overlapping features, and attribute values from both input layers for overlapping features. @@ -568,9 +576,9 @@ qgis:rastercalculator: > - sin(), cos(), tan(), atan2(), ln(), log10() - The extent and cellsize can be defined by the user. If the extent is not specified, the minimum extent that covers the input layers will be used. If the cellsize is not specified, the minimum cellsize of all input layers will be used. + The extent and cellsize can be defined by the user. If the extent is not specified, the minimum extent that covers the input layers will be used. If the cell size is not specified, the minimum cell size of all input layers will be used. - The cellsize is assumed to be the same in both X and Y axes. + The cell size is assumed to be the same in both X and Y axes. Layers are refered by their name as displayed in the layer list and the number of the band to use (based on 1), using the pattern 'layer_name@band number'. For instance, the first band from a layer named DEM will be referred as DEM@1. diff --git a/python/plugins/processing/algs/help/saga.yaml b/python/plugins/processing/algs/help/saga.yaml index 8068ccbb149..182c7893ffa 100644 --- a/python/plugins/processing/algs/help/saga.yaml +++ b/python/plugins/processing/algs/help/saga.yaml @@ -3,7 +3,7 @@ saga:rastercalculator: > It requires a base layer, and a set of additional layers. The base layer is identified as "a" in the formula, while the additional layers are identified as "b, c, d...", using the order in which they appear in the multiple selection dialog. - The resulting layer has the extent and cellsize of the main layer. + The resulting layer has the extent and cell size of the main layer. The following operators and functions are available. diff --git a/python/plugins/processing/algs/lidar/fusion/CanopyModel.py b/python/plugins/processing/algs/lidar/fusion/CanopyModel.py index 7b7982158e8..5d21ceef4fa 100644 --- a/python/plugins/processing/algs/lidar/fusion/CanopyModel.py +++ b/python/plugins/processing/algs/lidar/fusion/CanopyModel.py @@ -62,7 +62,7 @@ class CanopyModel(FusionAlgorithm): self.addParameter(ParameterFile( self.INPUT, self.tr('Input LAS layer'))) self.addParameter(ParameterNumber( - self.CELLSIZE, self.tr('Cellsize'), 0, None, 10.0)) + self.CELLSIZE, self.tr('Cell Size'), 0, None, 10.0)) self.addParameter(ParameterSelection( self.XYUNITS, self.tr('XY Units'), self.UNITS)) self.addParameter(ParameterSelection( diff --git a/python/plugins/processing/algs/lidar/fusion/Cover.py b/python/plugins/processing/algs/lidar/fusion/Cover.py index 11113e1e02c..c0c5ca0d2be 100644 --- a/python/plugins/processing/algs/lidar/fusion/Cover.py +++ b/python/plugins/processing/algs/lidar/fusion/Cover.py @@ -57,7 +57,7 @@ class Cover(FusionAlgorithm): self.addParameter(ParameterFile( self.GROUND, self.tr('Input ground DTM layer'))) self.addParameter(ParameterNumber( - self.CELLSIZE, self.tr('Cellsize'), 0, None, 10.0)) + self.CELLSIZE, self.tr('Cell Size'), 0, None, 10.0)) self.addParameter(ParameterNumber( self.HEIGHTBREAK, self.tr('Heightbreak'), 0, None, 10.0)) self.addParameter(ParameterSelection( diff --git a/python/plugins/processing/algs/lidar/fusion/GridMetrics.py b/python/plugins/processing/algs/lidar/fusion/GridMetrics.py index adc69e7b389..3917e21a50b 100644 --- a/python/plugins/processing/algs/lidar/fusion/GridMetrics.py +++ b/python/plugins/processing/algs/lidar/fusion/GridMetrics.py @@ -65,7 +65,7 @@ class GridMetrics(FusionAlgorithm): self.addParameter(ParameterNumber( self.HEIGHT, self.tr('Height break'))) self.addParameter(ParameterNumber( - self.CELLSIZE, self.tr('Cellsize'))) + self.CELLSIZE, self.tr('Cell Size'))) self.addOutput(OutputFile( self.OUTPUT_CSV_ELEVATION, self.tr('Output table with grid metrics'))) diff --git a/python/plugins/processing/algs/lidar/fusion/GridSurfaceCreate.py b/python/plugins/processing/algs/lidar/fusion/GridSurfaceCreate.py index 509346efc03..d93da5ab915 100644 --- a/python/plugins/processing/algs/lidar/fusion/GridSurfaceCreate.py +++ b/python/plugins/processing/algs/lidar/fusion/GridSurfaceCreate.py @@ -63,7 +63,7 @@ class GridSurfaceCreate(FusionAlgorithm): self.addParameter(ParameterFile( self.INPUT, self.tr('Input LAS layer'))) self.addParameter(ParameterNumber( - self.CELLSIZE, self.tr('Cellsize'), 0, None, 10.0)) + self.CELLSIZE, self.tr('Cell Size'), 0, None, 10.0)) self.addParameter(ParameterSelection( self.XYUNITS, self.tr('XY Units'), self.UNITS)) self.addParameter(ParameterSelection( diff --git a/python/plugins/processing/algs/lidar/fusion/GroundFilter.py b/python/plugins/processing/algs/lidar/fusion/GroundFilter.py index f89e8c17ad8..29d3643de63 100644 --- a/python/plugins/processing/algs/lidar/fusion/GroundFilter.py +++ b/python/plugins/processing/algs/lidar/fusion/GroundFilter.py @@ -50,7 +50,7 @@ class GroundFilter(FusionAlgorithm): self.addParameter(ParameterFile( self.INPUT, self.tr('Input LAS layer'))) self.addParameter(ParameterNumber(self.CELLSIZE, - self.tr('Cellsize for intermediate surfaces'), 0, None, 10)) + self.tr('Cell size for intermediate surfaces'), 0, None, 10)) self.addOutput(OutputFile( self.OUTPUT, self.tr('Output ground LAS file'))) self.addParameter(ParameterBoolean( diff --git a/python/plugins/processing/algs/lidar/fusion/TinSurfaceCreate.py b/python/plugins/processing/algs/lidar/fusion/TinSurfaceCreate.py index 1732496f42b..68ba8df055d 100644 --- a/python/plugins/processing/algs/lidar/fusion/TinSurfaceCreate.py +++ b/python/plugins/processing/algs/lidar/fusion/TinSurfaceCreate.py @@ -54,7 +54,7 @@ class TinSurfaceCreate(FusionAlgorithm): self.addParameter(ParameterFile( self.INPUT, self.tr('Input LAS layer'))) self.addParameter(ParameterNumber(self.CELLSIZE, - self.tr('Cellsize'), 0, None, 10.0)) + self.tr('Cell Size'), 0, None, 10.0)) self.addParameter(ParameterSelection(self.XYUNITS, self.tr('XY Units'), self.UNITS)) self.addParameter(ParameterSelection(self.ZUNITS, diff --git a/python/plugins/processing/algs/otb/OTBAlgorithmProvider.py b/python/plugins/processing/algs/otb/OTBAlgorithmProvider.py index 5b33250fbbd..68e9073b783 100644 --- a/python/plugins/processing/algs/otb/OTBAlgorithmProvider.py +++ b/python/plugins/processing/algs/otb/OTBAlgorithmProvider.py @@ -48,7 +48,8 @@ class OTBAlgorithmProvider(AlgorithmProvider): self.activate = True def getDescription(self): - return self.tr("Orfeo Toolbox (Image analysis)") + version = OTBUtils.getInstalledVersion() + return "Orfeo ToolBox ({})".format(version) if version is not None else "Orfeo ToolBox" def getName(self): return "otb" diff --git a/python/plugins/processing/algs/qgis/Buffer.py b/python/plugins/processing/algs/qgis/Buffer.py index fedc130555c..3efc696c181 100644 --- a/python/plugins/processing/algs/qgis/Buffer.py +++ b/python/plugins/processing/algs/qgis/Buffer.py @@ -45,7 +45,6 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, # With dissolve if dissolve: - first = True buffered_geometries = [] for inFeat in features: attrs = inFeat.attributes() @@ -55,12 +54,7 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, value = distance inGeom = inFeat.geometry() - if not inGeom: - ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, 'Feature {} has empty geometry. Skipping...'.format(inFeat.id())) - continue - if not inGeom.isGeosValid(): - ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, 'Feature {} has invalid geometry. Skipping...'.format(inFeat.id())) - continue + buffered_geometries.append(inGeom.buffer(float(value), segments, endCapStyle, joinStyle, mitreLimit)) current += 1 @@ -80,14 +74,8 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, value = distance inGeom = inFeat.geometry() outFeat = QgsFeature() - if inGeom.isEmpty() or inGeom.isGeosEmpty(): - pass - elif not inGeom.isGeosValid(): - ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, 'Feature {} has invalid geometry. Skipping...'.format(inFeat.id())) - continue - else: - outGeom = inGeom.buffer(float(value), segments, endCapStyle, joinStyle, mitreLimit) - outFeat.setGeometry(outGeom) + outGeom = inGeom.buffer(float(value), segments, endCapStyle, joinStyle, mitreLimit) + outFeat.setGeometry(outGeom) outFeat.setAttributes(attrs) writer.addFeature(outFeat) current += 1 diff --git a/python/plugins/processing/algs/qgis/Clip.py b/python/plugins/processing/algs/qgis/Clip.py index 0c9d17ad80b..99be2a4954f 100644 --- a/python/plugins/processing/algs/qgis/Clip.py +++ b/python/plugins/processing/algs/qgis/Clip.py @@ -119,16 +119,7 @@ class Clip(GeoAlgorithm): if new_geom.wkbType() == QgsWkbTypes.Unknown or QgsWkbTypes.flatType(new_geom.geometry().wkbType()) == QgsWkbTypes.GeometryCollection: int_com = in_feat.geometry().combine(new_geom) int_sym = in_feat.geometry().symDifference(new_geom) - if not int_com or not int_sym: - ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, - self.tr('GEOS geoprocessing error: One or more ' - 'input features have invalid geometry.')) - else: - new_geom = int_com.difference(int_sym) - if new_geom.isGeosEmpty() or not new_geom.isGeosValid(): - ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, - self.tr('GEOS geoprocessing error: One or more ' - 'input features have invalid geometry.')) + new_geom = int_com.difference(int_sym) else: # clip geometry totally contains feature geometry, so no need to perform intersection new_geom = in_feat.geometry() diff --git a/python/plugins/processing/algs/qgis/CreateAttributeIndex.py b/python/plugins/processing/algs/qgis/CreateAttributeIndex.py index 817820358e0..ead96c41595 100644 --- a/python/plugins/processing/algs/qgis/CreateAttributeIndex.py +++ b/python/plugins/processing/algs/qgis/CreateAttributeIndex.py @@ -28,7 +28,7 @@ __revision__ = '$Format:%H$' from qgis.core import QgsVectorDataProvider, QgsFields from processing.core.GeoAlgorithm import GeoAlgorithm -from processing.core.parameters import ParameterVector +from processing.core.parameters import ParameterTable from processing.core.parameters import ParameterTableField from processing.core.outputs import OutputVector @@ -45,8 +45,8 @@ class CreateAttributeIndex(GeoAlgorithm): self.name, self.i18n_name = self.trAlgorithm('Create attribute index') self.group, self.i18n_group = self.trAlgorithm('Vector general tools') - self.addParameter(ParameterVector(self.INPUT, - self.tr('Input Layer'))) + self.addParameter(ParameterTable(self.INPUT, + self.tr('Input Layer'))) self.addParameter(ParameterTableField(self.FIELD, self.tr('Attribute to index'), self.INPUT)) self.addOutput(OutputVector(self.OUTPUT, diff --git a/python/plugins/processing/algs/qgis/Difference.py b/python/plugins/processing/algs/qgis/Difference.py index 9045757b41e..6c5ef67f707 100644 --- a/python/plugins/processing/algs/qgis/Difference.py +++ b/python/plugins/processing/algs/qgis/Difference.py @@ -58,8 +58,6 @@ class Difference(GeoAlgorithm): self.tr('Input layer'))) self.addParameter(ParameterVector(Difference.OVERLAY, self.tr('Difference layer'))) - self.addParameter(ParameterBoolean(Difference.IGNORE_INVALID, - self.tr('Ignore invalid input features'), False, True)) self.addOutput(OutputVector(Difference.OUTPUT, self.tr('Difference'))) def processAlgorithm(self, progress): @@ -67,7 +65,6 @@ class Difference(GeoAlgorithm): self.getParameterValue(Difference.INPUT)) layerB = dataobjects.getObjectFromUri( self.getParameterValue(Difference.OVERLAY)) - ignoreInvalid = self.getParameterValue(Difference.IGNORE_INVALID) geomType = QgsWkbTypes.multiType(layerA.wkbType()) writer = self.getOutputFromName( @@ -80,7 +77,6 @@ class Difference(GeoAlgorithm): selectionA = vector.features(layerA) total = 100.0 / len(selectionA) for current, inFeatA in enumerate(selectionA): - add = True geom = inFeatA.geometry() diff_geom = QgsGeometry(geom) attrs = inFeatA.attributes() @@ -91,27 +87,15 @@ class Difference(GeoAlgorithm): tmpGeom = inFeatB.geometry() if diff_geom.intersects(tmpGeom): diff_geom = QgsGeometry(diff_geom.difference(tmpGeom)) - if diff_geom.isGeosEmpty(): - ProcessingLog.addToLog(ProcessingLog.LOG_INFO, - self.tr('Feature with NULL geometry found.')) - if not diff_geom.isGeosValid(): - if ignoreInvalid: - ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, - self.tr('GEOS geoprocessing error: One or more input features have invalid geometry.')) - add = False - else: - raise GeoAlgorithmExecutionException(self.tr('Features with invalid geometries found. Please fix these errors or specify the "Ignore invalid input features" flag')) - break - if add: - try: - outFeat.setGeometry(diff_geom) - outFeat.setAttributes(attrs) - writer.addFeature(outFeat) - except: - ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, - self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.')) - continue + try: + outFeat.setGeometry(diff_geom) + outFeat.setAttributes(attrs) + writer.addFeature(outFeat) + except: + ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, + self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.')) + continue progress.setPercentage(int(current * total)) diff --git a/python/plugins/processing/algs/qgis/Eliminate.py b/python/plugins/processing/algs/qgis/Eliminate.py index 144f5c59e2c..6b3766eb2c1 100644 --- a/python/plugins/processing/algs/qgis/Eliminate.py +++ b/python/plugins/processing/algs/qgis/Eliminate.py @@ -133,7 +133,7 @@ class Eliminate(GeoAlgorithm): y = str(comparisonvalue) except ValueError: selectionError = True - msg = self.tr('Cannot convert "%s" to unicode' % str(comparisonvalue)) + msg = self.tr('Cannot convert "%s" to Unicode' % str(comparisonvalue)) elif selectType == QVariant.Date: # date dateAndFormat = comparisonvalue.split(' ') diff --git a/python/plugins/processing/algs/qgis/FieldsCalculator.py b/python/plugins/processing/algs/qgis/FieldsCalculator.py index d97df4332d9..d04e65c6029 100644 --- a/python/plugins/processing/algs/qgis/FieldsCalculator.py +++ b/python/plugins/processing/algs/qgis/FieldsCalculator.py @@ -108,10 +108,7 @@ class FieldsCalculator(GeoAlgorithm): exp.setDistanceUnits(QgsProject.instance().distanceUnits()) exp.setAreaUnits(QgsProject.instance().areaUnits()) - exp_context = QgsExpressionContext() - exp_context.appendScope(QgsExpressionContextUtils.globalScope()) - exp_context.appendScope(QgsExpressionContextUtils.projectScope()) - exp_context.appendScope(QgsExpressionContextUtils.layerScope(layer)) + exp_context = QgsExpressionContext(QgsExpressionContextUtils.globalProjectLayerScopes(layer)) if not exp.prepare(exp_context): raise GeoAlgorithmExecutionException( diff --git a/python/plugins/processing/algs/qgis/GeometryByExpression.py b/python/plugins/processing/algs/qgis/GeometryByExpression.py index be927c09e08..c8dc36d4d25 100644 --- a/python/plugins/processing/algs/qgis/GeometryByExpression.py +++ b/python/plugins/processing/algs/qgis/GeometryByExpression.py @@ -95,10 +95,7 @@ class GeometryByExpression(GeoAlgorithm): if expression.hasParserError(): raise GeoAlgorithmExecutionException(expression.parserErrorString()) - exp_context = QgsExpressionContext() - exp_context.appendScope(QgsExpressionContextUtils.globalScope()) - exp_context.appendScope(QgsExpressionContextUtils.projectScope()) - exp_context.appendScope(QgsExpressionContextUtils.layerScope(layer)) + exp_context = QgsExpressionContext(QgsExpressionContextUtils.globalProjectLayerScopes(layer)) if not expression.prepare(exp_context): raise GeoAlgorithmExecutionException( diff --git a/python/plugins/processing/algs/qgis/Heatmap.py b/python/plugins/processing/algs/qgis/Heatmap.py index 1e8faee8f2c..5807c039941 100644 --- a/python/plugins/processing/algs/qgis/Heatmap.py +++ b/python/plugins/processing/algs/qgis/Heatmap.py @@ -32,6 +32,7 @@ from qgis.PyQt.QtGui import QIcon from qgis.core import QgsFeatureRequest from qgis.analysis import QgsKernelDensityEstimation +from processing.core.ProcessingLog import ProcessingLog from processing.core.GeoAlgorithm import GeoAlgorithm from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException from processing.core.parameters import ParameterVector @@ -166,8 +167,8 @@ class Heatmap(GeoAlgorithm): total = 100.0 / len(features) for current, f in enumerate(features): if kde.addFeature(f) != QgsKernelDensityEstimation.Success: - raise GeoAlgorithmExecutionException( - self.tr('Error adding feature to heatmap')) + ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, + self.tr('Error adding feature with ID {} to heatmap').format(f.id())) progress.setPercentage(int(current * total)) diff --git a/python/plugins/processing/algs/qgis/IdwInterpolationZValue.py b/python/plugins/processing/algs/qgis/IdwInterpolation.py similarity index 54% rename from python/plugins/processing/algs/qgis/IdwInterpolationZValue.py rename to python/plugins/processing/algs/qgis/IdwInterpolation.py index fd9ee291d44..f97a29e625f 100644 --- a/python/plugins/processing/algs/qgis/IdwInterpolationZValue.py +++ b/python/plugins/processing/algs/qgis/IdwInterpolation.py @@ -2,7 +2,7 @@ """ *************************************************************************** - IdwInterpolationZValue.py + IdwInterpolation.py --------------------- Date : October 2016 Copyright : (C) 2016 by Alexander Bruy @@ -29,7 +29,7 @@ import os from qgis.PyQt.QtGui import QIcon -from qgis.core import QgsRectangle, QgsWkbTypes +from qgis.core import QgsRectangle from qgis.analysis import (QgsInterpolator, QgsIDWInterpolator, QgsGridFileWriter @@ -37,20 +37,20 @@ from qgis.analysis import (QgsInterpolator, from processing.core.GeoAlgorithm import GeoAlgorithm from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException -from processing.core.parameters import ParameterVector -from processing.core.parameters import ParameterSelection -from processing.core.parameters import ParameterNumber -from processing.core.parameters import ParameterExtent +from processing.core.parameters import (Parameter, + ParameterNumber, + ParameterExtent, + _splitParameterOptions + ) from processing.core.outputs import OutputRaster from processing.tools import dataobjects pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0] -class IdwInterpolationZValue(GeoAlgorithm): +class IdwInterpolation(GeoAlgorithm): - INPUT_LAYER = 'INPUT_LAYER' - LAYER_TYPE = 'LAYER_TYPE' + INTERPOLATION_DATA = 'INTERPOLATION_DATA' DISTANCE_COEFFICIENT = 'DISTANCE_COEFFICIENT' COLUMNS = 'COLUMNS' ROWS = 'ROWS' @@ -63,20 +63,61 @@ class IdwInterpolationZValue(GeoAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'interpolation.png')) def defineCharacteristics(self): - self.name, self.i18n_name = self.trAlgorithm('IDW interpolation (using Z-values)') + self.name, self.i18n_name = self.trAlgorithm('IDW interpolation') self.group, self.i18n_group = self.trAlgorithm('Interpolation') - self.TYPES = [self.tr('Points'), - self.tr('Structure lines'), - self.tr('Break lines') - ] + class ParameterInterpolationData(Parameter): + default_metadata = { + 'widget_wrapper': 'processing.algs.qgis.ui.InterpolationDataWidget.InterpolationDataWidgetWrapper' + } - self.addParameter(ParameterVector(self.INPUT_LAYER, - self.tr('Vector layer'))) - self.addParameter(ParameterSelection(self.LAYER_TYPE, - self.tr('Type'), - self.TYPES, - 0)) + def __init__(self, name='', description=''): + Parameter.__init__(self, name, description) + + def setValue(self, value): + if value is None: + if not self.optional: + return False + self.value = None + return True + + if value == '': + if not self.optional: + return False + + if isinstance(value, str): + self.value = value if value != '' else None + else: + self.value = ParameterInterpolationData.dataToString(value) + return True + + def getValueAsCommandLineParameter(self): + return '"{}"'.format(self.value) + + def getAsScriptCode(self): + param_type = '' + param_type += 'interpolation data ' + return '##' + self.name + '=' + param_type + + @classmethod + def fromScriptCode(self, line): + isOptional, name, definition = _splitParameterOptions(line) + descName = _createDescriptiveName(name) + parent = definition.lower().strip()[len('interpolation data') + 1:] + return ParameterInterpolationData(name, description, parent) + + @staticmethod + def dataToString(data): + s = '' + for d in data: + s += '{}, {}, {:d}, {:d};'.format(c[0], + c[1], + c[2], + c[3]) + return s[:-1] + + self.addParameter(ParameterInterpolationData(self.INTERPOLATION_DATA, + self.tr('Input layer(s)'))) self.addParameter(ParameterNumber(self.DISTANCE_COEFFICIENT, self.tr('Distance coefficient P'), 0.0, 99.99, 2.0)) @@ -87,10 +128,10 @@ class IdwInterpolationZValue(GeoAlgorithm): self.tr('Number of rows'), 0, 10000000, 300)) self.addParameter(ParameterNumber(self.CELLSIZE_X, - self.tr('Cellsize X'), + self.tr('Cell Size X'), 0.0, 999999.000000, 0.0)) self.addParameter(ParameterNumber(self.CELLSIZE_Y, - self.tr('Cellsize Y'), + self.tr('Cell Size Y'), 0.0, 999999.000000, 0.0)) self.addParameter(ParameterExtent(self.EXTENT, self.tr('Extent'))) @@ -98,9 +139,7 @@ class IdwInterpolationZValue(GeoAlgorithm): self.tr('Interpolated'))) def processAlgorithm(self, progress): - layer = dataobjects.getObjectFromUri( - self.getParameterValue(self.INPUT_LAYER)) - layerType = self.getParameterValue(self.LAYER_TYPE) + interpolationData = self.getParameterValue(self.INTERPOLATION_DATA) coefficient = self.getParameterValue(self.DISTANCE_COEFFICIENT) columns = self.getParameterValue(self.COLUMNS) rows = self.getParameterValue(self.ROWS) @@ -109,9 +148,9 @@ class IdwInterpolationZValue(GeoAlgorithm): extent = self.getParameterValue(self.EXTENT).split(',') output = self.getOutputValue(self.OUTPUT_LAYER) - if not QgsWkbTypes.hasZ(layer.wkbType()): + if interpolationData is None: raise GeoAlgorithmExecutionException( - self.tr('Geometries in input layer does not have Z coordinates.')) + self.tr('You need to specify at least one input layer.')) xMin = float(extent[0]) xMax = float(extent[1]) @@ -119,19 +158,22 @@ class IdwInterpolationZValue(GeoAlgorithm): yMax = float(extent[3]) bbox = QgsRectangle(xMin, yMin, xMax, yMax) - layerData = QgsInterpolator.LayerData() - layerData.vectorLayer = layer - layerData.zCoordInterpolation = True - layerData.interpolationAttribute = -1 + layerData = [] + for row in interpolationData.split(';'): + v = row.split(',') + data = QgsInterpolator.LayerData() + data.vectorLayer = dataobjects.getObjectFromUri(v[0]) + data.zCoordInterpolation = bool(v[1]) + data.interpolationAttribute = int(v[2]) + if v[3] == '0': + data.mInputType = QgsInterpolator.POINTS + elif v[3] == '1': + data.mInputType = QgsInterpolator.STRUCTURE_LINES + else: + data.mInputType = QgsInterpolator.BREAK_LINES + layerData.append(data) - if layerType == 0: - layerData.mInputType = QgsInterpolator.POINTS - elif layerType == 1: - layerData.mInputType = QgsInterpolator.STRUCTURE_LINES - else: - layerData.mInputType = QgsInterpolator.BREAK_LINES - - interpolator = QgsIDWInterpolator([layerData]) + interpolator = QgsIDWInterpolator(layerData) interpolator.setDistanceCoefficient(coefficient) writer = QgsGridFileWriter(interpolator, diff --git a/python/plugins/processing/algs/qgis/IdwInterpolationAttribute.py b/python/plugins/processing/algs/qgis/IdwInterpolationAttribute.py deleted file mode 100644 index 64a9fc72e72..00000000000 --- a/python/plugins/processing/algs/qgis/IdwInterpolationAttribute.py +++ /dev/null @@ -1,147 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - IdwInterpolationAttribute.py - --------------------- - Date : October 2016 - Copyright : (C) 2016 by Alexander Bruy - Email : alexander dot bruy at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" - -__author__ = 'Alexander Bruy' -__date__ = 'October 2016' -__copyright__ = '(C) 2016, Alexander Bruy' - -# This will get replaced with a git SHA1 when you do a git archive - -__revision__ = '$Format:%H$' - -import os - -from qgis.PyQt.QtGui import QIcon - -from qgis.core import QgsRectangle -from qgis.analysis import (QgsInterpolator, - QgsIDWInterpolator, - QgsGridFileWriter - ) - -from processing.core.GeoAlgorithm import GeoAlgorithm -from processing.core.parameters import ParameterVector -from processing.core.parameters import ParameterTableField -from processing.core.parameters import ParameterSelection -from processing.core.parameters import ParameterNumber -from processing.core.parameters import ParameterExtent -from processing.core.outputs import OutputRaster -from processing.tools import dataobjects - -pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0] - - -class IdwInterpolationAttribute(GeoAlgorithm): - - INPUT_LAYER = 'INPUT_LAYER' - ATTRIBUTE = 'ATTRIBUTE' - LAYER_TYPE = 'LAYER_TYPE' - DISTANCE_COEFFICIENT = 'DISTANCE_COEFFICIENT' - COLUMNS = 'COLUMNS' - ROWS = 'ROWS' - CELLSIZE_X = 'CELLSIZE_X' - CELLSIZE_Y = 'CELLSIZE_Y' - EXTENT = 'EXTENT' - OUTPUT_LAYER = 'OUTPUT_LAYER' - - def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'interpolation.png')) - - def defineCharacteristics(self): - self.name, self.i18n_name = self.trAlgorithm('IDW interpolation (using attribute)') - self.group, self.i18n_group = self.trAlgorithm('Interpolation') - - self.TYPES = [self.tr('Points'), - self.tr('Structure lines'), - self.tr('Break lines') - ] - - self.addParameter(ParameterVector(self.INPUT_LAYER, - self.tr('Vector layer'))) - self.addParameter(ParameterTableField(self.ATTRIBUTE, - self.tr('Interpolation attribute'), - self.INPUT_LAYER, - ParameterTableField.DATA_TYPE_NUMBER)) - self.addParameter(ParameterSelection(self.LAYER_TYPE, - self.tr('Type'), - self.TYPES, - 0)) - self.addParameter(ParameterNumber(self.DISTANCE_COEFFICIENT, - self.tr('Distance coefficient P'), - 0.0, 99.99, 2.0)) - self.addParameter(ParameterNumber(self.COLUMNS, - self.tr('Number of columns'), - 0, 10000000, 300)) - self.addParameter(ParameterNumber(self.ROWS, - self.tr('Number of rows'), - 0, 10000000, 300)) - self.addParameter(ParameterNumber(self.CELLSIZE_X, - self.tr('Cellsize X'), - 0.0, 999999.000000, 0.0)) - self.addParameter(ParameterNumber(self.CELLSIZE_Y, - self.tr('Cellsize Y'), - 0.0, 999999.000000, 0.0)) - self.addParameter(ParameterExtent(self.EXTENT, - self.tr('Extent'))) - self.addOutput(OutputRaster(self.OUTPUT_LAYER, - self.tr('Interpolated'))) - - def processAlgorithm(self, progress): - layer = dataobjects.getObjectFromUri( - self.getParameterValue(self.INPUT_LAYER)) - fieldName = self.getParameterValue(self.ATTRIBUTE) - layerType = self.getParameterValue(self.LAYER_TYPE) - coefficient = self.getParameterValue(self.DISTANCE_COEFFICIENT) - columns = self.getParameterValue(self.COLUMNS) - rows = self.getParameterValue(self.ROWS) - cellsizeX = self.getParameterValue(self.CELLSIZE_X) - cellsizeY = self.getParameterValue(self.CELLSIZE_Y) - extent = self.getParameterValue(self.EXTENT).split(',') - output = self.getOutputValue(self.OUTPUT_LAYER) - - xMin = float(extent[0]) - xMax = float(extent[1]) - yMin = float(extent[2]) - yMax = float(extent[3]) - bbox = QgsRectangle(xMin, yMin, xMax, yMax) - - layerData = QgsInterpolator.LayerData() - layerData.vectorLayer = layer - layerData.zCoordInterpolation = False - layerData.interpolationAttribute = layer.dataProvider().fieldNameIndex(fieldName) - - if layerType == 0: - layerData.mInputType = QgsInterpolator.POINTS - elif layerType == 1: - layerData.mInputType = QgsInterpolator.STRUCTURE_LINES - else: - layerData.mInputType = QgsInterpolator.BREAK_LINES - - interpolator = QgsIDWInterpolator([layerData]) - interpolator.setDistanceCoefficient(coefficient) - - writer = QgsGridFileWriter(interpolator, - output, - bbox, - columns, - rows, - cellsizeX, - cellsizeY) - - writer.writeFile() diff --git a/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py b/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py index 828e366e584..9e5cbd4a023 100644 --- a/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py +++ b/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py @@ -167,10 +167,8 @@ from .Slope import Slope from .Ruggedness import Ruggedness from .Hillshade import Hillshade from .Relief import Relief -from .IdwInterpolationZValue import IdwInterpolationZValue -from .IdwInterpolationAttribute import IdwInterpolationAttribute -from .TinInterpolationZValue import TinInterpolationZValue -from .TinInterpolationAttribute import TinInterpolationAttribute +from .IdwInterpolation import IdwInterpolation +from .TinInterpolation import TinInterpolation from .ZonalStatisticsQgis import ZonalStatisticsQgis from .RemoveNullGeometry import RemoveNullGeometry from .ExtendLines import ExtendLines @@ -189,6 +187,7 @@ from .ShortestPathPointToLayer import ShortestPathPointToLayer from .ShortestPathLayerToPoint import ShortestPathLayerToPoint from .ServiceAreaFromPoint import ServiceAreaFromPoint from .ServiceAreaFromLayer import ServiceAreaFromLayer +from .TruncateTable import TruncateTable pluginPath = os.path.normpath(os.path.join( os.path.split(os.path.dirname(__file__))[0], os.pardir)) @@ -248,8 +247,7 @@ class QGISAlgorithmProvider(AlgorithmProvider): SingleSidedBuffer(), PointsAlongGeometry(), Aspect(), Slope(), Ruggedness(), Hillshade(), Relief(), ZonalStatisticsQgis(), - IdwInterpolationZValue(), IdwInterpolationAttribute(), - TinInterpolationZValue(), TinInterpolationAttribute(), + IdwInterpolation(), TinInterpolation(), RemoveNullGeometry(), ExtractByExpression(), ExtendLines(), ExtractSpecificNodes(), GeometryByExpression(), SnapGeometriesToLayer(), @@ -258,7 +256,7 @@ class QGISAlgorithmProvider(AlgorithmProvider): RasterCalculator(), Heatmap(), Orthogonalize(), ShortestPathPointToPoint(), ShortestPathPointToLayer(), ShortestPathLayerToPoint(), ServiceAreaFromPoint(), - ServiceAreaFromLayer() + ServiceAreaFromLayer(), TruncateTable() ] if hasMatplotlib: @@ -303,7 +301,7 @@ class QGISAlgorithmProvider(AlgorithmProvider): return 'qgis' def getDescription(self): - return self.tr('QGIS geoalgorithms') + return 'QGIS' def getIcon(self): return self._icon diff --git a/python/plugins/processing/algs/qgis/RasterCalculator.py b/python/plugins/processing/algs/qgis/RasterCalculator.py index 8eaf5bd328d..f8d27d9179f 100644 --- a/python/plugins/processing/algs/qgis/RasterCalculator.py +++ b/python/plugins/processing/algs/qgis/RasterCalculator.py @@ -81,7 +81,7 @@ class RasterCalculator(GeoAlgorithm): multiline=True, metadata={'widget_wrapper': ExpressionWidgetWrapper})) self.addParameter(ParameterNumber(self.CELLSIZE, - self.tr('Cellsize (use 0 or empty to set it automatically)'), + self.tr('Cell size (use 0 or empty to set it automatically)'), minValue=0.0, default=0.0, optional=True)) self.addParameter(ParameterExtent(self.EXTENT, self.tr('Output extent'), diff --git a/python/plugins/processing/algs/qgis/Relief.py b/python/plugins/processing/algs/qgis/Relief.py index 8eb64ac0fc9..3f8fec3c2e3 100644 --- a/python/plugins/processing/algs/qgis/Relief.py +++ b/python/plugins/processing/algs/qgis/Relief.py @@ -76,8 +76,8 @@ class Relief(GeoAlgorithm): return True if value == '': - if not self.optional: - return False + if not self.optional: + return False if isinstance(value, str): self.value = value if value != '' else None @@ -97,7 +97,7 @@ class Relief(GeoAlgorithm): def fromScriptCode(self, line): isOptional, name, definition = _splitParameterOptions(line) descName = _createDescriptiveName(name) - parent = definition.lower().strip()[len('relief colors') + 1:] + parent = definition.lower().strip()[len('relief colors') + 1:] return ParameterReliefColors(name, description, parent) @staticmethod @@ -117,7 +117,7 @@ class Relief(GeoAlgorithm): self.tr('Z factor'), 1.0, 999999.99, 1.0)) self.addParameter(ParameterBoolean(self.AUTO_COLORS, - self.tr('Generate relief classes automaticaly'), + self.tr('Generate relief classes automatically'), False)) self.addParameter(ParameterReliefColors(self.COLORS, self.tr('Relief colors'), @@ -145,7 +145,7 @@ class Relief(GeoAlgorithm): else: if colors is None: raise GeoAlgorithmExecutionException( - self.tr('Specify relief colors or activate "Generate relief classes automaticaly" option.')) + self.tr('Specify relief colors or activate "Generate relief classes automatically" option.')) reliefColors = [] for c in colors.split(';'): diff --git a/python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py b/python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py index cdd4e19e759..bb73ba89666 100644 --- a/python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py +++ b/python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py @@ -258,6 +258,11 @@ class ServiceAreaFromLayer(GeoAlgorithm): feat['start'] = origPoint writerPoints.addFeature(feat) + upperBoundary.append(startPoint) + lowerBoundary.append(startPoint) + geomUpper = QgsGeometry.fromMultiPoint(upperBoundary) + geomLower = QgsGeometry.fromMultiPoint(lowerBoundary) + geom = geomUpper.convexHull() feat.setGeometry(geom) feat['type'] = 'upper' diff --git a/python/plugins/processing/algs/qgis/ServiceAreaFromPoint.py b/python/plugins/processing/algs/qgis/ServiceAreaFromPoint.py index 197031a29c1..8471e725ca7 100644 --- a/python/plugins/processing/algs/qgis/ServiceAreaFromPoint.py +++ b/python/plugins/processing/algs/qgis/ServiceAreaFromPoint.py @@ -215,7 +215,7 @@ class ServiceAreaFromPoint(GeoAlgorithm): upperBoundary.append(graph.vertex(graph.edge(tree[i]).inVertex()).point()) lowerBoundary.append(graph.vertex(graph.edge(tree[i]).outVertex()).point()) - progress.setInfo(self.tr('Writting results...')) + progress.setInfo(self.tr('Writing results...')) fields = QgsFields() fields.append(QgsField('type', QVariant.String, '', 254, 0)) @@ -245,6 +245,11 @@ class ServiceAreaFromPoint(GeoAlgorithm): del writer + upperBoundary.append(startPoint) + lowerBoundary.append(startPoint) + geomUpper = QgsGeometry.fromMultiPoint(upperBoundary) + geomLower = QgsGeometry.fromMultiPoint(lowerBoundary) + writer = self.getOutputFromName( self.OUTPUT_POLYGON).getVectorWriter( fields, diff --git a/python/plugins/processing/algs/qgis/ShortestPathPointToPoint.py b/python/plugins/processing/algs/qgis/ShortestPathPointToPoint.py index 776285c8100..b3ff7154e93 100644 --- a/python/plugins/processing/algs/qgis/ShortestPathPointToPoint.py +++ b/python/plugins/processing/algs/qgis/ShortestPathPointToPoint.py @@ -232,7 +232,7 @@ class ShortestPathPointToPoint(GeoAlgorithm): self.setOutputValue(self.TRAVEL_COST, cost / multiplier) - progress.setInfo(self.tr('Writting results...')) + progress.setInfo(self.tr('Writing results...')) geom = QgsGeometry.fromPolyline(route) feat = QgsFeature() feat.setFields(fields) diff --git a/python/plugins/processing/algs/qgis/SpatialIndex.py b/python/plugins/processing/algs/qgis/SpatialIndex.py index 75cc74ef4e2..d517329ef63 100644 --- a/python/plugins/processing/algs/qgis/SpatialIndex.py +++ b/python/plugins/processing/algs/qgis/SpatialIndex.py @@ -62,7 +62,7 @@ class SpatialIndex(GeoAlgorithm): if provider.capabilities() & QgsVectorDataProvider.CreateSpatialIndex: if not provider.createSpatialIndex(): - progress.setInfo(self.tr('Can not create spatial index')) + progress.setInfo(self.tr('Could not create spatial index')) else: progress.setInfo(self.tr("Layer's data provider does not support " "spatial indexes")) diff --git a/python/plugins/processing/algs/qgis/SymmetricalDifference.py b/python/plugins/processing/algs/qgis/SymmetricalDifference.py index 098f7da0cca..23b5deb9bd0 100644 --- a/python/plugins/processing/algs/qgis/SymmetricalDifference.py +++ b/python/plugins/processing/algs/qgis/SymmetricalDifference.py @@ -83,7 +83,6 @@ class SymmetricalDifference(GeoAlgorithm): count = 0 for featA in featuresA: - add = True geom = featA.geometry() diffGeom = QgsGeometry(geom) attrs = featA.attributes() @@ -93,23 +92,15 @@ class SymmetricalDifference(GeoAlgorithm): tmpGeom = featB.geometry() if diffGeom.intersects(tmpGeom): diffGeom = QgsGeometry(diffGeom.difference(tmpGeom)) - if not diffGeom.isGeosValid(): - ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, - self.tr('GEOS geoprocessing error: One or ' - 'more input features have invalid ' - 'geometry.')) - add = False - break - if add: - try: - outFeat.setGeometry(diffGeom) - outFeat.setAttributes(attrs) - writer.addFeature(outFeat) - except: - ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, - self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.')) - continue + try: + outFeat.setGeometry(diffGeom) + outFeat.setAttributes(attrs) + writer.addFeature(outFeat) + except: + ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, + self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.')) + continue count += 1 progress.setPercentage(int(count * total)) @@ -117,7 +108,6 @@ class SymmetricalDifference(GeoAlgorithm): length = len(layerA.fields()) for featA in featuresB: - add = True geom = featA.geometry() diffGeom = QgsGeometry(geom) attrs = featA.attributes() @@ -128,23 +118,15 @@ class SymmetricalDifference(GeoAlgorithm): tmpGeom = featB.geometry() if diffGeom.intersects(tmpGeom): diffGeom = QgsGeometry(diffGeom.difference(tmpGeom)) - if not diffGeom.isGeosValid(): - ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, - self.tr('GEOS geoprocessing error: One or ' - 'more input features have invalid ' - 'geometry.')) - add = False - break - if add: - try: - outFeat.setGeometry(diffGeom) - outFeat.setAttributes(attrs) - writer.addFeature(outFeat) - except: - ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, - self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.')) - continue + try: + outFeat.setGeometry(diffGeom) + outFeat.setAttributes(attrs) + writer.addFeature(outFeat) + except: + ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, + self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.')) + continue count += 1 progress.setPercentage(int(count * total)) diff --git a/python/plugins/processing/algs/qgis/TinInterpolationZValue.py b/python/plugins/processing/algs/qgis/TinInterpolation.py similarity index 55% rename from python/plugins/processing/algs/qgis/TinInterpolationZValue.py rename to python/plugins/processing/algs/qgis/TinInterpolation.py index 332f6303f61..dce6eaca15c 100644 --- a/python/plugins/processing/algs/qgis/TinInterpolationZValue.py +++ b/python/plugins/processing/algs/qgis/TinInterpolation.py @@ -2,7 +2,7 @@ """ *************************************************************************** - TinInterpolationZValue.py + TinInterpolation.py --------------------- Date : October 2016 Copyright : (C) 2016 by Alexander Bruy @@ -29,28 +29,31 @@ import os from qgis.PyQt.QtGui import QIcon -from qgis.core import QgsRectangle, QgsWkbTypes +from qgis.core import QgsRectangle from qgis.analysis import (QgsInterpolator, QgsTINInterpolator, QgsGridFileWriter ) from processing.core.GeoAlgorithm import GeoAlgorithm -from processing.core.parameters import ParameterVector -from processing.core.parameters import ParameterSelection -from processing.core.parameters import ParameterNumber -from processing.core.parameters import ParameterExtent -from processing.core.outputs import OutputRaster -from processing.core.outputs import OutputVector +from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException +from processing.core.parameters import (Parameter, + ParameterNumber, + ParameterExtent, + ParameterSelection, + _splitParameterOptions + ) +from processing.core.outputs import (OutputRaster, + OutputVector + ) from processing.tools import dataobjects pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0] -class TinInterpolationZValue(GeoAlgorithm): +class TinInterpolation(GeoAlgorithm): - INPUT_LAYER = 'INPUT_LAYER' - LAYER_TYPE = 'LAYER_TYPE' + INTERPOLATION_DATA = 'INTERPOLATION_DATA' METHOD = 'METHOD' COLUMNS = 'COLUMNS' ROWS = 'ROWS' @@ -64,23 +67,65 @@ class TinInterpolationZValue(GeoAlgorithm): return QIcon(os.path.join(pluginPath, 'images', 'interpolation.png')) def defineCharacteristics(self): - self.name, self.i18n_name = self.trAlgorithm('TIN interpolation (using Z-values)') + self.name, self.i18n_name = self.trAlgorithm('TIN interpolation') self.group, self.i18n_group = self.trAlgorithm('Interpolation') - self.TYPES = [self.tr('Points'), - self.tr('Structure lines'), - self.tr('Break lines') - ] self.METHODS = [self.tr('Linear'), self.tr('Clough-Toucher (cubic)') ] - self.addParameter(ParameterVector(self.INPUT_LAYER, - self.tr('Vector layer'))) - self.addParameter(ParameterSelection(self.LAYER_TYPE, - self.tr('Type'), - self.TYPES, - 0)) + class ParameterInterpolationData(Parameter): + default_metadata = { + 'widget_wrapper': 'processing.algs.qgis.ui.InterpolationDataWidget.InterpolationDataWidgetWrapper' + } + + def __init__(self, name='', description=''): + Parameter.__init__(self, name, description) + + def setValue(self, value): + if value is None: + if not self.optional: + return False + self.value = None + return True + + if value == '': + if not self.optional: + return False + + if isinstance(value, str): + self.value = value if value != '' else None + else: + self.value = ParameterInterpolationData.dataToString(value) + return True + + def getValueAsCommandLineParameter(self): + return '"{}"'.format(self.value) + + def getAsScriptCode(self): + param_type = '' + param_type += 'interpolation data ' + return '##' + self.name + '=' + param_type + + @classmethod + def fromScriptCode(self, line): + isOptional, name, definition = _splitParameterOptions(line) + descName = _createDescriptiveName(name) + parent = definition.lower().strip()[len('interpolation data') + 1:] + return ParameterInterpolationData(name, description, parent) + + @staticmethod + def dataToString(data): + s = '' + for d in data: + s += '{}, {}, {:d}, {:d};'.format(c[0], + c[1], + c[2], + c[3]) + return s[:-1] + + self.addParameter(ParameterInterpolationData(self.INTERPOLATION_DATA, + self.tr('Input layer(s)'))) self.addParameter(ParameterSelection(self.METHOD, self.tr('Interpolation method'), self.METHODS, @@ -92,10 +137,10 @@ class TinInterpolationZValue(GeoAlgorithm): self.tr('Number of rows'), 0, 10000000, 300)) self.addParameter(ParameterNumber(self.CELLSIZE_X, - self.tr('Cellsize X'), + self.tr('Cell size X'), 0.0, 999999.000000, 0.0)) self.addParameter(ParameterNumber(self.CELLSIZE_Y, - self.tr('Cellsize Y'), + self.tr('Cell size Y'), 0.0, 999999.000000, 0.0)) self.addParameter(ParameterExtent(self.EXTENT, self.tr('Extent'))) @@ -106,9 +151,7 @@ class TinInterpolationZValue(GeoAlgorithm): )) # datatype=dataobjects.TYPE_VECTOR_LINE)) def processAlgorithm(self, progress): - layer = dataobjects.getObjectFromUri( - self.getParameterValue(self.INPUT_LAYER)) - layerType = self.getParameterValue(self.LAYER_TYPE) + interpolationData = self.getParameterValue(self.INTERPOLATION_DATA) method = self.getParameterValue(self.METHOD) columns = self.getParameterValue(self.COLUMNS) rows = self.getParameterValue(self.ROWS) @@ -118,9 +161,9 @@ class TinInterpolationZValue(GeoAlgorithm): output = self.getOutputValue(self.OUTPUT_LAYER) triangulation = self.getOutputValue(self.TRIANULATION_FILE) - if not QgsWkbTypes.hasZ(layer.wkbType()): + if interpolationData is None: raise GeoAlgorithmExecutionException( - self.tr('Geometries in input layer does not have Z coordinates.')) + self.tr('You need to specify at least one input layer.')) xMin = float(extent[0]) xMax = float(extent[1]) @@ -128,24 +171,27 @@ class TinInterpolationZValue(GeoAlgorithm): yMax = float(extent[3]) bbox = QgsRectangle(xMin, yMin, xMax, yMax) - layerData = QgsInterpolator.LayerData() - layerData.vectorLayer = layer - layerData.zCoordInterpolation = True - layerData.interpolationAttribute = -1 - - if layerType == 0: - layerData.mInputType = QgsInterpolator.POINTS - elif layerType == 1: - layerData.mInputType = QgsInterpolator.STRUCTURE_LINES - else: - layerData.mInputType = QgsInterpolator.BREAK_LINES + layerData = [] + for row in interpolationData.split(';'): + v = row.split(',') + data = QgsInterpolator.LayerData() + data.vectorLayer = dataobjects.getObjectFromUri(v[0]) + data.zCoordInterpolation = bool(v[1]) + data.interpolationAttribute = int(v[2]) + if v[3] == '0': + data.mInputType = QgsInterpolator.POINTS + elif v[3] == '1': + data.mInputType = QgsInterpolator.STRUCTURE_LINES + else: + data.mInputType = QgsInterpolator.BREAK_LINES + layerData.append(data) if method == 0: interpolationMethod = QgsTINInterpolator.Linear else: interpolationMethod = QgsTINInterpolator.CloughTocher - interpolator = QgsTINInterpolator([layerData], interpolationMethod) + interpolator = QgsTINInterpolator(layerData, interpolationMethod) interpolator.setExportTriangulationToFile(True) interpolator.setTriangulationFilePath(triangulation) diff --git a/python/plugins/processing/algs/qgis/TinInterpolationAttribute.py b/python/plugins/processing/algs/qgis/TinInterpolationAttribute.py deleted file mode 100644 index fdf4b30bda8..00000000000 --- a/python/plugins/processing/algs/qgis/TinInterpolationAttribute.py +++ /dev/null @@ -1,163 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -*************************************************************************** - TinInterpolationAttribute.py - --------------------- - Date : October 2016 - Copyright : (C) 2016 by Alexander Bruy - Email : alexander dot bruy at gmail dot com -*************************************************************************** -* * -* 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. * -* * -*************************************************************************** -""" - -__author__ = 'Alexander Bruy' -__date__ = 'October 2016' -__copyright__ = '(C) 2016, Alexander Bruy' - -# This will get replaced with a git SHA1 when you do a git archive - -__revision__ = '$Format:%H$' - -import os - -from qgis.PyQt.QtGui import QIcon - -from qgis.core import QgsRectangle -from qgis.analysis import (QgsInterpolator, - QgsTINInterpolator, - QgsGridFileWriter - ) - -from processing.core.GeoAlgorithm import GeoAlgorithm -from processing.core.parameters import ParameterVector -from processing.core.parameters import ParameterTableField -from processing.core.parameters import ParameterSelection -from processing.core.parameters import ParameterNumber -from processing.core.parameters import ParameterExtent -from processing.core.outputs import OutputRaster -from processing.core.outputs import OutputVector -from processing.tools import dataobjects - -pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0] - - -class TinInterpolationAttribute(GeoAlgorithm): - - INPUT_LAYER = 'INPUT_LAYER' - ATTRIBUTE = 'ATTRIBUTE' - LAYER_TYPE = 'LAYER_TYPE' - METHOD = 'METHOD' - COLUMNS = 'COLUMNS' - ROWS = 'ROWS' - CELLSIZE_X = 'CELLSIZE_X' - CELLSIZE_Y = 'CELLSIZE_Y' - EXTENT = 'EXTENT' - OUTPUT_LAYER = 'OUTPUT_LAYER' - TRIANULATION_FILE = 'TRIANULATION_FILE' - - def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'interpolation.png')) - - def defineCharacteristics(self): - self.name, self.i18n_name = self.trAlgorithm('TIN interpolation (using attribute)') - self.group, self.i18n_group = self.trAlgorithm('Interpolation') - - self.TYPES = [self.tr('Points'), - self.tr('Structure lines'), - self.tr('Break lines') - ] - self.METHODS = [self.tr('Linear'), - self.tr('Clough-Toucher (cubic)') - ] - - self.addParameter(ParameterVector(self.INPUT_LAYER, - self.tr('Vector layer'))) - self.addParameter(ParameterTableField(self.ATTRIBUTE, - self.tr('Interpolation attribute'), - self.INPUT_LAYER, - ParameterTableField.DATA_TYPE_NUMBER)) - self.addParameter(ParameterSelection(self.LAYER_TYPE, - self.tr('Type'), - self.TYPES, - 0)) - self.addParameter(ParameterSelection(self.METHOD, - self.tr('Interpolation method'), - self.METHODS, - 0)) - self.addParameter(ParameterNumber(self.COLUMNS, - self.tr('Number of columns'), - 0, 10000000, 300)) - self.addParameter(ParameterNumber(self.ROWS, - self.tr('Number of rows'), - 0, 10000000, 300)) - self.addParameter(ParameterNumber(self.CELLSIZE_X, - self.tr('Cellsize X'), - 0.0, 999999.000000, 0.0)) - self.addParameter(ParameterNumber(self.CELLSIZE_Y, - self.tr('Cellsize Y'), - 0.0, 999999.000000, 0.0)) - self.addParameter(ParameterExtent(self.EXTENT, - self.tr('Extent'))) - self.addOutput(OutputRaster(self.OUTPUT_LAYER, - self.tr('Interpolated'))) - self.addOutput(OutputVector(self.TRIANULATION_FILE, - self.tr('Triangulation'), - )) # datatype=dataobjects.TYPE_VECTOR_LINE)) - - def processAlgorithm(self, progress): - layer = dataobjects.getObjectFromUri( - self.getParameterValue(self.INPUT_LAYER)) - fieldName = self.getParameterValue(self.ATTRIBUTE) - layerType = self.getParameterValue(self.LAYER_TYPE) - method = self.getParameterValue(self.METHOD) - columns = self.getParameterValue(self.COLUMNS) - rows = self.getParameterValue(self.ROWS) - cellsizeX = self.getParameterValue(self.CELLSIZE_X) - cellsizeY = self.getParameterValue(self.CELLSIZE_Y) - extent = self.getParameterValue(self.EXTENT).split(',') - output = self.getOutputValue(self.OUTPUT_LAYER) - triangulation = self.getOutputValue(self.TRIANULATION_FILE) - - xMin = float(extent[0]) - xMax = float(extent[1]) - yMin = float(extent[2]) - yMax = float(extent[3]) - bbox = QgsRectangle(xMin, yMin, xMax, yMax) - - layerData = QgsInterpolator.LayerData() - layerData.vectorLayer = layer - layerData.zCoordInterpolation = False - layerData.interpolationAttribute = layer.dataProvider().fieldNameIndex(fieldName) - - if layerType == 0: - layerData.mInputType = QgsInterpolator.POINTS - elif layerType == 1: - layerData.mInputType = QgsInterpolator.STRUCTURE_LINES - else: - layerData.mInputType = QgsInterpolator.BREAK_LINES - - if method == 0: - interpolationMethod = QgsTINInterpolator.Linear - else: - interpolationMethod = QgsTINInterpolator.CloughTocher - - interpolator = QgsTINInterpolator([layerData], interpolationMethod) - interpolator.setExportTriangulationToFile(True) - interpolator.setTriangulationFilePath(triangulation) - - writer = QgsGridFileWriter(interpolator, - output, - bbox, - columns, - rows, - cellsizeX, - cellsizeY) - - writer.writeFile() diff --git a/python/plugins/processing/algs/qgis/TruncateTable.py b/python/plugins/processing/algs/qgis/TruncateTable.py new file mode 100644 index 00000000000..4095678d69a --- /dev/null +++ b/python/plugins/processing/algs/qgis/TruncateTable.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + TruncateTable.py + ----------------------- + Date : January 2017 + Copyright : (C) 2017 by Nyall Dawson + Email : nyall dot dawson at gmail dot com +*************************************************************************** +* * +* 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. * +* * +*************************************************************************** +""" + +__author__ = 'Nyall Dawson' +__date__ = 'January 2017' +__copyright__ = '(C) 2017, Nyall Dawson' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.parameters import ParameterTable +from processing.core.outputs import OutputVector +from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException +from processing.tools import dataobjects + + +class TruncateTable(GeoAlgorithm): + + INPUT = 'INPUT' + OUTPUT = 'OUTPUT' + + def defineCharacteristics(self): + self.name, self.i18n_name = self.trAlgorithm('Truncate table') + self.tags = self.tr('empty,delete,layer,clear,features') + self.group, self.i18n_group = self.trAlgorithm('Vector general tools') + + self.addParameter(ParameterTable(self.INPUT, + self.tr('Input Layer'))) + self.addOutput(OutputVector(self.OUTPUT, + self.tr('Truncated layer'), True)) + + def processAlgorithm(self, progress): + file_name = self.getParameterValue(self.INPUT) + layer = dataobjects.getObjectFromUri(file_name) + provider = layer.dataProvider() + + if not provider.truncate(): + raise GeoAlgorithmExecutionException( + self.tr('Could not truncate table.')) + + self.setOutputValue(self.OUTPUT, file_name) diff --git a/python/plugins/processing/algs/qgis/Union.py b/python/plugins/processing/algs/qgis/Union.py index 6cca0ad4f14..2c980566768 100644 --- a/python/plugins/processing/algs/qgis/Union.py +++ b/python/plugins/processing/algs/qgis/Union.py @@ -161,9 +161,6 @@ class Union(GeoAlgorithm): if len(lstIntersectingB) != 0: intB = QgsGeometry.unaryUnion(lstIntersectingB) diff_geom = diff_geom.difference(intB) - if diff_geom.isGeosEmpty() or not diff_geom.isGeosValid(): - ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, - self.tr('GEOS geoprocessing error: One or more input features have invalid geometry.')) if diff_geom.wkbType() == 0 or QgsWkbTypes.flatType(diff_geom.geometry().wkbType()) == QgsWkbTypes.GeometryCollection: temp_list = diff_geom.asGeometryCollection() @@ -214,9 +211,6 @@ class Union(GeoAlgorithm): if engine.intersects(tmpGeom.geometry()): add = True diff_geom = QgsGeometry(diff_geom.difference(tmpGeom)) - if diff_geom.isGeosEmpty() or not diff_geom.isGeosValid(): - ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, - self.tr('GEOS geoprocessing error: One or more input features have invalid geometry.')) else: try: # Ihis only happends if the bounding box diff --git a/python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py b/python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py index 63b71868791..b963c1b461e 100644 --- a/python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py +++ b/python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py @@ -95,9 +95,7 @@ class FieldsCalculatorDialog(BASE, WIDGET): def initContext(self): exp_context = self.builder.expressionContext() - exp_context.appendScope(QgsExpressionContextUtils.globalScope()) - exp_context.appendScope(QgsExpressionContextUtils.projectScope()) - exp_context.appendScope(QgsExpressionContextUtils.layerScope(self.layer)) + exp_context.appendScopes(QgsExpressionContextUtils.globalProjectLayerScopes(self.layer)) exp_context.lastScope().setVariable("row_number", 1) exp_context.setHighlightedVariables(["row_number"]) self.builder.setExpressionContext(exp_context) diff --git a/python/plugins/processing/algs/qgis/ui/InterpolationDataWidget.py b/python/plugins/processing/algs/qgis/ui/InterpolationDataWidget.py new file mode 100644 index 00000000000..674019262c3 --- /dev/null +++ b/python/plugins/processing/algs/qgis/ui/InterpolationDataWidget.py @@ -0,0 +1,174 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + InterpolationDataWidget.py + --------------------- + Date : December 2016 + Copyright : (C) 2016 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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. * +* * +*************************************************************************** +""" + +__author__ = 'Alexander Bruy' +__date__ = 'December 2016' +__copyright__ = '(C) 2016, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os + +from qgis.PyQt import uic +from qgis.PyQt.QtCore import pyqtSlot, QEvent +from qgis.PyQt.QtGui import (QIcon, + QBrush, + QColor) +from qgis.PyQt.QtWidgets import (QTreeWidgetItem, + QComboBox + ) +from qgis.core import (QgsApplication, + QgsMapLayer, + QgsMapLayerProxyModel, + QgsWkbTypes + ) +from qgis.gui import QgsFieldProxyModel +from qgis.analysis import QgsInterpolator + +from processing.gui.wrappers import WidgetWrapper +from processing.tools import dataobjects + +pluginPath = os.path.dirname(__file__) +WIDGET, BASE = uic.loadUiType(os.path.join(pluginPath, 'interpolationdatawidgetbase.ui')) + + +class InterpolationDataWidget(BASE, WIDGET): + + def __init__(self): + super(InterpolationDataWidget, self).__init__(None) + self.setupUi(self) + + self.btnAdd.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg')) + self.btnRemove.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg')) + + self.cmbLayers.setFilters(QgsMapLayerProxyModel.VectorLayer) + self.cmbFields.setFilters(QgsFieldProxyModel.Numeric) + self.cmbFields.setLayer(self.cmbLayers.currentLayer()) + + #self.delegate = InterpolationTypeDelegate() + #self.layersTree.setItemDelegateForColumn(2, self.delegate) + + @pyqtSlot() + def on_btnAdd_clicked(self): + layer = self.cmbLayers.currentLayer() + + attribute = '' + if self.chkUseZCoordinate.isChecked(): + attribute = 'Z_COORD' + else: + attribute = self.cmbFields.currentField() + + self.addLayerData(layer.name(), attribute) + + @pyqtSlot() + def on_btnRemove_clicked(self): + item = self.layersTree.currentItem() + if not item: + return + self.layersTree.invisibleRootItem().removeChild(item) + + @pyqtSlot(QgsMapLayer) + def on_cmbLayers_layerChanged(self, layer): + self.chkUseZCoordinate.setEnabled(False) + + if layer is None or not layer.isValid(): + return + + provider = layer.dataProvider() + if not provider: + return + + if QgsWkbTypes.hasZ(provider.wkbType()): + self.chkUseZCoordinate.setEnabled(True) + + self.cmbFields.setLayer(layer) + + def addLayerData(self, layerName, attribute): + item = QTreeWidgetItem() + item.setText(0, layerName) + item.setText(1, attribute) + self.layersTree.addTopLevelItem(item) + + comboBox = QComboBox() + comboBox.addItem(self.tr('Points')) + comboBox.addItem(self.tr('Structure lines')) + comboBox.addItem(self.tr('Break lines')) + comboBox.setCurrentIndex(0) + self.layersTree.setItemWidget(item, 2, comboBox) + + def setValue(self, value): + self.layersTree.clear() + rows = value.split(';') + for i, r in enumerate(rows): + v = r.split(',') + self.addLayerData(v[0], v[1]) + + comboBox = self.layersTree.itemWidget(self.layersTree.topLevelItem(i), 2) + comboBox.setCurrentIndex(comboBox.findText(v[3])) + + def value(self): + layers = '' + for i in range(self.layersTree.topLevelItemCount()): + item = self.layersTree.topLevelItem(i) + if item: + layerName = item.text(0) + layer = dataobjects.getObjectFromName(layerName) + if not layer: + continue + + provider = layer.dataProvider() + if not provider: + continue + + interpolationAttribute = item.text(1) + if interpolationAttribute == 'Z_COORD': + zCoord = True + fieldIndex = -1 + else: + zCoord = False + fieldIndex = layer.fields().indexFromName(interpolationAttribute) + + comboBox = self.layersTree.itemWidget(self.layersTree.topLevelItem(i), 2) + inputTypeName = comboBox.currentText() + if inputTypeName == self.tr('Points'): + inputType = QgsInterpolator.POINTS + elif inputTypeName == self.tr('Structure lines'): + inputType = QgsInterpolator.STRUCTURE_LINES + else: + inputType = QgsInterpolator.BREAK_LINES + + layers += '{},{},{:d},{:d};'.format(layer.source(), + zCoord, + fieldIndex, + inputType) + return layers[:-1] + + +class InterpolationDataWidgetWrapper(WidgetWrapper): + + def createWidget(self): + return InterpolationDataWidget() + + def setValue(self, value): + self.widget.setValue(value) + + def value(self): + return self.widget.value() diff --git a/python/plugins/processing/algs/qgis/ui/ReliefColorsWidget.py b/python/plugins/processing/algs/qgis/ui/ReliefColorsWidget.py index 0f4956416c1..32584631250 100644 --- a/python/plugins/processing/algs/qgis/ui/ReliefColorsWidget.py +++ b/python/plugins/processing/algs/qgis/ui/ReliefColorsWidget.py @@ -38,7 +38,7 @@ from qgis.PyQt.QtWidgets import (QTreeWidgetItem, QMessageBox, QInputDialog, QColorDialog - ) + ) from qgis.PyQt.QtXml import QDomDocument from qgis.core import QgsApplication, QgsMapLayer diff --git a/python/plugins/processing/algs/qgis/ui/interpolationdatawidgetbase.ui b/python/plugins/processing/algs/qgis/ui/interpolationdatawidgetbase.ui new file mode 100644 index 00000000000..cdd91cea345 --- /dev/null +++ b/python/plugins/processing/algs/qgis/ui/interpolationdatawidgetbase.ui @@ -0,0 +1,130 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Vector layer + + + cmbLayers + + + + + + + + 0 + 0 + + + + + + + + Interpolation attribute + + + cmbFields + + + + + + + + 0 + 0 + + + + + + + + + Vector layer + + + + + Attribute + + + + + Type + + + + + + + + Use Z-coordinate for interpolation + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + + + + ... + + + + + + + + + + QgsMapLayerComboBox + QComboBox +
    qgis.gui
    +
    + + QgsFieldComboBox + QComboBox +
    qgis.gui
    +
    +
    + + +
    diff --git a/python/plugins/processing/algs/saga/SagaAlgorithm212.py b/python/plugins/processing/algs/saga/SagaAlgorithm212.py index b4b8787784d..86dab873853 100644 --- a/python/plugins/processing/algs/saga/SagaAlgorithm212.py +++ b/python/plugins/processing/algs/saga/SagaAlgorithm212.py @@ -293,7 +293,7 @@ class SagaAlgorithm212(GeoAlgorithm): return commands def getOutputCellsize(self): - """Tries to guess the cellsize of the output, searching for + """Tries to guess the cell size of the output, searching for a parameter with an appropriate name for it. """ diff --git a/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py b/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py index 43dc6e0c06b..931b268f2f5 100644 --- a/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py +++ b/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py @@ -86,7 +86,7 @@ class SagaAlgorithmProvider(AlgorithmProvider): def _loadAlgorithms(self): self.algs = [] - version = SagaUtils.getSagaInstalledVersion(True) + version = SagaUtils.getInstalledVersion(True) if version is None: ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, self.tr('Problem with SAGA installation: SAGA was not found or is not correctly installed')) @@ -121,8 +121,8 @@ class SagaAlgorithmProvider(AlgorithmProvider): self.tr('Could not open SAGA algorithm: %s\n%s' % (descriptionFile, str(e)))) def getDescription(self): - version = SagaUtils.getSagaInstalledVersion() - return 'SAGA (%s)' % version if version is not None else 'SAGA' + version = SagaUtils.getInstalledVersion() + return 'SAGA ({})'.format(version) if version is not None else 'SAGA' def getName(self): return 'saga' diff --git a/python/plugins/processing/algs/saga/SagaUtils.py b/python/plugins/processing/algs/saga/SagaUtils.py index 26d4251d2fc..5a83cb55ff5 100644 --- a/python/plugins/processing/algs/saga/SagaUtils.py +++ b/python/plugins/processing/algs/saga/SagaUtils.py @@ -72,7 +72,7 @@ def findSagaFolder(): def sagaPath(): folder = ProcessingConfig.getSetting(SAGA_FOLDER) - if not os.path.isdir(folder): + if folder and not os.path.isdir(folder): folder = None ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, 'Specified SAGA folder does not exist. Will try to find built-in binaries.') @@ -112,7 +112,7 @@ _installedVersion = None _installedVersionFound = False -def getSagaInstalledVersion(runSaga=False): +def getInstalledVersion(runSaga=False): global _installedVersion global _installedVersionFound diff --git a/python/plugins/processing/core/AlgorithmProvider.py b/python/plugins/processing/core/AlgorithmProvider.py index 386725b3721..f0ba71bafba 100644 --- a/python/plugins/processing/core/AlgorithmProvider.py +++ b/python/plugins/processing/core/AlgorithmProvider.py @@ -101,7 +101,7 @@ class AlgorithmProvider(object): return self.tr('Generic algorithm provider') def getIcon(self): - return QIcon(os.path.dirname(__file__) + '/../images/alg.png') + return QIcon(os.path.dirname(__file__) + '/../images/alg.svg') def getSupportedOutputRasterLayerExtensions(self): return ['tif'] diff --git a/python/plugins/processing/core/GeoAlgorithm.py b/python/plugins/processing/core/GeoAlgorithm.py index 96897e5c3a8..da8a56dd574 100644 --- a/python/plugins/processing/core/GeoAlgorithm.py +++ b/python/plugins/processing/core/GeoAlgorithm.py @@ -52,7 +52,7 @@ from processing.algs.help import shortHelp class GeoAlgorithm(object): def __init__(self): - self._icon = QIcon(os.path.dirname(__file__) + '/../images/alg.png') + self._icon = QIcon(os.path.dirname(__file__) + '/../images/alg.svg') # Parameters needed by the algorithm self.parameters = list() diff --git a/python/plugins/processing/core/Processing.py b/python/plugins/processing/core/Processing.py index def9b6bd599..f920b8eb33c 100644 --- a/python/plugins/processing/core/Processing.py +++ b/python/plugins/processing/core/Processing.py @@ -57,7 +57,7 @@ from processing.modeler.ModelerAlgorithmProvider import ModelerAlgorithmProvider from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider from processing.algs.grass7.Grass7AlgorithmProvider import Grass7AlgorithmProvider from processing.algs.lidar.LidarToolsAlgorithmProvider import LidarToolsAlgorithmProvider -from processing.algs.gdal.GdalOgrAlgorithmProvider import GdalOgrAlgorithmProvider +from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider from processing.algs.otb.OTBAlgorithmProvider import OTBAlgorithmProvider from processing.algs.r.RAlgorithmProvider import RAlgorithmProvider from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider diff --git a/python/plugins/processing/core/ProcessingConfig.py b/python/plugins/processing/core/ProcessingConfig.py index 72254a87959..87067648adc 100644 --- a/python/plugins/processing/core/ProcessingConfig.py +++ b/python/plugins/processing/core/ProcessingConfig.py @@ -52,6 +52,7 @@ class ProcessingConfig(object): VECTOR_POLYGON_STYLE = 'VECTOR_POLYGON_STYLE' SHOW_RECENT_ALGORITHMS = 'SHOW_RECENT_ALGORITHMS' USE_SELECTED = 'USE_SELECTED' + FILTER_INVALID_GEOMETRIES = 'FILTER_INVALID_GEOMETRIES' USE_FILENAME_AS_LAYER_NAME = 'USE_FILENAME_AS_LAYER_NAME' KEEP_DIALOG_OPEN = 'KEEP_DIALOG_OPEN' SHOW_DEBUG_IN_DIALOG = 'SHOW_DEBUG_IN_DIALOG' @@ -70,7 +71,7 @@ class ProcessingConfig(object): @staticmethod def initialize(): - icon = QIcon(os.path.dirname(__file__) + '/../images/alg.png') + icon = QIcon(os.path.dirname(__file__) + '/../images/alg.svg') ProcessingConfig.settingIcons['General'] = icon ProcessingConfig.addSetting(Setting( ProcessingConfig.tr('General'), @@ -84,6 +85,14 @@ class ProcessingConfig(object): ProcessingConfig.tr('General'), ProcessingConfig.USE_SELECTED, ProcessingConfig.tr('Use only selected features'), True)) + invalidFeaturesOptions = [ProcessingConfig.tr('Do not filter (better performance'), + ProcessingConfig.tr('Ignore features with invalid geometries'), + ProcessingConfig.tr('Stop algorithm execution when a geometry is invalid')] + ProcessingConfig.addSetting(Setting( + ProcessingConfig.tr('General'), + ProcessingConfig.FILTER_INVALID_GEOMETRIES, + ProcessingConfig.tr('Invalid features filtering'), invalidFeaturesOptions[2], + valuetype=Setting.SELECTION, options=invalidFeaturesOptions)) ProcessingConfig.addSetting(Setting( ProcessingConfig.tr('General'), ProcessingConfig.USE_FILENAME_AS_LAYER_NAME, @@ -146,7 +155,7 @@ class ProcessingConfig(object): ProcessingConfig.addSetting(Setting( ProcessingConfig.tr('General'), ProcessingConfig.RECENT_ALGORITHMS, - ProcessingConfig.tr('Recent algs'), '', hidden=True)) + ProcessingConfig.tr('Recent algorithms'), '', hidden=True)) extensions = processing.tools.dataobjects.getSupportedOutputVectorLayerExtensions() ProcessingConfig.addSetting(Setting( ProcessingConfig.tr('General'), @@ -167,11 +176,11 @@ class ProcessingConfig(object): @staticmethod def getGroupIcon(group): if group == ProcessingConfig.tr('General'): - return QIcon(os.path.dirname(__file__) + '/../images/alg.png') + return QIcon(os.path.dirname(__file__) + '/../images/alg.svg') if group in ProcessingConfig.settingIcons: return ProcessingConfig.settingIcons[group] else: - return QIcon(os.path.dirname(__file__) + '/../images/alg.png') + return QIcon(os.path.dirname(__file__) + '/../images/alg.svg') @staticmethod def addSetting(setting): @@ -289,16 +298,15 @@ class Setting(object): self.validator(value) self.value = value - def read(self): - qsettings = QSettings() + def read(self, qsettings=QSettings()): value = qsettings.value(self.qname, None) if value is not None: if isinstance(self.value, bool): value = str(value).lower() == str(True).lower() self.value = value - def save(self): - QSettings().setValue(self.qname, self.value) + def save(self, qsettings=QSettings()): + qsettings.setValue(self.qname, self.value) def __str__(self): return self.name + '=' + str(self.value) diff --git a/python/plugins/processing/core/outputs.py b/python/plugins/processing/core/outputs.py index 57f30e569ed..b68427d65d1 100644 --- a/python/plugins/processing/core/outputs.py +++ b/python/plugins/processing/core/outputs.py @@ -38,13 +38,13 @@ from processing.tools.system import isWindows, getTempFilenameInTempFolder, getT from processing.tools.vector import VectorWriter, TableWriter from processing.tools import dataobjects -from qgis.core import QgsExpressionContext, QgsExpressionContextUtils, QgsExpression, QgsExpressionContextScope +from qgis.core import QgsExpressionContext, QgsExpressionContextUtils, QgsExpression, QgsExpressionContextScope, QgsProject def _expressionContext(alg): context = QgsExpressionContext() context.appendScope(QgsExpressionContextUtils.globalScope()) - context.appendScope(QgsExpressionContextUtils.projectScope()) + context.appendScope(QgsExpressionContextUtils.projectScope(QgsProject.instance())) processingScope = QgsExpressionContextScope() for param in alg.parameters: processingScope.setVariable('%s_value' % param.name, '') diff --git a/python/plugins/processing/core/parameters.py b/python/plugins/processing/core/parameters.py index af31e227763..089bca31312 100644 --- a/python/plugins/processing/core/parameters.py +++ b/python/plugins/processing/core/parameters.py @@ -38,7 +38,8 @@ import numbers from qgis.utils import iface from qgis.PyQt.QtCore import QCoreApplication from qgis.core import (QgsRasterLayer, QgsVectorLayer, QgsMapLayer, QgsCoordinateReferenceSystem, - QgsExpressionContext, QgsExpressionContextUtils, QgsExpression, QgsExpressionContextScope) + QgsExpressionContext, QgsExpressionContextUtils, QgsExpression, QgsExpressionContextScope, + QgsProject) from processing.tools.vector import resolveFieldIndex, features from processing.tools import dataobjects @@ -70,7 +71,7 @@ def _createDescriptiveName(s): def _expressionContext(): context = QgsExpressionContext() context.appendScope(QgsExpressionContextUtils.globalScope()) - context.appendScope(QgsExpressionContextUtils.projectScope()) + context.appendScope(QgsExpressionContextUtils.projectScope(QgsProject.instance())) if iface.mapCanvas(): context.appendScope(QgsExpressionContextUtils.mapSettingsScope(iface.mapCanvas().mapSettings())) @@ -229,7 +230,9 @@ class ParameterBoolean(Parameter): isOptional, name, definition = _splitParameterOptions(line) if definition.startswith("boolean"): descName = _createDescriptiveName(name) - default = definition.strip()[len('boolean') + 1:] + default = definition.strip()[len('boolean') + 1:] or None + if default == 'None': + default = None if default: param = ParameterBoolean(name, descName, default) else: @@ -292,6 +295,8 @@ class ParameterCrs(Parameter): if definition.startswith("crs"): descName = _createDescriptiveName(name) default = definition.strip()[len('crs') + 1:] + if default == 'None': + default = None if default: return ParameterCrs(name, descName, default, isOptional) else: @@ -574,7 +579,7 @@ class ParameterFixedTable(Parameter): if definition.startswith("fixedtable"): descName = _createDescriptiveName(name) default = definition.strip()[len('fixedtable') + 1:] or None - return ParameterFixedTable(name, descName, default, isOptional) + return ParameterFixedTable(name, descName, optional=isOptional) class ParameterMultipleInput(ParameterDataObject): @@ -1186,15 +1191,19 @@ class ParameterString(Parameter): param_type = '' if self.optional: param_type += 'optional ' - param_type += 'string' - return '##' + self.name + '=' + param_type + self.default + param_type += 'string ' + return '##' + self.name + '=' + param_type + repr(self.default) @classmethod def fromScriptCode(self, line): isOptional, name, definition = _splitParameterOptions(line) descName = _createDescriptiveName(name) if definition.lower().strip().startswith('string'): - default = definition.strip()[len('string') + 1:] + default = definition.strip()[len('string') + 1:] or None + if default == 'None': + default = None + elif default.startswith('"') or default.startswith('\''): + default = eval(default) if default: return ParameterString(name, descName, default, optional=isOptional) else: @@ -1255,15 +1264,17 @@ class ParameterExpression(Parameter): param_type = '' if self.optional: param_type += 'optional ' - param_type += 'expression' - return '##' + self.name + '=' + param_type + self.default + param_type += 'expression ' + return '##' + self.name + '=' + param_type + str(self.default) @classmethod def fromScriptCode(self, line): isOptional, name, definition = _splitParameterOptions(line) if definition.lower().strip().startswith('expression'): descName = _createDescriptiveName(name) - default = definition.strip()[len('expression') + 1:] + default = definition.strip()[len('expression') + 1:] or None + if default == 'None': + default = None if default: return ParameterExpression(name, descName, default, optional=isOptional) else: @@ -1413,7 +1424,7 @@ class ParameterTableField(Parameter): if self.optional: param_type += 'optional ' param_type += 'field' - return '##' + self.name + '=' + param_type + self.parent + return '##' + self.name + '=' + param_type + str(self.parent) @classmethod def fromScriptCode(self, line): @@ -1559,5 +1570,5 @@ def getParameterFromString(s): param = paramClass.fromScriptCode(s) if param is not None: return param - except AttributeError: + except: pass diff --git a/python/plugins/processing/gui/BatchPanel.py b/python/plugins/processing/gui/BatchPanel.py index 1f0cf3410bd..eb5ccbb399a 100644 --- a/python/plugins/processing/gui/BatchPanel.py +++ b/python/plugins/processing/gui/BatchPanel.py @@ -73,7 +73,7 @@ class BatchPanel(BASE, WIDGET): self.btnRemove.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg')) self.btnOpen.setIcon(QgsApplication.getThemeIcon('/mActionFileOpen.svg')) self.btnSave.setIcon(QgsApplication.getThemeIcon('/mActionFileSave.svg')) - self.btnAdvanced.setIcon(QIcon(os.path.join(pluginPath, 'images', 'alg.png'))) + self.btnAdvanced.setIcon(QIcon(os.path.join(pluginPath, 'images', 'alg.svg'))) self.alg = alg self.parent = parent diff --git a/python/plugins/processing/gui/ConfigDialog.py b/python/plugins/processing/gui/ConfigDialog.py index d4d96578c03..9c29afd1b0d 100644 --- a/python/plugins/processing/gui/ConfigDialog.py +++ b/python/plugins/processing/gui/ConfigDialog.py @@ -30,8 +30,7 @@ __revision__ = '$Format:%H$' import os from qgis.PyQt import uic -from qgis.PyQt.QtCore import (Qt, - QEvent) +from qgis.PyQt.QtCore import Qt, QEvent, QSettings from qgis.PyQt.QtWidgets import (QFileDialog, QDialog, QStyle, @@ -160,7 +159,7 @@ class ConfigDialog(BASE, WIDGET): Filter 'Providers' items """ providersItem = QStandardItem(self.tr('Providers')) - icon = QIcon(os.path.join(pluginPath, 'images', 'alg.png')) + icon = QIcon(os.path.join(pluginPath, 'images', 'alg.svg')) providersItem.setIcon(icon) providersItem.setEditable(False) emptyItem = QStandardItem() @@ -266,6 +265,7 @@ class ConfigDialog(BASE, WIDGET): def accept(self): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) + qsettings = QSettings() for setting in list(self.items.keys()): if setting.group != menusSettingsGroup or self.saveMenus: if isinstance(setting.value, bool): @@ -277,7 +277,7 @@ class ConfigDialog(BASE, WIDGET): QMessageBox.warning(self, self.tr('Wrong value'), self.tr('Wrong value for parameter "%s":\n\n%s' % (setting.description, str(e)))) return - setting.save() + setting.save(qsettings) Processing.updateAlgsList() settingsWatcher.settingsChanged.emit() QApplication.restoreOverrideCursor() diff --git a/python/plugins/processing/gui/CreateNewScriptAction.py b/python/plugins/processing/gui/CreateNewScriptAction.py index e3df462f87a..0c0c92ef1b8 100644 --- a/python/plugins/processing/gui/CreateNewScriptAction.py +++ b/python/plugins/processing/gui/CreateNewScriptAction.py @@ -49,7 +49,7 @@ class CreateNewScriptAction(ToolboxAction): def getIcon(self): if self.scriptType == self.SCRIPT_PYTHON: - return QIcon(os.path.join(pluginPath, 'images', 'script.png')) + return QIcon(os.path.join(pluginPath, 'images', 'script.svg')) elif self.scriptType == self.SCRIPT_R: return QIcon(os.path.join(pluginPath, 'images', 'r.svg')) diff --git a/python/plugins/processing/gui/GetScriptsAndModels.py b/python/plugins/processing/gui/GetScriptsAndModels.py index d1adb7d27df..662904a9f25 100644 --- a/python/plugins/processing/gui/GetScriptsAndModels.py +++ b/python/plugins/processing/gui/GetScriptsAndModels.py @@ -62,7 +62,7 @@ class GetScriptsAction(ToolboxAction): self.group, self.i18n_group = self.trAction('Tools') def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'script.png')) + return QIcon(os.path.join(pluginPath, 'images', 'script.svg')) def execute(self): dlg = GetScriptsAndModelsDialog(GetScriptsAndModelsDialog.SCRIPTS) @@ -94,7 +94,7 @@ class GetModelsAction(ToolboxAction): self.group, self.i18n_group = self.trAction('Tools') def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'model.png')) + return QIcon(os.path.join(pluginPath, 'images', 'model.svg')) def execute(self): dlg = GetScriptsAndModelsDialog(GetScriptsAndModelsDialog.MODELS) @@ -137,11 +137,11 @@ class GetScriptsAndModelsDialog(BASE, WIDGET): if self.resourceType == self.MODELS: self.folder = ModelerUtils.modelsFolders()[0] self.urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/models/' - self.icon = QIcon(os.path.join(pluginPath, 'images', 'model.png')) + self.icon = QIcon(os.path.join(pluginPath, 'images', 'model.svg')) elif self.resourceType == self.SCRIPTS: self.folder = ScriptUtils.scriptsFolders()[0] self.urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/scripts/' - self.icon = QIcon(os.path.join(pluginPath, 'images', 'script.png')) + self.icon = QIcon(os.path.join(pluginPath, 'images', 'script.svg')) else: self.folder = RUtils.RScriptsFolders()[0] self.urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/rscripts/' diff --git a/python/plugins/processing/gui/ParametersPanel.py b/python/plugins/processing/gui/ParametersPanel.py index ff3d80353a5..6ed71ba4177 100644 --- a/python/plugins/processing/gui/ParametersPanel.py +++ b/python/plugins/processing/gui/ParametersPanel.py @@ -123,15 +123,24 @@ class ParametersPanel(BASE, WIDGET): tooltips = self.alg.getParameterDescriptions() widget.setToolTip(tooltips.get(param.name, param.description)) - label = QLabel(desc) - # label.setToolTip(tooltip) - self.labels[param.name] = label + if type(widget) is QCheckBox: + # checkbox widget - so description is embedded in widget rather than a separate + # label + widget.setText(desc) + else: + label = QLabel(desc) + # label.setToolTip(tooltip) + self.labels[param.name] = label + + if param.isAdvanced: + self.layoutAdvanced.addWidget(label) + else: + self.layoutMain.insertWidget( + self.layoutMain.count() - 2, label) + if param.isAdvanced: - self.layoutAdvanced.addWidget(label) self.layoutAdvanced.addWidget(widget) else: - self.layoutMain.insertWidget( - self.layoutMain.count() - 2, label) self.layoutMain.insertWidget( self.layoutMain.count() - 2, widget) diff --git a/python/plugins/processing/gui/ToolboxAction.py b/python/plugins/processing/gui/ToolboxAction.py index 55b91ada024..7c4201950ac 100644 --- a/python/plugins/processing/gui/ToolboxAction.py +++ b/python/plugins/processing/gui/ToolboxAction.py @@ -37,7 +37,7 @@ class ToolboxAction(object): self.toolbox = toolbox def getIcon(self): - return QIcon(os.path.dirname(__file__) + '/../images/alg.png') + return QIcon(os.path.dirname(__file__) + '/../images/alg.svg') def tr(self, string, context=''): if context == '': diff --git a/python/plugins/processing/gui/algnames.txt b/python/plugins/processing/gui/algnames.txt index 9e63d4d06c9..740ca635e5c 100644 --- a/python/plugins/processing/gui/algnames.txt +++ b/python/plugins/processing/gui/algnames.txt @@ -1,20 +1,20 @@ -gdalogr:executesql,Execute SQL on vector layer -gdalogr:rasterinfo,Raster layer information -gdalogr:merge,Merge raster layers -gdalogr:ogr2ogr,Export vector layer -gdalogr:vectorinfo,Vector layer information -gdalogr:pcttorgb,PCT to RGB -gdalogr:rgbtopct,RGB to PCT -gdalogr:sieve,Remove small pixel clumps (nearest neighbour) -gdalogr:translate,Export raster layer -gdalogr:warpreproject,Reproject raster layer -gdalogr:polygonize,Vectorize raster layer -gdalogr:gridrasterize,Rasterize vector layer -gdalogr:gridnearestneighbor,Interpolate (Nearest Neighbor) -gdalogr:griddatametrics,Interpolate (Data metrics) -gdalogr:gridinvdist,Interpolate (Inverse distance weighting) -gdalogr:gridaverage,Interpolate (Average) -gdalogr:contour,Contour lines +gdal:executesql,Execute SQL on vector layer +gdal:rasterinfo,Raster layer information +gdal:merge,Merge raster layers +gdal:ogr2ogr,Export vector layer +gdal:vectorinfo,Vector layer information +gdal:pcttorgb,PCT to RGB +gdal:rgbtopct,RGB to PCT +gdal:sieve,Remove small pixel clumps (nearest neighbour) +gdal:translate,Export raster layer +gdal:warpreproject,Reproject raster layer +gdal:polygonize,Vectorize raster layer +gdal:gridrasterize,Rasterize vector layer +gdal:gridnearestneighbor,Interpolate (Nearest Neighbor) +gdal:griddatametrics,Interpolate (Data metrics) +gdal:gridinvdist,Interpolate (Inverse distance weighting) +gdal:gridaverage,Interpolate (Average) +gdal:contour,Contour lines qgis:creategrid,Create graticule saga:changegridvalues,Reclassify (simple) saga:creategraticule,Create graticule from extent diff --git a/python/plugins/processing/gui/menus.py b/python/plugins/processing/gui/menus.py index bab75d27df6..364790f0b04 100644 --- a/python/plugins/processing/gui/menus.py +++ b/python/plugins/processing/gui/menus.py @@ -70,44 +70,44 @@ defaultMenuEntries.update({'qgis:definecurrentprojection': managementToolsMenu, 'qgis:splitvectorlayer': managementToolsMenu, 'qgis:mergevectorlayers': managementToolsMenu, 'qgis:createspatialindex': managementToolsMenu}) -""" + rasterMenu = Processing.tr('&Raster') projectionsMenu = rasterMenu + "/" + Processing.tr('Projections') -defaultMenuEntries.update({'gdalogr:warpreproject':projectionsMenu, - 'gdalogr:assignprojection':projectionsMenu, - 'gdalogr:extractprojection':projectionsMenu}) +defaultMenuEntries.update({'gdal:warpreproject': projectionsMenu, + 'gdal:assignprojection': projectionsMenu, + 'gdal:extractprojection': projectionsMenu}) conversionMenu = rasterMenu + "/" + Processing.tr('Conversion') -defaultMenuEntries.update({'gdalogr:rasterize':conversionMenu, - 'gdalogr:rasterize_over':conversionMenu, - 'gdalogr:polygonize':conversionMenu, - 'gdalogr:translate':conversionMenu, - 'gdalogr:rgbtopct':conversionMenu, - 'gdalogr:pcttorgb':conversionMenu}) +defaultMenuEntries.update({'gdal:rasterize': conversionMenu, + 'gdal:rasterize_over': conversionMenu, + 'gdal:polygonize': conversionMenu, + 'gdal:translate': conversionMenu, + 'gdal:rgbtopct': conversionMenu, + 'gdal:pcttorgb': conversionMenu}) extractionMenu = rasterMenu + "/" + Processing.tr('Extraction') -defaultMenuEntries.update({'gdalogr:contour':extractionMenu, - 'gdalogr:cliprasterbyextent':extractionMenu, - 'gdalogr:cliprasterbymasklayer':extractionMenu}) +defaultMenuEntries.update({'gdal:contour': extractionMenu, + 'gdal:cliprasterbyextent': extractionMenu, + 'gdal:cliprasterbymasklayer': extractionMenu}) analysisMenu = rasterMenu + "/" + Processing.tr('Analysis') -defaultMenuEntries.update({'gdalogr:sieve':analysisMenu, 'gdalogr:nearblack':analysisMenu, - 'gdalogr:fillnodata':analysisMenu, - 'gdalogr:proximity':analysisMenu, - 'gdalogr:griddatametrics':analysisMenu, - 'gdalogr:gridaverage':analysisMenu, - 'gdalogr:gridinvdist':analysisMenu, - 'gdalogr:gridnearestneighbor':analysisMenu, - 'gdalogr:aspect':analysisMenu, - 'gdalogr:hillshade':analysisMenu, - 'gdalogr:roughness':analysisMenu, - 'gdalogr:slope':analysisMenu, - 'gdalogr:tpi':analysisMenu, - 'gdalogr:tri':analysisMenu}) +defaultMenuEntries.update({'gdal:sieve': analysisMenu, + 'gdal:nearblack': analysisMenu, + 'gdal:fillnodata': analysisMenu, + 'gdal:proximity': analysisMenu, + 'gdal:griddatametrics': analysisMenu, + 'gdal:gridaverage': analysisMenu, + 'gdal:gridinvdist': analysisMenu, + 'gdal:gridnearestneighbor': analysisMenu, + 'gdal:aspect': analysisMenu, + 'gdal:hillshade': analysisMenu, + 'gdal:roughness': analysisMenu, + 'gdal:slope': analysisMenu, + 'gdal:tpi': analysisMenu, + 'gdal:tri': analysisMenu}) miscMenu = rasterMenu + "/" + Processing.tr('Miscellaneous') -defaultMenuEntries.update({'gdalogr:buildvirtualraster':miscMenu, - 'gdalogr:merge':miscMenu, - 'gdalogr:rasterinfo':miscMenu, - 'gdalogr:overviews':miscMenu, - 'gdalogr:tileindex':miscMenu}) -""" +defaultMenuEntries.update({'gdal:buildvirtualraster': miscMenu, + 'gdal:merge': miscMenu, + 'gdal:rasterinfo': miscMenu, + 'gdal:overviews': miscMenu, + 'gdal:tileindex': miscMenu}) def initializeMenus(): diff --git a/python/plugins/processing/images/alg.png b/python/plugins/processing/images/alg.png deleted file mode 100644 index d90ab661cbb..00000000000 Binary files a/python/plugins/processing/images/alg.png and /dev/null differ diff --git a/python/plugins/processing/images/alg.svg b/python/plugins/processing/images/alg.svg new file mode 100644 index 00000000000..f891c284c52 --- /dev/null +++ b/python/plugins/processing/images/alg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/commander.png b/python/plugins/processing/images/commander.png deleted file mode 100644 index 73969b9fa0b..00000000000 Binary files a/python/plugins/processing/images/commander.png and /dev/null differ diff --git a/python/plugins/processing/images/commander.svg b/python/plugins/processing/images/commander.svg new file mode 100644 index 00000000000..5f1b2765b05 --- /dev/null +++ b/python/plugins/processing/images/commander.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/config.png b/python/plugins/processing/images/config.png deleted file mode 100644 index 9460dfc746b..00000000000 Binary files a/python/plugins/processing/images/config.png and /dev/null differ diff --git a/python/plugins/processing/images/delete.png b/python/plugins/processing/images/delete.png deleted file mode 100644 index dbe7a52cbe4..00000000000 Binary files a/python/plugins/processing/images/delete.png and /dev/null differ diff --git a/python/plugins/processing/images/delete.svg b/python/plugins/processing/images/delete.svg new file mode 100644 index 00000000000..6c1a09a1ca6 --- /dev/null +++ b/python/plugins/processing/images/delete.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/edit.png b/python/plugins/processing/images/edit.png deleted file mode 100644 index 04b9ef6648b..00000000000 Binary files a/python/plugins/processing/images/edit.png and /dev/null differ diff --git a/python/plugins/processing/images/edit.svg b/python/plugins/processing/images/edit.svg new file mode 100644 index 00000000000..cc9af01b02b --- /dev/null +++ b/python/plugins/processing/images/edit.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/history.gif b/python/plugins/processing/images/history.gif deleted file mode 100644 index f5eb471895c..00000000000 Binary files a/python/plugins/processing/images/history.gif and /dev/null differ diff --git a/python/plugins/processing/images/history.svg b/python/plugins/processing/images/history.svg new file mode 100644 index 00000000000..44c0ad35952 --- /dev/null +++ b/python/plugins/processing/images/history.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/input.png b/python/plugins/processing/images/input.png deleted file mode 100644 index 1aa7f095c6c..00000000000 Binary files a/python/plugins/processing/images/input.png and /dev/null differ diff --git a/python/plugins/processing/images/input.svg b/python/plugins/processing/images/input.svg new file mode 100644 index 00000000000..42fec177554 --- /dev/null +++ b/python/plugins/processing/images/input.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/minus.png b/python/plugins/processing/images/minus.png deleted file mode 100644 index a6d648fac17..00000000000 Binary files a/python/plugins/processing/images/minus.png and /dev/null differ diff --git a/python/plugins/processing/images/minus.svg b/python/plugins/processing/images/minus.svg new file mode 100644 index 00000000000..1cc42c97ce5 --- /dev/null +++ b/python/plugins/processing/images/minus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/model.png b/python/plugins/processing/images/model.png deleted file mode 100644 index 0a96a7d7825..00000000000 Binary files a/python/plugins/processing/images/model.png and /dev/null differ diff --git a/python/plugins/processing/images/model.svg b/python/plugins/processing/images/model.svg new file mode 100644 index 00000000000..961ce92eb98 --- /dev/null +++ b/python/plugins/processing/images/model.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/output.png b/python/plugins/processing/images/output.png deleted file mode 100644 index c824d563898..00000000000 Binary files a/python/plugins/processing/images/output.png and /dev/null differ diff --git a/python/plugins/processing/images/output.svg b/python/plugins/processing/images/output.svg new file mode 100644 index 00000000000..b11d50657b8 --- /dev/null +++ b/python/plugins/processing/images/output.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/plus.png b/python/plugins/processing/images/plus.png deleted file mode 100644 index 71cd64a54f1..00000000000 Binary files a/python/plugins/processing/images/plus.png and /dev/null differ diff --git a/python/plugins/processing/images/plus.svg b/python/plugins/processing/images/plus.svg new file mode 100644 index 00000000000..eeb05d1a95d --- /dev/null +++ b/python/plugins/processing/images/plus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/results.png b/python/plugins/processing/images/results.png deleted file mode 100644 index 6f47415f512..00000000000 Binary files a/python/plugins/processing/images/results.png and /dev/null differ diff --git a/python/plugins/processing/images/results.svg b/python/plugins/processing/images/results.svg new file mode 100644 index 00000000000..4c2b3d0036d --- /dev/null +++ b/python/plugins/processing/images/results.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/images/script.png b/python/plugins/processing/images/script.png deleted file mode 100644 index c5b797a7dfe..00000000000 Binary files a/python/plugins/processing/images/script.png and /dev/null differ diff --git a/python/plugins/processing/images/script.svg b/python/plugins/processing/images/script.svg new file mode 100644 index 00000000000..6fb50b66347 --- /dev/null +++ b/python/plugins/processing/images/script.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/python/plugins/processing/metadata.txt b/python/plugins/processing/metadata.txt index 9ad3b4b9146..54aff9d8586 100644 --- a/python/plugins/processing/metadata.txt +++ b/python/plugins/processing/metadata.txt @@ -9,8 +9,8 @@ qgisMinimumVersion=2.13 author=Victor Olaya email=volayaf@gmail.com -icon=images/alg.png +icon=images/alg.svg homepage=http://qgis.org tracker=https://hub.qgis.org/projects/quantum-gis/issues -repository=https://github.com/qgis/QGIS \ No newline at end of file +repository=https://github.com/qgis/QGIS diff --git a/python/plugins/processing/modeler/AddModelFromFileAction.py b/python/plugins/processing/modeler/AddModelFromFileAction.py index 2909c98703e..3b83fd8d13b 100644 --- a/python/plugins/processing/modeler/AddModelFromFileAction.py +++ b/python/plugins/processing/modeler/AddModelFromFileAction.py @@ -46,7 +46,7 @@ class AddModelFromFileAction(ToolboxAction): self.group, self.i18n_group = self.trAction('Tools') def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'model.png')) + return QIcon(os.path.join(pluginPath, 'images', 'model.svg')) def execute(self): settings = QSettings() diff --git a/python/plugins/processing/modeler/CreateNewModelAction.py b/python/plugins/processing/modeler/CreateNewModelAction.py index 345570818f1..2639e7133eb 100644 --- a/python/plugins/processing/modeler/CreateNewModelAction.py +++ b/python/plugins/processing/modeler/CreateNewModelAction.py @@ -41,7 +41,7 @@ class CreateNewModelAction(ToolboxAction): self.group, self.i18n_group = self.trAction('Tools') def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'model.png')) + return QIcon(os.path.join(pluginPath, 'images', 'model.svg')) def execute(self): dlg = ModelerDialog() diff --git a/python/plugins/processing/modeler/ModelerAlgorithm.py b/python/plugins/processing/modeler/ModelerAlgorithm.py index 98a80448520..e327250d5f1 100644 --- a/python/plugins/processing/modeler/ModelerAlgorithm.py +++ b/python/plugins/processing/modeler/ModelerAlgorithm.py @@ -263,7 +263,7 @@ class ModelerAlgorithm(GeoAlgorithm): GeoAlgorithm.__init__(self) def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'model.png')) + return QIcon(os.path.join(pluginPath, 'images', 'model.svg')) def defineCharacteristics(self): classes = [ParameterRaster, ParameterVector, ParameterTable, ParameterTableField, @@ -507,6 +507,15 @@ class ModelerAlgorithm(GeoAlgorithm): t0 = time.time() alg.algorithm.execute(progress, self) dt = time.time() - t0 + + # copy algorithm output value(s) back to model in case the algorithm modified those + for out in alg.algorithm.outputs: + if not out.hidden: + if out.name in alg.outputs: + modelOut = self.getOutputFromName(self.getSafeNameForOutput(alg.name, out.name)) + if modelOut: + modelOut.value = out.value + executed.append(alg.name) progress.setDebugInfo( self.tr('OK. Execution took %0.3f ms (%i outputs).', 'ModelerAlgorithm') % (dt, len(alg.algorithm.outputs))) diff --git a/python/plugins/processing/modeler/ModelerAlgorithmProvider.py b/python/plugins/processing/modeler/ModelerAlgorithmProvider.py index bf8af0bce48..4ad13ddc812 100644 --- a/python/plugins/processing/modeler/ModelerAlgorithmProvider.py +++ b/python/plugins/processing/modeler/ModelerAlgorithmProvider.py @@ -67,7 +67,7 @@ class ModelerAlgorithmProvider(AlgorithmProvider): return 'model' def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'model.png')) + return QIcon(os.path.join(pluginPath, 'images', 'model.svg')) def _loadAlgorithms(self): folders = ModelerUtils.modelsFolders() diff --git a/python/plugins/processing/modeler/ModelerDialog.py b/python/plugins/processing/modeler/ModelerDialog.py index d337da8fb09..21af69f2602 100644 --- a/python/plugins/processing/modeler/ModelerDialog.py +++ b/python/plugins/processing/modeler/ModelerDialog.py @@ -31,9 +31,11 @@ import sys import os from qgis.PyQt import uic -from qgis.PyQt.QtCore import Qt, QRectF, QMimeData, QPoint, QPointF, QSettings, QByteArray, QSize, pyqtSignal -from qgis.PyQt.QtWidgets import QGraphicsView, QTreeWidget, QMessageBox, QFileDialog, QTreeWidgetItem, QSizePolicy, QMainWindow -from qgis.PyQt.QtGui import QIcon, QImage, QPainter +from qgis.PyQt.QtCore import Qt, QRectF, QMimeData, QPoint, QPointF, QSettings, QByteArray, QSize, QSizeF, pyqtSignal +from qgis.PyQt.QtWidgets import QGraphicsView, QTreeWidget, QMessageBox, QFileDialog, QTreeWidgetItem, QSizePolicy, QMainWindow, QShortcut +from qgis.PyQt.QtGui import QIcon, QImage, QPainter, QKeySequence +from qgis.PyQt.QtSvg import QSvgGenerator +from qgis.PyQt.QtPrintSupport import QPrinter from qgis.core import QgsApplication from qgis.gui import QgsMessageBar from processing.core.ProcessingConfig import ProcessingConfig @@ -207,12 +209,22 @@ class ModelerDialog(BASE, WIDGET): self.searchBox.textChanged.connect(self.fillAlgorithmTree) self.algorithmTree.doubleClicked.connect(self.addAlgorithm) + # Ctrl+= should also trigger a zoom in action + ctrlEquals = QShortcut(QKeySequence("Ctrl+="), self) + ctrlEquals.activated.connect(self.zoomIn) + iconSize = settings.value("iconsize", 24) self.mToolbar.setIconSize(QSize(iconSize, iconSize)) self.mActionOpen.triggered.connect(self.openModel) self.mActionSave.triggered.connect(self.save) self.mActionSaveAs.triggered.connect(self.saveAs) + self.mActionZoomIn.triggered.connect(self.zoomIn) + self.mActionZoomOut.triggered.connect(self.zoomOut) + self.mActionZoomActual.triggered.connect(self.zoomActual) + self.mActionZoomToItems.triggered.connect(self.zoomToItems) self.mActionExportImage.triggered.connect(self.exportAsImage) + self.mActionExportPdf.triggered.connect(self.exportAsPdf) + self.mActionExportSvg.triggered.connect(self.exportAsSvg) self.mActionExportPython.triggered.connect(self.exportAsPython) self.mActionEditHelp.triggered.connect(self.editHelp) self.mActionRun.triggered.connect(self.runModel) @@ -286,7 +298,41 @@ class ModelerDialog(BASE, WIDGET): def saveAs(self): self.saveModel(True) + def zoomIn(self): + self.view.setTransformationAnchor(QGraphicsView.NoAnchor) + point = self.view.mapToScene(QPoint(self.view.viewport().width() / 2, self.view.viewport().height() / 2)) + + settings = QSettings() + factor = settings.value('/qgis/zoom_favor', 2.0) + + self.view.scale(factor, factor) + self.view.centerOn(point) + self.repaintModel() + + def zoomOut(self): + self.view.setTransformationAnchor(QGraphicsView.NoAnchor) + point = self.view.mapToScene(QPoint(self.view.viewport().width() / 2, self.view.viewport().height() / 2)) + + settings = QSettings() + factor = settings.value('/qgis/zoom_favor', 2.0) + factor = 1 / factor + + self.view.scale(factor, factor) + self.view.centerOn(point) + self.repaintModel() + + def zoomActual(self): + point = self.view.mapToScene(QPoint(self.view.viewport().width() / 2, self.view.viewport().height() / 2)) + self.view.resetTransform() + self.view.centerOn(point) + + def zoomToItems(self): + totalRect = self.scene.itemsBoundingRect() + totalRect.adjust(-10, -10, 10, 10) + self.view.fitInView(totalRect, Qt.KeepAspectRatio) + def exportAsImage(self): + self.repaintModel(controls=False) filename, fileFilter = QFileDialog.getSaveFileName(self, self.tr('Save Model As Image'), '', self.tr('PNG files (*.png *.PNG)')) @@ -296,10 +342,9 @@ class ModelerDialog(BASE, WIDGET): if not filename.lower().endswith('.png'): filename += '.png' - totalRect = QRectF(0, 0, 1, 1) - for item in list(self.scene.items()): - totalRect = totalRect.united(item.sceneBoundingRect()) + totalRect = self.scene.itemsBoundingRect() totalRect.adjust(-10, -10, 10, 10) + imgRect = QRectF(0, 0, totalRect.width(), totalRect.height()) img = QImage(totalRect.width(), totalRect.height(), QImage.Format_ARGB32_Premultiplied) @@ -307,12 +352,69 @@ class ModelerDialog(BASE, WIDGET): painter = QPainter() painter.setRenderHint(QPainter.Antialiasing) painter.begin(img) - self.scene.render(painter, totalRect, totalRect) + self.scene.render(painter, imgRect, totalRect) painter.end() img.save(filename) self.bar.pushMessage("", "Model was correctly exported as image", level=QgsMessageBar.SUCCESS, duration=5) + self.repaintModel(controls=True) + + def exportAsPdf(self): + self.repaintModel(controls=False) + filename, fileFilter = QFileDialog.getSaveFileName(self, + self.tr('Save Model As PDF'), '', + self.tr('SVG files (*.pdf *.PDF)')) + if not filename: + return + + if not filename.lower().endswith('.pdf'): + filename += '.pdf' + + totalRect = self.scene.itemsBoundingRect() + totalRect.adjust(-10, -10, 10, 10) + printerRect = QRectF(0, 0, totalRect.width(), totalRect.height()) + + printer = QPrinter() + printer.setOutputFormat(QPrinter.PdfFormat) + printer.setOutputFileName(filename) + printer.setPaperSize(QSizeF(printerRect.width(), printerRect.height()), QPrinter.DevicePixel) + printer.setFullPage(True) + + painter = QPainter(printer) + self.scene.render(painter, printerRect, totalRect) + painter.end() + + self.bar.pushMessage("", "Model was correctly exported as PDF", level=QgsMessageBar.SUCCESS, duration=5) + self.repaintModel(controls=True) + + def exportAsSvg(self): + self.repaintModel(controls=False) + filename, fileFilter = QFileDialog.getSaveFileName(self, + self.tr('Save Model As SVG'), '', + self.tr('SVG files (*.svg *.SVG)')) + if not filename: + return + + if not filename.lower().endswith('.svg'): + filename += '.svg' + + totalRect = self.scene.itemsBoundingRect() + totalRect.adjust(-10, -10, 10, 10) + svgRect = QRectF(0, 0, totalRect.width(), totalRect.height()) + + svg = QSvgGenerator() + svg.setFileName(filename) + svg.setSize(QSize(totalRect.width(), totalRect.height())) + svg.setViewBox(svgRect) + svg.setTitle(self.alg.name) + + painter = QPainter(svg) + self.scene.render(painter, svgRect, totalRect) + painter.end() + + self.bar.pushMessage("", "Model was correctly exported as SVG", level=QgsMessageBar.SUCCESS, duration=5) + self.repaintModel(controls=True) def exportAsPython(self): filename, filter = QFileDialog.getSaveFileName(self, @@ -399,11 +501,11 @@ class ModelerDialog(BASE, WIDGET): self.tr('The selected model could not be loaded.\n' 'See the log for more information.')) - def repaintModel(self): + def repaintModel(self, controls=True): self.scene = ModelerScene() self.scene.setSceneRect(QRectF(0, 0, ModelerAlgorithm.CANVAS_SIZE, ModelerAlgorithm.CANVAS_SIZE)) - self.scene.paintModel(self.alg) + self.scene.paintModel(self.alg, controls) self.view.setScene(self.scene) def addInput(self): @@ -437,7 +539,7 @@ class ModelerDialog(BASE, WIDGET): return QPointF(newX, MARGIN + BOX_HEIGHT / 2) def fillInputsTree(self): - icon = QIcon(os.path.join(pluginPath, 'images', 'input.png')) + icon = QIcon(os.path.join(pluginPath, 'images', 'input.svg')) parametersItem = QTreeWidgetItem() parametersItem.setText(0, self.tr('Parameters')) for paramType in ModelerParameterDefinitionDialog.paramTypes: diff --git a/python/plugins/processing/modeler/ModelerGraphicItem.py b/python/plugins/processing/modeler/ModelerGraphicItem.py index b0fdf6c7c1d..d3a9668fda6 100644 --- a/python/plugins/processing/modeler/ModelerGraphicItem.py +++ b/python/plugins/processing/modeler/ModelerGraphicItem.py @@ -27,9 +27,12 @@ __copyright__ = '(C) 2012, Victor Olaya' __revision__ = '$Format:%H$' import os +import math + from qgis.PyQt.QtCore import Qt, QPointF, QRectF -from qgis.PyQt.QtGui import QIcon, QFont, QFontMetricsF, QPen, QBrush, QColor, QPolygonF +from qgis.PyQt.QtGui import QIcon, QFont, QFontMetricsF, QPen, QBrush, QColor, QPolygonF, QPicture, QPainter from qgis.PyQt.QtWidgets import QGraphicsItem, QMessageBox, QMenu +from qgis.PyQt.QtSvg import QSvgRenderer from processing.modeler.ModelerAlgorithm import ModelerParameter, Algorithm, ModelerOutput from processing.modeler.ModelerParameterDefinitionDialog import ModelerParameterDefinitionDialog from processing.modeler.ModelerParametersDialog import ModelerParametersDialog @@ -42,18 +45,25 @@ class ModelerGraphicItem(QGraphicsItem): BOX_HEIGHT = 30 BOX_WIDTH = 200 - def __init__(self, element, model): + def __init__(self, element, model, controls): super(ModelerGraphicItem, self).__init__(None) + self.controls = controls self.model = model self.element = element if isinstance(element, ModelerParameter): - icon = QIcon(os.path.join(pluginPath, 'images', 'input.png')) - self.pixmap = icon.pixmap(20, 20, state=QIcon.On) + svg = QSvgRenderer(os.path.join(pluginPath, 'images', 'input.svg')) + self.picture = QPicture() + painter = QPainter(self.picture) + svg.render(painter) + self.pixmap = None self.text = element.param.description elif isinstance(element, ModelerOutput): # Output name - icon = QIcon(os.path.join(pluginPath, 'images', 'output.png')) - self.pixmap = icon.pixmap(20, 20, state=QIcon.On) + svg = QSvgRenderer(os.path.join(pluginPath, 'images', 'output.svg')) + self.picture = QPicture() + painter = QPainter(self.picture) + svg.render(painter) + self.pixmap = None self.text = element.description else: self.text = element.description @@ -64,20 +74,26 @@ class ModelerGraphicItem(QGraphicsItem): self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True) self.setZValue(1000) - if not isinstance(element, ModelerOutput): - icon = QIcon(os.path.join(pluginPath, 'images', 'edit.png')) + if not isinstance(element, ModelerOutput) and controls: + svg = QSvgRenderer(os.path.join(pluginPath, 'images', 'edit.svg')) + picture = QPicture() + painter = QPainter(picture) + svg.render(painter) pt = QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, ModelerGraphicItem.BOX_HEIGHT / 2 - - FlatButtonGraphicItem.HEIGHT / 2 + 1) - self.editButton = FlatButtonGraphicItem(icon, pt, self.editElement) + - FlatButtonGraphicItem.HEIGHT / 2) + self.editButton = FlatButtonGraphicItem(picture, pt, self.editElement) self.editButton.setParentItem(self) - icon = QIcon(os.path.join(pluginPath, 'images', 'delete.png')) + svg = QSvgRenderer(os.path.join(pluginPath, 'images', 'delete.svg')) + picture = QPicture() + painter = QPainter(picture) + svg.render(painter) pt = QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, - ModelerGraphicItem.BOX_HEIGHT / 2 - + FlatButtonGraphicItem.HEIGHT / 2 + 1) - self.deleteButton = FlatButtonGraphicItem(icon, pt, + + FlatButtonGraphicItem.HEIGHT / 2) + self.deleteButton = FlatButtonGraphicItem(picture, pt, self.removeElement) self.deleteButton.setParentItem(self) @@ -85,14 +101,16 @@ class ModelerGraphicItem(QGraphicsItem): alg = element.algorithm if alg.parameters: pt = self.getLinkPointForParameter(-1) - pt = QPointF(0, pt.y() + 2) - self.inButton = FoldButtonGraphicItem(pt, self.foldInput, self.element.paramsFolded) - self.inButton.setParentItem(self) + pt = QPointF(0, pt.y()) + if controls: + self.inButton = FoldButtonGraphicItem(pt, self.foldInput, self.element.paramsFolded) + self.inButton.setParentItem(self) if alg.outputs: pt = self.getLinkPointForOutput(-1) - pt = QPointF(0, pt.y() + 2) - self.outButton = FoldButtonGraphicItem(pt, self.foldOutput, self.element.outputsFolded) - self.outButton.setParentItem(self) + pt = QPointF(0, pt.y()) + if controls: + self.outButton = FoldButtonGraphicItem(pt, self.foldOutput, self.element.outputsFolded) + self.outButton.setParentItem(self) def foldInput(self, folded): self.element.paramsFolded = folded @@ -117,6 +135,7 @@ class ModelerGraphicItem(QGraphicsItem): def boundingRect(self): font = QFont('Verdana', 8) + font.setPixelSize(12) fm = QFontMetricsF(font) unfolded = isinstance(self.element, Algorithm) and not self.element.paramsFolded numParams = len(self.element.algorithm.parameters) if unfolded else 0 @@ -201,6 +220,7 @@ class ModelerGraphicItem(QGraphicsItem): def getAdjustedText(self, text): font = QFont('Verdana', 8) + font.setPixelSize(12) fm = QFontMetricsF(font) w = fm.width(text) if w < self.BOX_WIDTH - 25 - FlatButtonGraphicItem.WIDTH: @@ -218,27 +238,37 @@ class ModelerGraphicItem(QGraphicsItem): -(ModelerGraphicItem.BOX_HEIGHT + 2) / 2.0, ModelerGraphicItem.BOX_WIDTH + 2, ModelerGraphicItem.BOX_HEIGHT + 2) - painter.setPen(QPen(Qt.gray, 1)) - color = QColor(125, 232, 232) + if isinstance(self.element, ModelerParameter): - color = QColor(179, 179, 255) + color = QColor(238, 242, 131) + outline = QColor(234, 226, 118) + selected = QColor(116, 113, 68) elif isinstance(self.element, Algorithm): - color = Qt.white + color = QColor(255, 255, 255) + outline = Qt.gray + selected = QColor(50, 50, 50) + else: + color = QColor(172, 196, 114) + outline = QColor(90, 140, 90) + selected = QColor(42, 65, 42) + if self.isSelected(): + outline = selected + color = color.darker(110) + painter.setPen(QPen(outline, 0)) # 0 width "cosmetic" pen painter.setBrush(QBrush(color, Qt.SolidPattern)) painter.drawRect(rect) font = QFont('Verdana', 8) + font.setPixelSize(12) painter.setFont(font) painter.setPen(QPen(Qt.black)) text = self.getAdjustedText(self.text) if isinstance(self.element, Algorithm) and not self.element.active: painter.setPen(QPen(Qt.gray)) text = text + "\n(deactivated)" - elif self.isSelected(): - painter.setPen(QPen(Qt.blue)) fm = QFontMetricsF(font) text = self.getAdjustedText(self.text) - h = fm.height() - pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, h / 2.0) + h = fm.ascent() + pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, ModelerGraphicItem.BOX_HEIGHT / 2.0 - h + 1) painter.drawText(pt, text) painter.setPen(QPen(Qt.black)) if isinstance(self.element, Algorithm): @@ -257,7 +287,7 @@ class ModelerGraphicItem(QGraphicsItem): + 33, h) painter.drawText(pt, text) i += 1 - h = fm.height() * 1.2 + h = fm.height() * 1.1 h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0 pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, h) painter.drawText(pt, 'Out') @@ -272,6 +302,9 @@ class ModelerGraphicItem(QGraphicsItem): if self.pixmap: painter.drawPixmap(-(ModelerGraphicItem.BOX_WIDTH / 2.0) + 3, -8, self.pixmap) + elif self.picture: + painter.drawPicture(-(ModelerGraphicItem.BOX_WIDTH / 2.0) + 3, -8, + self.picture) def getLinkPointForParameter(self, paramIndex): offsetX = 25 @@ -279,6 +312,7 @@ class ModelerGraphicItem(QGraphicsItem): paramIndex = -1 offsetX = 17 font = QFont('Verdana', 8) + font.setPixelSize(12) fm = QFontMetricsF(font) if isinstance(self.element, Algorithm): h = -(fm.height() * 1.2) * (paramIndex + 2) - fm.height() / 2.0 + 8 @@ -292,6 +326,7 @@ class ModelerGraphicItem(QGraphicsItem): outputIndex = (outputIndex if not self.element.outputsFolded else -1) text = self.getAdjustedText(self.element.algorithm.outputs[outputIndex].description) font = QFont('Verdana', 8) + font.setPixelSize(12) fm = QFontMetricsF(font) w = fm.width(text) h = fm.height() * 1.2 * (outputIndex + 1) + fm.height() / 2.0 @@ -312,6 +347,7 @@ class ModelerGraphicItem(QGraphicsItem): def polygon(self): font = QFont('Verdana', 8) + font.setPixelSize(12) fm = QFontMetricsF(font) hUp = fm.height() * 1.2 * (len(self.element.parameters) + 2) hDown = fm.height() * 1.2 * (len(self.element.outputs) + 2) @@ -335,12 +371,11 @@ class FlatButtonGraphicItem(QGraphicsItem): WIDTH = 16 HEIGHT = 16 - def __init__(self, icon, position, action): + def __init__(self, picture, position, action): super(FlatButtonGraphicItem, self).__init__(None) self.setAcceptHoverEvents(True) self.setFlag(QGraphicsItem.ItemIsMovable, False) - self.pixmap = icon.pixmap(self.WIDTH, self.HEIGHT, - state=QIcon.On) + self.picture = picture self.position = position self.isIn = False self.action = action @@ -349,22 +384,22 @@ class FlatButtonGraphicItem(QGraphicsItem): self.action() def paint(self, painter, option, widget=None): - pt = QPointF(-self.WIDTH / 2, -self.HEIGHT / 2) + self.position + pt = QPointF(-math.floor(self.WIDTH / 2), -math.floor(self.HEIGHT / 2)) + self.position rect = QRectF(pt.x(), pt.y(), self.WIDTH, self.HEIGHT) if self.isIn: painter.setPen(QPen(Qt.transparent, 1)) - painter.setBrush(QBrush(Qt.lightGray, + painter.setBrush(QBrush(QColor(55, 55, 55, 33), Qt.SolidPattern)) else: painter.setPen(QPen(Qt.transparent, 1)) painter.setBrush(QBrush(Qt.transparent, Qt.SolidPattern)) painter.drawRect(rect) - painter.drawPixmap(pt.x(), pt.y(), self.pixmap) + painter.drawPicture(pt.x(), pt.y(), self.picture) def boundingRect(self): - rect = QRectF(self.position.x() - self.WIDTH / 2, - self.position.y() - self.HEIGHT / 2, + rect = QRectF(self.position.x() - math.floor(self.WIDTH / 2), + self.position.y() - math.floor(self.HEIGHT / 2), self.WIDTH, self.HEIGHT) return rect @@ -384,16 +419,24 @@ class FoldButtonGraphicItem(FlatButtonGraphicItem): HEIGHT = 11 def __init__(self, position, action, folded): - self.icons = {True: QIcon(os.path.join(pluginPath, 'images', 'plus.png')), - False: QIcon(os.path.join(pluginPath, 'images', 'minus.png'))} + plus = QPicture() + minus = QPicture() + + svg = QSvgRenderer(os.path.join(pluginPath, 'images', 'plus.svg')) + painter = QPainter(plus) + svg.render(painter) + svg = QSvgRenderer(os.path.join(pluginPath, 'images', 'minus.svg')) + painter = QPainter(minus) + svg.render(painter) + + self.pictures = {True: plus, + False: minus} self.folded = folded - icon = self.icons[self.folded] - super(FoldButtonGraphicItem, self).__init__(icon, position, action) + picture = self.pictures[self.folded] + super(FoldButtonGraphicItem, self).__init__(picture, position, action) def mousePressEvent(self, event): self.folded = not self.folded - icon = self.icons[self.folded] - self.pixmap = icon.pixmap(self.WIDTH, self.HEIGHT, - state=QIcon.On) + self.picture = self.pictures[self.folded] self.action(self.folded) diff --git a/python/plugins/processing/modeler/ModelerScene.py b/python/plugins/processing/modeler/ModelerScene.py index 280c3a757b9..4d315a36404 100644 --- a/python/plugins/processing/modeler/ModelerScene.py +++ b/python/plugins/processing/modeler/ModelerScene.py @@ -78,11 +78,11 @@ class ModelerScene(QGraphicsScene): items.append((self.algItems[value.alg], i)) return items - def paintModel(self, model): + def paintModel(self, model, controls=True): self.model = model # Inputs for inp in list(model.inputs.values()): - item = ModelerGraphicItem(inp, model) + item = ModelerGraphicItem(inp, model, controls) item.setFlag(QGraphicsItem.ItemIsMovable, True) item.setFlag(QGraphicsItem.ItemIsSelectable, True) self.addItem(item) @@ -91,7 +91,7 @@ class ModelerScene(QGraphicsScene): # We add the algs for alg in list(model.algs.values()): - item = ModelerGraphicItem(alg, model) + item = ModelerGraphicItem(alg, model, controls) item.setFlag(QGraphicsItem.ItemIsMovable, True) item.setFlag(QGraphicsItem.ItemIsSelectable, True) self.addItem(item) @@ -131,7 +131,7 @@ class ModelerScene(QGraphicsScene): for key in outputs: out = outputs[key] if out is not None: - item = ModelerGraphicItem(out, model) + item = ModelerGraphicItem(out, model, controls) item.setFlag(QGraphicsItem.ItemIsMovable, True) item.setFlag(QGraphicsItem.ItemIsSelectable, True) self.addItem(item) diff --git a/python/plugins/processing/preconfigured/PreconfiguredAlgorithmProvider.py b/python/plugins/processing/preconfigured/PreconfiguredAlgorithmProvider.py index fa348e88f36..dc711a94444 100644 --- a/python/plugins/processing/preconfigured/PreconfiguredAlgorithmProvider.py +++ b/python/plugins/processing/preconfigured/PreconfiguredAlgorithmProvider.py @@ -54,7 +54,7 @@ class PreconfiguredAlgorithmProvider(AlgorithmProvider): self.algs.append(alg) def getIcon(self): - return QIcon(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'images', 'alg.png')) + return QIcon(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'images', 'alg.svg')) def getName(self): return 'preconfigured' diff --git a/python/plugins/processing/script/AddScriptFromFileAction.py b/python/plugins/processing/script/AddScriptFromFileAction.py index e23ec7bec1a..1546829a5f1 100644 --- a/python/plugins/processing/script/AddScriptFromFileAction.py +++ b/python/plugins/processing/script/AddScriptFromFileAction.py @@ -47,7 +47,7 @@ class AddScriptFromFileAction(ToolboxAction): self.group, self.i18n_group = self.trAction('Tools') def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'script.png')) + return QIcon(os.path.join(pluginPath, 'images', 'script.svg')) def execute(self): settings = QSettings() diff --git a/python/plugins/processing/script/CreateScriptCollectionPluginAction.py b/python/plugins/processing/script/CreateScriptCollectionPluginAction.py index 1ee2e2285d3..2dfd56f78be 100644 --- a/python/plugins/processing/script/CreateScriptCollectionPluginAction.py +++ b/python/plugins/processing/script/CreateScriptCollectionPluginAction.py @@ -77,7 +77,7 @@ class CreateScriptCollectionPluginAction(ToolboxAction): self.group, self.i18n_group = self.trAction('Tools') def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'script.png')) + return QIcon(os.path.join(pluginPath, 'images', 'script.svg')) def execute(self): dlg = ScriptSelector() diff --git a/python/plugins/processing/script/ScriptAlgorithm.py b/python/plugins/processing/script/ScriptAlgorithm.py index ade671b4425..3a594885a2b 100644 --- a/python/plugins/processing/script/ScriptAlgorithm.py +++ b/python/plugins/processing/script/ScriptAlgorithm.py @@ -29,7 +29,7 @@ __revision__ = '$Format:%H$' import os import re import json -from qgis.core import QgsExpressionContextUtils, QgsExpressionContext +from qgis.core import QgsExpressionContextUtils, QgsExpressionContext, QgsProject from qgis.PyQt.QtGui import QIcon from processing.core.GeoAlgorithm import GeoAlgorithm from processing.gui.Help2Html import getHtmlFromHelpFile @@ -52,7 +52,7 @@ class ScriptAlgorithm(GeoAlgorithm): """ GeoAlgorithm.__init__(self) - self._icon = QIcon(os.path.join(pluginPath, 'images', 'script.png')) + self._icon = QIcon(os.path.join(pluginPath, 'images', 'script.svg')) self.script = script self.allowEdit = True @@ -166,7 +166,7 @@ class ScriptAlgorithm(GeoAlgorithm): context = QgsExpressionContext() context.appendScope(QgsExpressionContextUtils.globalScope()) - context.appendScope(QgsExpressionContextUtils.projectScope()) + context.appendScope(QgsExpressionContextUtils.projectScope(QgsProject.instance())) for var in variables: varname = var[1:] if context.hasVariable(varname): diff --git a/python/plugins/processing/script/ScriptAlgorithmProvider.py b/python/plugins/processing/script/ScriptAlgorithmProvider.py index 9d18a538ffd..ffff9d14570 100644 --- a/python/plugins/processing/script/ScriptAlgorithmProvider.py +++ b/python/plugins/processing/script/ScriptAlgorithmProvider.py @@ -67,7 +67,7 @@ class ScriptAlgorithmProvider(AlgorithmProvider): ProcessingConfig.addSetting(ScriptUtils.SCRIPTS_FOLDER) def getIcon(self): - return QIcon(os.path.join(pluginPath, 'images', 'script.png')) + return QIcon(os.path.join(pluginPath, 'images', 'script.svg')) def getName(self): return 'script' diff --git a/python/plugins/processing/tests/AlgorithmsTestBase.py b/python/plugins/processing/tests/AlgorithmsTestBase.py index fda8998d256..d573cdd71ef 100644 --- a/python/plugins/processing/tests/AlgorithmsTestBase.py +++ b/python/plugins/processing/tests/AlgorithmsTestBase.py @@ -36,6 +36,8 @@ import os import yaml import nose2 import gdal +import shutil +import glob import hashlib import tempfile @@ -47,7 +49,7 @@ from processing.modeler.ModelerAlgorithmProvider import ModelerAlgorithmProvider from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider from processing.algs.grass7.Grass7AlgorithmProvider import Grass7AlgorithmProvider from processing.algs.lidar.LidarToolsAlgorithmProvider import LidarToolsAlgorithmProvider -from processing.algs.gdal.GdalOgrAlgorithmProvider import GdalOgrAlgorithmProvider +from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider from processing.algs.otb.OTBAlgorithmProvider import OTBAlgorithmProvider from processing.algs.r.RAlgorithmProvider import RAlgorithmProvider from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider @@ -69,6 +71,8 @@ def processingTestDataPath(): class AlgorithmsTest(object): + in_place_layers = {} + def test_algorithms(self): """ This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml @@ -110,14 +114,14 @@ class AlgorithmsTest(object): if expectFailure: try: alg.execute() - self.check_results(alg.getOutputValuesAsDictionary(), defs['results']) + self.check_results(alg.getOutputValuesAsDictionary(), defs['params'], defs['results']) except Exception: pass else: raise _UnexpectedSuccess else: alg.execute() - self.check_results(alg.getOutputValuesAsDictionary(), defs['results']) + self.check_results(alg.getOutputValuesAsDictionary(), defs['params'], defs['results']) def load_params(self, params): """ @@ -126,22 +130,30 @@ class AlgorithmsTest(object): if isinstance(params, list): return [self.load_param(p) for p in params] elif isinstance(params, dict): - return {key: self.load_param(p) for key, p in list(params.items())} + return {key: self.load_param(p, key) for key, p in list(params.items())} else: return params - def load_param(self, param): + def load_param(self, param, id=None): """ Loads a parameter. If it's not a map, the parameter will be returned as-is. If it is a map, it will process the parameter based on its key `type` and return the appropriate parameter to pass to the algorithm. """ try: if param['type'] in ('vector', 'raster', 'table'): - return self.load_layer(param) + return self.load_layer(id, param) elif param['type'] == 'multi': return [self.load_param(p) for p in param['params']] elif param['type'] == 'file': return self.filepath_from_param(param) + elif param['type'] == 'interpolation': + prefix = processingTestDataPath() + tmp = '' + for r in param['name'].split(';'): + v = r.split(',') + tmp += '{},{},{},{};'.format(os.path.join(prefix, v[0]), + v[1], v[2], v[3]) + return tmp[:-1] except TypeError: # No type specified, use whatever is there return param @@ -168,12 +180,26 @@ class AlgorithmsTest(object): raise KeyError("Unknown type '{}' specified for parameter".format(param['type'])) - def load_layer(self, param): + def load_layer(self, id, param): """ Loads a layer which was specified as parameter. """ filepath = self.filepath_from_param(param) + try: + # check if alg modifies layer in place + if param['in_place']: + tmpdir = tempfile.mkdtemp() + self.cleanup_paths.append(tmpdir) + path, file_name = os.path.split(filepath) + base, ext = os.path.splitext(file_name) + for file in glob.glob(os.path.join(path, '{}.*'.format(base))): + shutil.copy(os.path.join(path, file), tmpdir) + filepath = os.path.join(tmpdir, file_name) + self.in_place_layers[id] = filepath + except: + pass + if param['type'] in ('vector', 'table'): lyr = QgsVectorLayer(filepath, param['name'], 'ogr') elif param['type'] == 'raster': @@ -193,19 +219,22 @@ class AlgorithmsTest(object): return os.path.join(prefix, param['name']) - def check_results(self, results, expected): + def check_results(self, results, params, expected): """ Checks if result produced by an algorithm matches with the expected specification. """ for id, expected_result in list(expected.items()): if expected_result['type'] in ('vector', 'table'): - expected_lyr = self.load_layer(expected_result) - try: - results[id] - except KeyError as e: - raise KeyError('Expected result {} does not exist in {}'.format(str(e), list(results.keys()))) + expected_lyr = self.load_layer(id, expected_result) + if 'in_place_result' in expected_result: + result_lyr = QgsVectorLayer(self.in_place_layers[id], id, 'ogr') + else: + try: + results[id] + except KeyError as e: + raise KeyError('Expected result {} does not exist in {}'.format(str(e), list(results.keys()))) - result_lyr = QgsVectorLayer(results[id], id, 'ogr') + result_lyr = QgsVectorLayer(results[id], id, 'ogr') compare = expected_result.get('compare', {}) diff --git a/python/plugins/processing/tests/ParametersTest.py b/python/plugins/processing/tests/ParametersTest.py index 74d136bdbf8..08ae80d7f74 100644 --- a/python/plugins/processing/tests/ParametersTest.py +++ b/python/plugins/processing/tests/ParametersTest.py @@ -25,6 +25,8 @@ __copyright__ = '(C) 2013, Victor Olaya' __revision__ = '$Format:%H$' +import sys +from inspect import isclass from qgis.testing import start_app, unittest from processing.core.parameters import (Parameter, @@ -66,6 +68,19 @@ class ParameterTest(unittest.TestCase): parameter.setValue(123) self.assertEqual(parameter.getValueAsCommandLineParameter(), '123') + def testScriptCode(self): + """Simple check that default constructed object export/import correctly""" + paramClasses = [c for c in list(sys.modules[__name__].__dict__.values()) + if isclass(c) and issubclass(c, Parameter) and c != Parameter] + + for paramClass in paramClasses: + param = paramClass() + if hasattr(param, 'getAsScriptCode'): + code = param.getAsScriptCode() + importedParam = paramClass.fromScriptCode(code) + self.assertEquals(param.optional, importedParam.optional) + self.assertEquals(param.default, importedParam.default, param) + class ParameterBooleanTest(unittest.TestCase): @@ -578,12 +593,29 @@ class ParameterStringTest(unittest.TestCase): code = parameter.getAsScriptCode() result = getParameterFromString(code) self.assertIsInstance(result, ParameterString) + self.assertEqual(result.default, parameter.default) + parameter.default = None parameter.optional = True code = parameter.getAsScriptCode() result = getParameterFromString(code) self.assertIsInstance(result, ParameterString) self.assertTrue(result.optional) + self.assertEqual(result.default, parameter.default) + + parameter.default = 'None' + code = parameter.getAsScriptCode() + result = getParameterFromString(code) + self.assertIsInstance(result, ParameterString) + self.assertTrue(result.optional) + self.assertEqual(result.default, parameter.default) + + parameter.default = 'It\'s Mario' + code = parameter.getAsScriptCode() + result = getParameterFromString(code) + self.assertIsInstance(result, ParameterString) + self.assertTrue(result.optional) + self.assertEqual(result.default, parameter.default) class ParameterExpressionTest(unittest.TestCase): @@ -619,6 +651,7 @@ class ParameterExpressionTest(unittest.TestCase): result = getParameterFromString(code) self.assertIsInstance(result, ParameterExpression) self.assertTrue(result.optional) + self.assertEquals(result.default, parameter.default) class ParameterTableFieldTest(unittest.TestCase): diff --git a/python/plugins/processing/tests/TestData.py b/python/plugins/processing/tests/TestData.py index a0d34da7a9d..80f42b41c4a 100644 --- a/python/plugins/processing/tests/TestData.py +++ b/python/plugins/processing/tests/TestData.py @@ -36,3 +36,7 @@ def table(): def points(): return os.path.join(testDataPath, 'points.gml') + + +def invalid_geometries(): + return os.path.join(testDataPath, 'invalidgeometries.gml') diff --git a/python/plugins/processing/tests/ToolsTest.py b/python/plugins/processing/tests/ToolsTest.py index 12496b4c184..cdf089378b5 100644 --- a/python/plugins/processing/tests/ToolsTest.py +++ b/python/plugins/processing/tests/ToolsTest.py @@ -32,8 +32,9 @@ import tempfile from qgis.core import (QgsVectorLayer, QgsFeatureRequest) from qgis.testing import start_app, unittest +from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException from processing.core.ProcessingConfig import ProcessingConfig -from processing.tests.TestData import testDataPath, points +from processing.tests.TestData import testDataPath, points, invalid_geometries from processing.tools import vector testDataPath = os.path.join(os.path.dirname(__file__), 'testdata') diff --git a/python/plugins/processing/tests/testdata/custom/points.cpg b/python/plugins/processing/tests/testdata/custom/points.cpg new file mode 100644 index 00000000000..3ad133c048f --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/points.cpg @@ -0,0 +1 @@ +UTF-8 \ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/custom/points.dbf b/python/plugins/processing/tests/testdata/custom/points.dbf new file mode 100644 index 00000000000..9fad2e9ba68 Binary files /dev/null and b/python/plugins/processing/tests/testdata/custom/points.dbf differ diff --git a/python/plugins/processing/tests/testdata/custom/points.prj b/python/plugins/processing/tests/testdata/custom/points.prj new file mode 100644 index 00000000000..a30c00a55de --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/points.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/custom/points.qpj b/python/plugins/processing/tests/testdata/custom/points.qpj new file mode 100644 index 00000000000..5fbc831e743 --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/points.qpj @@ -0,0 +1 @@ +GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] diff --git a/python/plugins/processing/tests/testdata/custom/points.shp b/python/plugins/processing/tests/testdata/custom/points.shp new file mode 100644 index 00000000000..a0a4405be68 Binary files /dev/null and b/python/plugins/processing/tests/testdata/custom/points.shp differ diff --git a/python/plugins/processing/tests/testdata/custom/points.shx b/python/plugins/processing/tests/testdata/custom/points.shx new file mode 100644 index 00000000000..7699aa20d55 Binary files /dev/null and b/python/plugins/processing/tests/testdata/custom/points.shx differ diff --git a/python/plugins/processing/tests/testdata/expected/create_attr_index_points.cpg b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.cpg new file mode 100644 index 00000000000..3ad133c048f --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.cpg @@ -0,0 +1 @@ +UTF-8 \ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/expected/create_attr_index_points.dbf b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.dbf new file mode 100644 index 00000000000..d22e822c089 Binary files /dev/null and b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.dbf differ diff --git a/python/plugins/processing/tests/testdata/expected/create_attr_index_points.ind b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.ind new file mode 100644 index 00000000000..f32e58c11a1 Binary files /dev/null and b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.ind differ diff --git a/python/plugins/processing/tests/testdata/expected/create_attr_index_points.prj b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.prj new file mode 100644 index 00000000000..a30c00a55de --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/expected/create_attr_index_points.qpj b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.qpj new file mode 100644 index 00000000000..5fbc831e743 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.qpj @@ -0,0 +1 @@ +GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] diff --git a/python/plugins/processing/tests/testdata/expected/create_attr_index_points.shp b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.shp new file mode 100644 index 00000000000..a0a4405be68 Binary files /dev/null and b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.shp differ diff --git a/python/plugins/processing/tests/testdata/expected/create_attr_index_points.shx b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.shx new file mode 100644 index 00000000000..7699aa20d55 Binary files /dev/null and b/python/plugins/processing/tests/testdata/expected/create_attr_index_points.shx differ diff --git a/python/plugins/processing/tests/testdata/expected/truncated.cpg b/python/plugins/processing/tests/testdata/expected/truncated.cpg new file mode 100644 index 00000000000..3ad133c048f --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/truncated.cpg @@ -0,0 +1 @@ +UTF-8 \ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/expected/truncated.dbf b/python/plugins/processing/tests/testdata/expected/truncated.dbf new file mode 100644 index 00000000000..14d19cdcea7 Binary files /dev/null and b/python/plugins/processing/tests/testdata/expected/truncated.dbf differ diff --git a/python/plugins/processing/tests/testdata/expected/truncated.prj b/python/plugins/processing/tests/testdata/expected/truncated.prj new file mode 100644 index 00000000000..a30c00a55de --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/truncated.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/expected/truncated.qpj b/python/plugins/processing/tests/testdata/expected/truncated.qpj new file mode 100644 index 00000000000..5fbc831e743 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/truncated.qpj @@ -0,0 +1 @@ +GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] diff --git a/python/plugins/processing/tests/testdata/expected/truncated.shp b/python/plugins/processing/tests/testdata/expected/truncated.shp new file mode 100644 index 00000000000..29de63a12be Binary files /dev/null and b/python/plugins/processing/tests/testdata/expected/truncated.shp differ diff --git a/python/plugins/processing/tests/testdata/expected/truncated.shx b/python/plugins/processing/tests/testdata/expected/truncated.shx new file mode 100644 index 00000000000..29de63a12be Binary files /dev/null and b/python/plugins/processing/tests/testdata/expected/truncated.shx differ diff --git a/python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml b/python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml index 46eb3e43782..bde997c8489 100644 --- a/python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml +++ b/python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml @@ -1,34 +1,8 @@ # See ../README.md for a description of the file format tests: -# MK: 23.2.2016 / Fails on travis:OSX -# - algorithm: gdalogr:rasterize -# name: Test (gdalogr:rasterize) -# params: -# BIGTIFF: 0 -# COMPRESS: 4 -# DIMENSIONS: 0 -# EXTRA: "" -# FIELD: "Bfloatval" -# HEIGHT: 100 -# INPUT: -# name: multipolys.gml -# type: vector -# JPEGCOMPRESSION: 75 -# NO_DATA: -9999 -# PREDICTOR: 1 -# RTYPE: 5 -# TFW: False -# TILED: False -# WIDTH: 100 -# ZLEVEL: 6 -# results: -# OUTPUT: -# hash: f1fedeb6782f9389cf43590d4c85ada9155ab61fef6dc285aaeb54d6 -# type: rasterhash - - - algorithm: gdalorg:rasterinfo - name: GDAL gdalinfo + - algorithm: gdal:gdalinfo + name: gdalinfo params: INPUT: name: raster.tif @@ -44,20 +18,8 @@ tests: - 'Band 1 Block=16x14 Type=Float32, ColorInterp=Gray' - ' NoData Value=-32768' -# - algorithm: gdalogr:polygonize -# name: GDAL polygonize -# params: -# FIELD: DN -# INPUT: -# name: raster.tif -# type: raster -# results: -# OUTPUT: -# name: expected/gdal/polygonize.gml -# type: vector - - - algorithm: gdalogr:information - name: GDAL ogrinfo + - algorithm: gdal:ogrinfo + name: ogrinfo params: INPUT: name: lines.gml @@ -72,8 +34,8 @@ tests: - 'Geometry: Line String' - 'Feature Count: [6|7]' # On some platforms returns 6 instead of 7... - - algorithm: gdalogr:buffervectors - name: OGR buffer lines + - algorithm: gdal:buffervectors + name: Buffer lines params: DISSOLVEALL: false DISTANCE: 1.0 @@ -92,8 +54,8 @@ tests: expectedFailure: - int(1) - - algorithm: gdalogr:buffervectors - name: OGR basic polygon buffer + - algorithm: gdal:buffervectors + name: Basic polygon buffer params: DISSOLVEALL: false DISTANCE: 0.5 @@ -110,8 +72,8 @@ tests: geometry: precision: 7 - - algorithm: gdalogr:buffervectors - name: OGR polygon buffer with dissolve + - algorithm: gdal:buffervectors + name: Polygon buffer with dissolve params: DISSOLVEALL: true DISTANCE: 0.5 @@ -128,8 +90,8 @@ tests: geometry: precision: 7 - - algorithm: gdalogr:createpointsalonglines - name: OGR points along lines + - algorithm: gdal:createpointsalonglines + name: Points along lines params: DISTANCE: 0.25 GEOMETRY: geometry @@ -141,8 +103,8 @@ tests: name: expected/gdal/points_along_lines.gml type: vector - - algorithm: gdalogr:offsetlinesforlines - name: OGR offset lines for lines (right-handed) + - algorithm: gdal:offsetlinesforlines + name: Offset lines for lines (right-handed) params: DISSOLVEALL: false GEOMETRY: geometry @@ -159,8 +121,8 @@ tests: geometry: precision: 7 - - algorithm: gdalogr:singlesidedbufferforlines - name: OGR one-side buffer for lines (left-handed) + - algorithm: gdal:singlesidedbufferforlines + name: One-side buffer for lines (left-handed) params: DISSOLVEALL: false GEOMETRY: geometry @@ -177,3 +139,318 @@ tests: compare: geometry: precision: 7 + + - algorithm: gdal:aspect + name: Aspect with standard parameters + params: + BAND: 1 + COMPUTE_EDGES: false + INPUT: + name: dem.tif + type: raster + TRIG_ANGLE: false + ZERO_FLAT: false + ZEVENBERGEN: false + results: + OUTPUT: + hash: 8436df662a44a00762aa29768e5d6ecfaf2d42e9a4da02d8afc6e3f6 + type: rasterhash + + - algorithm: gdal:aspect + name: Aspect without NULL (-9999) values (0 instead) + params: + BAND: 1 + COMPUTE_EDGES: false + INPUT: + name: dem.tif + type: raster + TRIG_ANGLE: false + ZERO_FLAT: true + ZEVENBERGEN: false + results: + OUTPUT: + hash: 43cccb440c7febb0095103eee3509b740e9f1bf2b3ad3b8a4c25622e + type: rasterhash + + - algorithm: gdal:aspect + name: Aspect with trigonometric angle + params: + BAND: 1 + COMPUTE_EDGES: false + INPUT: + name: dem.tif + type: raster + TRIG_ANGLE: true + ZERO_FLAT: false + ZEVENBERGEN: false + results: + OUTPUT: + hash: a95e8a09a613b551d3f33dfb4975c430f599dc55f761063ae9529124 + type: rasterhash + + - algorithm: gdal:aspect + name: Aspect zevenbergen + params: + BAND: 1 + COMPUTE_EDGES: false + INPUT: + name: dem.tif + type: raster + TRIG_ANGLE: false + ZERO_FLAT: false + ZEVENBERGEN: true + results: + OUTPUT: + hash: 2cd5868b21efbd286f4977795143c89df77ac8976f8bc2a2c4e310d8 + type: rasterhash + + - algorithm: gdal:aspect + name: Aspect with edges + params: + BAND: 1 + COMPUTE_EDGES: true + INPUT: + name: dem.tif + type: raster + TRIG_ANGLE: false + ZERO_FLAT: false + ZEVENBERGEN: false + results: + OUTPUT: + hash: d3a354c6e5f207779bb58f9bd23fd89a9f90a77d81aafc661d0ae077 + type: rasterhash + + - algorithm: gdal:cliprasterbyextent + name: Clip raster by extent + params: + BIGTIFF: '0' + COMPRESS: '4' + INPUT: + name: dem.tif + type: raster + JPEGCOMPRESSION: 75 + PREDICTOR: 1 + PROJWIN: 18.67551824296977,18.697800756150787,45.78984181545589,45.804309302274866 + RTYPE: '5' + TFW: false + TILED: false + ZLEVEL: 6 + results: + OUTPUT: + hash: 9913a7c0e1ced2c2ce1cd8f0e8103475bc2b0dd4d1d0adafe4920f93 + type: rasterhash + + - algorithm: gdal:cliprasterbyextent + name: Clip raster by extent and change no data values + params: + BIGTIFF: '0' + COMPRESS: '4' + INPUT: + name: dem.tif + type: raster + JPEGCOMPRESSION: 75 + NO_DATA: '-9999' + PREDICTOR: 1 + PROJWIN: 18.67460436727692,18.698371162148714,45.78995019401027,45.804344168369234 + RTYPE: '5' + TFW: false + TILED: false + ZLEVEL: 6 + results: + OUTPUT: + hash: df5de501bcec0c10f738d77f3b48d5545b48f0a22e0e028a8b1ccbe7 + type: rasterhash + + - algorithm: gdal:cliprasterbymasklayer + name: Clip raster by mask layer + params: + ALPHA_BAND: false + BIGTIFF: '0' + COMPRESS: '4' + CROP_TO_CUTLINE: true + INPUT: + name: dem.tif + type: raster + JPEGCOMPRESSION: 75 + KEEP_RESOLUTION: false + MASK: + name: custom/polygon_mask.gml + type: vector + PREDICTOR: 1 + RTYPE: '5' + TFW: false + TILED: false + ZLEVEL: 6 + results: + OUTPUT: + hash: 4f4720e4efe59a7f238f622659917bbeb5262369d15d5e2917dbcf8b + type: rasterhash + + - algorithm: gdal:cliprasterbymasklayer + name: Clip raster by mask layer and change no data value + params: + ALPHA_BAND: false + BIGTIFF: '0' + COMPRESS: '4' + CROP_TO_CUTLINE: true + INPUT: + name: dem.tif + type: raster + JPEGCOMPRESSION: 75 + KEEP_RESOLUTION: false + MASK: + name: custom/polygon_mask.gml + type: vector + NO_DATA: '-9999' + PREDICTOR: 1 + RTYPE: '5' + TFW: false + TILED: false + ZLEVEL: 6 + results: + OUTPUT: + hash: 1e0252e63c65dcf4ed1f2b17d2490d3e0331aeb59d8f59b59554f442 + type: rasterhash + + - algorithm: gdal:cliprasterbymasklayer + name: Clip raster by mask layer and add alpha band + params: + ALPHA_BAND: true + BIGTIFF: '0' + COMPRESS: '4' + CROP_TO_CUTLINE: true + INPUT: + name: dem.tif + type: raster + JPEGCOMPRESSION: 75 + KEEP_RESOLUTION: false + MASK: + name: custom/polygon_mask.gml + type: vector + PREDICTOR: 1 + RTYPE: '5' + TFW: false + TILED: false + ZLEVEL: 6 + results: + OUTPUT: + hash: 8f69431c6ff7db5174c1ca8e879ae39582fd4ce86f9b53edae0f38ce + type: rasterhash + + - algorithm: gdal:hillshade + name: Hillshade + params: + ALTITUDE: 45.0 + AZIMUTH: 315.0 + BAND: 1 + COMPUTE_EDGES: false + INPUT: + name: dem.tif + type: raster + SCALE: 1.0 + ZEVENBERGEN: false + Z_FACTOR: 1.0 + results: + OUTPUT: + hash: e5cf91b875b918682e456463165eddc4af4ae8855b143068e198ce2a + type: rasterhash + + - algorithm: gdal:hillshade + name: Hillshade with edges calculation + params: + ALTITUDE: 45.0 + AZIMUTH: 315.0 + BAND: 1 + COMPUTE_EDGES: true + INPUT: + name: dem.tif + type: raster + SCALE: 1.0 + ZEVENBERGEN: false + Z_FACTOR: 1.0 + results: + OUTPUT: + hash: 570671408b020c9cc817e876f0e8081e0b11920c7d297abfe1cb3368 + type: rasterhash + + - algorithm: gdal:hillshade + name: Hillshade with Zevenbergen formula + params: + ALTITUDE: 45.0 + AZIMUTH: 315.0 + BAND: 1 + COMPUTE_EDGES: false + INPUT: + name: dem.tif + type: raster + SCALE: 1.0 + ZEVENBERGEN: true + Z_FACTOR: 1.0 + results: + OUTPUT: + hash: ce2174ab155023367d38785fb867456c6a1ae3535ea0ec5ad7a694d5 + type: rasterhash + + - algorithm: gdal:slope + name: Slope + params: + AS_PERCENT: false + BAND: 1 + COMPUTE_EDGES: false + INPUT: + name: dem.tif + type: raster + SCALE: 1.0 + ZEVENBERGEN: false + results: + OUTPUT: + hash: 319c470de3315f440371d5df8a6e478a8ecaf1cf904a013dbf1b3a6a + type: rasterhash + + - algorithm: gdal:slope + name: Slope with edges + params: + AS_PERCENT: false + BAND: 1 + COMPUTE_EDGES: true + INPUT: + name: dem.tif + type: raster + SCALE: 1.0 + ZEVENBERGEN: false + results: + OUTPUT: + hash: f7f8df8b6517fd8660304f7f2fbd6ade2ae68035f4dd9a224c80b465 + type: rasterhash + + - algorithm: gdal:slope + name: Slope with Zevenbergen formula + params: + AS_PERCENT: false + BAND: 1 + COMPUTE_EDGES: false + INPUT: + name: dem.tif + type: raster + SCALE: 1.0 + ZEVENBERGEN: true + results: + OUTPUT: + hash: 90e42b1bc7be9cf7b4a729c6db44dde0bba39dd33012ade6bc8080e7 + type: rasterhash + + - algorithm: gdal:slope + name: Slope with percent instead of degree + params: + AS_PERCENT: true + BAND: 1 + COMPUTE_EDGES: false + INPUT: + name: dem.tif + type: raster + SCALE: 1.0 + ZEVENBERGEN: false + results: + OUTPUT: + hash: c9dc888254a571e7fbf66691fb72b35f030f87decf59ce67e32ad89d + type: rasterhash diff --git a/python/plugins/processing/tests/testdata/invalidgeometries.gfs b/python/plugins/processing/tests/testdata/invalidgeometries.gfs new file mode 100644 index 00000000000..cb490f0326f --- /dev/null +++ b/python/plugins/processing/tests/testdata/invalidgeometries.gfs @@ -0,0 +1,15 @@ + + + invalidgeometries + invalidgeometries + 3 + EPSG:4326 + + 1 + 122.17632 + 122.19038 + -8.60636 + -8.59579 + + + diff --git a/python/plugins/processing/tests/testdata/invalidgeometries.gml b/python/plugins/processing/tests/testdata/invalidgeometries.gml new file mode 100644 index 00000000000..b8b426b2865 --- /dev/null +++ b/python/plugins/processing/tests/testdata/invalidgeometries.gml @@ -0,0 +1,19 @@ + + + + + 122.1763203897661-8.606355050987483 + 122.1903768142314-8.595792419886385 + + + + + + 122.176320389766076,-8.601236237453875 122.179976685147238,-8.597742444089665 122.184526741621553,-8.598392452157425 122.188508041036584,-8.602129998547044 122.186395514816354,-8.606355050987483 122.183795482545321,-8.602617504597864 122.188508041036584,-8.598311201148954 122.190376814231385,-8.595792419886385 122.190376814231385,-8.595792419886385 122.176320389766076,-8.601236237453875 + + + diff --git a/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml b/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml index a02a50bc555..af2bb45c39e 100644 --- a/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml +++ b/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml @@ -1226,26 +1226,24 @@ tests: name: expected/multipoint_delaunay.gml type: vector - - algorithm: qgis:idwinterpolationusingattribute + - algorithm: qgis:idwinterpolation name: IDW interpolation using attribute params: - ATTRIBUTE: elev CELLSIZE_X: 0.02667 CELLSIZE_Y: 0.02667 COLUMNS: 300 DISTANCE_COEFFICIENT: 2.0 EXTENT: 0, 8, -5, 3 - INPUT_LAYER: - name: pointsz.gml - type: vector - LAYER_TYPE: '0' + INTERPOLATION_DATA: + name: pointsz.gml,False,1,0 + type: interpolation ROWS: 300 results: OUTPUT_LAYER: hash: 56d2671d50444f8571affba3f9e585830b82af5e380394178f521065 type: rasterhash - - algorithm: qgis:idwinterpolationusingzvalues + - algorithm: qgis:idwinterpolation name: IDW interpolation using Z value params: CELLSIZE_X: 0.02667 @@ -1253,28 +1251,25 @@ tests: COLUMNS: 300 DISTANCE_COEFFICIENT: 2.0 EXTENT: 0, 8, -5, 3 - INPUT_LAYER: - name: pointsz.gml - type: vector - LAYER_TYPE: '0' + INTERPOLATION_DATA: + name: pointsz.gml,True,-1,0 + type: interpolation ROWS: 300 results: OUTPUT_LAYER: hash: 56d2671d50444f8571affba3f9e585830b82af5e380394178f521065 type: rasterhash - - algorithm: qgis:tininterpolationusingattribute + - algorithm: qgis:tininterpolation name: TIN interpolation using attribute params: - ATTRIBUTE: elev CELLSIZE_X: 0.02667 CELLSIZE_Y: 0.02667 COLUMNS: 300 EXTENT: 0, 8, -5, 3 - INPUT_LAYER: - name: pointsz.gml - type: vector - LAYER_TYPE: '0' + INTERPOLATION_DATA: + name: pointsz.gml,False,1,0 + type: interpolation METHOD: '0' ROWS: 300 results: @@ -1285,17 +1280,16 @@ tests: # name: expected/triangulation.gml # type: vector - - algorithm: qgis:tininterpolationusingzvalues + - algorithm: qgis:tininterpolation name: TIN interpolation using Z value params: CELLSIZE_X: 0.02667 CELLSIZE_Y: 0.02667 COLUMNS: 300 EXTENT: 0, 8, -5, 3 - INPUT_LAYER: - name: pointsz.gml - type: vector - LAYER_TYPE: '0' + INTERPOLATION_DATA: + name: pointsz.gml,True,-1,0 + type: interpolation METHOD: '1' ROWS: 300 results: @@ -2040,348 +2034,6 @@ tests: name: expected/convex_hull_fields.gml type: vector - - algorithm: gdalogr:aspect - name: aspect with standard parameters - params: - BAND: 1 - COMPUTE_EDGES: false - INPUT: - name: dem.tif - type: raster - TRIG_ANGLE: false - ZERO_FLAT: false - ZEVENBERGEN: false - results: - OUTPUT: - hash: 8436df662a44a00762aa29768e5d6ecfaf2d42e9a4da02d8afc6e3f6 - type: rasterhash - - - algorithm: gdalogr:aspect - name: aspect without NULL (-9999) values (0 instead) - params: - BAND: 1 - COMPUTE_EDGES: false - INPUT: - name: dem.tif - type: raster - TRIG_ANGLE: false - ZERO_FLAT: true - ZEVENBERGEN: false - results: - OUTPUT: - hash: 43cccb440c7febb0095103eee3509b740e9f1bf2b3ad3b8a4c25622e - type: rasterhash - - - algorithm: gdalogr:aspect - name: aspect with trigonometric angle - params: - BAND: 1 - COMPUTE_EDGES: false - INPUT: - name: dem.tif - type: raster - TRIG_ANGLE: true - ZERO_FLAT: false - ZEVENBERGEN: false - results: - OUTPUT: - hash: a95e8a09a613b551d3f33dfb4975c430f599dc55f761063ae9529124 - type: rasterhash - - - algorithm: gdalogr:aspect - name: aspect zevenbergen - params: - BAND: 1 - COMPUTE_EDGES: false - INPUT: - name: dem.tif - type: raster - TRIG_ANGLE: false - ZERO_FLAT: false - ZEVENBERGEN: true - results: - OUTPUT: - hash: 2cd5868b21efbd286f4977795143c89df77ac8976f8bc2a2c4e310d8 - type: rasterhash - - - - algorithm: gdalogr:aspect - name: aspect with edges - params: - BAND: 1 - COMPUTE_EDGES: true - INPUT: - name: dem.tif - type: raster - TRIG_ANGLE: false - ZERO_FLAT: false - ZEVENBERGEN: false - results: - OUTPUT: - hash: d3a354c6e5f207779bb58f9bd23fd89a9f90a77d81aafc661d0ae077 - type: rasterhash - - - algorithm: gdalogr:cliprasterbyextent - name: standard clip raster by extent - params: - BIGTIFF: '0' - COMPRESS: '4' - INPUT: - name: dem.tif - type: raster - JPEGCOMPRESSION: 75 - PREDICTOR: 1 - PROJWIN: 18.67551824296977,18.697800756150787,45.78984181545589,45.804309302274866 - RTYPE: '5' - TFW: false - TILED: false - ZLEVEL: 6 - results: - OUTPUT: - hash: 9913a7c0e1ced2c2ce1cd8f0e8103475bc2b0dd4d1d0adafe4920f93 - type: rasterhash - - - algorithm: gdalogr:cliprasterbyextent - name: clip by extent and change no data values - params: - BIGTIFF: '0' - COMPRESS: '4' - INPUT: - name: dem.tif - type: raster - JPEGCOMPRESSION: 75 - NO_DATA: '-9999' - PREDICTOR: 1 - PROJWIN: 18.67460436727692,18.698371162148714,45.78995019401027,45.804344168369234 - RTYPE: '5' - TFW: false - TILED: false - ZLEVEL: 6 - results: - OUTPUT: - hash: df5de501bcec0c10f738d77f3b48d5545b48f0a22e0e028a8b1ccbe7 - type: rasterhash - - - - algorithm: gdalogr:cliprasterbymasklayer - name: clip by extent standard (with crop to cutline) - params: - ALPHA_BAND: false - BIGTIFF: '0' - COMPRESS: '4' - CROP_TO_CUTLINE: true - INPUT: - name: dem.tif - type: raster - JPEGCOMPRESSION: 75 - KEEP_RESOLUTION: false - MASK: - name: custom/polygon_mask.gml - type: vector - PREDICTOR: 1 - RTYPE: '5' - TFW: false - TILED: false - ZLEVEL: 6 - results: - OUTPUT: - hash: 4f4720e4efe59a7f238f622659917bbeb5262369d15d5e2917dbcf8b - type: rasterhash - - - algorithm: gdalogr:cliprasterbymasklayer - name: clip by extent and change no data value - params: - ALPHA_BAND: false - BIGTIFF: '0' - COMPRESS: '4' - CROP_TO_CUTLINE: true - INPUT: - name: dem.tif - type: raster - JPEGCOMPRESSION: 75 - KEEP_RESOLUTION: false - MASK: - name: custom/polygon_mask.gml - type: vector - NO_DATA: '-9999' - PREDICTOR: 1 - RTYPE: '5' - TFW: false - TILED: false - ZLEVEL: 6 - results: - OUTPUT: - hash: 1e0252e63c65dcf4ed1f2b17d2490d3e0331aeb59d8f59b59554f442 - type: rasterhash - - - algorithm: gdalogr:cliprasterbymasklayer - name: clip by extent and add alpha band - params: - ALPHA_BAND: true - BIGTIFF: '0' - COMPRESS: '4' - CROP_TO_CUTLINE: true - INPUT: - name: dem.tif - type: raster - JPEGCOMPRESSION: 75 - KEEP_RESOLUTION: false - MASK: - name: custom/polygon_mask.gml - type: vector - PREDICTOR: 1 - RTYPE: '5' - TFW: false - TILED: false - ZLEVEL: 6 - results: - OUTPUT: - hash: 8f69431c6ff7db5174c1ca8e879ae39582fd4ce86f9b53edae0f38ce - type: rasterhash - - - algorithm: gdalogr:cliprasterbymasklayer - name: clip by extent without cropping to cutline - params: - ALPHA_BAND: false - BIGTIFF: '0' - COMPRESS: '4' - CROP_TO_CUTLINE: false - INPUT: - name: dem.tif - type: raster - JPEGCOMPRESSION: 75 - KEEP_RESOLUTION: false - MASK: - name: custom/polygon_mask.gml - type: vector - PREDICTOR: 1 - RTYPE: '5' - TFW: false - TILED: false - ZLEVEL: 6 - results: - OUTPUT: - hash: 638165612b8cf59c631533438633c6c5b0fd5d3698d6ce75b359eef3 - type: rasterhash - - - algorithm: gdalogr:hillshade - name: hillshade standard - params: - ALTITUDE: 45.0 - AZIMUTH: 315.0 - BAND: 1 - COMPUTE_EDGES: false - INPUT: - name: dem.tif - type: raster - SCALE: 1.0 - ZEVENBERGEN: false - Z_FACTOR: 1.0 - results: - OUTPUT: - hash: e5cf91b875b918682e456463165eddc4af4ae8855b143068e198ce2a - type: rasterhash - - - algorithm: gdalogr:hillshade - name: hillshade with edges calculation - params: - ALTITUDE: 45.0 - AZIMUTH: 315.0 - BAND: 1 - COMPUTE_EDGES: true - INPUT: - name: dem.tif - type: raster - SCALE: 1.0 - ZEVENBERGEN: false - Z_FACTOR: 1.0 - results: - OUTPUT: - hash: 570671408b020c9cc817e876f0e8081e0b11920c7d297abfe1cb3368 - type: rasterhash - - - algorithm: gdalogr:hillshade - name: hillshade with zevenbergen formula - params: - ALTITUDE: 45.0 - AZIMUTH: 315.0 - BAND: 1 - COMPUTE_EDGES: false - INPUT: - name: dem.tif - type: raster - SCALE: 1.0 - ZEVENBERGEN: true - Z_FACTOR: 1.0 - results: - OUTPUT: - hash: ce2174ab155023367d38785fb867456c6a1ae3535ea0ec5ad7a694d5 - type: rasterhash - - - algorithm: gdalogr:slope - name: slope with standard parameters - params: - AS_PERCENT: false - BAND: 1 - COMPUTE_EDGES: false - INPUT: - name: dem.tif - type: raster - SCALE: 1.0 - ZEVENBERGEN: false - results: - OUTPUT: - hash: 319c470de3315f440371d5df8a6e478a8ecaf1cf904a013dbf1b3a6a - type: rasterhash - - - algorithm: gdalogr:slope - name: slope with edges - params: - AS_PERCENT: false - BAND: 1 - COMPUTE_EDGES: true - INPUT: - name: dem.tif - type: raster - SCALE: 1.0 - ZEVENBERGEN: false - results: - OUTPUT: - hash: f7f8df8b6517fd8660304f7f2fbd6ade2ae68035f4dd9a224c80b465 - type: rasterhash - - - algorithm: gdalogr:slope - name: slope with zevenbergen formula - params: - AS_PERCENT: false - BAND: 1 - COMPUTE_EDGES: false - INPUT: - name: dem.tif - type: raster - SCALE: 1.0 - ZEVENBERGEN: true - results: - OUTPUT: - hash: 90e42b1bc7be9cf7b4a729c6db44dde0bba39dd33012ade6bc8080e7 - type: rasterhash - - - algorithm: gdalogr:slope - name: slope with percent instead of degree - params: - AS_PERCENT: true - BAND: 1 - COMPUTE_EDGES: false - INPUT: - name: dem.tif - type: raster - SCALE: 1.0 - ZEVENBERGEN: false - results: - OUTPUT: - hash: c9dc888254a571e7fbf66691fb72b35f030f87decf59ce67e32ad89d - type: rasterhash - # These tests dissabled because algs require access to iface which # is not available in the test suite. #- algorithm: qgis:shortestpathpointtopoint @@ -2438,3 +2090,43 @@ tests: # OUTPUT_POLYGON: # name: expected/servicearea_bounds.gml # type: vector + + - algorithm: qgis:createattributeindex + name: Create attribute index + params: + FIELD: id + INPUT: + name: custom/points.shp + type: vector + in_place: true + results: + INPUT: + name: expected/create_attr_index_points.shp + type: vector + in_place_result: true + + - algorithm: qgis:createspatialindex + name: Create spatial index + params: + INPUT: + name: custom/points.shp + type: vector + in_place: true + results: + INPUT: + name: expected/create_attr_index_points.shp + type: vector + in_place_result: true + + - algorithm: qgis:truncatetable + name: Truncate table + params: + INPUT: + name: custom/points.shp + type: vector + in_place: true + results: + INPUT: + name: expected/truncated.shp + type: vector + in_place_result: true diff --git a/python/plugins/processing/tools/vector.py b/python/plugins/processing/tools/vector.py index 1413ae5a883..4677940a712 100644 --- a/python/plugins/processing/tools/vector.py +++ b/python/plugins/processing/tools/vector.py @@ -24,6 +24,7 @@ from builtins import str from builtins import range from builtins import object + __author__ = 'Victor Olaya' __date__ = 'February 2013' __copyright__ = '(C) 2013, Victor Olaya' @@ -42,13 +43,14 @@ import io import psycopg2 from osgeo import ogr -from qgis.PyQt.QtCore import QVariant, QSettings +from qgis.PyQt.QtCore import QVariant, QSettings, QCoreApplication from qgis.core import (Qgis, QgsFields, QgsField, QgsGeometry, QgsRectangle, QgsWkbTypes, QgsSpatialIndex, QgsProject, QgsMapLayer, QgsVectorLayer, QgsVectorFileWriter, QgsDistanceArea, QgsDataSourceUri, QgsCredentials, QgsFeatureRequest, QgsWkbTypes) from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.ProcessingLog import ProcessingLog from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException from processing.tools import dataobjects, spatialite, postgis @@ -95,6 +97,8 @@ def features(layer, request=QgsFeatureRequest()): """ class Features(object): + DO_NOT_CHECK, IGNORE, RAISE_EXCEPTION = range(3) + def __init__(self, layer, request): self.layer = layer self.selection = False @@ -105,6 +109,27 @@ def features(layer, request=QgsFeatureRequest()): else: self.iter = layer.getFeatures(request) + invalidFeaturesMethod = ProcessingConfig.getSetting(ProcessingConfig.FILTER_INVALID_GEOMETRIES) + + def filterFeature(f, ignoreInvalid): + geom = f.geometry() + if geom is None: + ProcessingLog.addToLog(ProcessingLog.LOG_INFO, + self.tr('Feature with NULL geometry found.')) + elif not geom.isGeosValid(): + ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, + self.tr('GEOS geoprocessing error: One or more input features have invalid geometry.')) + if ignoreInvalid: + return False + else: + raise GeoAlgorithmExecutionException(self.tr('Features with invalid geometries found. Please fix these geometries or specify the "Ignore invalid input features" flag')) + return True + + if invalidFeaturesMethod == self.IGNORE: + self.iter = filter(lambda x: filterFeature(x, True), self.iter) + elif invalidFeaturesMethod == self.RAISE_EXCEPTION: + self.iter = filter(lambda x: filterFeature(x, False), self.iter) + def __iter__(self): return self.iter @@ -114,6 +139,9 @@ def features(layer, request=QgsFeatureRequest()): else: return int(self.layer.featureCount()) + def tr(self, string): + return QCoreApplication.translate("FeatureIterator", string) + return Features(layer, request) diff --git a/python/plugins/processing/ui/DlgModeler.ui b/python/plugins/processing/ui/DlgModeler.ui index 42535793757..79da12ad29a 100644 --- a/python/plugins/processing/ui/DlgModeler.ui +++ b/python/plugins/processing/ui/DlgModeler.ui @@ -19,7 +19,7 @@ 3 - 6 + 2 @@ -55,7 +55,7 @@ Qt::WheelFocus - QFrame::StyledPanel + QFrame::NoFrame QFrame::Plain @@ -149,7 +149,7 @@ Qt::WheelFocus - QFrame::StyledPanel + QFrame::NoFrame QFrame::Plain @@ -171,7 +171,7 @@ 4 - 6 + 2 @@ -179,7 +179,7 @@ 4 - 6 + 0 @@ -219,7 +219,7 @@ 0 - 0 + 2 @@ -233,7 +233,7 @@ Qt::WheelFocus - QFrame::StyledPanel + QFrame::NoFrame QFrame::Plain @@ -252,18 +252,18 @@ - 4 + 0 - 6 + 2 - 4 + 0 - 6 + 0 @@ -309,7 +309,14 @@ + + + + + + + @@ -361,6 +368,51 @@ Ctrl+Shift+S + + + + :/images/themes/default/mActionZoomActual.svg:/images/themes/default/mActionZoomActual.svg + + + Zoom to &100% + + + Zoom to &100% + + + Ctrl+1 + + + + + + :/images/themes/default/mActionZoomIn.svg:/images/themes/default/mActionZoomIn.svg + + + Zoom in + + + Zoom in + + + Ctrl++ + + + + + + :/images/themes/default/mActionZoomOut.svg:/images/themes/default/mActionZoomOut.svg + + + Zoom out + + + Zoom out + + + Ctrl+- + + @@ -373,6 +425,45 @@ Export as image + + + + :/images/themes/default/mActionZoomFullExtent.svg:/images/themes/default/mActionZoomFullExtent.svg + + + Zoom full + + + Zoom full + + + Ctrl+0 + + + + + + :/images/themes/default/mActionSaveAsPDF.svg:/images/themes/default/mActionSaveAsPDF.svg + + + Export as PDF... + + + Export as PDF + + + + + + :/images/themes/default/mActionSaveAsSVG.svg:/images/themes/default/mActionSaveAsSVG.svg + + + Export as SVG... + + + Export as SVG + + diff --git a/python/pyplugin_installer/version_compare.py b/python/pyplugin_installer/version_compare.py index 116ba723b2f..4071d3091fd 100644 --- a/python/pyplugin_installer/version_compare.py +++ b/python/pyplugin_installer/version_compare.py @@ -23,7 +23,7 @@ and recognizes all major notations, prefixes (ver. and version), delimiters Usage: compareVersions(version1, version2) -The function accepts arguments of any type convertable to unicode string +The function accepts arguments of any type convertable to Unicode string and returns integer value: 0 - the versions are equal 1 - version 1 is higher @@ -31,7 +31,7 @@ and returns integer value: ----------------------------------------------------------------------------- HOW DOES IT WORK... -First, both arguments are converted to uppercase unicode and stripped of +First, both arguments are converted to uppercase Unicode and stripped of 'VERSION' or 'VER.' prefix. Then they are chopped into a list of particular numeric and alphabetic elements. The dots, dashes and underlines are recognized as delimiters. Also numbers and non numbers are separated. See example below: diff --git a/python/sip_helpers/CMakeLists.txt b/python/sip_helpers/CMakeLists.txt index 88f0f812fcd..46460fbd069 100644 --- a/python/sip_helpers/CMakeLists.txt +++ b/python/sip_helpers/CMakeLists.txt @@ -17,7 +17,8 @@ INCLUDE_DIRECTORIES(SYSTEM ) INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR}/../core + ${CMAKE_BINARY_DIR}/python/core + ${CMAKE_BINARY_DIR}/src/core ../../src/core ../../src/core/auth ../../src/core/pal diff --git a/resources/context_help/QgsDelimitedTextSourceSelect b/resources/context_help/QgsDelimitedTextSourceSelect index 7c3f549c97b..9c8689ac1c2 100644 --- a/resources/context_help/QgsDelimitedTextSourceSelect +++ b/resources/context_help/QgsDelimitedTextSourceSelect @@ -166,9 +166,9 @@ are escaped.

    Regular expressions are mini-language used to represent character patterns. There are many variations of regular expression syntax - QGIS uses the syntax provided by the QRegExp class of the Qt framework.

    In a regular expression delimited file each line is treated as a record. Each match of the regular expression in the line is treated as the end of a field. -If the regular expression contains capture groups (eg (cat|dog)) +If the regular expression contains capture groups (e.g., (cat|dog)) then these are extracted as fields. - If this is not desired then use non-capturing groups (eg (?:cat|dog)). + If this is not desired then use non-capturing groups (e.g., (?:cat|dog)).

    The regular expression is treated differently if it is anchored to the start of the line (that is, the pattern starts with ^). In this case the regular expression is matched against each line. If the line does not match it is discarded @@ -190,12 +190,12 @@ The delimited text layer recognizes the following well known text types - POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON, and MULTIPOLYGON. It will accept geometries with -a Z coordinate (eg POINT Z), a measure (POINT M), or both (POINT ZM). +a Z coordinate (e.g., POINT Z), a measure (POINT M), or both (POINT ZM).

    It can also handle the PostGIS EWKT variation, in which the geometry is preceded by an spatial reference -system id (eg SRID=4326;POINT(175.3 41.2)), and a variant used by Informix in which the WKT is -preceded by an integer spatial reference id (eg 1 POINT(175.3 41.2)). +system id (e.g., SRID=4326;POINT(175.3 41.2)), and a variant used by Informix in which the WKT is +preceded by an integer spatial reference id (e.g., 1 POINT(175.3 41.2)). In both cases the SRID is ignored.

    diff --git a/resources/context_help/QgsOpenVectorLayerDialog b/resources/context_help/QgsOpenVectorLayerDialog index af4a822755c..666844542e1 100644 --- a/resources/context_help/QgsOpenVectorLayerDialog +++ b/resources/context_help/QgsOpenVectorLayerDialog @@ -2,5 +2,5 @@ The open vector layer dialog is used to add vector data to the QGIS map view. Vector data are spatial data described using geometries of points, lines and polygons (enclosed areas).

    QGIS supports vector data in a number of formats, including those supported by the OGR library data provider plugin, such as ESRI shape files, MapInfo MIF (interchange format) and MapInfo TAB (native format).

    -QGIS supports PostGIS layers in a PostgreSQL database and SpatiaLite layers. Support for additional data types (eg. delimited text) is provided by additional data provider plugins. A list of OGR supported vector formats can be found in Appendix A.1 of the User Guide.

    +QGIS supports PostGIS layers in a PostgreSQL database and SpatiaLite layers. Support for additional data types (e.g., delimited text) is provided by additional data provider plugins. A list of OGR supported vector formats can be found in Appendix A.1 of the User Guide.

    Detailed description how to proceed with vector data is described in chapter 5 'Working with Vector Data'. diff --git a/resources/context_help/QgsPgNewConnection b/resources/context_help/QgsPgNewConnection index 6571f9c2b90..e744d548f74 100644 --- a/resources/context_help/QgsPgNewConnection +++ b/resources/context_help/QgsPgNewConnection @@ -27,6 +27,6 @@ This dialog allows you to define the settings for a connection to a PostgreSQL/P
  • Indicates that tables without geometry should also be listed by default. -
  • When initializing layers, various queries may be needed to establish the characteristics of the geometries stored in the database table. When this option is checked, these queries examine only a sample of the rows and use the table statistics, rather than the entire table. This can drastically speed up operations on large datasets, but may result in incorrect characterization of layers (eg. the feature count of filtered layers will not be accurately determined) and may even cause strange behaviour in case columns that are supposed to be unique actually are not. +
  • When initializing layers, various queries may be needed to establish the characteristics of the geometries stored in the database table. When this option is checked, these queries examine only a sample of the rows and use the table statistics, rather than the entire table. This can drastically speed up operations on large datasets, but may result in incorrect characterization of layers (e.g., the feature count of filtered layers will not be accurately determined) and may even cause strange behaviour in case columns that are supposed to be unique actually are not. diff --git a/resources/context_help/QgsQueryBuilder b/resources/context_help/QgsQueryBuilder index ebe2f13cbfa..15356522114 100644 --- a/resources/context_help/QgsQueryBuilder +++ b/resources/context_help/QgsQueryBuilder @@ -14,8 +14,8 @@ are sometimes limited (e.g. for shape files) or behave diffently. OGR where clauses depending on the - format (eg. - OGR SQL + format (e.g., + OGR SQL for shape files) @@ -30,7 +30,7 @@ are sometimes limited (e.g. for shape files) or behave diffently. SpatiaLite where clauses using SQLite and - SpatiaLite + SpatiaLite diff --git a/resources/function_help/json/$area b/resources/function_help/json/$area index fb15461a32f..f529aea95a9 100644 --- a/resources/function_help/json/$area +++ b/resources/function_help/json/$area @@ -1,6 +1,6 @@ { "name": "$area", "type": "function", - "description": "Returns the area of the current feature. The area calculated by this function respects both the current project's ellipsoid setting and area unit settings. Eg, if an ellipsoid has been set for the project then the calculated area will be ellipsoidal, and if no ellipsoid is set then the calculated area will be planimetric.", + "description": "Returns the area of the current feature. The area calculated by this function respects both the current project's ellipsoid setting and area unit settings. For example, if an ellipsoid has been set for the project then the calculated area will be ellipsoidal, and if no ellipsoid is set then the calculated area will be planimetric.", "examples": [ { "expression":"$area", "returns":"42"}] } diff --git a/resources/function_help/json/$length b/resources/function_help/json/$length index 74dc20cac2b..72c4bc29acc 100644 --- a/resources/function_help/json/$length +++ b/resources/function_help/json/$length @@ -1,7 +1,7 @@ { "name": "$length", "type": "function", - "description": "Returns the length of a linestring. If you need the length of a border of a polygon, use $perimeter instead. The length calculated by this function respects both the current project's ellipsoid setting and distance unit settings. Eg, if an ellipsoid has been set for the project then the calculated length will be ellipsoidal, and if no ellipsoid is set then the calculated length will be planimetric.", + "description": "Returns the length of a linestring. If you need the length of a border of a polygon, use $perimeter instead. The length calculated by this function respects both the current project's ellipsoid setting and distance unit settings. For example, if an ellipsoid has been set for the project then the calculated length will be ellipsoidal, and if no ellipsoid is set then the calculated length will be planimetric.", "examples": [ { "expression":"$length", "returns":"42.4711"} ] diff --git a/resources/function_help/json/$perimeter b/resources/function_help/json/$perimeter index cc1aec52aa8..d241c55ea65 100644 --- a/resources/function_help/json/$perimeter +++ b/resources/function_help/json/$perimeter @@ -1,7 +1,7 @@ { "name": "$perimeter", "type": "function", - "description": "Returns the perimeter length of the current feature. The perimeter calculated by this function respects both the current project's ellipsoid setting and distance unit settings. Eg, if an ellipsoid has been set for the project then the calculated perimeter will be ellipsoidal, and if no ellipsoid is set then the calculated perimeter will be planimetric.", + "description": "Returns the perimeter length of the current feature. The perimeter calculated by this function respects both the current project's ellipsoid setting and distance unit settings. For example, if an ellipsoid has been set for the project then the calculated perimeter will be ellipsoidal, and if no ellipsoid is set then the calculated perimeter will be planimetric.", "examples": [ { "expression":"$perimeter", "returns":"42"} ] } diff --git a/resources/function_help/json/boundary b/resources/function_help/json/boundary index 2fb8b0f8b01..996684f66f3 100644 --- a/resources/function_help/json/boundary +++ b/resources/function_help/json/boundary @@ -1,7 +1,7 @@ { "name": "boundary", "type": "function", - "description":"Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the geometry). For instance, a polygon geometry will have a boundary consisting of the linestrings for each ring in the polygon. Some geometry types do not have a defined boundary, eg points or geometry collections, and will return null.", + "description":"Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the geometry). For instance, a polygon geometry will have a boundary consisting of the linestrings for each ring in the polygon. Some geometry types do not have a defined boundary, e.g., points or geometry collections, and will return null.", "arguments": [ {"arg":"geometry","description":"a geometry"} ], "examples": [ { "expression":"geom_to_wkt(boundary(geom_from_wkt('Polygon((1 1, 0 0, -1 1, 1 1))')))", "returns":"'LineString(1 1,0 0,-1 1,1 1)'"}] } diff --git a/resources/function_help/json/color_part b/resources/function_help/json/color_part index c54e4f57e18..d3ba42a40b1 100644 --- a/resources/function_help/json/color_part +++ b/resources/function_help/json/color_part @@ -1,7 +1,7 @@ { "name": "color_part", "type": "function", - "description": "Returns a specific component from a color string, eg the red component or alpha component.", + "description": "Returns a specific component from a color string, e.g., the red component or alpha component.", "arguments": [ {"arg":"color", "description":"a color string"}, {"arg":"component", "description":"a string corresponding to the color component to return. Valid options are:
    "} diff --git a/resources/function_help/json/layer_property b/resources/function_help/json/layer_property index ca98189e151..470c33db79b 100644 --- a/resources/function_help/json/layer_property +++ b/resources/function_help/json/layer_property @@ -4,7 +4,7 @@ "description": "Returns a matching layer property or metadata value.", "arguments": [ {"arg":"layer", "description":"a string, representing either a layer name or layer ID"}, - {"arg":"property", "description":"a string corresponding to the property to return. Valid options are:
    "} + {"arg":"property", "description":"a string corresponding to the property to return. Valid options are:
    "} ], "examples": [ { "expression":"layer_property('streets','title')", "returns":"'Basemap Streets'"}, diff --git a/resources/function_help/json/longest_common_substring b/resources/function_help/json/longest_common_substring index 2b8ff7d0d72..a7fd0e358a6 100644 --- a/resources/function_help/json/longest_common_substring +++ b/resources/function_help/json/longest_common_substring @@ -1,7 +1,7 @@ { "name": "longest_common_substring", "type": "function", - "description": "Returns the longest common substring between two strings. This substring is the longest string that is a substring of the two input strings. Eg, the longest common substring of \"ABABC\" and \"BABCA\" is \"ABC\". The substring is case sensitive.", + "description": "Returns the longest common substring between two strings. This substring is the longest string that is a substring of the two input strings. For example, the longest common substring of \"ABABC\" and \"BABCA\" is \"ABC\". The substring is case sensitive.", "arguments": [ {"arg":"string1","description":"a string"}, {"arg":"string2","description":"a string"} diff --git a/resources/function_help/json/regexp_match b/resources/function_help/json/regexp_match index 330010deefd..cd97cb1ae61 100644 --- a/resources/function_help/json/regexp_match +++ b/resources/function_help/json/regexp_match @@ -3,7 +3,7 @@ "type": "function", "description": "Return the first matching position matching a regular expression within a string, or 0 if the substring is not found.", "arguments": [ {"arg":"input_string","description":"the string to test against the regular expression"}, - {"arg":"regex","description":"The regular expression to test against. Backslash characters must be double escaped (eg \"\\\\\\\\s\" to match a white space character)."} + {"arg":"regex","description":"The regular expression to test against. Backslash characters must be double escaped (e.g., \"\\\\\\\\s\" to match a white space character)."} ], "examples": [ { "expression":"regexp_match('QGIS ROCKS','\\\\\\\\sROCKS')", "returns":"4"}] } diff --git a/resources/function_help/json/regexp_matches b/resources/function_help/json/regexp_matches index 7b77ecfe05b..68f914564d0 100644 --- a/resources/function_help/json/regexp_matches +++ b/resources/function_help/json/regexp_matches @@ -6,7 +6,7 @@ {"arg":"string", "description":"the string to capture groups from against the regular expression"}, {"arg":"regex","description":"the regular expression used to capture groups"}, {"arg":"empty_value","optional":true,"default":"''","description":"the optional string to use as replacement for empty (zero length) matches"}], - "examples": [ { "expression":"regexp_matches('qgis=>rocks','(.*)=>(.*)')", "returns":"array: 'qgis', 'rocks'"}, + "examples": [ { "expression":"regexp_matches('QGIS=>rocks','(.*)=>(.*)')", "returns":"array: 'QGIS', 'rocks'"}, { "expression":"regexp_matches('key=>','(.*)=>(.*)','empty value')", "returns":"array: 'key', 'empty value'"} ] } diff --git a/resources/function_help/json/regexp_replace b/resources/function_help/json/regexp_replace index f480f29bb71..de5beeb83d3 100644 --- a/resources/function_help/json/regexp_replace +++ b/resources/function_help/json/regexp_replace @@ -3,7 +3,7 @@ "type": "function", "description": "Returns a string with the supplied regular expression replaced.", "arguments": [ {"arg":"input_string","description":"the string to replace matches in"}, - {"arg":"regex","description":"The regular expression to replace. Backslash characters must be double escaped (eg \"\\\\\\\\s\" to match a white space character)."}, + {"arg":"regex","description":"The regular expression to replace. Backslash characters must be double escaped (e.g., \"\\\\\\\\s\" to match a white space character)."}, {"arg":"replacement","description":"The string that will replace any matching occurrences of the supplied regular expression. Captured groups can be inserted into the replacement string using \\\\\\\\1, \\\\\\\\2, etc."} ], "examples": [ { "expression":"regexp_replace('QGIS SHOULD ROCK','\\\\\\\\sSHOULD\\\\\\\\s',' DOES ')", "returns":"'QGIS DOES ROCK'"}] diff --git a/resources/function_help/json/regexp_substr b/resources/function_help/json/regexp_substr index 7ce1beb3f2d..857a44330b5 100644 --- a/resources/function_help/json/regexp_substr +++ b/resources/function_help/json/regexp_substr @@ -3,7 +3,7 @@ "type": "function", "description": "Returns the portion of a string which matches a supplied regular expression.", "arguments": [ {"arg":"input_string","description":"the string to find matches in"}, - {"arg":"regex","description":"The regular expression to match against. Backslash characters must be double escaped (eg \"\\\\\\\\s\" to match a white space character)."} + {"arg":"regex","description":"The regular expression to match against. Backslash characters must be double escaped (e.g., \"\\\\\\\\s\" to match a white space character)."} ], "examples": [ { "expression":"regexp_substr('abc123','(\\\\\\\\d+)')", "returns":"'123'"}] } diff --git a/resources/function_help/json/set_color_part b/resources/function_help/json/set_color_part index 2abdd631322..e4cf8f0ba43 100644 --- a/resources/function_help/json/set_color_part +++ b/resources/function_help/json/set_color_part @@ -1,7 +1,7 @@ { "name": "set_color_part", "type": "function", - "description": "Sets a specific color component for a color string, eg the red component or alpha component.", + "description": "Sets a specific color component for a color string, e.g., the red component or alpha component.", "arguments": [ {"arg":"color", "description":"a color string"}, {"arg":"component", "description":"a string corresponding to the color component to set. Valid options are:
    "}, diff --git a/resources/function_help/json/simplify_vw b/resources/function_help/json/simplify_vw index ad4f84b9009..1543092fc01 100644 --- a/resources/function_help/json/simplify_vw +++ b/resources/function_help/json/simplify_vw @@ -1,7 +1,7 @@ { "name": "simplify_vw", "type": "function", - "description":"Simplifies a geometry by removing nodes using an area based threshold (ie, the Visvalingam-Whyatt algorithm). The algorithm removes vertices which create small areas in geometries, eg narrow spikes or nearly straight segments.", + "description":"Simplifies a geometry by removing nodes using an area based threshold (ie, the Visvalingam-Whyatt algorithm). The algorithm removes vertices which create small areas in geometries, e.g., narrow spikes or nearly straight segments.", "arguments": [ {"arg":"geometry","description":"a geometry"}, {"arg":"tolerance","description":"a measure of the maximum area created by a node for the node to be removed"} ], "examples": [ { "expression":"geom_to_wkt(simplify_vw(geometry:=geom_from_wkt('LineString(0 0, 5 0, 5.01 10, 5.02 0, 10 0)'),tolerance:=5))", "returns":"'LineString(0 0, 10 0)'"}] diff --git a/resources/symbology-ng-style.xml b/resources/symbology-ng-style.xml index 723fae7d38c..d0cf49f0c02 100644 --- a/resources/symbology-ng-style.xml +++ b/resources/symbology-ng-style.xml @@ -4078,19 +4078,19 @@ - + - + - + @@ -4197,7 +4197,7 @@ - + @@ -4227,13 +4227,13 @@ - + - + diff --git a/scripts/chkspelling_ag.sh b/scripts/chkspelling_ag.sh index ad44767959c..29e54a13a4a 100755 --- a/scripts/chkspelling_ag.sh +++ b/scripts/chkspelling_ag.sh @@ -1,6 +1,6 @@ #!/bin/bash ########################################################################### -# chkspelling.sh +# chkspelling_ag.sh # --------------------- # Date : December 2016 # Copyright : (C) 2016 by Denis Rouzaud @@ -40,7 +40,7 @@ if [[ ! -z $OUTPUT ]]; then # < ---------- get files + error ----------------------------------------------------------------------> ag --smart-case --only-matching --nogroup --nonumbers --all-text --word-regexp -p $AGIGNORE "$RE" $FILES | \ # <-- generate sed command .... <------------------------------ get correction word ----------------------------------> <------------------------------- match case -------------------------------------------> <-----replace : by / and add word boundary------> ...finalize sed command> - sed -e 's/\(\S*\):\([[:alnum:]]*\)$/ echo "sed -i \x27s\/"$( echo "\2:$(ag --nonumbers --ignore-case --word-regexp \2 scripts\/spelling.dat | cut -d: -f2)" | sed -r \x27s\/([A-Z]+):(.*)\/\\1:\\U\\2\/; s\/([A-Z][a-z]+):([a-z])\/\\1:\\U\\2\\L\/\x27 | sed -r \x27s\/(\\S\*):\/\\\\b\\1\\\\b\\\/\/\x27)"\/g\x27 \1" /e' | \ + sed -e 's/\(\S*\):\([[:alnum:]]*\)$/ echo "sed -i \x27s\/\/"$( echo "\2:$(ag --nonumbers --ignore-case --word-regexp \2 scripts\/spelling.dat | cut -d: -f2)" | sed -r \x27s\/([A-Z]+):(.*)\/\\1:\\U\\2\/; s\/([A-Z][a-z]+):([a-z])\/\\1:\\U\\2\\L\/\x27 | sed -r \x27s\/(\\S\*):\/\\\\b\\1\\\\b\\\/\/\x27)"\/g\x27 \1" /e' | \ # remove duplicate line sort -u echo "****" diff --git a/scripts/qgis_fixes/fix_uiimport.py b/scripts/qgis_fixes/fix_uiimport.py index 0ed6b937dcb..e4a924ba71c 100644 --- a/scripts/qgis_fixes/fix_uiimport.py +++ b/scripts/qgis_fixes/fix_uiimport.py @@ -20,9 +20,9 @@ class FixUiimport(fixer_base.BaseFix): imp = results.get('imp') if node.type == syms.import_from: - # Some imps are top-level (eg: 'import ham') - # some are first level (eg: 'import ham.eggs') - # some are third level (eg: 'import ham.eggs as spam') + # Some imps are top-level (e.g., 'import ham') + # some are first level (e.g., 'import ham.eggs') + # some are third level (e.g., 'import ham.eggs as spam') # Hence, the loop while not hasattr(imp, 'value'): imp = imp.children[0] diff --git a/scripts/qgis_srs.sh b/scripts/qgis_srs.sh index bc7d24dbfef..5a3ca124c5d 100755 --- a/scripts/qgis_srs.sh +++ b/scripts/qgis_srs.sh @@ -55,7 +55,7 @@ # DETAILS: # # The script creates an SQL plain text dump that can be imported into -# SQlite db eg. using SQLite Database Browser's "Import > Database from +# SQlite db e.g.,. using SQLite Database Browser's "Import > Database from # SQL file" tool. # # The ellipsoids (tbl_ellipsoid) and projections (tbl_projection) tables diff --git a/scripts/spelling.dat b/scripts/spelling.dat index 4b0487df0a2..bc208aa934c 100644 --- a/scripts/spelling.dat +++ b/scripts/spelling.dat @@ -67,6 +67,7 @@ attemtps:attempts attribut:attribute attruibutes:attributes authentification:authentication +automaticaly:automatically automaticly:automatically automatize:automate automatized:automated @@ -91,6 +92,7 @@ calender:calendar cancelation:cancellation capabilites:capabilities capatibilities:capabilities +capitalise:capitalize cariage:carriage centimetre:centimeter centimetres:centimeters @@ -139,6 +141,7 @@ debians:Debian's decompres:decompress definate:definite definately:definitely +definintion:definition deimiter:delimiter delemeter:delimiter delemiter:delimiter @@ -193,8 +196,10 @@ extention:extension failuer:failure familar:familiar fatser:faster -feture:feature fetaures:features +feture:feature +flavour:flavor +flavours:flavors forse:force fortan:fortran forwardig:forwarding @@ -208,9 +213,9 @@ furter:further futher:further futhermore:furthermore generiously:generously -granulatiry:granularity grahical:graphical grahpical:graphical +granulatiry:granularity grapic:graphic guage:gauge halfs:halves @@ -235,8 +240,8 @@ informatiom:information informations:information infromation:information initalize:initialize -initialisation:initialization initators:initiators +initialisation:initialization initializiation:initialization inofficial:unofficial instersction:intersection @@ -244,6 +249,7 @@ integreated:integrated integrety:integrity integrey:integrity intendet:intended +interactivly:interactively interchangable:interchangeable intermittant:intermittent intersecton:intersection @@ -254,6 +260,7 @@ jave:java kilometre:kilometer kilometres:kilometers labelling:labeling +labour:labor langage:language langauage:language langugage:language @@ -284,6 +291,7 @@ microprocesspr:microprocessor millimetre:millimeter millimetres:millimeters milliseonds:milliseconds +minimise:minimize miscelleneous:miscellaneous misformed:malformed mispelled:misspelled @@ -336,6 +344,7 @@ paramter:parameter paramters:parameters particularily:particularly pased:passed +peference:preference peprocessor:preprocessor perfoming:performing permissons:permissions @@ -356,6 +365,8 @@ prepaired:prepared primative:primitive princliple:principle priorty:priority +prioritise:prioritize +prioritising:prioritizing proccesors:processors proces:process processessing:processing @@ -378,6 +389,7 @@ protecion:protection protocoll:protocol psychadelic:psychedelic quering:querying +rasterise:rasterize recieve:receive recieved:received reciever:receiver @@ -458,6 +470,7 @@ supress:suppress surpress:suppress suspicously:suspiciously swaped:swapped +symbo:symbol syle:style symetrical:symmetrical synax:syntax @@ -507,5 +520,6 @@ wich:which widht:width wierd:weird writeable:writable +writting:writing xwindows:X yur:your diff --git a/scripts/tsstat.pl b/scripts/tsstat.pl index b7657a26fdd..77b56ed4c83 100755 --- a/scripts/tsstat.pl +++ b/scripts/tsstat.pl @@ -45,6 +45,7 @@ my $translators= { 'de' => 'Jürgen E. Fischer, Stephan Holl, Otto Dassau, Werner Macho', 'es' => 'Carlos Dávila, Javier César Aldariz, Gabriela Awad, Edwin Amado, Mayeul Kauffmann, Diana Galindo', 'el' => 'Theodoros Vakkas, Ioannis Tsimpiris, Evripidis Argyropoulos, Mike Pegnigiannis, Nikos Ves', + 'eo' => 'Augustin Roche, Nikolay Korotkiy', 'et' => 'Veiko Viil', 'eu' => 'Asier Sarasua Garmendia, Irantzu Alvarez', 'fa' => 'Mola Pahnadayan, Masoud Pashotan , Masoud Erfanyan', diff --git a/src/analysis/CMakeLists.txt b/src/analysis/CMakeLists.txt index 062cdb6aa15..d0632074d76 100644 --- a/src/analysis/CMakeLists.txt +++ b/src/analysis/CMakeLists.txt @@ -162,6 +162,8 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../core/geometry ${CMAKE_CURRENT_SOURCE_DIR}/../core/raster ${CMAKE_CURRENT_SOURCE_DIR}/../core/symbology-ng + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/analysis interpolation network ) @@ -172,14 +174,19 @@ INCLUDE_DIRECTORIES(SYSTEM ${SQLITE3_INCLUDE_DIR} ) -REMOVE_DEFINITIONS("-DANALYSIS_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("\"-DANALYSIS_EXPORT=${DLLEXPORT}\"") - ############################################################# # qgis_analysis library ADD_LIBRARY(qgis_analysis SHARED ${QGIS_ANALYSIS_SRCS} ${QGIS_ANALYSIS_MOC_SRCS} ${QGIS_ANALYSIS_HDRS}) +GENERATE_EXPORT_HEADER( + qgis_analysis + BASE_NAME ANALYSIS + EXPORT_FILE_NAME qgis_analysis.h + ) + +SET(QGIS_ANALYSIS_HDRS ${QGIS_ANALYSIS_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/qgis_analysis.h) + IF(NOT APPLE) INSTALL(FILES ${QGIS_ANALYSIS_HDRS} DESTINATION ${QGIS_INCLUDE_DIR}) ELSE(NOT APPLE) diff --git a/src/analysis/interpolation/Bezier3D.h b/src/analysis/interpolation/Bezier3D.h index bc471924f61..872305f8d45 100644 --- a/src/analysis/interpolation/Bezier3D.h +++ b/src/analysis/interpolation/Bezier3D.h @@ -19,6 +19,7 @@ #include "ParametricLine.h" #include "qgslogger.h" +#include "qgis_analysis.h" /** \ingroup analysis * Class Bezier3D represents a bezier curve, represented by control points. Parameter t is running from 0 to 1. The class is capable to calculate the curve point and the first two derivatives belonging to t.*/ @@ -31,7 +32,7 @@ class ANALYSIS_EXPORT Bezier3D: public ParametricLine Bezier3D(); //! Constructor, par is a pointer to the parent, controlpoly a controlpolygon Bezier3D( ParametricLine* par, QVector* controlpoly ); - //! Destructor + virtual ~Bezier3D(); //! Do not use this method, since a Bezier curve does not consist of other curves virtual void add( ParametricLine *pl ) override; diff --git a/src/analysis/interpolation/CloughTocherInterpolator.h b/src/analysis/interpolation/CloughTocherInterpolator.h index 7458c962c3e..e6fdd3b7b8f 100644 --- a/src/analysis/interpolation/CloughTocherInterpolator.h +++ b/src/analysis/interpolation/CloughTocherInterpolator.h @@ -19,6 +19,7 @@ #include "TriangleInterpolator.h" #include "Point3D.h" +#include "qgis_analysis.h" class NormVecDecorator; @@ -81,7 +82,6 @@ class ANALYSIS_EXPORT CloughTocherInterpolator : public TriangleInterpolator CloughTocherInterpolator(); //! Constructor with a pointer to the triangulation as argument CloughTocherInterpolator( NormVecDecorator* tin ); - //! Destructor virtual ~CloughTocherInterpolator(); //! Calculates the normal vector and assigns it to vec (not implemented at the moment) virtual bool calcNormVec( double x, double y, Vector3D* result ) override; diff --git a/src/analysis/interpolation/DualEdgeTriangulation.h b/src/analysis/interpolation/DualEdgeTriangulation.h index f3c3830d463..289fda8ed45 100644 --- a/src/analysis/interpolation/DualEdgeTriangulation.h +++ b/src/analysis/interpolation/DualEdgeTriangulation.h @@ -31,6 +31,7 @@ #include #include #include +#include "qgis_analysis.h" /** \ingroup analysis * DualEdgeTriangulation is an implementation of a triangulation class based on the dual edge data structure*/ diff --git a/src/analysis/interpolation/HalfEdge.h b/src/analysis/interpolation/HalfEdge.h index 17d26874778..678eb964288 100644 --- a/src/analysis/interpolation/HalfEdge.h +++ b/src/analysis/interpolation/HalfEdge.h @@ -17,6 +17,8 @@ #ifndef HALFEDGE_H #define HALFEDGE_H +#include "qgis_analysis.h" + /** \ingroup analysis * \class HalfEdge */ @@ -38,7 +40,7 @@ class ANALYSIS_EXPORT HalfEdge //! Default constructor. Values for mDual, mNext, mPoint are set to -10 which means that they are undefined HalfEdge(); HalfEdge( int dual, int next, int point, bool mbreak, bool forced ); - ~HalfEdge(); + //! Returns the number of the dual HalfEdge int getDual() const; //! Returns the number of the next HalfEdge @@ -71,11 +73,6 @@ inline HalfEdge::HalfEdge( int dual, int next, int point, bool mbreak, bool forc } -inline HalfEdge::~HalfEdge() -{ - -} - inline int HalfEdge::getDual() const { return mDual; diff --git a/src/analysis/interpolation/LinTriangleInterpolator.h b/src/analysis/interpolation/LinTriangleInterpolator.h index 75de7762533..06c7e16bb38 100644 --- a/src/analysis/interpolation/LinTriangleInterpolator.h +++ b/src/analysis/interpolation/LinTriangleInterpolator.h @@ -19,6 +19,7 @@ #include "TriangleInterpolator.h" #include "DualEdgeTriangulation.h" +#include "qgis_analysis.h" /** \ingroup analysis * LinTriangleInterpolator is a class which interpolates linearly on a triangulation*/ @@ -29,7 +30,6 @@ class ANALYSIS_EXPORT LinTriangleInterpolator : public TriangleInterpolator LinTriangleInterpolator(); //! Constructor with reference to a DualEdgeTriangulation object LinTriangleInterpolator( DualEdgeTriangulation* tin ); - //! Destructor virtual ~LinTriangleInterpolator(); //! Calculates the normal vector and assigns it to vec virtual bool calcNormVec( double x, double y, Vector3D* result ) override; diff --git a/src/analysis/interpolation/Line3D.h b/src/analysis/interpolation/Line3D.h index f0635f86c38..ce7f80e507e 100644 --- a/src/analysis/interpolation/Line3D.h +++ b/src/analysis/interpolation/Line3D.h @@ -18,6 +18,7 @@ #define LINE3D_H #include "Node.h" +#include "qgis_analysis.h" /** \ingroup analysis * This class represents a line. It is implemented as a single directed linked list of nodes (with related Point3D objects). Attention: the points inserted in a line are not deleted from Line3D*/ diff --git a/src/analysis/interpolation/MathUtils.h b/src/analysis/interpolation/MathUtils.h index 8cab13a703a..986754b19f1 100644 --- a/src/analysis/interpolation/MathUtils.h +++ b/src/analysis/interpolation/MathUtils.h @@ -18,6 +18,7 @@ #define MATHUTILS_H #include +#include "qgis_analysis.h" class Point3D; class Vector3D; diff --git a/src/analysis/interpolation/Node.h b/src/analysis/interpolation/Node.h index 0e941ebec9c..a481ab830f3 100644 --- a/src/analysis/interpolation/Node.h +++ b/src/analysis/interpolation/Node.h @@ -18,6 +18,7 @@ #define NODE_H #include "Point3D.h" +#include "qgis_analysis.h" /** \ingroup analysis * Node is a class used by Line3D. It represents a node in the single directed linked list. Associated Point3D objects are deleted when the node is deleted.*/ diff --git a/src/analysis/interpolation/NormVecDecorator.h b/src/analysis/interpolation/NormVecDecorator.h index d69dd69964b..4dd93f5ec7d 100644 --- a/src/analysis/interpolation/NormVecDecorator.h +++ b/src/analysis/interpolation/NormVecDecorator.h @@ -21,6 +21,7 @@ #include #include #include "qgslogger.h" +#include "qgis_analysis.h" class QProgressDialog; diff --git a/src/analysis/interpolation/ParametricLine.h b/src/analysis/interpolation/ParametricLine.h index 1204c9a86c4..5243418bc23 100644 --- a/src/analysis/interpolation/ParametricLine.h +++ b/src/analysis/interpolation/ParametricLine.h @@ -19,6 +19,7 @@ #include "Point3D.h" #include +#include "qgis_analysis.h" class Vector3D; @@ -41,7 +42,6 @@ class ANALYSIS_EXPORT ParametricLine /** Constructor, par is a pointer to the parent object, controlpoly the controlpolygon */ ParametricLine( ParametricLine* par, QVector* controlpoly ); - //! Destructor virtual ~ParametricLine(); virtual void add( ParametricLine* pl ) = 0; virtual void calcFirstDer( float t, Vector3D* v ) = 0; diff --git a/src/analysis/interpolation/Point3D.h b/src/analysis/interpolation/Point3D.h index 013d4832d8f..9e4e31d5138 100644 --- a/src/analysis/interpolation/Point3D.h +++ b/src/analysis/interpolation/Point3D.h @@ -18,6 +18,7 @@ #define POINT3D_H #include +#include "qgis_analysis.h" /** \ingroup analysis * Point3D is a class to represent a three dimensional point*/ @@ -35,7 +36,6 @@ class ANALYSIS_EXPORT Point3D //! Constructor with the x-, y- and z-coordinate as arguments Point3D( double x, double y, double z ); Point3D( const Point3D& p ); - ~Point3D(); Point3D& operator=( const Point3D& p ); bool operator==( const Point3D& p ) const; bool operator!=( const Point3D& p ) const; @@ -76,11 +76,6 @@ inline Point3D::Point3D( const Point3D& p ): mX( p.mX ), mY( p.mY ), mZ( p.mZ ) } -inline Point3D::~Point3D() -{ - -} - inline double Point3D::getX() const { return mX; diff --git a/src/analysis/interpolation/TriDecorator.h b/src/analysis/interpolation/TriDecorator.h index 2c65eff9925..c2d7876c73d 100644 --- a/src/analysis/interpolation/TriDecorator.h +++ b/src/analysis/interpolation/TriDecorator.h @@ -18,6 +18,7 @@ #define TRIDECORATOR_H #include "Triangulation.h" +#include "qgis_analysis.h" /** \ingroup analysis * Decorator class for Triangulations (s. Decorator pattern in Gamma et al.)*/ diff --git a/src/analysis/interpolation/TriangleInterpolator.h b/src/analysis/interpolation/TriangleInterpolator.h index 4155ca29a00..a67108a27f8 100644 --- a/src/analysis/interpolation/TriangleInterpolator.h +++ b/src/analysis/interpolation/TriangleInterpolator.h @@ -19,13 +19,14 @@ #include #include +#include "qgis_analysis.h" /** \ingroup analysis * This is an interface for interpolator classes for triangulations*/ class ANALYSIS_EXPORT TriangleInterpolator { public: - virtual ~TriangleInterpolator() {} + virtual ~TriangleInterpolator() = default; //! Calculates the normal vector and assigns it to vec virtual bool calcNormVec( double x, double y, Vector3D* result ) = 0; //! Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point diff --git a/src/analysis/interpolation/Triangulation.h b/src/analysis/interpolation/Triangulation.h index d6edfb19a68..33d0aa29e2b 100644 --- a/src/analysis/interpolation/Triangulation.h +++ b/src/analysis/interpolation/Triangulation.h @@ -20,6 +20,7 @@ #include #include #include +#include "qgis_analysis.h" class Line3D; diff --git a/src/analysis/interpolation/Vector3D.h b/src/analysis/interpolation/Vector3D.h index f4ae8441614..a28d524eee8 100644 --- a/src/analysis/interpolation/Vector3D.h +++ b/src/analysis/interpolation/Vector3D.h @@ -18,6 +18,7 @@ #define VECTOR3D_H #include +#include "qgis_analysis.h" /** \ingroup analysis * Class Vector3D represents a 3D-Vector, capable to store x-,y- and @@ -42,8 +43,7 @@ class ANALYSIS_EXPORT Vector3D Vector3D(); //! Copy constructor Vector3D( const Vector3D& v ); - //! Destructor - ~Vector3D(); + Vector3D& operator=( const Vector3D& v ); bool operator==( const Vector3D& v ) const; bool operator!=( const Vector3D& v ) const; @@ -83,11 +83,6 @@ inline Vector3D::Vector3D() } -inline Vector3D::~Vector3D() -{ - -} - //-------------------------------------------setter and getters------------------------------- inline double Vector3D::getX() const diff --git a/src/analysis/interpolation/qgsgridfilewriter.h b/src/analysis/interpolation/qgsgridfilewriter.h index 9c4e7cfa2b9..beb8ed21497 100644 --- a/src/analysis/interpolation/qgsgridfilewriter.h +++ b/src/analysis/interpolation/qgsgridfilewriter.h @@ -21,6 +21,7 @@ #include "qgsrectangle.h" #include #include +#include "qgis_analysis.h" class QgsInterpolator; diff --git a/src/analysis/interpolation/qgsidwinterpolator.cpp b/src/analysis/interpolation/qgsidwinterpolator.cpp index 1eedbce81b7..22995fee70a 100644 --- a/src/analysis/interpolation/qgsidwinterpolator.cpp +++ b/src/analysis/interpolation/qgsidwinterpolator.cpp @@ -29,11 +29,6 @@ QgsIDWInterpolator::QgsIDWInterpolator(): QgsInterpolator( QList() ), } -QgsIDWInterpolator::~QgsIDWInterpolator() -{ - -} - int QgsIDWInterpolator::interpolatePoint( double x, double y, double& result ) { if ( !mDataIsCached ) diff --git a/src/analysis/interpolation/qgsidwinterpolator.h b/src/analysis/interpolation/qgsidwinterpolator.h index 76ae1c290a9..93ef659a9aa 100644 --- a/src/analysis/interpolation/qgsidwinterpolator.h +++ b/src/analysis/interpolation/qgsidwinterpolator.h @@ -19,6 +19,7 @@ #define QGSIDWINTERPOLATOR_H #include "qgsinterpolator.h" +#include "qgis_analysis.h" /** \ingroup analysis * \class QgsIDWInterpolator @@ -27,7 +28,6 @@ class ANALYSIS_EXPORT QgsIDWInterpolator: public QgsInterpolator { public: QgsIDWInterpolator( const QList& layerData ); - ~QgsIDWInterpolator(); /** Calculates interpolation value for map coordinates x, y @param x x-coordinate (in map units) diff --git a/src/analysis/interpolation/qgsinterpolator.h b/src/analysis/interpolation/qgsinterpolator.h index dda56649009..1843ce0aac9 100644 --- a/src/analysis/interpolation/qgsinterpolator.h +++ b/src/analysis/interpolation/qgsinterpolator.h @@ -19,6 +19,7 @@ #define QGSINTERPOLATOR_H #include +#include "qgis_analysis.h" class QgsVectorLayer; class QgsGeometry; diff --git a/src/analysis/interpolation/qgstininterpolator.h b/src/analysis/interpolation/qgstininterpolator.h index 9a12f75d6bc..538a79497de 100644 --- a/src/analysis/interpolation/qgstininterpolator.h +++ b/src/analysis/interpolation/qgstininterpolator.h @@ -20,6 +20,7 @@ #include "qgsinterpolator.h" #include +#include "qgis_analysis.h" class Triangulation; class TriangleInterpolator; diff --git a/src/analysis/network/qgsgraph.h b/src/analysis/network/qgsgraph.h index e93b773b44a..8a15df80137 100644 --- a/src/analysis/network/qgsgraph.h +++ b/src/analysis/network/qgsgraph.h @@ -30,6 +30,7 @@ #include #include "qgspoint.h" +#include "qgis_analysis.h" class QgsGraphVertex; diff --git a/src/analysis/network/qgsgraphanalyzer.h b/src/analysis/network/qgsgraphanalyzer.h index 16ce6477789..7e52af5d786 100644 --- a/src/analysis/network/qgsgraphanalyzer.h +++ b/src/analysis/network/qgsgraphanalyzer.h @@ -17,6 +17,7 @@ #define QGSGRAPHANALYZER_H #include +#include "qgis_analysis.h" class QgsGraph; diff --git a/src/analysis/network/qgsgraphbuilder.h b/src/analysis/network/qgsgraphbuilder.h index a3d8434cca6..6f89ea46da7 100644 --- a/src/analysis/network/qgsgraphbuilder.h +++ b/src/analysis/network/qgsgraphbuilder.h @@ -19,6 +19,7 @@ #include "qgsgraphbuilderinterface.h" #include +#include "qgis_analysis.h" class QgsDistanceArea; class QgsCoordinateTransform; diff --git a/src/analysis/network/qgsgraphbuilderinterface.h b/src/analysis/network/qgsgraphbuilderinterface.h index e63672e0df5..c4ae8b42ab7 100644 --- a/src/analysis/network/qgsgraphbuilderinterface.h +++ b/src/analysis/network/qgsgraphbuilderinterface.h @@ -22,6 +22,7 @@ #include #include #include +#include "qgis_analysis.h" /** * \ingroup analysis @@ -50,7 +51,6 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface mDa.setEllipsoidalMode( ctfEnabled ); } - //! Destructor virtual ~QgsGraphBuilderInterface() { } diff --git a/src/analysis/network/qgsgraphdirector.h b/src/analysis/network/qgsgraphdirector.h index bb7de5c8d3f..ea38b15615f 100644 --- a/src/analysis/network/qgsgraphdirector.h +++ b/src/analysis/network/qgsgraphdirector.h @@ -22,6 +22,7 @@ #include #include "qgsnetworkstrategy.h" +#include "qgis_analysis.h" class QgsGraphBuilderInterface; @@ -40,7 +41,7 @@ class ANALYSIS_EXPORT QgsGraphDirector : public QObject void buildMessage( const QString& ) const; public: - //! Destructor + virtual ~QgsGraphDirector() { } /** diff --git a/src/analysis/network/qgsnetworkdistancestrategy.h b/src/analysis/network/qgsnetworkdistancestrategy.h index 53f340585b8..ec5d79d3a8d 100644 --- a/src/analysis/network/qgsnetworkdistancestrategy.h +++ b/src/analysis/network/qgsnetworkdistancestrategy.h @@ -17,6 +17,7 @@ #define QGSNETWORKDISTANCESTRATEGY_H #include +#include "qgis_analysis.h" /** \ingroup analysis * \class QgsNetworkDistanceStrategy diff --git a/src/analysis/network/qgsnetworkspeedstrategy.h b/src/analysis/network/qgsnetworkspeedstrategy.h index c19eac39b10..6844ebc9981 100644 --- a/src/analysis/network/qgsnetworkspeedstrategy.h +++ b/src/analysis/network/qgsnetworkspeedstrategy.h @@ -17,6 +17,7 @@ #define QGSNETWORKSPEEDSTRATEGY_H #include +#include "qgis_analysis.h" /** \ingroup analysis * \class QgsNetworkSpeedStrategy diff --git a/src/analysis/network/qgsnetworkstrategy.h b/src/analysis/network/qgsnetworkstrategy.h index dd8bffdc782..be78275f4ce 100644 --- a/src/analysis/network/qgsnetworkstrategy.h +++ b/src/analysis/network/qgsnetworkstrategy.h @@ -20,6 +20,7 @@ #include #include +#include "qgis_analysis.h" /** * \ingroup analysis @@ -39,7 +40,7 @@ class ANALYSIS_EXPORT QgsNetworkStrategy */ QgsNetworkStrategy() {} - virtual ~QgsNetworkStrategy() {} + virtual ~QgsNetworkStrategy() = default; /** * Returns list of the source layer attributes needed for cost calculation. diff --git a/src/analysis/network/qgsvectorlayerdirector.h b/src/analysis/network/qgsvectorlayerdirector.h index 6b4fd8816f8..b8b35148352 100644 --- a/src/analysis/network/qgsvectorlayerdirector.h +++ b/src/analysis/network/qgsvectorlayerdirector.h @@ -17,6 +17,7 @@ #define QGSVECTORLAYERDIRECTOR_H #include "qgsgraphdirector.h" +#include "qgis_analysis.h" class QgsGraphBuilderInterface; class QgsVectorLayer; @@ -64,7 +65,6 @@ class ANALYSIS_EXPORT QgsVectorLayerDirector : public QgsGraphDirector const Direction defaultDirection ); - //! Destructor virtual ~QgsVectorLayerDirector(); /* diff --git a/src/analysis/openstreetmap/qgsosmbase.h b/src/analysis/openstreetmap/qgsosmbase.h index c70cad42a50..d0566256251 100644 --- a/src/analysis/openstreetmap/qgsosmbase.h +++ b/src/analysis/openstreetmap/qgsosmbase.h @@ -20,6 +20,7 @@ #include "qgspoint.h" #include +#include "qgis_analysis.h" typedef qint64 QgsOSMId; diff --git a/src/analysis/openstreetmap/qgsosmdatabase.h b/src/analysis/openstreetmap/qgsosmdatabase.h index d55344a3bf9..1b52c556b9c 100644 --- a/src/analysis/openstreetmap/qgsosmdatabase.h +++ b/src/analysis/openstreetmap/qgsosmdatabase.h @@ -22,6 +22,7 @@ #include "qgsosmbase.h" #include "qgsgeometry.h" +#include "qgis_analysis.h" class QgsOSMNodeIterator; class QgsOSMWayIterator; @@ -49,6 +50,11 @@ class ANALYSIS_EXPORT QgsOSMDatabase explicit QgsOSMDatabase( const QString& dbFileName = QString() ); ~QgsOSMDatabase(); + //! QgsOSMDatabase cannot be copied. + QgsOSMDatabase( const QgsOSMDatabase& rh ) = delete; + //! QgsOSMDatabase cannot be copied. + QgsOSMDatabase& operator=( const QgsOSMDatabase& rh ) = delete; + void setFileName( const QString& dbFileName ) { mDbFileName = dbFileName; } QString filename() const { return mDbFileName; } bool isOpen() const; @@ -120,8 +126,6 @@ class ANALYSIS_EXPORT QgsOSMDatabase sqlite3_stmt* mStmtWayNodePoints; sqlite3_stmt* mStmtWayTags; - QgsOSMDatabase( const QgsOSMDatabase& rh ); - QgsOSMDatabase& operator=( const QgsOSMDatabase& rh ); }; diff --git a/src/analysis/openstreetmap/qgsosmdownload.h b/src/analysis/openstreetmap/qgsosmdownload.h index 4b9dea23c2b..123b4399729 100644 --- a/src/analysis/openstreetmap/qgsosmdownload.h +++ b/src/analysis/openstreetmap/qgsosmdownload.h @@ -20,6 +20,7 @@ #include #include #include +#include "qgis_analysis.h" class QgsRectangle; diff --git a/src/analysis/openstreetmap/qgsosmimport.h b/src/analysis/openstreetmap/qgsosmimport.h index 992a57ce6cf..5a1d4cef54e 100644 --- a/src/analysis/openstreetmap/qgsosmimport.h +++ b/src/analysis/openstreetmap/qgsosmimport.h @@ -20,6 +20,7 @@ #include #include "qgsosmbase.h" +#include "qgis_analysis.h" class QXmlStreamReader; diff --git a/src/analysis/raster/qgsalignraster.h b/src/analysis/raster/qgsalignraster.h index 1de12ae122c..a2212beaa14 100644 --- a/src/analysis/raster/qgsalignraster.h +++ b/src/analysis/raster/qgsalignraster.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_analysis.h" class QgsRectangle; @@ -49,6 +50,9 @@ class ANALYSIS_EXPORT QgsAlignRaster RasterInfo( const QString& layerpath ); ~RasterInfo(); + RasterInfo( const RasterInfo& rh ) = delete; + RasterInfo& operator=( const RasterInfo& rh ) = delete; + //! Check whether the given path is a valid raster bool isValid() const { return nullptr != mDataset; } @@ -87,9 +91,6 @@ class ANALYSIS_EXPORT QgsAlignRaster private: - RasterInfo( const RasterInfo& rh ); - RasterInfo& operator=( const RasterInfo& rh ); - friend class QgsAlignRaster; }; @@ -147,7 +148,7 @@ class ANALYSIS_EXPORT QgsAlignRaster //! @return false if the execution should be cancelled, true otherwise virtual bool progress( double complete ) = 0; - virtual ~ProgressHandler() {} + virtual ~ProgressHandler() = default; }; //! Assign a progress handler instance. Does not take ownership. nullptr can be passed. diff --git a/src/analysis/raster/qgsaspectfilter.cpp b/src/analysis/raster/qgsaspectfilter.cpp index e70ea6badf7..7c881492c59 100644 --- a/src/analysis/raster/qgsaspectfilter.cpp +++ b/src/analysis/raster/qgsaspectfilter.cpp @@ -23,11 +23,6 @@ QgsAspectFilter::QgsAspectFilter( const QString& inputFile, const QString& outpu } -QgsAspectFilter::~QgsAspectFilter() -{ - -} - float QgsAspectFilter::processNineCellWindow( float* x11, float* x21, float* x31, float* x12, float* x22, float* x32, diff --git a/src/analysis/raster/qgsaspectfilter.h b/src/analysis/raster/qgsaspectfilter.h index a3437315fe9..6368b191059 100644 --- a/src/analysis/raster/qgsaspectfilter.h +++ b/src/analysis/raster/qgsaspectfilter.h @@ -19,6 +19,7 @@ #define QGSASPECTFILTER_H #include "qgsderivativefilter.h" +#include "qgis_analysis.h" /** \ingroup analysis * Calculates aspect values in a window of 3x3 cells based on first order derivatives in x- and y- directions. Direction is clockwise starting from north*/ @@ -26,7 +27,6 @@ class ANALYSIS_EXPORT QgsAspectFilter: public QgsDerivativeFilter { public: QgsAspectFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat ); - ~QgsAspectFilter(); /** Calculates output value from nine input values. The input values and the output value can be equal to the nodata value if not present or outside of the border. Must be implemented by subclasses*/ diff --git a/src/analysis/raster/qgsderivativefilter.h b/src/analysis/raster/qgsderivativefilter.h index 796b089fb9a..67b9678beaa 100644 --- a/src/analysis/raster/qgsderivativefilter.h +++ b/src/analysis/raster/qgsderivativefilter.h @@ -19,6 +19,7 @@ #define QGSDERIVATIVEFILTER_H #include "qgsninecellfilter.h" +#include "qgis_analysis.h" /** \ingroup analysis * Adds the ability to calculate derivatives in x- and y-directions. Needs to be subclassed (e.g. for slope and aspect)*/ diff --git a/src/analysis/raster/qgshillshadefilter.cpp b/src/analysis/raster/qgshillshadefilter.cpp index 5d72d044d49..34a796cfaf2 100644 --- a/src/analysis/raster/qgshillshadefilter.cpp +++ b/src/analysis/raster/qgshillshadefilter.cpp @@ -25,10 +25,6 @@ QgsHillshadeFilter::QgsHillshadeFilter( const QString& inputFile, const QString& { } -QgsHillshadeFilter::~QgsHillshadeFilter() -{ -} - float QgsHillshadeFilter::processNineCellWindow( float* x11, float* x21, float* x31, float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 ) diff --git a/src/analysis/raster/qgshillshadefilter.h b/src/analysis/raster/qgshillshadefilter.h index 1cb4444c14b..6bf3cd7ee29 100644 --- a/src/analysis/raster/qgshillshadefilter.h +++ b/src/analysis/raster/qgshillshadefilter.h @@ -19,6 +19,7 @@ #define QGSHILLSHADEFILTER_H #include "qgsderivativefilter.h" +#include "qgis_analysis.h" /** \ingroup analysis * \class QgsHillshadeFilter @@ -28,7 +29,6 @@ class ANALYSIS_EXPORT QgsHillshadeFilter: public QgsDerivativeFilter public: QgsHillshadeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat, double lightAzimuth = 300, double lightAngle = 40 ); - ~QgsHillshadeFilter(); /** Calculates output value from nine input values. The input values and the output value can be equal to the nodata value if not present or outside of the border. Must be implemented by subclasses*/ diff --git a/src/analysis/raster/qgskde.cpp b/src/analysis/raster/qgskde.cpp index 57543e013bb..0c30f0d7355 100644 --- a/src/analysis/raster/qgskde.cpp +++ b/src/analysis/raster/qgskde.cpp @@ -23,12 +23,6 @@ #define M_PI 3.14159265358979323846 #endif -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 -#define TO8F(x) (x).toUtf8().constData() -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#endif - QgsKernelDensityEstimation::QgsKernelDensityEstimation( const QgsKernelDensityEstimation::Parameters& parameters, const QString& outputFile, const QString& outputFormat ) : mInputLayer( parameters.vectorLayer ) , mOutputFile( outputFile ) @@ -99,7 +93,7 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::prepare() return FileCreationError; // open the raster in GA_Update mode - mDatasetH = GDALOpen( TO8F( mOutputFile ), GA_Update ); + mDatasetH = GDALOpen( mOutputFile.toUtf8().constData(), GA_Update ); if ( !mDatasetH ) return FileCreationError; mRasterBandH = GDALGetRasterBand( mDatasetH, 1 ); diff --git a/src/analysis/raster/qgskde.h b/src/analysis/raster/qgskde.h index 960c3cb8167..820eb45abfa 100644 --- a/src/analysis/raster/qgskde.h +++ b/src/analysis/raster/qgskde.h @@ -23,6 +23,7 @@ #include #include #include +#include "qgis_analysis.h" class QgsVectorLayer; class QProgressDialog; diff --git a/src/analysis/raster/qgsninecellfilter.cpp b/src/analysis/raster/qgsninecellfilter.cpp index 30ccce47020..105a80fb242 100644 --- a/src/analysis/raster/qgsninecellfilter.cpp +++ b/src/analysis/raster/qgsninecellfilter.cpp @@ -21,12 +21,6 @@ #include #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 -#define TO8F(x) (x).toUtf8().constData() -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#endif - QgsNineCellFilter::QgsNineCellFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat ) : mInputFile( inputFile ) , mOutputFile( outputFile ) @@ -208,7 +202,7 @@ int QgsNineCellFilter::processRaster( QProgressDialog* p ) if ( p && p->wasCanceled() ) { //delete the dataset without closing (because it is faster) - GDALDeleteDataset( outputDriver, TO8F( mOutputFile ) ); + GDALDeleteDataset( outputDriver, mOutputFile.toUtf8().constData() ); return 7; } GDALClose( outputDataset ); @@ -218,7 +212,7 @@ int QgsNineCellFilter::processRaster( QProgressDialog* p ) GDALDatasetH QgsNineCellFilter::openInputFile( int& nCellsX, int& nCellsY ) { - GDALDatasetH inputDataset = GDALOpen( TO8F( mInputFile ), GA_ReadOnly ); + GDALDatasetH inputDataset = GDALOpen( mInputFile.toUtf8().constData(), GA_ReadOnly ); if ( inputDataset ) { nCellsX = GDALGetRasterXSize( inputDataset ); @@ -267,7 +261,7 @@ GDALDatasetH QgsNineCellFilter::openOutputFile( GDALDatasetH inputDataset, GDALD //open output file char **papszOptions = nullptr; - GDALDatasetH outputDataset = GDALCreate( outputDriver, TO8F( mOutputFile ), xSize, ySize, 1, GDT_Float32, papszOptions ); + GDALDatasetH outputDataset = GDALCreate( outputDriver, mOutputFile.toUtf8().constData(), xSize, ySize, 1, GDT_Float32, papszOptions ); if ( !outputDataset ) { return outputDataset; diff --git a/src/analysis/raster/qgsninecellfilter.h b/src/analysis/raster/qgsninecellfilter.h index 03e42db770b..5838910a90b 100644 --- a/src/analysis/raster/qgsninecellfilter.h +++ b/src/analysis/raster/qgsninecellfilter.h @@ -20,6 +20,7 @@ #include #include "gdal.h" +#include "qgis_analysis.h" class QProgressDialog; diff --git a/src/analysis/raster/qgsrastercalcnode.h b/src/analysis/raster/qgsrastercalcnode.h index f95f9cb9115..eaf7c5454a6 100644 --- a/src/analysis/raster/qgsrastercalcnode.h +++ b/src/analysis/raster/qgsrastercalcnode.h @@ -21,6 +21,7 @@ #include #include +#include "qgis_analysis.h" class QgsRasterBlock; class QgsRasterMatrix; @@ -76,6 +77,11 @@ class ANALYSIS_EXPORT QgsRasterCalcNode QgsRasterCalcNode( const QString& rasterName ); ~QgsRasterCalcNode(); + //! QgsRasterCalcNode cannot be copied + QgsRasterCalcNode( const QgsRasterCalcNode& rh ) = delete; + //! QgsRasterCalcNode cannot be copied + QgsRasterCalcNode& operator=( const QgsRasterCalcNode& rh ) = delete; + Type type() const { return mType; } //set left node @@ -103,8 +109,6 @@ class ANALYSIS_EXPORT QgsRasterCalcNode QgsRasterMatrix* mMatrix; Operator mOperator; - QgsRasterCalcNode( const QgsRasterCalcNode& rh ); - QgsRasterCalcNode& operator=( const QgsRasterCalcNode& rh ); }; diff --git a/src/analysis/raster/qgsrastercalculator.cpp b/src/analysis/raster/qgsrastercalculator.cpp index 1be0718b25e..b50aa175b5a 100644 --- a/src/analysis/raster/qgsrastercalculator.cpp +++ b/src/analysis/raster/qgsrastercalculator.cpp @@ -29,14 +29,6 @@ #include #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 -#define TO8(x) (x).toUtf8().constData() -#define TO8F(x) (x).toUtf8().constData() -#else -#define TO8(x) (x).toLocal8Bit().constData() -#define TO8F(x) QFile::encodeName( x ).constData() -#endif - QgsRasterCalculator::QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat, const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector& rasterEntries ) : mFormulaString( formulaString ) @@ -180,7 +172,7 @@ int QgsRasterCalculator::processCalculation( QProgressDialog* p ) if ( p && p->wasCanceled() ) { //delete the dataset without closing (because it is faster) - GDALDeleteDataset( outputDriver, TO8F( mOutputFile ) ); + GDALDeleteDataset( outputDriver, mOutputFile.toUtf8().constData() ); return static_cast< int >( Cancelled ); } GDALClose( outputDataset ); @@ -219,7 +211,7 @@ GDALDatasetH QgsRasterCalculator::openOutputFile( GDALDriverH outputDriver ) { //open output file char **papszOptions = nullptr; - GDALDatasetH outputDataset = GDALCreate( outputDriver, TO8F( mOutputFile ), mNumOutputColumns, mNumOutputRows, 1, GDT_Float32, papszOptions ); + GDALDatasetH outputDataset = GDALCreate( outputDriver, mOutputFile.toUtf8().constData(), mNumOutputColumns, mNumOutputRows, 1, GDT_Float32, papszOptions ); if ( !outputDataset ) { return outputDataset; diff --git a/src/analysis/raster/qgsrastercalculator.h b/src/analysis/raster/qgsrastercalculator.h index 27dc82696b2..a936d1a1781 100644 --- a/src/analysis/raster/qgsrastercalculator.h +++ b/src/analysis/raster/qgsrastercalculator.h @@ -23,6 +23,7 @@ #include #include #include "gdal.h" +#include "qgis_analysis.h" class QgsRasterLayer; class QProgressDialog; diff --git a/src/analysis/raster/qgsrastermatrix.h b/src/analysis/raster/qgsrastermatrix.h index 81282553e02..fea61e14929 100644 --- a/src/analysis/raster/qgsrastermatrix.h +++ b/src/analysis/raster/qgsrastermatrix.h @@ -18,6 +18,8 @@ #ifndef QGSRASTERMATRIX_H #define QGSRASTERMATRIX_H +#include "qgis_analysis.h" + /** \ingroup analysis * \class QgsRasterMatrix */ diff --git a/src/analysis/raster/qgsrelief.cpp b/src/analysis/raster/qgsrelief.cpp index 01187b5b015..6aa592251be 100644 --- a/src/analysis/raster/qgsrelief.cpp +++ b/src/analysis/raster/qgsrelief.cpp @@ -28,12 +28,6 @@ #include #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 -#define TO8F(x) (x).toUtf8().constData() -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#endif - QgsRelief::QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat ) : mInputFile( inputFile ) , mOutputFile( outputFile ) @@ -292,7 +286,7 @@ int QgsRelief::processRaster( QProgressDialog* p ) if ( p && p->wasCanceled() ) { //delete the dataset without closing (because it is faster) - GDALDeleteDataset( outputDriver, TO8F( mOutputFile ) ); + GDALDeleteDataset( outputDriver, mOutputFile.toUtf8().constData() ); return 7; } GDALClose( outputDataset ); @@ -415,7 +409,7 @@ bool QgsRelief::setElevationColor( double elevation, int* red, int* green, int* //duplicated from QgsNineCellFilter. Todo: make common base class GDALDatasetH QgsRelief::openInputFile( int& nCellsX, int& nCellsY ) { - GDALDatasetH inputDataset = GDALOpen( TO8F( mInputFile ), GA_ReadOnly ); + GDALDatasetH inputDataset = GDALOpen( mInputFile.toUtf8().constData(), GA_ReadOnly ); if ( inputDataset ) { nCellsX = GDALGetRasterXSize( inputDataset ); @@ -469,7 +463,7 @@ GDALDatasetH QgsRelief::openOutputFile( GDALDatasetH inputDataset, GDALDriverH o papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", "PACKBITS" ); //create three band raster (reg, green, blue) - GDALDatasetH outputDataset = GDALCreate( outputDriver, TO8F( mOutputFile ), xSize, ySize, 3, GDT_Byte, papszOptions ); + GDALDatasetH outputDataset = GDALCreate( outputDriver, mOutputFile.toUtf8().constData(), xSize, ySize, 3, GDT_Byte, papszOptions ); if ( !outputDataset ) { return outputDataset; diff --git a/src/analysis/raster/qgsrelief.h b/src/analysis/raster/qgsrelief.h index eaca801fc6f..2915a4787c8 100644 --- a/src/analysis/raster/qgsrelief.h +++ b/src/analysis/raster/qgsrelief.h @@ -23,6 +23,7 @@ #include #include #include "gdal.h" +#include "qgis_analysis.h" class QgsAspectFilter; class QgsSlopeFilter; @@ -45,6 +46,11 @@ class ANALYSIS_EXPORT QgsRelief QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat ); ~QgsRelief(); + //! QgsRelief cannot be copied + QgsRelief( const QgsRelief& rh ) = delete; + //! QgsRelief cannot be copied + QgsRelief& operator=( const QgsRelief& rh ) = delete; + /** Starts the calculation, reads from mInputFile and stores the result in mOutputFile @param p progress dialog that receives update and that is checked for abort. 0 if no progress bar is needed. @return 0 in case of success*/ @@ -122,8 +128,6 @@ class ANALYSIS_EXPORT QgsRelief */ bool calculateRegression( const QList< QPair < int, double > >& input, double& a, double& b ); - QgsRelief( const QgsRelief& rh ); - QgsRelief& operator=( const QgsRelief& rh ); }; #endif // QGSRELIEF_H diff --git a/src/analysis/raster/qgsruggednessfilter.h b/src/analysis/raster/qgsruggednessfilter.h index dfe86115e7f..af217c6e741 100644 --- a/src/analysis/raster/qgsruggednessfilter.h +++ b/src/analysis/raster/qgsruggednessfilter.h @@ -19,6 +19,7 @@ #define QGSRUGGEDNESSFILTER_H #include "qgsninecellfilter.h" +#include "qgis_analysis.h" /** \ingroup analysis * Calculates the ruggedness index based on a 3x3 moving window. diff --git a/src/analysis/raster/qgsslopefilter.h b/src/analysis/raster/qgsslopefilter.h index 8eaa9a1594e..e410e219022 100644 --- a/src/analysis/raster/qgsslopefilter.h +++ b/src/analysis/raster/qgsslopefilter.h @@ -19,6 +19,7 @@ #define QGSSLOPEFILTER_H #include "qgsderivativefilter.h" +#include "qgis_analysis.h" /** \ingroup analysis * Calculates slope values in a window of 3x3 cells based on first order derivatives in x- and y- directions*/ diff --git a/src/analysis/raster/qgstotalcurvaturefilter.h b/src/analysis/raster/qgstotalcurvaturefilter.h index df108ebaa48..22b4967109e 100644 --- a/src/analysis/raster/qgstotalcurvaturefilter.h +++ b/src/analysis/raster/qgstotalcurvaturefilter.h @@ -19,6 +19,7 @@ #define QGSTOTALCURVATUREFILTER_H #include "qgsninecellfilter.h" +#include "qgis_analysis.h" /** \ingroup analysis * Calculates total curvature as described by Wilson, Gallant (2000): terrain analysis*/ diff --git a/src/analysis/vector/qgsgeometryanalyzer.h b/src/analysis/vector/qgsgeometryanalyzer.h index d96e7547ef3..722fa5695a6 100644 --- a/src/analysis/vector/qgsgeometryanalyzer.h +++ b/src/analysis/vector/qgsgeometryanalyzer.h @@ -20,6 +20,7 @@ #include "qgsfeature.h" #include "qgsgeometry.h" +#include "qgis_analysis.h" class QgsVectorFileWriter; class QProgressDialog; diff --git a/src/analysis/vector/qgsgeometrysnapper.h b/src/analysis/vector/qgsgeometrysnapper.h index 26926576533..a440ce40e89 100644 --- a/src/analysis/vector/qgsgeometrysnapper.h +++ b/src/analysis/vector/qgsgeometrysnapper.h @@ -23,6 +23,7 @@ #include "qgsspatialindex.h" #include "qgsabstractgeometry.h" #include "qgspointv2.h" +#include "qgis_analysis.h" class QgsVectorLayer; @@ -122,7 +123,7 @@ class QgsSnapIndex class SnapItem { public: - virtual ~SnapItem() {} + virtual ~SnapItem() = default; SnapType type; virtual QgsPointV2 getSnapPoint( const QgsPointV2& p ) const = 0; diff --git a/src/analysis/vector/qgsoverlayanalyzer.h b/src/analysis/vector/qgsoverlayanalyzer.h index a15b88348d7..b68db6f3477 100644 --- a/src/analysis/vector/qgsoverlayanalyzer.h +++ b/src/analysis/vector/qgsoverlayanalyzer.h @@ -19,6 +19,7 @@ #define QGSOVERLAYANALYZERH #include "qgsvectorlayer.h" +#include "qgis_analysis.h" class QgsVectorFileWriter; class QProgressDialog; diff --git a/src/analysis/vector/qgspointsample.h b/src/analysis/vector/qgspointsample.h index 7db3d188571..b8d3ddf92bf 100644 --- a/src/analysis/vector/qgspointsample.h +++ b/src/analysis/vector/qgspointsample.h @@ -17,6 +17,7 @@ #include "qgsfeature.h" #include +#include "qgis_analysis.h" class QgsFeature; class QgsPoint; diff --git a/src/analysis/vector/qgstransectsample.h b/src/analysis/vector/qgstransectsample.h index b00c01e62f8..5fffbbb8cfc 100644 --- a/src/analysis/vector/qgstransectsample.h +++ b/src/analysis/vector/qgstransectsample.h @@ -18,6 +18,7 @@ #include "qgsfeature.h" #include #include +#include "qgis_analysis.h" class QgsDistanceArea; class QgsGeometry; diff --git a/src/analysis/vector/qgszonalstatistics.cpp b/src/analysis/vector/qgszonalstatistics.cpp index 0fd2df0cb28..3003daefe2b 100644 --- a/src/analysis/vector/qgszonalstatistics.cpp +++ b/src/analysis/vector/qgszonalstatistics.cpp @@ -28,12 +28,6 @@ #include #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 -#define TO8F(x) (x).toUtf8().constData() -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#endif - QgsZonalStatistics::QgsZonalStatistics( QgsVectorLayer* polygonLayer, const QString& rasterFile, const QString& attributePrefix, int rasterBand, Statistics stats ) : mRasterFilePath( rasterFile ) , mRasterBand( rasterBand ) @@ -69,7 +63,7 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p ) //open the raster layer and the raster band GDALAllRegister(); - GDALDatasetH inputDataset = GDALOpen( TO8F( mRasterFilePath ), GA_ReadOnly ); + GDALDatasetH inputDataset = GDALOpen( mRasterFilePath.toUtf8().constData(), GA_ReadOnly ); if ( !inputDataset ) { return 3; diff --git a/src/analysis/vector/qgszonalstatistics.h b/src/analysis/vector/qgszonalstatistics.h index 05d2d10325d..4ad1a45d486 100644 --- a/src/analysis/vector/qgszonalstatistics.h +++ b/src/analysis/vector/qgszonalstatistics.h @@ -22,6 +22,7 @@ #include #include #include +#include "qgis_analysis.h" class QgsGeometry; class QgsVectorLayer; diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 92a2e5c8f8a..9affa8e6fe2 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -524,6 +524,11 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} composer legend pluginmanager ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../ui + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui + ${CMAKE_BINARY_DIR}/src/python + ${CMAKE_BINARY_DIR}/src/analysis + ${CMAKE_BINARY_DIR}/src/app ) INCLUDE_DIRECTORIES(SYSTEM ${QWT_INCLUDE_DIR} @@ -587,9 +592,6 @@ ELSE (ANDROID) ADD_EXECUTABLE(${QGIS_APP_NAME} MACOSX_BUNDLE WIN32 ${QGIS_APPMAIN_SRCS} ${IMAGE_RCC_SRCS} ${TEST_RCC_SRCS}) ENDIF (ANDROID) -REMOVE_DEFINITIONS("-DAPP_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("\"-DAPP_EXPORT=${DLLEXPORT}\"") - # Putting IMAGE_RCC_SRCS into qgis_app lib is causing problems when the lib is # loaded (by plugin for example) in test unit (qgis_composerpicturetest). ADD_LIBRARY(qgis_app SHARED ${QGIS_APP_SRCS} ${QGIS_APP_MOC_SRCS} ${QGIS_APP_HDRS} ${QGIS_APP_MOC_HDRS}) @@ -609,6 +611,12 @@ TARGET_LINK_LIBRARIES(qgis_app libdxfrw ) +GENERATE_EXPORT_HEADER( + qgis_app + BASE_NAME APP + EXPORT_FILE_NAME qgis_app.h +) + IF (NOT ANDROID) SET_TARGET_PROPERTIES(qgis_app PROPERTIES VERSION ${COMPLETE_VERSION} diff --git a/src/app/composer/qgscomposer.cpp b/src/app/composer/qgscomposer.cpp index 294089982ba..7bd18909db4 100644 --- a/src/app/composer/qgscomposer.cpp +++ b/src/app/composer/qgscomposer.cpp @@ -547,7 +547,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title ) connect( mActionShowRulers, SIGNAL( triggered( bool ) ), this, SLOT( toggleRulers( bool ) ) ); //init undo/redo buttons - mComposition = new QgsComposition( mQgis->mapCanvas()->mapSettings() ); + mComposition = new QgsComposition( mQgis->mapCanvas()->mapSettings(), QgsProject::instance() ); mActionUndo->setEnabled( false ); mActionRedo->setEnabled( false ); @@ -878,7 +878,7 @@ void QgsComposer::changeEvent( QEvent* event ) #endif case QEvent::WindowStateChange: { - /* Listen out for window un-minimisation and restore composer map states. + /* Listen out for window un-minimization and restore composer map states. * We can't use showEvent to detect this due to QT Bug 36675 (see #6085). */ QWindowStateChangeEvent* changeEv = static_cast< QWindowStateChangeEvent* >( event ); @@ -1128,7 +1128,7 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked ) bool previewEnabled = mComposition->setAtlasMode( checked ? QgsComposition::PreviewAtlas : QgsComposition::AtlasOff ); if ( !previewEnabled ) { - //something went wrong, eg, no matching features + //something went wrong, e.g., no matching features QMessageBox::warning( nullptr, tr( "Enable atlas preview" ), tr( "No matching atlas features found!" ), QMessageBox::Ok, @@ -2488,7 +2488,7 @@ void QgsComposer::exportCompositionAsSVG( QgsComposer::OutputMode mode ) "with layers not being clipped to the map " "bounding box.

    " ) + tr( "If you require a vector-based output file from " - "Qgis it is suggested that you try printing " + "QGIS it is suggested that you try printing " "to PostScript if the SVG output is not " "satisfactory." "

    " ) ); @@ -3471,7 +3471,7 @@ void QgsComposer::writeXml( QDomNode& parentNode, QDomDocument& doc ) QDomElement composerElem = doc.createElement( QStringLiteral( "Composer" ) ); composerElem.setAttribute( QStringLiteral( "title" ), mTitle ); - //change preview mode of minimised / hidden maps before saving XML (show contents only on demand) + //change preview mode of minimized / hidden maps before saving XML (show contents only on demand) QMap< QgsComposerMap*, int >::const_iterator mapIt = mMapsToRestore.constBegin(); for ( ; mapIt != mMapsToRestore.constEnd(); ++mapIt ) { @@ -3543,7 +3543,7 @@ void QgsComposer::readXml( const QDomElement& composerElem, const QDomDocument& createComposerView(); //read composition settings - mComposition = new QgsComposition( mQgis->mapCanvas()->mapSettings() ); + mComposition = new QgsComposition( mQgis->mapCanvas()->mapSettings(), QgsProject::instance() ); QDomNodeList compositionNodeList = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ); if ( compositionNodeList.size() > 0 ) { diff --git a/src/app/composer/qgscomposeritemwidget.cpp b/src/app/composer/qgscomposeritemwidget.cpp index 11bea4e4709..479449e552d 100644 --- a/src/app/composer/qgscomposeritemwidget.cpp +++ b/src/app/composer/qgscomposeritemwidget.cpp @@ -177,12 +177,9 @@ QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem* updateVariables(); connect( mVariableEditor, SIGNAL( scopeChanged() ), this, SLOT( variablesChanged() ) ); // listen out for variable edits - QgsApplication* app = qobject_cast( QgsApplication::instance() ); - if ( app ) - { - connect( app, SIGNAL( settingsChanged() ), this, SLOT( updateVariables() ) ); - } - connect( QgsProject::instance(), SIGNAL( variablesChanged() ), this, SLOT( updateVariables() ) ); + connect( QgsApplication::instance(), &QgsApplication::customVariablesChanged, this, &QgsComposerItemWidget::updateVariables ); + connect( QgsProject::instance(), &QgsProject::customVariablesChanged, this, &QgsComposerItemWidget::updateVariables ); + if ( mItem->composition() ) connect( mItem->composition(), SIGNAL( variablesChanged() ), this, SLOT( updateVariables() ) ); } diff --git a/src/app/composer/qgscomposeritemwidget.h b/src/app/composer/qgscomposeritemwidget.h index 9df2f5e27da..b13932c5e31 100644 --- a/src/app/composer/qgscomposeritemwidget.h +++ b/src/app/composer/qgscomposeritemwidget.h @@ -39,7 +39,7 @@ class QgsDataDefinedButton; // contains a child QgsPanelWidget, which breaks lots of assumptions made in QgsPanelWidget // and related classes). // So QgsComposerItemWidget HAS a QgsComposerConfigObject to handle these common tasks. -// Specific item property widgets (eg QgsComposerMapWidget) should inherit from QgsComposerItemBaseWidget +// Specific item property widgets (e.g., QgsComposerMapWidget) should inherit from QgsComposerItemBaseWidget // (which is a QgsPanelWidget) and also HAS a QgsComposerConfigObject, with protected methods // which are just proxied through to the QgsComposerConfigObject. // phew! @@ -78,7 +78,7 @@ class QgsComposerConfigObject: public QObject //! Must be called when a data defined button changes void updateDataDefinedProperty(); - //! Updates data defined buttons to reflect current state of atlas (eg coverage layer) + //! Updates data defined buttons to reflect current state of atlas (e.g., coverage layer) void updateDataDefinedButtons(); private: diff --git a/src/app/composer/qgscomposerpicturewidget.cpp b/src/app/composer/qgscomposerpicturewidget.cpp index 57ea1a536e6..3630095f9ac 100644 --- a/src/app/composer/qgscomposerpicturewidget.cpp +++ b/src/app/composer/qgscomposerpicturewidget.cpp @@ -417,7 +417,7 @@ QIcon QgsComposerPictureWidget::svgToIcon( const QString& filePath ) const bool fillParam, fillOpacityParam, outlineParam, outlineWidthParam, outlineOpacityParam; bool hasDefaultFillColor = false, hasDefaultFillOpacity = false, hasDefaultOutlineColor = false, hasDefaultOutlineWidth = false, hasDefaultOutlineOpacity = false; - QgsSvgCache::instance()->containsParams( filePath, fillParam, hasDefaultFillColor, fill, + QgsApplication::svgCache()->containsParams( filePath, fillParam, hasDefaultFillColor, fill, fillOpacityParam, hasDefaultFillOpacity, fillOpacity, outlineParam, hasDefaultOutlineColor, outline, outlineWidthParam, hasDefaultOutlineWidth, outlineWidth, @@ -434,7 +434,7 @@ QIcon QgsComposerPictureWidget::svgToIcon( const QString& filePath ) const outlineWidth = 0.6; bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size) - const QImage& img = QgsSvgCache::instance()->svgAsImage( filePath, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache ); + const QImage& img = QgsApplication::svgCache()->svgAsImage( filePath, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache ); return QIcon( QPixmap::fromImage( img ) ); } @@ -458,7 +458,7 @@ void QgsComposerPictureWidget::updateSvgParamGui( bool resetValues ) QColor defaultFill, defaultOutline; double defaultOutlineWidth, defaultFillOpacity, defaultOutlineOpacity; bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultOutlineColor, hasDefaultOutlineWidth, hasDefaultOutlineOpacity; - QgsSvgCache::instance()->containsParams( picturePath, hasFillParam, hasDefaultFillColor, defaultFill, + QgsApplication::svgCache()->containsParams( picturePath, hasFillParam, hasDefaultFillColor, defaultFill, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasOutlineParam, hasDefaultOutlineColor, defaultOutline, hasOutlineWidthParam, hasDefaultOutlineWidth, defaultOutlineWidth, diff --git a/src/app/composer/qgscompositionwidget.cpp b/src/app/composer/qgscompositionwidget.cpp index 13f91864560..cb1816afa71 100644 --- a/src/app/composer/qgscompositionwidget.cpp +++ b/src/app/composer/qgscompositionwidget.cpp @@ -28,10 +28,9 @@ #include #include //for screen resolution -QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c )\ -: -QgsPanelWidget( parent ) -, mComposition( c ) +QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c ) + : QgsPanelWidget( parent ) + , mComposition( c ) { setupUi( this ); setPanelTitle( tr( "Composition properties" ) ); @@ -53,12 +52,8 @@ QgsPanelWidget( parent ) updateVariables(); connect( mVariableEditor, SIGNAL( scopeChanged() ), this, SLOT( variablesChanged() ) ); // listen out for variable edits - QgsApplication* app = qobject_cast( QgsApplication::instance() ); - if ( app ) - { - connect( app, SIGNAL( settingsChanged() ), this, SLOT( updateVariables() ) ); - } - connect( QgsProject::instance(), SIGNAL( variablesChanged() ), this, SLOT( updateVariables() ) ); + connect( QgsApplication::instance(), &QgsApplication::customVariablesChanged, this, &QgsCompositionWidget::updateVariables ); + connect( QgsProject::instance(), &QgsProject::customVariablesChanged, this, &QgsCompositionWidget::updateVariables ); if ( mComposition ) { @@ -210,7 +205,7 @@ void QgsCompositionWidget::updateVariables() { QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::compositionScope( mComposition ); mVariableEditor->setContext( &context ); mVariableEditor->setEditableScopeIndex( 2 ); diff --git a/src/app/dwg/libdxfrw/CMakeLists.txt b/src/app/dwg/libdxfrw/CMakeLists.txt index 8437c05b264..c8a10cdb47a 100644 --- a/src/app/dwg/libdxfrw/CMakeLists.txt +++ b/src/app/dwg/libdxfrw/CMakeLists.txt @@ -1,5 +1,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/core ${Qt5Core_INCLUDE_DIRS} ) diff --git a/src/app/dwg/libdxfrw/drw_base.h b/src/app/dwg/libdxfrw/drw_base.h index 6d1fd6874d3..090a2c2a68d 100644 --- a/src/app/dwg/libdxfrw/drw_base.h +++ b/src/app/dwg/libdxfrw/drw_base.h @@ -68,33 +68,33 @@ namespace DRW //! Version numbers for the DXF Format. enum Version { - UNKNOWNV, /*!< UNKNOWN VERSION. */ - AC1006, /*!< R10. */ - AC1009, /*!< R11 & R12. */ - AC1012, /*!< R13. */ - AC1014, /*!< R14. */ - AC1015, /*!< ACAD 2000. */ - AC1018, /*!< ACAD 2004. */ - AC1021, /*!< ACAD 2007. */ - AC1024, /*!< ACAD 2010. */ - AC1027 /*!< ACAD 2013. */ + UNKNOWNV, //!< UNKNOWN VERSION. + AC1006, //!< R10. + AC1009, //!< R11 & R12. + AC1012, //!< R13. + AC1014, //!< R14. + AC1015, //!< ACAD 2000. + AC1018, //!< ACAD 2004. + AC1021, //!< ACAD 2007. + AC1024, //!< ACAD 2010. + AC1027 //!< ACAD 2013. }; enum error { - BAD_NONE, /*!< No error. */ - BAD_UNKNOWN, /*!< UNKNOWN. */ - BAD_OPEN, /*!< error opening file. */ - BAD_VERSION, /*!< unsupported version. */ - BAD_READ_METADATA, /*!< error reading matadata. */ - BAD_READ_FILE_HEADER, /*!< error in file header read process. */ - BAD_READ_HEADER, /*!< error in header vars read process. */ - BAD_READ_HANDLES, /*!< error in object map read process. */ - BAD_READ_CLASSES, /*!< error in classes read process. */ - BAD_READ_TABLES, /*!< error in tables read process. */ - BAD_READ_BLOCKS, /*!< error in block read process. */ - BAD_READ_ENTITIES, /*!< error in entities read process. */ - BAD_READ_OBJECTS /*!< error in objects read process. */ + BAD_NONE, //!< No error. + BAD_UNKNOWN, //!< UNKNOWN. + BAD_OPEN, //!< Error opening file. + BAD_VERSION, //!< Unsupported version. + BAD_READ_METADATA, //!< Error reading matadata. + BAD_READ_FILE_HEADER, //!< Error in file header read process. + BAD_READ_HEADER, //!< Error in header vars read process. + BAD_READ_HANDLES, //!< Error in object map read process. + BAD_READ_CLASSES, //!< Error in classes read process. + BAD_READ_TABLES, //!< Error in tables read process. + BAD_READ_BLOCKS, //!< Error in block read process. + BAD_READ_ENTITIES, //!< Error in entities read process. + BAD_READ_OBJECTS //!< Error in objects read process. }; enum DBG_LEVEL @@ -171,7 +171,7 @@ class DRW_Coord z = data.z; return *this; } - /** < convert to unitary vector */ + //! < convert to unitary vector void unitize() { double dist; @@ -204,11 +204,11 @@ class DRW_Vertex2D DRW_Vertex2D( double sx, double sy, double b ): x( sx ), y( sy ), stawidth( 0 ), endwidth( 0 ), bulge( b ) {} public: - double x; /*!< x coordinate, code 10 */ - double y; /*!< y coordinate, code 20 */ - double stawidth; /*!< Start width, code 40 */ - double endwidth; /*!< End width, code 41 */ - double bulge; /*!< bulge, code 42 */ + double x; //!< X coordinate, code 10 + double y; //!< Y coordinate, code 20 + double stawidth; //!< Start width, code 40 + double endwidth; //!< End width, code 41 + double bulge; //!< Bulge, code 42 }; @@ -261,7 +261,7 @@ class DRW_Variant void setCoordY( double d ) { if ( vType == COORD ) vdata.y = d;} void setCoordZ( double d ) { if ( vType == COORD ) vdata.z = d;} enum TYPE type() { return vType;} - int code() { return vCode;} /*!< returns dxf code of this value*/ + int code() { return vCode;} //!< Returns dxf code of this value private: std::string sdata; @@ -285,7 +285,7 @@ class DRW_Variant DRW_VarContent content; private: enum TYPE vType; - int vCode; /*!< dxf code of this value*/ + int vCode; //!< Dxf code of this value }; @@ -317,33 +317,33 @@ class DRW_LW_Conv public: enum lineWidth { - width00 = 0, /*!< 0.00mm (dxf 0)*/ - width01 = 1, /*!< 0.05mm (dxf 5)*/ - width02 = 2, /*!< 0.09mm (dxf 9)*/ - width03 = 3, /*!< 0.13mm (dxf 13)*/ - width04 = 4, /*!< 0.15mm (dxf 15)*/ - width05 = 5, /*!< 0.18mm (dxf 18)*/ - width06 = 6, /*!< 0.20mm (dxf 20)*/ - width07 = 7, /*!< 0.25mm (dxf 25)*/ - width08 = 8, /*!< 0.30mm (dxf 30)*/ - width09 = 9, /*!< 0.35mm (dxf 35)*/ - width10 = 10, /*!< 0.40mm (dxf 40)*/ - width11 = 11, /*!< 0.50mm (dxf 50)*/ - width12 = 12, /*!< 0.53mm (dxf 53)*/ - width13 = 13, /*!< 0.60mm (dxf 60)*/ - width14 = 14, /*!< 0.70mm (dxf 70)*/ - width15 = 15, /*!< 0.80mm (dxf 80)*/ - width16 = 16, /*!< 0.90mm (dxf 90)*/ - width17 = 17, /*!< 1.00mm (dxf 100)*/ - width18 = 18, /*!< 1.06mm (dxf 106)*/ - width19 = 19, /*!< 1.20mm (dxf 120)*/ - width20 = 20, /*!< 1.40mm (dxf 140)*/ - width21 = 21, /*!< 1.58mm (dxf 158)*/ - width22 = 22, /*!< 2.00mm (dxf 200)*/ - width23 = 23, /*!< 2.11mm (dxf 211)*/ - widthByLayer = 29, /*!< by layer (dxf -1) */ - widthByBlock = 30, /*!< by block (dxf -2) */ - widthDefault = 31 /*!< by default (dxf -3) */ + width00 = 0, //!< 0.00mm (dxf 0) + width01 = 1, //!< 0.05mm (dxf 5) + width02 = 2, //!< 0.09mm (dxf 9) + width03 = 3, //!< 0.13mm (dxf 13) + width04 = 4, //!< 0.15mm (dxf 15) + width05 = 5, //!< 0.18mm (dxf 18) + width06 = 6, //!< 0.20mm (dxf 20) + width07 = 7, //!< 0.25mm (dxf 25) + width08 = 8, //!< 0.30mm (dxf 30) + width09 = 9, //!< 0.35mm (dxf 35) + width10 = 10, //!< 0.40mm (dxf 40) + width11 = 11, //!< 0.50mm (dxf 50) + width12 = 12, //!< 0.53mm (dxf 53) + width13 = 13, //!< 0.60mm (dxf 60) + width14 = 14, //!< 0.70mm (dxf 70) + width15 = 15, //!< 0.80mm (dxf 80) + width16 = 16, //!< 0.90mm (dxf 90) + width17 = 17, //!< 1.00mm (dxf 100) + width18 = 18, //!< 1.06mm (dxf 106) + width19 = 19, //!< 1.20mm (dxf 120) + width20 = 20, //!< 1.40mm (dxf 140) + width21 = 21, //!< 1.58mm (dxf 158) + width22 = 22, //!< 2.00mm (dxf 200) + width23 = 23, //!< 2.11mm (dxf 211) + widthByLayer = 29, //!< By layer (dxf -1) + widthByBlock = 30, //!< By block (dxf -2) + widthDefault = 31 //!< By default (dxf -3) }; static int lineWidth2dxfInt( enum lineWidth lw ) diff --git a/src/app/dwg/libdxfrw/drw_classes.h b/src/app/dwg/libdxfrw/drw_classes.h index fe7325d0c6e..ed83c713b1a 100644 --- a/src/app/dwg/libdxfrw/drw_classes.h +++ b/src/app/dwg/libdxfrw/drw_classes.h @@ -48,13 +48,13 @@ class DRW_Class private: void toDwgType(); public: - UTF8STRING recName; /*!< record name, code 1 */ - UTF8STRING className; /*!< C++ class name, code 2 */ - UTF8STRING appName; /*!< app name, code 3 */ - int proxyFlag; /*!< Proxy capabilities flag, code 90 */ - int instanceCount; /*!< number of instances for a custom class, code 91*/ - int wasaProxyFlag; /*!< proxy flag (app loaded on save), code 280 */ - int entityFlag; /*!< entity flag, code 281 (0 object, 1 entity)*/ + UTF8STRING recName; //!< Record name, code 1 + UTF8STRING className; //!< C++ class name, code 2 + UTF8STRING appName; //!< App name, code 3 + int proxyFlag; //!< Proxy capabilities flag, code 90 + int instanceCount; //!< Number of instances for a custom class, code 91 + int wasaProxyFlag; //!< Proxy flag (app loaded on save), code 280 + int entityFlag; //!< Entity flag, code 281 (0 object, 1 entity) public: //only for read dwg duint16 classNum; int dwgType; diff --git a/src/app/dwg/libdxfrw/drw_entities.cpp b/src/app/dwg/libdxfrw/drw_entities.cpp index bf1961173b2..5d35d048e75 100644 --- a/src/app/dwg/libdxfrw/drw_entities.cpp +++ b/src/app/dwg/libdxfrw/drw_entities.cpp @@ -1224,8 +1224,7 @@ void DRW_Insert::parseCode( int code, dxfReader *reader ) zscale = reader->getDouble(); break; case 50: - angle = reader->getDouble(); - angle = angle / ARAD; //convert to radian + angle = reader->getDouble() / ARAD; break; case 70: colcount = reader->getInt32(); @@ -1590,7 +1589,7 @@ void DRW_Text::parseCode( int code, dxfReader *reader ) widthscale = reader->getDouble(); break; case 50: - angle = reader->getDouble(); + angle = reader->getDouble() / ARAD; break; case 51: oblique = reader->getDouble(); @@ -1630,7 +1629,7 @@ bool DRW_Text::parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs ) QgsDebugMsg( "***************************** parsing text *********************************************" ); -// DataFlags RC Used to determine presence of subsquent data, set to 0xFF for R14- + // DataFlags RC Used to determine presence of subsequent data, set to 0xFF for R14- duint8 data_flags = 0x00; if ( version > DRW::AC1014 ) //2000+ { diff --git a/src/app/dwg/libdxfrw/drw_entities.h b/src/app/dwg/libdxfrw/drw_entities.h index 245180acbe2..af22ac6f445 100644 --- a/src/app/dwg/libdxfrw/drw_entities.h +++ b/src/app/dwg/libdxfrw/drw_entities.h @@ -209,27 +209,27 @@ class DRW_Entity bool parseDxfGroups( int code, dxfReader *reader ); public: - enum DRW::ETYPE eType; /*!< enum: entity type, code 0 */ - duint32 handle; /*!< entity identifier, code 5 */ - duint32 parentHandle; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */ - std::list > appData; /*!< list of application data, code 102 */ - DRW::Space space; /*!< space indicator, code 67*/ - UTF8STRING layer; /*!< layer name, code 8 */ - UTF8STRING lineType; /*!< line type, code 6 */ - duint32 material; /*!< hard pointer id to material object, code 347 */ - int color; /*!< entity color, code 62 */ - enum DRW_LW_Conv::lineWidth lWeight; /*!< entity lineweight, code 370 */ - double ltypeScale; /*!< linetype scale, code 48 */ - bool visible; /*!< entity visibility, code 60 */ - int numProxyGraph; /*!< Number of bytes in proxy graphics, code 92 */ - std::string proxyGraphics; /*!< proxy graphics bytes, code 310 */ - int color24; /*!< 24-bit color, code 420 */ - std::string colorName; /*!< color name, code 430 */ - int transparency; /*!< transparency, code 440 */ - int plotStyle; /*!< hard pointer id to plot style object, code 390 */ - DRW::ShadowMode shadow; /*!< shadow mode, code 284 */ - bool haveExtrusion; /*!< set to true if the entity have extrusion*/ - std::vector extData; /*!< FIFO list of extended data, codes 1000 to 1071*/ + enum DRW::ETYPE eType; //!< Enum: entity type, code 0 + duint32 handle; //!< Entity identifier, code 5 + duint32 parentHandle; //!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 + std::list > appData; //!< List of application data, code 102 + DRW::Space space; //!< Space indicator, code 67 + UTF8STRING layer; //!< Layer name, code 8 + UTF8STRING lineType; //!< Line type, code 6 + duint32 material; //!< Hard pointer id to material object, code 347 + int color; //!< Entity color, code 62 + enum DRW_LW_Conv::lineWidth lWeight; //!< Entity lineweight, code 370 + double ltypeScale; //!< Linetype scale, code 48 + bool visible; //!< Entity visibility, code 60 + int numProxyGraph; //!< Number of bytes in proxy graphics, code 92 + std::string proxyGraphics; //!< Proxy graphics bytes, code 310 + int color24; //!< 24-bit color, code 420 + std::string colorName; //!< Color name, code 430 + int transparency; //!< Transparency, code 440 + int plotStyle; //!< Hard pointer id to plot style object, code 390 + DRW::ShadowMode shadow; //!< Shadow mode, code 284 + bool haveExtrusion; //!< Set to true if the entity have extrusion + std::vector extData; //!< FIFO list of extended data, codes 1000 to 1071 protected: //only for read dwg duint8 haveNextLinks; // aka nolinks //B @@ -277,9 +277,9 @@ class DRW_Point : public DRW_Entity virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */ - double thickness; /*!< thickness, code 39 */ - DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ + DRW_Coord basePoint; //!< Base point, code 10, 20 & 30 + double thickness; //!< Thickness, code 39 + DRW_Coord extPoint; //!< Dir extrusion normal vector, code 210, 220 & 230 // TNick: we're not handling code 50 - Angle of the X axis for // the UCS in effect when the point was drawn }; @@ -304,7 +304,7 @@ class DRW_Line : public DRW_Point virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - DRW_Coord secPoint; /*!< second point, code 11, 21 & 31 */ + DRW_Coord secPoint; //!< Second point, code 11, 21 & 31 }; /** Class to handle ray entity @@ -354,7 +354,7 @@ class DRW_Circle : public DRW_Point virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - double mRadius; /*!< radius, code 40 */ + double mRadius; //!< Radius, code 40 }; /** Class to handle arc entity @@ -394,9 +394,9 @@ class DRW_Arc : public DRW_Circle virtual bool parseDwg( DRW::Version v, dwgBuffer *buf, duint32 bs = 0 ); public: - double staangle; /*!< start angle, code 50 in radians*/ - double endangle; /*!< end angle, code 51 in radians */ - int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */ + double staangle; //!< Start angle, code 50 in radians + double endangle; //!< End angle, code 51 in radians + int isccw; //!< Is counter clockwise arc?, only used in hatch, code 73 }; /** Class to handle ellipse and elliptic arc entity @@ -432,10 +432,10 @@ class DRW_Ellipse : public DRW_Line void correctAxis(); public: - double ratio; /*!< ratio, code 40 */ - double staparam; /*!< start parameter, code 41, 0.0 for full ellipse*/ - double endparam; /*!< end parameter, code 42, 2*PI for full ellipse */ - int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */ + double ratio; //!< Ratio, code 40 + double staparam; //!< Start parameter, code 41, 0.0 for full ellipse + double endparam; //!< End parameter, code 42, 2*PI for full ellipse + int isccw; //!< Is counter clockwise arc?, only used in hatch, code 73 }; /** Class to handle trace entity @@ -460,8 +460,8 @@ class DRW_Trace : public DRW_Line virtual bool parseDwg( DRW::Version v, dwgBuffer *buf, duint32 bs = 0 ); public: - DRW_Coord thirdPoint; /*!< third point, code 12, 22 & 32 */ - DRW_Coord fourthPoint; /*!< four point, code 13, 23 & 33 */ + DRW_Coord thirdPoint; //!< Third point, code 12, 22 & 32 + DRW_Coord fourthPoint; //!< Four point, code 13, 23 & 33 }; /** Class to handle solid entity @@ -544,7 +544,7 @@ class DRW_3Dface : public DRW_Trace virtual bool parseDwg( DRW::Version v, dwgBuffer *buf, duint32 bs = 0 ); public: - int invisibleflag; /*!< invisible edge flag, code 70 */ + int invisibleflag; //!< Invisible edge flag, code 70 }; @@ -570,8 +570,8 @@ class DRW_Block : public DRW_Point virtual bool parseDwg( DRW::Version v, dwgBuffer *buf, duint32 bs = 0 ); public: - UTF8STRING name; /*!< block name, code 2 */ - int flags; /*!< block type, code 70 */ + UTF8STRING name; //!< Block name, code 2 + int flags; //!< Block type, code 70 private: bool isEnd; //for dwg parsing }; @@ -604,15 +604,15 @@ class DRW_Insert : public DRW_Point virtual bool parseDwg( DRW::Version v, dwgBuffer *buf, duint32 bs = 0 ); public: - UTF8STRING name; /*!< block name, code 2 */ - double xscale; /*!< x scale factor, code 41 */ - double yscale; /*!< y scale factor, code 42 */ - double zscale; /*!< z scale factor, code 43 */ - double angle; /*!< rotation angle in radians, code 50 */ - int colcount; /*!< column count, code 70 */ - int rowcount; /*!< row count, code 71 */ - double colspace; /*!< column space, code 44 */ - double rowspace; /*!< row space, code 45 */ + UTF8STRING name; //!< Block name, code 2 + double xscale; //!< X scale factor, code 41 + double yscale; //!< Y scale factor, code 42 + double zscale; //!< Z scale factor, code 43 + double angle; //!< Rotation angle in radians, code 50 + int colcount; //!< Column count, code 70 + int rowcount; //!< Row count, code 71 + double colspace; //!< Column space, code 44 + double rowspace; //!< Row space, code 45 public: //only for read dwg dwgHandle blockRecH; dwgHandle seqendH; //RLZ: on implement attrib remove this handle from obj list (see pline/vertex code) @@ -684,14 +684,14 @@ class DRW_LWPolyline : public DRW_Entity bool parseDwg( DRW::Version v, dwgBuffer *buf, duint32 bs = 0 ); public: - std::vector::size_type vertexnum; /*!< number of vertices, code 90 */ - int flags; /*!< polyline flag, code 70, default 0 */ - double width; /*!< constant width, code 43 */ - double elevation; /*!< elevation, code 38 */ - double thickness; /*!< thickness, code 39 */ - DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ - DRW_Vertex2D *vertex; /*!< current vertex to add data */ - std::vector vertlist; /*!< vertex list */ + std::vector::size_type vertexnum; //!< Number of vertices, code 90 + int flags; //!< Polyline flag, code 70, default 0 + double width; //!< Constant width, code 43 + double elevation; //!< Elevation, code 38 + double thickness; //!< Thickness, code 39 + DRW_Coord extPoint; //!< Dir extrusion normal vector, code 210, 220 & 230 + DRW_Vertex2D *vertex; //!< Current vertex to add data + std::vector vertlist; //!< Vertex list }; /** Class to handle insert entries @@ -704,21 +704,21 @@ class DRW_Text : public DRW_Line //! Vertical alignments. enum VAlign { - VBaseLine = 0, /*!< Top = 0 */ - VBottom, /*!< Bottom = 1 */ - VMiddle, /*!< Middle = 2 */ - VTop /*!< Top = 3 */ + VBaseLine = 0, //!< Top = 0 + VBottom, //!< Bottom = 1 + VMiddle, //!< Middle = 2 + VTop //!< Top = 3 }; //! Horizontal alignments. enum HAlign { - HLeft = 0, /*!< Left = 0 */ - HCenter, /*!< Centered = 1 */ - HRight, /*!< Right = 2 */ - HAligned, /*!< Aligned = 3 (if VAlign==0) */ - HMiddle, /*!< middle = 4 (if VAlign==0) */ - HFit /*!< fit into point = 5 (if VAlign==0) */ + HLeft = 0, //!< Left = 0 + HCenter, //!< Centered = 1 + HRight, //!< Right = 2 + HAligned, //!< Aligned = 3 (if VAlign==0) + HMiddle, //!< Middle = 4 (if VAlign==0) + HFit //!< Fit into point = 5 (if VAlign==0) }; DRW_Text( enum DRW::ETYPE type = DRW::TEXT ) @@ -741,16 +741,16 @@ class DRW_Text : public DRW_Line virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - double height; /*!< height text, code 40 */ - UTF8STRING text; /*!< text string, code 1 */ - double angle; /*!< rotation angle in degrees (360), code 50 */ - double widthscale; /*!< width factor, code 41 */ - double oblique; /*!< oblique angle, code 51 */ - UTF8STRING style; /*!< style name, code 7 */ - int textgen; /*!< text generation, code 71 */ - enum HAlign alignH; /*!< horizontal align, code 72 */ - enum VAlign alignV; /*!< vertical align, code 73 */ - dwgHandle styleH; /*!< handle for text style */ + double height; //!< Height text, code 40 + UTF8STRING text; //!< Text string, code 1 + double angle; //!< Rotation angle in degrees (360), code 50 + double widthscale; //!< Width factor, code 41 + double oblique; //!< Oblique angle, code 51 + UTF8STRING style; //!< Style name, code 7 + int textgen; //!< Text generation, code 71 + enum HAlign alignH; //!< Horizontal align, code 72 + enum VAlign alignV; //!< Vertical align, code 73 + dwgHandle styleH; //!< Handle for text style }; /** Class to handle insert entries @@ -789,7 +789,7 @@ class DRW_MText : public DRW_Text virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - double interlin; /*!< width factor, code 44 */ + double interlin; //!< Width factor, code 44 private: bool haveXAxis; }; @@ -843,17 +843,17 @@ class DRW_Vertex : public DRW_Point } public: - double stawidth; /*!< Start width, code 40 */ - double endwidth; /*!< End width, code 41 */ - double bulge; /*!< bulge, code 42 */ + double stawidth; //!< Start width, code 40 + double endwidth; //!< End width, code 41 + double bulge; //!< Bulge, code 42 - int flags; /*!< vertex flag, code 70, default 0 */ - double tgdir; /*!< curve fit tangent direction, code 50 */ - int vindex1; /*!< polyface mesh vertex index, code 71, default 0 */ - int vindex2; /*!< polyface mesh vertex index, code 72, default 0 */ - int vindex3; /*!< polyface mesh vertex index, code 73, default 0 */ - int vindex4; /*!< polyface mesh vertex index, code 74, default 0 */ - int identifier; /*!< vertex identifier, code 91, default 0 */ + int flags; //!< Vertex flag, code 70, default 0 + double tgdir; //!< Curve fit tangent direction, code 50 + int vindex1; //!< Polyface mesh vertex index, code 71, default 0 + int vindex2; //!< Polyface mesh vertex index, code 72, default 0 + int vindex3; //!< Polyface mesh vertex index, code 73, default 0 + int vindex4; //!< Polyface mesh vertex index, code 74, default 0 + int identifier; //!< Vertex identifier, code 91, default 0 }; /** Class to handle polyline entity @@ -904,16 +904,16 @@ class DRW_Polyline : public DRW_Point virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - int flags; /*!< polyline flag, code 70, default 0 */ - double defstawidth; /*!< Start width, code 40, default 0 */ - double defendwidth; /*!< End width, code 41, default 0 */ - int vertexcount; /*!< polygon mesh M vertex or polyface vertex num, code 71, default 0 */ - int facecount; /*!< polygon mesh N vertex or polyface face num, code 72, default 0 */ - int smoothM; /*!< smooth surface M density, code 73, default 0 */ - int smoothN; /*!< smooth surface M density, code 74, default 0 */ - int curvetype; /*!< curves & smooth surface type, code 75, default 0 */ + int flags; //!< Polyline flag, code 70, default 0 + double defstawidth; //!< Start width, code 40, default 0 + double defendwidth; //!< End width, code 41, default 0 + int vertexcount; //!< Polygon mesh M vertex or polyface vertex num, code 71, default 0 + int facecount; //!< Polygon mesh N vertex or polyface face num, code 72, default 0 + int smoothM; //!< Smooth surface M density, code 73, default 0 + int smoothN; //!< Smooth surface M density, code 74, default 0 + int curvetype; //!< Curves & smooth surface type, code 75, default 0 - std::vector vertlist; /*!< vertex list */ + std::vector vertlist; //!< Vertex list private: std::list handleList; // list of handles, only in 2004+ @@ -962,34 +962,34 @@ class DRW_Spline : public DRW_Entity virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: -// double ex; /*!< normal vector x coordinate, code 210 */ -// double ey; /*!< normal vector y coordinate, code 220 */ -// double ez; /*!< normal vector z coordinate, code 230 */ - DRW_Coord normalVec; /*!< normal vector, code 210, 220, 230 */ - DRW_Coord tgStart; /*!< start tangent, code 12, 22, 32 */ -// double tgsx; /*!< start tangent x coordinate, code 12 */ -// double tgsy; /*!< start tangent y coordinate, code 22 */ -// double tgsz; /*!< start tangent z coordinate, code 32 */ - DRW_Coord tgEnd; /*!< end tangent, code 13, 23, 33 */ -// double tgex; /*!< end tangent x coordinate, code 13 */ -// double tgey; /*!< end tangent y coordinate, code 23 */ -// double tgez; /*!< end tangent z coordinate, code 33 */ - int flags; /*!< spline flag, code 70 */ - int degree; /*!< degree of the spline, code 71 */ - dint32 nknots; /*!< number of knots, code 72, default 0 */ - dint32 ncontrol; /*!< number of control points, code 73, default 0 */ - dint32 nfit; /*!< number of fit points, code 74, default 0 */ - double tolknot; /*!< knot tolerance, code 42, default 0.0000001 */ - double tolcontrol; /*!< control point tolerance, code 43, default 0.0000001 */ - double tolfit; /*!< fit point tolerance, code 44, default 0.0000001 */ +// double ex; //!< Normal vector x coordinate, code 210 +// double ey; //!< Normal vector y coordinate, code 220 +// double ez; //!< Normal vector z coordinate, code 230 + DRW_Coord normalVec; //!< Normal vector, code 210, 220, 230 + DRW_Coord tgStart; //!< Start tangent, code 12, 22, 32 +// double tgsx; //!< Start tangent x coordinate, code 12 +// double tgsy; //!< Start tangent y coordinate, code 22 +// double tgsz; //!< Start tangent z coordinate, code 32 + DRW_Coord tgEnd; //!< End tangent, code 13, 23, 33 +// double tgex; //!< End tangent x coordinate, code 13 +// double tgey; //!< End tangent y coordinate, code 23 +// double tgez; //!< End tangent z coordinate, code 33 + int flags; //!< Spline flag, code 70 + int degree; //!< Degree of the spline, code 71 + dint32 nknots; //!< Number of knots, code 72, default 0 + dint32 ncontrol; //!< Number of control points, code 73, default 0 + dint32 nfit; //!< Number of fit points, code 74, default 0 + double tolknot; //!< Knot tolerance, code 42, default 0.0000001 + double tolcontrol; //!< Control point tolerance, code 43, default 0.0000001 + double tolfit; //!< Fit point tolerance, code 44, default 0.0000001 - std::vector knotslist; /*!< knots list, code 40 */ - std::vector controllist; /*!< control points list, code 10, 20 & 30 */ - std::vector fitlist; /*!< fit points list, code 11, 21 & 31 */ + std::vector knotslist; //!< Knots list, code 40 + std::vector controllist; //!< Control points list, code 10, 20 & 30 + std::vector fitlist; //!< Fit points list, code 11, 21 & 31 private: - DRW_Coord *controlpoint; /*!< current control point to add data */ - DRW_Coord *fitpoint; /*!< current fit point to add data */ + DRW_Coord *controlpoint; //!< Current control point to add data + DRW_Coord *fitpoint; //!< Current fit point to add data }; /** Class to handle hatch loop @@ -1024,11 +1024,11 @@ class DRW_HatchLoop } public: - int type; /*!< boundary path type, code 92, polyline=2, default=0 */ - std::vector::size_type numedges; /*!< number of edges (if not a polyline), code 93 */ + int type; //!< Boundary path type, code 92, polyline=2, default=0 + std::vector::size_type numedges; //!< Number of edges (if not a polyline), code 93 //TODO: store lwpolylines as entities -// std::vector pollist; /*!< polyline list */ - std::vector objlist; /*!< entities list */ +// std::vector pollist; //!< Polyline list + std::vector objlist; //!< Entities list }; /** Class to handle hatch entity @@ -1075,18 +1075,18 @@ class DRW_Hatch : public DRW_Point virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - UTF8STRING name; /*!< hatch pattern name, code 2 */ - int solid; /*!< solid fill flag, code 70, solid=1, pattern=0 */ - int associative; /*!< associativity, code 71, associatve=1, non-assoc.=0 */ - int hstyle; /*!< hatch style, code 75 */ - int hpattern; /*!< hatch pattern type, code 76 */ - int doubleflag; /*!< hatch pattern double flag, code 77, double=1, single=0 */ - std::vector::size_type loopsnum; /*!< number of boundary paths (loops), code 91 */ - double angle; /*!< hatch pattern angle, code 52 */ - double scale; /*!< hatch pattern scale, code 41 */ - int deflines; /*!< number of pattern definition lines, code 78 */ + UTF8STRING name; //!< Hatch pattern name, code 2 + int solid; //!< Solid fill flag, code 70, solid=1, pattern=0 + int associative; //!< Associativity, code 71, associatve=1, non-assoc.=0 + int hstyle; //!< Hatch style, code 75 + int hpattern; //!< Hatch pattern type, code 76 + int doubleflag; //!< Hatch pattern double flag, code 77, double=1, single=0 + std::vector::size_type loopsnum; //!< Number of boundary paths (loops), code 91 + double angle; //!< Hatch pattern angle, code 52 + double scale; //!< Hatch pattern scale, code 41 + int deflines; //!< Number of pattern definition lines, code 78 - std::vector looplist; /*!< polyline list */ + std::vector looplist; //!< Polyline list private: void clearEntities() @@ -1140,7 +1140,7 @@ class DRW_Hatch : public DRW_Point } } - DRW_HatchLoop *loop; /*!< current loop to add data */ + DRW_HatchLoop *loop; //!< Current loop to add data DRW_Line *line; DRW_Arc *arc; DRW_Ellipse *ellipse; @@ -1176,15 +1176,15 @@ class DRW_Image : public DRW_Line virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - duint32 ref; /*!< Hard reference to imagedef object, code 340 */ - DRW_Coord vVector; /*!< V-vector of single pixel, x coordinate, code 12, 22 & 32 */ - double sizeu; /*!< image size in pixels, U value, code 13 */ - double sizev; /*!< image size in pixels, V value, code 23 */ - double dz; /*!< z coordinate, code 33 */ - int clip; /*!< Clipping state, code 280, 0=off 1=on */ - int brightness; /*!< Brightness value, code 281, (0-100) default 50 */ - int contrast; /*!< Brightness value, code 282, (0-100) default 50 */ - int fade; /*!< Brightness value, code 283, (0-100) default 0 */ + duint32 ref; //!< Hard reference to imagedef object, code 340 + DRW_Coord vVector; //!< V-vector of single pixel, x coordinate, code 12, 22 & 32 + double sizeu; //!< Image size in pixels, U value, code 13 + double sizev; //!< Image size in pixels, V value, code 23 + double dz; //!< Z coordinate, code 33 + int clip; //!< Clipping state, code 280, 0=off 1=on + int brightness; //!< Brightness value, code 281, (0-100) default 50 + int contrast; //!< Brightness value, code 282, (0-100) default 50 + int fade; //!< Brightness value, code 283, (0-100) default 0 }; @@ -1237,8 +1237,6 @@ class DRW_Dimension : public DRW_Entity { } - virtual ~DRW_Dimension() {} - virtual void applyExtrusion() {} protected: @@ -1253,28 +1251,28 @@ class DRW_Dimension : public DRW_Entity } public: - DRW_Coord getDefPoint() const {return defPoint;} /*!< Definition point, code 10, 20 & 30 */ + DRW_Coord getDefPoint() const {return defPoint;} //!< Definition point, code 10, 20 & 30 void setDefPoint( const DRW_Coord &p ) {defPoint = p;} - DRW_Coord getTextPoint() const {return textPoint;} /*!< Middle point of text, code 11, 21 & 31 */ + DRW_Coord getTextPoint() const {return textPoint;} //!< Middle point of text, code 11, 21 & 31 void setTextPoint( const DRW_Coord &p ) {textPoint = p;} - std::string getStyle() const {return style;} /*!< Dimension style, code 3 */ + std::string getStyle() const {return style;} //!< Dimension style, code 3 void setStyle( const std::string &s ) {style = s;} - int getAlign() const { return align;} /*!< attachment point, code 71 */ + int getAlign() const { return align;} //!< Attachment point, code 71 void setAlign( const int a ) { align = a;} - int getTextLineStyle() const { return linesty;} /*!< Dimension text line spacing style, code 72, default 1 */ + int getTextLineStyle() const { return linesty;} //!< Dimension text line spacing style, code 72, default 1 void setTextLineStyle( const int l ) { linesty = l;} - std::string getText() const {return text;} /*!< Dimension text explicitly entered by the user, code 1 */ + std::string getText() const {return text;} //!< Dimension text explicitly entered by the user, code 1 void setText( const std::string &t ) {text = t;} - double getTextLineFactor() const { return linefactor;} /*!< Dimension text line spacing factor, code 41, default 1? */ + double getTextLineFactor() const { return linefactor;} //!< Dimension text line spacing factor, code 41, default 1? void setTextLineFactor( const double l ) { linefactor = l;} - double getDir() const { return rot;} /*!< rotation angle of the dimension text, code 53 (optional) default 0 */ + double getDir() const { return rot;} //!< Rotation angle of the dimension text, code 53 (optional) default 0 void setDir( const double d ) { rot = d;} - DRW_Coord getExtrusion() {return extPoint;} /*!< extrusion, code 210, 220 & 230 */ + DRW_Coord getExtrusion() {return extPoint;} //!< Extrusion, code 210, 220 & 230 void setExtrusion( const DRW_Coord &p ) {extPoint = p;} - std::string getName() {return name;} /*!< Name of the block that contains the entities, code 2 */ + std::string getName() {return name;} //!< Name of the block that contains the entities, code 2 void setName( const std::string &s ) {name = s;} -// int getType(){ return type;} /*!< Dimension type, code 70 */ +// int getType(){ return type;} //!< Dimension type, code 70 protected: DRW_Coord getPt2() const {return clonePoint;} @@ -1287,36 +1285,36 @@ class DRW_Dimension : public DRW_Entity void setPt5( const DRW_Coord &p ) {circlePoint = p;} DRW_Coord getPt6() const {return arcPoint;} void setPt6( const DRW_Coord &p ) {arcPoint = p;} - double getAn50() const {return angle;} /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */ + double getAn50() const {return angle;} //!< Angle of rotated, horizontal, or vertical dimensions, code 50 void setAn50( const double d ) {angle = d;} - double getOb52() const {return oblique;} /*!< oblique angle, code 52 */ + double getOb52() const {return oblique;} //!< Oblique angle, code 52 void setOb52( const double d ) {oblique = d;} - double getRa40() const {return length;} /*!< Leader length, code 40 */ + double getRa40() const {return length;} //!< Leader length, code 40 void setRa40( const double d ) {length = d;} public: - int type; /*!< Dimension type, code 70 */ + int type; //!< Dimension type, code 70 private: - std::string name; /*!< Name of the block that contains the entities, code 2 */ - DRW_Coord defPoint; /*!< definition point, code 10, 20 & 30 (WCS) */ - DRW_Coord textPoint; /*!< Middle point of text, code 11, 21 & 31 (OCS) */ - UTF8STRING text; /*!< Dimension text explicitly entered by the user, code 1 */ - UTF8STRING style; /*!< Dimension style, code 3 */ - int align; /*!< attachment point, code 71 */ - int linesty; /*!< Dimension text line spacing style, code 72, default 1 */ - double linefactor; /*!< Dimension text line spacing factor, code 41, default 1? (value range 0.25 to 4.00) */ - double rot; /*!< rotation angle of the dimension text, code 53 */ - DRW_Coord extPoint; /*!< extrusion normal vector, code 210, 220 & 230 */ + std::string name; //!< Name of the block that contains the entities, code 2 + DRW_Coord defPoint; //!< Definition point, code 10, 20 & 30 (WCS) + DRW_Coord textPoint; //!< Middle point of text, code 11, 21 & 31 (OCS) + UTF8STRING text; //!< Dimension text explicitly entered by the user, code 1 + UTF8STRING style; //!< Dimension style, code 3 + int align; //!< Attachment point, code 71 + int linesty; //!< Dimension text line spacing style, code 72, default 1 + double linefactor; //!< Dimension text line spacing factor, code 41, default 1? (value range 0.25 to 4.00) + double rot; //!< Rotation angle of the dimension text, code 53 + DRW_Coord extPoint; //!< Extrusion normal vector, code 210, 220 & 230 - double hdir; /*!< horizontal direction for the dimension, code 51, default ? */ - DRW_Coord clonePoint; /*!< Insertion point for clones (Baseline & Continue), code 12, 22 & 32 (OCS) */ - DRW_Coord def1; /*!< Definition point 1for linear & angular, code 13, 23 & 33 (WCS) */ - DRW_Coord def2; /*!< Definition point 2, code 14, 24 & 34 (WCS) */ - double angle; /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */ - double oblique; /*!< oblique angle, code 52 */ + double hdir; //!< Horizontal direction for the dimension, code 51, default ? + DRW_Coord clonePoint; //!< Insertion point for clones (Baseline & Continue), code 12, 22 & 32 (OCS) + DRW_Coord def1; //!< Definition point 1for linear & angular, code 13, 23 & 33 (WCS) + DRW_Coord def2; //!< Definition point 2, code 14, 24 & 34 (WCS) + double angle; //!< Angle of rotated, horizontal, or vertical dimensions, code 50 + double oblique; //!< Oblique angle, code 52 - DRW_Coord circlePoint; /*!< Definition point for diameter, radius & angular dims code 15, 25 & 35 (WCS) */ - DRW_Coord arcPoint; /*!< Point defining dimension arc, x coordinate, code 16, 26 & 36 (OCS) */ - double length; /*!< Leader length, code 40 */ + DRW_Coord circlePoint; //!< Definition point for diameter, radius & angular dims code 15, 25 & 35 (WCS) + DRW_Coord arcPoint; //!< Point defining dimension arc, x coordinate, code 16, 26 & 36 (OCS) + double length; //!< Leader length, code 40 protected: dwgHandle dimStyleH; @@ -1341,14 +1339,14 @@ class DRW_DimAligned : public DRW_Dimension eType = DRW::DIMALIGNED; } - DRW_Coord getClonepoint() const {return getPt2();} /*!< Insertion for clones (Baseline & Continue), 12, 22 & 32 */ + DRW_Coord getClonepoint() const {return getPt2();} //!< Insertion for clones (Baseline & Continue), 12, 22 & 32 void setClonePoint( DRW_Coord &c ) {setPt2( c );} - DRW_Coord getDimPoint() const {return getDefPoint();} /*!< dim line location point, code 10, 20 & 30 */ + DRW_Coord getDimPoint() const {return getDefPoint();} //!< Dim line location point, code 10, 20 & 30 void setDimPoint( const DRW_Coord &p ) {setDefPoint( p );} - DRW_Coord getDef1Point() const {return getPt3();} /*!< Definition point 1, code 13, 23 & 33 */ + DRW_Coord getDef1Point() const {return getPt3();} //!< Definition point 1, code 13, 23 & 33 void setDef1Point( const DRW_Coord &p ) {setPt3( p );} - DRW_Coord getDef2Point() const {return getPt4();} /*!< Definition point 2, code 14, 24 & 34 */ + DRW_Coord getDef2Point() const {return getPt4();} //!< Definition point 2, code 14, 24 & 34 void setDef2Point( const DRW_Coord &p ) {setPt4( p );} protected: @@ -1371,9 +1369,9 @@ class DRW_DimLinear : public DRW_DimAligned eType = DRW::DIMLINEAR; } - double getAngle() const {return getAn50();} /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */ + double getAngle() const {return getAn50();} //!< Angle of rotated, horizontal, or vertical dimensions, code 50 void setAngle( const double d ) {setAn50( d );} - double getOblique() const {return getOb52();} /*!< oblique angle, code 52 */ + double getOblique() const {return getOb52();} //!< Oblique angle, code 52 void setOblique( const double d ) {setOb52( d );} }; @@ -1394,11 +1392,11 @@ class DRW_DimRadial : public DRW_Dimension eType = DRW::DIMRADIAL; } - DRW_Coord getCenterPoint() const {return getDefPoint();} /*!< center point, code 10, 20 & 30 */ + DRW_Coord getCenterPoint() const {return getDefPoint();} //!< Center point, code 10, 20 & 30 void setCenterPoint( const DRW_Coord &p ) {setDefPoint( p );} - DRW_Coord getDiameterPoint() const {return getPt5();} /*!< Definition point for radius, code 15, 25 & 35 */ + DRW_Coord getDiameterPoint() const {return getPt5();} //!< Definition point for radius, code 15, 25 & 35 void setDiameterPoint( const DRW_Coord &p ) {setPt5( p );} - double getLeaderLength() const {return getRa40();} /*!< Leader length, code 40 */ + double getLeaderLength() const {return getRa40();} //!< Leader length, code 40 void setLeaderLength( const double d ) {setRa40( d );} protected: @@ -1422,11 +1420,11 @@ class DRW_DimDiametric : public DRW_Dimension eType = DRW::DIMDIAMETRIC; } - DRW_Coord getDiameter1Point() const {return getPt5();} /*!< First definition point for diameter, code 15, 25 & 35 */ + DRW_Coord getDiameter1Point() const {return getPt5();} //!< First definition point for diameter, code 15, 25 & 35 void setDiameter1Point( const DRW_Coord &p ) {setPt5( p );} - DRW_Coord getDiameter2Point() const {return getDefPoint();} /*!< Oposite point for diameter, code 10, 20 & 30 */ + DRW_Coord getDiameter2Point() const {return getDefPoint();} //!< Oposite point for diameter, code 10, 20 & 30 void setDiameter2Point( const DRW_Coord &p ) {setDefPoint( p );} - double getLeaderLength() const {return getRa40();} /*!< Leader length, code 40 */ + double getLeaderLength() const {return getRa40();} //!< Leader length, code 40 void setLeaderLength( const double d ) {setRa40( d );} protected: @@ -1450,15 +1448,15 @@ class DRW_DimAngular : public DRW_Dimension eType = DRW::DIMANGULAR; } - DRW_Coord getFirstLine1() const {return getPt3();} /*!< Definition point line 1-1, code 13, 23 & 33 */ + DRW_Coord getFirstLine1() const {return getPt3();} //!< Definition point line 1-1, code 13, 23 & 33 void setFirstLine1( const DRW_Coord &p ) {setPt3( p );} - DRW_Coord getFirstLine2() const {return getPt4();} /*!< Definition point line 1-2, code 14, 24 & 34 */ + DRW_Coord getFirstLine2() const {return getPt4();} //!< Definition point line 1-2, code 14, 24 & 34 void setFirstLine2( const DRW_Coord &p ) {setPt4( p );} - DRW_Coord getSecondLine1() const {return getPt5();} /*!< Definition point line 2-1, code 15, 25 & 35 */ + DRW_Coord getSecondLine1() const {return getPt5();} //!< Definition point line 2-1, code 15, 25 & 35 void setSecondLine1( const DRW_Coord &p ) {setPt5( p );} - DRW_Coord getSecondLine2() const {return getDefPoint();} /*!< Definition point line 2-2, code 10, 20 & 30 */ + DRW_Coord getSecondLine2() const {return getDefPoint();} //!< Definition point line 2-2, code 10, 20 & 30 void setSecondLine2( const DRW_Coord &p ) {setDefPoint( p );} - DRW_Coord getDimPoint() const {return getPt6();} /*!< Dimension definition point, code 16, 26 & 36 */ + DRW_Coord getDimPoint() const {return getPt6();} //!< Dimension definition point, code 16, 26 & 36 void setDimPoint( const DRW_Coord &p ) {setPt6( p );} protected: @@ -1483,13 +1481,13 @@ class DRW_DimAngular3p : public DRW_Dimension eType = DRW::DIMANGULAR3P; } - DRW_Coord getFirstLine() const {return getPt3();} /*!< Definition point line 1, code 13, 23 & 33 */ + DRW_Coord getFirstLine() const {return getPt3();} //!< Definition point line 1, code 13, 23 & 33 void setFirstLine( const DRW_Coord &p ) {setPt3( p );} - DRW_Coord getSecondLine() const {return getPt4();} /*!< Definition point line 2, code 14, 24 & 34 */ + DRW_Coord getSecondLine() const {return getPt4();} //!< Definition point line 2, code 14, 24 & 34 void setSecondLine( const DRW_Coord &p ) {setPt4( p );} - DRW_Coord getVertexPoint() const {return getPt5();} /*!< Vertex point, code 15, 25 & 35 */ + DRW_Coord getVertexPoint() const {return getPt5();} //!< Vertex point, code 15, 25 & 35 void SetVertexPoint( const DRW_Coord &p ) {setPt5( p );} - DRW_Coord getDimPoint() const {return getDefPoint();} /*!< Dimension definition point, code 10, 20 & 30 */ + DRW_Coord getDimPoint() const {return getDefPoint();} //!< Dimension definition point, code 10, 20 & 30 void setDimPoint( const DRW_Coord &p ) {setDefPoint( p );} protected: @@ -1513,11 +1511,11 @@ class DRW_DimOrdinate : public DRW_Dimension eType = DRW::DIMORDINATE; } - DRW_Coord getOriginPoint() const {return getDefPoint();} /*!< Origin definition point, code 10, 20 & 30 */ + DRW_Coord getOriginPoint() const {return getDefPoint();} //!< Origin definition point, code 10, 20 & 30 void setOriginPoint( const DRW_Coord &p ) {setDefPoint( p );} - DRW_Coord getFirstLine() const {return getPt3();} /*!< Feature location point, code 13, 23 & 33 */ + DRW_Coord getFirstLine() const {return getPt3();} //!< Feature location point, code 13, 23 & 33 void setFirstLine( const DRW_Coord &p ) {setPt3( p );} - DRW_Coord getSecondLine() const {return getPt4();} /*!< Leader end point, code 14, 24 & 34 */ + DRW_Coord getSecondLine() const {return getPt4();} //!< Leader end point, code 14, 24 & 34 void setSecondLine( const DRW_Coord &p ) {setPt4( p );} protected: @@ -1564,26 +1562,26 @@ class DRW_Leader : public DRW_Entity virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - UTF8STRING style; /*!< Dimension style name, code 3 */ - int arrow; /*!< Arrowhead flag, code 71, 0=Disabled; 1=Enabled */ - int leadertype; /*!< Leader path type, code 72, 0=Straight line segments; 1=Spline */ - int flag; /*!< Leader creation flag, code 73, default 3 */ - int hookline; /*!< Hook line direction flag, code 74, default 1 */ - int hookflag; /*!< Hook line flag, code 75 */ - double textheight; /*!< Text annotation height, code 40 */ - double textwidth; /*!< Text annotation width, code 41 */ - int vertnum; /*!< Number of vertices, code 76 */ - int coloruse; /*!< Color to use if leader's DIMCLRD = BYBLOCK, code 77 */ - duint32 annotHandle; /*!< Hard reference to associated annotation, code 340 */ - DRW_Coord extrusionPoint; /*!< Normal vector, code 210, 220 & 230 */ - DRW_Coord horizdir; /*!< "Horizontal" direction for leader, code 211, 221 & 231 */ - DRW_Coord offsetblock; /*!< Offset of last leader vertex from block, code 212, 222 & 232 */ - DRW_Coord offsettext; /*!< Offset of last leader vertex from annotation, code 213, 223 & 233 */ + UTF8STRING style; //!< Dimension style name, code 3 + int arrow; //!< Arrowhead flag, code 71, 0=Disabled; 1=Enabled + int leadertype; //!< Leader path type, code 72, 0=Straight line segments; 1=Spline + int flag; //!< Leader creation flag, code 73, default 3 + int hookline; //!< Hook line direction flag, code 74, default 1 + int hookflag; //!< Hook line flag, code 75 + double textheight; //!< Text annotation height, code 40 + double textwidth; //!< Text annotation width, code 41 + int vertnum; //!< Number of vertices, code 76 + int coloruse; //!< Color to use if leader's DIMCLRD = BYBLOCK, code 77 + duint32 annotHandle; //!< Hard reference to associated annotation, code 340 + DRW_Coord extrusionPoint; //!< Normal vector, code 210, 220 & 230 + DRW_Coord horizdir; //!< "Horizontal" direction for leader, code 211, 221 & 231 + DRW_Coord offsetblock; //!< Offset of last leader vertex from block, code 212, 222 & 232 + DRW_Coord offsettext; //!< Offset of last leader vertex from annotation, code 213, 223 & 233 - std::vector vertexlist; /*!< vertex points list, code 10, 20 & 30 */ + std::vector vertexlist; //!< Vertex points list, code 10, 20 & 30 private: - DRW_Coord *vertexpoint; /*!< current control point to add data */ + DRW_Coord *vertexpoint; //!< Current control point to add data dwgHandle dimStyleH; dwgHandle AnnotH; }; @@ -1624,25 +1622,25 @@ class DRW_Viewport : public DRW_Point virtual bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - double pswidth; /*!< Width in paper space units, code 40 */ - double psheight; /*!< Height in paper space units, code 41 */ - int vpstatus; /*!< Viewport status, code 68 */ - int vpID; /*!< Viewport ID, code 69 */ - double centerPX; /*!< view center point X, code 12 */ - double centerPY; /*!< view center point Y, code 22 */ - double snapPX; /*!< Snap base point X, code 13 */ - double snapPY; /*!< Snap base point Y, code 23 */ - double snapSpPX; /*!< Snap spacing X, code 14 */ - double snapSpPY; /*!< Snap spacing Y, code 24 */ + double pswidth; //!< Width in paper space units, code 40 + double psheight; //!< Height in paper space units, code 41 + int vpstatus; //!< Viewport status, code 68 + int vpID; //!< Viewport ID, code 69 + double centerPX; //!< View center point X, code 12 + double centerPY; //!< View center point Y, code 22 + double snapPX; //!< Snap base point X, code 13 + double snapPY; //!< Snap base point Y, code 23 + double snapSpPX; //!< Snap spacing X, code 14 + double snapSpPY; //!< Snap spacing Y, code 24 //TODO: complete in dxf - DRW_Coord viewDir; /*!< View direction vector, code 16, 26 & 36 */ - DRW_Coord viewTarget; /*!< View target point, code 17, 27, 37 */ - double viewLength; /*!< Perspective lens length, code 42 */ - double frontClip; /*!< Front clip plane Z value, code 43 */ - double backClip; /*!< Back clip plane Z value, code 44 */ - double viewHeight; /*!< View height in model space units, code 45 */ - double snapAngle; /*!< Snap angle, code 50 */ - double twistAngle; /*!< view twist angle, code 51 */ + DRW_Coord viewDir; //!< View direction vector, code 16, 26 & 36 + DRW_Coord viewTarget; //!< View target point, code 17, 27, 37 + double viewLength; //!< Perspective lens length, code 42 + double frontClip; //!< Front clip plane Z value, code 43 + double backClip; //!< Back clip plane Z value, code 44 + double viewHeight; //!< View height in model space units, code 45 + double snapAngle; //!< Snap angle, code 50 + double twistAngle; //!< View twist angle, code 51 private: duint32 frozenLyCount; @@ -1650,30 +1648,30 @@ class DRW_Viewport : public DRW_Point #if 0 //used -DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */ +DRW_Coord basePoint; //!< Base point, code 10, 20 & 30 -double thickness; /*!< thickness, code 39 */ -DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ -enum DRW::ETYPE eType; /*!< enum: entity type, code 0 */ -duint32 handle; /*!< entity identifier, code 5 */ -std::list > appData; /*!< list of application data, code 102 */ -duint32 parentHandle; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */ -DRW::Space space; /*!< space indicator, code 67*/ -UTF8STRING layer; /*!< layer name, code 8 */ -UTF8STRING lineType; /*!< line type, code 6 */ -duint32 material; /*!< hard pointer id to material object, code 347 */ -int color; /*!< entity color, code 62 */ -enum DRW_LW_Conv::lineWidth lWeight; /*!< entity lineweight, code 370 */ -double ltypeScale; /*!< linetype scale, code 48 */ -bool visible; /*!< entity visibility, code 60 */ -int numProxyGraph; /*!< Number of bytes in proxy graphics, code 92 */ -std::string proxyGraphics; /*!< proxy graphics bytes, code 310 */ -int color24; /*!< 24-bit color, code 420 */ -std::string colorName; /*!< color name, code 430 */ -int transparency; /*!< transparency, code 440 */ -int plotStyle; /*!< hard pointer id to plot style object, code 390 */ -DRW::ShadowMode shadow; /*!< shadow mode, code 284 */ -bool haveExtrusion; /*!< set to true if the entity have extrusion*/ +double thickness; //!< Thickness, code 39 +DRW_Coord extPoint; //!< Dir extrusion normal vector, code 210, 220 & 230 +enum DRW::ETYPE eType; //!< Enum: entity type, code 0 +duint32 handle; //!< Entity identifier, code 5 +std::list > appData; //!< List of application data, code 102 +duint32 parentHandle; //!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 +DRW::Space space; //!< Space indicator, code 67 +UTF8STRING layer; //!< Layer name, code 8 +UTF8STRING lineType; //!< Line type, code 6 +duint32 material; //!< Hard pointer id to material object, code 347 +int color; //!< Entity color, code 62 +enum DRW_LW_Conv::lineWidth lWeight; //!< Entity lineweight, code 370 +double ltypeScale; //!< Linetype scale, code 48 +bool visible; //!< Entity visibility, code 60 +int numProxyGraph; //!< Number of bytes in proxy graphics, code 92 +std::string proxyGraphics; //!< Proxy graphics bytes, code 310 +int color24; //!< 24-bit color, code 420 +std::string colorName; //!< Color name, code 430 +int transparency; //!< Transparency, code 440 +int plotStyle; //!< Hard pointer id to plot style object, code 390 +DRW::ShadowMode shadow; //!< Shadow mode, code 284 +bool haveExtrusion; //!< Set to true if the entity have extrusion #endif #endif diff --git a/src/app/dwg/libdxfrw/drw_interface.h b/src/app/dwg/libdxfrw/drw_interface.h index e886c78fc50..49940220d15 100644 --- a/src/app/dwg/libdxfrw/drw_interface.h +++ b/src/app/dwg/libdxfrw/drw_interface.h @@ -36,20 +36,20 @@ class DRW_Interface { } - /** Called when header is parsed. */ + //! Called when header is parsed. virtual void addHeader( const DRW_Header* data ) = 0; - /** Called for every line Type. */ + //! Called for every line Type. virtual void addLType( const DRW_LType& data ) = 0; - /** Called for every layer. */ + //! Called for every layer. virtual void addLayer( const DRW_Layer& data ) = 0; - /** Called for every dim style. */ + //! Called for every dim style. virtual void addDimStyle( const DRW_Dimstyle& data ) = 0; - /** Called for every VPORT table. */ + //! Called for every VPORT table. virtual void addVport( const DRW_Vport& data ) = 0; - /** Called for every text style. */ + //! Called for every text style. virtual void addTextStyle( const DRW_Textstyle& data ) = 0; - /** Called for every AppId entry. */ + //! Called for every AppId entry. virtual void addAppId( const DRW_AppId& data ) = 0; /** @@ -69,98 +69,98 @@ class DRW_Interface */ virtual void setBlock( const int handle ) = 0; - /** Called to end the current block */ + //! Called to end the current block virtual void endBlock() = 0; - /** Called for every point */ + //! Called for every point virtual void addPoint( const DRW_Point& data ) = 0; - /** Called for every line */ + //! Called for every line virtual void addLine( const DRW_Line& data ) = 0; - /** Called for every ray */ + //! Called for every ray virtual void addRay( const DRW_Ray& data ) = 0; - /** Called for every xline */ + //! Called for every xline virtual void addXline( const DRW_Xline& data ) = 0; - /** Called for every arc */ + //! Called for every arc virtual void addArc( const DRW_Arc& data ) = 0; - /** Called for every circle */ + //! Called for every circle virtual void addCircle( const DRW_Circle& data ) = 0; - /** Called for every ellipse */ + //! Called for every ellipse virtual void addEllipse( const DRW_Ellipse& data ) = 0; - /** Called for every lwpolyline */ + //! Called for every lwpolyline virtual void addLWPolyline( const DRW_LWPolyline& data ) = 0; - /** Called for every polyline start */ + //! Called for every polyline start virtual void addPolyline( const DRW_Polyline& data ) = 0; - /** Called for every spline */ + //! Called for every spline virtual void addSpline( const DRW_Spline* data ) = 0; - /** Called for every spline knot value */ + //! Called for every spline knot value virtual void addKnot( const DRW_Entity& data ) = 0; - /** Called for every insert. */ + //! Called for every insert. virtual void addInsert( const DRW_Insert& data ) = 0; - /** Called for every trace start */ + //! Called for every trace start virtual void addTrace( const DRW_Trace& data ) = 0; - /** Called for every 3dface start */ + //! Called for every 3dface start virtual void add3dFace( const DRW_3Dface& data ) = 0; - /** Called for every solid start */ + //! Called for every solid start virtual void addSolid( const DRW_Solid& data ) = 0; - /** Called for every Multi Text entity. */ + //! Called for every Multi Text entity. virtual void addMText( const DRW_MText& data ) = 0; - /** Called for every Text entity. */ + //! Called for every Text entity. virtual void addText( const DRW_Text& data ) = 0; - /** Called for every aligned dimension entity. */ + //! Called for every aligned dimension entity. virtual void addDimAlign( const DRW_DimAligned *data ) = 0; - /** Called for every linear or rotated dimension entity. */ + //! Called for every linear or rotated dimension entity. virtual void addDimLinear( const DRW_DimLinear *data ) = 0; - /** Called for every radial dimension entity. */ + //! Called for every radial dimension entity. virtual void addDimRadial( const DRW_DimRadial *data ) = 0; - /** Called for every diametric dimension entity. */ + //! Called for every diametric dimension entity. virtual void addDimDiametric( const DRW_DimDiametric *data ) = 0; - /** Called for every angular dimension (2 lines version) entity. */ + //! Called for every angular dimension (2 lines version) entity. virtual void addDimAngular( const DRW_DimAngular *data ) = 0; - /** Called for every angular dimension (3 points version) entity. */ + //! Called for every angular dimension (3 points version) entity. virtual void addDimAngular3P( const DRW_DimAngular3p *data ) = 0; - /** Called for every ordinate dimension entity. */ + //! Called for every ordinate dimension entity. virtual void addDimOrdinate( const DRW_DimOrdinate *data ) = 0; - /** Called for every leader start. */ + //! Called for every leader start. virtual void addLeader( const DRW_Leader *data ) = 0; - /** Called for every hatch entity. */ + //! Called for every hatch entity. virtual void addHatch( const DRW_Hatch *data ) = 0; - /** Called for every viewport entity. */ + //! Called for every viewport entity. virtual void addViewport( const DRW_Viewport& data ) = 0; - /** Called for every image entity. */ + //! Called for every image entity. virtual void addImage( const DRW_Image *data ) = 0; - /** Called for every image definition. */ + //! Called for every image definition. virtual void linkImage( const DRW_ImageDef *data ) = 0; - /** Called for every comment in the DXF file (code 999). */ + //! Called for every comment in the DXF file (code 999). virtual void addComment( const char* comment ) = 0; virtual void writeHeader( DRW_Header& data ) = 0; diff --git a/src/app/dwg/libdxfrw/drw_objects.h b/src/app/dwg/libdxfrw/drw_objects.h index 141daac1170..d9160b40443 100644 --- a/src/app/dwg/libdxfrw/drw_objects.h +++ b/src/app/dwg/libdxfrw/drw_objects.h @@ -106,12 +106,12 @@ class DRW_TableEntry } public: - enum DRW::TTYPE tType; /*!< enum: entity type, code 0 */ - duint32 handle; /*!< entity identifier, code 5 */ - int parentHandle; /*!< Soft-pointer ID/handle to owner object, code 330 */ - UTF8STRING name; /*!< entry name, code 2 */ - int flags; /*!< Flags relevant to entry, code 70 */ - std::vector extData; /*!< FIFO list of extended data, codes 1000 to 1071*/ + enum DRW::TTYPE tType; //!< Enum: entity type, code 0 + duint32 handle; //!< Entity identifier, code 5 + int parentHandle; //!< Soft-pointer ID/handle to owner object, code 330 + UTF8STRING name; //!< Entry name, code 2 + int flags; //!< Flags relevant to entry, code 70 + std::vector extData; //!< FIFO list of extended data, codes 1000 to 1071 private: DRW_Variant *curr; @@ -166,75 +166,75 @@ class DRW_Dimstyle : public DRW_TableEntry public: //V12 - UTF8STRING dimpost; /*!< code 3 */ - UTF8STRING dimapost; /*!< code 4 */ + UTF8STRING dimpost; //!< Code 3 + UTF8STRING dimapost; //!< Code 4 /* handle are code 105 */ - UTF8STRING dimblk; /*!< code 5, code 342 V2000+ */ - UTF8STRING dimblk1; /*!< code 6, code 343 V2000+ */ - UTF8STRING dimblk2; /*!< code 7, code 344 V2000+ */ - double dimscale; /*!< code 40 */ - double dimasz; /*!< code 41 */ - double dimexo; /*!< code 42 */ - double dimdli; /*!< code 43 */ - double dimexe; /*!< code 44 */ - double dimrnd; /*!< code 45 */ - double dimdle; /*!< code 46 */ - double dimtp; /*!< code 47 */ - double dimtm; /*!< code 48 */ - double dimfxl; /*!< code 49 V2007+ */ - double dimtxt; /*!< code 140 */ - double dimcen; /*!< code 141 */ - double dimtsz; /*!< code 142 */ - double dimaltf; /*!< code 143 */ - double dimlfac; /*!< code 144 */ - double dimtvp; /*!< code 145 */ - double dimtfac; /*!< code 146 */ - double dimgap; /*!< code 147 */ - double dimaltrnd; /*!< code 148 V2000+ */ - int dimtol; /*!< code 71 */ - int dimlim; /*!< code 72 */ - int dimtih; /*!< code 73 */ - int dimtoh; /*!< code 74 */ - int dimse1; /*!< code 75 */ - int dimse2; /*!< code 76 */ - int dimtad; /*!< code 77 */ - int dimzin; /*!< code 78 */ - int dimazin; /*!< code 79 V2000+ */ - int dimalt; /*!< code 170 */ - int dimaltd; /*!< code 171 */ - int dimtofl; /*!< code 172 */ - int dimsah; /*!< code 173 */ - int dimtix; /*!< code 174 */ - int dimsoxd; /*!< code 175 */ - int dimclrd; /*!< code 176 */ - int dimclre; /*!< code 177 */ - int dimclrt; /*!< code 178 */ - int dimadec; /*!< code 179 V2000+ */ - int dimunit; /*!< code 270 R13+ (obsolete 2000+, use dimlunit & dimfrac) */ - int dimdec; /*!< code 271 R13+ */ - int dimtdec; /*!< code 272 R13+ */ - int dimaltu; /*!< code 273 R13+ */ - int dimalttd; /*!< code 274 R13+ */ - int dimaunit; /*!< code 275 R13+ */ - int dimfrac; /*!< code 276 V2000+ */ - int dimlunit; /*!< code 277 V2000+ */ - int dimdsep; /*!< code 278 V2000+ */ - int dimtmove; /*!< code 279 V2000+ */ - int dimjust; /*!< code 280 R13+ */ - int dimsd1; /*!< code 281 R13+ */ - int dimsd2; /*!< code 282 R13+ */ - int dimtolj; /*!< code 283 R13+ */ - int dimtzin; /*!< code 284 R13+ */ - int dimaltz; /*!< code 285 R13+ */ - int dimaltttz; /*!< code 286 R13+ */ - int dimfit; /*!< code 287 R13+ (obsolete 2000+, use dimatfit & dimtmove)*/ - int dimupt; /*!< code 288 R13+ */ - int dimatfit; /*!< code 289 V2000+ */ - int dimfxlon; /*!< code 290 V2007+ */ - UTF8STRING dimtxsty; /*!< code 340 R13+ */ - UTF8STRING dimldrblk; /*!< code 341 V2000+ */ - int dimlwd; /*!< code 371 V2000+ */ - int dimlwe; /*!< code 372 V2000+ */ + UTF8STRING dimblk; //!< Code 5, code 342 V2000+ + UTF8STRING dimblk1; //!< Code 6, code 343 V2000+ + UTF8STRING dimblk2; //!< Code 7, code 344 V2000+ + double dimscale; //!< Code 40 + double dimasz; //!< Code 41 + double dimexo; //!< Code 42 + double dimdli; //!< Code 43 + double dimexe; //!< Code 44 + double dimrnd; //!< Code 45 + double dimdle; //!< Code 46 + double dimtp; //!< Code 47 + double dimtm; //!< Code 48 + double dimfxl; //!< Code 49 V2007+ + double dimtxt; //!< Code 140 + double dimcen; //!< Code 141 + double dimtsz; //!< Code 142 + double dimaltf; //!< Code 143 + double dimlfac; //!< Code 144 + double dimtvp; //!< Code 145 + double dimtfac; //!< Code 146 + double dimgap; //!< Code 147 + double dimaltrnd; //!< Code 148 V2000+ + int dimtol; //!< Code 71 + int dimlim; //!< Code 72 + int dimtih; //!< Code 73 + int dimtoh; //!< Code 74 + int dimse1; //!< Code 75 + int dimse2; //!< Code 76 + int dimtad; //!< Code 77 + int dimzin; //!< Code 78 + int dimazin; //!< Code 79 V2000+ + int dimalt; //!< Code 170 + int dimaltd; //!< Code 171 + int dimtofl; //!< Code 172 + int dimsah; //!< Code 173 + int dimtix; //!< Code 174 + int dimsoxd; //!< Code 175 + int dimclrd; //!< Code 176 + int dimclre; //!< Code 177 + int dimclrt; //!< Code 178 + int dimadec; //!< Code 179 V2000+ + int dimunit; //!< Code 270 R13+ (obsolete 2000+, use dimlunit & dimfrac) + int dimdec; //!< Code 271 R13+ + int dimtdec; //!< Code 272 R13+ + int dimaltu; //!< Code 273 R13+ + int dimalttd; //!< Code 274 R13+ + int dimaunit; //!< Code 275 R13+ + int dimfrac; //!< Code 276 V2000+ + int dimlunit; //!< Code 277 V2000+ + int dimdsep; //!< Code 278 V2000+ + int dimtmove; //!< Code 279 V2000+ + int dimjust; //!< Code 280 R13+ + int dimsd1; //!< Code 281 R13+ + int dimsd2; //!< Code 282 R13+ + int dimtolj; //!< Code 283 R13+ + int dimtzin; //!< Code 284 R13+ + int dimaltz; //!< Code 285 R13+ + int dimaltttz; //!< Code 286 R13+ + int dimfit; //!< Code 287 R13+ (obsolete 2000+, use dimatfit & dimtmove) + int dimupt; //!< Code 288 R13+ + int dimatfit; //!< Code 289 V2000+ + int dimfxlon; //!< Code 290 V2007+ + UTF8STRING dimtxsty; //!< Code 340 R13+ + UTF8STRING dimldrblk; //!< Code 341 V2000+ + int dimlwd; //!< Code 371 V2000+ + int dimlwe; //!< Code 372 V2000+ }; @@ -264,12 +264,12 @@ class DRW_LType : public DRW_TableEntry void update(); public: - UTF8STRING desc; /*!< descriptive string, code 3 */ -// int align; /*!< align code, always 65 ('A') code 72 */ - std::vector::size_type size; /*!< element number, code 73 */ - double length; /*!< total length of pattern, code 40 */ -// int haveShape; /*!< complex linetype type, code 74 */ - std::vector path; /*!< trace, point or space length sequence, code 49 */ + UTF8STRING desc; //!< Descriptive string, code 3 +// int align; //!< Align code, always 65 ('A') code 72 + std::vector::size_type size; //!< Element number, code 73 + double length; //!< Total length of pattern, code 40 +// int haveShape; //!< Complex linetype type, code 74 + std::vector path; //!< Trace, point or space length sequence, code 49 private: int pathIdx; }; @@ -300,14 +300,14 @@ class DRW_Layer : public DRW_TableEntry bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - UTF8STRING lineType; /*!< line type, code 6 */ - int color; /*!< layer color, code 62 */ - int color24; /*!< 24-bit color, code 420 */ - int transparency; /*!< Transparency, code 440 */ - bool plotF; /*!< Plot flag, code 290 */ - enum DRW_LW_Conv::lineWidth lWeight; /*!< layer lineweight, code 370 */ - std::string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */ - std::string handleMaterialS; /*!< Hard-pointer ID/handle of materialstyle, code 347 */ + UTF8STRING lineType; //!< Line type, code 6 + int color; //!< Layer color, code 62 + int color24; //!< 24-bit color, code 420 + int transparency; //!< Transparency, code 440 + bool plotF; //!< Plot flag, code 290 + enum DRW_LW_Conv::lineWidth lWeight; //!< Layer lineweight, code 370 + std::string handlePlotS; //!< Hard-pointer ID/handle of plotstyle, code 390 + std::string handleMaterialS; //!< Hard-pointer ID/handle of materialstyle, code 347 /*only used for read dwg*/ dwgHandle lTypeH; }; @@ -334,8 +334,8 @@ class DRW_Block_Record : public DRW_TableEntry public: //Note: int DRW_TableEntry::flags; contains code 70 of block - int insUnits; /*!< block insertion units, code 70 of block_record*/ - DRW_Coord basePoint; /*!< block insertion base point dwg only */ + int insUnits; //!< Block insertion units, code 70 of block_record + DRW_Coord basePoint; //!< Block insertion base point dwg only protected: //dwg parser private: @@ -371,14 +371,14 @@ class DRW_Textstyle : public DRW_TableEntry bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - double height; /*!< Fixed text height (0 not set), code 40 */ - double width; /*!< Width factor, code 41 */ - double oblique; /*!< Oblique angle, code 50 */ - int genFlag; /*!< Text generation flags, code 71 */ - double lastHeight; /*!< Last height used, code 42 */ - UTF8STRING font; /*!< primary font file name, code 3 */ - UTF8STRING bigFont; /*!< bigfont file name or blank if none, code 4 */ - int fontFamily; /*!< ttf font family, italic and bold flags, code 1071 */ + double height; //!< Fixed text height (0 not set), code 40 + double width; //!< Width factor, code 41 + double oblique; //!< Oblique angle, code 50 + int genFlag; //!< Text generation flags, code 71 + double lastHeight; //!< Last height used, code 42 + UTF8STRING font; //!< Primary font file name, code 3 + UTF8STRING bigFont; //!< Bigfont file name or blank if none, code 4 + int fontFamily; //!< Ttf font family, italic and bold flags, code 1071 }; /** Class to handle vport symbol table entries @@ -416,30 +416,31 @@ class DRW_Vport : public DRW_TableEntry bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: - DRW_Coord lowerLeft; /*!< Lower left corner, code 10 & 20 */ - DRW_Coord UpperRight; /*!< Upper right corner, code 11 & 21 */ - DRW_Coord center; /*!< center point in WCS, code 12 & 22 */ - DRW_Coord snapBase; /*!< snap base point in DCS, code 13 & 23 */ - DRW_Coord snapSpacing; /*!< snap Spacing, code 14 & 24 */ - DRW_Coord gridSpacing; /*!< grid Spacing, code 15 & 25 */ - DRW_Coord viewDir; /*!< view direction from target point, code 16, 26 & 36 */ - DRW_Coord viewTarget; /*!< view target point, code 17, 27 & 37 */ - double height; /*!< view height, code 40 */ - double ratio; /*!< viewport aspect ratio, code 41 */ - double lensHeight; /*!< lens height, code 42 */ - double frontClip; /*!< front clipping plane, code 43 */ - double backClip; /*!< back clipping plane, code 44 */ - double snapAngle; /*!< snap rotation angle, code 50 */ - double twistAngle; /*!< view twist angle, code 51 */ - int viewMode; /*!< view mode, code 71 */ - int circleZoom; /*!< circle zoom percent, code 72 */ - int fastZoom; /*!< fast zoom setting, code 73 */ - int ucsIcon; /*!< UCSICON setting, code 74 */ - int snap; /*!< snap on/off, code 75 */ - int grid; /*!< grid on/off, code 76 */ - int snapStyle; /*!< snap style, code 77 */ - int snapIsopair; /*!< snap isopair, code 78 */ - int gridBehavior; /*!< grid behavior, code 60, undocumented */ + DRW_Coord lowerLeft; //!< Lower left corner, code 10 & 20 + DRW_Coord UpperRight; //!< Upper right corner, code 11 & 21 + DRW_Coord center; //!< Center point in WCS, code 12 & 22 + DRW_Coord snapBase; //!< Snap base point in DCS, code 13 & 23 + DRW_Coord snapSpacing; //!< Snap Spacing, code 14 & 24 + DRW_Coord gridSpacing; //!< Grid Spacing, code 15 & 25 + DRW_Coord viewDir; //!< View direction from target point, code 16, 26 & 36 + DRW_Coord viewTarget; //!< View target point, code 17, 27 & 37 + double height; //!< View height, code 40 + double ratio; //!< Viewport aspect ratio, code 41 + double lensHeight; //!< Lens height, code 42 + double frontClip; //!< Front clipping plane, code 43 + double backClip; //!< Back clipping plane, code 44 + double snapAngle; //!< Snap rotation angle, code 50 + double twistAngle; //!< View twist angle, code 51 + int viewMode; //!< View mode, code 71 + int circleZoom; //!< Circle zoom percent, code 72 + int fastZoom; //!< Fast zoom setting, code 73 + int ucsIcon; //!< UCSICON setting, code 74 + int snap; //!< Snap on/off, code 75 + int grid; //!< Grid on/off, code 76 + int snapStyle; //!< Snap style, code 77 + int snapIsopair; //!< Snap isopair, code 78 + int gridBehavior; //!< Grid behavior, code 60, undocumented + /** Code 60, bit coded possible value are * bit 1 (1) show out of limits * bit 2 (2) adaptive grid @@ -473,15 +474,15 @@ class DRW_ImageDef : public DRW_TableEntry // bool parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs = 0 ); public: -// std::string handle; /*!< entity identifier, code 5 */ - UTF8STRING name; /*!< File name of image, code 1 */ - int imgVersion; /*!< class version, code 90, 0=R14 version */ - double u; /*!< image size in pixels U value, code 10 */ - double v; /*!< image size in pixels V value, code 20 */ - double up; /*!< default size of one pixel U value, code 11 */ - double vp; /*!< default size of one pixel V value, code 12 really is 21*/ - int loaded; /*!< image is loaded flag, code 280, 0=unloaded, 1=loaded */ - int resolution; /*!< resolution units, code 281, 0=no, 2=centimeters, 5=inch */ +// std::string handle; //!< Entity identifier, code 5 + UTF8STRING name; //!< File name of image, code 1 + int imgVersion; //!< Class version, code 90, 0=R14 version + double u; //!< Image size in pixels U value, code 10 + double v; //!< Image size in pixels V value, code 20 + double up; //!< Default size of one pixel U value, code 11 + double vp; //!< Default size of one pixel V value, code 12 really is 21 + int loaded; //!< Image is loaded flag, code 280, 0=unloaded, 1=loaded + int resolution; //!< Resolution units, code 281, 0=no, 2=centimeters, 5=inch std::map reactors; }; diff --git a/src/app/dwg/libdxfrw/intern/drw_dbg.cpp b/src/app/dwg/libdxfrw/intern/drw_dbg.cpp index b2b0e16b7d4..8c6067086e6 100644 --- a/src/app/dwg/libdxfrw/intern/drw_dbg.cpp +++ b/src/app/dwg/libdxfrw/intern/drw_dbg.cpp @@ -33,7 +33,7 @@ class print_none virtual void printHL( int c, int s, int h ) {( void )c;( void )s;( void )h;} virtual void printPT( double x, double y, double z ) {( void )x;( void )y;( void )z;} print_none() {} - virtual ~print_none() {} + virtual ~print_none() = default; }; class print_debug : public print_none diff --git a/src/app/dwg/libdxfrw/intern/drw_textcodec.h b/src/app/dwg/libdxfrw/intern/drw_textcodec.h index d37fdb106ea..d5fe5f66986 100644 --- a/src/app/dwg/libdxfrw/intern/drw_textcodec.h +++ b/src/app/dwg/libdxfrw/intern/drw_textcodec.h @@ -36,7 +36,7 @@ class DRW_Converter table = t; cpLenght = l; } - virtual ~DRW_Converter() {} + virtual ~DRW_Converter() = default; virtual std::string fromUtf8( std::string *s ) {return *s;} virtual std::string toUtf8( std::string *s ); std::string encodeText( std::string stmp ); diff --git a/src/app/dwg/libdxfrw/intern/dwgbuffer.h b/src/app/dwg/libdxfrw/intern/dwgbuffer.h index 96f7ccce734..69f8ef7ed46 100644 --- a/src/app/dwg/libdxfrw/intern/dwgbuffer.h +++ b/src/app/dwg/libdxfrw/intern/dwgbuffer.h @@ -25,7 +25,7 @@ class dwgBasicStream protected: dwgBasicStream() {} public: - virtual ~dwgBasicStream() {} + virtual ~dwgBasicStream() = default; virtual bool read( duint8* s, duint64 n ) = 0; virtual duint64 size() = 0; virtual duint64 getPos() = 0; @@ -44,7 +44,6 @@ class dwgFileStream: public dwgBasicStream sz = stream->tellg(); stream->seekg( 0, std::ios_base::beg ); } - virtual ~dwgFileStream() {} virtual bool read( duint8* s, duint64 n ); virtual duint64 size() {return sz;} virtual duint64 getPos() {return stream->tellg();} @@ -66,7 +65,6 @@ class dwgCharStream: public dwgBasicStream pos = 0; isOk = true; } - virtual ~dwgCharStream() {} virtual bool read( duint8* s, duint64 n ); virtual duint64 size() {return sz;} virtual duint64 getPos() {return pos;} diff --git a/src/app/dwg/libdxfrw/intern/dwgreader.h b/src/app/dwg/libdxfrw/intern/dwgreader.h index 68947bd306a..64868883c37 100644 --- a/src/app/dwg/libdxfrw/intern/dwgreader.h +++ b/src/app/dwg/libdxfrw/intern/dwgreader.h @@ -69,7 +69,7 @@ class dwgPageInfo , uSize( 0 ) { } - ~dwgPageInfo() {} + duint64 Id; duint64 address; //in file stream, for rd18, rd21 duint64 size; //in file stream, for rd18, rd21 @@ -101,7 +101,7 @@ class dwgSectionInfo , address( 0 ) { } - ~dwgSectionInfo() {} + dint32 Id; //section Id, 2000- rd15 rd18 std::string name; //section name rd18 duint32 compressed;//is compressed? 1=no, 2=yes rd18, rd21(encoding) diff --git a/src/app/dwg/libdxfrw/intern/dwgreader15.h b/src/app/dwg/libdxfrw/intern/dwgreader15.h index 38f7d469b5e..a6ea43c884b 100644 --- a/src/app/dwg/libdxfrw/intern/dwgreader15.h +++ b/src/app/dwg/libdxfrw/intern/dwgreader15.h @@ -23,7 +23,6 @@ class dwgReader15 : public dwgReader { public: dwgReader15( std::ifstream *stream, dwgR *p ): dwgReader( stream, p ) { } - virtual ~dwgReader15() {} bool readMetaData(); bool readFileHeader(); bool readDwgHeader( DRW_Header& hdr ); diff --git a/src/app/dwg/libdxfrw/intern/dwgreader18.cpp b/src/app/dwg/libdxfrw/intern/dwgreader18.cpp index 7d69aa4d68a..bef9c978588 100644 --- a/src/app/dwg/libdxfrw/intern/dwgreader18.cpp +++ b/src/app/dwg/libdxfrw/intern/dwgreader18.cpp @@ -762,6 +762,7 @@ bool dwgReader18::readDwgClasses() /*********** objects map ************************/ + /** Note: object map are split in sections with max size 2035? * heach section are 2 bytes size + data bytes + 2 bytes crc * size value are data bytes + 2 and to calculate crc are used @@ -796,6 +797,7 @@ bool dwgReader18::readDwgHandles() /*********** objects ************************/ + /** * Reads all the object referenced in the object map section of the DWG file * (using their object file offsets) diff --git a/src/app/dwg/libdxfrw/intern/dwgreader21.cpp b/src/app/dwg/libdxfrw/intern/dwgreader21.cpp index 0fc42c92770..30adc9ffb26 100644 --- a/src/app/dwg/libdxfrw/intern/dwgreader21.cpp +++ b/src/app/dwg/libdxfrw/intern/dwgreader21.cpp @@ -621,6 +621,7 @@ bool dwgReader21::readDwgHandles() } /*********** objects ************************/ + /** * Reads all the object referenced in the object map section of the DWG file * (using their object file offsets) diff --git a/src/app/dwg/libdxfrw/intern/dwgreader24.h b/src/app/dwg/libdxfrw/intern/dwgreader24.h index 58b7ffaa591..6d0ffffe18c 100644 --- a/src/app/dwg/libdxfrw/intern/dwgreader24.h +++ b/src/app/dwg/libdxfrw/intern/dwgreader24.h @@ -23,7 +23,6 @@ class dwgReader24 : public dwgReader18 { public: dwgReader24( std::ifstream *stream, dwgR *p ): dwgReader18( stream, p ) { } - virtual ~dwgReader24() {} bool readFileHeader(); bool readDwgHeader( DRW_Header& hdr ); bool readDwgClasses(); diff --git a/src/app/dwg/libdxfrw/intern/dwgreader27.h b/src/app/dwg/libdxfrw/intern/dwgreader27.h index 7bb960bdbfd..4637fe9790e 100644 --- a/src/app/dwg/libdxfrw/intern/dwgreader27.h +++ b/src/app/dwg/libdxfrw/intern/dwgreader27.h @@ -23,7 +23,6 @@ class dwgReader27 : public dwgReader18 { public: dwgReader27( std::ifstream *stream, dwgR *p ): dwgReader18( stream, p ) { } - virtual ~dwgReader27() {} bool readFileHeader(); bool readDwgHeader( DRW_Header& hdr ); bool readDwgClasses(); diff --git a/src/app/dwg/libdxfrw/intern/dwgutil.h b/src/app/dwg/libdxfrw/intern/dwgutil.h index 53b936240fb..07d19117343 100644 --- a/src/app/dwg/libdxfrw/intern/dwgutil.h +++ b/src/app/dwg/libdxfrw/intern/dwgutil.h @@ -24,7 +24,7 @@ class dwgRSCodec { public: dwgRSCodec() {} - ~dwgRSCodec() {} + static void decode239I( duint8 *in, duint8 *out, duint32 blk ); static void decode251I( duint8 *in, duint8 *out, duint32 blk ); }; @@ -41,8 +41,6 @@ class dwgCompressor , rpos( 0 ) {} - ~dwgCompressor() {} - void decompress18( duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize ); static void decrypt18Hdr( duint8 *buf, duint32 size, duint32 offset ); // static void decrypt18Data(duint8 *buf, duint32 size, duint32 offset); @@ -72,31 +70,30 @@ class secEnum public: enum DWGSection { - UNKNOWNS, /*!< UNKNOWN section. */ - FILEHEADER, /*!< File Header (in R3-R15*/ - HEADER, /*!< AcDb:Header */ - CLASSES, /*!< AcDb:Classes */ - SUMARYINFO, /*!< AcDb:SummaryInfo */ - PREVIEW, /*!< AcDb:Preview */ - VBAPROY, /*!< AcDb:VBAProject */ - APPINFO, /*!< AcDb:AppInfo */ - FILEDEP, /*!< AcDb:FileDepList */ - REVHISTORY, /*!< AcDb:RevHistory */ - SECURITY, /*!< AcDb:Security */ - OBJECTS, /*!< AcDb:AcDbObjects */ - OBJFREESPACE, /*!< AcDb:ObjFreeSpace */ - TEMPLATE, /*!< AcDb:Template */ - HANDLES, /*!< AcDb:Handles */ - PROTOTYPE, /*!< AcDb:AcDsPrototype_1b */ - AUXHEADER, /*!< AcDb:AuxHeader, in (R13-R15) second file header */ - SIGNATURE, /*!< AcDb:Signature */ - APPINFOHISTORY, /*!< AcDb:AppInfoHistory (in ac1021 may be a renamed section?*/ - EXTEDATA, /*!< Extended Entity Data */ - PROXYGRAPHICS /*!< PROXY ENTITY GRAPHICS */ + UNKNOWNS, //!< UNKNOWN section. + FILEHEADER, //!< File Header (in R3-R15 + HEADER, //!< AcDb:Header + CLASSES, //!< AcDb:Classes + SUMARYINFO, //!< AcDb:SummaryInfo + PREVIEW, //!< AcDb:Preview + VBAPROY, //!< AcDb:VBAProject + APPINFO, //!< AcDb:AppInfo + FILEDEP, //!< AcDb:FileDepList + REVHISTORY, //!< AcDb:RevHistory + SECURITY, //!< AcDb:Security + OBJECTS, //!< AcDb:AcDbObjects + OBJFREESPACE, //!< AcDb:ObjFreeSpace + TEMPLATE, //!< AcDb:Template + HANDLES, //!< AcDb:Handles + PROTOTYPE, //!< AcDb:AcDsPrototype_1b + AUXHEADER, //!< AcDb:AuxHeader, in (R13-R15) second file header + SIGNATURE, //!< AcDb:Signature + APPINFOHISTORY, //!< AcDb:AppInfoHistory (in ac1021 may be a renamed section? + EXTEDATA, //!< Extended Entity Data + PROXYGRAPHICS //!< PROXY ENTITY GRAPHICS }; secEnum() {} - ~secEnum() {} static DWGSection getEnum( std::string nameSec ); }; diff --git a/src/app/dwg/libdxfrw/intern/dxfreader.h b/src/app/dwg/libdxfrw/intern/dxfreader.h index 0db0753228c..7bd8d1c4301 100644 --- a/src/app/dwg/libdxfrw/intern/dxfreader.h +++ b/src/app/dwg/libdxfrw/intern/dxfreader.h @@ -38,7 +38,7 @@ class dxfReader filestr = stream; type = INVALID; } - virtual ~dxfReader() {} + virtual ~dxfReader() = default; bool readRec( int *code ); std::string getString() {return strData;} @@ -81,7 +81,6 @@ class dxfReaderBinary : public dxfReader explicit dxfReaderBinary( std::ifstream *stream ) : dxfReader( stream, false ) {} - virtual ~dxfReaderBinary() {} virtual bool readCode( int *code ); virtual bool readString( std::string *text ); virtual bool readString(); @@ -98,7 +97,6 @@ class dxfReaderAscii : public dxfReader explicit dxfReaderAscii( std::ifstream *stream ) : dxfReader( stream, true ) {} - virtual ~dxfReaderAscii() {} virtual bool readCode( int *code ); virtual bool readString( std::string *text ); virtual bool readString(); diff --git a/src/app/dwg/libdxfrw/intern/dxfwriter.h b/src/app/dwg/libdxfrw/intern/dxfwriter.h index 56761138e9b..fbf644509fb 100644 --- a/src/app/dwg/libdxfrw/intern/dxfwriter.h +++ b/src/app/dwg/libdxfrw/intern/dxfwriter.h @@ -22,7 +22,7 @@ class dxfWriter : filestr( stream ) // , count( 0 ) {} - virtual ~dxfWriter() {} + virtual ~dxfWriter() = default; virtual bool writeString( int code, std::string text ) = 0; bool writeUtf8String( int code, std::string text ); bool writeUtf8Caps( int code, std::string text ); @@ -47,7 +47,6 @@ class dxfWriterBinary : public dxfWriter explicit dxfWriterBinary( std::ofstream *stream ) : dxfWriter( stream ) {} - virtual ~dxfWriterBinary() {} virtual bool writeString( int code, std::string text ); virtual bool writeInt16( int code, int data ); virtual bool writeInt32( int code, int data ); @@ -60,7 +59,6 @@ class dxfWriterAscii : public dxfWriter { public: explicit dxfWriterAscii( std::ofstream *stream ); - virtual ~dxfWriterAscii() {} virtual bool writeString( int code, std::string text ); virtual bool writeInt16( int code, int data ); virtual bool writeInt32( int code, int data ); diff --git a/src/app/dwg/libdxfrw/intern/rscodec.cpp b/src/app/dwg/libdxfrw/intern/rscodec.cpp index 44173f4ff53..48708be775a 100644 --- a/src/app/dwg/libdxfrw/intern/rscodec.cpp +++ b/src/app/dwg/libdxfrw/intern/rscodec.cpp @@ -424,7 +424,7 @@ bool RScodec::encode( unsigned char *data, unsigned char *parity ) symbols will be okay and that if we are in luck, the errors are in the parity part of the transmitted codeword). Of course, these insoluble cases can be returned as error flags to the calling routine if desired. */ -/** Return value: number of corrected errors or -1 if can't correct it */ +//! Return value: number of corrected errors or -1 if can't correct it int RScodec::decode( unsigned char *data ) { if ( !isOk ) return -1; diff --git a/src/app/dwg/libdxfrw/intern/rscodec.h b/src/app/dwg/libdxfrw/intern/rscodec.h index d0a13e442fb..aedb7db65da 100644 --- a/src/app/dwg/libdxfrw/intern/rscodec.h +++ b/src/app/dwg/libdxfrw/intern/rscodec.h @@ -28,6 +28,7 @@ #ifndef RSCODEC_H #define RSCODEC_H + /** mm: RS code over GF(2^4) nn: nn= (2^mm) - 1 length of codeword diff --git a/src/app/dwg/libdxfrw/libdxfrw.h b/src/app/dwg/libdxfrw/libdxfrw.h index f9a5f9fec89..3896eb687d0 100644 --- a/src/app/dwg/libdxfrw/libdxfrw.h +++ b/src/app/dwg/libdxfrw/libdxfrw.h @@ -70,7 +70,7 @@ class dxfRW DRW_ImageDef *writeImage( DRW_Image *ent, std::string name ); bool writeLeader( DRW_Leader *ent ); bool writeDimension( DRW_Dimension *ent ); - void setEllipseParts( int parts ) {elParts = parts;} /*!< set parts number when convert ellipse to polyline */ + void setEllipseParts( int parts ) {elParts = parts;} //!< Set parts number when convert ellipse to polyline private: /// used by read() to parse the content of the file @@ -138,9 +138,9 @@ class dxfRW bool dimstyleStd; bool applyExt; bool writingBlock; - int elParts; /*!< parts number when convert ellipse to polyline */ + int elParts; //!< Parts number when convert ellipse to polyline std::map blockMap; - std::vector imageDef; /*!< imageDef list */ + std::vector imageDef; //!< ImageDef list int currHandle; }; diff --git a/src/app/dwg/qgsdwgimportdialog.cpp b/src/app/dwg/qgsdwgimportdialog.cpp index 18c73bb64db..ba03d5415ee 100644 --- a/src/app/dwg/qgsdwgimportdialog.cpp +++ b/src/app/dwg/qgsdwgimportdialog.cpp @@ -69,11 +69,6 @@ QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f ) cbMergeLayers->setChecked( s.value( "/DwgImport/lastMergeLayers", false ).toBool() ); cbUseCurves->setChecked( s.value( "/DwgImport/lastUseCurves", true ).toBool() ); -#if !defined(GDAL_COMPUTE_VERSION) || GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,0,0) - cbUseCurves->setChecked( false ); - cbUseCurves->setHidden( true ); -#endif - leDrawing->setReadOnly( true ); pbImportDrawing->setHidden( true ); lblMessage->setHidden( true ); @@ -422,7 +417,7 @@ void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, QString name, QS if ( !layerGroup->children().isEmpty() ) { layerGroup->setExpanded( false ); - layerGroup->setVisible( visible ? Qt::Checked : Qt::Unchecked ); + layerGroup->setItemVisibilityChecked( visible ); } else { diff --git a/src/app/dwg/qgsdwgimporter.cpp b/src/app/dwg/qgsdwgimporter.cpp index 7b1f9660efb..2e6d3dc1a2f 100644 --- a/src/app/dwg/qgsdwgimporter.cpp +++ b/src/app/dwg/qgsdwgimporter.cpp @@ -140,7 +140,6 @@ void QgsDwgImporter::startTransaction() { Q_ASSERT( mDs ); -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) mInTransaction = GDALDatasetStartTransaction( mDs, 0 ) == OGRERR_NONE; if ( !mInTransaction ) { @@ -148,14 +147,12 @@ void QgsDwgImporter::startTransaction() .arg( mDatabase ) .arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); } -#endif } void QgsDwgImporter::commitTransaction() { Q_ASSERT( mDs != nullptr ); -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) if ( mInTransaction && GDALDatasetCommitTransaction( mDs ) != OGRERR_NONE ) { LOG( QObject::tr( "Could not commit transaction\nDatabase:%1\nError:%2" ) @@ -163,7 +160,6 @@ void QgsDwgImporter::commitTransaction() .arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); } mInTransaction = false; -#endif } QgsDwgImporter::~QgsDwgImporter() @@ -186,13 +182,8 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa OGRwkbGeometryType lineGeomType, hatchGeomType; if ( useCurves ) { -#if !defined(GDAL_COMPUTE_VERSION) || GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,0,0) - error = QObject::tr( "Curves only supported with GDAL2" ); - return false; -#else lineGeomType = wkbCompoundCurveZ; hatchGeomType = wkbCurvePolygonZ; -#endif } else { @@ -2270,8 +2261,10 @@ void QgsDwgImporter::addText( const DRW_Text &data ) setPoint( dfn, f, "ext", data.extPoint ); - QgsPointV2 p( QgsWkbTypes::PointZ, data.secPoint.x, data.secPoint.y, data.secPoint.z ); - + QgsPointV2 p( QgsWkbTypes::PointZ, + ( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.x : data.basePoint.x, + ( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.y : data.basePoint.y, + ( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.z : data.basePoint.z ); if ( !createFeature( layer, f, p ) ) { diff --git a/src/app/gps/qgsgpsinformationwidget.cpp b/src/app/gps/qgsgpsinformationwidget.cpp index 9b168b6188f..4525fd64bbe 100644 --- a/src/app/gps/qgsgpsinformationwidget.cpp +++ b/src/app/gps/qgsgpsinformationwidget.cpp @@ -441,7 +441,7 @@ void QgsGPSInformationWidget::connected( QgsGPSConnection *conn ) mGPSPlainTextEdit->appendPlainText( tr( "Connected!" ) ); mConnectButton->setText( tr( "Dis&connect" ) ); //insert connection into registry such that it can also be used by other dialogs or plugins - QgsGPSConnectionRegistry::instance()->registerConnection( mNmea ); + QgsApplication::gpsConnectionRegistry()->registerConnection( mNmea ); showStatusBarMessage( tr( "Connected to GPS device." ) ); if ( mLogFileGroupBox->isChecked() && ! mTxtLogFile->text().isEmpty() ) @@ -481,7 +481,7 @@ void QgsGPSInformationWidget::disconnectGps() mLogFile = nullptr; } - QgsGPSConnectionRegistry::instance()->unregisterConnection( mNmea ); + QgsApplication::gpsConnectionRegistry()->unregisterConnection( mNmea ); delete mNmea; mNmea = nullptr; if ( mpMapMarker ) // marker should not be shown on GPS disconnected - not current position @@ -703,7 +703,7 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in QgsRectangle myExtentLimit( mpCanvas->extent() ); myExtentLimit.scale( mSpinMapExtentMultiplier->value() * 0.01 ); - // only change the extents if the point is beyond the current extents to minimise repaints + // only change the extents if the point is beyond the current extents to minimize repaints if ( radRecenterMap->isChecked() || ( radRecenterWhenNeeded->isChecked() && !myExtentLimit.contains( myPoint ) ) ) { @@ -909,7 +909,7 @@ void QgsGPSInformationWidget::on_mBtnCloseFeature_clicked() f->setGeometry( g ); QgsGeometry featGeom = f->geometry(); - int avoidIntersectionsReturn = featGeom.avoidIntersections(); + int avoidIntersectionsReturn = featGeom.avoidIntersections( QgsProject::instance()->avoidIntersectionsLayers() ); f->setGeometry( featGeom ); if ( avoidIntersectionsReturn == 1 ) { diff --git a/src/app/main.cpp b/src/app/main.cpp index 3075d89b35e..efb088e3e02 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -99,6 +99,7 @@ typedef SInt32 SRefCon; #include "qgsdxfexport.h" #include "qgsmapthemes.h" #include "qgsvectorlayer.h" +#include "qgis_app.h" /** Print usage text */ diff --git a/src/app/nodetool/qgsselectedfeature.cpp b/src/app/nodetool/qgsselectedfeature.cpp index 3e91448b0b7..4bb237874ad 100644 --- a/src/app/nodetool/qgsselectedfeature.cpp +++ b/src/app/nodetool/qgsselectedfeature.cpp @@ -285,7 +285,7 @@ void QgsSelectedFeature::deleteSelectedVertexes() if ( res == QgsVectorLayer::EmptyGeometry ) { - //geometry has been cleared as a result of deleting vertices (eg not enough vertices left to leave a valid geometry), + //geometry has been cleared as a result of deleting vertices (e.g., not enough vertices left to leave a valid geometry), //so nothing more to do QgsGeometry empty; geometryChanged( mFeatureId, empty ); diff --git a/src/app/nodetool/qgsvertexentry.h b/src/app/nodetool/qgsvertexentry.h index 9f95d465ef1..07dcbff19df 100644 --- a/src/app/nodetool/qgsvertexentry.h +++ b/src/app/nodetool/qgsvertexentry.h @@ -43,6 +43,9 @@ class QgsVertexEntry int penWidth = 2 ); ~QgsVertexEntry(); + QgsVertexEntry( const QgsVertexEntry& rh ) = delete; + QgsVertexEntry& operator=( const QgsVertexEntry& rh ) = delete; + const QgsPointV2& point() const { return mPoint; } QgsPoint pointV1() const { return QgsPoint( mPoint.x(), mPoint.y() ); } QgsVertexId vertexId() const { return mVertexId; } @@ -52,10 +55,6 @@ class QgsVertexEntry void setSelected( bool selected = true ); - private: - - QgsVertexEntry( const QgsVertexEntry& rh ); - QgsVertexEntry& operator=( const QgsVertexEntry& rh ); }; #endif diff --git a/src/app/ogr/qgsnewogrconnection.cpp b/src/app/ogr/qgsnewogrconnection.cpp index dd7058c03df..2d74cae8504 100644 --- a/src/app/ogr/qgsnewogrconnection.cpp +++ b/src/app/ogr/qgsnewogrconnection.cpp @@ -22,15 +22,10 @@ #include "qgslogger.h" #include "qgsproviderregistry.h" #include "qgsogrhelperfunctions.h" +#include "qgsapplication.h" #include #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 -#define TO8F(x) (x).toUtf8().constData() -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#endif - QgsNewOgrConnection::QgsNewOgrConnection( QWidget *parent, const QString& connType, const QString& connName, Qt::WindowFlags fl ) : QDialog( parent, fl ) , mOriginalConnName( connName ) @@ -88,7 +83,7 @@ void QgsNewOgrConnection::testConnection() OGRDataSourceH poDS; OGRSFDriverH pahDriver; CPLErrorReset(); - poDS = OGROpen( TO8F( uri ), false, &pahDriver ); + poDS = OGROpen( uri.toUtf8().constData(), false, &pahDriver ); if ( !poDS ) { QMessageBox::information( this, tr( "Test connection" ), tr( "Connection failed - Check settings and try again.\n\nExtended error information:\n%1" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); diff --git a/src/app/ogr/qgsnewogrconnection.h b/src/app/ogr/qgsnewogrconnection.h index 100d829232b..c93cd992751 100644 --- a/src/app/ogr/qgsnewogrconnection.h +++ b/src/app/ogr/qgsnewogrconnection.h @@ -32,7 +32,7 @@ class QgsNewOgrConnection : public QDialog, private Ui::QgsNewOgrConnectionBase public: //! Constructor QgsNewOgrConnection( QWidget *parent = nullptr, const QString& connType = QString::null, const QString& connName = QString::null, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - //! Destructor + ~QgsNewOgrConnection(); //! Tests the connection using the parameters supplied void testConnection(); diff --git a/src/app/ogr/qgsopenvectorlayerdialog.cpp b/src/app/ogr/qgsopenvectorlayerdialog.cpp index 5649d5c1ca0..10e2c582c3f 100644 --- a/src/app/ogr/qgsopenvectorlayerdialog.cpp +++ b/src/app/ogr/qgsopenvectorlayerdialog.cpp @@ -31,6 +31,7 @@ #include "qgsnewogrconnection.h" #include "qgsogrhelperfunctions.h" #include "qgscontexthelp.h" +#include "qgsapplication.h" QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget* parent, Qt::WindowFlags fl ) : QDialog( parent, fl ) diff --git a/src/app/ogr/qgsvectorlayersaveasdialog.cpp b/src/app/ogr/qgsvectorlayersaveasdialog.cpp index f3a22ff0d31..8c2c0f93980 100644 --- a/src/app/ogr/qgsvectorlayersaveasdialog.cpp +++ b/src/app/ogr/qgsvectorlayersaveasdialog.cpp @@ -345,12 +345,7 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx bool fieldsAsDisplayedValues = false; const QString sFormat( format() ); - if ( sFormat == QLatin1String( "KML" ) ) - { - mAttributesSelection->setEnabled( true ); - selectAllFields = false; - } - else if ( sFormat == QLatin1String( "DXF" ) ) + if ( sFormat == QLatin1String( "DXF" ) ) { mAttributesSelection->setEnabled( false ); selectAllFields = false; diff --git a/src/app/ogr/qgsvectorlayersaveasdialog.h b/src/app/ogr/qgsvectorlayersaveasdialog.h index c586e976020..e01732cc098 100644 --- a/src/app/ogr/qgsvectorlayersaveasdialog.h +++ b/src/app/ogr/qgsvectorlayersaveasdialog.h @@ -23,6 +23,7 @@ #include "qgscontexthelp.h" #include "qgsfields.h" #include "qgsvectorfilewriter.h" +#include "qgis_app.h" class QgsVectorLayer; diff --git a/src/app/pluginmanager/qgsapppluginmanagerinterface.h b/src/app/pluginmanager/qgsapppluginmanagerinterface.h index 7e528827bea..3a18e6d572e 100644 --- a/src/app/pluginmanager/qgsapppluginmanagerinterface.h +++ b/src/app/pluginmanager/qgsapppluginmanagerinterface.h @@ -34,7 +34,6 @@ class QgsAppPluginManagerInterface : public QgsPluginManagerInterface //! Constructor explicit QgsAppPluginManagerInterface( QgsPluginManager * pluginManager ); - //! Destructor ~QgsAppPluginManagerInterface(); //! remove python plugins from the metadata registry (c++ plugins stay) diff --git a/src/app/pluginmanager/qgspluginmanager.h b/src/app/pluginmanager/qgspluginmanager.h index 08307b12225..fdece7a7501 100644 --- a/src/app/pluginmanager/qgspluginmanager.h +++ b/src/app/pluginmanager/qgspluginmanager.h @@ -50,7 +50,6 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag //! Constructor; set pluginsAreEnabled to false in --noplugins mode QgsPluginManager( QWidget *parent = nullptr, bool pluginsAreEnabled = true, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - //! Destructor ~QgsPluginManager(); //! Save pointer to python utils and enable Python support diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 1655c651faf..7121276b92c 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -266,10 +266,6 @@ #include #include -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(1,11,0) -#define SUPPORT_GEOPACKAGE -#endif - // // Other includes // @@ -879,7 +875,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh mLogDock->hide(); connect( mMessageButton, SIGNAL( toggled( bool ) ), mLogDock, SLOT( setVisible( bool ) ) ); connect( mLogDock, SIGNAL( visibilityChanged( bool ) ), mMessageButton, SLOT( setChecked( bool ) ) ); - connect( QgsMessageLog::instance(), SIGNAL( messageReceived( bool ) ), this, SLOT( toggleLogMessageIcon( bool ) ) ); + connect( QgsApplication::messageLog(), SIGNAL( messageReceived( bool ) ), this, SLOT( toggleLogMessageIcon( bool ) ) ); connect( mMessageButton, SIGNAL( toggled( bool ) ), this, SLOT( toggleLogMessageIcon( bool ) ) ); mVectorLayerTools = new QgsGuiVectorLayerTools(); @@ -1707,6 +1703,7 @@ void QgisApp::createActions() connect( mActionHideAllLayers, SIGNAL( triggered() ), this, SLOT( hideAllLayers() ) ); connect( mActionShowSelectedLayers, SIGNAL( triggered() ), this, SLOT( showSelectedLayers() ) ); connect( mActionHideSelectedLayers, SIGNAL( triggered() ), this, SLOT( hideSelectedLayers() ) ); + connect( mActionHideDeselectedLayers, &QAction::triggered, this, &QgisApp::hideDeselectedLayers ); // Plugin Menu Items @@ -1721,7 +1718,7 @@ void QgisApp::createActions() connect( mActionOptions, SIGNAL( triggered() ), this, SLOT( options() ) ); connect( mActionCustomProjection, SIGNAL( triggered() ), this, SLOT( customProjection() ) ); connect( mActionConfigureShortcuts, SIGNAL( triggered() ), this, SLOT( configureShortcuts() ) ); - connect( mActionStyleManagerV2, SIGNAL( triggered() ), this, SLOT( showStyleManager() ) ); + connect( mActionStyleManager, SIGNAL( triggered() ), this, SLOT( showStyleManager() ) ); connect( mActionCustomization, SIGNAL( triggered() ), this, SLOT( customize() ) ); #ifdef Q_OS_MAC @@ -1963,10 +1960,6 @@ void QgisApp::createMenus() */ // Layer menu -#ifndef SUPPORT_GEOPACKAGE - mProjectMenu->removeAction( mActionDwgImport ); - mNewLayerMenu->removeAction( mActionNewGeoPackageLayer ); -#endif // Panel and Toolbar Submenus mPanelMenu = new QMenu( tr( "Panels" ), this ); @@ -2028,7 +2021,11 @@ void QgisApp::createMenus() // keep plugins from hijacking About and Preferences application menus // these duplicate actions will be moved to application menus by Qt mProjectMenu->addAction( mActionAbout ); - mProjectMenu->addAction( mActionOptions ); + QAction* actionPrefs = new QAction( tr( "Preferences..." ), this ); + actionPrefs->setMenuRole( QAction::PreferencesRole ); + actionPrefs->setIcon( mActionOptions->icon() ); + connect( actionPrefs, &QAction::triggered, this, &QgisApp::options ); + mProjectMenu->addAction( actionPrefs ); // Window Menu @@ -2112,10 +2109,10 @@ void QgisApp::createToolBars() QToolButton *bt = new QToolButton( mAttributesToolBar ); bt->setPopupMode( QToolButton::MenuButtonPopup ); QList selectActions; - selectActions << mActionSelectByExpression << mActionSelectByForm << mActionSelectAll + selectActions << mActionSelectByForm << mActionSelectByExpression << mActionSelectAll << mActionInvertSelection; bt->addActions( selectActions ); - bt->setDefaultAction( mActionSelectByExpression ); + bt->setDefaultAction( mActionSelectByForm ); QAction* selectionAction = mAttributesToolBar->insertWidget( mActionDeselectAll, bt ); selectionAction->setObjectName( QStringLiteral( "ActionSelection" ) ); @@ -2236,9 +2233,7 @@ void QgisApp::createToolBars() bt->setPopupMode( QToolButton::MenuButtonPopup ); bt->addAction( mActionNewVectorLayer ); bt->addAction( mActionNewSpatiaLiteLayer ); -#ifdef SUPPORT_GEOPACKAGE bt->addAction( mActionNewGeoPackageLayer ); -#endif bt->addAction( mActionNewMemoryLayer ); QAction* defNewLayerAction = mActionNewVectorLayer; @@ -2253,11 +2248,9 @@ void QgisApp::createToolBars() case 2: defNewLayerAction = mActionNewMemoryLayer; break; -#ifdef SUPPORT_GEOPACKAGE case 3: defNewLayerAction = mActionNewGeoPackageLayer; break; -#endif } bt->setDefaultAction( defNewLayerAction ); QAction* newLayerAction = mLayerToolBar->addWidget( bt ); @@ -2626,8 +2619,8 @@ void QgisApp::setTheme( const QString& theThemeName ) mActionShowPythonDialog->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "console/iconRunConsole.png" ) ) ); mActionCheckQgisVersion->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionCheckQgisVersion.png" ) ) ); mActionOptions->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionOptions.svg" ) ) ); - mActionConfigureShortcuts->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionOptions.svg" ) ) ); - mActionCustomization->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionOptions.svg" ) ) ); + mActionConfigureShortcuts->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionKeyboardShortcuts.svg" ) ) ); + mActionCustomization->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionInterfaceCustomization.svg" ) ) ); mActionHelpContents->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionHelpContents.svg" ) ) ); mActionLocalHistogramStretch->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionLocalHistogramStretch.svg" ) ) ); mActionFullHistogramStretch->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionFullHistogramStretch.svg" ) ) ); @@ -2726,7 +2719,7 @@ void QgisApp::setTheme( const QString& theThemeName ) mActionMoveLabel->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMoveLabel.svg" ) ) ); mActionRotateLabel->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionRotateLabel.svg" ) ) ); mActionChangeLabelProperties->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionChangeLabelProperties.svg" ) ) ); - mActionDiagramProperties->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDiagramProperties.svg" ) ) ); + mActionDiagramProperties->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/diagram.svg" ) ) ); mActionDecorationCopyright->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/copyright_label.png" ) ) ); mActionDecorationNorthArrow->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/north_arrow.png" ) ) ); mActionDecorationScaleBar->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/scale_bar.png" ) ) ); @@ -2803,7 +2796,7 @@ void QgisApp::setupConnections() this, SLOT( markDirty() ) ); connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( removedChildren( QgsLayerTreeNode*, int, int ) ), this, SLOT( updateNewLayerInsertionPoint() ) ); - connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( visibilityChanged( QgsLayerTreeNode*, Qt::CheckState ) ), + connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( visibilityChanged( QgsLayerTreeNode* ) ), this, SLOT( markDirty() ) ); connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( customPropertyChanged( QgsLayerTreeNode*, QString ) ), this, SLOT( markDirty() ) ); @@ -5754,9 +5747,8 @@ void QgisApp::stopRendering() void QgisApp::hideAllLayers() { QgsDebugMsg( "hiding all layers!" ); + mLayerTreeView->layerTreeModel()->rootGroup()->setItemVisibilityCheckedRecursive( false ); - Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, mLayerTreeView->layerTreeModel()->rootGroup()->findLayers() ) - nodeLayer->setVisible( Qt::Unchecked ); } @@ -5764,9 +5756,7 @@ void QgisApp::hideAllLayers() void QgisApp::showAllLayers() { QgsDebugMsg( "Showing all layers!" ); - - Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, mLayerTreeView->layerTreeModel()->rootGroup()->findLayers() ) - nodeLayer->setVisible( Qt::Checked ); + mLayerTreeView->layerTreeModel()->rootGroup()->setItemVisibilityCheckedRecursive( true ); } //reimplements method from base (gui) class @@ -5776,13 +5766,21 @@ void QgisApp::hideSelectedLayers() Q_FOREACH ( QgsLayerTreeNode* node, mLayerTreeView->selectedNodes() ) { - if ( QgsLayerTree::isGroup( node ) ) - QgsLayerTree::toGroup( node )->setVisible( Qt::Unchecked ); - else if ( QgsLayerTree::isLayer( node ) ) - QgsLayerTree::toLayer( node )->setVisible( Qt::Unchecked ); + node->setItemVisibilityChecked( false ); } } +void QgisApp::hideDeselectedLayers() +{ + QList selectedLayerNodes = mLayerTreeView->selectedLayerNodes(); + + Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, mLayerTreeView->layerTreeModel()->rootGroup()->findLayers() ) + { + if ( selectedLayerNodes.contains( nodeLayer ) ) + continue; + nodeLayer->setItemVisibilityChecked( false ); + } +} // reimplements method from base (gui) class void QgisApp::showSelectedLayers() @@ -5791,10 +5789,12 @@ void QgisApp::showSelectedLayers() Q_FOREACH ( QgsLayerTreeNode* node, mLayerTreeView->selectedNodes() ) { - if ( QgsLayerTree::isGroup( node ) ) - QgsLayerTree::toGroup( node )->setVisible( Qt::Checked ); - else if ( QgsLayerTree::isLayer( node ) ) - QgsLayerTree::toLayer( node )->setVisible( Qt::Checked ); + QgsLayerTreeNode* nodeIter = node; + while ( nodeIter ) + { + nodeIter->setItemVisibilityChecked( true ); + nodeIter = nodeIter->parent(); + } } } @@ -6353,7 +6353,7 @@ void QgisApp::saveAsLayerDefinition() bool saved = QgsLayerDefinition::exportLayerDefinition( path, mLayerTreeView->selectedNodes(), errorMessage ); if ( !saved ) { - messageBar()->pushMessage( tr( "Error saving layer definintion file" ), errorMessage, QgsMessageBar::WARNING ); + messageBar()->pushMessage( tr( "Error saving layer definition file" ), errorMessage, QgsMessageBar::WARNING ); } } @@ -7492,6 +7492,8 @@ void QgisApp::selectByExpression() } QgsExpressionSelectionDialog* dlg = new QgsExpressionSelectionDialog( vlayer, QString(), this ); + dlg->setMessageBar( messageBar() ); + dlg->setMapCanvas( mapCanvas() ); dlg->setAttribute( Qt::WA_DeleteOnClose ); dlg->show(); } @@ -7520,6 +7522,7 @@ void QgisApp::selectByForm() QgsSelectByFormDialog* dlg = new QgsSelectByFormDialog( vlayer, context, this ); dlg->setMessageBar( messageBar() ); + dlg->setMapCanvas( mapCanvas() ); dlg->setAttribute( Qt::WA_DeleteOnClose ); dlg->show(); } @@ -7641,7 +7644,7 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer ) geom = newGeometry; } // avoid intersection if enabled in digitize settings - geom.avoidIntersections(); + geom.avoidIntersections( QgsProject::instance()->avoidIntersectionsLayers() ); } // now create new feature using pasted feature as a template. This automatically handles default @@ -8354,7 +8357,7 @@ void QgisApp::layerSubsetString() // hide the old layer QgsLayerTreeLayer* vLayerTreeLayer = QgsProject::instance()->layerTreeRoot()->findLayer( vlayer->id() ); if ( vLayerTreeLayer ) - vLayerTreeLayer->setVisible( Qt::Unchecked ); + vLayerTreeLayer->setItemVisibilityChecked( false ); vlayer = newLayer; } else @@ -8644,7 +8647,7 @@ void QgisApp::duplicateLayers( const QList& lyrList ) QgsLayerTreeLayer* nodeDupLayer = parentGroup->insertLayer( parentGroup->children().indexOf( nodeSelectedLyr ) + 1, dupLayer ); // always set duplicated layers to not visible so layer can be configured before being turned on - nodeDupLayer->setVisible( Qt::Unchecked ); + nodeDupLayer->setItemVisibilityChecked( false ); // duplicate the layer style QString errMsg; @@ -9099,7 +9102,7 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString& currentPage ) QSettings mySettings; QString oldScales = mySettings.value( QStringLiteral( "Map/scales" ), PROJECT_SCALES ).toString(); - bool oldCapitalise = mySettings.value( QStringLiteral( "/qgis/capitaliseLayerName" ), QVariant( false ) ).toBool(); + bool oldCapitalize = mySettings.value( QStringLiteral( "/qgis/capitalizeLayerName" ), QVariant( false ) ).toBool(); QgsOptions *optionsDialog = new QgsOptions( parent ); if ( !currentPage.isEmpty() ) @@ -9124,7 +9127,7 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString& currentPage ) mMapCanvas->setMapUpdateInterval( mySettings.value( QStringLiteral( "/qgis/map_update_interval" ), 250 ).toInt() ); - if ( oldCapitalise != mySettings.value( QStringLiteral( "/qgis/capitaliseLayerName" ), QVariant( false ) ).toBool() ) + if ( oldCapitalize != mySettings.value( QStringLiteral( "/qgis/capitalizeLayerName" ), QVariant( false ) ).toBool() ) { // if the layer capitalization has changed, we need to update all layer names Q_FOREACH ( QgsMapLayer* layer, QgsProject::instance()->mapLayers() ) @@ -10810,8 +10813,10 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer ) mActionPasteFeatures->setEnabled( isEditable && canAddFeatures && !clipboard()->isEmpty() ); mActionAddFeature->setEnabled( isEditable && canAddFeatures ); - mActionCircularStringCurvePoint->setEnabled( isEditable && isSpatial && ( canAddFeatures || canChangeGeometry ) && vlayer->geometryType() != QgsWkbTypes::PointGeometry ); - mActionCircularStringRadius->setEnabled( isEditable && isSpatial && ( canAddFeatures || canChangeGeometry ) ); + mActionCircularStringCurvePoint->setEnabled( isEditable && ( canAddFeatures || canChangeGeometry ) + && ( vlayer->geometryType() == QgsWkbTypes::LineGeometry || vlayer->geometryType() == QgsWkbTypes::PolygonGeometry ) ); + mActionCircularStringRadius->setEnabled( isEditable && ( canAddFeatures || canChangeGeometry ) + && ( vlayer->geometryType() == QgsWkbTypes::LineGeometry || vlayer->geometryType() == QgsWkbTypes::PolygonGeometry ) ); //does provider allow deleting of features? mActionDeleteSelected->setEnabled( isEditable && canDeleteFeatures && layerHasSelection ); @@ -11337,7 +11342,7 @@ bool QgisApp::addRasterLayers( QStringList const &theFileNameQStringList, bool g QgsPluginLayer* QgisApp::addPluginLayer( const QString& uri, const QString& baseName, const QString& providerKey ) { - QgsPluginLayer* layer = QgsPluginLayerRegistry::instance()->createLayer( providerKey, uri ); + QgsPluginLayer* layer = QgsApplication::pluginLayerRegistry()->createLayer( providerKey, uri ); if ( !layer ) return nullptr; @@ -11654,7 +11659,7 @@ void QgisApp::showLayerProperties( QgsMapLayer *ml ) if ( !pl ) return; - QgsPluginLayerType* plt = QgsPluginLayerRegistry::instance()->pluginLayerType( pl->pluginLayerType() ); + QgsPluginLayerType* plt = QgsApplication::pluginLayerRegistry()->pluginLayerType( pl->pluginLayerType() ); if ( !plt ) return; diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 145a40c8e32..1b7ff79b08a 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -128,6 +128,7 @@ class QgsDiagramProperties; #include "qgsrasterminmaxorigin.h" #include "ui_qgisapp.h" +#include "qgis_app.h" #ifdef HAVE_TOUCH #include @@ -151,9 +152,12 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QgisApp( QSplashScreen *splash, bool restorePlugins = true, bool skipVersionCheck = false, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window ); //! Constructor for unit tests QgisApp(); - //! Destructor + ~QgisApp(); + QgisApp( QgisApp const & ) = delete; + QgisApp & operator=( QgisApp const & ) = delete; + /** * Add a vector layer to the canvas, returns pointer to it */ @@ -411,6 +415,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QAction *actionHideAllLayers() { return mActionHideAllLayers; } QAction *actionShowAllLayers() { return mActionShowAllLayers; } QAction *actionHideSelectedLayers() { return mActionHideSelectedLayers; } + QAction *actionHideDeselectedLayers() { return mActionHideDeselectedLayers; } QAction *actionShowSelectedLayers() { return mActionShowSelectedLayers; } QAction *actionManagePlugins() { return mActionManagePlugins; } @@ -1027,6 +1032,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow void showAllLayers(); //reimplements method from base (gui) class void hideSelectedLayers(); + //! Hides any layers which are not selected + void hideDeselectedLayers(); //reimplements method from base (gui) class void showSelectedLayers(); //! Return pointer to the active layer @@ -1506,11 +1513,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow //! Configure layer tree view according to the user options from QSettings void setupLayerTreeViewFromSettings(); - /// QgisApp aren't copyable - QgisApp( QgisApp const & ); - /// QgisApp aren't copyable - QgisApp & operator=( QgisApp const & ); - void readSettings(); void writeSettings(); void createActions(); diff --git a/src/app/qgisappinterface.cpp b/src/app/qgisappinterface.cpp index a93236bd0ad..16771ac82c4 100644 --- a/src/app/qgisappinterface.cpp +++ b/src/app/qgisappinterface.cpp @@ -71,10 +71,6 @@ QgisAppInterface::QgisAppInterface( QgisApp * _qgis ) this, SIGNAL( layerSavedAs( QgsMapLayer*, QString ) ) ); } -QgisAppInterface::~QgisAppInterface() -{ -} - QgsPluginManagerInterface* QgisAppInterface::pluginManagerInterface() { return &pluginManagerIface; @@ -631,6 +627,7 @@ QAction *QgisAppInterface::actionRemoveAllFromOverview() { return qgis->actionRe QAction *QgisAppInterface::actionHideAllLayers() { return qgis->actionHideAllLayers(); } QAction *QgisAppInterface::actionShowAllLayers() { return qgis->actionShowAllLayers(); } QAction *QgisAppInterface::actionHideSelectedLayers() { return qgis->actionHideSelectedLayers(); } +QAction*QgisAppInterface::actionHideDeselectedLayers() { return qgis->actionHideDeselectedLayers(); } QAction *QgisAppInterface::actionShowSelectedLayers() { return qgis->actionShowSelectedLayers(); } //! Plugin menu actions diff --git a/src/app/qgisappinterface.h b/src/app/qgisappinterface.h index 02de57d0d6d..8a5c924cc47 100644 --- a/src/app/qgisappinterface.h +++ b/src/app/qgisappinterface.h @@ -20,6 +20,7 @@ #include "qgisinterface.h" #include "qgsapppluginmanagerinterface.h" +#include "qgis_app.h" class QgisApp; @@ -43,7 +44,9 @@ class APP_EXPORT QgisAppInterface : public QgisInterface * @param qgis Pointer to the QgisApp object */ QgisAppInterface( QgisApp *qgisapp ); - ~QgisAppInterface(); + + QgisAppInterface( QgisAppInterface const & ) = delete; + QgisAppInterface & operator=( QgisAppInterface const & ) = delete; QgsPluginManagerInterface* pluginManagerInterface() override; @@ -445,6 +448,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface virtual QAction *actionHideAllLayers() override; virtual QAction *actionShowAllLayers() override; virtual QAction *actionHideSelectedLayers() override; + virtual QAction *actionHideDeselectedLayers() override; virtual QAction *actionShowSelectedLayers() override; //! Plugin menu actions @@ -523,12 +527,6 @@ class APP_EXPORT QgisAppInterface : public QgisInterface private: - /// QgisInterface aren't copied - QgisAppInterface( QgisAppInterface const & ); - - /// QgisInterface aren't copied - QgisAppInterface & operator=( QgisAppInterface const & ); - //! Pointer to the QgisApp object QgisApp *qgis; diff --git a/src/app/qgisappstylesheet.h b/src/app/qgisappstylesheet.h index 71eb8371854..25b406853de 100644 --- a/src/app/qgisappstylesheet.h +++ b/src/app/qgisappstylesheet.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_app.h" /** @class QgisAppStyleSheet * @brief Adjustable stylesheet for the Qgis application diff --git a/src/app/qgsabout.h b/src/app/qgsabout.h index 162e7547bd1..2912a022e01 100644 --- a/src/app/qgsabout.h +++ b/src/app/qgsabout.h @@ -19,6 +19,7 @@ #include "ui_qgsabout.h" #include "qgsoptionsdialogbase.h" +#include "qgis_app.h" class APP_EXPORT QgsAbout : public QgsOptionsDialogBase, private Ui::QgsAbout { diff --git a/src/app/qgsaddattrdialog.h b/src/app/qgsaddattrdialog.h index 5d26b8ca718..27ab7bedb1a 100644 --- a/src/app/qgsaddattrdialog.h +++ b/src/app/qgsaddattrdialog.h @@ -21,6 +21,7 @@ #include "ui_qgsaddattrdialogbase.h" #include "qgisgui.h" #include "qgsfields.h" +#include "qgis_app.h" class QgsVectorLayer; diff --git a/src/app/qgsaddtaborgroup.h b/src/app/qgsaddtaborgroup.h index ebdbd7feb69..5b51eff9b89 100644 --- a/src/app/qgsaddtaborgroup.h +++ b/src/app/qgsaddtaborgroup.h @@ -21,6 +21,7 @@ #include "ui_qgsaddtaborgroupbase.h" #include "qgisgui.h" +#include "qgis_app.h" class QTreeWidgetItem; class QgsVectorLayer; diff --git a/src/app/qgsalignrasterdialog.cpp b/src/app/qgsalignrasterdialog.cpp index e0edb5b8de0..bbced151694 100644 --- a/src/app/qgsalignrasterdialog.cpp +++ b/src/app/qgsalignrasterdialog.cpp @@ -393,13 +393,11 @@ QgsAlignRasterLayerConfigDialog::QgsAlignRasterLayerConfigDialog() cboResample->addItem( tr( "Lanczos (6x6 kernel)" ), QgsAlignRaster::RA_Lanczos ); cboResample->addItem( tr( "Average" ), QgsAlignRaster::RA_Average ); cboResample->addItem( tr( "Mode" ), QgsAlignRaster::RA_Mode ); -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 cboResample->addItem( tr( "Maximum" ), QgsAlignRaster::RA_Max ); cboResample->addItem( tr( "Minimum" ), QgsAlignRaster::RA_Min ); cboResample->addItem( tr( "Median" ), QgsAlignRaster::RA_Median ); cboResample->addItem( tr( "First Quartile (Q1)" ), QgsAlignRaster::RA_Q1 ); cboResample->addItem( tr( "Third Quartile (Q3)" ), QgsAlignRaster::RA_Q3 ); -#endif editOutput = new QLineEdit( this ); btnBrowse = new QPushButton( tr( "Browse..." ), this ); diff --git a/src/app/qgsannotationwidget.h b/src/app/qgsannotationwidget.h index 91f7f657a87..fba5fa01df8 100644 --- a/src/app/qgsannotationwidget.h +++ b/src/app/qgsannotationwidget.h @@ -19,6 +19,7 @@ #define QGSANNOTATIONWIDGET_H #include "ui_qgsannotationwidgetbase.h" +#include "qgis_app.h" class QgsAnnotationItem; class QgsMarkerSymbol; diff --git a/src/app/qgsapplayertreeviewmenuprovider.cpp b/src/app/qgsapplayertreeviewmenuprovider.cpp index 2d02f21e5d7..a18a4b92070 100644 --- a/src/app/qgsapplayertreeviewmenuprovider.cpp +++ b/src/app/qgsapplayertreeviewmenuprovider.cpp @@ -80,6 +80,10 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu() menu->addAction( actions->actionMutuallyExclusiveGroup( menu ) ); + menu->addAction( actions->actionCheckAndAllChildren( menu ) ); + + menu->addAction( actions->actionUncheckAndAllChildren( menu ) ); + if ( mView->selectedNodes( true ).count() >= 2 ) menu->addAction( actions->actionGroupSelected( menu ) ); @@ -125,6 +129,8 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu() if ( !layer->isInScaleRange( mCanvas->scale() ) ) menu->addAction( tr( "Zoom to &Visible Scale" ), QgisApp::instance(), SLOT( zoomToLayerScale() ) ); + menu->addAction( actions->actionCheckAndAllParents( menu ) ); + // set layer crs menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSetCRS.png" ) ), tr( "Set Layer CRS" ), QgisApp::instance(), SLOT( setLayerCrs() ) ); @@ -169,7 +175,7 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu() //add recent colors action QList recentSchemes; - QgsColorSchemeRegistry::instance()->schemes( recentSchemes ); + QgsApplication::colorSchemeRegistry()->schemes( recentSchemes ); if ( !recentSchemes.isEmpty() ) { QgsColorSwatchGridAction* recentColorAction = new QgsColorSwatchGridAction( recentSchemes.at( 0 ), menuStyleManager, QStringLiteral( "symbology" ), menuStyleManager ); @@ -306,7 +312,7 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu() //add recent colors action QList recentSchemes; - QgsColorSchemeRegistry::instance()->schemes( recentSchemes ); + QgsApplication::colorSchemeRegistry()->schemes( recentSchemes ); if ( !recentSchemes.isEmpty() ) { QgsColorSwatchGridAction* recentColorAction = new QgsColorSwatchGridAction( recentSchemes.at( 0 ), menu, QStringLiteral( "symbology" ), menu ); diff --git a/src/app/qgsattributeactiondialog.cpp b/src/app/qgsattributeactiondialog.cpp index 43bc8343507..a15360c5bad 100644 --- a/src/app/qgsattributeactiondialog.cpp +++ b/src/app/qgsattributeactiondialog.cpp @@ -150,7 +150,8 @@ void QgsAttributeActionDialog::insertRow( int row, const QgsAction& action ) void QgsAttributeActionDialog::insertRow( int row, QgsAction::ActionType type, const QString& name, const QString& actionText, const QString& iconPath, bool capture, const QString& shortTitle, const QSet& actionScopes ) { - insertRow( row, QgsAction( type, name, actionText, iconPath, capture, shortTitle, actionScopes ) ); + if ( uniqueName( name ) == name ) + insertRow( row, QgsAction( type, name, actionText, iconPath, capture, shortTitle, actionScopes ) ); } void QgsAttributeActionDialog::moveUp() @@ -356,7 +357,7 @@ QString QgsAttributeActionDialog::uniqueName( QString name ) for ( int i = 0; i < pos; ++i ) { - if ( mAttributeActionTable->item( i, 0 )->text() == name ) + if ( mAttributeActionTable->item( i, Description )->text() == name ) unique = false; } diff --git a/src/app/qgsattributeactiondialog.h b/src/app/qgsattributeactiondialog.h index 53703be4ab1..de2d2d3049e 100644 --- a/src/app/qgsattributeactiondialog.h +++ b/src/app/qgsattributeactiondialog.h @@ -27,6 +27,7 @@ back to QgsVectorLayer. #include "qgsattributetableconfig.h" #include "qgsaction.h" #include +#include "qgis_app.h" class QgsActionManager; class QgsVectorLayer; @@ -49,8 +50,6 @@ class APP_EXPORT QgsAttributeActionDialog: public QWidget, private Ui::QgsAttrib QgsAttributeActionDialog( const QgsActionManager& actions, QWidget* parent = nullptr ); - ~QgsAttributeActionDialog() {} - void init( const QgsActionManager& action , const QgsAttributeTableConfig& attributeTableConfig ); QList actions() const; diff --git a/src/app/qgsattributetabledialog.cpp b/src/app/qgsattributetabledialog.cpp index 96578a47824..328aaa5b218 100644 --- a/src/app/qgsattributetabledialog.cpp +++ b/src/app/qgsattributetabledialog.cpp @@ -54,7 +54,7 @@ QgsExpressionContext QgsAttributeTableDialog::createExpressionContext() const { QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope(); + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ); if ( mLayer ) expContext << QgsExpressionContextUtils::layerScope( mLayer ); @@ -474,10 +474,7 @@ void QgsAttributeTableDialog::runFieldCalculation( QgsVectorLayer* layer, const int rownum = 1; - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( layer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( layer ) ); QgsField fld = layer->fields().at( fieldindex ); @@ -583,10 +580,7 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction ) void QgsAttributeTableDialog::filterExpressionBuilder() { // Show expression builder - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mLayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mLayer ) ); QgsExpressionBuilderDialog dlg( mLayer, mFilterQuery->text(), this, QStringLiteral( "generic" ), context ); dlg.setWindowTitle( tr( "Expression based filter" ) ); @@ -965,10 +959,7 @@ void QgsAttributeTableDialog::setFilterExpression( const QString& filterString, return; } - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mLayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mLayer ) ); if ( !filterExpression.prepare( &context ) ) { diff --git a/src/app/qgsattributetabledialog.h b/src/app/qgsattributetabledialog.h index 0f017741dd0..b9015eb4f6c 100644 --- a/src/app/qgsattributetabledialog.h +++ b/src/app/qgsattributetabledialog.h @@ -26,6 +26,7 @@ #include "ui_qgsattributetabledialog.h" #include "qgssearchwidgetwrapper.h" #include "qgsdockwidget.h" +#include "qgis_app.h" class QDialogButtonBox; class QPushButton; diff --git a/src/app/qgsattributetypedialog.h b/src/app/qgsattributetypedialog.h index b189f88f286..33173be6842 100644 --- a/src/app/qgsattributetypedialog.h +++ b/src/app/qgsattributetypedialog.h @@ -22,6 +22,7 @@ #include "qgseditorconfigwidget.h" #include "qgsfeature.h" #include "qgsvectordataprovider.h" +#include "qgis_app.h" class QDialog; diff --git a/src/app/qgsbookmarks.h b/src/app/qgsbookmarks.h index 7e05c762825..94997f724df 100644 --- a/src/app/qgsbookmarks.h +++ b/src/app/qgsbookmarks.h @@ -22,6 +22,7 @@ #include "ui_qgsbookmarksbase.h" #include "qgsdockwidget.h" +#include "qgis_app.h" /* * Model for project bookmarks diff --git a/src/app/qgsbrowserdockwidget.h b/src/app/qgsbrowserdockwidget.h index 05328cedd8c..40f3e23a680 100644 --- a/src/app/qgsbrowserdockwidget.h +++ b/src/app/qgsbrowserdockwidget.h @@ -24,6 +24,7 @@ #include "qgsbrowsertreeview.h" #include "qgsdockwidget.h" #include +#include "qgis_app.h" class QgsBrowserModel; class QModelIndex; diff --git a/src/app/qgsclipboard.h b/src/app/qgsclipboard.h index 16b56fac6a7..4fd89900291 100644 --- a/src/app/qgsclipboard.h +++ b/src/app/qgsclipboard.h @@ -25,6 +25,7 @@ #include "qgsfields.h" #include "qgsfeature.h" #include "qgscoordinatereferencesystem.h" +#include "qgis_app.h" /** \brief QGIS internal clipboard for features. @@ -67,7 +68,6 @@ class APP_EXPORT QgsClipboard : public QObject */ QgsClipboard(); - //! Destructor virtual ~QgsClipboard(); /** diff --git a/src/app/qgscustomization.h b/src/app/qgscustomization.h index a50b640aa1c..f146c22960e 100644 --- a/src/app/qgscustomization.h +++ b/src/app/qgscustomization.h @@ -25,6 +25,7 @@ #include #include #include +#include "qgis_app.h" class QString; class QWidget; diff --git a/src/app/qgscustomprojectiondialog.h b/src/app/qgscustomprojectiondialog.h index 056eb56fc46..45f1bcfb115 100644 --- a/src/app/qgscustomprojectiondialog.h +++ b/src/app/qgscustomprojectiondialog.h @@ -21,6 +21,7 @@ #include "ui_qgscustomprojectiondialogbase.h" #include "qgscontexthelp.h" #include "qgscoordinatereferencesystem.h" +#include "qgis_app.h" class QDir; diff --git a/src/app/qgsdecorationcopyright.cpp b/src/app/qgsdecorationcopyright.cpp index e64893b1c07..0c035e35cea 100644 --- a/src/app/qgsdecorationcopyright.cpp +++ b/src/app/qgsdecorationcopyright.cpp @@ -54,9 +54,6 @@ QgsDecorationCopyright::QgsDecorationCopyright( QObject* parent ) projectRead(); } -QgsDecorationCopyright::~QgsDecorationCopyright() -{} - void QgsDecorationCopyright::projectRead() { QgsDecorationItem::projectRead(); diff --git a/src/app/qgsdecorationcopyright.h b/src/app/qgsdecorationcopyright.h index 55754c2b027..50093078a1b 100644 --- a/src/app/qgsdecorationcopyright.h +++ b/src/app/qgsdecorationcopyright.h @@ -24,6 +24,7 @@ #include #include #include +#include "qgis_app.h" class QAction; class QPainter; @@ -36,8 +37,6 @@ class APP_EXPORT QgsDecorationCopyright : public QgsDecorationItem //! Constructor QgsDecorationCopyright( QObject* parent = nullptr ); - //! Destructor - virtual ~QgsDecorationCopyright(); public slots: //! set values on the gui when a project is read or the gui first loaded diff --git a/src/app/qgsdecorationcopyrightdialog.h b/src/app/qgsdecorationcopyrightdialog.h index f36ceb6f43d..ea8d914598c 100644 --- a/src/app/qgsdecorationcopyrightdialog.h +++ b/src/app/qgsdecorationcopyrightdialog.h @@ -13,6 +13,7 @@ #define QGSCOPYRIGHTLABELPLUGINGUI_H #include "ui_qgsdecorationcopyrightdialog.h" +#include "qgis_app.h" class QColor; class QFont; diff --git a/src/app/qgsdecorationgrid.h b/src/app/qgsdecorationgrid.h index 692442b98db..4ee188b9e88 100644 --- a/src/app/qgsdecorationgrid.h +++ b/src/app/qgsdecorationgrid.h @@ -28,6 +28,7 @@ class QgsMarkerSymbol; #include #include #include +#include "qgis_app.h" class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem { @@ -35,7 +36,7 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem public: //! Constructor QgsDecorationGrid( QObject* parent = nullptr ); - //! Destructor + virtual ~ QgsDecorationGrid(); enum GridStyle diff --git a/src/app/qgsdecorationgriddialog.h b/src/app/qgsdecorationgriddialog.h index 6bcbc6028fa..bc5ccda9c19 100644 --- a/src/app/qgsdecorationgriddialog.h +++ b/src/app/qgsdecorationgriddialog.h @@ -20,6 +20,7 @@ #include "ui_qgsdecorationgriddialog.h" #include +#include "qgis_app.h" class QgsDecorationGrid; class QgsLineSymbol; diff --git a/src/app/qgsdecorationitem.h b/src/app/qgsdecorationitem.h index 9e6ea80473d..1b526c88dc9 100644 --- a/src/app/qgsdecorationitem.h +++ b/src/app/qgsdecorationitem.h @@ -20,6 +20,7 @@ #include #include "qgsunittypes.h" +#include "qgis_app.h" class QPainter; @@ -41,7 +42,7 @@ class APP_EXPORT QgsDecorationItem: public QObject //! Constructor QgsDecorationItem( QObject* parent = nullptr ); - //! Destructor + virtual ~ QgsDecorationItem(); void setEnabled( bool enabled ) { mEnabled = enabled; } diff --git a/src/app/qgsdecorationnortharrow.h b/src/app/qgsdecorationnortharrow.h index 0a1b934ab09..5e520fe1751 100644 --- a/src/app/qgsdecorationnortharrow.h +++ b/src/app/qgsdecorationnortharrow.h @@ -22,6 +22,7 @@ #include "qgsdecorationitem.h" #include +#include "qgis_app.h" class QAction; class QToolBar; @@ -34,7 +35,7 @@ class APP_EXPORT QgsDecorationNorthArrow: public QgsDecorationItem public: //! Constructor QgsDecorationNorthArrow( QObject* parent = nullptr ); - //! Destructor + virtual ~QgsDecorationNorthArrow(); public slots: diff --git a/src/app/qgsdecorationnortharrowdialog.h b/src/app/qgsdecorationnortharrowdialog.h index b989cc83249..73f1609c026 100644 --- a/src/app/qgsdecorationnortharrowdialog.h +++ b/src/app/qgsdecorationnortharrowdialog.h @@ -13,6 +13,7 @@ #define QGSNORTHARROWPLUGINGUI_H #include "ui_qgsdecorationnortharrowdialog.h" +#include "qgis_app.h" class QgsDecorationNorthArrow; diff --git a/src/app/qgsdecorationscalebar.h b/src/app/qgsdecorationscalebar.h index 1121824d31a..2f1e3573c9a 100644 --- a/src/app/qgsdecorationscalebar.h +++ b/src/app/qgsdecorationscalebar.h @@ -27,6 +27,7 @@ email : sbr00pwb@users.sourceforge.net class QPainter; #include +#include "qgis_app.h" class APP_EXPORT QgsDecorationScaleBar: public QgsDecorationItem { @@ -34,7 +35,7 @@ class APP_EXPORT QgsDecorationScaleBar: public QgsDecorationItem public: //! Constructor QgsDecorationScaleBar( QObject* parent = nullptr ); - //! Destructor + virtual ~ QgsDecorationScaleBar(); public slots: diff --git a/src/app/qgsdecorationscalebardialog.h b/src/app/qgsdecorationscalebardialog.h index c06c01a8427..7069adac9b8 100644 --- a/src/app/qgsdecorationscalebardialog.h +++ b/src/app/qgsdecorationscalebardialog.h @@ -14,6 +14,7 @@ #include "ui_qgsdecorationscalebardialog.h" #include +#include "qgis_app.h" class QgsDecorationScaleBar; diff --git a/src/app/qgsdelattrdialog.h b/src/app/qgsdelattrdialog.h index b6ddf6ecfa8..188a73aed36 100644 --- a/src/app/qgsdelattrdialog.h +++ b/src/app/qgsdelattrdialog.h @@ -21,6 +21,7 @@ #include "ui_qgsdelattrdialogbase.h" #include #include +#include "qgis_app.h" class QgsVectorLayer; diff --git a/src/app/qgsdiagramproperties.cpp b/src/app/qgsdiagramproperties.cpp index 1edc9545a90..20904fabea6 100644 --- a/src/app/qgsdiagramproperties.cpp +++ b/src/app/qgsdiagramproperties.cpp @@ -47,7 +47,7 @@ QgsExpressionContext QgsDiagramProperties::createExpressionContext() const { QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ) << QgsExpressionContextUtils::mapSettingsScope( mMapCanvas->mapSettings() ) << QgsExpressionContextUtils::layerScope( mLayer ); @@ -370,7 +370,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare } else { - mSizeFieldExpressionWidget->setField( mLayer->fields().at( lidr->classificationAttribute() ).name() ); + mSizeFieldExpressionWidget->setField( lidr->classificationField() ); } } } @@ -379,15 +379,15 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare if ( dls ) { mDiagramDistanceSpinBox->setValue( dls->distance() ); - mPrioritySlider->setValue( dls->getPriority() ); - mZIndexSpinBox->setValue( dls->getZIndex() ); + mPrioritySlider->setValue( dls->priority() ); + mZIndexSpinBox->setValue( dls->zIndex() ); mDataDefinedXComboBox->setCurrentIndex( mDataDefinedXComboBox->findData( dls->xPosColumn ) ); mDataDefinedYComboBox->setCurrentIndex( mDataDefinedYComboBox->findData( dls->yPosColumn ) ); if ( dls->xPosColumn != -1 || dls->yPosColumn != -1 ) { mDataDefinedPositionGroupBox->setChecked( true ); } - mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( dls->getPlacement() ) ); + mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( dls->placement() ) ); chkLineAbove->setChecked( dls->linePlacementFlags() & QgsDiagramLayerSettings::AboveLine ); chkLineBelow->setChecked( dls->linePlacementFlags() & QgsDiagramLayerSettings::BelowLine ); @@ -571,7 +571,7 @@ void QgsDiagramProperties::on_mFindMaximumValueButton_clicked() QgsExpression exp( sizeFieldNameOrExp ); QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::mapSettingsScope( mMapCanvas->mapSettings() ) << QgsExpressionContextUtils::layerScope( mLayer ); @@ -801,8 +801,7 @@ void QgsDiagramProperties::apply() } else { - int attributeNumber = mLayer->fields().lookupField( sizeFieldNameOrExp ); - dr->setClassificationAttribute( attributeNumber ); + dr->setClassificationField( sizeFieldNameOrExp ); } dr->setDiagramSettings( ds ); renderer = dr; @@ -838,7 +837,7 @@ void QgsDiagramProperties::apply() } dls.setPlacement(( QgsDiagramLayerSettings::Placement )mPlacementComboBox->currentData().toInt() ); - unsigned int flags = 0; + QgsDiagramLayerSettings::LinePlacementFlags flags = 0; if ( chkLineAbove->isChecked() ) flags |= QgsDiagramLayerSettings::AboveLine; if ( chkLineBelow->isChecked() ) @@ -860,7 +859,7 @@ QString QgsDiagramProperties::showExpressionBuilder( const QString& initialExpre { QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ) << QgsExpressionContextUtils::mapSettingsScope( mMapCanvas->mapSettings() ) << QgsExpressionContextUtils::layerScope( mLayer ); diff --git a/src/app/qgsdiagramproperties.h b/src/app/qgsdiagramproperties.h index 5bc297e0674..429a3b7c547 100644 --- a/src/app/qgsdiagramproperties.h +++ b/src/app/qgsdiagramproperties.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_app.h" class QgsVectorLayer; class QgsMapCanvas; diff --git a/src/app/qgsdiscoverrelationsdlg.h b/src/app/qgsdiscoverrelationsdlg.h index b890b524e12..ce9dbb69f13 100644 --- a/src/app/qgsdiscoverrelationsdlg.h +++ b/src/app/qgsdiscoverrelationsdlg.h @@ -18,6 +18,7 @@ #include #include "ui_qgsdiscoverrelationsdlgbase.h" #include "qgsrelation.h" +#include "qgis_app.h" class QgsRelationManager; class QgsVectorLayer; diff --git a/src/app/qgsdisplayangle.h b/src/app/qgsdisplayangle.h index f0047a4b504..66e25bd0604 100644 --- a/src/app/qgsdisplayangle.h +++ b/src/app/qgsdisplayangle.h @@ -17,6 +17,7 @@ #define QGSDISPLAYANGLE_H #include "ui_qgsdisplayanglebase.h" +#include "qgis_app.h" class QgsMapToolMeasureAngle; diff --git a/src/app/qgsfeatureaction.h b/src/app/qgsfeatureaction.h index 6f9688ad3bb..606a95a674c 100644 --- a/src/app/qgsfeatureaction.h +++ b/src/app/qgsfeatureaction.h @@ -23,6 +23,7 @@ #include #include #include +#include "qgis_app.h" class QgsIdentifyResultsDialog; class QgsVectorLayer; diff --git a/src/app/qgsfieldcalculator.cpp b/src/app/qgsfieldcalculator.cpp index 3c5453ba8c4..012c3f9b684 100644 --- a/src/app/qgsfieldcalculator.cpp +++ b/src/app/qgsfieldcalculator.cpp @@ -39,10 +39,7 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl, QWidget* parent ) return; - QgsExpressionContext expContext; - expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mVectorLayer ); + QgsExpressionContext expContext( QgsExpressionContextUtils::globalProjectLayerScopes( mVectorLayer ) ); expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "row_number" ), 1, true ) ); expContext.setHighlightedVariables( QStringList() << QStringLiteral( "row_number" ) ); @@ -168,10 +165,7 @@ void QgsFieldCalculator::accept() exp.setDistanceUnits( QgsProject::instance()->distanceUnits() ); exp.setAreaUnits( QgsProject::instance()->areaUnits() ); - QgsExpressionContext expContext; - expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mVectorLayer ); + QgsExpressionContext expContext( QgsExpressionContextUtils::globalProjectLayerScopes( mVectorLayer ) ); if ( !exp.prepare( &expContext ) ) { @@ -455,6 +449,7 @@ void QgsFieldCalculator::populateFields() font.setItalic( true ); mExistingFieldComboBox->setItemData( mExistingFieldComboBox->count() - 1, font, Qt::FontRole ); } + mExistingFieldComboBox->setCurrentIndex( -1 ); } void QgsFieldCalculator::setOkButtonState() diff --git a/src/app/qgsfieldcalculator.h b/src/app/qgsfieldcalculator.h index 54936d9d6f3..7a270f620a8 100644 --- a/src/app/qgsfieldcalculator.h +++ b/src/app/qgsfieldcalculator.h @@ -19,6 +19,7 @@ #include "ui_qgsfieldcalculatorbase.h" #include "qgscontexthelp.h" #include "qgsfields.h" +#include "qgis_app.h" class QgsVectorLayer; diff --git a/src/app/qgsfieldsproperties.cpp b/src/app/qgsfieldsproperties.cpp index 22f1eef3681..659ef9626db 100644 --- a/src/app/qgsfieldsproperties.cpp +++ b/src/app/qgsfieldsproperties.cpp @@ -841,7 +841,7 @@ void QgsFieldsProperties::updateExpression() QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope(); + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ); QgsExpressionBuilderDialog dlg( mLayer, exp, nullptr, QStringLiteral( "generic" ), context ); diff --git a/src/app/qgsfieldsproperties.h b/src/app/qgsfieldsproperties.h index 5bcddab6a59..0cb075ee43c 100644 --- a/src/app/qgsfieldsproperties.h +++ b/src/app/qgsfieldsproperties.h @@ -26,6 +26,7 @@ #include "qgsvectorlayer.h" #include "ui_qgsfieldspropertiesbase.h" +#include "qgis_app.h" class DesignerTree; class DragList; diff --git a/src/app/qgsformannotationdialog.h b/src/app/qgsformannotationdialog.h index 8f8ff5854b2..114c9389437 100644 --- a/src/app/qgsformannotationdialog.h +++ b/src/app/qgsformannotationdialog.h @@ -16,6 +16,7 @@ #define QGSFORMANNOTATIONDIALOG_H #include "ui_qgsformannotationdialogbase.h" +#include "qgis_app.h" class QgsAnnotationWidget; class QgsFormAnnotationItem; diff --git a/src/app/qgshandlebadlayers.cpp b/src/app/qgshandlebadlayers.cpp index daf56b84dbe..42e70c48273 100644 --- a/src/app/qgshandlebadlayers.cpp +++ b/src/app/qgshandlebadlayers.cpp @@ -369,7 +369,7 @@ void QgsHandleBadLayers::apply() QString datasource = item->text(); node.namedItem( QStringLiteral( "datasource" ) ).toElement().firstChild().toText().setData( datasource ); - if ( QgsProject::instance()->read( node ) ) + if ( QgsProject::instance()->readLayer( node ) ) { mLayerList->removeRow( i-- ); } diff --git a/src/app/qgshandlebadlayers.h b/src/app/qgshandlebadlayers.h index c2aeaed5643..f59f37b6365 100644 --- a/src/app/qgshandlebadlayers.h +++ b/src/app/qgshandlebadlayers.h @@ -20,6 +20,7 @@ #include "ui_qgshandlebadlayersbase.h" #include "qgsproject.h" #include "qgsprojectbadlayerhandler.h" +#include "qgis_app.h" class APP_EXPORT QgsHandleBadLayersHandler : public QObject diff --git a/src/app/qgshtmlannotationdialog.h b/src/app/qgshtmlannotationdialog.h index d520cf9c2a1..eabb361335b 100644 --- a/src/app/qgshtmlannotationdialog.h +++ b/src/app/qgshtmlannotationdialog.h @@ -16,6 +16,7 @@ #define QgsHTMLAnnotationDialog_H #include "ui_qgsformannotationdialogbase.h" +#include "qgis_app.h" class QgsAnnotationWidget; class QgsHtmlAnnotationItem; diff --git a/src/app/qgsidentifyresultsdialog.cpp b/src/app/qgsidentifyresultsdialog.cpp index 04bea1b48a7..347cedc8e92 100644 --- a/src/app/qgsidentifyresultsdialog.cpp +++ b/src/app/qgsidentifyresultsdialog.cpp @@ -201,7 +201,7 @@ QgsWebView *QgsIdentifyResultsWebView::createWindow( QWebPage::WebWindowType typ // loaded and contentsSizeChanged () is emitted. // // 3) If QgsIdentifyResultsWebView is resized (on page load) after it was inserted into -// QTreeWidget, the row does not reflect that change automaticaly and +// QTreeWidget, the row does not reflect that change automatically and // consecutive resize of QTreeWidget will cause to shrink QgsIdentifyResultsWebView to the // original row height. That is expected, Qt: "setItemWidget() should only // be used to display static content... => we must not change QgsIdentifyResultsWebView @@ -587,10 +587,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat if ( !featureLabeled ) { featItem->setText( 0, tr( "Title" ) ); - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( vlayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( vlayer ) ); context.setFeature( f ); QString value = QgsExpression( vlayer->displayExpression() ).evaluate( &context ).toString(); diff --git a/src/app/qgsidentifyresultsdialog.h b/src/app/qgsidentifyresultsdialog.h index bc7cfac356e..3ecb79056b4 100644 --- a/src/app/qgsidentifyresultsdialog.h +++ b/src/app/qgsidentifyresultsdialog.h @@ -31,6 +31,7 @@ #include #include #include +#include "qgis_app.h" class QCloseEvent; class QTreeWidgetItem; @@ -110,11 +111,12 @@ class APP_EXPORT QgsIdentifyPlotCurve QwtPlot* plot, const QString &title = QString(), QColor color = QColor() ); ~QgsIdentifyPlotCurve(); + QgsIdentifyPlotCurve( const QgsIdentifyPlotCurve& rh ) = delete; + QgsIdentifyPlotCurve& operator=( const QgsIdentifyPlotCurve& rh ) = delete; + private: QwtPlotCurve* mPlotCurve; - QgsIdentifyPlotCurve( const QgsIdentifyPlotCurve& rh ); - QgsIdentifyPlotCurve& operator=( const QgsIdentifyPlotCurve& rh ); }; class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdentifyResultsBase diff --git a/src/app/qgsjoindialog.h b/src/app/qgsjoindialog.h index b80e3636c5b..0086535a13b 100644 --- a/src/app/qgsjoindialog.h +++ b/src/app/qgsjoindialog.h @@ -19,6 +19,7 @@ #define QgsJoinDIALOG_H #include "ui_qgsjoindialogbase.h" +#include "qgis_app.h" class QgsVectorLayer; struct QgsVectorJoinInfo; diff --git a/src/app/qgslabelengineconfigdialog.h b/src/app/qgslabelengineconfigdialog.h index 79d42a047ba..1705fe8d590 100644 --- a/src/app/qgslabelengineconfigdialog.h +++ b/src/app/qgslabelengineconfigdialog.h @@ -18,6 +18,7 @@ #include #include "ui_qgsengineconfigdialog.h" +#include "qgis_app.h" class APP_EXPORT QgsLabelEngineConfigDialog : public QDialog, private Ui::QgsEngineConfigDialog diff --git a/src/app/qgslabelinggui.cpp b/src/app/qgslabelinggui.cpp index 3fbed4d5f90..a52bc44e3a5 100644 --- a/src/app/qgslabelinggui.cpp +++ b/src/app/qgslabelinggui.cpp @@ -26,7 +26,7 @@ QgsExpressionContext QgsLabelingGui::createExpressionContext() const { QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ) << QgsExpressionContextUtils::mapSettingsScope( QgisApp::instance()->mapCanvas()->mapSettings() ); diff --git a/src/app/qgslabelinggui.h b/src/app/qgslabelinggui.h index a4671b1ed21..d5e745e54f3 100644 --- a/src/app/qgslabelinggui.h +++ b/src/app/qgslabelinggui.h @@ -20,6 +20,7 @@ #include "qgspallabeling.h" #include "qgstextformatwidget.h" +#include "qgis_app.h" class APP_EXPORT QgsLabelingGui : public QgsTextFormatWidget, private QgsExpressionContextGenerator { diff --git a/src/app/qgslabelpropertydialog.cpp b/src/app/qgslabelpropertydialog.cpp index 45fd2cfb45d..1e4617fadbc 100644 --- a/src/app/qgslabelpropertydialog.cpp +++ b/src/app/qgslabelpropertydialog.cpp @@ -223,7 +223,7 @@ void QgsLabelPropertyDialog::setDataDefinedValues( const QgsPalLayerSettings &la QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ) << QgsExpressionContextUtils::mapSettingsScope( QgisApp::instance()->mapCanvas()->mapSettings() ) << QgsExpressionContextUtils::layerScope( vlayer ); diff --git a/src/app/qgslabelpropertydialog.h b/src/app/qgslabelpropertydialog.h index 2aa3279021c..45d227d570d 100644 --- a/src/app/qgslabelpropertydialog.h +++ b/src/app/qgslabelpropertydialog.h @@ -22,6 +22,7 @@ #include "qgsfeature.h" #include "qgspallabeling.h" #include +#include "qgis_app.h" //! A dialog to enter data defined label attributes diff --git a/src/app/qgslayerstylingwidget.cpp b/src/app/qgslayerstylingwidget.cpp index 19afa865ce6..7e22e63f8a4 100644 --- a/src/app/qgslayerstylingwidget.cpp +++ b/src/app/qgslayerstylingwidget.cpp @@ -241,7 +241,7 @@ void QgsLayerStylingWidget::apply() { widget->apply(); QgsVectorLayer* layer = qobject_cast( mCurrentLayer ); - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( layer->renderer()->type() ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( layer->renderer()->type() ); undoName = QStringLiteral( "Style Change - %1" ).arg( m->visibleName() ); styleWasChanged = true; } diff --git a/src/app/qgslayerstylingwidget.h b/src/app/qgslayerstylingwidget.h index b16d2deee28..3273ae5bbfc 100644 --- a/src/app/qgslayerstylingwidget.h +++ b/src/app/qgslayerstylingwidget.h @@ -29,6 +29,7 @@ #include "ui_qgsmapstylingwidgetbase.h" #include "qgsmaplayerconfigwidgetfactory.h" +#include "qgis_app.h" class QgsLabelingWidget; class QgsMapLayer; diff --git a/src/app/qgsloadstylefromdbdialog.h b/src/app/qgsloadstylefromdbdialog.h index f81af253a2e..e5b20b12231 100644 --- a/src/app/qgsloadstylefromdbdialog.h +++ b/src/app/qgsloadstylefromdbdialog.h @@ -18,6 +18,7 @@ #include "ui_qgsloadstylefromdbdialog.h" #include "qgisgui.h" +#include "qgis_app.h" class APP_EXPORT QgsLoadStyleFromDBDialog : public QDialog, private Ui::QgsLoadStyleFromDBDialogLayout { diff --git a/src/app/qgsmapthemes.cpp b/src/app/qgsmapthemes.cpp index 179ba0654e0..1374cec68f3 100644 --- a/src/app/qgsmapthemes.cpp +++ b/src/app/qgsmapthemes.cpp @@ -42,6 +42,7 @@ QgsMapThemes::QgsMapThemes() mMenu->addAction( QgisApp::instance()->actionHideAllLayers() ); mMenu->addAction( QgisApp::instance()->actionShowSelectedLayers() ); mMenu->addAction( QgisApp::instance()->actionHideSelectedLayers() ); + mMenu->addAction( QgisApp::instance()->actionHideDeselectedLayers() ); mMenu->addSeparator(); mReplaceMenu = new QMenu( tr( "Replace Theme" ) ); diff --git a/src/app/qgsmapthemes.h b/src/app/qgsmapthemes.h index c63ee065fef..5f0d7203e67 100644 --- a/src/app/qgsmapthemes.h +++ b/src/app/qgsmapthemes.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_app.h" class QAction; class QDomDocument; diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp index af3de0da71a..298f77a993f 100644 --- a/src/app/qgsmaptooladdfeature.cpp +++ b/src/app/qgsmaptooladdfeature.cpp @@ -273,7 +273,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e ) delete g; QgsGeometry featGeom = f->geometry(); - int avoidIntersectionsReturn = featGeom.avoidIntersections(); + int avoidIntersectionsReturn = featGeom.avoidIntersections( QgsProject::instance()->avoidIntersectionsLayers() ); f->setGeometry( featGeom ); if ( avoidIntersectionsReturn == 1 ) { @@ -295,17 +295,14 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e ) //use always topological editing for avoidIntersection. //Otherwise, no way to guarantee the geometries don't have a small gap in between. - QStringList intersectionLayers = QgsProject::instance()->avoidIntersectionsList(); + QList intersectionLayers = QgsProject::instance()->avoidIntersectionsLayers(); bool avoidIntersection = !intersectionLayers.isEmpty(); if ( avoidIntersection ) //try to add topological points also to background layers { - QStringList::const_iterator lIt = intersectionLayers.constBegin(); - for ( ; lIt != intersectionLayers.constEnd(); ++lIt ) + Q_FOREACH ( QgsVectorLayer* vl, intersectionLayers ) { - QgsMapLayer* ml = QgsProject::instance()->mapLayer( *lIt ); - QgsVectorLayer* vl = qobject_cast( ml ); //can only add topological points if background layer is editable... - if ( vl && vl->geometryType() == QgsWkbTypes::PolygonGeometry && vl->isEditable() ) + if ( vl->geometryType() == QgsWkbTypes::PolygonGeometry && vl->isEditable() ) { vl->addTopologicalPoints( f->geometry() ); } diff --git a/src/app/qgsmaptooladdfeature.h b/src/app/qgsmaptooladdfeature.h index 86c944aa329..ce5035bf987 100644 --- a/src/app/qgsmaptooladdfeature.h +++ b/src/app/qgsmaptooladdfeature.h @@ -14,6 +14,7 @@ ***************************************************************************/ #include "qgsmaptoolcapture.h" +#include "qgis_app.h" //! This tool adds new point/line/polygon features to already existing vector layers class APP_EXPORT QgsMapToolAddFeature : public QgsMapToolCapture diff --git a/src/app/qgsmaptooladdpart.cpp b/src/app/qgsmaptooladdpart.cpp index 7b65e40bdb5..adeb79da0d8 100644 --- a/src/app/qgsmaptooladdpart.cpp +++ b/src/app/qgsmaptooladdpart.cpp @@ -149,7 +149,7 @@ void QgsMapToolAddPart::cadCanvasReleaseEvent( QgsMapMouseEvent * e ) QgsCurvePolygon* cp = new QgsCurvePolygon(); cp->setExteriorRing( curveToAdd ); QgsGeometry* geom = new QgsGeometry( cp ); - geom->avoidIntersections(); + geom->avoidIntersections( QgsProject::instance()->avoidIntersectionsLayers() ); const QgsCurvePolygon* cpGeom = dynamic_cast( geom->geometry() ); if ( !cpGeom ) diff --git a/src/app/qgsmaptooladdpart.h b/src/app/qgsmaptooladdpart.h index c9af2e1923a..d935d3fb057 100644 --- a/src/app/qgsmaptooladdpart.h +++ b/src/app/qgsmaptooladdpart.h @@ -14,6 +14,7 @@ ***************************************************************************/ #include "qgsmaptoolcapture.h" +#include "qgis_app.h" //! A map tool that adds new parts to multipart features class APP_EXPORT QgsMapToolAddPart : public QgsMapToolCapture diff --git a/src/app/qgsmaptooladdring.h b/src/app/qgsmaptooladdring.h index 8a21c8a3e60..295138c110f 100644 --- a/src/app/qgsmaptooladdring.h +++ b/src/app/qgsmaptooladdring.h @@ -14,6 +14,7 @@ ***************************************************************************/ #include "qgsmaptoolcapture.h" +#include "qgis_app.h" //! A tool to cut holes into polygons and multipolygon features class APP_EXPORT QgsMapToolAddRing: public QgsMapToolCapture diff --git a/src/app/qgsmaptoolannotation.h b/src/app/qgsmaptoolannotation.h index d94632e8676..0d81dfbba7d 100644 --- a/src/app/qgsmaptoolannotation.h +++ b/src/app/qgsmaptoolannotation.h @@ -20,6 +20,7 @@ #include "qgsmaptool.h" #include "qgsannotationitem.h" +#include "qgis_app.h" class APP_EXPORT QgsMapToolAnnotation: public QgsMapTool { diff --git a/src/app/qgsmaptoolchangelabelproperties.h b/src/app/qgsmaptoolchangelabelproperties.h index e46e9a7567a..c8b1dce6eb7 100644 --- a/src/app/qgsmaptoolchangelabelproperties.h +++ b/src/app/qgsmaptoolchangelabelproperties.h @@ -19,6 +19,7 @@ #define QGSMAPTOOLCHANGELABELPROPERTIES_H #include "qgsmaptoollabel.h" +#include "qgis_app.h" class APP_EXPORT QgsMapToolChangeLabelProperties: public QgsMapToolLabel { diff --git a/src/app/qgsmaptooldeletepart.h b/src/app/qgsmaptooldeletepart.h index efbe76412d1..1feee8debc8 100644 --- a/src/app/qgsmaptooldeletepart.h +++ b/src/app/qgsmaptooldeletepart.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLDELETEPART_H #include "qgsmaptooledit.h" +#include "qgis_app.h" class QgsVertexMarker; diff --git a/src/app/qgsmaptooldeletering.h b/src/app/qgsmaptooldeletering.h index 9281069b116..ae2fc0f7512 100644 --- a/src/app/qgsmaptooldeletering.h +++ b/src/app/qgsmaptooldeletering.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLDELETERING_H #include "qgsmaptooledit.h" +#include "qgis_app.h" class QgsVertexMarker; //! Map tool to delete vertices from line/polygon features diff --git a/src/app/qgsmaptoolfeatureaction.cpp b/src/app/qgsmaptoolfeatureaction.cpp index 0337f347dfd..a0dc4c6ad6c 100644 --- a/src/app/qgsmaptoolfeatureaction.cpp +++ b/src/app/qgsmaptoolfeatureaction.cpp @@ -134,7 +134,7 @@ bool QgsMapToolFeatureAction::doAction( QgsVectorLayer *layer, int x, int y ) // define custom substitutions: layer id and clicked coords QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::mapSettingsScope( mCanvas->mapSettings() ); QgsExpressionContextScope* actionScope = new QgsExpressionContextScope(); actionScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "click_x" ), point.x(), true ) ); diff --git a/src/app/qgsmaptoolfeatureaction.h b/src/app/qgsmaptoolfeatureaction.h index 385e02b2139..377e486e96e 100644 --- a/src/app/qgsmaptoolfeatureaction.h +++ b/src/app/qgsmaptoolfeatureaction.h @@ -21,6 +21,7 @@ #include #include +#include "qgis_app.h" class QgsVectorLayer; diff --git a/src/app/qgsmaptoolfillring.h b/src/app/qgsmaptoolfillring.h index afe01c488ce..3cdf9c36d50 100644 --- a/src/app/qgsmaptoolfillring.h +++ b/src/app/qgsmaptoolfillring.h @@ -15,6 +15,7 @@ ***************************************************************************/ #include "qgsmaptoolcapture.h" +#include "qgis_app.h" /** A tool to cut holes into polygon and multipolygon features and fill them * with new feature. Attributes are copied from parent feature. diff --git a/src/app/qgsmaptoolformannotation.h b/src/app/qgsmaptoolformannotation.h index f7c4dda6aa7..43934c5bbc5 100644 --- a/src/app/qgsmaptoolformannotation.h +++ b/src/app/qgsmaptoolformannotation.h @@ -19,6 +19,7 @@ #define QGSMAPTOOFORMANNOTATION_H #include "qgsmaptoolannotation.h" +#include "qgis_app.h" class APP_EXPORT QgsMapToolFormAnnotation: public QgsMapToolAnnotation { diff --git a/src/app/qgsmaptoolhtmlannotation.h b/src/app/qgsmaptoolhtmlannotation.h index 6f2e465c172..573d53f1c1c 100644 --- a/src/app/qgsmaptoolhtmlannotation.h +++ b/src/app/qgsmaptoolhtmlannotation.h @@ -19,6 +19,7 @@ #define QGSMAPTOOLHTMLANNOTATION_H #include "qgsmaptoolannotation.h" +#include "qgis_app.h" class APP_EXPORT QgsMapToolHtmlAnnotation: public QgsMapToolAnnotation { diff --git a/src/app/qgsmaptoolidentifyaction.h b/src/app/qgsmaptoolidentifyaction.h index 8507891f16c..33bbf4c166b 100644 --- a/src/app/qgsmaptoolidentifyaction.h +++ b/src/app/qgsmaptoolidentifyaction.h @@ -21,6 +21,7 @@ #include #include +#include "qgis_app.h" class QgsIdentifyResultsDialog; class QgsMapLayer; diff --git a/src/app/qgsmaptoollabel.h b/src/app/qgsmaptoollabel.h index 21921acdf18..d7998503d69 100644 --- a/src/app/qgsmaptoollabel.h +++ b/src/app/qgsmaptoollabel.h @@ -20,6 +20,7 @@ #include "qgsmaptool.h" #include "qgspallabeling.h" +#include "qgis_app.h" class QgsRubberBand; diff --git a/src/app/qgsmaptoolmeasureangle.h b/src/app/qgsmaptoolmeasureangle.h index 2b1acd53e40..621872ccc44 100644 --- a/src/app/qgsmaptoolmeasureangle.h +++ b/src/app/qgsmaptoolmeasureangle.h @@ -19,6 +19,7 @@ #include "qgsmaptool.h" #include "qgspoint.h" #include "qgsdistancearea.h" +#include "qgis_app.h" class QgsDisplayAngle; class QgsRubberBand; diff --git a/src/app/qgsmaptoolmovefeature.h b/src/app/qgsmaptoolmovefeature.h index eda9c22712e..bc68abd755c 100644 --- a/src/app/qgsmaptoolmovefeature.h +++ b/src/app/qgsmaptoolmovefeature.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLMOVEFEATURE_H #include "qgsmaptooladvanceddigitizing.h" +#include "qgis_app.h" //! Map tool for translating feature position by mouse drag class APP_EXPORT QgsMapToolMoveFeature: public QgsMapToolAdvancedDigitizing diff --git a/src/app/qgsmaptoolmovelabel.h b/src/app/qgsmaptoolmovelabel.h index 464eb99c4ad..58d072fbedf 100644 --- a/src/app/qgsmaptoolmovelabel.h +++ b/src/app/qgsmaptoolmovelabel.h @@ -19,6 +19,7 @@ #define QGSMAPTOOLMOVELABEL_H #include "qgsmaptoollabel.h" +#include "qgis_app.h" //! A map tool for dragging label positions class APP_EXPORT QgsMapToolMoveLabel: public QgsMapToolLabel diff --git a/src/app/qgsmaptooloffsetcurve.h b/src/app/qgsmaptooloffsetcurve.h index d3b685f021b..29b21215876 100644 --- a/src/app/qgsmaptooloffsetcurve.h +++ b/src/app/qgsmaptooloffsetcurve.h @@ -18,6 +18,7 @@ #include "qgsmaptooledit.h" #include "qgsgeometry.h" +#include "qgis_app.h" class QgsVertexMarker; class QgsDoubleSpinBox; diff --git a/src/app/qgsmaptooloffsetpointsymbol.h b/src/app/qgsmaptooloffsetpointsymbol.h index 62dfa8e6492..2cab37b5042 100644 --- a/src/app/qgsmaptooloffsetpointsymbol.h +++ b/src/app/qgsmaptooloffsetpointsymbol.h @@ -18,6 +18,7 @@ #include "qgsmaptoolpointsymbol.h" #include "qgssymbol.h" +#include "qgis_app.h" class QgsMarkerSymbol; class QgsPointMarkerItem; diff --git a/src/app/qgsmaptoolpinlabels.h b/src/app/qgsmaptoolpinlabels.h index 3a4e4120a5d..b0729a87c89 100644 --- a/src/app/qgsmaptoolpinlabels.h +++ b/src/app/qgsmaptoolpinlabels.h @@ -19,6 +19,7 @@ #define QGSMAPTOOLPINLABELS_H #include "qgsmaptoollabel.h" +#include "qgis_app.h" class QgsRubberBand; class QgsLabelPosition; diff --git a/src/app/qgsmaptoolpointsymbol.h b/src/app/qgsmaptoolpointsymbol.h index 8ac68288965..6c6855d2bbc 100644 --- a/src/app/qgsmaptoolpointsymbol.h +++ b/src/app/qgsmaptoolpointsymbol.h @@ -18,6 +18,7 @@ #include "qgsmaptooledit.h" #include "qgsfeature.h" +#include "qgis_app.h" class QgsMarkerSymbol; diff --git a/src/app/qgsmaptoolreshape.cpp b/src/app/qgsmaptoolreshape.cpp index af02b8bce62..ca1733868d6 100644 --- a/src/app/qgsmaptoolreshape.cpp +++ b/src/app/qgsmaptoolreshape.cpp @@ -17,6 +17,7 @@ #include "qgsfeatureiterator.h" #include "qgsgeometry.h" #include "qgsmapcanvas.h" +#include "qgsproject.h" #include "qgsvectorlayer.h" #include "qgisapp.h" @@ -108,7 +109,7 @@ void QgsMapToolReshape::cadCanvasReleaseEvent( QgsMapMouseEvent * e ) QHash > ignoreFeatures; ignoreFeatures.insert( vlayer, vlayer->allFeatureIds() ); - if ( geom.avoidIntersections( ignoreFeatures ) != 0 ) + if ( geom.avoidIntersections( QgsProject::instance()->avoidIntersectionsLayers(), ignoreFeatures ) != 0 ) { emit messageEmitted( tr( "An error was reported during intersection removal" ), QgsMessageBar::CRITICAL ); vlayer->destroyEditCommand(); diff --git a/src/app/qgsmaptoolreshape.h b/src/app/qgsmaptoolreshape.h index e0d0ebc1212..8ea0f309169 100644 --- a/src/app/qgsmaptoolreshape.h +++ b/src/app/qgsmaptoolreshape.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLRESHAPE_H #include "qgsmaptoolcapture.h" +#include "qgis_app.h" //! A map tool that draws a line and splits the features cut by the line class APP_EXPORT QgsMapToolReshape: public QgsMapToolCapture diff --git a/src/app/qgsmaptoolrotatefeature.h b/src/app/qgsmaptoolrotatefeature.h index 19c479bb667..1b99fcfcda1 100644 --- a/src/app/qgsmaptoolrotatefeature.h +++ b/src/app/qgsmaptoolrotatefeature.h @@ -19,6 +19,7 @@ #include #include "qgsmaptooledit.h" +#include "qgis_app.h" class QgsDoubleSpinBox; class QHBoxLayout; diff --git a/src/app/qgsmaptoolrotatelabel.h b/src/app/qgsmaptoolrotatelabel.h index 06af32172b4..b61a7506a02 100644 --- a/src/app/qgsmaptoolrotatelabel.h +++ b/src/app/qgsmaptoolrotatelabel.h @@ -19,6 +19,7 @@ #define QGSMAPTOOLROTATELABEL_H #include "qgsmaptoollabel.h" +#include "qgis_app.h" class QgsPointRotationItem; class APP_EXPORT QgsMapToolRotateLabel: public QgsMapToolLabel diff --git a/src/app/qgsmaptoolrotatepointsymbols.h b/src/app/qgsmaptoolrotatepointsymbols.h index 087cccc1ca5..dfb0ea6439b 100644 --- a/src/app/qgsmaptoolrotatepointsymbols.h +++ b/src/app/qgsmaptoolrotatepointsymbols.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLROTATEPOINTSYMBOLS_H #include "qgsmaptoolpointsymbol.h" +#include "qgis_app.h" class QgsPointRotationItem; class QgsMarkerSymbol; diff --git a/src/app/qgsmaptoolselect.h b/src/app/qgsmaptoolselect.h index e3cb869ff8e..aad655bf10a 100644 --- a/src/app/qgsmaptoolselect.h +++ b/src/app/qgsmaptoolselect.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLSELECT_H #include "qgsmaptool.h" +#include "qgis_app.h" class QgsMapCanvas; class QMouseEvent; diff --git a/src/app/qgsmaptoolselectfreehand.h b/src/app/qgsmaptoolselectfreehand.h index 45776865c75..5cddce45bf8 100644 --- a/src/app/qgsmaptoolselectfreehand.h +++ b/src/app/qgsmaptoolselectfreehand.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLSELECTFREEHAND_H #include "qgsmaptool.h" +#include "qgis_app.h" class QgsMapCanvas; class QgsRubberBand; diff --git a/src/app/qgsmaptoolselectpolygon.h b/src/app/qgsmaptoolselectpolygon.h index 0ef804427f4..d0415fe893f 100644 --- a/src/app/qgsmaptoolselectpolygon.h +++ b/src/app/qgsmaptoolselectpolygon.h @@ -17,6 +17,7 @@ email : jpalmer at linz dot govt dot nz #define QGSMAPTOOLSELECTPOLYGON_H #include "qgsmaptool.h" +#include "qgis_app.h" class QgsMapCanvas; class QgsRubberBand; diff --git a/src/app/qgsmaptoolselectradius.h b/src/app/qgsmaptoolselectradius.h index fa0fb1f59ad..61f101865c8 100644 --- a/src/app/qgsmaptoolselectradius.h +++ b/src/app/qgsmaptoolselectradius.h @@ -19,6 +19,7 @@ email : jpalmer at linz dot govt dot nz #include "qgsmaptool.h" #include "qgspoint.h" +#include "qgis_app.h" class QgsMapCanvas; class QgsRubberBand; diff --git a/src/app/qgsmaptoolselectrectangle.h b/src/app/qgsmaptoolselectrectangle.h index 269fc4868d9..cfc35096100 100644 --- a/src/app/qgsmaptoolselectrectangle.h +++ b/src/app/qgsmaptoolselectrectangle.h @@ -19,6 +19,7 @@ #include #include "qgsmaptool.h" +#include "qgis_app.h" class QPoint; class QMouseEvent; diff --git a/src/app/qgsmaptoolshowhidelabels.h b/src/app/qgsmaptoolshowhidelabels.h index 25cc468d8a0..0677d38c04f 100644 --- a/src/app/qgsmaptoolshowhidelabels.h +++ b/src/app/qgsmaptoolshowhidelabels.h @@ -20,6 +20,7 @@ #include "qgsmaptoollabel.h" #include "qgsfeature.h" +#include "qgis_app.h" //! A map tool for showing or hidding a feature's label diff --git a/src/app/qgsmaptoolsimplify.h b/src/app/qgsmaptoolsimplify.h index d3b83c6382a..96ae196699e 100644 --- a/src/app/qgsmaptoolsimplify.h +++ b/src/app/qgsmaptoolsimplify.h @@ -22,6 +22,7 @@ #include #include "qgsfeature.h" #include "qgstolerance.h" +#include "qgis_app.h" class QgsRubberBand; class QgsMapToolSimplify; diff --git a/src/app/qgsmaptoolsplitfeatures.h b/src/app/qgsmaptoolsplitfeatures.h index 249df5a6562..1d528acd4a5 100644 --- a/src/app/qgsmaptoolsplitfeatures.h +++ b/src/app/qgsmaptoolsplitfeatures.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLSPLITFEATURES_H #include "qgsmaptoolcapture.h" +#include "qgis_app.h" //! A map tool that draws a line and splits the features cut by the line class APP_EXPORT QgsMapToolSplitFeatures: public QgsMapToolCapture diff --git a/src/app/qgsmaptoolsvgannotation.h b/src/app/qgsmaptoolsvgannotation.h index 061a72ad2de..2e5103f4485 100644 --- a/src/app/qgsmaptoolsvgannotation.h +++ b/src/app/qgsmaptoolsvgannotation.h @@ -19,6 +19,7 @@ #define QGSMAPTOOLSVGANNOTATION_H #include "qgsmaptoolannotation.h" +#include "qgis_app.h" class APP_EXPORT QgsMapToolSvgAnnotation: public QgsMapToolAnnotation { diff --git a/src/app/qgsmaptooltextannotation.h b/src/app/qgsmaptooltextannotation.h index 6f485dc21fd..27fb66109e9 100644 --- a/src/app/qgsmaptooltextannotation.h +++ b/src/app/qgsmaptooltextannotation.h @@ -19,6 +19,7 @@ #define QGSMAPTOOLTEXTANNOTATION_H #include "qgsmaptoolannotation.h" +#include "qgis_app.h" class APP_EXPORT QgsMapToolTextAnnotation: public QgsMapToolAnnotation { diff --git a/src/app/qgsmeasuredialog.cpp b/src/app/qgsmeasuredialog.cpp index 361af14f3d7..332efd68613 100644 --- a/src/app/qgsmeasuredialog.cpp +++ b/src/app/qgsmeasuredialog.cpp @@ -348,7 +348,7 @@ void QgsMeasureDialog::updateUi() QgsUnitTypes::unitType( mAreaUnits ) == QgsUnitTypes::Standard ) { // only shown if both conditions are true: - // - the display unit is a standard distance measurement (eg square feet) + // - the display unit is a standard distance measurement (e.g., square feet) // - either the canvas units is also a standard distance OR we are using an ellipsoid (in which case the // value will be in square meters) toolTip += "
    * " + tr( "The value is converted from %1 to %2." ).arg( QgsUnitTypes::toString( resultUnit ), @@ -422,7 +422,7 @@ void QgsMeasureDialog::updateUi() QgsUnitTypes::unitType( mDistanceUnits ) == QgsUnitTypes::Standard ) { // only shown if both conditions are true: - // - the display unit is a standard distance measurement (eg feet) + // - the display unit is a standard distance measurement (e.g., feet) // - either the canvas units is also a standard distance OR we are using an ellipsoid (in which case the // value will be in meters) toolTip += "
    * " + tr( "The value is converted from %1 to %2." ).arg( QgsUnitTypes::toString( resultUnit ), diff --git a/src/app/qgsmeasuredialog.h b/src/app/qgsmeasuredialog.h index 0cbc2684b08..620aeecc7f9 100644 --- a/src/app/qgsmeasuredialog.h +++ b/src/app/qgsmeasuredialog.h @@ -22,6 +22,7 @@ #include "qgspoint.h" #include "qgsdistancearea.h" #include "qgscontexthelp.h" +#include "qgis_app.h" class QCloseEvent; class QgsMeasureTool; diff --git a/src/app/qgsmeasuretool.h b/src/app/qgsmeasuretool.h index ca35cb8bd06..4f31922462b 100644 --- a/src/app/qgsmeasuretool.h +++ b/src/app/qgsmeasuretool.h @@ -18,6 +18,7 @@ #define QGSMEASURETOOL_H #include "qgsmaptool.h" +#include "qgis_app.h" class QgsDistanceArea; class QgsMapCanvas; diff --git a/src/app/qgsmergeattributesdialog.cpp b/src/app/qgsmergeattributesdialog.cpp index 23b4d21cd3d..c8a80c81103 100644 --- a/src/app/qgsmergeattributesdialog.cpp +++ b/src/app/qgsmergeattributesdialog.cpp @@ -367,7 +367,8 @@ QVariant QgsMergeAttributesDialog::calcStatistic( int col, QgsStatisticalSummary summary.calculate( values ); - return QVariant::fromValue( summary.statistic( stat ) ); + double val = summary.statistic( stat ); + return qIsNaN( val ) ? QVariant( QVariant::Double ) : val; } QVariant QgsMergeAttributesDialog::concatenationAttribute( int col ) diff --git a/src/app/qgsmergeattributesdialog.h b/src/app/qgsmergeattributesdialog.h index 82338ee8903..7d79d26d364 100644 --- a/src/app/qgsmergeattributesdialog.h +++ b/src/app/qgsmergeattributesdialog.h @@ -23,6 +23,7 @@ #include "qgsfeature.h" #include "qgsstatisticalsummary.h" #include "qgsfields.h" +#include "qgis_app.h" class QgsMapCanvas; class QgsRubberBand; @@ -47,7 +48,7 @@ class APP_EXPORT QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeA QgsAttributes mergedAttributes() const; - /** Returns a list of attribute indexes which should be skipped when merging (eg, attributes + /** Returns a list of attribute indexes which should be skipped when merging (e.g., attributes * which have been set to "skip" */ QSet skippedAttributeIndexes() const; diff --git a/src/app/qgsnewspatialitelayerdialog.h b/src/app/qgsnewspatialitelayerdialog.h index d1f6dacf3c0..8417b90aa8b 100644 --- a/src/app/qgsnewspatialitelayerdialog.h +++ b/src/app/qgsnewspatialitelayerdialog.h @@ -27,6 +27,7 @@ extern "C" { #include #include +#include "qgis_app.h" } class APP_EXPORT QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNewSpatialiteLayerDialogBase diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index 82a223b44f4..2eb9668427f 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -138,7 +138,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) mRemoveCustomVarBtn->setEnabled( false ); mCustomVariablesTable->setEnabled( false ); } - QStringList customVarsList = mSettings->value( QStringLiteral( "qgis/customEnvVars" ), "" ).toStringList(); + QStringList customVarsList = mSettings->value( QStringLiteral( "qgis/customEnvVars" ) ).toStringList(); Q_FOREACH ( const QString &varStr, customVarsList ) { int pos = varStr.indexOf( QLatin1Char( '|' ) ); @@ -221,25 +221,20 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) mCurrentVariablesTable->resizeColumnToContents( 0 ); //local directories to search when loading c++ plugins - QString myPaths = mSettings->value( QStringLiteral( "plugins/searchPathsForPlugins" ), "" ).toString(); - if ( !myPaths.isEmpty() ) + QStringList pathList = mSettings->value( QStringLiteral( "plugins/searchPathsForPlugins" ) ).toStringList(); + Q_FOREACH ( const QString& path, pathList ) { - QStringList myPathList = myPaths.split( '|' ); - QStringList::const_iterator pathIt = myPathList.constBegin(); - for ( ; pathIt != myPathList.constEnd(); ++pathIt ) - { - QListWidgetItem* newItem = new QListWidgetItem( mListPluginPaths ); - newItem->setText( *pathIt ); - newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); - mListPluginPaths->addItem( newItem ); - } + QListWidgetItem* newItem = new QListWidgetItem( mListPluginPaths ); + newItem->setText( path ); + newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); + mListPluginPaths->addItem( newItem ); } //local directories to search when looking for an SVG with a given basename - QStringList svgPaths = QgsApplication::svgPaths(); - if ( !svgPaths.isEmpty() ) + pathList = QgsApplication::svgPaths(); + if ( !pathList.isEmpty() ) { - Q_FOREACH ( const QString& path, svgPaths ) + Q_FOREACH ( const QString& path, pathList ) { QListWidgetItem* newItem = new QListWidgetItem( mListSVGPaths ); newItem->setText( path ); @@ -248,10 +243,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) } } - QStringList templatePaths = QgsApplication::composerTemplatePaths(); - if ( !templatePaths.isEmpty() ) + //local directories to search when looking for a composer templates + pathList = QgsApplication::composerTemplatePaths(); + if ( !pathList.isEmpty() ) { - Q_FOREACH ( const QString& path, templatePaths ) + Q_FOREACH ( const QString& path, pathList ) { QListWidgetItem* newItem = new QListWidgetItem( mListComposerTemplatePaths ); newItem->setText( path ); @@ -260,13 +256,12 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) } } - QStringList hiddenItems = mSettings->value( QStringLiteral( "/browser/hiddenPaths" ), - QStringList() ).toStringList(); - QStringList::const_iterator pathIt = hiddenItems.constBegin(); - for ( ; pathIt != hiddenItems.constEnd(); ++pathIt ) + //paths hidden from browser + pathList = mSettings->value( QStringLiteral( "/browser/hiddenPaths" ) ).toStringList(); + Q_FOREACH ( const QString& path, pathList ) { QListWidgetItem* newItem = new QListWidgetItem( mListHiddenBrowserPaths ); - newItem->setText( *pathIt ); + newItem->setText( path ); mListHiddenBrowserPaths->addItem( newItem ); } @@ -300,18 +295,13 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) mProxyTypeComboBox->setCurrentIndex( mProxyTypeComboBox->findText( settingProxyType ) ); //URLs excluded not going through proxies - QString proxyExcludedURLs = mSettings->value( QStringLiteral( "proxy/proxyExcludedUrls" ), "" ).toString(); - if ( !proxyExcludedURLs.isEmpty() ) + pathList = mSettings->value( QStringLiteral( "proxy/proxyExcludedUrls" ) ).toStringList(); + Q_FOREACH ( const QString& path, pathList ) { - QStringList splitUrls = proxyExcludedURLs.split( '|' ); - QStringList::const_iterator urlIt = splitUrls.constBegin(); - for ( ; urlIt != splitUrls.constEnd(); ++urlIt ) - { - QListWidgetItem* newItem = new QListWidgetItem( mExcludeUrlListWidget ); - newItem->setText( *urlIt ); - newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); - mExcludeUrlListWidget->addItem( newItem ); - } + QListWidgetItem* newItem = new QListWidgetItem( mExcludeUrlListWidget ); + newItem->setText( path ); + newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); + mExcludeUrlListWidget->addItem( newItem ); } // cache settings @@ -703,7 +693,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) pbnMeasureColor->setContext( QStringLiteral( "gui" ) ); pbnMeasureColor->setDefaultColor( QColor( 222, 155, 67 ) ); - capitaliseCheckBox->setChecked( mSettings->value( QStringLiteral( "/qgis/capitaliseLayerName" ), QVariant( false ) ).toBool() ); + capitalizeCheckBox->setChecked( mSettings->value( QStringLiteral( "/qgis/capitalizeLayerName" ), QVariant( false ) ).toBool() ); int projOpen = mSettings->value( QStringLiteral( "/qgis/projOpenAtLaunch" ), 0 ).toInt(); mProjectOnLaunchCmbBx->setCurrentIndex( projOpen ); @@ -731,7 +721,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) spinZoomFactor->setValue( mSettings->value( QStringLiteral( "/qgis/zoom_factor" ), 2 ).toDouble() ); // predefined scales for scale combobox - myPaths = mSettings->value( QStringLiteral( "Map/scales" ), PROJECT_SCALES ).toString(); + QString myPaths = mSettings->value( QStringLiteral( "Map/scales" ), PROJECT_SCALES ).toString(); if ( !myPaths.isEmpty() ) { QStringList myScalesList = myPaths.split( ',' ); @@ -753,7 +743,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) //find custom color scheme from registry QList customSchemes; - QgsColorSchemeRegistry::instance()->schemes( customSchemes ); + QgsApplication::colorSchemeRegistry()->schemes( customSchemes ); if ( customSchemes.length() > 0 ) { mTreeCustomColors->setScheme( customSchemes.at( 0 ) ); @@ -826,7 +816,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) QStringList myI18nList = i18nList(); Q_FOREACH ( const QString& l, myI18nList ) { - cboLocale->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( l ) ), QLocale( l ).nativeLanguageName(), l ); + // QTBUG-57802: eo locale is improperly handled + QString displayName = l.startsWith( QLatin1String( "eo" ) ) ? QLocale::languageToString( QLocale::Esperanto ) : QLocale( l ).nativeLanguageName(); + cboLocale->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( l ) ), displayName, l ); } cboLocale->setCurrentIndex( cboLocale->findData( myUserLocale ) ); bool myLocaleOverrideFlag = mSettings->value( QStringLiteral( "locale/overrideFlag" ), false ).toBool(); @@ -937,15 +929,13 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) mVariableEditor->reloadContext(); mVariableEditor->setEditableScopeIndex( 0 ); - - mAdvancedSettingsEditor->setSettingsObject( mSettings ); // restore window and widget geometry/state restoreOptionsBaseUi(); } -//! Destructor + QgsOptions::~QgsOptions() { delete mSettings; @@ -987,7 +977,7 @@ void QgsOptions::on_cbxProjectDefaultNew_toggled( bool checked ) void QgsOptions::on_pbnProjectDefaultSetCurrent_clicked() { QString fileName = QgsApplication::qgisSettingsDirPath() + QStringLiteral( "project_default.qgs" ); - if ( QgsProject::instance()->write( QFileInfo( fileName ) ) ) + if ( QgsProject::instance()->write( fileName ) ) { QMessageBox::information( nullptr, tr( "Save default project" ), tr( "Current project saved as default" ) ); } @@ -1081,46 +1071,34 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "qgis/customEnvVars" ), QVariant( customVars ) ); //search directories for user plugins - QString myPaths; + QStringList pathsList; for ( int i = 0; i < mListPluginPaths->count(); ++i ) { - if ( i != 0 ) - { - myPaths += '|'; - } - myPaths += mListPluginPaths->item( i )->text(); + pathsList << mListPluginPaths->item( i )->text(); } - mSettings->setValue( QStringLiteral( "plugins/searchPathsForPlugins" ), myPaths ); + mSettings->setValue( QStringLiteral( "help/helpSearchPath" ), pathsList ); //search directories for svgs - myPaths.clear(); + pathsList.clear(); for ( int i = 0; i < mListSVGPaths->count(); ++i ) { - if ( i != 0 ) - { - myPaths += '|'; - } - myPaths += mListSVGPaths->item( i )->text(); + pathsList << mListSVGPaths->item( i )->text(); } - mSettings->setValue( QStringLiteral( "svg/searchPathsForSVG" ), myPaths ); + mSettings->setValue( QStringLiteral( "svg/searchPathsForSVG" ), pathsList ); - myPaths.clear(); + pathsList.clear(); for ( int i = 0; i < mListComposerTemplatePaths->count(); ++i ) { - if ( i != 0 ) - { - myPaths += '|'; - } - myPaths += mListComposerTemplatePaths->item( i )->text(); + pathsList << mListComposerTemplatePaths->item( i )->text(); } - mSettings->setValue( QStringLiteral( "composer/searchPathsForTemplates" ), myPaths ); + mSettings->setValue( QStringLiteral( "composer/searchPathsForTemplates" ), pathsList ); - QStringList paths; + pathsList.clear(); for ( int i = 0; i < mListHiddenBrowserPaths->count(); ++i ) { - paths << mListHiddenBrowserPaths->item( i )->text(); + pathsList << mListHiddenBrowserPaths->item( i )->text(); } - mSettings->setValue( QStringLiteral( "/browser/hiddenPaths" ), paths ); + mSettings->setValue( QStringLiteral( "/browser/hiddenPaths" ), pathsList ); //Network timeout mSettings->setValue( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), mNetworkTimeoutSpinBox->value() ); @@ -1213,8 +1191,8 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "/qgis/map_update_interval" ), spinMapUpdateInterval->value() ); mSettings->setValue( QStringLiteral( "/qgis/legendDoubleClickAction" ), cmbLegendDoubleClickAction->currentIndex() ); - bool legendLayersCapitalise = mSettings->value( QStringLiteral( "/qgis/capitaliseLayerName" ), false ).toBool(); - mSettings->setValue( QStringLiteral( "/qgis/capitaliseLayerName" ), capitaliseCheckBox->isChecked() ); + bool legendLayersCapitalize = mSettings->value( QStringLiteral( "/qgis/capitalizeLayerName" ), false ).toBool(); + mSettings->setValue( QStringLiteral( "/qgis/capitalizeLayerName" ), capitalizeCheckBox->isChecked() ); // Default simplify drawing configuration QgsVectorSimplifyMethod::SimplifyHints simplifyHints = QgsVectorSimplifyMethod::NoSimplification; @@ -1404,7 +1382,7 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "/qgis/digitizing/offset_miter_limit" ), mCurveOffsetMiterLimitComboBox->value() ); // default scale list - myPaths.clear(); + QString myPaths; for ( int i = 0; i < mListGlobalScales->count(); ++i ) { if ( i != 0 ) @@ -1470,7 +1448,7 @@ void QgsOptions::saveOptions() // refresh legend if any legend item's state is to be changed if ( legendLayersBold != mLegendLayersBoldChkBx->isChecked() || legendGroupsBold != mLegendGroupsBoldChkBx->isChecked() - || legendLayersCapitalise != capitaliseCheckBox->isChecked() ) + || legendLayersCapitalize != capitalizeCheckBox->isChecked() ) { // TODO[MD] QgisApp::instance()->legend()->updateLegendItemStyles(); } @@ -1492,12 +1470,6 @@ void QgsOptions::saveOptions() } saveDefaultDatumTransformations(); - - QgsApplication* app = qobject_cast( QgsApplication::instance() ); - if ( app ) - { - app->emitSettingsChanged(); - } } void QgsOptions::rejectOptions() @@ -1886,12 +1858,8 @@ void QgsOptions::loadGdalDriverList() // in GDAL 2.0 vector and mixed drivers are returned by GDALGetDriver, so filter out non-raster drivers // TODO add same UI for vector drivers -#ifdef GDAL_COMPUTE_VERSION -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) if ( QString( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_RASTER, nullptr ) ) != "YES" ) continue; -#endif -#endif myGdalDriverDescription = GDALGetDescription( myGdalDriver ); myDrivers << myGdalDriverDescription; diff --git a/src/app/qgsoptions.h b/src/app/qgsoptions.h index 355999b11d9..e4b4500b319 100644 --- a/src/app/qgsoptions.h +++ b/src/app/qgsoptions.h @@ -27,6 +27,7 @@ #include #include +#include "qgis_app.h" class QgsExpressionContext; @@ -46,7 +47,7 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption * @param modal true for modal dialog */ QgsOptions( QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - //! Destructor + ~QgsOptions(); /** Sets the page with the specified widget name as the current page diff --git a/src/app/qgspluginmetadata.h b/src/app/qgspluginmetadata.h index 4b133af4964..8de356f43a7 100644 --- a/src/app/qgspluginmetadata.h +++ b/src/app/qgspluginmetadata.h @@ -19,6 +19,7 @@ #ifndef QGSPLUGINMETADATA_H #define QGSPLUGINMETADATA_H #include +#include "qgis_app.h" class QgisPlugin; /** diff --git a/src/app/qgspluginregistry.cpp b/src/app/qgspluginregistry.cpp index ba7bcf4e22d..88868b348f6 100644 --- a/src/app/qgspluginregistry.cpp +++ b/src/app/qgspluginregistry.cpp @@ -380,7 +380,7 @@ void QgsPluginRegistry::loadCppPlugin( const QString& theFullPathName ) { // something went wrong QMessageBox::warning( mQgisInterface->mainWindow(), QObject::tr( "Error Loading Plugin" ), - QObject::tr( "There was an error loading a plugin." + QObject::tr( "There was an error loading a plugin. " "The following diagnostic information may help the QGIS developers resolve the issue:\n%1." ) .arg( myError ) ); //disable it to the qsettings file [ts] diff --git a/src/app/qgspluginregistry.h b/src/app/qgspluginregistry.h index 7403e8b6037..78414b2b9c9 100644 --- a/src/app/qgspluginregistry.h +++ b/src/app/qgspluginregistry.h @@ -21,6 +21,7 @@ #include #include "qgspluginmetadata.h" +#include "qgis_app.h" class QgsPythonUtils; class QgisPlugin; diff --git a/src/app/qgspointmarkeritem.cpp b/src/app/qgspointmarkeritem.cpp index 158055436fd..bdaad7800ab 100644 --- a/src/app/qgspointmarkeritem.cpp +++ b/src/app/qgspointmarkeritem.cpp @@ -17,6 +17,7 @@ #include "qgssymbol.h" #include "qgsmapcanvas.h" #include "qgsmapsettings.h" +#include "qgsproject.h" #include #include @@ -31,7 +32,7 @@ QgsRenderContext QgsPointMarkerItem::renderContext( QPainter* painter ) { QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ); if ( mMapCanvas ) { diff --git a/src/app/qgspointmarkeritem.h b/src/app/qgspointmarkeritem.h index f2400486a50..3c728980c31 100644 --- a/src/app/qgspointmarkeritem.h +++ b/src/app/qgspointmarkeritem.h @@ -21,6 +21,7 @@ #include "effects/qgspainteffect.h" #include #include +#include "qgis_app.h" class QgsMarkerSymbol; diff --git a/src/app/qgspointrotationitem.h b/src/app/qgspointrotationitem.h index d8fa69bdcbd..71def87c64e 100644 --- a/src/app/qgspointrotationitem.h +++ b/src/app/qgspointrotationitem.h @@ -19,6 +19,7 @@ #include "qgsmapcanvasitem.h" #include #include +#include "qgis_app.h" //! An item that shows a rotated point symbol (e.g. arrow) centered to a map location together with a text displaying the rotation value class APP_EXPORT QgsPointRotationItem: public QgsMapCanvasItem diff --git a/src/app/qgsprojectlayergroupdialog.h b/src/app/qgsprojectlayergroupdialog.h index 9ca1fc34216..f5ead903f7b 100644 --- a/src/app/qgsprojectlayergroupdialog.h +++ b/src/app/qgsprojectlayergroupdialog.h @@ -17,6 +17,7 @@ #include "QDialog" #include "ui_qgsprojectlayergroupdialogbase.h" +#include "qgis_app.h" class QDomElement; diff --git a/src/app/qgsprojectproperties.cpp b/src/app/qgsprojectproperties.cpp index f42c8cb13be..8d9fe85dbc6 100644 --- a/src/app/qgsprojectproperties.cpp +++ b/src/app/qgsprojectproperties.cpp @@ -674,7 +674,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa connect( mButtonExportColors, SIGNAL( clicked( bool ) ), mTreeProjectColors, SLOT( showExportColorsDialog() ) ); QList projectSchemes; - QgsColorSchemeRegistry::instance()->schemes( projectSchemes ); + QgsApplication::colorSchemeRegistry()->schemes( projectSchemes ); if ( projectSchemes.length() > 0 ) { mTreeProjectColors->setScheme( projectSchemes.at( 0 ) ); @@ -723,7 +723,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa // Variables editor mVariableEditor->context()->appendScope( QgsExpressionContextUtils::globalScope() ); - mVariableEditor->context()->appendScope( QgsExpressionContextUtils::projectScope() ); + mVariableEditor->context()->appendScope( QgsExpressionContextUtils::projectScope( QgsProject::instance() ) ); mVariableEditor->reloadContext(); mVariableEditor->setEditableScopeIndex( 1 ); @@ -1190,7 +1190,7 @@ void QgsProjectProperties::apply() QgsProject::instance()->relationManager()->setRelations( mRelationManagerDlg->relations() ); //save variables - QgsProject::instance()->setVariables( mVariableEditor->variablesInActiveScope() ); + QgsProject::instance()->setCustomVariables( mVariableEditor->variablesInActiveScope() ); emit refresh(); } diff --git a/src/app/qgsprojectproperties.h b/src/app/qgsprojectproperties.h index 54a086fbf66..9e9f109c8ad 100644 --- a/src/app/qgsprojectproperties.h +++ b/src/app/qgsprojectproperties.h @@ -23,6 +23,7 @@ #include "qgsunittypes.h" #include "qgisgui.h" #include "qgscontexthelp.h" +#include "qgis_app.h" class QgsMapCanvas; class QgsRelationManagerDialog; @@ -43,7 +44,7 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui: //! Constructor QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - //! Destructor + ~QgsProjectProperties(); /** Gets the currently select map units diff --git a/src/app/qgsrastercalcdialog.h b/src/app/qgsrastercalcdialog.h index f2dbfcaa32a..20e67c356d0 100644 --- a/src/app/qgsrastercalcdialog.h +++ b/src/app/qgsrastercalcdialog.h @@ -20,6 +20,7 @@ #include "ui_qgsrastercalcdialogbase.h" #include "qgsrastercalculator.h" +#include "qgis_app.h" //! A dialog to enter a raster calculation expression class APP_EXPORT QgsRasterCalcDialog: public QDialog, private Ui::QgsRasterCalcDialogBase diff --git a/src/app/qgsrasterlayerproperties.cpp b/src/app/qgsrasterlayerproperties.cpp index ad09df54423..412718c51f3 100644 --- a/src/app/qgsrasterlayerproperties.cpp +++ b/src/app/qgsrasterlayerproperties.cpp @@ -361,17 +361,17 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv } //insert renderer widgets into registry - QgsRasterRendererRegistry::instance()->insertWidgetFunction( QStringLiteral( "paletted" ), QgsPalettedRendererWidget::create ); - QgsRasterRendererRegistry::instance()->insertWidgetFunction( QStringLiteral( "multibandcolor" ), QgsMultiBandColorRendererWidget::create ); - QgsRasterRendererRegistry::instance()->insertWidgetFunction( QStringLiteral( "singlebandpseudocolor" ), QgsSingleBandPseudoColorRendererWidget::create ); - QgsRasterRendererRegistry::instance()->insertWidgetFunction( QStringLiteral( "singlebandgray" ), QgsSingleBandGrayRendererWidget::create ); - QgsRasterRendererRegistry::instance()->insertWidgetFunction( QStringLiteral( "hillshade" ), QgsHillshadeRendererWidget::create ); + QgsApplication::rasterRendererRegistry()->insertWidgetFunction( QStringLiteral( "paletted" ), QgsPalettedRendererWidget::create ); + QgsApplication::rasterRendererRegistry()->insertWidgetFunction( QStringLiteral( "multibandcolor" ), QgsMultiBandColorRendererWidget::create ); + QgsApplication::rasterRendererRegistry()->insertWidgetFunction( QStringLiteral( "singlebandpseudocolor" ), QgsSingleBandPseudoColorRendererWidget::create ); + QgsApplication::rasterRendererRegistry()->insertWidgetFunction( QStringLiteral( "singlebandgray" ), QgsSingleBandGrayRendererWidget::create ); + QgsApplication::rasterRendererRegistry()->insertWidgetFunction( QStringLiteral( "hillshade" ), QgsHillshadeRendererWidget::create ); //fill available renderers into combo box QgsRasterRendererRegistryEntry entry; - Q_FOREACH ( const QString& name, QgsRasterRendererRegistry::instance()->renderersList() ) + Q_FOREACH ( const QString& name, QgsApplication::rasterRendererRegistry()->renderersList() ) { - if ( QgsRasterRendererRegistry::instance()->rendererData( name, entry ) ) + if ( QgsApplication::rasterRendererRegistry()->rendererData( name, entry ) ) { if (( mRasterLayer->rasterType() != QgsRasterLayer::ColorLayer && entry.name != QLatin1String( "singlebandcolordata" ) ) || ( mRasterLayer->rasterType() == QgsRasterLayer::ColorLayer && entry.name == QLatin1String( "singlebandcolordata" ) ) ) @@ -540,15 +540,40 @@ void QgsRasterLayerProperties::setRendererWidget( const QString& rendererName ) { QgsDebugMsg( "rendererName = " + rendererName ); QgsRasterRendererWidget* oldWidget = mRendererWidget; + QgsRasterRenderer* oldRenderer = mRasterLayer->renderer(); + + int alphaBand = -1; + double opacity = 1; + if ( oldRenderer ) + { + // Retain alpha band and opacity when switching renderer + alphaBand = oldRenderer->alphaBand(); + opacity = oldRenderer->opacity(); + } QgsRasterRendererRegistryEntry rendererEntry; - if ( QgsRasterRendererRegistry::instance()->rendererData( rendererName, rendererEntry ) ) + if ( QgsApplication::rasterRendererRegistry()->rendererData( rendererName, rendererEntry ) ) { if ( rendererEntry.widgetCreateFunction ) //single band color data renderer e.g. has no widget { QgsDebugMsg( "renderer has widgetCreateFunction" ); // Current canvas extent (used to calc min/max) in layer CRS QgsRectangle myExtent = mMapCanvas->mapSettings().outputExtentToLayerExtent( mRasterLayer, mMapCanvas->extent() ); + if ( oldWidget ) + { + if ( rendererName == "singlebandgray" ) + { + whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( QgsRaster::SingleBandGray, mRasterLayer->dataProvider() ) ); + whileBlocking( mRasterLayer )->setDefaultContrastEnhancement(); + } + else if ( rendererName == "multibandcolor" ) + { + whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( QgsRaster::MultiBandColor, mRasterLayer->dataProvider() ) ); + whileBlocking( mRasterLayer )->setDefaultContrastEnhancement(); + } + } + mRasterLayer->renderer()->setAlphaBand( alphaBand ); + mRasterLayer->renderer()->setOpacity( opacity ); mRendererWidget = rendererEntry.widgetCreateFunction( mRasterLayer, myExtent ); mRendererWidget->setMapCanvas( mMapCanvas ); mRendererStackedWidget->addWidget( mRendererWidget ); @@ -994,7 +1019,7 @@ void QgsRasterLayerProperties::apply() void QgsRasterLayerProperties::on_mLayerOrigNameLineEd_textEdited( const QString& text ) { - leDisplayName->setText( mRasterLayer->capitaliseLayerName( text ) ); + leDisplayName->setText( mRasterLayer->capitalizeLayerName( text ) ); } void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked() diff --git a/src/app/qgsrasterlayerproperties.h b/src/app/qgsrasterlayerproperties.h index 42aa87ad9a5..004504d9ddc 100644 --- a/src/app/qgsrasterlayerproperties.h +++ b/src/app/qgsrasterlayerproperties.h @@ -24,6 +24,7 @@ #include "qgisgui.h" #include "qgscontexthelp.h" #include "qgsmaplayerstylemanager.h" +#include "qgis_app.h" class QgsPoint; class QgsMapLayer; @@ -48,7 +49,7 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private * @param ml Map layer for which properties will be displayed */ QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanvas* theCanvas, QWidget *parent = nullptr, Qt::WindowFlags = QgisGui::ModalDialogFlags ); - //! \brief Destructor + ~QgsRasterLayerProperties(); //! Synchronize state with associated raster layer diff --git a/src/app/qgsrelationadddlg.h b/src/app/qgsrelationadddlg.h index 696217cbf4a..3be468c322f 100644 --- a/src/app/qgsrelationadddlg.h +++ b/src/app/qgsrelationadddlg.h @@ -17,6 +17,7 @@ #include #include "ui_qgsrelationadddlgbase.h" +#include "qgis_app.h" class QgsVectorLayer; diff --git a/src/app/qgsrelationmanagerdialog.h b/src/app/qgsrelationmanagerdialog.h index 48a0964afe5..af9ab7f4645 100644 --- a/src/app/qgsrelationmanagerdialog.h +++ b/src/app/qgsrelationmanagerdialog.h @@ -18,6 +18,7 @@ #include #include "ui_qgsrelationmanagerdialogbase.h" +#include "qgis_app.h" class QgsRelation; class QgsRelationManager; diff --git a/src/app/qgsrulebasedlabelingwidget.cpp b/src/app/qgsrulebasedlabelingwidget.cpp index 6e77a1fe15b..74e03324ab6 100644 --- a/src/app/qgsrulebasedlabelingwidget.cpp +++ b/src/app/qgsrulebasedlabelingwidget.cpp @@ -19,6 +19,7 @@ #include "qgsfeatureiterator.h" #include "qgslabelinggui.h" #include "qgsmapcanvas.h" +#include "qgsproject.h" #include "qgsrulebasedlabeling.h" #include "qgsvectorlayer.h" #include "qgsvectorlayerlabeling.h" @@ -27,6 +28,27 @@ #include #include + +static QList _globalProjectAtlasMapLayerScopes( QgsMapCanvas* mapCanvas, const QgsMapLayer* layer ) +{ + QList scopes; + scopes << QgsExpressionContextUtils::globalScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) + << QgsExpressionContextUtils::atlasScope( nullptr ); + if ( mapCanvas ) + { + scopes << QgsExpressionContextUtils::mapSettingsScope( mapCanvas->mapSettings() ) + << new QgsExpressionContextScope( mapCanvas->expressionContextScope() ); + } + else + { + scopes << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); + } + scopes << QgsExpressionContextUtils::layerScope( layer ); + return scopes; +} + + QgsRuleBasedLabelingWidget::QgsRuleBasedLabelingWidget( QgsVectorLayer* layer, QgsMapCanvas* canvas, QWidget* parent ) : QgsPanelWidget( parent ) , mLayer( layer ) @@ -643,20 +665,7 @@ void QgsLabelingRulePropsWidget::testFilter() return; } - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::atlasScope( nullptr ); - if ( mMapCanvas ) - { - context << QgsExpressionContextUtils::mapSettingsScope( mMapCanvas->mapSettings() ) - << new QgsExpressionContextScope( mMapCanvas->expressionContextScope() ); - } - else - { - context << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); - } - context << QgsExpressionContextUtils::layerScope( mLayer ); + QgsExpressionContext context( _globalProjectAtlasMapLayerScopes( mMapCanvas, mLayer ) ); if ( !filter.prepare( &context ) ) { @@ -686,22 +695,10 @@ void QgsLabelingRulePropsWidget::testFilter() QMessageBox::information( this, tr( "Filter" ), tr( "Filter returned %n feature(s)", "number of filtered features", count ) ); } + void QgsLabelingRulePropsWidget::buildExpression() { - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::atlasScope( nullptr ); - if ( mMapCanvas ) - { - context << QgsExpressionContextUtils::mapSettingsScope( mMapCanvas->mapSettings() ) - << new QgsExpressionContextScope( mMapCanvas->expressionContextScope() ); - } - else - { - context << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); - } - context << QgsExpressionContextUtils::layerScope( mLayer ); + QgsExpressionContext context( _globalProjectAtlasMapLayerScopes( mMapCanvas, mLayer ) ); QgsExpressionBuilderDialog dlg( mLayer, editFilter->text(), this, QStringLiteral( "generic" ), context ); diff --git a/src/app/qgsrulebasedlabelingwidget.h b/src/app/qgsrulebasedlabelingwidget.h index 54f166e06ab..b1c330824da 100644 --- a/src/app/qgsrulebasedlabelingwidget.h +++ b/src/app/qgsrulebasedlabelingwidget.h @@ -22,6 +22,7 @@ #include #include "qgsrulebasedlabeling.h" +#include "qgis_app.h" class QgsMapCanvas; class QgsVectorLayer; diff --git a/src/app/qgssavestyletodbdialog.h b/src/app/qgssavestyletodbdialog.h index bfc0b5444c9..b0aef4c698d 100644 --- a/src/app/qgssavestyletodbdialog.h +++ b/src/app/qgssavestyletodbdialog.h @@ -18,6 +18,7 @@ #include "ui_qgssavetodbdialog.h" #include "qgisgui.h" +#include "qgis_app.h" class APP_EXPORT QgsSaveStyleToDbDialog : public QDialog, private Ui::QgsSaveToDBDialog { diff --git a/src/app/qgsselectbyformdialog.cpp b/src/app/qgsselectbyformdialog.cpp index c7536f204c1..3b9c01e7adf 100644 --- a/src/app/qgsselectbyformdialog.cpp +++ b/src/app/qgsselectbyformdialog.cpp @@ -15,11 +15,14 @@ #include "qgsselectbyformdialog.h" #include "qgsattributeform.h" +#include "qgsmapcanvas.h" #include #include QgsSelectByFormDialog::QgsSelectByFormDialog( QgsVectorLayer* layer, const QgsAttributeEditorContext& context, QWidget* parent, Qt::WindowFlags fl ) : QDialog( parent, fl ) + , mLayer( layer ) + , mMessageBar( nullptr ) { QgsAttributeEditorContext dlgContext = context; dlgContext.setFormMode( QgsAttributeEditorContext::StandaloneDialog ); @@ -51,5 +54,62 @@ QgsSelectByFormDialog::~QgsSelectByFormDialog() void QgsSelectByFormDialog::setMessageBar( QgsMessageBar* messageBar ) { + mMessageBar = messageBar; mForm->setMessageBar( messageBar ); } + +void QgsSelectByFormDialog::setMapCanvas( QgsMapCanvas* canvas ) +{ + mMapCanvas = canvas; + connect( mForm, &QgsAttributeForm::zoomToFeatures, this, &QgsSelectByFormDialog::zoomToFeatures ); +} + +void QgsSelectByFormDialog::zoomToFeatures( const QString& filter ) +{ + QgsFeatureIds ids; + + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mLayer ) ); + + QgsFeatureRequest request = QgsFeatureRequest().setFilterExpression( filter ) + .setExpressionContext( context ) + .setSubsetOfAttributes( QgsAttributeList() ); + + QgsFeatureIterator features = mLayer->getFeatures( request ); + + QgsRectangle bbox; + bbox.setMinimal(); + QgsFeature feat; + int featureCount = 0; + while ( features.nextFeature( feat ) ) + { + QgsGeometry geom = feat.geometry(); + if ( geom.isEmpty() || geom.geometry()->isEmpty() ) + continue; + + QgsRectangle r = mMapCanvas->mapSettings().layerExtentToOutputExtent( mLayer, geom.boundingBox() ); + bbox.combineExtentWith( r ); + featureCount++; + } + features.close(); + + QSettings settings; + int timeout = settings.value( QStringLiteral( "/qgis/messageTimeout" ), 5 ).toInt(); + if ( featureCount > 0 ) + { + mMapCanvas->zoomToFeatureExtent( bbox ); + if ( mMessageBar ) + { + mMessageBar->pushMessage( QString(), + tr( "Zoomed to %n matching feature(s)", "number of matching features", featureCount ), + QgsMessageBar::INFO, + timeout ); + } + } + else if ( mMessageBar ) + { + mMessageBar->pushMessage( QString(), + tr( "No matching features found" ), + QgsMessageBar::INFO, + timeout ); + } +} diff --git a/src/app/qgsselectbyformdialog.h b/src/app/qgsselectbyformdialog.h index b62520f5c3b..2ce875a1eb4 100644 --- a/src/app/qgsselectbyformdialog.h +++ b/src/app/qgsselectbyformdialog.h @@ -18,10 +18,12 @@ #include #include "qgsattributeeditorcontext.h" +#include "qgis_app.h" class QgsAttributeForm; class QgsMessageBar; class QgsVectorLayer; +class QgsMapCanvas; /** \ingroup app * \class QgsSelectByFormDialog @@ -54,9 +56,21 @@ class APP_EXPORT QgsSelectByFormDialog : public QDialog */ void setMessageBar( QgsMessageBar* messageBar ); + /** + * Sets a map canvas associated with the dialog. + */ + void setMapCanvas( QgsMapCanvas* canvas ); + + private slots: + + void zoomToFeatures( const QString& filter ); + private: QgsAttributeForm* mForm; + QgsVectorLayer* mLayer; + QgsMessageBar* mMessageBar; + QgsMapCanvas* mMapCanvas; }; diff --git a/src/app/qgssnappinglayertreemodel.cpp b/src/app/qgssnappinglayertreemodel.cpp index 3a55cebd771..6b38d523cf5 100644 --- a/src/app/qgssnappinglayertreemodel.cpp +++ b/src/app/qgssnappinglayertreemodel.cpp @@ -144,7 +144,7 @@ QgsSnappingLayerTreeModel::QgsSnappingLayerTreeModel( QgsProject* project, QObje , mLayerTreeModel( nullptr ) { connect( project, &QgsProject::snappingConfigChanged, this, &QgsSnappingLayerTreeModel::onSnappingSettingsChanged ); - connect( project, &QgsProject::avoidIntersectionsListChanged, this, &QgsSnappingLayerTreeModel::onSnappingSettingsChanged ); + connect( project, &QgsProject::avoidIntersectionsLayersChanged, this, &QgsSnappingLayerTreeModel::onSnappingSettingsChanged ); } QgsSnappingLayerTreeModel::~QgsSnappingLayerTreeModel() @@ -494,7 +494,7 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex& idx, int role ) con { if ( role == Qt::CheckStateRole && vl->geometryType() == QgsWkbTypes::PolygonGeometry ) { - if ( mProject->avoidIntersectionsList().contains( vl->id() ) ) + if ( mProject->avoidIntersectionsLayers().contains( vl ) ) { return Qt::Checked; } @@ -620,14 +620,14 @@ bool QgsSnappingLayerTreeModel::setData( const QModelIndex& index, const QVarian if ( !mIndividualLayerSettings.contains( vl ) ) return false; - QStringList avoidIntersectionsList = mProject->avoidIntersectionsList(); + QList avoidIntersectionsList = mProject->avoidIntersectionsLayers(); - if ( value.toInt() == Qt::Checked && !avoidIntersectionsList.contains( vl->id() ) ) - avoidIntersectionsList.append( vl->id() ); + if ( value.toInt() == Qt::Checked && !avoidIntersectionsList.contains( vl ) ) + avoidIntersectionsList.append( vl ); else - avoidIntersectionsList.removeAll( vl->id() ); + avoidIntersectionsList.removeAll( vl ); - mProject->setAvoidIntersectionsList( avoidIntersectionsList ); + mProject->setAvoidIntersectionsLayers( avoidIntersectionsList ); return true; } } diff --git a/src/app/qgssnappinglayertreemodel.h b/src/app/qgssnappinglayertreemodel.h index e54890b0516..da6f1087162 100644 --- a/src/app/qgssnappinglayertreemodel.h +++ b/src/app/qgssnappinglayertreemodel.h @@ -23,6 +23,7 @@ #include "qgslayertreemodel.h" #include "qgssnappingconfig.h" +#include "qgis_app.h" class QgsMapCanvas; class QgsProject; diff --git a/src/app/qgssnappingwidget.h b/src/app/qgssnappingwidget.h index dccf5c71212..4f99b96a253 100644 --- a/src/app/qgssnappingwidget.h +++ b/src/app/qgssnappingwidget.h @@ -34,6 +34,7 @@ class QgsProject; #include #include +#include "qgis_app.h" /** * A widget which lets the user defines settings for snapping on a project @@ -55,7 +56,7 @@ class APP_EXPORT QgsSnappingWidget : public QWidget */ QgsSnappingWidget( QgsProject* project, QgsMapCanvas* canvas, QWidget* parent = nullptr ); - //! Destructor + virtual ~QgsSnappingWidget(); /** diff --git a/src/app/qgssponsors.cpp b/src/app/qgssponsors.cpp index 6d43cc7bcef..07f88e50f1e 100644 --- a/src/app/qgssponsors.cpp +++ b/src/app/qgssponsors.cpp @@ -32,7 +32,7 @@ QgsSponsors::QgsSponsors( QWidget *parent ) init(); QString intro = tr( "

    We work really hard to make this nice software for you. " "See all the cool features it has? Get a warm fuzzy feeling when you use it? " - "QGIS is a labour of love by a dedicated team of developers. We want you to copy " + "QGIS is a labor of love by a dedicated team of developers. We want you to copy " "& share it and put it in the hands of as many people as possible. If QGIS " "is saving you money or you like our work and have the financial ability to " "help, please consider sponsoring the development of QGIS. We use money from " diff --git a/src/app/qgssponsors.h b/src/app/qgssponsors.h index 8b05b082f53..f238c2fe10b 100644 --- a/src/app/qgssponsors.h +++ b/src/app/qgssponsors.h @@ -18,6 +18,7 @@ #define QGSSPONSORS_H #include "ui_qgssponsorsbase.h" +#include "qgis_app.h" class APP_EXPORT QgsSponsors : public QDialog, private Ui::QgsSponsorsBase { diff --git a/src/app/qgsstatisticalsummarydockwidget.cpp b/src/app/qgsstatisticalsummarydockwidget.cpp index c7513fa0c7b..b9b561ed20f 100644 --- a/src/app/qgsstatisticalsummarydockwidget.cpp +++ b/src/app/qgsstatisticalsummarydockwidget.cpp @@ -62,7 +62,7 @@ QgsExpressionContext QgsStatisticalSummaryDockWidget::createExpressionContext() { QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::mapSettingsScope( QgisApp::instance()->mapCanvas()->mapSettings() ) << QgsExpressionContextUtils::layerScope( mLayer ); @@ -202,8 +202,9 @@ void QgsStatisticalSummaryDockWidget::updateNumericStatistics( bool selectedOnly int row = 0; Q_FOREACH ( QgsStatisticalSummary::Statistic stat, statsToDisplay ) { + double val = stats.statistic( stat ); addRow( row, QgsStatisticalSummary::displayName( stat ), - QString::number( stats.statistic( stat ) ), + qIsNaN( val ) ? QString() : QString::number( val ), stats.count() != 0 ); row++; } diff --git a/src/app/qgsstatisticalsummarydockwidget.h b/src/app/qgsstatisticalsummarydockwidget.h index b8f33f3c5d2..6e3f22df289 100644 --- a/src/app/qgsstatisticalsummarydockwidget.h +++ b/src/app/qgsstatisticalsummarydockwidget.h @@ -22,6 +22,7 @@ #include "qgsstringstatisticalsummary.h" #include "qgsdatetimestatisticalsummary.h" #include "qgsdockwidget.h" +#include "qgis_app.h" class QgsBrowserModel; class QModelIndex; diff --git a/src/app/qgsstatusbarcoordinateswidget.h b/src/app/qgsstatusbarcoordinateswidget.h index 7384fffeb7b..5cb237a7a96 100644 --- a/src/app/qgsstatusbarcoordinateswidget.h +++ b/src/app/qgsstatusbarcoordinateswidget.h @@ -28,6 +28,7 @@ class QgsMapCanvas; class QgsPoint; #include +#include "qgis_app.h" class APP_EXPORT QgsStatusBarCoordinatesWidget : public QWidget { diff --git a/src/app/qgsstatusbarmagnifierwidget.h b/src/app/qgsstatusbarmagnifierwidget.h index 88784893922..56c994d2fb9 100644 --- a/src/app/qgsstatusbarmagnifierwidget.h +++ b/src/app/qgsstatusbarmagnifierwidget.h @@ -23,6 +23,7 @@ class QHBoxLayout; class QgsDoubleSpinBox; #include +#include "qgis_app.h" /** * A widget which lets the user select the current level of magnification to @@ -40,7 +41,7 @@ class APP_EXPORT QgsStatusBarMagnifierWidget : public QWidget */ QgsStatusBarMagnifierWidget( QWidget* parent = nullptr ); - //! Destructor + virtual ~QgsStatusBarMagnifierWidget(); void setDefaultFactor( double factor ); diff --git a/src/app/qgsstatusbarscalewidget.h b/src/app/qgsstatusbarscalewidget.h index aa382b4d2a0..5cfe2665824 100644 --- a/src/app/qgsstatusbarscalewidget.h +++ b/src/app/qgsstatusbarscalewidget.h @@ -28,6 +28,7 @@ class QgsScaleComboBox; #include +#include "qgis_app.h" /** * Widget to define scale of the map canvas. @@ -39,7 +40,7 @@ class APP_EXPORT QgsStatusBarScaleWidget : public QWidget public: explicit QgsStatusBarScaleWidget( QgsMapCanvas* canvas, QWidget *parent = 0 ); - //! Destructor + virtual ~QgsStatusBarScaleWidget(); /** diff --git a/src/app/qgssvgannotationdialog.h b/src/app/qgssvgannotationdialog.h index b15751a42d4..2e2c4b8307e 100644 --- a/src/app/qgssvgannotationdialog.h +++ b/src/app/qgssvgannotationdialog.h @@ -19,6 +19,7 @@ #define QGSSVGANNOTATIONDIALOG_H #include "ui_qgsformannotationdialogbase.h" +#include "qgis_app.h" class QgsSvgAnnotationItem; class QgsAnnotationWidget; diff --git a/src/app/qgstextannotationdialog.h b/src/app/qgstextannotationdialog.h index c673dc961dd..9a784829b6e 100644 --- a/src/app/qgstextannotationdialog.h +++ b/src/app/qgstextannotationdialog.h @@ -19,6 +19,7 @@ #define QGSTEXTANNOTATIONDIALOG_H #include "ui_qgstextannotationdialogbase.h" +#include "qgis_app.h" class QgsAnnotationWidget; class QgsTextAnnotationItem; diff --git a/src/app/qgstip.h b/src/app/qgstip.h index c81ddbd8355..13905755908 100644 --- a/src/app/qgstip.h +++ b/src/app/qgstip.h @@ -17,6 +17,7 @@ #include #include +#include "qgis_app.h" /** \ingroup app * \brief An QgsTip represents a tip generated by the diff --git a/src/app/qgstipfactory.h b/src/app/qgstipfactory.h index eeba72e6421..f79864e19a8 100644 --- a/src/app/qgstipfactory.h +++ b/src/app/qgstipfactory.h @@ -18,6 +18,7 @@ #include "qgstip.h" #include +#include "qgis_app.h" /** \ingroup app * \brief A factory class to serve up tips to the user. @@ -33,7 +34,7 @@ class APP_EXPORT QgsTipFactory : public QObject public: //! Constructor QgsTipFactory(); - //! Destructor + ~QgsTipFactory(); /** Get a random tip (generic or gui-centric) diff --git a/src/app/qgstipgui.h b/src/app/qgstipgui.h index 506fe62baf9..454ece926bc 100644 --- a/src/app/qgstipgui.h +++ b/src/app/qgstipgui.h @@ -18,6 +18,7 @@ #define QGSTIPGUI_H #include "ui_qgstipguibase.h" +#include "qgis_app.h" class QgsTip; class APP_EXPORT QgsTipGui : public QDialog, private Ui::QgsTipGuiBase diff --git a/src/app/qgsundowidget.h b/src/app/qgsundowidget.h index 5687bd7fc4e..b5ebfaf218d 100644 --- a/src/app/qgsundowidget.h +++ b/src/app/qgsundowidget.h @@ -27,6 +27,7 @@ #include #include "qgspanelwidget.h" +#include "qgis_app.h" class QgsMapCanvas; class QgsMapLayer; diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index 3d85c6d3f9a..646fd014da2 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -112,7 +112,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties( connect( mOptionsStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( mOptionsStackedWidget_CurrentChanged( int ) ) ); mContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ) << QgsExpressionContextUtils::mapSettingsScope( QgisApp::instance()->mapCanvas()->mapSettings() ) << QgsExpressionContextUtils::layerScope( mLayer ); @@ -309,7 +309,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties( // use visibility as selection mLayersDependenciesTreeModel->setFlag( QgsLayerTreeModel::AllowNodeChangeVisibility ); - mLayersDependenciesTreeGroup->setVisible( Qt::Unchecked ); + mLayersDependenciesTreeGroup->setItemVisibilityChecked( false ); QSet dependencySources; Q_FOREACH ( const QgsMapLayerDependency& dep, mLayer->dependencies() ) @@ -318,7 +318,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties( } Q_FOREACH ( QgsLayerTreeLayer* layer, mLayersDependenciesTreeGroup->findLayers() ) { - layer->setVisible( dependencySources.contains( layer->layerId() ) ? Qt::Checked : Qt::Unchecked ); + layer->setItemVisibilityChecked( dependencySources.contains( layer->layerId() ) ); } mLayersDependenciesTreeView->setModel( mLayersDependenciesTreeModel.data() ); @@ -693,7 +693,7 @@ QString QgsVectorLayerProperties::metadata() void QgsVectorLayerProperties::on_mLayerOrigNameLineEdit_textEdited( const QString& text ) { - txtDisplayName->setText( mLayer->capitaliseLayerName( text ) ); + txtDisplayName->setText( mLayer->capitalizeLayerName( text ) ); } void QgsVectorLayerProperties::on_mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem& crs ) @@ -1333,7 +1333,7 @@ void QgsVectorLayerProperties::updateVariableEditor() QgsExpressionContext context; mVariableEditor->setContext( &context ); mVariableEditor->context()->appendScope( QgsExpressionContextUtils::globalScope() ); - mVariableEditor->context()->appendScope( QgsExpressionContextUtils::projectScope() ); + mVariableEditor->context()->appendScope( QgsExpressionContextUtils::projectScope( QgsProject::instance() ) ); mVariableEditor->context()->appendScope( QgsExpressionContextUtils::layerScope( mLayer ) ); mVariableEditor->reloadContext(); mVariableEditor->setEditableScopeIndex( 2 ); diff --git a/src/app/qgsvectorlayerproperties.h b/src/app/qgsvectorlayerproperties.h index ebfb3018c31..2be398d73f6 100644 --- a/src/app/qgsvectorlayerproperties.h +++ b/src/app/qgsvectorlayerproperties.h @@ -27,6 +27,7 @@ #include "qgsvectorlayer.h" #include "layertree/qgslayertreemodel.h" #include "layertree/qgslayertreegroup.h" +#include "qgis_app.h" class QgsMapLayer; diff --git a/src/app/qgsversioninfo.cpp b/src/app/qgsversioninfo.cpp index 973289e67df..9fb093430d5 100644 --- a/src/app/qgsversioninfo.cpp +++ b/src/app/qgsversioninfo.cpp @@ -15,7 +15,7 @@ #include "qgsversioninfo.h" #include "qgis.h" - +#include "qgsapplication.h" #include "qgsnetworkaccessmanager.h" QgsVersionInfo::QgsVersionInfo( QObject *parent ) diff --git a/src/auth/basic/CMakeLists.txt b/src/auth/basic/CMakeLists.txt index ec718bf39a9..cca6c9d43a4 100644 --- a/src/auth/basic/CMakeLists.txt +++ b/src/auth/basic/CMakeLists.txt @@ -19,6 +19,8 @@ INCLUDE_DIRECTORIES ( ../../core ../../core/auth ../../core/geometry + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) INCLUDE_DIRECTORIES (SYSTEM ${QCA_INCLUDE_DIR} diff --git a/src/auth/identcert/CMakeLists.txt b/src/auth/identcert/CMakeLists.txt index 4d15aabfd5d..0819efd5014 100644 --- a/src/auth/identcert/CMakeLists.txt +++ b/src/auth/identcert/CMakeLists.txt @@ -19,6 +19,8 @@ INCLUDE_DIRECTORIES ( ../../core ../../core/auth ../../core/geometry + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) INCLUDE_DIRECTORIES (SYSTEM ${QCA_INCLUDE_DIR} diff --git a/src/auth/pkipaths/CMakeLists.txt b/src/auth/pkipaths/CMakeLists.txt index c6bb95fd3f0..093078f347a 100644 --- a/src/auth/pkipaths/CMakeLists.txt +++ b/src/auth/pkipaths/CMakeLists.txt @@ -19,6 +19,8 @@ INCLUDE_DIRECTORIES ( ../../core ../../core/auth ../../core/geometry + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) INCLUDE_DIRECTORIES (SYSTEM ${QCA_INCLUDE_DIR} diff --git a/src/auth/pkipkcs12/CMakeLists.txt b/src/auth/pkipkcs12/CMakeLists.txt index 44f23bb6b34..39009b860b2 100644 --- a/src/auth/pkipkcs12/CMakeLists.txt +++ b/src/auth/pkipkcs12/CMakeLists.txt @@ -19,6 +19,8 @@ INCLUDE_DIRECTORIES ( ../../core ../../core/auth ../../core/geometry + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) INCLUDE_DIRECTORIES (SYSTEM ${QCA_INCLUDE_DIR} diff --git a/src/browser/CMakeLists.txt b/src/browser/CMakeLists.txt index 4864f78bebf..55b68facd7c 100644 --- a/src/browser/CMakeLists.txt +++ b/src/browser/CMakeLists.txt @@ -65,6 +65,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../gui/editorwidgets/core ${CMAKE_CURRENT_BINARY_DIR}/../ui ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) INCLUDE_DIRECTORIES(SYSTEM ${GEOS_INCLUDE_DIR} diff --git a/src/browser/main.cpp b/src/browser/main.cpp index c4f4df0db7f..948d863817f 100644 --- a/src/browser/main.cpp +++ b/src/browser/main.cpp @@ -114,8 +114,6 @@ int main( int argc, char ** argv ) } } - QgsNetworkAccessManager::instance(); - QgsBrowser w; a.connect( &a, SIGNAL( aboutToQuit() ), &w, SLOT( saveWindowState() ) ); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a7534fc6f97..ecfc306243c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -903,6 +903,7 @@ ENDIF (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} auth composer dxf @@ -927,10 +928,6 @@ INCLUDE_DIRECTORIES(SYSTEM ${QCA_INCLUDE_DIR} ) -REMOVE_DEFINITIONS("-DCORE_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("\"-DCORE_EXPORT=${DLLEXPORT}\"") - - #for PAL classes IF (WIN32) ADD_DEFINITIONS("-D_HAVE_WINDOWS_H_") @@ -946,6 +943,14 @@ ADD_DEFINITIONS(-DTEST_DATA_DIR="\\"${TEST_DATA_DIR}\\"") ADD_LIBRARY(qgis_core SHARED ${QGIS_CORE_SRCS} ${QGIS_CORE_MOC_SRCS} ${QGIS_CORE_HDRS} ${QGIS_CORE_MOC_HDRS}) +GENERATE_EXPORT_HEADER( + qgis_core + BASE_NAME CORE + EXPORT_FILE_NAME qgis_core.h +) + +SET(QGIS_CORE_HDRS ${QGIS_CORE_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/qgis_core.h) + IF(ENABLE_MODELTEST) TARGET_LINK_LIBRARIES(qgis_core ${QT_QTTEST_LIBRARY}) ENDIF(ENABLE_MODELTEST) diff --git a/src/core/auth/qgsauthcertutils.h b/src/core/auth/qgsauthcertutils.h index 8625c4587c8..119e61854dd 100644 --- a/src/core/auth/qgsauthcertutils.h +++ b/src/core/auth/qgsauthcertutils.h @@ -23,6 +23,8 @@ #include #include +#include "qgis_core.h" + class QgsAuthConfigSslServer; #define SSL_ISSUER_INFO( var, prop ) var.issuerInfo( prop ).value(0) diff --git a/src/core/auth/qgsauthconfig.cpp b/src/core/auth/qgsauthconfig.cpp index 6c7d2704ff9..b3ab2272db0 100644 --- a/src/core/auth/qgsauthconfig.cpp +++ b/src/core/auth/qgsauthconfig.cpp @@ -357,18 +357,10 @@ QgsAuthConfigSslServer::QgsAuthConfigSslServer() , mVersion( 1 ) { // TODO: figure out if Qt 5 has changed yet again, e.g. TLS-only -#if QT_VERSION >= 0x040800 mQtVersion = 480; // Qt 4.8 defaults to SecureProtocols, i.e. TlsV1SslV3 // http://qt-project.org/doc/qt-4.8/qssl.html#SslProtocol-enum mSslProtocol = QSsl::SecureProtocols; -#else - mQtVersion = 470; - // older Qt 4.7 defaults to now-vulnerable SSLv3 - // http://qt-project.org/doc/qt-4.7/qssl.html - // Default this to TlsV1 instead - mSslProtocol = QSsl::TlsV1; -#endif } const QList QgsAuthConfigSslServer::sslIgnoredErrors() const diff --git a/src/core/auth/qgsauthconfig.h b/src/core/auth/qgsauthconfig.h index ac103fd2700..f98abada01d 100644 --- a/src/core/auth/qgsauthconfig.h +++ b/src/core/auth/qgsauthconfig.h @@ -17,6 +17,7 @@ #ifndef QGSAUTHCONFIG_H #define QGSAUTHCONFIG_H +#include "qgis_core.h" #include #include @@ -299,8 +300,6 @@ class CORE_EXPORT QgsAuthConfigSslServer //! Construct a default SSL server configuration QgsAuthConfigSslServer(); - ~QgsAuthConfigSslServer() {} - //! Server certificate object const QSslCertificate sslCertificate() const { return mSslCert; } //! Set server certificate object diff --git a/src/core/auth/qgsauthcrypto.h b/src/core/auth/qgsauthcrypto.h index 0625804054c..9469b95f679 100644 --- a/src/core/auth/qgsauthcrypto.h +++ b/src/core/auth/qgsauthcrypto.h @@ -20,6 +20,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * Funtions for hashing/checking master password and encrypt/decrypting data with password * \since 2.8 diff --git a/src/core/auth/qgsauthmanager.h b/src/core/auth/qgsauthmanager.h index 9f241f9c727..e4f47473c1e 100644 --- a/src/core/auth/qgsauthmanager.h +++ b/src/core/auth/qgsauthmanager.h @@ -17,6 +17,7 @@ #ifndef QGSAUTHMANAGER_H #define QGSAUTHMANAGER_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/auth/qgsauthmethod.h b/src/core/auth/qgsauthmethod.h index 08cc9b3ab52..c72d628c7aa 100644 --- a/src/core/auth/qgsauthmethod.h +++ b/src/core/auth/qgsauthmethod.h @@ -24,6 +24,8 @@ #include #include +#include "qgis_core.h" + class QgsAuthMethodConfig; /** \ingroup core @@ -53,8 +55,6 @@ class CORE_EXPORT QgsAuthMethod : public QObject }; Q_DECLARE_FLAGS( Expansions, Expansion ) - virtual ~QgsAuthMethod() {} - //! A non-translated short name representing the auth method virtual QString key() const = 0; diff --git a/src/core/auth/qgsauthmethodmetadata.h b/src/core/auth/qgsauthmethodmetadata.h index 7f80a94bb3e..3cae0e4f291 100644 --- a/src/core/auth/qgsauthmethodmetadata.h +++ b/src/core/auth/qgsauthmethodmetadata.h @@ -19,6 +19,8 @@ #include +#include "qgis_core.h" + /** \ingroup core * Holds data auth method key, description, and associated shared library file information. diff --git a/src/core/auth/qgsauthmethodregistry.cpp b/src/core/auth/qgsauthmethodregistry.cpp index 62bc0381ea4..2c80fa56726 100644 --- a/src/core/auth/qgsauthmethodregistry.cpp +++ b/src/core/auth/qgsauthmethodregistry.cpp @@ -324,7 +324,6 @@ QWidget *QgsAuthMethodRegistry::editWidget( const QString &authMethodKey, QWidge return editFactory( parent ); } -#if QT_VERSION >= 0x050000 QFunctionPointer QgsAuthMethodRegistry::function( QString const & authMethodKey, QString const & functionName ) { @@ -342,25 +341,6 @@ QFunctionPointer QgsAuthMethodRegistry::function( QString const & authMethodKey, return 0; } } -#else -void *QgsAuthMethodRegistry::function( QString const & authMethodKey, - QString const & functionName ) -{ - QLibrary myLib( library( authMethodKey ) ); - - QgsDebugMsg( "Library name is " + myLib.fileName() ); - - if ( myLib.load() ) - { - return myLib.resolve( functionName.toLatin1().data() ); - } - else - { - QgsDebugMsg( "Cannot load library: " + myLib.errorString() ); - return nullptr; - } -} -#endif QLibrary *QgsAuthMethodRegistry::authMethodLibrary( const QString &authMethodKey ) const { diff --git a/src/core/auth/qgsauthmethodregistry.h b/src/core/auth/qgsauthmethodregistry.h index 1b6054efdb4..857316b113a 100644 --- a/src/core/auth/qgsauthmethodregistry.h +++ b/src/core/auth/qgsauthmethodregistry.h @@ -22,6 +22,8 @@ #include #include +#include "qgis_core.h" + class QgsAuthMethod; class QgsAuthMethodMetadata; @@ -76,8 +78,6 @@ class CORE_EXPORT QgsAuthMethodRegistry */ QWidget *editWidget( const QString & authMethodKey, QWidget * parent = nullptr ); -#if QT_VERSION >= 0x050000 - /** Get pointer to auth method function @param authMethodKey identificator of the auth method @param functionName name of function @@ -85,16 +85,6 @@ class CORE_EXPORT QgsAuthMethodRegistry */ QFunctionPointer function( const QString & authMethodKey, const QString & functionName ); -#else - - /** Get pointer to auth method function - @param authMethodKey identificator of the auth method - @param functionName name of function - @return pointer to function or nullptr on error - */ - void *function( const QString & authMethodKey, - const QString & functionName ); -#endif //! Return the library object associated with an auth method key QLibrary *authMethodLibrary( const QString & authMethodKey ) const; diff --git a/src/core/composer/qgsaddremoveitemcommand.cpp b/src/core/composer/qgsaddremoveitemcommand.cpp index aee29dc9b9c..42e1f815943 100644 --- a/src/core/composer/qgsaddremoveitemcommand.cpp +++ b/src/core/composer/qgsaddremoveitemcommand.cpp @@ -80,5 +80,5 @@ void QgsAddRemoveItemCommand::switchState() emit itemAdded( mItem ); mState = Added; } - QgsProject::instance()->setDirty( true ); + mComposition->project()->setDirty( true ); } diff --git a/src/core/composer/qgsaddremoveitemcommand.h b/src/core/composer/qgsaddremoveitemcommand.h index 11a4aa08cce..e1ead45e5e1 100644 --- a/src/core/composer/qgsaddremoveitemcommand.h +++ b/src/core/composer/qgsaddremoveitemcommand.h @@ -19,6 +19,9 @@ #define QGSADDREMOVEITEMCOMMAND_H #include + +#include "qgis_core.h" + class QgsComposerItem; class QgsComposition; diff --git a/src/core/composer/qgsaddremovemultiframecommand.cpp b/src/core/composer/qgsaddremovemultiframecommand.cpp index edb4aef10b8..f9d968e5a1f 100644 --- a/src/core/composer/qgsaddremovemultiframecommand.cpp +++ b/src/core/composer/qgsaddremovemultiframecommand.cpp @@ -78,7 +78,7 @@ void QgsAddRemoveMultiFrameCommand::switchState() mComposition->addMultiFrame( mMultiFrame ); mState = Added; } - QgsProject::instance()->setDirty( true ); + mComposition->project()->setDirty( true ); } } diff --git a/src/core/composer/qgsaddremovemultiframecommand.h b/src/core/composer/qgsaddremovemultiframecommand.h index 3a216c007a2..74f32b20125 100644 --- a/src/core/composer/qgsaddremovemultiframecommand.h +++ b/src/core/composer/qgsaddremovemultiframecommand.h @@ -20,6 +20,8 @@ #include +#include "qgis_core.h" + class QgsComposerMultiFrame; class QgsComposition; diff --git a/src/core/composer/qgsatlascomposition.cpp b/src/core/composer/qgsatlascomposition.cpp index 005c4264556..ba2fd16aa19 100644 --- a/src/core/composer/qgsatlascomposition.cpp +++ b/src/core/composer/qgsatlascomposition.cpp @@ -45,11 +45,7 @@ QgsAtlasComposition::QgsAtlasComposition( QgsComposition* composition ) { //listen out for layer removal - connect( QgsProject::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( removeLayers( QStringList ) ) ); -} - -QgsAtlasComposition::~QgsAtlasComposition() -{ + connect( mComposition->project(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( removeLayers( QStringList ) ) ); } void QgsAtlasComposition::setEnabled( bool enabled ) @@ -629,7 +625,7 @@ void QgsAtlasComposition::readXml( const QDomElement& atlasElem, const QDomDocum // look for stored layer name QString coverageLayerId = atlasElem.attribute( QStringLiteral( "coverageLayer" ) ); - mCoverageLayer = qobject_cast( QgsProject::instance()->mapLayer( coverageLayerId ) ); + mCoverageLayer = qobject_cast( mComposition->project()->mapLayer( coverageLayerId ) ); mPageNameExpression = atlasElem.attribute( QStringLiteral( "pageNameExpression" ), QString() ); mSingleFile = atlasElem.attribute( QStringLiteral( "singleFile" ), QStringLiteral( "false" ) ) == QLatin1String( "true" ) ? true : false; @@ -722,7 +718,7 @@ QgsExpressionContext QgsAtlasComposition::createExpressionContext() { QgsExpressionContext expressionContext; expressionContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope(); + << QgsExpressionContextUtils::projectScope( mComposition->project() ); if ( mComposition ) expressionContext << QgsExpressionContextUtils::compositionScope( mComposition ); diff --git a/src/core/composer/qgsatlascomposition.h b/src/core/composer/qgsatlascomposition.h index 3ce5f287166..e7529f9ad52 100644 --- a/src/core/composer/qgsatlascomposition.h +++ b/src/core/composer/qgsatlascomposition.h @@ -16,9 +16,11 @@ #ifndef QGSATLASCOMPOSITION_H #define QGSATLASCOMPOSITION_H +#include "qgis_core.h" #include "qgsfeature.h" #include "qgsgeometry.h" #include "qgsrectangle.h" +#include "qgsexpression.h" #include #include @@ -45,7 +47,6 @@ class CORE_EXPORT QgsAtlasComposition : public QObject Q_OBJECT public: QgsAtlasComposition( QgsComposition* composition ); - ~QgsAtlasComposition(); /** Returns whether the atlas generation is enabled * @returns true if atlas is enabled diff --git a/src/core/composer/qgscomposerarrow.cpp b/src/core/composer/qgscomposerarrow.cpp index 9b710994082..0352e56998f 100644 --- a/src/core/composer/qgscomposerarrow.cpp +++ b/src/core/composer/qgscomposerarrow.cpp @@ -258,7 +258,7 @@ void QgsComposerArrow::drawSVGMarker( QPainter* p, MarkerType type, const QStrin return; QSvgRenderer r; - const QByteArray &svgContent = QgsSvgCache::instance()->svgContent( svgFileName, mArrowHeadWidth, mArrowHeadFillColor, mArrowHeadOutlineColor, mArrowHeadOutlineWidth, + const QByteArray &svgContent = QgsApplication::svgCache()->svgContent( svgFileName, mArrowHeadWidth, mArrowHeadFillColor, mArrowHeadOutlineColor, mArrowHeadOutlineWidth, 1.0, 1.0 ); r.load( svgContent ); diff --git a/src/core/composer/qgscomposerarrow.h b/src/core/composer/qgscomposerarrow.h index 9d2cf13d350..5e929ada1e7 100644 --- a/src/core/composer/qgscomposerarrow.h +++ b/src/core/composer/qgscomposerarrow.h @@ -18,6 +18,7 @@ #ifndef QGSCOMPOSERARROW_H #define QGSCOMPOSERARROW_H +#include "qgis_core.h" #include "qgscomposeritem.h" #include #include diff --git a/src/core/composer/qgscomposerattributetablemodelv2.cpp b/src/core/composer/qgscomposerattributetablemodelv2.cpp index e7ccb3401e7..0569469a1d8 100644 --- a/src/core/composer/qgscomposerattributetablemodelv2.cpp +++ b/src/core/composer/qgscomposerattributetablemodelv2.cpp @@ -26,12 +26,6 @@ QgsComposerAttributeTableColumnModelV2::QgsComposerAttributeTableColumnModelV2( QgsComposerAttributeTableV2 *composerTable, QObject *parent ) : QAbstractTableModel( parent ) , mComposerTable( composerTable ) { - -} - -QgsComposerAttributeTableColumnModelV2::~QgsComposerAttributeTableColumnModelV2() -{ - } QModelIndex QgsComposerAttributeTableColumnModelV2::index( int row, int column, const QModelIndex &parent ) const @@ -451,11 +445,6 @@ QgsComposerTableSortColumnsProxyModelV2::QgsComposerTableSortColumnsProxyModelV2 setDynamicSortFilter( true ); } -QgsComposerTableSortColumnsProxyModelV2::~QgsComposerTableSortColumnsProxyModelV2() -{ - -} - bool QgsComposerTableSortColumnsProxyModelV2::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const { //get QgsComposerTableColumn corresponding to row diff --git a/src/core/composer/qgscomposerattributetablemodelv2.h b/src/core/composer/qgscomposerattributetablemodelv2.h index f1b6a648710..36c698af0dc 100644 --- a/src/core/composer/qgscomposerattributetablemodelv2.h +++ b/src/core/composer/qgscomposerattributetablemodelv2.h @@ -21,6 +21,8 @@ #include #include +#include "qgis_core.h" + class QgsComposerAttributeTableV2; class QgsComposerTableColumn; @@ -48,7 +50,6 @@ class CORE_EXPORT QgsComposerAttributeTableColumnModelV2: public QAbstractTableM * @param parent optional parent */ QgsComposerAttributeTableColumnModelV2( QgsComposerAttributeTableV2 *composerTable, QObject *parent = nullptr ); - virtual ~QgsComposerAttributeTableColumnModelV2(); virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const override; int columnCount( const QModelIndex &parent = QModelIndex() ) const override; @@ -150,8 +151,6 @@ class CORE_EXPORT QgsComposerTableSortColumnsProxyModelV2: public QSortFilterPro */ QgsComposerTableSortColumnsProxyModelV2( QgsComposerAttributeTableV2 *composerTable, ColumnFilterType filterType, QObject *parent = nullptr ); - virtual ~QgsComposerTableSortColumnsProxyModelV2(); - bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override; int columnCount( const QModelIndex &parent = QModelIndex() ) const override; virtual QVariant data( const QModelIndex &index, int role ) const override; diff --git a/src/core/composer/qgscomposerattributetablev2.cpp b/src/core/composer/qgscomposerattributetablev2.cpp index 24b047f95b3..1dded1b143f 100644 --- a/src/core/composer/qgscomposerattributetablev2.cpp +++ b/src/core/composer/qgscomposerattributetablev2.cpp @@ -62,7 +62,7 @@ QgsComposerAttributeTableV2::QgsComposerAttributeTableV2( QgsComposition* compos , mFeatureFilter( QLatin1String( "" ) ) { //set first vector layer from layer registry as default one - QMap layerMap = QgsProject::instance()->mapLayers(); + QMap layerMap = mComposition->project()->mapLayers(); QMap::const_iterator mapIt = layerMap.constBegin(); for ( ; mapIt != layerMap.constEnd(); ++mapIt ) { @@ -79,10 +79,11 @@ QgsComposerAttributeTableV2::QgsComposerAttributeTableV2( QgsComposition* compos //listen for modifications to layer and refresh table when they occur connect( mVectorLayer, SIGNAL( layerModified() ), this, SLOT( refreshAttributes() ) ); } - connect( QgsProject::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); if ( mComposition ) { + connect( mComposition->project(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); + //refresh table attributes when composition is refreshed connect( mComposition, SIGNAL( refreshItemsTriggered() ), this, SLOT( refreshAttributes() ) ); @@ -95,10 +96,6 @@ QgsComposerAttributeTableV2::QgsComposerAttributeTableV2( QgsComposition* compos refreshAttributes(); } -QgsComposerAttributeTableV2::~QgsComposerAttributeTableV2() -{ -} - QString QgsComposerAttributeTableV2::displayName() const { return tr( "" ); @@ -144,7 +141,7 @@ void QgsComposerAttributeTableV2::setRelationId( const QString& relationId ) QgsVectorLayer* prevLayer = sourceLayer(); mRelationId = relationId; - QgsRelation relation = QgsProject::instance()->relationManager()->relation( mRelationId ); + QgsRelation relation = mComposition->project()->relationManager()->relation( mRelationId ); QgsVectorLayer* newLayer = relation.referencingLayer(); if ( mSource == QgsComposerAttributeTableV2::RelationChildren && newLayer != prevLayer ) @@ -442,7 +439,7 @@ bool QgsComposerAttributeTableV2::getTableContents( QgsComposerTableContents &co if ( mSource == QgsComposerAttributeTableV2::RelationChildren ) { - QgsRelation relation = QgsProject::instance()->relationManager()->relation( mRelationId ); + QgsRelation relation = mComposition->project()->relationManager()->relation( mRelationId ); QgsFeature atlasFeature = mComposition->atlasComposition().feature(); req = relation.getRelatedFeaturesRequest( atlasFeature ); } @@ -568,7 +565,7 @@ QgsVectorLayer *QgsComposerAttributeTableV2::sourceLayer() return mVectorLayer; case QgsComposerAttributeTableV2::RelationChildren: { - QgsRelation relation = QgsProject::instance()->relationManager()->relation( mRelationId ); + QgsRelation relation = mComposition->project()->relationManager()->relation( mRelationId ); return relation.referencingLayer(); } } @@ -735,7 +732,7 @@ bool QgsComposerAttributeTableV2::readXml( const QDomElement& itemElem, const QD } else { - QgsMapLayer* ml = QgsProject::instance()->mapLayer( layerId ); + QgsMapLayer* ml = mComposition->project()->mapLayer( layerId ); if ( ml ) { mVectorLayer = dynamic_cast( ml ); diff --git a/src/core/composer/qgscomposerattributetablev2.h b/src/core/composer/qgscomposerattributetablev2.h index fde6a128b34..f2569053f37 100644 --- a/src/core/composer/qgscomposerattributetablev2.h +++ b/src/core/composer/qgscomposerattributetablev2.h @@ -18,6 +18,7 @@ #ifndef QGSCOMPOSERATTRIBUTETABLEV2_H #define QGSCOMPOSERATTRIBUTETABLEV2_H +#include "qgis_core.h" #include "qgscomposertablev2.h" class QgsComposerMap; @@ -67,7 +68,6 @@ class CORE_EXPORT QgsComposerAttributeTableV2: public QgsComposerTableV2 }; QgsComposerAttributeTableV2( QgsComposition* composition, bool createUndoCommands ); - ~QgsComposerAttributeTableV2(); virtual QString displayName() const override; @@ -101,7 +101,7 @@ class CORE_EXPORT QgsComposerAttributeTableV2: public QgsComposerTableV2 */ ContentSource source() const { return mSource; } - /** Returns the source layer for the table, considering the table source mode. Eg, + /** Returns the source layer for the table, considering the table source mode. For example, * if the table is set to atlas feature mode, then the source layer will be the * atlas coverage layer. If the table is set to layer attributes mode, then * the source layer will be the user specified vector layer. diff --git a/src/core/composer/qgscomposereffect.cpp b/src/core/composer/qgscomposereffect.cpp index 1cb4ff57ca9..895dcd77d72 100644 --- a/src/core/composer/qgscomposereffect.cpp +++ b/src/core/composer/qgscomposereffect.cpp @@ -24,10 +24,6 @@ QgsComposerEffect::QgsComposerEffect() { } -QgsComposerEffect::~QgsComposerEffect() -{ -} - void QgsComposerEffect::draw( QPainter *painter ) { QPoint offset; diff --git a/src/core/composer/qgscomposereffect.h b/src/core/composer/qgscomposereffect.h index d6069a6d43d..a9afdfe3b5e 100644 --- a/src/core/composer/qgscomposereffect.h +++ b/src/core/composer/qgscomposereffect.h @@ -21,6 +21,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * \class QgsComposerEffect */ @@ -30,7 +32,6 @@ class CORE_EXPORT QgsComposerEffect : public QGraphicsEffect public: QgsComposerEffect(); - ~QgsComposerEffect(); void setCompositionMode( QPainter::CompositionMode compositionMode ); diff --git a/src/core/composer/qgscomposerframe.cpp b/src/core/composer/qgscomposerframe.cpp index 6efc2194901..0fc39afa9eb 100644 --- a/src/core/composer/qgscomposerframe.cpp +++ b/src/core/composer/qgscomposerframe.cpp @@ -46,10 +46,6 @@ QgsComposerFrame::QgsComposerFrame() setBackgroundEnabled( false ); } -QgsComposerFrame::~QgsComposerFrame() -{ -} - bool QgsComposerFrame::writeXml( QDomElement& elem, QDomDocument & doc ) const { QDomElement frameElem = doc.createElement( QStringLiteral( "ComposerFrame" ) ); diff --git a/src/core/composer/qgscomposerframe.h b/src/core/composer/qgscomposerframe.h index 323565a59f5..1eefd82b0e4 100644 --- a/src/core/composer/qgscomposerframe.h +++ b/src/core/composer/qgscomposerframe.h @@ -16,6 +16,7 @@ #ifndef QGSCOMPOSERFRAME_H #define QGSCOMPOSERFRAME_H +#include "qgis_core.h" #include "qgscomposeritem.h" class QgsComposition; @@ -31,8 +32,6 @@ class CORE_EXPORT QgsComposerFrame: public QgsComposerItem public: QgsComposerFrame( QgsComposition* c, QgsComposerMultiFrame* mf, qreal x, qreal y, qreal width, qreal height ); - ~QgsComposerFrame(); - /** Sets the visible part of the multiframe's content which is visible within * this frame (relative to the total multiframe extent in mm). * @param section visible portion of content diff --git a/src/core/composer/qgscomposerhtml.cpp b/src/core/composer/qgscomposerhtml.cpp index 18bbbc2059e..c59622384c9 100644 --- a/src/core/composer/qgscomposerhtml.cpp +++ b/src/core/composer/qgscomposerhtml.cpp @@ -185,7 +185,7 @@ void QgsComposerHtml::loadHtml( const bool useCache, const QgsExpressionContext //set html, using the specified url as base if in Url mode or the project file if in manual mode const QUrl baseUrl = mContentMode == QgsComposerHtml::Url ? QUrl( mActualFetchedUrl ) : - QUrl::fromLocalFile( QgsProject::instance()->fileInfo().absoluteFilePath() ); + QUrl::fromLocalFile( mComposition->project()->fileInfo().absoluteFilePath() ); mWebPage->mainFrame()->setHtml( loadedHtml, baseUrl ); //set user stylesheet @@ -547,8 +547,8 @@ void QgsComposerHtml::setExpressionContext( const QgsFeature &feature, QgsVector if ( mComposition ) { mDistanceArea->setEllipsoidalMode( mComposition->mapSettings().hasCrsTransformEnabled() ); + mDistanceArea->setEllipsoid( mComposition->project()->ellipsoid() ); } - mDistanceArea->setEllipsoid( QgsProject::instance()->ellipsoid() ); // create JSON representation of feature QgsJSONExporter exporter( layer ); diff --git a/src/core/composer/qgscomposerhtml.h b/src/core/composer/qgscomposerhtml.h index d083c6192f7..c915d17edff 100644 --- a/src/core/composer/qgscomposerhtml.h +++ b/src/core/composer/qgscomposerhtml.h @@ -16,6 +16,7 @@ #ifndef QGSCOMPOSERHTML_H #define QGSCOMPOSERHTML_H +#include "qgis_core.h" #include "qgscomposermultiframe.h" #include "qgsfeature.h" #include diff --git a/src/core/composer/qgscomposeritem.h b/src/core/composer/qgscomposeritem.h index 05f4580e432..d96f287623e 100644 --- a/src/core/composer/qgscomposeritem.h +++ b/src/core/composer/qgscomposeritem.h @@ -17,6 +17,7 @@ #ifndef QGSCOMPOSERITEM_H #define QGSCOMPOSERITEM_H +#include "qgis_core.h" #include "qgscomposeritemcommand.h" #include "qgscomposerobject.h" #include @@ -375,7 +376,7 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec */ void setTransparency( const int transparency ); - /** Returns whether effects (eg blend modes) are enabled for the item + /** Returns whether effects (e.g., blend modes) are enabled for the item * @returns true if effects are enabled * @see setEffectsEnabled * @see transparency @@ -383,7 +384,7 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec */ bool effectsEnabled() const { return mEffectsEnabled; } - /** Sets whether effects (eg blend modes) are enabled for the item + /** Sets whether effects (e.g., blend modes) are enabled for the item * @param effectsEnabled set to true to enable effects * @see effectsEnabled * @see setTransparency @@ -467,7 +468,7 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec /** Sets visibility for item. * @param visible set to true to show item, false to hide item * @note QGraphicsItem::setVisible should not be called directly - * on a QgsComposerItem, as some item types (eg groups) need to override + * on a QgsComposerItem, as some item types (e.g., groups) need to override * the visibility toggle. * @note added in version 2.5 */ diff --git a/src/core/composer/qgscomposeritemcommand.cpp b/src/core/composer/qgscomposeritemcommand.cpp index 8c29729d941..233a0b01f5f 100644 --- a/src/core/composer/qgscomposeritemcommand.cpp +++ b/src/core/composer/qgscomposeritemcommand.cpp @@ -19,6 +19,7 @@ #include "qgscomposeritem.h" #include "qgscomposerframe.h" #include "qgscomposermultiframe.h" +#include "qgscomposition.h" #include "qgsproject.h" #include "qgslogger.h" @@ -39,10 +40,6 @@ QgsComposerItemCommand::QgsComposerItemCommand( QgsComposerItem* item, const QSt } } -QgsComposerItemCommand::~QgsComposerItemCommand() -{ -} - void QgsComposerItemCommand::undo() { restoreState( mPreviousState ); @@ -118,7 +115,7 @@ void QgsComposerItemCommand::restoreState( QDomDocument& stateDoc ) const destItem->readXml( stateDoc.documentElement().firstChild().toElement(), stateDoc ); destItem->repaint(); - QgsProject::instance()->setDirty( true ); + destItem->composition()->project()->setDirty( true ); } // @@ -131,10 +128,6 @@ QgsComposerMergeCommand::QgsComposerMergeCommand( Context c, QgsComposerItem* it { } -QgsComposerMergeCommand::~QgsComposerMergeCommand() -{ -} - bool QgsComposerMergeCommand::mergeWith( const QUndoCommand * command ) { QgsComposerItem* thisItem = item(); diff --git a/src/core/composer/qgscomposeritemcommand.h b/src/core/composer/qgscomposeritemcommand.h index 00ca73049f4..49c765743c2 100644 --- a/src/core/composer/qgscomposeritemcommand.h +++ b/src/core/composer/qgscomposeritemcommand.h @@ -21,6 +21,8 @@ #include #include +#include "qgis_core.h" + class QgsComposerItem; class QgsComposerMultiFrame; @@ -31,7 +33,6 @@ class CORE_EXPORT QgsComposerItemCommand: public QUndoCommand { public: QgsComposerItemCommand( QgsComposerItem* item, const QString& text, QUndoCommand* parent = nullptr ); - virtual ~QgsComposerItemCommand(); //! Reverses the command void undo() override; @@ -157,7 +158,6 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand }; QgsComposerMergeCommand( Context c, QgsComposerItem* item, const QString& text ); - ~QgsComposerMergeCommand(); bool mergeWith( const QUndoCommand * command ) override; int id() const override { return static_cast< int >( mContext ); } diff --git a/src/core/composer/qgscomposeritemgroup.h b/src/core/composer/qgscomposeritemgroup.h index 09e3132963a..8ab27ed3b63 100644 --- a/src/core/composer/qgscomposeritemgroup.h +++ b/src/core/composer/qgscomposeritemgroup.h @@ -17,6 +17,7 @@ #ifndef QGSCOMPOSERITEMGROUP_H #define QGSCOMPOSERITEMGROUP_H +#include "qgis_core.h" #include "qgscomposeritem.h" #include diff --git a/src/core/composer/qgscomposerlabel.cpp b/src/core/composer/qgscomposerlabel.cpp index f76f07deaca..ac996b60287 100644 --- a/src/core/composer/qgscomposerlabel.cpp +++ b/src/core/composer/qgscomposerlabel.cpp @@ -165,7 +165,7 @@ void QgsComposerLabel::contentChanged() //set this to true after html is loaded. mHtmlLoaded = false; - const QUrl baseUrl = QUrl::fromLocalFile( QgsProject::instance()->fileInfo().absoluteFilePath() ); + const QUrl baseUrl = QUrl::fromLocalFile( mComposition->project()->fileInfo().absoluteFilePath() ); mWebPage->mainFrame()->setHtml( textToDraw, baseUrl ); //For very basic html labels with no external assets, the html load will already be @@ -265,7 +265,7 @@ void QgsComposerLabel::refreshExpressionContext() mDistanceArea->setSourceCrs( mComposition->mapSettings().destinationCrs().srsid() ); } mDistanceArea->setEllipsoidalMode( mComposition->mapSettings().hasCrsTransformEnabled() ); - mDistanceArea->setEllipsoid( QgsProject::instance()->ellipsoid() ); + mDistanceArea->setEllipsoid( mComposition->project()->ellipsoid() ); contentChanged(); update(); diff --git a/src/core/composer/qgscomposerlabel.h b/src/core/composer/qgscomposerlabel.h index 300adc7ecb4..269720587f8 100644 --- a/src/core/composer/qgscomposerlabel.h +++ b/src/core/composer/qgscomposerlabel.h @@ -17,6 +17,7 @@ #ifndef QGSCOMPOSERLABEL_H #define QGSCOMPOSERLABEL_H +#include "qgis_core.h" #include "qgscomposeritem.h" #include diff --git a/src/core/composer/qgscomposerlegend.cpp b/src/core/composer/qgscomposerlegend.cpp index 160a754a9d2..20db111265d 100644 --- a/src/core/composer/qgscomposerlegend.cpp +++ b/src/core/composer/qgscomposerlegend.cpp @@ -46,14 +46,14 @@ QgsComposerLegend::QgsComposerLegend( QgsComposition* composition ) , mForceResize( false ) , mSizeToContents( true ) { - mLegendModel = new QgsLegendModel( QgsProject::instance()->layerTreeRoot() ); + mLegendModel = new QgsLegendModel( mComposition->project()->layerTreeRoot() ); connect( &composition->atlasComposition(), SIGNAL( renderEnded() ), this, SLOT( onAtlasEnded() ) ); connect( &composition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( onAtlasFeature( QgsFeature* ) ) ); // Connect to the main layertreeroot. // It serves in "auto update mode" as a medium between the main app legend and this one - connect( QgsProject::instance()->layerTreeRoot(), SIGNAL( customPropertyChanged( QgsLayerTreeNode*, QString ) ), this, SLOT( nodeCustomPropertyChanged( QgsLayerTreeNode*, QString ) ) ); + connect( mComposition->project()->layerTreeRoot(), SIGNAL( customPropertyChanged( QgsLayerTreeNode*, QString ) ), this, SLOT( nodeCustomPropertyChanged( QgsLayerTreeNode*, QString ) ) ); } QgsComposerLegend::QgsComposerLegend() @@ -225,7 +225,7 @@ bool QgsComposerLegend::resizeToContents() const void QgsComposerLegend::setCustomLayerTree( QgsLayerTreeGroup* rootGroup ) { - mLegendModel->setRootGroup( rootGroup ? rootGroup : QgsProject::instance()->layerTreeRoot() ); + mLegendModel->setRootGroup( rootGroup ? rootGroup : mComposition->project()->layerTreeRoot() ); delete mCustomLayerTree; mCustomLayerTree = rootGroup; @@ -237,7 +237,7 @@ void QgsComposerLegend::setAutoUpdateModel( bool autoUpdate ) if ( autoUpdate == autoUpdateModel() ) return; - setCustomLayerTree( autoUpdate ? nullptr : QgsLayerTree::toGroup( QgsProject::instance()->layerTreeRoot()->clone() ) ); + setCustomLayerTree( autoUpdate ? nullptr : QgsLayerTree::toGroup( mComposition->project()->layerTreeRoot()->clone() ) ); adjustBoxSize(); updateItem(); } @@ -414,7 +414,7 @@ bool QgsComposerLegend::writeXml( QDomElement& elem, QDomDocument & doc ) const return _writeXml( composerLegendElem, doc ); } -static void _readOldLegendGroup( QDomElement& elem, QgsLayerTreeGroup* parentGroup ) +static void _readOldLegendGroup( QDomElement& elem, QgsLayerTreeGroup* parentGroup, QgsProject* project ) { QDomElement itemElem = elem.firstChildElement(); @@ -424,7 +424,7 @@ static void _readOldLegendGroup( QDomElement& elem, QgsLayerTreeGroup* parentGro if ( itemElem.tagName() == QLatin1String( "LayerItem" ) ) { QString layerId = itemElem.attribute( QStringLiteral( "layerId" ) ); - if ( QgsMapLayer* layer = QgsProject::instance()->mapLayer( layerId ) ) + if ( QgsMapLayer* layer = project->mapLayer( layerId ) ) { QgsLayerTreeLayer* nodeLayer = parentGroup->addLayer( layer ); QString userText = itemElem.attribute( QStringLiteral( "userText" ) ); @@ -447,7 +447,7 @@ static void _readOldLegendGroup( QDomElement& elem, QgsLayerTreeGroup* parentGro if ( !style.isEmpty() ) nodeGroup->setCustomProperty( QStringLiteral( "legend/title-style" ), style ); - _readOldLegendGroup( itemElem, nodeGroup ); + _readOldLegendGroup( itemElem, nodeGroup, project ); } itemElem = itemElem.nextSiblingElement(); @@ -527,7 +527,7 @@ bool QgsComposerLegend::readXml( const QDomElement& itemElem, const QDomDocument { // QGIS <= 2.4 QgsLayerTreeGroup* nodeRoot = new QgsLayerTreeGroup(); - _readOldLegendGroup( oldLegendModelElem, nodeRoot ); + _readOldLegendGroup( oldLegendModelElem, nodeRoot, mComposition->project() ); setCustomLayerTree( nodeRoot ); } else @@ -687,7 +687,7 @@ void QgsComposerLegend::doUpdateFilterByMap() mLegendModel->setLayerStyleOverrides( QMap() ); - bool filterByExpression = QgsLayerTreeUtils::hasLegendFilterExpression( *( mCustomLayerTree ? mCustomLayerTree : QgsProject::instance()->layerTreeRoot() ) ); + bool filterByExpression = QgsLayerTreeUtils::hasLegendFilterExpression( *( mCustomLayerTree ? mCustomLayerTree : mComposition->project()->layerTreeRoot() ) ); if ( mComposerMap && ( mLegendFilterByMap || filterByExpression || mInAtlas ) ) { diff --git a/src/core/composer/qgscomposerlegend.h b/src/core/composer/qgscomposerlegend.h index 1d257d6f188..8fb098434a9 100644 --- a/src/core/composer/qgscomposerlegend.h +++ b/src/core/composer/qgscomposerlegend.h @@ -18,6 +18,7 @@ #ifndef QGSCOMPOSERLEGEND_H #define QGSCOMPOSERLEGEND_H +#include "qgis_core.h" #include "qgscomposeritem.h" #include "qgslayertreemodel.h" #include "qgslegendsettings.h" diff --git a/src/core/composer/qgscomposermap.cpp b/src/core/composer/qgscomposermap.cpp index 1d65d85b59b..08b0cabc344 100644 --- a/src/core/composer/qgscomposermap.cpp +++ b/src/core/composer/qgscomposermap.cpp @@ -77,10 +77,12 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int w mXOffset = 0.0; mYOffset = 0.0; + QgsProject* project = mComposition->project(); + //get the color for map canvas background and set map background color accordingly - int bgRedInt = QgsProject::instance()->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorRedPart" ), 255 ); - int bgGreenInt = QgsProject::instance()->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorGreenPart" ), 255 ); - int bgBlueInt = QgsProject::instance()->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorBluePart" ), 255 ); + int bgRedInt = project->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorRedPart" ), 255 ); + int bgGreenInt = project->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorGreenPart" ), 255 ); + int bgBlueInt = project->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorBluePart" ), 255 ); setBackgroundColor( QColor( bgRedInt, bgGreenInt, bgBlueInt ) ); //calculate mExtent based on width/height ratio and map canvas extent @@ -218,7 +220,7 @@ QgsMapSettings QgsComposerMap::mapSettings( const QgsRectangle& extent, QSizeF s const int layerIdx = mCurrentExportLayer - ( hasBackground() ? 1 : 0 ); if ( layerIdx >= 0 && layerIdx < layers.length() ) { - // exporting with separate layers (eg, to svg layers), so we only want to render a single map layer + // exporting with separate layers (e.g., to svg layers), so we only want to render a single map layer QgsMapLayer* ml = layers[ layers.length() - layerIdx - 1 ]; layers.clear(); layers << ml; @@ -544,8 +546,8 @@ QList QgsComposerMap::layersToRender( const QgsExpressionContext* presetName = exprVal.toString(); } - if ( QgsProject::instance()->mapThemeCollection()->hasMapTheme( presetName ) ) - renderLayers = QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( presetName ); + if ( mComposition->project()->mapThemeCollection()->hasMapTheme( presetName ) ) + renderLayers = mComposition->project()->mapThemeCollection()->mapThemeVisibleLayers( presetName ); else // fallback to using map canvas layers renderLayers = mComposition->mapSettings().layers(); } @@ -567,7 +569,7 @@ QList QgsComposerMap::layersToRender( const QgsExpressionContext* //need to convert layer names to layer ids Q_FOREACH ( const QString& name, layerNames ) { - QList< QgsMapLayer* > matchingLayers = QgsProject::instance()->mapLayersByName( name ); + QList< QgsMapLayer* > matchingLayers = mComposition->project()->mapLayersByName( name ); Q_FOREACH ( QgsMapLayer* layer, matchingLayers ) { renderLayers << layer; @@ -605,8 +607,8 @@ QMap QgsComposerMap::layerStyleOverridesToRender( const QgsExp presetName = exprVal.toString(); } - if ( QgsProject::instance()->mapThemeCollection()->hasMapTheme( presetName ) ) - return QgsProject::instance()->mapThemeCollection()->mapThemeStyleOverrides( presetName ); + if ( mComposition->project()->mapThemeCollection()->hasMapTheme( presetName ) ) + return mComposition->project()->mapThemeCollection()->mapThemeStyleOverrides( presetName ); else return QMap(); } @@ -1200,7 +1202,7 @@ bool QgsComposerMap::containsAdvancedEffects() const void QgsComposerMap::connectUpdateSlot() { //connect signal from layer registry to update in case of new or deleted layers - QgsProject* project = QgsProject::instance(); + QgsProject* project = mComposition->project(); if ( project ) { connect( project, SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( layersChanged() ) ); @@ -1403,7 +1405,7 @@ bool QgsComposerMap::readXml( const QDomElement& itemElem, const QDomDocument& d for ( int i = 0; i < layerIdNodeList.size(); ++i ) { QString layerId = layerIdNodeList.at( i ).toElement().text(); - if ( QgsMapLayer* ml = QgsProject::instance()->mapLayer( layerId ) ) + if ( QgsMapLayer* ml = mComposition->project()->mapLayer( layerId ) ) mLayers << ml; } } @@ -1615,7 +1617,7 @@ void QgsComposerMap::syncLayerSet() QList currentLayers; if ( mKeepLayerSet ) { - currentLayers = QgsProject::instance()->mapLayers().values(); + currentLayers = mComposition->project()->mapLayers().values(); } else //only consider layers visible in the map { diff --git a/src/core/composer/qgscomposermap.h b/src/core/composer/qgscomposermap.h index a1d89253705..c8d32392c3b 100644 --- a/src/core/composer/qgscomposermap.h +++ b/src/core/composer/qgscomposermap.h @@ -18,6 +18,7 @@ #define QGSCOMPOSERMAP_H //#include "ui_qgscomposermapbase.h" +#include "qgis_core.h" #include "qgscomposeritem.h" #include "qgsrectangle.h" #include diff --git a/src/core/composer/qgscomposermapgrid.cpp b/src/core/composer/qgscomposermapgrid.cpp index c4dbd3d43f5..e9218f2839d 100644 --- a/src/core/composer/qgscomposermapgrid.cpp +++ b/src/core/composer/qgscomposermapgrid.cpp @@ -42,10 +42,6 @@ QgsComposerMapGridStack::QgsComposerMapGridStack( QgsComposerMap* map ) } -QgsComposerMapGridStack::~QgsComposerMapGridStack() -{ -} - void QgsComposerMapGridStack::addGrid( QgsComposerMapGrid* grid ) { QgsComposerMapItemStack::addItem( grid ); @@ -1426,7 +1422,7 @@ QString QgsComposerMapGrid::gridAnnotationString( double value, QgsComposerMapGr if ( geographic && coord == QgsComposerMapGrid::Longitude && ( mGridAnnotationFormat == QgsComposerMapGrid::Decimal || mGridAnnotationFormat == QgsComposerMapGrid::DecimalWithSuffix ) ) { - // wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W" + // wrap around longitudes > 180 or < -180 degrees, so that, e.g., "190E" -> "170W" double wrappedX = fmod( value, 360.0 ); if ( wrappedX > 180.0 ) { @@ -1449,7 +1445,7 @@ QString QgsComposerMapGrid::gridAnnotationString( double value, QgsComposerMapGr double coordRounded = qRound( value * pow( 10.0, mGridAnnotationPrecision ) ) / pow( 10.0, mGridAnnotationPrecision ); if ( coord == QgsComposerMapGrid::Longitude ) { - //don't use E/W suffixes if ambiguous (eg 180 degrees) + //don't use E/W suffixes if ambiguous (e.g., 180 degrees) if ( !geographic || ( coordRounded != 180.0 && coordRounded != 0.0 ) ) { hemisphere = value < 0 ? QObject::tr( "W" ) : QObject::tr( "E" ); @@ -1457,7 +1453,7 @@ QString QgsComposerMapGrid::gridAnnotationString( double value, QgsComposerMapGr } else { - //don't use N/S suffixes if ambiguous (eg 0 degrees) + //don't use N/S suffixes if ambiguous (e.g., 0 degrees) if ( !geographic || coordRounded != 0.0 ) { hemisphere = value < 0 ? QObject::tr( "S" ) : QObject::tr( "N" ); diff --git a/src/core/composer/qgscomposermapgrid.h b/src/core/composer/qgscomposermapgrid.h index f08fb2020b8..c8a48e1d988 100644 --- a/src/core/composer/qgscomposermapgrid.h +++ b/src/core/composer/qgscomposermapgrid.h @@ -18,6 +18,7 @@ #ifndef QGSCOMPOSERMAPGRID_H #define QGSCOMPOSERMAPGRID_H +#include "qgis_core.h" #include "qgscomposermapitem.h" #include "qgscoordinatereferencesystem.h" #include "qgsrectangle.h" @@ -51,8 +52,6 @@ class CORE_EXPORT QgsComposerMapGridStack : public QgsComposerMapItemStack */ QgsComposerMapGridStack( QgsComposerMap* map ); - virtual ~QgsComposerMapGridStack(); - /** Adds a new map grid to the stack and takes ownership of the grid. * The grid will be added to the end of the stack, and rendered * above any existing map grids already present in the stack. diff --git a/src/core/composer/qgscomposermapitem.cpp b/src/core/composer/qgscomposermapitem.cpp index b14254216c8..85da235edd4 100644 --- a/src/core/composer/qgscomposermapitem.cpp +++ b/src/core/composer/qgscomposermapitem.cpp @@ -29,11 +29,6 @@ QgsComposerMapItem::QgsComposerMapItem( const QString &name, QgsComposerMap *map } -QgsComposerMapItem::~QgsComposerMapItem() -{ - -} - bool QgsComposerMapItem::writeXml( QDomElement &elem, QDomDocument &doc ) const { Q_UNUSED( doc ); diff --git a/src/core/composer/qgscomposermapitem.h b/src/core/composer/qgscomposermapitem.h index d1c25afc1fc..53053f00b71 100644 --- a/src/core/composer/qgscomposermapitem.h +++ b/src/core/composer/qgscomposermapitem.h @@ -17,13 +17,14 @@ #ifndef QGSCOMPOSERMAPITEM_H #define QGSCOMPOSERMAPITEM_H +#include "qgis_core.h" #include "qgscomposerobject.h" class QgsComposerMap; /** \ingroup core * \class QgsComposerMapItem - * \brief An item which is drawn inside a QgsComposerMap, eg a grid or map overview. + * \brief An item which is drawn inside a QgsComposerMap, e.g., a grid or map overview. */ class CORE_EXPORT QgsComposerMapItem : public QgsComposerObject { @@ -37,8 +38,6 @@ class CORE_EXPORT QgsComposerMapItem : public QgsComposerObject */ QgsComposerMapItem( const QString& name, QgsComposerMap* map ); - virtual ~QgsComposerMapItem(); - /** Draws the item on to a painter * @param painter destination QPainter */ diff --git a/src/core/composer/qgscomposermapoverview.cpp b/src/core/composer/qgscomposermapoverview.cpp index 427f865e155..de5d3413fa5 100644 --- a/src/core/composer/qgscomposermapoverview.cpp +++ b/src/core/composer/qgscomposermapoverview.cpp @@ -314,11 +314,6 @@ QgsComposerMapOverviewStack::QgsComposerMapOverviewStack( QgsComposerMap *map ) } -QgsComposerMapOverviewStack::~QgsComposerMapOverviewStack() -{ - -} - void QgsComposerMapOverviewStack::addOverview( QgsComposerMapOverview *overview ) { QgsComposerMapItemStack::addItem( overview ); diff --git a/src/core/composer/qgscomposermapoverview.h b/src/core/composer/qgscomposermapoverview.h index a2544400c5f..dfda85ce5c6 100644 --- a/src/core/composer/qgscomposermapoverview.h +++ b/src/core/composer/qgscomposermapoverview.h @@ -18,6 +18,7 @@ #ifndef QGSCOMPOSERMAPOVERVIEW_H #define QGSCOMPOSERMAPOVERVIEW_H +#include "qgis_core.h" #include "qgscomposermapitem.h" #include #include @@ -45,8 +46,6 @@ class CORE_EXPORT QgsComposerMapOverviewStack : public QgsComposerMapItemStack */ QgsComposerMapOverviewStack( QgsComposerMap* map ); - virtual ~QgsComposerMapOverviewStack(); - /** Adds a new map overview to the stack and takes ownership of the overview. * The overview will be added to the end of the stack, and rendered * above any existing map overviews already present in the stack. diff --git a/src/core/composer/qgscomposermodel.cpp b/src/core/composer/qgscomposermodel.cpp index 53abef4ed08..659168a4ee4 100644 --- a/src/core/composer/qgscomposermodel.cpp +++ b/src/core/composer/qgscomposermodel.cpp @@ -36,10 +36,6 @@ QgsComposerModel::QgsComposerModel( QgsComposition* composition, QObject *parent } -QgsComposerModel::~QgsComposerModel() -{ -} - QgsComposerItem* QgsComposerModel::itemFromIndex( const QModelIndex &index ) const { //try to return the QgsComposerItem corresponding to a QModelIndex @@ -537,7 +533,7 @@ void QgsComposerModel::removeItem( QgsComposerItem * item ) QModelIndex itemIndex = indexForItem( item ); if ( !itemIndex.isValid() ) { - //removing an item not in the scene (eg, deleted item) + //removing an item not in the scene (e.g., deleted item) //we need to remove it from the list, but don't need to call //beginRemoveRows or endRemoveRows since the item was not used by the model mItemZList.removeAt( pos ); diff --git a/src/core/composer/qgscomposermodel.h b/src/core/composer/qgscomposermodel.h index 6d829725524..872dfe01c50 100644 --- a/src/core/composer/qgscomposermodel.h +++ b/src/core/composer/qgscomposermodel.h @@ -18,6 +18,7 @@ #ifndef QGSCOMPOSERMODEL_H #define QGSCOMPOSERMODEL_H +#include "qgis_core.h" #include #include #include @@ -65,8 +66,6 @@ class CORE_EXPORT QgsComposerModel: public QAbstractItemModel */ explicit QgsComposerModel( QgsComposition* composition, QObject* parent = nullptr ); - ~QgsComposerModel(); - //reimplemented QAbstractItemModel methods QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override; QModelIndex parent( const QModelIndex &index ) const override; diff --git a/src/core/composer/qgscomposermousehandles.cpp b/src/core/composer/qgscomposermousehandles.cpp index 722a9cc5811..9509c1b8ece 100644 --- a/src/core/composer/qgscomposermousehandles.cpp +++ b/src/core/composer/qgscomposermousehandles.cpp @@ -52,11 +52,6 @@ QgsComposerMouseHandles::QgsComposerMouseHandles( QgsComposition *composition ) setAcceptHoverEvents( true ); } -QgsComposerMouseHandles::~QgsComposerMouseHandles() -{ - -} - QGraphicsView* QgsComposerMouseHandles::graphicsView() { //have we already found the current view? @@ -629,7 +624,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent* event subcommand->saveAfterState(); } mComposition->undoStack()->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mComposition->project()->setDirty( true ); } else if ( mCurrentMouseMoveAction != QgsComposerMouseHandles::NoAction ) { @@ -643,7 +638,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent* event { if (( *itemIter )->positionLock() || (( *itemIter )->flags() & QGraphicsItem::ItemIsSelectable ) == 0 ) { - //don't resize locked items or unselectable items (eg, items which make up an item group) + //don't resize locked items or unselectable items (e.g., items which make up an item group) continue; } QgsComposerItemCommand* subcommand = new QgsComposerItemCommand( *itemIter, QLatin1String( "" ), parentCommand ); @@ -669,7 +664,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent* event subcommand->saveAfterState(); } mComposition->undoStack()->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mComposition->project()->setDirty( true ); } deleteAlignItems(); @@ -1078,7 +1073,7 @@ void QgsComposerMouseHandles::resizeMouseMove( QPointF currentPosition, bool loc itemTransform.translate( sceneTranslate.x(), sceneTranslate.y() ); setTransform( itemTransform ); - //handle non-normalised resizes - eg, dragging the left handle so far to the right that it's past the right handle + //handle non-normalised resizes - e.g., dragging the left handle so far to the right that it's past the right handle if ( mBeginHandleWidth + rx >= 0 && mBeginHandleHeight + ry >= 0 ) { mResizeRect = QRectF( 0, 0, mBeginHandleWidth + rx, mBeginHandleHeight + ry ); diff --git a/src/core/composer/qgscomposermousehandles.h b/src/core/composer/qgscomposermousehandles.h index a0c3a6c2094..621f8a978e9 100644 --- a/src/core/composer/qgscomposermousehandles.h +++ b/src/core/composer/qgscomposermousehandles.h @@ -20,6 +20,8 @@ #include #include +#include "qgis_core.h" + class QgsComposition; class QgsComposerItem; class QGraphicsView; @@ -70,7 +72,6 @@ class CORE_EXPORT QgsComposerMouseHandles: public QObject, public QGraphicsRectI }; QgsComposerMouseHandles( QgsComposition *composition ); - virtual ~QgsComposerMouseHandles(); void setComposition( QgsComposition* c ) { mComposition = c; } QgsComposition* composition() { return mComposition; } diff --git a/src/core/composer/qgscomposermultiframe.h b/src/core/composer/qgscomposermultiframe.h index 6cb22a18161..467e7209671 100644 --- a/src/core/composer/qgscomposermultiframe.h +++ b/src/core/composer/qgscomposermultiframe.h @@ -16,6 +16,7 @@ #ifndef QGSCOMPOSERMULTIFRAME_H #define QGSCOMPOSERMULTIFRAME_H +#include "qgis_core.h" #include "qgscomposerobject.h" #include #include @@ -214,7 +215,7 @@ class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject /** Creates a new frame and adds it to the multi frame and composition. * @param currentFrame an existing QgsComposerFrame from which to copy the size - * and general frame properties (eg frame style, background, rendering settings). + * and general frame properties (e.g., frame style, background, rendering settings). * @param pos position of top-left corner of the new frame * @param size size of the new frame * @returns new QgsComposerFrame diff --git a/src/core/composer/qgscomposermultiframecommand.cpp b/src/core/composer/qgscomposermultiframecommand.cpp index 3e423e3c84e..e356d354964 100644 --- a/src/core/composer/qgscomposermultiframecommand.cpp +++ b/src/core/composer/qgscomposermultiframecommand.cpp @@ -17,6 +17,7 @@ #include "qgscomposermultiframecommand.h" #include "qgscomposermultiframe.h" +#include "qgscomposition.h" #include "qgsproject.h" QgsComposerMultiFrameCommand::QgsComposerMultiFrameCommand( QgsComposerMultiFrame* multiFrame, const QString& text, QUndoCommand* parent ): @@ -28,10 +29,6 @@ QgsComposerMultiFrameCommand::QgsComposerMultiFrameCommand(): QUndoCommand( QLat { } -QgsComposerMultiFrameCommand::~QgsComposerMultiFrameCommand() -{ -} - void QgsComposerMultiFrameCommand::undo() { restoreState( mPreviousState ); @@ -72,7 +69,7 @@ void QgsComposerMultiFrameCommand::restoreState( QDomDocument& stateDoc ) if ( mMultiFrame ) { mMultiFrame->readXml( stateDoc.documentElement().firstChild().toElement(), stateDoc ); - QgsProject::instance()->setDirty( true ); + mMultiFrame->composition()->project()->setDirty( true ); } } @@ -99,11 +96,6 @@ QgsComposerMultiFrameMergeCommand::QgsComposerMultiFrameMergeCommand( QgsCompose } -QgsComposerMultiFrameMergeCommand::~QgsComposerMultiFrameMergeCommand() -{ - -} - bool QgsComposerMultiFrameMergeCommand::mergeWith( const QUndoCommand *command ) { const QgsComposerMultiFrameCommand* c = dynamic_cast( command ); diff --git a/src/core/composer/qgscomposermultiframecommand.h b/src/core/composer/qgscomposermultiframecommand.h index 86e01918ea2..4a0e539f9b8 100644 --- a/src/core/composer/qgscomposermultiframecommand.h +++ b/src/core/composer/qgscomposermultiframecommand.h @@ -21,6 +21,8 @@ #include #include +#include "qgis_core.h" + class QgsComposerMultiFrame; /** \ingroup core @@ -30,7 +32,6 @@ class CORE_EXPORT QgsComposerMultiFrameCommand: public QUndoCommand { public: QgsComposerMultiFrameCommand( QgsComposerMultiFrame* multiFrame, const QString& text, QUndoCommand* parent = nullptr ); - ~QgsComposerMultiFrameCommand(); void undo() override; void redo() override; @@ -86,7 +87,6 @@ class CORE_EXPORT QgsComposerMultiFrameMergeCommand: public QgsComposerMultiFram }; QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame* multiFrame, const QString& text ); - ~QgsComposerMultiFrameMergeCommand(); bool mergeWith( const QUndoCommand * command ) override; int id() const override { return static_cast< int >( mContext ); } diff --git a/src/core/composer/qgscomposernodesitem.cpp b/src/core/composer/qgscomposernodesitem.cpp index 7b6704b1e40..3c36af008c1 100644 --- a/src/core/composer/qgscomposernodesitem.cpp +++ b/src/core/composer/qgscomposernodesitem.cpp @@ -47,10 +47,6 @@ QgsComposerNodesItem::QgsComposerNodesItem( const QString& tagName, mPolygon = polygon.translated( -topLeft ); } -QgsComposerNodesItem::~QgsComposerNodesItem() -{ -} - double QgsComposerNodesItem::computeDistance( QPointF pt1, QPointF pt2 ) const { diff --git a/src/core/composer/qgscomposernodesitem.h b/src/core/composer/qgscomposernodesitem.h index 5f16b4f290b..6171cc87c2e 100644 --- a/src/core/composer/qgscomposernodesitem.h +++ b/src/core/composer/qgscomposernodesitem.h @@ -17,6 +17,7 @@ #ifndef QGSCOMPOSERNODESITEM_H #define QGSCOMPOSERNODESITEM_H +#include "qgis_core.h" #include "qgscomposeritem.h" #include #include @@ -45,9 +46,6 @@ class CORE_EXPORT QgsComposerNodesItem: public QgsComposerItem */ QgsComposerNodesItem( const QString &mTagName, const QPolygonF &polygon, QgsComposition* c ); - //! Destructor - ~QgsComposerNodesItem(); - /** Add a node in current shape. * @param pt is the location of the new node * @param checkArea is a flag to indicate if there's a space constraint. diff --git a/src/core/composer/qgscomposerobject.cpp b/src/core/composer/qgscomposerobject.cpp index b0bd75cf010..16ad5ff5431 100644 --- a/src/core/composer/qgscomposerobject.cpp +++ b/src/core/composer/qgscomposerobject.cpp @@ -21,6 +21,7 @@ #include "qgscomposerutils.h" #include "qgscomposerobject.h" #include "qgsdatadefined.h" +#include "qgsproject.h" QgsComposerObject::QgsComposerObject( QgsComposition* composition ) : QObject( nullptr ) @@ -195,8 +196,6 @@ QgsExpressionContext QgsComposerObject::createExpressionContext() const } else { - return QgsExpressionContext() - << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope(); + return QgsExpressionContext() << QgsExpressionContextUtils::globalScope(); } } diff --git a/src/core/composer/qgscomposerobject.h b/src/core/composer/qgscomposerobject.h index 97df132496e..069895f5e1c 100644 --- a/src/core/composer/qgscomposerobject.h +++ b/src/core/composer/qgscomposerobject.h @@ -17,6 +17,7 @@ #ifndef QGSCOMPOSEROBJECT_H #define QGSCOMPOSEROBJECT_H +#include "qgis_core.h" #include "qgsobjectcustomproperties.h" #include "qgsexpressioncontextgenerator.h" #include diff --git a/src/core/composer/qgscomposerpicture.cpp b/src/core/composer/qgscomposerpicture.cpp index 5600e680527..291e2b77692 100644 --- a/src/core/composer/qgscomposerpicture.cpp +++ b/src/core/composer/qgscomposerpicture.cpp @@ -99,11 +99,6 @@ void QgsComposerPicture::init() connect( mComposition, SIGNAL( printResolutionChanged() ), this, SLOT( recalculateSize() ) ); } -QgsComposerPicture::~QgsComposerPicture() -{ - -} - void QgsComposerPicture::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) { Q_UNUSED( itemStyle ); @@ -377,7 +372,7 @@ void QgsComposerPicture::loadLocalPicture( const QString &path ) if ( sourceFileSuffix.compare( QLatin1String( "svg" ), Qt::CaseInsensitive ) == 0 ) { //try to open svg - const QByteArray &svgContent = QgsSvgCache::instance()->svgContent( pic.fileName(), rect().width(), mSvgFillColor, mSvgBorderColor, mSvgBorderWidth, + const QByteArray &svgContent = QgsApplication::svgCache()->svgContent( pic.fileName(), rect().width(), mSvgFillColor, mSvgBorderColor, mSvgBorderWidth, 1.0, 1.0 ); mSVG.load( svgContent ); if ( mSVG.isValid() ) @@ -749,7 +744,7 @@ bool QgsComposerPicture::writeXml( QDomElement& elem, QDomDocument & doc ) const return false; } QDomElement composerPictureElem = doc.createElement( QStringLiteral( "ComposerPicture" ) ); - composerPictureElem.setAttribute( QStringLiteral( "file" ), QgsProject::instance()->writePath( mSourcePath ) ); + composerPictureElem.setAttribute( QStringLiteral( "file" ), mComposition->project()->writePath( mSourcePath ) ); composerPictureElem.setAttribute( QStringLiteral( "pictureWidth" ), QString::number( mPictureWidth ) ); composerPictureElem.setAttribute( QStringLiteral( "pictureHeight" ), QString::number( mPictureHeight ) ); composerPictureElem.setAttribute( QStringLiteral( "resizeMode" ), QString::number( static_cast< int >( mResizeMode ) ) ); @@ -827,7 +822,7 @@ bool QgsComposerPicture::readXml( const QDomElement& itemElem, const QDomDocumen setDataDefinedProperty( QgsComposerObject::PictureSource, expressionActive, true, sourceExpression, QString() ); } - mSourcePath = QgsProject::instance()->readPath( itemElem.attribute( QStringLiteral( "file" ) ) ); + mSourcePath = mComposition->project()->readPath( itemElem.attribute( QStringLiteral( "file" ) ) ); //picture rotation if ( !qgsDoubleNear( itemElem.attribute( QStringLiteral( "pictureRotation" ), QStringLiteral( "0" ) ).toDouble(), 0.0 ) ) diff --git a/src/core/composer/qgscomposerpicture.h b/src/core/composer/qgscomposerpicture.h index 6016ea9e3cd..62ac71763d5 100644 --- a/src/core/composer/qgscomposerpicture.h +++ b/src/core/composer/qgscomposerpicture.h @@ -17,6 +17,7 @@ #ifndef QGSCOMPOSERPICTURE_H #define QGSCOMPOSERPICTURE_H +#include "qgis_core.h" #include "qgscomposeritem.h" #include #include @@ -61,7 +62,6 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem }; QgsComposerPicture( QgsComposition *composition ); - ~QgsComposerPicture(); //! Return correct graphics item type. virtual int type() const override { return ComposerPicture; } diff --git a/src/core/composer/qgscomposerpolygon.cpp b/src/core/composer/qgscomposerpolygon.cpp index 88dd30a36e7..eef4523a859 100644 --- a/src/core/composer/qgscomposerpolygon.cpp +++ b/src/core/composer/qgscomposerpolygon.cpp @@ -36,10 +36,6 @@ QgsComposerPolygon::QgsComposerPolygon( const QPolygonF& polygon, QgsComposition createDefaultPolygonStyleSymbol(); } -QgsComposerPolygon::~QgsComposerPolygon() -{ -} - bool QgsComposerPolygon::_addNode( const int indexPoint, QPointF newPoint, const double radius ) diff --git a/src/core/composer/qgscomposerpolygon.h b/src/core/composer/qgscomposerpolygon.h index d4e533cfff7..f90270eaeea 100644 --- a/src/core/composer/qgscomposerpolygon.h +++ b/src/core/composer/qgscomposerpolygon.h @@ -17,7 +17,9 @@ #ifndef QGSCOMPOSERPOLYGON_H #define QGSCOMPOSERPOLYGON_H +#include "qgis_core.h" #include "qgscomposernodesitem.h" +#include "qgssymbol.h" #include #include @@ -45,9 +47,6 @@ class CORE_EXPORT QgsComposerPolygon: public QgsComposerNodesItem */ QgsComposerPolygon( const QPolygonF &polygon, QgsComposition* c ); - //! Destructor - ~QgsComposerPolygon(); - //! Overridden to return shape name virtual QString displayName() const override; diff --git a/src/core/composer/qgscomposerpolyline.cpp b/src/core/composer/qgscomposerpolyline.cpp index 02005bc6ec4..1d88bd76b69 100644 --- a/src/core/composer/qgscomposerpolyline.cpp +++ b/src/core/composer/qgscomposerpolyline.cpp @@ -36,10 +36,6 @@ QgsComposerPolyline::QgsComposerPolyline( const QPolygonF& polyline, QgsComposit createDefaultPolylineStyleSymbol(); } -QgsComposerPolyline::~QgsComposerPolyline() -{ -} - bool QgsComposerPolyline::_addNode( const int indexPoint, QPointF newPoint, const double radius ) diff --git a/src/core/composer/qgscomposerpolyline.h b/src/core/composer/qgscomposerpolyline.h index ba748c868ae..d20a36a56f6 100644 --- a/src/core/composer/qgscomposerpolyline.h +++ b/src/core/composer/qgscomposerpolyline.h @@ -17,7 +17,9 @@ #ifndef QGSCOMPOSERPOLYLINE_H #define QGSCOMPOSERPOLYLINE_H +#include "qgis_core.h" #include "qgscomposernodesitem.h" +#include "qgssymbol.h" #include #include @@ -44,9 +46,6 @@ class CORE_EXPORT QgsComposerPolyline: public QgsComposerNodesItem */ QgsComposerPolyline( const QPolygonF &polyline, QgsComposition* c ); - //! Destructor - ~QgsComposerPolyline(); - //! Overridden to return shape name virtual QString displayName() const override; diff --git a/src/core/composer/qgscomposerscalebar.cpp b/src/core/composer/qgscomposerscalebar.cpp index f4507eb7dde..1fa3987c8a6 100644 --- a/src/core/composer/qgscomposerscalebar.cpp +++ b/src/core/composer/qgscomposerscalebar.cpp @@ -304,7 +304,7 @@ double QgsComposerScaleBar::mapWidth() const QgsDistanceArea da; da.setEllipsoidalMode( mComposition->mapSettings().hasCrsTransformEnabled() ); da.setSourceCrs( mComposition->mapSettings().destinationCrs().srsid() ); - da.setEllipsoid( QgsProject::instance()->ellipsoid() ); + da.setEllipsoid( mComposition->project()->ellipsoid() ); QgsUnitTypes::DistanceUnit units = QgsUnitTypes::DistanceMeters; double measure = da.measureLine( QgsPoint( composerMapRect.xMinimum(), composerMapRect.yMinimum() ), diff --git a/src/core/composer/qgscomposerscalebar.h b/src/core/composer/qgscomposerscalebar.h index ba39365b7c4..5402d5a3181 100644 --- a/src/core/composer/qgscomposerscalebar.h +++ b/src/core/composer/qgscomposerscalebar.h @@ -16,6 +16,7 @@ #ifndef QGSCOMPOSERSCALEBAR_H #define QGSCOMPOSERSCALEBAR_H +#include "qgis_core.h" #include "qgscomposeritem.h" #include #include diff --git a/src/core/composer/qgscomposershape.h b/src/core/composer/qgscomposershape.h index 89a2de9dfb3..1562c4e020f 100644 --- a/src/core/composer/qgscomposershape.h +++ b/src/core/composer/qgscomposershape.h @@ -18,6 +18,7 @@ #ifndef QGSCOMPOSERSHAPE_H #define QGSCOMPOSERSHAPE_H +#include "qgis_core.h" #include "qgscomposeritem.h" #include #include diff --git a/src/core/composer/qgscomposertablecolumn.cpp b/src/core/composer/qgscomposertablecolumn.cpp index b78a19d3b06..cfd55cd92fc 100644 --- a/src/core/composer/qgscomposertablecolumn.cpp +++ b/src/core/composer/qgscomposertablecolumn.cpp @@ -29,12 +29,6 @@ QgsComposerTableColumn::QgsComposerTableColumn( const QString& heading ) } - -QgsComposerTableColumn::~QgsComposerTableColumn() -{ - -} - bool QgsComposerTableColumn::writeXml( QDomElement& columnElem, QDomDocument& doc ) const { //background color diff --git a/src/core/composer/qgscomposertablecolumn.h b/src/core/composer/qgscomposertablecolumn.h index 6fbc8701372..259cf4343e6 100644 --- a/src/core/composer/qgscomposertablecolumn.h +++ b/src/core/composer/qgscomposertablecolumn.h @@ -23,6 +23,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * Stores properties of a column in a QgsComposerTable. Some properties of a QgsComposerTableColumn are applicable only in certain contexts. For instance, the attribute and setAttribute methods only @@ -38,8 +40,6 @@ class CORE_EXPORT QgsComposerTableColumn: public QObject */ QgsComposerTableColumn( const QString& heading = QString() ); - virtual ~QgsComposerTableColumn(); - /** Writes the column's properties to xml for storage. * @param columnElem an existing QDomElement in which to store the column's properties. * @param doc QDomDocument for the destination xml. diff --git a/src/core/composer/qgscomposertablev2.cpp b/src/core/composer/qgscomposertablev2.cpp index b537ff9309d..eedd3c829e4 100644 --- a/src/core/composer/qgscomposertablev2.cpp +++ b/src/core/composer/qgscomposertablev2.cpp @@ -342,7 +342,7 @@ void QgsComposerTableV2::render( QPainter *p, const QRectF &, const int frameInd mComposition->plotStyle() == QgsComposition::Postscript ) { //exporting composition, so force an attribute refresh - //we do this in case vector layer has changed via an external source (eg, another database user) + //we do this in case vector layer has changed via an external source (e.g., another database user) refreshAttributes(); } diff --git a/src/core/composer/qgscomposertablev2.h b/src/core/composer/qgscomposertablev2.h index 7c10788c7f6..2552cade205 100644 --- a/src/core/composer/qgscomposertablev2.h +++ b/src/core/composer/qgscomposertablev2.h @@ -18,6 +18,7 @@ #ifndef QGSCOMPOSERTABLEV2_H #define QGSCOMPOSERTABLEV2_H +#include "qgis_core.h" #include "qgscomposermultiframe.h" #include #include diff --git a/src/core/composer/qgscomposertexttable.cpp b/src/core/composer/qgscomposertexttable.cpp index f8295e005af..7ec71b3af51 100644 --- a/src/core/composer/qgscomposertexttable.cpp +++ b/src/core/composer/qgscomposertexttable.cpp @@ -26,11 +26,6 @@ QgsComposerTextTableV2::QgsComposerTextTableV2( QgsComposition* c, bool createUn } -QgsComposerTextTableV2::~QgsComposerTextTableV2() -{ - -} - void QgsComposerTextTableV2::addRow( const QStringList& row ) { mRowText.append( row ); diff --git a/src/core/composer/qgscomposertexttable.h b/src/core/composer/qgscomposertexttable.h index e4df33df7d2..e00db2d3cba 100644 --- a/src/core/composer/qgscomposertexttable.h +++ b/src/core/composer/qgscomposertexttable.h @@ -18,6 +18,7 @@ #ifndef QGSCOMPOSERTEXTTABLE_H #define QGSCOMPOSERTEXTTABLE_H +#include "qgis_core.h" #include "qgscomposertablev2.h" /** \ingroup core @@ -31,7 +32,6 @@ class CORE_EXPORT QgsComposerTextTableV2 : public QgsComposerTableV2 public: QgsComposerTextTableV2( QgsComposition* c, bool createUndoCommands ); - ~QgsComposerTextTableV2(); /** Adds a row to the table * @param row list of strings to use for each cell's value in the newly added row diff --git a/src/core/composer/qgscomposerutils.h b/src/core/composer/qgscomposerutils.h index 8c00b546f00..41e4a46257f 100644 --- a/src/core/composer/qgscomposerutils.h +++ b/src/core/composer/qgscomposerutils.h @@ -17,6 +17,7 @@ #ifndef QGSCOMPOSERUTILS_H #define QGSCOMPOSERUTILS_H +#include "qgis_core.h" #include "qgscomposition.h" //for page size and orientation enums #include #include diff --git a/src/core/composer/qgscomposition.cpp b/src/core/composer/qgscomposition.cpp index 1253b7c335f..7ec3cbcba90 100644 --- a/src/core/composer/qgscomposition.cpp +++ b/src/core/composer/qgscomposition.cpp @@ -61,9 +61,10 @@ #include "gdal.h" #include "cpl_conv.h" -QgsComposition::QgsComposition( const QgsMapSettings& mapSettings ) +QgsComposition::QgsComposition( const QgsMapSettings& mapSettings, QgsProject* project ) : QGraphicsScene( nullptr ) , mMapSettings( mapSettings ) + , mProject( project ) , mAtlasComposition( this ) { init(); @@ -171,6 +172,11 @@ QgsComposition::~QgsComposition() delete mItemsModel; } +QgsProject* QgsComposition::project() const +{ + return mProject; +} + void QgsComposition::loadDefaults() { QSettings settings; @@ -367,7 +373,7 @@ void QgsComposition::setPaperSize( const double width, const double height, bool mPages.at( i )->setSceneRect( QRectF( 0, currentY, width, height ) ); currentY += ( height + mSpaceBetweenPages ); } - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); updateBounds(); emit paperSizeChanged(); } @@ -493,7 +499,7 @@ void QgsComposition::setNumPages( const int pages ) } } - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); updateBounds(); emit nPagesChanged(); @@ -555,7 +561,7 @@ void QgsComposition::setPageStyleSymbol( QgsFillSymbol* symbol ) { delete mPageStyleSymbol; mPageStyleSymbol = static_cast( symbol->clone() ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } void QgsComposition::createDefaultPageStyleSymbol() @@ -780,7 +786,7 @@ void QgsComposition::setPrintResolution( const int dpi ) { mPrintResolution = dpi; emit printResolutionChanged(); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } QgsComposerMap* QgsComposition::worldFileMap() const @@ -791,7 +797,7 @@ QgsComposerMap* QgsComposition::worldFileMap() const void QgsComposition::setWorldFileMap( QgsComposerMap* map ) { mWorldFileMapId = map ? map->uuid() : QString(); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } void QgsComposition::setUseAdvancedEffects( const bool effectsEnabled ) @@ -1711,7 +1717,7 @@ void QgsComposition::alignSelectedItemsLeft() subcommand->saveAfterState(); } mUndoStack->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } void QgsComposition::alignSelectedItemsHCenter() @@ -1741,7 +1747,7 @@ void QgsComposition::alignSelectedItemsHCenter() subcommand->saveAfterState(); } mUndoStack->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } void QgsComposition::alignSelectedItemsRight() @@ -1771,7 +1777,7 @@ void QgsComposition::alignSelectedItemsRight() subcommand->saveAfterState(); } mUndoStack->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } void QgsComposition::alignSelectedItemsTop() @@ -1800,7 +1806,7 @@ void QgsComposition::alignSelectedItemsTop() subcommand->saveAfterState(); } mUndoStack->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } void QgsComposition::alignSelectedItemsVCenter() @@ -1828,7 +1834,7 @@ void QgsComposition::alignSelectedItemsVCenter() subcommand->saveAfterState(); } mUndoStack->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } void QgsComposition::alignSelectedItemsBottom() @@ -1856,7 +1862,7 @@ void QgsComposition::alignSelectedItemsBottom() subcommand->saveAfterState(); } mUndoStack->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } void QgsComposition::lockSelectedItems() @@ -1874,7 +1880,7 @@ void QgsComposition::lockSelectedItems() setAllUnselected(); mUndoStack->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } void QgsComposition::unlockAllItems() @@ -1903,7 +1909,7 @@ void QgsComposition::unlockAllItems() } } mUndoStack->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } QgsComposerItemGroup *QgsComposition::groupItems( QList items ) @@ -1932,7 +1938,7 @@ QgsComposerItemGroup *QgsComposition::groupItems( QList items QObject::connect( c, SIGNAL( itemAdded( QgsComposerItem* ) ), this, SLOT( sendItemAddedSignal( QgsComposerItem* ) ) ); undoStack()->push( c ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); //QgsDebugMsg( QString( "itemgroup after pushAddRemove has %1" ) .arg( itemGroup->items().size() ) ); emit composerItemGroupAdded( itemGroup ); @@ -1956,7 +1962,7 @@ QList QgsComposition::ungroupItems( QgsComposerItemGroup* gro QObject::connect( c, SIGNAL( itemAdded( QgsComposerItem* ) ), this, SLOT( sendItemAddedSignal( QgsComposerItem* ) ) ); undoStack()->push( c ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); QSet groupedItems = group->items(); @@ -2007,7 +2013,7 @@ void QgsComposition::updateZValues( const bool addUndoCommands ) if ( addUndoCommands ) { mUndoStack->push( parentCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } } @@ -2356,7 +2362,7 @@ void QgsComposition::endCommand() if ( mActiveItemCommand->containsChange() ) //protect against empty commands { mUndoStack->push( mActiveItemCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } else { @@ -2401,7 +2407,7 @@ void QgsComposition::endMultiFrameCommand() if ( mActiveMultiFrameCommand->containsChange() ) { mUndoStack->push( mActiveMultiFrameCommand ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } else { @@ -2638,7 +2644,7 @@ void QgsComposition::pushAddRemoveCommand( QgsComposerItem* item, const QString& QgsAddRemoveItemCommand* c = new QgsAddRemoveItemCommand( state, item, this, text ); connectAddRemoveCommandSignals( c ); undoStack()->push( c ); - QgsProject::instance()->setDirty( true ); + mProject->setDirty( true ); } void QgsComposition::connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c ) @@ -2830,7 +2836,7 @@ void QgsComposition::georeferenceOutput( const QString& file, QgsComposerMap* ma { GDALSetGeoTransform( outputDS, t ); #if 0 - //TODO - metadata can be set here, eg: + //TODO - metadata can be set here, e.g.: GDALSetMetadataItem( outputDS, "AUTHOR", "me", nullptr ); #endif GDALSetProjection( outputDS, mMapSettings.destinationCrs().toWkt().toLocal8Bit().constData() ); @@ -3569,7 +3575,7 @@ QgsExpressionContext QgsComposition::createExpressionContext() const { QgsExpressionContext context = QgsExpressionContext(); context.appendScope( QgsExpressionContextUtils::globalScope() ); - context.appendScope( QgsExpressionContextUtils::projectScope() ); + context.appendScope( QgsExpressionContextUtils::projectScope( mProject ) ); context.appendScope( QgsExpressionContextUtils::compositionScope( this ) ); if ( mAtlasComposition.enabled() ) { diff --git a/src/core/composer/qgscomposition.h b/src/core/composer/qgscomposition.h index 93870e40e0d..ef6d56d28dc 100644 --- a/src/core/composer/qgscomposition.h +++ b/src/core/composer/qgscomposition.h @@ -16,6 +16,7 @@ #ifndef QGSCOMPOSITION_H #define QGSCOMPOSITION_H +#include "qgis_core.h" #include #include @@ -104,7 +105,8 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo Landscape }; - explicit QgsComposition( const QgsMapSettings& mapSettings ); + //! Construct a composition, using given map settings and project + explicit QgsComposition( const QgsMapSettings& mapSettings, QgsProject* project ); //! Composition atlas modes enum AtlasMode @@ -116,6 +118,14 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo ~QgsComposition(); + /** + * The project associated with the composition. Used to get access to layers, map themes, + * relations and various other bits. It is never null. + * + * \note Added in QGIS 3.0 + */ + QgsProject* project() const; + /** Changes size of paper item. * @param width page width in mm * @param height page height in mm @@ -798,7 +808,7 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo /** Calculates the bounds of all non-gui items in the composition. Ignores snap lines and mouse handles. * @param ignorePages set to true to ignore page items - * @param margin optional marginal (in percent, eg 0.05 = 5% ) to add around items + * @param margin optional marginal (in percent, e.g., 0.05 = 5% ) to add around items */ QRectF compositionBounds( bool ignorePages = false, double margin = 0.0 ) const; @@ -852,6 +862,9 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo //! Reference to map settings of QGIS main map const QgsMapSettings& mMapSettings; + //! Pointer to associated project (not null) + QgsProject* mProject; + QgsComposition::PlotStyle mPlotStyle; double mPageWidth; double mPageHeight; @@ -940,7 +953,7 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo //! Loads default composer settings void loadDefaults(); - //! Loads composer settings which may change, eg grid color + //! Loads composer settings which may change, e.g., grid color void loadSettings(); //! Calculates the item minimum position from an xml string diff --git a/src/core/composer/qgsdoubleboxscalebarstyle.cpp b/src/core/composer/qgsdoubleboxscalebarstyle.cpp index 7588bbcd343..56f613d7446 100644 --- a/src/core/composer/qgsdoubleboxscalebarstyle.cpp +++ b/src/core/composer/qgsdoubleboxscalebarstyle.cpp @@ -30,11 +30,6 @@ QgsDoubleBoxScaleBarStyle::QgsDoubleBoxScaleBarStyle(): QgsScaleBarStyle( nullpt } -QgsDoubleBoxScaleBarStyle::~QgsDoubleBoxScaleBarStyle() -{ - -} - QString QgsDoubleBoxScaleBarStyle::name() const { return QStringLiteral( "Double Box" ); diff --git a/src/core/composer/qgsdoubleboxscalebarstyle.h b/src/core/composer/qgsdoubleboxscalebarstyle.h index b393f5d6e17..a0d9371e125 100644 --- a/src/core/composer/qgsdoubleboxscalebarstyle.h +++ b/src/core/composer/qgsdoubleboxscalebarstyle.h @@ -17,6 +17,7 @@ #ifndef QGSDOUBLEBOXSCALEBARSTYLE_H #define QGSDOUBLEBOXSCALEBARSTYLE_H +#include "qgis_core.h" #include "qgsscalebarstyle.h" /** \ingroup core @@ -26,7 +27,6 @@ class CORE_EXPORT QgsDoubleBoxScaleBarStyle: public QgsScaleBarStyle { public: QgsDoubleBoxScaleBarStyle( const QgsComposerScaleBar* bar ); - ~QgsDoubleBoxScaleBarStyle(); QString name() const override; diff --git a/src/core/composer/qgsgroupungroupitemscommand.cpp b/src/core/composer/qgsgroupungroupitemscommand.cpp index 0ee18d85d92..4d73daf794c 100644 --- a/src/core/composer/qgsgroupungroupitemscommand.cpp +++ b/src/core/composer/qgsgroupungroupitemscommand.cpp @@ -92,5 +92,5 @@ void QgsGroupUngroupItemsCommand::switchState() mState = Grouped; emit itemAdded( mGroup ); } - QgsProject::instance()->setDirty( true ); + mComposition->project()->setDirty( true ); } diff --git a/src/core/composer/qgsgroupungroupitemscommand.h b/src/core/composer/qgsgroupungroupitemscommand.h index 847a0313541..e7db084cfa8 100644 --- a/src/core/composer/qgsgroupungroupitemscommand.h +++ b/src/core/composer/qgsgroupungroupitemscommand.h @@ -18,6 +18,7 @@ #ifndef QGSGROUPUNGROUPITEMSCOMMAND_H #define QGSGROUPUNGROUPITEMSCOMMAND_H +#include "qgis_core.h" #include #include "qgscomposeritem.h" diff --git a/src/core/composer/qgsnumericscalebarstyle.cpp b/src/core/composer/qgsnumericscalebarstyle.cpp index 793351208a8..f855563fa74 100644 --- a/src/core/composer/qgsnumericscalebarstyle.cpp +++ b/src/core/composer/qgsnumericscalebarstyle.cpp @@ -31,11 +31,6 @@ QgsNumericScaleBarStyle::QgsNumericScaleBarStyle(): QgsScaleBarStyle( nullptr ), } -QgsNumericScaleBarStyle::~QgsNumericScaleBarStyle() -{ - -} - QString QgsNumericScaleBarStyle::name() const { return QStringLiteral( "Numeric" ); diff --git a/src/core/composer/qgsnumericscalebarstyle.h b/src/core/composer/qgsnumericscalebarstyle.h index b915b86d8e3..ce2bb61257f 100644 --- a/src/core/composer/qgsnumericscalebarstyle.h +++ b/src/core/composer/qgsnumericscalebarstyle.h @@ -17,6 +17,7 @@ #ifndef QGSNUMERICSCALEBARSTYLE_H #define QGSNUMERICSCALEBARSTYLE_H +#include "qgis_core.h" #include "qgsscalebarstyle.h" /** \ingroup core @@ -26,7 +27,6 @@ class CORE_EXPORT QgsNumericScaleBarStyle: public QgsScaleBarStyle { public: QgsNumericScaleBarStyle( QgsComposerScaleBar* bar ); - ~QgsNumericScaleBarStyle(); QString name() const override; diff --git a/src/core/composer/qgspaperitem.cpp b/src/core/composer/qgspaperitem.cpp index d5d53d42e2c..7b5f3c53b69 100644 --- a/src/core/composer/qgspaperitem.cpp +++ b/src/core/composer/qgspaperitem.cpp @@ -34,10 +34,6 @@ QgsPaperGrid::QgsPaperGrid( double x, double y, double width, double height, Qgs setPos( x, y ); } -QgsPaperGrid::~QgsPaperGrid() -{ -} - void QgsPaperGrid::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) { Q_UNUSED( itemStyle ); diff --git a/src/core/composer/qgspaperitem.h b/src/core/composer/qgspaperitem.h index 275e53acdb3..c0aeafd59b5 100644 --- a/src/core/composer/qgspaperitem.h +++ b/src/core/composer/qgspaperitem.h @@ -18,6 +18,7 @@ #ifndef QGSPAPERITEM_H #define QGSPAPERITEM_H +#include "qgis_core.h" #include "qgscomposeritem.h" #include @@ -28,7 +29,6 @@ class CORE_EXPORT QgsPaperGrid: public QGraphicsRectItem { public: QgsPaperGrid( double x, double y, double width, double height, QgsComposition* composition ); - ~QgsPaperGrid(); //! \brief Reimplementation of QCanvasItem::paint void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) override; diff --git a/src/core/composer/qgsscalebarstyle.cpp b/src/core/composer/qgsscalebarstyle.cpp index 7934fe08adf..ef986b66972 100644 --- a/src/core/composer/qgsscalebarstyle.cpp +++ b/src/core/composer/qgsscalebarstyle.cpp @@ -30,11 +30,6 @@ QgsScaleBarStyle::QgsScaleBarStyle(): mScaleBar( nullptr ) } -QgsScaleBarStyle::~QgsScaleBarStyle() -{ - -} - void QgsScaleBarStyle::drawLabels( QPainter* p ) const { if ( !p || !mScaleBar ) diff --git a/src/core/composer/qgsscalebarstyle.h b/src/core/composer/qgsscalebarstyle.h index 23e4cf991ff..b17665ffb33 100644 --- a/src/core/composer/qgsscalebarstyle.h +++ b/src/core/composer/qgsscalebarstyle.h @@ -20,6 +20,8 @@ #include #include +#include "qgis_core.h" + class QgsComposerScaleBar; class QPainter; @@ -31,7 +33,7 @@ class CORE_EXPORT QgsScaleBarStyle { public: QgsScaleBarStyle( const QgsComposerScaleBar* bar ); - virtual ~QgsScaleBarStyle(); + virtual ~QgsScaleBarStyle() = default; /** Draws the style @param p painter object diff --git a/src/core/composer/qgssingleboxscalebarstyle.h b/src/core/composer/qgssingleboxscalebarstyle.h index 356f54739be..9c4b05a1da8 100644 --- a/src/core/composer/qgssingleboxscalebarstyle.h +++ b/src/core/composer/qgssingleboxscalebarstyle.h @@ -17,6 +17,7 @@ #ifndef QGSSINGLEBOXSCALEBARSTYLE_H #define QGSSINGLEBOXSCALEBARSTYLE_H +#include "qgis_core.h" #include "qgsscalebarstyle.h" /** \ingroup core diff --git a/src/core/composer/qgsticksscalebarstyle.cpp b/src/core/composer/qgsticksscalebarstyle.cpp index 795708da3cb..f6cd3d6a34e 100644 --- a/src/core/composer/qgsticksscalebarstyle.cpp +++ b/src/core/composer/qgsticksscalebarstyle.cpp @@ -29,11 +29,6 @@ QgsTicksScaleBarStyle::QgsTicksScaleBarStyle(): QgsScaleBarStyle( nullptr ) mTickPosition = TicksMiddle; } -QgsTicksScaleBarStyle::~QgsTicksScaleBarStyle() -{ - -} - QString QgsTicksScaleBarStyle::name() const { switch ( mTickPosition ) diff --git a/src/core/composer/qgsticksscalebarstyle.h b/src/core/composer/qgsticksscalebarstyle.h index 8eb00491285..f891b349b41 100644 --- a/src/core/composer/qgsticksscalebarstyle.h +++ b/src/core/composer/qgsticksscalebarstyle.h @@ -17,6 +17,7 @@ #ifndef QGSTICKSSCALEBARSTYLE_H #define QGSTICKSSCALEBARSTYLE_H +#include "qgis_core.h" #include "qgsscalebarstyle.h" /** \ingroup core @@ -33,7 +34,6 @@ class CORE_EXPORT QgsTicksScaleBarStyle: public QgsScaleBarStyle }; QgsTicksScaleBarStyle( const QgsComposerScaleBar* bar ); - ~QgsTicksScaleBarStyle(); QString name() const override; diff --git a/src/core/diagram/qgsdiagram.h b/src/core/diagram/qgsdiagram.h index 8b210eb5721..2f32ac4bd4f 100644 --- a/src/core/diagram/qgsdiagram.h +++ b/src/core/diagram/qgsdiagram.h @@ -15,6 +15,7 @@ #ifndef QGSDIAGRAM_H #define QGSDIAGRAM_H +#include "qgis_core.h" #include #include #include "qgsexpression.h" //for QMap with QgsExpression diff --git a/src/core/diagram/qgshistogramdiagram.cpp b/src/core/diagram/qgshistogramdiagram.cpp index 565499f647c..b8cb40b716d 100644 --- a/src/core/diagram/qgshistogramdiagram.cpp +++ b/src/core/diagram/qgshistogramdiagram.cpp @@ -26,10 +26,6 @@ QgsHistogramDiagram::QgsHistogramDiagram() mScaleFactor = 0; } -QgsHistogramDiagram::~QgsHistogramDiagram() -{ -} - QgsHistogramDiagram* QgsHistogramDiagram::clone() const { return new QgsHistogramDiagram( *this ); diff --git a/src/core/diagram/qgshistogramdiagram.h b/src/core/diagram/qgshistogramdiagram.h index ff87ed28e3c..03902e44111 100644 --- a/src/core/diagram/qgshistogramdiagram.h +++ b/src/core/diagram/qgshistogramdiagram.h @@ -18,6 +18,7 @@ #define DIAGRAM_NAME_HISTOGRAM "Histogram" +#include "qgis_core.h" #include "qgsdiagram.h" #include #include @@ -37,7 +38,6 @@ class CORE_EXPORT QgsHistogramDiagram: public QgsDiagram { public: QgsHistogramDiagram(); - ~QgsHistogramDiagram(); virtual QgsHistogramDiagram* clone() const override; diff --git a/src/core/diagram/qgspiediagram.cpp b/src/core/diagram/qgspiediagram.cpp index 62060856ece..ccd6f3a6922 100644 --- a/src/core/diagram/qgspiediagram.cpp +++ b/src/core/diagram/qgspiediagram.cpp @@ -26,10 +26,6 @@ QgsPieDiagram::QgsPieDiagram() mPen.setStyle( Qt::SolidLine ); } -QgsPieDiagram::~QgsPieDiagram() -{ -} - QgsPieDiagram* QgsPieDiagram::clone() const { return new QgsPieDiagram( *this ); @@ -52,7 +48,7 @@ QSizeF QgsPieDiagram::diagramSize( const QgsFeature& feature, const QgsRenderCon } else { - attrVal = feature.attributes().at( is.classificationAttribute ); + attrVal = feature.attribute( is.classificationField ); } bool ok = false; diff --git a/src/core/diagram/qgspiediagram.h b/src/core/diagram/qgspiediagram.h index c6526357a6b..a310fafdc26 100644 --- a/src/core/diagram/qgspiediagram.h +++ b/src/core/diagram/qgspiediagram.h @@ -17,6 +17,7 @@ #define DIAGRAM_NAME_PIE "Pie" +#include "qgis_core.h" #include "qgsdiagram.h" #include #include @@ -35,7 +36,6 @@ class CORE_EXPORT QgsPieDiagram: public QgsDiagram { public: QgsPieDiagram(); - ~QgsPieDiagram(); virtual QgsPieDiagram* clone() const override; diff --git a/src/core/diagram/qgstextdiagram.cpp b/src/core/diagram/qgstextdiagram.cpp index 467fcb65fda..2afd7681563 100644 --- a/src/core/diagram/qgstextdiagram.cpp +++ b/src/core/diagram/qgstextdiagram.cpp @@ -27,10 +27,6 @@ QgsTextDiagram::QgsTextDiagram(): mOrientation( Vertical ), mShape( Circle ) mBrush.setStyle( Qt::SolidPattern ); } -QgsTextDiagram::~QgsTextDiagram() -{ -} - QgsTextDiagram* QgsTextDiagram::clone() const { return new QgsTextDiagram( *this ); @@ -51,7 +47,7 @@ QSizeF QgsTextDiagram::diagramSize( const QgsFeature& feature, const QgsRenderCo } else { - attrVal = feature.attributes().at( is.classificationAttribute ); + attrVal = feature.attribute( is.classificationField ); } bool ok = false; diff --git a/src/core/diagram/qgstextdiagram.h b/src/core/diagram/qgstextdiagram.h index c07c9e6d9d0..61d177b06bf 100644 --- a/src/core/diagram/qgstextdiagram.h +++ b/src/core/diagram/qgstextdiagram.h @@ -17,6 +17,7 @@ #define DIAGRAM_NAME_TEXT "Text" +#include "qgis_core.h" #include "qgsdiagram.h" #include #include @@ -48,7 +49,6 @@ class CORE_EXPORT QgsTextDiagram: public QgsDiagram }; QgsTextDiagram(); - ~QgsTextDiagram(); virtual QgsTextDiagram* clone() const override; void renderDiagram( const QgsFeature& feature, QgsRenderContext& c, const QgsDiagramSettings& s, QPointF position ) override; diff --git a/src/core/dxf/qgsdxfexport.cpp b/src/core/dxf/qgsdxfexport.cpp index 1afa8b5b476..68b0de1a5b9 100644 --- a/src/core/dxf/qgsdxfexport.cpp +++ b/src/core/dxf/qgsdxfexport.cpp @@ -396,10 +396,6 @@ QgsDxfExport& QgsDxfExport::operator=( const QgsDxfExport & dxfExport ) return *this; } -QgsDxfExport::~QgsDxfExport() -{ -} - void QgsDxfExport::addLayers( const QList< QPair< QgsVectorLayer *, int > > &layers ) { mLayers = layers; @@ -1093,10 +1089,7 @@ void QgsDxfExport::writeEntitiesSymbolLevels( QgsVectorLayer* layer ) QHash< QgsSymbol*, QList > features; QgsRenderContext ctx = renderContext(); - ctx.expressionContext() - << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( layer ); + ctx.expressionContext().appendScopes( QgsExpressionContextUtils::globalProjectLayerScopes( layer ) ); QgsSymbolRenderContext sctx( ctx, QgsUnitTypes::RenderMillimeters, 1.0, false, 0, nullptr ); renderer->startRender( ctx, layer->fields() ); diff --git a/src/core/dxf/qgsdxfexport.h b/src/core/dxf/qgsdxfexport.h index 4f096621925..db94b4f125a 100644 --- a/src/core/dxf/qgsdxfexport.h +++ b/src/core/dxf/qgsdxfexport.h @@ -18,6 +18,7 @@ #ifndef QGSDXFEXPORT_H #define QGSDXFEXPORT_H +#include "qgis_core.h" #include "qgsgeometry.h" #include "qgssymbol.h" // for OutputUnit enum #include "qgsmapsettings.h" @@ -52,7 +53,6 @@ class CORE_EXPORT QgsDxfExport QgsDxfExport(); QgsDxfExport( const QgsDxfExport &dxfExport ); - ~QgsDxfExport(); QgsDxfExport &operator=( const QgsDxfExport &dxfExport ); /** diff --git a/src/core/dxf/qgsdxfpaintdevice.h b/src/core/dxf/qgsdxfpaintdevice.h index 08a3790df03..5b1c45d5e80 100644 --- a/src/core/dxf/qgsdxfpaintdevice.h +++ b/src/core/dxf/qgsdxfpaintdevice.h @@ -20,6 +20,8 @@ #include +#include "qgis_core.h" + class QgsDxfPaintEngine; class QgsDxfExport; class QPaintEngine; diff --git a/src/core/dxf/qgsdxfpaintengine.cpp b/src/core/dxf/qgsdxfpaintengine.cpp index 0e92a1d5e68..45126d67e3a 100644 --- a/src/core/dxf/qgsdxfpaintengine.cpp +++ b/src/core/dxf/qgsdxfpaintengine.cpp @@ -27,10 +27,6 @@ QgsDxfPaintEngine::QgsDxfPaintEngine( const QgsDxfPaintDevice* dxfDevice, QgsDxf { } -QgsDxfPaintEngine::~QgsDxfPaintEngine() -{ -} - bool QgsDxfPaintEngine::begin( QPaintDevice* pdev ) { Q_UNUSED( pdev ); diff --git a/src/core/dxf/qgsdxfpaintengine.h b/src/core/dxf/qgsdxfpaintengine.h index 2cc9a1bbf8b..15859bcc3f2 100644 --- a/src/core/dxf/qgsdxfpaintengine.h +++ b/src/core/dxf/qgsdxfpaintengine.h @@ -18,8 +18,10 @@ #ifndef QGSDXFPAINTENGINE_H #define QGSDXFPAINTENGINE_H +#include "qgis_core.h" #include #include "qgsabstractgeometry.h" +#include "qgspointv2.h" class QgsDxfExport; class QgsDxfPaintDevice; @@ -34,7 +36,6 @@ class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine { public: QgsDxfPaintEngine( const QgsDxfPaintDevice* dxfDevice, QgsDxfExport* dxf ); - ~QgsDxfPaintEngine(); bool begin( QPaintDevice* pdev ) override; bool end() override; diff --git a/src/core/effects/qgsblureffect.cpp b/src/core/effects/qgsblureffect.cpp index 3f462552398..2c71188dcb1 100644 --- a/src/core/effects/qgsblureffect.cpp +++ b/src/core/effects/qgsblureffect.cpp @@ -36,11 +36,6 @@ QgsBlurEffect::QgsBlurEffect() } -QgsBlurEffect::~QgsBlurEffect() -{ - -} - void QgsBlurEffect::draw( QgsRenderContext &context ) { if ( !source() || !enabled() || !context.painter() ) diff --git a/src/core/effects/qgsblureffect.h b/src/core/effects/qgsblureffect.h index b3d68ec206a..bc1bb3a6b00 100644 --- a/src/core/effects/qgsblureffect.h +++ b/src/core/effects/qgsblureffect.h @@ -17,6 +17,7 @@ #ifndef QGSBLUREFFECT_H #define QGSBLUREFFECT_H +#include "qgis_core.h" #include "qgspainteffect.h" #include "qgis.h" #include @@ -48,7 +49,6 @@ class CORE_EXPORT QgsBlurEffect : public QgsPaintEffect static QgsPaintEffect* create( const QgsStringMap& map ); QgsBlurEffect(); - virtual ~QgsBlurEffect(); virtual QString type() const override { return QStringLiteral( "blur" ); } virtual QgsStringMap properties() const override; diff --git a/src/core/effects/qgscoloreffect.cpp b/src/core/effects/qgscoloreffect.cpp index a23df4a741b..c5a1458cfc1 100644 --- a/src/core/effects/qgscoloreffect.cpp +++ b/src/core/effects/qgscoloreffect.cpp @@ -41,11 +41,6 @@ QgsColorEffect::QgsColorEffect() } -QgsColorEffect::~QgsColorEffect() -{ - -} - void QgsColorEffect::draw( QgsRenderContext &context ) { if ( !source() || !enabled() || !context.painter() ) @@ -53,7 +48,7 @@ void QgsColorEffect::draw( QgsRenderContext &context ) QPainter* painter = context.painter(); - //rasterise source and apply modifications + //rasterize source and apply modifications QImage image = sourceAsImage( context )->copy(); QgsImageOperation::adjustBrightnessContrast( image, mBrightness, mContrast / 100.0 + 1 ); diff --git a/src/core/effects/qgscoloreffect.h b/src/core/effects/qgscoloreffect.h index 8a8e1b8a284..0648e021de3 100644 --- a/src/core/effects/qgscoloreffect.h +++ b/src/core/effects/qgscoloreffect.h @@ -17,6 +17,7 @@ #ifndef QGSCOLOREFFECT_H #define QGSCOLOREFFECT_H +#include "qgis_core.h" #include "qgspainteffect.h" #include "qgsimageoperation.h" #include "qgis.h" @@ -24,7 +25,7 @@ /** \ingroup core * \class QgsColorEffect - * \brief A paint effect which alters the colors (eg brightness, contrast) in a + * \brief A paint effect which alters the colors (e.g., brightness, contrast) in a * source picture. * * \note Added in version 2.9 @@ -42,7 +43,6 @@ class CORE_EXPORT QgsColorEffect : public QgsPaintEffect static QgsPaintEffect* create( const QgsStringMap& map ); QgsColorEffect(); - virtual ~QgsColorEffect(); virtual QString type() const override { return QStringLiteral( "color" ); } virtual QgsStringMap properties() const override; diff --git a/src/core/effects/qgseffectstack.cpp b/src/core/effects/qgseffectstack.cpp index a591a509f07..3cd7d1655a5 100644 --- a/src/core/effects/qgseffectstack.cpp +++ b/src/core/effects/qgseffectstack.cpp @@ -183,7 +183,7 @@ bool QgsEffectStack::readProperties( const QDomElement &element ) for ( int i = 0; i < childNodes.size(); ++i ) { QDomElement childElement = childNodes.at( i ).toElement(); - QgsPaintEffect* effect = QgsPaintEffectRegistry::instance()->createEffect( childElement ); + QgsPaintEffect* effect = QgsApplication::paintEffectRegistry()->createEffect( childElement ); if ( effect ) mEffectList << effect; } diff --git a/src/core/effects/qgseffectstack.h b/src/core/effects/qgseffectstack.h index ae581e0222a..cc8b8fbbfe2 100644 --- a/src/core/effects/qgseffectstack.h +++ b/src/core/effects/qgseffectstack.h @@ -17,6 +17,7 @@ #ifndef QGSEFFECTSTACK_H #define QGSEFFECTSTACK_H +#include "qgis_core.h" #include "qgspainteffect.h" /** \ingroup core diff --git a/src/core/effects/qgsgloweffect.cpp b/src/core/effects/qgsgloweffect.cpp index 225a61d29c6..30b0a358fe0 100644 --- a/src/core/effects/qgsgloweffect.cpp +++ b/src/core/effects/qgsgloweffect.cpp @@ -230,11 +230,6 @@ QgsOuterGlowEffect::QgsOuterGlowEffect() } -QgsOuterGlowEffect::~QgsOuterGlowEffect() -{ - -} - QgsPaintEffect *QgsOuterGlowEffect::create( const QgsStringMap &map ) { QgsOuterGlowEffect* effect = new QgsOuterGlowEffect(); @@ -259,11 +254,6 @@ QgsInnerGlowEffect::QgsInnerGlowEffect() } -QgsInnerGlowEffect::~QgsInnerGlowEffect() -{ - -} - QgsPaintEffect *QgsInnerGlowEffect::create( const QgsStringMap &map ) { QgsInnerGlowEffect* effect = new QgsInnerGlowEffect(); diff --git a/src/core/effects/qgsgloweffect.h b/src/core/effects/qgsgloweffect.h index fc238a27bf9..6bfc91c5753 100644 --- a/src/core/effects/qgsgloweffect.h +++ b/src/core/effects/qgsgloweffect.h @@ -17,6 +17,7 @@ #ifndef QGSGLOWEFFECT_H #define QGSGLOWEFFECT_H +#include "qgis_core.h" #include "qgspainteffect.h" #include "qgssymbol.h" #include @@ -240,7 +241,6 @@ class CORE_EXPORT QgsOuterGlowEffect : public QgsGlowEffect static QgsPaintEffect* create( const QgsStringMap& map ); QgsOuterGlowEffect(); - virtual ~QgsOuterGlowEffect(); virtual QString type() const override { return QStringLiteral( "outerGlow" ); } virtual QgsOuterGlowEffect* clone() const override; @@ -271,7 +271,6 @@ class CORE_EXPORT QgsInnerGlowEffect : public QgsGlowEffect static QgsPaintEffect* create( const QgsStringMap& map ); QgsInnerGlowEffect(); - virtual ~QgsInnerGlowEffect(); virtual QString type() const override { return QStringLiteral( "innerGlow" ); } virtual QgsInnerGlowEffect* clone() const override; diff --git a/src/core/effects/qgsimageoperation.h b/src/core/effects/qgsimageoperation.h index 4af7a36b8e5..84bd8aff21c 100644 --- a/src/core/effects/qgsimageoperation.h +++ b/src/core/effects/qgsimageoperation.h @@ -22,6 +22,8 @@ #include #include +#include "qgis_core.h" + class QgsColorRamp; /** \ingroup core diff --git a/src/core/effects/qgspainteffect.cpp b/src/core/effects/qgspainteffect.cpp index 31a2dc2a5c1..e043a32b528 100644 --- a/src/core/effects/qgspainteffect.cpp +++ b/src/core/effects/qgspainteffect.cpp @@ -255,11 +255,6 @@ QgsDrawSourceEffect::QgsDrawSourceEffect() } -QgsDrawSourceEffect::~QgsDrawSourceEffect() -{ - -} - QgsPaintEffect *QgsDrawSourceEffect::create( const QgsStringMap &map ) { QgsDrawSourceEffect* effect = new QgsDrawSourceEffect(); @@ -281,7 +276,7 @@ void QgsDrawSourceEffect::draw( QgsRenderContext &context ) } else { - //rasterise source and apply modifications + //rasterize source and apply modifications QImage image = sourceAsImage( context )->copy(); QgsImageOperation::multiplyOpacity( image, 1.0 - mTransparency ); painter->save(); diff --git a/src/core/effects/qgspainteffect.h b/src/core/effects/qgspainteffect.h index 03e85065bec..b368a8fc8be 100644 --- a/src/core/effects/qgspainteffect.h +++ b/src/core/effects/qgspainteffect.h @@ -17,6 +17,7 @@ #ifndef QGSPAINTEFFECT_H #define QGSPAINTEFFECT_H +#include "qgis_core.h" #include "qgis.h" #include #include @@ -247,7 +248,7 @@ class CORE_EXPORT QgsPaintEffect * * The draw source effect can be used to draw an unaltered copy of the original source * picture. Minor changes like lowering the opacity and applying a blend mode are - * supported, however these changes will force the resultant output to be rasterised. + * supported, however these changes will force the resultant output to be rasterized. * If no alterations are performed then the original picture will be rendered as a vector. * * \note Added in version 2.9 @@ -258,7 +259,6 @@ class CORE_EXPORT QgsDrawSourceEffect : public QgsPaintEffect public: QgsDrawSourceEffect(); - virtual ~QgsDrawSourceEffect(); /** Creates a new QgsDrawSource effect from a properties string map. * @param map encoded properties string map diff --git a/src/core/effects/qgspainteffectregistry.cpp b/src/core/effects/qgspainteffectregistry.cpp index 2425fe7fbcd..1bb014db8d9 100644 --- a/src/core/effects/qgspainteffectregistry.cpp +++ b/src/core/effects/qgspainteffectregistry.cpp @@ -56,12 +56,6 @@ QgsPaintEffectRegistry::~QgsPaintEffectRegistry() qDeleteAll( mMetadata ); } -QgsPaintEffectRegistry* QgsPaintEffectRegistry::instance() -{ - static QgsPaintEffectRegistry sInstance; - return &sInstance; -} - QgsPaintEffectAbstractMetadata *QgsPaintEffectRegistry::effectMetadata( const QString &name ) const { if ( mMetadata.contains( name ) ) @@ -97,7 +91,7 @@ QgsPaintEffect *QgsPaintEffectRegistry::createEffect( const QDomElement &element QString type = element.attribute( QStringLiteral( "type" ) ); - QgsPaintEffect* effect = instance()->createEffect( type ); + QgsPaintEffect* effect = QgsApplication::paintEffectRegistry()->createEffect( type ); if ( !effect ) return nullptr; diff --git a/src/core/effects/qgspainteffectregistry.h b/src/core/effects/qgspainteffectregistry.h index 6c6fa4d32b8..de202f77f0f 100644 --- a/src/core/effects/qgspainteffectregistry.h +++ b/src/core/effects/qgspainteffectregistry.h @@ -16,6 +16,7 @@ #ifndef QGSPAINTEFFECTREGISTRY_H #define QGSPAINTEFFECTREGISTRY_H +#include "qgis_core.h" #include "qgis.h" #include #include @@ -43,7 +44,7 @@ class CORE_EXPORT QgsPaintEffectAbstractMetadata */ QgsPaintEffectAbstractMetadata( const QString& name, const QString& visibleName ); - virtual ~QgsPaintEffectAbstractMetadata() {} + virtual ~QgsPaintEffectAbstractMetadata() = default; /** Returns the unique string representing the paint effect class * @returns unique string @@ -147,7 +148,10 @@ class CORE_EXPORT QgsPaintEffectMetadata : public QgsPaintEffectAbstractMetadata /** \ingroup core * \class QgsPaintEffectRegistry - * \brief Singleton registry of available paint effects + * \brief Registry of available paint effects. + * + * QgsPaintEffectRegistry is not usually directly created, but rather accessed through + * QgsApplication::paintEffectRegistry(). * * \note Added in version 2.9 */ @@ -155,9 +159,13 @@ class CORE_EXPORT QgsPaintEffectRegistry { public: - /** Returns a reference to the singleton instance of the paint effect registry. - */ - static QgsPaintEffectRegistry* instance(); + QgsPaintEffectRegistry(); + ~QgsPaintEffectRegistry(); + + //! QgsPaintEffectRegistry cannot be copied. + QgsPaintEffectRegistry( const QgsPaintEffectRegistry& rh ) = delete; + //! QgsPaintEffectRegistry cannot be copied. + QgsPaintEffectRegistry& operator=( const QgsPaintEffectRegistry& rh ) = delete; /** Returns the metadata for a specific effect. * @param name unique string name for paint effect class @@ -208,16 +216,9 @@ class CORE_EXPORT QgsPaintEffectRegistry */ static bool isDefaultStack( QgsPaintEffect* effect ); - protected: - QgsPaintEffectRegistry(); - ~QgsPaintEffectRegistry(); - - QMap mMetadata; - private: - QgsPaintEffectRegistry( const QgsPaintEffectRegistry& rh ); - QgsPaintEffectRegistry& operator=( const QgsPaintEffectRegistry& rh ); + QMap mMetadata; }; #endif //QGSPAINTEFFECTREGISTRY_H diff --git a/src/core/effects/qgsshadoweffect.cpp b/src/core/effects/qgsshadoweffect.cpp index d289bd0e318..cd80df73db8 100644 --- a/src/core/effects/qgsshadoweffect.cpp +++ b/src/core/effects/qgsshadoweffect.cpp @@ -33,11 +33,6 @@ QgsShadowEffect::QgsShadowEffect() } -QgsShadowEffect::~QgsShadowEffect() -{ - -} - void QgsShadowEffect::draw( QgsRenderContext &context ) { if ( !source() || !enabled() || !context.painter() ) @@ -174,11 +169,6 @@ QgsDropShadowEffect::QgsDropShadowEffect() } -QgsDropShadowEffect::~QgsDropShadowEffect() -{ - -} - QgsDropShadowEffect* QgsDropShadowEffect::clone() const { return new QgsDropShadowEffect( *this ); @@ -202,11 +192,6 @@ QgsInnerShadowEffect::QgsInnerShadowEffect() } -QgsInnerShadowEffect::~QgsInnerShadowEffect() -{ - -} - QgsInnerShadowEffect* QgsInnerShadowEffect::clone() const { return new QgsInnerShadowEffect( *this ); diff --git a/src/core/effects/qgsshadoweffect.h b/src/core/effects/qgsshadoweffect.h index 75d2fb5139e..bf513d36c0d 100644 --- a/src/core/effects/qgsshadoweffect.h +++ b/src/core/effects/qgsshadoweffect.h @@ -17,6 +17,7 @@ #ifndef QGSSHADOWEFFECT_H #define QGSSHADOWEFFECT_H +#include "qgis_core.h" #include "qgspainteffect.h" #include "qgis.h" #include "qgssymbol.h" @@ -35,7 +36,6 @@ class CORE_EXPORT QgsShadowEffect : public QgsPaintEffect public: QgsShadowEffect(); - virtual ~QgsShadowEffect(); virtual QgsStringMap properties() const override; virtual void readProperties( const QgsStringMap& props ) override; @@ -198,7 +198,6 @@ class CORE_EXPORT QgsDropShadowEffect : public QgsShadowEffect static QgsPaintEffect* create( const QgsStringMap& map ); QgsDropShadowEffect(); - virtual ~QgsDropShadowEffect(); virtual QString type() const override { return QStringLiteral( "dropShadow" ); } virtual QgsDropShadowEffect* clone() const override; @@ -228,7 +227,6 @@ class CORE_EXPORT QgsInnerShadowEffect : public QgsShadowEffect static QgsPaintEffect* create( const QgsStringMap& map ); QgsInnerShadowEffect(); - virtual ~QgsInnerShadowEffect(); virtual QString type() const override { return QStringLiteral( "innerShadow" ); } virtual QgsInnerShadowEffect* clone() const override; diff --git a/src/core/effects/qgstransformeffect.cpp b/src/core/effects/qgstransformeffect.cpp index a1cc6c38bd0..884ff5c7c09 100644 --- a/src/core/effects/qgstransformeffect.cpp +++ b/src/core/effects/qgstransformeffect.cpp @@ -44,11 +44,6 @@ QgsTransformEffect::QgsTransformEffect() } -QgsTransformEffect::~QgsTransformEffect() -{ - -} - void QgsTransformEffect::draw( QgsRenderContext &context ) { if ( !source() || !enabled() || !context.painter() ) diff --git a/src/core/effects/qgstransformeffect.h b/src/core/effects/qgstransformeffect.h index 942adac0a57..d173501accb 100644 --- a/src/core/effects/qgstransformeffect.h +++ b/src/core/effects/qgstransformeffect.h @@ -17,6 +17,7 @@ #ifndef QGSTRANSFORMEFFECT_H #define QGSTRANSFORMEFFECT_H +#include "qgis_core.h" #include "qgspainteffect.h" #include "qgis.h" #include "qgsmapunitscale.h" @@ -42,7 +43,6 @@ class CORE_EXPORT QgsTransformEffect : public QgsPaintEffect static QgsPaintEffect* create( const QgsStringMap& map ); QgsTransformEffect(); - virtual ~QgsTransformEffect(); virtual QString type() const override { return QStringLiteral( "transform" ); } virtual QgsStringMap properties() const override; diff --git a/src/core/fieldformatter/qgsdatetimefieldformatter.cpp b/src/core/fieldformatter/qgsdatetimefieldformatter.cpp index ec9c0af6103..f597230c914 100644 --- a/src/core/fieldformatter/qgsdatetimefieldformatter.cpp +++ b/src/core/fieldformatter/qgsdatetimefieldformatter.cpp @@ -60,7 +60,7 @@ QString QgsDateTimeFieldFormatter::representValue( QgsVectorLayer* layer, int fi return result; } -QString QgsDateTimeFieldFormatter::defaultFormat( const QVariant::Type type ) +QString QgsDateTimeFieldFormatter::defaultFormat( QVariant::Type type ) { switch ( type ) { diff --git a/src/core/fieldformatter/qgsdatetimefieldformatter.h b/src/core/fieldformatter/qgsdatetimefieldformatter.h index 39696c3f01f..6a6caa9d3d0 100644 --- a/src/core/fieldformatter/qgsdatetimefieldformatter.h +++ b/src/core/fieldformatter/qgsdatetimefieldformatter.h @@ -16,8 +16,17 @@ #ifndef QGSDATETIMEFIELDKIT_H #define QGSDATETIMEFIELDKIT_H +#include "qgis_core.h" #include "qgsfieldformatter.h" +/** + * \ingroup core + * Field formatter for a date time field. + * This represents a date, time or datetime value based on + * the field configuration. + * + * \note Added in QGIS 3.0 + */ class CORE_EXPORT QgsDateTimeFieldFormatter : public QgsFieldFormatter { public: @@ -37,7 +46,7 @@ class CORE_EXPORT QgsDateTimeFieldFormatter : public QgsFieldFormatter * - QVariant::Date * - QVariant::Time */ - static QString defaultFormat( const QVariant::Type type ); + static QString defaultFormat( QVariant::Type type ); }; #endif // QGSDATETIMEFIELDKIT_H diff --git a/src/core/fieldformatter/qgsfallbackfieldformatter.h b/src/core/fieldformatter/qgsfallbackfieldformatter.h index e8a8620705a..3a7514362d8 100644 --- a/src/core/fieldformatter/qgsfallbackfieldformatter.h +++ b/src/core/fieldformatter/qgsfallbackfieldformatter.h @@ -16,8 +16,16 @@ #ifndef QGSFALLBACKFIELDKIT_H #define QGSFALLBACKFIELDKIT_H +#include "qgis_core.h" #include "qgsfieldformatter.h" +/** + * \ingroup core + * A default fallback field formatter in case no specialized field formatter is defined. + * The values will be returned unmodified. + * + * \note Added in QGIS 3.0 + */ class CORE_EXPORT QgsFallbackFieldFormatter : public QgsFieldFormatter { public: diff --git a/src/core/fieldformatter/qgskeyvaluefieldformatter.cpp b/src/core/fieldformatter/qgskeyvaluefieldformatter.cpp index 3628a3acb95..27dd7ce3ea6 100644 --- a/src/core/fieldformatter/qgskeyvaluefieldformatter.cpp +++ b/src/core/fieldformatter/qgskeyvaluefieldformatter.cpp @@ -32,7 +32,6 @@ QString QgsKeyValueFieldFormatter::representValue( QgsVectorLayer* layer, int fi if ( value.isNull() ) { - QSettings settings; return QgsApplication::nullRepresentation(); } @@ -40,7 +39,8 @@ QString QgsKeyValueFieldFormatter::representValue( QgsVectorLayer* layer, int fi const QVariantMap map = value.toMap(); for ( QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i ) { - if ( !result.isEmpty() ) result.append( ", " ); + if ( !result.isEmpty() ) + result.append( ", " ); result.append( i.key() ).append( ": " ).append( i.value().toString() ); } return result; diff --git a/src/core/fieldformatter/qgskeyvaluefieldformatter.h b/src/core/fieldformatter/qgskeyvaluefieldformatter.h index b5fed36041d..70078da560d 100644 --- a/src/core/fieldformatter/qgskeyvaluefieldformatter.h +++ b/src/core/fieldformatter/qgskeyvaluefieldformatter.h @@ -16,8 +16,20 @@ #ifndef QGSKEYVALUEFIELDKIT_H #define QGSKEYVALUEFIELDKIT_H +#include "qgis_core.h" #include "qgsfieldformatter.h" +/** + * \ingroup core + * Field formatter for a key value field. + * This represents a list type value. + * Values will be represented as a colon-delimited and + * comma-separated list. + * + * E.g. "color: yellow, amount: 5" + * + * \note Added in QGIS 3.0 + */ class CORE_EXPORT QgsKeyValueFieldFormatter : public QgsFieldFormatter { public: diff --git a/src/core/fieldformatter/qgslistfieldformatter.cpp b/src/core/fieldformatter/qgslistfieldformatter.cpp index 3214eb21464..6440ea0b231 100644 --- a/src/core/fieldformatter/qgslistfieldformatter.cpp +++ b/src/core/fieldformatter/qgslistfieldformatter.cpp @@ -31,16 +31,15 @@ QString QgsListFieldFormatter::representValue( QgsVectorLayer* layer, int fieldI if ( value.isNull() ) { - QSettings settings; return QgsApplication::nullRepresentation(); } QString result; - const QVariantList list = value.toList(); - for ( QVariantList::const_iterator i = list.constBegin(); i != list.constEnd(); ++i ) + Q_FOREACH ( const QVariant& val, value.toList() ) { - if ( !result.isEmpty() ) result.append( ", " ); - result.append( i->toString() ); + if ( !result.isEmpty() ) + result.append( ", " ); + result.append( val.toString() ); } return result; } diff --git a/src/core/fieldformatter/qgslistfieldformatter.h b/src/core/fieldformatter/qgslistfieldformatter.h index 3b7a4749bc5..c85bd985230 100644 --- a/src/core/fieldformatter/qgslistfieldformatter.h +++ b/src/core/fieldformatter/qgslistfieldformatter.h @@ -16,8 +16,17 @@ #ifndef QGSLISTFIELDKIT_H #define QGSLISTFIELDKIT_H +#include "qgis_core.h" #include "qgsfieldformatter.h" +/** + * \ingroup core + * Field formatter for a list field. + * This represents a list type value. + * Values will be represented as a comma-separated list. + * + * \note Added in QGIS 3.0 + */ class CORE_EXPORT QgsListFieldFormatter : public QgsFieldFormatter { public: diff --git a/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp b/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp index 32be2e1413e..0c46841981a 100644 --- a/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp +++ b/src/core/fieldformatter/qgsrelationreferencefieldformatter.cpp @@ -74,10 +74,7 @@ QString QgsRelationReferenceFieldFormatter::representValue( QgsVectorLayer* laye return value.toString(); QgsExpression expr( referencedLayer->displayExpression() ); - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( referencedLayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( referencedLayer ) ); context.setFeature( feature ); QString title = expr.evaluate( &context ).toString(); if ( expr.hasEvalError() ) diff --git a/src/core/fieldformatter/qgsrelationreferencefieldformatter.h b/src/core/fieldformatter/qgsrelationreferencefieldformatter.h index 3a7216dd948..6c798989bab 100644 --- a/src/core/fieldformatter/qgsrelationreferencefieldformatter.h +++ b/src/core/fieldformatter/qgsrelationreferencefieldformatter.h @@ -16,8 +16,17 @@ #ifndef QGSRELATIONREFERENCEFIELDKIT_H #define QGSRELATIONREFERENCEFIELDKIT_H +#include "qgis_core.h" #include "qgsfieldformatter.h" +/** + * \ingroup core + * Field formatter for a relation reference field. + * A value relation field formatter looks up the values from + * features on another layer. + * + * \note Added in QGIS 3.0 + */ class CORE_EXPORT QgsRelationReferenceFieldFormatter : public QgsFieldFormatter { public: diff --git a/src/core/fieldformatter/qgsvaluemapfieldformatter.h b/src/core/fieldformatter/qgsvaluemapfieldformatter.h index 400501b2365..6fe94b3379b 100644 --- a/src/core/fieldformatter/qgsvaluemapfieldformatter.h +++ b/src/core/fieldformatter/qgsvaluemapfieldformatter.h @@ -16,8 +16,26 @@ #ifndef QGSVALUEMAPFIELDKIT_H #define QGSVALUEMAPFIELDKIT_H +#include "qgis_core.h" #include "qgsfieldformatter.h" +/** + * \ingroup core + * Field formatter for a ValueMap field. + * A value relation field formatter looks up the values a map. + * + * The map is defined in the configuration as dictionary under the key "map". + * + * { "map": { 1: "one", 2: "two", 3: "three" } } + * + * Values that are not on the map will be wrapped in parantheses. So with the above + * configuration: + * + * - 3 => "three" + * - 5 => "(5)" + * + * \note Added in QGIS 3.0 + */ class CORE_EXPORT QgsValueMapFieldFormatter : public QgsFieldFormatter { public: diff --git a/src/core/fieldformatter/qgsvaluerelationfieldformatter.h b/src/core/fieldformatter/qgsvaluerelationfieldformatter.h index a3e4a9c0092..20383051a67 100644 --- a/src/core/fieldformatter/qgsvaluerelationfieldformatter.h +++ b/src/core/fieldformatter/qgsvaluerelationfieldformatter.h @@ -16,11 +16,20 @@ #ifndef QGSVALUERELATIONFIELDKIT_H #define QGSVALUERELATIONFIELDKIT_H +#include "qgis_core.h" #include "qgsfieldformatter.h" #include #include +/** + * \ingroup core + * Field formatter for a value relation field. + * A value relation field formatter looks up the values from + * features on another layer. + * + * \note Added in QGIS 3.0 + */ class CORE_EXPORT QgsValueRelationFieldFormatter : public QgsFieldFormatter { public: @@ -49,6 +58,13 @@ class CORE_EXPORT QgsValueRelationFieldFormatter : public QgsFieldFormatter QVariant createCache( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config ) const override; + /** + * Create a cache for a value relation field. + * This can be used to keep the value map in the local memory + * if doing multiple lookups in a loop. + * + * \note Added in QGIS 3.0 + */ static ValueRelationCache createCache( const QVariantMap& config ); }; diff --git a/src/core/geometry/qgsabstractgeometry.cpp b/src/core/geometry/qgsabstractgeometry.cpp index 2e24612537b..f8ce3b2cd92 100644 --- a/src/core/geometry/qgsabstractgeometry.cpp +++ b/src/core/geometry/qgsabstractgeometry.cpp @@ -27,10 +27,6 @@ QgsAbstractGeometry::QgsAbstractGeometry(): mWkbType( QgsWkbTypes::Unknown ) { } -QgsAbstractGeometry::~QgsAbstractGeometry() -{ -} - QgsAbstractGeometry::QgsAbstractGeometry( const QgsAbstractGeometry& geom ) { mWkbType = geom.mWkbType; diff --git a/src/core/geometry/qgsabstractgeometry.h b/src/core/geometry/qgsabstractgeometry.h index 599ba07ce57..666ded5c5c9 100644 --- a/src/core/geometry/qgsabstractgeometry.h +++ b/src/core/geometry/qgsabstractgeometry.h @@ -16,6 +16,7 @@ email : marco.hugentobler at sourcepole dot com #ifndef QGSABSTRACTGEOMETRYV2 #define QGSABSTRACTGEOMETRYV2 +#include "qgis_core.h" #include "qgscoordinatetransform.h" #include "qgswkbtypes.h" #include "qgswkbptr.h" @@ -53,7 +54,7 @@ class CORE_EXPORT QgsAbstractGeometry }; QgsAbstractGeometry(); - virtual ~QgsAbstractGeometry(); + virtual ~QgsAbstractGeometry() = default; QgsAbstractGeometry( const QgsAbstractGeometry& geom ); virtual QgsAbstractGeometry& operator=( const QgsAbstractGeometry& geom ); @@ -392,7 +393,7 @@ class CORE_EXPORT QgsAbstractGeometry */ virtual QgsRectangle calculateBoundingBox() const; - /** Clears any cached parameters associated with the geometry, eg bounding boxes + /** Clears any cached parameters associated with the geometry, e.g., bounding boxes */ virtual void clearCache() const {} diff --git a/src/core/geometry/qgscircularstring.cpp b/src/core/geometry/qgscircularstring.cpp index 035018b7720..d1c640caeae 100644 --- a/src/core/geometry/qgscircularstring.cpp +++ b/src/core/geometry/qgscircularstring.cpp @@ -31,11 +31,6 @@ QgsCircularString::QgsCircularString(): QgsCurve() mWkbType = QgsWkbTypes::CircularString; } -QgsCircularString::~QgsCircularString() -{ - -} - bool QgsCircularString::operator==( const QgsCurve& other ) const { const QgsCircularString* otherLine = dynamic_cast< const QgsCircularString* >( &other ); diff --git a/src/core/geometry/qgscircularstring.h b/src/core/geometry/qgscircularstring.h index 521d9016a13..5d9df75825a 100644 --- a/src/core/geometry/qgscircularstring.h +++ b/src/core/geometry/qgscircularstring.h @@ -18,6 +18,7 @@ #ifndef QGSCIRCULARSTRING_H #define QGSCIRCULARSTRING_H +#include "qgis_core.h" #include "qgscurve.h" #include @@ -31,7 +32,6 @@ class CORE_EXPORT QgsCircularString: public QgsCurve { public: QgsCircularString(); - ~QgsCircularString(); virtual bool operator==( const QgsCurve& other ) const override; virtual bool operator!=( const QgsCurve& other ) const override; diff --git a/src/core/geometry/qgscompoundcurve.h b/src/core/geometry/qgscompoundcurve.h index a2f0ac15e1a..094e1090562 100644 --- a/src/core/geometry/qgscompoundcurve.h +++ b/src/core/geometry/qgscompoundcurve.h @@ -18,6 +18,7 @@ #ifndef QGSCOMPOUNDCURVEV2_H #define QGSCOMPOUNDCURVEV2_H +#include "qgis_core.h" #include "qgscurve.h" /** \ingroup core diff --git a/src/core/geometry/qgscurve.cpp b/src/core/geometry/qgscurve.cpp index 3a8b6b3fa57..f0a35161a0d 100644 --- a/src/core/geometry/qgscurve.cpp +++ b/src/core/geometry/qgscurve.cpp @@ -23,9 +23,6 @@ QgsCurve::QgsCurve(): QgsAbstractGeometry() {} -QgsCurve::~QgsCurve() -{} - bool QgsCurve::isClosed() const { if ( numPoints() == 0 ) diff --git a/src/core/geometry/qgscurve.h b/src/core/geometry/qgscurve.h index a6ff8d7245b..204ff07ecdd 100644 --- a/src/core/geometry/qgscurve.h +++ b/src/core/geometry/qgscurve.h @@ -18,6 +18,7 @@ #ifndef QGSCURVEV2_H #define QGSCURVEV2_H +#include "qgis_core.h" #include "qgsabstractgeometry.h" #include "qgsrectangle.h" @@ -33,7 +34,6 @@ class CORE_EXPORT QgsCurve: public QgsAbstractGeometry { public: QgsCurve(); - virtual ~QgsCurve(); virtual bool operator==( const QgsCurve& other ) const = 0; virtual bool operator!=( const QgsCurve& other ) const = 0; @@ -81,8 +81,7 @@ class CORE_EXPORT QgsCurve: public QgsAbstractGeometry */ virtual int numPoints() const = 0; - /** Calculates the area of the curve. Derived classes should override this - * to return the correct area of the curve. + /** Sums up the area of the curve by iterating over the vertices (shoelace formula). */ virtual void sumUpArea( double& sum ) const = 0; diff --git a/src/core/geometry/qgscurvepolygon.cpp b/src/core/geometry/qgscurvepolygon.cpp index d0cc4b1a7e6..0bc765143bc 100644 --- a/src/core/geometry/qgscurvepolygon.cpp +++ b/src/core/geometry/qgscurvepolygon.cpp @@ -359,7 +359,7 @@ double QgsCurvePolygon::area() const double totalArea = 0.0; - if ( mExteriorRing->isClosed() ) + if ( mExteriorRing->isRing() ) { double area = 0.0; mExteriorRing->sumUpArea( area ); @@ -370,7 +370,7 @@ double QgsCurvePolygon::area() const for ( ; ringIt != mInteriorRings.constEnd(); ++ringIt ) { double area = 0.0; - if (( *ringIt )->isClosed() ) + if (( *ringIt )->isRing() ) { ( *ringIt )->sumUpArea( area ); totalArea -= qAbs( area ); diff --git a/src/core/geometry/qgscurvepolygon.h b/src/core/geometry/qgscurvepolygon.h index 473fd79b185..bc79218e2b2 100644 --- a/src/core/geometry/qgscurvepolygon.h +++ b/src/core/geometry/qgscurvepolygon.h @@ -18,6 +18,7 @@ #ifndef QGSCURVEPOLYGONV2_H #define QGSCURVEPOLYGONV2_H +#include "qgis_core.h" #include "qgssurface.h" class QgsPolygonV2; diff --git a/src/core/geometry/qgsgeometry.cpp b/src/core/geometry/qgsgeometry.cpp index 2758209d7d2..9ff716c1a02 100644 --- a/src/core/geometry/qgsgeometry.cpp +++ b/src/core/geometry/qgsgeometry.cpp @@ -1897,14 +1897,14 @@ bool QgsGeometry::deletePart( int partNum ) return ok; } -int QgsGeometry::avoidIntersections( const QHash > &ignoreFeatures ) +int QgsGeometry::avoidIntersections( const QList& avoidIntersectionsLayers, const QHash > &ignoreFeatures ) { if ( !d->geometry ) { return 1; } - QgsAbstractGeometry* diffGeom = QgsGeometryEditUtils::avoidIntersections( *( d->geometry ), ignoreFeatures ); + QgsAbstractGeometry* diffGeom = QgsGeometryEditUtils::avoidIntersections( *( d->geometry ), avoidIntersectionsLayers, ignoreFeatures ); if ( diffGeom ) { detach( false ); diff --git a/src/core/geometry/qgsgeometry.h b/src/core/geometry/qgsgeometry.h index 1cca15989b0..b37f9c35a98 100644 --- a/src/core/geometry/qgsgeometry.h +++ b/src/core/geometry/qgsgeometry.h @@ -16,6 +16,7 @@ email : morb at ozemail dot com dot au #ifndef QGSGEOMETRY_H #define QGSGEOMETRY_H +#include "qgis_core.h" #include #include #include @@ -95,7 +96,7 @@ class CORE_EXPORT QgsGeometry */ explicit QgsGeometry( QgsAbstractGeometry* geom ); - //! Destructor + ~QgsGeometry(); /** Returns the underlying geometry store. @@ -617,7 +618,7 @@ class CORE_EXPORT QgsGeometry /** * Returns a point guaranteed to lie on the surface of a geometry. While the centroid() - * of a geometry may be located outside of the geometry itself (eg for concave shapes), + * of a geometry may be located outside of the geometry itself (e.g., for concave shapes), * the point on surface will always be inside the geometry. * @see centroid() * @see poleOfInaccessibility() @@ -807,10 +808,12 @@ class CORE_EXPORT QgsGeometry * 1 if geometry is not of polygon type, * 2 if avoid intersection would change the geometry type, * 3 other error during intersection removal + * @param avoidIntersectionsLayers list of layers to check for intersections * @param ignoreFeatures possibility to give a list of features where intersections should be ignored (not available in python bindings) * @note added in 1.5 */ - int avoidIntersections( const QHash >& ignoreFeatures = ( QHash >() ) ); + int avoidIntersections( const QList& avoidIntersectionsLayers, + const QHash >& ignoreFeatures = ( QHash >() ) ); /** \ingroup core */ @@ -959,8 +962,8 @@ class CORE_EXPORT QgsGeometry * roughly doubles the number of vertices in a geometry. * @param iterations number of smoothing iterations to run. More iterations results * in a smoother geometry - * @param offset fraction of line to create new vertices along, between 0 and 1.0 - * eg the default value of 0.25 will create new vertices 25% and 75% along each line segment + * @param offset fraction of line to create new vertices along, between 0 and 1.0, + * e.g., the default value of 0.25 will create new vertices 25% and 75% along each line segment * of the geometry for each iteration. Smaller values result in "tighter" smoothing. * @param minimumDistance minimum segment length to apply smoothing to * @param maxAngle maximum angle at node (0-180) at which smoothing will be applied @@ -1017,8 +1020,8 @@ class CORE_EXPORT QgsGeometry * @param line line to smooth * @param iterations number of smoothing iterations to run. More iterations results * in a smoother geometry - * @param offset fraction of line to create new vertices along, between 0 and 1.0 - * eg the default value of 0.25 will create new vertices 25% and 75% along each line segment + * @param offset fraction of line to create new vertices along, between 0 and 1.0, + * e.g., the default value of 0.25 will create new vertices 25% and 75% along each line segment * of the geometry for each iteration. Smaller values result in "tighter" smoothing. * @param minimumDistance minimum segment length to apply smoothing to * @param maxAngle maximum angle at node (0-180) at which smoothing will be applied @@ -1030,8 +1033,8 @@ class CORE_EXPORT QgsGeometry * @param polygon polygon to smooth * @param iterations number of smoothing iterations to run. More iterations results * in a smoother geometry - * @param offset fraction of segment to create new vertices along, between 0 and 1.0 - * eg the default value of 0.25 will create new vertices 25% and 75% along each line segment + * @param offset fraction of segment to create new vertices along, between 0 and 1.0, + * e.g., the default value of 0.25 will create new vertices 25% and 75% along each line segment * of the geometry for each iteration. Smaller values result in "tighter" smoothing. * @param minimumDistance minimum segment length to apply smoothing to * @param maxAngle maximum angle at node (0-180) at which smoothing will be applied diff --git a/src/core/geometry/qgsgeometrycollection.h b/src/core/geometry/qgsgeometrycollection.h index 05e09497c2c..11c25f951bb 100644 --- a/src/core/geometry/qgsgeometrycollection.h +++ b/src/core/geometry/qgsgeometrycollection.h @@ -16,6 +16,7 @@ email : marco.hugentobler at sourcepole dot com #ifndef QGSGEOMETRYCOLLECTIONV2_H #define QGSGEOMETRYCOLLECTIONV2_H +#include "qgis_core.h" #include "qgsabstractgeometry.h" #include "qgspointv2.h" #include diff --git a/src/core/geometry/qgsgeometryeditutils.cpp b/src/core/geometry/qgsgeometryeditutils.cpp index a77ec629914..c2e1b376b07 100644 --- a/src/core/geometry/qgsgeometryeditutils.cpp +++ b/src/core/geometry/qgsgeometryeditutils.cpp @@ -224,7 +224,9 @@ bool QgsGeometryEditUtils::deletePart( QgsAbstractGeometry* geom, int partNum ) return c->removeGeometry( partNum ); } -QgsAbstractGeometry* QgsGeometryEditUtils::avoidIntersections( const QgsAbstractGeometry& geom, QHash > ignoreFeatures ) +QgsAbstractGeometry* QgsGeometryEditUtils::avoidIntersections( const QgsAbstractGeometry& geom, + const QList& avoidIntersectionsLayers, + QHash > ignoreFeatures ) { QScopedPointer geomEngine( QgsGeometry::createGeometryEngine( &geom ) ); if ( geomEngine.isNull() ) @@ -240,39 +242,32 @@ QgsAbstractGeometry* QgsGeometryEditUtils::avoidIntersections( const QgsAbstract return nullptr; } - QStringList avoidIntersectionsList = QgsProject::instance()->avoidIntersectionsList(); - if ( avoidIntersectionsList.isEmpty() ) + if ( avoidIntersectionsLayers.isEmpty() ) return nullptr; //no intersections stored in project does not mean error QList< QgsAbstractGeometry* > nearGeometries; //go through list, convert each layer to vector layer and call QgsVectorLayer::removePolygonIntersections for each - QgsVectorLayer* currentLayer = nullptr; - QStringList::const_iterator aIt = avoidIntersectionsList.constBegin(); - for ( ; aIt != avoidIntersectionsList.constEnd(); ++aIt ) + Q_FOREACH ( QgsVectorLayer* currentLayer, avoidIntersectionsLayers ) { - currentLayer = dynamic_cast( QgsProject::instance()->mapLayer( *aIt ) ); - if ( currentLayer ) + QgsFeatureIds ignoreIds; + QHash >::const_iterator ignoreIt = ignoreFeatures.find( currentLayer ); + if ( ignoreIt != ignoreFeatures.constEnd() ) + ignoreIds = ignoreIt.value(); + + QgsFeatureIterator fi = currentLayer->getFeatures( QgsFeatureRequest( geom.boundingBox() ) + .setFlags( QgsFeatureRequest::ExactIntersect ) + .setSubsetOfAttributes( QgsAttributeList() ) ); + QgsFeature f; + while ( fi.nextFeature( f ) ) { - QgsFeatureIds ignoreIds; - QHash >::const_iterator ignoreIt = ignoreFeatures.find( currentLayer ); - if ( ignoreIt != ignoreFeatures.constEnd() ) - ignoreIds = ignoreIt.value(); + if ( ignoreIds.contains( f.id() ) ) + continue; - QgsFeatureIterator fi = currentLayer->getFeatures( QgsFeatureRequest( geom.boundingBox() ) - .setFlags( QgsFeatureRequest::ExactIntersect ) - .setSubsetOfAttributes( QgsAttributeList() ) ); - QgsFeature f; - while ( fi.nextFeature( f ) ) - { - if ( ignoreIds.contains( f.id() ) ) - continue; + if ( !f.hasGeometry() ) + continue; - if ( !f.hasGeometry() ) - continue; - - nearGeometries << f.geometry().geometry()->clone(); - } + nearGeometries << f.geometry().geometry()->clone(); } } diff --git a/src/core/geometry/qgsgeometryeditutils.h b/src/core/geometry/qgsgeometryeditutils.h index 36f3b9b0001..42084b72d90 100644 --- a/src/core/geometry/qgsgeometryeditutils.h +++ b/src/core/geometry/qgsgeometryeditutils.h @@ -59,9 +59,12 @@ class QgsGeometryEditUtils /** Alters a geometry so that it avoids intersections with features from all open vector layers. * @param geom geometry to alter + * @param avoidIntersectionsLayers list of layers to check for intersections * @param ignoreFeatures map of layer to feature id of features to ignore */ - static QgsAbstractGeometry* avoidIntersections( const QgsAbstractGeometry& geom, QHash > ignoreFeatures = ( QHash >() ) ); + static QgsAbstractGeometry* avoidIntersections( const QgsAbstractGeometry& geom, + const QList& avoidIntersectionsLayers, + QHash > ignoreFeatures = ( QHash >() ) ); }; #endif // QGSGEOMETRYEDITUTILS_H diff --git a/src/core/geometry/qgsgeometryengine.h b/src/core/geometry/qgsgeometryengine.h index 64ff3228df0..bfb519de708 100644 --- a/src/core/geometry/qgsgeometryengine.h +++ b/src/core/geometry/qgsgeometryengine.h @@ -16,6 +16,7 @@ email : marco.hugentobler at sourcepole dot com #ifndef QGSGEOMETRYENGINE_H #define QGSGEOMETRYENGINE_H +#include "qgis_core.h" #include "qgslinestring.h" #include @@ -32,7 +33,7 @@ class CORE_EXPORT QgsGeometryEngine { public: QgsGeometryEngine( const QgsAbstractGeometry* geometry ): mGeometry( geometry ) {} - virtual ~QgsGeometryEngine() {} + virtual ~QgsGeometryEngine() = default; virtual void geometryChanged() = 0; virtual void prepareGeometry() = 0; diff --git a/src/core/geometry/qgsgeometryfactory.h b/src/core/geometry/qgsgeometryfactory.h index ea8498dc2de..e1584de18bd 100644 --- a/src/core/geometry/qgsgeometryfactory.h +++ b/src/core/geometry/qgsgeometryfactory.h @@ -18,6 +18,7 @@ #ifndef QGSGEOMETRYFACTORY_H #define QGSGEOMETRYFACTORY_H +#include "qgis_core.h" #include class QgsAbstractGeometry; diff --git a/src/core/geometry/qgsgeometryutils.h b/src/core/geometry/qgsgeometryutils.h index ac5dd0f173e..cb56c734cf1 100644 --- a/src/core/geometry/qgsgeometryutils.h +++ b/src/core/geometry/qgsgeometryutils.h @@ -16,6 +16,7 @@ email : marco.hugentobler at sourcepole dot com #ifndef QGSGEOMETRYUTILS_H #define QGSGEOMETRYUTILS_H +#include "qgis_core.h" #include "qgspointv2.h" #include @@ -239,7 +240,7 @@ class CORE_EXPORT QgsGeometryUtils /** Parses a WKT string and returns of list of blocks contained in the WKT. * @param wkt WKT string in the format "TYPE1 (contents1), TYPE2 (TYPE3 (contents3), TYPE4 (contents4))" * @param defaultType default geometry type for childen - * @returns list of WKT child block strings, eg List("TYPE1 (contents1)", "TYPE2 (TYPE3 (contents3), TYPE4 (contents4))") + * @returns list of WKT child block strings, e.g., List("TYPE1 (contents1)", "TYPE2 (TYPE3 (contents3), TYPE4 (contents4))") */ static QStringList wktGetChildBlocks( const QString& wkt , const QString &defaultType = "" ); diff --git a/src/core/geometry/qgsgeos.h b/src/core/geometry/qgsgeos.h index 37dc46457c0..68dfa038b8c 100644 --- a/src/core/geometry/qgsgeos.h +++ b/src/core/geometry/qgsgeos.h @@ -16,6 +16,7 @@ email : marco.hugentobler at sourcepole dot com #ifndef QGSGEOS_H #define QGSGEOS_H +#include "qgis_core.h" #include "qgsgeometryengine.h" #include diff --git a/src/core/geometry/qgslinestring.cpp b/src/core/geometry/qgslinestring.cpp index 85287245cb6..c329702d394 100644 --- a/src/core/geometry/qgslinestring.cpp +++ b/src/core/geometry/qgslinestring.cpp @@ -40,9 +40,6 @@ QgsLineString::QgsLineString(): QgsCurve() mWkbType = QgsWkbTypes::LineString; } -QgsLineString::~QgsLineString() -{} - bool QgsLineString::operator==( const QgsCurve& other ) const { const QgsLineString* otherLine = dynamic_cast< const QgsLineString* >( &other ); @@ -852,8 +849,6 @@ QgsPointV2 QgsLineString::centroid() const void QgsLineString::sumUpArea( double& sum ) const { int maxIndex = numPoints() - 1; - if ( maxIndex == 1 ) - return; //no area, just a single line for ( int i = 0; i < maxIndex; ++i ) { diff --git a/src/core/geometry/qgslinestring.h b/src/core/geometry/qgslinestring.h index 9c1ae8f0a6b..8963e4ecf5c 100644 --- a/src/core/geometry/qgslinestring.h +++ b/src/core/geometry/qgslinestring.h @@ -18,6 +18,7 @@ #ifndef QGSLINESTRINGV2_H #define QGSLINESTRINGV2_H +#include "qgis_core.h" #include "qgscurve.h" #include @@ -36,7 +37,6 @@ class CORE_EXPORT QgsLineString: public QgsCurve { public: QgsLineString(); - ~QgsLineString(); bool operator==( const QgsCurve& other ) const override; bool operator!=( const QgsCurve& other ) const override; diff --git a/src/core/geometry/qgsmulticurve.h b/src/core/geometry/qgsmulticurve.h index dd23fb7c32b..15a5669a734 100644 --- a/src/core/geometry/qgsmulticurve.h +++ b/src/core/geometry/qgsmulticurve.h @@ -16,6 +16,7 @@ email : marco.hugentobler at sourcepole dot com #ifndef QGSMULTICURVEV2_H #define QGSMULTICURVEV2_H +#include "qgis_core.h" #include "qgsgeometrycollection.h" /** \ingroup core diff --git a/src/core/geometry/qgsmultilinestring.h b/src/core/geometry/qgsmultilinestring.h index 2d2b894875c..4b044034837 100644 --- a/src/core/geometry/qgsmultilinestring.h +++ b/src/core/geometry/qgsmultilinestring.h @@ -16,6 +16,7 @@ email : marco.hugentobler at sourcepole dot com #ifndef QGSMULTILINESTRINGV2_H #define QGSMULTILINESTRINGV2_H +#include "qgis_core.h" #include "qgsmulticurve.h" /** \ingroup core diff --git a/src/core/geometry/qgsmultipoint.h b/src/core/geometry/qgsmultipoint.h index 3211f22a525..72826be88fe 100644 --- a/src/core/geometry/qgsmultipoint.h +++ b/src/core/geometry/qgsmultipoint.h @@ -16,6 +16,7 @@ email : marco.hugentobler at sourcepole dot com #ifndef QGSMULTIPOINTV2_H #define QGSMULTIPOINTV2_H +#include "qgis_core.h" #include "qgsgeometrycollection.h" /** \ingroup core diff --git a/src/core/geometry/qgsmultipolygon.h b/src/core/geometry/qgsmultipolygon.h index 8aae2f52d54..1ea73f4400e 100644 --- a/src/core/geometry/qgsmultipolygon.h +++ b/src/core/geometry/qgsmultipolygon.h @@ -16,6 +16,7 @@ email : marco.hugentobler at sourcepole dot com #ifndef QGSMULTIPOLYGONV2_H #define QGSMULTIPOLYGONV2_H +#include "qgis_core.h" #include "qgsmultisurface.h" /** \ingroup core diff --git a/src/core/geometry/qgsmultisurface.h b/src/core/geometry/qgsmultisurface.h index 04f982a70a5..a06f53d22c4 100644 --- a/src/core/geometry/qgsmultisurface.h +++ b/src/core/geometry/qgsmultisurface.h @@ -16,6 +16,7 @@ email : marco.hugentobler at sourcepole dot com #ifndef QGSMULTISURFACEV2_H #define QGSMULTISURFACEV2_H +#include "qgis_core.h" #include "qgsgeometrycollection.h" /** \ingroup core diff --git a/src/core/geometry/qgspointv2.h b/src/core/geometry/qgspointv2.h index 6a5c2d3c9e5..34e17bd1aa8 100644 --- a/src/core/geometry/qgspointv2.h +++ b/src/core/geometry/qgspointv2.h @@ -18,6 +18,7 @@ #ifndef QGSPOINTV2_H #define QGSPOINTV2_H +#include "qgis_core.h" #include "qgsabstractgeometry.h" #include "qgsrectangle.h" @@ -50,7 +51,7 @@ class CORE_EXPORT QgsPointV2: public QgsAbstractGeometry */ explicit QgsPointV2( QPointF p ); - /** Construct a point with a specified type (eg PointZ, PointM) and initial x, y, z, and m values. + /** Construct a point with a specified type (e.g., PointZ, PointM) and initial x, y, z, and m values. * @param type point type * @param x x-coordinate of point * @param y y-coordinate of point @@ -153,7 +154,7 @@ class CORE_EXPORT QgsPointV2: public QgsAbstractGeometry /** * Returns the distance between this point and a specified x, y coordinate. In certain - * cases it may be more appropriate to call the faster distanceSquared() method, eg + * cases it may be more appropriate to call the faster distanceSquared() method, e.g., * when comparing distances. * @note added in QGIS 3.0 * @see distanceSquared() @@ -162,7 +163,7 @@ class CORE_EXPORT QgsPointV2: public QgsAbstractGeometry /** * Returns the 2D distance between this point and another point. In certain - * cases it may be more appropriate to call the faster distanceSquared() method, eg + * cases it may be more appropriate to call the faster distanceSquared() method, e.g., * when comparing distances. * @note added in QGIS 3.0 */ diff --git a/src/core/geometry/qgspolygon.h b/src/core/geometry/qgspolygon.h index 630284cb182..e8324f6c504 100644 --- a/src/core/geometry/qgspolygon.h +++ b/src/core/geometry/qgspolygon.h @@ -18,6 +18,7 @@ #ifndef QGSPOLYGONV2_H #define QGSPOLYGONV2_H +#include "qgis_core.h" #include "qgscurvepolygon.h" /** \ingroup core diff --git a/src/core/geometry/qgssurface.h b/src/core/geometry/qgssurface.h index 54f2e113f1e..5a99905835c 100644 --- a/src/core/geometry/qgssurface.h +++ b/src/core/geometry/qgssurface.h @@ -18,6 +18,7 @@ #ifndef QGSSURFACEV2_H #define QGSSURFACEV2_H +#include "qgis_core.h" #include "qgsabstractgeometry.h" #include "qgsrectangle.h" diff --git a/src/core/geometry/qgswkbptr.h b/src/core/geometry/qgswkbptr.h index 7a62e3ba750..f8075e6461b 100644 --- a/src/core/geometry/qgswkbptr.h +++ b/src/core/geometry/qgswkbptr.h @@ -15,6 +15,7 @@ #ifndef QGSWKBPTR_H #define QGSWKBPTR_H +#include "qgis_core.h" #include "qgswkbtypes.h" #include "qgsapplication.h" #include "qgis.h" diff --git a/src/core/geometry/qgswkbtypes.h b/src/core/geometry/qgswkbtypes.h index a4d4f89ccaf..fb349f2a99f 100644 --- a/src/core/geometry/qgswkbtypes.h +++ b/src/core/geometry/qgswkbtypes.h @@ -21,6 +21,8 @@ #include #include +#include "qgis_core.h" + /*************************************************************************** * This class is considered CRITICAL and any change MUST be accompanied with * full unit tests in testqgsstatisticalsummary.cpp. @@ -37,6 +39,29 @@ class CORE_EXPORT QgsWkbTypes { public: + /** + * The WKB type describes the number of dimensions a geometry has + * + * - Point + * - LineString + * - Polygon + * + * as well as the number of dimensions for each individual vertex + * + * - X (always) + * - Y (always) + * - Z (optional) + * - M (measurement value, optional) + * + * it also has values for multi types, collections, unknown geometry, + * null geometry, no geometry and curve support. + * + * These classes of geometry are often used for data sources to + * communicate what kind of geometry should be expected for a given + * geometry field. It is also used for tools or algorithms to decide + * if they should be available for a given geometry type or act in + * a different mode. + */ enum Type { Unknown = 0, @@ -97,6 +122,12 @@ class CORE_EXPORT QgsWkbTypes MultiPolygon25D }; + /** + * The geometry types are used to group QgsWkbTypes::Type in a + * coarse way. + * + * @see geometryType( QgsWkbTypes::Type ) + */ enum GeometryType { PointGeometry, @@ -106,7 +137,7 @@ class CORE_EXPORT QgsWkbTypes NullGeometry }; - /** Returns the single type for a WKB type. Eg, for MultiPolygon WKB types the single type would be Polygon. + /** Returns the single type for a WKB type. For example, for MultiPolygon WKB types the single type would be Polygon. * @see isSingleType() * @see multiType() * @see flatType() @@ -232,7 +263,7 @@ class CORE_EXPORT QgsWkbTypes return Unknown; } - /** Returns the multi type for a WKB type. Eg, for Polygon WKB types the multi type would be MultiPolygon. + /** Returns the multi type for a WKB type. For example, for Polygon WKB types the multi type would be MultiPolygon. * @see isMultiType() * @see singleType() * @see flatType() @@ -359,7 +390,7 @@ class CORE_EXPORT QgsWkbTypes } /** Returns the flat type for a WKB type. This is the WKB type minus any Z or M dimensions. - * Eg, for PolygonZM WKB types the single type would be Polygon. + * For example, for PolygonZM WKB types the single type would be Polygon. * @see singleType() * @see multiType() */ @@ -578,8 +609,9 @@ class CORE_EXPORT QgsWkbTypes return 2 + hasZ( type ) + hasM( type ); } - /** Returns the geometry type for a WKB type, eg both MultiPolygon and CurvePolygon would have a + /** Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a * PolygonGeometry geometry type. + * GeometryCollections are reported as QgsWkbTypes::UnknownGeometry. */ static GeometryType geometryType( Type type ) { @@ -655,7 +687,7 @@ class CORE_EXPORT QgsWkbTypes return UnknownGeometry; } - /** Returns a display string type for a WKB type, eg the geometry name used in WKT geometry representations. + /** Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representations. */ static QString displayString( Type type ); diff --git a/src/core/gps/qextserialport/qwineventnotifier.h b/src/core/gps/qextserialport/qwineventnotifier.h index f637fea0f8a..c26a6ab2567 100644 --- a/src/core/gps/qextserialport/qwineventnotifier.h +++ b/src/core/gps/qextserialport/qwineventnotifier.h @@ -1,5 +1,6 @@ #ifndef QWINEVENTNOTIFIER_H #define QWINEVENTNOTIFIER_H +#include "qgis_core.h" #include #include diff --git a/src/core/gps/qgsgpsconnection.h b/src/core/gps/qgsgpsconnection.h index d333e78eb84..4fff592ae8a 100644 --- a/src/core/gps/qgsgpsconnection.h +++ b/src/core/gps/qgsgpsconnection.h @@ -22,6 +22,8 @@ #include #include +#include "qgis_core.h" + class QIODevice; struct CORE_EXPORT QgsSatelliteInfo diff --git a/src/core/gps/qgsgpsconnectionregistry.cpp b/src/core/gps/qgsgpsconnectionregistry.cpp index 119a22c12f8..bf4bbbe5ce3 100644 --- a/src/core/gps/qgsgpsconnectionregistry.cpp +++ b/src/core/gps/qgsgpsconnectionregistry.cpp @@ -27,12 +27,6 @@ QgsGPSConnectionRegistry::~QgsGPSConnectionRegistry() qDeleteAll( mConnections ); } -QgsGPSConnectionRegistry* QgsGPSConnectionRegistry::instance() -{ - static QgsGPSConnectionRegistry mInstance; - return &mInstance; -} - void QgsGPSConnectionRegistry::registerConnection( QgsGPSConnection* c ) { mConnections.insert( c ); diff --git a/src/core/gps/qgsgpsconnectionregistry.h b/src/core/gps/qgsgpsconnectionregistry.h index c9abd7e3369..2ec1150c362 100644 --- a/src/core/gps/qgsgpsconnectionregistry.h +++ b/src/core/gps/qgsgpsconnectionregistry.h @@ -21,17 +21,28 @@ #include #include +#include "qgis_core.h" + class QgsGPSConnection; /** \ingroup core - * A singleton class to register / unregister existing GPS connections such that the information - is available to all classes and plugins*/ + * A class to register / unregister existing GPS connections such that the information + * is available to all classes and plugins. + * + * QgsGPSConnectionRegistry is not usually directly created, but rather accessed through + * QgsApplication::gpsConnectionRegistry(). +*/ class CORE_EXPORT QgsGPSConnectionRegistry { public: - static QgsGPSConnectionRegistry* instance(); + QgsGPSConnectionRegistry(); ~QgsGPSConnectionRegistry(); + //! QgsGPSConnectionRegistry cannot be copied. + QgsGPSConnectionRegistry( const QgsGPSConnectionRegistry& rh ) = delete; + //! QgsGPSConnectionRegistry cannot be copied. + QgsGPSConnectionRegistry& operator=( const QgsGPSConnectionRegistry& rh ) = delete; + //! Inserts a connection into the registry. The connection is owned by the registry class until it is unregistered again void registerConnection( QgsGPSConnection* c ); //! Unregisters connection. The registry does no longer own the connection @@ -39,17 +50,9 @@ class CORE_EXPORT QgsGPSConnectionRegistry QList< QgsGPSConnection *> connectionList() const; - protected: - QgsGPSConnectionRegistry(); - - static QgsGPSConnectionRegistry* mInstance; - - QSet mConnections; - private: - QgsGPSConnectionRegistry( const QgsGPSConnectionRegistry& rh ); - QgsGPSConnectionRegistry& operator=( const QgsGPSConnectionRegistry& rh ); + QSet mConnections; }; #endif // QGSGPSCONNECTIONREGISTRY_H diff --git a/src/core/gps/qgsgpsdconnection.h b/src/core/gps/qgsgpsdconnection.h index 6727920931a..e2fb6be05fc 100644 --- a/src/core/gps/qgsgpsdconnection.h +++ b/src/core/gps/qgsgpsdconnection.h @@ -18,6 +18,7 @@ #ifndef QGSGPSDCONNECTION_H #define QGSGPSDCONNECTION_H +#include "qgis_core.h" #include "qgsnmeaconnection.h" #include diff --git a/src/core/gps/qgsgpsdetector.h b/src/core/gps/qgsgpsdetector.h index 8e95d152310..71868dad317 100644 --- a/src/core/gps/qgsgpsdetector.h +++ b/src/core/gps/qgsgpsdetector.h @@ -22,6 +22,7 @@ #include #include +#include "qgis_core.h" #include "qextserialport.h" class QgsGPSConnection; diff --git a/src/core/gps/qgsnmeaconnection.h b/src/core/gps/qgsnmeaconnection.h index 5fdbef80489..ddb742fab47 100644 --- a/src/core/gps/qgsnmeaconnection.h +++ b/src/core/gps/qgsnmeaconnection.h @@ -18,6 +18,7 @@ #ifndef QGSNMEACONNECTION_H #define QGSNMEACONNECTION_H +#include "qgis_core.h" #include "qgsgpsconnection.h" /** \ingroup core diff --git a/src/core/gps/qgsqtlocationconnection.h b/src/core/gps/qgsqtlocationconnection.h index 13855fbf913..8e43c69be90 100644 --- a/src/core/gps/qgsqtlocationconnection.h +++ b/src/core/gps/qgsqtlocationconnection.h @@ -18,6 +18,7 @@ #ifndef QGSQTLOCATIONCONNECTION_H #define QGSQTLOCATIONCONNECTION_H +#include "qgis_core.h" #include "qgsgpsconnection.h" #include diff --git a/src/core/layertree/qgslayertreegroup.cpp b/src/core/layertree/qgslayertreegroup.cpp index 37e39f6794b..769f50f6c1e 100644 --- a/src/core/layertree/qgslayertreegroup.cpp +++ b/src/core/layertree/qgslayertreegroup.cpp @@ -24,26 +24,24 @@ #include -QgsLayerTreeGroup::QgsLayerTreeGroup( const QString& name, Qt::CheckState checked ) - : QgsLayerTreeNode( NodeGroup ) +QgsLayerTreeGroup::QgsLayerTreeGroup( const QString& name, bool checked ) + : QgsLayerTreeNode( NodeGroup, checked ) , mName( name ) - , mChecked( checked ) , mChangingChildVisibility( false ) , mMutuallyExclusive( false ) , mMutuallyExclusiveChildIndex( -1 ) { - connect( this, SIGNAL( visibilityChanged( QgsLayerTreeNode*, Qt::CheckState ) ), this, SLOT( nodeVisibilityChanged( QgsLayerTreeNode* ) ) ); + connect( this, &QgsLayerTreeNode::visibilityChanged, this, &QgsLayerTreeGroup::nodeVisibilityChanged ); } QgsLayerTreeGroup::QgsLayerTreeGroup( const QgsLayerTreeGroup& other ) : QgsLayerTreeNode( other ) , mName( other.mName ) - , mChecked( other.mChecked ) , mChangingChildVisibility( other.mChangingChildVisibility ) , mMutuallyExclusive( other.mMutuallyExclusive ) , mMutuallyExclusiveChildIndex( other.mMutuallyExclusiveChildIndex ) { - connect( this, SIGNAL( visibilityChanged( QgsLayerTreeNode*, Qt::CheckState ) ), this, SLOT( nodeVisibilityChanged( QgsLayerTreeNode* ) ) ); + connect( this, &QgsLayerTreeNode::visibilityChanged, this, &QgsLayerTreeGroup::nodeVisibilityChanged ); } QString QgsLayerTreeGroup::name() const @@ -118,7 +116,7 @@ void QgsLayerTreeGroup::insertChildNodes( int index, const QListdump().split( '\n' ); @@ -335,54 +329,9 @@ QgsLayerTreeGroup* QgsLayerTreeGroup::clone() const return new QgsLayerTreeGroup( *this ); } -void QgsLayerTreeGroup::setVisible( Qt::CheckState state ) -{ - if ( mChecked == state ) - return; - - mChecked = state; - emit visibilityChanged( this, state ); - - if ( mMutuallyExclusive ) - { - if ( mMutuallyExclusiveChildIndex < 0 || mMutuallyExclusiveChildIndex >= mChildren.count() ) - mMutuallyExclusiveChildIndex = 0; // just choose the first one if we have lost the active one - updateChildVisibilityMutuallyExclusive(); - } - else if ( mChecked == Qt::Unchecked || mChecked == Qt::Checked ) - { - updateChildVisibility(); - } -} - -void QgsLayerTreeGroup::updateChildVisibility() -{ - mChangingChildVisibility = true; // guard against running again setVisible() triggered from children - - // update children to have the correct visibility - Q_FOREACH ( QgsLayerTreeNode* child, mChildren ) - { - if ( QgsLayerTree::isGroup( child ) ) - QgsLayerTree::toGroup( child )->setVisible( mChecked ); - else if ( QgsLayerTree::isLayer( child ) ) - QgsLayerTree::toLayer( child )->setVisible( mChecked ); - } - - mChangingChildVisibility = false; -} - - static bool _nodeIsChecked( QgsLayerTreeNode* node ) { - Qt::CheckState state; - if ( QgsLayerTree::isGroup( node ) ) - state = QgsLayerTree::toGroup( node )->isVisible(); - else if ( QgsLayerTree::isLayer( node ) ) - state = QgsLayerTree::toLayer( node )->isVisible(); - else - return false; - - return state == Qt::Checked || state == Qt::PartiallyChecked; + return node->itemVisibilityChecked(); } @@ -398,7 +347,6 @@ void QgsLayerTreeGroup::setIsMutuallyExclusive( bool enabled, int initialChildIn if ( !enabled ) { - updateVisibilityFromChildren(); return; } @@ -433,14 +381,6 @@ QStringList QgsLayerTreeGroup::findLayerIds() const return lst; } - -void QgsLayerTreeGroup::layerDestroyed() -{ - //QgsMapLayer* layer = static_cast( sender() ); - //removeLayer( layer ); -} - - void QgsLayerTreeGroup::nodeVisibilityChanged( QgsLayerTreeNode* node ) { int childIndex = mChildren.indexOf( node ); @@ -451,69 +391,12 @@ void QgsLayerTreeGroup::nodeVisibilityChanged( QgsLayerTreeNode* node ) { if ( _nodeIsChecked( node ) ) mMutuallyExclusiveChildIndex = childIndex; + else if ( mMutuallyExclusiveChildIndex == childIndex ) + mMutuallyExclusiveChildIndex = -1; - // we need to update this node's check status in two cases: - // 1. it was unchecked and a child node got checked - // 2. it was checked and the only checked child got unchecked - updateVisibilityFromChildren(); - - // we also need to make sure there is only one child node checked + // we need to make sure there is only one child node checked updateChildVisibilityMutuallyExclusive(); } - else - { - updateVisibilityFromChildren(); - } -} - -void QgsLayerTreeGroup::updateVisibilityFromChildren() -{ - if ( mChangingChildVisibility ) - return; - - if ( mChildren.isEmpty() ) - return; - - if ( mMutuallyExclusive ) - { - // if in mutually exclusive mode, our check state depends only on the check state of the chosen child index - - if ( mMutuallyExclusiveChildIndex < 0 || mMutuallyExclusiveChildIndex >= mChildren.count() ) - return; - - Qt::CheckState meChildState = _nodeIsChecked( mChildren.at( mMutuallyExclusiveChildIndex ) ) ? Qt::Checked : Qt::Unchecked; - - setVisible( meChildState ); - return; - } - - bool hasVisible = false, hasHidden = false; - - Q_FOREACH ( QgsLayerTreeNode* child, mChildren ) - { - if ( QgsLayerTree::isLayer( child ) ) - { - bool layerVisible = QgsLayerTree::toLayer( child )->isVisible() == Qt::Checked; - if ( layerVisible ) hasVisible = true; - if ( !layerVisible ) hasHidden = true; - } - else if ( QgsLayerTree::isGroup( child ) ) - { - Qt::CheckState state = QgsLayerTree::toGroup( child )->isVisible(); - if ( state == Qt::Checked || state == Qt::PartiallyChecked ) hasVisible = true; - if ( state == Qt::Unchecked || state == Qt::PartiallyChecked ) hasHidden = true; - } - } - - Qt::CheckState newState; - if ( hasVisible && !hasHidden ) - newState = Qt::Checked; - else if ( hasHidden && !hasVisible ) - newState = Qt::Unchecked; - else - newState = Qt::PartiallyChecked; - - setVisible( newState ); } void QgsLayerTreeGroup::updateChildVisibilityMutuallyExclusive() @@ -526,11 +409,23 @@ void QgsLayerTreeGroup::updateChildVisibilityMutuallyExclusive() int index = 0; Q_FOREACH ( QgsLayerTreeNode* child, mChildren ) { - Qt::CheckState checked = ( index == mMutuallyExclusiveChildIndex ? mChecked : Qt::Unchecked ); - if ( QgsLayerTree::isGroup( child ) ) - QgsLayerTree::toGroup( child )->setVisible( checked ); - else if ( QgsLayerTree::isLayer( child ) ) - QgsLayerTree::toLayer( child )->setVisible( checked ); + child->setItemVisibilityChecked( index == mMutuallyExclusiveChildIndex ); + ++index; + } + + mChangingChildVisibility = false; +} + +void QgsLayerTreeGroup::setItemVisibilityCheckedRecursive( bool checked ) +{ + QgsLayerTreeNode::setItemVisibilityChecked( checked ); + + mChangingChildVisibility = true; // guard against running again setVisible() triggered from children + + int index = 0; + Q_FOREACH ( QgsLayerTreeNode* child, mChildren ) + { + child->setItemVisibilityCheckedRecursive( checked && ( mMutuallyExclusiveChildIndex < 0 || index == mMutuallyExclusiveChildIndex ) ); ++index; } diff --git a/src/core/layertree/qgslayertreegroup.h b/src/core/layertree/qgslayertreegroup.h index 20faad9c8f0..410581afb21 100644 --- a/src/core/layertree/qgslayertreegroup.h +++ b/src/core/layertree/qgslayertreegroup.h @@ -16,6 +16,7 @@ #ifndef QGSLAYERTREEGROUP_H #define QGSLAYERTREEGROUP_H +#include "qgis_core.h" #include "qgslayertreenode.h" class QgsMapLayer; @@ -32,7 +33,8 @@ class CORE_EXPORT QgsLayerTreeGroup : public QgsLayerTreeNode { Q_OBJECT public: - QgsLayerTreeGroup( const QString& name = QString(), Qt::CheckState checked = Qt::Checked ); + //! Constructor + QgsLayerTreeGroup( const QString& name = QString(), bool checked = true ); QgsLayerTreeGroup( const QgsLayerTreeGroup& other ); //! Get group's name @@ -92,10 +94,8 @@ class CORE_EXPORT QgsLayerTreeGroup : public QgsLayerTreeNode //! Return a clone of the group. The children are cloned too. virtual QgsLayerTreeGroup* clone() const override; - //! Return the check state of the group node - Qt::CheckState isVisible() const { return mChecked; } - //! Set check state of the group node - will also update children - void setVisible( Qt::CheckState state ); + //! Check or uncheck a node and all its children (taking into account exclusion rules) + virtual void setItemVisibilityCheckedRecursive( bool checked ) override; //! Return whether the group is mutually exclusive (only one child can be checked at a time) //! @note added in 2.12 @@ -107,20 +107,15 @@ class CORE_EXPORT QgsLayerTreeGroup : public QgsLayerTreeNode void setIsMutuallyExclusive( bool enabled, int initialChildIndex = -1 ); protected slots: - void layerDestroyed(); void nodeVisibilityChanged( QgsLayerTreeNode* node ); protected: - //! Set check state of this group from its children - void updateVisibilityFromChildren(); - //! Set check state of children (when this group's check state changes) - if not mutually exclusive - void updateChildVisibility(); + //! Set check state of children - if mutually exclusive void updateChildVisibilityMutuallyExclusive(); protected: QString mName; - Qt::CheckState mChecked; bool mChangingChildVisibility; diff --git a/src/core/layertree/qgslayertreelayer.cpp b/src/core/layertree/qgslayertreelayer.cpp index 3c848e90b8e..bd3a24c8e8b 100644 --- a/src/core/layertree/qgslayertreelayer.cpp +++ b/src/core/layertree/qgslayertreelayer.cpp @@ -21,21 +21,19 @@ QgsLayerTreeLayer::QgsLayerTreeLayer( QgsMapLayer *layer ) - : QgsLayerTreeNode( NodeLayer ) + : QgsLayerTreeNode( NodeLayer, true ) , mLayerId( layer->id() ) , mLayer( nullptr ) - , mVisible( Qt::Checked ) { Q_ASSERT( QgsProject::instance()->mapLayer( mLayerId ) == layer ); attachToLayer(); } QgsLayerTreeLayer::QgsLayerTreeLayer( const QString& layerId, const QString& name ) - : QgsLayerTreeNode( NodeLayer ) + : QgsLayerTreeNode( NodeLayer, true ) , mLayerId( layerId ) , mLayerName( name ) , mLayer( nullptr ) - , mVisible( Qt::Checked ) { attachToLayer(); } @@ -45,7 +43,6 @@ QgsLayerTreeLayer::QgsLayerTreeLayer( const QgsLayerTreeLayer& other ) , mLayerId( other.mLayerId ) , mLayerName( other.mLayerName ) , mLayer( nullptr ) - , mVisible( other.mVisible ) { attachToLayer(); } @@ -94,15 +91,6 @@ void QgsLayerTreeLayer::setName( const QString& n ) } } -void QgsLayerTreeLayer::setVisible( Qt::CheckState state ) -{ - if ( mVisible == state ) - return; - - mVisible = state; - emit visibilityChanged( this, state ); -} - QgsLayerTreeLayer* QgsLayerTreeLayer::readXml( QDomElement& element ) { if ( element.tagName() != QLatin1String( "layer-tree-layer" ) ) @@ -124,7 +112,7 @@ QgsLayerTreeLayer* QgsLayerTreeLayer::readXml( QDomElement& element ) nodeLayer->readCommonXml( element ); - nodeLayer->setVisible( checked ); + nodeLayer->setItemVisibilityChecked( checked != Qt::Unchecked ); nodeLayer->setExpanded( isExpanded ); return nodeLayer; } @@ -135,7 +123,7 @@ void QgsLayerTreeLayer::writeXml( QDomElement& parentElement ) QDomElement elem = doc.createElement( QStringLiteral( "layer-tree-layer" ) ); elem.setAttribute( QStringLiteral( "id" ), mLayerId ); elem.setAttribute( QStringLiteral( "name" ), name() ); - elem.setAttribute( QStringLiteral( "checked" ), QgsLayerTreeUtils::checkStateToXml( mVisible ) ); + elem.setAttribute( QStringLiteral( "checked" ), mChecked ? QStringLiteral( "Qt::Checked" ) : QStringLiteral( "Qt::Unchecked" ) ); elem.setAttribute( QStringLiteral( "expanded" ), mExpanded ? "1" : "0" ); writeCommonXml( elem ); @@ -145,7 +133,7 @@ void QgsLayerTreeLayer::writeXml( QDomElement& parentElement ) QString QgsLayerTreeLayer::dump() const { - return QStringLiteral( "LAYER: %1 visible=%2 expanded=%3 id=%4\n" ).arg( name() ).arg( mVisible ).arg( mExpanded ).arg( layerId() ); + return QStringLiteral( "LAYER: %1 checked=%2 expanded=%3 id=%4\n" ).arg( name() ).arg( mChecked ).arg( mExpanded ).arg( layerId() ); } QgsLayerTreeLayer* QgsLayerTreeLayer::clone() const diff --git a/src/core/layertree/qgslayertreelayer.h b/src/core/layertree/qgslayertreelayer.h index cf06c32bf4d..c9acf8f0e1e 100644 --- a/src/core/layertree/qgslayertreelayer.h +++ b/src/core/layertree/qgslayertreelayer.h @@ -16,6 +16,7 @@ #ifndef QGSLAYERTREELAYER_H #define QGSLAYERTREELAYER_H +#include "qgis_core.h" #include "qgslayertreenode.h" class QgsMapLayer; @@ -58,9 +59,6 @@ class CORE_EXPORT QgsLayerTreeLayer : public QgsLayerTreeNode //! @note added in 3.0 void setName( const QString& n ) override; - Qt::CheckState isVisible() const { return mVisible; } - void setVisible( Qt::CheckState visible ); - static QgsLayerTreeLayer* readXml( QDomElement& element ); virtual void writeXml( QDomElement& parentElement ) override; @@ -88,7 +86,6 @@ class CORE_EXPORT QgsLayerTreeLayer : public QgsLayerTreeNode QString mLayerId; QString mLayerName; // only used if layer does not exist QgsMapLayer* mLayer; // not owned! may be null - Qt::CheckState mVisible; }; diff --git a/src/core/layertree/qgslayertreemodel.cpp b/src/core/layertree/qgslayertreemodel.cpp index 8ee7a7a40ca..c4faea10573 100644 --- a/src/core/layertree/qgslayertreemodel.cpp +++ b/src/core/layertree/qgslayertreemodel.cpp @@ -284,12 +284,12 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const if ( qobject_cast( nodeLayer->layer() )->geometryType() == QgsWkbTypes::NullGeometry ) return QVariant(); // do not show checkbox for non-spatial tables } - return nodeLayer->isVisible(); + return nodeLayer->itemVisibilityChecked() ? Qt::Checked : Qt::Unchecked; } else if ( QgsLayerTree::isGroup( node ) ) { QgsLayerTreeGroup* nodeGroup = QgsLayerTree::toGroup( node ); - return nodeGroup->isVisible(); + return nodeGroup->itemVisibilityChecked() ? Qt::Checked : Qt::Unchecked; } } else if ( role == Qt::FontRole ) @@ -307,7 +307,7 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const if ( QgsLayerTree::isLayer( node ) ) { const QgsMapLayer* layer = QgsLayerTree::toLayer( node )->layer(); - if ( layer && !layer->isInScaleRange( mLegendMapViewScale ) ) + if ( !node->isVisible() || ( layer && !layer->isInScaleRange( mLegendMapViewScale ) ) ) { brush.setColor( Qt::lightGray ); } @@ -393,19 +393,24 @@ bool QgsLayerTreeModel::setData( const QModelIndex& index, const QVariant& value if ( !testFlag( AllowNodeChangeVisibility ) ) return false; - if ( QgsLayerTree::isLayer( node ) ) + bool checked = static_cast< Qt::CheckState >( value.toInt() ) == Qt::Checked; + if ( checked && node->children().isEmpty() ) { - QgsLayerTreeLayer* layer = QgsLayerTree::toLayer( node ); - layer->setVisible( static_cast< Qt::CheckState >( value.toInt() ) ); - return true; + node->setItemVisibilityCheckedParentRecursive( checked ); + } + else if ( testFlag( ActionHierarchical ) ) + { + if ( node->children().isEmpty() ) + node->setItemVisibilityCheckedParentRecursive( checked ); + else + node->setItemVisibilityCheckedRecursive( checked ); + } + else + { + node->setItemVisibilityChecked( checked ); } - if ( QgsLayerTree::isGroup( node ) ) - { - QgsLayerTreeGroup* group = QgsLayerTree::toGroup( node ); - group->setVisible( static_cast< Qt::CheckState >( value.toInt() ) ); - return true; - } + recursivelyEmitDataChanged( index ); return true; } @@ -934,7 +939,7 @@ void QgsLayerTreeModel::connectToRootNode() connect( mRootNode, SIGNAL( addedChildren( QgsLayerTreeNode*, int, int ) ), this, SLOT( nodeAddedChildren( QgsLayerTreeNode*, int, int ) ) ); connect( mRootNode, SIGNAL( willRemoveChildren( QgsLayerTreeNode*, int, int ) ), this, SLOT( nodeWillRemoveChildren( QgsLayerTreeNode*, int, int ) ) ); connect( mRootNode, SIGNAL( removedChildren( QgsLayerTreeNode*, int, int ) ), this, SLOT( nodeRemovedChildren() ) ); - connect( mRootNode, SIGNAL( visibilityChanged( QgsLayerTreeNode*, Qt::CheckState ) ), this, SLOT( nodeVisibilityChanged( QgsLayerTreeNode* ) ) ); + connect( mRootNode, &QgsLayerTreeNode::visibilityChanged, this, &QgsLayerTreeModel::nodeVisibilityChanged ); connect( mRootNode, SIGNAL( nameChanged( QgsLayerTreeNode*, QString ) ), this, SLOT( nodeNameChanged( QgsLayerTreeNode*, QString ) ) ); connect( mRootNode, SIGNAL( customPropertyChanged( QgsLayerTreeNode*, QString ) ), this, SLOT( nodeCustomPropertyChanged( QgsLayerTreeNode*, QString ) ) ); diff --git a/src/core/layertree/qgslayertreemodel.h b/src/core/layertree/qgslayertreemodel.h index 330f7d4f8a2..ad6ada9bf3b 100644 --- a/src/core/layertree/qgslayertreemodel.h +++ b/src/core/layertree/qgslayertreemodel.h @@ -16,6 +16,7 @@ #ifndef QGSLAYERTREEMODEL_H #define QGSLAYERTREEMODEL_H +#include "qgis_core.h" #include #include #include @@ -87,6 +88,7 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel AllowNodeRename = 0x2000, //!< Allow renaming of groups and layers AllowNodeChangeVisibility = 0x4000, //!< Allow user to set node visibility with a check box AllowLegendChangeState = 0x8000, //!< Allow check boxes for legend nodes (if supported by layer's legend) + ActionHierarchical = 0x10000, //!< Check/uncheck action has consequences on children (or parents for leaf node) }; Q_DECLARE_FLAGS( Flags, Flag ) diff --git a/src/core/layertree/qgslayertreemodellegendnode.cpp b/src/core/layertree/qgslayertreemodellegendnode.cpp index 68ebfba105d..b1b52a60e60 100644 --- a/src/core/layertree/qgslayertreemodellegendnode.cpp +++ b/src/core/layertree/qgslayertreemodellegendnode.cpp @@ -35,10 +35,6 @@ QgsLayerTreeModelLegendNode::QgsLayerTreeModelLegendNode( QgsLayerTreeLayer* nod { } -QgsLayerTreeModelLegendNode::~QgsLayerTreeModelLegendNode() -{ -} - QgsLayerTreeModel* QgsLayerTreeModelLegendNode::model() const { return qobject_cast( parent() ); @@ -144,10 +140,6 @@ QgsSymbolLegendNode::QgsSymbolLegendNode( QgsLayerTreeLayer* nodeLayer, const Qg mSymbolUsesMapUnits = ( mItem.symbol()->outputUnit() != QgsUnitTypes::RenderMillimeters ); } -QgsSymbolLegendNode::~QgsSymbolLegendNode() -{ -} - Qt::ItemFlags QgsSymbolLegendNode::flags() const { if ( mItem.isCheckable() ) diff --git a/src/core/layertree/qgslayertreemodellegendnode.h b/src/core/layertree/qgslayertreemodellegendnode.h index c7053a1303f..3827e0bac87 100644 --- a/src/core/layertree/qgslayertreemodellegendnode.h +++ b/src/core/layertree/qgslayertreemodellegendnode.h @@ -19,6 +19,7 @@ #ifndef QGSLAYERTREEMODELLEGENDNODE_H #define QGSLAYERTREEMODELLEGENDNODE_H +#include "qgis_core.h" #include #include @@ -44,7 +45,6 @@ class CORE_EXPORT QgsLayerTreeModelLegendNode : public QObject { Q_OBJECT public: - ~QgsLayerTreeModelLegendNode(); enum LegendNodeRoles { @@ -148,7 +148,6 @@ class CORE_EXPORT QgsSymbolLegendNode : public QgsLayerTreeModelLegendNode public: QgsSymbolLegendNode( QgsLayerTreeLayer* nodeLayer, const QgsLegendSymbolItem& item, QObject* parent = nullptr ); - ~QgsSymbolLegendNode(); virtual Qt::ItemFlags flags() const override; virtual QVariant data( int role ) const override; diff --git a/src/core/layertree/qgslayertreenode.cpp b/src/core/layertree/qgslayertreenode.cpp index f1ef54fb46d..0784aa99811 100644 --- a/src/core/layertree/qgslayertreenode.cpp +++ b/src/core/layertree/qgslayertreenode.cpp @@ -22,8 +22,9 @@ #include -QgsLayerTreeNode::QgsLayerTreeNode( QgsLayerTreeNode::NodeType t ) +QgsLayerTreeNode::QgsLayerTreeNode( QgsLayerTreeNode::NodeType t, bool checked ) : mNodeType( t ) + , mChecked( checked ) , mParent( nullptr ) , mExpanded( true ) { @@ -32,6 +33,7 @@ QgsLayerTreeNode::QgsLayerTreeNode( QgsLayerTreeNode::NodeType t ) QgsLayerTreeNode::QgsLayerTreeNode( const QgsLayerTreeNode& other ) : QObject() , mNodeType( other.mNodeType ) + , mChecked( other.mChecked ) , mParent( nullptr ) , mExpanded( other.mExpanded ) , mProperties( other.mProperties ) @@ -59,11 +61,62 @@ QgsLayerTreeNode* QgsLayerTreeNode::readXml( QDomElement& element ) } +void QgsLayerTreeNode::setItemVisibilityChecked( bool checked ) +{ + if ( mChecked == checked ) + return; + mChecked = checked; + emit visibilityChanged( this ); +} + +void QgsLayerTreeNode::setItemVisibilityCheckedRecursive( bool checked ) +{ + setItemVisibilityChecked( checked ); +} + +void QgsLayerTreeNode::setItemVisibilityCheckedParentRecursive( bool checked ) +{ + setItemVisibilityChecked( checked ); + if ( mParent ) + mParent->setItemVisibilityCheckedParentRecursive( checked ); +} + +bool QgsLayerTreeNode::isVisible() const +{ + return mChecked && ( !mParent || mParent->isVisible() ); +} + + bool QgsLayerTreeNode::isExpanded() const { return mExpanded; } +bool QgsLayerTreeNode::isItemVisibilityCheckedRecursive() const +{ + if ( !mChecked ) + return false; + Q_FOREACH ( QgsLayerTreeNode* child, mChildren ) + { + if ( !child->isItemVisibilityCheckedRecursive() ) + return false; + } + + return true; +} + +bool QgsLayerTreeNode::isItemVisibilityUncheckedRecursive() const +{ + if ( mChecked ) + return false; + Q_FOREACH ( QgsLayerTreeNode* child, mChildren ) + { + if ( !child->isItemVisibilityUncheckedRecursive() ) + return false; + } + + return true; +} void QgsLayerTreeNode::setExpanded( bool expanded ) { @@ -134,7 +187,7 @@ void QgsLayerTreeNode::insertChildrenPrivate( int index, QList #include "qgsobjectcustomproperties.h" @@ -82,6 +83,8 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject QgsLayerTreeNode *parent() { return mParent; } //! Get list of children of the node. Children are owned by the parent QList children() { return mChildren; } + //! Get list of children of the node. Children are owned by the parent + const QList& children() const { return mChildren; } //! Return name of the node //! @note added in 3.0 @@ -101,6 +104,34 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject //! Create a copy of the node. Returns new instance virtual QgsLayerTreeNode *clone() const = 0; + //! Returns whether a node is really visible (ie checked and all its ancestors checked as well) + //! @note added in 3.0 + bool isVisible() const; + + //! Returns whether a node is checked (independantly of its ancestors or children) + //! @note added in 3.0 + bool itemVisibilityChecked() const { return mChecked; } + + //! Check or uncheck a node (independantly of its ancestors or children) + //! @note added in 3.0 + void setItemVisibilityChecked( bool checked ); + + //! Check or uncheck a node and all its children (taking into account exclusion rules) + //! @note added in 3.0 + virtual void setItemVisibilityCheckedRecursive( bool checked ); + + //! Check or uncheck a node and all its parents + //! @note added in 3.0 + void setItemVisibilityCheckedParentRecursive( bool checked ); + + //! Return whether this node is checked and all its children. + //! @note added in 3.0 + bool isItemVisibilityCheckedRecursive() const; + + //! Return whether this node is unchecked and all its children. + //! @note added in 3.0 + bool isItemVisibilityUncheckedRecursive() const; + //! Return whether the node should be shown as expanded or collapsed in GUI bool isExpanded() const; //! Set whether the node should be shown as expanded or collapsed in GUI @@ -128,7 +159,7 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject //! Emitted when one or more nodes has been removed from a node within the tree void removedChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo ); //! Emitted when check state of a node within the tree has been changed - void visibilityChanged( QgsLayerTreeNode *node, Qt::CheckState state ); + void visibilityChanged( QgsLayerTreeNode *node ); //! Emitted when a custom property of a node within the tree has been changed or removed void customPropertyChanged( QgsLayerTreeNode *node, const QString& key ); //! Emitted when the collapsed/expanded state of a node within the tree has been changed @@ -139,12 +170,15 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject protected: - QgsLayerTreeNode( NodeType t ); + //! Constructor + QgsLayerTreeNode( NodeType t, bool checked = true ); QgsLayerTreeNode( const QgsLayerTreeNode &other ); // low-level utility functions + //! Read common XML elements. void readCommonXml( QDomElement &element ); + //! Write common XML elements. void writeCommonXml( QDomElement &element ); //! Low-level insertion of children to the node. The children must not have any parent yet! @@ -155,6 +189,7 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject protected: //! type of the node - determines which subclass is used NodeType mNodeType; + bool mChecked; //! pointer to the parent node - null in case of root node QgsLayerTreeNode *mParent; //! list of children - node is responsible for their deletion diff --git a/src/core/layertree/qgslayertreeregistrybridge.cpp b/src/core/layertree/qgslayertreeregistrybridge.cpp index 19eca855e63..45f62064bc8 100644 --- a/src/core/layertree/qgslayertreeregistrybridge.cpp +++ b/src/core/layertree/qgslayertreeregistrybridge.cpp @@ -52,7 +52,7 @@ void QgsLayerTreeRegistryBridge::layersAdded( const QList& layers Q_FOREACH ( QgsMapLayer* layer, layers ) { QgsLayerTreeLayer* nodeLayer = new QgsLayerTreeLayer( layer ); - nodeLayer->setVisible( mNewLayersVisible ? Qt::Checked : Qt::Unchecked ); + nodeLayer->setItemVisibilityChecked( mNewLayersVisible ); nodes << nodeLayer; diff --git a/src/core/layertree/qgslayertreeregistrybridge.h b/src/core/layertree/qgslayertreeregistrybridge.h index 29a134a235b..e2d39a93719 100644 --- a/src/core/layertree/qgslayertreeregistrybridge.h +++ b/src/core/layertree/qgslayertreeregistrybridge.h @@ -19,6 +19,8 @@ #include #include +#include "qgis_core.h" + class QgsLayerTreeGroup; class QgsLayerTreeNode; class QgsMapLayer; diff --git a/src/core/layertree/qgslayertreeutils.cpp b/src/core/layertree/qgslayertreeutils.cpp index 78319e46625..3039aad6891 100644 --- a/src/core/layertree/qgslayertreeutils.cpp +++ b/src/core/layertree/qgslayertreeutils.cpp @@ -112,7 +112,7 @@ static QDomElement _writeOldLegendLayer( QDomDocument& doc, QgsLayerTreeLayer* n QDomElement layerElem = doc.createElement( QStringLiteral( "legendlayer" ) ); layerElem.setAttribute( QStringLiteral( "drawingOrder" ), drawingOrder ); layerElem.setAttribute( QStringLiteral( "open" ), nodeLayer->isExpanded() ? "true" : "false" ); - layerElem.setAttribute( QStringLiteral( "checked" ), QgsLayerTreeUtils::checkStateToXml( nodeLayer->isVisible() ) ); + layerElem.setAttribute( QStringLiteral( "checked" ), QgsLayerTreeUtils::checkStateToXml( nodeLayer->itemVisibilityChecked() ? Qt::Checked : Qt::Unchecked ) ); layerElem.setAttribute( QStringLiteral( "name" ), nodeLayer->name() ); layerElem.setAttribute( QStringLiteral( "showFeatureCount" ), nodeLayer->customProperty( QStringLiteral( "showFeatureCount" ) ).toInt() ); @@ -123,7 +123,7 @@ static QDomElement _writeOldLegendLayer( QDomDocument& doc, QgsLayerTreeLayer* n QDomElement layerFileElem = doc.createElement( QStringLiteral( "legendlayerfile" ) ); layerFileElem.setAttribute( QStringLiteral( "isInOverview" ), nodeLayer->customProperty( QStringLiteral( "overview" ) ).toInt() ); layerFileElem.setAttribute( QStringLiteral( "layerid" ), nodeLayer->layerId() ); - layerFileElem.setAttribute( QStringLiteral( "visible" ), nodeLayer->isVisible() == Qt::Checked ? 1 : 0 ); + layerFileElem.setAttribute( QStringLiteral( "visible" ), nodeLayer->isVisible() ? 1 : 0 ); layerElem.appendChild( fileGroupElem ); fileGroupElem.appendChild( layerFileElem ); @@ -138,7 +138,7 @@ static QDomElement _writeOldLegendGroup( QDomDocument& doc, QgsLayerTreeGroup* n QDomElement groupElem = doc.createElement( QStringLiteral( "legendgroup" ) ); groupElem.setAttribute( QStringLiteral( "open" ), nodeGroup->isExpanded() ? "true" : "false" ); groupElem.setAttribute( QStringLiteral( "name" ), nodeGroup->name() ); - groupElem.setAttribute( QStringLiteral( "checked" ), QgsLayerTreeUtils::checkStateToXml( nodeGroup->isVisible() ) ); + groupElem.setAttribute( QStringLiteral( "checked" ), QgsLayerTreeUtils::checkStateToXml( nodeGroup->itemVisibilityChecked() ? Qt::Checked : Qt::Unchecked ) ); if ( nodeGroup->customProperty( QStringLiteral( "embedded" ) ).toInt() ) { @@ -210,7 +210,7 @@ static void _readOldLegendGroup( const QDomElement& groupElem, QgsLayerTreeGroup QgsLayerTreeGroup* groupNode = new QgsLayerTreeGroup( groupElem.attribute( QStringLiteral( "name" ) ) ); - groupNode->setVisible( QgsLayerTreeUtils::checkStateFromXml( groupElem.attribute( QStringLiteral( "checked" ) ) ) ); + groupNode->setItemVisibilityChecked( QgsLayerTreeUtils::checkStateFromXml( groupElem.attribute( QStringLiteral( "checked" ) ) ) != Qt::Unchecked ); groupNode->setExpanded( groupElem.attribute( QStringLiteral( "open" ) ) == QLatin1String( "true" ) ); if ( groupElem.attribute( QStringLiteral( "embedded" ) ) == QLatin1String( "1" ) ) @@ -241,7 +241,7 @@ static void _readOldLegendLayer( const QDomElement& layerElem, QgsLayerTreeGroup QString layerId = layerFileElem.attribute( QStringLiteral( "layerid" ) ); QgsLayerTreeLayer* layerNode = new QgsLayerTreeLayer( layerId, layerElem.attribute( QStringLiteral( "name" ) ) ); - layerNode->setVisible( QgsLayerTreeUtils::checkStateFromXml( layerElem.attribute( QStringLiteral( "checked" ) ) ) ); + layerNode->setItemVisibilityChecked( QgsLayerTreeUtils::checkStateFromXml( layerElem.attribute( QStringLiteral( "checked" ) ) ) != Qt::Unchecked ); layerNode->setExpanded( layerElem.attribute( QStringLiteral( "open" ) ) == QLatin1String( "true" ) ); if ( layerFileElem.attribute( QStringLiteral( "isInOverview" ) ) == QLatin1String( "1" ) ) diff --git a/src/core/layertree/qgslayertreeutils.h b/src/core/layertree/qgslayertreeutils.h index 69a0fed40ab..6cdabf0217a 100644 --- a/src/core/layertree/qgslayertreeutils.h +++ b/src/core/layertree/qgslayertreeutils.h @@ -19,6 +19,7 @@ #include #include #include +#include "qgis_core.h" class QDomElement; class QDomDocument; diff --git a/src/core/pal/feature.cpp b/src/core/pal/feature.cpp index f8918c4134b..9b38b9df450 100644 --- a/src/core/pal/feature.cpp +++ b/src/core/pal/feature.cpp @@ -732,7 +732,7 @@ int FeaturePart::createCandidatesAlongLineNearStraightSegments( QList 0.98 ) diff --git a/src/core/pal/feature.h b/src/core/pal/feature.h index 725d2a6892b..7478f763620 100644 --- a/src/core/pal/feature.h +++ b/src/core/pal/feature.h @@ -30,6 +30,7 @@ #ifndef FEATURE_H #define FEATURE_H +#include "qgis_core.h" #include "pointset.h" #include "labelposition.h" // for LabelPosition enum #include "qgslabelfeature.h" @@ -66,15 +67,17 @@ namespace pal } ~LabelInfo() { delete [] char_info; } + //! LabelInfo cannot be copied + LabelInfo( const LabelInfo& rh ) = delete; + //! LabelInfo cannot be copied + LabelInfo& operator=( const LabelInfo& rh ) = delete; + double max_char_angle_inside; double max_char_angle_outside; double label_height; int char_num; CharacterInfo* char_info; - private: - LabelInfo( const LabelInfo& rh ); - LabelInfo& operator=( const LabelInfo& rh ); }; class LabelPosition; @@ -143,7 +146,7 @@ namespace pal */ int createCandidatesOverPoint( double x, double y, QList &lPos, double angle ); - /** Generates candidates following a prioritised list of predefined positions around a point. + /** Generates candidates following a prioritized list of predefined positions around a point. * @param x x coordinate of the point * @param y y coordinate of the point * @param lPos pointer to an array of candidates, will be filled by generated candidate diff --git a/src/core/pal/geomfunction.h b/src/core/pal/geomfunction.h index c7028511ade..7e977102d10 100644 --- a/src/core/pal/geomfunction.h +++ b/src/core/pal/geomfunction.h @@ -30,6 +30,7 @@ #ifndef PAL_GEOM_FUNCTION #define PAL_GEOM_FUNCTION +#include "qgis_core.h" #include "math.h" #include "qgsgeos.h" diff --git a/src/core/pal/labelposition.cpp b/src/core/pal/labelposition.cpp index b7befb2cd30..592b957a860 100644 --- a/src/core/pal/labelposition.cpp +++ b/src/core/pal/labelposition.cpp @@ -393,9 +393,9 @@ bool LabelPosition::pruneCallback( LabelPosition *candidatePosition, void *ctx ) FeaturePart *obstaclePart = ( reinterpret_cast< PruneCtx* >( ctx ) )->obstacle; // test whether we should ignore this obstacle for the candidate. We do this if: - // 1. it's not a hole, and the obstacle belongs to the same label feature as the candidate (eg + // 1. it's not a hole, and the obstacle belongs to the same label feature as the candidate (e.g., // features aren't obstacles for their own labels) - // 2. it IS a hole, and the hole belongs to a different label feature to the candidate (eg, holes + // 2. it IS a hole, and the hole belongs to a different label feature to the candidate (e.g., holes // are ONLY obstacles for the labels of the feature they belong to) if (( !obstaclePart->getHoleOf() && candidatePosition->feature->hasSameLabelFeatureAs( obstaclePart ) ) || ( obstaclePart->getHoleOf() && !candidatePosition->feature->hasSameLabelFeatureAs( dynamic_cast< FeaturePart* >( obstaclePart->getHoleOf() ) ) ) ) diff --git a/src/core/pal/labelposition.h b/src/core/pal/labelposition.h index bdbe7ed13b3..d6af100cc22 100644 --- a/src/core/pal/labelposition.h +++ b/src/core/pal/labelposition.h @@ -30,6 +30,7 @@ #ifndef LABELPOSITION_H #define LABELPOSITION_H +#include "qgis_core.h" #include "pointset.h" #include "rtree.hpp" #include diff --git a/src/core/pal/layer.h b/src/core/pal/layer.h index 5c979bfce02..9a10dae7469 100644 --- a/src/core/pal/layer.h +++ b/src/core/pal/layer.h @@ -30,6 +30,7 @@ #ifndef PAL_LAYER_H_ #define PAL_LAYER_H_ +#include "qgis_core.h" #include "pal.h" // for LineArrangementFlags enum #include "rtree.hpp" #include diff --git a/src/core/pal/pal.h b/src/core/pal/pal.h index ff55f949ed1..3075d85009e 100644 --- a/src/core/pal/pal.h +++ b/src/core/pal/pal.h @@ -30,6 +30,7 @@ #ifndef PAL_H #define PAL_H +#include "qgis_core.h" #include "qgsgeometry.h" #include "qgspallabeling.h" #include @@ -94,11 +95,13 @@ namespace pal */ Pal(); - /** - * \brief delete an instance - */ ~Pal(); + //! Pal cannot be copied. + Pal( const Pal& other ) = delete; + //! Pal cannot be copied. + Pal& operator=( const Pal& other ) = delete; + /** * \brief add a new layer * @@ -324,11 +327,6 @@ namespace pal */ int getMaxIt(); - private: - - Pal( const Pal& other ); - Pal& operator=( const Pal& other ); - }; } // end namespace pal diff --git a/src/core/pal/palstat.h b/src/core/pal/palstat.h index 521a02ebe68..c098a459d18 100644 --- a/src/core/pal/palstat.h +++ b/src/core/pal/palstat.h @@ -49,11 +49,12 @@ namespace pal public: - /** - * \brief delete stats - */ ~PalStat(); + //! PalStat cannot be copied + PalStat( const PalStat& other ) = delete; + //! PalStat cannot be copied + PalStat& operator=( const PalStat& other ) = delete; /** * \brief the number of object in problem @@ -96,8 +97,7 @@ namespace pal int *layersNbLabelledObjects; // [nbLayers] PalStat(); - PalStat( const PalStat& other ); - PalStat& operator=( const PalStat& other ); + }; } // end namespace pal diff --git a/src/core/pal/pointset.h b/src/core/pal/pointset.h index 19f1df6e96e..10f9bb6e444 100644 --- a/src/core/pal/pointset.h +++ b/src/core/pal/pointset.h @@ -35,6 +35,8 @@ #include #include +#include "qgis_core.h" + namespace pal { diff --git a/src/core/pal/priorityqueue.h b/src/core/pal/priorityqueue.h index f9a36abf21c..e75c5676e26 100644 --- a/src/core/pal/priorityqueue.h +++ b/src/core/pal/priorityqueue.h @@ -58,6 +58,11 @@ namespace pal PriorityQueue( int n, int maxId, bool min ); ~PriorityQueue(); + //! PriorityQueue cannot be copied. + PriorityQueue( const PriorityQueue & ) = delete; + //! PriorityQueue cannot be copied. + PriorityQueue &operator=( const PriorityQueue & ) = delete; + void print(); int getSize(); @@ -81,8 +86,6 @@ namespace pal int getId( int key ); private: - PriorityQueue( const PriorityQueue & ); - PriorityQueue &operator=( const PriorityQueue & ); int size; int maxsize; diff --git a/src/core/pal/problem.h b/src/core/pal/problem.h index 86c8f18466f..ff9a7973ceb 100644 --- a/src/core/pal/problem.h +++ b/src/core/pal/problem.h @@ -30,6 +30,7 @@ #ifndef PAL_PROBLEM_H #define PAL_PROBLEM_H +#include "qgis_core.h" #include #include #include "rtree.hpp" @@ -112,6 +113,11 @@ namespace pal ~Problem(); + //! Problem cannot be copied + Problem( const Problem& other ) = delete; + //! Problem cannot be copied + Problem& operator=( const Problem& other ) = delete; + /** Adds a candidate label position to the problem. * @param position label candidate position. Ownership is transferred to Problem. * @note added in QGIS 2.12 @@ -178,9 +184,6 @@ namespace pal private: - Problem( const Problem& other ); - Problem& operator=( const Problem& other ); - /** * How many layers are labelled ? */ diff --git a/src/core/pal/rtree.hpp b/src/core/pal/rtree.hpp index b998b41699c..fe2e78563a3 100644 --- a/src/core/pal/rtree.hpp +++ b/src/core/pal/rtree.hpp @@ -146,8 +146,6 @@ namespace pal Iterator() { Init(); } - ~Iterator() { } - /// Is iterator invalid bool IsNull() const { return ( m_tos <= 0 ); } @@ -460,7 +458,7 @@ namespace pal ASSERT( MINNODES > 0 ); - // We only support machine word size simple data type eg. integer index or object pointer. + // We only support machine word size simple data type, e.g., integer index or object pointer. // Since we are storing as union with non data branch ASSERT( sizeof( DATATYPE ) == sizeof( void* ) || sizeof( DATATYPE ) == sizeof( int ) ); diff --git a/src/core/qgis.cpp b/src/core/qgis.cpp index a17d82798b2..20950f32f9a 100644 --- a/src/core/qgis.cpp +++ b/src/core/qgis.cpp @@ -47,11 +47,7 @@ const int Qgis::QGIS_VERSION_INT = VERSION_INT; // Release name QString Qgis::QGIS_RELEASE_NAME( QStringLiteral( RELEASE_NAME ) ); -#if GDAL_VERSION_NUM >= 1800 const QString GEOPROJ4 = QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" ); -#else -const QString GEOPROJ4 = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"; -#endif const QString GEOWKT = "GEOGCS[\"WGS 84\", " diff --git a/src/core/qgis.h b/src/core/qgis.h index c91a34eb5ad..606d4531909 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -32,7 +32,8 @@ #include #include -#include +#include "qgswkbtypes.h" +#include "qgis_core.h" /** \ingroup core * The Qgis class provides global constants for use throughout the application. @@ -236,7 +237,7 @@ inline double qgsRound( double x ) return x < 0.0 ? std::ceil( x - 0.5 ) : std::floor( x + 0.5 ); } -/** Converts a string to a double in a permissive way, eg allowing for incorrect +/** Converts a string to a double in a permissive way, e.g., allowing for incorrect * numbers of digits between thousand separators * @param string string to convert * @param ok will be set to true if conversion was successful @@ -246,7 +247,7 @@ inline double qgsRound( double x ) */ CORE_EXPORT double qgsPermissiveToDouble( QString string, bool& ok ); -/** Converts a string to an integer in a permissive way, eg allowing for incorrect +/** Converts a string to an integer in a permissive way, e.g., allowing for incorrect * numbers of digits between thousand separators * @param string string to convert * @param ok will be set to true if conversion was successful diff --git a/src/core/qgsaction.h b/src/core/qgsaction.h index b170160c026..f6156af2f95 100644 --- a/src/core/qgsaction.h +++ b/src/core/qgsaction.h @@ -16,6 +16,7 @@ #ifndef QGSACTION_H #define QGSACTION_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/qgsactionmanager.cpp b/src/core/qgsactionmanager.cpp index b8523192fa3..e5d8fcc4f8a 100644 --- a/src/core/qgsactionmanager.cpp +++ b/src/core/qgsactionmanager.cpp @@ -156,7 +156,7 @@ QgsExpressionContext QgsActionManager::createExpressionContext() const { QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope(); + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ); if ( mLayer ) context << QgsExpressionContextUtils::layerScope( mLayer ); diff --git a/src/core/qgsactionmanager.h b/src/core/qgsactionmanager.h index de88e6cc8c9..b79bb31055e 100644 --- a/src/core/qgsactionmanager.h +++ b/src/core/qgsactionmanager.h @@ -24,6 +24,7 @@ #ifndef QGSACTIONMANAGER_H #define QGSACTIONMANAGER_H +#include "qgis_core.h" #include #include diff --git a/src/core/qgsactionscope.h b/src/core/qgsactionscope.h index 6f29fb7cff4..036798d2dfd 100644 --- a/src/core/qgsactionscope.h +++ b/src/core/qgsactionscope.h @@ -16,6 +16,7 @@ #ifndef QGSACTIONSCOPE_H #define QGSACTIONSCOPE_H +#include "qgis_core.h" #include #include "qgsexpressioncontext.h" diff --git a/src/core/qgsactionscoperegistry.h b/src/core/qgsactionscoperegistry.h index 36c94ec0ef9..d11ded49941 100644 --- a/src/core/qgsactionscoperegistry.h +++ b/src/core/qgsactionscoperegistry.h @@ -16,6 +16,7 @@ #ifndef QGSACTIONSCOPEREGISTRY_H #define QGSACTIONSCOPEREGISTRY_H +#include "qgis_core.h" #include #include #include "qgsactionscope.h" diff --git a/src/core/qgsaggregatecalculator.cpp b/src/core/qgsaggregatecalculator.cpp index 4e6524b76f6..a0b75d0ca6e 100644 --- a/src/core/qgsaggregatecalculator.cpp +++ b/src/core/qgsaggregatecalculator.cpp @@ -421,7 +421,8 @@ QVariant QgsAggregateCalculator::calculateNumericAggregate( QgsFeatureIterator& } } s.finalize(); - return s.statistic( stat ); + double val = s.statistic( stat ); + return qIsNaN( val ) ? QVariant() : val; } QVariant QgsAggregateCalculator::calculateStringAggregate( QgsFeatureIterator& fit, int attr, QgsExpression* expression, diff --git a/src/core/qgsaggregatecalculator.h b/src/core/qgsaggregatecalculator.h index 18df5d51bdc..21795fdb1ff 100644 --- a/src/core/qgsaggregatecalculator.h +++ b/src/core/qgsaggregatecalculator.h @@ -18,6 +18,7 @@ #ifndef QGSAGGREGATECALCULATOR_H #define QGSAGGREGATECALCULATOR_H +#include "qgis_core.h" #include "qgsstatisticalsummary.h" #include "qgsdatetimestatisticalsummary.h" #include "qgsstringstatisticalsummary.h" diff --git a/src/core/qgsannotation.h b/src/core/qgsannotation.h index 7650c8e1dd8..3b5102e2f04 100644 --- a/src/core/qgsannotation.h +++ b/src/core/qgsannotation.h @@ -18,6 +18,7 @@ #ifndef QGSANNOTATION_H #define QGSANNOTATION_H +#include "qgis_core.h" #include "qgspoint.h" #include "qgscoordinatereferencesystem.h" diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp index 8ebc6609cc0..62eb247379d 100644 --- a/src/core/qgsapplication.cpp +++ b/src/core/qgsapplication.cpp @@ -27,6 +27,15 @@ #include "qgsruntimeprofiler.h" #include "qgstaskmanager.h" #include "qgsfieldformatterregistry.h" +#include "qgssvgcache.h" +#include "qgscolorschemeregistry.h" +#include "qgspainteffectregistry.h" +#include "qgsrasterrendererregistry.h" +#include "qgsrendererregistry.h" +#include "qgssymbollayerregistry.h" +#include "gps/qgsgpsconnectionregistry.h" +#include "qgspluginlayerregistry.h" +#include "qgsmessagelog.h" #include #include @@ -104,15 +113,39 @@ const char* QgsApplication::QGIS_APPLICATION_NAME = "QGIS3"; */ QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled, const QString& customConfigPath, const QString& platformName ) : QApplication( argc, argv, GUIenabled ) + , mActionScopeRegistry( nullptr ) + , mProfiler( nullptr ) + , mTaskManager( nullptr ) + , mFieldFormatterRegistry( nullptr ) + , mColorSchemeRegistry( nullptr ) + , mPaintEffectRegistry( nullptr ) + , mRendererRegistry( nullptr ) + , mSvgCache( nullptr ) + , mSymbolLayerRegistry( nullptr ) + , mRasterRendererRegistry( nullptr ) + , mGpsConnectionRegistry( nullptr ) + , mDataItemProviderRegistry( nullptr ) + , mPluginLayerRegistry( nullptr ) + , mMessageLog( nullptr ) { sPlatformName = platformName; // don't use initializer lists or scoped pointers - as more objects are added here we // will need to be careful with the order of creation/destruction - mTaskManager = new QgsTaskManager(); + mMessageLog = new QgsMessageLog(); mProfiler = new QgsRuntimeProfiler(); + mTaskManager = new QgsTaskManager(); mActionScopeRegistry = new QgsActionScopeRegistry(); mFieldFormatterRegistry = new QgsFieldFormatterRegistry(); + mSvgCache = new QgsSvgCache(); + mColorSchemeRegistry = new QgsColorSchemeRegistry(); + mColorSchemeRegistry->addDefaultSchemes(); + mPaintEffectRegistry = new QgsPaintEffectRegistry(); + mSymbolLayerRegistry = new QgsSymbolLayerRegistry(); + mRendererRegistry = new QgsRendererRegistry(); + mRasterRendererRegistry = new QgsRasterRendererRegistry(); + mGpsConnectionRegistry = new QgsGPSConnectionRegistry(); + mPluginLayerRegistry = new QgsPluginLayerRegistry(); init( customConfigPath ); // init can also be called directly by e.g. unit tests that don't inherit QApplication. } @@ -246,8 +279,18 @@ QgsApplication::~QgsApplication() { delete mActionScopeRegistry; delete mTaskManager; - delete mProfiler; delete mFieldFormatterRegistry; + delete mRasterRendererRegistry; + delete mRendererRegistry; + delete mSymbolLayerRegistry; + delete mPaintEffectRegistry; + delete mColorSchemeRegistry; + delete mSvgCache; + delete mGpsConnectionRegistry; + delete mPluginLayerRegistry; + delete mDataItemProviderRegistry; + delete mProfiler; + delete mMessageLog; } QgsApplication* QgsApplication::instance() @@ -420,7 +463,7 @@ QString QgsApplication::activeThemePath() QString QgsApplication::appIconPath() { - return iconsPath() + ( QDate::currentDate().month() == 12 ? tr( "qgis-icon-60x60_xmas.png", "December application icon" ) : QStringLiteral( "qgis-icon-60x60.png" ) ); + return iconsPath() + QStringLiteral( "qgis-icon-60x60.png" ); } QString QgsApplication::iconPath( const QString& iconFile ) @@ -729,16 +772,11 @@ QStringList QgsApplication::svgPaths() //local directories to search when looking for an SVG with a given basename //defined by user in options dialog QSettings settings; - QStringList myPathList; - QString myPaths = settings.value( QStringLiteral( "svg/searchPathsForSVG" ), QString() ).toString(); - if ( !myPaths.isEmpty() ) - { - myPathList = myPaths.split( '|' ); - } + QStringList pathList = settings.value( QStringLiteral( "svg/searchPathsForSVG" ) ).toStringList(); // maintain user set order while stripping duplicates QStringList paths; - Q_FOREACH ( const QString& path, myPathList ) + Q_FOREACH ( const QString& path, pathList ) { if ( !paths.contains( path ) ) paths.append( path ); @@ -760,14 +798,9 @@ QStringList QgsApplication::composerTemplatePaths() //local directories to search when looking for an SVG with a given basename //defined by user in options dialog QSettings settings; - QStringList myPathList; - QString myPaths = settings.value( QStringLiteral( "composer/searchPathsForTemplates" ), QString() ).toString(); - if ( !myPaths.isEmpty() ) - { - myPathList = myPaths.split( '|' ); - } + QStringList pathList = settings.value( QStringLiteral( "composer/searchPathsForTemplates" ) ).toStringList(); - return myPathList; + return pathList; } QString QgsApplication::userStylePath() @@ -904,6 +937,8 @@ void QgsApplication::initQgis() // set the provider plugin path (this creates provider registry) QgsProviderRegistry::instance( pluginPath() ); + instance()->mDataItemProviderRegistry = new QgsDataItemProviderRegistry(); + // create project instance if doesn't exist QgsProject::instance(); @@ -1258,6 +1293,75 @@ void QgsApplication::copyPath( const QString& src, const QString& dst ) } } +QVariantMap QgsApplication::customVariables() +{ + //read values from QSettings + QSettings settings; + + QVariantMap variables; + + //check if settings contains any variables + if ( settings.contains( QStringLiteral( "/variables/values" ) ) ) + { + QList< QVariant > customVariableVariants = settings.value( QStringLiteral( "/variables/values" ) ).toList(); + QList< QVariant > customVariableNames = settings.value( QStringLiteral( "/variables/names" ) ).toList(); + int variableIndex = 0; + for ( QList< QVariant >::const_iterator it = customVariableVariants.constBegin(); + it != customVariableVariants.constEnd(); ++it ) + { + if ( variableIndex >= customVariableNames.length() ) + { + break; + } + + QVariant value = ( *it ); + QString name = customVariableNames.at( variableIndex ).toString(); + + variables.insert( name, value ); + variableIndex++; + } + } + + return variables; +} + +void QgsApplication::setCustomVariables( const QVariantMap& variables ) +{ + QSettings settings; + + QList< QVariant > customVariableValues; + QList< QVariant > customVariableNames; + + QVariantMap::const_iterator it = variables.constBegin(); + for ( ; it != variables.constEnd(); ++it ) + { + customVariableNames << it.key(); + customVariableValues << it.value(); + } + + settings.setValue( QStringLiteral( "/variables/names" ), customVariableNames ); + settings.setValue( QStringLiteral( "/variables/values" ), customVariableValues ); + + emit instance()->customVariablesChanged(); +} + +void QgsApplication::setCustomVariable( const QString& name, const QVariant& value ) +{ + // save variable to settings + QSettings settings; + + QList< QVariant > customVariableVariants = settings.value( QStringLiteral( "/variables/values" ) ).toList(); + QList< QVariant > customVariableNames = settings.value( QStringLiteral( "/variables/names" ) ).toList(); + + customVariableVariants << value; + customVariableNames << name; + + settings.setValue( QStringLiteral( "/variables/names" ), customVariableNames ); + settings.setValue( QStringLiteral( "/variables/values" ), customVariableVariants ); + + emit instance()->customVariablesChanged(); +} + QString QgsApplication::nullRepresentation() { QgsApplication* app = instance(); @@ -1439,11 +1543,55 @@ QgsTaskManager* QgsApplication::taskManager() return instance()->mTaskManager; } -void QgsApplication::emitSettingsChanged() +QgsColorSchemeRegistry* QgsApplication::colorSchemeRegistry() { - emit settingsChanged(); + return instance()->mColorSchemeRegistry; } +QgsPaintEffectRegistry* QgsApplication::paintEffectRegistry() +{ + return instance()->mPaintEffectRegistry; +} + +QgsRendererRegistry*QgsApplication::rendererRegistry() +{ + return instance()->mRendererRegistry; +} + +QgsRasterRendererRegistry* QgsApplication::rasterRendererRegistry() +{ + return instance()->mRasterRendererRegistry; +} + +QgsDataItemProviderRegistry*QgsApplication::dataItemProviderRegistry() +{ + return instance()->mDataItemProviderRegistry; +} + +QgsSvgCache* QgsApplication::svgCache() +{ + return instance()->mSvgCache; +} + +QgsSymbolLayerRegistry* QgsApplication::symbolLayerRegistry() +{ + return instance()->mSymbolLayerRegistry; +} + +QgsGPSConnectionRegistry* QgsApplication::gpsConnectionRegistry() +{ + return instance()->mGpsConnectionRegistry; +} + +QgsPluginLayerRegistry*QgsApplication::pluginLayerRegistry() +{ + return instance()->mPluginLayerRegistry; +} + +QgsMessageLog* QgsApplication::messageLog() +{ + return instance()->mMessageLog; +} QgsFieldFormatterRegistry* QgsApplication::fieldFormatterRegistry() { diff --git a/src/core/qgsapplication.h b/src/core/qgsapplication.h index bf968c17880..0b16268a06d 100644 --- a/src/core/qgsapplication.h +++ b/src/core/qgsapplication.h @@ -15,6 +15,7 @@ #ifndef QGSAPPLICATION_H #define QGSAPPLICATION_H +#include "qgis_core.h" #include #include #include @@ -26,6 +27,16 @@ class QgsActionScopeRegistry; class QgsRuntimeProfiler; class QgsTaskManager; class QgsFieldFormatterRegistry; +class QgsColorSchemeRegistry; +class QgsPaintEffectRegistry; +class QgsRendererRegistry; +class QgsSvgCache; +class QgsSymbolLayerRegistry; +class QgsRasterRendererRegistry; +class QgsGPSConnectionRegistry; +class QgsDataItemProviderRegistry; +class QgsPluginLayerRegistry; +class QgsMessageLog; /** \ingroup core * Extends QApplication to provide access to QGIS specific resources such @@ -224,7 +235,7 @@ class CORE_EXPORT QgsApplication : public QApplication */ static QString osName(); - /** Returns the QGIS platform name, eg "desktop" or "server". + /** Returns the QGIS platform name, e.g., "desktop" or "server". * @note added in QGIS 2.14 * @see osName() */ @@ -375,6 +386,69 @@ class CORE_EXPORT QgsApplication : public QApplication */ static QgsTaskManager* taskManager(); + /** + * Returns the application's color scheme registry, used for managing color schemes. + * @note added in QGIS 3.0 + */ + static QgsColorSchemeRegistry* colorSchemeRegistry(); + + /** + * Returns the application's paint effect registry, used for managing paint effects. + * @note added in QGIS 3.0 + */ + static QgsPaintEffectRegistry* paintEffectRegistry(); + + /** + * Returns the application's renderer registry, used for managing vector layer renderers. + * @note added in QGIS 3.0 + */ + static QgsRendererRegistry* rendererRegistry(); + + /** + * Returns the application's raster renderer registry, used for managing raster layer renderers. + * @note added in QGIS 3.0 + * @note not available in Python bindings + */ + static QgsRasterRendererRegistry* rasterRendererRegistry(); + + /** + * Returns the application's data item provider registry, which keeps a list of data item + * providers that may add items to the browser tree. + * @note added in QGIS 3.0 + */ + static QgsDataItemProviderRegistry* dataItemProviderRegistry(); + + /** + * Returns the application's SVG cache, used for caching SVG images and handling parameter replacement + * within SVG files. + * @note added in QGIS 3.0 + */ + static QgsSvgCache* svgCache(); + + /** + * Returns the application's symbol layer registry, used for managing symbol layers. + * @note added in QGIS 3.0 + */ + static QgsSymbolLayerRegistry* symbolLayerRegistry(); + + /** + * Returns the application's GPS connection registry, used for managing GPS connections. + * @note added in QGIS 3.0 + */ + static QgsGPSConnectionRegistry* gpsConnectionRegistry(); + + /** + * Returns the application's plugin layer registry, used for managing plugin layer types. + * @note added in QGIS 3.0 + */ + static QgsPluginLayerRegistry* pluginLayerRegistry(); + + /** + * Returns the application's message log. + * @note added in QGIS 3.0 + */ + static QgsMessageLog* messageLog(); + #ifdef ANDROID //dummy method to workaround sip generation issue issue bool x11EventFilter( XEvent * event ) @@ -417,25 +491,42 @@ class CORE_EXPORT QgsApplication : public QApplication */ static void setNullRepresentation( const QString& nullRepresentation ); - public slots: - - /** Causes the application instance to emit the settingsChanged() signal. This should - * be called whenever global, application-wide settings are altered to advise listeners - * that they may need to update their state. - * @see settingsChanged() - * @note added in QGIS 3.0 + /** + * Custom expression variables for this application. + * This does not include generated variables (like system name, user name etc.) + * + * \see QgsExpressionContextUtils::globalVariables(). + * \note Added in QGIS 3.0 */ - void emitSettingsChanged(); + static QVariantMap customVariables(); + + /** + * Custom expression variables for this application. + * Do not include generated variables (like system name, user name etc.) + * + * \see QgsExpressionContextUtils::globalVariables(). + * \note Added in QGIS 3.0 + */ + static void setCustomVariables( const QVariantMap& customVariables ); + + + /** + * Set a single custom expression variable. + * + * \note Added in QGIS 3.0 + */ + static void setCustomVariable( const QString& name, const QVariant& value ); signals: //! @note not available in python bindings void preNotify( QObject * receiver, QEvent * event, bool * done ); - /** Emitted whenever any global, application-wide settings are changed. + /** + * Emitted whenever a custom global variable changes. * @note added in QGIS 3.0 - * @see emitSettingsChanged() */ - void settingsChanged(); + void customVariablesChanged(); + /** * \copydoc nullRepresentation() @@ -492,6 +583,16 @@ class CORE_EXPORT QgsApplication : public QApplication QgsRuntimeProfiler* mProfiler; QgsTaskManager* mTaskManager; QgsFieldFormatterRegistry* mFieldFormatterRegistry; + QgsColorSchemeRegistry* mColorSchemeRegistry; + QgsPaintEffectRegistry* mPaintEffectRegistry; + QgsRendererRegistry* mRendererRegistry; + QgsSvgCache* mSvgCache; + QgsSymbolLayerRegistry* mSymbolLayerRegistry; + QgsRasterRendererRegistry* mRasterRendererRegistry; + QgsGPSConnectionRegistry* mGpsConnectionRegistry; + QgsDataItemProviderRegistry* mDataItemProviderRegistry; + QgsPluginLayerRegistry* mPluginLayerRegistry; + QgsMessageLog* mMessageLog; QString mNullRepresentation; }; diff --git a/src/core/qgsattributeeditorelement.h b/src/core/qgsattributeeditorelement.h index 5e6535db7d1..4b83c4ed385 100644 --- a/src/core/qgsattributeeditorelement.h +++ b/src/core/qgsattributeeditorelement.h @@ -16,6 +16,7 @@ #ifndef QGSATTRIBUTEEDITORELEMENT_H #define QGSATTRIBUTEEDITORELEMENT_H +#include "qgis_core.h" #include "qgsrelation.h" #include "qgsoptionalexpression.h" @@ -56,8 +57,8 @@ class CORE_EXPORT QgsAttributeEditorElement , mShowLabel( true ) {} - //! Destructor - virtual ~QgsAttributeEditorElement() {} + + virtual ~QgsAttributeEditorElement() = default; /** * Return the name of this element @@ -155,7 +156,7 @@ class CORE_EXPORT QgsAttributeEditorContainer : public QgsAttributeEditorElement , mColumnCount( 1 ) {} - //! Destructor + virtual ~QgsAttributeEditorContainer(); /** @@ -269,9 +270,6 @@ class CORE_EXPORT QgsAttributeEditorField : public QgsAttributeEditorElement , mIdx( idx ) {} - //! Destructor - virtual ~QgsAttributeEditorField() {} - /** * Return the index of the field * @return @@ -322,9 +320,6 @@ class CORE_EXPORT QgsAttributeEditorRelation : public QgsAttributeEditorElement , mShowUnlinkButton( true ) {} - //! Destructor - virtual ~QgsAttributeEditorRelation() {} - /** * Get the id of the relation which shall be embedded * diff --git a/src/core/qgsattributetableconfig.h b/src/core/qgsattributetableconfig.h index 32448c92607..11f1f6a7529 100644 --- a/src/core/qgsattributetableconfig.h +++ b/src/core/qgsattributetableconfig.h @@ -21,6 +21,8 @@ #include #include +#include "qgis_core.h" + class QgsFields; /** \ingroup core diff --git a/src/core/qgsbearingutils.h b/src/core/qgsbearingutils.h index 400d107ba24..9709312cb9a 100644 --- a/src/core/qgsbearingutils.h +++ b/src/core/qgsbearingutils.h @@ -21,6 +21,7 @@ class QgsCoordinateReferenceSystem; class QgsPoint; +#include "qgis_core.h" /** * \class QgsBearingUtils diff --git a/src/core/qgsbrowsermodel.cpp b/src/core/qgsbrowsermodel.cpp index 2b29ac91dff..2b162a5a1a9 100644 --- a/src/core/qgsbrowsermodel.cpp +++ b/src/core/qgsbrowsermodel.cpp @@ -37,10 +37,6 @@ QgsBrowserWatcher::QgsBrowserWatcher( QgsDataItem *item ) { } -QgsBrowserWatcher::~QgsBrowserWatcher() -{ -} - // sort function for QList, e.g. sorted/grouped provider listings static bool cmpByDataItemName_( QgsDataItem* a, QgsDataItem* b ) { @@ -133,7 +129,7 @@ void QgsBrowserModel::addRootItems() // container for displaying providers as sorted groups (by QgsDataProvider::DataCapability enum) QMap providerMap; - Q_FOREACH ( QgsDataItemProvider* pr, QgsDataItemProviderRegistry::instance()->providers() ) + Q_FOREACH ( QgsDataItemProvider* pr, QgsApplication::dataItemProviderRegistry()->providers() ) { int capabilities = pr->capabilities(); if ( capabilities == QgsDataProvider::NoDataCapabilities ) diff --git a/src/core/qgsbrowsermodel.h b/src/core/qgsbrowsermodel.h index b514350d3ae..0972c7e45bc 100644 --- a/src/core/qgsbrowsermodel.h +++ b/src/core/qgsbrowsermodel.h @@ -15,6 +15,7 @@ #ifndef QGSBROWSERMODEL_H #define QGSBROWSERMODEL_H +#include "qgis_core.h" #include #include #include @@ -34,7 +35,6 @@ class CORE_EXPORT QgsBrowserWatcher : public QFutureWatcher QgsLimitedRandomColorRamp::randomColors( int count, for ( int i = 0; i < count; ++i ) { //increment hue by golden ratio (approx 137.507 degrees) - //as this minimises hue nearness as count increases + //as this minimizes hue nearness as count increases //see http://basecase.org/env/on-rainbows for more details currentHueAngle += 137.50776; //scale hue to between hueMax and hueMin @@ -417,11 +417,6 @@ QgsRandomColorRamp::QgsRandomColorRamp() { } -QgsRandomColorRamp::~QgsRandomColorRamp() -{ - -} - int QgsRandomColorRamp::count() const { return -1; diff --git a/src/core/qgscolorramp.h b/src/core/qgscolorramp.h index a3cc9482137..d1283523c36 100644 --- a/src/core/qgscolorramp.h +++ b/src/core/qgscolorramp.h @@ -16,6 +16,7 @@ #ifndef QGSCOLORRAMP_H #define QGSCOLORRAMP_H +#include "qgis_core.h" #include #include #include "qgis.h" @@ -30,7 +31,7 @@ class CORE_EXPORT QgsColorRamp { public: - virtual ~QgsColorRamp() {} + virtual ~QgsColorRamp() = default; /** Returns number of defined colors, or -1 if undefined */ @@ -193,12 +194,12 @@ class CORE_EXPORT QgsGradientColorRamp : public QgsColorRamp */ QgsGradientStopsList stops() const { return mStops; } - /** Returns any additional info attached to the gradient ramp (eg authorship notes) + /** Returns any additional info attached to the gradient ramp (e.g., authorship notes) * @see setInfo() */ QgsStringMap info() const { return mInfo; } - /** Sets additional info to attach to the gradient ramp (eg authorship notes) + /** Sets additional info to attach to the gradient ramp (e.g., authorship notes) * @param info map of string info to attach * @see info() */ @@ -358,7 +359,6 @@ class CORE_EXPORT QgsRandomColorRamp: public QgsColorRamp { public: QgsRandomColorRamp(); - ~QgsRandomColorRamp(); int count() const override; diff --git a/src/core/qgscolorscheme.cpp b/src/core/qgscolorscheme.cpp index 60ee6e7d8ae..e06cf38b782 100644 --- a/src/core/qgscolorscheme.cpp +++ b/src/core/qgscolorscheme.cpp @@ -29,11 +29,6 @@ QgsColorScheme::QgsColorScheme() } -QgsColorScheme::~QgsColorScheme() -{ - -} - bool QgsColorScheme::setColors( const QgsNamedColorList &colors, const QString &context, const QColor &baseColor ) { //base implementation does nothing @@ -53,11 +48,6 @@ QgsRecentColorScheme::QgsRecentColorScheme() : QgsColorScheme() } -QgsRecentColorScheme::~QgsRecentColorScheme() -{ - -} - QgsNamedColorList QgsRecentColorScheme::fetchColors( const QString &context, const QColor &baseColor ) { Q_UNUSED( context ); @@ -135,11 +125,6 @@ QgsCustomColorScheme::QgsCustomColorScheme() : QgsColorScheme() } -QgsCustomColorScheme::~QgsCustomColorScheme() -{ - -} - QgsNamedColorList QgsCustomColorScheme::fetchColors( const QString &context, const QColor &baseColor ) { Q_UNUSED( context ); @@ -223,11 +208,6 @@ QgsProjectColorScheme::QgsProjectColorScheme() } -QgsProjectColorScheme::~QgsProjectColorScheme() -{ - -} - QgsNamedColorList QgsProjectColorScheme::fetchColors( const QString &context, const QColor &baseColor ) { Q_UNUSED( context ); @@ -295,11 +275,6 @@ QgsGplColorScheme::QgsGplColorScheme() } -QgsGplColorScheme::~QgsGplColorScheme() -{ - -} - QgsNamedColorList QgsGplColorScheme::fetchColors( const QString &context, const QColor &baseColor ) { Q_UNUSED( context ); @@ -370,11 +345,6 @@ QgsUserColorScheme::QgsUserColorScheme( const QString &filename ) } } -QgsUserColorScheme::~QgsUserColorScheme() -{ - -} - QString QgsUserColorScheme::schemeName() const { return mName; diff --git a/src/core/qgscolorscheme.h b/src/core/qgscolorscheme.h index fedd159cde5..725a37ebe79 100644 --- a/src/core/qgscolorscheme.h +++ b/src/core/qgscolorscheme.h @@ -23,6 +23,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * List of colors paired with a friendly display name identifying the color * \note Added in version 2.5 @@ -54,7 +56,7 @@ class CORE_EXPORT QgsColorScheme QgsColorScheme(); - virtual ~QgsColorScheme(); + virtual ~QgsColorScheme() = default; /** Gets the name for the color scheme * @returns color scheme name @@ -113,8 +115,6 @@ class CORE_EXPORT QgsGplColorScheme : public QgsColorScheme QgsGplColorScheme(); - virtual ~QgsGplColorScheme(); - virtual QgsNamedColorList fetchColors( const QString &context = QString(), const QColor &baseColor = QColor() ) override; @@ -144,8 +144,6 @@ class CORE_EXPORT QgsUserColorScheme : public QgsGplColorScheme */ QgsUserColorScheme( const QString &filename ); - virtual ~QgsUserColorScheme(); - virtual QString schemeName() const override; virtual QgsUserColorScheme* clone() const override; @@ -191,8 +189,6 @@ class CORE_EXPORT QgsRecentColorScheme : public QgsColorScheme QgsRecentColorScheme(); - virtual ~QgsRecentColorScheme(); - virtual QString schemeName() const override { return QObject::tr( "Recent colors" ); } virtual SchemeFlags flags() const override { return ShowInAllContexts; } @@ -227,8 +223,6 @@ class CORE_EXPORT QgsCustomColorScheme : public QgsColorScheme QgsCustomColorScheme(); - virtual ~QgsCustomColorScheme(); - virtual QString schemeName() const override { return QObject::tr( "Standard colors" ); } virtual SchemeFlags flags() const override { return ShowInAllContexts; } @@ -254,8 +248,6 @@ class CORE_EXPORT QgsProjectColorScheme : public QgsColorScheme QgsProjectColorScheme(); - virtual ~QgsProjectColorScheme(); - virtual QString schemeName() const override { return QObject::tr( "Project colors" ); } virtual SchemeFlags flags() const override { return ShowInAllContexts; } diff --git a/src/core/qgscolorschemeregistry.cpp b/src/core/qgscolorschemeregistry.cpp index 27764dbe5b9..f894a1ff321 100644 --- a/src/core/qgscolorschemeregistry.cpp +++ b/src/core/qgscolorschemeregistry.cpp @@ -21,28 +21,6 @@ #include #include -// -// Static calls to enforce singleton behaviour -// -QgsColorSchemeRegistry *QgsColorSchemeRegistry::mInstance = nullptr; -QgsColorSchemeRegistry *QgsColorSchemeRegistry::instance() -{ - if ( !mInstance ) - { - mInstance = new QgsColorSchemeRegistry(); - - //add default color schemes - mInstance->addDefaultSchemes(); - //add user schemes - mInstance->addUserSchemes(); - } - - return mInstance; -} - -// -// Main class begins now... -// QgsColorSchemeRegistry::QgsColorSchemeRegistry() { @@ -57,7 +35,7 @@ QgsColorSchemeRegistry::~QgsColorSchemeRegistry() void QgsColorSchemeRegistry::populateFromInstance() { //get schemes from global instance - QList< QgsColorScheme* > schemeList = QgsColorSchemeRegistry::instance()->schemes(); + QList< QgsColorScheme* > schemeList = QgsApplication::colorSchemeRegistry()->schemes(); //add to this scheme registry QList< QgsColorScheme* >::iterator it = schemeList.begin(); diff --git a/src/core/qgscolorschemeregistry.h b/src/core/qgscolorschemeregistry.h index 99b1be79a60..b7186ddf35d 100644 --- a/src/core/qgscolorschemeregistry.h +++ b/src/core/qgscolorschemeregistry.h @@ -18,6 +18,7 @@ #ifndef QGSCOLORSCHEMEREGISTRY_H #define QGSCOLORSCHEMEREGISTRY_H +#include "qgis_core.h" #include "qgscolorscheme.h" #include @@ -26,7 +27,7 @@ * \brief Registry of color schemes * * A registry of QgsColorScheme color schemes. This class can be created directly, or - * accessed via a global instance. + * accessed via a QgsApplication::colorSchemeRegistry(). * \note Added in version 2.5 */ class CORE_EXPORT QgsColorSchemeRegistry @@ -34,10 +35,6 @@ class CORE_EXPORT QgsColorSchemeRegistry public: - /** Returns the global instance pointer, creating the object on the first call. - */ - static QgsColorSchemeRegistry * instance(); - /** Constructor for an empty color scheme registry */ QgsColorSchemeRegistry(); @@ -98,8 +95,6 @@ class CORE_EXPORT QgsColorSchemeRegistry private: - static QgsColorSchemeRegistry *mInstance; - QList< QgsColorScheme* > mColorSchemeList; }; diff --git a/src/core/qgsconditionalstyle.cpp b/src/core/qgsconditionalstyle.cpp index 7363736d9c0..d6c8e7cfd01 100644 --- a/src/core/qgsconditionalstyle.cpp +++ b/src/core/qgsconditionalstyle.cpp @@ -166,10 +166,6 @@ QgsConditionalStyle& QgsConditionalStyle::operator=( const QgsConditionalStyle & return ( *this ); } -QgsConditionalStyle::~QgsConditionalStyle() -{ -} - QString QgsConditionalStyle::displayText() const { if ( name().isEmpty() ) diff --git a/src/core/qgsconditionalstyle.h b/src/core/qgsconditionalstyle.h index 33fd56a3379..1a0a010d707 100644 --- a/src/core/qgsconditionalstyle.h +++ b/src/core/qgsconditionalstyle.h @@ -1,6 +1,7 @@ #ifndef QGSCONDITIONALSTYLE_H #define QGSCONDITIONALSTYLE_H +#include "qgis_core.h" #include #include #include @@ -69,7 +70,6 @@ class CORE_EXPORT QgsConditionalStyle QgsConditionalStyle(); QgsConditionalStyle( const QgsConditionalStyle& other ); QgsConditionalStyle( const QString& rule ); - ~QgsConditionalStyle(); QgsConditionalStyle& operator=( const QgsConditionalStyle& other ); diff --git a/src/core/qgsconnectionpool.h b/src/core/qgsconnectionpool.h index be77d45fb36..cecb8934eb4 100644 --- a/src/core/qgsconnectionpool.h +++ b/src/core/qgsconnectionpool.h @@ -78,6 +78,11 @@ class QgsConnectionPoolGroup } } + //! QgsConnectionPoolGroup cannot be copied + QgsConnectionPoolGroup( const QgsConnectionPoolGroup& other ) = delete; + //! QgsConnectionPoolGroup cannot be copied + QgsConnectionPoolGroup& operator=( const QgsConnectionPoolGroup& other ) = delete; + T acquire() { // we are going to acquire a resource - if no resource is available, we will block here @@ -214,11 +219,6 @@ class QgsConnectionPoolGroup QSemaphore sem; QTimer* expirationTimer; - private: - - QgsConnectionPoolGroup( const QgsConnectionPoolGroup& other ); - QgsConnectionPoolGroup& operator=( const QgsConnectionPoolGroup& other ); - }; diff --git a/src/core/qgscontexthelp.h b/src/core/qgscontexthelp.h index e48bf17b051..0210843967f 100644 --- a/src/core/qgscontexthelp.h +++ b/src/core/qgscontexthelp.h @@ -23,6 +23,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * Provides a context based help browser for a dialog. * @@ -45,7 +47,7 @@ class CORE_EXPORT QgsContextHelp : public QObject private: //! Constructor QgsContextHelp(); - //! Destructor + ~QgsContextHelp(); QProcess *start(); diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp index dbb6814630b..90f30f92ec6 100644 --- a/src/core/qgscoordinatereferencesystem.cpp +++ b/src/core/qgscoordinatereferencesystem.cpp @@ -214,12 +214,10 @@ bool QgsCoordinateReferenceSystem::createFromUserInput( const QString &theDefini OGRSpatialReferenceH crs = OSRNewSpatialReference( nullptr ); // make sure towgs84 parameter is loaded if using an ESRI definition and gdal >= 1.9 -#if GDAL_VERSION_NUM >= 1900 if ( theDefinition.startsWith( QLatin1String( "ESRI::" ) ) ) { setupESRIWktFix(); } -#endif if ( OSRSetFromUserInput( crs, theDefinition.toLocal8Bit().constData() ) == OGRERR_NONE ) { @@ -238,7 +236,6 @@ void QgsCoordinateReferenceSystem::setupESRIWktFix() { // make sure towgs84 parameter is loaded if gdal >= 1.9 // this requires setting GDAL_FIX_ESRI_WKT=GEOGCS (see qgis bug #5598 and gdal bug #4673) -#if GDAL_VERSION_NUM >= 1900 const char* configOld = CPLGetConfigOption( "GDAL_FIX_ESRI_WKT", "" ); const char* configNew = "GEOGCS"; // only set if it was not set, to let user change the value if needed @@ -254,7 +251,6 @@ void QgsCoordinateReferenceSystem::setupESRIWktFix() { QgsDebugMsg( QString( "GDAL_FIX_ESRI_WKT was already set : %1" ).arg( configNew ) ); } -#endif } bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs( const QString& theCrs ) diff --git a/src/core/qgscoordinatereferencesystem.h b/src/core/qgscoordinatereferencesystem.h index d5f7c5908f8..21239400dd6 100644 --- a/src/core/qgscoordinatereferencesystem.h +++ b/src/core/qgscoordinatereferencesystem.h @@ -19,6 +19,7 @@ #define QGSCOORDINATEREFERENCESYSTEM_H //Standard includes +#include "qgis_core.h" #include //qt includes @@ -176,9 +177,9 @@ typedef void ( *CUSTOM_CRS_VALIDATION )( QgsCoordinateReferenceSystem& ); * Caveats * ======= * - * There are two different flavours of WKT: one is defined by OGC, the other is the standard + * There are two different flavors of WKT: one is defined by OGC, the other is the standard * used by ESRI. They look very similar, but they are not the same. QGIS is able to consume - * both flavours. + * both flavors. * * \see QgsCoordinateTransform */ @@ -238,7 +239,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem // static creators /** Creates a CRS from a given OGC WMS-format Coordinate Reference System string. - * @param ogcCrs OGR compliant CRS definition, eg "EPSG:4326" + * @param ogcCrs OGR compliant CRS definition, e.g., "EPSG:4326" * @returns matching CRS, or an invalid CRS if string could not be matched * @note added in QGIS 3.0 * @see createFromOgcWmsCrs() @@ -474,9 +475,9 @@ class CORE_EXPORT QgsCoordinateReferenceSystem /** Returns the authority identifier for the CRS. * - * The identifier includes both the authority (eg EPSG) and the CRS number (eg 4326). + * The identifier includes both the authority (e.g., EPSG) and the CRS number (e.g., 4326). * This is the best method to use when showing a very short CRS identifier to a user, - * eg "EPSG:4326". + * e.g., "EPSG:4326". * * If CRS object is a custom CRS (not found in database), the method will return * internal QGIS CRS ID with "QGIS" authority, for example "QGIS:100005" @@ -485,7 +486,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem */ QString authid() const; - /** Returns the descriptive name of the CRS, eg "WGS 84" or "GDA 94 / Vicgrid94". In most + /** Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94". In most * cases this is the best method to use when showing a friendly identifier for the CRS to a * user. * @returns descriptive name of the CRS @@ -530,7 +531,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem */ bool isGeographic() const; - /** Returns whether axis is inverted (eg. for WMS 1.3) for the CRS. + /** Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS. * @returns true if CRS axis is inverted */ bool hasAxisInverted() const; diff --git a/src/core/qgscoordinatetransform.h b/src/core/qgscoordinatetransform.h index 49e8139eab2..97e37e884a1 100644 --- a/src/core/qgscoordinatetransform.h +++ b/src/core/qgscoordinatetransform.h @@ -17,6 +17,7 @@ #ifndef QGSCOORDINATETRANSFORM_H #define QGSCOORDINATETRANSFORM_H +#include "qgis_core.h" #include #include "qgscoordinatereferencesystem.h" diff --git a/src/core/qgscoordinateutils.h b/src/core/qgscoordinateutils.h index 41bd29fa853..578eb2766a6 100644 --- a/src/core/qgscoordinateutils.h +++ b/src/core/qgscoordinateutils.h @@ -20,6 +20,8 @@ #include +#include "qgis_core.h" + class QgsPoint; class QgsCoordinateReferenceSystem; diff --git a/src/core/qgscredentials.cpp b/src/core/qgscredentials.cpp index d35481ea209..546835c0075 100644 --- a/src/core/qgscredentials.cpp +++ b/src/core/qgscredentials.cpp @@ -42,10 +42,6 @@ QgsCredentials::QgsCredentials() { } -QgsCredentials::~QgsCredentials() -{ -} - bool QgsCredentials::get( const QString& realm, QString &username, QString &password, const QString& message ) { if ( mCredentialCache.contains( realm ) ) diff --git a/src/core/qgscredentials.h b/src/core/qgscredentials.h index d5bb1405ef0..7ef653f60f0 100644 --- a/src/core/qgscredentials.h +++ b/src/core/qgscredentials.h @@ -23,6 +23,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * Interface for requesting credentials in QGIS in GUI independent way. * This class provides abstraction of a dialog for requesting credentials to the user. @@ -37,8 +39,8 @@ class CORE_EXPORT QgsCredentials { public: - //! virtual destructor - virtual ~QgsCredentials(); + + virtual ~QgsCredentials() = default; bool get( const QString& realm, QString &username, QString &password, const QString& message = QString::null ); void put( const QString& realm, const QString& username, const QString& password ); diff --git a/src/core/qgscrscache.cpp b/src/core/qgscrscache.cpp index 898f4bf8951..e2cba367954 100644 --- a/src/core/qgscrscache.cpp +++ b/src/core/qgscrscache.cpp @@ -29,9 +29,6 @@ QgsCoordinateTransformCache::QgsCoordinateTransformCache() { } -QgsCoordinateTransformCache::~QgsCoordinateTransformCache() -{} - QgsCoordinateTransform QgsCoordinateTransformCache::transform( const QString& srcAuthId, const QString& destAuthId, int srcDatumTransform, int destDatumTransform ) { QList< QgsCoordinateTransform > values = diff --git a/src/core/qgscrscache.h b/src/core/qgscrscache.h index 74059fd715a..ffb4f783008 100644 --- a/src/core/qgscrscache.h +++ b/src/core/qgscrscache.h @@ -18,6 +18,7 @@ #ifndef QGSCRSCACHE_H #define QGSCRSCACHE_H +#include "qgis_core.h" #include "qgscoordinatereferencesystem.h" #include #include @@ -32,7 +33,10 @@ class CORE_EXPORT QgsCoordinateTransformCache public: static QgsCoordinateTransformCache* instance(); - ~QgsCoordinateTransformCache(); + //! QgsCoordinateTransformCache cannot be copied + QgsCoordinateTransformCache( const QgsCoordinateTransformCache& rh ) = delete; + //! QgsCoordinateTransformCache cannot be copied + QgsCoordinateTransformCache& operator=( const QgsCoordinateTransformCache& rh ) = delete; /** Returns coordinate transformation. Cache keeps ownership @param srcAuthId auth id string of source crs @@ -50,8 +54,7 @@ class CORE_EXPORT QgsCoordinateTransformCache QMultiHash< QPair< QString, QString >, QgsCoordinateTransform > mTransforms; //same auth_id pairs might have different datum transformations QgsCoordinateTransformCache(); - QgsCoordinateTransformCache( const QgsCoordinateTransformCache& rh ); - QgsCoordinateTransformCache& operator=( const QgsCoordinateTransformCache& rh ); + }; #endif // QGSCRSCACHE_H diff --git a/src/core/qgscsexception.h b/src/core/qgscsexception.h index 8e4e4562a41..561e9b71c79 100644 --- a/src/core/qgscsexception.h +++ b/src/core/qgscsexception.h @@ -17,6 +17,7 @@ #ifndef QGSCSEXCEPTION_H #define QGSCSEXCEPTION_H +#include "qgis_core.h" #include "qgsexception.h" /** \ingroup core diff --git a/src/core/qgsdartmeasurement.h b/src/core/qgsdartmeasurement.h index 7745f92bb01..c60b7fd3f7d 100644 --- a/src/core/qgsdartmeasurement.h +++ b/src/core/qgsdartmeasurement.h @@ -18,6 +18,8 @@ #include +#include "qgis_core.h" + /** \ingroup core * \class QgsDartMeasurement */ diff --git a/src/core/qgsdatadefined.cpp b/src/core/qgsdatadefined.cpp index 44206a0b36e..d5ba71297c4 100644 --- a/src/core/qgsdatadefined.cpp +++ b/src/core/qgsdatadefined.cpp @@ -67,6 +67,9 @@ QgsDataDefined* QgsDataDefined::fromMap( const QgsStringMap &map, const QString return new QgsDataDefined( active, useExpression, expression, field ); } +QgsDataDefined::~QgsDataDefined() +{} + QgsDataDefined::QgsDataDefined( const QString & string ) { QgsExpression expression( string ); @@ -79,11 +82,6 @@ QgsDataDefined::QgsDataDefined( const QString & string ) expression.isField() ? expression.rootNode()->dump() : QString() ); } -QgsDataDefined::~QgsDataDefined() -{ - -} - bool QgsDataDefined::hasDefaultValues() const { return ( !d->active && !d->useExpression && d->expressionString.isEmpty() && d->field.isEmpty() ); diff --git a/src/core/qgsdatadefined.h b/src/core/qgsdatadefined.h index c682e154af0..a496f42ce6a 100644 --- a/src/core/qgsdatadefined.h +++ b/src/core/qgsdatadefined.h @@ -15,6 +15,7 @@ #ifndef QGSDATADEFINED_H #define QGSDATADEFINED_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/qgsdataitem.cpp b/src/core/qgsdataitem.cpp index 054a165c635..f6044780561 100644 --- a/src/core/qgsdataitem.cpp +++ b/src/core/qgsdataitem.cpp @@ -769,10 +769,6 @@ void QgsDirectoryItem::init() { } -QgsDirectoryItem::~QgsDirectoryItem() -{ -} - QIcon QgsDirectoryItem::icon() { if ( state() == Populating ) @@ -838,7 +834,7 @@ QVector QgsDirectoryItem::createChildren() } } - Q_FOREACH ( QgsDataItemProvider* provider, QgsDataItemProviderRegistry::instance()->providers() ) + Q_FOREACH ( QgsDataItemProvider* provider, QgsApplication::dataItemProviderRegistry()->providers() ) { int capabilities = provider->capabilities(); @@ -1084,10 +1080,6 @@ QgsProjectItem::QgsProjectItem( QgsDataItem* parent, const QString &name, const setState( Populated ); // no more children } -QgsProjectItem::~QgsProjectItem() -{ -} - QgsErrorItem::QgsErrorItem( QgsDataItem* parent, const QString& error, const QString& path ) : QgsDataItem( QgsDataItem::Error, parent, error, path ) { @@ -1096,10 +1088,6 @@ QgsErrorItem::QgsErrorItem( QgsDataItem* parent, const QString& error, const QSt setState( Populated ); // no more children } -QgsErrorItem::~QgsErrorItem() -{ -} - QgsFavoritesItem::QgsFavoritesItem( QgsDataItem* parent, const QString& name, const QString& path ) : QgsDataCollectionItem( parent, name, QStringLiteral( "favorites:" ) ) { @@ -1110,10 +1098,6 @@ QgsFavoritesItem::QgsFavoritesItem( QgsDataItem* parent, const QString& name, co populate(); } -QgsFavoritesItem::~QgsFavoritesItem() -{ -} - QVector QgsFavoritesItem::createChildren() { QVector children; @@ -1171,7 +1155,7 @@ QVector QgsFavoritesItem::createChildren( const QString& favDir ) { QVector children; QString pathName = pathComponent( favDir ); - Q_FOREACH ( QgsDataItemProvider* provider, QgsDataItemProviderRegistry::instance()->providers() ) + Q_FOREACH ( QgsDataItemProvider* provider, QgsApplication::dataItemProviderRegistry()->providers() ) { int capabilities = provider->capabilities(); @@ -1272,10 +1256,6 @@ void QgsZipItem::init() } -QgsZipItem::~QgsZipItem() -{ -} - // internal function to scan a vsidir (zip or tar file) recursively // GDAL trunk has this since r24423 (05/16/12) - VSIReadDirRecursive() // use a copy of the function internally for now, diff --git a/src/core/qgsdataitem.h b/src/core/qgsdataitem.h index c38e9453ec8..65f6c4f5b1b 100644 --- a/src/core/qgsdataitem.h +++ b/src/core/qgsdataitem.h @@ -17,6 +17,7 @@ #ifndef QGSDATAITEM_H #define QGSDATAITEM_H +#include "qgis_core.h" #include #include #include @@ -440,7 +441,6 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem * @param dirPath path to directory in file system * @param path item path in the tree, it may be dirPath or dirPath with some prefix, e.g. favorites: */ QgsDirectoryItem( QgsDataItem* parent, const QString& name, const QString& dirPath, const QString& path ); - ~QgsDirectoryItem(); virtual void setState( State state ) override; @@ -482,7 +482,6 @@ class CORE_EXPORT QgsProjectItem : public QgsDataItem * @param path The full path to the project. */ QgsProjectItem( QgsDataItem* parent, const QString& name, const QString& path ); - ~QgsProjectItem(); virtual bool hasDragEnabled() const override { return true; } @@ -497,7 +496,6 @@ class CORE_EXPORT QgsErrorItem : public QgsDataItem public: QgsErrorItem( QgsDataItem* parent, const QString& error, const QString& path ); - ~QgsErrorItem(); }; @@ -536,8 +534,6 @@ class CORE_EXPORT QgsFavoritesItem : public QgsDataCollectionItem */ QgsFavoritesItem( QgsDataItem* parent, const QString& name, const QString& path = QString() ); - ~QgsFavoritesItem(); - QVector createChildren() override; /** @@ -574,7 +570,6 @@ class CORE_EXPORT QgsZipItem : public QgsDataCollectionItem public: QgsZipItem( QgsDataItem* parent, const QString& name, const QString& path ); QgsZipItem( QgsDataItem* parent, const QString& name, const QString& filePath, const QString& path ); - ~QgsZipItem(); QVector createChildren() override; const QStringList & getZipFileList(); diff --git a/src/core/qgsdataitemprovider.h b/src/core/qgsdataitemprovider.h index 111665a6a34..91460c04092 100644 --- a/src/core/qgsdataitemprovider.h +++ b/src/core/qgsdataitemprovider.h @@ -16,6 +16,8 @@ #ifndef QGSDATAITEMPROVIDER_H #define QGSDATAITEMPROVIDER_H +#include "qgis_core.h" + class QgsDataItem; class QString; @@ -35,7 +37,7 @@ class QString; class CORE_EXPORT QgsDataItemProvider { public: - virtual ~QgsDataItemProvider() {} + virtual ~QgsDataItemProvider() = default; //! Human-readable name of the provider name virtual QString name() = 0; diff --git a/src/core/qgsdataitemproviderregistry.cpp b/src/core/qgsdataitemproviderregistry.cpp index 8608cd1c987..9666d4c01b3 100644 --- a/src/core/qgsdataitemproviderregistry.cpp +++ b/src/core/qgsdataitemproviderregistry.cpp @@ -95,12 +95,6 @@ QgsDataItemProviderRegistry::QgsDataItemProviderRegistry() } } -QgsDataItemProviderRegistry* QgsDataItemProviderRegistry::instance() -{ - static QgsDataItemProviderRegistry sInstance; - return &sInstance; -} - QgsDataItemProviderRegistry::~QgsDataItemProviderRegistry() { qDeleteAll( mProviders ); diff --git a/src/core/qgsdataitemproviderregistry.h b/src/core/qgsdataitemproviderregistry.h index d4769e75210..3466253d1f9 100644 --- a/src/core/qgsdataitemproviderregistry.h +++ b/src/core/qgsdataitemproviderregistry.h @@ -18,21 +18,32 @@ #include +#include "qgis_core.h" + class QgsDataItemProvider; /** \ingroup core - * This singleton class keeps a list of data item providers that may add items to the browser tree. + * This class keeps a list of data item providers that may add items to the browser tree. * When created, it automatically adds providers from provider plugins (e.g. PostGIS, WMS, ...) * + * QgsDataItemProviderRegistry is not usually directly created, but rather accessed through + * QgsApplication::dataItemProviderRegistry(). + * * @note added in 2.10 */ class CORE_EXPORT QgsDataItemProviderRegistry { public: - static QgsDataItemProviderRegistry* instance(); + + QgsDataItemProviderRegistry(); ~QgsDataItemProviderRegistry(); + //! QgsDataItemProviderRegistry cannot be copied. + QgsDataItemProviderRegistry( const QgsDataItemProviderRegistry& rh ) = delete; + //! QgsDataItemProviderRegistry cannot be copied. + QgsDataItemProviderRegistry& operator=( const QgsDataItemProviderRegistry& rh ) = delete; + //! Get list of available providers QList providers() const { return mProviders; } @@ -43,13 +54,10 @@ class CORE_EXPORT QgsDataItemProviderRegistry void removeProvider( QgsDataItemProvider* provider ); private: - QgsDataItemProviderRegistry(); //! available providers. this class owns the pointers QList mProviders; - QgsDataItemProviderRegistry( const QgsDataItemProviderRegistry& rh ); - QgsDataItemProviderRegistry& operator=( const QgsDataItemProviderRegistry& rh ); }; #endif // QGSDATAITEMPROVIDERREGISTRY_H diff --git a/src/core/qgsdataprovider.h b/src/core/qgsdataprovider.h index a7fe47ea827..66c61a6ef18 100644 --- a/src/core/qgsdataprovider.h +++ b/src/core/qgsdataprovider.h @@ -16,6 +16,7 @@ #ifndef QQGSDATAPROVIDER_H #define QQGSDATAPROVIDER_H +#include "qgis_core.h" #include #include #include @@ -78,12 +79,6 @@ class CORE_EXPORT QgsDataProvider : public QObject : mDataSourceURI( uri ) {} - /** - * We need this so the subclass destructors get called - */ - virtual ~QgsDataProvider() {} - - /** Returns the coordinate system for the data source. * If the provider isn't capable of returning its projection then an invalid * QgsCoordinateReferenceSystem will be returned. diff --git a/src/core/qgsdatasourceuri.h b/src/core/qgsdatasourceuri.h index a9852eec265..fd3f0926461 100644 --- a/src/core/qgsdatasourceuri.h +++ b/src/core/qgsdatasourceuri.h @@ -19,6 +19,7 @@ #ifndef QGSDATASOURCEURI_H #define QGSDATASOURCEURI_H +#include "qgis_core.h" #include "qgis.h" #include @@ -236,7 +237,7 @@ class CORE_EXPORT QgsDataSourceUri QString mKeyColumn; //! Use estimated metadata flag bool mUseEstimatedMetadata; - //! Disable SelectAtId capability (eg. to trigger the attribute table memory model for expensive views) + //! Disable SelectAtId capability (e.g., to trigger the attribute table memory model for expensive views) bool mSelectAtIdDisabled; //! geometry type (or QgsWkbTypes::Unknown if not specified) QgsWkbTypes::Type mWkbType; diff --git a/src/core/qgsdatetimestatisticalsummary.h b/src/core/qgsdatetimestatisticalsummary.h index 325fd61e703..1a41b4935be 100644 --- a/src/core/qgsdatetimestatisticalsummary.h +++ b/src/core/qgsdatetimestatisticalsummary.h @@ -16,6 +16,7 @@ #ifndef QGSDATETIMESTATISTICALSUMMARY_H #define QGSDATETIMESTATISTICALSUMMARY_H +#include "qgis_core.h" #include "qgis.h" #include "qgsinterval.h" #include @@ -63,13 +64,13 @@ class CORE_EXPORT QgsDateTimeStatisticalSummary QgsDateTimeStatisticalSummary( QgsDateTimeStatisticalSummary::Statistics stats = All ); /** Returns flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg count). + * are always calculated (e.g., count). * @see setStatistics */ Statistics statistics() const { return mStatistics; } /** Sets flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg count). + * are always calculated (e.g., count). * @param stats flags for statistics to calculate * @see statistics */ diff --git a/src/core/qgsdatumtransformstore.h b/src/core/qgsdatumtransformstore.h index e9d68981bae..eec7f44a347 100644 --- a/src/core/qgsdatumtransformstore.h +++ b/src/core/qgsdatumtransformstore.h @@ -15,6 +15,7 @@ #ifndef QGSDATUMTRANSFORMSTORE_H #define QGSDATUMTRANSFORMSTORE_H +#include "qgis_core.h" #include "qgscoordinatereferencesystem.h" class QgsCoordinateTransform; diff --git a/src/core/qgsdbfilterproxymodel.cpp b/src/core/qgsdbfilterproxymodel.cpp index b1cdb81dab5..25bcc618171 100644 --- a/src/core/qgsdbfilterproxymodel.cpp +++ b/src/core/qgsdbfilterproxymodel.cpp @@ -22,11 +22,6 @@ QgsDbFilterProxyModel::QgsDbFilterProxyModel( QObject* parent ): QSortFilterProx } -QgsDbFilterProxyModel::~QgsDbFilterProxyModel() -{ - -} - bool QgsDbFilterProxyModel::filterAcceptsRow( int row, const QModelIndex & source_parent ) const { //if parent is valid, we have a toplevel item that should be always shown diff --git a/src/core/qgsdbfilterproxymodel.h b/src/core/qgsdbfilterproxymodel.h index 73c970e5fea..5434daa1d49 100644 --- a/src/core/qgsdbfilterproxymodel.h +++ b/src/core/qgsdbfilterproxymodel.h @@ -20,6 +20,8 @@ #include +#include "qgis_core.h" + /** \ingroup core * A class that implements a custom filter and can be used as a proxy for QgsDbTableModel*/ @@ -29,7 +31,6 @@ class CORE_EXPORT QgsDbFilterProxyModel: public QSortFilterProxyModel public: QgsDbFilterProxyModel( QObject* parent = nullptr ); - ~QgsDbFilterProxyModel(); //! Calls QSortFilterProxyModel::setFilterWildcard and triggers update void _setFilterWildcard( const QString& pattern ); //! Calls QSortFilterProxyModel::setFilterRegExp and triggers update diff --git a/src/core/qgsdiagramrenderer.cpp b/src/core/qgsdiagramrenderer.cpp index b23d34d2b42..1e0e72677ce 100644 --- a/src/core/qgsdiagramrenderer.cpp +++ b/src/core/qgsdiagramrenderer.cpp @@ -25,74 +25,59 @@ #include #include -Q_NOWARN_DEPRECATED_PUSH // because of deprecated xform member QgsDiagramLayerSettings::QgsDiagramLayerSettings() - : placement( AroundPoint ) - , placementFlags( OnLine ) - , priority( 5 ) - , zIndex( 0.0 ) - , obstacle( false ) - , dist( 0.0 ) - , renderer( nullptr ) - , xPosColumn( -1 ) + : xPosColumn( -1 ) , yPosColumn( -1 ) , showColumn( -1 ) - , showAll( true ) + , mRenderer( nullptr ) { } -Q_NOWARN_DEPRECATED_POP -Q_NOWARN_DEPRECATED_PUSH // because of deprecated xform member QgsDiagramLayerSettings::QgsDiagramLayerSettings( const QgsDiagramLayerSettings& rh ) - : placement( rh.placement ) - , placementFlags( rh.placementFlags ) - , priority( rh.priority ) - , zIndex( rh.zIndex ) - , obstacle( rh.obstacle ) - , dist( rh.dist ) - , renderer( rh.renderer ? rh.renderer->clone() : nullptr ) - , xPosColumn( rh.xPosColumn ) + : xPosColumn( rh.xPosColumn ) , yPosColumn( rh.yPosColumn ) , showColumn( rh.showColumn ) - , showAll( rh.showAll ) , mCt( rh.mCt ) + , mPlacement( rh.mPlacement ) + , mPlacementFlags( rh.mPlacementFlags ) + , mPriority( rh.mPriority ) + , mZIndex( rh.mZIndex ) + , mObstacle( rh.mObstacle ) + , mDistance( rh.mDistance ) + , mRenderer( rh.mRenderer ? rh.mRenderer->clone() : nullptr ) + , mShowAll( rh.mShowAll ) { } -Q_NOWARN_DEPRECATED_POP -Q_NOWARN_DEPRECATED_PUSH // because of deprecated xform member QgsDiagramLayerSettings&QgsDiagramLayerSettings::operator=( const QgsDiagramLayerSettings & rh ) { - placement = rh.placement; - placementFlags = rh.placementFlags; - priority = rh.priority; - zIndex = rh.zIndex; - obstacle = rh.obstacle; - dist = rh.dist; - renderer = rh.renderer ? rh.renderer->clone() : nullptr; + mPlacement = rh.mPlacement; + mPlacementFlags = rh.mPlacementFlags; + mPriority = rh.mPriority; + mZIndex = rh.mZIndex; + mObstacle = rh.mObstacle; + mDistance = rh.mDistance; + mRenderer = rh.mRenderer ? rh.mRenderer->clone() : nullptr; mCt = rh.mCt; xPosColumn = rh.xPosColumn; yPosColumn = rh.yPosColumn; showColumn = rh.showColumn; - showAll = rh.showAll; + mShowAll = rh.mShowAll; return *this; } -Q_NOWARN_DEPRECATED_POP -Q_NOWARN_DEPRECATED_PUSH // because of deprecated fields member QgsDiagramLayerSettings::~QgsDiagramLayerSettings() { - delete renderer; + delete mRenderer; } -Q_NOWARN_DEPRECATED_POP void QgsDiagramLayerSettings::setRenderer( QgsDiagramRenderer *diagramRenderer ) { - if ( diagramRenderer == renderer ) + if ( diagramRenderer == mRenderer ) return; - delete renderer; - renderer = diagramRenderer; + delete mRenderer; + mRenderer = diagramRenderer; } void QgsDiagramLayerSettings::setCoordinateTransform( const QgsCoordinateTransform& transform ) @@ -104,16 +89,16 @@ void QgsDiagramLayerSettings::readXml( const QDomElement& elem, const QgsVectorL { Q_UNUSED( layer ) - placement = static_cast< Placement >( elem.attribute( QStringLiteral( "placement" ) ).toInt() ); - placementFlags = static_cast< LinePlacementFlags >( elem.attribute( QStringLiteral( "linePlacementFlags" ) ).toInt() ); - priority = elem.attribute( QStringLiteral( "priority" ) ).toInt(); - zIndex = elem.attribute( QStringLiteral( "zIndex" ) ).toDouble(); - obstacle = elem.attribute( QStringLiteral( "obstacle" ) ).toInt(); - dist = elem.attribute( QStringLiteral( "dist" ) ).toDouble(); + mPlacement = static_cast< Placement >( elem.attribute( QStringLiteral( "placement" ) ).toInt() ); + mPlacementFlags = static_cast< LinePlacementFlag >( elem.attribute( QStringLiteral( "linePlacementFlags" ) ).toInt() ); + mPriority = elem.attribute( QStringLiteral( "priority" ) ).toInt(); + mZIndex = elem.attribute( QStringLiteral( "zIndex" ) ).toDouble(); + mObstacle = elem.attribute( QStringLiteral( "obstacle" ) ).toInt(); + mDistance = elem.attribute( QStringLiteral( "dist" ) ).toDouble(); xPosColumn = elem.attribute( QStringLiteral( "xPosColumn" ) ).toInt(); yPosColumn = elem.attribute( QStringLiteral( "yPosColumn" ) ).toInt(); showColumn = elem.attribute( QStringLiteral( "showColumn" ) ).toInt(); - showAll = ( elem.attribute( QStringLiteral( "showAll" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) ); + mShowAll = ( elem.attribute( QStringLiteral( "showAll" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) ); } void QgsDiagramLayerSettings::writeXml( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const @@ -121,24 +106,24 @@ void QgsDiagramLayerSettings::writeXml( QDomElement& layerElem, QDomDocument& do Q_UNUSED( layer ) QDomElement diagramLayerElem = doc.createElement( QStringLiteral( "DiagramLayerSettings" ) ); - diagramLayerElem.setAttribute( QStringLiteral( "placement" ), placement ); - diagramLayerElem.setAttribute( QStringLiteral( "linePlacementFlags" ), placementFlags ); - diagramLayerElem.setAttribute( QStringLiteral( "priority" ), priority ); - diagramLayerElem.setAttribute( QStringLiteral( "zIndex" ), zIndex ); - diagramLayerElem.setAttribute( QStringLiteral( "obstacle" ), obstacle ); - diagramLayerElem.setAttribute( QStringLiteral( "dist" ), QString::number( dist ) ); + diagramLayerElem.setAttribute( QStringLiteral( "placement" ), mPlacement ); + diagramLayerElem.setAttribute( QStringLiteral( "linePlacementFlags" ), mPlacementFlags ); + diagramLayerElem.setAttribute( QStringLiteral( "priority" ), mPriority ); + diagramLayerElem.setAttribute( QStringLiteral( "zIndex" ), mZIndex ); + diagramLayerElem.setAttribute( QStringLiteral( "obstacle" ), mObstacle ); + diagramLayerElem.setAttribute( QStringLiteral( "dist" ), QString::number( mDistance ) ); diagramLayerElem.setAttribute( QStringLiteral( "xPosColumn" ), xPosColumn ); diagramLayerElem.setAttribute( QStringLiteral( "yPosColumn" ), yPosColumn ); diagramLayerElem.setAttribute( QStringLiteral( "showColumn" ), showColumn ); - diagramLayerElem.setAttribute( QStringLiteral( "showAll" ), showAll ); + diagramLayerElem.setAttribute( QStringLiteral( "showAll" ), mShowAll ); layerElem.appendChild( diagramLayerElem ); } QSet QgsDiagramLayerSettings::referencedFields( const QgsExpressionContext &context, const QgsFields& fieldsParameter ) const { QSet< QString > referenced; - if ( renderer ) - referenced = renderer->referencedFields( context, fieldsParameter ); + if ( mRenderer ) + referenced = mRenderer->referencedFields( context ); //and the ones needed for data defined diagram positions if ( xPosColumn >= 0 && xPosColumn < fieldsParameter.count() ) @@ -446,10 +431,8 @@ QSizeF QgsDiagramRenderer::sizeMapUnits( const QgsFeature& feature, const QgsRen return size; } -QSet QgsDiagramRenderer::referencedFields( const QgsExpressionContext &context, const QgsFields &fields ) const +QSet QgsDiagramRenderer::referencedFields( const QgsExpressionContext &context ) const { - Q_UNUSED( fields ); - QSet< QString > referenced; if ( !mDiagram ) @@ -541,10 +524,6 @@ QgsSingleCategoryDiagramRenderer::QgsSingleCategoryDiagramRenderer(): QgsDiagram { } -QgsSingleCategoryDiagramRenderer::~QgsSingleCategoryDiagramRenderer() -{ -} - QgsSingleCategoryDiagramRenderer* QgsSingleCategoryDiagramRenderer::clone() const { return new QgsSingleCategoryDiagramRenderer( *this ); @@ -595,10 +574,6 @@ QgsLinearlyInterpolatedDiagramRenderer::QgsLinearlyInterpolatedDiagramRenderer() mInterpolationSettings.classificationAttributeIsExpression = false; } -QgsLinearlyInterpolatedDiagramRenderer::~QgsLinearlyInterpolatedDiagramRenderer() -{ -} - QgsLinearlyInterpolatedDiagramRenderer* QgsLinearlyInterpolatedDiagramRenderer::clone() const { return new QgsLinearlyInterpolatedDiagramRenderer( *this ); @@ -623,9 +598,9 @@ QList QgsLinearlyInterpolatedDiagramRenderer::diagramAttributes() const return mSettings.categoryAttributes; } -QSet QgsLinearlyInterpolatedDiagramRenderer::referencedFields( const QgsExpressionContext &context, const QgsFields& fields ) const +QSet QgsLinearlyInterpolatedDiagramRenderer::referencedFields( const QgsExpressionContext &context ) const { - QSet< QString > referenced = QgsDiagramRenderer::referencedFields( context, fields ); + QSet< QString > referenced = QgsDiagramRenderer::referencedFields( context ); if ( mInterpolationSettings.classificationAttributeIsExpression ) { QgsExpression* expression = mDiagram->getExpression( mInterpolationSettings.classificationAttributeExpression, context ); @@ -636,7 +611,7 @@ QSet QgsLinearlyInterpolatedDiagramRenderer::referencedFields( const Qg } else { - referenced << fields.at( mInterpolationSettings.classificationAttribute ).name(); + referenced << mInterpolationSettings.classificationField; } return referenced; } @@ -661,7 +636,14 @@ void QgsLinearlyInterpolatedDiagramRenderer::readXml( const QDomElement& elem, c } else { - mInterpolationSettings.classificationAttribute = elem.attribute( QStringLiteral( "classificationAttribute" ) ).toInt(); + if ( elem.hasAttribute( QStringLiteral( "classificationAttribute" ) ) ) + { + int idx = elem.attribute( QStringLiteral( "classificationAttribute" ) ).toInt(); + if ( idx >= 0 && idx < layer->fields().count() ) + mInterpolationSettings.classificationField = layer->fields().at( idx ).name(); + } + else + mInterpolationSettings.classificationField = elem.attribute( QStringLiteral( "classificationField " ) ); } QDomElement settingsElem = elem.firstChildElement( QStringLiteral( "DiagramCategory" ) ); if ( !settingsElem.isNull() ) @@ -686,7 +668,7 @@ void QgsLinearlyInterpolatedDiagramRenderer::writeXml( QDomElement& layerElem, Q } else { - rendererElem.setAttribute( QStringLiteral( "classificationAttribute" ), mInterpolationSettings.classificationAttribute ); + rendererElem.setAttribute( QStringLiteral( "classificationField" ), mInterpolationSettings.classificationField ); } mSettings.writeXml( rendererElem, doc, layer ); _writeXml( rendererElem, doc, layer ); diff --git a/src/core/qgsdiagramrenderer.h b/src/core/qgsdiagramrenderer.h index 63615c1a0e1..21077fd79bc 100644 --- a/src/core/qgsdiagramrenderer.h +++ b/src/core/qgsdiagramrenderer.h @@ -15,6 +15,7 @@ #ifndef QGSDIAGRAMRENDERERV2_H #define QGSDIAGRAMRENDERERV2_H +#include "qgis_core.h" #include #include #include @@ -63,13 +64,14 @@ class CORE_EXPORT QgsDiagramLayerSettings }; //! Line placement flags for controlling line based placements - enum LinePlacementFlags + enum LinePlacementFlag { OnLine = 1, - AboveLine = 2, - BelowLine = 4, - MapOrientation = 8 + AboveLine = 1 << 1, + BelowLine = 1 << 2, + MapOrientation = 1 << 4, }; + Q_DECLARE_FLAGS( LinePlacementFlags, LinePlacementFlag ) QgsDiagramLayerSettings(); @@ -80,30 +82,26 @@ class CORE_EXPORT QgsDiagramLayerSettings ~QgsDiagramLayerSettings(); - /** Returns the diagram placement. + /** + * Returns the diagram placement. * @see setPlacement() * @note added in QGIS 2.16 */ - //TODO QGIS 3.0 - rename getter to placement() - Placement getPlacement() const { return placement; } + Placement placement() const { return mPlacement; } /** Sets the diagram placement. * @param value placement value - * @see getPlacement() + * @see placement() * @note added in QGIS 2.16 */ - void setPlacement( Placement value ) { placement = value; } - - //! Diagram placement - //TODO QGIS 3.0 - make private, rename to mPlacement - Placement placement; + void setPlacement( Placement value ) { mPlacement = value; } /** Returns the diagram placement flags. These are only used if the diagram placement * is set to a line type. * @see setLinePlacementFlags() * @note added in QGIS 2.16 */ - unsigned int linePlacementFlags() const { return placementFlags; } + LinePlacementFlags linePlacementFlags() const { return mPlacementFlags; } /** Sets the the diagram placement flags. These are only used if the diagram placement * is set to a line type. @@ -111,11 +109,7 @@ class CORE_EXPORT QgsDiagramLayerSettings * @see getPlacement() * @note added in QGIS 2.16 */ - void setLinePlacementFlags( unsigned int flags ) { placementFlags = flags; } - - //! Diagram placement flags - // TODO QGIS 3.0 - make private, rename to mPlacementFlags, use QFlags - unsigned int placementFlags; + void setLinePlacementFlags( LinePlacementFlags flags ) { mPlacementFlags = flags; } /** Returns the diagram priority. * @returns diagram priority, where 0 = low and 10 = high @@ -124,21 +118,15 @@ class CORE_EXPORT QgsDiagramLayerSettings * @see setPriority() * @note added in QGIS 2.16 */ - //TODO QGIS 3.0 - rename getter to priority() - int getPriority() const { return priority; } + int priority() const { return mPriority; } /** Sets the diagram priority. * @param value priority, where 0 = low and 10 = high - * @see getPriority() + * @see priority() * @note added in QGIS 2.16 */ - void setPriority( int value ) { priority = value; } + void setPriority( int value ) { mPriority = value; } - //! Placement priority, where 0 = low and 10 = high - //! @note placement priority is shared with labeling, so diagrams with a high priority may displace labels - //! and vice-versa - // TODO QGIS 3.0 - make private, rename to mPriority - int priority; /** Returns the diagram z-index. Diagrams (or labels) with a higher z-index are drawn over diagrams * with a lower z-index. @@ -147,81 +135,61 @@ class CORE_EXPORT QgsDiagramLayerSettings * @see setZIndex() * @note added in QGIS 2.16 */ - //TODO QGIS 3.0 - rename getter to zIndex() - double getZIndex() const { return zIndex; } + double zIndex() const { return mZIndex; } /** Sets the diagram z-index. Diagrams (or labels) with a higher z-index are drawn over diagrams * with a lower z-index. * @param index diagram z-index - * @see getZIndex() + * @see zIndex() * @note added in QGIS 2.16 */ - void setZIndex( double index ) { zIndex = index; } - - //! Z-index of diagrams, where diagrams with a higher z-index are drawn on top of diagrams with a lower z-index - // TODO QGIS 3.0 - rename to mZIndex, make private - double zIndex; - + void setZIndex( double index ) { mZIndex = index; } /** Returns whether the feature associated with a diagram acts as an obstacle for other labels or diagrams. * @see setIsObstacle() * @note added in QGIS 2.16 */ - bool isObstacle() const { return obstacle; } + bool isObstacle() const { return mObstacle; } /** Sets whether the feature associated with a diagram acts as an obstacle for other labels or diagrams. * @param isObstacle set to true for feature to act as obstacle * @see isObstacle() * @note added in QGIS 2.16 */ - void setIsObstacle( bool isObstacle ) { obstacle = isObstacle; } - - //! Whether associated feature acts as an obstacle for other labels or diagrams - // TODO QGIS 3.0 - rename to mObstacle, make private - bool obstacle; + void setIsObstacle( bool isObstacle ) { mObstacle = isObstacle; } /** Returns the distance between the diagram and the feature (in mm). * @see setDistance() * @note added in QGIS 2.16 */ - double distance() const { return dist; } + double distance() const { return mDistance; } /** Sets the distance between the diagram and the feature. * @param distance distance in mm * @see distance() * @note added in QGIS 2.16 */ - void setDistance( double distance ) { dist = distance; } - - //! Distance between diagram and the feature (in mm) - // TODO QGIS 3.0 - make private, rename to mDistance - double dist; + void setDistance( double distance ) { mDistance = distance; } /** Returns the diagram renderer associated with the layer. * @see setRenderer() * @note added in QGIS 2.16 */ - // TODO QGIS 3.0 - rename to renderer() - QgsDiagramRenderer* getRenderer() { return renderer; } + QgsDiagramRenderer* renderer() { return mRenderer; } /** Returns the diagram renderer associated with the layer. * @see setRenderer() * @note added in QGIS 2.16 */ - // TODO QGIS 3.0 - rename to renderer() - const QgsDiagramRenderer* getRenderer() const { return renderer; } + const QgsDiagramRenderer* renderer() const { return mRenderer; } /** Sets the diagram renderer associated with the layer. * @param diagramRenderer diagram renderer. Ownership is transferred to the object. - * @see getRenderer() + * @see renderer() * @note added in QGIS 2.16 */ void setRenderer( QgsDiagramRenderer* diagramRenderer ); - //! Associated diagram renderer. Owned by this object. - // TODO QGIS 3.0 - make private, rename to mRenderer - QgsDiagramRenderer* renderer; - /** Returns the coordinate transform associated with the layer, or an * invalid transform if no transformation is required. * @see setCoordinateTransform() @@ -249,18 +217,14 @@ class CORE_EXPORT QgsDiagramLayerSettings * @see setShowAllDiagrams() * @note added in QGIS 2.16 */ - bool showAllDiagrams() const { return showAll; } + bool showAllDiagrams() const { return mShowAll; } /** Sets whether the layer should show all diagrams, including overlapping diagrams * @param showAllDiagrams set to true to show all diagrams * @see showAllDiagrams() * @note added in QGIS 2.16 */ - void setShowAllDiagrams( bool showAllDiagrams ) { showAll = showAllDiagrams; } - - //! Whether to show all diagrams, including overlapping diagrams - // TODO QGIS 3.0 - make private, rename to mShowAll - bool showAll; + void setShowAllDiagrams( bool showAllDiagrams ) { mShowAll = showAllDiagrams; } void readXml( const QDomElement& elem, const QgsVectorLayer* layer ); void writeXml( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const; @@ -277,6 +241,32 @@ class CORE_EXPORT QgsDiagramLayerSettings //! Associated coordinate transform, or invalid transform for no transformation QgsCoordinateTransform mCt; + + //! Diagram placement + Placement mPlacement = AroundPoint; + + //! Diagram placement flags + LinePlacementFlags mPlacementFlags = OnLine; + + //! Placement priority, where 0 = low and 10 = high + //! @note placement priority is shared with labeling, so diagrams with a high priority may displace labels + //! and vice-versa + int mPriority = 5; + + //! Z-index of diagrams, where diagrams with a higher z-index are drawn on top of diagrams with a lower z-index + double mZIndex = 0.0; + + //! Whether associated feature acts as an obstacle for other labels or diagrams + bool mObstacle = false; + + //! Distance between diagram and the feature (in mm) + double mDistance = 0.0; + + //! Associated diagram renderer. Owned by this object. + QgsDiagramRenderer* mRenderer = nullptr; + + //! Whether to show all diagrams, including overlapping diagrams + bool mShowAll = true; }; /** \ingroup core @@ -390,9 +380,8 @@ class CORE_EXPORT QgsDiagramInterpolationSettings double lowerValue; double upperValue; - //! Index of the classification attribute - //TODO QGIS 3.0 - don't store index, store field name - int classificationAttribute; + //! Name of the field for classification + QString classificationField; QString classificationAttributeExpression; bool classificationAttributeIsExpression; @@ -425,11 +414,9 @@ class CORE_EXPORT QgsDiagramRenderer /** Returns the set of any fields required for diagram rendering * @param context expression context the diagrams will be drawn using - * @param fields layer fields * @note added in QGIS 2.16 */ - //TODO QGIS 3.0 - remove need for fields parameter - virtual QSet< QString > referencedFields( const QgsExpressionContext& context = QgsExpressionContext(), const QgsFields& fields = QgsFields() ) const; + virtual QSet< QString > referencedFields( const QgsExpressionContext& context = QgsExpressionContext() ) const; void renderDiagram( const QgsFeature& feature, QgsRenderContext& c, QPointF pos ) const; @@ -539,7 +526,6 @@ class CORE_EXPORT QgsSingleCategoryDiagramRenderer : public QgsDiagramRenderer { public: QgsSingleCategoryDiagramRenderer(); - ~QgsSingleCategoryDiagramRenderer(); QgsSingleCategoryDiagramRenderer* clone() const override; @@ -572,7 +558,6 @@ class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer : public QgsDiagramRend { public: QgsLinearlyInterpolatedDiagramRenderer(); - ~QgsLinearlyInterpolatedDiagramRenderer(); QgsLinearlyInterpolatedDiagramRenderer* clone() const override; @@ -583,7 +568,7 @@ class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer : public QgsDiagramRend QList diagramAttributes() const override; - virtual QSet< QString > referencedFields( const QgsExpressionContext& context = QgsExpressionContext(), const QgsFields& fields = QgsFields() ) const override; + virtual QSet< QString > referencedFields( const QgsExpressionContext& context = QgsExpressionContext() ) const override; QString rendererName() const override { return QStringLiteral( "LinearlyInterpolated" ); } @@ -599,8 +584,19 @@ class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer : public QgsDiagramRend void setUpperSize( QSizeF s ) { mInterpolationSettings.upperSize = s; } QSizeF upperSize() const { return mInterpolationSettings.upperSize; } - int classificationAttribute() const { return mInterpolationSettings.classificationAttribute; } - void setClassificationAttribute( int index ) { mInterpolationSettings.classificationAttribute = index; } + /** + * Returns the field name used for interpolating the diagram size. + * @see setClassificationField() + * @note added in QGIS 3.0 + */ + QString classificationField() const { return mInterpolationSettings.classificationField; } + + /** + * Sets the field name used for interpolating the diagram size. + * @see classificationField() + * @note added in QGIS 3.0 + */ + void setClassificationField( const QString& field ) { mInterpolationSettings.classificationField = field; } QString classificationAttributeExpression() const { return mInterpolationSettings.classificationAttributeExpression; } void setClassificationAttributeExpression( const QString& expression ) { mInterpolationSettings.classificationAttributeExpression = expression; } diff --git a/src/core/qgsdistancearea.cpp b/src/core/qgsdistancearea.cpp index 259bc3fddbf..efd68180227 100644 --- a/src/core/qgsdistancearea.cpp +++ b/src/core/qgsdistancearea.cpp @@ -60,10 +60,6 @@ QgsDistanceArea::QgsDistanceArea( const QgsDistanceArea & origDA ) _copy( origDA ); } -QgsDistanceArea::~QgsDistanceArea() -{ -} - //! Assignment operator QgsDistanceArea & QgsDistanceArea::operator=( const QgsDistanceArea & origDA ) { diff --git a/src/core/qgsdistancearea.h b/src/core/qgsdistancearea.h index fa9c4b0b116..b8ac6e9e308 100644 --- a/src/core/qgsdistancearea.h +++ b/src/core/qgsdistancearea.h @@ -16,6 +16,7 @@ #ifndef QGSDISTANCEAREA_H #define QGSDISTANCEAREA_H +#include "qgis_core.h" #include #include "qgscoordinatetransform.h" #include "qgsunittypes.h" @@ -41,9 +42,6 @@ class CORE_EXPORT QgsDistanceArea //! Constructor QgsDistanceArea(); - //! Destructor - ~QgsDistanceArea(); - //! Copy constructor QgsDistanceArea( const QgsDistanceArea &origDA ); @@ -245,7 +243,7 @@ class CORE_EXPORT QgsDistanceArea * @param distance distance to format * @param decimals number of decimal places to show * @param unit unit of distance - * @param keepBaseUnit set to false to allow conversion of large distances to more suitable units, eg meters to + * @param keepBaseUnit set to false to allow conversion of large distances to more suitable units, e.g., meters to * kilometers * @returns formatted distance string * @note added in QGIS 2.16 @@ -257,7 +255,7 @@ class CORE_EXPORT QgsDistanceArea * @param area area to format * @param decimals number of decimal places to show * @param unit unit of area - * @param keepBaseUnit set to false to allow conversion of large areas to more suitable units, eg square meters to + * @param keepBaseUnit set to false to allow conversion of large areas to more suitable units, e.g., square meters to * square kilometers * @returns formatted area string * @note added in QGIS 2.14 diff --git a/src/core/qgseditformconfig.cpp b/src/core/qgseditformconfig.cpp index 17f476d42b9..25a581d938f 100644 --- a/src/core/qgseditformconfig.cpp +++ b/src/core/qgseditformconfig.cpp @@ -93,6 +93,9 @@ QgsEditFormConfig::QgsEditFormConfig( const QgsEditFormConfig& o ) { } +QgsEditFormConfig::~QgsEditFormConfig() +{} + QgsEditFormConfig& QgsEditFormConfig::operator=( const QgsEditFormConfig & o ) { d = o.d; @@ -104,11 +107,6 @@ bool QgsEditFormConfig::operator==( const QgsEditFormConfig& o ) return d == o.d; } -QgsEditFormConfig::~QgsEditFormConfig() -{ - -} - void QgsEditFormConfig::addTab( QgsAttributeEditorElement* data ) { d.detach(); diff --git a/src/core/qgseditformconfig.h b/src/core/qgseditformconfig.h index 97d93822a04..59b9e5a5d0a 100644 --- a/src/core/qgseditformconfig.h +++ b/src/core/qgseditformconfig.h @@ -18,6 +18,7 @@ #ifndef QGSEDITFORMCONFIG_H #define QGSEDITFORMCONFIG_H +#include "qgis_core.h" #include #include #include @@ -93,13 +94,12 @@ class CORE_EXPORT QgsEditFormConfig * @note Added in QGIS 3.0 */ QgsEditFormConfig( const QgsEditFormConfig& o ); + ~QgsEditFormConfig(); QgsEditFormConfig& operator=( const QgsEditFormConfig& o ); bool operator==( const QgsEditFormConfig& o ); - ~QgsEditFormConfig(); - /** * Adds a new element to the invisible root container in the layout. * diff --git a/src/core/qgseditorwidgetsetup.h b/src/core/qgseditorwidgetsetup.h index f37d09305fb..7f3eb35c7aa 100644 --- a/src/core/qgseditorwidgetsetup.h +++ b/src/core/qgseditorwidgetsetup.h @@ -16,6 +16,7 @@ #ifndef QGSEDITORWIDGETSETUP_H #define QGSEDITORWIDGETSETUP_H +#include "qgis_core.h" #include /** \ingroup core diff --git a/src/core/qgserror.h b/src/core/qgserror.h index a0aae0cbd5d..b5c18a74713 100644 --- a/src/core/qgserror.h +++ b/src/core/qgserror.h @@ -20,6 +20,8 @@ #include #include +#include "qgis_core.h" + // Macro to create Error message including info about where it was created. #define QGS_ERROR_MESSAGE(message, tag) QgsErrorMessage(QString(message),QString(tag), QString(__FILE__), QString(__FUNCTION__), __LINE__) diff --git a/src/core/qgsexception.h b/src/core/qgsexception.h index e24d2f01b8d..3d68aa24fde 100644 --- a/src/core/qgsexception.h +++ b/src/core/qgsexception.h @@ -19,6 +19,8 @@ #include +#include "qgis_core.h" + /** \ingroup core * Defines a qgis exception class. */ diff --git a/src/core/qgsexpression.cpp b/src/core/qgsexpression.cpp index c8614d10399..9e5790d168a 100644 --- a/src/core/qgsexpression.cpp +++ b/src/core/qgsexpression.cpp @@ -4511,7 +4511,7 @@ double QgsExpression::evaluateToDouble( const QString &text, const double fallba QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope(); + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ); QVariant result = expr.evaluate( &context ); convertedValue = result.toDouble( &ok ); @@ -5775,8 +5775,8 @@ void QgsExpression::initVariableHelp() gVariableHelpTexts.insert( QStringLiteral( "qgis_version" ), QCoreApplication::translate( "variable_help", "Current QGIS version string." ) ); gVariableHelpTexts.insert( QStringLiteral( "qgis_version_no" ), QCoreApplication::translate( "variable_help", "Current QGIS version number." ) ); gVariableHelpTexts.insert( QStringLiteral( "qgis_release_name" ), QCoreApplication::translate( "variable_help", "Current QGIS release name." ) ); - gVariableHelpTexts.insert( QStringLiteral( "qgis_os_name" ), QCoreApplication::translate( "variable_help", "Operating system name, eg 'windows', 'linux' or 'osx'." ) ); - gVariableHelpTexts.insert( QStringLiteral( "qgis_platform" ), QCoreApplication::translate( "variable_help", "QGIS platform, eg 'desktop' or 'server'." ) ); + gVariableHelpTexts.insert( QStringLiteral( "qgis_os_name" ), QCoreApplication::translate( "variable_help", "Operating system name, e.g., 'windows', 'linux' or 'osx'." ) ); + gVariableHelpTexts.insert( QStringLiteral( "qgis_platform" ), QCoreApplication::translate( "variable_help", "QGIS platform, e.g., 'desktop' or 'server'." ) ); gVariableHelpTexts.insert( QStringLiteral( "user_account_name" ), QCoreApplication::translate( "variable_help", "Current user's operating system account name." ) ); gVariableHelpTexts.insert( QStringLiteral( "user_full_name" ), QCoreApplication::translate( "variable_help", "Current user's operating system user name (if available)." ) ); @@ -5785,7 +5785,7 @@ void QgsExpression::initVariableHelp() gVariableHelpTexts.insert( QStringLiteral( "project_path" ), QCoreApplication::translate( "variable_help", "Full path (including file name) of current project." ) ); gVariableHelpTexts.insert( QStringLiteral( "project_folder" ), QCoreApplication::translate( "variable_help", "Folder for current project." ) ); gVariableHelpTexts.insert( QStringLiteral( "project_filename" ), QCoreApplication::translate( "variable_help", "Filename of current project." ) ); - gVariableHelpTexts.insert( QStringLiteral( "project_crs" ), QCoreApplication::translate( "variable_help", "Coordinate reference system of project (eg 'EPSG:4326')." ) ); + gVariableHelpTexts.insert( QStringLiteral( "project_crs" ), QCoreApplication::translate( "variable_help", "Coordinate reference system of project (e.g., 'EPSG:4326')." ) ); gVariableHelpTexts.insert( QStringLiteral( "project_crs_definition" ), QCoreApplication::translate( "variable_help", "Coordinate reference system of project (full definition)." ) ); //layer variables @@ -5828,7 +5828,7 @@ void QgsExpression::initVariableHelp() gVariableHelpTexts.insert( QStringLiteral( "row_number" ), QCoreApplication::translate( "variable_help", "Stores the number of the current row." ) ); gVariableHelpTexts.insert( QStringLiteral( "grid_number" ), QCoreApplication::translate( "variable_help", "Current grid annotation value." ) ); - gVariableHelpTexts.insert( QStringLiteral( "grid_axis" ), QCoreApplication::translate( "variable_help", "Current grid annotation axis (eg, 'x' for longitude, 'y' for latitude)." ) ); + gVariableHelpTexts.insert( QStringLiteral( "grid_axis" ), QCoreApplication::translate( "variable_help", "Current grid annotation axis (e.g., 'x' for longitude, 'y' for latitude)." ) ); //symbol variables gVariableHelpTexts.insert( QStringLiteral( "geometry_part_count" ), QCoreApplication::translate( "variable_help", "Number of parts in rendered feature's geometry." ) ); @@ -5905,6 +5905,10 @@ QString QgsExpression::formatPreviewString( const QVariant& value ) else return tr( "<geometry: %1>" ).arg( QgsWkbTypes::displayString( geom.geometry()->wkbType() ) ); } + else if ( !value.isValid() ) + { + return tr( "NULL" ); + } else if ( value.canConvert< QgsFeature >() ) { //result is a feature diff --git a/src/core/qgsexpression.h b/src/core/qgsexpression.h index 96b4cd91329..a90c44d6589 100644 --- a/src/core/qgsexpression.h +++ b/src/core/qgsexpression.h @@ -16,6 +16,7 @@ #ifndef QGSEXPRESSION_H #define QGSEXPRESSION_H +#include "qgis_core.h" #include #include #include @@ -276,7 +277,7 @@ class CORE_EXPORT QgsExpression */ void setGeomCalculator( const QgsDistanceArea* calc ); - /** Returns the desired distance units for calculations involving geomCalculator(), eg "$length" and "$perimeter". + /** Returns the desired distance units for calculations involving geomCalculator(), e.g., "$length" and "$perimeter". * @note distances are only converted when a geomCalculator() has been set * @note added in QGIS 2.14 * @see setDistanceUnits() @@ -284,7 +285,7 @@ class CORE_EXPORT QgsExpression */ QgsUnitTypes::DistanceUnit distanceUnits() const; - /** Sets the desired distance units for calculations involving geomCalculator(), eg "$length" and "$perimeter". + /** Sets the desired distance units for calculations involving geomCalculator(), e.g., "$length" and "$perimeter". * @note distances are only converted when a geomCalculator() has been set * @note added in QGIS 2.14 * @see distanceUnits() @@ -292,7 +293,7 @@ class CORE_EXPORT QgsExpression */ void setDistanceUnits( QgsUnitTypes::DistanceUnit unit ); - /** Returns the desired areal units for calculations involving geomCalculator(), eg "$area". + /** Returns the desired areal units for calculations involving geomCalculator(), e.g., "$area". * @note areas are only converted when a geomCalculator() has been set * @note added in QGIS 2.14 * @see setAreaUnits() @@ -300,7 +301,7 @@ class CORE_EXPORT QgsExpression */ QgsUnitTypes::AreaUnit areaUnits() const; - /** Sets the desired areal units for calculations involving geomCalculator(), eg "$area". + /** Sets the desired areal units for calculations involving geomCalculator(), e.g., "$area". * @note areas are only converted when a geomCalculator() has been set * @note added in QGIS 2.14 * @see areaUnits() @@ -534,7 +535,7 @@ class CORE_EXPORT QgsExpression , mIsContextual( isContextual ) {} - virtual ~Function() {} + virtual ~Function() = default; //! The name of the function. QString name() const { return mName; } @@ -566,7 +567,7 @@ class CORE_EXPORT QgsExpression virtual bool usesGeometry( const NodeFunction* node ) const; /** Returns a list of possible aliases for the function. These include - * other permissible names for the function, eg deprecated names. + * other permissible names for the function, e.g., deprecated names. * @return list of known aliases * @note added in QGIS 2.9 */ @@ -723,8 +724,6 @@ class CORE_EXPORT QgsExpression , mReferencedColumns( referencedColumns ) {} - virtual ~StaticFunction() {} - /** Returns result of evaluating the function. * @param values list of values passed to the function * @param context context expression is being evaluated against @@ -842,7 +841,7 @@ class CORE_EXPORT QgsExpression class CORE_EXPORT Node { public: - virtual ~Node() {} + virtual ~Node() = default; /** * Abstract virtual that returns the type of this node. @@ -1189,13 +1188,15 @@ class CORE_EXPORT QgsExpression {} ~WhenThen() { delete mWhenExp; delete mThenExp; } + //! WhenThen nodes cannot be copied. + WhenThen( const WhenThen& rh ) = delete; + //! WhenThen nodes cannot be copied. + WhenThen& operator=( const WhenThen& rh ) = delete; + // protected: Node* mWhenExp; Node* mThenExp; - private: - WhenThen( const WhenThen& rh ); - WhenThen& operator=( const WhenThen& rh ); }; typedef QList WhenThenList; @@ -1250,7 +1251,7 @@ class CORE_EXPORT QgsExpression static QString group( const QString& group ); /** Formats an expression result for friendly display to the user. Truncates the result to a sensible - * length, and presents text representations of non numeric/text types (eg geometries and features). + * length, and presents text representations of non numeric/text types (e.g., geometries and features). * @param value expression result to format * @returns formatted string, may contain HTML formatting characters * @note added in QGIS 2.14 diff --git a/src/core/qgsexpressioncontext.cpp b/src/core/qgsexpressioncontext.cpp index 91ea5ee44ba..3de75f51c78 100644 --- a/src/core/qgsexpressioncontext.cpp +++ b/src/core/qgsexpressioncontext.cpp @@ -209,6 +209,11 @@ void QgsExpressionContextScope::setFields( const QgsFields &fields ) // QgsExpressionContext // +QgsExpressionContext::QgsExpressionContext( const QList& scopes ) + : mStack( scopes ) +{ +} + QgsExpressionContext::QgsExpressionContext( const QgsExpressionContext& other ) { Q_FOREACH ( const QgsExpressionContextScope* scope, other.mStack ) @@ -423,6 +428,11 @@ void QgsExpressionContext::appendScope( QgsExpressionContextScope* scope ) mStack.append( scope ); } +void QgsExpressionContext::appendScopes( const QList& scopes ) +{ + mStack.append( scopes ); +} + QgsExpressionContextScope* QgsExpressionContext::popScope() { if ( !mStack.isEmpty() ) @@ -501,29 +511,11 @@ QgsExpressionContextScope* QgsExpressionContextUtils::globalScope() { QgsExpressionContextScope* scope = new QgsExpressionContextScope( QObject::tr( "Global" ) ); - //read values from QSettings - QSettings settings; + QVariantMap customVariables = QgsApplication::customVariables(); - //check if settings contains any variables - if ( settings.contains( QStringLiteral( "/variables/values" ) ) ) + for ( QVariantMap::const_iterator it = customVariables.constBegin(); it != customVariables.constEnd(); ++it ) { - QList< QVariant > customVariableVariants = settings.value( QStringLiteral( "/variables/values" ) ).toList(); - QList< QVariant > customVariableNames = settings.value( QStringLiteral( "/variables/names" ) ).toList(); - int variableIndex = 0; - for ( QList< QVariant >::const_iterator it = customVariableVariants.constBegin(); - it != customVariableVariants.constEnd(); ++it ) - { - if ( variableIndex >= customVariableNames.length() ) - { - break; - } - - QVariant value = ( *it ); - QString name = customVariableNames.at( variableIndex ).toString(); - - scope->setVariable( name, value ); - variableIndex++; - } + scope->setVariable( it.key(), it.value() ); } //add some extra global variables @@ -540,35 +532,12 @@ QgsExpressionContextScope* QgsExpressionContextUtils::globalScope() void QgsExpressionContextUtils::setGlobalVariable( const QString& name, const QVariant& value ) { - // save variable to settings - QSettings settings; - - QList< QVariant > customVariableVariants = settings.value( QStringLiteral( "/variables/values" ) ).toList(); - QList< QVariant > customVariableNames = settings.value( QStringLiteral( "/variables/names" ) ).toList(); - - customVariableVariants << value; - customVariableNames << name; - - settings.setValue( QStringLiteral( "/variables/names" ), customVariableNames ); - settings.setValue( QStringLiteral( "/variables/values" ), customVariableVariants ); + QgsApplication::setCustomVariable( name, value ); } -void QgsExpressionContextUtils::setGlobalVariables( const QgsStringMap &variables ) +void QgsExpressionContextUtils::setGlobalVariables( const QVariantMap &variables ) { - QSettings settings; - - QList< QVariant > customVariableVariants; - QList< QVariant > customVariableNames; - - QMap< QString, QString >::const_iterator it = variables.constBegin(); - for ( ; it != variables.constEnd(); ++it ) - { - customVariableNames << it.key(); - customVariableVariants << it.value(); - } - - settings.setValue( QStringLiteral( "/variables/names" ), customVariableNames ); - settings.setValue( QStringLiteral( "/variables/values" ), customVariableVariants ); + QgsApplication::setCustomVariables( variables ); } /// @cond PRIVATE @@ -576,12 +545,16 @@ void QgsExpressionContextUtils::setGlobalVariables( const QgsStringMap &variable class GetNamedProjectColor : public QgsScopedExpressionFunction { public: - GetNamedProjectColor() + GetNamedProjectColor( const QgsProject* project ) : QgsScopedExpressionFunction( QStringLiteral( "project_color" ), 1, QStringLiteral( "Color" ) ) + , mProject( project ) { + if ( !project ) + return; + //build up color list from project. Do this in advance for speed - QStringList colorStrings = QgsProject::instance()->readListEntry( QStringLiteral( "Palette" ), QStringLiteral( "/Colors" ) ); - QStringList colorLabels = QgsProject::instance()->readListEntry( QStringLiteral( "Palette" ), QStringLiteral( "/Labels" ) ); + QStringList colorStrings = project->readListEntry( QStringLiteral( "Palette" ), QStringLiteral( "/Colors" ) ); + QStringList colorLabels = project->readListEntry( QStringLiteral( "Palette" ), QStringLiteral( "/Labels" ) ); //generate list from custom colors int colorIndex = 0; @@ -613,26 +586,28 @@ class GetNamedProjectColor : public QgsScopedExpressionFunction QgsScopedExpressionFunction* clone() const override { - return new GetNamedProjectColor(); + return new GetNamedProjectColor( mProject ); } private: + const QgsProject* mProject = nullptr; QHash< QString, QColor > mColors; }; ///@endcond -QgsExpressionContextScope* QgsExpressionContextUtils::projectScope() +QgsExpressionContextScope* QgsExpressionContextUtils::projectScope( const QgsProject* project ) { - QgsProject* project = QgsProject::instance(); - QgsExpressionContextScope* scope = new QgsExpressionContextScope( QObject::tr( "Project" ) ); - const QgsStringMap vars = QgsProject::instance()->variables(); + if ( !project ) + return scope; - QgsStringMap::const_iterator it = vars.constBegin(); + const QVariantMap vars = project->customVariables(); + + QVariantMap::const_iterator it = vars.constBegin(); for ( ; it != vars.constEnd(); ++it ) { @@ -648,24 +623,28 @@ QgsExpressionContextScope* QgsExpressionContextUtils::projectScope() scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "project_crs" ), projectCrs.authid(), true ) ); scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "project_crs_definition" ), projectCrs.toProj4(), true ) ); - scope->addFunction( QStringLiteral( "project_color" ), new GetNamedProjectColor() ); + scope->addFunction( QStringLiteral( "project_color" ), new GetNamedProjectColor( project ) ); return scope; } -void QgsExpressionContextUtils::setProjectVariable( const QString& name, const QVariant& value ) +void QgsExpressionContextUtils::setProjectVariable( QgsProject* project, const QString& name, const QVariant& value ) { - QgsProject* project = QgsProject::instance(); + if ( !project ) + return; - QgsStringMap vars = project->variables(); + QVariantMap vars = project->customVariables(); - vars.insert( name, value.toString() ); + vars.insert( name, value ); - project->setVariables( vars ); + project->setCustomVariables( vars ); } -void QgsExpressionContextUtils::setProjectVariables( const QgsStringMap& variables ) +void QgsExpressionContextUtils::setProjectVariables( QgsProject* project, const QVariantMap& variables ) { - QgsProject::instance()->setVariables( variables ); + if ( !project ) + return; + + project->setCustomVariables( variables ); } QgsExpressionContextScope* QgsExpressionContextUtils::layerScope( const QgsMapLayer* layer ) @@ -709,6 +688,20 @@ QgsExpressionContextScope* QgsExpressionContextUtils::layerScope( const QgsMapLa return scope; } +QList QgsExpressionContextUtils::globalProjectLayerScopes( const QgsMapLayer* layer ) +{ + QList scopes; + scopes << globalScope(); + + QgsProject* project = QgsProject::instance(); // TODO: use project associated with layer + if ( project ) + scopes << projectScope( project ); + + if ( layer ) + scopes << layerScope( layer ); + return scopes; +} + void QgsExpressionContextUtils::setLayerVariable( QgsMapLayer* layer, const QString& name, const QVariant& value ) { if ( !layer ) @@ -725,7 +718,7 @@ void QgsExpressionContextUtils::setLayerVariable( QgsMapLayer* layer, const QStr layer->setCustomProperty( QStringLiteral( "variableValues" ), variableValues ); } -void QgsExpressionContextUtils::setLayerVariables( QgsMapLayer* layer, const QgsStringMap& variables ) +void QgsExpressionContextUtils::setLayerVariables( QgsMapLayer* layer, const QVariantMap& variables ) { if ( !layer ) return; @@ -733,11 +726,11 @@ void QgsExpressionContextUtils::setLayerVariables( QgsMapLayer* layer, const Qgs QStringList variableNames; QStringList variableValues; - QMap< QString, QString >::const_iterator it = variables.constBegin(); + QVariantMap::const_iterator it = variables.constBegin(); for ( ; it != variables.constEnd(); ++it ) { variableNames << it.key(); - variableValues << it.value(); + variableValues << it.value().toString(); } layer->setCustomProperty( QStringLiteral( "variableNames" ), variableNames ); @@ -831,7 +824,7 @@ void QgsExpressionContextUtils::setCompositionVariable( QgsComposition* composit composition->setCustomProperty( QStringLiteral( "variableValues" ), variableValues ); } -void QgsExpressionContextUtils::setCompositionVariables( QgsComposition* composition, const QgsStringMap& variables ) +void QgsExpressionContextUtils::setCompositionVariables( QgsComposition* composition, const QVariantMap& variables ) { if ( !composition ) return; @@ -839,11 +832,11 @@ void QgsExpressionContextUtils::setCompositionVariables( QgsComposition* composi QStringList variableNames; QStringList variableValues; - QMap< QString, QString >::const_iterator it = variables.constBegin(); + QVariantMap::const_iterator it = variables.constBegin(); for ( ; it != variables.constEnd(); ++it ) { variableNames << it.key(); - variableValues << it.value(); + variableValues << it.value().toString(); } composition->setCustomProperty( QStringLiteral( "variableNames" ), variableNames ); @@ -934,7 +927,7 @@ void QgsExpressionContextUtils::setComposerItemVariable( QgsComposerItem* compos composerItem->setCustomProperty( QStringLiteral( "variableValues" ), variableValues ); } -void QgsExpressionContextUtils::setComposerItemVariables( QgsComposerItem* composerItem, const QgsStringMap& variables ) +void QgsExpressionContextUtils::setComposerItemVariables( QgsComposerItem* composerItem, const QVariantMap& variables ) { if ( !composerItem ) return; @@ -942,11 +935,11 @@ void QgsExpressionContextUtils::setComposerItemVariables( QgsComposerItem* compo QStringList variableNames; QStringList variableValues; - QMap< QString, QString >::const_iterator it = variables.constBegin(); + QVariantMap::const_iterator it = variables.constBegin(); for ( ; it != variables.constEnd(); ++it ) { variableNames << it.key(); - variableValues << it.value(); + variableValues << it.value().toString(); } composerItem->setCustomProperty( QStringLiteral( "variableNames" ), variableNames ); @@ -963,7 +956,7 @@ QgsExpressionContext QgsExpressionContextUtils::createFeatureBasedContext( const void QgsExpressionContextUtils::registerContextFunctions() { - QgsExpression::registerFunction( new GetNamedProjectColor() ); + QgsExpression::registerFunction( new GetNamedProjectColor( nullptr ) ); } bool QgsScopedExpressionFunction::usesGeometry( const QgsExpression::NodeFunction* node ) const diff --git a/src/core/qgsexpressioncontext.h b/src/core/qgsexpressioncontext.h index c2a73db1301..a2367b2991f 100644 --- a/src/core/qgsexpressioncontext.h +++ b/src/core/qgsexpressioncontext.h @@ -15,6 +15,7 @@ #ifndef QGSEXPRESSIONCONTEXT_H #define QGSEXPRESSIONCONTEXT_H +#include "qgis_core.h" #include #include #include @@ -28,6 +29,7 @@ class QgsComposition; class QgsComposerItem; class QgsAtlasComposition; class QgsMapSettings; +class QgsProject; class QgsSymbol; /** \ingroup core @@ -61,8 +63,6 @@ class CORE_EXPORT QgsScopedExpressionFunction : public QgsExpression::Function , mReferencedColumns( referencedColumns ) {} - virtual ~QgsScopedExpressionFunction() {} - virtual QVariant func( const QVariantList& values, const QgsExpressionContext* context, QgsExpression* parent ) override = 0; /** Returns a clone of the function. @@ -269,6 +269,12 @@ class CORE_EXPORT QgsExpressionContext QgsExpressionContext() {} + /** Initializes the context with given list of scopes. + * Ownership of the scopes is transferred to the stack. + * @note added in QGIS 3.0 + */ + explicit QgsExpressionContext( const QList& scopes ); + /** Copy constructor */ QgsExpressionContext( const QgsExpressionContext& other ); @@ -415,6 +421,14 @@ class CORE_EXPORT QgsExpressionContext */ void appendScope( QgsExpressionContextScope* scope ); + /** Appends a list of scopes to the end of the context. This scopes will override + * any matching variables or functions provided by existing scopes within the + * context. Ownership of the scopes is transferred to the stack. + * @param scopes scopes to append to context + * @note added in QGIS 3.0 + */ + void appendScopes( const QList& scopes ); + /** * Removes the last scope from the expression context and return it. */ @@ -535,7 +549,7 @@ class CORE_EXPORT QgsExpressionContext /** \ingroup core * \class QgsExpressionContextUtils * \brief Contains utilities for working with QgsExpressionContext objects, including methods - * for creating scopes for specific uses (eg project scopes, layer scopes). + * for creating scopes for specific uses (e.g., project scopes, layer scopes). * \note added in QGIS 2.12 */ @@ -564,36 +578,44 @@ class CORE_EXPORT QgsExpressionContextUtils * @see setGlobalVariable() * @see globalScope() */ - static void setGlobalVariables( const QgsStringMap& variables ); + static void setGlobalVariables( const QVariantMap& variables ); - /** Creates a new scope which contains variables and functions relating to the current QGIS project. + /** Creates a new scope which contains variables and functions relating to a QGIS project. * For instance, project path and title, and variables specified through the project properties. + * @param project What project to use * @see setProjectVariable() */ - static QgsExpressionContextScope* projectScope(); + static QgsExpressionContextScope* projectScope( const QgsProject* project ); /** Sets a project context variable. This variable will be contained within scopes retrieved via * projectScope(). + * @param project Project to apply changes to * @param name variable name * @param value variable value * @see setProjectVariables() * @see projectScope() */ - static void setProjectVariable( const QString& name, const QVariant& value ); + static void setProjectVariable( QgsProject* project, const QString& name, const QVariant& value ); /** Sets all project context variables. Existing project variables will be removed and replaced * with the variables specified. + * @param project Project to apply changes to * @param variables new set of project variables * @see setProjectVariable() * @see projectScope() */ - static void setProjectVariables( const QgsStringMap& variables ); + static void setProjectVariables( QgsProject* project, const QVariantMap& variables ); /** Creates a new scope which contains variables and functions relating to a QgsMapLayer. * For instance, layer name, id and fields. */ static QgsExpressionContextScope* layerScope( const QgsMapLayer* layer ); + /** Creates a list of three scopes: global, layer's project and layer. + * @note added in QGIS 3.0 + */ + static QList globalProjectLayerScopes( const QgsMapLayer* layer ); + /** Sets a layer context variable. This variable will be contained within scopes retrieved via * layerScope(). * @param layer map layer @@ -611,7 +633,7 @@ class CORE_EXPORT QgsExpressionContextUtils * @see setLayerVariable() * @see layerScope() */ - static void setLayerVariables( QgsMapLayer* layer, const QgsStringMap& variables ); + static void setLayerVariables( QgsMapLayer* layer, const QVariantMap& variables ); /** Creates a new scope which contains variables and functions relating to a QgsMapSettings object. * For instance, map scale and rotation. @@ -649,7 +671,7 @@ class CORE_EXPORT QgsExpressionContextUtils * @see setCompositionVariable() * @see compositionScope() */ - static void setCompositionVariables( QgsComposition* composition, const QgsStringMap& variables ); + static void setCompositionVariables( QgsComposition* composition, const QVariantMap& variables ); /** Creates a new scope which contains variables and functions relating to a QgsAtlasComposition. * For instance, current page name and number. @@ -680,7 +702,7 @@ class CORE_EXPORT QgsExpressionContextUtils * @see setComposerItemVariable() * @see composerItemScope() */ - static void setComposerItemVariables( QgsComposerItem* composerItem, const QgsStringMap& variables ); + static void setComposerItemVariables( QgsComposerItem* composerItem, const QVariantMap& variables ); /** Helper function for creating an expression context which contains just a feature and fields * collection. Generally this method should not be used as the created context does not include diff --git a/src/core/qgsexpressioncontextgenerator.h b/src/core/qgsexpressioncontextgenerator.h index c84fb61ae00..365a1aee0ee 100644 --- a/src/core/qgsexpressioncontextgenerator.h +++ b/src/core/qgsexpressioncontextgenerator.h @@ -45,7 +45,7 @@ class QgsExpressionContextGenerator */ virtual QgsExpressionContext createExpressionContext() const = 0; - virtual ~QgsExpressionContextGenerator() {} + virtual ~QgsExpressionContextGenerator() = default; }; #endif // QGSEXPRESSIONCONTEXTGENERATOR_H diff --git a/src/core/qgsexpressionfieldbuffer.h b/src/core/qgsexpressionfieldbuffer.h index b73c4bd5f37..626ab84fc45 100644 --- a/src/core/qgsexpressionfieldbuffer.h +++ b/src/core/qgsexpressionfieldbuffer.h @@ -18,6 +18,7 @@ #ifndef QGSEXPRESSIONFIELDBUFFER_H #define QGSEXPRESSIONFIELDBUFFER_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/qgsfeature.h b/src/core/qgsfeature.h index 0c2d51b796e..2ae8557d0d0 100644 --- a/src/core/qgsfeature.h +++ b/src/core/qgsfeature.h @@ -16,6 +16,7 @@ email : sherman at mrcc.com #ifndef QGSFEATURE_H #define QGSFEATURE_H +#include "qgis_core.h" #include #include #include @@ -172,7 +173,7 @@ class CORE_EXPORT QgsFeature bool operator!=( const QgsFeature& other ) const; - //! Destructor + virtual ~QgsFeature(); /** Get the feature ID for this feature. diff --git a/src/core/qgsfeaturefilterprovider.h b/src/core/qgsfeaturefilterprovider.h index 66743ec8046..1a4c3ff0bc5 100644 --- a/src/core/qgsfeaturefilterprovider.h +++ b/src/core/qgsfeaturefilterprovider.h @@ -20,6 +20,8 @@ #include +#include "qgis_core.h" + class QString; class QgsVectorLayer; class QgsFeatureRequest; @@ -40,8 +42,7 @@ class CORE_EXPORT QgsFeatureFilterProvider //! Constructor QgsFeatureFilterProvider() {} - //! Destructor - virtual ~QgsFeatureFilterProvider() {} + virtual ~QgsFeatureFilterProvider() = default; /** Add additional filters to the feature request to further restrict the features returned by the request. * Derived classes must implement this method. diff --git a/src/core/qgsfeatureiterator.cpp b/src/core/qgsfeatureiterator.cpp index 53a2640e950..e4ba2b0b405 100644 --- a/src/core/qgsfeatureiterator.cpp +++ b/src/core/qgsfeatureiterator.cpp @@ -30,10 +30,6 @@ QgsAbstractFeatureIterator::QgsAbstractFeatureIterator( const QgsFeatureRequest& { } -QgsAbstractFeatureIterator::~QgsAbstractFeatureIterator() -{ -} - bool QgsAbstractFeatureIterator::nextFeature( QgsFeature& f ) { bool dataOk = false; diff --git a/src/core/qgsfeatureiterator.h b/src/core/qgsfeatureiterator.h index 9bc11ff1d9f..f69e1ebfdc7 100644 --- a/src/core/qgsfeatureiterator.h +++ b/src/core/qgsfeatureiterator.h @@ -15,6 +15,7 @@ #ifndef QGSFEATUREITERATOR_H #define QGSFEATUREITERATOR_H +#include "qgis_core.h" #include "qgsfeaturerequest.h" #include "qgsindexedfeature.h" @@ -51,7 +52,7 @@ class CORE_EXPORT QgsAbstractFeatureIterator QgsAbstractFeatureIterator( const QgsFeatureRequest& request ); //! destructor makes sure that the iterator is closed properly - virtual ~QgsAbstractFeatureIterator(); + virtual ~QgsAbstractFeatureIterator() = default; //! fetch next feature, return true on success virtual bool nextFeature( QgsFeature& f ); diff --git a/src/core/qgsfeaturerequest.h b/src/core/qgsfeaturerequest.h index 25158e7919a..761c795bc4e 100644 --- a/src/core/qgsfeaturerequest.h +++ b/src/core/qgsfeaturerequest.h @@ -15,6 +15,7 @@ #ifndef QGSFEATUREREQUEST_H #define QGSFEATUREREQUEST_H +#include "qgis_core.h" #include #include diff --git a/src/core/qgsfeaturestore.h b/src/core/qgsfeaturestore.h index 640716f2557..eb23c776162 100644 --- a/src/core/qgsfeaturestore.h +++ b/src/core/qgsfeaturestore.h @@ -15,6 +15,7 @@ #ifndef QGSFEATURESTORE_H #define QGSFEATURESTORE_H +#include "qgis_core.h" #include "qgis.h" #include "qgsfeature.h" #include "qgsfields.h" diff --git a/src/core/qgsfeedback.h b/src/core/qgsfeedback.h index d86e96394c5..2a843d74b6a 100644 --- a/src/core/qgsfeedback.h +++ b/src/core/qgsfeedback.h @@ -18,6 +18,8 @@ #include +#include "qgis_core.h" + /** \ingroup core * Base class for feedback objects to be used for cancellation of something running in a worker thread. * The class may be used as is or it may be subclassed for extended functionality @@ -47,8 +49,6 @@ class CORE_EXPORT QgsFeedback : public QObject , mCancelled( false ) {} - virtual ~QgsFeedback() {} - //! Tells the internal routines that the current operation should be cancelled. This should be run by the main thread void cancel() { diff --git a/src/core/qgsfield.cpp b/src/core/qgsfield.cpp index 5cfa7a633a1..41f6ecfcba6 100644 --- a/src/core/qgsfield.cpp +++ b/src/core/qgsfield.cpp @@ -37,7 +37,7 @@ QgsField::QgsField( QString nam, QString typ, int len, int prec, bool num, , mComment( comment ) { // This function used to lower case the field name since some stores - // use upper case (eg. shapefiles), but that caused problems with + // use upper case (e.g., shapefiles), but that caused problems with // attribute actions getting confused between uppercase and // lowercase versions of the attribute names, so just leave the // names how they are now. @@ -68,10 +68,6 @@ QgsField &QgsField::operator =( const QgsField & other ) return *this; } -QgsField::~QgsField() -{ -} - bool QgsField::operator==( const QgsField& other ) const { return *( other.d ) == *d; diff --git a/src/core/qgsfield.h b/src/core/qgsfield.h index 7fa1d4bd1d2..fa46998fa72 100644 --- a/src/core/qgsfield.h +++ b/src/core/qgsfield.h @@ -20,13 +20,11 @@ #include #include #include +#include "qgsfield_p.h" +#include "qgis_core.h" typedef QList QgsAttributeList; -class QgsExpression; -class QgsFieldPrivate; -class QgsFieldsPrivate; - /*************************************************************************** * This class is considered CRITICAL and any change MUST be accompanied with * full unit tests in testqgsfield.cpp. @@ -62,12 +60,12 @@ class CORE_EXPORT QgsField /** Constructor. Constructs a new QgsField object. * @param name Field name * @param type Field variant type, currently supported: String / Int / Double - * @param typeName Field type (eg. char, varchar, text, int, serial, double). + * @param typeName Field type (e.g., char, varchar, text, int, serial, double). * Field types are usually unique to the source and are stored exactly * as returned from the data store. * @param len Field length * @param prec Field precision. Usually decimal places but may also be - * used in conjunction with other fields types (eg. variable character fields) + * used in conjunction with other fields types (e.g., variable character fields) * @param comment Comment for the field * @param subType If the field is a collection, its element's type. When * all the elements don't need to have the same type, leave @@ -89,8 +87,7 @@ class CORE_EXPORT QgsField */ QgsField& operator =( const QgsField &other ); - //! Destructor - virtual ~QgsField(); + virtual ~QgsField() = default; bool operator==( const QgsField& other ) const; bool operator!=( const QgsField& other ) const; diff --git a/src/core/qgsfield_p.h b/src/core/qgsfield_p.h index 1f56e0bf9d6..3ea436bcf42 100644 --- a/src/core/qgsfield_p.h +++ b/src/core/qgsfield_p.h @@ -28,6 +28,7 @@ // #include "qgsfieldconstraints.h" +#include "qgseditorwidgetsetup.h" #include #include #include diff --git a/src/core/qgsfieldconstraints.h b/src/core/qgsfieldconstraints.h index 03d92e94c5e..04d62513cdd 100644 --- a/src/core/qgsfieldconstraints.h +++ b/src/core/qgsfieldconstraints.h @@ -20,6 +20,8 @@ #include #include +#include "qgis_core.h" + /** * \class QgsFieldConstraints * \ingroup core diff --git a/src/core/qgsfieldformatter.cpp b/src/core/qgsfieldformatter.cpp index be8cbc55cf4..3831b0c1c19 100644 --- a/src/core/qgsfieldformatter.cpp +++ b/src/core/qgsfieldformatter.cpp @@ -23,10 +23,6 @@ QgsFieldFormatter::QgsFieldFormatter() { } -QgsFieldFormatter::~QgsFieldFormatter() -{ -} - QString QgsFieldFormatter::representValue( QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const { Q_UNUSED( layer ) diff --git a/src/core/qgsfieldformatter.h b/src/core/qgsfieldformatter.h index 2122cd72e49..0601ae8ea76 100644 --- a/src/core/qgsfieldformatter.h +++ b/src/core/qgsfieldformatter.h @@ -19,6 +19,8 @@ #include #include +#include "qgis_core.h" + class QgsVectorLayer; /** @@ -40,7 +42,7 @@ class CORE_EXPORT QgsFieldFormatter public: QgsFieldFormatter(); - virtual ~QgsFieldFormatter(); + virtual ~QgsFieldFormatter() = default; /** * Return a unique id for this field formatter. diff --git a/src/core/qgsfieldformatterregistry.h b/src/core/qgsfieldformatterregistry.h index d0b4886c729..68548e91fe4 100644 --- a/src/core/qgsfieldformatterregistry.h +++ b/src/core/qgsfieldformatterregistry.h @@ -20,6 +20,8 @@ #include #include +#include "qgis_core.h" + class QgsFieldFormatter; /** diff --git a/src/core/qgsfields.cpp b/src/core/qgsfields.cpp index 8287e34ef21..358d5a79c0c 100644 --- a/src/core/qgsfields.cpp +++ b/src/core/qgsfields.cpp @@ -42,9 +42,7 @@ QgsFields& QgsFields::operator =( const QgsFields & other ) } QgsFields::~QgsFields() -{ - -} +{} void QgsFields::clear() { diff --git a/src/core/qgsfields.h b/src/core/qgsfields.h index a4227a4a308..d8e13684ccc 100644 --- a/src/core/qgsfields.h +++ b/src/core/qgsfields.h @@ -16,8 +16,11 @@ #ifndef QGSFIELDS_H #define QGSFIELDS_H +#include "qgis_core.h" #include "qgsfield.h" +class QgsFieldsPrivate; + /*************************************************************************** * This class is considered CRITICAL and any change MUST be accompanied with * full unit tests in testqgsfields.cpp. diff --git a/src/core/qgsfields_p.h b/src/core/qgsfields_p.h index a383cfe6a87..06f0db69970 100644 --- a/src/core/qgsfields_p.h +++ b/src/core/qgsfields_p.h @@ -28,6 +28,7 @@ // version without notice, or even be removed. // +#include "qgis_core.h" #include #include "qgsfields.h" diff --git a/src/core/qgsfontutils.h b/src/core/qgsfontutils.h index 6c39c940b1d..82918d574b3 100644 --- a/src/core/qgsfontutils.h +++ b/src/core/qgsfontutils.h @@ -20,6 +20,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * \class QgsFontUtils */ @@ -138,9 +140,9 @@ class CORE_EXPORT QgsFontUtils * @param font QFont to convert * @param pointToPixelMultiplier scaling factor to apply to convert point sizes to pixel font sizes. * The CSS returned by this function will always use pixels for font sizes, so this parameter - * should be set to a suitable value to convert point sizes to pixels (eg taking into account + * should be set to a suitable value to convert point sizes to pixels (e.g., taking into account * desination DPI) - * @returns partial CSS string, eg "font-family: Comic Sans; font-size: 12px;" + * @returns partial CSS string, e.g., "font-family: Comic Sans; font-size: 12px;" * @note added in QGIS 2.16 */ static QString asCSS( const QFont& font, double pointToPixelMultiplier = 1.0 ); diff --git a/src/core/qgsgeometrycache.h b/src/core/qgsgeometrycache.h index edc27461ff2..32e64a8c663 100644 --- a/src/core/qgsgeometrycache.h +++ b/src/core/qgsgeometrycache.h @@ -15,6 +15,7 @@ #ifndef QGSGEOMETRYCACHE_H #define QGSGEOMETRYCACHE_H +#include "qgis_core.h" #include "qgsgeometry.h" #include "qgsfeature.h" #include "qgsrectangle.h" diff --git a/src/core/qgsgeometrysimplifier.cpp b/src/core/qgsgeometrysimplifier.cpp index bb2f430dd61..c3602c9cfe9 100644 --- a/src/core/qgsgeometrysimplifier.cpp +++ b/src/core/qgsgeometrysimplifier.cpp @@ -19,17 +19,11 @@ #include "qgsrectangle.h" #include "qgsgeometry.h" -QgsAbstractGeometrySimplifier::~QgsAbstractGeometrySimplifier() -{ -} - -//! Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance bool QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol ) { return ( envelope.xMaximum() - envelope.xMinimum() ) < mapToPixelTol && ( envelope.yMaximum() - envelope.yMinimum() ) < mapToPixelTol; } -//! Returns whether the device-geometry can be replaced by its BBOX when is applied the specified tolerance bool QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( const QVector& points, float mapToPixelTol ) { QgsRectangle r; @@ -44,17 +38,10 @@ bool QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( const QV /***************************************************************************/ -/** - * Implementation of GeometrySimplifier using the Douglas-Peucker algorithm - */ QgsTopologyPreservingSimplifier::QgsTopologyPreservingSimplifier( double tolerance ) : mTolerance( tolerance ) { } -QgsTopologyPreservingSimplifier::~QgsTopologyPreservingSimplifier() -{ -} -//! Returns a simplified version the specified geometry QgsGeometry QgsTopologyPreservingSimplifier::simplify( const QgsGeometry& geometry ) const { return geometry.simplify( mTolerance ); diff --git a/src/core/qgsgeometrysimplifier.h b/src/core/qgsgeometrysimplifier.h index cb891d23e27..0efa60517b1 100644 --- a/src/core/qgsgeometrysimplifier.h +++ b/src/core/qgsgeometrysimplifier.h @@ -23,13 +23,15 @@ class QgsGeometry; class QgsRectangle; +#include "qgis_core.h" + /** \ingroup core * Abstract base class for simplify geometries using a specific algorithm */ class CORE_EXPORT QgsAbstractGeometrySimplifier { public: - virtual ~QgsAbstractGeometrySimplifier(); + virtual ~QgsAbstractGeometrySimplifier() = default; //! Returns a simplified version the specified geometry virtual QgsGeometry simplify( const QgsGeometry& geometry ) const = 0; @@ -53,10 +55,13 @@ class CORE_EXPORT QgsAbstractGeometrySimplifier class CORE_EXPORT QgsTopologyPreservingSimplifier : public QgsAbstractGeometrySimplifier { public: - QgsTopologyPreservingSimplifier( double tolerance ); - virtual ~QgsTopologyPreservingSimplifier(); - //! Returns a simplified version the specified geometry + /** + * Constructor for QgsTopologyPreservingSimplifier. The tolerance parameter + * is specified in layer units. + */ + QgsTopologyPreservingSimplifier( double tolerance ); + virtual QgsGeometry simplify( const QgsGeometry& geometry ) const override; protected: diff --git a/src/core/qgsgeometryvalidator.h b/src/core/qgsgeometryvalidator.h index 4f6c227df58..61960c79598 100644 --- a/src/core/qgsgeometryvalidator.h +++ b/src/core/qgsgeometryvalidator.h @@ -16,6 +16,7 @@ email : jef at norbit dot de #ifndef QGSGEOMETRYVALIDATOR_H #define QGSGEOMETRYVALIDATOR_H +#include "qgis_core.h" #include #include "qgsgeometry.h" diff --git a/src/core/qgsgml.cpp b/src/core/qgsgml.cpp index 95f4abaaec2..b6d9fa38dcb 100644 --- a/src/core/qgsgml.cpp +++ b/src/core/qgsgml.cpp @@ -55,10 +55,6 @@ QgsGml::QgsGml( } } -QgsGml::~QgsGml() -{ -} - int QgsGml::getFeatures( const QString& uri, QgsWkbTypes::Type* wkbType, QgsRectangle* extent, const QString& userName, const QString& password , const QString& authcfg ) { //start with empty extent @@ -872,11 +868,7 @@ void QgsGmlStreamingParser::endElement( const XML_Char* el ) { const int wkbSize = OGR_G_WkbSize( hGeom ); unsigned char* pabyBuffer = new unsigned char[ wkbSize ]; -#if GDAL_VERSION_MAJOR >= 2 OGR_G_ExportToIsoWkb( hGeom, wkbNDR, pabyBuffer ); -#else - OGR_G_ExportToWkb( hGeom, wkbNDR, pabyBuffer ); -#endif QgsGeometry g; g.fromWkb( pabyBuffer, wkbSize ); if ( mInvertAxisOrientation ) diff --git a/src/core/qgsgml.h b/src/core/qgsgml.h index cc801e83ab3..f3be1f9c289 100644 --- a/src/core/qgsgml.h +++ b/src/core/qgsgml.h @@ -15,6 +15,7 @@ #ifndef QGSGML_H #define QGSGML_H +#include "qgis_core.h" #include #include "qgis.h" #include "qgsfields.h" @@ -88,6 +89,11 @@ class CORE_EXPORT QgsGmlStreamingParser bool invertAxisOrientation = false ); ~QgsGmlStreamingParser(); + //! QgsGmlStreamingParser cannot be copied. + QgsGmlStreamingParser( const QgsGmlStreamingParser& other ) = delete; + //! QgsGmlStreamingParser cannot be copied. + QgsGmlStreamingParser& operator=( const QgsGmlStreamingParser& other ) = delete; + /** Process a new chunk of data. atEnd must be set to true when this is the last chunk of data. */ bool processData( const QByteArray& data, bool atEnd, QString& errorMsg ); @@ -131,9 +137,6 @@ class CORE_EXPORT QgsGmlStreamingParser private: - QgsGmlStreamingParser( const QgsGmlStreamingParser& other ); - QgsGmlStreamingParser& operator=( const QgsGmlStreamingParser& other ); - enum ParseMode { none, @@ -335,8 +338,6 @@ class CORE_EXPORT QgsGml : public QObject const QString& geometryAttribute, const QgsFields & fields ); - ~QgsGml(); - /** Does the Http GET request to the wfs server * Supports only UTF-8, UTF-16, ISO-8859-1, ISO-8859-1 XML encodings. * @param uri GML URL diff --git a/src/core/qgsgmlschema.cpp b/src/core/qgsgmlschema.cpp index 1026305f5b9..d3a05296d18 100644 --- a/src/core/qgsgmlschema.cpp +++ b/src/core/qgsgmlschema.cpp @@ -65,11 +65,6 @@ QgsGmlSchema::QgsGmlSchema() << QStringLiteral( "Polygon" ) << QStringLiteral( "MultiPolygon" ); } -QgsGmlSchema::~QgsGmlSchema() -{ - -} - QString QgsGmlSchema::readAttribute( const QString& attributeName, const XML_Char** attr ) const { int i = 0; diff --git a/src/core/qgsgmlschema.h b/src/core/qgsgmlschema.h index 4c893da8e75..391c3304338 100644 --- a/src/core/qgsgmlschema.h +++ b/src/core/qgsgmlschema.h @@ -15,6 +15,7 @@ #ifndef QGSGMLSCHEMA_H #define QGSGMLSCHEMA_H +#include "qgis_core.h" #include #include "qgis.h" #include "qgserror.h" @@ -78,8 +79,6 @@ class CORE_EXPORT QgsGmlSchema : public QObject public: QgsGmlSchema(); - ~QgsGmlSchema(); - //! Get fields info from XSD bool parseXSD( const QByteArray &xml ); diff --git a/src/core/qgshistogram.cpp b/src/core/qgshistogram.cpp index 0bee53c301f..2d65cf07d55 100644 --- a/src/core/qgshistogram.cpp +++ b/src/core/qgshistogram.cpp @@ -29,11 +29,6 @@ QgsHistogram::QgsHistogram() } -QgsHistogram::~QgsHistogram() -{ - -} - void QgsHistogram::prepareValues() { qSort( mValues.begin(), mValues.end() ); diff --git a/src/core/qgshistogram.h b/src/core/qgshistogram.h index eacd92ca57d..7505de49364 100644 --- a/src/core/qgshistogram.h +++ b/src/core/qgshistogram.h @@ -20,6 +20,8 @@ #include +#include "qgis_core.h" + class QgsVectorLayer; @@ -36,7 +38,7 @@ class CORE_EXPORT QgsHistogram QgsHistogram(); - virtual ~QgsHistogram(); + virtual ~QgsHistogram() = default; /** Assigns numeric source values for the histogram. * @param values list of doubles diff --git a/src/core/qgsinterval.h b/src/core/qgsinterval.h index 5e11cd3b2c4..c68e28c0fdb 100644 --- a/src/core/qgsinterval.h +++ b/src/core/qgsinterval.h @@ -23,6 +23,9 @@ ****************************************************************************/ #include + +#include "qgis_core.h" + class QString; /** \ingroup core diff --git a/src/core/qgsjsonutils.h b/src/core/qgsjsonutils.h index 6074bcd3de0..9dca5a1bcb5 100644 --- a/src/core/qgsjsonutils.h +++ b/src/core/qgsjsonutils.h @@ -16,6 +16,7 @@ #ifndef QGSJSONUTILS_H #define QGSJSONUTILS_H +#include "qgis_core.h" #include "qgsfeature.h" #include "qgscoordinatereferencesystem.h" #include "qgscoordinatetransform.h" diff --git a/src/core/qgslabelfeature.h b/src/core/qgslabelfeature.h index d9442b36d32..8024935b028 100644 --- a/src/core/qgslabelfeature.h +++ b/src/core/qgslabelfeature.h @@ -1,6 +1,7 @@ #ifndef QGSLABELFEATURE_H #define QGSLABELFEATURE_H +#include "qgis_core.h" #include "qgspallabeling.h" #include "geos_c.h" @@ -92,7 +93,7 @@ class CORE_EXPORT QgsLabelFeature GEOSGeometry* geometry() const { return mGeometry; } /** Sets the label's obstacle geometry, if different to the feature geometry. - * This can be used to override the shape of the feature for obstacle detection, eg to + * This can be used to override the shape of the feature for obstacle detection, e.g., to * buffer around a point geometry to prevent labels being placed too close to the * point itself. It not set, the feature's geometry is used for obstacle detection. * Ownership of obstacle geometry is transferred. diff --git a/src/core/qgslabelingengine.h b/src/core/qgslabelingengine.h index 5e8bd6fd4c1..6a9550a983e 100644 --- a/src/core/qgslabelingengine.h +++ b/src/core/qgslabelingengine.h @@ -16,6 +16,7 @@ #ifndef QGSLABELINGENGINEV2_H #define QGSLABELINGENGINEV2_H +#include "qgis_core.h" #include "qgsmapsettings.h" #include "qgspallabeling.h" @@ -43,8 +44,8 @@ class CORE_EXPORT QgsAbstractLabelProvider public: //! Construct the provider with default values QgsAbstractLabelProvider( const QString& layerId = QString(), const QString& providerId = QString() ); - //! Vritual destructor - virtual ~QgsAbstractLabelProvider() {} + + virtual ~QgsAbstractLabelProvider() = default; //! Associate provider with a labeling engine (should be only called internally from QgsLabelingEngine) void setEngine( const QgsLabelingEngine* engine ) { mEngine = engine; } @@ -165,6 +166,11 @@ class CORE_EXPORT QgsLabelingEngine //! Clean up everything (especially the registered providers) ~QgsLabelingEngine(); + //! QgsLabelingEngine cannot be copied. + QgsLabelingEngine( const QgsLabelingEngine& rh ) = delete; + //! QgsLabelingEngine cannot be copied. + QgsLabelingEngine& operator=( const QgsLabelingEngine& rh ) = delete; + enum Flag { UseAllLabels = 1 << 1, //!< Whether to draw all labels even if there would be collisions @@ -238,10 +244,6 @@ class CORE_EXPORT QgsLabelingEngine //! Resulting labeling layout QgsLabelingResults* mResults; - private: - - QgsLabelingEngine( const QgsLabelingEngine& rh ); - QgsLabelingEngine& operator=( const QgsLabelingEngine& rh ); }; Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLabelingEngine::Flags ) diff --git a/src/core/qgslabelsearchtree.h b/src/core/qgslabelsearchtree.h index 1fb3e6f5319..c43e74749c0 100644 --- a/src/core/qgslabelsearchtree.h +++ b/src/core/qgslabelsearchtree.h @@ -19,6 +19,7 @@ #ifndef QGSLABELSEARCHTREE_H #define QGSLABELSEARCHTREE_H +#include "qgis_core.h" #include #include #include @@ -36,6 +37,11 @@ class CORE_EXPORT QgsLabelSearchTree QgsLabelSearchTree(); ~QgsLabelSearchTree(); + //! QgsLabelSearchTree cannot be copied. + QgsLabelSearchTree( const QgsLabelSearchTree& rh ) = delete; + //! QgsLabelSearchTree cannot be copied. + QgsLabelSearchTree& operator=( const QgsLabelSearchTree& rh ) = delete; + //! Removes and deletes all the entries void clear(); @@ -62,8 +68,6 @@ class CORE_EXPORT QgsLabelSearchTree mutable pal::RTree mSpatialIndex; QList< QgsLabelPosition* > mOwnedPositions; - QgsLabelSearchTree( const QgsLabelSearchTree& rh ); - QgsLabelSearchTree& operator=( const QgsLabelSearchTree& rh ); }; #endif // QGSLABELTREE_H diff --git a/src/core/qgslayerdefinition.h b/src/core/qgslayerdefinition.h index 519980c2a19..db3260625be 100644 --- a/src/core/qgslayerdefinition.h +++ b/src/core/qgslayerdefinition.h @@ -16,6 +16,7 @@ #define QGSLAYERDEFINITION_H +#include "qgis_core.h" #include class QgsLayerTreeGroup; diff --git a/src/core/qgslegendrenderer.h b/src/core/qgslegendrenderer.h index bee60f2cc03..26b9117a8d3 100644 --- a/src/core/qgslegendrenderer.h +++ b/src/core/qgslegendrenderer.h @@ -16,6 +16,7 @@ #ifndef QGSLEGENDRENDERER_H #define QGSLEGENDRENDERER_H +#include "qgis_core.h" #include class QRectF; diff --git a/src/core/qgslegendsettings.h b/src/core/qgslegendsettings.h index 04d3ca74668..84399c6ca05 100644 --- a/src/core/qgslegendsettings.h +++ b/src/core/qgslegendsettings.h @@ -16,6 +16,7 @@ #ifndef QGSLEGENDSETTINGS_H #define QGSLEGENDSETTINGS_H +#include "qgis_core.h" #include #include diff --git a/src/core/qgslegendstyle.h b/src/core/qgslegendstyle.h index 3218df533f5..3417d65bcc3 100644 --- a/src/core/qgslegendstyle.h +++ b/src/core/qgslegendstyle.h @@ -24,6 +24,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * Composer legend components style */ diff --git a/src/core/qgslocalec.h b/src/core/qgslocalec.h index 7815eb8533d..e7f8516ca08 100644 --- a/src/core/qgslocalec.h +++ b/src/core/qgslocalec.h @@ -20,6 +20,8 @@ #include +#include "qgis_core.h" + /** \ingroup core */ class CORE_EXPORT QgsLocaleNumC @@ -31,10 +33,10 @@ class CORE_EXPORT QgsLocaleNumC QgsLocaleNumC(); ~QgsLocaleNumC(); - private: - - QgsLocaleNumC( const QgsLocaleNumC& rh ); - QgsLocaleNumC& operator=( const QgsLocaleNumC& rh ); + //! QgsLocaleNumC cannot be copied + QgsLocaleNumC( const QgsLocaleNumC& rh ) = delete; + //! QgsLocaleNumC cannot be copied + QgsLocaleNumC& operator=( const QgsLocaleNumC& rh ) = delete; }; diff --git a/src/core/qgslogger.h b/src/core/qgslogger.h index f319aa7531a..8f19d4a3d24 100644 --- a/src/core/qgslogger.h +++ b/src/core/qgslogger.h @@ -22,6 +22,9 @@ #include #include #include + +#include "qgis_core.h" + class QFile; #ifdef QGISDEBUG diff --git a/src/core/qgsmaphittest.h b/src/core/qgsmaphittest.h index 5bf6f7fd660..0e018aac2f7 100644 --- a/src/core/qgsmaphittest.h +++ b/src/core/qgsmaphittest.h @@ -15,6 +15,7 @@ #ifndef QGSMAPHITTEST_H #define QGSMAPHITTEST_H +#include "qgis_core.h" #include "qgsmapsettings.h" #include "qgsgeometry.h" diff --git a/src/core/qgsmaplayer.cpp b/src/core/qgsmaplayer.cpp index 5dc07907af0..9e71d42ebf0 100644 --- a/src/core/qgsmaplayer.cpp +++ b/src/core/qgsmaplayer.cpp @@ -63,7 +63,7 @@ QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type, , mStyleManager( new QgsMapLayerStyleManager( this ) ) { // Set the display name = internal name - mLayerName = capitaliseLayerName( mLayerOrigName ); + mLayerName = capitalizeLayerName( mLayerOrigName ); mShortName = QLatin1String( "" ); //mShortName.replace( QRegExp( "[\\W]" ), "_" ); @@ -106,7 +106,7 @@ QString QgsMapLayer::id() const void QgsMapLayer::setName( const QString& name ) { - QString newName = capitaliseLayerName( name ); + QString newName = capitalizeLayerName( name ); if ( name == mLayerOrigName && newName == mLayerName ) return; @@ -823,7 +823,7 @@ QList QgsMapLayer::fromLayerDefinition( QDomDocument& document, bo else if ( type == QLatin1String( "plugin" ) ) { QString typeName = layerElem.attribute( QStringLiteral( "name" ) ); - layer = QgsPluginLayerRegistry::instance()->createLayer( typeName ); + layer = QgsApplication::pluginLayerRegistry()->createLayer( typeName ); } if ( !layer ) @@ -994,16 +994,16 @@ void QgsMapLayer::setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSign emit crsChanged(); } -QString QgsMapLayer::capitaliseLayerName( const QString& name ) +QString QgsMapLayer::capitalizeLayerName( const QString& name ) { - // Capitalise the first letter of the layer name if requested + // Capitalize the first letter of the layer name if requested QSettings settings; - bool capitaliseLayerName = - settings.value( QStringLiteral( "/qgis/capitaliseLayerName" ), QVariant( false ) ).toBool(); + bool capitalizeLayerName = + settings.value( QStringLiteral( "/qgis/capitalizeLayerName" ), QVariant( false ) ).toBool(); QString layerName( name ); - if ( capitaliseLayerName && !layerName.isEmpty() ) + if ( capitalizeLayerName && !layerName.isEmpty() ) layerName = layerName.at( 0 ).toUpper() + layerName.mid( 1 ); return layerName; diff --git a/src/core/qgsmaplayer.h b/src/core/qgsmaplayer.h index e01e4f7e72d..2e76b7b6d87 100644 --- a/src/core/qgsmaplayer.h +++ b/src/core/qgsmaplayer.h @@ -18,6 +18,7 @@ #ifndef QGSMAPLAYER_H #define QGSMAPLAYER_H +#include "qgis_core.h" #include #include #include @@ -71,6 +72,11 @@ class CORE_EXPORT QgsMapLayer : public QObject virtual ~QgsMapLayer(); + //! QgsMapLayer cannot be copied + QgsMapLayer( QgsMapLayer const & ) = delete; + //! QgsMapLayer cannot be copied + QgsMapLayer & operator=( QgsMapLayer const & ) = delete; + /** Returns the type of the layer. */ QgsMapLayer::LayerType type() const; @@ -419,8 +425,8 @@ class CORE_EXPORT QgsMapLayer : public QObject //! Sets layer's spatial reference system void setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSignal = true ); - //! A convenience function to (un)capitalise the layer name - static QString capitaliseLayerName( const QString& name ); + //! A convenience function to (un)capitalize the layer name + static QString capitalizeLayerName( const QString& name ); /** Retrieve the style URI for this layer * (either as a .qml file on disk or as a @@ -874,16 +880,10 @@ class CORE_EXPORT QgsMapLayer : public QObject private to make sure setCrs must be used and crsChanged() is emitted */ QgsCoordinateReferenceSystem mCRS; - //! Private copy constructor - QgsMapLayer not copyable - QgsMapLayer( QgsMapLayer const & ); - - //! Private assign operator - QgsMapLayer not copyable - QgsMapLayer & operator=( QgsMapLayer const & ); - //! Unique ID of this layer - used to refer to this layer in map layer registry QString mID; - //! Type of the layer (eg. vector, raster) + //! Type of the layer (e.g., vector, raster) QgsMapLayer::LayerType mLayerType; //! Blend mode for the layer diff --git a/src/core/qgsmaplayerdependency.h b/src/core/qgsmaplayerdependency.h index 0f77cbb8676..c1f9fac52ef 100644 --- a/src/core/qgsmaplayerdependency.h +++ b/src/core/qgsmaplayerdependency.h @@ -19,6 +19,7 @@ #ifndef QGSMAPLAYERDEPENDENCY_H #define QGSMAPLAYERDEPENDENCY_H +#include "qgis_core.h" #include /** \ingroup core diff --git a/src/core/qgsmaplayerlegend.h b/src/core/qgsmaplayerlegend.h index a146ba3db9d..c9c8a0a6736 100644 --- a/src/core/qgsmaplayerlegend.h +++ b/src/core/qgsmaplayerlegend.h @@ -24,6 +24,8 @@ class QgsPluginLayer; class QgsRasterLayer; class QgsVectorLayer; +#include "qgis_core.h" + /** \ingroup core * The QgsMapLayerLegend class is abstract interface for implementations diff --git a/src/core/qgsmaplayermodel.h b/src/core/qgsmaplayermodel.h index e85f83d034d..06affb23155 100644 --- a/src/core/qgsmaplayermodel.h +++ b/src/core/qgsmaplayermodel.h @@ -20,6 +20,8 @@ #include #include +#include "qgis_core.h" + class QgsMapLayer; diff --git a/src/core/qgsmaplayerproxymodel.h b/src/core/qgsmaplayerproxymodel.h index 1a48f7bcfa0..6b1ec687ace 100644 --- a/src/core/qgsmaplayerproxymodel.h +++ b/src/core/qgsmaplayerproxymodel.h @@ -19,6 +19,8 @@ #include #include +#include "qgis_core.h" + class QgsMapLayerModel; class QgsMapLayer; diff --git a/src/core/qgsmaplayerrenderer.h b/src/core/qgsmaplayerrenderer.h index c6c40698c1b..6b2cf27464b 100644 --- a/src/core/qgsmaplayerrenderer.h +++ b/src/core/qgsmaplayerrenderer.h @@ -18,6 +18,8 @@ #include +#include "qgis_core.h" + class QgsFeedback; /** \ingroup core @@ -46,7 +48,7 @@ class CORE_EXPORT QgsMapLayerRenderer { public: QgsMapLayerRenderer( const QString& layerID ) : mLayerID( layerID ) {} - virtual ~QgsMapLayerRenderer() {} + virtual ~QgsMapLayerRenderer() = default; //! Do the rendering (based on data stored in the class) virtual bool render() = 0; diff --git a/src/core/qgsmaplayerstylemanager.h b/src/core/qgsmaplayerstylemanager.h index defaefa7457..37046b50445 100644 --- a/src/core/qgsmaplayerstylemanager.h +++ b/src/core/qgsmaplayerstylemanager.h @@ -24,6 +24,8 @@ class QgsMapLayer; #include #include +#include "qgis_core.h" + class QDomElement; /** \ingroup core diff --git a/src/core/qgsmaprenderercache.h b/src/core/qgsmaprenderercache.h index 7d81272a674..244dea77d55 100644 --- a/src/core/qgsmaprenderercache.h +++ b/src/core/qgsmaprenderercache.h @@ -16,6 +16,7 @@ #ifndef QGSMAPRENDERERCACHE_H #define QGSMAPRENDERERCACHE_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/qgsmaprenderercustompainterjob.cpp b/src/core/qgsmaprenderercustompainterjob.cpp index 3bdf4e040d1..14be0a1465b 100644 --- a/src/core/qgsmaprenderercustompainterjob.cpp +++ b/src/core/qgsmaprenderercustompainterjob.cpp @@ -326,7 +326,7 @@ bool QgsMapRendererJob::needTemporaryImage( QgsMapLayer* ml ) || ( vl->featureBlendMode() != QPainter::CompositionMode_SourceOver ) || ( vl->layerTransparency() != 0 ) ) ) { - //layer properties require rasterisation + //layer properties require rasterization return true; } } diff --git a/src/core/qgsmaprenderercustompainterjob.h b/src/core/qgsmaprenderercustompainterjob.h index 01387dd12ad..3ade5f49af7 100644 --- a/src/core/qgsmaprenderercustompainterjob.h +++ b/src/core/qgsmaprenderercustompainterjob.h @@ -16,6 +16,7 @@ #ifndef QGSMAPRENDERERCUSTOMPAINTERJOB_H #define QGSMAPRENDERERCUSTOMPAINTERJOB_H +#include "qgis_core.h" #include "qgsmaprendererjob.h" #include diff --git a/src/core/qgsmaprendererjob.h b/src/core/qgsmaprendererjob.h index 4a54692e724..3c4c112acc7 100644 --- a/src/core/qgsmaprendererjob.h +++ b/src/core/qgsmaprendererjob.h @@ -16,6 +16,7 @@ #ifndef QGSMAPRENDERERJOB_H #define QGSMAPRENDERERJOB_H +#include "qgis_core.h" #include #include #include @@ -87,8 +88,6 @@ class CORE_EXPORT QgsMapRendererJob : public QObject QgsMapRendererJob( const QgsMapSettings& settings ); - virtual ~QgsMapRendererJob() {} - //! Start the rendering job and immediately return. //! Does nothing if the rendering is already in progress. virtual void start() = 0; diff --git a/src/core/qgsmaprendererparalleljob.h b/src/core/qgsmaprendererparalleljob.h index 945321c0755..80af023ed6e 100644 --- a/src/core/qgsmaprendererparalleljob.h +++ b/src/core/qgsmaprendererparalleljob.h @@ -16,6 +16,7 @@ #ifndef QGSMAPRENDERERPARALLELJOB_H #define QGSMAPRENDERERPARALLELJOB_H +#include "qgis_core.h" #include "qgsmaprendererjob.h" /** \ingroup core diff --git a/src/core/qgsmaprenderersequentialjob.h b/src/core/qgsmaprenderersequentialjob.h index 7cbd11d6484..35c5e1c8adc 100644 --- a/src/core/qgsmaprenderersequentialjob.h +++ b/src/core/qgsmaprenderersequentialjob.h @@ -16,6 +16,7 @@ #ifndef QGSMAPRENDERERSEQUENTIALJOB_H #define QGSMAPRENDERERSEQUENTIALJOB_H +#include "qgis_core.h" #include "qgsmaprendererjob.h" class QgsMapRendererCustomPainterJob; diff --git a/src/core/qgsmapsettings.h b/src/core/qgsmapsettings.h index 4d832bc1f9b..5b7e85767ac 100644 --- a/src/core/qgsmapsettings.h +++ b/src/core/qgsmapsettings.h @@ -16,6 +16,7 @@ #ifndef QGSMAPSETTINGS_H #define QGSMAPSETTINGS_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/qgsmapthemecollection.cpp b/src/core/qgsmapthemecollection.cpp index 96a07328028..89547b12e32 100644 --- a/src/core/qgsmapthemecollection.cpp +++ b/src/core/qgsmapthemecollection.cpp @@ -103,7 +103,7 @@ void QgsMapThemeCollection::applyThemeToLayer( QgsLayerTreeLayer* nodeLayer, Qgs MapThemeLayerRecord layerRec; bool isVisible = findRecordForLayer( nodeLayer->layer(), rec, layerRec ); - nodeLayer->setVisible( isVisible ? Qt::Checked : Qt::Unchecked ); + nodeLayer->setItemVisibilityChecked( isVisible ); if ( !isVisible ) return; diff --git a/src/core/qgsmapthemecollection.h b/src/core/qgsmapthemecollection.h index 7e6051928b7..73e677caf74 100644 --- a/src/core/qgsmapthemecollection.h +++ b/src/core/qgsmapthemecollection.h @@ -16,6 +16,7 @@ #ifndef QGSMAPTHEMECOLLECTION_H #define QGSMAPTHEMECOLLECTION_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/qgsmaptopixel.h b/src/core/qgsmaptopixel.h index f6d07891bdb..4a3ded75702 100644 --- a/src/core/qgsmaptopixel.h +++ b/src/core/qgsmaptopixel.h @@ -17,6 +17,7 @@ #ifndef QGSMAPTOPIXEL #define QGSMAPTOPIXEL +#include "qgis_core.h" #include #include #include "qgsunittypes.h" diff --git a/src/core/qgsmaptopixelgeometrysimplifier.cpp b/src/core/qgsmaptopixelgeometrysimplifier.cpp index e2e04f52133..1ac739b2919 100644 --- a/src/core/qgsmaptopixelgeometrysimplifier.cpp +++ b/src/core/qgsmaptopixelgeometrysimplifier.cpp @@ -33,10 +33,6 @@ QgsMapToPixelSimplifier::QgsMapToPixelSimplifier( int simplifyFlags, double tole { } -QgsMapToPixelSimplifier::~QgsMapToPixelSimplifier() -{ -} - ////////////////////////////////////////////////////////////////////////////////////////////// // Helper simplification methods diff --git a/src/core/qgsmaptopixelgeometrysimplifier.h b/src/core/qgsmaptopixelgeometrysimplifier.h index c510a012695..edd9a92afde 100644 --- a/src/core/qgsmaptopixelgeometrysimplifier.h +++ b/src/core/qgsmaptopixelgeometrysimplifier.h @@ -17,6 +17,7 @@ #ifndef QGSMAPTOPIXELGEOMETRYSIMPLIFIER_H #define QGSMAPTOPIXELGEOMETRYSIMPLIFIER_H +#include "qgis_core.h" #include "qgis.h" #include "qgsgeometrysimplifier.h" #include @@ -45,7 +46,6 @@ class CORE_EXPORT QgsMapToPixelSimplifier : public QgsAbstractGeometrySimplifier //! Constructor QgsMapToPixelSimplifier( int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance ); - virtual ~QgsMapToPixelSimplifier(); //! Applicable simplification flags enum SimplifyFlag diff --git a/src/core/qgsmapunitscale.h b/src/core/qgsmapunitscale.h index 6529d01fba0..e5aaa27cea3 100644 --- a/src/core/qgsmapunitscale.h +++ b/src/core/qgsmapunitscale.h @@ -18,6 +18,7 @@ #ifndef QGSMAPUNITSCALE_H #define QGSMAPUNITSCALE_H +#include "qgis_core.h" #include #include "qgsrendercontext.h" diff --git a/src/core/qgsmessagelog.cpp b/src/core/qgsmessagelog.cpp index 4e37c619d5b..d93af829f5c 100644 --- a/src/core/qgsmessagelog.cpp +++ b/src/core/qgsmessagelog.cpp @@ -14,6 +14,7 @@ ***************************************************************************/ #include "qgsmessagelog.h" +#include "qgsapplication.h" #include #include #include @@ -21,30 +22,17 @@ class QgsMessageLogConsole; -QgsMessageLog *QgsMessageLog::sInstance = nullptr; - QgsMessageLog::QgsMessageLog() : QObject() { - sInstance = this; -} - -QgsMessageLog *QgsMessageLog::instance() -{ - if ( !sInstance ) - { - qRegisterMetaType( "QgsMessageLog::MessageLevel" ); - sInstance = new QgsMessageLog(); - } - - return sInstance; + qRegisterMetaType< QgsMessageLog::MessageLevel >( "QgsMessageLog::MessageLevel" ); } void QgsMessageLog::logMessage( const QString& message, const QString& tag, QgsMessageLog::MessageLevel level ) { QgsDebugMsg( QString( "%1 %2[%3] %4" ).arg( QDateTime::currentDateTime().toString( Qt::ISODate ), tag ).arg( level ).arg( message ) ); - QgsMessageLog::instance()->emitMessage( message, tag, level ); + QgsApplication::messageLog()->emitMessage( message, tag, level ); } void QgsMessageLog::emitMessage( const QString& message, const QString& tag, QgsMessageLog::MessageLevel level ) @@ -57,9 +45,9 @@ void QgsMessageLog::emitMessage( const QString& message, const QString& tag, Qgs } QgsMessageLogConsole::QgsMessageLogConsole() - : QObject( QgsMessageLog::instance() ) + : QObject( QgsApplication::messageLog() ) { - connect( QgsMessageLog::instance(), SIGNAL( messageReceived( QString, QString, QgsMessageLog::MessageLevel ) ), + connect( QgsApplication::messageLog(), SIGNAL( messageReceived( QString, QString, QgsMessageLog::MessageLevel ) ), this, SLOT( logMessage( QString, QString, QgsMessageLog::MessageLevel ) ) ); } diff --git a/src/core/qgsmessagelog.h b/src/core/qgsmessagelog.h index 844147f95b2..9a7b6914c47 100644 --- a/src/core/qgsmessagelog.h +++ b/src/core/qgsmessagelog.h @@ -19,6 +19,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * Interface for logging messages from QGIS in GUI independent way. * This class provides abstraction of a tabbed window for showing messages to the user. @@ -27,13 +29,16 @@ * QGIS application uses QgsMessageLog class for logging messages in a dockable * window for the user. + * + * QgsMessageLog is not usually directly created, but rather accessed through + * QgsApplication::messageLog(). */ class CORE_EXPORT QgsMessageLog : public QObject { Q_OBJECT + Q_ENUMS( MessageLevel ) public: - static QgsMessageLog *instance(); enum MessageLevel { @@ -44,6 +49,8 @@ class CORE_EXPORT QgsMessageLog : public QObject NONE = 3 }; + QgsMessageLog(); + //! add a message to the instance (and create it if necessary) static void logMessage( const QString& message, const QString& tag = QString::null, MessageLevel level = WARNING ); @@ -53,14 +60,11 @@ class CORE_EXPORT QgsMessageLog : public QObject void messageReceived( bool received ); private: - QgsMessageLog(); void emitMessage( const QString& message, const QString& tag, QgsMessageLog::MessageLevel level ); - static QgsMessageLog *sInstance; }; - /** \ingroup core \brief Default implementation of message logging interface diff --git a/src/core/qgsmessageoutput.cpp b/src/core/qgsmessageoutput.cpp index e8aafac982a..9a105395f60 100644 --- a/src/core/qgsmessageoutput.cpp +++ b/src/core/qgsmessageoutput.cpp @@ -38,11 +38,6 @@ QgsMessageOutput* QgsMessageOutput::createMessageOutput() return mMessageOutputCreator(); } -QgsMessageOutput::~QgsMessageOutput() -{ -} - - void QgsMessageOutput::showMessage( const QString& title, const QString& message, MessageType msgType ) { QgsMessageOutput *output = QgsMessageOutput::createMessageOutput(); diff --git a/src/core/qgsmessageoutput.h b/src/core/qgsmessageoutput.h index cdd4bbcfb72..aca8f6fa84a 100644 --- a/src/core/qgsmessageoutput.h +++ b/src/core/qgsmessageoutput.h @@ -20,6 +20,8 @@ #include #include +#include "qgis_core.h" + class QgsMessageOutput; typedef QgsMessageOutput*( *MESSAGE_OUTPUT_CREATOR )(); @@ -42,8 +44,7 @@ class CORE_EXPORT QgsMessageOutput //! message can be in plain text or in html format enum MessageType { MessageText, MessageHtml }; - //! virtual destructor - virtual ~QgsMessageOutput(); + virtual ~QgsMessageOutput() = default; //! set message, it won't be displayed until virtual void setMessage( const QString& message, MessageType msgType ) = 0; diff --git a/src/core/qgsmimedatautils.h b/src/core/qgsmimedatautils.h index dfbab68edfc..722f8edb9bd 100644 --- a/src/core/qgsmimedatautils.h +++ b/src/core/qgsmimedatautils.h @@ -18,6 +18,8 @@ #include #include +#include "qgis_core.h" + class QgsLayerItem; class QgsLayerTreeNode; diff --git a/src/core/qgsmultirenderchecker.cpp b/src/core/qgsmultirenderchecker.cpp index 840f701c24b..70ca517ad6b 100644 --- a/src/core/qgsmultirenderchecker.cpp +++ b/src/core/qgsmultirenderchecker.cpp @@ -128,10 +128,6 @@ QgsCompositionChecker::QgsCompositionChecker() { } -QgsCompositionChecker::~QgsCompositionChecker() -{ -} - bool QgsCompositionChecker::testComposition( QString &theReport, int page, int pixelDiff ) { if ( !mComposition ) diff --git a/src/core/qgsmultirenderchecker.h b/src/core/qgsmultirenderchecker.h index f151aabd754..56edce64034 100644 --- a/src/core/qgsmultirenderchecker.h +++ b/src/core/qgsmultirenderchecker.h @@ -16,6 +16,7 @@ #ifndef QGSMULTIRENDERCHECKER_H #define QGSMULTIRENDERCHECKER_H +#include "qgis_core.h" #include "qgsrenderchecker.h" /** \ingroup core @@ -53,6 +54,8 @@ class CORE_EXPORT QgsMultiRenderChecker public: QgsMultiRenderChecker(); + virtual ~QgsMultiRenderChecker() = default; + /** * Base directory name for the control image (with control image path * suffixed) the path to the image will be constructed like this: @@ -139,7 +142,6 @@ class CORE_EXPORT QgsCompositionChecker : public QgsMultiRenderChecker { public: QgsCompositionChecker( const QString& testName, QgsComposition* composition ); - ~QgsCompositionChecker(); void setSize( QSize size ) { mSize = size; } diff --git a/src/core/qgsnetworkaccessmanager.cpp b/src/core/qgsnetworkaccessmanager.cpp index d9d66b650ff..c9d5f315f87 100644 --- a/src/core/qgsnetworkaccessmanager.cpp +++ b/src/core/qgsnetworkaccessmanager.cpp @@ -46,7 +46,6 @@ class QgsNetworkProxyFactory : public QNetworkProxyFactory { public: QgsNetworkProxyFactory() {} - virtual ~QgsNetworkProxyFactory() {} virtual QList queryProxy( const QNetworkProxyQuery & query = QNetworkProxyQuery() ) override { @@ -122,10 +121,6 @@ QgsNetworkAccessManager::QgsNetworkAccessManager( QObject *parent ) setProxyFactory( new QgsNetworkProxyFactory() ); } -QgsNetworkAccessManager::~QgsNetworkAccessManager() -{ -} - void QgsNetworkAccessManager::insertProxyFactory( QNetworkProxyFactory *factory ) { mProxyFactories.insert( 0, factory ); diff --git a/src/core/qgsnetworkaccessmanager.h b/src/core/qgsnetworkaccessmanager.h index 9fd74c551bf..a95b958935c 100644 --- a/src/core/qgsnetworkaccessmanager.h +++ b/src/core/qgsnetworkaccessmanager.h @@ -24,6 +24,8 @@ #include #include +#include "qgis_core.h" + /** * \class QgsNetworkAccessManager * \brief network access manager for QGIS @@ -52,9 +54,6 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager QgsNetworkAccessManager( QObject *parent = nullptr ); - //! destructor - ~QgsNetworkAccessManager(); - //! insert a factory into the proxy factories list void insertProxyFactory( QNetworkProxyFactory *factory ); diff --git a/src/core/qgsnetworkcontentfetcher.h b/src/core/qgsnetworkcontentfetcher.h index 9ea8b9f8a46..58deaa3de5f 100644 --- a/src/core/qgsnetworkcontentfetcher.h +++ b/src/core/qgsnetworkcontentfetcher.h @@ -23,6 +23,8 @@ #include #include +#include "qgis_core.h" + /** \class QgsNetworkContentFetcher \ingroup core diff --git a/src/core/qgsnetworkdiskcache.cpp b/src/core/qgsnetworkdiskcache.cpp index 2a1a821297f..0eac8364abe 100644 --- a/src/core/qgsnetworkdiskcache.cpp +++ b/src/core/qgsnetworkdiskcache.cpp @@ -26,10 +26,6 @@ QgsNetworkDiskCache::QgsNetworkDiskCache( QObject *parent ) { } -QgsNetworkDiskCache::~QgsNetworkDiskCache() -{ -} - QString QgsNetworkDiskCache::cacheDirectory() const { QMutexLocker lock( &smDiskCacheMutex ); diff --git a/src/core/qgsnetworkdiskcache.h b/src/core/qgsnetworkdiskcache.h index 4edbf17ead1..af3c9bc2024 100644 --- a/src/core/qgsnetworkdiskcache.h +++ b/src/core/qgsnetworkdiskcache.h @@ -34,7 +34,6 @@ class QgsNetworkDiskCache : public QNetworkDiskCache Q_OBJECT public: - ~QgsNetworkDiskCache(); //! @see QNetworkDiskCache::cacheDirectory QString cacheDirectory() const; diff --git a/src/core/qgsnetworkreplyparser.h b/src/core/qgsnetworkreplyparser.h index ca7cf7b1b18..30b2ecf96d5 100644 --- a/src/core/qgsnetworkreplyparser.h +++ b/src/core/qgsnetworkreplyparser.h @@ -21,6 +21,8 @@ #include +#include "qgis_core.h" + /** \ingroup core \brief Multipart QNetworkReply parser. diff --git a/src/core/qgsobjectcustomproperties.h b/src/core/qgsobjectcustomproperties.h index 27782bdf219..eb5b229aa5a 100644 --- a/src/core/qgsobjectcustomproperties.h +++ b/src/core/qgsobjectcustomproperties.h @@ -20,6 +20,7 @@ #include #include +#include "qgis_core.h" class QDomDocument; class QDomNode; diff --git a/src/core/qgsofflineediting.cpp b/src/core/qgsofflineediting.cpp index bc875d739bd..90902573296 100644 --- a/src/core/qgsofflineediting.cpp +++ b/src/core/qgsofflineediting.cpp @@ -60,10 +60,6 @@ QgsOfflineEditing::QgsOfflineEditing() connect( QgsProject::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( layerAdded( QgsMapLayer* ) ) ); } -QgsOfflineEditing::~QgsOfflineEditing() -{ -} - /** * convert current project to offline project * returns offline project file path diff --git a/src/core/qgsofflineediting.h b/src/core/qgsofflineediting.h index b5dfb3b4bdb..a44b4c894fe 100644 --- a/src/core/qgsofflineediting.h +++ b/src/core/qgsofflineediting.h @@ -19,6 +19,7 @@ #ifndef QGS_OFFLINE_EDITING_H #define QGS_OFFLINE_EDITING_H +#include "qgis_core.h" #include #include @@ -48,7 +49,6 @@ class CORE_EXPORT QgsOfflineEditing : public QObject }; QgsOfflineEditing(); - ~QgsOfflineEditing(); /** Convert current project for offline editing * @param offlineDataPath Path to offline db file diff --git a/src/core/qgsogcutils.h b/src/core/qgsogcutils.h index 90d0b64b0d3..5b3014bb967 100644 --- a/src/core/qgsogcutils.h +++ b/src/core/qgsogcutils.h @@ -21,6 +21,7 @@ class QDomElement; class QDomDocument; class QString; +#include "qgis_core.h" #include #include diff --git a/src/core/qgsogrutils.cpp b/src/core/qgsogrutils.cpp index 9e5066044e9..5d7d5a67a3c 100644 --- a/src/core/qgsogrutils.cpp +++ b/src/core/qgsogrutils.cpp @@ -21,16 +21,6 @@ #include #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 -#define TO8(x) (x).toUtf8().constData() -#define TO8F(x) (x).toUtf8().constData() -#define FROM8(x) QString::fromUtf8(x) -#else -#define TO8(x) (x).toLocal8Bit().constData() -#define TO8F(x) QFile::encodeName( x ).constData() -#define FROM8(x) QString::fromLocal8Bit(x) -#endif - QgsFeature QgsOgrUtils::readOgrFeature( OGRFeatureH ogrFet, const QgsFields& fields, QTextCodec* encoding ) { QgsFeature feature; @@ -80,15 +70,12 @@ QgsFields QgsOgrUtils::readOgrFields( OGRFeatureH ogrFet, QTextCodec* encoding ) case OFTInteger: varType = QVariant::Int; break; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 case OFTInteger64: varType = QVariant::LongLong; break; -#endif case OFTReal: varType = QVariant::Double; break; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1400 case OFTDate: varType = QVariant::Date; break; @@ -99,7 +86,6 @@ QgsFields QgsOgrUtils::readOgrFields( OGRFeatureH ogrFet, QTextCodec* encoding ) varType = QVariant::DateTime; break; case OFTString: -#endif default: varType = QVariant::String; // other unsupported, leave it as a string } @@ -148,11 +134,9 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField case QVariant::Int: value = QVariant( OGR_F_GetFieldAsInteger( ogrFet, attIndex ) ); break; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 case QVariant::LongLong: value = QVariant( OGR_F_GetFieldAsInteger64( ogrFet, attIndex ) ); break; -#endif case QVariant::Double: value = QVariant( OGR_F_GetFieldAsDouble( ogrFet, attIndex ) ); break; @@ -245,13 +229,13 @@ QgsFeatureList QgsOgrUtils::stringToFeatureList( const QString& string, const Qg // create memory file system object from string buffer QByteArray ba = string.toUtf8(); - VSIFCloseL( VSIFileFromMemBuffer( TO8( randomFileName ), reinterpret_cast< GByte* >( ba.data() ), + VSIFCloseL( VSIFileFromMemBuffer( randomFileName.toUtf8().constData(), reinterpret_cast< GByte* >( ba.data() ), static_cast< vsi_l_offset >( ba.size() ), FALSE ) ); - OGRDataSourceH hDS = OGROpen( TO8( randomFileName ), false, nullptr ); + OGRDataSourceH hDS = OGROpen( randomFileName.toUtf8().constData(), false, nullptr ); if ( !hDS ) { - VSIUnlink( TO8( randomFileName ) ); + VSIUnlink( randomFileName.toUtf8().constData() ); return features; } @@ -259,7 +243,7 @@ QgsFeatureList QgsOgrUtils::stringToFeatureList( const QString& string, const Qg if ( !ogrLayer ) { OGR_DS_Destroy( hDS ); - VSIUnlink( TO8( randomFileName ) ); + VSIUnlink( randomFileName.toUtf8().constData() ); return features; } @@ -274,7 +258,7 @@ QgsFeatureList QgsOgrUtils::stringToFeatureList( const QString& string, const Qg } OGR_DS_Destroy( hDS ); - VSIUnlink( TO8( randomFileName ) ); + VSIUnlink( randomFileName.toUtf8().constData() ); return features; } @@ -289,13 +273,13 @@ QgsFields QgsOgrUtils::stringToFields( const QString& string, QTextCodec* encodi // create memory file system object from buffer QByteArray ba = string.toUtf8(); - VSIFCloseL( VSIFileFromMemBuffer( TO8( randomFileName ), reinterpret_cast< GByte* >( ba.data() ), + VSIFCloseL( VSIFileFromMemBuffer( randomFileName.toUtf8().constData(), reinterpret_cast< GByte* >( ba.data() ), static_cast< vsi_l_offset >( ba.size() ), FALSE ) ); - OGRDataSourceH hDS = OGROpen( TO8( randomFileName ), false, nullptr ); + OGRDataSourceH hDS = OGROpen( randomFileName.toUtf8().constData(), false, nullptr ); if ( !hDS ) { - VSIUnlink( TO8( randomFileName ) ); + VSIUnlink( randomFileName.toUtf8().constData() ); return fields; } @@ -303,7 +287,7 @@ QgsFields QgsOgrUtils::stringToFields( const QString& string, QTextCodec* encodi if ( !ogrLayer ) { OGR_DS_Destroy( hDS ); - VSIUnlink( TO8( randomFileName ) ); + VSIUnlink( randomFileName.toUtf8().constData() ); return fields; } @@ -316,6 +300,6 @@ QgsFields QgsOgrUtils::stringToFields( const QString& string, QTextCodec* encodi } OGR_DS_Destroy( hDS ); - VSIUnlink( TO8( randomFileName ) ); + VSIUnlink( randomFileName.toUtf8().constData() ); return fields; } diff --git a/src/core/qgsogrutils.h b/src/core/qgsogrutils.h index 247ae0171ee..feea2ce9464 100644 --- a/src/core/qgsogrutils.h +++ b/src/core/qgsogrutils.h @@ -16,6 +16,7 @@ #ifndef QGSOGRUTILS_H #define QGSOGRUTILS_H +#include "qgis_core.h" #include "qgsfeature.h" #include diff --git a/src/core/qgsoptional.h b/src/core/qgsoptional.h index d1c5ca35fa7..d60fae67802 100644 --- a/src/core/qgsoptional.h +++ b/src/core/qgsoptional.h @@ -16,6 +16,8 @@ #ifndef QGSOPTIONAL_H #define QGSOPTIONAL_H +#include "qgis_core.h" + /** * \ingroup core diff --git a/src/core/qgsoptionalexpression.h b/src/core/qgsoptionalexpression.h index 50723de0dce..9a66fc4be92 100644 --- a/src/core/qgsoptionalexpression.h +++ b/src/core/qgsoptionalexpression.h @@ -19,6 +19,8 @@ #include "qgsoptional.h" #include "qgsexpression.h" +#include "qgis_core.h" + /** * \ingroup core * diff --git a/src/core/qgsowsconnection.cpp b/src/core/qgsowsconnection.cpp index 69be50addd0..711d6acdcfc 100644 --- a/src/core/qgsowsconnection.cpp +++ b/src/core/qgsowsconnection.cpp @@ -92,11 +92,6 @@ QgsOwsConnection::QgsOwsConnection( const QString & theService, const QString & QgsDebugMsg( QString( "encoded uri: '%1'." ).arg( QString( mUri.encodedUri() ) ) ); } -QgsOwsConnection::~QgsOwsConnection() -{ - -} - QgsDataSourceUri QgsOwsConnection::uri() const { return mUri; diff --git a/src/core/qgsowsconnection.h b/src/core/qgsowsconnection.h index defa0f4d496..850dd7b858a 100644 --- a/src/core/qgsowsconnection.h +++ b/src/core/qgsowsconnection.h @@ -22,6 +22,7 @@ #ifndef QGSOWSCONNECTION_H #define QGSOWSCONNECTION_H +#include "qgis_core.h" #include "qgsdatasourceuri.h" #include @@ -43,9 +44,6 @@ class CORE_EXPORT QgsOwsConnection : public QObject */ QgsOwsConnection( const QString & theService, const QString & theConnName ); - //! Destructor - ~QgsOwsConnection(); - //! Returns the list of connections for the specified service static QStringList connectionList( const QString & theService ); diff --git a/src/core/qgspaintenginehack.h b/src/core/qgspaintenginehack.h index 2468215a8f8..82d15687258 100644 --- a/src/core/qgspaintenginehack.h +++ b/src/core/qgspaintenginehack.h @@ -16,6 +16,8 @@ #include +#include "qgis_core.h" + /** \ingroup core * Hack to workaround Qt #5114 by disabling PatternTransform */ diff --git a/src/core/qgspainting.h b/src/core/qgspainting.h index 6c271962c2a..85e96553413 100644 --- a/src/core/qgspainting.h +++ b/src/core/qgspainting.h @@ -3,6 +3,8 @@ #include +#include "qgis_core.h" + /** * @ingroup core * Misc painting enums and functions. diff --git a/src/core/qgspalgeometry.h b/src/core/qgspalgeometry.h index c065341648f..32c0ccf38fb 100644 --- a/src/core/qgspalgeometry.h +++ b/src/core/qgspalgeometry.h @@ -45,7 +45,7 @@ class QgsTextLabelFeature : public QgsLabelFeature } /** Returns the text component corresponding to a specified label part - * @param partId Set to -1 for labels which are not broken into parts (eg, non-curved labels), or the required + * @param partId Set to -1 for labels which are not broken into parts (e.g., non-curved labels), or the required * part index for labels which are broken into parts (curved labels) * @note added in QGIS 2.10 */ diff --git a/src/core/qgspallabeling.cpp b/src/core/qgspallabeling.cpp index aa6421e3372..9e2e643b680 100644 --- a/src/core/qgspallabeling.cpp +++ b/src/core/qgspallabeling.cpp @@ -1830,7 +1830,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont doClip = true; } - // if using fitInPolygonOnly option, generate the permissible zone (must happen before geometry is modified - eg + // if using fitInPolygonOnly option, generate the permissible zone (must happen before geometry is modified - e.g., // as a result of using perimeter based labeling and the geometry is converted to a boundary) QgsGeometry permissibleZone; if ( geom.type() == QgsWkbTypes::PolygonGeometry && fitInPolygonOnly ) diff --git a/src/core/qgspallabeling.h b/src/core/qgspallabeling.h index 3d3da6ea9b3..5297d333745 100644 --- a/src/core/qgspallabeling.h +++ b/src/core/qgspallabeling.h @@ -21,6 +21,7 @@ #ifndef QGSPALLABELING_H #define QGSPALLABELING_H +#include "qgis_core.h" #include #include #include @@ -146,7 +147,7 @@ class CORE_EXPORT QgsPalLayerSettings Curved, //! Arranges candidates following the curvature of a line feature. Applies to line layers only. Horizontal, //!< Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only. Free, //!< Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the polygon's orientation. Applies to polygon layers only. - OrderedPositionsAroundPoint, //!< Candidates are placed in predefined positions around a point. Peference is given to positions with greatest cartographic appeal, eg top right, bottom right, etc. Applies to point layers only. + OrderedPositionsAroundPoint, //!< Candidates are placed in predefined positions around a point. Preference is given to positions with greatest cartographic appeal, e.g., top right, bottom right, etc. Applies to point layers only. PerimeterCurved, //! Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only. }; @@ -191,7 +192,7 @@ class CORE_EXPORT QgsPalLayerSettings respects the direction of the line feature, so a line from right to left labels will have labels placed placed above the line feature. */ MapOrientation = 8, /**< Signifies that the AboveLine and BelowLine flags should respect the map's orientation rather - than the feature's orientation. Eg, AboveLine will always result in label's being placed + than the feature's orientation. For example, AboveLine will always result in label's being placed above a line, regardless of the line's direction. */ }; @@ -227,7 +228,7 @@ class CORE_EXPORT QgsPalLayerSettings MultiLeft = 0, MultiCenter, MultiRight, - MultiFollowPlacement /*!< Alignment follows placement of label, eg labels to the left of a feature + MultiFollowPlacement /*!< Alignment follows placement of label, e.g., labels to the left of a feature will be drawn with right alignment*/ }; @@ -385,7 +386,7 @@ class CORE_EXPORT QgsPalLayerSettings QString fieldName; - /** Is this label made from a expression string eg FieldName || 'mm' + /** Is this label made from a expression string, e.g., FieldName || 'mm' */ bool isExpression; @@ -427,7 +428,7 @@ class CORE_EXPORT QgsPalLayerSettings bool centroidInside; // whether centroid-point calculated must be inside polygon /** Ordered list of predefined label positions for points. Positions earlier - * in the list will be prioritised over later positions. Only used when the placement + * in the list will be prioritized over later positions. Only used when the placement * is set to QgsPalLayerSettings::OrderedPositionsAroundPoint. * @note not available in Python bindings */ @@ -506,7 +507,7 @@ class CORE_EXPORT QgsPalLayerSettings * @param labelFeature if using QgsLabelingEngine, this will receive the label feature. Not available * in Python bindings. * @param obstacleGeometry optional obstacle geometry, if a different geometry to the feature's geometry - * should be used as an obstacle for labels (eg, if the feature has been rendered with an offset point + * should be used as an obstacle for labels (e.g., if the feature has been rendered with an offset point * symbol, the obstacle geometry should represent the bounds of the offset symbol). If not set, * the feature's original geometry will be used as an obstacle for labels. Not available * in Python bindings. @@ -588,13 +589,13 @@ class CORE_EXPORT QgsPalLayerSettings */ QMap > dataDefinedNames() const { return mDataDefinedNames; } - /** Returns the label text formatting settings, eg font settings, buffer settings, etc. + /** Returns the label text formatting settings, e.g., font settings, buffer settings, etc. * @see setFormat() * @note added in QGIS 3.0 */ const QgsTextFormat& format() const { return mFormat; } - /** Sets the label text formatting settings, eg font settings, buffer settings, etc. + /** Sets the label text formatting settings, e.g., font settings, buffer settings, etc. * @param format label text format * @see format() * @note added in QGIS 3.0 @@ -705,14 +706,17 @@ class CORE_EXPORT QgsLabelingResults QgsLabelingResults(); ~QgsLabelingResults(); + //! QgsLabelingResults cannot be copied. + QgsLabelingResults( const QgsLabelingResults& ) = delete; + //! QgsLabelingResults cannot be copied. + QgsLabelingResults& operator=( const QgsLabelingResults& rh ) = delete; + //! return infos about labels at a given (map) position QList labelsAtPosition( const QgsPoint& p ) const; //! return infos about labels within a given (map) rectangle QList labelsWithinRect( const QgsRectangle& r ) const; private: - QgsLabelingResults( const QgsLabelingResults& ); // no copying allowed - QgsLabelingResults& operator=( const QgsLabelingResults& rh ); QgsLabelSearchTree* mLabelSearchTree; @@ -811,7 +815,7 @@ class CORE_EXPORT QgsPalLabeling /** Splits a text string to a list of graphemes, which are the smallest allowable character * divisions in the string. This accounts for scripts were individual characters are not - * allowed to be split apart (eg Arabic and Indic based scripts) + * allowed to be split apart (e.g., Arabic and Indic based scripts) * @param text string to split * @returns list of graphemes * @note added in QGIS 2.10 diff --git a/src/core/qgspluginlayer.h b/src/core/qgspluginlayer.h index 66a7a670204..952737275b7 100644 --- a/src/core/qgspluginlayer.h +++ b/src/core/qgspluginlayer.h @@ -15,6 +15,7 @@ #ifndef QGSPLUGINLAYER_H #define QGSPLUGINLAYER_H +#include "qgis_core.h" #include "qgsmaplayer.h" typedef QList< QPair > QgsLegendSymbologyList; diff --git a/src/core/qgspluginlayerregistry.cpp b/src/core/qgspluginlayerregistry.cpp index 150e90c69e7..032c5356bf4 100644 --- a/src/core/qgspluginlayerregistry.cpp +++ b/src/core/qgspluginlayerregistry.cpp @@ -26,10 +26,6 @@ QgsPluginLayerType::QgsPluginLayerType( const QString& name ) { } -QgsPluginLayerType::~QgsPluginLayerType() -{ -} - QString QgsPluginLayerType::name() { return mName; @@ -52,19 +48,9 @@ bool QgsPluginLayerType::showLayerProperties( QgsPluginLayer *layer ) return false; } -//============================================================================= - -//! Static calls to enforce singleton behaviour -QgsPluginLayerRegistry* QgsPluginLayerRegistry::_instance = nullptr; -QgsPluginLayerRegistry* QgsPluginLayerRegistry::instance() -{ - if ( !_instance ) - { - _instance = new QgsPluginLayerRegistry(); - } - return _instance; -} - +// +// QgsPluginLayerRegistry +// QgsPluginLayerRegistry::QgsPluginLayerRegistry() { diff --git a/src/core/qgspluginlayerregistry.h b/src/core/qgspluginlayerregistry.h index 9d0a8fbf628..6407829be15 100644 --- a/src/core/qgspluginlayerregistry.h +++ b/src/core/qgspluginlayerregistry.h @@ -22,6 +22,8 @@ #include #include +#include "qgis_core.h" + class QgsPluginLayer; /** \ingroup core @@ -32,7 +34,7 @@ class CORE_EXPORT QgsPluginLayerType public: QgsPluginLayerType( const QString& name ); - virtual ~QgsPluginLayerType(); + virtual ~QgsPluginLayerType() = default; QString name(); @@ -54,17 +56,23 @@ class CORE_EXPORT QgsPluginLayerType //============================================================================= /** \ingroup core - a registry of plugin layers types + * A registry of plugin layers types. + * + * QgsPluginLayerRegistry is not usually directly created, but rather accessed through + * QgsApplication::pluginLayerRegistry(). */ class CORE_EXPORT QgsPluginLayerRegistry { public: - //! Means of accessing canonical single instance - static QgsPluginLayerRegistry* instance(); - + QgsPluginLayerRegistry(); ~QgsPluginLayerRegistry(); + //! QgsPluginLayerRegistry cannot be copied. + QgsPluginLayerRegistry( const QgsPluginLayerRegistry& rh ) = delete; + //! QgsPluginLayerRegistry cannot be copied. + QgsPluginLayerRegistry& operator=( const QgsPluginLayerRegistry& rh ) = delete; + /** List all known layer types * \note added in v2.1 */ QStringList pluginLayerTypes(); @@ -87,14 +95,6 @@ class CORE_EXPORT QgsPluginLayerRegistry typedef QMap PluginLayerTypes; - //! Private since instance() creates it - QgsPluginLayerRegistry(); - QgsPluginLayerRegistry( const QgsPluginLayerRegistry& rh ); - QgsPluginLayerRegistry& operator=( const QgsPluginLayerRegistry& rh ); - - //! Pointer to canonical Singleton object - static QgsPluginLayerRegistry* _instance; - PluginLayerTypes mPluginLayerTypes; }; diff --git a/src/core/qgspoint.cpp b/src/core/qgspoint.cpp index c366a542fff..01bf797c0bc 100644 --- a/src/core/qgspoint.cpp +++ b/src/core/qgspoint.cpp @@ -180,7 +180,7 @@ QString QgsPoint::toDegreesMinutesSeconds( int thePrecision, const bool useSuffi { //first, limit longitude to -360 to 360 degree range double myWrappedX = fmod( m_x, 360.0 ); - //next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W" + //next, wrap around longitudes > 180 or < -180 degrees, so that, e.g., "190E" -> "170W" if ( myWrappedX > 180.0 ) { myWrappedX = myWrappedX - 360.0; @@ -192,7 +192,7 @@ QString QgsPoint::toDegreesMinutesSeconds( int thePrecision, const bool useSuffi //first, limit latitude to -180 to 180 degree range double myWrappedY = fmod( m_y, 180.0 ); - //next, wrap around latitudes > 90 or < -90 degrees, so that eg "110S" -> "70N" + //next, wrap around latitudes > 90 or < -90 degrees, so that, e.g., "110S" -> "70N" if ( myWrappedY > 90.0 ) { myWrappedY = myWrappedY - 180.0; @@ -294,7 +294,7 @@ QString QgsPoint::toDegreesMinutes( int thePrecision, const bool useSuffix, cons { //first, limit longitude to -360 to 360 degree range double myWrappedX = fmod( m_x, 360.0 ); - //next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W" + //next, wrap around longitudes > 180 or < -180 degrees, so that, e.g., "190E" -> "170W" if ( myWrappedX > 180.0 ) { myWrappedX = myWrappedX - 360.0; diff --git a/src/core/qgspoint.h b/src/core/qgspoint.h index a62b124b1c4..ea65981ba21 100644 --- a/src/core/qgspoint.h +++ b/src/core/qgspoint.h @@ -18,6 +18,7 @@ #ifndef QGSPOINT_H #define QGSPOINT_H +#include "qgis_core.h" #include #include @@ -241,10 +242,10 @@ class CORE_EXPORT QgsPoint * Its up to the calling function to ensure that this point can * be meaningfully represented in this form. * @param thePrecision number of decimal points to use for seconds - * @param useSuffix set to true to include a direction suffix (eg 'N'), + * @param useSuffix set to true to include a direction suffix (e.g., 'N'), * set to false to use a "-" prefix for west and south coordinates * @param padded set to true to force minutes and seconds to use two decimals, - * eg, '05' instead of '5'. + * e.g., '05' instead of '5'. */ QString toDegreesMinutesSeconds( int thePrecision, const bool useSuffix = true, const bool padded = false ) const; @@ -252,10 +253,10 @@ class CORE_EXPORT QgsPoint * Its up to the calling function to ensure that this point can * be meaningfully represented in this form. * @param thePrecision number of decimal points to use for minutes - * @param useSuffix set to true to include a direction suffix (eg 'N'), + * @param useSuffix set to true to include a direction suffix (e.g., 'N'), * set to false to use a "-" prefix for west and south coordinates * @param padded set to true to force minutes to use two decimals, - * eg, '05' instead of '5'. + * e.g., '05' instead of '5'. */ QString toDegreesMinutes( int thePrecision, const bool useSuffix = true, const bool padded = false ) const; diff --git a/src/core/qgspointlocator.cpp b/src/core/qgspointlocator.cpp index 9264cd108f0..d32f1b8d215 100644 --- a/src/core/qgspointlocator.cpp +++ b/src/core/qgspointlocator.cpp @@ -65,7 +65,6 @@ class QgsPointLocator_Stream : public IDataStream : mDataList( dataList ) , mIt( mDataList ) { } - ~QgsPointLocator_Stream() { } virtual IData* getNext() override { return mIt.next(); } virtual bool hasNext() override { return mIt.hasNext(); } @@ -193,8 +192,6 @@ class QgsPointLocator_VisitorArea : public IVisitor , mGeomPt( QgsGeometry::fromPoint( origPt ) ) {} - ~QgsPointLocator_VisitorArea() {} - void visitNode( const INode& n ) override { Q_UNUSED( n ); } void visitData( std::vector& v ) override { Q_UNUSED( v ); } @@ -852,7 +849,7 @@ QgsPointLocator::Match QgsPointLocator::nearestVertex( const QgsPoint& point, do QgsRectangle rect( point.x() - tolerance, point.y() - tolerance, point.x() + tolerance, point.y() + tolerance ); mRTree->intersectsWithQuery( rect2region( rect ), visitor ); if ( m.isValid() && m.distance() > tolerance ) - return Match(); // // make sure that only match strictly within the tolerance is returned + return Match(); // make sure that only match strictly within the tolerance is returned return m; } @@ -874,7 +871,7 @@ QgsPointLocator::Match QgsPointLocator::nearestEdge( const QgsPoint& point, doub QgsRectangle rect( point.x() - tolerance, point.y() - tolerance, point.x() + tolerance, point.y() + tolerance ); mRTree->intersectsWithQuery( rect2region( rect ), visitor ); if ( m.isValid() && m.distance() > tolerance ) - return Match(); // // make sure that only match strictly within the tolerance is returned + return Match(); // make sure that only match strictly within the tolerance is returned return m; } diff --git a/src/core/qgspointlocator.h b/src/core/qgspointlocator.h index 8b3ba976185..ce0395d06cf 100644 --- a/src/core/qgspointlocator.h +++ b/src/core/qgspointlocator.h @@ -19,6 +19,7 @@ class QgsPoint; class QgsVectorLayer; +#include "qgis_core.h" #include "qgsfeature.h" #include "qgspoint.h" #include "qgscoordinatereferencesystem.h" @@ -176,7 +177,7 @@ class CORE_EXPORT QgsPointLocator : public QObject //! Implement the interface and pass its instance to QgsPointLocator or QgsSnappingUtils methods. struct MatchFilter { - virtual ~MatchFilter() {} + virtual ~MatchFilter() = default; virtual bool acceptMatch( const Match& match ) = 0; }; diff --git a/src/core/qgsproject.cpp b/src/core/qgsproject.cpp index 6815c99e8a6..620bb4c3000 100644 --- a/src/core/qgsproject.cpp +++ b/src/core/qgsproject.cpp @@ -106,16 +106,16 @@ QStringList makeKeyTokens_( const QString& scope, const QString& key ) @param scope scope of key @param key keyname - @param rootProperty is likely to be the top level QgsPropertyKey in QgsProject:e:Imp. + @param rootProperty is likely to be the top level QgsProjectPropertyKey in QgsProject:e:Imp. @return null if not found, otherwise located Property */ -QgsProperty* findKey_( const QString& scope, - const QString& key, - QgsPropertyKey& rootProperty ) +QgsProjectProperty* findKey_( const QString& scope, + const QString& key, + QgsProjectPropertyKey& rootProperty ) { - QgsPropertyKey* currentProperty = &rootProperty; - QgsProperty* nextProperty; // link to next property down hiearchy + QgsProjectPropertyKey* currentProperty = &rootProperty; + QgsProjectProperty* nextProperty; // link to next property down hiearchy QStringList keySequence = makeKeyTokens_( scope, key ); @@ -144,7 +144,7 @@ QgsProperty* findKey_( const QString& scope, { if ( nextProperty->isKey() ) { - currentProperty = static_cast( nextProperty ); + currentProperty = static_cast( nextProperty ); } else if ( nextProperty->isValue() && 1 == keySequence.count() ) { @@ -156,7 +156,7 @@ QgsProperty* findKey_( const QString& scope, } else { - // QgsPropertyValue not Key, so return null + // QgsProjectPropertyValue not Key, so return null return nullptr; } } @@ -185,17 +185,17 @@ QgsProperty* findKey_( const QString& scope, @param rootProperty is the property from which to start adding @param value the value associated with the key */ -QgsProperty *addKey_( const QString& scope, - const QString& key, - QgsPropertyKey* rootProperty, - const QVariant& value ) +QgsProjectProperty *addKey_( const QString& scope, + const QString& key, + QgsProjectPropertyKey* rootProperty, + const QVariant& value ) { QStringList keySequence = makeKeyTokens_( scope, key ); // cursor through property key/value hierarchy - QgsPropertyKey *currentProperty = rootProperty; - QgsProperty *nextProperty; // link to next property down hiearchy - QgsPropertyKey* newPropertyKey; + QgsProjectPropertyKey *currentProperty = rootProperty; + QgsProjectProperty *nextProperty; // link to next property down hiearchy + QgsProjectPropertyKey* newPropertyKey; while ( ! keySequence.isEmpty() ) { @@ -223,13 +223,13 @@ QgsProperty *addKey_( const QString& scope, } else if (( nextProperty = currentProperty->find( keySequence.first() ) ) ) { - currentProperty = dynamic_cast( nextProperty ); + currentProperty = dynamic_cast( nextProperty ); if ( currentProperty ) { continue; } - else // QgsPropertyValue not Key, so return null + else // QgsProjectPropertyValue not Key, so return null { return nullptr; } @@ -256,12 +256,12 @@ QgsProperty *addKey_( const QString& scope, void removeKey_( const QString& scope, const QString& key, - QgsPropertyKey &rootProperty ) + QgsProjectPropertyKey &rootProperty ) { - QgsPropertyKey *currentProperty = &rootProperty; + QgsProjectPropertyKey *currentProperty = &rootProperty; - QgsProperty *nextProperty = nullptr; // link to next property down hiearchy - QgsPropertyKey *previousQgsPropertyKey = nullptr; // link to previous property up hiearchy + QgsProjectProperty *nextProperty = nullptr; // link to next property down hiearchy + QgsProjectPropertyKey *previousQgsPropertyKey = nullptr; // link to previous property up hiearchy QStringList keySequence = makeKeyTokens_( scope, key ); @@ -290,13 +290,13 @@ void removeKey_( const QString& scope, else if (( nextProperty = currentProperty->find( keySequence.first() ) ) ) { previousQgsPropertyKey = currentProperty; - currentProperty = dynamic_cast( nextProperty ); + currentProperty = dynamic_cast( nextProperty ); if ( currentProperty ) { continue; } - else // QgsPropertyValue not Key, so return null + else // QgsProjectPropertyValue not Key, so return null { return; } @@ -448,7 +448,7 @@ void QgsProject::clear() mAutoTransaction = false; mEvaluateDefaultValues = false; mDirty = false; - mVariables.clear(); + mCustomVariables.clear(); mEmbeddedLayers.clear(); mRelationManager->clear(); @@ -475,7 +475,7 @@ void QgsProject::clear() } // basically a debugging tool to dump property list values -void dump_( const QgsPropertyKey& topQgsPropertyKey ) +void dump_( const QgsProjectPropertyKey& topQgsPropertyKey ) { QgsDebugMsg( "current properties:" ); topQgsPropertyKey.dump(); @@ -509,10 +509,10 @@ scope. "layers" is a list containing three string values. \endcode @param doc xml document -@param project_properties should be the top QgsPropertyKey node. +@param project_properties should be the top QgsProjectPropertyKey node. */ -void _getProperties( const QDomDocument& doc, QgsPropertyKey& project_properties ) +void _getProperties( const QDomDocument& doc, QgsProjectPropertyKey& project_properties ) { QDomNodeList properties = doc.elementsByTagName( QStringLiteral( "properties" ) ); @@ -719,7 +719,7 @@ bool QgsProject::addLayer( const QDomElement &layerElem, QList &broken else if ( type == QLatin1String( "plugin" ) ) { QString typeName = layerElem.attribute( QStringLiteral( "name" ) ); - mapLayer = QgsPluginLayerRegistry::instance()->createLayer( typeName ); + mapLayer = QgsApplication::pluginLayerRegistry()->createLayer( typeName ); } if ( !mapLayer ) @@ -757,9 +757,9 @@ bool QgsProject::addLayer( const QDomElement &layerElem, QList &broken } } -bool QgsProject::read( const QFileInfo& file ) +bool QgsProject::read( const QString& filename ) { - mFile.setFileName( file.filePath() ); + mFile.setFileName( filename ); return read(); } @@ -925,19 +925,19 @@ bool QgsProject::read() QStringList variableNames = readListEntry( QStringLiteral( "Variables" ), QStringLiteral( "/variableNames" ) ); QStringList variableValues = readListEntry( QStringLiteral( "Variables" ), QStringLiteral( "/variableValues" ) ); - mVariables.clear(); + mCustomVariables.clear(); if ( variableNames.length() == variableValues.length() ) { for ( int i = 0; i < variableNames.length(); ++i ) { - mVariables.insert( variableNames.at( i ), variableValues.at( i ) ); + mCustomVariables.insert( variableNames.at( i ), variableValues.at( i ) ); } } else { QgsMessageLog::logMessage( tr( "Project Variables Invalid" ), tr( "The project contains invalid variable settings." ) ); } - emit variablesChanged(); + emit customVariablesChanged(); // read the project: used by map canvas and legend emit readProject( *doc ); @@ -994,44 +994,54 @@ void QgsProject::loadEmbeddedNodes( QgsLayerTreeGroup *group ) } } -QgsStringMap QgsProject::variables() const +QVariantMap QgsProject::customVariables() const { - return mVariables; + return mCustomVariables; } -void QgsProject::setVariables( const QgsStringMap& variables ) +void QgsProject::setCustomVariables( const QVariantMap& variables ) { - if ( variables == mVariables ) + if ( variables == mCustomVariables ) return; //write variable to project QStringList variableNames; QStringList variableValues; - QMap< QString, QString >::const_iterator it = variables.constBegin(); + QVariantMap::const_iterator it = variables.constBegin(); for ( ; it != variables.constEnd(); ++it ) { variableNames << it.key(); - variableValues << it.value(); + variableValues << it.value().toString(); } writeEntry( QStringLiteral( "Variables" ), QStringLiteral( "/variableNames" ), variableNames ); writeEntry( QStringLiteral( "Variables" ), QStringLiteral( "/variableValues" ), variableValues ); - mVariables = variables; + mCustomVariables = variables; - emit variablesChanged(); + emit customVariablesChanged(); } -QStringList QgsProject::avoidIntersectionsList() const +QList QgsProject::avoidIntersectionsLayers() const { - return readListEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/AvoidIntersectionsList" ), QStringList() ); + QList layers; + QStringList layerIds = readListEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/AvoidIntersectionsList" ), QStringList() ); + Q_FOREACH ( const QString& layerId, layerIds ) + { + if ( QgsVectorLayer* vlayer = qobject_cast( mapLayer( layerId ) ) ) + layers << vlayer; + } + return layers; } -void QgsProject::setAvoidIntersectionsList( const QStringList& avoidIntersectionsList ) +void QgsProject::setAvoidIntersectionsLayers( const QList& layers ) { - writeEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/AvoidIntersectionsList" ), avoidIntersectionsList ); - emit avoidIntersectionsListChanged(); + QStringList list; + Q_FOREACH ( QgsVectorLayer* layer, layers ) + list << layer->id(); + writeEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/AvoidIntersectionsList" ), list ); + emit avoidIntersectionsLayersChanged(); } QgsExpressionContext QgsProject::createExpressionContext() const @@ -1039,7 +1049,7 @@ QgsExpressionContext QgsProject::createExpressionContext() const QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope(); + << QgsExpressionContextUtils::projectScope( this ); return context; } @@ -1123,7 +1133,7 @@ void QgsProject::cleanTransactionGroups( bool force ) emit transactionGroupsChanged(); } -bool QgsProject::read( QDomNode &layerNode ) +bool QgsProject::readLayer( const QDomNode& layerNode ) { QList brokenNodes; QList< QPair< QgsVectorLayer*, QDomElement > > vectorLayerList; @@ -1147,9 +1157,9 @@ bool QgsProject::read( QDomNode &layerNode ) return false; } -bool QgsProject::write( QFileInfo const &file ) +bool QgsProject::write( const QString& filename ) { - mFile.setFileName( file.filePath() ); + mFile.setFileName( filename ); return write(); } @@ -1390,7 +1400,7 @@ QStringList QgsProject::readListEntry( const QString& scope, const QStringList& def, bool* ok ) const { - QgsProperty* property = findKey_( scope, key, mProperties ); + QgsProjectProperty* property = findKey_( scope, key, mProperties ); QVariant value; @@ -1417,7 +1427,7 @@ QString QgsProject::readEntry( const QString& scope, const QString& def, bool* ok ) const { - QgsProperty *property = findKey_( scope, key, mProperties ); + QgsProjectProperty *property = findKey_( scope, key, mProperties ); QVariant value; @@ -1439,7 +1449,7 @@ QString QgsProject::readEntry( const QString& scope, int QgsProject::readNumEntry( const QString& scope, const QString &key, int def, bool* ok ) const { - QgsProperty *property = findKey_( scope, key, mProperties ); + QgsProjectProperty *property = findKey_( scope, key, mProperties ); QVariant value; @@ -1467,7 +1477,7 @@ double QgsProject::readDoubleEntry( const QString& scope, const QString& key, double def, bool* ok ) const { - QgsProperty *property = findKey_( scope, key, mProperties ); + QgsProjectProperty *property = findKey_( scope, key, mProperties ); if ( property ) { QVariant value = property->value(); @@ -1486,7 +1496,7 @@ double QgsProject::readDoubleEntry( const QString& scope, const QString& key, bool QgsProject::readBoolEntry( const QString& scope, const QString &key, bool def, bool* ok ) const { - QgsProperty *property = findKey_( scope, key, mProperties ); + QgsProjectProperty *property = findKey_( scope, key, mProperties ); if ( property ) { @@ -1516,13 +1526,13 @@ bool QgsProject::removeEntry( const QString& scope, const QString& key ) QStringList QgsProject::entryList( const QString& scope, const QString& key ) const { - QgsProperty *foundProperty = findKey_( scope, key, mProperties ); + QgsProjectProperty *foundProperty = findKey_( scope, key, mProperties ); QStringList entries; if ( foundProperty ) { - QgsPropertyKey *propertyKey = dynamic_cast( foundProperty ); + QgsProjectPropertyKey *propertyKey = dynamic_cast( foundProperty ); if ( propertyKey ) { propertyKey->entryList( entries ); } @@ -1533,13 +1543,13 @@ QStringList QgsProject::entryList( const QString& scope, const QString& key ) co QStringList QgsProject::subkeyList( const QString& scope, const QString& key ) const { - QgsProperty *foundProperty = findKey_( scope, key, mProperties ); + QgsProjectProperty *foundProperty = findKey_( scope, key, mProperties ); QStringList entries; if ( foundProperty ) { - QgsPropertyKey *propertyKey = dynamic_cast( foundProperty ); + QgsProjectPropertyKey *propertyKey = dynamic_cast( foundProperty ); if ( propertyKey ) { propertyKey->subkeyList( entries ); } @@ -2009,7 +2019,7 @@ QgsLayerTreeGroup *QgsProject::createEmbeddedGroup( const QString &groupName, co QgsLayerTreeLayer *layer = newGroup->findLayer( layerId ); if ( layer ) { - layer->setVisible( invisibleLayers.contains( layerId ) ? Qt::Unchecked : Qt::Checked ); + layer->setItemVisibilityChecked( invisibleLayers.contains( layerId ) ); } } diff --git a/src/core/qgsproject.h b/src/core/qgsproject.h index 99e8f0831dd..3017e572d65 100644 --- a/src/core/qgsproject.h +++ b/src/core/qgsproject.h @@ -21,6 +21,7 @@ #ifndef QGSPROJECT_H #define QGSPROJECT_H +#include "qgis_core.h" #include #include #include @@ -77,7 +78,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera Q_PROPERTY( QgsCoordinateReferenceSystem crs READ crs WRITE setCrs ) Q_PROPERTY( QgsMapThemeCollection* mapThemeCollection READ mapThemeCollection NOTIFY mapThemeCollectionChanged ) Q_PROPERTY( QgsSnappingConfig snappingConfig READ snappingConfig WRITE setSnappingConfig NOTIFY snappingConfigChanged ) - Q_PROPERTY( QStringList avoidIntersectionsList READ avoidIntersectionsList WRITE setAvoidIntersectionsList NOTIFY avoidIntersectionsListChanged ) + Q_PROPERTY( QList avoidIntersectionsLayers READ avoidIntersectionsLayers WRITE setAvoidIntersectionsLayers NOTIFY avoidIntersectionsLayersChanged ) public: //! Returns the QgsProject singleton instance @@ -146,7 +147,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera void setCrs( const QgsCoordinateReferenceSystem& crs ); /** - * Returns a proj string representing the project's ellipsoid setting, eg "WGS84". + * Returns a proj string representing the project's ellipsoid setting, e.g., "WGS84". * @see setEllipsoid() * @see crs() * @note added in QGIS 2.18 @@ -154,7 +155,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera QString ellipsoid() const; /** - * Sets the project's ellipsoid from a proj string representation, eg "WGS84". + * Sets the project's ellipsoid from a proj string representation, e.g., "WGS84". * @see ellipsoid() * @see setCrs() * @note added in QGIS 2.18 @@ -166,52 +167,37 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera */ void clear(); - /** Reads a project file. - * @param file name of project file to read - * @note Any current plug-in state is erased - * @note Calling read() performs the following operations: - * - * - Gets the extents - * - Creates maplayers - * - Registers maplayers - * - * @note it's presumed that the caller has already reset the map canvas, map registry, and legend + /** Reads given project file from the given file. + * @param filename name of project file to read + * @returns true if project file has been read successfully */ - bool read( const QFileInfo& file ); + bool read( const QString& filename ); - /** Reads the current project file. - * @note Any current plug-in state is erased - * @note Calling read() performs the following operations: - * - * - Gets the extents - * - Creates maplayers - * - Registers maplayers - * - * @note it's presumed that the caller has already reset the map canvas, map registry, and legend + /** Reads the project from its currently associated file (see fileName() ). + * @returns true if project file has been read successfully */ bool read(); /** Reads the layer described in the associated DOM node. + * + * @note This method is mainly for use by QgsProjectBadLayerHandler subclasses + * that may fix definition of bad layers with the user's help in GUI. Calling + * this method with corrected DOM node adds the layer back to the project. * * @param layerNode represents a QgsProject DOM node that encodes a specific layer. - * - * QgsProject raises an exception when one of the QgsProject::read() - * implementations fails. Since the read()s are invoked from qgisapp, - * then qgisapp handles the exception. It prompts the user for the new - * location of the data, if any. If there is a new location, the DOM - * node associated with the layer has its datasource tag corrected. - * Then that node is passed to this member function to be re-opened. - * */ - bool read( QDomNode& layerNode ); + bool readLayer( const QDomNode& layerNode ); - /** Writes the project to a file. - * @param file destination file + /** + * Writes the project to a file. + * @param filename destination file * @note calling this implicitly sets the project's filename (see setFileName() ) * @note isDirty() will be set to false if project is successfully written * @returns true if project was written successfully + * + * \note Added in QGIS 3.0 */ - bool write( const QFileInfo& file ); + bool write( const QString& filename ); /** Writes the project to its current associated file (see fileName() ). * @note isDirty() will be set to false if project is successfully written @@ -479,27 +465,27 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera * * @note Added in QGIS 3.0 */ - QStringList avoidIntersectionsList() const; + QList avoidIntersectionsLayers() const; /** * A list of layers with which intersections should be avoided. * * @note Added in QGIS 3.0 */ - void setAvoidIntersectionsList( const QStringList& avoidIntersectionsList ); + void setAvoidIntersectionsLayers( const QList& layers ); /** * A map of custom project variables. * To get all available variables including generated ones * use QgsExpressionContextUtils::projectScope() instead. */ - QgsStringMap variables() const; + QVariantMap customVariables() const; /** * A map of custom project variables. * Be careful not to set generated variables. */ - void setVariables( const QgsStringMap& variables ); + void setCustomVariables( const QVariantMap& customVariables ); // // Functionality from QgsMapLayerRegistry @@ -756,7 +742,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera /** Emitted whenever the expression variables stored in the project have been changed. * @note added in QGIS 3.0 */ - void variablesChanged(); + void customVariablesChanged(); /** * Emitted whenever a new transaction group has been created or a @@ -774,11 +760,11 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera void topologicalEditingChanged(); /** - * Emitted whenever avoidIntersectionsList has changed. + * Emitted whenever avoidIntersectionsLayers has changed. * * @note Added in QGIS 3.0 */ - void avoidIntersectionsListChanged(); + void avoidIntersectionsLayersChanged(); /** * Emitted when the map theme collection changes. @@ -983,10 +969,10 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera QScopedPointer mMapThemeCollection; - QgsStringMap mVariables; + QVariantMap mCustomVariables; QFile mFile; // current physical project file - mutable QgsPropertyKey mProperties; // property hierarchy, TODO: this shouldn't be mutable + mutable QgsProjectPropertyKey mProperties; // property hierarchy, TODO: this shouldn't be mutable QString mTitle; // project title bool mAutoTransaction; // transaction grouped editing bool mEvaluateDefaultValues; // evaluate default values immediately diff --git a/src/core/qgsprojectbadlayerhandler.cpp b/src/core/qgsprojectbadlayerhandler.cpp index 953487387c9..230e278f1a1 100644 --- a/src/core/qgsprojectbadlayerhandler.cpp +++ b/src/core/qgsprojectbadlayerhandler.cpp @@ -16,22 +16,19 @@ #include "qgsprojectbadlayerhandler.h" #include "qgslogger.h" #include "qgsmessagelog.h" +#include "qgsapplication.h" #include void QgsProjectBadLayerHandler::handleBadLayers( const QList& layers ) { - QgsMessageLog::instance()->logMessage( QStringLiteral( "%1 bad layers dismissed:" ).arg( layers.size() ) ); + QgsApplication::messageLog()->logMessage( QStringLiteral( "%1 bad layers dismissed:" ).arg( layers.size() ) ); Q_FOREACH ( const QDomNode& layer, layers ) { - QgsMessageLog::instance()->logMessage( QStringLiteral( " * %1" ).arg( dataSource( layer ) ) ); + QgsApplication::messageLog()->logMessage( QStringLiteral( " * %1" ).arg( dataSource( layer ) ) ); } } -QgsProjectBadLayerHandler::~QgsProjectBadLayerHandler() -{ -} - QgsProjectBadLayerHandler::DataType QgsProjectBadLayerHandler::dataType( const QDomNode& layerNode ) { QString type = layerNode.toElement().attribute( QStringLiteral( "type" ) ); diff --git a/src/core/qgsprojectbadlayerhandler.h b/src/core/qgsprojectbadlayerhandler.h index 91026468e68..27f2bae5d3b 100644 --- a/src/core/qgsprojectbadlayerhandler.h +++ b/src/core/qgsprojectbadlayerhandler.h @@ -18,6 +18,8 @@ #include +#include "qgis_core.h" + /** \ingroup core * Interface for classes that handle missing layer files when reading project file. */ @@ -35,10 +37,9 @@ class CORE_EXPORT QgsProjectBadLayerHandler * log. * * @note Added in QGIS 3.0 - * @see QgsProjectBadLayerGuiHandler */ virtual void handleBadLayers( const QList& layers ); - virtual ~QgsProjectBadLayerHandler(); + virtual ~QgsProjectBadLayerHandler() = default; protected: diff --git a/src/core/qgsprojectfiletransform.cpp b/src/core/qgsprojectfiletransform.cpp index 8f6ac9dcdeb..36dc925215e 100644 --- a/src/core/qgsprojectfiletransform.cpp +++ b/src/core/qgsprojectfiletransform.cpp @@ -404,7 +404,7 @@ void QgsProjectFileTransform::transform1100to1200() for ( int i = 0; i < tolList.childNodes().count(); i++ ) units << QStringLiteral( "0" ); - QgsPropertyValue value( units ); + QgsProjectPropertyValue value( units ); value.writeXml( QStringLiteral( "LayerSnappingToleranceUnitList" ), digitizing, mDom ); } diff --git a/src/core/qgsprojectfiletransform.h b/src/core/qgsprojectfiletransform.h index 55d7183cdee..f773f404e3e 100644 --- a/src/core/qgsprojectfiletransform.h +++ b/src/core/qgsprojectfiletransform.h @@ -26,10 +26,12 @@ #ifndef QGSPROJECTFILETRANSFORM_H #define QGSPROJECTFILETRANSFORM_H +#include "qgis_core.h" #include #include #include "qgsprojectversion.h" + class QgsRasterLayer; /** \ingroup core @@ -39,7 +41,6 @@ class CORE_EXPORT QgsProjectFileTransform public: //Default constructor //QgsProjectfiletransform() {} - ~QgsProjectFileTransform() {} /** Create an instance from a Dom and a supplied version * @param domDocument The Dom document to use as content diff --git a/src/core/qgsprojectproperty.cpp b/src/core/qgsprojectproperty.cpp index 8d30cc92a72..e69010eb65a 100644 --- a/src/core/qgsprojectproperty.cpp +++ b/src/core/qgsprojectproperty.cpp @@ -21,26 +21,18 @@ #include #include -QgsProperty::QgsProperty() +QgsProjectProperty::QgsProjectProperty() { } -QgsProperty::~QgsProperty() -{ -} - -QgsPropertyValue::~QgsPropertyValue() -{ -} - -void QgsPropertyValue::dump( int tabs ) const +void QgsProjectPropertyValue::dump( int tabs ) const { QString tabString; tabString.fill( '\t', tabs ); - if ( QVariant::StringList == value_.type() ) + if ( QVariant::StringList == mValue.type() ) { - QStringList sl = value_.toStringList(); + QStringList sl = mValue.toStringList(); for ( QStringList::const_iterator i = sl.begin(); i != sl.end(); ++i ) { @@ -49,12 +41,11 @@ void QgsPropertyValue::dump( int tabs ) const } else { - QgsDebugMsg( QString( "%1%2" ).arg( tabString, value_.toString() ) ); + QgsDebugMsg( QString( "%1%2" ).arg( tabString, mValue.toString() ) ); } -} // QgsPropertyValue::dump() +} - -bool QgsPropertyValue::readXml( QDomNode & keyNode ) +bool QgsProjectPropertyValue::readXml( const QDomNode& keyNode ) { // this *should* be a Dom element node QDomElement subkeyElement = keyNode.toElement(); @@ -71,7 +62,7 @@ bool QgsPropertyValue::readXml( QDomNode & keyNode ) // the values come in as strings; we need to restore them to their // original values *and* types - value_.clear(); + mValue.clear(); // get the type associated with the value first QVariant::Type type = QVariant::nameToType( typeString.toLocal8Bit().constData() ); @@ -98,7 +89,7 @@ bool QgsPropertyValue::readXml( QDomNode & keyNode ) return false; case QVariant::String: - value_ = subkeyElement.text(); // no translating necessary + mValue = subkeyElement.text(); // no translating necessary break; case QVariant::StringList: @@ -123,7 +114,7 @@ bool QgsPropertyValue::readXml( QDomNode & keyNode ) ++i; } - value_ = valueStringList; + mValue = valueStringList; break; } @@ -164,23 +155,23 @@ bool QgsPropertyValue::readXml( QDomNode & keyNode ) return false; case QVariant::Int: - value_ = QVariant( subkeyElement.text() ).toInt(); + mValue = QVariant( subkeyElement.text() ).toInt(); break; case QVariant::UInt: - value_ = QVariant( subkeyElement.text() ).toUInt(); + mValue = QVariant( subkeyElement.text() ).toUInt(); break; case QVariant::Bool: - value_ = QVariant( subkeyElement.text() ).toBool(); + mValue = QVariant( subkeyElement.text() ).toBool(); break; case QVariant::Double: - value_ = QVariant( subkeyElement.text() ).toDouble(); + mValue = QVariant( subkeyElement.text() ).toDouble(); break; case QVariant::ByteArray: - value_ = QVariant( subkeyElement.text() ).toByteArray(); + mValue = QVariant( subkeyElement.text() ).toByteArray(); break; case QVariant::Polygon: @@ -211,47 +202,43 @@ bool QgsPropertyValue::readXml( QDomNode & keyNode ) QgsDebugMsg( "no support for QVariant::Pen" ); return false; - // - // QGIS DIES NOT SUPPORT THESE VARIANT TYPES IN VERSION 3.1 DISABLING FOR NOW - // - /* - case QVariant::LongLong : - value_ = QVariant(subkeyElement.text()).toLongLong(); - break; +#if 0 // Currently unsupported variant types + case QVariant::LongLong : + value_ = QVariant( subkeyElement.text() ).toLongLong(); + break; + + case QVariant::ULongLong : + value_ = QVariant( subkeyElement.text() ).toULongLong(); + break; +#endif - case QVariant::ULongLong : - value_ = QVariant(subkeyElement.text()).toULongLong(); - break; - */ default : QgsDebugMsg( QString( "unsupported value type %1 .. not propertly translated to QVariant" ).arg( typeString ) ); } return true; -} // QgsPropertyValue::readXml +} -/** - keyElement created by parent QgsPropertyKey -*/ -bool QgsPropertyValue::writeXml( QString const & nodeName, - QDomElement & keyElement, - QDomDocument & document ) +// keyElement is created by parent QgsProjectPropertyKey +bool QgsProjectPropertyValue::writeXml( QString const & nodeName, + QDomElement & keyElement, + QDomDocument & document ) { QDomElement valueElement = document.createElement( nodeName ); // remember the type so that we can rebuild it when the project is read in - valueElement.setAttribute( QStringLiteral( "type" ), value_.typeName() ); + valueElement.setAttribute( QStringLiteral( "type" ), mValue.typeName() ); // we handle string lists differently from other types in that we // create a sequence of repeated elements to cover all the string list // members; each value will be in a tag. // XXX Not the most elegant way to handle string lists? - if ( QVariant::StringList == value_.type() ) + if ( QVariant::StringList == mValue.type() ) { - QStringList sl = value_.toStringList(); + QStringList sl = mValue.toStringList(); for ( QStringList::iterator i = sl.begin(); i != sl.end(); @@ -266,28 +253,28 @@ bool QgsPropertyValue::writeXml( QString const & nodeName, } else // we just plop the value in as plain ole text { - QDomText valueText = document.createTextNode( value_.toString() ); + QDomText valueText = document.createTextNode( mValue.toString() ); valueElement.appendChild( valueText ); } keyElement.appendChild( valueElement ); return true; -} // QgsPropertyValue::writeXml +} -QgsPropertyKey::QgsPropertyKey( const QString &name ) +QgsProjectPropertyKey::QgsProjectPropertyKey( const QString &name ) : mName( name ) {} -QgsPropertyKey::~QgsPropertyKey() +QgsProjectPropertyKey::~QgsProjectPropertyKey() { clearKeys(); } -QVariant QgsPropertyKey::value() const +QVariant QgsProjectPropertyKey::value() const { - QgsProperty *foundQgsProperty = mProperties.value( name() ); + QgsProjectProperty *foundQgsProperty = mProperties.value( name() ); if ( !foundQgsProperty ) { @@ -296,10 +283,10 @@ QVariant QgsPropertyKey::value() const } return foundQgsProperty->value(); -} // QVariant QgsPropertyKey::value() +} -void QgsPropertyKey::dump( int tabs ) const +void QgsProjectPropertyKey::dump( int tabs ) const { QString tabString; @@ -312,12 +299,12 @@ void QgsPropertyKey::dump( int tabs ) const if ( ! mProperties.isEmpty() ) { - QHashIterator < QString, QgsProperty* > i( mProperties ); + QHashIterator < QString, QgsProjectProperty* > i( mProperties ); while ( i.hasNext() ) { if ( i.next().value()->isValue() ) { - QgsPropertyValue * propertyValue = static_cast( i.value() ); + QgsProjectPropertyValue * propertyValue = static_cast( i.value() ); if ( QVariant::StringList == propertyValue->value().type() ) { @@ -334,7 +321,7 @@ void QgsPropertyKey::dump( int tabs ) const QgsDebugMsg( QString( "%1key: <%2> subkey: <%3>" ) .arg( tabString, i.key(), - dynamic_cast( i.value() )->name() ) ); + dynamic_cast( i.value() )->name() ) ); i.value()->dump( tabs + 1 ); } @@ -354,11 +341,11 @@ void QgsPropertyKey::dump( int tabs ) const } } -} // QgsPropertyKey::dump +} -bool QgsPropertyKey::readXml( QDomNode & keyNode ) +bool QgsProjectPropertyKey::readXml( const QDomNode& keyNode ) { int i = 0; QDomNodeList subkeys = keyNode.childNodes(); @@ -373,7 +360,7 @@ bool QgsPropertyKey::readXml( QDomNode & keyNode ) subkeys.item( i ).toElement().hasAttribute( QStringLiteral( "type" ) ) ) // and we have a "type" attribute { // then we're a key value delete mProperties.take( subkeys.item( i ).nodeName() ); - mProperties.insert( subkeys.item( i ).nodeName(), new QgsPropertyValue ); + mProperties.insert( subkeys.item( i ).nodeName(), new QgsProjectPropertyValue ); QDomNode subkey = subkeys.item( i ); @@ -398,14 +385,14 @@ bool QgsPropertyKey::readXml( QDomNode & keyNode ) } return true; -} // QgsPropertyKey::readXml(QDomNode & keyNode) +} -/** +/* Property keys will always create a Dom element for itself and then recursively call writeXml for any constituent properties. */ -bool QgsPropertyKey::writeXml( QString const &nodeName, QDomElement & element, QDomDocument & document ) +bool QgsProjectPropertyKey::writeXml( QString const &nodeName, QDomElement & element, QDomDocument & document ) { // If it's an _empty_ node (i.e., one with no properties) we need to emit // an empty place holder; else create new Dom elements as necessary. @@ -414,7 +401,7 @@ bool QgsPropertyKey::writeXml( QString const &nodeName, QDomElement & element, Q if ( ! mProperties.isEmpty() ) { - QHashIterator < QString, QgsProperty* > i( mProperties ); + QHashIterator < QString, QgsProjectProperty* > i( mProperties ); while ( i.hasNext() ) { i.next(); @@ -428,16 +415,12 @@ bool QgsPropertyKey::writeXml( QString const &nodeName, QDomElement & element, Q element.appendChild( keyElement ); return true; -} // QgsPropertyKey::writeXml +} - - -/** Return keys that do not contain other keys - */ -void QgsPropertyKey::entryList( QStringList & entries ) const +void QgsProjectPropertyKey::entryList( QStringList & entries ) const { // now add any leaf nodes to the entries list - QHashIterator < QString, QgsProperty* > i( mProperties ); + QHashIterator < QString, QgsProjectProperty* > i( mProperties ); while ( i.hasNext() ) { // add any of the nodes that have just a single value @@ -446,14 +429,12 @@ void QgsPropertyKey::entryList( QStringList & entries ) const entries.append( i.key() ); } } -} // QgsPropertyKey::entryList +} - - -void QgsPropertyKey::subkeyList( QStringList & entries ) const +void QgsProjectPropertyKey::subkeyList( QStringList & entries ) const { // now add any leaf nodes to the entries list - QHashIterator < QString, QgsProperty* > i( mProperties ); + QHashIterator < QString, QgsProjectProperty* > i( mProperties ); while ( i.hasNext() ) { // add any of the nodes that have just a single value @@ -462,10 +443,10 @@ void QgsPropertyKey::subkeyList( QStringList & entries ) const entries.append( i.key() ); } } -} // QgsPropertyKey::subkeyList +} -bool QgsPropertyKey::isLeaf() const +bool QgsProjectPropertyKey::isLeaf() const { if ( 0 == count() ) { @@ -473,7 +454,7 @@ bool QgsPropertyKey::isLeaf() const } else if ( 1 == count() ) { - QHashIterator < QString, QgsProperty* > i( mProperties ); + QHashIterator < QString, QgsProjectProperty* > i( mProperties ); if ( i.hasNext() && i.next().value()->isValue() ) { @@ -484,7 +465,7 @@ bool QgsPropertyKey::isLeaf() const return false; } -void QgsPropertyKey::setName( const QString& name ) +void QgsProjectPropertyKey::setName( const QString& name ) { mName = name; -} // QgsPropertyKey::isLeaf +} diff --git a/src/core/qgsprojectproperty.h b/src/core/qgsprojectproperty.h index ed92904846f..e2e735edd43 100644 --- a/src/core/qgsprojectproperty.h +++ b/src/core/qgsprojectproperty.h @@ -26,45 +26,57 @@ #include #include +#include "qgis_core.h" + class QDomNode; class QDomElement; class QDomDocument; -/** \ingroup core +/** + * \class QgsProjectProperty + * \ingroup core * An Abstract Base Class for QGIS project property hierarchies. - - Each sub-class is either a QgsPropertyKey or QgsPropertyValue. QgsPropertyKeys can - contain either QgsPropertyKeys or QgsPropertyValues, thus describing an - hierarchy. QgsPropertyValues are always graph leaves. - - @note - - This is really a hidden QgsProject implementation class. It was getting - too large and unwieldy, so it's broken out here into separate files. - + * + * Each sub-class is either a QgsProjectPropertyKey or QgsProjectPropertyValue. QgsProjectPropertyKey can + * contain either QgsProjectPropertyKey or QgsProjectPropertyValues, thus describing an + * hierarchy. QgsProjectPropertyValues are always graph leaves. + * + * @note This class is used internally by QgsProject. It's generally recommended that the methods in + * QgsProject are used to modify project properties rather than using these low-level classes. + * @note added in QGIS 3.0 */ -class CORE_EXPORT QgsProperty +class CORE_EXPORT QgsProjectProperty { public: - QgsProperty(); - virtual ~QgsProperty(); + QgsProjectProperty(); + virtual ~QgsProjectProperty() = default; - /** Dumps out the keys and values + /** + * Dumps out the keys and values * * @param tabs is number of tabs to print; used for pretty-printing hierarchy */ virtual void dump( int tabs = 0 ) const = 0; - //! Returns true if is a QgsPropertyKey + /** + * Returns true if the property is a QgsProjectPropertyKey. + * @see isValue() + * @see isLeaf() + */ virtual bool isKey() const = 0; - //! Returns true if is a QgsPropertyValue + /** + * Returns true if the property is a QgsProjectPropertyValue. + * @see isKey() + * @see isLeaf() + */ virtual bool isValue() const = 0; - /** Returns true if a leaf node + /** + * Returns true if property is a leaf node. * - * A leaf node is a key node that has either no value or a single value. + * A leaf node is a key node that has either no value or only a single value. * A non-leaf node would be a key node with key sub-nodes. * * This is used for entryList() and subkeyList() implementation. @@ -72,14 +84,14 @@ class CORE_EXPORT QgsProperty virtual bool isLeaf() const = 0; /** - * restores property hierarchy to given Dom node + * Restores the property hierarchy from a specified DOM node. * - * Used for restoring properties from project file + * Used for restoring properties from project file */ - virtual bool readXml( QDomNode & keyNode ) = 0; + virtual bool readXml( const QDomNode& keyNode ) = 0; /** - * adds property hierarchy to given Dom element + * Writes the property hierarchy to a specified DOM element. * * Used for saving properties to project file. * @@ -87,113 +99,99 @@ class CORE_EXPORT QgsProperty * @param element the parent (or encompassing) property element * @param document the overall project file Dom document */ - virtual bool writeXml( const QString & nodeName, - QDomElement & element, - QDomDocument & document ) = 0; + virtual bool writeXml( const QString& nodeName, + QDomElement& element, + QDomDocument& document ) = 0; - /** Return the node's value + /** + * Returns the node's value. * - * For QgsPropertyValue nodes, this is straightforward -- just return the - * embedded QVariant, _value. For QgsPropertyKey, this means returning - * the QgsPropertyValue _value that is keyed by its name, if it exists; - * i.e., QgsPropertyKey "foo" will return the property value mapped to its + * For QgsProjectPropertyValue nodes, this is straightforward -- just return the + * embedded QVariant, _value. For QgsProjectPropertyKey, this means returning + * the QgsProjectPropertyValue _value that is keyed by its name, if it exists; + * i.e., QgsProjectPropertyKey "foo" will return the property value mapped to its * name, "foo", in its QHash of QProperties. * */ virtual QVariant value() const = 0; -}; // class QgsProperty +}; - - -/** \ingroup core - * QgsPropertyValue node - -Contains a QgsPropertyKey's value +/** + * \class QgsProjectPropertyValue + * \ingroup core + * Project property value node, contains a QgsProjectPropertyKey's value. + * \note added in QGIS 3.0 */ -class CORE_EXPORT QgsPropertyValue : public QgsProperty +class CORE_EXPORT QgsProjectPropertyValue : public QgsProjectProperty { public: - QgsPropertyValue() {} - QgsPropertyValue( const QVariant &value ) - : value_( value ) + //! Constructor for QgsProjectPropertyValue. + QgsProjectPropertyValue() = default; + + /** + * Constructor for QgsProjectPropertyValue, initialized to a specified value. + */ + QgsProjectPropertyValue( const QVariant &value ) + : mValue( value ) {} - virtual ~QgsPropertyValue(); - - //! Returns true if is a QgsPropertyKey virtual bool isKey() const override { return false; } - - //! Returns true if is a QgsPropertyValue virtual bool isValue() const override { return true; } + QVariant value() const override { return mValue; } - QVariant value() const override { return value_; } - - /** Returns true if is a leaf node - * - * @note I suppose, in a way, value nodes can also be qualified as leaf - * nodes even though we're only counting key nodes. - */ + //value nodes can also be qualified as leaf nodes even though we only count key nodes. bool isLeaf() const override { return true; } void dump( int tabs = 0 ) const override; - - bool readXml( QDomNode & keyNode ) override; - - bool writeXml( const QString & nodeName, - QDomElement & element, - QDomDocument & document ) override; - - int count() const { return 0; } - - /** Return keys that do not contain other keys - * Since QgsPropertyValue isn't a key, don't do anything. - */ - void entryList( QStringList & keyName, QStringList & entries ) const - { Q_UNUSED( keyName ); Q_UNUSED( entries ); /* NOP */ } + bool readXml( const QDomNode& keyNode ) override; + bool writeXml( const QString& nodeName, + QDomElement& element, + QDomDocument& document ) override; private: - /** We use QVariant as it's very handy to keep multiple types and provides - * type conversions - */ - QVariant value_; + // We use QVariant as it's very handy to keep multiple types and provides type conversions + QVariant mValue; -}; // class QgsPropertyValue +}; - - -/** \ingroup core - QgsPropertyKey node - - Can, itself, contain QgsPropertyKeys and QgsPropertyValues. - - The internal QHash, mProperties, maps key names to their respective - QgsPropertyValue or next QgsPropertyKey in the key name sequence. The key with - the current name should contain its QgsPropertyValue. - - E.g., given the key sequence "/foo/bar", "foo" will have a corresponding - QgsPropertyKey with a name "foo". It will contain an element in its - mProperties that maps to "bar", which is another QgsPropertyKey. The "bar" - QgsPropertyKey will, in turn, have an element that maps to itself, i.e. "bar", - that will contain a QgsPropertyValue. - +/** + * \class QgsProjectPropertyKey + * \ingroup core + * + * Project property key node. + * + * Can, itself, contain QgsProjectPropertyKey and QgsProjectPropertyValues. + * + * The internal QHash, mProperties, maps key names to their respective + * QgsProjectPropertyValue or next QgsProjectPropertyKey in the key name sequence. The key with + * the current name should contain its QgsProjectPropertyValue. + * + * E.g., given the key sequence "/foo/bar", "foo" will have a corresponding + * QgsProjectPropertyKey with a name "foo". It will contain an element in its + * mProperties that maps to "bar", which is another QgsProjectPropertyKey. The "bar" + * QgsProjectPropertyKey will, in turn, have an element that maps to itself, i.e. "bar", + * that will contain a QgsProjectPropertyValue. + * + * \note added in QGIS 3.0 */ -class CORE_EXPORT QgsPropertyKey : public QgsProperty +class CORE_EXPORT QgsProjectPropertyKey : public QgsProjectProperty { public: /** - * Create a new QgsPropertyKey with the specified identifier. + * Create a new QgsProjectPropertyKey with the specified identifier. */ - QgsPropertyKey( const QString& name = QString() ); - virtual ~QgsPropertyKey(); + QgsProjectPropertyKey( const QString& name = QString() ); + virtual ~QgsProjectPropertyKey(); /** * The name of the property is used as identifier. + * @see setName() */ QString name() const { return mName; } @@ -201,6 +199,7 @@ class CORE_EXPORT QgsPropertyKey : public QgsProperty * The name of the property is used as identifier. * * @note Added in QGIS 3.0 + * @see name() */ void setName( const QString& name ); @@ -210,34 +209,43 @@ class CORE_EXPORT QgsPropertyKey : public QgsProperty */ QVariant value() const override; - - /// add the given property key - QgsPropertyKey *addKey( const QString & keyName ) + /** + * Adds the specified property key as a sub-key. + */ + QgsProjectPropertyKey* addKey( const QString& keyName ) { - delete mProperties.take( keyName ); - mProperties.insert( keyName, new QgsPropertyKey( keyName ) ); + if ( mProperties.contains( keyName ) ) + delete mProperties.take( keyName ); - return dynamic_cast( mProperties.value( keyName ) ); + QgsProjectPropertyKey* p = new QgsProjectPropertyKey( keyName ); + mProperties.insert( keyName, p ); + + return p; } - - /// remove the given key + /** + * Removes the specified key. + */ void removeKey( const QString & keyName ) { delete mProperties.take( keyName ); } - /** Set the value associated with this key + /** + * Sets the value associated with this key. * @param name is the key name * @param value is the value to set * @return pointer to property value */ - QgsPropertyValue * setValue( const QString & name, const QVariant & value ) + QgsProjectPropertyValue* setValue( const QString & name, const QVariant & value ) { - delete mProperties.take( name ); - mProperties.insert( name, new QgsPropertyValue( value ) ); + if ( mProperties.contains( name ) ) + delete mProperties.take( name ); - return dynamic_cast( mProperties.value( name ) ); + QgsProjectPropertyValue* p = new QgsProjectPropertyValue( value ); + mProperties.insert( name, p ); + + return p; } /** Set the value associated with this key @@ -245,68 +253,75 @@ class CORE_EXPORT QgsPropertyKey : public QgsProperty * @note that the single value node associated with each key is always * stored keyed by the current key name */ - QgsPropertyValue * setValue( const QVariant & value ) + QgsProjectPropertyValue * setValue( const QVariant & value ) { return setValue( name(), value ); } void dump( int tabs = 0 ) const override; - - bool readXml( QDomNode & keyNode ) override; - + bool readXml( const QDomNode& keyNode ) override; bool writeXml( const QString &nodeName, QDomElement & element, QDomDocument & document ) override; - /// how many elements are contained within this one? + /** + * Returns the number of sub-keys contained by this property. + */ int count() const { return mProperties.count(); } - /// Does this property not have any subkeys or values? - /* virtual */ bool isEmpty() const { return mProperties.isEmpty(); } - - //! Returns true if is a QgsPropertyKey - virtual bool isKey() const override { return true; } - - //! Returns true if is a QgsPropertyValue - virtual bool isValue() const override { return false; } - - /// return keys that do not contain other keys - void entryList( QStringList & entries ) const; - - /// return keys that contain other keys - void subkeyList( QStringList & entries ) const; - - /** Returns true if a leaf node - * A leaf node is a key node that has either no value or a single value. - * A non-leaf node would be a key node with key sub-nodes. + /** + * Returns true if this property contains no sub-keys. */ + bool isEmpty() const { return mProperties.isEmpty(); } + + virtual bool isKey() const override { return true; } + virtual bool isValue() const override { return false; } bool isLeaf() const override; - /// reset the QgsProperty key to prestine state + /** + * Returns any sub-keys contained by this property that do not contain other keys. + * @see subkeyList() + */ + void entryList( QStringList & entries ) const; + + /** + * Return any sub-keys contained by this property which themselves contain other keys. + * @see entryList() + */ + void subkeyList( QStringList & entries ) const; + + /** + * Resets the property to a default, empty state. + */ virtual void clear() { - mName = QLatin1String( "" ); + mName.clear(); clearKeys(); } - /// delete any sub-nodes + /** + * Deletes any sub-nodes from the property. + */ virtual void clearKeys() { qDeleteAll( mProperties ); mProperties.clear(); } - QgsProperty * find( QString & propertyName ) + /** + * Attempts to find a property with a matching sub-key name. + */ + QgsProjectProperty* find( const QString& propertyName ) const { return mProperties.value( propertyName ); } private: - /// every key has a name + //! Name of the key QString mName; - /// sub-keys - QHash < QString, QgsProperty* > mProperties; + //! Sub-keys + QHash < QString, QgsProjectProperty* > mProperties; -}; // class QgsPropertyKey +}; #endif diff --git a/src/core/qgsprojectversion.h b/src/core/qgsprojectversion.h index abdc9122b90..63d56037eee 100644 --- a/src/core/qgsprojectversion.h +++ b/src/core/qgsprojectversion.h @@ -20,6 +20,7 @@ #include #include +#include "qgis_core.h" /** \ingroup core * A class to describe the version of a project. @@ -40,7 +41,7 @@ class CORE_EXPORT QgsProjectVersion , mMinor( 0 ) , mSub( 0 ) {} - ~QgsProjectVersion() {} + QgsProjectVersion( int major, int minor, int sub, const QString& name = "" ); QgsProjectVersion( const QString& string ); int majorVersion() { return mMajor;} diff --git a/src/core/qgsprovidermetadata.h b/src/core/qgsprovidermetadata.h index bb5defad318..fed76695e27 100644 --- a/src/core/qgsprovidermetadata.h +++ b/src/core/qgsprovidermetadata.h @@ -22,6 +22,8 @@ #include +#include "qgis_core.h" + /** \ingroup core * Holds data provider key, description, and associated shared library file information. diff --git a/src/core/qgsproviderregistry.h b/src/core/qgsproviderregistry.h index c35967ea178..a723d45cf90 100644 --- a/src/core/qgsproviderregistry.h +++ b/src/core/qgsproviderregistry.h @@ -25,6 +25,8 @@ #include #include +#include "qgis_core.h" + class QgsDataProvider; class QgsProviderMetadata; diff --git a/src/core/qgspythonrunner.cpp b/src/core/qgspythonrunner.cpp index 1e99173c54d..9a48b6fcab2 100644 --- a/src/core/qgspythonrunner.cpp +++ b/src/core/qgspythonrunner.cpp @@ -65,7 +65,3 @@ QgsPythonRunner::QgsPythonRunner() { } -QgsPythonRunner::~QgsPythonRunner() -{ - -} diff --git a/src/core/qgspythonrunner.h b/src/core/qgspythonrunner.h index 07fc0edd79f..9bfa6edc5b1 100644 --- a/src/core/qgspythonrunner.h +++ b/src/core/qgspythonrunner.h @@ -17,6 +17,8 @@ #include +#include "qgis_core.h" + /** \ingroup core Utility class for running python commands from various parts of QGIS. There is no direct python support in the core library, so it is expected @@ -48,7 +50,7 @@ class CORE_EXPORT QgsPythonRunner protected: //! Protected constructor: can be instantiated only from children QgsPythonRunner(); - virtual ~QgsPythonRunner(); + virtual ~QgsPythonRunner() = default; virtual bool runCommand( QString command, QString messageOnError = QString() ) = 0; diff --git a/src/core/qgsrectangle.h b/src/core/qgsrectangle.h index 00c51acfe3a..8c6fa6fe2e6 100644 --- a/src/core/qgsrectangle.h +++ b/src/core/qgsrectangle.h @@ -18,6 +18,7 @@ #ifndef QGSRECTANGLE_H #define QGSRECTANGLE_H +#include "qgis_core.h" #include #include @@ -43,7 +44,7 @@ class CORE_EXPORT QgsRectangle QgsRectangle( const QRectF & qRectF ); //! Copy constructor QgsRectangle( const QgsRectangle &other ); - //! Destructor + ~QgsRectangle(); //! Set the rectangle from two QgsPoints. The rectangle is //! normalised after construction. diff --git a/src/core/qgsrelation.h b/src/core/qgsrelation.h index 93d0d0aa385..92eded123b4 100644 --- a/src/core/qgsrelation.h +++ b/src/core/qgsrelation.h @@ -16,6 +16,7 @@ #ifndef QGSRELATION_H #define QGSRELATION_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/qgsrelationmanager.h b/src/core/qgsrelationmanager.h index 1bbeb52f727..23e9f09a04b 100644 --- a/src/core/qgsrelationmanager.h +++ b/src/core/qgsrelationmanager.h @@ -16,6 +16,7 @@ #ifndef QGSRELATIONMANAGER_H #define QGSRELATIONMANAGER_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/qgsrenderchecker.h b/src/core/qgsrenderchecker.h index 187e23a522d..d724296bd4e 100644 --- a/src/core/qgsrenderchecker.h +++ b/src/core/qgsrenderchecker.h @@ -16,6 +16,7 @@ #ifndef QGSRENDERCHECKER_H #define QGSRENDERCHECKER_H +#include "qgis_core.h" #include #include #include @@ -39,9 +40,6 @@ class CORE_EXPORT QgsRenderChecker QgsRenderChecker(); - //! Destructor - ~QgsRenderChecker() {} - QString controlImagePath() const; QString report() { return mReport; } diff --git a/src/core/qgsrendercontext.h b/src/core/qgsrendercontext.h index 1bcb3267791..f0c0495f020 100644 --- a/src/core/qgsrendercontext.h +++ b/src/core/qgsrendercontext.h @@ -18,6 +18,7 @@ #ifndef QGSRENDERCONTEXT_H #define QGSRENDERCONTEXT_H +#include "qgis_core.h" #include #include "qgsabstractgeometry.h" diff --git a/src/core/qgsrulebasedlabeling.h b/src/core/qgsrulebasedlabeling.h index 62b3a777dd4..ea6bb3547d8 100644 --- a/src/core/qgsrulebasedlabeling.h +++ b/src/core/qgsrulebasedlabeling.h @@ -15,6 +15,7 @@ #ifndef QGSRULEBASEDLABELING_H #define QGSRULEBASEDLABELING_H +#include "qgis_core.h" #include #include @@ -57,6 +58,11 @@ class CORE_EXPORT QgsRuleBasedLabeling : public QgsAbstractVectorLayerLabeling Rule( QgsPalLayerSettings* settings, int scaleMinDenom = 0, int scaleMaxDenom = 0, const QString& filterExp = QString(), const QString& description = QString(), bool elseRule = false ); ~Rule(); + //! Rules cannot be copied. + Rule( const Rule& rh ) = delete; + //! Rules cannot be copied. + Rule& operator=( const Rule& rh ) = delete; + //! The result of registering a rule enum RegisterResult { @@ -298,10 +304,6 @@ class CORE_EXPORT QgsRuleBasedLabeling : public QgsAbstractVectorLayerLabeling // temporary QgsExpression* mFilter; - private: - - Rule( const Rule& rh ); - Rule& operator=( const Rule& rh ); }; diff --git a/src/core/qgsrunprocess.h b/src/core/qgsrunprocess.h index ad1e59983d3..e3de96ef125 100644 --- a/src/core/qgsrunprocess.h +++ b/src/core/qgsrunprocess.h @@ -24,6 +24,8 @@ #include #include +#include "qgis_core.h" + class QgsMessageOutput; /** \ingroup core diff --git a/src/core/qgsruntimeprofiler.h b/src/core/qgsruntimeprofiler.h index 5ad6ecd7b3f..0bba5f7cb3c 100644 --- a/src/core/qgsruntimeprofiler.h +++ b/src/core/qgsruntimeprofiler.h @@ -5,6 +5,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * \class QgsRuntimeProfiler */ diff --git a/src/core/qgsscalecalculator.h b/src/core/qgsscalecalculator.h index 615b841b5b4..4403131e989 100644 --- a/src/core/qgsscalecalculator.h +++ b/src/core/qgsscalecalculator.h @@ -19,6 +19,7 @@ #ifndef QGSSCALECALCULATOR_H #define QGSSCALECALCULATOR_H +#include "qgis_core.h" #include #include "qgsunittypes.h" diff --git a/src/core/qgsscaleexpression.h b/src/core/qgsscaleexpression.h index 040cca229b7..66dcd0c9699 100644 --- a/src/core/qgsscaleexpression.h +++ b/src/core/qgsscaleexpression.h @@ -16,6 +16,7 @@ #ifndef QGSSCALEEXPRESSION_H #define QGSSCALEEXPRESSION_H +#include "qgis_core.h" #include "qgsexpression.h" /** \ingroup core diff --git a/src/core/qgsscaleutils.h b/src/core/qgsscaleutils.h index 68cfee2bd14..00dc96a7ab0 100644 --- a/src/core/qgsscaleutils.h +++ b/src/core/qgsscaleutils.h @@ -16,6 +16,8 @@ #include #include +#include "qgis_core.h" + #ifndef QGSSCALEUTILS_H #define QGSSCALEUTILS_H diff --git a/src/core/qgssimplifymethod.h b/src/core/qgssimplifymethod.h index 065cd04b59c..26745334e31 100644 --- a/src/core/qgssimplifymethod.h +++ b/src/core/qgssimplifymethod.h @@ -16,6 +16,8 @@ #ifndef QGSSIMPLIFYMETHOD_H #define QGSSIMPLIFYMETHOD_H +#include "qgis_core.h" + class QgsAbstractGeometrySimplifier; /** \ingroup core diff --git a/src/core/qgsslconnect.h b/src/core/qgsslconnect.h index 897b095e6ea..5b4db206250 100644 --- a/src/core/qgsslconnect.h +++ b/src/core/qgsslconnect.h @@ -18,6 +18,8 @@ #include +#include "qgis_core.h" + struct sqlite3; /** \ingroup core diff --git a/src/core/qgssnapper.h b/src/core/qgssnapper.h index 75afc8cb61e..0b8bbc43dd5 100644 --- a/src/core/qgssnapper.h +++ b/src/core/qgssnapper.h @@ -18,6 +18,7 @@ #ifndef QGSSNAPPER_H #define QGSSNAPPER_H +#include "qgis_core.h" #include "qgspoint.h" #include "qgstolerance.h" #include "qgsfeature.h" diff --git a/src/core/qgssnappingconfig.cpp b/src/core/qgssnappingconfig.cpp index 1145421e348..4159a50d2e6 100644 --- a/src/core/qgssnappingconfig.cpp +++ b/src/core/qgssnappingconfig.cpp @@ -111,10 +111,6 @@ QgsSnappingConfig::QgsSnappingConfig( QgsProject* project ) reset(); } -QgsSnappingConfig::~QgsSnappingConfig() -{ -} - bool QgsSnappingConfig::operator==( const QgsSnappingConfig& other ) const { return mEnabled == other.mEnabled diff --git a/src/core/qgssnappingconfig.h b/src/core/qgssnappingconfig.h index 6cc89f9ab2d..abf58adbf5c 100644 --- a/src/core/qgssnappingconfig.h +++ b/src/core/qgssnappingconfig.h @@ -16,6 +16,7 @@ #ifndef QGSPROJECTSNAPPINGSETTINGS_H #define QGSPROJECTSNAPPINGSETTINGS_H +#include "qgis_core.h" #include "qgstolerance.h" class QDomDocument; @@ -124,8 +125,6 @@ class CORE_EXPORT QgsSnappingConfig */ explicit QgsSnappingConfig( QgsProject* project = nullptr ); - ~QgsSnappingConfig(); - bool operator==( const QgsSnappingConfig& other ) const; //! reset to default values diff --git a/src/core/qgssnappingutils.cpp b/src/core/qgssnappingutils.cpp index e28adadfc40..b3616f2fcee 100644 --- a/src/core/qgssnappingutils.cpp +++ b/src/core/qgssnappingutils.cpp @@ -91,7 +91,9 @@ bool QgsSnappingUtils::isIndexPrepared( QgsVectorLayer* vl, const QgsRectangle& if ( mStrategy == IndexAlwaysFull && loc->hasIndex() ) return true; - if ( mStrategy == IndexHybrid && loc->hasIndex() && ( !loc->extent() || loc->extent()->contains( areaOfInterest ) ) ) + QgsRectangle aoi( areaOfInterest ); + aoi.scale( 0.999 ); + if (( mStrategy == IndexHybrid || mStrategy == IndexExtent ) && loc->hasIndex() && ( !loc->extent() || loc->extent()->contains( aoi ) ) ) return true; return false; // the index - even if it exists - is not suitable @@ -339,7 +341,13 @@ void QgsSnappingUtils::prepareIndex( const QList& layers QTime tt; tt.start(); QgsPointLocator* loc = locatorForLayer( vl ); - if ( mStrategy == IndexHybrid ) + if ( mStrategy == IndexExtent ) + { + QgsRectangle rect( mMapSettings.extent() ); + loc->setExtent( &rect ); + loc->init(); + } + else if ( mStrategy == IndexHybrid ) { // first time the layer is used? - let's set an initial guess about indexing if ( !mHybridMaxAreaPerLayer.contains( vl->id() ) ) @@ -487,7 +495,7 @@ QString QgsSnappingUtils::dump() .arg( layer.layer->name() ) .arg( layer.type ).arg( layer.tolerance ).arg( layer.unit ); - if ( mStrategy == IndexAlwaysFull || mStrategy == IndexHybrid ) + if ( mStrategy == IndexAlwaysFull || mStrategy == IndexHybrid || mStrategy == IndexExtent ) { if ( QgsPointLocator* loc = locatorForLayer( layer.layer ) ) { diff --git a/src/core/qgssnappingutils.h b/src/core/qgssnappingutils.h index 8cb5050ce43..7b46fa2b948 100644 --- a/src/core/qgssnappingutils.h +++ b/src/core/qgssnappingutils.h @@ -17,6 +17,7 @@ #define QGSSNAPPINGUTILS_H +#include "qgis_core.h" #include "qgsmapsettings.h" #include "qgstolerance.h" #include "qgspointlocator.h" @@ -89,7 +90,8 @@ class CORE_EXPORT QgsSnappingUtils : public QObject { IndexAlwaysFull, //!< For all layers build index of full extent. Uses more memory, but queries are faster. IndexNeverFull, //!< For all layers only create temporary indexes of small extent. Low memory usage, slower queries. - IndexHybrid //!< For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and memory usage. + IndexHybrid, //!< For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and memory usage. + IndexExtent //!< For all layer build index of extent given in map settings }; //! Set a strategy for indexing geometry data - determines how fast and memory consuming the data structures will be diff --git a/src/core/qgsspatialindex.h b/src/core/qgsspatialindex.h index 8a9ba9ff8ab..8d549ec4356 100644 --- a/src/core/qgsspatialindex.h +++ b/src/core/qgsspatialindex.h @@ -34,6 +34,7 @@ class QgsFeature; class QgsRectangle; class QgsPoint; +#include "qgis_core.h" #include #include diff --git a/src/core/qgssqlexpressioncompiler.cpp b/src/core/qgssqlexpressioncompiler.cpp index 6ebac5507f2..05fdfc9e5a2 100644 --- a/src/core/qgssqlexpressioncompiler.cpp +++ b/src/core/qgssqlexpressioncompiler.cpp @@ -22,11 +22,6 @@ QgsSqlExpressionCompiler::QgsSqlExpressionCompiler( const QgsFields& fields, Fla { } -QgsSqlExpressionCompiler::~QgsSqlExpressionCompiler() -{ - -} - QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::compile( const QgsExpression* exp ) { if ( exp->rootNode() ) @@ -220,7 +215,8 @@ QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::compileNode( const Qg break; case QgsExpression::boDiv: - return Fail; // handle cast to real + op = QStringLiteral( "/" ); + break; case QgsExpression::boMod: op = QStringLiteral( "%" ); @@ -231,7 +227,8 @@ QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::compileNode( const Qg break; case QgsExpression::boIntDiv: - return Fail; // handle cast to int + op = QStringLiteral( "/" ); + break; case QgsExpression::boPow: op = QStringLiteral( "^" ); @@ -254,7 +251,27 @@ QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::compileNode( const Qg if ( failOnPartialNode && ( lr == Partial || rr == Partial ) ) return Fail; + if ( n->op() == QgsExpression::boDiv && mFlags.testFlag( IntegerDivisionResultsInInteger ) ) + { + right = castToReal( right ); + if ( right.isEmpty() ) + { + // not supported + return Fail; + } + } + result = '(' + left + ' ' + op + ' ' + right + ')'; + if ( n->op() == QgsExpression::boIntDiv ) + { + result = castToInt( result ); + if ( result.isEmpty() ) + { + // not supported + return Fail; + } + } + if ( lr == Complete && rr == Complete ) return ( partialCompilation ? Partial : Complete ); else if (( lr == Partial && rr == Complete ) || ( lr == Complete && rr == Partial ) || ( lr == Partial && rr == Partial ) ) @@ -319,11 +336,46 @@ QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::compileNode( const Qg if ( rn != Complete && rn != Partial ) return rn; - result = QStringLiteral( "%1 %2IN(%3)" ).arg( nd, n->isNotIn() ? "NOT " : "", list.join( QStringLiteral( "," ) ) ); + result = QStringLiteral( "%1 %2IN (%3)" ).arg( nd, n->isNotIn() ? "NOT " : "", list.join( QStringLiteral( "," ) ) ); return ( inResult == Partial || rn == Partial ) ? Partial : Complete; } case QgsExpression::ntFunction: + { + const QgsExpression::NodeFunction* n = static_cast( node ); + QgsExpression::Function* fd = QgsExpression::Functions()[n->fnIndex()]; + + // get sql function to compile node expression + QString nd = sqlFunctionFromFunctionName( fd->name() ); + // if no sql function the node can't be compiled + if ( nd.isEmpty() ) + return Fail; + + // compile arguments + QStringList args; + Result inResult = Complete; + Q_FOREACH ( const QgsExpression::Node* ln, n->args()->list() ) + { + QString s; + Result r = compileNode( ln, s ); + if ( r == Complete || r == Partial ) + { + args << s; + if ( r == Partial ) + inResult = Partial; + } + else + return r; + } + + // update arguments to be adapted to SQL function + args = sqlArgumentsFromFunctionName( fd->name(), args ); + + // build result + result = QStringLiteral( "%1(%2)" ).arg( nd, args.join( ',' ) ); + return inResult == Partial ? Partial : Complete; + } + case QgsExpression::ntCondition: break; } @@ -331,6 +383,30 @@ QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::compileNode( const Qg return Fail; } +QString QgsSqlExpressionCompiler::sqlFunctionFromFunctionName( const QString& fnName ) const +{ + Q_UNUSED( fnName ); + return QString(); +} + +QStringList QgsSqlExpressionCompiler::sqlArgumentsFromFunctionName( const QString& fnName, const QStringList& fnArgs ) const +{ + Q_UNUSED( fnName ); + return QStringList( fnArgs ); +} + +QString QgsSqlExpressionCompiler::castToReal( const QString& value ) const +{ + Q_UNUSED( value ); + return QString(); +} + +QString QgsSqlExpressionCompiler::castToInt( const QString& value ) const +{ + Q_UNUSED( value ); + return QString(); +} + bool QgsSqlExpressionCompiler::nodeIsNullLiteral( const QgsExpression::Node* node ) const { if ( node->nodeType() != QgsExpression::ntLiteral ) diff --git a/src/core/qgssqlexpressioncompiler.h b/src/core/qgssqlexpressioncompiler.h index ccf683d387c..37eefc5e7db 100644 --- a/src/core/qgssqlexpressioncompiler.h +++ b/src/core/qgssqlexpressioncompiler.h @@ -16,6 +16,7 @@ #ifndef QGSSQLEXPRESSIONCOMPILER_H #define QGSSQLEXPRESSIONCOMPILER_H +#include "qgis_core.h" #include "qgsexpression.h" #include "qgsfields.h" @@ -47,10 +48,11 @@ class CORE_EXPORT QgsSqlExpressionCompiler */ enum Flag { - CaseInsensitiveStringMatch = 0x01, //!< Provider performs case-insensitive string matching for all strings - LikeIsCaseInsensitive = 0x02, //!< Provider treats LIKE as case-insensitive - NoNullInBooleanLogic = 0x04, //!< Provider does not support using NULL with boolean logic, eg "(...) OR NULL" - NoUnaryMinus = 0x08, //!< Provider does not unary minus, eg " -( 100 * 2 ) = ..." + CaseInsensitiveStringMatch = 1, //!< Provider performs case-insensitive string matching for all strings + LikeIsCaseInsensitive = 1 << 1, //!< Provider treats LIKE as case-insensitive + NoNullInBooleanLogic = 1 << 2, //!< Provider does not support using NULL with boolean logic, e.g., "(...) OR NULL" + NoUnaryMinus = 1 << 3, //!< Provider does not unary minus, e.g., " -( 100 * 2 ) = ..." + IntegerDivisionResultsInInteger = 1 << 4, //!< Dividing int by int results in int on provider. Subclass must implement the castToReal() function to allow compilation of division. }; Q_DECLARE_FLAGS( Flags, Flag ) @@ -59,7 +61,7 @@ class CORE_EXPORT QgsSqlExpressionCompiler * @param flags flags which control how expression is compiled */ explicit QgsSqlExpressionCompiler( const QgsFields& fields, QgsSqlExpressionCompiler::Flags flags = Flags() ); - virtual ~QgsSqlExpressionCompiler(); + virtual ~QgsSqlExpressionCompiler() = default; /** Compiles an expression and returns the result of the compilation. */ @@ -93,6 +95,36 @@ class CORE_EXPORT QgsSqlExpressionCompiler */ virtual Result compileNode( const QgsExpression::Node* node, QString& str ); + /** Return the SQL function for the expression function. + * Derived classes should override this to help compile functions + * @param fnName expression function name + * @returns the SQL function name + */ + virtual QString sqlFunctionFromFunctionName( const QString& fnName ) const; + + /** Return the Arguments for SQL function for the expression function. + * Derived classes should override this to help compile functions + * @param fnName expression function name + * @param fnArgs arguments from expression + * @returns the arguments updated for SQL Function + */ + virtual QStringList sqlArgumentsFromFunctionName( const QString& fnName, const QStringList& fnArgs ) const; + + /** + * Casts a value to a real result. Subclasses which indicate the IntegerDivisionResultsInInteger + * flag must reimplement this to cast a numeric value to a real type value so that division results + * in a real value result instead of integer. + * @note added in QGIS 3.0 + */ + virtual QString castToReal( const QString& value ) const; + + /** + * Casts a value to a integer result. Subclasses must reimplement this to cast a numeric value to a integer + * type value so that integer division results in a integer value result instead of real. + * @note added in QGIS 3.0 + */ + virtual QString castToInt( const QString& value ) const; + QString mResult; QgsFields mFields; diff --git a/src/core/qgssqliteexpressioncompiler.cpp b/src/core/qgssqliteexpressioncompiler.cpp index e0f87d55787..803532385cd 100644 --- a/src/core/qgssqliteexpressioncompiler.cpp +++ b/src/core/qgssqliteexpressioncompiler.cpp @@ -19,7 +19,7 @@ #include "qgssqlexpressioncompiler.h" QgsSQLiteExpressionCompiler::QgsSQLiteExpressionCompiler( const QgsFields& fields ) - : QgsSqlExpressionCompiler( fields, QgsSqlExpressionCompiler::LikeIsCaseInsensitive ) + : QgsSqlExpressionCompiler( fields, QgsSqlExpressionCompiler::LikeIsCaseInsensitive | QgsSqlExpressionCompiler::IntegerDivisionResultsInInteger ) { } @@ -84,4 +84,38 @@ QString QgsSQLiteExpressionCompiler::quotedValue( const QVariant& value, bool& o } } +static const QMap& functionNamesSqlFunctionsMap() +{ + static QMap fnNames; + if ( fnNames.isEmpty() ) + { + fnNames = + { + { "abs", "abs" }, + { "char", "char" }, + { "coalesce", "coalesce" }, + { "lower", "lower" }, + { "round", "round" }, + { "trim", "trim" }, + { "upper", "upper" }, + }; + } + return fnNames; +} + +QString QgsSQLiteExpressionCompiler::sqlFunctionFromFunctionName( const QString& fnName ) const +{ + return functionNamesSqlFunctionsMap().value( fnName, QString() ); +} + +QString QgsSQLiteExpressionCompiler::castToReal( const QString& value ) const +{ + return QStringLiteral( "CAST((%1) AS REAL)" ).arg( value ); +} + +QString QgsSQLiteExpressionCompiler::castToInt( const QString& value ) const +{ + return QStringLiteral( "CAST((%1) AS INTEGER)" ).arg( value ); +} + ///@endcond diff --git a/src/core/qgssqliteexpressioncompiler.h b/src/core/qgssqliteexpressioncompiler.h index ec5e02679cf..1c6fa8b5bdc 100644 --- a/src/core/qgssqliteexpressioncompiler.h +++ b/src/core/qgssqliteexpressioncompiler.h @@ -18,6 +18,7 @@ ///@cond PRIVATE +#include "qgis_core.h" #include "qgssqlexpressioncompiler.h" /** \ingroup core @@ -44,6 +45,9 @@ class CORE_EXPORT QgsSQLiteExpressionCompiler : public QgsSqlExpressionCompiler virtual Result compileNode( const QgsExpression::Node* node, QString& str ) override; virtual QString quotedIdentifier( const QString& identifier ) override; virtual QString quotedValue( const QVariant& value, bool& ok ) override; + virtual QString sqlFunctionFromFunctionName( const QString& fnName ) const override; + virtual QString castToReal( const QString& value ) const override; + virtual QString castToInt( const QString& value ) const override; }; diff --git a/src/core/qgssqlstatement.h b/src/core/qgssqlstatement.h index 3b888795a62..08c5bf001bc 100644 --- a/src/core/qgssqlstatement.h +++ b/src/core/qgssqlstatement.h @@ -24,6 +24,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core Class for parsing SQL statements. * @note Added in QGIS 2.16 @@ -196,7 +198,7 @@ class CORE_EXPORT QgsSQLStatement class CORE_EXPORT Node { public: - virtual ~Node() {} + virtual ~Node() = default; /** * Abstract virtual that returns the type of this node. @@ -693,7 +695,7 @@ class CORE_EXPORT QgsSQLStatement class CORE_EXPORT Visitor { public: - virtual ~Visitor() {} + virtual ~Visitor() = default; //! Visit NodeUnaryOperator virtual void visit( const NodeUnaryOperator& n ) = 0; //! Visit NodeBinaryOperator diff --git a/src/core/qgsstatisticalsummary.cpp b/src/core/qgsstatisticalsummary.cpp index b478cae55c0..f165521fa7c 100644 --- a/src/core/qgsstatisticalsummary.cpp +++ b/src/core/qgsstatisticalsummary.cpp @@ -31,11 +31,6 @@ QgsStatisticalSummary::QgsStatisticalSummary( Statistics stats ) reset(); } -QgsStatisticalSummary::~QgsStatisticalSummary() -{ - -} - void QgsStatisticalSummary::reset() { mCount = 0; @@ -107,7 +102,19 @@ void QgsStatisticalSummary::addVariant( const QVariant& value ) void QgsStatisticalSummary::finalize() { if ( mCount == 0 ) + { + mMin = std::numeric_limits::quiet_NaN(); + mMax = std::numeric_limits::quiet_NaN(); + mMean = std::numeric_limits::quiet_NaN(); + mMedian = std::numeric_limits::quiet_NaN(); + mStdev = std::numeric_limits::quiet_NaN(); + mSampleStdev = std::numeric_limits::quiet_NaN(); + mMinority = std::numeric_limits::quiet_NaN(); + mMajority = std::numeric_limits::quiet_NaN(); + mFirstQuartile = std::numeric_limits::quiet_NaN(); + mThirdQuartile = std::numeric_limits::quiet_NaN(); return; + } mMean = mSum / mCount; diff --git a/src/core/qgsstatisticalsummary.h b/src/core/qgsstatisticalsummary.h index 5232cb4dc46..a4cc8c72f5b 100644 --- a/src/core/qgsstatisticalsummary.h +++ b/src/core/qgsstatisticalsummary.h @@ -19,6 +19,8 @@ #include #include +#include "qgis_core.h" + /*************************************************************************** * This class is considered CRITICAL and any change MUST be accompanied with * full unit tests in testqgsstatisticalsummary.cpp. @@ -69,16 +71,16 @@ class CORE_EXPORT QgsStatisticalSummary */ QgsStatisticalSummary( QgsStatisticalSummary::Statistics stats = All ); - virtual ~QgsStatisticalSummary(); + virtual ~QgsStatisticalSummary() = default; /** Returns flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg sum, min and max). + * are always calculated (e.g., sum, min and max). * @see setStatistics */ Statistics statistics() const { return mStatistics; } /** Sets flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg sum, min and max). + * are always calculated (e.g., sum, min and max). * @param stats flags for statistics to calculate * @see statistics */ @@ -135,7 +137,8 @@ class CORE_EXPORT QgsStatisticalSummary /** Returns the value of a specified statistic * @param stat statistic to return - * @returns calculated value of statistic + * @returns calculated value of statistic. A NaN value may be returned for invalid + * statistics. */ double statistic( Statistic stat ) const; @@ -152,35 +155,42 @@ class CORE_EXPORT QgsStatisticalSummary */ double sum() const { return mSum; } - /** Returns calculated mean of values + /** Returns calculated mean of values. A NaN value may be returned if the mean cannot + * be calculated. */ double mean() const { return mMean; } /** Returns calculated median of values. This is only calculated if Statistic::Median has - * been specified in the constructor or via setStatistics. + * been specified in the constructor or via setStatistics. A NaN value may be returned if the median cannot + * be calculated. */ double median() const { return mMedian; } - /** Returns calculated minimum from values. + /** Returns calculated minimum from values. A NaN value may be returned if the minimum cannot + * be calculated. */ double min() const { return mMin; } - /** Returns calculated maximum from values. + /** Returns calculated maximum from values. A NaN value may be returned if the maximum cannot + * be calculated. */ double max() const { return mMax; } - /** Returns calculated range (difference between maximum and minimum values). + /** Returns calculated range (difference between maximum and minimum values). A NaN value may be returned if the range cannot + * be calculated. */ - double range() const { return mMax - mMin; } + double range() const { return qIsNaN( mMax ) || qIsNaN( mMin ) ? std::numeric_limits::quiet_NaN() : mMax - mMin; } /** Returns population standard deviation. This is only calculated if Statistic::StDev has - * been specified in the constructor or via setStatistics. + * been specified in the constructor or via setStatistics. A NaN value may be returned if the standard deviation cannot + * be calculated. * @see sampleStDev */ double stDev() const { return mStdev; } /** Returns sample standard deviation. This is only calculated if Statistic::StDev has - * been specified in the constructor or via setStatistics. + * been specified in the constructor or via setStatistics. A NaN value may be returned if the standard deviation cannot + * be calculated. * @see stDev */ double sampleStDev() const { return mSampleStdev; } @@ -193,38 +203,43 @@ class CORE_EXPORT QgsStatisticalSummary /** Returns minority of values. The minority is the value with least occurances in the list * This is only calculated if Statistic::Minority has been specified in the constructor - * or via setStatistics. + * or via setStatistics. A NaN value may be returned if the minority cannot + * be calculated. * @see majority */ double minority() const { return mMinority; } /** Returns majority of values. The majority is the value with most occurances in the list * This is only calculated if Statistic::Majority has been specified in the constructor - * or via setStatistics. + * or via setStatistics. A NaN value may be returned if the majority cannot + * be calculated. * @see minority */ double majority() const { return mMajority; } /** Returns the first quartile of the values. The quartile is calculated using the - * "Tukey's hinges" method. + * "Tukey's hinges" method. A NaN value may be returned if the first quartile cannot + * be calculated. * @see thirdQuartile * @see interQuartileRange */ double firstQuartile() const { return mFirstQuartile; } /** Returns the third quartile of the values. The quartile is calculated using the - * "Tukey's hinges" method. + * "Tukey's hinges" method. A NaN value may be returned if the third quartile cannot + * be calculated. * @see firstQuartile * @see interQuartileRange */ double thirdQuartile() const { return mThirdQuartile; } /** Returns the inter quartile range of the values. The quartiles are calculated using the - * "Tukey's hinges" method. + * "Tukey's hinges" method. A NaN value may be returned if the IQR cannot + * be calculated. * @see firstQuartile * @see thirdQuartile */ - double interQuartileRange() const { return mThirdQuartile - mFirstQuartile; } + double interQuartileRange() const { return qIsNaN( mThirdQuartile ) || qIsNaN( mFirstQuartile ) ? std::numeric_limits::quiet_NaN() : mThirdQuartile - mFirstQuartile; } /** Returns the friendly display name for a statistic * @param statistic statistic to return name for diff --git a/src/core/qgsstringstatisticalsummary.h b/src/core/qgsstringstatisticalsummary.h index b1f7baf4042..ba3993ce281 100644 --- a/src/core/qgsstringstatisticalsummary.h +++ b/src/core/qgsstringstatisticalsummary.h @@ -19,6 +19,8 @@ #include #include +#include "qgis_core.h" + /*************************************************************************** * This class is considered CRITICAL and any change MUST be accompanied with * full unit tests in test_qgsstringstatisticalsummary.py. @@ -62,13 +64,13 @@ class CORE_EXPORT QgsStringStatisticalSummary QgsStringStatisticalSummary( QgsStringStatisticalSummary::Statistics stats = All ); /** Returns flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg count). + * are always calculated (e.g., count). * @see setStatistics */ Statistics statistics() const { return mStatistics; } /** Sets flags which specify which statistics will be calculated. Some statistics - * are always calculated (eg count). + * are always calculated (e.g., count). * @param stats flags for statistics to calculate * @see statistics */ diff --git a/src/core/qgsstringutils.h b/src/core/qgsstringutils.h index bd6f8097f8e..d9b986d5ab3 100644 --- a/src/core/qgsstringutils.h +++ b/src/core/qgsstringutils.h @@ -13,6 +13,7 @@ * * ***************************************************************************/ +#include "qgis_core.h" #include #include #include @@ -195,7 +196,7 @@ class CORE_EXPORT QgsStringUtils static int levenshteinDistance( const QString &string1, const QString &string2, bool caseSensitive = false ); /** Returns the longest common substring between two strings. This substring is the longest - * string that is a substring of the two input strings. Eg, the longest common substring + * string that is a substring of the two input strings. For example, the longest common substring * of "ABABC" and "BABCA" is "ABC". * @param string1 first string * @param string2 second string @@ -221,7 +222,7 @@ class CORE_EXPORT QgsStringUtils */ static QString soundex( const QString &string ); - /** Returns a string with any URL (eg http(s)/ftp) and mailto: text converted to valid HTML + /** Returns a string with any URL (e.g., http(s)/ftp) and mailto: text converted to valid HTML * links. * @param string string to insert links into * @param foundLinks if specified, will be set to true if any links were inserted into the string diff --git a/src/core/qgstaskmanager.h b/src/core/qgstaskmanager.h index 99365fd22d1..4dc4f994a43 100644 --- a/src/core/qgstaskmanager.h +++ b/src/core/qgstaskmanager.h @@ -23,6 +23,8 @@ #include #include +#include "qgis_core.h" + class QgsTask; class QgsTaskRunnableWrapper; @@ -213,7 +215,7 @@ class CORE_EXPORT QgsTask : public QObject /** * Will be emitted by task if it has terminated for any reason - * other then completion (eg when a task has been cancelled or encountered + * other then completion (e.g., when a task has been cancelled or encountered * an internal error). * @note derived classes should not emit this signal directly, it will automatically * be emitted diff --git a/src/core/qgstextlabelfeature.h b/src/core/qgstextlabelfeature.h index 59db97bcf0f..15fb249e940 100644 --- a/src/core/qgstextlabelfeature.h +++ b/src/core/qgstextlabelfeature.h @@ -32,7 +32,7 @@ class QgsTextLabelFeature : public QgsLabelFeature ~QgsTextLabelFeature(); /** Returns the text component corresponding to a specified label part - * @param partId Set to -1 for labels which are not broken into parts (eg, non-curved labels), or the required + * @param partId Set to -1 for labels which are not broken into parts (e.g., non-curved labels), or the required * part index for labels which are broken into parts (curved labels) * @note added in QGIS 2.10 */ diff --git a/src/core/qgstextrenderer.h b/src/core/qgstextrenderer.h index 9c3da97b6b9..c992d0616e9 100644 --- a/src/core/qgstextrenderer.h +++ b/src/core/qgstextrenderer.h @@ -17,6 +17,7 @@ #ifndef QGSTEXTRENDERER_H #define QGSTEXTRENDERER_H +#include "qgis_core.h" #include "qgsmapunitscale.h" #include "qgsunittypes.h" #include @@ -257,12 +258,12 @@ class CORE_EXPORT QgsTextBackgroundSettings */ void setEnabled( bool enabled ); - /** Returns the type of background shape (eg square, ellipse, SVG). + /** Returns the type of background shape (e.g., square, ellipse, SVG). * @see setType() */ ShapeType type() const; - /** Sets the type of background shape to draw (eg square, ellipse, SVG). + /** Sets the type of background shape to draw (e.g., square, ellipse, SVG). * @param type shape type * @see type() */ @@ -280,14 +281,14 @@ class CORE_EXPORT QgsTextBackgroundSettings */ void setSvgFile( const QString& file ); - /** Returns the method used to determine the size of the background shape (eg fixed size or buffer + /** Returns the method used to determine the size of the background shape (e.g., fixed size or buffer * around text). * @see setSizeType() * @see size() */ SizeType sizeType() const; - /** Sets the method used to determine the size of the background shape (eg fixed size or buffer + /** Sets the method used to determine the size of the background shape (e.g., fixed size or buffer * around text). * @param type size method * @see sizeType() @@ -295,8 +296,8 @@ class CORE_EXPORT QgsTextBackgroundSettings */ void setSizeType( SizeType type ); - /** Returns the size of the background shape. The meaning of the size depends on the current sizeType() - * eg, for size types of QgsTextBackgroundSettings::SizeFixed the size will represent the actual width and + /** Returns the size of the background shape. The meaning of the size depends on the current sizeType(), + * e.g., for size types of QgsTextBackgroundSettings::SizeFixed the size will represent the actual width and * height of the shape, for QgsTextBackgroundSettings::SizeBuffer the size will represent the horizontal * and vertical margins to add to the text when calculating the size of the shape. * @see setSize() @@ -304,8 +305,8 @@ class CORE_EXPORT QgsTextBackgroundSettings */ QSizeF size() const; - /** Sets the size of the background shape. The meaning of the size depends on the current sizeType() - * eg, for size types of QgsTextBackgroundSettings::SizeFixed the size will represent the actual width and + /** Sets the size of the background shape. The meaning of the size depends on the current sizeType(), + * e.g., for size types of QgsTextBackgroundSettings::SizeFixed the size will represent the actual width and * height of the shape, for QgsTextBackgroundSettings::SizeBuffer the size will represent the horizontal * and vertical margins to add to the text when calculating the size of the shape. * @param size QSizeF representing horizontal and vertical size components for shape @@ -634,14 +635,14 @@ class CORE_EXPORT QgsTextShadowSettings void setEnabled( bool enabled ); /** Returns the placement for the drop shadow. The placement determines - * both the z-order stacking position for the shadow and the what shape (eg text, + * both the z-order stacking position for the shadow and the what shape (e.g., text, * background shape) is used for casting the shadow. * @see setShadowPlacement() */ QgsTextShadowSettings::ShadowPlacement shadowPlacement() const; /** Sets the placement for the drop shadow. The placement determines - * both the z-order stacking position for the shadow and the what shape (eg text, + * both the z-order stacking position for the shadow and the what shape (e.g., text, * background shape) is used for casting the shadow. * @param placement shadow placement * @see shadowPlacement() @@ -939,14 +940,14 @@ class CORE_EXPORT QgsTextFormat */ void setFont( const QFont& font ); - /** Returns the named style for the font used for rendering text (eg "bold"). + /** Returns the named style for the font used for rendering text (e.g., "bold"). * @see setNamedStyle() * @see font() */ QString namedStyle() const; /** Sets the named style for the font used for rendering text. - * @param style named style, eg "bold" + * @param style named style, e.g., "bold" * @see namedStyle() * @see setFont() */ @@ -1183,7 +1184,7 @@ class CORE_EXPORT QgsTextRenderer * @param context render context * @param format text format * @param part component of text to draw. Note that Shadow parts cannot be drawn - * individually and instead are drawn with their associated part (eg drawn together + * individually and instead are drawn with their associated part (e.g., drawn together * with the text or background parts) * @param drawAsOutlines set to false to render text as text. This allows outputs to * formats like SVG to maintain text as text objects, but at the cost of degraded @@ -1201,7 +1202,7 @@ class CORE_EXPORT QgsTextRenderer * @param context render context * @param format text format * @param part component of text to draw. Note that Shadow parts cannot be drawn - * individually and instead are drawn with their associated part (eg drawn together + * individually and instead are drawn with their associated part (e.g., drawn together * with the text or background parts) * @param drawAsOutlines set to false to render text as text. This allows outputs to * formats like SVG to maintain text as text objects, but at the cost of degraded diff --git a/src/core/qgstextrenderer_p.h b/src/core/qgstextrenderer_p.h index 741fd3797ee..43fae457676 100644 --- a/src/core/qgstextrenderer_p.h +++ b/src/core/qgstextrenderer_p.h @@ -17,6 +17,7 @@ #ifndef QGSTEXTRENDERER_PRIVATE_H #define QGSTEXTRENDERER_PRIVATE_H +#include "qgis_core.h" #include "qgstextrenderer.h" #include "qgsmapunitscale.h" #include "qgsunittypes.h" @@ -66,8 +67,6 @@ class CORE_EXPORT QgsTextBufferSettingsPrivate : public QSharedData { } - ~QgsTextBufferSettingsPrivate() {} - bool enabled; double size; QgsUnitTypes::RenderUnit sizeUnit; @@ -134,8 +133,6 @@ class CORE_EXPORT QgsTextBackgroundSettingsPrivate : public QSharedData { } - ~QgsTextBackgroundSettingsPrivate() {} - bool enabled; QgsTextBackgroundSettings::ShapeType type; QString svgFile; @@ -205,8 +202,6 @@ class CORE_EXPORT QgsTextShadowSettingsPrivate : public QSharedData { } - ~QgsTextShadowSettingsPrivate() {} - bool enabled; QgsTextShadowSettings::ShadowPlacement shadowUnder; int offsetAngle; @@ -254,13 +249,11 @@ class CORE_EXPORT QgsTextSettingsPrivate : public QSharedData { } - ~QgsTextSettingsPrivate() {} - QFont textFont; QString textNamedStyle; QgsUnitTypes::RenderUnit fontSizeUnits; QgsMapUnitScale fontSizeMapUnitScale; - double fontSize; //may differ from size in textFont due to units (eg size in map units) + double fontSize; //may differ from size in textFont due to units (e.g., size in map units) QColor textColor; double opacity; QPainter::CompositionMode blendMode; diff --git a/src/core/qgstolerance.h b/src/core/qgstolerance.h index 214d8e64357..1580b3f0257 100644 --- a/src/core/qgstolerance.h +++ b/src/core/qgstolerance.h @@ -16,6 +16,7 @@ #ifndef QGSTOLERANCE_H #define QGSTOLERANCE_H +#include "qgis_core.h" #include "qgis.h" class QgsMapSettings; diff --git a/src/core/qgstracer.h b/src/core/qgstracer.h index a43490a354d..bc88a1296ac 100644 --- a/src/core/qgstracer.h +++ b/src/core/qgstracer.h @@ -18,6 +18,7 @@ class QgsVectorLayer; +#include "qgis_core.h" #include #include diff --git a/src/core/qgstrackedvectorlayertools.h b/src/core/qgstrackedvectorlayertools.h index 32ef3a78267..a03313b0698 100644 --- a/src/core/qgstrackedvectorlayertools.h +++ b/src/core/qgstrackedvectorlayertools.h @@ -16,6 +16,7 @@ #ifndef QGSTRACKEDVECTORLAYERTOOLS_H #define QGSTRACKEDVECTORLAYERTOOLS_H +#include "qgis_core.h" #include "qgsvectorlayertools.h" /** \ingroup gui diff --git a/src/core/qgstransaction.h b/src/core/qgstransaction.h index b2f2eedb836..48317d9b6d8 100644 --- a/src/core/qgstransaction.h +++ b/src/core/qgstransaction.h @@ -22,6 +22,8 @@ #include #include +#include "qgis_core.h" + class QgsVectorDataProvider; class QgsVectorLayer; @@ -51,6 +53,12 @@ class CORE_EXPORT QgsTransaction : public QObject Q_OBJECT public: + + //! QgsTransaction cannot be copied. + QgsTransaction( const QgsTransaction& other ) = delete; + //! QgsTransaction cannot be copied. + const QgsTransaction& operator=( const QgsTransaction& other ) = delete; + //! Creates a transaction for the specified connection string and provider static QgsTransaction* create( const QString& connString, const QString& providerKey ); @@ -106,8 +114,6 @@ class CORE_EXPORT QgsTransaction : public QObject QString mConnString; private: - QgsTransaction( const QgsTransaction& other ); - const QgsTransaction& operator=( const QgsTransaction& other ); bool mTransactionActive; QSet mLayers; diff --git a/src/core/qgstransactiongroup.cpp b/src/core/qgstransactiongroup.cpp index 486c9fc8e01..786c8ee86ce 100644 --- a/src/core/qgstransactiongroup.cpp +++ b/src/core/qgstransactiongroup.cpp @@ -30,10 +30,6 @@ QgsTransactionGroup::QgsTransactionGroup( QObject *parent ) } -QgsTransactionGroup::~QgsTransactionGroup() -{ -} - bool QgsTransactionGroup::addLayer( QgsVectorLayer* layer ) { if ( !QgsTransaction::supportsTransaction( layer ) ) diff --git a/src/core/qgstransactiongroup.h b/src/core/qgstransactiongroup.h index b92171c6442..284f4c46c53 100644 --- a/src/core/qgstransactiongroup.h +++ b/src/core/qgstransactiongroup.h @@ -16,11 +16,12 @@ #ifndef QGSTRANSACTIONGROUP_H #define QGSTRANSACTIONGROUP_H +#include "qgis_core.h" #include #include +#include "qgstransaction.h" class QgsVectorLayer; -class QgsTransaction; /** \ingroup core * \class QgsTransactionGroup @@ -31,8 +32,6 @@ class CORE_EXPORT QgsTransactionGroup : public QObject public: explicit QgsTransactionGroup( QObject *parent = 0 ); - ~QgsTransactionGroup(); - /** * Add a layer to this transaction group. * diff --git a/src/core/qgsunittypes.h b/src/core/qgsunittypes.h index 00dc9a0ebc1..56f862ee9d3 100644 --- a/src/core/qgsunittypes.h +++ b/src/core/qgsunittypes.h @@ -18,6 +18,7 @@ #ifndef QGSUNITTYPES_H #define QGSUNITTYPES_H +#include "qgis_core.h" #include "qgis.h" /*************************************************************************** @@ -56,7 +57,7 @@ class CORE_EXPORT QgsUnitTypes enum DistanceUnitType { Standard = 0, //!< Unit is a standard measurement unit - Geographic, //!< Unit is a geographic (eg degree based) unit + Geographic, //!< Unit is a geographic (e.g., degree based) unit UnknownType, //!< Unknown unit type }; @@ -93,8 +94,8 @@ class CORE_EXPORT QgsUnitTypes RenderMillimeters = 0, //!< Millimeters RenderMapUnits, //!< Map units RenderPixels, //!< Pixels - RenderPercentage, //!< Percentage of another measurement (eg canvas size, feature size) - RenderPoints, //! points (eg for font sizes) + RenderPercentage, //!< Percentage of another measurement (e.g., canvas size, feature size) + RenderPoints, //! points (e.g., for font sizes) RenderUnknownUnit, //!< Mixed or unknown units }; @@ -183,7 +184,7 @@ class CORE_EXPORT QgsUnitTypes */ Q_INVOKABLE static double fromUnitToUnitFactor( AreaUnit fromUnit, AreaUnit toUnit ); - /** Converts a distance unit to its corresponding area unit, eg meters to square meters + /** Converts a distance unit to its corresponding area unit, e.g., meters to square meters * @param distanceUnit distance unit to convert * @return matching areal unit */ diff --git a/src/core/qgsvectordataprovider.cpp b/src/core/qgsvectordataprovider.cpp index 0c0958f271c..b383efe57db 100644 --- a/src/core/qgsvectordataprovider.cpp +++ b/src/core/qgsvectordataprovider.cpp @@ -42,11 +42,6 @@ QgsVectorDataProvider::QgsVectorDataProvider( const QString& uri ) setEncoding( settings.value( QStringLiteral( "/UI/encoding" ), "System" ).toString() ); } - -QgsVectorDataProvider::~QgsVectorDataProvider() -{ -} - QString QgsVectorDataProvider::storageType() const { return QStringLiteral( "Generic vector file" ); @@ -69,6 +64,20 @@ bool QgsVectorDataProvider::deleteFeatures( const QgsFeatureIds &ids ) return false; } +bool QgsVectorDataProvider::truncate() +{ + if ( !( capabilities() & DeleteFeatures ) ) + return false; + + QgsFeatureIds toDelete; + QgsFeatureIterator it = getFeatures( QgsFeatureRequest().setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( QgsAttributeList() ) ); + QgsFeature f; + while ( it.nextFeature( f ) ) + toDelete << f.id(); + + return deleteFeatures( toDelete ); +} + bool QgsVectorDataProvider::addAttributes( const QList &attributes ) { Q_UNUSED( attributes ); @@ -128,9 +137,13 @@ bool QgsVectorDataProvider::changeGeometryValues( const QgsGeometryMap &geometry bool QgsVectorDataProvider::changeFeatures( const QgsChangedAttributesMap &attr_map, const QgsGeometryMap &geometry_map ) { - Q_UNUSED( attr_map ); - Q_UNUSED( geometry_map ); - return false; + if ( !( capabilities() & ChangeAttributeValues ) || !( capabilities() & ChangeGeometries ) ) + return false; + + bool result = true; + result = result && changeAttributeValues( attr_map ); + result = result && changeGeometryValues( geometry_map ); + return result; } bool QgsVectorDataProvider::createSpatialIndex() diff --git a/src/core/qgsvectordataprovider.h b/src/core/qgsvectordataprovider.h index aca0bb85c4e..c48c877a3ab 100644 --- a/src/core/qgsvectordataprovider.h +++ b/src/core/qgsvectordataprovider.h @@ -17,6 +17,7 @@ class QTextCodec; +#include "qgis_core.h" #include #include #include @@ -100,6 +101,8 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider ChangeFeatures = 1 << 18, //! Supports renaming attributes (fields). Added in QGIS 2.16 RenameAttributes = 1 << 19, + //! Supports fast truncation of the layer (removing all features). Added in QGIS 3.0 + FastTruncate = 1 << 20, }; Q_DECLARE_FLAGS( Capabilities, Capability ) @@ -115,11 +118,6 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider */ QgsVectorDataProvider( const QString& uri = QString() ); - /** - * Destructor - */ - virtual ~QgsVectorDataProvider(); - /** * Return feature source object that can be used for querying provider's data. The returned feature source * is independent from provider - any changes to provider's state (e.g. change of subset string) will not be @@ -245,12 +243,22 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider virtual bool addFeatures( QgsFeatureList &flist ); /** - * Deletes one or more features + * Deletes one or more features from the provider. This requires the DeleteFeatures capability. * @param id list containing feature ids to delete * @return true in case of success and false in case of failure + * @see truncate() */ virtual bool deleteFeatures( const QgsFeatureIds &id ); + /** + * Removes all features from the layer. This requires either the FastTruncate or DeleteFeatures capability. + * Providers with the FastTruncate capability will use an optimised method to truncate the layer. + * @returns true in case of success and false in case of failure. + * @note added in QGIS 3.0 + * @see deleteFeatures() + */ + virtual bool truncate(); + /** * Adds new attributes * @param attributes list of new attributes @@ -274,14 +282,18 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider virtual bool renameAttributes( const QgsFieldNameMap& renamedAttributes ); /** - * Changes attribute values of existing features. + * Changes attribute values of existing features. This should + * succeed if the provider reports the ChangeAttributeValues capability. * @param attr_map a map containing changed attributes * @return true in case of success and false in case of failure */ virtual bool changeAttributeValues( const QgsChangedAttributesMap &attr_map ); /** - * Changes attribute values and geometries of existing features. + * Changes attribute values and geometries of existing features. This should + * succeed if the provider reports both the ChangeAttributeValues and + * ChangeGeometries capabilities. Providers which report the ChangeFeatures + * capability implement an optimised version of this method. * @param attr_map a map containing changed attributes * @param geometry_map A QgsGeometryMap whose index contains the feature IDs * that will have their geometries changed. @@ -295,8 +307,8 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider * Returns any literal default values which are present at the provider for a specified * field index. Important - this should ONLY be called when creating an attribute to insert * directly into the database. Do not call this method for non-feature creation or modification, - * eg when validating an attribute or to compare it against an existing value, as calling it - * can cause changes to the underlying data source (eg Postgres provider where the default value + * e.g., when validating an attribute or to compare it against an existing value, as calling it + * can cause changes to the underlying data source (e.g., Postgres provider where the default value * is calculated as a result of a sequence). It is recommended that you instead use the methods * in QgsVectorLayerUtils such as QgsVectorLayerUtils::createFeature() * so that default value handling and validation is automatically carried out. @@ -307,7 +319,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider /** * Returns any default value clauses which are present at the provider for a specified * field index. These clauses are usually SQL fragments which must be evaluated by the - * provider, eg sequence values. + * provider, e.g., sequence values. * @see defaultValue() * @note added in QGIS 3.0 */ @@ -322,7 +334,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const; /** - * Returns true if a constraint check should be skipped for a specified field (eg if + * Returns true if a constraint check should be skipped for a specified field (e.g., if * the value returned by defaultValue() is trusted implicitly. An optional attribute value can be * passed which can help refine the skip constraint check. * @note added in QGIS 3.0 diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index 15ec73a8c8c..ae015b33bac 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -50,20 +50,10 @@ #include #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 -#define TO8F(x) (x).toUtf8().constData() -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#endif - QgsVectorFileWriter::FieldValueConverter::FieldValueConverter() { } -QgsVectorFileWriter::FieldValueConverter::~FieldValueConverter() -{ -} - QgsField QgsVectorFileWriter::FieldValueConverter::fieldDefinition( const QgsField& field ) { return field; @@ -213,23 +203,6 @@ void QgsVectorFileWriter::init( QString vectorFileName, vectorFileName += QLatin1String( ".dbf" ); } -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1700 - // check for unique fieldnames - QSet fieldNames; - for ( int i = 0; i < fields.count(); ++i ) - { - QString name = fields[i].name().left( 10 ); - if ( fieldNames.contains( name ) ) - { - mErrorMessage = QObject::tr( "trimming attribute name '%1' to ten significant characters produces duplicate column name." ) - .arg( fields[i].name() ); - mError = ErrAttributeCreationFailed; - return; - } - fieldNames << name; - } -#endif - if ( action == CreateOrOverwriteFile || action == CreateOrOverwriteLayer ) deleteShapeFile( vectorFileName ); } @@ -300,9 +273,9 @@ void QgsVectorFileWriter::init( QString vectorFileName, // create the data source if ( action == CreateOrOverwriteFile ) - mDS = OGR_Dr_CreateDataSource( poDriver, TO8F( vectorFileName ), options ); + mDS = OGR_Dr_CreateDataSource( poDriver, vectorFileName.toUtf8().constData(), options ); else - mDS = OGROpen( TO8F( vectorFileName ), TRUE, nullptr ); + mDS = OGROpen( vectorFileName.toUtf8().constData(), TRUE, nullptr ); if ( options ) { @@ -334,7 +307,7 @@ void QgsVectorFileWriter::init( QString vectorFileName, for ( int i = 0; i < layer_count; i++ ) { OGRLayerH hLayer = OGR_DS_GetLayer( mDS, i ); - if ( EQUAL( OGR_L_GetName( hLayer ), TO8F( layerName ) ) ) + if ( EQUAL( OGR_L_GetName( hLayer ), layerName.toUtf8().constData() ) ) { if ( OGR_DS_DeleteLayer( mDS, i ) != OGRERR_NONE ) { @@ -402,9 +375,9 @@ void QgsVectorFileWriter::init( QString vectorFileName, CPLSetConfigOption( "SHAPE_ENCODING", "" ); if ( action == CreateOrOverwriteFile || action == CreateOrOverwriteLayer ) - mLayer = OGR_DS_CreateLayer( mDS, TO8F( layerName ), mOgrRef, wkbType, options ); + mLayer = OGR_DS_CreateLayer( mDS, layerName.toUtf8().constData(), mOgrRef, wkbType, options ); else - mLayer = OGR_DS_GetLayerByName( mDS, TO8F( layerName ) ); + mLayer = OGR_DS_GetLayerByName( mDS, layerName.toUtf8().constData() ); if ( options ) { @@ -495,13 +468,6 @@ void QgsVectorFileWriter::init( QString vectorFileName, switch ( attrField.type() ) { -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 2000000 - case QVariant::LongLong: - ogrType = OFTString; - ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21; - ogrPrecision = -1; - break; -#else case QVariant::LongLong: { const char* pszDataTypes = GDALGetMetadataItem( poDriver, GDAL_DMD_CREATIONFIELDDATATYPES, NULL ); @@ -513,7 +479,6 @@ void QgsVectorFileWriter::init( QString vectorFileName, ogrPrecision = 0; break; } -#endif case QVariant::String: ogrType = OFTString; if ( ogrWidth <= 0 || ogrWidth > 255 ) @@ -624,25 +589,8 @@ void QgsVectorFileWriter::init( QString vectorFileName, QgsDebugMsg( QString( "returned field index for %1: %2" ).arg( name ).arg( ogrIdx ) ); if ( ogrIdx < 0 || existingIdxs.contains( ogrIdx ) ) { -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1700 - // if we didn't find our new column, assume it's name was truncated and - // it was the last one added (like for shape files) - int fieldCount = OGR_FD_GetFieldCount( defn ); - - OGRFieldDefnH fdefn = OGR_FD_GetFieldDefn( defn, fieldCount - 1 ); - if ( fdefn ) - { - const char *fieldName = OGR_Fld_GetNameRef( fdefn ); - - if ( attrField.name().left( strlen( fieldName ) ) == fieldName ) - { - ogrIdx = fieldCount - 1; - } - } -#else // GDAL 1.7 not just truncates, but launders more aggressivly. ogrIdx = OGR_FD_GetFieldCount( defn ) - 1; -#endif if ( ogrIdx < 0 ) { @@ -1158,12 +1106,10 @@ QMap QgsVectorFileWriter::initMetaData() QStringLiteral( "geometry" ) // Default value ) ); -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) layerOptions.insert( "SPATIAL_INDEX", new BoolOption( QObject::tr( "If a spatial index must be created." ), true // Default value ) ); -#endif driverMetadata.insert( QStringLiteral( "GPKG" ), MetaData( @@ -1535,7 +1481,7 @@ QMap QgsVectorFileWriter::initMetaData() ) ); layerOptions.insert( QStringLiteral( "FORMAT" ), new SetOption( - QObject::tr( "Controls the format used for the geometry column. Defaults to WKB." + QObject::tr( "Controls the format used for the geometry column. Defaults to WKB. " "This is generally more space and processing efficient, but harder " "to inspect or use in simple applications than WKT (Well Known Text)." ), QStringList() @@ -1569,7 +1515,7 @@ QMap QgsVectorFileWriter::initMetaData() "for databases that have big string blobs. However, use with care, since " "the value of such columns will be seen as compressed binary content with " "other SQLite utilities (or previous OGR versions). With OGR, when inserting, " - "modifying or queryings compressed columns, compression/decompression is " + "modifying or querying compressed columns, compression/decompression is " "done transparently. However, such columns cannot be (easily) queried with " "an attribute filter or WHERE clause. Note: in table definition, such columns " "have the 'VARCHAR_deflate' declaration type." ), @@ -1621,14 +1567,14 @@ QMap QgsVectorFileWriter::initMetaData() ) ); layerOptions.insert( QStringLiteral( "SPATIAL_INDEX" ), new BoolOption( - QObject::tr( "If the database is of the SpatiaLite flavour, and if OGR is linked " + QObject::tr( "If the database is of the SpatiaLite flavor, and if OGR is linked " "against libspatialite, this option can be used to control if a spatial " "index must be created." ), true // Default value ) ); layerOptions.insert( QStringLiteral( "COMPRESS_GEOM" ), new BoolOption( - QObject::tr( "If the format of the geometry BLOB is of the SpatiaLite flavour, " + QObject::tr( "If the format of the geometry BLOB is of the SpatiaLite flavor, " "this option can be used to control if the compressed format for " "geometries (LINESTRINGs, POLYGONs) must be used" ), false // Default value @@ -1981,7 +1927,6 @@ OGRFeatureH QgsVectorFileWriter::createFeature( const QgsFeature& feature ) switch ( attrValue.type() ) { -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 case QVariant::Int: case QVariant::UInt: OGR_F_SetFieldInteger( poFeature, ogrField, attrValue.toInt() ); @@ -1993,17 +1938,6 @@ OGRFeatureH QgsVectorFileWriter::createFeature( const QgsFeature& feature ) case QVariant::String: OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() ); break; -#else - case QVariant::Int: - OGR_F_SetFieldInteger( poFeature, ogrField, attrValue.toInt() ); - break; - case QVariant::String: - case QVariant::LongLong: - case QVariant::UInt: - case QVariant::ULongLong: - OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() ); - break; -#endif case QVariant::Double: OGR_F_SetFieldDouble( poFeature, ogrField, attrValue.toDouble() ); break; @@ -2296,10 +2230,6 @@ QgsVectorFileWriter::SaveVectorOptions::SaveVectorOptions() { } -QgsVectorFileWriter::SaveVectorOptions::~SaveVectorOptions() -{ -} - QgsVectorFileWriter::WriterError QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer, const QString& fileName, @@ -2677,11 +2607,11 @@ QMap QgsVectorFileWriter::ogrDriverList() poDriver = OGRGetDriverByName( drvName.toLocal8Bit().constData() ); if ( poDriver ) { - OGRDataSourceH ds = OGR_Dr_CreateDataSource( poDriver, TO8F( QString( "/vsimem/spatialitetest.sqlite" ) ), options ); + OGRDataSourceH ds = OGR_Dr_CreateDataSource( poDriver, QString( "/vsimem/spatialitetest.sqlite" ).toUtf8().constData(), options ); if ( ds ) { writableDrivers << QStringLiteral( "SpatiaLite" ); - OGR_Dr_DeleteDataSource( poDriver, TO8F( QString( "/vsimem/spatialitetest.sqlite" ) ) ); + OGR_Dr_DeleteDataSource( poDriver, QString( "/vsimem/spatialitetest.sqlite" ).toUtf8().constData() ); OGR_DS_Destroy( ds ); } } @@ -2769,7 +2699,6 @@ void QgsVectorFileWriter::createSymbolLayerTable( QgsVectorLayer* vl, const Qgs mapUnits = ct.destinationCrs().mapUnits(); } -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1700 mSymbolLayerTable.clear(); OGRStyleTableH ogrStyleTable = OGR_STBL_Create(); OGRStyleMgrH styleManager = OGR_SM_Create( ogrStyleTable ); @@ -2793,7 +2722,6 @@ void QgsVectorFileWriter::createSymbolLayerTable( QgsVectorLayer* vl, const Qgs } } OGR_DS_SetStyleTableDirectly( ds, ogrStyleTable ); -#endif } QgsVectorFileWriter::WriterError QgsVectorFileWriter::exportFeaturesSymbolLevels( QgsVectorLayer* layer, QgsFeatureIterator& fit, @@ -2802,10 +2730,7 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::exportFeaturesSymbolLevels if ( !layer ) return ErrInvalidLayer; - mRenderContext.expressionContext() = QgsExpressionContext(); - mRenderContext.expressionContext() << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( layer ); + mRenderContext.expressionContext() = QgsExpressionContext( QgsExpressionContextUtils::globalProjectLayerScopes( layer ) ); QgsFeatureRenderer *renderer = layer->renderer(); if ( !renderer ) @@ -3083,7 +3008,7 @@ QStringList QgsVectorFileWriter::concatenateOptions( const QMapfields().at( idx ); - if ( OGR_FD_GetFieldIndex( defn, TO8F( fld.name() ) ) < 0 ) + if ( OGR_FD_GetFieldIndex( defn, fld.name().toUtf8().constData() ) < 0 ) { ret = true; break; diff --git a/src/core/qgsvectorfilewriter.h b/src/core/qgsvectorfilewriter.h index 4b039ac1d91..a5021dc2c32 100644 --- a/src/core/qgsvectorfilewriter.h +++ b/src/core/qgsvectorfilewriter.h @@ -19,6 +19,7 @@ #ifndef QGSVECTORFILEWRITER_H #define QGSVECTORFILEWRITER_H +#include "qgis_core.h" #include "qgsfields.h" #include "qgssymbol.h" #include @@ -55,7 +56,7 @@ class CORE_EXPORT QgsVectorFileWriter Option( const QString& docString, OptionType type ) : docString( docString ) , type( type ) {} - virtual ~Option() {} + virtual ~Option() = default; QString docString; OptionType type; @@ -182,8 +183,7 @@ class CORE_EXPORT QgsVectorFileWriter //! Constructor FieldValueConverter(); - //! Destructor - virtual ~FieldValueConverter(); + virtual ~FieldValueConverter() = default; /** Return a possibly modified field definition. Default implementation will return provided field unmodified. * @param field original field definition @@ -337,8 +337,7 @@ class CORE_EXPORT QgsVectorFileWriter //! Constructor SaveVectorOptions(); - //! Destructor - virtual ~SaveVectorOptions(); + virtual ~SaveVectorOptions() = default; //! OGR driver to use QString driverName; @@ -421,6 +420,11 @@ class CORE_EXPORT QgsVectorFileWriter SymbologyExport symbologyExport = NoSymbology ); + //! QgsVectorFileWriter cannot be copied. + QgsVectorFileWriter( const QgsVectorFileWriter& rh ) = delete; + //! QgsVectorFileWriter cannot be copied. + QgsVectorFileWriter& operator=( const QgsVectorFileWriter& rh ) = delete; + //! Returns map with format filter string as key and OGR format key as value static QMap< QString, QString> supportedFiltersAndFormats(); @@ -537,9 +541,7 @@ class CORE_EXPORT QgsVectorFileWriter SymbologyExport mSymbologyExport; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1700 QMap< QgsSymbolLayer*, QString > mSymbolLayerTable; -#endif //! Scale for symbology export (e.g. for symbols units in map units) double mSymbologyScaleDenominator; @@ -609,9 +611,6 @@ class CORE_EXPORT QgsVectorFileWriter void addRendererAttributes( QgsVectorLayer* vl, QgsAttributeList& attList ); static QMap sDriverMetadata; - QgsVectorFileWriter( const QgsVectorFileWriter& rh ); - QgsVectorFileWriter& operator=( const QgsVectorFileWriter& rh ); - //! Concatenates a list of options using their default values static QStringList concatenateOptions( const QMap& options ); }; diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index 36746f04802..c42f71d4686 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -309,10 +309,7 @@ void QgsVectorLayer::selectByExpression( const QString& expression, QgsVectorLay { QgsFeatureIds newSelection; - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( this ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( this ) ); if ( behaviour == SetSelection || behaviour == AddToSelection ) { @@ -737,9 +734,7 @@ bool QgsVectorLayer::countSymbolFeatures( bool showProgress ) // Renderer (rule based) may depend on context scale, with scale is ignored if 0 QgsRenderContext renderContext; renderContext.setRendererScale( 0 ); - renderContext.expressionContext() << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( this ); + renderContext.expressionContext().appendScopes( QgsExpressionContextUtils::globalProjectLayerScopes( this ) ); mRenderer->startRender( renderContext, fields() ); @@ -1525,7 +1520,7 @@ void QgsVectorLayer::setDataSource( const QString& dataSource, const QString& ba QgsWkbTypes::GeometryType geomType = mValid && mDataProvider ? geometryType() : QgsWkbTypes::UnknownGeometry; mDataSource = dataSource; - mLayerName = capitaliseLayerName( baseName ); + mLayerName = capitalizeLayerName( baseName ); setName( mLayerName ); setDataProvider( provider ); @@ -3122,10 +3117,7 @@ QVariant QgsVectorLayer::defaultValue( int index, const QgsFeature& feature, Qgs if ( !evalContext ) { // no context passed, so we create a default one - tempContext.reset( new QgsExpressionContext() ); - tempContext->appendScope( QgsExpressionContextUtils::globalScope() ); - tempContext->appendScope( QgsExpressionContextUtils::projectScope() ); - tempContext->appendScope( QgsExpressionContextUtils::layerScope( this ) ); + tempContext.reset( new QgsExpressionContext( QgsExpressionContextUtils::globalProjectLayerScopes( this ) ) ); evalContext = tempContext.data(); } @@ -3612,9 +3604,7 @@ QList QgsVectorLayer::getValues( const QString &fieldOrExpression, boo { // try to use expression expression.reset( new QgsExpression( fieldOrExpression ) ); - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( this ); + context.appendScopes( QgsExpressionContextUtils::globalProjectLayerScopes( this ) ); if ( expression->hasParserError() || !expression->prepare( &context ) ) { @@ -4006,12 +3996,7 @@ void QgsVectorLayer::setAttributeTableConfig( const QgsAttributeTableConfig& att QgsExpressionContext QgsVectorLayer::createExpressionContext() const { - QgsExpressionContext expContext; - expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( this ); - - return expContext; + return QgsExpressionContext( QgsExpressionContextUtils::globalProjectLayerScopes( this ) ); } void QgsVectorLayer::setDiagramLayerSettings( const QgsDiagramLayerSettings& s ) diff --git a/src/core/qgsvectorlayer.h b/src/core/qgsvectorlayer.h index b985895ce07..1f1bf0fc780 100644 --- a/src/core/qgsvectorlayer.h +++ b/src/core/qgsvectorlayer.h @@ -19,6 +19,7 @@ #ifndef QGSVECTORLAYER_H #define QGSVECTORLAYER_H +#include "qgis_core.h" #include #include #include @@ -447,16 +448,21 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte * @param path The path or url of the parameter. Typically this encodes * parameters used by the data provider as url query items. * @param baseName The name used to represent the layer in the legend - * @param providerLib The name of the data provider, eg "memory", "postgres" + * @param providerLib The name of the data provider, e.g., "memory", "postgres" * @param loadDefaultStyleFlag whether to load the default style * */ QgsVectorLayer( const QString& path = QString::null, const QString& baseName = QString::null, const QString& providerLib = QString::null, bool loadDefaultStyleFlag = true ); - //! Destructor + virtual ~QgsVectorLayer(); + //! QgsVectorLayer cannot be copied. + QgsVectorLayer( const QgsVectorLayer & rhs ) = delete; + //! QgsVectorLayer cannot be copied. + QgsVectorLayer & operator=( QgsVectorLayer const & rhs ) = delete; + //! Returns the permanent storage type for this layer as a friendly name. QString storageType() const; @@ -1952,13 +1958,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte */ virtual bool isReadOnly() const override; - //! Vector layers are not copyable - QgsVectorLayer( const QgsVectorLayer & rhs ); - - //! Vector layers are not copyable - QgsVectorLayer & operator=( QgsVectorLayer const & rhs ); - - /** Bind layer to a specific data provider * @param provider should be "postgres", "ogr", or ?? * @todo XXX should this return bool? Throw exceptions? diff --git a/src/core/qgsvectorlayercache.h b/src/core/qgsvectorlayercache.h index 5287da41119..90db4653e3d 100644 --- a/src/core/qgsvectorlayercache.h +++ b/src/core/qgsvectorlayercache.h @@ -19,6 +19,7 @@ #ifndef QgsVectorLayerCache_H #define QgsVectorLayerCache_H +#include "qgis_core.h" #include #include "qgsvectorlayer.h" diff --git a/src/core/qgsvectorlayerdiagramprovider.cpp b/src/core/qgsvectorlayerdiagramprovider.cpp index 919acaa71f9..57ae61d0503 100644 --- a/src/core/qgsvectorlayerdiagramprovider.cpp +++ b/src/core/qgsvectorlayerdiagramprovider.cpp @@ -61,8 +61,8 @@ QgsVectorLayerDiagramProvider::QgsVectorLayerDiagramProvider( QgsVectorLayer* la void QgsVectorLayerDiagramProvider::init() { mName = mLayerId; - mPriority = 1 - mSettings.getPriority() / 10.0; // convert 0..10 --> 1..0 - mPlacement = QgsPalLayerSettings::Placement( mSettings.getPlacement() ); + mPriority = 1 - mSettings.priority() / 10.0; // convert 0..10 --> 1..0 + mPlacement = QgsPalLayerSettings::Placement( mSettings.placement() ); mLinePlacementFlags = mSettings.linePlacementFlags(); } @@ -147,7 +147,7 @@ void QgsVectorLayerDiagramProvider::drawLabel( QgsRenderContext& context, pal::L QgsPoint centerPt = xform.transform( outPt.x() - label->getWidth() / 2, outPt.y() - label->getHeight() / 2 ); - mSettings.getRenderer()->renderDiagram( feature, context, centerPt.toQPointF() ); + mSettings.renderer()->renderDiagram( feature, context, centerPt.toQPointF() ); //insert into label search tree to manipulate position interactively mEngine->results()->mLabelSearchTree->insertLabel( label, label->getFeaturePart()->featureId(), mLayerId, QString(), QFont(), true, false ); @@ -195,7 +195,7 @@ QgsLabelFeature* QgsVectorLayerDiagramProvider::registerDiagram( QgsFeature& fea { const QgsMapSettings& mapSettings = mEngine->mapSettings(); - const QgsDiagramRenderer* dr = mSettings.getRenderer(); + const QgsDiagramRenderer* dr = mSettings.renderer(); if ( dr ) { QList settingList = dr->diagramSettings(); @@ -315,7 +315,7 @@ QgsLabelFeature* QgsVectorLayerDiagramProvider::registerDiagram( QgsFeature& fea lf->setFixedAngle( 0 ); lf->setAlwaysShow( alwaysShow ); lf->setIsObstacle( mSettings.isObstacle() ); - lf->setZIndex( mSettings.getZIndex() ); + lf->setZIndex( mSettings.zIndex() ); if ( geosObstacleGeomClone ) { lf->setObstacleGeometry( geosObstacleGeomClone ); diff --git a/src/core/qgsvectorlayerdiagramprovider.h b/src/core/qgsvectorlayerdiagramprovider.h index ea59fc52703..5205c3548d3 100644 --- a/src/core/qgsvectorlayerdiagramprovider.h +++ b/src/core/qgsvectorlayerdiagramprovider.h @@ -16,6 +16,7 @@ #ifndef QGSVECTORLAYERDIAGRAMPROVIDER_H #define QGSVECTORLAYERDIAGRAMPROVIDER_H +#include "qgis_core.h" #include "qgslabelingengine.h" #include "qgslabelfeature.h" #include "qgsdiagramrenderer.h" @@ -94,7 +95,7 @@ class CORE_EXPORT QgsVectorLayerDiagramProvider : public QgsAbstractLabelProvide * @param context render context. The QgsExpressionContext contained within the render context * must have already had the feature and fields sets prior to calling this method. * @param obstacleGeometry optional obstacle geometry, if a different geometry to the feature's geometry - * should be used as an obstacle for labels (eg, if the feature has been rendered with an offset point + * should be used as an obstacle for labels (e.g., if the feature has been rendered with an offset point * symbol, the obstacle geometry should represent the bounds of the offset symbol). If not set, * the feature's original geometry will be used as an obstacle for labels. Ownership of obstacleGeometry * is transferred. diff --git a/src/core/qgsvectorlayereditbuffer.cpp b/src/core/qgsvectorlayereditbuffer.cpp index 2d1e4f22ab4..40d753e0fbc 100644 --- a/src/core/qgsvectorlayereditbuffer.cpp +++ b/src/core/qgsvectorlayereditbuffer.cpp @@ -40,11 +40,6 @@ QgsVectorLayerEditBuffer::QgsVectorLayerEditBuffer( QgsVectorLayer* layer ) connect( L->undoStack(), &QUndoStack::indexChanged, this, &QgsVectorLayerEditBuffer::undoIndexChanged ); // TODO[MD]: queued? } -QgsVectorLayerEditBuffer::~QgsVectorLayerEditBuffer() -{ -} - - bool QgsVectorLayerEditBuffer::isModified() const { return !L->undoStack()->isClean(); diff --git a/src/core/qgsvectorlayereditbuffer.h b/src/core/qgsvectorlayereditbuffer.h index 4a9d528cfbe..210788ed2d1 100644 --- a/src/core/qgsvectorlayereditbuffer.h +++ b/src/core/qgsvectorlayereditbuffer.h @@ -15,6 +15,7 @@ #ifndef QGSVECTORLAYEREDITBUFFER_H #define QGSVECTORLAYEREDITBUFFER_H +#include "qgis_core.h" #include #include @@ -36,7 +37,6 @@ class CORE_EXPORT QgsVectorLayerEditBuffer : public QObject Q_OBJECT public: QgsVectorLayerEditBuffer( QgsVectorLayer* layer ); - ~QgsVectorLayerEditBuffer(); //! Returns true if the provider has been modified since the last commit virtual bool isModified() const; diff --git a/src/core/qgsvectorlayereditpassthrough.h b/src/core/qgsvectorlayereditpassthrough.h index 72f19a25a36..d1bd8cc23ac 100644 --- a/src/core/qgsvectorlayereditpassthrough.h +++ b/src/core/qgsvectorlayereditpassthrough.h @@ -15,6 +15,7 @@ #ifndef QGSVECTORLAYEREDITPASSTHROUGH_H #define QGSVECTORLAYEREDITPASSTHROUGH_H +#include "qgis_core.h" #include "qgsvectorlayereditbuffer.h" class QgsVectorLayer; diff --git a/src/core/qgsvectorlayereditutils.cpp b/src/core/qgsvectorlayereditutils.cpp index 1ec89e7474e..3546c3df0ec 100644 --- a/src/core/qgsvectorlayereditutils.cpp +++ b/src/core/qgsvectorlayereditutils.cpp @@ -322,7 +322,7 @@ int QgsVectorLayerEditUtils::splitFeatures( const QList& splitLine, bo QgsRectangle bBox; //bounding box of the split line int returnCode = 0; int splitFunctionReturn; //return code of QgsGeometry::splitGeometry - int numberOfSplittedFeatures = 0; + int numberOfSplitFeatures = 0; QgsFeatureIterator features; const QgsFeatureIds selectedIds = L->selectedFeatureIds(); @@ -405,7 +405,7 @@ int QgsVectorLayerEditUtils::splitFeatures( const QList& splitLine, bo addTopologicalPoints( *topol_it ); } } - ++numberOfSplittedFeatures; + ++numberOfSplitFeatures; } else if ( splitFunctionReturn > 1 ) //1 means no split but also no error { @@ -413,7 +413,7 @@ int QgsVectorLayerEditUtils::splitFeatures( const QList& splitLine, bo } } - if ( numberOfSplittedFeatures == 0 && !selectedIds.isEmpty() ) + if ( numberOfSplitFeatures == 0 && !selectedIds.isEmpty() ) { //There is a selection but no feature has been split. //Maybe user forgot that only the selected features are split @@ -432,7 +432,7 @@ int QgsVectorLayerEditUtils::splitParts( const QList& splitLine, bool QgsRectangle bBox; //bounding box of the split line int returnCode = 0; int splitFunctionReturn; //return code of QgsGeometry::splitGeometry - int numberOfSplittedParts = 0; + int numberOfSplitParts = 0; QgsFeatureIterator fit; @@ -540,7 +540,7 @@ int QgsVectorLayerEditUtils::splitParts( const QList& splitLine, bool addTopologicalPoints( *topol_it ); } } - ++numberOfSplittedParts; + ++numberOfSplitParts; } else if ( splitFunctionReturn > 1 ) //1 means no split but also no error { @@ -548,7 +548,7 @@ int QgsVectorLayerEditUtils::splitParts( const QList& splitLine, bool } } - if ( numberOfSplittedParts == 0 && L->selectedFeatureCount() > 0 && returnCode == 0 ) + if ( numberOfSplitParts == 0 && L->selectedFeatureCount() > 0 && returnCode == 0 ) { //There is a selection but no feature has been split. //Maybe user forgot that only the selected features are split diff --git a/src/core/qgsvectorlayereditutils.h b/src/core/qgsvectorlayereditutils.h index b30b18005ad..a9a42b69c06 100644 --- a/src/core/qgsvectorlayereditutils.h +++ b/src/core/qgsvectorlayereditutils.h @@ -16,6 +16,7 @@ #define QGSVECTORLAYEREDITUTILS_H +#include "qgis_core.h" #include "qgsfeature.h" #include "qgsvectorlayer.h" diff --git a/src/core/qgsvectorlayerfeatureiterator.cpp b/src/core/qgsvectorlayerfeatureiterator.cpp index 86eb5defc25..11206c1bb52 100644 --- a/src/core/qgsvectorlayerfeatureiterator.cpp +++ b/src/core/qgsvectorlayerfeatureiterator.cpp @@ -584,7 +584,7 @@ void QgsVectorLayerFeatureIterator::prepareFields() mExpressionContext.reset( new QgsExpressionContext() ); mExpressionContext->appendScope( QgsExpressionContextUtils::globalScope() ); - mExpressionContext->appendScope( QgsExpressionContextUtils::projectScope() ); + mExpressionContext->appendScope( QgsExpressionContextUtils::projectScope( QgsProject::instance() ) ); mExpressionContext->setFields( mSource->mFields ); mFieldsToPrepare = ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes ) ? mRequest.subsetOfAttributes() : mSource->mFields.allAttributesList(); diff --git a/src/core/qgsvectorlayerfeatureiterator.h b/src/core/qgsvectorlayerfeatureiterator.h index c077bb07129..405cf6845a6 100644 --- a/src/core/qgsvectorlayerfeatureiterator.h +++ b/src/core/qgsvectorlayerfeatureiterator.h @@ -15,6 +15,7 @@ #ifndef QGSVECTORLAYERFEATUREITERATOR_H #define QGSVECTORLAYERFEATUREITERATOR_H +#include "qgis_core.h" #include "qgsfeatureiterator.h" #include "qgsfields.h" diff --git a/src/core/qgsvectorlayerimport.h b/src/core/qgsvectorlayerimport.h index 4b92af4d06c..24f61705ada 100644 --- a/src/core/qgsvectorlayerimport.h +++ b/src/core/qgsvectorlayerimport.h @@ -19,6 +19,7 @@ #ifndef QGSVECTORLAYERIMPORT_H #define QGSVECTORLAYERIMPORT_H +#include "qgis_core.h" #include "qgsfeature.h" class QProgressDialog; @@ -99,6 +100,11 @@ class CORE_EXPORT QgsVectorLayerImport QProgressDialog *progress = nullptr ); + //! QgsVectorLayerImport cannot be copied + QgsVectorLayerImport( const QgsVectorLayerImport& rh ) = delete; + //! QgsVectorLayerImport cannot be copied + QgsVectorLayerImport& operator=( const QgsVectorLayerImport& rh ) = delete; + //! Checks whether there were any errors ImportError hasError(); @@ -135,10 +141,6 @@ class CORE_EXPORT QgsVectorLayerImport QgsFeatureList mFeatureBuffer; QProgressDialog *mProgress; - private: - - QgsVectorLayerImport( const QgsVectorLayerImport& rh ); - QgsVectorLayerImport& operator=( const QgsVectorLayerImport& rh ); }; #endif diff --git a/src/core/qgsvectorlayerjoinbuffer.cpp b/src/core/qgsvectorlayerjoinbuffer.cpp index f8eb3aef240..675ee01f393 100644 --- a/src/core/qgsvectorlayerjoinbuffer.cpp +++ b/src/core/qgsvectorlayerjoinbuffer.cpp @@ -29,10 +29,6 @@ QgsVectorLayerJoinBuffer::QgsVectorLayerJoinBuffer( QgsVectorLayer* layer ) { } -QgsVectorLayerJoinBuffer::~QgsVectorLayerJoinBuffer() -{ -} - static QList _outEdges( QgsVectorLayer* vl ) { QList lst; diff --git a/src/core/qgsvectorlayerjoinbuffer.h b/src/core/qgsvectorlayerjoinbuffer.h index c56868ce33e..55cdf067db8 100644 --- a/src/core/qgsvectorlayerjoinbuffer.h +++ b/src/core/qgsvectorlayerjoinbuffer.h @@ -18,6 +18,7 @@ #ifndef QGSVECTORLAYERJOINBUFFER_H #define QGSVECTORLAYERJOINBUFFER_H +#include "qgis_core.h" #include "qgsvectorlayer.h" #include @@ -34,7 +35,6 @@ class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject Q_OBJECT public: QgsVectorLayerJoinBuffer( QgsVectorLayer* layer = nullptr ); - ~QgsVectorLayerJoinBuffer(); /** Joins another vector layer to this layer @param joinInfo join object containing join layer id, target and source field diff --git a/src/core/qgsvectorlayerlabeling.cpp b/src/core/qgsvectorlayerlabeling.cpp index 7664137c7ec..5d538660b55 100644 --- a/src/core/qgsvectorlayerlabeling.cpp +++ b/src/core/qgsvectorlayerlabeling.cpp @@ -19,10 +19,6 @@ #include "qgsvectorlayer.h" -QgsAbstractVectorLayerLabeling::~QgsAbstractVectorLayerLabeling() -{ -} - QgsAbstractVectorLayerLabeling* QgsAbstractVectorLayerLabeling::create( const QDomElement& element ) { if ( element.attribute( QStringLiteral( "type" ) ) == QLatin1String( "rule-based" ) ) diff --git a/src/core/qgsvectorlayerlabeling.h b/src/core/qgsvectorlayerlabeling.h index 86fa7d8c8a9..abd048c5c43 100644 --- a/src/core/qgsvectorlayerlabeling.h +++ b/src/core/qgsvectorlayerlabeling.h @@ -18,6 +18,8 @@ #include #include +#include "qgis_core.h" + class QDomDocument; class QDomElement; @@ -36,7 +38,7 @@ class CORE_EXPORT QgsAbstractVectorLayerLabeling { public: - virtual ~QgsAbstractVectorLayerLabeling(); + virtual ~QgsAbstractVectorLayerLabeling() = default; //! Unique type string of the labeling configuration implementation virtual QString type() const = 0; diff --git a/src/core/qgsvectorlayerlabelprovider.h b/src/core/qgsvectorlayerlabelprovider.h index d1e4ab8c87b..0e983aed9e2 100644 --- a/src/core/qgsvectorlayerlabelprovider.h +++ b/src/core/qgsvectorlayerlabelprovider.h @@ -16,6 +16,7 @@ #ifndef QGSVECTORLAYERLABELPROVIDER_H #define QGSVECTORLAYERLABELPROVIDER_H +#include "qgis_core.h" #include "qgslabelingengine.h" #include "qgsrenderer.h" @@ -75,7 +76,7 @@ class CORE_EXPORT QgsVectorLayerLabelProvider : public QgsAbstractLabelProvider * @param context render context. The QgsExpressionContext contained within the render context * must have already had the feature and fields sets prior to calling this method. * @param obstacleGeometry optional obstacle geometry, if a different geometry to the feature's geometry - * should be used as an obstacle for labels (eg, if the feature has been rendered with an offset point + * should be used as an obstacle for labels (e.g., if the feature has been rendered with an offset point * symbol, the obstacle geometry should represent the bounds of the offset symbol). If not set, * the feature's original geometry will be used as an obstacle for labels. */ diff --git a/src/core/qgsvectorlayertools.cpp b/src/core/qgsvectorlayertools.cpp index 3ca7efb5e5f..17d75855c90 100644 --- a/src/core/qgsvectorlayertools.cpp +++ b/src/core/qgsvectorlayertools.cpp @@ -24,11 +24,6 @@ QgsVectorLayerTools::QgsVectorLayerTools() : QObject( nullptr ) {} - -QgsVectorLayerTools::~QgsVectorLayerTools() -{} - - bool QgsVectorLayerTools::copyMoveFeatures( QgsVectorLayer* layer, QgsFeatureRequest& request, double dx, double dy, QString* errorMsg ) const { bool res = false; diff --git a/src/core/qgsvectorlayertools.h b/src/core/qgsvectorlayertools.h index 6a9dab28eec..e1f397fed79 100644 --- a/src/core/qgsvectorlayertools.h +++ b/src/core/qgsvectorlayertools.h @@ -16,6 +16,7 @@ #ifndef QGSVECTORLAYERTOOLS_H #define QGSVECTORLAYERTOOLS_H +#include "qgis_core.h" #include #include "qgsfeature.h" @@ -40,8 +41,6 @@ class CORE_EXPORT QgsVectorLayerTools : public QObject public: QgsVectorLayerTools(); - virtual ~QgsVectorLayerTools(); - /** * This method should/will be called, whenever a new feature will be added to the layer * diff --git a/src/core/qgsvectorlayerundocommand.cpp b/src/core/qgsvectorlayerundocommand.cpp index 5e1c8dffbdc..0bea9467950 100644 --- a/src/core/qgsvectorlayerundocommand.cpp +++ b/src/core/qgsvectorlayerundocommand.cpp @@ -155,10 +155,6 @@ bool QgsVectorLayerUndoCommandChangeGeometry::mergeWith( const QUndoCommand *oth return true; } -QgsVectorLayerUndoCommandChangeGeometry::~QgsVectorLayerUndoCommandChangeGeometry() -{ -} - void QgsVectorLayerUndoCommandChangeGeometry::undo() { if ( FID_IS_NEW( mFid ) ) diff --git a/src/core/qgsvectorlayerundocommand.h b/src/core/qgsvectorlayerundocommand.h index 88befb10259..177dba413fd 100644 --- a/src/core/qgsvectorlayerundocommand.h +++ b/src/core/qgsvectorlayerundocommand.h @@ -16,6 +16,7 @@ #ifndef QGSVECTORLAYERUNDOCOMMAND_H #define QGSVECTORLAYERUNDOCOMMAND_H +#include "qgis_core.h" #include #include @@ -122,7 +123,6 @@ class CORE_EXPORT QgsVectorLayerUndoCommandChangeGeometry : public QgsVectorLaye * @param newGeom new geometry for feature */ QgsVectorLayerUndoCommandChangeGeometry( QgsVectorLayerEditBuffer* buffer, QgsFeatureId fid, const QgsGeometry &newGeom ); - ~QgsVectorLayerUndoCommandChangeGeometry(); virtual void undo() override; virtual void redo() override; diff --git a/src/core/qgsvectorlayerutils.cpp b/src/core/qgsvectorlayerutils.cpp index 3c55d0d27b2..d97fcb3527a 100644 --- a/src/core/qgsvectorlayerutils.cpp +++ b/src/core/qgsvectorlayerutils.cpp @@ -239,10 +239,7 @@ QgsFeature QgsVectorLayerUtils::createFeature( QgsVectorLayer* layer, const QgsG if ( !evalContext ) { // no context passed, so we create a default one - tempContext.reset( new QgsExpressionContext() ); - tempContext->appendScope( QgsExpressionContextUtils::globalScope() ); - tempContext->appendScope( QgsExpressionContextUtils::projectScope() ); - tempContext->appendScope( QgsExpressionContextUtils::layerScope( layer ) ); + tempContext.reset( new QgsExpressionContext( QgsExpressionContextUtils::globalProjectLayerScopes( layer ) ) ); evalContext = tempContext.data(); } diff --git a/src/core/qgsvectorlayerutils.h b/src/core/qgsvectorlayerutils.h index 64246276cd7..0a6a8b1b0de 100644 --- a/src/core/qgsvectorlayerutils.h +++ b/src/core/qgsvectorlayerutils.h @@ -16,6 +16,7 @@ #ifndef QGSVECTORLAYERUTILS_H #define QGSVECTORLAYERUTILS_H +#include "qgis_core.h" #include "qgsvectorlayer.h" #include "qgsgeometry.h" @@ -56,7 +57,7 @@ class CORE_EXPORT QgsVectorLayerUtils /** * Creates a new feature ready for insertion into a layer. Default values and constraints - * (eg unique constraints) will automatically be handled. An optional attribute map can be + * (e.g., unique constraints) will automatically be handled. An optional attribute map can be * passed for the new feature to copy as many attribute values as possible from the map, * assuming that they respect the layer's constraints. Note that the created feature is not * automatically inserted into the layer. diff --git a/src/core/qgsvectorsimplifymethod.h b/src/core/qgsvectorsimplifymethod.h index 3dbfb220872..154516c0f20 100644 --- a/src/core/qgsvectorsimplifymethod.h +++ b/src/core/qgsvectorsimplifymethod.h @@ -16,6 +16,7 @@ #ifndef QGSVECTORSIMPLIFYMETHOD_H #define QGSVECTORSIMPLIFYMETHOD_H +#include "qgis_core.h" #include /** \ingroup core diff --git a/src/core/qgsvirtuallayerdefinition.h b/src/core/qgsvirtuallayerdefinition.h index 709a2494a95..a8defb32288 100644 --- a/src/core/qgsvirtuallayerdefinition.h +++ b/src/core/qgsvirtuallayerdefinition.h @@ -17,6 +17,7 @@ email : hugo dot mercier at oslandia dot com #ifndef QGSVIRTUALLAYERDEFINITION_H #define QGSVIRTUALLAYERDEFINITION_H +#include "qgis_core.h" #include "qgsfields.h" #include "qgis.h" diff --git a/src/core/qgsvirtuallayerdefinitionutils.h b/src/core/qgsvirtuallayerdefinitionutils.h index 15d5ae1172a..5e7f9471ff3 100644 --- a/src/core/qgsvirtuallayerdefinitionutils.h +++ b/src/core/qgsvirtuallayerdefinitionutils.h @@ -17,6 +17,8 @@ email : hugo dot mercier at oslandia dot com #ifndef QGSVIRTUALLAYERDEFINITION_UTILS_H #define QGSVIRTUALLAYERDEFINITION_UTILS_H +#include "qgis_core.h" + class QgsVectorLayer; class QgsVirtualLayerDefinition; diff --git a/src/core/qgswebframe.h b/src/core/qgswebframe.h index 727e128dd21..4cfd9832c8a 100644 --- a/src/core/qgswebframe.h +++ b/src/core/qgswebframe.h @@ -16,6 +16,8 @@ #ifndef QGSWEBFRAME_H #define QGSWEBFRAME_H +#include "qgis_core.h" + #ifdef WITH_QTWEBKIT #include #else diff --git a/src/core/qgswebpage.h b/src/core/qgswebpage.h index 57a1d5a0438..53f941b5f6e 100644 --- a/src/core/qgswebpage.h +++ b/src/core/qgswebpage.h @@ -16,6 +16,7 @@ #ifndef QGSWEBPAGE_H #define QGSWEBPAGE_H +#include "qgis_core.h" #include "qgsmessagelog.h" #include diff --git a/src/core/qgswebview.h b/src/core/qgswebview.h index 19458eea6fb..5e26e0b1d0c 100644 --- a/src/core/qgswebview.h +++ b/src/core/qgswebview.h @@ -23,6 +23,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core */ diff --git a/src/core/qgsxmlutils.h b/src/core/qgsxmlutils.h index 40b0fbb4752..94c5830aab4 100644 --- a/src/core/qgsxmlutils.h +++ b/src/core/qgsxmlutils.h @@ -20,6 +20,7 @@ class QDomElement; class QgsRectangle; +#include "qgis_core.h" #include "qgis.h" #include "qgsunittypes.h" diff --git a/src/core/raster/qgsbilinearrasterresampler.cpp b/src/core/raster/qgsbilinearrasterresampler.cpp index 2c8d2ed6490..6e241d3e969 100644 --- a/src/core/raster/qgsbilinearrasterresampler.cpp +++ b/src/core/raster/qgsbilinearrasterresampler.cpp @@ -23,10 +23,6 @@ QgsBilinearRasterResampler::QgsBilinearRasterResampler() { } -QgsBilinearRasterResampler::~QgsBilinearRasterResampler() -{ -} - QgsBilinearRasterResampler* QgsBilinearRasterResampler::clone() const { return new QgsBilinearRasterResampler(); diff --git a/src/core/raster/qgsbilinearrasterresampler.h b/src/core/raster/qgsbilinearrasterresampler.h index 7fbb8f13076..a04a5a3fde6 100644 --- a/src/core/raster/qgsbilinearrasterresampler.h +++ b/src/core/raster/qgsbilinearrasterresampler.h @@ -21,6 +21,8 @@ #include "qgsrasterresampler.h" #include +#include "qgis_core.h" + /** \ingroup core Bilinear Raster Resampler */ @@ -28,7 +30,6 @@ class CORE_EXPORT QgsBilinearRasterResampler: public QgsRasterResampler { public: QgsBilinearRasterResampler(); - ~QgsBilinearRasterResampler(); void resample( const QImage& srcImage, QImage& dstImage ) override; QString type() const override { return QStringLiteral( "bilinear" ); } diff --git a/src/core/raster/qgsbrightnesscontrastfilter.cpp b/src/core/raster/qgsbrightnesscontrastfilter.cpp index b01e33bf45f..2ad4df31153 100644 --- a/src/core/raster/qgsbrightnesscontrastfilter.cpp +++ b/src/core/raster/qgsbrightnesscontrastfilter.cpp @@ -29,10 +29,6 @@ QgsBrightnessContrastFilter::QgsBrightnessContrastFilter( QgsRasterInterface* in { } -QgsBrightnessContrastFilter::~QgsBrightnessContrastFilter() -{ -} - QgsBrightnessContrastFilter* QgsBrightnessContrastFilter::clone() const { QgsDebugMsgLevel( "Entered", 4 ); diff --git a/src/core/raster/qgsbrightnesscontrastfilter.h b/src/core/raster/qgsbrightnesscontrastfilter.h index bb6608353da..fd14790f357 100644 --- a/src/core/raster/qgsbrightnesscontrastfilter.h +++ b/src/core/raster/qgsbrightnesscontrastfilter.h @@ -18,6 +18,7 @@ #ifndef QGSBRIGHTNESSCONTRASTFILTER_H #define QGSBRIGHTNESSCONTRASTFILTER_H +#include "qgis_core.h" #include "qgsrasterinterface.h" class QDomElement; @@ -29,7 +30,6 @@ class CORE_EXPORT QgsBrightnessContrastFilter : public QgsRasterInterface { public: QgsBrightnessContrastFilter( QgsRasterInterface *input = nullptr ); - ~QgsBrightnessContrastFilter(); QgsBrightnessContrastFilter* clone() const override; diff --git a/src/core/raster/qgscliptominmaxenhancement.h b/src/core/raster/qgscliptominmaxenhancement.h index b9158856c9e..83ccc24726c 100644 --- a/src/core/raster/qgscliptominmaxenhancement.h +++ b/src/core/raster/qgscliptominmaxenhancement.h @@ -19,6 +19,7 @@ email : ersts@amnh.org #ifndef QGSCLIPTOMINMAXENHANCEMENT_H #define QGSCLIPTOMINMAXENHANCEMENT_H +#include "qgis_core.h" #include "qgscontrastenhancementfunction.h" /** \ingroup core diff --git a/src/core/raster/qgscolorrampshader.cpp b/src/core/raster/qgscolorrampshader.cpp index a5624498d24..927d6c004d6 100644 --- a/src/core/raster/qgscolorrampshader.cpp +++ b/src/core/raster/qgscolorrampshader.cpp @@ -26,22 +26,28 @@ originally part of the larger QgsRasterLayer class #include "qgis.h" #include "qgscolorramp.h" #include "qgscolorrampshader.h" +#include "qgsrasterinterface.h" +#include "qgsrasterminmaxorigin.h" #include - -QgsColorRampShader::QgsColorRampShader( double theMinimumValue, double theMaximumValue ) +QgsColorRampShader::QgsColorRampShader( double theMinimumValue, double theMaximumValue, QgsColorRamp* theColorRamp, Type theType, ClassificationMode theClassificationMode ) : QgsRasterShaderFunction( theMinimumValue, theMaximumValue ) - , mColorRampType( INTERPOLATED ) + , mColorRampType( theType ) + , mClassificationMode( theClassificationMode ) , mLUTOffset( 0.0 ) , mLUTFactor( 1.0 ) , mLUTInitialized( false ) , mClip( false ) { QgsDebugMsgLevel( "called.", 4 ); + + setSourceColorRamp( theColorRamp ); } QgsColorRampShader::QgsColorRampShader( const QgsColorRampShader& other ) : QgsRasterShaderFunction( other ) + , mColorRampType( other.mColorRampType ) + , mClassificationMode( other.mClassificationMode ) , mLUT( other.mLUT ) , mLUTOffset( other.mLUTOffset ) , mLUTFactor( other.mLUTFactor ) @@ -54,6 +60,8 @@ QgsColorRampShader::QgsColorRampShader( const QgsColorRampShader& other ) QgsColorRampShader & QgsColorRampShader::operator=( const QgsColorRampShader & other ) { mSourceColorRamp.reset( other.sourceColorRamp()->clone() ); + mColorRampType = other.mColorRampType; + mClassificationMode = other.mClassificationMode; mLUT = other.mLUT; mLUTOffset = other.mLUTOffset; mLUTFactor = other.mLUTFactor; @@ -62,19 +70,15 @@ QgsColorRampShader & QgsColorRampShader::operator=( const QgsColorRampShader & o return *this; } -QgsColorRampShader::~QgsColorRampShader() -{ -} - QString QgsColorRampShader::colorRampTypeAsQString() { switch ( mColorRampType ) { - case INTERPOLATED: + case Interpolated: return QStringLiteral( "INTERPOLATED" ); - case DISCRETE: + case Discrete: return QStringLiteral( "DISCRETE" ); - case EXACT: + case Exact: return QStringLiteral( "EXACT" ); } return QStringLiteral( "Unknown" ); @@ -88,7 +92,7 @@ void QgsColorRampShader::setColorRampItemList( const QList= maximumValue() ) + { + return; + } + + bool discrete = colorRampType() == Discrete; + + QList entryValues; + QVector entryColors; + + double min = minimumValue(); + double max = maximumValue(); + + if ( classificationMode() == Continuous ) + { + if ( sourceColorRamp() && sourceColorRamp()->count() > 1 ) + { + int numberOfEntries = sourceColorRamp()->count(); + entryValues.reserve( numberOfEntries ); + if ( discrete ) + { + double intervalDiff = max - min; + + // remove last class when ColorRamp is gradient and discrete, as they are implemented with an extra stop + QgsGradientColorRamp* colorGradientRamp = dynamic_cast( sourceColorRamp() ); + if ( colorGradientRamp != NULL && colorGradientRamp->isDiscrete() ) + { + numberOfEntries--; + } + else + { + // if color ramp is continuous scale values to get equally distributed classes. + // Doesn't work perfectly when stops are non equally distributed. + intervalDiff *= ( numberOfEntries - 1 ) / ( double )numberOfEntries; + } + + // skip first value (always 0.0) + for ( int i = 1; i < numberOfEntries; ++i ) + { + double value = sourceColorRamp()->value( i ); + entryValues.push_back( min + value * intervalDiff ); + } + entryValues.push_back( std::numeric_limits::infinity() ); + } + else + { + for ( int i = 0; i < numberOfEntries; ++i ) + { + double value = sourceColorRamp()->value( i ); + entryValues.push_back( min + value * ( max - min ) ); + } + } + // for continuous mode take original color map colors + for ( int i = 0; i < numberOfEntries; ++i ) + { + int idx = i; + entryColors.push_back( sourceColorRamp()->color( sourceColorRamp()->value( idx ) ) ); + } + } + } + else // for other classification modes interpolate colors linearly + { + if ( classes < 2 ) + return; // < 2 classes is not useful, shouldn't happen, but if it happens save it from crashing + + if ( classificationMode() == Quantile ) + { // Quantile + if ( band < 0 || !input ) + return; // quantile classificationr requires a valid band, minMaxOrigin, and input + + double cut1 = std::numeric_limits::quiet_NaN(); + double cut2 = std::numeric_limits::quiet_NaN(); + int sampleSize = 250000; + + // set min and max from histogram, used later to calculate number of decimals to display + input->cumulativeCut( band, 0.0, 1.0, min, max, extent, sampleSize ); + + entryValues.reserve( classes ); + if ( discrete ) + { + double intervalDiff = 1.0 / ( classes ); + for ( int i = 1; i < classes; ++i ) + { + input->cumulativeCut( band, 0.0, i * intervalDiff, cut1, cut2, extent, sampleSize ); + entryValues.push_back( cut2 ); + } + entryValues.push_back( std::numeric_limits::infinity() ); + } + else + { + double intervalDiff = 1.0 / ( classes - 1 ); + for ( int i = 0; i < classes; ++i ) + { + input->cumulativeCut( band, 0.0, i * intervalDiff, cut1, cut2, extent, sampleSize ); + entryValues.push_back( cut2 ); + } + } + } + else // EqualInterval + { + entryValues.reserve( classes ); + if ( discrete ) + { + // in discrete mode the lowest value is not an entry and the highest + // value is inf, there are ( numberOfEntries ) of which the first + // and last are not used. + double intervalDiff = ( max - min ) / ( classes ); + + for ( int i = 1; i < classes; ++i ) + { + entryValues.push_back( min + i * intervalDiff ); + } + entryValues.push_back( std::numeric_limits::infinity() ); + } + else + { + //because the highest value is also an entry, there are (numberOfEntries - 1) intervals + double intervalDiff = ( max - min ) / ( classes - 1 ); + + for ( int i = 0; i < classes; ++i ) + { + entryValues.push_back( min + i * intervalDiff ); + } + } + } + + if ( !sourceColorRamp() || sourceColorRamp()->count() == 1 ) + { + //hard code color range from blue -> red (previous default) + int colorDiff = 0; + if ( classes != 0 ) + { + colorDiff = ( int )( 255 / classes ); + } + + entryColors.reserve( classes ); + for ( int i = 0; i < classes; ++i ) + { + QColor currentColor; + int idx = i; + currentColor.setRgb( colorDiff*idx, 0, 255 - colorDiff * idx ); + entryColors.push_back( currentColor ); + } + } + else + { + entryColors.reserve( classes ); + for ( int i = 0; i < classes; ++i ) + { + int idx = i; + entryColors.push_back( sourceColorRamp()->color((( double ) idx ) / ( classes - 1 ) ) ); + } + } + } + + QList::const_iterator value_it = entryValues.begin(); + QVector::const_iterator color_it = entryColors.begin(); + + // calculate a reasonable number of decimals to display + double maxabs = log10( qMax( qAbs( max ), qAbs( min ) ) ); + int nDecimals = qRound( qMax( 3.0 + maxabs - log10( max - min ), maxabs <= 15.0 ? maxabs + 0.49 : 0.0 ) ); + + QList colorRampItems; + for ( ; value_it != entryValues.end(); ++value_it, ++color_it ) + { + QgsColorRampShader::ColorRampItem newColorRampItem; + newColorRampItem.value = *value_it; + newColorRampItem.color = *color_it; + newColorRampItem.label = QString::number( *value_it, 'g', nDecimals ); + colorRampItems.append( newColorRampItem ); + } + + qSort( colorRampItems ); + setColorRampItemList( colorRampItems ); +} + +void QgsColorRampShader::classifyColorRamp( const int band, const QgsRectangle& extent, QgsRasterInterface* input ) +{ + classifyColorRamp( colorRampItemList().count(), band, extent, input ); +} bool QgsColorRampShader::shade( double theValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue, int *theReturnAlphaValue ) { @@ -201,7 +387,7 @@ bool QgsColorRampShader::shade( double theValue, int* theReturnRedValue, int* th const QgsColorRampShader::ColorRampItem& currentColorRampItem = mColorRampItemList.at( idx ); - if ( QgsColorRampShader::INTERPOLATED == mColorRampType ) + if ( colorRampType() == Interpolated ) { // Interpolate the color between two class breaks linearly. if ( idx < 1 || overflow || currentColorRampItem.value - DOUBLE_DIFF_THRESHOLD <= theValue ) { @@ -229,7 +415,7 @@ bool QgsColorRampShader::shade( double theValue, int* theReturnRedValue, int* th *theReturnAlphaValue = static_cast< int >( static_cast< double >( previousColorRampItem.color.alpha() ) + ( static_cast< double >( currentColorRampItem.color.alpha() - previousColorRampItem.color.alpha() ) * scale ) ); return true; } - else if ( QgsColorRampShader::DISCRETE == mColorRampType ) + else if ( colorRampType() == Discrete ) { // Assign the color of the higher class for every pixel between two class breaks. // NOTE: The implementation has always been different than the documentation, // which said lower class before, see http://hub.qgis.org/issues/13995 diff --git a/src/core/raster/qgscolorrampshader.h b/src/core/raster/qgscolorrampshader.h index 26a20f257c5..6e05e94d1f7 100644 --- a/src/core/raster/qgscolorrampshader.h +++ b/src/core/raster/qgscolorrampshader.h @@ -21,11 +21,14 @@ originally part of the larger QgsRasterLayer class #ifndef QGSCOLORRAMPSHADER_H #define QGSCOLORRAMPSHADER_H +#include "qgis_core.h" #include #include #include "qgscolorramp.h" +#include "qgsrasterinterface.h" #include "qgsrastershaderfunction.h" +#include "qgsrectangle.h" /** \ingroup core * A ramp shader will color a raster pixel based on a list of values ranges in a ramp. @@ -35,11 +38,31 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction public: - QgsColorRampShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0 ); + //! Supported methods for color interpolation. + enum Type + { + Interpolated, //!< Interpolates the color between two class breaks linearly. + Discrete, //!< Assigns the color of the higher class for every pixel between two class breaks. + Exact //!< Assigns the color of the exact matching value in the color ramp item list + }; - /** Destructor + //! Classification modes used to create the color ramp shader + enum ClassificationMode + { + Continuous = 1, //!< Uses breaks from color palette + EqualInterval = 2, //!< Uses equal interval + Quantile = 3 //!< Uses quantile (i.e. equal pixel) count + }; + + /** Creates a new color ramp shader. + * @param theMinimumValue minimum value for the raster shader + * @param theMaximumValue maximum value for the raster shader + * @param theType interpolation type used + * @param theClassificationMode method used to classify the color ramp shader + * @param theColorRamp vector color ramp used to classify the color ramp shader + * @returns new QgsColorRampShader */ - virtual ~QgsColorRampShader(); + QgsColorRampShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0, QgsColorRamp* theColorRamp = nullptr, Type theType = Interpolated, ClassificationMode theClassificationMode = Continuous ); /** Copy constructor */ @@ -72,19 +95,11 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction bool operator<( const ColorRampItem& other ) const { return value < other.value; } }; - //! Supported methods for color interpolation. - enum ColorRamp_TYPE - { - INTERPOLATED, //!< Interpolates the color between two class breaks linearly. - DISCRETE, //!< Assigns the color of the higher class for every pixel between two class breaks. - EXACT //!< Assigns the color of the exact matching value in the color ramp item list - }; - //! \brief Get the custom colormap QList colorRampItemList() const { return mColorRampItemList.toList(); } //! \brief Get the color ramp type - QgsColorRampShader::ColorRamp_TYPE colorRampType() const { return mColorRampType; } + Type colorRampType() const { return mColorRampType; } //! \brief Get the color ramp type as a string QString colorRampTypeAsQString(); @@ -93,7 +108,7 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction void setColorRampItemList( const QList& theList ); //TODO: sort on set //! \brief Set the color ramp type - void setColorRampType( QgsColorRampShader::ColorRamp_TYPE theColorRampType ); + void setColorRampType( QgsColorRampShader::Type theColorRampType ); /** Get the source color ramp * @note added in QGIS 3.0 @@ -110,6 +125,21 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction //! \brief Set the color ramp type void setColorRampType( const QString& theType ); + /** Classify color ramp shader + * @param classes number of classes + * @param band raster band used in classification (only used in quantile mode) + * @param extent extent used in classification (only used in quantile mode) + * @param input raster input used in classification (only used in quantile mode) + */ + void classifyColorRamp( const int classes = 0, const int band = -1, const QgsRectangle& extent = QgsRectangle(), QgsRasterInterface* input = nullptr ); + + /** Classify color ramp shader + * @param band raster band used in classification (quantile mode only) + * @param extent extent used in classification (quantile mode only) + * @param input raster input used in classification (quantile mode only) + */ + void classifyColorRamp( const int band = -1, const QgsRectangle& extent = QgsRectangle(), QgsRasterInterface* input = nullptr ); + //! \brief Generates and new RGB value based on one input value bool shade( double, int*, int*, int*, int* ) override; @@ -119,6 +149,12 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction //! \brief Get symbology items if provided by renderer void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const override; + //! Sets classification mode + void setClassificationMode( ClassificationMode classificationMode ) { mClassificationMode = classificationMode; } + + //! Returns the classification mode + ClassificationMode classificationMode() const { return mClassificationMode; } + /** Sets whether the shader should not render values out of range. * @param clip set to true to clip values which are out of range. * @see clip() @@ -144,8 +180,8 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction * interpolated for values between the item values (false)*/ QVector mColorRampItemList; - //! \brief The color ramp type - QgsColorRampShader::ColorRamp_TYPE mColorRampType; + Type mColorRampType; + ClassificationMode mClassificationMode; /** Look up table to speed up finding the right color. * It is initialized on the first call to shade(). */ diff --git a/src/core/raster/qgscontrastenhancement.h b/src/core/raster/qgscontrastenhancement.h index fa8086befb8..ee49b969cf0 100644 --- a/src/core/raster/qgscontrastenhancement.h +++ b/src/core/raster/qgscontrastenhancement.h @@ -21,6 +21,7 @@ class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz #ifndef QGSCONTRASTENHANCEMENT_H #define QGSCONTRASTENHANCEMENT_H +#include "qgis_core.h" #include #include "qgis.h" @@ -55,6 +56,8 @@ class CORE_EXPORT QgsContrastEnhancement QgsContrastEnhancement( const QgsContrastEnhancement& ce ); ~QgsContrastEnhancement(); + const QgsContrastEnhancement& operator=( const QgsContrastEnhancement& ) = delete; + /* * * Static methods @@ -146,7 +149,6 @@ class CORE_EXPORT QgsContrastEnhancement //! \brief Method to calculate the actual enhanceContrasted value(s) int calculateContrastEnhancementValue( double ); - const QgsContrastEnhancement& operator=( const QgsContrastEnhancement& ); }; #endif diff --git a/src/core/raster/qgscontrastenhancementfunction.h b/src/core/raster/qgscontrastenhancementfunction.h index 4221fa84361..fdb84c230f5 100644 --- a/src/core/raster/qgscontrastenhancementfunction.h +++ b/src/core/raster/qgscontrastenhancementfunction.h @@ -19,6 +19,7 @@ email : ersts@amnh.org #ifndef QGSCONTRASTENHANCEMENTFUNCTION_H #define QGSCONTRASTENHANCEMENTFUNCTION_H +#include "qgis_core.h" #include "qgis.h" /** \ingroup core @@ -33,7 +34,7 @@ class CORE_EXPORT QgsContrastEnhancementFunction public: QgsContrastEnhancementFunction( Qgis::DataType, double, double ); QgsContrastEnhancementFunction( const QgsContrastEnhancementFunction& f ); - virtual ~QgsContrastEnhancementFunction() {} + virtual ~QgsContrastEnhancementFunction() = default; //! \brief A customizable method that takes in a double and returns a int between 0 and 255 virtual int enhance( double ); diff --git a/src/core/raster/qgscubicrasterresampler.cpp b/src/core/raster/qgscubicrasterresampler.cpp index a71657cf3fe..41112edda9b 100644 --- a/src/core/raster/qgscubicrasterresampler.cpp +++ b/src/core/raster/qgscubicrasterresampler.cpp @@ -35,10 +35,6 @@ QgsCubicRasterResampler::QgsCubicRasterResampler() { } -QgsCubicRasterResampler::~QgsCubicRasterResampler() -{ -} - QgsCubicRasterResampler* QgsCubicRasterResampler::clone() const { return new QgsCubicRasterResampler(); diff --git a/src/core/raster/qgscubicrasterresampler.h b/src/core/raster/qgscubicrasterresampler.h index 36f7001e1f7..ea69ee87bcc 100644 --- a/src/core/raster/qgscubicrasterresampler.h +++ b/src/core/raster/qgscubicrasterresampler.h @@ -21,6 +21,8 @@ #include "qgsrasterresampler.h" #include +#include "qgis_core.h" + /** \ingroup core Cubic Raster Resampler */ @@ -28,7 +30,6 @@ class CORE_EXPORT QgsCubicRasterResampler: public QgsRasterResampler { public: QgsCubicRasterResampler(); - ~QgsCubicRasterResampler(); QgsCubicRasterResampler * clone() const override; void resample( const QImage& srcImage, QImage& dstImage ) override; QString type() const override { return QStringLiteral( "cubic" ); } diff --git a/src/core/raster/qgshillshaderenderer.h b/src/core/raster/qgshillshaderenderer.h index be4cee42ad1..9bb7bce56d6 100644 --- a/src/core/raster/qgshillshaderenderer.h +++ b/src/core/raster/qgshillshaderenderer.h @@ -19,6 +19,7 @@ #define QGSHILLSHADERENDERER_H +#include "qgis_core.h" #include "qgsrasterrenderer.h" class QgsRasterBlock; diff --git a/src/core/raster/qgshuesaturationfilter.cpp b/src/core/raster/qgshuesaturationfilter.cpp index 4d7f0f0d4ee..2ac0d4037ec 100644 --- a/src/core/raster/qgshuesaturationfilter.cpp +++ b/src/core/raster/qgshuesaturationfilter.cpp @@ -35,10 +35,6 @@ QgsHueSaturationFilter::QgsHueSaturationFilter( QgsRasterInterface* input ) { } -QgsHueSaturationFilter::~QgsHueSaturationFilter() -{ -} - QgsHueSaturationFilter* QgsHueSaturationFilter::clone() const { QgsDebugMsgLevel( "Entered hue/saturation filter", 4 ); diff --git a/src/core/raster/qgshuesaturationfilter.h b/src/core/raster/qgshuesaturationfilter.h index 70224589a20..a74b93e5092 100644 --- a/src/core/raster/qgshuesaturationfilter.h +++ b/src/core/raster/qgshuesaturationfilter.h @@ -18,6 +18,7 @@ #ifndef QGSHUESATURATIONFILTER_H #define QGSHUESATURATIONFILTER_H +#include "qgis_core.h" #include "qgsrasterinterface.h" class QDomElement; @@ -39,7 +40,6 @@ class CORE_EXPORT QgsHueSaturationFilter : public QgsRasterInterface }; QgsHueSaturationFilter( QgsRasterInterface *input = nullptr ); - ~QgsHueSaturationFilter(); QgsHueSaturationFilter * clone() const override; diff --git a/src/core/raster/qgslinearminmaxenhancement.h b/src/core/raster/qgslinearminmaxenhancement.h index 61e2a20cb00..26356ffd056 100644 --- a/src/core/raster/qgslinearminmaxenhancement.h +++ b/src/core/raster/qgslinearminmaxenhancement.h @@ -19,6 +19,7 @@ email : ersts@amnh.org #ifndef QGSLINEARMINMAXENHANCEMENT_H #define QGSLINEARMINMAXENHANCEMENT_H +#include "qgis_core.h" #include "qgscontrastenhancementfunction.h" /** \ingroup core diff --git a/src/core/raster/qgslinearminmaxenhancementwithclip.h b/src/core/raster/qgslinearminmaxenhancementwithclip.h index 9b577a0b7d4..abafe581b96 100644 --- a/src/core/raster/qgslinearminmaxenhancementwithclip.h +++ b/src/core/raster/qgslinearminmaxenhancementwithclip.h @@ -19,6 +19,7 @@ email : ersts@amnh.org #ifndef QGSLINEARMINMAXENHANCEMENTWITHCLIP_H #define QGSLINEARMINMAXENHANCEMENTWITHCLIP_H +#include "qgis_core.h" #include "qgscontrastenhancementfunction.h" /** \ingroup core diff --git a/src/core/raster/qgsmultibandcolorrenderer.h b/src/core/raster/qgsmultibandcolorrenderer.h index c47e2eeac95..8e535a78796 100644 --- a/src/core/raster/qgsmultibandcolorrenderer.h +++ b/src/core/raster/qgsmultibandcolorrenderer.h @@ -18,6 +18,7 @@ #ifndef QGSMULTIBANDCOLORRENDERER_H #define QGSMULTIBANDCOLORRENDERER_H +#include "qgis_core.h" #include "qgsrasterrenderer.h" class QgsContrastEnhancement; @@ -33,6 +34,12 @@ class CORE_EXPORT QgsMultiBandColorRenderer: public QgsRasterRenderer QgsContrastEnhancement* redEnhancement = nullptr, QgsContrastEnhancement* greenEnhancement = nullptr, QgsContrastEnhancement* blueEnhancement = nullptr ); ~QgsMultiBandColorRenderer(); + + //! QgsMultiBandColorRenderer cannot be copied. Use clone() instead. + QgsMultiBandColorRenderer( const QgsMultiBandColorRenderer& ) = delete; + //! QgsMultiBandColorRenderer cannot be copied. Use clone() instead. + const QgsMultiBandColorRenderer& operator=( const QgsMultiBandColorRenderer& ) = delete; + QgsMultiBandColorRenderer * clone() const override; static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input ); @@ -71,8 +78,6 @@ class CORE_EXPORT QgsMultiBandColorRenderer: public QgsRasterRenderer QgsContrastEnhancement* mGreenContrastEnhancement; QgsContrastEnhancement* mBlueContrastEnhancement; - QgsMultiBandColorRenderer( const QgsMultiBandColorRenderer& ); - const QgsMultiBandColorRenderer& operator=( const QgsMultiBandColorRenderer& ); }; #endif // QGSMULTIBANDCOLORRENDERER_H diff --git a/src/core/raster/qgspalettedrasterrenderer.h b/src/core/raster/qgspalettedrasterrenderer.h index e28f8b3858f..838ee46c173 100644 --- a/src/core/raster/qgspalettedrasterrenderer.h +++ b/src/core/raster/qgspalettedrasterrenderer.h @@ -18,6 +18,7 @@ #ifndef QGSPALETTEDRASTERRENDERER_H #define QGSPALETTEDRASTERRENDERER_H +#include "qgis_core.h" #include #include "qgsrasterrenderer.h" @@ -36,6 +37,12 @@ class CORE_EXPORT QgsPalettedRasterRenderer: public QgsRasterRenderer QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber, QColor* colorArray, int nColors, const QVector& labels = QVector() ); QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber, QRgb* colorArray, int nColors, const QVector& labels = QVector() ); ~QgsPalettedRasterRenderer(); + + //! QgsPalettedRasterRenderer cannot be copied. Use clone() instead. + QgsPalettedRasterRenderer( const QgsPalettedRasterRenderer& ) = delete; + //! QgsPalettedRasterRenderer cannot be copied. Use clone() instead. + const QgsPalettedRasterRenderer& operator=( const QgsPalettedRasterRenderer& ) = delete; + QgsPalettedRasterRenderer * clone() const override; static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input ); @@ -74,8 +81,6 @@ class CORE_EXPORT QgsPalettedRasterRenderer: public QgsRasterRenderer //! Optional category labels, size of vector may be < mNColors QVector mLabels; - QgsPalettedRasterRenderer( const QgsPalettedRasterRenderer& ); - const QgsPalettedRasterRenderer& operator=( const QgsPalettedRasterRenderer& ); }; #endif // QGSPALETTEDRASTERRENDERER_H diff --git a/src/core/raster/qgsraster.h b/src/core/raster/qgsraster.h index e3b00466acd..79f00d4ecb7 100644 --- a/src/core/raster/qgsraster.h +++ b/src/core/raster/qgsraster.h @@ -18,6 +18,7 @@ #ifndef QGSRASTER_H #define QGSRASTER_H +#include "qgis_core.h" #include #include "qgis.h" diff --git a/src/core/raster/qgsrasterbandstats.h b/src/core/raster/qgsrasterbandstats.h index ca93dba2664..af2cec6eacd 100644 --- a/src/core/raster/qgsrasterbandstats.h +++ b/src/core/raster/qgsrasterbandstats.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERBANDSTATS #define QGSRASTERBANDSTATS +#include "qgis_core.h" #include #include diff --git a/src/core/raster/qgsrasterblock.h b/src/core/raster/qgsrasterblock.h index 3256ba37c03..6e603504145 100644 --- a/src/core/raster/qgsrasterblock.h +++ b/src/core/raster/qgsrasterblock.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERBLOCK_H #define QGSRASTERBLOCK_H +#include "qgis_core.h" #include #include #include "qgis.h" diff --git a/src/core/raster/qgsrasterchecker.h b/src/core/raster/qgsrasterchecker.h index 68b44846720..3412c241eaa 100644 --- a/src/core/raster/qgsrasterchecker.h +++ b/src/core/raster/qgsrasterchecker.h @@ -16,6 +16,7 @@ #ifndef QGSRASTERCHECKER_H #define QGSRASTERCHECKER_H +#include "qgis_core.h" #include #include class QImage; @@ -31,9 +32,6 @@ class CORE_EXPORT QgsRasterChecker QgsRasterChecker(); - //! Destructor - ~QgsRasterChecker() {} - QString report() { return mReport; } /** diff --git a/src/core/raster/qgsrasterdataprovider.cpp b/src/core/raster/qgsrasterdataprovider.cpp index 4b45b31d70c..fc171d660bd 100644 --- a/src/core/raster/qgsrasterdataprovider.cpp +++ b/src/core/raster/qgsrasterdataprovider.cpp @@ -20,6 +20,7 @@ #include "qgsrasteridentifyresult.h" #include "qgsrasterprojector.h" #include "qgslogger.h" +#include "qgsapplication.h" #include #include diff --git a/src/core/raster/qgsrasterdataprovider.h b/src/core/raster/qgsrasterdataprovider.h index 6bccd2af864..334b2e396ae 100644 --- a/src/core/raster/qgsrasterdataprovider.h +++ b/src/core/raster/qgsrasterdataprovider.h @@ -23,6 +23,7 @@ #ifndef QGSRASTERDATAPROVIDER_H #define QGSRASTERDATAPROVIDER_H +#include "qgis_core.h" #include #include @@ -56,8 +57,6 @@ class CORE_EXPORT QgsImageFetcher : public QObject public: //! Constructor QgsImageFetcher( QObject* parent = 0 ) : QObject( parent ) {} - //! Destructor - virtual ~QgsImageFetcher() {} /** Starts the image download * @note Make sure to connect to "finish" and "error" before starting */ @@ -87,8 +86,6 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast QgsRasterDataProvider( const QString & uri ); - virtual ~QgsRasterDataProvider() {} - virtual QgsRasterInterface * clone() const override = 0; /* It makes no sense to set input on provider */ diff --git a/src/core/raster/qgsrasterdrawer.h b/src/core/raster/qgsrasterdrawer.h index 7030f599808..08268fe39cc 100644 --- a/src/core/raster/qgsrasterdrawer.h +++ b/src/core/raster/qgsrasterdrawer.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERDRAWER_H #define QGSRASTERDRAWER_H +#include "qgis_core.h" #include class QPainter; diff --git a/src/core/raster/qgsrasterfilewriter.h b/src/core/raster/qgsrasterfilewriter.h index 8e446e454ca..663315e8b8d 100644 --- a/src/core/raster/qgsrasterfilewriter.h +++ b/src/core/raster/qgsrasterfilewriter.h @@ -15,6 +15,7 @@ #ifndef QGSRASTERFILEWRITER_H #define QGSRASTERFILEWRITER_H +#include "qgis_core.h" #include "qgscoordinatereferencesystem.h" #include #include diff --git a/src/core/raster/qgsrasterhistogram.h b/src/core/raster/qgsrasterhistogram.h index 474274bb692..c82b04f5c65 100644 --- a/src/core/raster/qgsrasterhistogram.h +++ b/src/core/raster/qgsrasterhistogram.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERHISTOGRAM #define QGSRASTERHISTOGRAM +#include "qgis_core.h" #include #include diff --git a/src/core/raster/qgsrasteridentifyresult.cpp b/src/core/raster/qgsrasteridentifyresult.cpp index 77da28a34bc..a78187dff16 100644 --- a/src/core/raster/qgsrasteridentifyresult.cpp +++ b/src/core/raster/qgsrasteridentifyresult.cpp @@ -42,6 +42,3 @@ QgsRasterIdentifyResult::QgsRasterIdentifyResult( const QgsError& theError ) { } -QgsRasterIdentifyResult::~QgsRasterIdentifyResult() -{ -} diff --git a/src/core/raster/qgsrasteridentifyresult.h b/src/core/raster/qgsrasteridentifyresult.h index c9ca82a5419..a34315c506f 100644 --- a/src/core/raster/qgsrasteridentifyresult.h +++ b/src/core/raster/qgsrasteridentifyresult.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERIDENTIFYRESULT_H #define QGSRASTERIDENTIFYRESULT_H +#include "qgis_core.h" #include "qgis.h" #include "qgsraster.h" #include "qgserror.h" @@ -41,7 +42,7 @@ class CORE_EXPORT QgsRasterIdentifyResult */ QgsRasterIdentifyResult( const QgsError& theError ); - virtual ~QgsRasterIdentifyResult(); + virtual ~QgsRasterIdentifyResult() = default; //! \brief Returns true if valid bool isValid() const { return mValid; } diff --git a/src/core/raster/qgsrasterinterface.cpp b/src/core/raster/qgsrasterinterface.cpp index 7be4f39955d..b73e091b02f 100644 --- a/src/core/raster/qgsrasterinterface.cpp +++ b/src/core/raster/qgsrasterinterface.cpp @@ -36,10 +36,6 @@ QgsRasterInterface::QgsRasterInterface( QgsRasterInterface * input ) { } -QgsRasterInterface::~QgsRasterInterface() -{ -} - void QgsRasterInterface::initStatistics( QgsRasterBandStats &theStatistics, int theBandNo, int theStats, diff --git a/src/core/raster/qgsrasterinterface.h b/src/core/raster/qgsrasterinterface.h index 0cfd85d98a3..011960822bb 100644 --- a/src/core/raster/qgsrasterinterface.h +++ b/src/core/raster/qgsrasterinterface.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERINTERFACE_H #define QGSRASTERINTERFACE_H +#include "qgis_core.h" #include #include // for tr() @@ -94,7 +95,7 @@ class CORE_EXPORT QgsRasterInterface QgsRasterInterface( QgsRasterInterface * input = nullptr ); - virtual ~QgsRasterInterface(); + virtual ~QgsRasterInterface() = default; //! Clone itself, create deep copy virtual QgsRasterInterface *clone() const = 0; @@ -208,7 +209,7 @@ class CORE_EXPORT QgsRasterInterface /** \brief Get histogram. Histograms are cached in providers. * @param theBandNo The band (number). - * @param theBinCount Number of bins (intervals,buckets). If 0, the number of bins is decided automaticaly according to data type, raster size etc. + * @param theBinCount Number of bins (intervals,buckets). If 0, the number of bins is decided automatically according to data type, raster size etc. * @param theMinimum Minimum value, if NaN, raster minimum value will be used. * @param theMaximum Maximum value, if NaN, raster minimum value will be used. * @param theExtent Extent used to calc histogram, if empty, whole raster extent is used. diff --git a/src/core/raster/qgsrasteriterator.h b/src/core/raster/qgsrasteriterator.h index 63f6586242d..40e0790eafe 100644 --- a/src/core/raster/qgsrasteriterator.h +++ b/src/core/raster/qgsrasteriterator.h @@ -15,6 +15,7 @@ #ifndef QGSRASTERITERATOR_H #define QGSRASTERITERATOR_H +#include "qgis_core.h" #include "qgsrectangle.h" #include diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp index 2cc9c206325..a455b2f846c 100644 --- a/src/core/raster/qgsrasterlayer.cpp +++ b/src/core/raster/qgsrasterlayer.cpp @@ -242,7 +242,7 @@ QString QgsRasterLayer::bandName( int theBandNo ) const void QgsRasterLayer::setRendererForDrawingStyle( QgsRaster::DrawingStyle theDrawingStyle ) { - setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( theDrawingStyle, mDataProvider ) ); + setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( theDrawingStyle, mDataProvider ) ); } /** @@ -550,7 +550,7 @@ QPixmap QgsRasterLayer::paletteAsPixmap( int theBandNumber ) { QgsDebugMsgLevel( "....got color ramp item list", 4 ); myShader.setColorRampItemList( myColorRampItemList ); - myShader.setColorRampType( QgsColorRampShader::DISCRETE ); + myShader.setColorRampType( QgsColorRampShader::Discrete ); // Draw image int mySize = 100; QPixmap myPalettePixmap( mySize, mySize ); @@ -758,7 +758,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider ) // TODO: this should go somewhere else QgsRasterShader* shader = new QgsRasterShader(); QgsColorRampShader* colorRampShader = new QgsColorRampShader(); - colorRampShader->setColorRampType( QgsColorRampShader::INTERPOLATED ); + colorRampShader->setColorRampType( QgsColorRampShader::Interpolated ); colorRampShader->setColorRampItemList( colorTable ); shader->setRasterShaderFunction( colorRampShader ); r->setShader( shader ); @@ -910,12 +910,16 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh QgsRasterMinMaxOrigin myMinMaxOrigin; QgsRasterRenderer* myRasterRenderer = nullptr; QgsSingleBandGrayRenderer* myGrayRenderer = nullptr; + QgsSingleBandPseudoColorRenderer* myPseudoColorRenderer = nullptr; QgsMultiBandColorRenderer* myMultiBandRenderer = nullptr; QString rendererType = rasterRenderer->type(); if ( rendererType == QLatin1String( "singlebandgray" ) ) { myGrayRenderer = dynamic_cast( rasterRenderer ); - if ( !myGrayRenderer ) return; + if ( !myGrayRenderer ) + { + return; + } myBands << myGrayRenderer->grayBand(); myRasterRenderer = myGrayRenderer; myMinMaxOrigin = myGrayRenderer->minMaxOrigin(); @@ -923,11 +927,25 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh else if ( rendererType == QLatin1String( "multibandcolor" ) ) { myMultiBandRenderer = dynamic_cast( rasterRenderer ); - if ( !myMultiBandRenderer ) return; + if ( !myMultiBandRenderer ) + { + return; + } myBands << myMultiBandRenderer->redBand() << myMultiBandRenderer->greenBand() << myMultiBandRenderer->blueBand(); myRasterRenderer = myMultiBandRenderer; myMinMaxOrigin = myMultiBandRenderer->minMaxOrigin(); } + else if ( rendererType == QLatin1String( "singlebandpseudocolor" ) ) + { + myPseudoColorRenderer = dynamic_cast( rasterRenderer ); + if ( !myPseudoColorRenderer ) + { + return; + } + myBands << myPseudoColorRenderer->band(); + myRasterRenderer = myPseudoColorRenderer; + myMinMaxOrigin = myPseudoColorRenderer->minMaxOrigin(); + } Q_FOREACH ( int myBand, myBands ) { @@ -941,9 +959,25 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh double max; computeMinMax( myBand, myMinMaxOrigin, theLimits, theExtent, theSampleSize, min, max ); - myEnhancement->setMinimumValue( min ); - myEnhancement->setMaximumValue( max ); - myEnhancements.append( myEnhancement ); + if ( rendererType == QLatin1String( "singlebandpseudocolor" ) ) + { + myPseudoColorRenderer->setClassificationMin( min ); + myPseudoColorRenderer->setClassificationMax( max ); + if ( myPseudoColorRenderer->shader() ) + { + QgsColorRampShader* colorRampShader = dynamic_cast( myPseudoColorRenderer->shader()->rasterShaderFunction() ); + if ( colorRampShader ) + { + colorRampShader->classifyColorRamp( myPseudoColorRenderer->band(), theExtent, myPseudoColorRenderer->input() ); + } + } + } + else + { + myEnhancement->setMinimumValue( min ); + myEnhancement->setMaximumValue( max ); + myEnhancements.append( myEnhancement ); + } } else { @@ -1057,8 +1091,30 @@ void QgsRasterLayer::refreshRendererIfNeeded( QgsRasterRenderer* rasterRenderer, SAMPLE_SIZE, min, max ); sbpcr->setClassificationMin( min ); sbpcr->setClassificationMax( max ); - dynamic_cast( renderer() )->setClassificationMin( min ); - dynamic_cast( renderer() )->setClassificationMax( max ); + + if ( sbpcr->shader() ) + { + QgsColorRampShader* colorRampShader = dynamic_cast( sbpcr->shader()->rasterShaderFunction() ); + if ( colorRampShader ) + { + colorRampShader->classifyColorRamp( sbpcr->band(), theExtent, rasterRenderer->input() ); + } + } + + QgsSingleBandPseudoColorRenderer* r = dynamic_cast( renderer() ); + r->setClassificationMin( min ); + r->setClassificationMax( max ); + + if ( r->shader() ) + { + QgsColorRampShader* colorRampShader = dynamic_cast( r->shader()->rasterShaderFunction() ); + if ( colorRampShader ) + { + colorRampShader->classifyColorRamp( sbpcr->band(), theExtent, rasterRenderer->input() ); + } + } + + emit repaintRequested(); emit styleChanged(); emit rendererChanged(); return; @@ -1202,7 +1258,11 @@ QDateTime QgsRasterLayer::timestamp() const void QgsRasterLayer::setRenderer( QgsRasterRenderer* theRenderer ) { QgsDebugMsgLevel( "Entered", 4 ); - if ( !theRenderer ) { return; } + if ( !theRenderer ) + { + return; + } + mPipe.set( theRenderer ); emit rendererChanged(); emit styleChanged(); @@ -1334,7 +1394,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe { QString rendererType = rasterRendererElem.attribute( QStringLiteral( "type" ) ); QgsRasterRendererRegistryEntry rendererEntry; - if ( QgsRasterRendererRegistry::instance()->rendererData( rendererType, rendererEntry ) ) + if ( QgsApplication::rasterRendererRegistry()->rendererData( rendererType, rendererEntry ) ) { QgsRasterRenderer *renderer = rendererEntry.rendererCreateFunction( rasterRendererElem, dataProvider() ); mPipe.set( renderer ); diff --git a/src/core/raster/qgsrasterlayer.h b/src/core/raster/qgsrasterlayer.h index e4d4fb8773e..775073c5d11 100644 --- a/src/core/raster/qgsrasterlayer.h +++ b/src/core/raster/qgsrasterlayer.h @@ -21,6 +21,7 @@ #ifndef QGSRASTERLAYER_H #define QGSRASTERLAYER_H +#include "qgis_core.h" #include #include #include @@ -193,7 +194,6 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer const QString &providerKey, bool loadDefaultStyleFlag = true ); - //! \brief The destructor ~QgsRasterLayer(); //! \brief This enumerator describes the types of shading that can be used diff --git a/src/core/raster/qgsrasterlayerrenderer.cpp b/src/core/raster/qgsrasterlayerrenderer.cpp index 54686bb2602..f2df19feab5 100644 --- a/src/core/raster/qgsrasterlayerrenderer.cpp +++ b/src/core/raster/qgsrasterlayerrenderer.cpp @@ -179,7 +179,7 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer* layer, QgsRender mPipe = new QgsRasterPipe( *layer->pipe() ); QgsRasterRenderer* rasterRenderer = mPipe->renderer(); if ( rasterRenderer ) - layer->refreshRendererIfNeeded( rasterRenderer, myRasterExtent ); + layer->refreshRendererIfNeeded( rasterRenderer, rendererContext.extent() ); } QgsRasterLayerRenderer::~QgsRasterLayerRenderer() diff --git a/src/core/raster/qgsrasterminmaxorigin.h b/src/core/raster/qgsrasterminmaxorigin.h index 62cb17af371..8c9758d9faa 100644 --- a/src/core/raster/qgsrasterminmaxorigin.h +++ b/src/core/raster/qgsrasterminmaxorigin.h @@ -21,6 +21,8 @@ #include #include +#include "qgis_core.h" + /** \ingroup core * This class describes the origin of min/max values. It does not store by * itself the min/max values. diff --git a/src/core/raster/qgsrasternuller.cpp b/src/core/raster/qgsrasternuller.cpp index 913541d5fdd..6f55dfc0e64 100644 --- a/src/core/raster/qgsrasternuller.cpp +++ b/src/core/raster/qgsrasternuller.cpp @@ -23,10 +23,6 @@ QgsRasterNuller::QgsRasterNuller( QgsRasterInterface* input ) { } -QgsRasterNuller::~QgsRasterNuller() -{ -} - QgsRasterNuller* QgsRasterNuller::clone() const { QgsDebugMsgLevel( "Entered", 4 ); diff --git a/src/core/raster/qgsrasternuller.h b/src/core/raster/qgsrasternuller.h index e52f8a6dfc3..6a3e00789a7 100644 --- a/src/core/raster/qgsrasternuller.h +++ b/src/core/raster/qgsrasternuller.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERNULLER_H #define QGSRASTERNULLER_H +#include "qgis_core.h" #include "qgsrasterrange.h" #include "qgsrasterinterface.h" @@ -30,7 +31,6 @@ class CORE_EXPORT QgsRasterNuller : public QgsRasterInterface { public: QgsRasterNuller( QgsRasterInterface* input = nullptr ); - ~QgsRasterNuller(); struct NoData { diff --git a/src/core/raster/qgsrasterpipe.h b/src/core/raster/qgsrasterpipe.h index bf695b1baf5..3d2280d322b 100644 --- a/src/core/raster/qgsrasterpipe.h +++ b/src/core/raster/qgsrasterpipe.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERPIPE_H #define QGSRASTERPIPE_H +#include "qgis_core.h" #include #include #include @@ -61,6 +62,8 @@ class CORE_EXPORT QgsRasterPipe ~QgsRasterPipe(); + QgsRasterPipe& operator=( const QgsRasterPipe& rh ) = delete; + /** Try to insert interface at specified index and connect * if connection would fail, the interface is not inserted and false is returned */ bool insert( int idx, QgsRasterInterface* theInterface ); @@ -128,7 +131,6 @@ class CORE_EXPORT QgsRasterPipe Returns true if connected or false if connection failed */ bool connect( QVector theInterfaces ); - QgsRasterPipe& operator=( const QgsRasterPipe& rh ); }; #endif diff --git a/src/core/raster/qgsrasterprojector.cpp b/src/core/raster/qgsrasterprojector.cpp index 9fcbec166cb..41967d7ee79 100644 --- a/src/core/raster/qgsrasterprojector.cpp +++ b/src/core/raster/qgsrasterprojector.cpp @@ -46,10 +46,6 @@ QgsRasterProjector* QgsRasterProjector::clone() const return projector; } -QgsRasterProjector::~QgsRasterProjector() -{ -} - int QgsRasterProjector::bandCount() const { if ( mInput ) return mInput->bandCount(); diff --git a/src/core/raster/qgsrasterprojector.h b/src/core/raster/qgsrasterprojector.h index 26aa5bd0c93..5571dee7eff 100644 --- a/src/core/raster/qgsrasterprojector.h +++ b/src/core/raster/qgsrasterprojector.h @@ -23,6 +23,7 @@ #ifndef QGSRASTERPROJECTOR_H #define QGSRASTERPROJECTOR_H +#include "qgis_core.h" #include #include @@ -56,9 +57,6 @@ class CORE_EXPORT QgsRasterProjector : public QgsRasterInterface QgsRasterProjector(); - //! \brief The destructor - ~QgsRasterProjector(); - QgsRasterProjector *clone() const override; int bandCount() const override; @@ -124,6 +122,9 @@ class ProjectorData ProjectorData( const QgsRectangle &extent, int width, int height, QgsRasterInterface *input, const QgsCoordinateTransform &inverseCt, QgsRasterProjector::Precision precision ); ~ProjectorData(); + ProjectorData( const ProjectorData& other ) = delete; + ProjectorData& operator=( const ProjectorData& other ) = delete; + /** \brief Get source row and column indexes for current source extent and resolution If source pixel is outside source extent theSrcRow and theSrcCol are left unchanged. @return true if inside source @@ -135,8 +136,6 @@ class ProjectorData int srcCols() const { return mSrcCols; } private: - ProjectorData( const ProjectorData& other ); - ProjectorData& operator=( const ProjectorData& other ); //! \brief get destination point for _current_ destination position void destPointOnCPMatrix( int theRow, int theCol, double *theX, double *theY ); diff --git a/src/core/raster/qgsrasterpyramid.h b/src/core/raster/qgsrasterpyramid.h index 544ea2badc4..55fe8a2f0d1 100644 --- a/src/core/raster/qgsrasterpyramid.h +++ b/src/core/raster/qgsrasterpyramid.h @@ -18,6 +18,8 @@ #ifndef QGSRASTERPYRAMID #define QGSRASTERPYRAMID +#include "qgis_core.h" + /** \ingroup core * This struct is used to store pyramid info for the raster layer. */ diff --git a/src/core/raster/qgsrasterrange.h b/src/core/raster/qgsrasterrange.h index a4a837b36a0..fb1ce908a7f 100644 --- a/src/core/raster/qgsrasterrange.h +++ b/src/core/raster/qgsrasterrange.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERRANGE_H #define QGSRASTERRANGE_H +#include "qgis_core.h" #include class QgsRasterRange; diff --git a/src/core/raster/qgsrasterrenderer.h b/src/core/raster/qgsrasterrenderer.h index ef58df9f71a..4d27804f207 100644 --- a/src/core/raster/qgsrasterrenderer.h +++ b/src/core/raster/qgsrasterrenderer.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERRENDERER_H #define QGSRASTERRENDERER_H +#include "qgis_core.h" #include #include "qgsrasterinterface.h" @@ -43,6 +44,11 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface QgsRasterRenderer( QgsRasterInterface* input = nullptr, const QString& type = "" ); virtual ~QgsRasterRenderer(); + //! QgsRasterRenderer cannot be copied. Use clone() instead. + QgsRasterRenderer( const QgsRasterRenderer& ) = delete; + //! QgsRasterRenderer cannot be copied. Use clone() instead. + const QgsRasterRenderer& operator=( const QgsRasterRenderer& ) = delete; + QgsRasterRenderer * clone() const override = 0; virtual int bandCount() const override; @@ -105,10 +111,6 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface //! Origin of min/max values QgsRasterMinMaxOrigin mMinMaxOrigin; - private: - - QgsRasterRenderer( const QgsRasterRenderer& ); - const QgsRasterRenderer& operator=( const QgsRasterRenderer& ); }; #endif // QGSRASTERRENDERER_H diff --git a/src/core/raster/qgsrasterrendererregistry.cpp b/src/core/raster/qgsrasterrendererregistry.cpp index e5cf48719ee..90da8d5bda1 100644 --- a/src/core/raster/qgsrasterrendererregistry.cpp +++ b/src/core/raster/qgsrasterrendererregistry.cpp @@ -49,12 +49,6 @@ QIcon QgsRasterRendererRegistryEntry::icon() return QgsApplication::getThemeIcon( QString( "styleicons/%1.svg" ).arg( name ) ); } -QgsRasterRendererRegistry* QgsRasterRendererRegistry::instance() -{ - static QgsRasterRendererRegistry mInstance; - return &mInstance; -} - QgsRasterRendererRegistry::QgsRasterRendererRegistry() { // insert items in a particular order, which is returned in renderersList() diff --git a/src/core/raster/qgsrasterrendererregistry.h b/src/core/raster/qgsrasterrendererregistry.h index a7e3fa3754a..e13f9a5ac58 100644 --- a/src/core/raster/qgsrasterrendererregistry.h +++ b/src/core/raster/qgsrasterrendererregistry.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERRENDERERREGISTRY_H #define QGSRASTERRENDERERREGISTRY_H +#include "qgis_core.h" #include "qgsrasterlayer.h" //for DrawingStyle enum #include #include @@ -48,12 +49,17 @@ struct CORE_EXPORT QgsRasterRendererRegistryEntry /** \ingroup core * Registry for raster renderers. + * + * QgsRasterRendererRegistry is not usually directly created, but rather accessed through + * QgsApplication::rasterRendererRegistry(). + * * \note not available in Python bindings */ class CORE_EXPORT QgsRasterRendererRegistry { public: - static QgsRasterRendererRegistry* instance(); + + QgsRasterRendererRegistry(); void insert( const QgsRasterRendererRegistryEntry& entry ); void insertWidgetFunction( const QString& rendererName, QgsRasterRendererWidgetCreateFunc func ); @@ -65,11 +71,7 @@ class CORE_EXPORT QgsRasterRendererRegistry Caller takes ownership*/ QgsRasterRenderer* defaultRendererForDrawingStyle( QgsRaster::DrawingStyle theDrawingStyle, QgsRasterDataProvider* provider ) const; - protected: - QgsRasterRendererRegistry(); - private: - static QgsRasterRendererRegistry* mInstance; QHash< QString, QgsRasterRendererRegistryEntry > mEntries; QStringList mSortedEntries; diff --git a/src/core/raster/qgsrasterresamplefilter.h b/src/core/raster/qgsrasterresamplefilter.h index 6020cc95bcd..ce0460132b5 100644 --- a/src/core/raster/qgsrasterresamplefilter.h +++ b/src/core/raster/qgsrasterresamplefilter.h @@ -18,6 +18,7 @@ #ifndef QGSRASTERRESAMPLEFILTER_H #define QGSRASTERRESAMPLEFILTER_H +#include "qgis_core.h" #include "qgsrasterinterface.h" class QgsRasterResampler; diff --git a/src/core/raster/qgsrasterresampler.h b/src/core/raster/qgsrasterresampler.h index b1fa05b30ad..22487651bc0 100644 --- a/src/core/raster/qgsrasterresampler.h +++ b/src/core/raster/qgsrasterresampler.h @@ -28,7 +28,7 @@ class QImage; class QgsRasterResampler { public: - virtual ~QgsRasterResampler() {} + virtual ~QgsRasterResampler() = default; virtual void resample( const QImage& srcImage, QImage& dstImage ) = 0; /** diff --git a/src/core/raster/qgsrastershader.cpp b/src/core/raster/qgsrastershader.cpp index b866936199a..a66886d6bd6 100644 --- a/src/core/raster/qgsrastershader.cpp +++ b/src/core/raster/qgsrastershader.cpp @@ -147,6 +147,7 @@ void QgsRasterShader::writeXml( QDomDocument& doc, QDomElement& parent ) const { QDomElement colorRampShaderElem = doc.createElement( QStringLiteral( "colorrampshader" ) ); colorRampShaderElem.setAttribute( "colorRampType", colorRampShader->colorRampTypeAsQString() ); + colorRampShaderElem.setAttribute( "classificationMode", colorRampShader->classificationMode() ); colorRampShaderElem.setAttribute( QStringLiteral( "clip" ), colorRampShader->clip() ); // save source color ramp @@ -189,6 +190,7 @@ void QgsRasterShader::readXml( const QDomElement& elem ) } colorRampShader->setColorRampType( colorRampShaderElem.attribute( QStringLiteral( "colorRampType" ), QStringLiteral( "INTERPOLATED" ) ) ); + colorRampShader->setClassificationMode( static_cast< QgsColorRampShader::ClassificationMode >( colorRampShaderElem.attribute( QStringLiteral( "classificationMode" ), QStringLiteral( "1" ) ).toInt() ) ); colorRampShader->setClip( colorRampShaderElem.attribute( QStringLiteral( "clip" ), QStringLiteral( "0" ) ) == QLatin1String( "1" ) ); QList itemList; diff --git a/src/core/raster/qgsrastershader.h b/src/core/raster/qgsrastershader.h index e797923a14b..b3921a5b19d 100644 --- a/src/core/raster/qgsrastershader.h +++ b/src/core/raster/qgsrastershader.h @@ -20,6 +20,8 @@ email : ersts@amnh.org #ifndef QGSRASTERSHADER_H #define QGSRASTERSHADER_H +#include "qgis_core.h" + class QDomDocument; class QDomElement; class QgsRasterShaderFunction; @@ -34,6 +36,11 @@ class CORE_EXPORT QgsRasterShader QgsRasterShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0 ); ~QgsRasterShader(); + //! QgsRasterShader cannot be copied + QgsRasterShader( const QgsRasterShader& rh ) = delete; + //! QgsRasterShader cannot be copied + QgsRasterShader& operator=( const QgsRasterShader& rh ) = delete; + /* * * Non-Static Inline methods @@ -69,8 +76,14 @@ class CORE_EXPORT QgsRasterShader //! \brief Return the minimum value void setMinimumValue( double ); + /** + * Writes shader state to an XML element. + */ void writeXml( QDomDocument& doc, QDomElement& parent ) const; + /** + * Reads shader state from an XML element. + */ void readXml( const QDomElement& elem ); private: @@ -83,7 +96,5 @@ class CORE_EXPORT QgsRasterShader //! \brief Pointer to the shader function QgsRasterShaderFunction* mRasterShaderFunction; - QgsRasterShader( const QgsRasterShader& rh ); - QgsRasterShader& operator=( const QgsRasterShader& rh ); }; #endif diff --git a/src/core/raster/qgsrastershaderfunction.h b/src/core/raster/qgsrastershaderfunction.h index bbf34ea29b2..f86b7c4a3b0 100644 --- a/src/core/raster/qgsrastershaderfunction.h +++ b/src/core/raster/qgsrastershaderfunction.h @@ -25,6 +25,7 @@ email : ersts@amnh.org * typically used to render grayscale images as false color. */ +#include "qgis_core.h" #include #include @@ -33,7 +34,7 @@ class CORE_EXPORT QgsRasterShaderFunction public: QgsRasterShaderFunction( double theMinimumValue = 0.0, double theMaximumValue = 255.0 ); - virtual ~QgsRasterShaderFunction() {} + virtual ~QgsRasterShaderFunction() = default; //! \brief Set the maximum value virtual void setMaximumValue( double ); diff --git a/src/core/raster/qgsrastertransparency.h b/src/core/raster/qgsrastertransparency.h index 680e09a5ab7..832693035cf 100644 --- a/src/core/raster/qgsrastertransparency.h +++ b/src/core/raster/qgsrastertransparency.h @@ -18,6 +18,7 @@ email : ersts@amnh.org #ifndef QGSRASTERTRANSPARENCY_H #define QGSRASTERTRANSPARENCY_H +#include "qgis_core.h" #include class QDomDocument; class QDomElement; diff --git a/src/core/raster/qgssinglebandcolordatarenderer.cpp b/src/core/raster/qgssinglebandcolordatarenderer.cpp index 7b422cd41c3..e9e702d9237 100644 --- a/src/core/raster/qgssinglebandcolordatarenderer.cpp +++ b/src/core/raster/qgssinglebandcolordatarenderer.cpp @@ -28,10 +28,6 @@ QgsSingleBandColorDataRenderer::QgsSingleBandColorDataRenderer( QgsRasterInterfa } -QgsSingleBandColorDataRenderer::~QgsSingleBandColorDataRenderer() -{ -} - QgsSingleBandColorDataRenderer* QgsSingleBandColorDataRenderer::clone() const { QgsSingleBandColorDataRenderer * renderer = new QgsSingleBandColorDataRenderer( nullptr, mBand ); diff --git a/src/core/raster/qgssinglebandcolordatarenderer.h b/src/core/raster/qgssinglebandcolordatarenderer.h index ea9f949ca8c..8be0638398b 100644 --- a/src/core/raster/qgssinglebandcolordatarenderer.h +++ b/src/core/raster/qgssinglebandcolordatarenderer.h @@ -18,6 +18,7 @@ #ifndef QGSSINGLEBANDCOLORDATARENDERER_H #define QGSSINGLEBANDCOLORDATARENDERER_H +#include "qgis_core.h" #include "qgsrasterrenderer.h" class QDomElement; @@ -29,7 +30,12 @@ class CORE_EXPORT QgsSingleBandColorDataRenderer: public QgsRasterRenderer { public: QgsSingleBandColorDataRenderer( QgsRasterInterface* input, int band ); - ~QgsSingleBandColorDataRenderer(); + + //! QgsSingleBandColorDataRenderer cannot be copied. Use clone() instead. + QgsSingleBandColorDataRenderer( const QgsSingleBandColorDataRenderer& ) = delete; + //! QgsSingleBandColorDataRenderer cannot be copied. Use clone() instead. + const QgsSingleBandColorDataRenderer& operator=( const QgsSingleBandColorDataRenderer& ) = delete; + QgsSingleBandColorDataRenderer * clone() const override; static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input ); @@ -45,8 +51,6 @@ class CORE_EXPORT QgsSingleBandColorDataRenderer: public QgsRasterRenderer private: int mBand; - QgsSingleBandColorDataRenderer( const QgsSingleBandColorDataRenderer& ); - const QgsSingleBandColorDataRenderer& operator=( const QgsSingleBandColorDataRenderer& ); }; #endif // QGSSINGLEBANDCOLORDATARENDERER_H diff --git a/src/core/raster/qgssinglebandgrayrenderer.h b/src/core/raster/qgssinglebandgrayrenderer.h index 3b5d1296d09..72b875929cf 100644 --- a/src/core/raster/qgssinglebandgrayrenderer.h +++ b/src/core/raster/qgssinglebandgrayrenderer.h @@ -18,6 +18,7 @@ #ifndef QGSSINGLEBANDGRAYRENDERER_H #define QGSSINGLEBANDGRAYRENDERER_H +#include "qgis_core.h" #include "qgsrasterrenderer.h" class QgsContrastEnhancement; @@ -37,6 +38,12 @@ class CORE_EXPORT QgsSingleBandGrayRenderer: public QgsRasterRenderer QgsSingleBandGrayRenderer( QgsRasterInterface* input, int grayBand ); ~QgsSingleBandGrayRenderer(); + + //! QgsSingleBandGrayRenderer cannot be copied. Use clone() instead. + QgsSingleBandGrayRenderer( const QgsSingleBandGrayRenderer& ) = delete; + //! QgsSingleBandGrayRenderer cannot be copied. Use clone() instead. + const QgsSingleBandGrayRenderer& operator=( const QgsSingleBandGrayRenderer& ) = delete; + QgsSingleBandGrayRenderer * clone() const override; static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input ); @@ -63,8 +70,6 @@ class CORE_EXPORT QgsSingleBandGrayRenderer: public QgsRasterRenderer Gradient mGradient; QgsContrastEnhancement* mContrastEnhancement; - QgsSingleBandGrayRenderer( const QgsSingleBandGrayRenderer& ); - const QgsSingleBandGrayRenderer& operator=( const QgsSingleBandGrayRenderer& ); }; #endif // QGSSINGLEBANDGRAYRENDERER_H diff --git a/src/core/raster/qgssinglebandpseudocolorrenderer.cpp b/src/core/raster/qgssinglebandpseudocolorrenderer.cpp index 00d7f960080..17deaeef769 100644 --- a/src/core/raster/qgssinglebandpseudocolorrenderer.cpp +++ b/src/core/raster/qgssinglebandpseudocolorrenderer.cpp @@ -16,10 +16,12 @@ ***************************************************************************/ #include "qgssinglebandpseudocolorrenderer.h" +#include "qgscolorramp.h" #include "qgscolorrampshader.h" #include "qgsrastershader.h" #include "qgsrastertransparency.h" #include "qgsrasterviewport.h" + #include #include #include @@ -47,6 +49,32 @@ void QgsSingleBandPseudoColorRenderer::setBand( int bandNo ) mBand = bandNo; } +void QgsSingleBandPseudoColorRenderer::setClassificationMin( double min ) +{ + mClassificationMin = min; + if ( shader() ) + { + QgsColorRampShader* colorRampShader = dynamic_cast( shader()->rasterShaderFunction() ); + if ( colorRampShader ) + { + colorRampShader->setMinimumValue( min ); + } + } +} + +void QgsSingleBandPseudoColorRenderer::setClassificationMax( double max ) +{ + mClassificationMax = max; + if ( shader() ) + { + QgsColorRampShader* colorRampShader = dynamic_cast( shader()->rasterShaderFunction() ); + if ( colorRampShader ) + { + colorRampShader->setMaximumValue( max ); + } + } +} + QgsSingleBandPseudoColorRenderer* QgsSingleBandPseudoColorRenderer::clone() const { QgsRasterShader *shader = nullptr; @@ -67,6 +95,7 @@ QgsSingleBandPseudoColorRenderer* QgsSingleBandPseudoColorRenderer::clone() cons colorRampShader->setSourceColorRamp( origColorRampShader->sourceColorRamp()->clone() ); } colorRampShader->setColorRampType( origColorRampShader->colorRampType() ); + colorRampShader->setClassificationMode( origColorRampShader->classificationMode() ); colorRampShader->setClip( origColorRampShader->clip() ); colorRampShader->setColorRampItemList( origColorRampShader->colorRampItemList() ); shader->setRasterShaderFunction( colorRampShader ); @@ -84,6 +113,22 @@ void QgsSingleBandPseudoColorRenderer::setShader( QgsRasterShader* shader ) mShader = shader; } +void QgsSingleBandPseudoColorRenderer::createShader( QgsColorRamp* colorRamp, QgsColorRampShader::Type colorRampType, QgsColorRampShader::ClassificationMode classificationMode, int classes, bool clip, const QgsRectangle& extent ) +{ + if ( band() == -1 || classificationMin() >= classificationMax() ) + { + return; + } + + QgsColorRampShader* colorRampShader = new QgsColorRampShader( classificationMin(), classificationMax(), colorRamp, colorRampType, classificationMode ); + colorRampShader->classifyColorRamp( classes, band(), extent, input() ); + colorRampShader->setClip( clip ); + + QgsRasterShader* rasterShader = new QgsRasterShader(); + rasterShader->setRasterShaderFunction( colorRampShader ); + setShader( rasterShader ); +} + QgsRasterRenderer* QgsSingleBandPseudoColorRenderer::create( const QDomElement& elem, QgsRasterInterface* input ) { if ( elem.isNull() ) diff --git a/src/core/raster/qgssinglebandpseudocolorrenderer.h b/src/core/raster/qgssinglebandpseudocolorrenderer.h index a112a901423..f23fb71302e 100644 --- a/src/core/raster/qgssinglebandpseudocolorrenderer.h +++ b/src/core/raster/qgssinglebandpseudocolorrenderer.h @@ -18,7 +18,11 @@ #ifndef QGSSINGLEBANDPSEUDOCOLORRENDERER_H #define QGSSINGLEBANDPSEUDOCOLORRENDERER_H +#include "qgis_core.h" +#include "qgscolorramp.h" +#include "qgscolorrampshader.h" #include "qgsrasterrenderer.h" +#include "qgsrectangle.h" class QDomElement; class QgsRasterShader; @@ -28,10 +32,18 @@ class QgsRasterShader; */ class CORE_EXPORT QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer { + public: + //! Note: takes ownership of QgsRasterShader - QgsSingleBandPseudoColorRenderer( QgsRasterInterface* input, int band, QgsRasterShader* shader ); + QgsSingleBandPseudoColorRenderer( QgsRasterInterface* input, int band = -1, QgsRasterShader* shader = nullptr ); ~QgsSingleBandPseudoColorRenderer(); + + //! QgsSingleBandPseudoColorRenderer cannot be copied. Use clone() instead. + QgsSingleBandPseudoColorRenderer( const QgsSingleBandPseudoColorRenderer& ) = delete; + //! QgsSingleBandPseudoColorRenderer cannot be copied. Use clone() instead. + const QgsSingleBandPseudoColorRenderer& operator=( const QgsSingleBandPseudoColorRenderer& ) = delete; + QgsSingleBandPseudoColorRenderer * clone() const override; static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input ); @@ -40,10 +52,23 @@ class CORE_EXPORT QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer //! Takes ownership of the shader void setShader( QgsRasterShader* shader ); + + //! Returns the raster shader QgsRasterShader* shader() { return mShader; } + //! @note available in python as constShader const QgsRasterShader* shader() const { return mShader; } + /** Creates a color ramp shader + * @param colorRamp vector color ramp + * @param colorRampType type of color ramp shader + * @param classificationMode classification mode + * @param classes number of classes + * @param clip clip out of range values + * @param extent extent used in classification (only used in quantile mode) + */ + void createShader( QgsColorRamp* colorRamp = nullptr, QgsColorRampShader::Type colorRampType = QgsColorRampShader::Interpolated, QgsColorRampShader::ClassificationMode classificationMode = QgsColorRampShader::Continuous, int classes = 0, bool clip = false, const QgsRectangle& extent = QgsRectangle() ); + void writeXml( QDomDocument& doc, QDomElement& parentElem ) const override; void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const override; @@ -63,10 +88,11 @@ class CORE_EXPORT QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer double classificationMin() const { return mClassificationMin; } double classificationMax() const { return mClassificationMax; } - void setClassificationMin( double min ) { mClassificationMin = min; } - void setClassificationMax( double max ) { mClassificationMax = max; } + void setClassificationMin( double min ); + void setClassificationMax( double max ); private: + QgsRasterShader* mShader; int mBand; @@ -75,8 +101,6 @@ class CORE_EXPORT QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer double mClassificationMin; double mClassificationMax; - QgsSingleBandPseudoColorRenderer( const QgsSingleBandPseudoColorRenderer& ); - const QgsSingleBandPseudoColorRenderer& operator=( const QgsSingleBandPseudoColorRenderer& ); }; #endif // QGSSINGLEBANDPSEUDOCOLORRENDERER_H diff --git a/src/core/simplify/effectivearea.h b/src/core/simplify/effectivearea.h index 3cd172312e4..00d1d20cc86 100644 --- a/src/core/simplify/effectivearea.h +++ b/src/core/simplify/effectivearea.h @@ -86,15 +86,14 @@ struct EFFECTIVE_AREAS delete [] res_arealist; } + EFFECTIVE_AREAS( const EFFECTIVE_AREAS& other ) = delete; + EFFECTIVE_AREAS& operator=( const EFFECTIVE_AREAS& other ) = delete; + bool is3d; QgsPointSequence inpts; areanode *initial_arealist; double *res_arealist; -private: - - EFFECTIVE_AREAS( const EFFECTIVE_AREAS& other ); - EFFECTIVE_AREAS& operator=( const EFFECTIVE_AREAS& other ); }; diff --git a/src/core/symbology-ng/qgs25drenderer.h b/src/core/symbology-ng/qgs25drenderer.h index 2df00776d5c..90ff1d00b44 100644 --- a/src/core/symbology-ng/qgs25drenderer.h +++ b/src/core/symbology-ng/qgs25drenderer.h @@ -16,6 +16,7 @@ #ifndef QGS25DRENDERER_H #define QGS25DRENDERER_H +#include "qgis_core.h" #include "qgsrenderer.h" class QgsOuterGlowEffect; diff --git a/src/core/symbology-ng/qgsarrowsymbollayer.h b/src/core/symbology-ng/qgsarrowsymbollayer.h index 3b3beb8b7c4..ddbd0212c60 100644 --- a/src/core/symbology-ng/qgsarrowsymbollayer.h +++ b/src/core/symbology-ng/qgsarrowsymbollayer.h @@ -16,6 +16,7 @@ #ifndef QGSARROWSYMBOLLAYERV2_H #define QGSARROWSYMBOLLAYERV2_H +#include "qgis_core.h" #include "qgssymbollayer.h" diff --git a/src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp b/src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp index 7e6b59c3120..22ee18eca23 100644 --- a/src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp +++ b/src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp @@ -168,10 +168,6 @@ QgsCategorizedSymbolRenderer::QgsCategorizedSymbolRenderer( const QString& attrN } } -QgsCategorizedSymbolRenderer::~QgsCategorizedSymbolRenderer() -{ -} - void QgsCategorizedSymbolRenderer::rebuildHash() { mSymbolHash.clear(); diff --git a/src/core/symbology-ng/qgscategorizedsymbolrenderer.h b/src/core/symbology-ng/qgscategorizedsymbolrenderer.h index fafeb679cc4..ee8922c6ea9 100644 --- a/src/core/symbology-ng/qgscategorizedsymbolrenderer.h +++ b/src/core/symbology-ng/qgscategorizedsymbolrenderer.h @@ -15,6 +15,7 @@ #ifndef QGSCATEGORIZEDSYMBOLRENDERERV2_H #define QGSCATEGORIZEDSYMBOLRENDERERV2_H +#include "qgis_core.h" #include "qgssymbol.h" #include "qgsrenderer.h" #include "qgsexpression.h" @@ -39,8 +40,6 @@ class CORE_EXPORT QgsRendererCategory //! copy constructor QgsRendererCategory( const QgsRendererCategory& cat ); - ~QgsRendererCategory() {} - QgsRendererCategory& operator=( QgsRendererCategory cat ); QVariant value() const; @@ -80,8 +79,6 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer QgsCategorizedSymbolRenderer( const QString& attrName = QString(), const QgsCategoryList& categories = QgsCategoryList() ); - virtual ~QgsCategorizedSymbolRenderer(); - virtual QgsSymbol* symbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override; virtual QgsSymbol* originalSymbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override; virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override; diff --git a/src/core/symbology-ng/qgscolorbrewerpalette.h b/src/core/symbology-ng/qgscolorbrewerpalette.h index 991fa930a5c..508b2f26277 100644 --- a/src/core/symbology-ng/qgscolorbrewerpalette.h +++ b/src/core/symbology-ng/qgscolorbrewerpalette.h @@ -15,6 +15,7 @@ #ifndef QGSCOLORBREWERPALETTE_H #define QGSCOLORBREWERPALETTE_H +#include "qgis_core.h" #include #include diff --git a/src/core/symbology-ng/qgscptcityarchive.cpp b/src/core/symbology-ng/qgscptcityarchive.cpp index 342bccd4715..f97119a5c47 100644 --- a/src/core/symbology-ng/qgscptcityarchive.cpp +++ b/src/core/symbology-ng/qgscptcityarchive.cpp @@ -503,11 +503,6 @@ QgsCptCityDataItem::QgsCptCityDataItem( QgsCptCityDataItem::Type type, QgsCptCit { } -QgsCptCityDataItem::~QgsCptCityDataItem() -{ - // QgsDebugMsg( "mName = " + mName + " mPath = " + mPath ); -} - QVector QgsCptCityDataItem::createChildren() { QVector children; @@ -822,11 +817,7 @@ QgsCptCityCollectionItem::QgsCptCityCollectionItem( QgsCptCityDataItem* parent, QgsCptCityCollectionItem::~QgsCptCityCollectionItem() { - Q_FOREACH ( QgsCptCityDataItem* i, mChildren ) - { - // QgsDebugMsg( QString( "delete child = 0x%0" ).arg(( qlonglong )i, 8, 16, QLatin1Char( '0' ) ) ); - delete i; - } + qDeleteAll( mChildren ); } QVector< QgsCptCityDataItem* > QgsCptCityCollectionItem::childrenRamps( bool recursive ) @@ -899,10 +890,6 @@ QgsCptCityDirectoryItem::QgsCptCityDirectoryItem( QgsCptCityDataItem* parent, // populate(); } -QgsCptCityDirectoryItem::~QgsCptCityDirectoryItem() -{ -} - QVector QgsCptCityDirectoryItem::createChildren() { if ( ! mValid ) @@ -1061,13 +1048,15 @@ QMap< QString, QStringList > QgsCptCityDirectoryItem::rampsMap() } } +#if 0 //TODO what to do with other vars? e.g. schemeNames - // // add schemes to archive - // mSchemeMap[ path ] = schemeNames; - // schemeCount += schemeName.count(); - // schemeNames.clear(); - // listVariant.clear(); - // prevName = ""; + // add schemes to archive + mSchemeMap[ path ] = schemeNames; + schemeCount += schemeName.count(); + schemeNames.clear(); + listVariant.clear(); + prevName = ""; +#endif return mRampsMap; } @@ -1148,10 +1137,6 @@ QgsCptCitySelectionItem::QgsCptCitySelectionItem( QgsCptCityDataItem* parent, parseXml(); } -QgsCptCitySelectionItem::~QgsCptCitySelectionItem() -{ -} - QVector QgsCptCitySelectionItem::createChildren() { if ( ! mValid ) @@ -1279,10 +1264,6 @@ QgsCptCityAllRampsItem::QgsCptCityAllRampsItem( QgsCptCityDataItem* parent, // populate(); } -QgsCptCityAllRampsItem::~QgsCptCityAllRampsItem() -{ -} - QVector QgsCptCityAllRampsItem::createChildren() { if ( ! mValid ) diff --git a/src/core/symbology-ng/qgscptcityarchive.h b/src/core/symbology-ng/qgscptcityarchive.h index a94e61f12bc..9a916fa6366 100644 --- a/src/core/symbology-ng/qgscptcityarchive.h +++ b/src/core/symbology-ng/qgscptcityarchive.h @@ -17,6 +17,7 @@ #ifndef QGSCPTCITYARCHIVE_H #define QGSCPTCITYARCHIVE_H +#include "qgis_core.h" #include "qgscolorramp.h" #include @@ -41,6 +42,11 @@ class CORE_EXPORT QgsCptCityArchive const QString& baseDir = QString() ); ~QgsCptCityArchive(); + //! QgsCptCityArchive cannot be copied + QgsCptCityArchive( const QgsCptCityArchive& rh ) = delete; + //! QgsCptCityArchive cannot be copied + QgsCptCityArchive& operator=( const QgsCptCityArchive& rh ) = delete; + // basic dir info QString baseDir() const; static QString baseDir( QString archiveName ); @@ -82,10 +88,6 @@ class CORE_EXPORT QgsCptCityArchive // mapping of copyinginfo, key is fileName static QMap< QString, QMap< QString, QString > > mCopyingInfoMap; - private: - - QgsCptCityArchive( const QgsCptCityArchive& rh ); - QgsCptCityArchive& operator=( const QgsCptCityArchive& rh ); }; /** Base class for all items in the model @@ -106,7 +108,6 @@ class CORE_EXPORT QgsCptCityDataItem : public QObject QgsCptCityDataItem( QgsCptCityDataItem::Type type, QgsCptCityDataItem* parent, const QString& name, const QString& path ); - virtual ~QgsCptCityDataItem(); bool hasChildren(); @@ -210,7 +211,6 @@ class CORE_EXPORT QgsCptCityColorRampItem : public QgsCptCityDataItem const QString& name, const QString& path, const QStringList& variantList, bool initialize = false ); - ~QgsCptCityColorRampItem() {} // --- reimplemented from QgsCptCityDataItem --- @@ -259,7 +259,6 @@ class CORE_EXPORT QgsCptCityDirectoryItem : public QgsCptCityCollectionItem public: QgsCptCityDirectoryItem( QgsCptCityDataItem* parent, const QString& name, const QString& path ); - ~QgsCptCityDirectoryItem(); QVector createChildren() override; @@ -283,7 +282,6 @@ class CORE_EXPORT QgsCptCitySelectionItem : public QgsCptCityCollectionItem Q_OBJECT public: QgsCptCitySelectionItem( QgsCptCityDataItem* parent, const QString& name, const QString& path ); - ~QgsCptCitySelectionItem(); QVector createChildren() override; @@ -304,7 +302,6 @@ class CORE_EXPORT QgsCptCityAllRampsItem : public QgsCptCityCollectionItem public: QgsCptCityAllRampsItem( QgsCptCityDataItem* parent, const QString& name, const QVector& items ); - ~QgsCptCityAllRampsItem(); QVector createChildren() override; diff --git a/src/core/symbology-ng/qgsellipsesymbollayer.cpp b/src/core/symbology-ng/qgsellipsesymbollayer.cpp index 4df2da95726..98520820501 100644 --- a/src/core/symbology-ng/qgsellipsesymbollayer.cpp +++ b/src/core/symbology-ng/qgsellipsesymbollayer.cpp @@ -51,10 +51,6 @@ QgsEllipseSymbolLayer::QgsEllipseSymbolLayer() mAngle = 0; } -QgsEllipseSymbolLayer::~QgsEllipseSymbolLayer() -{ -} - QgsSymbolLayer* QgsEllipseSymbolLayer::create( const QgsStringMap& properties ) { QgsEllipseSymbolLayer* layer = new QgsEllipseSymbolLayer(); diff --git a/src/core/symbology-ng/qgsellipsesymbollayer.h b/src/core/symbology-ng/qgsellipsesymbollayer.h index d88055d7e12..aa726176350 100644 --- a/src/core/symbology-ng/qgsellipsesymbollayer.h +++ b/src/core/symbology-ng/qgsellipsesymbollayer.h @@ -17,6 +17,7 @@ #define DEFAULT_ELLIPSE_JOINSTYLE Qt::MiterJoin +#include "qgis_core.h" #include "qgsmarkersymbollayer.h" #include @@ -28,7 +29,6 @@ class CORE_EXPORT QgsEllipseSymbolLayer: public QgsMarkerSymbolLayer { public: QgsEllipseSymbolLayer(); - ~QgsEllipseSymbolLayer(); static QgsSymbolLayer* create( const QgsStringMap& properties = QgsStringMap() ); static QgsSymbolLayer* createFromSld( QDomElement &element ); diff --git a/src/core/symbology-ng/qgsfillsymbollayer.cpp b/src/core/symbology-ng/qgsfillsymbollayer.cpp index 6accc454a17..e6a469be30d 100644 --- a/src/core/symbology-ng/qgsfillsymbollayer.cpp +++ b/src/core/symbology-ng/qgsfillsymbollayer.cpp @@ -1581,10 +1581,6 @@ QgsImageFillSymbolLayer::QgsImageFillSymbolLayer() setSubSymbol( new QgsLineSymbol() ); } -QgsImageFillSymbolLayer::~QgsImageFillSymbolLayer() -{ -} - void QgsImageFillSymbolLayer::renderPolygon( const QPolygonF& points, QList* rings, QgsSymbolRenderContext& context ) { QPainter* p = context.renderContext().painter(); @@ -1825,7 +1821,7 @@ QgsMapUnitScale QgsSVGFillSymbolLayer::mapUnitScale() const void QgsSVGFillSymbolLayer::setSvgFilePath( const QString& svgPath ) { - mSvgData = QgsSvgCache::instance()->getImageData( svgPath ); + mSvgData = QgsApplication::svgCache()->getImageData( svgPath ); storeViewBox(); mSvgFilePath = svgPath; @@ -1964,11 +1960,11 @@ void QgsSVGFillSymbolLayer::applyPattern( QBrush& brush, const QString& svgFileP { bool fitsInCache = true; double outlineWidth = QgsSymbolLayerUtils::convertToPainterUnits( context.renderContext(), svgOutlineWidth, svgOutlineWidthUnit, svgOutlineWidthMapUnitScale ); - const QImage& patternImage = QgsSvgCache::instance()->svgAsImage( svgFilePath, size, svgFillColor, svgOutlineColor, outlineWidth, + const QImage& patternImage = QgsApplication::svgCache()->svgAsImage( svgFilePath, size, svgFillColor, svgOutlineColor, outlineWidth, context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor(), fitsInCache ); if ( !fitsInCache ) { - const QPicture& patternPict = QgsSvgCache::instance()->svgAsPicture( svgFilePath, size, svgFillColor, svgOutlineColor, outlineWidth, + const QPicture& patternPict = QgsApplication::svgCache()->svgAsPicture( svgFilePath, size, svgFillColor, svgOutlineColor, outlineWidth, context.renderContext().scaleFactor(), 1.0 ); double hwRatio = 1.0; if ( patternPict.width() > 0 ) @@ -2280,7 +2276,7 @@ void QgsSVGFillSymbolLayer::setDefaultSvgParams() bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultOutlineColor, hasDefaultOutlineWidth, hasDefaultOutlineOpacity; QColor defaultFillColor, defaultOutlineColor; double defaultOutlineWidth, defaultFillOpacity, defaultOutlineOpacity; - QgsSvgCache::instance()->containsParams( mSvgFilePath, hasFillParam, hasDefaultFillColor, defaultFillColor, + QgsApplication::svgCache()->containsParams( mSvgFilePath, hasFillParam, hasDefaultFillColor, defaultFillColor, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasOutlineParam, hasDefaultOutlineColor, defaultOutlineColor, hasOutlineWidthParam, hasDefaultOutlineWidth, defaultOutlineWidth, @@ -3659,11 +3655,6 @@ QgsRasterFillSymbolLayer::QgsRasterFillSymbolLayer( const QString &imageFilePath QgsImageFillSymbolLayer::setSubSymbol( nullptr ); //disable sub symbol } -QgsRasterFillSymbolLayer::~QgsRasterFillSymbolLayer() -{ - -} - QgsSymbolLayer *QgsRasterFillSymbolLayer::create( const QgsStringMap &properties ) { FillCoordinateMode mode = QgsRasterFillSymbolLayer::Feature; diff --git a/src/core/symbology-ng/qgsfillsymbollayer.h b/src/core/symbology-ng/qgsfillsymbollayer.h index dfc3e094469..6d992d4b02b 100644 --- a/src/core/symbology-ng/qgsfillsymbollayer.h +++ b/src/core/symbology-ng/qgsfillsymbollayer.h @@ -16,6 +16,7 @@ #ifndef QGSFILLSYMBOLLAYERV2_H #define QGSFILLSYMBOLLAYERV2_H +#include "qgis_core.h" #include "qgssymbollayer.h" #define DEFAULT_SIMPLEFILL_COLOR QColor(0,0,255) @@ -221,7 +222,7 @@ class CORE_EXPORT QgsGradientFillSymbolLayer : public QgsFillSymbolLayer double estimateMaxBleed() const override; - //! Type of gradient, eg linear or radial + //! Type of gradient, e.g., linear or radial GradientType gradientType() const { return mGradientType; } void setGradientType( GradientType gradientType ) { mGradientType = gradientType; } @@ -587,7 +588,6 @@ class CORE_EXPORT QgsImageFillSymbolLayer: public QgsFillSymbolLayer public: QgsImageFillSymbolLayer(); - virtual ~QgsImageFillSymbolLayer(); void renderPolygon( const QPolygonF& points, QList* rings, QgsSymbolRenderContext& context ) override; virtual QgsSymbol* subSymbol() override { return mOutline; } @@ -653,7 +653,6 @@ class CORE_EXPORT QgsRasterFillSymbolLayer: public QgsImageFillSymbolLayer }; QgsRasterFillSymbolLayer( const QString& imageFilePath = QString() ); - ~QgsRasterFillSymbolLayer(); static QgsSymbolLayer* create( const QgsStringMap& properties = QgsStringMap() ); diff --git a/src/core/symbology-ng/qgsgeometrygeneratorsymbollayer.h b/src/core/symbology-ng/qgsgeometrygeneratorsymbollayer.h index c7faf34fc15..92184ee44ff 100644 --- a/src/core/symbology-ng/qgsgeometrygeneratorsymbollayer.h +++ b/src/core/symbology-ng/qgsgeometrygeneratorsymbollayer.h @@ -16,6 +16,7 @@ #ifndef QGSGEOMETRYGENERATORSYMBOLLAYERV2_H #define QGSGEOMETRYGENERATORSYMBOLLAYERV2_H +#include "qgis_core.h" #include "qgssymbollayer.h" /** \ingroup core diff --git a/src/core/symbology-ng/qgsgraduatedsymbolrenderer.h b/src/core/symbology-ng/qgsgraduatedsymbolrenderer.h index 37f9c36d72d..6fe5f6a1889 100644 --- a/src/core/symbology-ng/qgsgraduatedsymbolrenderer.h +++ b/src/core/symbology-ng/qgsgraduatedsymbolrenderer.h @@ -15,6 +15,7 @@ #ifndef QGSGRADUATEDSYMBOLRENDERERV2_H #define QGSGRADUATEDSYMBOLRENDERERV2_H +#include "qgis_core.h" #include "qgssymbol.h" #include "qgsrenderer.h" #include "qgsexpression.h" @@ -31,8 +32,6 @@ class CORE_EXPORT QgsRendererRange QgsRendererRange( double lowerValue, double upperValue, QgsSymbol* symbol, const QString& label, bool render = true ); QgsRendererRange( const QgsRendererRange& range ); - ~QgsRendererRange() {} - // default dtor is ok QgsRendererRange& operator=( QgsRendererRange range ); diff --git a/src/core/symbology-ng/qgsheatmaprenderer.h b/src/core/symbology-ng/qgsheatmaprenderer.h index c365af53eef..8988153d207 100644 --- a/src/core/symbology-ng/qgsheatmaprenderer.h +++ b/src/core/symbology-ng/qgsheatmaprenderer.h @@ -15,6 +15,7 @@ #ifndef QGSHEATMAPRENDERER_H #define QGSHEATMAPRENDERER_H +#include "qgis_core.h" #include "qgis.h" #include "qgsrenderer.h" #include "qgssymbol.h" @@ -36,6 +37,11 @@ class CORE_EXPORT QgsHeatmapRenderer : public QgsFeatureRenderer QgsHeatmapRenderer(); virtual ~QgsHeatmapRenderer(); + //! Direct copies are forbidden. Use clone() instead. + QgsHeatmapRenderer( const QgsHeatmapRenderer& ) = delete; + //! Direct copies are forbidden. Use clone() instead. + QgsHeatmapRenderer& operator=( const QgsHeatmapRenderer& ) = delete; + //reimplemented methods virtual QgsHeatmapRenderer* clone() const override; virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override; @@ -158,10 +164,6 @@ class CORE_EXPORT QgsHeatmapRenderer : public QgsFeatureRenderer void setWeightExpression( const QString& expression ) { mWeightExpressionString = expression; } private: - //! Private copy constructor. @see clone() - QgsHeatmapRenderer( const QgsHeatmapRenderer& ); - //! Private assignment operator. @see clone() - QgsHeatmapRenderer& operator=( const QgsHeatmapRenderer& ); QVector mValues; diff --git a/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp b/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp index db3323c5fc2..befbc12b835 100644 --- a/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp +++ b/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp @@ -43,10 +43,6 @@ QgsInvertedPolygonRenderer::QgsInvertedPolygonRenderer( QgsFeatureRenderer* subR } } -QgsInvertedPolygonRenderer::~QgsInvertedPolygonRenderer() -{ -} - void QgsInvertedPolygonRenderer::setEmbeddedRenderer( QgsFeatureRenderer* subRenderer ) { if ( subRenderer ) diff --git a/src/core/symbology-ng/qgsinvertedpolygonrenderer.h b/src/core/symbology-ng/qgsinvertedpolygonrenderer.h index f74a099f659..4ba763849a4 100644 --- a/src/core/symbology-ng/qgsinvertedpolygonrenderer.h +++ b/src/core/symbology-ng/qgsinvertedpolygonrenderer.h @@ -15,6 +15,7 @@ #ifndef QGSINVERTEDPOLYGONRENDERER_H #define QGSINVERTEDPOLYGONRENDERER_H +#include "qgis_core.h" #include "qgis.h" #include "qgsrenderer.h" #include "qgsexpression.h" @@ -46,7 +47,10 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRenderer */ QgsInvertedPolygonRenderer( QgsFeatureRenderer* embeddedRenderer = nullptr ); - virtual ~QgsInvertedPolygonRenderer(); + //! Direct copies are forbidden. Use clone() instead. + QgsInvertedPolygonRenderer( const QgsInvertedPolygonRenderer& ) = delete; + //! Direct copies are forbidden. Use clone() instead. + QgsInvertedPolygonRenderer& operator=( const QgsInvertedPolygonRenderer& ) = delete; virtual QgsInvertedPolygonRenderer* clone() const override; virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override; @@ -138,10 +142,6 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRenderer static QgsInvertedPolygonRenderer* convertFromRenderer( const QgsFeatureRenderer* renderer ); private: - //! Private copy constructor. @see clone() - QgsInvertedPolygonRenderer( const QgsInvertedPolygonRenderer& ); - //! Private assignment operator. @see clone() - QgsInvertedPolygonRenderer& operator=( const QgsInvertedPolygonRenderer& ); //! Embedded renderer QScopedPointer mSubRenderer; diff --git a/src/core/symbology-ng/qgslegendsymbolitem.h b/src/core/symbology-ng/qgslegendsymbolitem.h index 03e349ffeea..03d8d53c1f7 100644 --- a/src/core/symbology-ng/qgslegendsymbolitem.h +++ b/src/core/symbology-ng/qgslegendsymbolitem.h @@ -18,6 +18,8 @@ #include +#include "qgis_core.h" + class QgsSymbol; /** \ingroup core diff --git a/src/core/symbology-ng/qgslinesymbollayer.cpp b/src/core/symbology-ng/qgslinesymbollayer.cpp index 02905773a63..d466afee339 100644 --- a/src/core/symbology-ng/qgslinesymbollayer.cpp +++ b/src/core/symbology-ng/qgslinesymbollayer.cpp @@ -261,7 +261,7 @@ void QgsSimpleLineSymbolLayer::renderPolygonOutline( const QPolygonF& points, QL } } - //use intersect mode, as a clip path may already exist (eg, for composer maps) + //use intersect mode, as a clip path may already exist (e.g., for composer maps) p->setClipPath( clipPath, Qt::IntersectClip ); } diff --git a/src/core/symbology-ng/qgslinesymbollayer.h b/src/core/symbology-ng/qgslinesymbollayer.h index 75f708916bd..de1dd1fefae 100644 --- a/src/core/symbology-ng/qgslinesymbollayer.h +++ b/src/core/symbology-ng/qgslinesymbollayer.h @@ -16,6 +16,7 @@ #ifndef QGSLINESYMBOLLAYERV2_H #define QGSLINESYMBOLLAYERV2_H +#include "qgis_core.h" #include "qgssymbollayer.h" #include diff --git a/src/core/symbology-ng/qgsmarkersymbollayer.cpp b/src/core/symbology-ng/qgsmarkersymbollayer.cpp index a2dae580124..c6abee3bcb4 100644 --- a/src/core/symbology-ng/qgsmarkersymbollayer.cpp +++ b/src/core/symbology-ng/qgsmarkersymbollayer.cpp @@ -1751,7 +1751,7 @@ QgsSymbolLayer* QgsSvgMarkerSymbolLayer::create( const QgsStringMap& props ) double outlineWidth; bool hasFillParam = false, hasFillOpacityParam = false, hasOutlineParam = false, hasOutlineWidthParam = false, hasOutlineOpacityParam = false; bool hasDefaultFillColor = false, hasDefaultFillOpacity = false, hasDefaultOutlineColor = false, hasDefaultOutlineWidth = false, hasDefaultOutlineOpacity = false; - QgsSvgCache::instance()->containsParams( name, hasFillParam, hasDefaultFillColor, fillColor, + QgsApplication::svgCache()->containsParams( name, hasFillParam, hasDefaultFillColor, fillColor, hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity, hasOutlineParam, hasDefaultOutlineColor, outlineColor, hasOutlineWidthParam, hasDefaultOutlineWidth, outlineWidth, @@ -1861,7 +1861,7 @@ void QgsSvgMarkerSymbolLayer::setPath( const QString& path ) double outlineWidth, fillOpacity, outlineOpacity; bool hasFillParam = false, hasFillOpacityParam = false, hasOutlineParam = false, hasOutlineWidthParam = false, hasOutlineOpacityParam = false; bool hasDefaultFillColor = false, hasDefaultFillOpacity = false, hasDefaultOutlineColor = false, hasDefaultOutlineWidth = false, hasDefaultOutlineOpacity = false; - QgsSvgCache::instance()->containsParams( path, hasFillParam, hasDefaultFillColor, defaultFillColor, + QgsApplication::svgCache()->containsParams( path, hasFillParam, hasDefaultFillColor, defaultFillColor, hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity, hasOutlineParam, hasDefaultOutlineColor, defaultOutlineColor, hasOutlineWidthParam, hasDefaultOutlineWidth, outlineWidth, @@ -1983,7 +1983,7 @@ void QgsSvgMarkerSymbolLayer::renderPoint( QPointF point, QgsSymbolRenderContext if ( !context.renderContext().forceVectorOutput() && !rotated ) { usePict = false; - const QImage& img = QgsSvgCache::instance()->svgAsImage( path, size, fillColor, outlineColor, outlineWidth, + const QImage& img = QgsApplication::svgCache()->svgAsImage( path, size, fillColor, outlineColor, outlineWidth, context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor(), fitsInCache ); if ( fitsInCache && img.width() > 1 ) { @@ -2006,7 +2006,7 @@ void QgsSvgMarkerSymbolLayer::renderPoint( QPointF point, QgsSymbolRenderContext if ( usePict || !fitsInCache ) { p->setOpacity( context.alpha() ); - const QPicture& pct = QgsSvgCache::instance()->svgAsPicture( path, size, fillColor, outlineColor, outlineWidth, + const QPicture& pct = QgsApplication::svgCache()->svgAsPicture( path, size, fillColor, outlineColor, outlineWidth, context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor(), context.renderContext().forceVectorOutput() ); if ( pct.width() > 1 ) @@ -2358,7 +2358,7 @@ bool QgsSvgMarkerSymbolLayer::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa outlineColor = QgsSymbolLayerUtils::decodeColor( colorString ); } - const QByteArray &svgContent = QgsSvgCache::instance()->svgContent( path, size, fillColor, outlineColor, outlineWidth, + const QByteArray &svgContent = QgsApplication::svgCache()->svgContent( path, size, fillColor, outlineColor, outlineWidth, context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor() ); @@ -2441,7 +2441,7 @@ QRectF QgsSvgMarkerSymbolLayer::bounds( QPointF point, QgsSymbolRenderContext& c outlineColor = QgsSymbolLayerUtils::decodeColor( colorString ); } - QSizeF svgViewbox = QgsSvgCache::instance()->svgViewboxSize( path, scaledSize, fillColor, outlineColor, outlineWidth, + QSizeF svgViewbox = QgsApplication::svgCache()->svgViewboxSize( path, scaledSize, fillColor, outlineColor, outlineWidth, context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor() ); diff --git a/src/core/symbology-ng/qgsmarkersymbollayer.h b/src/core/symbology-ng/qgsmarkersymbollayer.h index 238a0585d67..c8e928cf3c2 100644 --- a/src/core/symbology-ng/qgsmarkersymbollayer.h +++ b/src/core/symbology-ng/qgsmarkersymbollayer.h @@ -16,6 +16,7 @@ #ifndef QGSMARKERSYMBOLLAYERV2_H #define QGSMARKERSYMBOLLAYERV2_H +#include "qgis_core.h" #include "qgssymbollayer.h" #define DEFAULT_SIMPLEMARKER_NAME "circle" @@ -256,7 +257,7 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayer : public QgsSimpleMarkerSymbolLayer */ void setBorderColor( const QColor& color ) { mBorderColor = color; } - /** Returns the marker's outline style (eg solid, dashed, etc) + /** Returns the marker's outline style (e.g., solid, dashed, etc) * @note added in 2.4 * @see setOutlineStyle() * @see borderColor() @@ -264,7 +265,7 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayer : public QgsSimpleMarkerSymbolLayer */ Qt::PenStyle outlineStyle() const { return mOutlineStyle; } - /** Sets the marker's outline style (eg solid, dashed, etc) + /** Sets the marker's outline style (e.g., solid, dashed, etc) * @param outlineStyle style * @note added in 2.4 * @see outlineStyle() @@ -273,7 +274,7 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayer : public QgsSimpleMarkerSymbolLayer */ void setOutlineStyle( Qt::PenStyle outlineStyle ) { mOutlineStyle = outlineStyle; } - /** Returns the marker's outline join style (eg miter, bevel, etc). + /** Returns the marker's outline join style (e.g., miter, bevel, etc). * @note added in 2.16 * @see setPenJoinStyle() * @see borderColor() @@ -281,7 +282,7 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayer : public QgsSimpleMarkerSymbolLayer */ Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; } - /** Sets the marker's outline join style (eg miter, bevel, etc). + /** Sets the marker's outline join style (e.g., miter, bevel, etc). * @param style join style * @note added in 2.16 * @see penJoinStyle() diff --git a/src/core/symbology-ng/qgsnullsymbolrenderer.cpp b/src/core/symbology-ng/qgsnullsymbolrenderer.cpp index 15a1496dd3f..eeb4e2eca8f 100644 --- a/src/core/symbology-ng/qgsnullsymbolrenderer.cpp +++ b/src/core/symbology-ng/qgsnullsymbolrenderer.cpp @@ -25,10 +25,6 @@ QgsNullSymbolRenderer::QgsNullSymbolRenderer() { } -QgsNullSymbolRenderer::~QgsNullSymbolRenderer() -{ -} - QgsSymbol* QgsNullSymbolRenderer::symbolForFeature( QgsFeature& , QgsRenderContext& ) { return nullptr; diff --git a/src/core/symbology-ng/qgsnullsymbolrenderer.h b/src/core/symbology-ng/qgsnullsymbolrenderer.h index 9defdf3b1b9..785405a691f 100644 --- a/src/core/symbology-ng/qgsnullsymbolrenderer.h +++ b/src/core/symbology-ng/qgsnullsymbolrenderer.h @@ -15,6 +15,7 @@ #ifndef QGSNULLSYMBOLRENDERER_H #define QGSNULLSYMBOLRENDERER_H +#include "qgis_core.h" #include "qgis.h" #include "qgsrenderer.h" #include "qgssymbol.h" @@ -32,8 +33,6 @@ class CORE_EXPORT QgsNullSymbolRenderer : public QgsFeatureRenderer QgsNullSymbolRenderer(); - virtual ~QgsNullSymbolRenderer(); - virtual QgsSymbol* symbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override; virtual QgsSymbol* originalSymbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override; diff --git a/src/core/symbology-ng/qgspointclusterrenderer.h b/src/core/symbology-ng/qgspointclusterrenderer.h index 600de1d8a79..e394d13736d 100644 --- a/src/core/symbology-ng/qgspointclusterrenderer.h +++ b/src/core/symbology-ng/qgspointclusterrenderer.h @@ -18,6 +18,7 @@ #ifndef QGSPOINTCLUSTERRENDERER_H #define QGSPOINTCLUSTERRENDERER_H +#include "qgis_core.h" #include "qgspointdistancerenderer.h" /** \class QgsPointClusterRenderer diff --git a/src/core/symbology-ng/qgspointdisplacementrenderer.h b/src/core/symbology-ng/qgspointdisplacementrenderer.h index eef22c2b1a4..7cc070b1d07 100644 --- a/src/core/symbology-ng/qgspointdisplacementrenderer.h +++ b/src/core/symbology-ng/qgspointdisplacementrenderer.h @@ -18,6 +18,7 @@ #ifndef QGSPOINTDISPLACEMENTRENDERER_H #define QGSPOINTDISPLACEMENTRENDERER_H +#include "qgis_core.h" #include "qgspointdistancerenderer.h" /** \class QgsPointDisplacementRenderer diff --git a/src/core/symbology-ng/qgspointdistancerenderer.cpp b/src/core/symbology-ng/qgspointdistancerenderer.cpp index 08acc99cb17..0dbd01663a7 100644 --- a/src/core/symbology-ng/qgspointdistancerenderer.cpp +++ b/src/core/symbology-ng/qgspointdistancerenderer.cpp @@ -62,7 +62,7 @@ bool QgsPointDistanceRenderer::renderFeature( QgsFeature& feature, QgsRenderCont QgsMarkerSymbol* symbol = firstSymbolForFeature( feature, context ); - //if the feature has no symbol (eg, no matching rule in a rule-based renderer), skip it + //if the feature has no symbol (e.g., no matching rule in a rule-based renderer), skip it if ( !symbol ) return false; @@ -432,7 +432,7 @@ QgsExpressionContextScope* QgsPointDistanceRenderer::createGroupScope( const Clu QgsExpressionContextScope* clusterScope = new QgsExpressionContextScope(); if ( group.size() > 1 ) { - //scan through symbols to check color, eg if all clustered symbols are same color + //scan through symbols to check color, e.g., if all clustered symbols are same color QColor groupColor; ClusteredGroup::const_iterator groupIt = group.constBegin(); for ( ; groupIt != group.constEnd(); ++groupIt ) diff --git a/src/core/symbology-ng/qgspointdistancerenderer.h b/src/core/symbology-ng/qgspointdistancerenderer.h index e98bc3d05c9..025d6fc0b11 100644 --- a/src/core/symbology-ng/qgspointdistancerenderer.h +++ b/src/core/symbology-ng/qgspointdistancerenderer.h @@ -18,6 +18,7 @@ #ifndef QGSPOINTDISTANCERENDERER_H #define QGSPOINTDISTANCERENDERER_H +#include "qgis_core.h" #include "qgsrenderer.h" #include @@ -25,7 +26,7 @@ class QgsSpatialIndex; /** \class QgsPointDistanceRenderer * \ingroup core - * An abstract base class for distance based point renderers (eg clusterer and displacement renderers). + * An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers). * QgsPointDistanceRenderer handles calculation of point clusters using a distance based threshold. * Subclasses must implement drawGroup() to handle the rendering of individual point clusters * in the desired style. diff --git a/src/core/symbology-ng/qgsrenderer.cpp b/src/core/symbology-ng/qgsrenderer.cpp index 8cf792dffbc..2aae94628b1 100644 --- a/src/core/symbology-ng/qgsrenderer.cpp +++ b/src/core/symbology-ng/qgsrenderer.cpp @@ -125,7 +125,7 @@ QgsFeatureRenderer* QgsFeatureRenderer::load( QDomElement& element ) // load renderer QString rendererType = element.attribute( QStringLiteral( "type" ) ); - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( rendererType ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( rendererType ); if ( !m ) return nullptr; @@ -139,7 +139,7 @@ QgsFeatureRenderer* QgsFeatureRenderer::load( QDomElement& element ) QDomElement effectElem = element.firstChildElement( QStringLiteral( "effect" ) ); if ( !effectElem.isNull() ) { - r->setPaintEffect( QgsPaintEffectRegistry::instance()->createEffect( effectElem ) ); + r->setPaintEffect( QgsApplication::paintEffectRegistry()->createEffect( effectElem ) ); } // restore order by @@ -247,7 +247,7 @@ QgsFeatureRenderer* QgsFeatureRenderer::loadSld( const QDomNode &node, QgsWkbTyp QgsDebugMsg( QString( "Instantiating a '%1' renderer..." ).arg( rendererType ) ); // create the renderer and return it - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( rendererType ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( rendererType ); if ( !m ) { errorMessage = QStringLiteral( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType ); diff --git a/src/core/symbology-ng/qgsrenderer.h b/src/core/symbology-ng/qgsrenderer.h index 96cd0fc2639..0f4f7cc7564 100644 --- a/src/core/symbology-ng/qgsrenderer.h +++ b/src/core/symbology-ng/qgsrenderer.h @@ -16,6 +16,7 @@ #ifndef QGSRENDERERV2_H #define QGSRENDERERV2_H +#include "qgis_core.h" #include "qgis.h" #include "qgsrectangle.h" #include "qgsrendercontext.h" diff --git a/src/core/symbology-ng/qgsrendererregistry.cpp b/src/core/symbology-ng/qgsrendererregistry.cpp index 659f7f6eecc..1e0ee5c16bc 100644 --- a/src/core/symbology-ng/qgsrendererregistry.cpp +++ b/src/core/symbology-ng/qgsrendererregistry.cpp @@ -94,13 +94,6 @@ QgsRendererRegistry::~QgsRendererRegistry() qDeleteAll( mRenderers ); } -QgsRendererRegistry* QgsRendererRegistry::instance() -{ - static QgsRendererRegistry mInstance; - return &mInstance; -} - - bool QgsRendererRegistry::addRenderer( QgsRendererAbstractMetadata* metadata ) { if ( !metadata || mRenderers.contains( metadata->name() ) ) @@ -127,8 +120,6 @@ QgsRendererAbstractMetadata* QgsRendererRegistry::rendererMetadata( const QStrin return mRenderers.value( rendererName ); } -QgsRendererMetadata::~QgsRendererMetadata() {} - QStringList QgsRendererRegistry::renderersList( QgsRendererAbstractMetadata::LayerTypes layerTypes ) const { QStringList renderers; diff --git a/src/core/symbology-ng/qgsrendererregistry.h b/src/core/symbology-ng/qgsrendererregistry.h index 72a6a41a2f2..75aa6e20b9a 100644 --- a/src/core/symbology-ng/qgsrendererregistry.h +++ b/src/core/symbology-ng/qgsrendererregistry.h @@ -15,6 +15,7 @@ #ifndef QGSRENDERERV2REGISTRY_H #define QGSRENDERERV2REGISTRY_H +#include "qgis_core.h" #include #include #include @@ -53,7 +54,7 @@ class CORE_EXPORT QgsRendererAbstractMetadata , mVisibleName( visibleName ) , mIcon( icon ) {} - virtual ~QgsRendererAbstractMetadata() {} + virtual ~QgsRendererAbstractMetadata() = default; QString name() const { return mName; } QString visibleName() const { return mVisibleName; } @@ -137,7 +138,7 @@ class CORE_EXPORT QgsRendererMetadata : public QgsRendererAbstractMetadata , mLayerTypes( layerTypes ) {} - virtual ~QgsRendererMetadata(); + virtual ~QgsRendererMetadata() = default; virtual QgsFeatureRenderer* createRenderer( QDomElement& elem ) override { return mCreateFunc ? mCreateFunc( elem ) : nullptr; } virtual QgsRendererWidget* createRendererWidget( QgsVectorLayer* layer, QgsStyle* style, QgsFeatureRenderer* renderer ) override @@ -175,20 +176,27 @@ class CORE_EXPORT QgsRendererMetadata : public QgsRendererAbstractMetadata * \class QgsRendererRegistry * \brief Registry of renderers. * - * This is a singleton, renderers can be added / removed at any time + * QgsRendererRegistry is not usually directly created, but rather accessed through + * QgsApplication::rendererRegistry(). + * */ class CORE_EXPORT QgsRendererRegistry { public: - //! Returns a pointer to the QgsRendererRegistry singleton - static QgsRendererRegistry* instance(); + QgsRendererRegistry(); + ~QgsRendererRegistry(); + + //! QgsRendererRegistry cannot be copied. + QgsRendererRegistry( const QgsRendererRegistry& rh ) = delete; + //! QgsRendererRegistry cannot be copied. + QgsRendererRegistry& operator=( const QgsRendererRegistry& rh ) = delete; //! Adds a renderer to the registry. Takes ownership of the metadata object. //! @param metadata renderer metadata //! @returns true if renderer was added successfully, or false if renderer could not - //! be added (eg a renderer with a duplicate name already exists) + //! be added (e.g., a renderer with a duplicate name already exists) bool addRenderer( QgsRendererAbstractMetadata* metadata ); //! Removes a renderer from registry. @@ -210,20 +218,13 @@ class CORE_EXPORT QgsRendererRegistry //! @note added in QGIS 2.16 QStringList renderersList( const QgsVectorLayer* layer ) const; - protected: - //! protected constructor - QgsRendererRegistry(); - ~QgsRendererRegistry(); + private: //! Map of name to renderer QMap mRenderers; //! List of renderers, maintained in the order that they have been added QStringList mRenderersOrder; - - private: - QgsRendererRegistry( const QgsRendererRegistry& rh ); - QgsRendererRegistry& operator=( const QgsRendererRegistry& rh ); }; #endif // QGSRENDERERV2REGISTRY_H diff --git a/src/core/symbology-ng/qgsrulebasedrenderer.h b/src/core/symbology-ng/qgsrulebasedrenderer.h index e7e299939ab..4ba2f649d6b 100644 --- a/src/core/symbology-ng/qgsrulebasedrenderer.h +++ b/src/core/symbology-ng/qgsrulebasedrenderer.h @@ -16,6 +16,7 @@ #ifndef QGSRULEBASEDRENDERERV2_H #define QGSRULEBASEDRENDERERV2_H +#include "qgis_core.h" #include "qgsfields.h" #include "qgsfeature.h" #include "qgis.h" @@ -123,6 +124,11 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer const QString& label = QString(), const QString& description = QString(), bool elseRule = false ); ~Rule(); + //! Rules cannot be copied + Rule( const Rule& rh ) = delete; + //! Rules cannot be copied + Rule& operator=( const Rule& rh ) = delete; + /** * Dump for debug purpose * @param indent How many characters to indent. Will increase by two with every of the recursive calls @@ -389,9 +395,6 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer private: - Rule( const Rule& rh ); - Rule& operator=( const Rule& rh ); - /** * Check which child rules are else rules and update the internal list of else rules * diff --git a/src/core/symbology-ng/qgssinglesymbolrenderer.cpp b/src/core/symbology-ng/qgssinglesymbolrenderer.cpp index 9c378351118..97be0c78326 100644 --- a/src/core/symbology-ng/qgssinglesymbolrenderer.cpp +++ b/src/core/symbology-ng/qgssinglesymbolrenderer.cpp @@ -40,10 +40,6 @@ QgsSingleSymbolRenderer::QgsSingleSymbolRenderer( QgsSymbol* symbol ) Q_ASSERT( symbol ); } -QgsSingleSymbolRenderer::~QgsSingleSymbolRenderer() -{ -} - QgsSymbol* QgsSingleSymbolRenderer::symbolForFeature( QgsFeature&, QgsRenderContext & ) { return mSymbol.data(); diff --git a/src/core/symbology-ng/qgssinglesymbolrenderer.h b/src/core/symbology-ng/qgssinglesymbolrenderer.h index f2df6f42f1e..fcbbadc0b92 100644 --- a/src/core/symbology-ng/qgssinglesymbolrenderer.h +++ b/src/core/symbology-ng/qgssinglesymbolrenderer.h @@ -15,6 +15,7 @@ #ifndef QGSSINGLESYMBOLRENDERERV2_H #define QGSSINGLESYMBOLRENDERERV2_H +#include "qgis_core.h" #include "qgis.h" #include "qgsrenderer.h" #include "qgssymbol.h" @@ -30,8 +31,6 @@ class CORE_EXPORT QgsSingleSymbolRenderer : public QgsFeatureRenderer QgsSingleSymbolRenderer( QgsSymbol* symbol ); - virtual ~QgsSingleSymbolRenderer(); - virtual QgsSymbol* symbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override; virtual QgsSymbol* originalSymbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override; virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override; diff --git a/src/core/symbology-ng/qgsstyle.h b/src/core/symbology-ng/qgsstyle.h index 15253cd808a..cea214b5ab1 100644 --- a/src/core/symbology-ng/qgsstyle.h +++ b/src/core/symbology-ng/qgsstyle.h @@ -16,6 +16,7 @@ #ifndef QGSSTYLEV2_H #define QGSSTYLEV2_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/symbology-ng/qgssvgcache.cpp b/src/core/symbology-ng/qgssvgcache.cpp index bf16b9262a6..5bafaa1e38f 100644 --- a/src/core/symbology-ng/qgssvgcache.cpp +++ b/src/core/symbology-ng/qgssvgcache.cpp @@ -94,12 +94,6 @@ int QgsSvgCacheEntry::dataSize() const return size; } -QgsSvgCache* QgsSvgCache::instance() -{ - static QgsSvgCache mInstance; - return &mInstance; -} - QgsSvgCache::QgsSvgCache( QObject *parent ) : QObject( parent ) , mTotalSize( 0 ) diff --git a/src/core/symbology-ng/qgssvgcache.h b/src/core/symbology-ng/qgssvgcache.h index eb5bea0e082..5fb4c214b22 100644 --- a/src/core/symbology-ng/qgssvgcache.h +++ b/src/core/symbology-ng/qgssvgcache.h @@ -27,6 +27,8 @@ #include #include +#include "qgis_core.h" + class QDomElement; class QImage; class QPicture; @@ -52,6 +54,11 @@ class CORE_EXPORT QgsSvgCacheEntry QgsSvgCacheEntry( const QString& file, double size, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, const QColor& fill, const QColor& outline, const QString& lookupKey = QString() ); ~QgsSvgCacheEntry(); + //! QgsSvgCacheEntry cannot be copied. + QgsSvgCacheEntry( const QgsSvgCacheEntry& rh ) = delete; + //! QgsSvgCacheEntry cannot be copied. + QgsSvgCacheEntry& operator=( const QgsSvgCacheEntry& rh ) = delete; + //! Absolute path to SVG file QString file; //! Lookup key used by QgsSvgCache's hashtable (relative or absolute path). Needed for removal from the hashtable @@ -82,16 +89,15 @@ class CORE_EXPORT QgsSvgCacheEntry //! Return memory usage in bytes int dataSize() const; - private: - - QgsSvgCacheEntry( const QgsSvgCacheEntry& rh ); - QgsSvgCacheEntry& operator=( const QgsSvgCacheEntry& rh ); }; /** \ingroup core * A cache for images / pictures derived from svg files. This class supports parameter replacement in svg files according to the svg params specification (http://www.w3.org/TR/2009/WD-SVGParamPrimer-20090616/). Supported are the parameters 'fill-color', 'pen-color', 'outline-width', 'stroke-width'. E.g. #include @@ -202,7 +203,7 @@ class CORE_EXPORT QgsSymbol void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; /** Returns the units to use for sizes and widths within the symbol. Individual - * symbol layer definitions will interpret this in different ways, eg a marker symbol + * symbol layer definitions will interpret this in different ways, e.g., a marker symbol * may use it to specify the units for the marker size, while a line symbol * may use it to specify the units for the line width. * @returns output unit, or QgsUnitTypes::RenderUnknownUnit if the symbol contains mixed units @@ -211,7 +212,7 @@ class CORE_EXPORT QgsSymbol QgsUnitTypes::RenderUnit outputUnit() const; /** Sets the units to use for sizes and widths within the symbol. Individual - * symbol definitions will interpret this in different ways, eg a marker symbol + * symbol definitions will interpret this in different ways, e.g., a marker symbol * may use it to specify the units for the marker size, while a line symbol * may use it to specify the units for the line width. * @param unit output units diff --git a/src/core/symbology-ng/qgssymbollayer.h b/src/core/symbology-ng/qgssymbollayer.h index 96f87d6d004..a7ab2977210 100644 --- a/src/core/symbology-ng/qgssymbollayer.h +++ b/src/core/symbology-ng/qgssymbollayer.h @@ -23,6 +23,7 @@ #define DEG2RAD(x) ((x)*M_PI/180) #define DEFAULT_SCALE_METHOD QgsSymbol::ScaleDiameter +#include "qgis_core.h" #include #include #include @@ -136,13 +137,13 @@ class CORE_EXPORT QgsSymbolLayer bool isLocked() const { return mLocked; } /** Returns the estimated maximum distance which the layer style will bleed outside - the drawn shape. Eg, polygons drawn with an outline will draw half the width + the drawn shape. For example, polygons drawn with an outline will draw half the width of the outline outside of the polygon. This amount is estimated, since it may be affected by data defined symbology rules.*/ virtual double estimateMaxBleed() const { return 0; } /** Sets the units to use for sizes and widths within the symbol layer. Individual - * symbol layer subclasses will interpret this in different ways, eg a marker symbol + * symbol layer subclasses will interpret this in different ways, e.g., a marker symbol * layer may use it to specify the units for the marker size, while a line symbol * layer may use it to specify the units for the line width. * @param unit output units @@ -151,7 +152,7 @@ class CORE_EXPORT QgsSymbolLayer virtual void setOutputUnit( QgsUnitTypes::RenderUnit unit ) { Q_UNUSED( unit ); } /** Returns the units to use for sizes and widths within the symbol layer. Individual - * symbol layer subclasses will interpret this in different ways, eg a marker symbol + * symbol layer subclasses will interpret this in different ways, e.g., a marker symbol * layer may use it to specify the units for the marker size, while a line symbol * layer may use it to specify the units for the line width. * @returns output unit, or QgsUnitTypes::RenderUnknownUnit if the symbol layer contains mixed units diff --git a/src/core/symbology-ng/qgssymbollayerregistry.cpp b/src/core/symbology-ng/qgssymbollayerregistry.cpp index b49862c62c7..ca3cbc40a0a 100644 --- a/src/core/symbology-ng/qgssymbollayerregistry.cpp +++ b/src/core/symbology-ng/qgssymbollayerregistry.cpp @@ -86,12 +86,6 @@ QgsSymbolLayerAbstractMetadata* QgsSymbolLayerRegistry::symbolLayerMetadata( con return mMetadata.value( name ); } -QgsSymbolLayerRegistry* QgsSymbolLayerRegistry::instance() -{ - static QgsSymbolLayerRegistry mInstance; - return &mInstance; -} - QgsSymbolLayer* QgsSymbolLayerRegistry::defaultSymbolLayer( QgsSymbol::SymbolType type ) { switch ( type ) diff --git a/src/core/symbology-ng/qgssymbollayerregistry.h b/src/core/symbology-ng/qgssymbollayerregistry.h index 42ee998dd5f..ba6c76c4c47 100644 --- a/src/core/symbology-ng/qgssymbollayerregistry.h +++ b/src/core/symbology-ng/qgssymbollayerregistry.h @@ -16,6 +16,7 @@ #ifndef QGSSYMBOLLAYERREGISTRY_H #define QGSSYMBOLLAYERREGISTRY_H +#include "qgis_core.h" #include "qgssymbol.h" class QgsVectorLayer; @@ -36,7 +37,7 @@ class CORE_EXPORT QgsSymbolLayerAbstractMetadata , mType( type ) {} - virtual ~QgsSymbolLayerAbstractMetadata() {} + virtual ~QgsSymbolLayerAbstractMetadata() = default; QString name() const { return mName; } QString visibleName() const { return mVisibleName; } @@ -111,15 +112,22 @@ class CORE_EXPORT QgsSymbolLayerMetadata : public QgsSymbolLayerAbstractMetadata /** \ingroup core - Registry of available symbol layer classes. - Implemented as a singleton. + * Registry of available symbol layer classes. + * + * QgsSymbolLayerRegistry is not usually directly created, but rather accessed through + * QgsApplication::symbolLayerRegistry(). */ class CORE_EXPORT QgsSymbolLayerRegistry { public: - //! return the single instance of this class (instantiate it if not exists) - static QgsSymbolLayerRegistry* instance(); + QgsSymbolLayerRegistry(); + ~QgsSymbolLayerRegistry(); + + //! QgsSymbolLayerRegistry cannot be copied. + QgsSymbolLayerRegistry( const QgsSymbolLayerRegistry& rh ) = delete; + //! QgsSymbolLayerRegistry cannot be copied. + QgsSymbolLayerRegistry& operator=( const QgsSymbolLayerRegistry& rh ) = delete; //! return metadata for specified symbol layer. Returns NULL if not found QgsSymbolLayerAbstractMetadata* symbolLayerMetadata( const QString& name ) const; @@ -139,15 +147,9 @@ class CORE_EXPORT QgsSymbolLayerRegistry //! create a new instance of symbol layer for specified symbol type with default settings static QgsSymbolLayer* defaultSymbolLayer( QgsSymbol::SymbolType type ); - protected: - QgsSymbolLayerRegistry(); - ~QgsSymbolLayerRegistry(); + private: QMap mMetadata; - - private: - QgsSymbolLayerRegistry( const QgsSymbolLayerRegistry& rh ); - QgsSymbolLayerRegistry& operator=( const QgsSymbolLayerRegistry& rh ); }; #endif diff --git a/src/core/symbology-ng/qgssymbollayerutils.cpp b/src/core/symbology-ng/qgssymbollayerutils.cpp index c9428d75b48..2e7bccc3f60 100644 --- a/src/core/symbology-ng/qgssymbollayerutils.cpp +++ b/src/core/symbology-ng/qgssymbollayerutils.cpp @@ -888,7 +888,7 @@ QgsSymbolLayer* QgsSymbolLayerUtils::loadSymbolLayer( QDomElement& element ) QgsStringMap props = parseProperties( element ); QgsSymbolLayer* layer; - layer = QgsSymbolLayerRegistry::instance()->createSymbolLayer( layerClass, props ); + layer = QgsApplication::symbolLayerRegistry()->createSymbolLayer( layerClass, props ); if ( layer ) { layer->setLocked( locked ); @@ -899,7 +899,7 @@ QgsSymbolLayer* QgsSymbolLayerUtils::loadSymbolLayer( QDomElement& element ) QDomElement effectElem = element.firstChildElement( QStringLiteral( "effect" ) ); if ( !effectElem.isNull() ) { - layer->setPaintEffect( QgsPaintEffectRegistry::instance()->createEffect( effectElem ) ); + layer->setPaintEffect( QgsApplication::paintEffectRegistry()->createEffect( effectElem ) ); } return layer; } @@ -997,7 +997,7 @@ bool QgsSymbolLayerUtils::createSymbolLayerListFromSld( QDomElement& element, { case QgsWkbTypes::PolygonGeometry: // polygon layer and point symbolizer: draw poligon centroid - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "CentroidFill" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "CentroidFill" ), element ); if ( l ) layers.append( l ); @@ -1013,7 +1013,7 @@ bool QgsSymbolLayerUtils::createSymbolLayerListFromSld( QDomElement& element, case QgsWkbTypes::LineGeometry: // line layer and point symbolizer: draw central point - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "SimpleMarker" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "SimpleMarker" ), element ); if ( l ) layers.append( l ); @@ -1049,7 +1049,7 @@ bool QgsSymbolLayerUtils::createSymbolLayerListFromSld( QDomElement& element, case QgsWkbTypes::PointGeometry: // point layer and line symbolizer: draw a little line marker - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "MarkerLine" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "MarkerLine" ), element ); if ( l ) layers.append( l ); @@ -1132,13 +1132,13 @@ QgsSymbolLayer* QgsSymbolLayerUtils::createFillLayerFromSld( QDomElement &elemen QgsSymbolLayer *l = nullptr; if ( needLinePatternFill( element ) ) - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "LinePatternFill" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "LinePatternFill" ), element ); else if ( needPointPatternFill( element ) ) - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "PointPatternFill" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "PointPatternFill" ), element ); else if ( needSvgFill( element ) ) - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "SVGFill" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "SVGFill" ), element ); else - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "SimpleFill" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "SimpleFill" ), element ); return l; } @@ -1155,9 +1155,9 @@ QgsSymbolLayer* QgsSymbolLayerUtils::createLineLayerFromSld( QDomElement &elemen QgsSymbolLayer *l = nullptr; if ( needMarkerLine( element ) ) - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "MarkerLine" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "MarkerLine" ), element ); else - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "SimpleLine" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "SimpleLine" ), element ); return l; } @@ -1174,13 +1174,13 @@ QgsSymbolLayer* QgsSymbolLayerUtils::createMarkerLayerFromSld( QDomElement &elem QgsSymbolLayer *l = nullptr; if ( needFontMarker( element ) ) - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "FontMarker" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "FontMarker" ), element ); else if ( needSvgMarker( element ) ) - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "SvgMarker" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "SvgMarker" ), element ); else if ( needEllipseMarker( element ) ) - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "EllipseMarker" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "EllipseMarker" ), element ); else - l = QgsSymbolLayerRegistry::instance()->createSymbolLayerFromSld( QStringLiteral( "SimpleMarker" ), element ); + l = QgsApplication::symbolLayerRegistry()->createSymbolLayerFromSld( QStringLiteral( "SimpleMarker" ), element ); return l; } @@ -1426,7 +1426,7 @@ bool QgsSymbolLayerUtils::convertPolygonSymbolizerToPointMarker( QDomElement &el map[QStringLiteral( "size" )] = QString::number( 6 ); map[QStringLiteral( "angle" )] = QString::number( 0 ); map[QStringLiteral( "offset" )] = encodePoint( QPointF( 0, 0 ) ); - layers.append( QgsSymbolLayerRegistry::instance()->createSymbolLayer( QStringLiteral( "SimpleMarker" ), map ) ); + layers.append( QgsApplication::symbolLayerRegistry()->createSymbolLayer( QStringLiteral( "SimpleMarker" ), map ) ); } } @@ -1607,7 +1607,7 @@ bool QgsSymbolLayerUtils::convertPolygonSymbolizerToPointMarker( QDomElement &el map[QStringLiteral( "angle" )] = QString::number( angle ); if ( !offset.isNull() ) map[QStringLiteral( "offset" )] = encodePoint( offset ); - layers.append( QgsSymbolLayerRegistry::instance()->createSymbolLayer( QStringLiteral( "SvgMarker" ), map ) ); + layers.append( QgsApplication::symbolLayerRegistry()->createSymbolLayer( QStringLiteral( "SvgMarker" ), map ) ); } else if ( format == QLatin1String( "ttf" ) ) { @@ -1621,7 +1621,7 @@ bool QgsSymbolLayerUtils::convertPolygonSymbolizerToPointMarker( QDomElement &el map[QStringLiteral( "angle" )] = QString::number( angle ); if ( !offset.isNull() ) map[QStringLiteral( "offset" )] = encodePoint( offset ); - layers.append( QgsSymbolLayerRegistry::instance()->createSymbolLayer( QStringLiteral( "FontMarker" ), map ) ); + layers.append( QgsApplication::symbolLayerRegistry()->createSymbolLayer( QStringLiteral( "FontMarker" ), map ) ); } } } diff --git a/src/core/symbology-ng/qgssymbollayerutils.h b/src/core/symbology-ng/qgssymbollayerutils.h index 495344ff95d..7780231a5de 100644 --- a/src/core/symbology-ng/qgssymbollayerutils.h +++ b/src/core/symbology-ng/qgssymbollayerutils.h @@ -17,6 +17,7 @@ #ifndef QGSSYMBOLLAYERUTILS_H #define QGSSYMBOLLAYERUTILS_H +#include "qgis_core.h" #include #include #include diff --git a/src/core/symbology-ng/qgssymbologyconversion.h b/src/core/symbology-ng/qgssymbologyconversion.h index 39a3bdf2b3f..1acb8b3150c 100644 --- a/src/core/symbology-ng/qgssymbologyconversion.h +++ b/src/core/symbology-ng/qgssymbologyconversion.h @@ -19,6 +19,7 @@ class QDomNode; class QgsFeatureRenderer; +#include "qgis_core.h" #include "qgis.h" #include diff --git a/src/core/symbology-ng/qgsvectorfieldsymbollayer.h b/src/core/symbology-ng/qgsvectorfieldsymbollayer.h index 01aaaa848d1..feb1e662435 100644 --- a/src/core/symbology-ng/qgsvectorfieldsymbollayer.h +++ b/src/core/symbology-ng/qgsvectorfieldsymbollayer.h @@ -18,6 +18,7 @@ #ifndef QGSVECTORFIELDSYMBOLLAYER_H #define QGSVECTORFIELDSYMBOLLAYER_H +#include "qgis_core.h" #include "qgssymbollayer.h" /** \ingroup core diff --git a/src/crssync/CMakeLists.txt b/src/crssync/CMakeLists.txt index f2d84c18cf8..3a277725cbe 100644 --- a/src/crssync/CMakeLists.txt +++ b/src/crssync/CMakeLists.txt @@ -3,6 +3,7 @@ ADD_EXECUTABLE(crssync main.cpp) INCLUDE_DIRECTORIES( ../core ../core/geometry + ${CMAKE_BINARY_DIR}/src/core ) INCLUDE_DIRECTORIES(SYSTEM ${GDAL_INCLUDE_DIR} diff --git a/src/customwidgets/CMakeLists.txt b/src/customwidgets/CMakeLists.txt index 2856f08df9f..8198feb0c2d 100644 --- a/src/customwidgets/CMakeLists.txt +++ b/src/customwidgets/CMakeLists.txt @@ -7,10 +7,6 @@ FIND_PACKAGE(Qt5Designer REQUIRED) SET(QT_USE_QTDESIGNER ON) - -REMOVE_DEFINITIONS("-DCUSTOMWIDGETS_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("\"-DCUSTOMWIDGETS_EXPORT=${DLLEXPORT}\"") - ######################################################## # Files @@ -106,6 +102,9 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../gui/attributetable/ ${CMAKE_CURRENT_SOURCE_DIR}/../gui/editorwidgets/ ${CMAKE_CURRENT_SOURCE_DIR}/../gui/editorwidgets/core + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui + ${CMAKE_BINARY_DIR}/src/customwidgets ${CMAKE_CURRENT_BINARY_DIR}/../ui/ ) INCLUDE_DIRECTORIES(SYSTEM @@ -125,9 +124,6 @@ QT5_ADD_RESOURCES(IMAGE_RCC_SRCS ${IMAGE_RCCS}) ADD_LIBRARY(qgis_customwidgets SHARED ${QGIS_CUSTOMWIDGETS_SRCS} ${QGIS_CUSTOMWIDGETS_MOC_SRCS} ${QGIS_CUSTOMWIDGETS_HDRS} ${IMAGE_RCC_SRCS}) -# TODO: apple -INSTALL(FILES ${QGIS_CUSTOMWIDGETS_HDRS} DESTINATION ${QGIS_INCLUDE_DIR}) - SET_TARGET_PROPERTIES(qgis_customwidgets PROPERTIES VERSION ${COMPLETE_VERSION} SOVERSION ${COMPLETE_VERSION} @@ -138,8 +134,19 @@ ADD_DEPENDENCIES(qgis_customwidgets ui) TARGET_LINK_LIBRARIES(qgis_customwidgets qgis_gui) +GENERATE_EXPORT_HEADER( + qgis_customwidgets + BASE_NAME CUSTOMWIDGETS + EXPORT_FILE_NAME qgis_customwidgets.h +) + +SET(QGIS_CUSTOMWIDGETS_HDRS ${QGIS_CUSTOMWIDGETS_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/qgis_customwidgets.h) + # install INSTALL(TARGETS qgis_customwidgets RUNTIME DESTINATION ${QT_PLUGINS_DIR}/designer LIBRARY DESTINATION ${QT_PLUGINS_DIR}/designer ) + +# TODO: apple +INSTALL(FILES ${QGIS_CUSTOMWIDGETS_HDRS} DESTINATION ${QGIS_INCLUDE_DIR}) diff --git a/src/customwidgets/qgscollapsiblegroupboxplugin.h b/src/customwidgets/qgscollapsiblegroupboxplugin.h index 31b751af837..a7ea82f1b3b 100644 --- a/src/customwidgets/qgscollapsiblegroupboxplugin.h +++ b/src/customwidgets/qgscollapsiblegroupboxplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif class CUSTOMWIDGETS_EXPORT QgsCollapsibleGroupBoxPlugin : public QObject, public QDesignerCustomWidgetInterface diff --git a/src/customwidgets/qgscolorbuttonplugin.h b/src/customwidgets/qgscolorbuttonplugin.h index cdb713cc35e..d44e9186a8d 100644 --- a/src/customwidgets/qgscolorbuttonplugin.h +++ b/src/customwidgets/qgscolorbuttonplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsdatadefinedbuttonplugin.h b/src/customwidgets/qgsdatadefinedbuttonplugin.h index 9ba4eb6c1ae..237396d9b9e 100644 --- a/src/customwidgets/qgsdatadefinedbuttonplugin.h +++ b/src/customwidgets/qgsdatadefinedbuttonplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsdatetimeeditplugin.h b/src/customwidgets/qgsdatetimeeditplugin.h index 67440adf919..b9a3fbd51aa 100644 --- a/src/customwidgets/qgsdatetimeeditplugin.h +++ b/src/customwidgets/qgsdatetimeeditplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsdockwidgetplugin.h b/src/customwidgets/qgsdockwidgetplugin.h index 5d4997a1e0a..cc1aa452b80 100644 --- a/src/customwidgets/qgsdockwidgetplugin.h +++ b/src/customwidgets/qgsdockwidgetplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif class CUSTOMWIDGETS_EXPORT QgsDockWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface diff --git a/src/customwidgets/qgsdoublespinboxplugin.h b/src/customwidgets/qgsdoublespinboxplugin.h index 58c0ac86f77..c26cd0ccac0 100644 --- a/src/customwidgets/qgsdoublespinboxplugin.h +++ b/src/customwidgets/qgsdoublespinboxplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsexpressionbuilderwidgetplugin.h b/src/customwidgets/qgsexpressionbuilderwidgetplugin.h index 68670265af8..61a43edd17a 100644 --- a/src/customwidgets/qgsexpressionbuilderwidgetplugin.h +++ b/src/customwidgets/qgsexpressionbuilderwidgetplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsextentgroupboxplugin.h b/src/customwidgets/qgsextentgroupboxplugin.h index f3167d963fb..cf6cbf3cde0 100644 --- a/src/customwidgets/qgsextentgroupboxplugin.h +++ b/src/customwidgets/qgsextentgroupboxplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsexternalresourcewidgetplugin.h b/src/customwidgets/qgsexternalresourcewidgetplugin.h index ae782cdc485..e5b472679f9 100644 --- a/src/customwidgets/qgsexternalresourcewidgetplugin.h +++ b/src/customwidgets/qgsexternalresourcewidgetplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsfieldcomboboxplugin.h b/src/customwidgets/qgsfieldcomboboxplugin.h index 3d671ec8539..2a99b08fef5 100644 --- a/src/customwidgets/qgsfieldcomboboxplugin.h +++ b/src/customwidgets/qgsfieldcomboboxplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsfieldexpressionwidgetplugin.h b/src/customwidgets/qgsfieldexpressionwidgetplugin.h index f09927d667c..7dbcfba952a 100644 --- a/src/customwidgets/qgsfieldexpressionwidgetplugin.h +++ b/src/customwidgets/qgsfieldexpressionwidgetplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsfilewidgetplugin.h b/src/customwidgets/qgsfilewidgetplugin.h index 9757eda1911..d4c251af2e8 100644 --- a/src/customwidgets/qgsfilewidgetplugin.h +++ b/src/customwidgets/qgsfilewidgetplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsfilterlineeditplugin.h b/src/customwidgets/qgsfilterlineeditplugin.h index d8fe6cb4e3c..1d49cea0c7f 100644 --- a/src/customwidgets/qgsfilterlineeditplugin.h +++ b/src/customwidgets/qgsfilterlineeditplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsmaplayercomboboxplugin.h b/src/customwidgets/qgsmaplayercomboboxplugin.h index c63a5689f2e..35a6873541f 100644 --- a/src/customwidgets/qgsmaplayercomboboxplugin.h +++ b/src/customwidgets/qgsmaplayercomboboxplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsprojectionselectionwidgetplugin.h b/src/customwidgets/qgsprojectionselectionwidgetplugin.h index f340b1560bd..63c3ae91783 100644 --- a/src/customwidgets/qgsprojectionselectionwidgetplugin.h +++ b/src/customwidgets/qgsprojectionselectionwidgetplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsrelationeditorwidgetplugin.h b/src/customwidgets/qgsrelationeditorwidgetplugin.h index 101e007c10a..30c11543496 100644 --- a/src/customwidgets/qgsrelationeditorwidgetplugin.h +++ b/src/customwidgets/qgsrelationeditorwidgetplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsrelationreferencewidgetplugin.h b/src/customwidgets/qgsrelationreferencewidgetplugin.h index 3dc4cd69837..bfe3867ec05 100644 --- a/src/customwidgets/qgsrelationreferencewidgetplugin.h +++ b/src/customwidgets/qgsrelationreferencewidgetplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsscalerangewidgetplugin.h b/src/customwidgets/qgsscalerangewidgetplugin.h index a22c2d4bbc6..84aa45fa18d 100644 --- a/src/customwidgets/qgsscalerangewidgetplugin.h +++ b/src/customwidgets/qgsscalerangewidgetplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsscalewidgetplugin.h b/src/customwidgets/qgsscalewidgetplugin.h index 19afb7de9ea..1fb399494f5 100644 --- a/src/customwidgets/qgsscalewidgetplugin.h +++ b/src/customwidgets/qgsscalewidgetplugin.h @@ -24,6 +24,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/customwidgets/qgsspinboxplugin.h b/src/customwidgets/qgsspinboxplugin.h index 0099342c2b9..68a8ecea6f6 100644 --- a/src/customwidgets/qgsspinboxplugin.h +++ b/src/customwidgets/qgsspinboxplugin.h @@ -23,6 +23,7 @@ #else #include #include +#include "qgis_customwidgets.h" #endif diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 8094a5fd4bc..222b4c976e8 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -223,6 +223,7 @@ SET(QGIS_GUI_SRCS qgsfieldmodel.cpp qgsfieldproxymodel.cpp qgsfieldvalidator.cpp + qgsfieldvalueslineedit.cpp qgsfiledropedit.cpp qgsfilewidget.cpp qgsfilterlineedit.cpp @@ -286,7 +287,6 @@ SET(QGIS_GUI_SRCS qgspluginmanagerinterface.cpp qgspresetcolorrampdialog.cpp qgsprevieweffect.cpp - qgsprojectbadlayerguihandler.cpp qgsprojectionselectionwidget.cpp qgsprojectionselector.cpp qgsquerybuilder.cpp @@ -391,6 +391,7 @@ SET(QGIS_GUI_MOC_HDRS qgsfieldmodel.h qgsfieldproxymodel.h qgsfieldvalidator.h + qgsfieldvalueslineedit.h qgsfiledropedit.h qgsfilewidget.h qgsfilterlineedit.h @@ -448,7 +449,6 @@ SET(QGIS_GUI_MOC_HDRS qgspluginmanagerinterface.h qgspresetcolorrampdialog.h qgsprevieweffect.h - qgsprojectbadlayerguihandler.h qgsprojectionselectionwidget.h qgsprojectionselector.h qgsquerybuilder.h @@ -788,6 +788,8 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/editorwidgets/core ${CMAKE_CURRENT_SOURCE_DIR}/layertree ${CMAKE_CURRENT_SOURCE_DIR}/effects + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ../core ../core/auth ../core/composer @@ -809,9 +811,6 @@ INCLUDE_DIRECTORIES(SYSTEM ${GDAL_INCLUDE_DIR} ) -REMOVE_DEFINITIONS("-DGUI_EXPORT=${DLLIMPORT}") -ADD_DEFINITIONS("\"-DGUI_EXPORT=${DLLEXPORT}\"") - # disable deprecation warnings for classes re-exporting deprecated methods IF(MSVC) SET_SOURCE_FILES_PROPERTIES( @@ -834,6 +833,14 @@ ADD_LIBRARY(qgis_gui SHARED ${QGIS_GUI_SRCS} ${QGIS_GUI_MOC_SRCS} ${QGIS_GUI_HDRS} ${QGIS_GUI_MOC_HDRS} ) +GENERATE_EXPORT_HEADER( + qgis_gui + BASE_NAME GUI + EXPORT_FILE_NAME qgis_gui.h +) + +SET(QGIS_GUI_HDRS ${QGIS_GUI_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/qgis_gui.h) + IF(NOT APPLE) INSTALL(FILES ${QGIS_GUI_HDRS} ${QGIS_GUI_MOC_HDRS} DESTINATION ${QGIS_INCLUDE_DIR}) ELSE(NOT APPLE) diff --git a/src/gui/attributetable/qgsattributetabledelegate.h b/src/gui/attributetable/qgsattributetabledelegate.h index c29f049e0a1..63dcd4b55e8 100644 --- a/src/gui/attributetable/qgsattributetabledelegate.h +++ b/src/gui/attributetable/qgsattributetabledelegate.h @@ -17,6 +17,7 @@ #define QGSATTRIBUTETABLEDELEGATE_H #include +#include "qgis_gui.h" class QgsFeatureSelectionModel; class QPainter; diff --git a/src/gui/attributetable/qgsattributetablefiltermodel.cpp b/src/gui/attributetable/qgsattributetablefiltermodel.cpp index d3080e05034..d52ca274b4e 100644 --- a/src/gui/attributetable/qgsattributetablefiltermodel.cpp +++ b/src/gui/attributetable/qgsattributetablefiltermodel.cpp @@ -386,9 +386,7 @@ void QgsAttributeTableFilterModel::generateListOfVisibleFeatures() bool filter = false; QgsRectangle rect = mCanvas->mapSettings().mapToLayerCoordinates( layer(), mCanvas->extent() ); QgsRenderContext renderContext; - renderContext.expressionContext() << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( layer() ); + renderContext.expressionContext().appendScopes( QgsExpressionContextUtils::globalProjectLayerScopes( layer() ) ); QgsFeatureRenderer* renderer = layer()->renderer(); mFilteredFeatures.clear(); @@ -409,7 +407,7 @@ void QgsAttributeTableFilterModel::generateListOfVisibleFeatures() if ( renderer && renderer->capabilities() & QgsFeatureRenderer::ScaleDependent ) { // setup scale - // mapRenderer()->renderContext()->scale is not automaticaly updated when + // mapRenderer()->renderContext()->scale is not automatically updated when // render extent changes (because it's scale is used to identify if changed // since last render) -> use local context renderContext.setExtent( ms.visibleExtent() ); diff --git a/src/gui/attributetable/qgsattributetablefiltermodel.h b/src/gui/attributetable/qgsattributetablefiltermodel.h index 0930ffc8bb7..44f4496a039 100644 --- a/src/gui/attributetable/qgsattributetablefiltermodel.h +++ b/src/gui/attributetable/qgsattributetablefiltermodel.h @@ -22,6 +22,7 @@ #include "qgsattributetablemodel.h" #include "qgsfeaturemodel.h" +#include "qgis_gui.h" class QgsVectorLayerCache; class QgsMapCanvas; diff --git a/src/gui/attributetable/qgsattributetablemodel.cpp b/src/gui/attributetable/qgsattributetablemodel.cpp index 5674520104d..147df184400 100644 --- a/src/gui/attributetable/qgsattributetablemodel.cpp +++ b/src/gui/attributetable/qgsattributetablemodel.cpp @@ -46,9 +46,7 @@ QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayerCache *layerCache, , mSortFieldIndex( -1 ) , mExtraColumns( 0 ) { - mExpressionContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( layerCache->layer() ); + mExpressionContext.appendScopes( QgsExpressionContextUtils::globalProjectLayerScopes( layerCache->layer() ) ); if ( layerCache->layer()->geometryType() == QgsWkbTypes::NullGeometry ) { diff --git a/src/gui/attributetable/qgsattributetablemodel.h b/src/gui/attributetable/qgsattributetablemodel.h index 71e654c1238..8758ccdb100 100644 --- a/src/gui/attributetable/qgsattributetablemodel.h +++ b/src/gui/attributetable/qgsattributetablemodel.h @@ -28,6 +28,7 @@ #include "qgsconditionalstyle.h" #include "qgsattributeeditorcontext.h" #include "qgsvectorlayercache.h" +#include "qgis_gui.h" class QgsMapCanvas; class QgsMapLayerAction; diff --git a/src/gui/attributetable/qgsattributetableview.h b/src/gui/attributetable/qgsattributetableview.h index ffa0fc7118f..2472304209b 100644 --- a/src/gui/attributetable/qgsattributetableview.h +++ b/src/gui/attributetable/qgsattributetableview.h @@ -20,6 +20,7 @@ #include #include "qgsfeature.h" // For QgsFeatureIds +#include "qgis_gui.h" class QgsAttributeTableDelegate; class QgsAttributeTableFilterModel; diff --git a/src/gui/attributetable/qgsdualview.cpp b/src/gui/attributetable/qgsdualview.cpp index e71608601a2..a5293da1b81 100644 --- a/src/gui/attributetable/qgsdualview.cpp +++ b/src/gui/attributetable/qgsdualview.cpp @@ -299,10 +299,7 @@ void QgsDualView::toggleSearchMode( bool enabled ) void QgsDualView::previewExpressionBuilder() { // Show expression builder - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mLayerCache->layer() ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mLayerCache->layer() ) ); QgsExpressionBuilderDialog dlg( mLayerCache->layer(), mFeatureList->displayExpression(), this, QStringLiteral( "generic" ), context ); dlg.setWindowTitle( tr( "Expression based preview" ) ); @@ -550,10 +547,7 @@ void QgsDualView::modifySort() sortingGroupBox->setLayout( new QGridLayout() ); QgsExpressionBuilderWidget* expressionBuilder = new QgsExpressionBuilderWidget(); - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( layer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( layer ) ); expressionBuilder->setExpressionContext( context ); expressionBuilder->setLayer( layer ); expressionBuilder->loadFieldNames(); diff --git a/src/gui/attributetable/qgsdualview.h b/src/gui/attributetable/qgsdualview.h index 867b6c03635..f9ce1961481 100644 --- a/src/gui/attributetable/qgsdualview.h +++ b/src/gui/attributetable/qgsdualview.h @@ -24,6 +24,7 @@ #include "qgsattributetablefiltermodel.h" #include "qgsdistancearea.h" #include "qgsattributeform.h" +#include "qgis_gui.h" class QgsFeatureRequest; class QSignalMapper; diff --git a/src/gui/attributetable/qgsfeaturelistmodel.cpp b/src/gui/attributetable/qgsfeaturelistmodel.cpp index 7ddcb1d9d47..5d1412d9686 100644 --- a/src/gui/attributetable/qgsfeaturelistmodel.cpp +++ b/src/gui/attributetable/qgsfeaturelistmodel.cpp @@ -91,10 +91,7 @@ QVariant QgsFeatureListModel::data( const QModelIndex &index, int role ) const mFilterModel->layerCache()->featureAtId( idxToFid( index ), feat ); - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mFilterModel->layer() ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mFilterModel->layer() ) ); context.setFeature( feat ); return mExpression->evaluate( &context ); } @@ -175,10 +172,7 @@ bool QgsFeatureListModel::setDisplayExpression( const QString& expression ) { QgsExpression* exp = new QgsExpression( expression ); - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mFilterModel->layer() ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mFilterModel->layer() ) ); exp->prepare( &context ); diff --git a/src/gui/attributetable/qgsfeaturelistmodel.h b/src/gui/attributetable/qgsfeaturelistmodel.h index 99a1030fb8e..b804de2b6c6 100644 --- a/src/gui/attributetable/qgsfeaturelistmodel.h +++ b/src/gui/attributetable/qgsfeaturelistmodel.h @@ -23,6 +23,7 @@ #include "qgsfeaturemodel.h" #include "qgsfeature.h" // QgsFeatureId +#include "qgis_gui.h" class QgsAttributeTableFilterModel; class QgsAttributeTableModel; diff --git a/src/gui/attributetable/qgsfeaturelistview.h b/src/gui/attributetable/qgsfeaturelistview.h index 21f288e1280..b93109377d2 100644 --- a/src/gui/attributetable/qgsfeaturelistview.h +++ b/src/gui/attributetable/qgsfeaturelistview.h @@ -20,6 +20,7 @@ #include #include "qgsfeature.h" // For QgsFeatureIds +#include "qgis_gui.h" class QgsAttributeTableFilterModel; class QgsFeatureListModel; @@ -52,11 +53,6 @@ class GUI_EXPORT QgsFeatureListView : public QListView */ explicit QgsFeatureListView( QWidget* parent = nullptr ); - /** - * Destructor - */ - virtual ~QgsFeatureListView() {} - /** * Returns the layer cache * @return the layer cache used as backend diff --git a/src/gui/attributetable/qgsfeaturelistviewdelegate.h b/src/gui/attributetable/qgsfeaturelistviewdelegate.h index 612946e6e1a..92c5e700819 100644 --- a/src/gui/attributetable/qgsfeaturelistviewdelegate.h +++ b/src/gui/attributetable/qgsfeaturelistviewdelegate.h @@ -17,6 +17,7 @@ #include #include +#include "qgis_gui.h" class QgsVectorLayer; class QgsFeatureListModel; diff --git a/src/gui/attributetable/qgsfeaturemodel.h b/src/gui/attributetable/qgsfeaturemodel.h index 74082b2ef0f..2316b446cbd 100644 --- a/src/gui/attributetable/qgsfeaturemodel.h +++ b/src/gui/attributetable/qgsfeaturemodel.h @@ -24,7 +24,7 @@ class QgsFeatureModel { public: - virtual ~QgsFeatureModel() {} + virtual ~QgsFeatureModel() = default; virtual QModelIndex fidToIndex( QgsFeatureId fid ) = 0; }; diff --git a/src/gui/attributetable/qgsfeatureselectionmodel.h b/src/gui/attributetable/qgsfeatureselectionmodel.h index f530f3a61dd..9cefad20290 100644 --- a/src/gui/attributetable/qgsfeatureselectionmodel.h +++ b/src/gui/attributetable/qgsfeatureselectionmodel.h @@ -18,6 +18,7 @@ #include #include "qgsfeature.h" +#include "qgis_gui.h" class QgsVectorLayer; class QgsFeatureModel; diff --git a/src/gui/attributetable/qgsfieldconditionalformatwidget.cpp b/src/gui/attributetable/qgsfieldconditionalformatwidget.cpp index 98982547221..894e28b4160 100644 --- a/src/gui/attributetable/qgsfieldconditionalformatwidget.cpp +++ b/src/gui/attributetable/qgsfieldconditionalformatwidget.cpp @@ -74,10 +74,7 @@ void QgsFieldConditionalFormatWidget::updateIcon() void QgsFieldConditionalFormatWidget::setExpression() { - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mLayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mLayer ) ); context.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "value" ), 0, true ) ); context.setHighlightedVariables( QStringList() << QStringLiteral( "value" ) ); diff --git a/src/gui/attributetable/qgsfieldconditionalformatwidget.h b/src/gui/attributetable/qgsfieldconditionalformatwidget.h index 9761e4ceec3..d88b4c2d0a4 100644 --- a/src/gui/attributetable/qgsfieldconditionalformatwidget.h +++ b/src/gui/attributetable/qgsfieldconditionalformatwidget.h @@ -24,6 +24,7 @@ #include "ui_qgsfieldconditionalformatwidget.h" #include "qgsconditionalstyle.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsFieldConditionalFormatWidget diff --git a/src/gui/attributetable/qgsgenericfeatureselectionmanager.h b/src/gui/attributetable/qgsgenericfeatureselectionmanager.h index 20f63037bbe..5c1b8d3359e 100644 --- a/src/gui/attributetable/qgsgenericfeatureselectionmanager.h +++ b/src/gui/attributetable/qgsgenericfeatureselectionmanager.h @@ -18,6 +18,7 @@ #include "qgsfeature.h" #include "qgsifeatureselectionmanager.h" +#include "qgis_gui.h" /** \ingroup gui * This selection manager synchronizes a local set of selected features with an attribute table. diff --git a/src/gui/attributetable/qgsifeatureselectionmanager.h b/src/gui/attributetable/qgsifeatureselectionmanager.h index e71a1d9cc02..e6da8dbf005 100644 --- a/src/gui/attributetable/qgsifeatureselectionmanager.h +++ b/src/gui/attributetable/qgsifeatureselectionmanager.h @@ -19,6 +19,7 @@ #include #include "qgsfeature.h" +#include "qgis_gui.h" /** \ingroup gui * Is an interface class to abstract feature selection handling. diff --git a/src/gui/attributetable/qgsorganizetablecolumnsdialog.h b/src/gui/attributetable/qgsorganizetablecolumnsdialog.h index 5d2f7f2372e..e8ba7179a04 100644 --- a/src/gui/attributetable/qgsorganizetablecolumnsdialog.h +++ b/src/gui/attributetable/qgsorganizetablecolumnsdialog.h @@ -22,6 +22,7 @@ #include "ui_qgsorganizetablecolumnsdialog.h" #include "qgsattributetableconfig.h" +#include "qgis_gui.h" class QgsVectorLayer; @@ -44,9 +45,6 @@ class GUI_EXPORT QgsOrganizeTableColumnsDialog : public QDialog, private Ui::Qgs */ QgsOrganizeTableColumnsDialog( const QgsVectorLayer* vl, QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::Window ); - /** - * Destructor - */ ~QgsOrganizeTableColumnsDialog(); /** diff --git a/src/gui/attributetable/qgsvectorlayerselectionmanager.h b/src/gui/attributetable/qgsvectorlayerselectionmanager.h index 6dbf0601bf0..c91cf3848ef 100644 --- a/src/gui/attributetable/qgsvectorlayerselectionmanager.h +++ b/src/gui/attributetable/qgsvectorlayerselectionmanager.h @@ -17,6 +17,7 @@ #define QGSVECTORLAYERSELECTIONMANAGER_H #include "qgsifeatureselectionmanager.h" +#include "qgis_gui.h" class QgsVectorLayer; diff --git a/src/gui/auth/qgsauthauthoritieseditor.cpp b/src/gui/auth/qgsauthauthoritieseditor.cpp index 692b5fccfda..7ee328d4b26 100644 --- a/src/gui/auth/qgsauthauthoritieseditor.cpp +++ b/src/gui/auth/qgsauthauthoritieseditor.cpp @@ -99,10 +99,6 @@ QgsAuthAuthoritiesEditor::QgsAuthAuthoritiesEditor( QWidget *parent ) } } -QgsAuthAuthoritiesEditor::~QgsAuthAuthoritiesEditor() -{ -} - static void setItemBold_( QTreeWidgetItem* item ) { item->setFirstColumnSpanned( true ); diff --git a/src/gui/auth/qgsauthauthoritieseditor.h b/src/gui/auth/qgsauthauthoritieseditor.h index e0c4204c202..2a575b0561a 100644 --- a/src/gui/auth/qgsauthauthoritieseditor.h +++ b/src/gui/auth/qgsauthauthoritieseditor.h @@ -23,6 +23,7 @@ #include "ui_qgsauthauthoritieseditor.h" #include "qgsauthcertutils.h" #include "qgsauthmanager.h" +#include "qgis_gui.h" class QgsMessageBar; class QMenu; @@ -42,7 +43,6 @@ class GUI_EXPORT QgsAuthAuthoritiesEditor : public QWidget, private Ui::QgsAuthA * @param parent Parent widget */ explicit QgsAuthAuthoritiesEditor( QWidget *parent = nullptr ); - ~QgsAuthAuthoritiesEditor(); private slots: void populateCaCertsView(); diff --git a/src/gui/auth/qgsauthcertificateinfo.cpp b/src/gui/auth/qgsauthcertificateinfo.cpp index 6809a238308..093657dd61e 100644 --- a/src/gui/auth/qgsauthcertificateinfo.cpp +++ b/src/gui/auth/qgsauthcertificateinfo.cpp @@ -112,10 +112,6 @@ QgsAuthCertInfo::QgsAuthCertInfo( const QSslCertificate& cert, } } -QgsAuthCertInfo::~QgsAuthCertInfo() -{ -} - void QgsAuthCertInfo::setupError( const QString &msg ) { lblError->setVisible( true ); @@ -939,6 +935,3 @@ QgsAuthCertInfoDialog::QgsAuthCertInfoDialog( const QSslCertificate& cert, setLayout( layout ); } -QgsAuthCertInfoDialog::~QgsAuthCertInfoDialog() -{ -} diff --git a/src/gui/auth/qgsauthcertificateinfo.h b/src/gui/auth/qgsauthcertificateinfo.h index 31c5658da5d..c27874745fb 100644 --- a/src/gui/auth/qgsauthcertificateinfo.h +++ b/src/gui/auth/qgsauthcertificateinfo.h @@ -29,6 +29,7 @@ #include #include "ui_qgsauthcertificateinfo.h" #include "qgsauthcertutils.h" +#include "qgis_gui.h" /** \ingroup gui * Widget for viewing detailed info on a certificate and its hierarchical trust chain @@ -42,7 +43,6 @@ class GUI_EXPORT QgsAuthCertInfo : public QWidget, private Ui::QgsAuthCertInfo bool manageCertTrust = false, QWidget *parent = nullptr, const QList& connectionCAs = QList() ); - ~QgsAuthCertInfo(); bool trustCacheRebuilt() { return mTrustCacheRebuilt; } @@ -154,7 +154,6 @@ class GUI_EXPORT QgsAuthCertInfoDialog : public QDialog bool manageCertTrust, QWidget *parent = nullptr, const QList& connectionCAs = QList() ); - ~QgsAuthCertInfoDialog(); //! Get access to embedded info widget QgsAuthCertInfo *certInfoWidget() { return mCertInfoWdgt; } diff --git a/src/gui/auth/qgsauthcertificatemanager.cpp b/src/gui/auth/qgsauthcertificatemanager.cpp index 4e307f84d11..6d5603d7338 100644 --- a/src/gui/auth/qgsauthcertificatemanager.cpp +++ b/src/gui/auth/qgsauthcertificatemanager.cpp @@ -26,11 +26,6 @@ QgsAuthCertEditors::QgsAuthCertEditors( QWidget *parent ) setupUi( this ); } -QgsAuthCertEditors::~QgsAuthCertEditors() -{ -} - - QgsAuthCertManager::QgsAuthCertManager( QWidget *parent ) : QDialog( parent ) @@ -50,7 +45,3 @@ QgsAuthCertManager::QgsAuthCertManager( QWidget *parent ) setLayout( layout ); } - -QgsAuthCertManager::~QgsAuthCertManager() -{ -} diff --git a/src/gui/auth/qgsauthcertificatemanager.h b/src/gui/auth/qgsauthcertificatemanager.h index c77be78fe3f..d6106ee47b8 100644 --- a/src/gui/auth/qgsauthcertificatemanager.h +++ b/src/gui/auth/qgsauthcertificatemanager.h @@ -21,6 +21,7 @@ #include #include +#include "qgis_gui.h" /** \ingroup gui @@ -38,7 +39,6 @@ class GUI_EXPORT QgsAuthCertEditors : public QWidget, private Ui::QgsAuthCertMan */ explicit QgsAuthCertEditors( QWidget *parent = nullptr ); - ~QgsAuthCertEditors(); }; @@ -59,8 +59,6 @@ class GUI_EXPORT QgsAuthCertManager : public QDialog */ explicit QgsAuthCertManager( QWidget *parent = nullptr ); - ~QgsAuthCertManager(); - //! Get access to embedded editors widget QgsAuthCertEditors *certEditorsWidget() { return mCertEditors; } diff --git a/src/gui/auth/qgsauthcerttrustpolicycombobox.cpp b/src/gui/auth/qgsauthcerttrustpolicycombobox.cpp index 5d0b3721205..1d9310d6018 100644 --- a/src/gui/auth/qgsauthcerttrustpolicycombobox.cpp +++ b/src/gui/auth/qgsauthcerttrustpolicycombobox.cpp @@ -58,10 +58,6 @@ QgsAuthCertTrustPolicyComboBox::QgsAuthCertTrustPolicyComboBox( QWidget *parent, setDefaultTrustPolicy( defaultpolicy ); } -QgsAuthCertTrustPolicyComboBox::~QgsAuthCertTrustPolicyComboBox() -{ -} - QgsAuthCertUtils::CertTrustPolicy QgsAuthCertTrustPolicyComboBox::trustPolicy() { return ( QgsAuthCertUtils::CertTrustPolicy )itemData( currentIndex() ).toInt(); diff --git a/src/gui/auth/qgsauthcerttrustpolicycombobox.h b/src/gui/auth/qgsauthcerttrustpolicycombobox.h index c219d749e01..c7984f25e67 100644 --- a/src/gui/auth/qgsauthcerttrustpolicycombobox.h +++ b/src/gui/auth/qgsauthcerttrustpolicycombobox.h @@ -19,6 +19,7 @@ #include #include "qgsauthcertutils.h" +#include "qgis_gui.h" /** \ingroup gui * Widget for editing the trust policy associated with a Certificate (Intermediate) Authority @@ -39,7 +40,6 @@ class GUI_EXPORT QgsAuthCertTrustPolicyComboBox : public QComboBox QWidget *parent = nullptr, QgsAuthCertUtils::CertTrustPolicy policy = QgsAuthCertUtils::DefaultTrust, QgsAuthCertUtils::CertTrustPolicy defaultpolicy = QgsAuthCertUtils::DefaultTrust ); - ~QgsAuthCertTrustPolicyComboBox(); //! Get currently set trust policy QgsAuthCertUtils::CertTrustPolicy trustPolicy(); diff --git a/src/gui/auth/qgsauthconfigedit.cpp b/src/gui/auth/qgsauthconfigedit.cpp index 0fd667de700..8d47330d421 100644 --- a/src/gui/auth/qgsauthconfigedit.cpp +++ b/src/gui/auth/qgsauthconfigedit.cpp @@ -92,10 +92,6 @@ QgsAuthConfigEdit::QgsAuthConfigEdit( QWidget *parent , const QString& authcfg , } } -QgsAuthConfigEdit::~QgsAuthConfigEdit() -{ -} - void QgsAuthConfigEdit::populateAuthMethods() { QStringList authMethodKeys = QgsAuthManager::instance()->authMethodsKeys( mDataProvider ); diff --git a/src/gui/auth/qgsauthconfigedit.h b/src/gui/auth/qgsauthconfigedit.h index 958d451c93d..1731ca0d977 100644 --- a/src/gui/auth/qgsauthconfigedit.h +++ b/src/gui/auth/qgsauthconfigedit.h @@ -21,6 +21,7 @@ #include #include "ui_qgsauthconfigedit.h" +#include "qgis_gui.h" class QgsAuthMethodEdit; @@ -50,7 +51,6 @@ class GUI_EXPORT QgsAuthConfigEdit : public QDialog, private Ui::QgsAuthConfigEd */ explicit QgsAuthConfigEdit( QWidget *parent = nullptr, const QString& authcfg = QString(), const QString &dataprovider = QString() ); - ~QgsAuthConfigEdit(); //! Authentication config id, updated with generated id when a new config is saved to auth database const QString configId() const { return mAuthCfg; } diff --git a/src/gui/auth/qgsauthconfigeditor.cpp b/src/gui/auth/qgsauthconfigeditor.cpp index 9cc105f57c1..8cd5fe23c3f 100644 --- a/src/gui/auth/qgsauthconfigeditor.cpp +++ b/src/gui/auth/qgsauthconfigeditor.cpp @@ -126,10 +126,6 @@ QgsAuthConfigEditor::QgsAuthConfigEditor( QWidget *parent, bool showUtilities, b } } -QgsAuthConfigEditor::~QgsAuthConfigEditor() -{ -} - void QgsAuthConfigEditor::setMasterPassword() { QgsAuthGuiUtils::setMasterPassword( messageBar(), messageTimeout() ); diff --git a/src/gui/auth/qgsauthconfigeditor.h b/src/gui/auth/qgsauthconfigeditor.h index edfc12238ea..a74892ab37b 100644 --- a/src/gui/auth/qgsauthconfigeditor.h +++ b/src/gui/auth/qgsauthconfigeditor.h @@ -22,6 +22,7 @@ #include "ui_qgsauthconfigeditor.h" #include "qgsauthmanager.h" +#include "qgis_gui.h" class QgsMessageBar; @@ -41,7 +42,6 @@ class GUI_EXPORT QgsAuthConfigEditor : public QWidget, private Ui::QgsAuthConfig * @param relayMessages Whether to relay auth manager messages to internal message bar */ explicit QgsAuthConfigEditor( QWidget *parent = nullptr, bool showUtilities = true, bool relayMessages = true ); - ~QgsAuthConfigEditor(); //! Hide the widget's title, e.g. when embedding void toggleTitleVisibility( bool visible ); diff --git a/src/gui/auth/qgsauthconfigidedit.cpp b/src/gui/auth/qgsauthconfigidedit.cpp index e89b9c9c64d..a8b4f315e3b 100644 --- a/src/gui/auth/qgsauthconfigidedit.cpp +++ b/src/gui/auth/qgsauthconfigidedit.cpp @@ -37,10 +37,6 @@ QgsAuthConfigIdEdit::QgsAuthConfigIdEdit( QWidget *parent, const QString &authcf updateValidityStyle( validate() ); } -QgsAuthConfigIdEdit::~QgsAuthConfigIdEdit() -{ -} - const QString QgsAuthConfigIdEdit::configId() { if ( validate() ) diff --git a/src/gui/auth/qgsauthconfigidedit.h b/src/gui/auth/qgsauthconfigidedit.h index 03e84a4f9c4..8b900f14bcb 100644 --- a/src/gui/auth/qgsauthconfigidedit.h +++ b/src/gui/auth/qgsauthconfigidedit.h @@ -20,6 +20,7 @@ #include "ui_qgsauthconfigidedit.h" #include +#include "qgis_gui.h" /** \ingroup gui * \brief Custom widget for editing an authentication configuration ID @@ -39,7 +40,6 @@ class GUI_EXPORT QgsAuthConfigIdEdit : public QWidget, private Ui::QgsAuthConfig * @param allowEmpty Whether to allow no ID to be set, even when editing, e.g. Add config functions */ explicit QgsAuthConfigIdEdit( QWidget *parent = nullptr, const QString &authcfg = QString(), bool allowEmpty = true ); - ~QgsAuthConfigIdEdit(); //! The authentication configuration ID, if valid, otherwise null QString QString const configId(); diff --git a/src/gui/auth/qgsauthconfigselect.cpp b/src/gui/auth/qgsauthconfigselect.cpp index 734a88b8508..6fb125fac6d 100644 --- a/src/gui/auth/qgsauthconfigselect.cpp +++ b/src/gui/auth/qgsauthconfigselect.cpp @@ -58,10 +58,6 @@ QgsAuthConfigSelect::QgsAuthConfigSelect( QWidget *parent, const QString &datapr } } -QgsAuthConfigSelect::~QgsAuthConfigSelect() -{ -} - void QgsAuthConfigSelect::setConfigId( const QString& authcfg ) { if ( mDisabled && mAuthNotify ) @@ -288,10 +284,6 @@ QgsAuthConfigUriEdit::QgsAuthConfigUriEdit( QWidget *parent, const QString &data } } -QgsAuthConfigUriEdit::~QgsAuthConfigUriEdit() -{ -} - void QgsAuthConfigUriEdit::setDataSourceUri( const QString &datauri ) { if ( mDisabled ) diff --git a/src/gui/auth/qgsauthconfigselect.h b/src/gui/auth/qgsauthconfigselect.h index 4547b30f66d..dcaebb6a86a 100644 --- a/src/gui/auth/qgsauthconfigselect.h +++ b/src/gui/auth/qgsauthconfigselect.h @@ -21,6 +21,7 @@ #include "ui_qgsauthconfigselect.h" #include "qgsauthconfig.h" +#include "qgis_gui.h" /** \ingroup gui @@ -39,7 +40,6 @@ class GUI_EXPORT QgsAuthConfigSelect : public QWidget, private Ui::QgsAuthConfig * @param dataprovider The key of the calling layer provider, if applicable */ explicit QgsAuthConfigSelect( QWidget *parent = nullptr, const QString &dataprovider = QString() ); - ~QgsAuthConfigSelect(); //! Set the authentication config id for the resource void setConfigId( const QString& authcfg ); @@ -117,7 +117,6 @@ class GUI_EXPORT QgsAuthConfigUriEdit : public QDialog, private Ui::QgsAuthConfi explicit QgsAuthConfigUriEdit( QWidget *parent = nullptr, const QString &datauri = QString(), const QString &dataprovider = QString() ); - ~QgsAuthConfigUriEdit(); //! Set the data source URI to parse void setDataSourceUri( const QString &datauri ); diff --git a/src/gui/auth/qgsautheditorwidgets.cpp b/src/gui/auth/qgsautheditorwidgets.cpp index fc5cec5a959..c17296d85c9 100644 --- a/src/gui/auth/qgsautheditorwidgets.cpp +++ b/src/gui/auth/qgsautheditorwidgets.cpp @@ -50,10 +50,6 @@ QgsAuthMethodPlugins::QgsAuthMethodPlugins( QWidget *parent ) } } -QgsAuthMethodPlugins::~QgsAuthMethodPlugins() -{ -} - void QgsAuthMethodPlugins::setupTable() { tblAuthPlugins->setColumnCount( 3 ); @@ -125,10 +121,6 @@ QgsAuthEditorWidgets::QgsAuthEditorWidgets( QWidget *parent ) } } -QgsAuthEditorWidgets::~QgsAuthEditorWidgets() -{ -} - void QgsAuthEditorWidgets::on_btnCertManager_clicked() { QgsAuthCertManager *dlg = new QgsAuthCertManager( this ); diff --git a/src/gui/auth/qgsautheditorwidgets.h b/src/gui/auth/qgsautheditorwidgets.h index 4d574309e58..4a8fb24bc77 100644 --- a/src/gui/auth/qgsautheditorwidgets.h +++ b/src/gui/auth/qgsautheditorwidgets.h @@ -20,6 +20,7 @@ #include #include "ui_qgsautheditorwidgets.h" #include "ui_qgsauthmethodplugins.h" +#include "qgis_gui.h" /** \ingroup gui * Dialog for viewing available authentication method plugins @@ -36,8 +37,6 @@ class GUI_EXPORT QgsAuthMethodPlugins : public QDialog, private Ui::QgsAuthMetho */ explicit QgsAuthMethodPlugins( QWidget *parent = nullptr ); - ~QgsAuthMethodPlugins(); - private slots: void populateTable(); @@ -64,8 +63,6 @@ class GUI_EXPORT QgsAuthEditorWidgets : public QWidget, private Ui::QgsAuthEdito */ explicit QgsAuthEditorWidgets( QWidget *parent = nullptr ); - ~QgsAuthEditorWidgets(); - private slots: void on_btnCertManager_clicked(); void on_btnAuthPlugins_clicked(); diff --git a/src/gui/auth/qgsauthguiutils.h b/src/gui/auth/qgsauthguiutils.h index 94c2c7d55e0..69e9fd4cc19 100644 --- a/src/gui/auth/qgsauthguiutils.h +++ b/src/gui/auth/qgsauthguiutils.h @@ -18,6 +18,7 @@ #define QGSAUTHGUIUTILS_H #include +#include "qgis_gui.h" class QWidget; class QgsMessageBar; diff --git a/src/gui/auth/qgsauthidentitieseditor.cpp b/src/gui/auth/qgsauthidentitieseditor.cpp index ec65f3c481a..d367701c838 100644 --- a/src/gui/auth/qgsauthidentitieseditor.cpp +++ b/src/gui/auth/qgsauthidentitieseditor.cpp @@ -75,10 +75,6 @@ QgsAuthIdentitiesEditor::QgsAuthIdentitiesEditor( QWidget *parent ) } } -QgsAuthIdentitiesEditor::~QgsAuthIdentitiesEditor() -{ -} - static void setItemBold_( QTreeWidgetItem* item ) { item->setFirstColumnSpanned( true ); diff --git a/src/gui/auth/qgsauthidentitieseditor.h b/src/gui/auth/qgsauthidentitieseditor.h index 135875deefb..5349285f8c6 100644 --- a/src/gui/auth/qgsauthidentitieseditor.h +++ b/src/gui/auth/qgsauthidentitieseditor.h @@ -22,6 +22,7 @@ #include "ui_qgsauthidentitieseditor.h" #include "qgsauthmanager.h" +#include "qgis_gui.h" class QgsMessageBar; @@ -39,7 +40,6 @@ class GUI_EXPORT QgsAuthIdentitiesEditor : public QWidget, private Ui::QgsAuthId * @param parent Parent widget */ explicit QgsAuthIdentitiesEditor( QWidget *parent = nullptr ); - ~QgsAuthIdentitiesEditor(); private slots: void populateIdentitiesView(); diff --git a/src/gui/auth/qgsauthimportcertdialog.cpp b/src/gui/auth/qgsauthimportcertdialog.cpp index 4e162303341..a352e60dcc9 100644 --- a/src/gui/auth/qgsauthimportcertdialog.cpp +++ b/src/gui/auth/qgsauthimportcertdialog.cpp @@ -85,10 +85,6 @@ QgsAuthImportCertDialog::QgsAuthImportCertDialog( QWidget *parent , } } -QgsAuthImportCertDialog::~QgsAuthImportCertDialog() -{ -} - const QList QgsAuthImportCertDialog::certificatesToImport() { if ( mDisabled ) diff --git a/src/gui/auth/qgsauthimportcertdialog.h b/src/gui/auth/qgsauthimportcertdialog.h index 7ebd603d7ac..8982642a9cf 100644 --- a/src/gui/auth/qgsauthimportcertdialog.h +++ b/src/gui/auth/qgsauthimportcertdialog.h @@ -21,6 +21,7 @@ #include "ui_qgsauthimportcertdialog.h" #include +#include "qgis_gui.h" class QPushButton; @@ -56,7 +57,6 @@ class GUI_EXPORT QgsAuthImportCertDialog : public QDialog, private Ui::QgsAuthIm explicit QgsAuthImportCertDialog( QWidget *parent = nullptr, QgsAuthImportCertDialog::CertFilter filter = NoFilter, QgsAuthImportCertDialog::CertInput input = AllInputs ); - ~QgsAuthImportCertDialog(); //! Get list of certificate objects to import const QList certificatesToImport(); diff --git a/src/gui/auth/qgsauthimportidentitydialog.cpp b/src/gui/auth/qgsauthimportidentitydialog.cpp index d99fd7a4f37..1344c0e6c75 100644 --- a/src/gui/auth/qgsauthimportidentitydialog.cpp +++ b/src/gui/auth/qgsauthimportidentitydialog.cpp @@ -78,10 +78,6 @@ QgsAuthImportIdentityDialog::QgsAuthImportIdentityDialog( QgsAuthImportIdentityD } } -QgsAuthImportIdentityDialog::~QgsAuthImportIdentityDialog() -{ -} - QgsAuthImportIdentityDialog::IdentityType QgsAuthImportIdentityDialog::identityType() { if ( mDisabled ) diff --git a/src/gui/auth/qgsauthimportidentitydialog.h b/src/gui/auth/qgsauthimportidentitydialog.h index 5ea363cac45..96a95b606b3 100644 --- a/src/gui/auth/qgsauthimportidentitydialog.h +++ b/src/gui/auth/qgsauthimportidentitydialog.h @@ -24,6 +24,7 @@ #include #include "qgsauthconfig.h" +#include "qgis_gui.h" /** \ingroup gui * Widget for importing an identity certificate/key bundle into the authentication database @@ -61,7 +62,6 @@ class GUI_EXPORT QgsAuthImportIdentityDialog : public QDialog, private Ui::QgsAu */ explicit QgsAuthImportIdentityDialog( QgsAuthImportIdentityDialog::IdentityType identitytype, QWidget *parent = nullptr ); - ~QgsAuthImportIdentityDialog(); //! Get identity type QgsAuthImportIdentityDialog::IdentityType identityType(); diff --git a/src/gui/auth/qgsauthmasterpassresetdialog.cpp b/src/gui/auth/qgsauthmasterpassresetdialog.cpp index 5c1330c35ac..14d3ddd1354 100644 --- a/src/gui/auth/qgsauthmasterpassresetdialog.cpp +++ b/src/gui/auth/qgsauthmasterpassresetdialog.cpp @@ -44,10 +44,6 @@ QgsMasterPasswordResetDialog::QgsMasterPasswordResetDialog( QWidget *parent ) } } -QgsMasterPasswordResetDialog::~QgsMasterPasswordResetDialog() -{ -} - bool QgsMasterPasswordResetDialog::requestMasterPasswordReset( QString *newpass, QString *oldpass, bool *keepbackup ) { if ( !QgsAuthManager::instance()->isDisabled() ) diff --git a/src/gui/auth/qgsauthmasterpassresetdialog.h b/src/gui/auth/qgsauthmasterpassresetdialog.h index 50c9b7e077a..16cb1fff63d 100644 --- a/src/gui/auth/qgsauthmasterpassresetdialog.h +++ b/src/gui/auth/qgsauthmasterpassresetdialog.h @@ -20,6 +20,7 @@ #include #include "ui_qgsauthmasterpassresetdialog.h" +#include "qgis_gui.h" class QLabel; class QVBoxLayout; @@ -37,7 +38,6 @@ class GUI_EXPORT QgsMasterPasswordResetDialog : public QDialog, private Ui::QgsM public: explicit QgsMasterPasswordResetDialog( QWidget *parent = nullptr ); - ~QgsMasterPasswordResetDialog(); bool requestMasterPasswordReset( QString *newpass, QString *oldpass, bool *keepbackup ); diff --git a/src/gui/auth/qgsauthmethodedit.h b/src/gui/auth/qgsauthmethodedit.h index f595f78006c..e41de97700f 100644 --- a/src/gui/auth/qgsauthmethodedit.h +++ b/src/gui/auth/qgsauthmethodedit.h @@ -20,6 +20,7 @@ #include #include "qgis.h" +#include "qgis_gui.h" /** \ingroup gui * Abstract base class for the edit widget of authentication method plugins @@ -64,7 +65,7 @@ class GUI_EXPORT QgsAuthMethodEdit : public QWidget : QWidget( parent ) {} - virtual ~QgsAuthMethodEdit() {} + virtual ~QgsAuthMethodEdit() = default; }; #endif // QGSAUTHMETHODEDIT_H diff --git a/src/gui/auth/qgsauthserverseditor.cpp b/src/gui/auth/qgsauthserverseditor.cpp index 22971af85d5..7099e5e43fc 100644 --- a/src/gui/auth/qgsauthserverseditor.cpp +++ b/src/gui/auth/qgsauthserverseditor.cpp @@ -73,10 +73,6 @@ QgsAuthServersEditor::QgsAuthServersEditor( QWidget *parent ) } } -QgsAuthServersEditor::~QgsAuthServersEditor() -{ -} - static void setItemBold_( QTreeWidgetItem* item ) { item->setFirstColumnSpanned( true ); diff --git a/src/gui/auth/qgsauthserverseditor.h b/src/gui/auth/qgsauthserverseditor.h index 1703fef24e3..f05cee5964e 100644 --- a/src/gui/auth/qgsauthserverseditor.h +++ b/src/gui/auth/qgsauthserverseditor.h @@ -21,6 +21,7 @@ #include "ui_qgsauthserverseditor.h" #include "qgsauthmanager.h" +#include "qgis_gui.h" class QgsMessageBar; @@ -38,7 +39,6 @@ class GUI_EXPORT QgsAuthServersEditor : public QWidget, private Ui::QgsAuthServe * @param parent Parent Widget */ explicit QgsAuthServersEditor( QWidget *parent = nullptr ); - ~QgsAuthServersEditor(); private slots: void populateSslConfigsView(); @@ -65,7 +65,7 @@ class GUI_EXPORT QgsAuthServersEditor : public QWidget, private Ui::QgsAuthServe void authMessageOut( const QString& message, const QString& authtag, QgsAuthManager::MessageLevel level ); protected: - //! Overridden show event of base widget + void showEvent( QShowEvent *e ) override; private: diff --git a/src/gui/auth/qgsauthsslconfigwidget.cpp b/src/gui/auth/qgsauthsslconfigwidget.cpp index 84c45ad0ed6..bf81e89ace0 100644 --- a/src/gui/auth/qgsauthsslconfigwidget.cpp +++ b/src/gui/auth/qgsauthsslconfigwidget.cpp @@ -88,10 +88,6 @@ QgsAuthSslConfigWidget::QgsAuthSslConfigWidget( QWidget *parent, } } -QgsAuthSslConfigWidget::~QgsAuthSslConfigWidget() -{ -} - QGroupBox *QgsAuthSslConfigWidget::certificateGroupBox() { if ( mDisabled ) @@ -621,10 +617,6 @@ QgsAuthSslConfigDialog::QgsAuthSslConfigDialog( QWidget *parent , const QSslCert mSaveButton->setEnabled( mSslConfigWdgt->readyToSave() ); } -QgsAuthSslConfigDialog::~QgsAuthSslConfigDialog() -{ -} - void QgsAuthSslConfigDialog::accept() { mSslConfigWdgt->saveSslCertConfig(); diff --git a/src/gui/auth/qgsauthsslconfigwidget.h b/src/gui/auth/qgsauthsslconfigwidget.h index dfea1c8c60a..8a206eadeff 100644 --- a/src/gui/auth/qgsauthsslconfigwidget.h +++ b/src/gui/auth/qgsauthsslconfigwidget.h @@ -25,6 +25,7 @@ #include #include "qgsauthconfig.h" +#include "qgis_gui.h" class QComboBox; class QGroupBox; @@ -50,7 +51,6 @@ class GUI_EXPORT QgsAuthSslConfigWidget : public QWidget, private Ui::QgsAuthSsl const QSslCertificate &cert = QSslCertificate(), const QString &hostport = QString(), const QList& connectionCAs = QList() ); - ~QgsAuthSslConfigWidget(); //! Access to the certificate's group box widget QGroupBox *certificateGroupBox(); @@ -199,13 +199,11 @@ class GUI_EXPORT QgsAuthSslConfigDialog : public QDialog explicit QgsAuthSslConfigDialog( QWidget *parent = nullptr, const QSslCertificate& cert = QSslCertificate(), const QString &hostport = QString() ); - ~QgsAuthSslConfigDialog(); //! Access the embedded SSL server configuration widget QgsAuthSslConfigWidget *sslCustomConfigWidget() { return mSslConfigWdgt; } public slots: - //! Overridden base dialog accept slot void accept() override; private slots: diff --git a/src/gui/auth/qgsauthsslerrorsdialog.cpp b/src/gui/auth/qgsauthsslerrorsdialog.cpp index 1d1e1c7d2a5..3b107c197ee 100644 --- a/src/gui/auth/qgsauthsslerrorsdialog.cpp +++ b/src/gui/auth/qgsauthsslerrorsdialog.cpp @@ -93,10 +93,6 @@ QgsAuthSslErrorsDialog::QgsAuthSslErrorsDialog( QNetworkReply *reply, populateErrorsList(); } -QgsAuthSslErrorsDialog::~QgsAuthSslErrorsDialog() -{ -} - void QgsAuthSslErrorsDialog::loadUnloadCertificate( bool load ) { grpbxSslErrors->setCollapsed( load ); diff --git a/src/gui/auth/qgsauthsslerrorsdialog.h b/src/gui/auth/qgsauthsslerrorsdialog.h index d36e9541616..35a28ec25b2 100644 --- a/src/gui/auth/qgsauthsslerrorsdialog.h +++ b/src/gui/auth/qgsauthsslerrorsdialog.h @@ -21,6 +21,7 @@ #include #include #include "ui_qgsauthsslerrorsdialog.h" +#include "qgis_gui.h" class QNetworkReply; class QPushButton; @@ -46,8 +47,6 @@ class GUI_EXPORT QgsAuthSslErrorsDialog : public QDialog, private Ui::QgsAuthSsl QWidget *parent = nullptr , const QString &digest = QString(), const QString &hostport = QString() ); - ~QgsAuthSslErrorsDialog(); - private slots: void loadUnloadCertificate( bool load ); diff --git a/src/gui/auth/qgsauthsslimportdialog.cpp b/src/gui/auth/qgsauthsslimportdialog.cpp index 798b839f001..7ca37bc4a0f 100644 --- a/src/gui/auth/qgsauthsslimportdialog.cpp +++ b/src/gui/auth/qgsauthsslimportdialog.cpp @@ -142,10 +142,6 @@ QgsAuthSslImportDialog::QgsAuthSslImportDialog( QWidget *parent ) } } -QgsAuthSslImportDialog::~QgsAuthSslImportDialog() -{ -} - void QgsAuthSslImportDialog::accept() { wdgtSslConfig->saveSslCertConfig(); diff --git a/src/gui/auth/qgsauthsslimportdialog.h b/src/gui/auth/qgsauthsslimportdialog.h index 263ab72f38f..84878f8b036 100644 --- a/src/gui/auth/qgsauthsslimportdialog.h +++ b/src/gui/auth/qgsauthsslimportdialog.h @@ -67,6 +67,7 @@ #include #include #include +#include "qgis_gui.h" class QPushButton; class QSslSocket; @@ -86,10 +87,8 @@ class GUI_EXPORT QgsAuthSslImportDialog : public QDialog, private Ui::QgsAuthSsl * @param parent */ QgsAuthSslImportDialog( QWidget *parent = nullptr ); - ~QgsAuthSslImportDialog(); public slots: - //! Overridden slot of base dialog void accept() override; private slots: diff --git a/src/gui/auth/qgsauthtrustedcasdialog.cpp b/src/gui/auth/qgsauthtrustedcasdialog.cpp index 5ebaee0485c..56471cd5c81 100644 --- a/src/gui/auth/qgsauthtrustedcasdialog.cpp +++ b/src/gui/auth/qgsauthtrustedcasdialog.cpp @@ -70,10 +70,6 @@ QgsAuthTrustedCAsDialog::QgsAuthTrustedCAsDialog( QWidget *parent, } } -QgsAuthTrustedCAsDialog::~QgsAuthTrustedCAsDialog() -{ -} - static void setItemBold_( QTreeWidgetItem* item ) { item->setFirstColumnSpanned( true ); diff --git a/src/gui/auth/qgsauthtrustedcasdialog.h b/src/gui/auth/qgsauthtrustedcasdialog.h index 081c90bb4c6..d9fbb688fb9 100644 --- a/src/gui/auth/qgsauthtrustedcasdialog.h +++ b/src/gui/auth/qgsauthtrustedcasdialog.h @@ -23,6 +23,7 @@ #include #include "qgsauthmanager.h" +#include "qgis_gui.h" class QgsMessageBar; @@ -42,7 +43,6 @@ class GUI_EXPORT QgsAuthTrustedCAsDialog : public QDialog, private Ui::QgsAuthTr */ explicit QgsAuthTrustedCAsDialog( QWidget *parent = nullptr, const QList& trustedCAs = QList() ); - ~QgsAuthTrustedCAsDialog(); private slots: void populateCaCertsView(); @@ -65,7 +65,7 @@ class GUI_EXPORT QgsAuthTrustedCAsDialog : public QDialog, private Ui::QgsAuthTr void authMessageOut( const QString& message, const QString& authtag, QgsAuthManager::MessageLevel level ); protected: - //! Overridden widget show event + void showEvent( QShowEvent *e ) override; private: diff --git a/src/gui/editorwidgets/core/qgseditorconfigwidget.h b/src/gui/editorwidgets/core/qgseditorconfigwidget.h index c6bf97e8b66..b9f206af5aa 100644 --- a/src/gui/editorwidgets/core/qgseditorconfigwidget.h +++ b/src/gui/editorwidgets/core/qgseditorconfigwidget.h @@ -17,6 +17,7 @@ #define QGSEDITORCONFIGWIDGET_H #include +#include "qgis_gui.h" class QgsVectorLayer; @@ -71,11 +72,6 @@ class GUI_EXPORT QgsEditorConfigWidget : public QWidget */ QgsVectorLayer* layer(); - /** - * Destructor - */ - virtual ~QgsEditorConfigWidget() {} - signals: /** Emitted when the configuration of the widget is changed. diff --git a/src/gui/editorwidgets/core/qgseditorwidgetautoconf.cpp b/src/gui/editorwidgets/core/qgseditorwidgetautoconf.cpp index 94892708294..9b4a4a90557 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetautoconf.cpp +++ b/src/gui/editorwidgets/core/qgseditorwidgetautoconf.cpp @@ -96,7 +96,7 @@ QgsEditorWidgetSetup QgsEditorWidgetAutoConf::editorWidgetSetup( const QgsVector { // important check - for provider fields, we CANNOT use auto configured widgets if the field // uses a default value clause - otherwise the widget will obliterate the default value clause - // (eg by trying to convert it to a number/date/etc). Instead we have to use a text edit + // (e.g., by trying to convert it to a number/date/etc). Instead we have to use a text edit // widget so that the clause remains intact int providerOrigin = vl->fields().fieldOriginIndex( fieldIndex ); if ( !vl->dataProvider()->defaultValueClause( providerOrigin ).isEmpty() ) diff --git a/src/gui/editorwidgets/core/qgseditorwidgetautoconf.h b/src/gui/editorwidgets/core/qgseditorwidgetautoconf.h index 8d6dfb0e9a9..7a8b616a249 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetautoconf.h +++ b/src/gui/editorwidgets/core/qgseditorwidgetautoconf.h @@ -17,6 +17,7 @@ #include #include +#include "qgis_gui.h" class QgsVectorLayer; class QgsEditorWidgetSetup; @@ -88,4 +89,4 @@ class GUI_EXPORT QgsEditorWidgetAutoConf }; ///@endcond -#endif // QGSEDITORWIDGETAUTOCONF_H \ No newline at end of file +#endif // QGSEDITORWIDGETAUTOCONF_H diff --git a/src/gui/editorwidgets/core/qgseditorwidgetfactory.cpp b/src/gui/editorwidgets/core/qgseditorwidgetfactory.cpp index 0309278fc1b..406d2073a39 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetfactory.cpp +++ b/src/gui/editorwidgets/core/qgseditorwidgetfactory.cpp @@ -28,10 +28,6 @@ QgsEditorWidgetFactory::QgsEditorWidgetFactory( const QString& name ) { } -QgsEditorWidgetFactory::~QgsEditorWidgetFactory() -{ -} - /** * By default a simple QgsFilterLineEdit is returned as search widget. * Override in own factory to get something different than the default. diff --git a/src/gui/editorwidgets/core/qgseditorwidgetfactory.h b/src/gui/editorwidgets/core/qgseditorwidgetfactory.h index 9046a000f33..669763a2cf9 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetfactory.h +++ b/src/gui/editorwidgets/core/qgseditorwidgetfactory.h @@ -20,6 +20,7 @@ #include #include #include +#include "qgis_gui.h" class QgsEditorConfigWidget; class QgsEditorWidgetWrapper; @@ -47,7 +48,7 @@ class GUI_EXPORT QgsEditorWidgetFactory */ QgsEditorWidgetFactory( const QString& name ); - virtual ~QgsEditorWidgetFactory(); + virtual ~QgsEditorWidgetFactory() = default; /** * Override this in your implementation. diff --git a/src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp b/src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp index df55beab170..af644c244e2 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp +++ b/src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp @@ -193,12 +193,12 @@ bool QgsEditorWidgetRegistry::registerWidget( const QString& widgetId, QgsEditor { if ( !widgetFactory ) { - QgsMessageLog::instance()->logMessage( QStringLiteral( "QgsEditorWidgetRegistry: Factory not valid." ) ); + QgsApplication::messageLog()->logMessage( QStringLiteral( "QgsEditorWidgetRegistry: Factory not valid." ) ); return false; } else if ( mWidgetFactories.contains( widgetId ) ) { - QgsMessageLog::instance()->logMessage( QStringLiteral( "QgsEditorWidgetRegistry: Factory with id %1 already registered." ).arg( widgetId ) ); + QgsApplication::messageLog()->logMessage( QStringLiteral( "QgsEditorWidgetRegistry: Factory with id %1 already registered." ).arg( widgetId ) ); return false; } else diff --git a/src/gui/editorwidgets/core/qgseditorwidgetregistry.h b/src/gui/editorwidgets/core/qgseditorwidgetregistry.h index ddccffd6c31..3f8936587ef 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetregistry.h +++ b/src/gui/editorwidgets/core/qgseditorwidgetregistry.h @@ -21,6 +21,7 @@ #include "qgseditorwidgetfactory.h" #include "qgsattributeeditorcontext.h" #include "qgseditorwidgetautoconf.h" +#include "qgis_gui.h" class QgsMapLayer; class QDomNode; diff --git a/src/gui/editorwidgets/core/qgseditorwidgetwrapper.h b/src/gui/editorwidgets/core/qgseditorwidgetwrapper.h index d9655eb8ae3..dd433921ec1 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetwrapper.h +++ b/src/gui/editorwidgets/core/qgseditorwidgetwrapper.h @@ -24,6 +24,7 @@ class QgsVectorLayer; class QgsField; #include "qgswidgetwrapper.h" +#include "qgis_gui.h" /** \ingroup gui * Manages an editor widget diff --git a/src/gui/editorwidgets/core/qgssearchwidgetwrapper.cpp b/src/gui/editorwidgets/core/qgssearchwidgetwrapper.cpp index 774dee5da60..5b272c5ef96 100644 --- a/src/gui/editorwidgets/core/qgssearchwidgetwrapper.cpp +++ b/src/gui/editorwidgets/core/qgssearchwidgetwrapper.cpp @@ -30,10 +30,10 @@ QList QgsSearchWidgetWrapper::exclusiveFilte << GreaterThanOrEqualTo << LessThanOrEqualTo << Between + << IsNotBetween << Contains << DoesNotContain << IsNull - << IsNotBetween << IsNotNull; } @@ -50,7 +50,7 @@ QString QgsSearchWidgetWrapper::toString( QgsSearchWidgetWrapper::FilterFlag fla case EqualTo: return QObject::tr( "Equal to (=)" ); case NotEqualTo: - return QObject::tr( "Not equal to" ); + return QObject::tr( "Not equal to (!=)" ); case GreaterThan: return QObject::tr( "Greater than (>)" ); case LessThan: @@ -61,6 +61,8 @@ QString QgsSearchWidgetWrapper::toString( QgsSearchWidgetWrapper::FilterFlag fla return QObject::tr( "Less than or equal to (<=)" ); case Between: return QObject::tr( "Between (inclusive)" ); + case IsNotBetween: + return QObject::tr( "Not between (inclusive)" ); case CaseInsensitive: return QObject::tr( "Case insensitive" ); case Contains: @@ -71,8 +73,6 @@ QString QgsSearchWidgetWrapper::toString( QgsSearchWidgetWrapper::FilterFlag fla return QObject::tr( "Is missing (null)" ); case IsNotNull: return QObject::tr( "Is not missing (not null)" ); - case IsNotBetween: - return QObject::tr( "Is not between (inclusive)" ); } return QString(); diff --git a/src/gui/editorwidgets/core/qgssearchwidgetwrapper.h b/src/gui/editorwidgets/core/qgssearchwidgetwrapper.h index 16a8f8ca84f..912bafbca83 100644 --- a/src/gui/editorwidgets/core/qgssearchwidgetwrapper.h +++ b/src/gui/editorwidgets/core/qgssearchwidgetwrapper.h @@ -25,6 +25,7 @@ class QgsField; #include "qgsattributeeditorcontext.h" #include "qgswidgetwrapper.h" +#include "qgis_gui.h" /** \ingroup gui * Manages an editor widget @@ -61,13 +62,13 @@ class GUI_EXPORT QgsSearchWidgetWrapper : public QgsWidgetWrapper }; Q_DECLARE_FLAGS( FilterFlags, FilterFlag ) - /** Returns a list of exclusive filter flags, which cannot be combined with other flags (eg EqualTo/NotEqualTo) + /** Returns a list of exclusive filter flags, which cannot be combined with other flags (e.g., EqualTo/NotEqualTo) * @note added in QGIS 2.16 * @see nonExclusiveFilterFlags() */ static QList< FilterFlag > exclusiveFilterFlags(); - /** Returns a list of non-exclusive filter flags, which can be combined with other flags (eg CaseInsensitive) + /** Returns a list of non-exclusive filter flags, which can be combined with other flags (e.g., CaseInsensitive) * @note added in QGIS 2.16 * @see exclusiveFilterFlags() */ diff --git a/src/gui/editorwidgets/core/qgswidgetwrapper.h b/src/gui/editorwidgets/core/qgswidgetwrapper.h index 8f506d91333..be63d101aa0 100644 --- a/src/gui/editorwidgets/core/qgswidgetwrapper.h +++ b/src/gui/editorwidgets/core/qgswidgetwrapper.h @@ -23,6 +23,7 @@ class QgsVectorLayer; #include "qgsattributeeditorcontext.h" +#include "qgis_gui.h" /** \ingroup gui * Manages an editor widget diff --git a/src/gui/editorwidgets/qgscheckboxconfigdlg.h b/src/gui/editorwidgets/qgscheckboxconfigdlg.h index 901470d1cec..dcf7fa50b66 100644 --- a/src/gui/editorwidgets/qgscheckboxconfigdlg.h +++ b/src/gui/editorwidgets/qgscheckboxconfigdlg.h @@ -19,6 +19,7 @@ #include "ui_qgscheckboxconfigdlgbase.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsCheckBoxConfigDlg diff --git a/src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.h b/src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.h index 311c9021f8a..83a486ec531 100644 --- a/src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_gui.h" class QCheckBox; class QgsCheckboxWidgetFactory; diff --git a/src/gui/editorwidgets/qgscheckboxwidgetfactory.h b/src/gui/editorwidgets/qgscheckboxwidgetfactory.h index bf701b4fb31..141eee09182 100644 --- a/src/gui/editorwidgets/qgscheckboxwidgetfactory.h +++ b/src/gui/editorwidgets/qgscheckboxwidgetfactory.h @@ -17,6 +17,7 @@ #define QGSCHECKBOXWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsCheckboxWidgetFactory diff --git a/src/gui/editorwidgets/qgscheckboxwidgetwrapper.h b/src/gui/editorwidgets/qgscheckboxwidgetwrapper.h index f64c1276db1..745b08d1699 100644 --- a/src/gui/editorwidgets/qgscheckboxwidgetwrapper.h +++ b/src/gui/editorwidgets/qgscheckboxwidgetwrapper.h @@ -20,6 +20,7 @@ #include #include +#include "qgis_gui.h" /** \ingroup gui * Wraps a checkbox widget. This will offer a checkbox to represent boolean values. diff --git a/src/gui/editorwidgets/qgsclassificationwidgetwrapper.h b/src/gui/editorwidgets/qgsclassificationwidgetwrapper.h index 62b431bbe01..e23e63fbab0 100644 --- a/src/gui/editorwidgets/qgsclassificationwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsclassificationwidgetwrapper.h @@ -19,6 +19,7 @@ #include "qgseditorwidgetwrapper.h" #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsClassificationWidgetWrapper diff --git a/src/gui/editorwidgets/qgsclassificationwidgetwrapperfactory.h b/src/gui/editorwidgets/qgsclassificationwidgetwrapperfactory.h index 6977da27e90..d71e90b1dfa 100644 --- a/src/gui/editorwidgets/qgsclassificationwidgetwrapperfactory.h +++ b/src/gui/editorwidgets/qgsclassificationwidgetwrapperfactory.h @@ -17,6 +17,7 @@ #define QGSCLASSIFICATIONWIDGETWRAPPERFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsClassificationWidgetWrapperFactory diff --git a/src/gui/editorwidgets/qgscolorwidgetfactory.h b/src/gui/editorwidgets/qgscolorwidgetfactory.h index 4f1d0b7b534..fb5c11a37a0 100644 --- a/src/gui/editorwidgets/qgscolorwidgetfactory.h +++ b/src/gui/editorwidgets/qgscolorwidgetfactory.h @@ -17,6 +17,7 @@ #define QGSCOLORWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsColorWidgetFactory diff --git a/src/gui/editorwidgets/qgscolorwidgetwrapper.h b/src/gui/editorwidgets/qgscolorwidgetwrapper.h index 5a2f423f05d..e6e38384efe 100644 --- a/src/gui/editorwidgets/qgscolorwidgetwrapper.h +++ b/src/gui/editorwidgets/qgscolorwidgetwrapper.h @@ -17,6 +17,7 @@ #define QGSCOLORWIDGETWRAPPER_H #include "qgseditorwidgetwrapper.h" +#include "qgis_gui.h" class QgsColorButton; diff --git a/src/gui/editorwidgets/qgsdatetimeedit.h b/src/gui/editorwidgets/qgsdatetimeedit.h index dc850dc19e1..b9eae70b188 100644 --- a/src/gui/editorwidgets/qgsdatetimeedit.h +++ b/src/gui/editorwidgets/qgsdatetimeedit.h @@ -17,6 +17,7 @@ #define QGSDATETIMEEDIT_H #include +#include "qgis_gui.h" class QToolButton; class QLineEdit; @@ -32,7 +33,7 @@ class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit public: explicit QgsDateTimeEdit( QWidget *parent = nullptr ); - //! determines if the widget allows setting null date/time. + //! Determines if the widget allows setting null date/time. void setAllowNull( bool allowNull ); bool allowNull() const {return mAllowNull;} @@ -48,8 +49,10 @@ class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit */ QDateTime dateTime() const; - //! Set the current date as NULL - //! @note if the widget is not configured to accept NULL dates, this will have no effect + /** + * Set the current date as NULL + * @note if the widget is not configured to accept NULL dates, this will have no effect + */ virtual void clear() override; /** Resets the widget to show no value (ie, an "unknown" state). diff --git a/src/gui/editorwidgets/qgsdatetimeeditconfig.h b/src/gui/editorwidgets/qgsdatetimeeditconfig.h index 00584dc45ec..671adafc1d9 100644 --- a/src/gui/editorwidgets/qgsdatetimeeditconfig.h +++ b/src/gui/editorwidgets/qgsdatetimeeditconfig.h @@ -18,6 +18,7 @@ #include "qgseditorconfigwidget.h" #include "ui_qgsdatetimeeditconfig.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsDateTimeEditConfig diff --git a/src/gui/editorwidgets/qgsdatetimeeditfactory.h b/src/gui/editorwidgets/qgsdatetimeeditfactory.h index 3faea9caa6b..f84f54aee28 100644 --- a/src/gui/editorwidgets/qgsdatetimeeditfactory.h +++ b/src/gui/editorwidgets/qgsdatetimeeditfactory.h @@ -17,6 +17,7 @@ #define QGSDATETIMEEDITFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsDateTimeEditFactory diff --git a/src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp b/src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp index b3068da3a98..37746c49997 100644 --- a/src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp +++ b/src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp @@ -84,9 +84,9 @@ void QgsDateTimeEditWrapper::initWidget( QWidget *editor ) } else { - QgsMessageLog::instance()->logMessage( tr( "The usual date/time widget QDateTimeEdit cannot be configured to allow NULL values. " - "For that the QGIS custom widget QgsDateTimeEdit needs to be used." ), - QStringLiteral( "field widgets" ) ); + QgsApplication::messageLog()->logMessage( tr( "The usual date/time widget QDateTimeEdit cannot be configured to allow NULL values. " + "For that the QGIS custom widget QgsDateTimeEdit needs to be used." ), + QStringLiteral( "field widgets" ) ); } if ( mQgsDateTimeEdit ) diff --git a/src/gui/editorwidgets/qgsdatetimeeditwrapper.h b/src/gui/editorwidgets/qgsdatetimeeditwrapper.h index 14f27d3a401..57f171c7789 100644 --- a/src/gui/editorwidgets/qgsdatetimeeditwrapper.h +++ b/src/gui/editorwidgets/qgsdatetimeeditwrapper.h @@ -19,6 +19,7 @@ #include #include "qgseditorwidgetwrapper.h" +#include "qgis_gui.h" class QgsDateTimeEdit; diff --git a/src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.h b/src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.h index 0d9080e875b..4f4288254fa 100644 --- a/src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_gui.h" class QgsDateTimeEditFactory; class QgsDateTimeEdit; diff --git a/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp b/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp index 8ceb19221e9..91596271ea4 100644 --- a/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp +++ b/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp @@ -18,6 +18,7 @@ #include "qgsfields.h" #include "qgsfieldvalidator.h" #include "qgsexpression.h" +#include "qgsfieldvalueslineedit.h" #include #include @@ -100,10 +101,6 @@ QgsSearchWidgetWrapper::FilterFlags QgsDefaultSearchWidgetWrapper::supportedFlag case QVariant::Double: case QVariant::LongLong: case QVariant::ULongLong: - //numeric - flags |= GreaterThan | LessThan | GreaterThanOrEqualTo | LessThanOrEqualTo; - break; - case QVariant::Date: case QVariant::DateTime: case QVariant::Time: @@ -255,10 +252,20 @@ void QgsDefaultSearchWidgetWrapper::initWidget( QWidget* widget ) mContainer->setLayout( new QHBoxLayout() ); mContainer->layout()->setMargin( 0 ); mContainer->layout()->setContentsMargins( 0, 0, 0, 0 ); - mLineEdit = new QgsFilterLineEdit(); + QVariant::Type fldType = layer()->fields().at( mFieldIdx ).type(); + + if ( fldType == QVariant::String ) + { + mLineEdit = new QgsFieldValuesLineEdit(); + static_cast< QgsFieldValuesLineEdit* >( mLineEdit )->setLayer( layer() ); + static_cast< QgsFieldValuesLineEdit* >( mLineEdit )->setAttributeIndex( mFieldIdx ); + } + else + { + mLineEdit = new QgsFilterLineEdit(); + } mContainer->layout()->addWidget( mLineEdit ); - QVariant::Type fldType = layer()->fields().at( mFieldIdx ).type(); if ( fldType == QVariant::String ) { mCheckbox = new QCheckBox( QStringLiteral( "Case sensitive" ) ); diff --git a/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.h b/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.h index 1d8486bbd39..b1a48d027b4 100644 --- a/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.h @@ -17,9 +17,10 @@ #define QGSDEFAULTSEARCHWIDGETWRAPPER_H #include "qgssearchwidgetwrapper.h" -#include +#include "qgsfilterlineedit.h" #include +#include "qgis_gui.h" /** \ingroup gui * Wraps a search widget. Default form is just a QgsLineFilterEdit diff --git a/src/gui/editorwidgets/qgsdoublespinbox.h b/src/gui/editorwidgets/qgsdoublespinbox.h index 6fc55dd27c7..e38a5bb65cc 100644 --- a/src/gui/editorwidgets/qgsdoublespinbox.h +++ b/src/gui/editorwidgets/qgsdoublespinbox.h @@ -17,6 +17,7 @@ #define QGSDOUBLESPINBOX_H #include +#include "qgis_gui.h" class QgsSpinBoxLineEdit; diff --git a/src/gui/editorwidgets/qgsdummyconfigdlg.h b/src/gui/editorwidgets/qgsdummyconfigdlg.h index acdbcb5f73e..2a2aefcb6a4 100644 --- a/src/gui/editorwidgets/qgsdummyconfigdlg.h +++ b/src/gui/editorwidgets/qgsdummyconfigdlg.h @@ -18,6 +18,7 @@ #include "ui_qgsdummyconfigdlgbase.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui diff --git a/src/gui/editorwidgets/qgsenumerationwidgetfactory.h b/src/gui/editorwidgets/qgsenumerationwidgetfactory.h index cf158b4025e..627eb5b9675 100644 --- a/src/gui/editorwidgets/qgsenumerationwidgetfactory.h +++ b/src/gui/editorwidgets/qgsenumerationwidgetfactory.h @@ -17,6 +17,7 @@ #define QGSENUMERATIONWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsEnumerationWidgetFactory diff --git a/src/gui/editorwidgets/qgsenumerationwidgetwrapper.h b/src/gui/editorwidgets/qgsenumerationwidgetwrapper.h index 23052321647..721ba536fb4 100644 --- a/src/gui/editorwidgets/qgsenumerationwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsenumerationwidgetwrapper.h @@ -19,6 +19,7 @@ #include "qgseditorwidgetwrapper.h" #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsEnumerationWidgetWrapper diff --git a/src/gui/editorwidgets/qgsexternalresourceconfigdlg.h b/src/gui/editorwidgets/qgsexternalresourceconfigdlg.h index fddb5f6b2fc..03605e714e3 100644 --- a/src/gui/editorwidgets/qgsexternalresourceconfigdlg.h +++ b/src/gui/editorwidgets/qgsexternalresourceconfigdlg.h @@ -19,6 +19,7 @@ #include "ui_qgsexternalresourceconfigdlg.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsExternalResourceConfigDlg diff --git a/src/gui/editorwidgets/qgsexternalresourcewidgetfactory.h b/src/gui/editorwidgets/qgsexternalresourcewidgetfactory.h index a069eaa1b63..9572aa665d1 100644 --- a/src/gui/editorwidgets/qgsexternalresourcewidgetfactory.h +++ b/src/gui/editorwidgets/qgsexternalresourcewidgetfactory.h @@ -18,6 +18,7 @@ #define QGSEXTERNALRESOURCEWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui diff --git a/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.h b/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.h index 0ba07a328dc..50b94d28342 100644 --- a/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.h +++ b/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.h @@ -22,6 +22,7 @@ class QLabel; class QLineEdit; #include "qgseditorwidgetwrapper.h" +#include "qgis_gui.h" diff --git a/src/gui/editorwidgets/qgsfilenamewidgetfactory.h b/src/gui/editorwidgets/qgsfilenamewidgetfactory.h index 3a92ebdbd16..fcc193074a9 100644 --- a/src/gui/editorwidgets/qgsfilenamewidgetfactory.h +++ b/src/gui/editorwidgets/qgsfilenamewidgetfactory.h @@ -17,6 +17,7 @@ #define QGSFILENAMEWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsFileNameWidgetFactory diff --git a/src/gui/editorwidgets/qgsfilenamewidgetwrapper.h b/src/gui/editorwidgets/qgsfilenamewidgetwrapper.h index f5d59b5ae66..4972bb4cd30 100644 --- a/src/gui/editorwidgets/qgsfilenamewidgetwrapper.h +++ b/src/gui/editorwidgets/qgsfilenamewidgetwrapper.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_gui.h" /** \ingroup gui diff --git a/src/gui/editorwidgets/qgshiddenwidgetfactory.h b/src/gui/editorwidgets/qgshiddenwidgetfactory.h index 325460f26d1..308d159681b 100644 --- a/src/gui/editorwidgets/qgshiddenwidgetfactory.h +++ b/src/gui/editorwidgets/qgshiddenwidgetfactory.h @@ -17,6 +17,7 @@ #define QGSHIDDENWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsHiddenWidgetFactory diff --git a/src/gui/editorwidgets/qgshiddenwidgetwrapper.h b/src/gui/editorwidgets/qgshiddenwidgetwrapper.h index f283cce8e5b..45dfa609859 100644 --- a/src/gui/editorwidgets/qgshiddenwidgetwrapper.h +++ b/src/gui/editorwidgets/qgshiddenwidgetwrapper.h @@ -17,6 +17,7 @@ #define QGSHIDDENWIDGETWRAPPER_H #include "qgseditorwidgetwrapper.h" +#include "qgis_gui.h" /** \ingroup gui * Wraps a hidden widget. Fields with this widget type will not be visible. diff --git a/src/gui/editorwidgets/qgskeyvaluewidgetfactory.h b/src/gui/editorwidgets/qgskeyvaluewidgetfactory.h index 8fa52f7a2cf..295284170f6 100644 --- a/src/gui/editorwidgets/qgskeyvaluewidgetfactory.h +++ b/src/gui/editorwidgets/qgskeyvaluewidgetfactory.h @@ -17,6 +17,7 @@ #define QGSKEYVALUEEDITFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** @ingroup gui * Factory for widgets for editing a QVariantMap diff --git a/src/gui/editorwidgets/qgskeyvaluewidgetwrapper.h b/src/gui/editorwidgets/qgskeyvaluewidgetwrapper.h index c2892f75d55..c99fc44d7d6 100644 --- a/src/gui/editorwidgets/qgskeyvaluewidgetwrapper.h +++ b/src/gui/editorwidgets/qgskeyvaluewidgetwrapper.h @@ -17,6 +17,7 @@ #define QGSKEYVALUEWIDGETWRAPPER_H #include "qgseditorwidgetwrapper.h" +#include "qgis_gui.h" class QgsKeyValueWidget; diff --git a/src/gui/editorwidgets/qgslistwidgetfactory.h b/src/gui/editorwidgets/qgslistwidgetfactory.h index 33b3d7f7004..f09f33eae23 100644 --- a/src/gui/editorwidgets/qgslistwidgetfactory.h +++ b/src/gui/editorwidgets/qgslistwidgetfactory.h @@ -17,6 +17,7 @@ #define QGSLISTWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** @ingroup gui * Factory for widgets for editing a QVariantList or a QStringList diff --git a/src/gui/editorwidgets/qgslistwidgetwrapper.h b/src/gui/editorwidgets/qgslistwidgetwrapper.h index 132b1191ee2..d9c31a02587 100644 --- a/src/gui/editorwidgets/qgslistwidgetwrapper.h +++ b/src/gui/editorwidgets/qgslistwidgetwrapper.h @@ -17,6 +17,7 @@ #define QGSLISTWIDGETWRAPPER_H #include "qgseditorwidgetwrapper.h" +#include "qgis_gui.h" class QgsListWidget; diff --git a/src/gui/editorwidgets/qgsmultiedittoolbutton.h b/src/gui/editorwidgets/qgsmultiedittoolbutton.h index c8113985acc..e229a60753a 100644 --- a/src/gui/editorwidgets/qgsmultiedittoolbutton.h +++ b/src/gui/editorwidgets/qgsmultiedittoolbutton.h @@ -18,6 +18,7 @@ #include "qgsfields.h" #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsMultiEditToolButton diff --git a/src/gui/editorwidgets/qgsphotoconfigdlg.h b/src/gui/editorwidgets/qgsphotoconfigdlg.h index 6c29289594c..5ff5cc47172 100644 --- a/src/gui/editorwidgets/qgsphotoconfigdlg.h +++ b/src/gui/editorwidgets/qgsphotoconfigdlg.h @@ -19,6 +19,7 @@ #include "ui_qgsphotoconfigdlgbase.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsPhotoConfigDlg diff --git a/src/gui/editorwidgets/qgsphotowidgetfactory.h b/src/gui/editorwidgets/qgsphotowidgetfactory.h index c0c4760004b..9f774c2a1de 100644 --- a/src/gui/editorwidgets/qgsphotowidgetfactory.h +++ b/src/gui/editorwidgets/qgsphotowidgetfactory.h @@ -17,6 +17,7 @@ #define QGSPHOTOWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsPhotoWidgetFactory diff --git a/src/gui/editorwidgets/qgsphotowidgetwrapper.h b/src/gui/editorwidgets/qgsphotowidgetwrapper.h index 037e460ef1f..4f895659abf 100644 --- a/src/gui/editorwidgets/qgsphotowidgetwrapper.h +++ b/src/gui/editorwidgets/qgsphotowidgetwrapper.h @@ -24,6 +24,7 @@ #ifdef WITH_QTWEBKIT #include +#include "qgis_gui.h" #endif class QgsPixmapLabel; diff --git a/src/gui/editorwidgets/qgsrangeconfigdlg.h b/src/gui/editorwidgets/qgsrangeconfigdlg.h index 939f3b62a96..cef71008a5b 100644 --- a/src/gui/editorwidgets/qgsrangeconfigdlg.h +++ b/src/gui/editorwidgets/qgsrangeconfigdlg.h @@ -18,6 +18,7 @@ #include "ui_qgsrangeconfigdlgbase.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsRangeConfigDlg diff --git a/src/gui/editorwidgets/qgsrangewidgetfactory.h b/src/gui/editorwidgets/qgsrangewidgetfactory.h index 7262e813698..b29ddd2aaa4 100644 --- a/src/gui/editorwidgets/qgsrangewidgetfactory.h +++ b/src/gui/editorwidgets/qgsrangewidgetfactory.h @@ -17,6 +17,7 @@ #define QGSRANGEWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsRangeWidgetFactory diff --git a/src/gui/editorwidgets/qgsrangewidgetwrapper.h b/src/gui/editorwidgets/qgsrangewidgetwrapper.h index 42971c2bc72..ec7474bb829 100644 --- a/src/gui/editorwidgets/qgsrangewidgetwrapper.h +++ b/src/gui/editorwidgets/qgsrangewidgetwrapper.h @@ -20,6 +20,7 @@ #include #include +#include "qgis_gui.h" class QAbstractSlider; class QSlider; diff --git a/src/gui/editorwidgets/qgsrelationreferenceconfigdlg.h b/src/gui/editorwidgets/qgsrelationreferenceconfigdlg.h index 661a0023e77..a3a95e66a18 100644 --- a/src/gui/editorwidgets/qgsrelationreferenceconfigdlg.h +++ b/src/gui/editorwidgets/qgsrelationreferenceconfigdlg.h @@ -20,6 +20,7 @@ #include "ui_qgsrelationreferenceconfigdlgbase.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsRelationReferenceConfigDlg diff --git a/src/gui/editorwidgets/qgsrelationreferencefactory.h b/src/gui/editorwidgets/qgsrelationreferencefactory.h index 720fc54dd8a..1af7a29b2f1 100644 --- a/src/gui/editorwidgets/qgsrelationreferencefactory.h +++ b/src/gui/editorwidgets/qgsrelationreferencefactory.h @@ -18,6 +18,7 @@ #include "qgsattributeeditorcontext.h" #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" class QgsMapCanvas; class QgsMessageBar; diff --git a/src/gui/editorwidgets/qgsrelationreferencesearchwidgetwrapper.h b/src/gui/editorwidgets/qgsrelationreferencesearchwidgetwrapper.h index 9299e082e61..454d9ecc9ca 100644 --- a/src/gui/editorwidgets/qgsrelationreferencesearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsrelationreferencesearchwidgetwrapper.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_gui.h" class QgsRelationReferenceWidgetFactory; class QgsMapCanvas; diff --git a/src/gui/editorwidgets/qgsrelationreferencewidget.cpp b/src/gui/editorwidgets/qgsrelationreferencewidget.cpp index c83c55c1793..558e2464228 100644 --- a/src/gui/editorwidgets/qgsrelationreferencewidget.cpp +++ b/src/gui/editorwidgets/qgsrelationreferencewidget.cpp @@ -269,10 +269,7 @@ void QgsRelationReferenceWidget::setForeignKey( const QVariant& value ) if ( mReadOnlySelector ) { QgsExpression expr( mReferencedLayer->displayExpression() ); - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mReferencedLayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mReferencedLayer ) ); context.setFeature( mFeature ); QString title = expr.evaluate( &context ).toString(); if ( expr.hasEvalError() ) @@ -742,10 +739,7 @@ void QgsRelationReferenceWidget::featureIdentified( const QgsFeature& feature ) if ( mReadOnlySelector ) { QgsExpression expr( mReferencedLayer->displayExpression() ); - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mReferencedLayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mReferencedLayer ) ); context.setFeature( feature ); QString title = expr.evaluate( &context ).toString(); if ( expr.hasEvalError() ) diff --git a/src/gui/editorwidgets/qgsrelationreferencewidget.h b/src/gui/editorwidgets/qgsrelationreferencewidget.h index 2f713aaab43..abf9c388d79 100644 --- a/src/gui/editorwidgets/qgsrelationreferencewidget.h +++ b/src/gui/editorwidgets/qgsrelationreferencewidget.h @@ -24,6 +24,7 @@ #include #include #include +#include "qgis_gui.h" class QgsAttributeForm; class QgsVectorLayerTools; diff --git a/src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.h b/src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.h index c192d56765d..7f2ebd3bfd6 100644 --- a/src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.h +++ b/src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.h @@ -17,6 +17,7 @@ #define QGSRELATIONREFERENCEWIDGETWRAPPER_H #include "qgseditorwidgetwrapper.h" +#include "qgis_gui.h" class QgsRelationReferenceWidget; class QgsMapCanvas; diff --git a/src/gui/editorwidgets/qgsrelationwidgetwrapper.h b/src/gui/editorwidgets/qgsrelationwidgetwrapper.h index 6ecbcdbf76a..0d8e578ded2 100644 --- a/src/gui/editorwidgets/qgsrelationwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsrelationwidgetwrapper.h @@ -17,6 +17,7 @@ #define QGSRELATIONWIDGETWRAPPER_H #include "qgswidgetwrapper.h" +#include "qgis_gui.h" class QgsRelationEditorWidget; diff --git a/src/gui/editorwidgets/qgssearchwidgettoolbutton.h b/src/gui/editorwidgets/qgssearchwidgettoolbutton.h index a43386548cc..870961b3f10 100644 --- a/src/gui/editorwidgets/qgssearchwidgettoolbutton.h +++ b/src/gui/editorwidgets/qgssearchwidgettoolbutton.h @@ -18,6 +18,7 @@ #include "editorwidgets/core/qgssearchwidgetwrapper.h" #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsSearchWidgetToolButton diff --git a/src/gui/editorwidgets/qgsspinbox.h b/src/gui/editorwidgets/qgsspinbox.h index d0bff10bd32..f5254b5b80f 100644 --- a/src/gui/editorwidgets/qgsspinbox.h +++ b/src/gui/editorwidgets/qgsspinbox.h @@ -17,6 +17,7 @@ #define QGSSPINBOX_H #include +#include "qgis_gui.h" class QgsSpinBoxLineEdit; diff --git a/src/gui/editorwidgets/qgstexteditconfigdlg.h b/src/gui/editorwidgets/qgstexteditconfigdlg.h index 5823d0d2789..df210a7ddcf 100644 --- a/src/gui/editorwidgets/qgstexteditconfigdlg.h +++ b/src/gui/editorwidgets/qgstexteditconfigdlg.h @@ -19,6 +19,7 @@ #include "ui_qgstexteditconfigdlg.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsTextEditConfigDlg diff --git a/src/gui/editorwidgets/qgstexteditsearchwidgetwrapper.h b/src/gui/editorwidgets/qgstexteditsearchwidgetwrapper.h index ff7366be30e..6fe6e13c85e 100644 --- a/src/gui/editorwidgets/qgstexteditsearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgstexteditsearchwidgetwrapper.h @@ -17,6 +17,7 @@ #define QGSTEXTEDITSEARCHWIDGETWRAPPER_H #include "qgsdefaultsearchwidgetwrapper.h" +#include "qgis_gui.h" class QgsTextEditWidgetFactory; diff --git a/src/gui/editorwidgets/qgstexteditwidgetfactory.h b/src/gui/editorwidgets/qgstexteditwidgetfactory.h index 1d7d75bf8e0..cfe1b699967 100644 --- a/src/gui/editorwidgets/qgstexteditwidgetfactory.h +++ b/src/gui/editorwidgets/qgstexteditwidgetfactory.h @@ -17,6 +17,7 @@ #define QGSTEXTEDITWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsTextEditWidgetFactory diff --git a/src/gui/editorwidgets/qgstexteditwrapper.cpp b/src/gui/editorwidgets/qgstexteditwrapper.cpp index dea2534de38..c6dea886c62 100644 --- a/src/gui/editorwidgets/qgstexteditwrapper.cpp +++ b/src/gui/editorwidgets/qgstexteditwrapper.cpp @@ -158,7 +158,7 @@ void QgsTextEditWrapper::showIndeterminateState() { mLineEdit->blockSignals( true ); // for interdeminate state we need to clear the placeholder text - we want an empty line edit, not - // one showing the default value (eg "NULL") + // one showing the default value (e.g., "NULL") mLineEdit->setPlaceholderText( QString() ); } diff --git a/src/gui/editorwidgets/qgstexteditwrapper.h b/src/gui/editorwidgets/qgstexteditwrapper.h index f7a388915af..e7ce9ba0335 100644 --- a/src/gui/editorwidgets/qgstexteditwrapper.h +++ b/src/gui/editorwidgets/qgstexteditwrapper.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_gui.h" /** \ingroup gui * Wraps a text widget. Users will be able to modify text with this widget type. diff --git a/src/gui/editorwidgets/qgsuniquevaluesconfigdlg.h b/src/gui/editorwidgets/qgsuniquevaluesconfigdlg.h index e996b8abd55..1048dedb7a3 100644 --- a/src/gui/editorwidgets/qgsuniquevaluesconfigdlg.h +++ b/src/gui/editorwidgets/qgsuniquevaluesconfigdlg.h @@ -19,6 +19,7 @@ #include "ui_qgsuniquevaluesconfigdlgbase.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsUniqueValuesConfigDlg diff --git a/src/gui/editorwidgets/qgsuniquevaluewidgetfactory.h b/src/gui/editorwidgets/qgsuniquevaluewidgetfactory.h index ed7d1e8c533..55a670cb62c 100644 --- a/src/gui/editorwidgets/qgsuniquevaluewidgetfactory.h +++ b/src/gui/editorwidgets/qgsuniquevaluewidgetfactory.h @@ -17,6 +17,7 @@ #define QGSUNIQUEVALUEWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** * \ingroup gui diff --git a/src/gui/editorwidgets/qgsuniquevaluewidgetwrapper.h b/src/gui/editorwidgets/qgsuniquevaluewidgetwrapper.h index 1ee72b75cde..9a9e0c5bfcd 100644 --- a/src/gui/editorwidgets/qgsuniquevaluewidgetwrapper.h +++ b/src/gui/editorwidgets/qgsuniquevaluewidgetwrapper.h @@ -20,6 +20,7 @@ #include #include +#include "qgis_gui.h" /** \ingroup gui * Wraps a unique value widget. Will offer any value previously used for this field. diff --git a/src/gui/editorwidgets/qgsuuidwidgetfactory.h b/src/gui/editorwidgets/qgsuuidwidgetfactory.h index 14724d71b40..8f9fad5f8ca 100644 --- a/src/gui/editorwidgets/qgsuuidwidgetfactory.h +++ b/src/gui/editorwidgets/qgsuuidwidgetfactory.h @@ -17,6 +17,7 @@ #define QGSUUIDWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsUuidWidgetFactory diff --git a/src/gui/editorwidgets/qgsuuidwidgetwrapper.h b/src/gui/editorwidgets/qgsuuidwidgetwrapper.h index c5f15248a12..1c4e5c7ad80 100644 --- a/src/gui/editorwidgets/qgsuuidwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsuuidwidgetwrapper.h @@ -20,6 +20,7 @@ #include #include +#include "qgis_gui.h" /** \ingroup gui diff --git a/src/gui/editorwidgets/qgsvaluemapconfigdlg.h b/src/gui/editorwidgets/qgsvaluemapconfigdlg.h index 80618bb980a..038be5a75df 100644 --- a/src/gui/editorwidgets/qgsvaluemapconfigdlg.h +++ b/src/gui/editorwidgets/qgsvaluemapconfigdlg.h @@ -19,6 +19,7 @@ #include "ui_qgsvaluemapconfigdlgbase.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsValueMapConfigDlg diff --git a/src/gui/editorwidgets/qgsvaluemapsearchwidgetwrapper.h b/src/gui/editorwidgets/qgsvaluemapsearchwidgetwrapper.h index 1e98441bd7a..8935ae5f0bc 100644 --- a/src/gui/editorwidgets/qgsvaluemapsearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsvaluemapsearchwidgetwrapper.h @@ -18,6 +18,7 @@ #include "qgssearchwidgetwrapper.h" #include +#include "qgis_gui.h" /** \ingroup gui * Wraps a value map search widget. This widget will offer a combobox with values from another layer diff --git a/src/gui/editorwidgets/qgsvaluemapwidgetfactory.h b/src/gui/editorwidgets/qgsvaluemapwidgetfactory.h index ca5870eded1..0fd570d2512 100644 --- a/src/gui/editorwidgets/qgsvaluemapwidgetfactory.h +++ b/src/gui/editorwidgets/qgsvaluemapwidgetfactory.h @@ -17,6 +17,7 @@ #define QGSVALUEMAPWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsValueMapWidgetFactory diff --git a/src/gui/editorwidgets/qgsvaluemapwidgetwrapper.h b/src/gui/editorwidgets/qgsvaluemapwidgetwrapper.h index d0ef83b9e14..952fe6e271c 100644 --- a/src/gui/editorwidgets/qgsvaluemapwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsvaluemapwidgetwrapper.h @@ -19,6 +19,7 @@ #include "qgseditorwidgetwrapper.h" #include +#include "qgis_gui.h" /** \ingroup gui diff --git a/src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp b/src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp index 306b0147732..ff047a7d131 100644 --- a/src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp +++ b/src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp @@ -72,10 +72,7 @@ void QgsValueRelationConfigDlg::editExpression() if ( !vl ) return; - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( vl ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( vl ) ); QgsExpressionBuilderDialog dlg( vl, mFilterExpression->toPlainText(), this, QStringLiteral( "generic" ), context ); dlg.setWindowTitle( tr( "Edit filter expression" ) ); diff --git a/src/gui/editorwidgets/qgsvaluerelationconfigdlg.h b/src/gui/editorwidgets/qgsvaluerelationconfigdlg.h index e420acf7c05..d9a8bba4f4b 100644 --- a/src/gui/editorwidgets/qgsvaluerelationconfigdlg.h +++ b/src/gui/editorwidgets/qgsvaluerelationconfigdlg.h @@ -19,6 +19,7 @@ #include "ui_qgsvaluerelationconfigdlgbase.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsValueRelationConfigDlg diff --git a/src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h b/src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h index 2eac25d0e9b..0d74b1249eb 100644 --- a/src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h @@ -22,6 +22,7 @@ #include #include #include +#include "qgis_gui.h" class QgsValueRelationWidgetFactory; diff --git a/src/gui/editorwidgets/qgsvaluerelationwidgetfactory.h b/src/gui/editorwidgets/qgsvaluerelationwidgetfactory.h index 3254f7a32d4..cf00f69ceb5 100644 --- a/src/gui/editorwidgets/qgsvaluerelationwidgetfactory.h +++ b/src/gui/editorwidgets/qgsvaluerelationwidgetfactory.h @@ -19,6 +19,7 @@ #include "qgseditorwidgetfactory.h" #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsValueRelationWidgetFactory diff --git a/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h b/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h index a5d23a8a87a..2a4f2ed69b7 100644 --- a/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h @@ -22,6 +22,7 @@ #include #include #include +#include "qgis_gui.h" class QgsValueRelationWidgetFactory; diff --git a/src/gui/editorwidgets/qgswebviewconfigdlg.h b/src/gui/editorwidgets/qgswebviewconfigdlg.h index 6f69b55963c..a1fb6c0b37d 100644 --- a/src/gui/editorwidgets/qgswebviewconfigdlg.h +++ b/src/gui/editorwidgets/qgswebviewconfigdlg.h @@ -19,6 +19,7 @@ #include "ui_qgswebviewconfigdlgbase.h" #include "qgseditorconfigwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsWebViewWidgetConfigDlg diff --git a/src/gui/editorwidgets/qgswebviewwidgetfactory.h b/src/gui/editorwidgets/qgswebviewwidgetfactory.h index 0e5fe2c78e9..8032194c3d8 100644 --- a/src/gui/editorwidgets/qgswebviewwidgetfactory.h +++ b/src/gui/editorwidgets/qgswebviewwidgetfactory.h @@ -17,6 +17,7 @@ #define QGSWEBVIEWWIDGETFACTORY_H #include "qgseditorwidgetfactory.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsWebViewWidgetFactory diff --git a/src/gui/editorwidgets/qgswebviewwidgetwrapper.h b/src/gui/editorwidgets/qgswebviewwidgetwrapper.h index 810bb24a0c6..06275f4834f 100644 --- a/src/gui/editorwidgets/qgswebviewwidgetwrapper.h +++ b/src/gui/editorwidgets/qgswebviewwidgetwrapper.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_gui.h" /** \ingroup gui * Wraps a web view widget. Will show the content available at the URL of the value in a web browser. diff --git a/src/gui/effects/qgseffectdrawmodecombobox.h b/src/gui/effects/qgseffectdrawmodecombobox.h index 0f0e71b2735..b6ccc611fcd 100644 --- a/src/gui/effects/qgseffectdrawmodecombobox.h +++ b/src/gui/effects/qgseffectdrawmodecombobox.h @@ -18,6 +18,7 @@ #include #include "qgspainteffect.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsEffectDrawModeComboBox diff --git a/src/gui/effects/qgseffectstackpropertieswidget.cpp b/src/gui/effects/qgseffectstackpropertieswidget.cpp index 41a82f2436a..636efea25ac 100644 --- a/src/gui/effects/qgseffectstackpropertieswidget.cpp +++ b/src/gui/effects/qgseffectstackpropertieswidget.cpp @@ -61,7 +61,7 @@ class EffectItem : public QStandardItem { if ( role == Qt::DisplayRole || role == Qt::EditRole ) { - return QgsPaintEffectRegistry::instance()->effectMetadata( mEffect->type() )->visibleName(); + return QgsApplication::paintEffectRegistry()->effectMetadata( mEffect->type() )->visibleName(); } if ( role == Qt::CheckStateRole ) { @@ -371,11 +371,6 @@ QgsEffectStackPropertiesDialog::QgsEffectStackPropertiesDialog( QgsEffectStack * layout()->addWidget( mPropertiesWidget ); } -QgsEffectStackPropertiesDialog::~QgsEffectStackPropertiesDialog() -{ - -} - QgsEffectStack* QgsEffectStackPropertiesDialog::stack() { return mPropertiesWidget->stack(); diff --git a/src/gui/effects/qgseffectstackpropertieswidget.h b/src/gui/effects/qgseffectstackpropertieswidget.h index 842be0286cc..e3eb0a18eab 100644 --- a/src/gui/effects/qgseffectstackpropertieswidget.h +++ b/src/gui/effects/qgseffectstackpropertieswidget.h @@ -22,6 +22,7 @@ #include #include "ui_qgseffectstackpropertieswidgetbase.h" +#include "qgis_gui.h" class EffectItem; class QgsPaintEffect; @@ -156,7 +157,6 @@ class GUI_EXPORT QgsEffectStackPropertiesDialog: public QgsDialog * @param f window flags */ QgsEffectStackPropertiesDialog( QgsEffectStack* stack, QWidget* parent = nullptr, Qt::WindowFlags f = 0 ); - ~QgsEffectStackPropertiesDialog(); /** Returns effect stack attached to the dialog * @returns QgsEffectStack modified by the dialog diff --git a/src/gui/effects/qgspainteffectpropertieswidget.cpp b/src/gui/effects/qgspainteffectpropertieswidget.cpp index c73d9aaf975..ccfc1837d10 100644 --- a/src/gui/effects/qgspainteffectpropertieswidget.cpp +++ b/src/gui/effects/qgspainteffectpropertieswidget.cpp @@ -29,7 +29,7 @@ static bool _initWidgetFunction( const QString& name, QgsPaintEffectWidgetFunc f ) { - QgsPaintEffectRegistry* registry = QgsPaintEffectRegistry::instance(); + QgsPaintEffectRegistry* registry = QgsApplication::paintEffectRegistry(); QgsPaintEffectAbstractMetadata* abstractMetadata = registry->effectMetadata( name ); if ( !abstractMetadata ) @@ -88,7 +88,7 @@ QgsPaintEffectPropertiesWidget::QgsPaintEffectPropertiesWidget( QgsPaintEffect* void QgsPaintEffectPropertiesWidget::populateEffectTypes() { - QgsPaintEffectRegistry* registry = QgsPaintEffectRegistry::instance(); + QgsPaintEffectRegistry* registry = QgsApplication::paintEffectRegistry(); QStringList types = registry->effects(); Q_FOREACH ( const QString& type, types ) @@ -116,7 +116,7 @@ void QgsPaintEffectPropertiesWidget::updateEffectWidget( QgsPaintEffect* effect stackedWidget->removeWidget( stackedWidget->currentWidget() ); } - QgsPaintEffectRegistry* registry = QgsPaintEffectRegistry::instance(); + QgsPaintEffectRegistry* registry = QgsApplication::paintEffectRegistry(); QgsPaintEffectAbstractMetadata* am = registry->effectMetadata( effect->type() ); if ( am ) { @@ -146,7 +146,7 @@ void QgsPaintEffectPropertiesWidget::effectTypeChanged() return; // get creation function for new effect from registry - QgsPaintEffectRegistry* registry = QgsPaintEffectRegistry::instance(); + QgsPaintEffectRegistry* registry = QgsApplication::paintEffectRegistry(); QgsPaintEffectAbstractMetadata* am = registry->effectMetadata( newEffectType ); if ( !am ) // check whether the metadata is assigned return; diff --git a/src/gui/effects/qgspainteffectpropertieswidget.h b/src/gui/effects/qgspainteffectpropertieswidget.h index 0bc24ac0c5e..36f3eaeb2ab 100644 --- a/src/gui/effects/qgspainteffectpropertieswidget.h +++ b/src/gui/effects/qgspainteffectpropertieswidget.h @@ -17,6 +17,7 @@ #define QGSPAINTEFFECTPROPERTIESWIDGET_H #include "ui_qgseffectpropertieswidget.h" +#include "qgis_gui.h" class QgsPaintEffect; diff --git a/src/gui/effects/qgspainteffectwidget.h b/src/gui/effects/qgspainteffectwidget.h index 5ca0fe2ff8a..a031f087481 100644 --- a/src/gui/effects/qgspainteffectwidget.h +++ b/src/gui/effects/qgspainteffectwidget.h @@ -17,6 +17,7 @@ #define QGSPAINTEFFECTWIDGET_H #include +#include "qgis_gui.h" class QgsPaintEffect; class QgsShadowEffect; @@ -40,7 +41,6 @@ class GUI_EXPORT QgsPaintEffectWidget : public QWidget public: QgsPaintEffectWidget( QWidget* parent = nullptr ) : QWidget( parent ) {} - virtual ~QgsPaintEffectWidget() {} /** * Sets the paint effect to modify with the widget diff --git a/src/gui/layertree/qgscustomlayerorderwidget.cpp b/src/gui/layertree/qgscustomlayerorderwidget.cpp index a0423d00e1b..a876cf04931 100644 --- a/src/gui/layertree/qgscustomlayerorderwidget.cpp +++ b/src/gui/layertree/qgscustomlayerorderwidget.cpp @@ -54,7 +54,7 @@ QgsCustomLayerOrderWidget::QgsCustomLayerOrderWidget( QgsLayerTreeMapCanvasBridg connect( mModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( modelUpdated() ) ); connect( mModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( modelUpdated() ) ); - connect( bridge->rootGroup(), SIGNAL( visibilityChanged( QgsLayerTreeNode*, Qt::CheckState ) ), this, SLOT( nodeVisibilityChanged( QgsLayerTreeNode*, Qt::CheckState ) ) ); + connect( bridge->rootGroup(), &QgsLayerTreeNode::visibilityChanged, this, &QgsCustomLayerOrderWidget::nodeVisibilityChanged ); QVBoxLayout* l = new QVBoxLayout; l->setMargin( 0 ); @@ -76,9 +76,8 @@ void QgsCustomLayerOrderWidget::bridgeCustomLayerOrderChanged( const QStringList mModel->refreshModel( mBridge->hasCustomLayerOrder() ? mBridge->customLayerOrder() : mBridge->defaultLayerOrder() ); } -void QgsCustomLayerOrderWidget::nodeVisibilityChanged( QgsLayerTreeNode* node, Qt::CheckState state ) +void QgsCustomLayerOrderWidget::nodeVisibilityChanged( QgsLayerTreeNode* node ) { - Q_UNUSED( state ); if ( QgsLayerTree::isLayer( node ) ) { mModel->updateLayerVisibility( QgsLayerTree::toLayer( node )->layerId() ); @@ -141,7 +140,7 @@ bool CustomLayerOrderModel::setData( const QModelIndex& index, const QVariant& v QgsLayerTreeLayer* nodeLayer = mBridge->rootGroup()->findLayer( id ); if ( nodeLayer ) { - nodeLayer->setVisible( static_cast< Qt::CheckState >( value.toInt() ) ); + nodeLayer->setItemVisibilityChecked( static_cast< Qt::CheckState >( value.toInt() ) == Qt::Checked ); return true; } } diff --git a/src/gui/layertree/qgscustomlayerorderwidget.h b/src/gui/layertree/qgscustomlayerorderwidget.h index 7cf93c00c40..597de2108f4 100644 --- a/src/gui/layertree/qgscustomlayerorderwidget.h +++ b/src/gui/layertree/qgscustomlayerorderwidget.h @@ -18,6 +18,7 @@ #include #include +#include "qgis_gui.h" class CustomLayerOrderModel; class QgsLayerTreeMapCanvasBridge; @@ -48,7 +49,8 @@ class GUI_EXPORT QgsCustomLayerOrderWidget : public QWidget protected slots: void bridgeHasCustomLayerOrderChanged( bool state ); void bridgeCustomLayerOrderChanged( const QStringList& order ); - void nodeVisibilityChanged( QgsLayerTreeNode* node, Qt::CheckState state ); + //! Slot triggered when the ivsibility of a node changes + void nodeVisibilityChanged( QgsLayerTreeNode* node ); void modelUpdated(); diff --git a/src/gui/layertree/qgslayertreeembeddedconfigwidget.h b/src/gui/layertree/qgslayertreeembeddedconfigwidget.h index 7b3aae233e1..38c736c2457 100644 --- a/src/gui/layertree/qgslayertreeembeddedconfigwidget.h +++ b/src/gui/layertree/qgslayertreeembeddedconfigwidget.h @@ -17,6 +17,7 @@ #define QGSLAYERTREEEMBEDDEDCONFIGWIDGET_H #include "ui_qgslayertreeembeddedconfigwidget.h" +#include "qgis_gui.h" class QgsMapLayer; diff --git a/src/gui/layertree/qgslayertreeembeddedwidgetregistry.h b/src/gui/layertree/qgslayertreeembeddedwidgetregistry.h index f6574a81d12..29b8798fadc 100644 --- a/src/gui/layertree/qgslayertreeembeddedwidgetregistry.h +++ b/src/gui/layertree/qgslayertreeembeddedwidgetregistry.h @@ -18,6 +18,7 @@ #include #include +#include "qgis_gui.h" class QgsMapLayer; @@ -32,7 +33,7 @@ class QgsMapLayer; class GUI_EXPORT QgsLayerTreeEmbeddedWidgetProvider { public: - virtual ~QgsLayerTreeEmbeddedWidgetProvider() {} + virtual ~QgsLayerTreeEmbeddedWidgetProvider() = default; //! Unique name of the provider (among other providers) virtual QString id() const = 0; @@ -67,6 +68,11 @@ class GUI_EXPORT QgsLayerTreeEmbeddedWidgetRegistry ~QgsLayerTreeEmbeddedWidgetRegistry(); + //! QgsLayerTreeEmbeddedWidgetRegistry cannot be copied. + QgsLayerTreeEmbeddedWidgetRegistry( const QgsLayerTreeEmbeddedWidgetRegistry& other ) = delete; + //! QgsLayerTreeEmbeddedWidgetRegistry cannot be copied. + QgsLayerTreeEmbeddedWidgetRegistry& operator=( const QgsLayerTreeEmbeddedWidgetRegistry& other ) = delete; + //! Return list of all registered providers QStringList providers() const; @@ -88,10 +94,6 @@ class GUI_EXPORT QgsLayerTreeEmbeddedWidgetRegistry //! storage of all the providers QMap mProviders; - private: - - QgsLayerTreeEmbeddedWidgetRegistry( const QgsLayerTreeEmbeddedWidgetRegistry& other ); - QgsLayerTreeEmbeddedWidgetRegistry& operator=( const QgsLayerTreeEmbeddedWidgetRegistry& other ); }; diff --git a/src/gui/layertree/qgslayertreemapcanvasbridge.cpp b/src/gui/layertree/qgslayertreemapcanvasbridge.cpp index 41d48f229da..085e78c39bb 100644 --- a/src/gui/layertree/qgslayertreemapcanvasbridge.cpp +++ b/src/gui/layertree/qgslayertreemapcanvasbridge.cpp @@ -37,7 +37,7 @@ QgsLayerTreeMapCanvasBridge::QgsLayerTreeMapCanvasBridge( QgsLayerTreeGroup *roo connect( root, SIGNAL( addedChildren( QgsLayerTreeNode*, int, int ) ), this, SLOT( nodeAddedChildren( QgsLayerTreeNode*, int, int ) ) ); connect( root, SIGNAL( customPropertyChanged( QgsLayerTreeNode*, QString ) ), this, SLOT( nodeCustomPropertyChanged( QgsLayerTreeNode*, QString ) ) ); connect( root, SIGNAL( removedChildren( QgsLayerTreeNode*, int, int ) ), this, SLOT( nodeRemovedChildren() ) ); - connect( root, SIGNAL( visibilityChanged( QgsLayerTreeNode*, Qt::CheckState ) ), this, SLOT( nodeVisibilityChanged() ) ); + connect( root, &QgsLayerTreeNode::visibilityChanged, this, &QgsLayerTreeMapCanvasBridge::nodeVisibilityChanged ); setCanvasLayers(); } @@ -127,7 +127,7 @@ void QgsLayerTreeMapCanvasBridge::setCanvasLayers() QgsLayerTreeLayer* nodeLayer = mRoot->findLayer( layerId ); if ( nodeLayer ) { - if ( nodeLayer->isVisible() == Qt::Checked ) + if ( nodeLayer->isVisible() ) canvasLayers << nodeLayer->layer(); if ( nodeLayer->customProperty( QStringLiteral( "overview" ), 0 ).toInt() ) overviewLayers << nodeLayer->layer(); @@ -262,7 +262,7 @@ void QgsLayerTreeMapCanvasBridge::setCanvasLayers( QgsLayerTreeNode *node, QList if ( QgsLayerTree::isLayer( node ) ) { QgsLayerTreeLayer* nodeLayer = QgsLayerTree::toLayer( node ); - if ( nodeLayer->isVisible() == Qt::Checked ) + if ( nodeLayer->isVisible() ) canvasLayers << nodeLayer->layer(); if ( nodeLayer->customProperty( QStringLiteral( "overview" ), 0 ).toInt() ) overviewLayers << nodeLayer->layer(); diff --git a/src/gui/layertree/qgslayertreemapcanvasbridge.h b/src/gui/layertree/qgslayertreemapcanvasbridge.h index b17a1bef2b2..70eff2f35b3 100644 --- a/src/gui/layertree/qgslayertreemapcanvasbridge.h +++ b/src/gui/layertree/qgslayertreemapcanvasbridge.h @@ -20,6 +20,7 @@ #include #include "qgscoordinatereferencesystem.h" +#include "qgis_gui.h" class QgsMapCanvas; class QgsMapLayer; diff --git a/src/gui/layertree/qgslayertreeview.cpp b/src/gui/layertree/qgslayertreeview.cpp index be815a27769..1661fd842a3 100644 --- a/src/gui/layertree/qgslayertreeview.cpp +++ b/src/gui/layertree/qgslayertreeview.cpp @@ -382,3 +382,25 @@ void QgsLayerTreeView::collapseAllNodes() _expandAllNodes( layerTreeModel()->rootGroup(), false, layerTreeModel() ); collapseAll(); } + +void QgsLayerTreeView::mouseReleaseEvent( QMouseEvent *event ) +{ + const QgsLayerTreeModel::Flags oldFlags = layerTreeModel()->flags(); + if ( event->modifiers() & Qt::ControlModifier ) + layerTreeModel()->setFlags( oldFlags | QgsLayerTreeModel::ActionHierarchical ); + else + layerTreeModel()->setFlags( oldFlags & ~QgsLayerTreeModel::ActionHierarchical ); + QTreeView::mouseReleaseEvent( event ); + layerTreeModel()->setFlags( oldFlags ); +} + +void QgsLayerTreeView::keyPressEvent( QKeyEvent *event ) +{ + const QgsLayerTreeModel::Flags oldFlags = layerTreeModel()->flags(); + if ( event->modifiers() & Qt::ControlModifier ) + layerTreeModel()->setFlags( oldFlags | QgsLayerTreeModel::ActionHierarchical ); + else + layerTreeModel()->setFlags( oldFlags & ~QgsLayerTreeModel::ActionHierarchical ); + QTreeView::keyPressEvent( event ); + layerTreeModel()->setFlags( oldFlags ); +} diff --git a/src/gui/layertree/qgslayertreeview.h b/src/gui/layertree/qgslayertreeview.h index e0e5040c0b2..a6bd100c1c1 100644 --- a/src/gui/layertree/qgslayertreeview.h +++ b/src/gui/layertree/qgslayertreeview.h @@ -17,6 +17,7 @@ #define QGSLAYERTREEVIEW_H #include +#include "qgis_gui.h" class QgsLayerTreeGroup; class QgsLayerTreeLayer; @@ -111,6 +112,9 @@ class GUI_EXPORT QgsLayerTreeView : public QTreeView QgsMapLayer* layerForIndex( const QModelIndex& index ) const; + void mouseReleaseEvent( QMouseEvent *event ) override; + void keyPressEvent( QKeyEvent *event ) override; + protected slots: void modelRowsInserted( const QModelIndex& index, int start, int end ); @@ -142,7 +146,7 @@ class GUI_EXPORT QgsLayerTreeView : public QTreeView class GUI_EXPORT QgsLayerTreeViewMenuProvider { public: - virtual ~QgsLayerTreeViewMenuProvider() {} + virtual ~QgsLayerTreeViewMenuProvider() = default; //! Return a newly created menu instance (or null pointer on error) virtual QMenu* createContextMenu() = 0; diff --git a/src/gui/layertree/qgslayertreeviewdefaultactions.cpp b/src/gui/layertree/qgslayertreeviewdefaultactions.cpp index b6f73ef0245..48036ee85c0 100644 --- a/src/gui/layertree/qgslayertreeviewdefaultactions.cpp +++ b/src/gui/layertree/qgslayertreeviewdefaultactions.cpp @@ -123,6 +123,60 @@ QAction* QgsLayerTreeViewDefaultActions::actionMutuallyExclusiveGroup( QObject* return a; } +QAction* QgsLayerTreeViewDefaultActions::actionCheckAndAllChildren( QObject* parent ) +{ + QgsLayerTreeNode* node = mView->currentNode(); + if ( !node || !QgsLayerTree::isGroup( node ) || node->isItemVisibilityCheckedRecursive() ) + return nullptr; + QAction* a = new QAction( tr( "Check and all its children (Ctrl-click)" ), parent ); + connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::checkAndAllChildren ); + return a; +} + +QAction* QgsLayerTreeViewDefaultActions::actionUncheckAndAllChildren( QObject* parent ) +{ + QgsLayerTreeNode* node = mView->currentNode(); + if ( !node || !QgsLayerTree::isGroup( node ) || node->isItemVisibilityUncheckedRecursive() ) + return nullptr; + QAction* a = new QAction( tr( "Uncheck and all its children (Ctrl-click)" ), parent ); + connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::uncheckAndAllChildren ); + return a; +} + +QAction* QgsLayerTreeViewDefaultActions::actionCheckAndAllParents( QObject* parent ) +{ + QgsLayerTreeNode* node = mView->currentNode(); + if ( !node || !QgsLayerTree::isLayer( node ) || node->isVisible() ) + return nullptr; + QAction* a = new QAction( tr( "Check and all its parents" ), parent ); + connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::checkAndAllParents ); + return a; +} + +void QgsLayerTreeViewDefaultActions::checkAndAllChildren() +{ + QgsLayerTreeNode* node = mView->currentNode(); + if ( !node ) + return; + node->setItemVisibilityCheckedRecursive( true ); +} + +void QgsLayerTreeViewDefaultActions::uncheckAndAllChildren() +{ + QgsLayerTreeNode* node = mView->currentNode(); + if ( !node ) + return; + node->setItemVisibilityCheckedRecursive( false ); +} + +void QgsLayerTreeViewDefaultActions::checkAndAllParents() +{ + QgsLayerTreeNode* node = mView->currentNode(); + if ( !node ) + return; + node->setItemVisibilityCheckedParentRecursive( true ); +} + void QgsLayerTreeViewDefaultActions::addGroup() { QgsLayerTreeGroup* group = mView->currentGroupNode(); diff --git a/src/gui/layertree/qgslayertreeviewdefaultactions.h b/src/gui/layertree/qgslayertreeviewdefaultactions.h index 4f3499509ec..57d4fab68b0 100644 --- a/src/gui/layertree/qgslayertreeviewdefaultactions.h +++ b/src/gui/layertree/qgslayertreeviewdefaultactions.h @@ -17,6 +17,7 @@ #define QGSLAYERTREEVIEWDEFAULTACTIONS_H #include +#include "qgis_gui.h" class QAction; @@ -46,6 +47,15 @@ class GUI_EXPORT QgsLayerTreeViewDefaultActions : public QObject QAction* actionRenameGroupOrLayer( QObject* parent = nullptr ); QAction* actionShowFeatureCount( QObject* parent = nullptr ); + //! Action to check a group and all its children + QAction* actionCheckAndAllChildren( QObject* parent = nullptr ); + + //! Action to uncheck a group and all its children + QAction* actionUncheckAndAllChildren( QObject* parent = nullptr ); + + //! Action to check a group and all its parents + QAction* actionCheckAndAllParents( QObject* parent = nullptr ); + QAction* actionZoomToLayer( QgsMapCanvas* canvas, QObject* parent = nullptr ); QAction* actionZoomToGroup( QgsMapCanvas* canvas, QObject* parent = nullptr ); // TODO: zoom to selected @@ -75,6 +85,11 @@ class GUI_EXPORT QgsLayerTreeViewDefaultActions : public QObject //! @note added in 2.12 void mutuallyExclusiveGroup(); + private slots: + void checkAndAllChildren(); + void uncheckAndAllChildren(); + void checkAndAllParents(); + protected: void zoomToLayers( QgsMapCanvas* canvas, const QList& layers ); diff --git a/src/gui/qgisgui.cpp b/src/gui/qgisgui.cpp index 51ff7b38c90..eecef73c95a 100644 --- a/src/gui/qgisgui.cpp +++ b/src/gui/qgisgui.cpp @@ -20,6 +20,7 @@ #include "qgslogger.h" #include +#include "qgis_gui.h" namespace QgisGui diff --git a/src/gui/qgisgui.h b/src/gui/qgisgui.h index 1c0e94be94a..de1d7faf24c 100644 --- a/src/gui/qgisgui.h +++ b/src/gui/qgisgui.h @@ -19,6 +19,7 @@ #include #include #include +#include "qgis_gui.h" class QFont; diff --git a/src/gui/qgisinterface.cpp b/src/gui/qgisinterface.cpp index e830bfb103f..afa767126f2 100644 --- a/src/gui/qgisinterface.cpp +++ b/src/gui/qgisinterface.cpp @@ -23,7 +23,3 @@ QgisInterface::QgisInterface() } - -QgisInterface::~QgisInterface() -{ -} diff --git a/src/gui/qgisinterface.h b/src/gui/qgisinterface.h index da8bb93bdf4..b2c507242f0 100644 --- a/src/gui/qgisinterface.h +++ b/src/gui/qgisinterface.h @@ -49,6 +49,7 @@ class QgsVectorLayerTools; #include "qgis.h" #include "qgsmaplayer.h" +#include "qgis_gui.h" /** \ingroup gui @@ -72,9 +73,6 @@ class GUI_EXPORT QgisInterface : public QObject //! Constructor QgisInterface(); - //! Virtual destructor - virtual ~QgisInterface(); - virtual QgsPluginManagerInterface* pluginManagerInterface() = 0; virtual QgsLayerTreeView* layerTreeView() = 0; @@ -539,6 +537,12 @@ class GUI_EXPORT QgisInterface : public QObject virtual QAction *actionHideAllLayers() = 0; virtual QAction *actionShowAllLayers() = 0; virtual QAction *actionHideSelectedLayers() = 0; + + /** + * Returns the Hide Deselected Layers action. + * @note added in QGIS 3.0 + */ + virtual QAction *actionHideDeselectedLayers() = 0; virtual QAction *actionShowSelectedLayers() = 0; // Plugin menu actions diff --git a/src/gui/qgsactionmenu.cpp b/src/gui/qgsactionmenu.cpp index fac834b43c0..9f20551bfea 100644 --- a/src/gui/qgsactionmenu.cpp +++ b/src/gui/qgsactionmenu.cpp @@ -57,10 +57,6 @@ QgsFeature QgsActionMenu::feature() return mFeature; } -QgsActionMenu::~QgsActionMenu() -{ -} - void QgsActionMenu::setFeature( const QgsFeature& feature ) { mFeature = feature; diff --git a/src/gui/qgsactionmenu.h b/src/gui/qgsactionmenu.h index 0056a77eba9..c3567364568 100644 --- a/src/gui/qgsactionmenu.h +++ b/src/gui/qgsactionmenu.h @@ -21,6 +21,7 @@ #include "qgsfeature.h" #include "qgsaction.h" +#include "qgis_gui.h" class QgsMapLayer; class QgsMapLayerAction; @@ -76,11 +77,6 @@ class GUI_EXPORT QgsActionMenu : public QMenu */ explicit QgsActionMenu( QgsVectorLayer *layer, const QgsFeatureId fid, const QString& actionScope, QWidget *parent = nullptr ); - /** - * Destructor - */ - ~QgsActionMenu(); - /** * Change the feature on which actions are performed * diff --git a/src/gui/qgsadvanceddigitizingcanvasitem.cpp b/src/gui/qgsadvanceddigitizingcanvasitem.cpp index c69b19033f5..55698e52997 100644 --- a/src/gui/qgsadvanceddigitizingcanvasitem.cpp +++ b/src/gui/qgsadvanceddigitizingcanvasitem.cpp @@ -32,10 +32,6 @@ QgsAdvancedDigitizingCanvasItem::QgsAdvancedDigitizingCanvasItem( QgsMapCanvas* { } -QgsAdvancedDigitizingCanvasItem::~QgsAdvancedDigitizingCanvasItem() -{ -} - void QgsAdvancedDigitizingCanvasItem::paint( QPainter* painter ) { if ( !mAdvancedDigitizingDockWidget->cadEnabled() ) diff --git a/src/gui/qgsadvanceddigitizingcanvasitem.h b/src/gui/qgsadvanceddigitizingcanvasitem.h index 518d86557bc..08cf001a153 100644 --- a/src/gui/qgsadvanceddigitizingcanvasitem.h +++ b/src/gui/qgsadvanceddigitizingcanvasitem.h @@ -19,6 +19,7 @@ #include #include "qgsmapcanvasitem.h" +#include "qgis_gui.h" class QgsAdvancedDigitizingDockWidget; @@ -29,7 +30,6 @@ class GUI_EXPORT QgsAdvancedDigitizingCanvasItem : public QgsMapCanvasItem { public: explicit QgsAdvancedDigitizingCanvasItem( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget ); - ~QgsAdvancedDigitizingCanvasItem(); void paint( QPainter *painter ) override; diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 3c024a5684f..4a409cbdcf8 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -21,6 +21,7 @@ #include "qgsmessagebaritem.h" #include +#include "qgis_gui.h" class QgsAdvancedDigitizingCanvasItem; @@ -259,7 +260,6 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private */ QgsMapMouseEvent::SnappingMode snappingMode() { return mSnappingMode; } - //! key press event on the dock void keyPressEvent( QKeyEvent* e ) override; //! determines if CAD tools are enabled or if map tools behaves "nomally" diff --git a/src/gui/qgsannotationitem.h b/src/gui/qgsannotationitem.h index 22976f7b757..54d3ed6d950 100644 --- a/src/gui/qgsannotationitem.h +++ b/src/gui/qgsannotationitem.h @@ -21,6 +21,7 @@ #include "qgsmapcanvasitem.h" #include "qgscoordinatereferencesystem.h" #include "qgsannotation.h" +#include "qgis_gui.h" class QDomDocument; class QDomElement; @@ -71,17 +72,14 @@ class GUI_EXPORT QgsAnnotationItem: public QgsMapCanvasItem, public QgsAnnotatio virtual void setMapPosition( const QgsPoint& pos ); QgsPoint mapPosition() const override { return mMapPosition; } - virtual QPointF relativePosition() const override; - virtual double scaleFactor() const override; - virtual bool showItem() const override { return isVisible(); } - /** Sets the CRS of the map position. - @param crs the CRS to set */ + /** + * Sets the CRS of the map position. + */ virtual void setMapPositionCrs( const QgsCoordinateReferenceSystem& crs ); - //! Returns the CRS of the map position. QgsCoordinateReferenceSystem mapPositionCrs() const override { return mMapPositionCrs; } void setFrameSize( QSizeF size ); diff --git a/src/gui/qgsattributedialog.h b/src/gui/qgsattributedialog.h index a5939abdc1c..ea07ee3c0f8 100644 --- a/src/gui/qgsattributedialog.h +++ b/src/gui/qgsattributedialog.h @@ -24,6 +24,7 @@ #include #include #include +#include "qgis_gui.h" class QgsDistanceArea; class QgsHighlight; @@ -81,7 +82,7 @@ class GUI_EXPORT QgsAttributeDialog : public QDialog /** * Toggles the form mode. - * @param mode form mode. Eg if set to QgsAttributeForm::AddFeatureMode, the dialog will be editable even with an invalid feature and + * @param mode form mode. For example, if set to QgsAttributeForm::AddFeatureMode, the dialog will be editable even with an invalid feature and * will add a new feature when the form is accepted. */ void setMode( QgsAttributeForm::Mode mode ) { mAttributeForm->setMode( mode ); } diff --git a/src/gui/qgsattributeeditorcontext.h b/src/gui/qgsattributeeditorcontext.h index 778312f1e7e..b61ae9e1956 100644 --- a/src/gui/qgsattributeeditorcontext.h +++ b/src/gui/qgsattributeeditorcontext.h @@ -22,6 +22,7 @@ #include #include #include +#include "qgis_gui.h" /** \ingroup gui diff --git a/src/gui/qgsattributeform.cpp b/src/gui/qgsattributeform.cpp index 1ee4aedf58c..cdf472eeb16 100644 --- a/src/gui/qgsattributeform.cpp +++ b/src/gui/qgsattributeform.cpp @@ -291,7 +291,7 @@ bool QgsAttributeForm::saveEdits() // need to check dstVar.isNull() != srcVar.isNull() // otherwise if dstVar=NULL and scrVar=0, then dstVar = srcVar - // be careful- sometimes two null qvariants will be reported as not equal!! (eg different types) + // be careful- sometimes two null qvariants will be reported as not equal!! (e.g., different types) bool changed = ( dstVar != srcVar && !dstVar.isNull() && !srcVar.isNull() ) || ( dstVar.isNull() != srcVar.isNull() ); if ( changed && srcVar.isValid() @@ -405,6 +405,15 @@ void QgsAttributeForm::filterTriggered() setMode( SingleEditMode ); } +void QgsAttributeForm::searchZoomTo() +{ + QString filter = createFilterExpression(); + if ( filter.isEmpty() ) + return; + + emit zoomToFeatures( filter ); +} + void QgsAttributeForm::filterAndTriggered() { QString filter = createFilterExpression(); @@ -699,7 +708,7 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww ) // if the layer is NOT being edited then we only check layer based constraints, and not // any constraints enforced by the provider. Because: // 1. we want to keep browsing features nice and responsive. It's nice to give feedback as to whether - // the value checks out, but not if it's too slow to do so. Some constraints (eg unique) can be + // the value checks out, but not if it's too slow to do so. Some constraints (e.g., unique) can be // expensive to test. A user can freely remove a layer-based constraint if it proves to be too slow // to test, but they are unlikely to have any control over provider-side constraints // 2. the provider has already accepted the value, so presumably it doesn't violate the constraint @@ -1310,24 +1319,36 @@ void QgsAttributeForm::init() boxLayout->addWidget( clearButton ); boxLayout->addStretch( 1 ); + QPushButton* zoomButton = new QPushButton(); + zoomButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); + zoomButton->setText( tr( "&Zoom to features" ) ); + connect( zoomButton, &QToolButton::clicked, this, &QgsAttributeForm::searchZoomTo ); + boxLayout->addWidget( zoomButton ); + QToolButton* selectButton = new QToolButton(); selectButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); selectButton->setText( tr( "&Select features" ) ); + selectButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFormSelect.svg" ) ) ); selectButton->setPopupMode( QToolButton::MenuButtonPopup ); + selectButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); connect( selectButton, &QToolButton::clicked, this, &QgsAttributeForm::searchSetSelection ); QMenu* selectMenu = new QMenu( selectButton ); QAction* selectAction = new QAction( tr( "Select features" ), selectMenu ); + selectAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFormSelect.svg" ) ) ); connect( selectAction, &QAction::triggered, this, &QgsAttributeForm::searchSetSelection ); selectMenu->addAction( selectAction ); QAction* addSelectAction = new QAction( tr( "Add to current selection" ), selectMenu ); + addSelectAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconSelectAdd.svg" ) ) ); connect( addSelectAction, &QAction::triggered, this, &QgsAttributeForm::searchAddToSelection ); selectMenu->addAction( addSelectAction ); - QAction* filterSelectAction = new QAction( tr( "Filter current selection" ), selectMenu ); - connect( filterSelectAction, &QAction::triggered, this, &QgsAttributeForm::searchIntersectSelection ); - selectMenu->addAction( filterSelectAction ); QAction* deselectAction = new QAction( tr( "Remove from current selection" ), selectMenu ); + deselectAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconSelectRemove.svg" ) ) ); connect( deselectAction, &QAction::triggered, this, &QgsAttributeForm::searchRemoveFromSelection ); selectMenu->addAction( deselectAction ); + QAction* filterSelectAction = new QAction( tr( "Filter current selection" ), selectMenu ); + filterSelectAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconSelectIntersect.svg" ) ) ); + connect( filterSelectAction, &QAction::triggered, this, &QgsAttributeForm::searchIntersectSelection ); + selectMenu->addAction( filterSelectAction ); selectButton->setMenu( selectMenu ); boxLayout->addWidget( selectButton ); diff --git a/src/gui/qgsattributeform.h b/src/gui/qgsattributeform.h index 6e5c5fe9686..af0bbc9fefc 100644 --- a/src/gui/qgsattributeform.h +++ b/src/gui/qgsattributeform.h @@ -23,6 +23,7 @@ #include #include #include +#include "qgis_gui.h" class QgsAttributeFormInterface; @@ -191,6 +192,12 @@ class GUI_EXPORT QgsAttributeForm : public QWidget */ void closed(); + /** + * Emitted when the user chooses to zoom to a filtered set of features. + * @note added in QGIS 3.0 + */ + void zoomToFeatures( const QString& filter ); + public slots: /** @@ -250,6 +257,7 @@ class GUI_EXPORT QgsAttributeForm : public QWidget void filterOrTriggered(); void filterTriggered(); + void searchZoomTo(); void searchSetSelection(); void searchAddToSelection(); void searchRemoveFromSelection(); diff --git a/src/gui/qgsattributeformeditorwidget.h b/src/gui/qgsattributeformeditorwidget.h index 58ef5ff0354..d3955de9cd0 100644 --- a/src/gui/qgsattributeformeditorwidget.h +++ b/src/gui/qgsattributeformeditorwidget.h @@ -20,6 +20,7 @@ #include #include "qgsattributeeditorcontext.h" #include "qgssearchwidgetwrapper.h" +#include "qgis_gui.h" class QgsAttributeForm; class QgsEditorWidgetWrapper; @@ -72,7 +73,7 @@ class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget const QgsAttributeEditorContext &context = QgsAttributeEditorContext() ); /** Sets the current mode for the widget. The widget will adapt its state and visible widgets to - * reflect the updated mode. Eg, showing multi edit tool buttons if the mode is set to MultiEditMode. + * reflect the updated mode. For example, showing multi edit tool buttons if the mode is set to MultiEditMode. * @param mode widget mode * @see mode() */ diff --git a/src/gui/qgsattributeforminterface.cpp b/src/gui/qgsattributeforminterface.cpp index ac9b898eda1..9e32a40d88e 100644 --- a/src/gui/qgsattributeforminterface.cpp +++ b/src/gui/qgsattributeforminterface.cpp @@ -23,10 +23,6 @@ QgsAttributeFormInterface::QgsAttributeFormInterface( QgsAttributeForm* form ) { } -QgsAttributeFormInterface::~QgsAttributeFormInterface() -{ -} - bool QgsAttributeFormInterface::acceptChanges( const QgsFeature& feature ) { Q_UNUSED( feature ) diff --git a/src/gui/qgsattributeforminterface.h b/src/gui/qgsattributeforminterface.h index 0d4e8baf67a..1d0cde60f06 100644 --- a/src/gui/qgsattributeforminterface.h +++ b/src/gui/qgsattributeforminterface.h @@ -16,6 +16,8 @@ #ifndef QGSATTRIBUTEFORMINTERFACE_H #define QGSATTRIBUTEFORMINTERFACE_H +#include "qgis_gui.h" + class QgsAttributeForm; class QgsFeature; @@ -27,7 +29,7 @@ class GUI_EXPORT QgsAttributeFormInterface public: explicit QgsAttributeFormInterface( QgsAttributeForm* form ); - virtual ~QgsAttributeFormInterface(); + virtual ~QgsAttributeFormInterface() = default; virtual bool acceptChanges( const QgsFeature& feature ); diff --git a/src/gui/qgsattributeformlegacyinterface.h b/src/gui/qgsattributeformlegacyinterface.h index ea9908d863a..11650531082 100644 --- a/src/gui/qgsattributeformlegacyinterface.h +++ b/src/gui/qgsattributeformlegacyinterface.h @@ -19,6 +19,7 @@ #include #include "qgsattributeforminterface.h" +#include "qgis_gui.h" /** \ingroup gui * This class helps to support legacy open form scripts to be compatible with the new diff --git a/src/gui/qgsattributetypeloaddialog.cpp b/src/gui/qgsattributetypeloaddialog.cpp index b10058a0b2a..d7ea04f4a11 100644 --- a/src/gui/qgsattributetypeloaddialog.cpp +++ b/src/gui/qgsattributetypeloaddialog.cpp @@ -53,11 +53,6 @@ QgsAttributeTypeLoadDialog::QgsAttributeTypeLoadDialog( QgsVectorLayer *vl ) valueComboBox->setDisabled( true ); } -QgsAttributeTypeLoadDialog::~QgsAttributeTypeLoadDialog() -{ - -} - void QgsAttributeTypeLoadDialog::setVectorLayer( QgsVectorLayer *layer ) { mLayer = layer; diff --git a/src/gui/qgsattributetypeloaddialog.h b/src/gui/qgsattributetypeloaddialog.h index b6cde689902..4e28cf451c1 100644 --- a/src/gui/qgsattributetypeloaddialog.h +++ b/src/gui/qgsattributetypeloaddialog.h @@ -20,6 +20,7 @@ #include "ui_qgsattributeloadfrommap.h" #include +#include "qgis_gui.h" class QDialog; class QLayout; @@ -36,7 +37,6 @@ class GUI_EXPORT QgsAttributeTypeLoadDialog: public QDialog, private Ui::QgsAttr public: QgsAttributeTypeLoadDialog( QgsVectorLayer *vl ); - ~QgsAttributeTypeLoadDialog(); /** * Overloaded accept method which will write the feature field diff --git a/src/gui/qgsblendmodecombobox.cpp b/src/gui/qgsblendmodecombobox.cpp index 1f6f86c3320..8bda8718c5a 100644 --- a/src/gui/qgsblendmodecombobox.cpp +++ b/src/gui/qgsblendmodecombobox.cpp @@ -30,10 +30,6 @@ QgsBlendModeComboBox::QgsBlendModeComboBox( QWidget* parent ) : QComboBox( paren updateModes(); } -QgsBlendModeComboBox::~QgsBlendModeComboBox() -{ -} - /* Returns a QStringList of the translated blend modes * "-" is used to indicate the position of a separator in the list * This list is designed to emulate GIMP's layer modes, where diff --git a/src/gui/qgsblendmodecombobox.h b/src/gui/qgsblendmodecombobox.h index c1706d4d4fb..af200596e36 100644 --- a/src/gui/qgsblendmodecombobox.h +++ b/src/gui/qgsblendmodecombobox.h @@ -20,6 +20,7 @@ #include #include // For QPainter::CompositionMode enum +#include "qgis_gui.h" /** \ingroup gui * A combobox which lets the user select blend modes from a predefined list @@ -29,7 +30,6 @@ class GUI_EXPORT QgsBlendModeComboBox : public QComboBox Q_OBJECT public: QgsBlendModeComboBox( QWidget* parent = nullptr ); - virtual ~QgsBlendModeComboBox(); //! Function to read the selected blend mode as QPainter::CompositionMode QPainter::CompositionMode blendMode(); diff --git a/src/gui/qgsbrowsertreeview.cpp b/src/gui/qgsbrowsertreeview.cpp index 3f3a1e2586b..48a5904051e 100644 --- a/src/gui/qgsbrowsertreeview.cpp +++ b/src/gui/qgsbrowsertreeview.cpp @@ -27,10 +27,6 @@ QgsBrowserTreeView::QgsBrowserTreeView( QWidget *parent ) { } -QgsBrowserTreeView::~QgsBrowserTreeView() -{ -} - void QgsBrowserTreeView::setModel( QAbstractItemModel* model ) { diff --git a/src/gui/qgsbrowsertreeview.h b/src/gui/qgsbrowsertreeview.h index a7245afc99e..8a630bdcaf1 100644 --- a/src/gui/qgsbrowsertreeview.h +++ b/src/gui/qgsbrowsertreeview.h @@ -17,6 +17,7 @@ #define QGSBROWSERTREEVIEW_H #include +#include "qgis_gui.h" //class QgsBrowserModel; @@ -31,7 +32,6 @@ class GUI_EXPORT QgsBrowserTreeView : public QTreeView Q_OBJECT public: QgsBrowserTreeView( QWidget *parent = nullptr ); - ~QgsBrowserTreeView(); virtual void setModel( QAbstractItemModel* model ) override; virtual void showEvent( QShowEvent * e ) override; diff --git a/src/gui/qgsbusyindicatordialog.cpp b/src/gui/qgsbusyindicatordialog.cpp index 3611439dd70..cb9db621df2 100644 --- a/src/gui/qgsbusyindicatordialog.cpp +++ b/src/gui/qgsbusyindicatordialog.cpp @@ -44,10 +44,6 @@ QgsBusyIndicatorDialog::QgsBusyIndicatorDialog( const QString& message, QWidget* } } -QgsBusyIndicatorDialog::~QgsBusyIndicatorDialog() -{ -} - void QgsBusyIndicatorDialog::setMessage( const QString& message ) { if ( !message.isEmpty() ) diff --git a/src/gui/qgsbusyindicatordialog.h b/src/gui/qgsbusyindicatordialog.h index 826125f7938..cc5703a1dd4 100644 --- a/src/gui/qgsbusyindicatordialog.h +++ b/src/gui/qgsbusyindicatordialog.h @@ -22,6 +22,7 @@ #include #include +#include "qgis_gui.h" /** \ingroup gui @@ -40,7 +41,6 @@ class GUI_EXPORT QgsBusyIndicatorDialog : public QDialog * @param fl widget flags */ QgsBusyIndicatorDialog( const QString& message = "", QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - ~QgsBusyIndicatorDialog(); QString message() const { return mMessage; } void setMessage( const QString& message ); diff --git a/src/gui/qgscharacterselectdialog.cpp b/src/gui/qgscharacterselectdialog.cpp index 09aed07df26..168c5d1bc3e 100644 --- a/src/gui/qgscharacterselectdialog.cpp +++ b/src/gui/qgscharacterselectdialog.cpp @@ -28,10 +28,6 @@ QgsCharacterSelectorDialog::QgsCharacterSelectorDialog( QWidget *parent, Qt::Win connect( mCharWidget, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) ); } -QgsCharacterSelectorDialog::~QgsCharacterSelectorDialog() -{ -} - const QChar& QgsCharacterSelectorDialog::selectCharacter( bool* gotChar, const QFont& font, const QString& style ) { mCharSelectLabelFont->setText( QStringLiteral( "%1 %2" ).arg( font.family(), style ) ); diff --git a/src/gui/qgscharacterselectdialog.h b/src/gui/qgscharacterselectdialog.h index 8c9a3d49aa7..82d45048c43 100644 --- a/src/gui/qgscharacterselectdialog.h +++ b/src/gui/qgscharacterselectdialog.h @@ -21,6 +21,7 @@ #include #include "qgisgui.h" #include "ui_qgscharacterselectdialogbase.h" +#include "qgis_gui.h" class CharacterWidget; @@ -34,7 +35,6 @@ class GUI_EXPORT QgsCharacterSelectorDialog : public QDialog, private Ui::QgsCha public: QgsCharacterSelectorDialog( QWidget* parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - ~QgsCharacterSelectorDialog(); public slots: const QChar& selectCharacter( bool* gotChar, const QFont& font, const QString& style ); diff --git a/src/gui/qgscodeeditor.cpp b/src/gui/qgscodeeditor.cpp index 374319fe21b..a6b407f293b 100644 --- a/src/gui/qgscodeeditor.cpp +++ b/src/gui/qgscodeeditor.cpp @@ -40,10 +40,6 @@ QgsCodeEditor::QgsCodeEditor( QWidget *parent, const QString& title, bool foldin setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); } -QgsCodeEditor::~QgsCodeEditor() -{ -} - // Workaround a bug in QScintilla 2.8.X void QgsCodeEditor::focusOutEvent( QFocusEvent *event ) { diff --git a/src/gui/qgscodeeditor.h b/src/gui/qgscodeeditor.h index 8149e8d4414..f7387d5187d 100644 --- a/src/gui/qgscodeeditor.h +++ b/src/gui/qgscodeeditor.h @@ -20,6 +20,7 @@ #include // qscintilla includes #include +#include "qgis_gui.h" class QWidget; @@ -45,7 +46,6 @@ class GUI_EXPORT QgsCodeEditor : public QsciScintilla * @note added in 2.6 */ QgsCodeEditor( QWidget *parent = nullptr, const QString& title = "", bool folding = false, bool margin = false ); - ~QgsCodeEditor(); /** Set the widget title * @param title widget title diff --git a/src/gui/qgscodeeditorcss.cpp b/src/gui/qgscodeeditorcss.cpp index 0d5f4571f5e..a881be23195 100644 --- a/src/gui/qgscodeeditorcss.cpp +++ b/src/gui/qgscodeeditorcss.cpp @@ -34,10 +34,6 @@ QgsCodeEditorCSS::QgsCodeEditorCSS( QWidget *parent ) setSciLexerCSS(); } -QgsCodeEditorCSS::~QgsCodeEditorCSS() -{ -} - void QgsCodeEditorCSS::setSciLexerCSS() { QsciLexerCSS* lexer = new QsciLexerCSS( this ); diff --git a/src/gui/qgscodeeditorcss.h b/src/gui/qgscodeeditorcss.h index 3f49ddef512..b76c6123967 100644 --- a/src/gui/qgscodeeditorcss.h +++ b/src/gui/qgscodeeditorcss.h @@ -17,6 +17,7 @@ #define QGSCODEEDITORCSS_H #include "qgscodeeditor.h" +#include "qgis_gui.h" /** \ingroup gui @@ -30,7 +31,6 @@ class GUI_EXPORT QgsCodeEditorCSS : public QgsCodeEditor public: QgsCodeEditorCSS( QWidget *parent = nullptr ); - ~QgsCodeEditorCSS(); private: void setSciLexerCSS(); diff --git a/src/gui/qgscodeeditorhtml.cpp b/src/gui/qgscodeeditorhtml.cpp index cdacebbba9c..29c07cd4d31 100644 --- a/src/gui/qgscodeeditorhtml.cpp +++ b/src/gui/qgscodeeditorhtml.cpp @@ -34,10 +34,6 @@ QgsCodeEditorHTML::QgsCodeEditorHTML( QWidget *parent ) setSciLexerHTML(); } -QgsCodeEditorHTML::~QgsCodeEditorHTML() -{ -} - void QgsCodeEditorHTML::setSciLexerHTML() { QsciLexerHTML* lexer = new QsciLexerHTML( this ); diff --git a/src/gui/qgscodeeditorhtml.h b/src/gui/qgscodeeditorhtml.h index 9cea35bb355..7f564d4a14e 100644 --- a/src/gui/qgscodeeditorhtml.h +++ b/src/gui/qgscodeeditorhtml.h @@ -17,6 +17,7 @@ #define QGSCODEEDITORHTML_H #include "qgscodeeditor.h" +#include "qgis_gui.h" /** \ingroup gui @@ -31,7 +32,6 @@ class GUI_EXPORT QgsCodeEditorHTML : public QgsCodeEditor public: QgsCodeEditorHTML( QWidget *parent = nullptr ); - ~QgsCodeEditorHTML(); private: void setSciLexerHTML(); diff --git a/src/gui/qgscodeeditorpython.cpp b/src/gui/qgscodeeditorpython.cpp index 3e112b39b9d..03ccafeeb74 100644 --- a/src/gui/qgscodeeditorpython.cpp +++ b/src/gui/qgscodeeditorpython.cpp @@ -36,10 +36,6 @@ QgsCodeEditorPython::QgsCodeEditorPython( QWidget *parent, const QList setSciLexerPython(); } -QgsCodeEditorPython::~QgsCodeEditorPython() -{ -} - void QgsCodeEditorPython::setSciLexerPython() { // current line diff --git a/src/gui/qgscodeeditorpython.h b/src/gui/qgscodeeditorpython.h index b59acdd5d8d..adf1f078824 100644 --- a/src/gui/qgscodeeditorpython.h +++ b/src/gui/qgscodeeditorpython.h @@ -17,6 +17,7 @@ #define QGSCODEEDITORPYTHON_H #include "qgscodeeditor.h" +#include "qgis_gui.h" /** \ingroup gui @@ -39,7 +40,6 @@ class GUI_EXPORT QgsCodeEditorPython : public QgsCodeEditor * @note added in 2.6 */ QgsCodeEditorPython( QWidget *parent = nullptr, const QList &filenames = QList() ); - ~QgsCodeEditorPython(); /** Load APIs from one or more files * @param filenames The list of apis files to load for the python lexer diff --git a/src/gui/qgscodeeditorsql.cpp b/src/gui/qgscodeeditorsql.cpp index ab168e6c0a8..10b59cc08b9 100644 --- a/src/gui/qgscodeeditorsql.cpp +++ b/src/gui/qgscodeeditorsql.cpp @@ -36,10 +36,6 @@ QgsCodeEditorSQL::QgsCodeEditorSQL( QWidget *parent ) setSciLexerSQL(); } -QgsCodeEditorSQL::~QgsCodeEditorSQL() -{ -} - /** Internal use. setAutoCompletionCaseSensitivity( false ) is not sufficient when installing diff --git a/src/gui/qgscodeeditorsql.h b/src/gui/qgscodeeditorsql.h index f7441fc1223..cbbeed1d965 100644 --- a/src/gui/qgscodeeditorsql.h +++ b/src/gui/qgscodeeditorsql.h @@ -17,6 +17,7 @@ #define QGSCODEEDITORSQL_H #include "qgscodeeditor.h" +#include "qgis_gui.h" /** \ingroup gui @@ -31,7 +32,6 @@ class GUI_EXPORT QgsCodeEditorSQL : public QgsCodeEditor public: QgsCodeEditorSQL( QWidget *parent = nullptr ); - ~QgsCodeEditorSQL(); private: //QgsCodeEditor *mSciWidget; diff --git a/src/gui/qgscollapsiblegroupbox.cpp b/src/gui/qgscollapsiblegroupbox.cpp index 9c950dfef8f..bd204d4005b 100644 --- a/src/gui/qgscollapsiblegroupbox.cpp +++ b/src/gui/qgscollapsiblegroupbox.cpp @@ -40,10 +40,6 @@ QgsCollapsibleGroupBoxBasic::QgsCollapsibleGroupBoxBasic( const QString &title, init(); } -QgsCollapsibleGroupBoxBasic::~QgsCollapsibleGroupBoxBasic() -{ -} - void QgsCollapsibleGroupBoxBasic::init() { // variables diff --git a/src/gui/qgscollapsiblegroupbox.h b/src/gui/qgscollapsiblegroupbox.h index f315f57fa9b..fb00a4db4c4 100644 --- a/src/gui/qgscollapsiblegroupbox.h +++ b/src/gui/qgscollapsiblegroupbox.h @@ -23,6 +23,7 @@ #include #include #include +#include "qgis_gui.h" class QToolButton; class QScrollArea; @@ -41,8 +42,6 @@ class GUI_EXPORT QgsGroupBoxCollapseButton : public QToolButton , mShiftDown( false ) {} - ~QgsGroupBoxCollapseButton() {} - bool altDown() const { return mAltDown; } void setAltDown( bool updown ) { mAltDown = updown; } @@ -97,7 +96,6 @@ class GUI_EXPORT QgsCollapsibleGroupBoxBasic : public QGroupBox public: QgsCollapsibleGroupBoxBasic( QWidget *parent = nullptr ); QgsCollapsibleGroupBoxBasic( const QString &title, QWidget *parent = nullptr ); - ~QgsCollapsibleGroupBoxBasic(); /** * Returns the current collapsed state of this group box diff --git a/src/gui/qgscolorbrewercolorrampdialog.h b/src/gui/qgscolorbrewercolorrampdialog.h index 92e474bbe30..68079923281 100644 --- a/src/gui/qgscolorbrewercolorrampdialog.h +++ b/src/gui/qgscolorbrewercolorrampdialog.h @@ -20,6 +20,7 @@ #include "qgspanelwidget.h" #include "qgscolorramp.h" #include "ui_qgscolorbrewercolorrampwidgetbase.h" +#include "qgis_gui.h" class QgsColorBrewerColorRamp; diff --git a/src/gui/qgscolorbutton.cpp b/src/gui/qgscolorbutton.cpp index 591d571d973..a7705efefaf 100644 --- a/src/gui/qgscolorbutton.cpp +++ b/src/gui/qgscolorbutton.cpp @@ -55,7 +55,7 @@ QgsColorButton::QgsColorButton( QWidget *parent, const QString& cdt, QgsColorSch { //if a color scheme registry was specified, use it, otherwise use the global instance - mColorSchemeRegistry = registry ? registry : QgsColorSchemeRegistry::instance(); + mColorSchemeRegistry = registry ? registry : QgsApplication::colorSchemeRegistry(); setAcceptDrops( true ); setMinimumSize( QSize( 24, 16 ) ); @@ -68,10 +68,6 @@ QgsColorButton::QgsColorButton( QWidget *parent, const QString& cdt, QgsColorSch setPopupMode( QToolButton::MenuButtonPopup ); } -QgsColorButton::~QgsColorButton() -{ -} - QSize QgsColorButton::sizeHint() const { //make sure height of button looks good under different platforms diff --git a/src/gui/qgscolorbutton.h b/src/gui/qgscolorbutton.h index 1968ec94ac5..9ec8763a22e 100644 --- a/src/gui/qgscolorbutton.h +++ b/src/gui/qgscolorbutton.h @@ -18,6 +18,7 @@ #include #include #include +#include "qgis_gui.h" class QMimeData; class QgsColorSchemeRegistry; @@ -64,8 +65,6 @@ class GUI_EXPORT QgsColorButton : public QToolButton */ QgsColorButton( QWidget *parent = nullptr, const QString& cdt = "", QgsColorSchemeRegistry* registry = nullptr ); - virtual ~QgsColorButton(); - virtual QSize sizeHint() const override; /** Return the currently selected color. diff --git a/src/gui/qgscolordialog.cpp b/src/gui/qgscolordialog.cpp index 12c2f85cf35..5d80c869c5c 100644 --- a/src/gui/qgscolordialog.cpp +++ b/src/gui/qgscolordialog.cpp @@ -58,11 +58,6 @@ QgsColorDialog::QgsColorDialog( QWidget *parent, Qt::WindowFlags fl, const QColo connect( this, SIGNAL( rejected() ), this, SLOT( discardColor() ) ); } -QgsColorDialog::~QgsColorDialog() -{ - -} - QColor QgsColorDialog::color() const { return mColorWidget->color(); diff --git a/src/gui/qgscolordialog.h b/src/gui/qgscolordialog.h index 919c878f7a1..461546da135 100644 --- a/src/gui/qgscolordialog.h +++ b/src/gui/qgscolordialog.h @@ -19,6 +19,7 @@ #include #include "ui_qgscolordialog.h" +#include "qgis_gui.h" class QColor; @@ -44,8 +45,6 @@ class GUI_EXPORT QgsColorDialog : public QDialog, private Ui::QgsColorDialogBase QgsColorDialog( QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags, const QColor& color = QColor() ); - ~QgsColorDialog(); - /** Returns the current color for the dialog * @returns dialog color */ diff --git a/src/gui/qgscolorrampbutton.h b/src/gui/qgscolorrampbutton.h index a7b565aeb9a..407f4bdac17 100644 --- a/src/gui/qgscolorrampbutton.h +++ b/src/gui/qgscolorrampbutton.h @@ -21,6 +21,7 @@ #include "qgsstyle.h" #include +#include "qgis_gui.h" class QgsPanelWidget; diff --git a/src/gui/qgscolorschemelist.cpp b/src/gui/qgscolorschemelist.cpp index 5e8857e28e7..e74a841d8c6 100644 --- a/src/gui/qgscolorschemelist.cpp +++ b/src/gui/qgscolorschemelist.cpp @@ -53,11 +53,6 @@ QgsColorSchemeList::QgsColorSchemeList( QWidget *parent, QgsColorScheme *scheme, setDefaultDropAction( Qt::CopyAction ); } -QgsColorSchemeList::~QgsColorSchemeList() -{ - -} - void QgsColorSchemeList::setScheme( QgsColorScheme *scheme, const QString &context, const QColor &baseColor ) { mScheme = scheme; @@ -313,11 +308,6 @@ QgsColorSchemeModel::QgsColorSchemeModel( QgsColorScheme *scheme, const QString } } -QgsColorSchemeModel::~QgsColorSchemeModel() -{ - -} - QModelIndex QgsColorSchemeModel::index( int row, int column, const QModelIndex &parent ) const { if ( column < 0 || column >= columnCount() ) diff --git a/src/gui/qgscolorschemelist.h b/src/gui/qgscolorschemelist.h index 5caa9a43b86..13f0afe4840 100644 --- a/src/gui/qgscolorschemelist.h +++ b/src/gui/qgscolorschemelist.h @@ -20,6 +20,7 @@ #include #include #include +#include "qgis_gui.h" class QMimeData; class QgsPanelWidget; @@ -74,8 +75,6 @@ class GUI_EXPORT QgsColorSchemeModel: public QAbstractItemModel */ explicit QgsColorSchemeModel( QgsColorScheme* scheme, const QString &context = QString(), const QColor &baseColor = QColor(), QObject* parent = nullptr ); - ~QgsColorSchemeModel(); - //reimplemented QAbstractItemModel methods QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override; QModelIndex parent( const QModelIndex &index ) const override; @@ -163,8 +162,6 @@ class GUI_EXPORT QgsColorSchemeList: public QTreeView */ QgsColorSchemeList( QWidget *parent = nullptr, QgsColorScheme* scheme = nullptr, const QString &context = QString(), const QColor &baseColor = QColor() ); - virtual ~QgsColorSchemeList(); - /** Saves the current colors shown in the list back to a color scheme, if supported * by the color scheme. * @note this method is only effective if the color scheme is editable diff --git a/src/gui/qgscolorswatchgrid.cpp b/src/gui/qgscolorswatchgrid.cpp index cb48acec027..ae0060edc8c 100644 --- a/src/gui/qgscolorswatchgrid.cpp +++ b/src/gui/qgscolorswatchgrid.cpp @@ -52,11 +52,6 @@ QgsColorSwatchGrid::QgsColorSwatchGrid( QgsColorScheme* scheme, const QString& c refreshColors(); } -QgsColorSwatchGrid::~QgsColorSwatchGrid() -{ - -} - QSize QgsColorSwatchGrid::minimumSizeHint() const { return QSize( mWidth, calculateHeight() ); @@ -376,11 +371,6 @@ QgsColorSwatchGridAction::QgsColorSwatchGridAction( QgsColorScheme* scheme, QMen setVisible( !mColorSwatchGrid->colors()->isEmpty() ); } -QgsColorSwatchGridAction::~QgsColorSwatchGridAction() -{ - -} - void QgsColorSwatchGridAction::setBaseColor( const QColor &baseColor ) { mColorSwatchGrid->setBaseColor( baseColor ); diff --git a/src/gui/qgscolorswatchgrid.h b/src/gui/qgscolorswatchgrid.h index 18edfb4c505..ac9f0021334 100644 --- a/src/gui/qgscolorswatchgrid.h +++ b/src/gui/qgscolorswatchgrid.h @@ -18,6 +18,7 @@ #include "qgscolorscheme.h" #include #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsColorSwatchGrid @@ -39,8 +40,6 @@ class GUI_EXPORT QgsColorSwatchGrid : public QWidget */ QgsColorSwatchGrid( QgsColorScheme* scheme, const QString& context = QString(), QWidget *parent = nullptr ); - virtual ~QgsColorSwatchGrid(); - //Reimplemented to set fixed size on widget virtual QSize minimumSizeHint() const override; @@ -169,8 +168,6 @@ class GUI_EXPORT QgsColorSwatchGridAction: public QWidgetAction */ QgsColorSwatchGridAction( QgsColorScheme* scheme, QMenu* menu = nullptr, const QString& context = QString(), QWidget *parent = nullptr ); - virtual ~QgsColorSwatchGridAction(); - /** Sets the base color for the color grid * @param baseColor base color to pass to scheme for color generation * @see baseColor diff --git a/src/gui/qgscolorwidgets.cpp b/src/gui/qgscolorwidgets.cpp index f75d142e6a5..2d7c8aaf249 100644 --- a/src/gui/qgscolorwidgets.cpp +++ b/src/gui/qgscolorwidgets.cpp @@ -44,11 +44,6 @@ QgsColorWidget::QgsColorWidget( QWidget* parent, const ColorComponent component setAcceptDrops( true ); } -QgsColorWidget::~QgsColorWidget() -{ - -} - int QgsColorWidget::componentValue() const { return componentValue( mComponent ); @@ -993,11 +988,6 @@ QgsColorRampWidget::QgsColorRampWidget( QWidget *parent, setMarkerSize( 5 ); } -QgsColorRampWidget::~QgsColorRampWidget() -{ - -} - QSize QgsColorRampWidget::sizeHint() const { if ( mOrientation == QgsColorRampWidget::Horizontal ) @@ -1316,10 +1306,6 @@ QgsColorSliderWidget::QgsColorSliderWidget( QWidget *parent, const ColorComponen connect( mSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( spinChanged( int ) ) ); } -QgsColorSliderWidget::~QgsColorSliderWidget() -{ -} - void QgsColorSliderWidget::setComponent( const QgsColorWidget::ColorComponent component ) { QgsColorWidget::setComponent( component ); @@ -1447,11 +1433,6 @@ QgsColorTextWidget::QgsColorTextWidget( QWidget *parent ) updateText(); } -QgsColorTextWidget::~QgsColorTextWidget() -{ - -} - void QgsColorTextWidget::setColor( const QColor &color, const bool emitSignals ) { QgsColorWidget::setColor( color, emitSignals ); @@ -1563,11 +1544,6 @@ QgsColorPreviewWidget::QgsColorPreviewWidget( QWidget *parent ) } -QgsColorPreviewWidget::~QgsColorPreviewWidget() -{ - -} - void QgsColorPreviewWidget::drawColor( const QColor &color, QRect rect, QPainter& painter ) { painter.setPen( Qt::NoPen ); @@ -1725,11 +1701,6 @@ QgsColorWidgetAction::QgsColorWidgetAction( QgsColorWidget* colorWidget, QMenu* connect( mColorWidget, SIGNAL( hovered() ), this, SLOT( onHover() ) ); } -QgsColorWidgetAction::~QgsColorWidgetAction() -{ - -} - void QgsColorWidgetAction::onHover() { //see https://bugreports.qt-project.org/browse/QTBUG-10427?focusedCommentId=185610&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-185610 diff --git a/src/gui/qgscolorwidgets.h b/src/gui/qgscolorwidgets.h index 57ca838f534..b127b494524 100644 --- a/src/gui/qgscolorwidgets.h +++ b/src/gui/qgscolorwidgets.h @@ -18,6 +18,7 @@ #include #include +#include "qgis_gui.h" class QColor; class QSpinBox; @@ -27,9 +28,9 @@ class QToolButton; /** \ingroup gui * \class QgsColorWidget * A base class for interactive color widgets. Widgets can either allow setting a single component of - * a color (eg the red or green components), or an entire color. The QgsColorWidget also keeps track of + * a color (e.g., the red or green components), or an entire color. The QgsColorWidget also keeps track of * any explicitly set hue for the color, so that this information is not lost when the widget is - * set to a color with an ambiguous hue (eg black or white shades). + * set to a color with an ambiguous hue (e.g., black or white shades). * \note Added in version 2.5 */ @@ -59,8 +60,6 @@ class GUI_EXPORT QgsColorWidget : public QWidget */ QgsColorWidget( QWidget* parent = nullptr, const ColorComponent component = Multiple ); - virtual ~QgsColorWidget(); - /** Returns the current color for the widget * @returns current widget color * @see setColor @@ -129,7 +128,7 @@ class GUI_EXPORT QgsColorWidget : public QWidget ColorComponent mComponent; - /** QColor wipes the hue information when it is ambiguous (eg, for saturation = 0). So + /** QColor wipes the hue information when it is ambiguous (e.g., for saturation = 0). So * the hue is stored in mExplicit hue to keep it around, as it is useful when modifying colors */ int mExplicitHue; @@ -145,7 +144,7 @@ class GUI_EXPORT QgsColorWidget : public QWidget int componentRange( const ColorComponent component ) const; /** Returns the value of a component of the widget's current color. This method correctly - * handles hue values when the color has an ambiguous hue (eg black or white shades) + * handles hue values when the color has an ambiguous hue (e.g., black or white shades) * @param component color component to return * @returns value of color component, or -1 if widget has an invalid color set * @see hue @@ -153,7 +152,7 @@ class GUI_EXPORT QgsColorWidget : public QWidget int componentValue( const ColorComponent component ) const; /** Returns the hue for the widget. This may differ from the hue for the QColor returned by color(), - * as QColor returns a hue of -1 if the color's hue is ambiguous (eg, if the saturation is zero). + * as QColor returns a hue of -1 if the color's hue is ambiguous (e.g., if the saturation is zero). * @returns explicitly set hue for widget */ int hue() const; @@ -203,8 +202,6 @@ class GUI_EXPORT QgsColorWidgetAction: public QWidgetAction */ QgsColorWidgetAction( QgsColorWidget* colorWidget, QMenu* menu = nullptr, QWidget *parent = nullptr ); - virtual ~QgsColorWidgetAction(); - /** Returns the color widget contained in the widget action. */ QgsColorWidget* colorWidget() { return mColorWidget; } @@ -432,7 +429,7 @@ class GUI_EXPORT QgsColorBox : public QgsColorWidget /** \ingroup gui * \class QgsColorRampWidget * A color ramp widget. This widget consists of an interactive box filled with a color which varies along - * its length by a single color component (eg, varying saturation from 0 to 100%). + * its length by a single color component (e.g., varying saturation from 0 to 100%). * \note Added in version 2.5 */ @@ -459,8 +456,6 @@ class GUI_EXPORT QgsColorRampWidget : public QgsColorWidget const ColorComponent component = QgsColorWidget::Red, const Orientation orientation = QgsColorRampWidget::Horizontal ); - virtual ~QgsColorRampWidget(); - virtual QSize sizeHint() const override; void paintEvent( QPaintEvent* event ) override; @@ -562,8 +557,6 @@ class GUI_EXPORT QgsColorSliderWidget : public QgsColorWidget */ QgsColorSliderWidget( QWidget* parent = nullptr, const ColorComponent component = QgsColorWidget::Red ); - virtual ~QgsColorSliderWidget(); - virtual void setComponent( const ColorComponent component ) override; virtual void setComponentValue( const int value ) override; virtual void setColor( const QColor &color, const bool emitSignals = false ) override; @@ -626,8 +619,6 @@ class GUI_EXPORT QgsColorTextWidget : public QgsColorWidget */ QgsColorTextWidget( QWidget* parent = nullptr ); - virtual ~QgsColorTextWidget(); - virtual void setColor( const QColor &color, const bool emitSignals = false ) override; protected: @@ -686,8 +677,6 @@ class GUI_EXPORT QgsColorPreviewWidget : public QgsColorWidget */ QgsColorPreviewWidget( QWidget* parent = nullptr ); - virtual ~QgsColorPreviewWidget(); - void paintEvent( QPaintEvent* event ) override; virtual QSize sizeHint() const override; diff --git a/src/gui/qgscomposeritemcombobox.h b/src/gui/qgscomposeritemcombobox.h index e6a5c2b9db3..d3d2fde13bb 100644 --- a/src/gui/qgscomposeritemcombobox.h +++ b/src/gui/qgscomposeritemcombobox.h @@ -18,6 +18,7 @@ #include #include "qgscomposeritem.h" +#include "qgis_gui.h" class QgsComposerProxyModel; diff --git a/src/gui/qgscomposerruler.cpp b/src/gui/qgscomposerruler.cpp index f9be45d22f0..458431781b6 100644 --- a/src/gui/qgscomposerruler.cpp +++ b/src/gui/qgscomposerruler.cpp @@ -338,17 +338,17 @@ int QgsComposerRuler::optimumNumberDivisions( double rulerScale, int scaleMultip switch ( scaleMultiple ) { case 1: - //numbers increase by 1 increment each time, eg 1, 2, 3 or 10, 20, 30 + //numbers increase by 1 increment each time, e.g., 1, 2, 3 or 10, 20, 30 //so we can draw either 10, 5 or 2 small ticks and have each fall on a nice value validSmallDivisions << 10 << 5 << 2; break; case 2: - //numbers increase by 2 increments each time, eg 2, 4, 6 or 20, 40, 60 + //numbers increase by 2 increments each time, e.g., 2, 4, 6 or 20, 40, 60 //so we can draw either 10, 4 or 2 small ticks and have each fall on a nice value validSmallDivisions << 10 << 4 << 2; break; case 5: - //numbers increase by 5 increments each time, eg 5, 10, 15 or 100, 500, 1000 + //numbers increase by 5 increments each time, e.g., 5, 10, 15 or 100, 500, 1000 //so we can draw either 10 or 5 small ticks and have each fall on a nice value validSmallDivisions << 10 << 5; break; diff --git a/src/gui/qgscomposerruler.h b/src/gui/qgscomposerruler.h index ac695f2a382..2a5a521405b 100644 --- a/src/gui/qgscomposerruler.h +++ b/src/gui/qgscomposerruler.h @@ -17,6 +17,7 @@ #include "qgscomposeritem.h" #include +#include "qgis_gui.h" class QgsComposition; class QGraphicsLineItem; diff --git a/src/gui/qgscomposerview.cpp b/src/gui/qgscomposerview.cpp index 9edb2daa820..52799707f9f 100644 --- a/src/gui/qgscomposerview.cpp +++ b/src/gui/qgscomposerview.cpp @@ -335,7 +335,7 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e ) } //find highest non-locked QgsComposerItem at clicked position - //(other graphics items may be higher, eg selection handles) + //(other graphics items may be higher, e.g., selection handles) QList::iterator itemIter = itemsAtCursorPos.begin(); for ( ; itemIter != itemsAtCursorPos.end(); ++itemIter ) { @@ -1951,7 +1951,7 @@ void QgsComposerView::wheelEvent( QWheelEvent* event ) { if ( mRubberBandItem || mRubberBandLineItem ) { - //ignore wheel events while marquee operations are active (eg, creating new item) + //ignore wheel events while marquee operations are active (e.g., creating new item) return; } diff --git a/src/gui/qgscomposerview.h b/src/gui/qgscomposerview.h index fb302e5ef9e..a4ad0659a68 100644 --- a/src/gui/qgscomposerview.h +++ b/src/gui/qgscomposerview.h @@ -20,6 +20,7 @@ #include #include "qgsprevieweffect.h" // for QgsPreviewEffect::PreviewMode #include +#include "qgis_gui.h" class QDomDocument; class QDomElement; diff --git a/src/gui/qgscompoundcolorwidget.cpp b/src/gui/qgscompoundcolorwidget.cpp index 4e65ff7d0bf..cd695b7966b 100644 --- a/src/gui/qgscompoundcolorwidget.cpp +++ b/src/gui/qgscompoundcolorwidget.cpp @@ -60,7 +60,7 @@ QgsCompoundColorWidget::QgsCompoundColorWidget( QWidget *parent, const QColor& c //get schemes with ShowInColorDialog set refreshSchemeComboBox(); - QList schemeList = QgsColorSchemeRegistry::instance()->schemes( QgsColorScheme::ShowInColorDialog ); + QList schemeList = QgsApplication::colorSchemeRegistry()->schemes( QgsColorScheme::ShowInColorDialog ); //choose a reasonable starting scheme int activeScheme = settings.value( QStringLiteral( "/Windows/ColorDialog/activeScheme" ), 0 ).toInt(); @@ -270,7 +270,7 @@ void QgsCompoundColorWidget::refreshSchemeComboBox() { mSchemeComboBox->blockSignals( true ); mSchemeComboBox->clear(); - QList schemeList = QgsColorSchemeRegistry::instance()->schemes( QgsColorScheme::ShowInColorDialog ); + QList schemeList = QgsApplication::colorSchemeRegistry()->schemes( QgsColorScheme::ShowInColorDialog ); QList::const_iterator schemeIt = schemeList.constBegin(); for ( ; schemeIt != schemeList.constEnd(); ++schemeIt ) { @@ -323,7 +323,7 @@ void QgsCompoundColorWidget::importPalette() importedScheme->setName( paletteName ); importedScheme->setColors( importedColors ); - QgsColorSchemeRegistry::instance()->addColorScheme( importedScheme ); + QgsApplication::colorSchemeRegistry()->addColorScheme( importedScheme ); //refresh combobox refreshSchemeComboBox(); @@ -333,7 +333,7 @@ void QgsCompoundColorWidget::importPalette() void QgsCompoundColorWidget::removePalette() { //get current scheme - QList schemeList = QgsColorSchemeRegistry::instance()->schemes( QgsColorScheme::ShowInColorDialog ); + QList schemeList = QgsApplication::colorSchemeRegistry()->schemes( QgsColorScheme::ShowInColorDialog ); int prevIndex = mSchemeComboBox->currentIndex(); if ( prevIndex >= schemeList.length() ) { @@ -363,7 +363,7 @@ void QgsCompoundColorWidget::removePalette() } //remove scheme from registry - QgsColorSchemeRegistry::instance()->removeColorScheme( userScheme ); + QgsApplication::colorSchemeRegistry()->removeColorScheme( userScheme ); refreshSchemeComboBox(); prevIndex = qMax( qMin( prevIndex, mSchemeComboBox->count() - 1 ), 0 ); mSchemeComboBox->setCurrentIndex( prevIndex ); @@ -401,7 +401,7 @@ void QgsCompoundColorWidget::newPalette() QgsUserColorScheme* newScheme = new QgsUserColorScheme( destFileInfo.fileName() ); newScheme->setName( name ); - QgsColorSchemeRegistry::instance()->addColorScheme( newScheme ); + QgsApplication::colorSchemeRegistry()->addColorScheme( newScheme ); //refresh combobox and set new scheme as active refreshSchemeComboBox(); @@ -430,7 +430,7 @@ void QgsCompoundColorWidget::schemeIndexChanged( int index ) } //get schemes with ShowInColorDialog set - QList schemeList = QgsColorSchemeRegistry::instance()->schemes( QgsColorScheme::ShowInColorDialog ); + QList schemeList = QgsApplication::colorSchemeRegistry()->schemes( QgsColorScheme::ShowInColorDialog ); if ( index >= schemeList.length() ) { return; diff --git a/src/gui/qgscompoundcolorwidget.h b/src/gui/qgscompoundcolorwidget.h index d7740fa6d55..e8f6fc5d413 100644 --- a/src/gui/qgscompoundcolorwidget.h +++ b/src/gui/qgscompoundcolorwidget.h @@ -19,6 +19,7 @@ #include "qgisgui.h" #include "qgspanelwidget.h" #include "ui_qgscompoundcolorwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsCompoundColorWidget diff --git a/src/gui/qgsconfigureshortcutsdialog.cpp b/src/gui/qgsconfigureshortcutsdialog.cpp index c31a523de6d..3543684c209 100644 --- a/src/gui/qgsconfigureshortcutsdialog.cpp +++ b/src/gui/qgsconfigureshortcutsdialog.cpp @@ -28,6 +28,7 @@ #include #include #include +#include QgsConfigureShortcutsDialog::QgsConfigureShortcutsDialog( QWidget* parent, QgsShortcutsManager* manager ) : QDialog( parent ) @@ -480,3 +481,19 @@ void QgsConfigureShortcutsDialog::setCurrentActionShortcut( const QKeySequence& actionChanged( treeActions->currentItem(), nullptr ); } + +void QgsConfigureShortcutsDialog::on_mLeFilter_textChanged( const QString& text ) +{ + for ( int i = 0; i < treeActions->topLevelItemCount(); i++ ) + { + QTreeWidgetItem* item = treeActions->topLevelItem( i ); + if ( !item->text( 0 ).contains( text, Qt::CaseInsensitive ) && !item->text( 1 ).contains( text, Qt::CaseInsensitive ) ) + { + item->setHidden( true ); + } + else + { + item->setHidden( false ); + } + } +} diff --git a/src/gui/qgsconfigureshortcutsdialog.h b/src/gui/qgsconfigureshortcutsdialog.h index c7c25423853..600889a202d 100644 --- a/src/gui/qgsconfigureshortcutsdialog.h +++ b/src/gui/qgsconfigureshortcutsdialog.h @@ -19,6 +19,7 @@ #include #include "ui_qgsconfigureshortcutsdialog.h" +#include "qgis_gui.h" class QShortcut; class QgsShortcutsManager; @@ -54,6 +55,7 @@ class GUI_EXPORT QgsConfigureShortcutsDialog : public QDialog, private Ui::QgsCo void setNoShortcut(); void saveShortcuts(); void loadShortcuts(); + void on_mLeFilter_textChanged( const QString& text ); void actionChanged( QTreeWidgetItem* current, QTreeWidgetItem* previous ); diff --git a/src/gui/qgscredentialdialog.cpp b/src/gui/qgscredentialdialog.cpp index 63e71946ca8..246a9c32d37 100644 --- a/src/gui/qgscredentialdialog.cpp +++ b/src/gui/qgscredentialdialog.cpp @@ -46,10 +46,6 @@ QgsCredentialDialog::QgsCredentialDialog( QWidget *parent, Qt::WindowFlags fl ) leUsername->setFocus(); } -QgsCredentialDialog::~QgsCredentialDialog() -{ -} - bool QgsCredentialDialog::request( const QString& realm, QString &username, QString &password, const QString& message ) { bool ok; diff --git a/src/gui/qgscredentialdialog.h b/src/gui/qgscredentialdialog.h index adf9d63efa7..524bd8e7301 100644 --- a/src/gui/qgscredentialdialog.h +++ b/src/gui/qgscredentialdialog.h @@ -22,6 +22,7 @@ #include "qgscredentials.h" #include +#include "qgis_gui.h" class QPushButton; @@ -33,7 +34,6 @@ class GUI_EXPORT QgsCredentialDialog : public QDialog, public QgsCredentials, pr Q_OBJECT public: QgsCredentialDialog( QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - ~QgsCredentialDialog(); signals: diff --git a/src/gui/qgscursors.h b/src/gui/qgscursors.h index 7728eb786f6..0cb202e3223 100644 --- a/src/gui/qgscursors.h +++ b/src/gui/qgscursors.h @@ -18,6 +18,8 @@ #ifndef QGSCURSORS_H #define QGSCURSORS_H +#include "qgis_gui.h" + /** \ingroup gui * Bitmap cursors for map operations. */ diff --git a/src/gui/qgscustomdrophandler.cpp b/src/gui/qgscustomdrophandler.cpp index 55388c51343..74ed40ee6a1 100644 --- a/src/gui/qgscustomdrophandler.cpp +++ b/src/gui/qgscustomdrophandler.cpp @@ -14,7 +14,3 @@ ***************************************************************************/ #include "qgscustomdrophandler.h" - -QgsCustomDropHandler::~QgsCustomDropHandler() -{ -} diff --git a/src/gui/qgscustomdrophandler.h b/src/gui/qgscustomdrophandler.h index e23308dd98d..59bc3c44067 100644 --- a/src/gui/qgscustomdrophandler.h +++ b/src/gui/qgscustomdrophandler.h @@ -17,6 +17,7 @@ #define QGSCUSTOMDROPHANDLER_H #include "qgsmimedatautils.h" +#include "qgis_gui.h" /** \ingroup gui * Abstract base class that may be implemented to handle new types of data to be dropped in QGIS. @@ -27,7 +28,7 @@ class GUI_EXPORT QgsCustomDropHandler { public: - virtual ~QgsCustomDropHandler(); + virtual ~QgsCustomDropHandler() = default; //! Type of custom URI recognized by the handler virtual QString key() const = 0; diff --git a/src/gui/qgsdatadefinedbutton.h b/src/gui/qgsdatadefinedbutton.h index 06203510695..12e4f8f2ccc 100644 --- a/src/gui/qgsdatadefinedbutton.h +++ b/src/gui/qgsdatadefinedbutton.h @@ -22,6 +22,7 @@ #include #include #include "qgsexpressioncontextgenerator.h" +#include "qgis_gui.h" class QgsVectorLayer; class QgsDataDefined; diff --git a/src/gui/qgsdatumtransformdialog.h b/src/gui/qgsdatumtransformdialog.h index c6ac31cd4cc..8deacb7ac40 100644 --- a/src/gui/qgsdatumtransformdialog.h +++ b/src/gui/qgsdatumtransformdialog.h @@ -19,6 +19,7 @@ #define QGSDATUMTRANSFORMDIALOG_H #include "ui_qgsdatumtransformdialogbase.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsDatumTransformDialog diff --git a/src/gui/qgsdetaileditemdata.h b/src/gui/qgsdetaileditemdata.h index 6ecffc55f52..cbe6eb9d39c 100644 --- a/src/gui/qgsdetaileditemdata.h +++ b/src/gui/qgsdetaileditemdata.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_gui.h" /** \ingroup gui * This class is the data only representation of a diff --git a/src/gui/qgsdetaileditemdelegate.h b/src/gui/qgsdetaileditemdelegate.h index 013f4a088fa..e5e769d7a75 100644 --- a/src/gui/qgsdetaileditemdelegate.h +++ b/src/gui/qgsdetaileditemdelegate.h @@ -19,6 +19,7 @@ #include #include +#include "qgis_gui.h" class QCheckBox; class QgsDetailedItemWidget; diff --git a/src/gui/qgsdetaileditemwidget.cpp b/src/gui/qgsdetaileditemwidget.cpp index 0a9a51bf39f..e85de0a082e 100644 --- a/src/gui/qgsdetaileditemwidget.cpp +++ b/src/gui/qgsdetaileditemwidget.cpp @@ -23,10 +23,6 @@ QgsDetailedItemWidget::QgsDetailedItemWidget( QWidget * parent ) setupUi( this ); } -QgsDetailedItemWidget::~QgsDetailedItemWidget() -{ -} - void QgsDetailedItemWidget::setData( const QgsDetailedItemData& theData ) { lblTitle->setText( theData.title() ); diff --git a/src/gui/qgsdetaileditemwidget.h b/src/gui/qgsdetaileditemwidget.h index 8161a2996b1..ecd72ac1de9 100644 --- a/src/gui/qgsdetaileditemwidget.h +++ b/src/gui/qgsdetaileditemwidget.h @@ -19,6 +19,7 @@ #include #include +#include "qgis_gui.h" /** \ingroup gui * A widget renderer for detailed item views. @@ -30,7 +31,6 @@ class GUI_EXPORT QgsDetailedItemWidget : Q_OBJECT public: QgsDetailedItemWidget( QWidget * parent = nullptr ); - ~QgsDetailedItemWidget(); void setData( const QgsDetailedItemData& theData ); void setChecked( bool theFlag ); private: diff --git a/src/gui/qgsdial.h b/src/gui/qgsdial.h index 07362cf02d3..6843b63829a 100644 --- a/src/gui/qgsdial.h +++ b/src/gui/qgsdial.h @@ -17,6 +17,7 @@ #include #include +#include "qgis_gui.h" class QPaintEvent; diff --git a/src/gui/qgsdialog.cpp b/src/gui/qgsdialog.cpp index a21b6a91494..5b846e133ba 100644 --- a/src/gui/qgsdialog.cpp +++ b/src/gui/qgsdialog.cpp @@ -39,7 +39,3 @@ QgsDialog::QgsDialog( QWidget *parent, Qt::WindowFlags fl, setLayout( layout ); } -QgsDialog::~QgsDialog() -{ -} - diff --git a/src/gui/qgsdialog.h b/src/gui/qgsdialog.h index 3274108dc21..6cc9ab028a6 100644 --- a/src/gui/qgsdialog.h +++ b/src/gui/qgsdialog.h @@ -23,6 +23,7 @@ #include #include #include +#include "qgis_gui.h" /** \ingroup gui * A generic dialog with layout and button box @@ -38,7 +39,6 @@ class GUI_EXPORT QgsDialog : public QDialog QgsDialog( QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags, QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Close, Qt::Orientation orientation = Qt::Horizontal ); - ~QgsDialog(); //! Returns the central layout. Widgets added to it must have this dialog as parent. QVBoxLayout *layout() { return mLayout; } diff --git a/src/gui/qgsdockwidget.h b/src/gui/qgsdockwidget.h index da1ba298fba..86774107f40 100644 --- a/src/gui/qgsdockwidget.h +++ b/src/gui/qgsdockwidget.h @@ -18,6 +18,7 @@ #define QGSDOCKWIDGET_H #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsDockWidget diff --git a/src/gui/qgsencodingfiledialog.cpp b/src/gui/qgsencodingfiledialog.cpp index 04e42cc7de8..6764522db0f 100644 --- a/src/gui/qgsencodingfiledialog.cpp +++ b/src/gui/qgsencodingfiledialog.cpp @@ -67,13 +67,6 @@ QgsEncodingFileDialog::QgsEncodingFileDialog( QWidget* parent, // Connect our slot to get a signal when the user is done with the file dialog connect( this, SIGNAL( accepted() ), this, SLOT( saveUsedEncoding() ) ); - - -} - -QgsEncodingFileDialog::~QgsEncodingFileDialog() -{ - } QString QgsEncodingFileDialog::encoding() const diff --git a/src/gui/qgsencodingfiledialog.h b/src/gui/qgsencodingfiledialog.h index 2719649f34f..e39c4594a88 100644 --- a/src/gui/qgsencodingfiledialog.h +++ b/src/gui/qgsencodingfiledialog.h @@ -17,6 +17,7 @@ #define QGSENCODINGFILEDIALOG_H #include +#include "qgis_gui.h" class QComboBox; class QPushButton; @@ -30,7 +31,6 @@ class GUI_EXPORT QgsEncodingFileDialog: public QFileDialog QgsEncodingFileDialog( QWidget* parent = nullptr, const QString& caption = QString(), const QString& directory = QString(), const QString& filter = QString(), const QString& encoding = QString() ); - ~QgsEncodingFileDialog(); //! Returns a string describing the chosen encoding QString encoding() const; //! Adds a 'Cancel All' button for the user to click diff --git a/src/gui/qgserrordialog.cpp b/src/gui/qgserrordialog.cpp index b6bbcae2cd6..0d66be95a2a 100644 --- a/src/gui/qgserrordialog.cpp +++ b/src/gui/qgserrordialog.cpp @@ -52,10 +52,6 @@ QgsErrorDialog::QgsErrorDialog( const QgsError & theError, const QString & theTi if ( state == Qt::Checked ) on_mDetailPushButton_clicked(); } -QgsErrorDialog::~QgsErrorDialog() -{ -} - void QgsErrorDialog::show( const QgsError & theError, const QString & theTitle, QWidget *parent, Qt::WindowFlags fl ) { QgsErrorDialog d( theError, theTitle, parent, fl ); diff --git a/src/gui/qgserrordialog.h b/src/gui/qgserrordialog.h index 7c85a04e723..09c032dc261 100644 --- a/src/gui/qgserrordialog.h +++ b/src/gui/qgserrordialog.h @@ -22,6 +22,7 @@ #include "ui_qgserrordialogbase.h" #include "qgisgui.h" #include "qgserror.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsErrorDialog @@ -31,7 +32,6 @@ class GUI_EXPORT QgsErrorDialog: public QDialog, private Ui::QgsErrorDialogBase Q_OBJECT public: QgsErrorDialog( const QgsError & theError, const QString & theTitle, QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - ~QgsErrorDialog(); /** Show dialog with error * @param theError error diff --git a/src/gui/qgsexpressionbuilderdialog.h b/src/gui/qgsexpressionbuilderdialog.h index 9d48b3a557e..874889ff7f5 100644 --- a/src/gui/qgsexpressionbuilderdialog.h +++ b/src/gui/qgsexpressionbuilderdialog.h @@ -18,6 +18,7 @@ #include #include "ui_qgsexpressionbuilderdialogbase.h" +#include "qgis_gui.h" /** \ingroup gui * A generic dialog for building expression strings diff --git a/src/gui/qgsexpressionbuilderwidget.cpp b/src/gui/qgsexpressionbuilderwidget.cpp index c23429c9685..08a992f810b 100644 --- a/src/gui/qgsexpressionbuilderwidget.cpp +++ b/src/gui/qgsexpressionbuilderwidget.cpp @@ -104,6 +104,7 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent ) expressionTree->setCurrentIndex( firstItem ); lblAutoSave->setText( QLatin1String( "" ) ); + txtExpressionString->setWrapMode( QsciScintilla::WrapWord ); } diff --git a/src/gui/qgsexpressionbuilderwidget.h b/src/gui/qgsexpressionbuilderwidget.h index 10099062882..86b5fc29977 100644 --- a/src/gui/qgsexpressionbuilderwidget.h +++ b/src/gui/qgsexpressionbuilderwidget.h @@ -26,6 +26,7 @@ #include "QStandardItem" #include "QSortFilterProxyModel" #include "QStringListModel" +#include "qgis_gui.h" class QgsFields; class QgsExpressionHighlighter; @@ -79,7 +80,7 @@ class QgsExpressionItem : public QStandardItem */ void setHelpText( const QString& helpText ) { mHelpText = helpText; } - /** Get the type of expression item eg header, field, ExpressionNode. + /** Get the type of expression item, e.g., header, field, ExpressionNode. * * @return The QgsExpressionItem::ItemType */ diff --git a/src/gui/qgsexpressionhighlighter.h b/src/gui/qgsexpressionhighlighter.h index 2e01b7ea35d..22c67a259a0 100644 --- a/src/gui/qgsexpressionhighlighter.h +++ b/src/gui/qgsexpressionhighlighter.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_gui.h" class QTextDocument; diff --git a/src/gui/qgsexpressionlineedit.cpp b/src/gui/qgsexpressionlineedit.cpp index e6e53c0e011..fe6f8ba57fa 100644 --- a/src/gui/qgsexpressionlineedit.cpp +++ b/src/gui/qgsexpressionlineedit.cpp @@ -20,6 +20,7 @@ #include "qgsexpressionbuilderdialog.h" #include "qgsexpressioncontextgenerator.h" #include "qgscodeeditorsql.h" +#include "qgsproject.h" #include "qgsvectorlayer.h" #include #include @@ -45,7 +46,7 @@ QgsExpressionLineEdit::QgsExpressionLineEdit( QWidget *parent ) mExpressionContext = QgsExpressionContext(); mExpressionContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope(); + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ); } void QgsExpressionLineEdit::setExpressionDialogTitle( const QString& title ) diff --git a/src/gui/qgsexpressionlineedit.h b/src/gui/qgsexpressionlineedit.h index eb6faff90ac..f98ebd8b6f2 100644 --- a/src/gui/qgsexpressionlineedit.h +++ b/src/gui/qgsexpressionlineedit.h @@ -19,6 +19,7 @@ #include #include "qgsexpressioncontext.h" #include "qgsdistancearea.h" +#include "qgis_gui.h" class QgsFilterLineEdit; class QToolButton; diff --git a/src/gui/qgsexpressionselectiondialog.cpp b/src/gui/qgsexpressionselectiondialog.cpp index 501f6fd3776..fa655f1580c 100644 --- a/src/gui/qgsexpressionselectiondialog.cpp +++ b/src/gui/qgsexpressionselectiondialog.cpp @@ -14,8 +14,11 @@ ***************************************************************************/ #include "qgsexpressionselectiondialog.h" + #include "qgsapplication.h" #include "qgsexpression.h" +#include "qgsgeometry.h" +#include "qgsmessagebar.h" #include "qgsvectorlayer.h" #include @@ -23,6 +26,8 @@ QgsExpressionSelectionDialog::QgsExpressionSelectionDialog( QgsVectorLayer* layer, const QString& startText, QWidget* parent ) : QDialog( parent ) , mLayer( layer ) + , mMessageBar( nullptr ) + , mMapCanvas( nullptr ) { setupUi( this ); @@ -44,12 +49,12 @@ QgsExpressionSelectionDialog::QgsExpressionSelectionDialog( QgsVectorLayer* laye mExpressionBuilder->loadFieldNames(); mExpressionBuilder->loadRecent( QStringLiteral( "Selection" ) ); - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mLayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mLayer ) ); mExpressionBuilder->setExpressionContext( context ); + // by default, zoom to features is hidden, shown only if canvas is set + mButtonZoomToFeatures->setVisible( false ); + QSettings settings; restoreGeometry( settings.value( QStringLiteral( "/Windows/ExpressionSelectionDialog/geometry" ) ).toByteArray() ); } @@ -75,6 +80,17 @@ void QgsExpressionSelectionDialog::setGeomCalculator( const QgsDistanceArea & da mExpressionBuilder->setGeomCalculator( da ); } +void QgsExpressionSelectionDialog::setMessageBar( QgsMessageBar* messageBar ) +{ + mMessageBar = messageBar; +} + +void QgsExpressionSelectionDialog::setMapCanvas( QgsMapCanvas* canvas ) +{ + mMapCanvas = canvas; + mButtonZoomToFeatures->setVisible( true ); +} + void QgsExpressionSelectionDialog::on_mActionSelect_triggered() { mLayer->selectByExpression( mExpressionBuilder->expressionText(), @@ -103,6 +119,60 @@ void QgsExpressionSelectionDialog::on_mActionRemoveFromSelection_triggered() saveRecent(); } +void QgsExpressionSelectionDialog::on_mButtonZoomToFeatures_clicked() +{ + if ( mExpressionBuilder->expressionText().isEmpty() || !mMapCanvas ) + return; + + QgsFeatureIds ids; + + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mLayer ) ); + + QgsFeatureRequest request = QgsFeatureRequest().setFilterExpression( mExpressionBuilder->expressionText() ) + .setExpressionContext( context ) + .setSubsetOfAttributes( QgsAttributeList() ); + + QgsFeatureIterator features = mLayer->getFeatures( request ); + + QgsRectangle bbox; + bbox.setMinimal(); + QgsFeature feat; + int featureCount = 0; + while ( features.nextFeature( feat ) ) + { + QgsGeometry geom = feat.geometry(); + if ( geom.isEmpty() || geom.geometry()->isEmpty() ) + continue; + + QgsRectangle r = mMapCanvas->mapSettings().layerExtentToOutputExtent( mLayer, geom.boundingBox() ); + bbox.combineExtentWith( r ); + featureCount++; + } + features.close(); + + QSettings settings; + int timeout = settings.value( QStringLiteral( "/qgis/messageTimeout" ), 5 ).toInt(); + if ( featureCount > 0 ) + { + mMapCanvas->zoomToFeatureExtent( bbox ); + if ( mMessageBar ) + { + mMessageBar->pushMessage( QString(), + tr( "Zoomed to %n matching feature(s)", "number of matching features", featureCount ), + QgsMessageBar::INFO, + timeout ); + } + } + else if ( mMessageBar ) + { + mMessageBar->pushMessage( QString(), + tr( "No matching features found" ), + QgsMessageBar::INFO, + timeout ); + } + saveRecent(); +} + void QgsExpressionSelectionDialog::closeEvent( QCloseEvent *closeEvent ) { QDialog::closeEvent( closeEvent ); diff --git a/src/gui/qgsexpressionselectiondialog.h b/src/gui/qgsexpressionselectiondialog.h index e4eb59d3d18..9a25f719572 100644 --- a/src/gui/qgsexpressionselectiondialog.h +++ b/src/gui/qgsexpressionselectiondialog.h @@ -16,9 +16,14 @@ #ifndef QGSEXPRESSIONSELECTIONDIALOG_H #define QGSEXPRESSIONSELECTIONDIALOG_H -#include #include "ui_qgsexpressionselectiondialogbase.h" +#include "qgsmapcanvas.h" +#include "qgsmessagebar.h" + +#include +#include "qgis_gui.h" + /** \ingroup gui * This class offers a dialog to change feature selections. * To do so, a QgsExpressionBuilderWidget is shown in a dialog. @@ -62,11 +67,25 @@ class GUI_EXPORT QgsExpressionSelectionDialog : public QDialog, private Ui::QgsE */ void setGeomCalculator( const QgsDistanceArea & da ); - public slots: + /** Sets the message bar to display feedback from the dialog. This is used when zooming to + * features to display the count of selected features. + * @param messageBar target message bar + * @note added in QGIS 3.0 + */ + void setMessageBar( QgsMessageBar* messageBar ); + + /** + * Sets a map canvas associated with the dialog. + * @note added in QGIS 3.0 + */ + void setMapCanvas( QgsMapCanvas* canvas ); + + private slots: void on_mActionSelect_triggered(); void on_mActionAddToSelection_triggered(); void on_mActionRemoveFromSelection_triggered(); void on_mActionSelectIntersect_triggered(); + void on_mButtonZoomToFeatures_clicked(); void on_mPbnClose_clicked(); protected: @@ -88,6 +107,8 @@ class GUI_EXPORT QgsExpressionSelectionDialog : public QDialog, private Ui::QgsE private: void saveRecent(); QgsVectorLayer* mLayer; + QgsMessageBar* mMessageBar; + QgsMapCanvas* mMapCanvas; }; #endif diff --git a/src/gui/qgsextentgroupbox.h b/src/gui/qgsextentgroupbox.h index 306ae2ef96b..54e2b6281f0 100644 --- a/src/gui/qgsextentgroupbox.h +++ b/src/gui/qgsextentgroupbox.h @@ -21,6 +21,7 @@ #include "qgscoordinatereferencesystem.h" #include "qgsrectangle.h" +#include "qgis_gui.h" class QgsCoordinateReferenceSystem; diff --git a/src/gui/qgsexternalresourcewidget.h b/src/gui/qgsexternalresourcewidget.h index 090a655d0ba..9e1a41774a9 100644 --- a/src/gui/qgsexternalresourcewidget.h +++ b/src/gui/qgsexternalresourcewidget.h @@ -24,6 +24,7 @@ class QgsPixmapLabel; #include #include "qgsfilewidget.h" +#include "qgis_gui.h" diff --git a/src/gui/qgsfeatureselectiondlg.h b/src/gui/qgsfeatureselectiondlg.h index 99a030ccf4f..d3fb0d22015 100644 --- a/src/gui/qgsfeatureselectiondlg.h +++ b/src/gui/qgsfeatureselectiondlg.h @@ -19,6 +19,7 @@ class QgsGenericFeatureSelectionManager; #include "ui_qgsfeatureselectiondlg.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsFeatureSelectionDlg diff --git a/src/gui/qgsfieldcombobox.h b/src/gui/qgsfieldcombobox.h index 0b25395236c..7d65215109f 100644 --- a/src/gui/qgsfieldcombobox.h +++ b/src/gui/qgsfieldcombobox.h @@ -19,6 +19,7 @@ #include #include "qgsfieldproxymodel.h" +#include "qgis_gui.h" class QgsMapLayer; class QgsVectorLayer; diff --git a/src/gui/qgsfieldexpressionwidget.cpp b/src/gui/qgsfieldexpressionwidget.cpp index c2aa7e73281..604636f2e68 100644 --- a/src/gui/qgsfieldexpressionwidget.cpp +++ b/src/gui/qgsfieldexpressionwidget.cpp @@ -67,7 +67,7 @@ QgsFieldExpressionWidget::QgsFieldExpressionWidget( QWidget *parent ) mExpressionContext = QgsExpressionContext(); mExpressionContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope(); + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ); } void QgsFieldExpressionWidget::setExpressionDialogTitle( const QString& title ) diff --git a/src/gui/qgsfieldexpressionwidget.h b/src/gui/qgsfieldexpressionwidget.h index 480fa6e4a32..957ca57b0de 100644 --- a/src/gui/qgsfieldexpressionwidget.h +++ b/src/gui/qgsfieldexpressionwidget.h @@ -26,6 +26,7 @@ #include "qgsfieldproxymodel.h" #include "qgsexpressioncontext.h" #include "qgsexpressioncontextgenerator.h" +#include "qgis_gui.h" class QgsMapLayer; class QgsVectorLayer; diff --git a/src/gui/qgsfieldmodel.h b/src/gui/qgsfieldmodel.h index 73260dbdff1..9eb71bcb2f1 100644 --- a/src/gui/qgsfieldmodel.h +++ b/src/gui/qgsfieldmodel.h @@ -20,6 +20,7 @@ #include #include #include "qgsfields.h" +#include "qgis_gui.h" class QgsVectorLayer; diff --git a/src/gui/qgsfieldproxymodel.h b/src/gui/qgsfieldproxymodel.h index 6c0b29e8a7b..dfa6256038c 100644 --- a/src/gui/qgsfieldproxymodel.h +++ b/src/gui/qgsfieldproxymodel.h @@ -17,6 +17,7 @@ #define QGSFIELDPROXYMODEL_H #include +#include "qgis_gui.h" class QgsFieldModel; diff --git a/src/gui/qgsfieldvalidator.h b/src/gui/qgsfieldvalidator.h index 82393a67cab..16e8f8e97fd 100644 --- a/src/gui/qgsfieldvalidator.h +++ b/src/gui/qgsfieldvalidator.h @@ -24,6 +24,7 @@ #include #include #include "qgsfields.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsFieldValidator diff --git a/src/gui/qgsfieldvalueslineedit.cpp b/src/gui/qgsfieldvalueslineedit.cpp new file mode 100644 index 00000000000..69768406c51 --- /dev/null +++ b/src/gui/qgsfieldvalueslineedit.cpp @@ -0,0 +1,137 @@ +/*************************************************************************** + qgsfieldvalueslineedit.cpp + ------------------------- + Date : 20-08-2016 + Copyright : (C) 2016 by Nyall Dawson + Email : nyall dot dawson at gmail dot com + *************************************************************************** + * * + * 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 "qgsfieldvalueslineedit.h" +#include "qgsvectorlayer.h" +#include "qgsfloatingwidget.h" +#include +#include +#include +#include + +QgsFieldValuesLineEdit::QgsFieldValuesLineEdit( QWidget *parent ) + : QgsFilterLineEdit( parent ) + , mLayer( nullptr ) + , mAttributeIndex( -1 ) + , mUpdateRequested( false ) + , mGatherer( nullptr ) +{ + QCompleter* c = new QCompleter( this ); + c->setCaseSensitivity( Qt::CaseInsensitive ); + c->setFilterMode( Qt::MatchContains ); + setCompleter( c ); + connect( this, &QgsFieldValuesLineEdit::textEdited, this, &QgsFieldValuesLineEdit::requestCompleterUpdate ); + mShowPopupTimer.setSingleShot( true ); + mShowPopupTimer.setInterval( 100 ); + connect( &mShowPopupTimer, &QTimer::timeout, this, &QgsFieldValuesLineEdit::triggerCompleterUpdate ); +} + +QgsFieldValuesLineEdit::~QgsFieldValuesLineEdit() +{ + if ( mGatherer ) + { + mGatherer->stop(); + mGatherer->wait(); // mGatherer is deleted when wait completes + } +} + +void QgsFieldValuesLineEdit::setLayer( QgsVectorLayer* layer ) +{ + if ( mLayer == layer ) + return; + + mLayer = layer; + emit layerChanged( layer ); +} + +void QgsFieldValuesLineEdit::setAttributeIndex( int index ) +{ + if ( mAttributeIndex == index ) + return; + + mAttributeIndex = index; + emit attributeIndexChanged( index ); +} + +void QgsFieldValuesLineEdit::requestCompleterUpdate() +{ + mUpdateRequested = true; + mShowPopupTimer.start(); +} + +void QgsFieldValuesLineEdit::triggerCompleterUpdate() +{ + mShowPopupTimer.stop(); + QString currentText = text(); + + if ( currentText.isEmpty() ) + { + if ( mGatherer ) + mGatherer->stop(); + return; + } + + updateCompletionList( currentText ); +} + +void QgsFieldValuesLineEdit::updateCompletionList( const QString &text ) +{ + if ( text.isEmpty() ) + { + if ( mGatherer ) + mGatherer->stop(); + return; + } + + mUpdateRequested = true; + if ( mGatherer ) + { + mRequestedCompletionText = text; + mGatherer->stop(); + return; + } + + mGatherer = new QgsFieldValuesLineEditValuesGatherer( mLayer, mAttributeIndex ); + mGatherer->setSubstring( text ); + + connect( mGatherer, &QgsFieldValuesLineEditValuesGatherer::collectedValues, this, &QgsFieldValuesLineEdit::updateCompleter ); + connect( mGatherer, &QgsFieldValuesLineEditValuesGatherer::finished, this, &QgsFieldValuesLineEdit::gathererThreadFinished ); + + mGatherer->start(); +} + +void QgsFieldValuesLineEdit::gathererThreadFinished() +{ + bool wasCancelled = mGatherer->wasCancelled(); + + delete mGatherer; + mGatherer = nullptr; + + if ( wasCancelled ) + { + QString text = mRequestedCompletionText; + mRequestedCompletionText.clear(); + updateCompletionList( text ); + return; + } +} + +void QgsFieldValuesLineEdit::updateCompleter( const QStringList& values ) +{ + mUpdateRequested = false; + completer()->setModel( new QStringListModel( values ) ); + completer()->complete(); +} + diff --git a/src/gui/qgsfieldvalueslineedit.h b/src/gui/qgsfieldvalueslineedit.h new file mode 100644 index 00000000000..d4f314cc640 --- /dev/null +++ b/src/gui/qgsfieldvalueslineedit.h @@ -0,0 +1,218 @@ +/*************************************************************************** + qgsfieldvalueslineedit.h + ----------------------- + Date : 20-08-2016 + Copyright : (C) 2016 by Nyall Dawson + Email : nyall dot dawson at gmail dot com + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ +#ifndef QGSFIELDVALUESLINEEDIT_H +#define QGSFIELDVALUESLINEEDIT_H + +#include "qgsfilterlineedit.h" +#include "qgsfeedback.h" +#include "qgsvectorlayer.h" +#include +#include +#include +#include +#include +#include +#include "qgis_gui.h" + +class QgsFloatingWidget; + +// just internal guff - definitely not for exposing to public API! +///@cond PRIVATE + +/** \class QgsFieldValuesLineEditValuesGatherer + * Collates unique values containing a matching substring in a thread. + */ +class QgsFieldValuesLineEditValuesGatherer: public QThread +{ + Q_OBJECT + + public: + QgsFieldValuesLineEditValuesGatherer( QgsVectorLayer* layer, int attributeIndex ) + : mLayer( layer ) + , mAttributeIndex( attributeIndex ) + , mFeedback( nullptr ) + , mWasCancelled( false ) + {} + + /** Sets the substring to find matching values containing + */ + void setSubstring( const QString& string ) { mSubstring = string; } + + virtual void run() override + { + mWasCancelled = false; + if ( mSubstring.isEmpty() ) + { + emit collectedValues( QStringList() ); + return; + } + + // allow responsive cancellation + mFeedback = new QgsFeedback(); + // just get 100 values... maybe less/more would be useful? + mValues = mLayer->uniqueStringsMatching( mAttributeIndex, mSubstring, 100, mFeedback ); + + // be overly cautious - it's *possible* stop() might be called between deleting mFeedback and nulling it + mFeedbackMutex.lock(); + delete mFeedback; + mFeedback = nullptr; + mFeedbackMutex.unlock(); + + emit collectedValues( mValues ); + } + + //! Informs the gatherer to immediately stop collecting values + void stop() + { + // be cautious, in case gatherer stops naturally just as we are cancelling it and mFeedback gets deleted + mFeedbackMutex.lock(); + if ( mFeedback ) + mFeedback->cancel(); + mFeedbackMutex.unlock(); + + mWasCancelled = true; + } + + //! Returns true if collection was cancelled before completion + bool wasCancelled() const { return mWasCancelled; } + + signals: + + /** Emitted when values have been collected + * @param values list of unique matching string values + */ + void collectedValues( const QStringList& values ); + + private: + + QgsVectorLayer* mLayer; + int mAttributeIndex; + QString mSubstring; + QStringList mValues; + QgsFeedback* mFeedback; + QMutex mFeedbackMutex; + bool mWasCancelled; +}; + +///@endcond + +/** \class QgsFieldValuesLineEdit + * \ingroup gui + * A line edit with an autocompleter which takes unique values from a vector layer's fields. + * The autocompleter is populated from the vector layer in the background to ensure responsive + * interaction with the widget. + * \note added in QGIS 3.0 + */ +class GUI_EXPORT QgsFieldValuesLineEdit: public QgsFilterLineEdit +{ + Q_OBJECT + + Q_PROPERTY( QgsVectorLayer* layer READ layer WRITE setLayer NOTIFY layerChanged ) + Q_PROPERTY( int attributeIndex READ attributeIndex WRITE setAttributeIndex NOTIFY attributeIndexChanged ) + + public: + + /** Constructor for QgsFieldValuesLineEdit + * @param parent parent widget + */ + QgsFieldValuesLineEdit( QWidget *parent = nullptr ); + + virtual ~QgsFieldValuesLineEdit(); + + /** Sets the layer containing the field that values will be shown from. + * @param layer vector layer + * @see layer() + * @see setAttributeIndex() + */ + void setLayer( QgsVectorLayer* layer ); + + /** Returns the layer containing the field that values will be shown from. + * @see setLayer() + * @see attributeIndex() + */ + QgsVectorLayer* layer() const { return mLayer; } + + /** Sets the attribute index for the field containing values to show in the widget. + * @param index index of attribute + * @see attributeIndex() + * @see setLayer() + */ + void setAttributeIndex( int index ); + + /** Returns the attribute index for the field containing values shown in the widget. + * @see setAttributeIndex() + * @see layer() + */ + int attributeIndex() const { return mAttributeIndex; } + + signals: + + /** Emitted when the layer associated with the widget changes. + * @param layer vector layer + */ + void layerChanged( QgsVectorLayer* layer ); + + /** Emitted when the field associated with the widget changes. + * @param index new attribute index for field + */ + void attributeIndexChanged( int index ); + + private slots: + + /** Requests that the autocompleter updates its completion list. The update will not occur immediately + * but after a preset timeout to avoid multiple updates while a user is quickly typing. + */ + void requestCompleterUpdate(); + + /** Updates the autocompleter list immediately. Calling + * this will trigger a background request to the layer to fetch matching unique values. + */ + void triggerCompleterUpdate(); + + /** Updates the values shown in the completer list. + * @param values list of string values to show + */ + void updateCompleter( const QStringList& values ); + + /** Called when the gatherer thread is complete, regardless of whether it finished collecting values. + * Cleans up the gatherer thread and triggers a new background thread if the widget's text has changed + * in the meantime. + */ + void gathererThreadFinished(); + + private: + + QgsVectorLayer* mLayer; + int mAttributeIndex; + + //! Will be true when a background update of the completer values is occurring + bool mUpdateRequested; + + //! Timer to prevent multiple updates of autocomplete list + QTimer mShowPopupTimer; + + //! Background value gatherer thread + QgsFieldValuesLineEditValuesGatherer* mGatherer; + + //! Will be set to the latest completion text string which should be requested + QString mRequestedCompletionText; + + //! Kicks off the gathering of completer text values for a specified substring + void updateCompletionList( const QString& substring ); + +}; + + +#endif //QGSFIELDVALUESLINEEDIT_H diff --git a/src/gui/qgsfiledownloader.cpp b/src/gui/qgsfiledownloader.cpp index 23aed4ffcbc..9cb9cfc75c6 100644 --- a/src/gui/qgsfiledownloader.cpp +++ b/src/gui/qgsfiledownloader.cpp @@ -15,6 +15,7 @@ #include "qgsfiledownloader.h" #include "qgsnetworkaccessmanager.h" +#include "qgsapplication.h" #include #include diff --git a/src/gui/qgsfiledownloader.h b/src/gui/qgsfiledownloader.h index e12d886f939..3825969ec87 100644 --- a/src/gui/qgsfiledownloader.h +++ b/src/gui/qgsfiledownloader.h @@ -22,6 +22,7 @@ #include #ifndef QT_NO_SSL #include +#include "qgis_gui.h" #endif /** \ingroup gui diff --git a/src/gui/qgsfiledropedit.cpp b/src/gui/qgsfiledropedit.cpp index d3ee7ceac4d..74b49507b67 100644 --- a/src/gui/qgsfiledropedit.cpp +++ b/src/gui/qgsfiledropedit.cpp @@ -39,9 +39,6 @@ QgsFileDropEdit::QgsFileDropEdit( QWidget *parent ) setAcceptDrops( true ); } -QgsFileDropEdit::~QgsFileDropEdit() -{} - /*! Limit drops to directories. */ diff --git a/src/gui/qgsfiledropedit.h b/src/gui/qgsfiledropedit.h index aca397ceba3..a167f2c1a97 100644 --- a/src/gui/qgsfiledropedit.h +++ b/src/gui/qgsfiledropedit.h @@ -16,6 +16,7 @@ #define QGSFILEDROPEDIT_H #include +#include "qgis_gui.h" /** \ingroup gui * A line edit for capturing file names that can have files dropped onto @@ -27,7 +28,6 @@ class GUI_EXPORT QgsFileDropEdit: public QLineEdit public: QgsFileDropEdit( QWidget *parent = nullptr ); - virtual ~QgsFileDropEdit(); bool isDirOnly() const { return mDirOnly; } void setDirOnly( bool isDirOnly ); diff --git a/src/gui/qgsfilewidget.cpp b/src/gui/qgsfilewidget.cpp index ad46fb2ae56..adba86ce6fd 100644 --- a/src/gui/qgsfilewidget.cpp +++ b/src/gui/qgsfilewidget.cpp @@ -72,10 +72,6 @@ QgsFileWidget::QgsFileWidget( QWidget *parent ) setLayout( layout ); } -QgsFileWidget::~QgsFileWidget() -{ -} - QString QgsFileWidget::filePath() { return mFilePath; diff --git a/src/gui/qgsfilewidget.h b/src/gui/qgsfilewidget.h index 8c4694ff7d4..093a27bb437 100644 --- a/src/gui/qgsfilewidget.h +++ b/src/gui/qgsfilewidget.h @@ -24,6 +24,7 @@ class QVariant; class QgsFilterLineEdit; #include +#include "qgis_gui.h" /** \ingroup gui * @brief The QgsFileWidget class creates a widget for selecting a file or a folder. @@ -66,8 +67,6 @@ class GUI_EXPORT QgsFileWidget : public QWidget */ explicit QgsFileWidget( QWidget *parent = 0 ); - ~QgsFileWidget(); - //! Returns the current file path QString filePath(); diff --git a/src/gui/qgsfilterlineedit.h b/src/gui/qgsfilterlineedit.h index 9c9c8e89e12..bcba651f872 100644 --- a/src/gui/qgsfilterlineedit.h +++ b/src/gui/qgsfilterlineedit.h @@ -19,6 +19,7 @@ #define QGSFILTERLINEEDIT_H #include +#include "qgis_gui.h" class QToolButton; diff --git a/src/gui/qgsfloatingwidget.cpp b/src/gui/qgsfloatingwidget.cpp index f1d5e0efa38..9d20ddd76fd 100644 --- a/src/gui/qgsfloatingwidget.cpp +++ b/src/gui/qgsfloatingwidget.cpp @@ -34,12 +34,15 @@ QgsFloatingWidget::QgsFloatingWidget( QWidget *parent ) { mParentEventFilter = new QgsFloatingWidgetEventFilter( parent ); parent->installEventFilter( mParentEventFilter ); - connect( mParentEventFilter, SIGNAL( anchorPointChanged() ), this, SLOT( anchorPointChanged() ) ); + connect( mParentEventFilter, &QgsFloatingWidgetEventFilter::anchorPointChanged, this, &QgsFloatingWidget::onAnchorPointChanged ); } } void QgsFloatingWidget::setAnchorWidget( QWidget *widget ) { + if ( widget == mAnchorWidget ) + return; + // remove existing event filter if ( mAnchorWidget ) { @@ -53,10 +56,11 @@ void QgsFloatingWidget::setAnchorWidget( QWidget *widget ) { mAnchorEventFilter = new QgsFloatingWidgetEventFilter( mAnchorWidget ); mAnchorWidget->installEventFilter( mAnchorEventFilter ); - connect( mAnchorEventFilter, SIGNAL( anchorPointChanged() ), this, SLOT( anchorPointChanged() ) ); + connect( mAnchorEventFilter, &QgsFloatingWidgetEventFilter::anchorPointChanged, this, &QgsFloatingWidget::onAnchorPointChanged ); } - anchorPointChanged(); + onAnchorPointChanged(); + emit anchorWidgetChanged( mAnchorWidget ); } QWidget *QgsFloatingWidget::anchorWidget() @@ -64,9 +68,29 @@ QWidget *QgsFloatingWidget::anchorWidget() return mAnchorWidget; } +void QgsFloatingWidget::setAnchorPoint( QgsFloatingWidget::AnchorPoint point ) +{ + if ( point == mFloatAnchorPoint ) + return; + + mFloatAnchorPoint = point; + onAnchorPointChanged(); + emit anchorPointChanged( mFloatAnchorPoint ); +} + +void QgsFloatingWidget::setAnchorWidgetPoint( QgsFloatingWidget::AnchorPoint point ) +{ + if ( point == mAnchorWidgetAnchorPoint ) + return; + + mAnchorWidgetAnchorPoint = point; + onAnchorPointChanged(); + emit anchorWidgetPointChanged( mAnchorWidgetAnchorPoint ); +} + void QgsFloatingWidget::showEvent( QShowEvent *e ) { - anchorPointChanged(); + onAnchorPointChanged(); QWidget::showEvent( e ); } @@ -79,8 +103,11 @@ void QgsFloatingWidget::paintEvent( QPaintEvent* e ) style()->drawPrimitive( QStyle::PE_Widget, &opt, &p, this ); } -void QgsFloatingWidget::anchorPointChanged() +void QgsFloatingWidget::onAnchorPointChanged() { + if ( !parentWidget() ) + return; + if ( mAnchorWidget ) { QPoint anchorWidgetOrigin; diff --git a/src/gui/qgsfloatingwidget.h b/src/gui/qgsfloatingwidget.h index dad87e148c3..01c7fe07005 100644 --- a/src/gui/qgsfloatingwidget.h +++ b/src/gui/qgsfloatingwidget.h @@ -16,19 +16,25 @@ #define QGSFLOATINGWIDGET_H #include +#include "qgis_gui.h" +class QgsFloatingWidgetEventFilter; /** \ingroup gui * \class QgsFloatingWidget * A QWidget subclass for creating widgets which float outside of the normal Qt layout * system. Floating widgets use an "anchor widget" to determine how they are anchored * within their parent widget. - * \note Added in version 2.16 + * \note Added in version 3.0 */ class GUI_EXPORT QgsFloatingWidget: public QWidget { Q_OBJECT + Q_ENUMS( AnchorPoint ) + Q_PROPERTY( QWidget* anchorWidget READ anchorWidget WRITE setAnchorWidget NOTIFY anchorWidgetChanged ) + Q_PROPERTY( AnchorPoint anchorPoint READ anchorPoint WRITE setAnchorPoint NOTIFY anchorPointChanged ) + Q_PROPERTY( AnchorPoint anchorWidgetPoint READ anchorWidgetPoint WRITE setAnchorWidgetPoint NOTIFY anchorWidgetPointChanged ) public: @@ -75,7 +81,7 @@ class GUI_EXPORT QgsFloatingWidget: public QWidget * @param point anchor point * @see anchorPoint() */ - void setAnchorPoint( AnchorPoint point ) { mFloatAnchorPoint = point; anchorPointChanged(); } + void setAnchorPoint( AnchorPoint point ); /** Returns the anchor widget's anchor point, which corresponds to the point on the anchor widget which * the floating widget should "attach" to. The floating widget should remain fixed in the same relative position @@ -89,7 +95,18 @@ class GUI_EXPORT QgsFloatingWidget: public QWidget * to this anchor widget whenever the widget's parent is resized or moved. * @see setAnchorWidgetPoint() */ - void setAnchorWidgetPoint( AnchorPoint point ) { mAnchorWidgetAnchorPoint = point; anchorPointChanged(); } + void setAnchorWidgetPoint( AnchorPoint point ); + + signals: + + //! Emitted when the anchor widget changes + void anchorWidgetChanged( QWidget* widget ); + + //! Emitted when the anchor point changes + void anchorPointChanged( AnchorPoint point ); + + //! Emitted when the anchor widget point changes + void anchorWidgetPointChanged( AnchorPoint point ); protected: void showEvent( QShowEvent* e ) override; @@ -98,13 +115,13 @@ class GUI_EXPORT QgsFloatingWidget: public QWidget private slots: //! Repositions the floating widget to a changed anchor point - void anchorPointChanged(); + void onAnchorPointChanged(); private: QWidget* mAnchorWidget; - QObject* mParentEventFilter; - QObject* mAnchorEventFilter; + QgsFloatingWidgetEventFilter* mParentEventFilter; + QgsFloatingWidgetEventFilter* mAnchorEventFilter; AnchorPoint mFloatAnchorPoint; AnchorPoint mAnchorWidgetAnchorPoint; diff --git a/src/gui/qgsfocuswatcher.h b/src/gui/qgsfocuswatcher.h index 8cdddc88af4..50576de0a32 100644 --- a/src/gui/qgsfocuswatcher.h +++ b/src/gui/qgsfocuswatcher.h @@ -17,6 +17,7 @@ #define QGSFOCUSWATCHER_H #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsFocusWatcher diff --git a/src/gui/qgsformannotationitem.h b/src/gui/qgsformannotationitem.h index 765b3131ebe..24adc0ffe45 100644 --- a/src/gui/qgsformannotationitem.h +++ b/src/gui/qgsformannotationitem.h @@ -21,6 +21,7 @@ #include "qgsannotationitem.h" #include "qgsfeature.h" #include +#include "qgis_gui.h" class QGraphicsProxyWidget; @@ -34,15 +35,11 @@ class GUI_EXPORT QgsFormAnnotationItem: public QObject, public QgsAnnotationItem ~QgsFormAnnotationItem(); void paint( QPainter * painter ) override; - - //! paint function called by map canvas void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ) override; - QSizeF minimumFrameSize() const override; //! Returns the optimal frame size QSizeF preferredFrameSize() const; - //! Reimplemented from QgsAnnotationItem void setMapPosition( const QgsPoint& pos ) override; void setDesignerForm( const QString& uiFile ); diff --git a/src/gui/qgsgenericprojectionselector.cpp b/src/gui/qgsgenericprojectionselector.cpp index 2ab1dc86862..6877e9ea716 100644 --- a/src/gui/qgsgenericprojectionselector.cpp +++ b/src/gui/qgsgenericprojectionselector.cpp @@ -61,7 +61,7 @@ void QgsGenericProjectionSelector::setMessage( QString theMessage ) textEdit->setHtml( theMessage ); textEdit->show(); } -//! Destructor + QgsGenericProjectionSelector::~QgsGenericProjectionSelector() { QSettings settings; diff --git a/src/gui/qgsgenericprojectionselector.h b/src/gui/qgsgenericprojectionselector.h index a145b5c84bf..858e730d2a9 100644 --- a/src/gui/qgsgenericprojectionselector.h +++ b/src/gui/qgsgenericprojectionselector.h @@ -23,6 +23,7 @@ #include #include "qgscontexthelp.h" +#include "qgis_gui.h" /** * \ingroup gui @@ -55,7 +56,7 @@ class GUI_EXPORT QgsGenericProjectionSelector : public QDialog, private Ui::QgsG QgsGenericProjectionSelector( QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - //! Destructor + ~QgsGenericProjectionSelector(); public slots: diff --git a/src/gui/qgsgeometryrubberband.h b/src/gui/qgsgeometryrubberband.h index ee69f0906c8..23aca047493 100644 --- a/src/gui/qgsgeometryrubberband.h +++ b/src/gui/qgsgeometryrubberband.h @@ -21,6 +21,7 @@ #include "qgsmapcanvasitem.h" #include #include +#include "qgis_gui.h" class QgsAbstractGeometry; diff --git a/src/gui/qgsgradientcolorrampdialog.h b/src/gui/qgsgradientcolorrampdialog.h index 59ff77c005d..25da0bfdea4 100644 --- a/src/gui/qgsgradientcolorrampdialog.h +++ b/src/gui/qgsgradientcolorrampdialog.h @@ -19,6 +19,7 @@ #include #include "ui_qgsgradientcolorrampdialogbase.h" +#include "qgis_gui.h" class QgsGradientColorRamp; class QwtPlot; @@ -121,8 +122,6 @@ class GUI_EXPORT QgsGradientPlotEventFilter: public QObject QgsGradientPlotEventFilter( QwtPlot *plot ); - virtual ~QgsGradientPlotEventFilter() {} - virtual bool eventFilter( QObject* object, QEvent* event ) override; signals: diff --git a/src/gui/qgsgradientstopeditor.h b/src/gui/qgsgradientstopeditor.h index d17ecff467e..b56a7dfe508 100644 --- a/src/gui/qgsgradientstopeditor.h +++ b/src/gui/qgsgradientstopeditor.h @@ -18,6 +18,7 @@ #include "qgscolorramp.h" #include +#include "qgis_gui.h" /** \ingroup gui diff --git a/src/gui/qgsgroupwmsdatadialog.h b/src/gui/qgsgroupwmsdatadialog.h index 8e6d2873ba4..38bfb780177 100644 --- a/src/gui/qgsgroupwmsdatadialog.h +++ b/src/gui/qgsgroupwmsdatadialog.h @@ -19,6 +19,7 @@ #include "ui_qgsgroupwmsdatadialogbase.h" #include "qgisgui.h" #include "qgis.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsGroupWmsDataDialog diff --git a/src/gui/qgshighlight.h b/src/gui/qgshighlight.h index 4f8ffe60aa5..f6119c70e8c 100644 --- a/src/gui/qgshighlight.h +++ b/src/gui/qgshighlight.h @@ -24,6 +24,7 @@ #include #include #include +#include "qgis_gui.h" class QgsMapLayer; class QgsVectorLayer; diff --git a/src/gui/qgshistogramwidget.h b/src/gui/qgshistogramwidget.h index 40471e7b8a4..7d9f46e68c0 100644 --- a/src/gui/qgshistogramwidget.h +++ b/src/gui/qgshistogramwidget.h @@ -24,6 +24,7 @@ #include "qgsgraduatedsymbolrenderer.h" #include #include +#include "qgis_gui.h" class QgsVectorLayer; class QgsGraduatedSymbolRenderer; diff --git a/src/gui/qgshtmlannotationitem.cpp b/src/gui/qgshtmlannotationitem.cpp index 10f19ae5f02..bc3cfd21a0f 100644 --- a/src/gui/qgshtmlannotationitem.cpp +++ b/src/gui/qgshtmlannotationitem.cpp @@ -217,10 +217,7 @@ void QgsHtmlAnnotationItem::setFeatureForMapPosition() mFeatureId = currentFeatureId; mFeature = currentFeature; - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mVectorLayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mVectorLayer ) ); if ( mMapCanvas ) context.appendScope( QgsExpressionContextUtils::mapSettingsScope( mMapCanvas->mapSettings() ) ); context.setFeature( mFeature ); diff --git a/src/gui/qgshtmlannotationitem.h b/src/gui/qgshtmlannotationitem.h index 760b3dcd84a..91c947eeed3 100644 --- a/src/gui/qgshtmlannotationitem.h +++ b/src/gui/qgshtmlannotationitem.h @@ -22,6 +22,7 @@ #include "qgsfeature.h" #include +#include "qgis_gui.h" class QGraphicsProxyWidget; class QgsWebView; @@ -36,13 +37,10 @@ class GUI_EXPORT QgsHtmlAnnotationItem: public QObject, public QgsAnnotationItem ~QgsHtmlAnnotationItem(); void paint( QPainter * painter ) override; - - //! paint function called by map canvas void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ) override; QSizeF minimumFrameSize() const override; - //! Reimplemented from QgsAnnotationItem void setMapPosition( const QgsPoint& pos ) override; void setHTMLPage( const QString& htmlFile ); diff --git a/src/gui/qgsidentifymenu.h b/src/gui/qgsidentifymenu.h index 7abae8145a4..f8fb6124faf 100644 --- a/src/gui/qgsidentifymenu.h +++ b/src/gui/qgsidentifymenu.h @@ -20,6 +20,7 @@ #include "qgsmaplayeractionregistry.h" #include "qgsmaptoolidentify.h" +#include "qgis_gui.h" /// @cond PRIVATE class CustomActionRegistry : public QgsMapLayerActionRegistry diff --git a/src/gui/qgskeyvaluewidget.h b/src/gui/qgskeyvaluewidget.h index f3f661877a4..6af7414748f 100644 --- a/src/gui/qgskeyvaluewidget.h +++ b/src/gui/qgskeyvaluewidget.h @@ -19,6 +19,7 @@ #include "qgstablewidgetbase.h" #include #include +#include "qgis_gui.h" ///@cond PRIVATE @@ -84,4 +85,4 @@ class GUI_EXPORT QgsKeyValueWidget: public QgsTableWidgetBase }; -#endif // QGSKEYVALUEWIDGET_H \ No newline at end of file +#endif // QGSKEYVALUEWIDGET_H diff --git a/src/gui/qgslegendfilterbutton.cpp b/src/gui/qgslegendfilterbutton.cpp index e33c495de71..bd5db78bac2 100644 --- a/src/gui/qgslegendfilterbutton.cpp +++ b/src/gui/qgslegendfilterbutton.cpp @@ -46,10 +46,6 @@ QgsLegendFilterButton::QgsLegendFilterButton( QWidget* parent ) connect( this, SIGNAL( toggled( bool ) ), this, SLOT( onToggle( bool ) ) ); } -QgsLegendFilterButton::~QgsLegendFilterButton() -{ -} - void QgsLegendFilterButton::onToggle( bool checked ) { if ( checked && expressionText().isEmpty() ) diff --git a/src/gui/qgslegendfilterbutton.h b/src/gui/qgslegendfilterbutton.h index fe2fc20c5f6..01e22a5289b 100644 --- a/src/gui/qgslegendfilterbutton.h +++ b/src/gui/qgslegendfilterbutton.h @@ -16,6 +16,7 @@ #define QGS_LEGEND_FILTER_BUTTON_H #include +#include "qgis_gui.h" class QgsVectorLayer; @@ -38,7 +39,6 @@ class GUI_EXPORT QgsLegendFilterButton: public QToolButton * @param parent The parent QWidget */ QgsLegendFilterButton( QWidget* parent = nullptr ); - ~QgsLegendFilterButton(); /** * Returns the current text used as filter expression diff --git a/src/gui/qgslimitedrandomcolorrampdialog.h b/src/gui/qgslimitedrandomcolorrampdialog.h index d4ab88f1dc3..80ed99f53ff 100644 --- a/src/gui/qgslimitedrandomcolorrampdialog.h +++ b/src/gui/qgslimitedrandomcolorrampdialog.h @@ -20,6 +20,7 @@ #include "qgspanelwidget.h" #include "qgscolorramp.h" #include "ui_qgslimitedrandomcolorrampwidgetbase.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsLimitedRandomColorRampWidget diff --git a/src/gui/qgslistwidget.h b/src/gui/qgslistwidget.h index b29e1f0f11d..1e739f1ff9a 100644 --- a/src/gui/qgslistwidget.h +++ b/src/gui/qgslistwidget.h @@ -19,6 +19,7 @@ #include "qgstablewidgetbase.h" #include #include +#include "qgis_gui.h" ///@cond PRIVATE @@ -91,4 +92,4 @@ class GUI_EXPORT QgsListWidget: public QgsTableWidgetBase }; -#endif // QGSKEYVALUEWIDGET_H \ No newline at end of file +#endif // QGSKEYVALUEWIDGET_H diff --git a/src/gui/qgslonglongvalidator.h b/src/gui/qgslonglongvalidator.h index 05763659429..642663bf17e 100644 --- a/src/gui/qgslonglongvalidator.h +++ b/src/gui/qgslonglongvalidator.h @@ -23,6 +23,7 @@ #include #include #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsLongLongValidator diff --git a/src/gui/qgsludialog.cpp b/src/gui/qgsludialog.cpp index ff3783045ef..babdd65674c 100644 --- a/src/gui/qgsludialog.cpp +++ b/src/gui/qgsludialog.cpp @@ -24,11 +24,6 @@ QgsLUDialog::QgsLUDialog( QWidget *parent, Qt::WindowFlags fl ) setupUi( this ); } -QgsLUDialog::~QgsLUDialog() -{ - -} - QString QgsLUDialog::lowerValue() const { return mLowerEdit->text(); diff --git a/src/gui/qgsludialog.h b/src/gui/qgsludialog.h index 4a3c70b5d69..f9cda078f4e 100644 --- a/src/gui/qgsludialog.h +++ b/src/gui/qgsludialog.h @@ -20,6 +20,7 @@ #include "ui_qgsludialogbase.h" #include "qgisgui.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsLUDialog @@ -29,7 +30,6 @@ class GUI_EXPORT QgsLUDialog: public QDialog, private Ui::QgsLUDialogBase Q_OBJECT public: QgsLUDialog( QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - ~QgsLUDialog(); QString lowerValue() const; void setLowerValue( const QString& val ); QString upperValue() const; diff --git a/src/gui/qgsmanageconnectionsdialog.h b/src/gui/qgsmanageconnectionsdialog.h index 9f5bb447114..46a509132c7 100644 --- a/src/gui/qgsmanageconnectionsdialog.h +++ b/src/gui/qgsmanageconnectionsdialog.h @@ -21,6 +21,7 @@ #include #include #include "ui_qgsmanageconnectionsdialogbase.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsManageConnectionsDialog diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index e7895574e7c..42ab67091f1 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -486,7 +486,7 @@ void QgsMapCanvas::refreshMap() //build the expression context QgsExpressionContext expressionContext; expressionContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::mapSettingsScope( mSettings ) << new QgsExpressionContextScope( mExpressionContextScope ); diff --git a/src/gui/qgsmapcanvas.h b/src/gui/qgsmapcanvas.h index b5f1faf26c2..84324fd5420 100644 --- a/src/gui/qgsmapcanvas.h +++ b/src/gui/qgsmapcanvas.h @@ -35,6 +35,7 @@ #ifdef HAVE_TOUCH #include +#include "qgis_gui.h" #endif class QWheelEvent; @@ -79,7 +80,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView //! Constructor QgsMapCanvas( QWidget * parent = nullptr ); - //! Destructor + ~QgsMapCanvas(); //! Returns the magnification factor @@ -288,6 +289,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView //! Zooms in/out with a given center void zoomWithCenter( int x, int y, bool zoomIn ); + //! Zooms to feature extent. Adds a small margin around the extent + //! and does a pan if rect is empty (point extent) + void zoomToFeatureExtent( QgsRectangle& rect ); + //! Returns whether the scale is locked, so zooming can be performed using magnication. //! @note added in 2.16 //! @see setScaleLocked() @@ -589,10 +594,6 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView //! called when panning is in action, reset indicates end of panning void moveCanvasContents( bool reset = false ); - //! Zooms to feature extent. Adds a small margin around the extent - //! and does a pan if rect is empty (point extent) - void zoomToFeatureExtent( QgsRectangle& rect ); - //! called on resize or changed extent to notify canvas items to change their rectangle void updateCanvasItemPositions(); diff --git a/src/gui/qgsmapcanvasitem.h b/src/gui/qgsmapcanvasitem.h index 4ca45a662cb..a0453927b1f 100644 --- a/src/gui/qgsmapcanvasitem.h +++ b/src/gui/qgsmapcanvasitem.h @@ -18,6 +18,7 @@ #include #include "qgsrectangle.h" +#include "qgis_gui.h" class QgsMapCanvas; class QgsRenderContext; @@ -39,7 +40,6 @@ class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem //! function to be implemented by derived classes virtual void paint( QPainter * painter ) = 0; - //! paint function called by map canvas virtual void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ) override; @@ -58,7 +58,6 @@ class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem //! called on changed extent or resize event to update position of the item virtual void updatePosition(); - //! default implementation for canvas items virtual QRectF boundingRect() const override; //! returns canvas item rectangle in map units diff --git a/src/gui/qgsmapcanvasmap.cpp b/src/gui/qgsmapcanvasmap.cpp index 6a2babf8082..845bdce3f51 100644 --- a/src/gui/qgsmapcanvasmap.cpp +++ b/src/gui/qgsmapcanvasmap.cpp @@ -28,10 +28,6 @@ QgsMapCanvasMap::QgsMapCanvasMap( QgsMapCanvas* canvas ) setZValue( -10 ); } -QgsMapCanvasMap::~QgsMapCanvasMap() -{ -} - void QgsMapCanvasMap::setContent( const QImage& image, const QgsRectangle& rect ) { mImage = image; diff --git a/src/gui/qgsmapcanvasmap.h b/src/gui/qgsmapcanvasmap.h index d82f68a5359..99cd10dd89c 100644 --- a/src/gui/qgsmapcanvasmap.h +++ b/src/gui/qgsmapcanvasmap.h @@ -35,8 +35,6 @@ class QgsMapCanvasMap : public QgsMapCanvasItem //! constructor QgsMapCanvasMap( QgsMapCanvas* canvas ); - ~QgsMapCanvasMap(); - //! @note added in 2.4 void setContent( const QImage& image, const QgsRectangle& rect ); diff --git a/src/gui/qgsmapcanvassnapper.h b/src/gui/qgsmapcanvassnapper.h index f96f1fff516..9fb7afee166 100644 --- a/src/gui/qgsmapcanvassnapper.h +++ b/src/gui/qgsmapcanvassnapper.h @@ -20,6 +20,7 @@ #include #include "qgssnapper.h" +#include "qgis_gui.h" class QgsMapCanvas; class QPoint; @@ -42,6 +43,11 @@ class GUI_EXPORT QgsMapCanvasSnapper ~QgsMapCanvasSnapper(); + //! QgsMapCanvasSnapper cannot be copied + QgsMapCanvasSnapper( const QgsMapCanvasSnapper& rh ) = delete; + //! QgsMapCanvasSnapper cannot be copied + QgsMapCanvasSnapper& operator=( const QgsMapCanvasSnapper& rh ) = delete; + /** Does a snap to the current layer. Uses snap mode * QgsSnapper::SnapWithResultsForSamePosition if topological editing is enabled * and QgsSnapper::SnapWithOneResult_BY_SEGMENT if not. As this method is usually used to @@ -78,8 +84,6 @@ class GUI_EXPORT QgsMapCanvasSnapper //! The object which does the snapping operations QgsSnapper* mSnapper; - QgsMapCanvasSnapper( const QgsMapCanvasSnapper& rh ); - QgsMapCanvasSnapper& operator=( const QgsMapCanvasSnapper& rh ); }; #endif diff --git a/src/gui/qgsmapcanvassnappingutils.h b/src/gui/qgsmapcanvassnappingutils.h index 8b075cd6850..f18fdb4261c 100644 --- a/src/gui/qgsmapcanvassnappingutils.h +++ b/src/gui/qgsmapcanvassnappingutils.h @@ -16,6 +16,7 @@ #define QGSMAPCANVASSNAPPINGUTILS_H #include "qgssnappingutils.h" +#include "qgis_gui.h" class QgsMapCanvas; diff --git a/src/gui/qgsmapcanvastracer.h b/src/gui/qgsmapcanvastracer.h index 32f6d6583cb..a6a526d0639 100644 --- a/src/gui/qgsmapcanvastracer.h +++ b/src/gui/qgsmapcanvastracer.h @@ -16,6 +16,7 @@ #define QGSMAPCANVASTRACER_H #include "qgstracer.h" +#include "qgis_gui.h" class QAction; class QgsMapCanvas; diff --git a/src/gui/qgsmaplayeractionregistry.cpp b/src/gui/qgsmaplayeractionregistry.cpp index 017223cb052..666a21d732b 100644 --- a/src/gui/qgsmaplayeractionregistry.cpp +++ b/src/gui/qgsmaplayeractionregistry.cpp @@ -114,11 +114,6 @@ QgsMapLayerActionRegistry::QgsMapLayerActionRegistry( QObject *parent ) : QObjec // constructor does nothing } -QgsMapLayerActionRegistry::~QgsMapLayerActionRegistry() -{ - -} - void QgsMapLayerActionRegistry::addMapLayerAction( QgsMapLayerAction * action ) { mMapLayerActionList.append( action ); diff --git a/src/gui/qgsmaplayeractionregistry.h b/src/gui/qgsmaplayeractionregistry.h index 90dab76835b..c06ab2eb8cf 100644 --- a/src/gui/qgsmaplayeractionregistry.h +++ b/src/gui/qgsmaplayeractionregistry.h @@ -22,6 +22,7 @@ #include #include "qgsmaplayer.h" +#include "qgis_gui.h" class QgsFeature; @@ -111,8 +112,6 @@ class GUI_EXPORT QgsMapLayerActionRegistry : public QObject //! Returns the instance pointer, creating the object on the first call static QgsMapLayerActionRegistry * instance(); - ~QgsMapLayerActionRegistry(); - //! Adds a map layer action to the registry void addMapLayerAction( QgsMapLayerAction * action ); diff --git a/src/gui/qgsmaplayercombobox.h b/src/gui/qgsmaplayercombobox.h index 7ff9d882909..5ec66f5f5a2 100644 --- a/src/gui/qgsmaplayercombobox.h +++ b/src/gui/qgsmaplayercombobox.h @@ -19,6 +19,7 @@ #include #include "qgsmaplayerproxymodel.h" +#include "qgis_gui.h" class QgsMapLayer; class QgsVectorLayer; diff --git a/src/gui/qgsmaplayerconfigwidget.h b/src/gui/qgsmaplayerconfigwidget.h index 3bba2fc58ba..dca08a2ac8e 100644 --- a/src/gui/qgsmaplayerconfigwidget.h +++ b/src/gui/qgsmaplayerconfigwidget.h @@ -19,6 +19,7 @@ #include #include "qgspanelwidget.h" +#include "qgis_gui.h" class QgsMapCanvas; class QgsMapLayer; diff --git a/src/gui/qgsmaplayerconfigwidgetfactory.cpp b/src/gui/qgsmaplayerconfigwidgetfactory.cpp index 76b36fe5752..74ccc311527 100644 --- a/src/gui/qgsmaplayerconfigwidgetfactory.cpp +++ b/src/gui/qgsmaplayerconfigwidgetfactory.cpp @@ -30,10 +30,6 @@ QgsMapLayerConfigWidgetFactory::QgsMapLayerConfigWidgetFactory( const QString& t { } -QgsMapLayerConfigWidgetFactory::~QgsMapLayerConfigWidgetFactory() -{ -} - bool QgsMapLayerConfigWidgetFactory::supportsLayer( QgsMapLayer *layer ) const { Q_UNUSED( layer ); diff --git a/src/gui/qgsmaplayerconfigwidgetfactory.h b/src/gui/qgsmaplayerconfigwidgetfactory.h index 061e91de6e8..af0f51e77a2 100644 --- a/src/gui/qgsmaplayerconfigwidgetfactory.h +++ b/src/gui/qgsmaplayerconfigwidgetfactory.h @@ -17,6 +17,7 @@ #define QGSMAPLAYERCONFIGWIDGETFACTORY_H #include +#include "qgis_gui.h" class QgsMapLayer; class QgsMapLayerConfigWidget; @@ -37,8 +38,7 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory //! Constructor QgsMapLayerConfigWidgetFactory( const QString &title, const QIcon &icon ); - //! Destructor - virtual ~QgsMapLayerConfigWidgetFactory(); + virtual ~QgsMapLayerConfigWidgetFactory() = default; /** * @brief The icon that will be shown in the UI for the panel. diff --git a/src/gui/qgsmaplayerstylemanagerwidget.h b/src/gui/qgsmaplayerstylemanagerwidget.h index c7f2e7bbe4c..a8bc11a7b41 100644 --- a/src/gui/qgsmaplayerstylemanagerwidget.h +++ b/src/gui/qgsmaplayerstylemanagerwidget.h @@ -20,6 +20,7 @@ #include #include "qgsmaplayerconfigwidget.h" +#include "qgis_gui.h" class QgsMapLayer; class QgsMapCanvas; diff --git a/src/gui/qgsmapmouseevent.h b/src/gui/qgsmapmouseevent.h index 08642b23acb..7810802e757 100644 --- a/src/gui/qgsmapmouseevent.h +++ b/src/gui/qgsmapmouseevent.h @@ -20,6 +20,7 @@ #include "qgspoint.h" #include "qgspointlocator.h" +#include "qgis_gui.h" class QgsMapCanvas; class QgsMapToolAdvancedDigitizing; diff --git a/src/gui/qgsmapoverviewcanvas.cpp b/src/gui/qgsmapoverviewcanvas.cpp index dbc34b89f8a..9d73ef8c2df 100644 --- a/src/gui/qgsmapoverviewcanvas.cpp +++ b/src/gui/qgsmapoverviewcanvas.cpp @@ -47,10 +47,6 @@ QgsMapOverviewCanvas::QgsMapOverviewCanvas( QWidget * parent, QgsMapCanvas* mapC connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsMapOverviewCanvas::destinationCrsChanged ); } -QgsMapOverviewCanvas::~QgsMapOverviewCanvas() -{ -} - void QgsMapOverviewCanvas::resizeEvent( QResizeEvent* e ) { mPixmap = QPixmap(); diff --git a/src/gui/qgsmapoverviewcanvas.h b/src/gui/qgsmapoverviewcanvas.h index 19c3ef9acc9..97d7b5202ad 100644 --- a/src/gui/qgsmapoverviewcanvas.h +++ b/src/gui/qgsmapoverviewcanvas.h @@ -32,6 +32,7 @@ class QgsRectangle; class QgsMapRendererQImageJob; #include "qgsmapsettings.h" +#include "qgis_gui.h" /** \ingroup gui * A widget that displays an overview map. @@ -43,8 +44,6 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget public: QgsMapOverviewCanvas( QWidget * parent = nullptr, QgsMapCanvas* mapCanvas = nullptr ); - ~QgsMapOverviewCanvas(); - //! renders overview and updates panning widget void refresh(); diff --git a/src/gui/qgsmaptip.cpp b/src/gui/qgsmaptip.cpp index 4cbca96ac69..de8eb1642ea 100644 --- a/src/gui/qgsmaptip.cpp +++ b/src/gui/qgsmaptip.cpp @@ -43,11 +43,6 @@ QgsMapTip::QgsMapTip() mMapTipVisible = false; } -QgsMapTip::~QgsMapTip() -{ - -} - void QgsMapTip::showMapTip( QgsMapLayer *pLayer, QgsPoint & mapPosition, QPoint & thePixelPosition, @@ -191,10 +186,7 @@ QString QgsMapTip::fetchFeature( QgsMapLayer *layer, QgsPoint &mapPosition, QgsM if ( !vlayer->getFeatures( QgsFeatureRequest().setFilterRect( r ).setFlags( QgsFeatureRequest::ExactIntersect ) ).nextFeature( feature ) ) return QString(); - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( vlayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( vlayer ) ); if ( mapCanvas ) context.appendScope( QgsExpressionContextUtils::mapSettingsScope( mapCanvas->mapSettings() ) ); diff --git a/src/gui/qgsmaptip.h b/src/gui/qgsmaptip.h index b90a58bcaa8..086d77b21d5 100644 --- a/src/gui/qgsmaptip.h +++ b/src/gui/qgsmaptip.h @@ -26,6 +26,7 @@ class QgsWebView; #include #include #include "qgsfeature.h" +#include "qgis_gui.h" /** \ingroup gui * A maptip is a class to display a tip on a map canvas @@ -55,10 +56,6 @@ class GUI_EXPORT QgsMapTip : public QWidget */ QgsMapTip(); - /** Destructor - */ - virtual ~QgsMapTip(); - /** Show a maptip at a given point on the map canvas * @param thepLayer a qgis vector map layer pointer that will * be used to provide the attribute data for the map tip. diff --git a/src/gui/qgsmaptool.h b/src/gui/qgsmaptool.h index e059e2333a7..b09d1e4f39c 100644 --- a/src/gui/qgsmaptool.h +++ b/src/gui/qgsmaptool.h @@ -27,6 +27,7 @@ #ifdef HAVE_TOUCH #include +#include "qgis_gui.h" #endif class QgsMapLayer; @@ -71,7 +72,6 @@ class GUI_EXPORT QgsMapTool : public QObject */ virtual Flags flags() const { return Flags(); } - //! virtual destructor virtual ~QgsMapTool(); //! Mouse move event for overriding. Default implementation does nothing. diff --git a/src/gui/qgsmaptooladvanceddigitizing.cpp b/src/gui/qgsmaptooladvanceddigitizing.cpp index ad215a8efb1..f36f3bfd1a0 100644 --- a/src/gui/qgsmaptooladvanceddigitizing.cpp +++ b/src/gui/qgsmaptooladvanceddigitizing.cpp @@ -29,10 +29,6 @@ QgsMapToolAdvancedDigitizing::QgsMapToolAdvancedDigitizing( QgsMapCanvas* canvas { } -QgsMapToolAdvancedDigitizing::~QgsMapToolAdvancedDigitizing() -{ -} - void QgsMapToolAdvancedDigitizing::canvasPressEvent( QgsMapMouseEvent* e ) { snap( e ); diff --git a/src/gui/qgsmaptooladvanceddigitizing.h b/src/gui/qgsmaptooladvanceddigitizing.h index 0fa51c7d952..7ab938479b1 100644 --- a/src/gui/qgsmaptooladvanceddigitizing.h +++ b/src/gui/qgsmaptooladvanceddigitizing.h @@ -18,6 +18,7 @@ #define QGSMAPTOOLADVANCEDDIGITIZE_H #include "qgsmaptooledit.h" +#include "qgis_gui.h" class QgsMapMouseEvent; class QgsAdvancedDigitizingDockWidget; @@ -51,13 +52,11 @@ class GUI_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapToolEdit */ explicit QgsMapToolAdvancedDigitizing( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget ); - ~QgsMapToolAdvancedDigitizing(); - - //! catch the mouse press event, filters it, transforms it to map coordinates and send it to virtual method + //! Catch the mouse press event, filters it, transforms it to map coordinates and send it to virtual method virtual void canvasPressEvent( QgsMapMouseEvent* e ) override; - //! catch the mouse release event, filters it, transforms it to map coordinates and send it to virtual method + //! Catch the mouse release event, filters it, transforms it to map coordinates and send it to virtual method virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override; - //! catch the mouse move event, filters it, transforms it to map coordinates and send it to virtual method + //! Catch the mouse move event, filters it, transforms it to map coordinates and send it to virtual method virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override; /** diff --git a/src/gui/qgsmaptoolcapture.h b/src/gui/qgsmaptoolcapture.h index 07617bdf771..19a067ef53d 100644 --- a/src/gui/qgsmaptoolcapture.h +++ b/src/gui/qgsmaptoolcapture.h @@ -23,6 +23,7 @@ #include #include +#include "qgis_gui.h" class QgsRubberBand; class QgsVertexMarker; @@ -40,13 +41,9 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing //! constructor QgsMapToolCapture( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget, CaptureMode mode = CaptureNone ); - //! destructor virtual ~QgsMapToolCapture(); - //! active the tool virtual void activate() override; - - //! deactive the tool virtual void deactivate() override; //! Adds a whole curve (e.g. circularstring) to the captured geometry. Curve must be in map CRS @@ -59,12 +56,6 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing */ const QgsCompoundCurve* captureCurve() const { return &mCaptureCurve; } - - /** - * Update the rubberband according to mouse position - * - * @param e The mouse event - */ virtual void cadCanvasMoveEvent( QgsMapMouseEvent * e ) override; /** diff --git a/src/gui/qgsmaptooledit.cpp b/src/gui/qgsmaptooledit.cpp index 0ec70de3794..f5f8a023b4b 100644 --- a/src/gui/qgsmaptooledit.cpp +++ b/src/gui/qgsmaptooledit.cpp @@ -29,11 +29,6 @@ QgsMapToolEdit::QgsMapToolEdit( QgsMapCanvas* canvas ) { } -QgsMapToolEdit::~QgsMapToolEdit() -{ -} - - double QgsMapToolEdit::defaultZValue() const { QSettings().value( QStringLiteral( "/qgis/digitizing/default_z_value" ), Qgis::DEFAULT_Z_COORDINATE ).toDouble(); diff --git a/src/gui/qgsmaptooledit.h b/src/gui/qgsmaptooledit.h index 1647064b148..40069e4ac04 100644 --- a/src/gui/qgsmaptooledit.h +++ b/src/gui/qgsmaptooledit.h @@ -18,6 +18,7 @@ #include "qgis.h" #include "qgsmaptool.h" +#include "qgis_gui.h" class QgsRubberBand; class QgsGeometryRubberBand; @@ -33,7 +34,6 @@ class GUI_EXPORT QgsMapToolEdit: public QgsMapTool public: QgsMapToolEdit( QgsMapCanvas* canvas ); - virtual ~QgsMapToolEdit(); virtual Flags flags() const override { return QgsMapTool::EditTool; } diff --git a/src/gui/qgsmaptoolemitpoint.h b/src/gui/qgsmaptoolemitpoint.h index 31dbc53f4f7..1e409bb9bcb 100644 --- a/src/gui/qgsmaptoolemitpoint.h +++ b/src/gui/qgsmaptoolemitpoint.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLEMITPOINT_H #include "qgsmaptool.h" +#include "qgis_gui.h" class QgsMapCanvas; @@ -34,14 +35,8 @@ class GUI_EXPORT QgsMapToolEmitPoint : public QgsMapTool QgsMapToolEmitPoint( QgsMapCanvas* canvas ); virtual Flags flags() const override { return QgsMapTool::AllowZoomRect; } - - //! Overridden mouse move event virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override; - - //! Overridden mouse press event - emits the signal virtual void canvasPressEvent( QgsMapMouseEvent* e ) override; - - //! Overridden mouse release event virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override; signals: diff --git a/src/gui/qgsmaptoolidentify.h b/src/gui/qgsmaptoolidentify.h index b93c201e159..e0834b639ef 100644 --- a/src/gui/qgsmaptoolidentify.h +++ b/src/gui/qgsmaptoolidentify.h @@ -24,6 +24,7 @@ #include #include +#include "qgis_gui.h" class QgsRasterLayer; class QgsVectorLayer; @@ -93,18 +94,10 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool virtual ~QgsMapToolIdentify(); virtual Flags flags() const override { return QgsMapTool::AllowZoomRect; } - - //! Overridden mouse move event virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override; - - //! Overridden mouse press event virtual void canvasPressEvent( QgsMapMouseEvent* e ) override; - - //! Overridden mouse release event virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override; - virtual void activate() override; - virtual void deactivate() override; /** Performs the identification. diff --git a/src/gui/qgsmaptoolidentifyfeature.cpp b/src/gui/qgsmaptoolidentifyfeature.cpp index 1669d2f48aa..b59690d6fac 100644 --- a/src/gui/qgsmaptoolidentifyfeature.cpp +++ b/src/gui/qgsmaptoolidentifyfeature.cpp @@ -31,10 +31,6 @@ QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsV mCursor = QCursor( cursorPixmap, 1, 1 ); } -QgsMapToolIdentifyFeature::~QgsMapToolIdentifyFeature() -{ -} - void QgsMapToolIdentifyFeature::canvasReleaseEvent( QgsMapMouseEvent* e ) { diff --git a/src/gui/qgsmaptoolidentifyfeature.h b/src/gui/qgsmaptoolidentifyfeature.h index 9709e5de397..9691118c333 100644 --- a/src/gui/qgsmaptoolidentifyfeature.h +++ b/src/gui/qgsmaptoolidentifyfeature.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLIDENTIFYFEATURE_H #include "qgsmaptoolidentify.h" +#include "qgis_gui.h" /** \ingroup gui * @brief The QgsMapToolIdentifyFeature class is a map tool to identify a feature on a chosen layer. @@ -36,8 +37,6 @@ class GUI_EXPORT QgsMapToolIdentifyFeature : public QgsMapToolIdentify */ QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsVectorLayer* vl = nullptr ); - ~QgsMapToolIdentifyFeature(); - //! change the layer used by the map tool to identify void setLayer( QgsVectorLayer* vl ) { mLayer = vl; } diff --git a/src/gui/qgsmaptoolpan.h b/src/gui/qgsmaptoolpan.h index 73c350027e3..9eab80bced6 100644 --- a/src/gui/qgsmaptoolpan.h +++ b/src/gui/qgsmaptoolpan.h @@ -17,6 +17,7 @@ #define QGSMAPTOOLPAN_H #include "qgsmaptool.h" +#include "qgis_gui.h" class QgsMapCanvas; @@ -33,14 +34,8 @@ class GUI_EXPORT QgsMapToolPan : public QgsMapTool QgsMapToolPan( QgsMapCanvas* canvas ); virtual Flags flags() const override { return QgsMapTool::Transient | QgsMapTool::AllowZoomRect; } - - //! Mouse press event virtual void canvasPressEvent( QgsMapMouseEvent* e ) override; - - //! Overridden mouse move event virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override; - - //! Overridden mouse release event virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override; private: diff --git a/src/gui/qgsmaptooltouch.h b/src/gui/qgsmaptooltouch.h index 6cc74d0d446..207588921c2 100644 --- a/src/gui/qgsmaptooltouch.h +++ b/src/gui/qgsmaptooltouch.h @@ -19,6 +19,7 @@ #include "qgsmaptool.h" #include #include +#include "qgis_gui.h" class QgsMapCanvas; @@ -38,14 +39,8 @@ class GUI_EXPORT QgsMapToolTouch : public QgsMapTool void activate() override; void deactivate() override; - - //! Overridden mouse move event virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override; - - //! Overridden mouse release event virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override; - - //! Overridden Mouse double click event. virtual void canvasDoubleClickEvent( QgsMapMouseEvent* e ) override; virtual Flags flags() const override { return QgsMapTool::Transient | QgsMapTool::AllowZoomRect; } diff --git a/src/gui/qgsmaptoolzoom.h b/src/gui/qgsmaptoolzoom.h index 8486249cd18..d22465069cf 100644 --- a/src/gui/qgsmaptoolzoom.h +++ b/src/gui/qgsmaptoolzoom.h @@ -18,6 +18,7 @@ #include "qgsmaptool.h" #include +#include "qgis_gui.h" class QgsRubberBand; @@ -32,20 +33,12 @@ class GUI_EXPORT QgsMapToolZoom : public QgsMapTool public: //! constructor QgsMapToolZoom( QgsMapCanvas* canvas, bool zoomOut ); - ~QgsMapToolZoom(); virtual Flags flags() const override { return QgsMapTool::Transient; } - - //! Overridden mouse move event virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override; - - //! Overridden mouse press event virtual void canvasPressEvent( QgsMapMouseEvent* e ) override; - - //! Overridden mouse release event virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override; - virtual void deactivate() override; protected: diff --git a/src/gui/qgsmessagebar.cpp b/src/gui/qgsmessagebar.cpp index 0fe3208ab73..ba01d3c4182 100644 --- a/src/gui/qgsmessagebar.cpp +++ b/src/gui/qgsmessagebar.cpp @@ -99,10 +99,6 @@ QgsMessageBar::QgsMessageBar( QWidget *parent ) setVisible( false ); } -QgsMessageBar::~QgsMessageBar() -{ -} - void QgsMessageBar::mousePressEvent( QMouseEvent * e ) { if ( mCountProgress == childAt( e->pos() ) && e->button() == Qt::LeftButton ) diff --git a/src/gui/qgsmessagebar.h b/src/gui/qgsmessagebar.h index 96ef80b3a50..e8e762e0552 100644 --- a/src/gui/qgsmessagebar.h +++ b/src/gui/qgsmessagebar.h @@ -24,6 +24,7 @@ #include #include #include +#include "qgis_gui.h" class QWidget; class QGridLayout; @@ -53,7 +54,6 @@ class GUI_EXPORT QgsMessageBar: public QFrame }; QgsMessageBar( QWidget *parent = nullptr ); - ~QgsMessageBar(); /** * Display a message item on the bar after hiding the currently visible one diff --git a/src/gui/qgsmessagebaritem.cpp b/src/gui/qgsmessagebaritem.cpp index 77110cf3ea8..3f211b0d5b4 100644 --- a/src/gui/qgsmessagebaritem.cpp +++ b/src/gui/qgsmessagebaritem.cpp @@ -75,10 +75,6 @@ QgsMessageBarItem::QgsMessageBarItem( QWidget *widget, QgsMessageBar::MessageLev writeContent(); } -QgsMessageBarItem::~QgsMessageBarItem() -{ -} - void QgsMessageBarItem::writeContent() { if ( !mLayout ) diff --git a/src/gui/qgsmessagebaritem.h b/src/gui/qgsmessagebaritem.h index a474ba0f770..7643d50a44d 100644 --- a/src/gui/qgsmessagebaritem.h +++ b/src/gui/qgsmessagebaritem.h @@ -24,6 +24,7 @@ #include #include #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsMessageBarItem @@ -44,8 +45,6 @@ class GUI_EXPORT QgsMessageBarItem : public QWidget //! make out a widget containing a widget to be displayed on the bar QgsMessageBarItem( QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent = nullptr ); - ~QgsMessageBarItem(); - QgsMessageBarItem *setText( const QString& text ); QgsMessageBarItem *setTitle( const QString& title ); diff --git a/src/gui/qgsmessagelogviewer.cpp b/src/gui/qgsmessagelogviewer.cpp index 2e598fd0265..cebf872450b 100644 --- a/src/gui/qgsmessagelogviewer.cpp +++ b/src/gui/qgsmessagelogviewer.cpp @@ -36,16 +36,12 @@ QgsMessageLogViewer::QgsMessageLogViewer( QStatusBar *statusBar, QWidget *parent Q_UNUSED( statusBar ) setupUi( this ); - connect( QgsMessageLog::instance(), SIGNAL( messageReceived( QString, QString, QgsMessageLog::MessageLevel ) ), + connect( QgsApplication::messageLog(), SIGNAL( messageReceived( QString, QString, QgsMessageLog::MessageLevel ) ), this, SLOT( logMessage( QString, QString, QgsMessageLog::MessageLevel ) ) ); connect( tabWidget, SIGNAL( tabCloseRequested( int ) ), this, SLOT( closeTab( int ) ) ); } -QgsMessageLogViewer::~QgsMessageLogViewer() -{ -} - void QgsMessageLogViewer::logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level ) { if ( tag.isNull() ) diff --git a/src/gui/qgsmessagelogviewer.h b/src/gui/qgsmessagelogviewer.h index c8c1630f47f..9f6805bc1a8 100644 --- a/src/gui/qgsmessagelogviewer.h +++ b/src/gui/qgsmessagelogviewer.h @@ -22,6 +22,7 @@ #include "qgsmessagelog.h" #include +#include "qgis_gui.h" class QStatusBar; class QToolButton; @@ -36,7 +37,6 @@ class GUI_EXPORT QgsMessageLogViewer: public QDialog, private Ui::QgsMessageLogV Q_OBJECT public: QgsMessageLogViewer( QStatusBar *statusBar = nullptr, QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - ~QgsMessageLogViewer(); public slots: void logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level ); diff --git a/src/gui/qgsmessageviewer.h b/src/gui/qgsmessageviewer.h index c26a72cf9b7..d2182b86c5e 100644 --- a/src/gui/qgsmessageviewer.h +++ b/src/gui/qgsmessageviewer.h @@ -22,6 +22,7 @@ #include "qgsmessageoutput.h" #include +#include "qgis_gui.h" /** \ingroup gui diff --git a/src/gui/qgsnewgeopackagelayerdialog.cpp b/src/gui/qgsnewgeopackagelayerdialog.cpp index cf363fab1d2..8ef4dc968c7 100644 --- a/src/gui/qgsnewgeopackagelayerdialog.cpp +++ b/src/gui/qgsnewgeopackagelayerdialog.cpp @@ -42,15 +42,6 @@ #include #include -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) -#define SUPPORT_GEOMETRY_LESS -#define SUPPORT_CURVE_GEOMETRIES -#define SUPPORT_INTEGER64 -#define SUPPORT_SPATIAL_INDEX -#define SUPPORT_IDENTIFIER_DESCRIPTION -#define SUPPORT_FIELD_WIDTH -#endif - QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::WindowFlags fl ) : QDialog( parent, fl ) , mOkButton( nullptr ) @@ -65,16 +56,14 @@ QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::W mAddAttributeButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionNewAttribute.svg" ) ) ); mRemoveAttributeButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDeleteAttribute.svg" ) ) ); -#ifdef SUPPORT_GEOMETRY_LESS mGeometryTypeBox->addItem( tr( "Non spatial" ), wkbNone ); -#endif mGeometryTypeBox->addItem( tr( "Point" ), wkbPoint ); mGeometryTypeBox->addItem( tr( "Line" ), wkbLineString ); mGeometryTypeBox->addItem( tr( "Polygon" ), wkbPolygon ); mGeometryTypeBox->addItem( tr( "Multi point" ), wkbMultiPoint ); mGeometryTypeBox->addItem( tr( "Multi line" ), wkbMultiLineString ); mGeometryTypeBox->addItem( tr( "Multi polygon" ), wkbMultiPolygon ); -#ifdef SUPPORT_CURVE_GEOMETRIES + #if 0 // QGIS always create CompoundCurve and there's no real interest of having just CircularString. CompoundCurve are more useful mGeometryTypeBox->addItem( tr( "Circular string" ), wkbCircularString ); @@ -83,19 +72,14 @@ QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::W mGeometryTypeBox->addItem( tr( "Curve polygon" ), wkbCurvePolygon ); mGeometryTypeBox->addItem( tr( "Multi curve" ), wkbMultiCurve ); mGeometryTypeBox->addItem( tr( "Multi surface" ), wkbMultiSurface ); -#endif -#ifdef SUPPORT_GEOMETRY_LESS mGeometryColumnEdit->setEnabled( false ); mCheckBoxCreateSpatialIndex->setEnabled( false ); mCrsSelector->setEnabled( false ); -#endif mFieldTypeBox->addItem( tr( "Text data" ), "text" ); mFieldTypeBox->addItem( tr( "Whole number (integer)" ), "integer" ); -#ifdef SUPPORT_INTEGER64 mFieldTypeBox->addItem( tr( "Whole number (integer 64 bit)" ), "integer64" ); -#endif mFieldTypeBox->addItem( tr( "Decimal number (real)" ), "real" ); mFieldTypeBox->addItem( tr( "Date" ), "date" ); mFieldTypeBox->addItem( tr( "Date&time" ), "datetime" ); @@ -116,24 +100,7 @@ QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::W mAddAttributeButton->setEnabled( false ); mRemoveAttributeButton->setEnabled( false ); -#ifndef SUPPORT_SPATIAL_INDEX - mCheckBoxCreateSpatialIndex->hide(); - mCheckBoxCreateSpatialIndex->setChecked( false ); -#else mCheckBoxCreateSpatialIndex->setChecked( true ); -#endif - -#ifndef SUPPORT_IDENTIFIER_DESCRIPTION - mLayerIdentifierLabel->hide(); - mLayerIdentifierEdit->hide(); - mLayerDescriptionLabel->hide(); - mLayerDescriptionEdit->hide(); -#endif - -#ifndef SUPPORT_FIELD_WIDTH - mFieldLengthLabel->hide(); - mFieldLengthEdit->hide(); -#endif } QgsNewGeoPackageLayerDialog::~QgsNewGeoPackageLayerDialog() @@ -411,10 +378,8 @@ bool QgsNewGeoPackageLayerDialog::apply() if ( wkbType != wkbNone && !geometryColumn.isEmpty() ) options = CSLSetNameValue( options, "GEOMETRY_COLUMN", geometryColumn.toUtf8().constData() ); -#ifdef SUPPORT_SPATIAL_INDEX if ( wkbType != wkbNone ) options = CSLSetNameValue( options, "SPATIAL_INDEX", mCheckBoxCreateSpatialIndex->isChecked() ? "YES" : "NO" ); -#endif OGRLayerH hLayer = OGR_DS_CreateLayer( hDS, tableName.toUtf8().constData(), hSRS, wkbType, options ); CSLDestroy( options ); @@ -441,10 +406,8 @@ bool QgsNewGeoPackageLayerDialog::apply() ogrType = OFTString; else if ( fieldType == QLatin1String( "integer" ) ) ogrType = OFTInteger; -#ifdef SUPPORT_INTEGER64 else if ( fieldType == "integer64" ) ogrType = OFTInteger64; -#endif else if ( fieldType == QLatin1String( "real" ) ) ogrType = OFTReal; else if ( fieldType == QLatin1String( "date" ) ) diff --git a/src/gui/qgsnewgeopackagelayerdialog.h b/src/gui/qgsnewgeopackagelayerdialog.h index 4ce0ae302e4..67e8e021c22 100644 --- a/src/gui/qgsnewgeopackagelayerdialog.h +++ b/src/gui/qgsnewgeopackagelayerdialog.h @@ -22,6 +22,7 @@ #include "qgscontexthelp.h" #include "qgis.h" +#include "qgis_gui.h" /** \ingroup gui * Dialog to set up parameters to create a new GeoPackage layer, and on accept() to create it and add it to the layers */ diff --git a/src/gui/qgsnewhttpconnection.cpp b/src/gui/qgsnewhttpconnection.cpp index fb803055bd9..839827e56d3 100644 --- a/src/gui/qgsnewhttpconnection.cpp +++ b/src/gui/qgsnewhttpconnection.cpp @@ -184,10 +184,6 @@ QgsNewHttpConnection::QgsNewHttpConnection( on_txtName_textChanged( connName ); } -QgsNewHttpConnection::~QgsNewHttpConnection() -{ -} - void QgsNewHttpConnection::on_txtName_textChanged( const QString &text ) { Q_UNUSED( text ); @@ -220,7 +216,7 @@ void QgsNewHttpConnection::accept() if ( !txtPassword->text().isEmpty() && QMessageBox::question( this, tr( "Saving passwords" ), - tr( "WARNING: You have entered a password. It will be stored in plain text in your project files and in your home directory on Unix-like systems, or in your user profile on Windows. If you do not want this to happen, please press the Cancel button.\nNote: giving the password is optional. It will be requested interactivly, when needed." ), + tr( "WARNING: You have entered a password. It will be stored in plain text in your project files and in your home directory on Unix-like systems, or in your user profile on Windows. If you do not want this to happen, please press the Cancel button.\nNote: Giving the password is optional. It will be requested interactively, when needed." ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) { return; diff --git a/src/gui/qgsnewhttpconnection.h b/src/gui/qgsnewhttpconnection.h index 975c6706c85..cca1033915a 100644 --- a/src/gui/qgsnewhttpconnection.h +++ b/src/gui/qgsnewhttpconnection.h @@ -19,6 +19,7 @@ #include "ui_qgsnewhttpconnectionbase.h" #include "qgisgui.h" #include "qgscontexthelp.h" +#include "qgis_gui.h" class QgsAuthConfigSelect; @@ -33,10 +34,9 @@ class GUI_EXPORT QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpCo public: //! Constructor QgsNewHttpConnection( QWidget *parent = nullptr, const QString& baseKey = "/Qgis/connections-wms/", const QString& connName = QString::null, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - //! Destructor - ~QgsNewHttpConnection(); + public slots: - //! Saves the connection to ~/.qt/qgisrc + // Saves the connection to ~/.qt/qgisrc void accept() override; void on_txtName_textChanged( const QString & ); diff --git a/src/gui/qgsnewmemorylayerdialog.h b/src/gui/qgsnewmemorylayerdialog.h index 4bdab8fff33..2262f8ddf8d 100644 --- a/src/gui/qgsnewmemorylayerdialog.h +++ b/src/gui/qgsnewmemorylayerdialog.h @@ -20,6 +20,7 @@ #include "ui_qgsnewmemorylayerdialogbase.h" #include "qgisgui.h" #include "qgis.h" +#include "qgis_gui.h" class QgsVectorLayer; diff --git a/src/gui/qgsnewnamedialog.h b/src/gui/qgsnewnamedialog.h index 9197a95552c..14111cda15f 100644 --- a/src/gui/qgsnewnamedialog.h +++ b/src/gui/qgsnewnamedialog.h @@ -21,6 +21,7 @@ class QLabel; class QLineEdit; #include "qgsdialog.h" +#include "qgis_gui.h" /** \ingroup gui * New name, for example new layer name dialog. If existing names are provided, diff --git a/src/gui/qgsnewvectorlayerdialog.h b/src/gui/qgsnewvectorlayerdialog.h index 0f0a247e02e..3c1f2c25a25 100644 --- a/src/gui/qgsnewvectorlayerdialog.h +++ b/src/gui/qgsnewvectorlayerdialog.h @@ -22,6 +22,7 @@ #include "qgscontexthelp.h" #include "qgis.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsNewVectorLayerDialog diff --git a/src/gui/qgsoptionsdialogbase.h b/src/gui/qgsoptionsdialogbase.h index e7b6d040594..d8a27ba7037 100644 --- a/src/gui/qgsoptionsdialogbase.h +++ b/src/gui/qgsoptionsdialogbase.h @@ -22,6 +22,7 @@ #include #include #include +#include "qgis_gui.h" class QDialogButtonBox; class QListWidget; diff --git a/src/gui/qgsorderbydialog.h b/src/gui/qgsorderbydialog.h index a45921474b3..f63b74c7492 100644 --- a/src/gui/qgsorderbydialog.h +++ b/src/gui/qgsorderbydialog.h @@ -21,6 +21,7 @@ #include "ui_qgsorderbydialogbase.h" #include "qgsfeaturerequest.h" +#include "qgis_gui.h" class QgsVectorLayer; diff --git a/src/gui/qgsowssourceselect.cpp b/src/gui/qgsowssourceselect.cpp index 6880b936c8a..f0a27adade2 100644 --- a/src/gui/qgsowssourceselect.cpp +++ b/src/gui/qgsowssourceselect.cpp @@ -36,6 +36,7 @@ #include "qgsdataprovider.h" #include "qgsowssourceselect.h" #include "qgsnetworkaccessmanager.h" +#include "qgsapplication.h" #include #include diff --git a/src/gui/qgsowssourceselect.h b/src/gui/qgsowssourceselect.h index 2c5c3f8b7f8..be6370e67ac 100644 --- a/src/gui/qgsowssourceselect.h +++ b/src/gui/qgsowssourceselect.h @@ -27,6 +27,7 @@ #include #include #include +#include "qgis_gui.h" class QgsDataProvider; class QButtonGroup; @@ -58,7 +59,7 @@ class GUI_EXPORT QgsOWSSourceSelect : public QDialog, public Ui::QgsOWSSourceSel //! Constructor QgsOWSSourceSelect( const QString& service, QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags, bool managerMode = false, bool embeddedMode = false ); - //! Destructor + ~QgsOWSSourceSelect(); public slots: diff --git a/src/gui/qgspanelwidget.cpp b/src/gui/qgspanelwidget.cpp index 01bf929e9d1..fc7407d7641 100644 --- a/src/gui/qgspanelwidget.cpp +++ b/src/gui/qgspanelwidget.cpp @@ -57,7 +57,7 @@ QgsPanelWidget*QgsPanelWidget::findParentPanel( QWidget* widget ) if ( p->window() == p ) { - // break on encountering a window - eg a dialog opened from a panel should not inline + // break on encountering a window - e.g., a dialog opened from a panel should not inline // widgets inside the parent panel return nullptr; } diff --git a/src/gui/qgspanelwidget.h b/src/gui/qgspanelwidget.h index a039baa244f..c8b1f9081cb 100644 --- a/src/gui/qgspanelwidget.h +++ b/src/gui/qgspanelwidget.h @@ -18,6 +18,7 @@ #include #include #include +#include "qgis_gui.h" /** \ingroup gui * @brief Base class for any widget that can be shown as a inline panel @@ -110,7 +111,7 @@ class GUI_EXPORT QgsPanelWidget : public QWidget * @note This argument is normally raised with emit panelAccepted(this) * so that callers can retrive the widget easier in calling code. * @note this is emitted only when this panel is accepted, and is not emitted for - * child panels. Eg, if this panel opens a second stacked panel, then this panel + * child panels. For example, if this panel opens a second stacked panel, then this panel * will not emit panelAccepted when the second panel is accepted. */ void panelAccepted( QgsPanelWidget* panel ); diff --git a/src/gui/qgspanelwidgetstack.h b/src/gui/qgspanelwidgetstack.h index 2338c1e49d9..b396dce91f8 100644 --- a/src/gui/qgspanelwidgetstack.h +++ b/src/gui/qgspanelwidgetstack.h @@ -21,6 +21,7 @@ #include #include "ui_qgsrenderercontainerbase.h" +#include "qgis_gui.h" class QgsPanelWidget; diff --git a/src/gui/qgspixmaplabel.h b/src/gui/qgspixmaplabel.h index 06efcad0580..26c05c8fdfa 100644 --- a/src/gui/qgspixmaplabel.h +++ b/src/gui/qgspixmaplabel.h @@ -17,6 +17,7 @@ #define QGSPIXMAPLABEL_H #include +#include "qgis_gui.h" /** \ingroup gui * @brief The QgsPixmapLabel class shows a pixmap and adjusts its size to the space given diff --git a/src/gui/qgspluginmanagerinterface.cpp b/src/gui/qgspluginmanagerinterface.cpp index 7c5c1e651dd..df4c9146eed 100644 --- a/src/gui/qgspluginmanagerinterface.cpp +++ b/src/gui/qgspluginmanagerinterface.cpp @@ -19,8 +19,3 @@ QgsPluginManagerInterface::QgsPluginManagerInterface() { } - -QgsPluginManagerInterface::~QgsPluginManagerInterface() -{ -} - diff --git a/src/gui/qgspluginmanagerinterface.h b/src/gui/qgspluginmanagerinterface.h index a9272893a90..270e9f174f9 100644 --- a/src/gui/qgspluginmanagerinterface.h +++ b/src/gui/qgspluginmanagerinterface.h @@ -21,6 +21,7 @@ #include #include #include "qgsmessagebar.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsPluginManagerInterface @@ -34,9 +35,6 @@ class GUI_EXPORT QgsPluginManagerInterface : public QObject //! Constructor QgsPluginManagerInterface(); - //! Virtual destructor - virtual ~QgsPluginManagerInterface(); - //! remove python plugins from the metadata registry (c++ plugins stay) virtual void clearPythonPluginMetadata() = 0; diff --git a/src/gui/qgspresetcolorrampdialog.cpp b/src/gui/qgspresetcolorrampdialog.cpp index ba58f6b4dd3..f1d516381f5 100644 --- a/src/gui/qgspresetcolorrampdialog.cpp +++ b/src/gui/qgspresetcolorrampdialog.cpp @@ -41,10 +41,6 @@ QgsPresetColorRampWidget::QgsPresetColorRampWidget( const QgsPresetSchemeColorRa updatePreview(); } -QgsPresetColorRampWidget::~QgsPresetColorRampWidget() -{ -} - QgsPresetSchemeColorRamp QgsPresetColorRampWidget::ramp() const { return mRamp; diff --git a/src/gui/qgspresetcolorrampdialog.h b/src/gui/qgspresetcolorrampdialog.h index aa9675356b6..ef5fdf49ca9 100644 --- a/src/gui/qgspresetcolorrampdialog.h +++ b/src/gui/qgspresetcolorrampdialog.h @@ -20,6 +20,7 @@ #include "qgspanelwidget.h" #include "qgscolorramp.h" #include "ui_qgspresetcolorrampwidgetbase.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsPresetColorRampWidget @@ -39,8 +40,6 @@ class GUI_EXPORT QgsPresetColorRampWidget : public QgsPanelWidget, private Ui::Q */ QgsPresetColorRampWidget( const QgsPresetSchemeColorRamp& ramp, QWidget* parent = nullptr ); - ~QgsPresetColorRampWidget(); - /** Returns a color ramp representing the current settings from the dialog. * @see setRamp() */ diff --git a/src/gui/qgsprevieweffect.cpp b/src/gui/qgsprevieweffect.cpp index 5f487af5c5a..d9a271e8af0 100644 --- a/src/gui/qgsprevieweffect.cpp +++ b/src/gui/qgsprevieweffect.cpp @@ -27,11 +27,6 @@ QgsPreviewEffect::QgsPreviewEffect( QObject* parent ) setEnabled( false ); } -QgsPreviewEffect::~QgsPreviewEffect() -{ - -} - void QgsPreviewEffect::setMode( QgsPreviewEffect::PreviewMode mode ) { mMode = mode; diff --git a/src/gui/qgsprevieweffect.h b/src/gui/qgsprevieweffect.h index 63f88e465b2..8d97229771d 100644 --- a/src/gui/qgsprevieweffect.h +++ b/src/gui/qgsprevieweffect.h @@ -19,6 +19,7 @@ #define QGSPREVIEWEFFECT_H #include +#include "qgis_gui.h" /** \ingroup gui * A graphics effect which can be applied to a widget to simulate various printing and @@ -39,7 +40,6 @@ class GUI_EXPORT QgsPreviewEffect: public QGraphicsEffect }; QgsPreviewEffect( QObject* parent ); - ~QgsPreviewEffect(); /** Sets the mode for the preview effect, which controls how the effect modifies a widgets appearance. * @param mode PreviewMode to use to draw the widget diff --git a/src/gui/qgsprojectbadlayerguihandler.cpp b/src/gui/qgsprojectbadlayerguihandler.cpp deleted file mode 100644 index 7bf2bd63abc..00000000000 --- a/src/gui/qgsprojectbadlayerguihandler.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/*************************************************************************** - qgsprojectbadlayerguihandler.cpp - handle bad layers - --------------------- - begin : December 2009 - copyright : (C) 2009 by Martin Dobias - email : wonder dot sk at gmail dot com - *************************************************************************** - * * - * 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 "qgsprojectbadlayerguihandler.h" - -#include -#include -#include -#include -#include - -#include "qgslogger.h" -#include "qgisgui.h" -#include "qgsproviderregistry.h" -#include "qgsproject.h" - -QgsProjectBadLayerGuiHandler::QgsProjectBadLayerGuiHandler() -{ -} - -bool QgsProjectBadLayerGuiHandler::mIgnore = false; - -void QgsProjectBadLayerGuiHandler::handleBadLayers( const QList& layers ) -{ - QgsDebugMsg( QString( "%1 bad layers found" ).arg( layers.size() ) ); - - // make sure we have arrow cursor (and not a wait cursor) - QApplication::setOverrideCursor( Qt::ArrowCursor ); - - QMessageBox messageBox; - - QAbstractButton *ignoreButton = - messageBox.addButton( tr( "Ignore" ), QMessageBox::ActionRole ); - - QAbstractButton *okButton = messageBox.addButton( QMessageBox :: Ok ); - - messageBox.addButton( QMessageBox :: Cancel ); - - messageBox.setWindowTitle( tr( "QGIS Project Read Error" ) ); - messageBox.setText( tr( "Unable to open one or more project layers.\nChoose " - "ignore to continue loading without the missing layers. Choose cancel to " - "return to your pre-project load state. Choose OK to try to find the " - "missing layers." ) ); - messageBox.setIcon( QMessageBox::Critical ); - messageBox.exec(); - - QgsProjectBadLayerGuiHandler::mIgnore = false; - - if ( messageBox.clickedButton() == okButton ) - { - QgsDebugMsg( "want to find missing layers is true" ); - - // attempt to find the new locations for missing layers - // XXX vector file hard-coded -- but what if it's raster? - - QString filter = QgsProviderRegistry::instance()->fileVectorFilters(); - findLayers( filter, layers ); - } - else if ( messageBox.clickedButton() == ignoreButton ) - { - QgsProjectBadLayerGuiHandler::mIgnore = true; - } - else - { - // Do nothing - } - - QApplication::restoreOverrideCursor(); -} - -bool QgsProjectBadLayerGuiHandler::findLayer( const QString& fileFilters, const QDomNode& constLayerNode ) -{ - // XXX actually we could possibly get away with a copy of the node - QDomNode& layerNode = const_cast( constLayerNode ); - - bool retVal = false; - - switch ( providerType( layerNode ) ) - { - case IS_FILE: - QgsDebugMsg( "layer is file based" ); - retVal = findMissingFile( fileFilters, layerNode ); - break; - - case IS_DATABASE: - QgsDebugMsg( "layer is database based" ); - break; - - case IS_URL: - QgsDebugMsg( "layer is URL based" ); - break; - - case IS_Unknown: - QgsDebugMsg( "layer has an unknown type" ); - break; - } - return retVal; -} -bool QgsProjectBadLayerGuiHandler::findMissingFile( const QString& fileFilters, QDomNode& layerNode ) -{ - // Prepend that file name to the valid file format filter list since it - // makes it easier for the user to not only find the original file, but to - // perhaps find a similar file. - - QFileInfo originalDataSource( dataSource( layerNode ) ); - - QString memoryQualifier; // to differentiate between last raster and - // vector directories - - switch ( dataType( layerNode ) ) - { - case IS_VECTOR: - { - memoryQualifier = QStringLiteral( "lastVectorFileFilter" ); - - break; - } - case IS_RASTER: - { - memoryQualifier = QStringLiteral( "lastRasterFileFilter" ); - - break; - } - default: - QgsDebugMsg( "unable to determine data type" ); - return false; - } - - // Prepend the original data source base name to make it easier to pick it - // out from a list of other files; however the appropriate filter strings - // for the file type will also be added in case the file name itself has - // changed, too. - - QString myFileFilters = originalDataSource.fileName() + ";;" + fileFilters; - - QStringList selectedFiles; - QString enc; - QString title = QObject::tr( "Where is '%1' (original location: %2)?" ) - .arg( originalDataSource.fileName(), - originalDataSource.absoluteFilePath() ); - - bool retVal = QgisGui::openFilesRememberingFilter( memoryQualifier, - myFileFilters, - selectedFiles, - enc, - title, - true ); - - if ( selectedFiles.isEmpty() ) - { - return retVal; - } - else - { - setDataSource( layerNode, selectedFiles.first() ); - if ( ! QgsProject::instance()->read( layerNode ) ) - { - QgsDebugMsg( "unable to re-read layer" ); - } - } - return retVal; -} - -void QgsProjectBadLayerGuiHandler::findLayers( const QString& fileFilters, const QList& layerNodes ) -{ - - for ( QList::const_iterator i = layerNodes.begin(); - i != layerNodes.end(); - ++i ) - { - if ( findLayer( fileFilters, *i ) ) - { - // If findLayer returns true, the user hit Cancel All button - break; - } - } -} diff --git a/src/gui/qgsprojectbadlayerguihandler.h b/src/gui/qgsprojectbadlayerguihandler.h deleted file mode 100644 index bf3e97cd4a7..00000000000 --- a/src/gui/qgsprojectbadlayerguihandler.h +++ /dev/null @@ -1,65 +0,0 @@ -/*************************************************************************** - qgsprojectbadlayerguihandler.h - handle bad layers - --------------------- - begin : December 2009 - copyright : (C) 2009 by Martin Dobias - email : wonder dot sk at gmail dot com - *************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ -#ifndef QGSPROJECTBADLAYERGUIHANDLER_H -#define QGSPROJECTBADLAYERGUIHANDLER_H - -#include "qgsprojectbadlayerhandler.h" -#include - -/** \ingroup gui - Handler for missing layers within project. - - Gives user a chance to select path to the missing layers. - */ -class GUI_EXPORT QgsProjectBadLayerGuiHandler : public QObject, public QgsProjectBadLayerHandler -{ - Q_OBJECT - - public: - QgsProjectBadLayerGuiHandler(); - - virtual void handleBadLayers( const QList& layers ) override; - - //! Flag to store the Ignore button press of MessageBox used by QgsLegend - static bool mIgnore; - - protected: - //! This is used to locate files that have moved or otherwise are missing - bool findMissingFile( const QString& fileFilters, QDomNode& layerNode ); - - /** - * Find relocated data source for the given layer - * - * This QDom object represents a QgsProject node that maps to a specific layer. - * - * @param fileFilters file filters to use - * @param constLayerNode QDom node containing layer project information - * - * @todo - * - * XXX Only implemented for file based layers. It will need to be extended for - * XXX other data source types such as databases. - */ - bool findLayer( const QString& fileFilters, const QDomNode& constLayerNode ); - - /** - * Find relocated data sources for given layers - * These QDom objects represent QgsProject nodes that map to specific layers. - */ - void findLayers( const QString& fileFilters, const QList& layerNodes ); - -}; - -#endif // QGSPROJECTBADLAYERGUIHANDLER_H diff --git a/src/gui/qgsprojectionselectionwidget.h b/src/gui/qgsprojectionselectionwidget.h index 8680db18259..01664fbca69 100644 --- a/src/gui/qgsprojectionselectionwidget.h +++ b/src/gui/qgsprojectionselectionwidget.h @@ -23,6 +23,7 @@ #include #include "qgscoordinatereferencesystem.h" +#include "qgis_gui.h" class QgsGenericProjectionSelector; diff --git a/src/gui/qgsprojectionselector.h b/src/gui/qgsprojectionselector.h index 9bbfabca8f2..dc43388bc3f 100644 --- a/src/gui/qgsprojectionselector.h +++ b/src/gui/qgsprojectionselector.h @@ -17,6 +17,7 @@ #include #include "qgis.h" +#include "qgis_gui.h" class QResizeEvent; @@ -108,10 +109,10 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti void pushProjectionToFront(); protected: - //! Used to ensure the projection list view is actually populated + // Used to ensure the projection list view is actually populated void showEvent( QShowEvent * theEvent ) override; - //! Used to manage column sizes + // Used to manage column sizes void resizeEvent( QResizeEvent * theEvent ) override; private: diff --git a/src/gui/qgsquerybuilder.h b/src/gui/qgsquerybuilder.h index 375dc63c12d..048fdd3de5a 100644 --- a/src/gui/qgsquerybuilder.h +++ b/src/gui/qgsquerybuilder.h @@ -22,6 +22,7 @@ #include "ui_qgsquerybuilderbase.h" #include "qgisgui.h" #include "qgscontexthelp.h" +#include "qgis_gui.h" class QgsVectorLayer; diff --git a/src/gui/qgsrasterformatsaveoptionswidget.cpp b/src/gui/qgsrasterformatsaveoptionswidget.cpp index 837718ac336..4a479a01a81 100644 --- a/src/gui/qgsrasterformatsaveoptionswidget.cpp +++ b/src/gui/qgsrasterformatsaveoptionswidget.cpp @@ -105,10 +105,6 @@ QgsRasterFormatSaveOptionsWidget::QgsRasterFormatSaveOptionsWidget( QWidget* par QgsDebugMsg( "done" ); } -QgsRasterFormatSaveOptionsWidget::~QgsRasterFormatSaveOptionsWidget() -{ -} - void QgsRasterFormatSaveOptionsWidget::setFormat( const QString& format ) { mFormat = format; @@ -635,3 +631,31 @@ void QgsRasterFormatSaveOptionsWidget::showEvent( QShowEvent * event ) QgsDebugMsg( "done" ); } +void QgsRasterFormatSaveOptionsWidget::setOptions( const QString& options ) +{ + mOptionsTable->blockSignals( true ); + mOptionsTable->clearContents(); + + QStringList values; + QStringList optionsList = options.trimmed().split( ' ', QString::SkipEmptyParts ); + Q_FOREACH ( const QString &opt, optionsList ) + { + int rowCount = mOptionsTable->rowCount(); + mOptionsTable->insertRow( rowCount ); + + values = opt.split( '=' ); + if ( values.count() == 2 ) + { + QTableWidgetItem* nameItem = new QTableWidgetItem( values.at( 0 ) ); + mOptionsTable->setItem( rowCount, 0, nameItem ); + QTableWidgetItem* valueItem = new QTableWidgetItem( values.at( 1 ) ); + mOptionsTable->setItem( rowCount, 0, valueItem ); + } + } + + mOptionsMap[ currentProfileKey()] = options.trimmed(); + mOptionsLineEdit->setText( options.trimmed() ); + mOptionsLineEdit->setCursorPosition( 0 ); + + mOptionsTable->blockSignals( false ); +} diff --git a/src/gui/qgsrasterformatsaveoptionswidget.h b/src/gui/qgsrasterformatsaveoptionswidget.h index a86a903b591..f7ed005eed5 100644 --- a/src/gui/qgsrasterformatsaveoptionswidget.h +++ b/src/gui/qgsrasterformatsaveoptionswidget.h @@ -20,6 +20,7 @@ #include "ui_qgsrasterformatsaveoptionswidgetbase.h" #include "qgsraster.h" +#include "qgis_gui.h" class QgsRasterLayer; @@ -45,22 +46,72 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget, QgsRasterFormatSaveOptionsWidget( QWidget* parent = nullptr, const QString& format = "GTiff", QgsRasterFormatSaveOptionsWidget::Type type = Default, const QString& provider = "gdal" ); - ~QgsRasterFormatSaveOptionsWidget(); + /** + * Set output raster format, it is used to determine list + * of available options + */ void setFormat( const QString& format ); + + /** + * Set provider key, , it is used to determine list + * of available options + */ void setProvider( const QString& provider ); + + /** + * Set output raster layer + */ void setRasterLayer( QgsRasterLayer* rasterLayer ) { mRasterLayer = rasterLayer; mRasterFileName = QString(); } + + /** + * Set output raster file name + */ void setRasterFileName( const QString& file ) { mRasterLayer = nullptr; mRasterFileName = file; } + + /** + * Returns list of selected options + * @see setOptions() + */ QStringList options() const; + + /** + * Populate widget with user-defined options. String should contain + * key=value pairs separated by spaces, e.g. "TILED=YES TFW=YES" + * @see options() + * @note added in QGIS 3.0 + */ + void setOptions( const QString& options ); + + /** + * Set widget look and feel + */ void setType( QgsRasterFormatSaveOptionsWidget::Type type = Default ); + + /** + * Set pyramids format to use + */ void setPyramidsFormat( QgsRaster::RasterPyramidsFormat format ) { mPyramids = true; mPyramidsFormat = format; } public slots: void apply(); + + /** + * Opens window with options desctiption for given provider + * and output format + */ void helpOptions(); + + /** + * Validates options correctness + */ QString validateOptions( bool gui = true, bool reportOk = true ); + + /** + * Reloads profiles list from QGIS settings + */ void updateProfiles(); private slots: diff --git a/src/gui/qgsrasterlayersaveasdialog.cpp b/src/gui/qgsrasterlayersaveasdialog.cpp index 6d3ebb4d450..0577e4e1f89 100644 --- a/src/gui/qgsrasterlayersaveasdialog.cpp +++ b/src/gui/qgsrasterlayersaveasdialog.cpp @@ -156,10 +156,6 @@ void QgsRasterLayerSaveAsDialog::setValidators() mMaximumSizeYLineEdit->setValidator( new QIntValidator( this ) ); } -QgsRasterLayerSaveAsDialog::~QgsRasterLayerSaveAsDialog() -{ -} - void QgsRasterLayerSaveAsDialog::on_mBrowseButton_clicked() { QString fileName; diff --git a/src/gui/qgsrasterlayersaveasdialog.h b/src/gui/qgsrasterlayersaveasdialog.h index 98b50535b3b..dd719e009a4 100644 --- a/src/gui/qgsrasterlayersaveasdialog.h +++ b/src/gui/qgsrasterlayersaveasdialog.h @@ -19,6 +19,7 @@ #include "qgsrectangle.h" #include "qgscoordinatereferencesystem.h" #include "qgsrasterrange.h" +#include "qgis_gui.h" class QgsRasterLayer; class QgsRasterDataProvider; @@ -52,7 +53,6 @@ class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRast QgsRasterDataProvider* sourceProvider, const QgsRectangle& currentExtent, const QgsCoordinateReferenceSystem& layerCrs, const QgsCoordinateReferenceSystem& currentCrs, QWidget* parent = nullptr, Qt::WindowFlags f = 0 ); - ~QgsRasterLayerSaveAsDialog(); Mode mode() const; int nColumns() const; diff --git a/src/gui/qgsrasterpyramidsoptionswidget.cpp b/src/gui/qgsrasterpyramidsoptionswidget.cpp index 8415e3db3c4..3104c4ea725 100644 --- a/src/gui/qgsrasterpyramidsoptionswidget.cpp +++ b/src/gui/qgsrasterpyramidsoptionswidget.cpp @@ -41,11 +41,6 @@ QgsRasterPyramidsOptionsWidget::QgsRasterPyramidsOptionsWidget( QWidget* parent, updateUi(); } -QgsRasterPyramidsOptionsWidget::~QgsRasterPyramidsOptionsWidget() -{ -} - - void QgsRasterPyramidsOptionsWidget::updateUi() { QSettings mySettings; diff --git a/src/gui/qgsrasterpyramidsoptionswidget.h b/src/gui/qgsrasterpyramidsoptionswidget.h index c35a7a98f87..69bf1219d05 100644 --- a/src/gui/qgsrasterpyramidsoptionswidget.h +++ b/src/gui/qgsrasterpyramidsoptionswidget.h @@ -19,6 +19,7 @@ #define QGSRASTERPYRAMIDSOPTIONSWIDGET_H #include "ui_qgsrasterpyramidsoptionswidgetbase.h" +#include "qgis_gui.h" class QCheckBox; @@ -33,7 +34,6 @@ class GUI_EXPORT QgsRasterPyramidsOptionsWidget: public QWidget, public: QgsRasterPyramidsOptionsWidget( QWidget* parent = nullptr, const QString& provider = "gdal" ); - ~QgsRasterPyramidsOptionsWidget(); QStringList configOptions() const { return mSaveOptionsWidget->options(); } QgsRasterFormatSaveOptionsWidget* createOptionsWidget() { return mSaveOptionsWidget; } diff --git a/src/gui/qgsrelationeditorwidget.h b/src/gui/qgsrelationeditorwidget.h index 3f4ad727ade..147ee42de4c 100644 --- a/src/gui/qgsrelationeditorwidget.h +++ b/src/gui/qgsrelationeditorwidget.h @@ -25,6 +25,7 @@ #include "qgscollapsiblegroupbox.h" #include "qgsdualview.h" #include "qgsrelation.h" +#include "qgis_gui.h" class QgsFeature; class QgsGenericFeatureSelectionManager; diff --git a/src/gui/qgsrubberband.cpp b/src/gui/qgsrubberband.cpp index 7109594f278..345cbf1e980 100644 --- a/src/gui/qgsrubberband.cpp +++ b/src/gui/qgsrubberband.cpp @@ -53,10 +53,6 @@ QgsRubberBand::QgsRubberBand() { } -QgsRubberBand::~QgsRubberBand() -{ -} - /*! Set the outline and fill color. */ @@ -195,7 +191,7 @@ void QgsRubberBand::removePoint( int index, bool doUpdate/* = true*/, int geomet if ( !mPoints[geometryIndex].isEmpty() ) { - // negative index removes from end, eg -1 removes last one + // negative index removes from end, e.g., -1 removes last one if ( index < 0 ) { index = mPoints.at( geometryIndex ).size() + index; diff --git a/src/gui/qgsrubberband.h b/src/gui/qgsrubberband.h index 3f7c845f248..c34006e242a 100644 --- a/src/gui/qgsrubberband.h +++ b/src/gui/qgsrubberband.h @@ -21,6 +21,7 @@ #include #include #include +#include "qgis_gui.h" class QgsVectorLayer; class QPaintEvent; @@ -74,7 +75,6 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem * @param geometryType Defines how the data should be drawn onto the screen. (Use Qgis::Line, Qgis::Polygon or Qgis::Point) */ QgsRubberBand( QgsMapCanvas* mapCanvas, QgsWkbTypes::GeometryType geometryType = QgsWkbTypes::LineGeometry ); - ~QgsRubberBand(); /** * Set the color for the rubberband diff --git a/src/gui/qgsscalecombobox.cpp b/src/gui/qgsscalecombobox.cpp index 3f73211d7ef..97b10009373 100644 --- a/src/gui/qgsscalecombobox.cpp +++ b/src/gui/qgsscalecombobox.cpp @@ -39,10 +39,6 @@ QgsScaleComboBox::QgsScaleComboBox( QWidget* parent ) fixupScale(); } -QgsScaleComboBox::~QgsScaleComboBox() -{ -} - void QgsScaleComboBox::updateScales( const QStringList &scales ) { QStringList myScalesList; diff --git a/src/gui/qgsscalecombobox.h b/src/gui/qgsscalecombobox.h index 5171fe7c68a..a4c4c52d667 100644 --- a/src/gui/qgsscalecombobox.h +++ b/src/gui/qgsscalecombobox.h @@ -19,6 +19,7 @@ #define QGSSCALECOMBOBOX_H #include +#include "qgis_gui.h" /** \ingroup gui * A combobox which lets the user select map scale from predefined list @@ -29,7 +30,6 @@ class GUI_EXPORT QgsScaleComboBox : public QComboBox Q_OBJECT public: QgsScaleComboBox( QWidget* parent = nullptr ); - virtual ~QgsScaleComboBox(); //! Function to read the selected scale as text QString scaleString(); diff --git a/src/gui/qgsscalerangewidget.cpp b/src/gui/qgsscalerangewidget.cpp index f604fe74769..cb85e5f95f4 100644 --- a/src/gui/qgsscalerangewidget.cpp +++ b/src/gui/qgsscalerangewidget.cpp @@ -67,10 +67,6 @@ QgsScaleRangeWidget::QgsScaleRangeWidget( QWidget *parent ) connect( mMaximumScaleWidget, SIGNAL( scaleChanged( double ) ), this, SLOT( emitRangeChanged() ) ); } -QgsScaleRangeWidget::~QgsScaleRangeWidget() -{ -} - void QgsScaleRangeWidget::reloadProjectScales() { bool projectScales = QgsProject::instance()->readBoolEntry( QStringLiteral( "Scales" ), QStringLiteral( "/useProjectScales" ) ); diff --git a/src/gui/qgsscalerangewidget.h b/src/gui/qgsscalerangewidget.h index 11567fdac4f..91b2b73a6cd 100644 --- a/src/gui/qgsscalerangewidget.h +++ b/src/gui/qgsscalerangewidget.h @@ -18,6 +18,7 @@ #include #include +#include "qgis_gui.h" class QgsMapCanvas; class QgsScaleWidget; @@ -31,7 +32,6 @@ class GUI_EXPORT QgsScaleRangeWidget : public QWidget public: explicit QgsScaleRangeWidget( QWidget *parent = nullptr ); - ~QgsScaleRangeWidget(); //! set the map canvas which will be used for the current scale buttons diff --git a/src/gui/qgsscalevisibilitydialog.h b/src/gui/qgsscalevisibilitydialog.h index 43fa271a0e4..066359d1c57 100644 --- a/src/gui/qgsscalevisibilitydialog.h +++ b/src/gui/qgsscalevisibilitydialog.h @@ -18,6 +18,7 @@ #include #include +#include "qgis_gui.h" class QgsMapCanvas; class QgsScaleRangeWidget; diff --git a/src/gui/qgsscalewidget.cpp b/src/gui/qgsscalewidget.cpp index 267506887d9..06ce83d14b8 100644 --- a/src/gui/qgsscalewidget.cpp +++ b/src/gui/qgsscalewidget.cpp @@ -41,11 +41,6 @@ QgsScaleWidget::QgsScaleWidget( QWidget *parent ) connect( mCurrentScaleButton, SIGNAL( clicked() ), this, SLOT( setScaleFromCanvas() ) ); } - -QgsScaleWidget::~QgsScaleWidget() -{ -} - void QgsScaleWidget::setShowCurrentScaleButton( bool showCurrentScaleButton ) { mShowCurrentScaleButton = showCurrentScaleButton; diff --git a/src/gui/qgsscalewidget.h b/src/gui/qgsscalewidget.h index 534873a8e47..2c9fbe7ae7f 100644 --- a/src/gui/qgsscalewidget.h +++ b/src/gui/qgsscalewidget.h @@ -21,6 +21,7 @@ #include "qgsscalecombobox.h" +#include "qgis_gui.h" class QgsMapCanvas; @@ -38,8 +39,6 @@ class GUI_EXPORT QgsScaleWidget : public QWidget public: explicit QgsScaleWidget( QWidget *parent = nullptr ); - virtual ~QgsScaleWidget(); - //! shows a button to set the scale to the current scale of the map canvas next to the combobox //! @note the map canvas must be defined to show the button void setShowCurrentScaleButton( bool showCurrentScaleButton ); diff --git a/src/gui/qgssearchquerybuilder.cpp b/src/gui/qgssearchquerybuilder.cpp index 51e589479cb..f3b203a488b 100644 --- a/src/gui/qgssearchquerybuilder.cpp +++ b/src/gui/qgssearchquerybuilder.cpp @@ -64,11 +64,6 @@ QgsSearchQueryBuilder::QgsSearchQueryBuilder( QgsVectorLayer* layer, populateFields(); } -QgsSearchQueryBuilder::~QgsSearchQueryBuilder() -{ -} - - void QgsSearchQueryBuilder::populateFields() { if ( !mLayer ) @@ -200,10 +195,7 @@ long QgsSearchQueryBuilder::countRecords( const QString& searchString ) int count = 0; QgsFeature feat; - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::layerScope( mLayer ); + QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mLayer ) ); if ( !search.prepare( &context ) ) { diff --git a/src/gui/qgssearchquerybuilder.h b/src/gui/qgssearchquerybuilder.h index 4c788d12a0a..fcbffa84a4d 100644 --- a/src/gui/qgssearchquerybuilder.h +++ b/src/gui/qgssearchquerybuilder.h @@ -24,6 +24,7 @@ #include "ui_qgsquerybuilderbase.h" #include "qgisgui.h" #include "qgscontexthelp.h" +#include "qgis_gui.h" class QgsField; class QgsVectorLayer; @@ -41,8 +42,6 @@ class GUI_EXPORT QgsSearchQueryBuilder : public QDialog, private Ui::QgsQueryBui QgsSearchQueryBuilder( QgsVectorLayer* layer, QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags ); - ~QgsSearchQueryBuilder(); - //! returns newly created search string QString searchString(); diff --git a/src/gui/qgsshortcutsmanager.h b/src/gui/qgsshortcutsmanager.h index 5998287b005..f45df33d805 100644 --- a/src/gui/qgsshortcutsmanager.h +++ b/src/gui/qgsshortcutsmanager.h @@ -19,6 +19,7 @@ #include #include #include +#include "qgis_gui.h" class QShortcut; @@ -39,7 +40,7 @@ class GUI_EXPORT QgsShortcutsManager : public QObject /** Constructor for QgsShortcutsManager. * @param parent parent object - * @param settingsRoot root QSettings path for storing settings, eg "/myplugin/shortcuts". Leave + * @param settingsRoot root QSettings path for storing settings, e.g., "/myplugin/shortcuts". Leave * as the default value to store settings alongside built in QGIS shortcuts, but care must be * taken to not register actions which conflict with the built in QGIS actions. */ diff --git a/src/gui/qgsslider.h b/src/gui/qgsslider.h index a0d9a455a87..d7f800a3256 100644 --- a/src/gui/qgsslider.h +++ b/src/gui/qgsslider.h @@ -17,6 +17,7 @@ #include #include +#include "qgis_gui.h" class QPaintEvent; diff --git a/src/gui/qgssourceselectdialog.h b/src/gui/qgssourceselectdialog.h index 8cda87e293a..072220d0cf4 100644 --- a/src/gui/qgssourceselectdialog.h +++ b/src/gui/qgssourceselectdialog.h @@ -19,6 +19,7 @@ #include "ui_qgssourceselectdialogbase.h" #include "qgsrectangle.h" #include "qgscoordinatereferencesystem.h" +#include "qgis_gui.h" class QStandardItemModel; class QSortFilterProxyModel; @@ -38,7 +39,7 @@ class GUI_EXPORT QgsSourceSelectDialog : public QDialog, protected Ui::QgsSource //! Constructor QgsSourceSelectDialog( const QString& serviceName, ServiceType serviceType, QWidget* parent, Qt::WindowFlags fl ); - //! Destructor + ~QgsSourceSelectDialog(); //! Sets the current extent and CRS. Used to select an appropriate CRS and possibly to retrieve data only in the current extent void setCurrentExtentAndCrs( const QgsRectangle& canvasExtent, const QgsCoordinateReferenceSystem& canvasCrs ); diff --git a/src/gui/qgssqlcomposerdialog.cpp b/src/gui/qgssqlcomposerdialog.cpp index ea189039f6b..97d70aa12b9 100644 --- a/src/gui/qgssqlcomposerdialog.cpp +++ b/src/gui/qgssqlcomposerdialog.cpp @@ -26,14 +26,6 @@ email : even.rouault at spatialys.com #include -QgsSQLComposerDialog::TableSelectedCallback::~TableSelectedCallback() -{ -} - -QgsSQLComposerDialog::SQLValidatorCallback::~SQLValidatorCallback() -{ -} - QgsSQLComposerDialog::QgsSQLComposerDialog( QWidget * parent, Qt::WindowFlags fl ) : QDialog( parent, fl ) , mTableSelectedCallback( nullptr ) diff --git a/src/gui/qgssqlcomposerdialog.h b/src/gui/qgssqlcomposerdialog.h index a398dfd194d..38f796c9812 100644 --- a/src/gui/qgssqlcomposerdialog.h +++ b/src/gui/qgssqlcomposerdialog.h @@ -27,6 +27,7 @@ email : even.rouault at spatialys.com #include #include #include +#include "qgis_gui.h" /** \ingroup gui * SQL composer dialog @@ -51,7 +52,7 @@ class GUI_EXPORT QgsSQLComposerDialog : public QDialog, private Ui::QgsSQLCompos class GUI_EXPORT TableSelectedCallback { public: - virtual ~TableSelectedCallback(); + virtual ~TableSelectedCallback() = default; //! method called when a table is selected virtual void tableSelected( const QString& name ) = 0; }; @@ -63,7 +64,7 @@ class GUI_EXPORT QgsSQLComposerDialog : public QDialog, private Ui::QgsSQLCompos class GUI_EXPORT SQLValidatorCallback { public: - virtual ~SQLValidatorCallback(); + virtual ~SQLValidatorCallback() = default; //! method should return true if the SQL is valid. Otherwise return false and set the errorReason virtual bool isValid( const QString& sql, QString& errorReason, QString& warningMsg ) = 0; }; diff --git a/src/gui/qgssublayersdialog.h b/src/gui/qgssublayersdialog.h index 992975c7c71..df2f97e061a 100644 --- a/src/gui/qgssublayersdialog.h +++ b/src/gui/qgssublayersdialog.h @@ -19,6 +19,7 @@ #include #include #include "qgscontexthelp.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsSublayersDialog diff --git a/src/gui/qgssubstitutionlistwidget.h b/src/gui/qgssubstitutionlistwidget.h index 155fe7c5924..5e269d420b5 100644 --- a/src/gui/qgssubstitutionlistwidget.h +++ b/src/gui/qgssubstitutionlistwidget.h @@ -22,6 +22,7 @@ #include "qgspanelwidget.h" #include "ui_qgssubstitutionlistwidgetbase.h" #include "qgsstringutils.h" +#include "qgis_gui.h" /** \class QgsSubstitutionListWidget * \ingroup gui diff --git a/src/gui/qgssvgannotationitem.cpp b/src/gui/qgssvgannotationitem.cpp index 19a51b12eae..94e7606b022 100644 --- a/src/gui/qgssvgannotationitem.cpp +++ b/src/gui/qgssvgannotationitem.cpp @@ -26,11 +26,6 @@ QgsSvgAnnotationItem::QgsSvgAnnotationItem( QgsMapCanvas* canvas ): QgsAnnotatio } -QgsSvgAnnotationItem::~QgsSvgAnnotationItem() -{ - -} - void QgsSvgAnnotationItem::writeXml( QDomDocument& doc ) const { QDomElement documentElem = doc.documentElement(); diff --git a/src/gui/qgssvgannotationitem.h b/src/gui/qgssvgannotationitem.h index 2c430b05e55..d951a7f22eb 100644 --- a/src/gui/qgssvgannotationitem.h +++ b/src/gui/qgssvgannotationitem.h @@ -20,6 +20,7 @@ #include "qgsannotationitem.h" #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsSvgAnnotationItem @@ -29,7 +30,6 @@ class GUI_EXPORT QgsSvgAnnotationItem: public QgsAnnotationItem public: QgsSvgAnnotationItem( QgsMapCanvas* canvas ); - ~QgsSvgAnnotationItem(); void writeXml( QDomDocument& doc ) const override; void readXml( const QDomDocument& doc, const QDomElement& itemElem ) override; diff --git a/src/gui/qgstablewidgetbase.h b/src/gui/qgstablewidgetbase.h index ef2b7145b48..3757bb4c2ae 100644 --- a/src/gui/qgstablewidgetbase.h +++ b/src/gui/qgstablewidgetbase.h @@ -19,6 +19,7 @@ #include "ui_qgstablewidgetbase.h" #include #include +#include "qgis_gui.h" /** \ingroup gui * Base widget allowing to edit a collection, using a table. @@ -72,4 +73,4 @@ class GUI_EXPORT QgsTableWidgetBase: public QWidget, public Ui::QgsTableWidgetBa }; -#endif // QGSTABLEWIDGETBASE_H \ No newline at end of file +#endif // QGSTABLEWIDGETBASE_H diff --git a/src/gui/qgstablewidgetitem.h b/src/gui/qgstablewidgetitem.h index 9d4a305a6c3..670d03c0737 100644 --- a/src/gui/qgstablewidgetitem.h +++ b/src/gui/qgstablewidgetitem.h @@ -17,6 +17,7 @@ #define QGSTABLEWIDGETITEM_H #include +#include "qgis_gui.h" /** \ingroup gui * This can be used like a regular QTableWidgetItem with the difference that a diff --git a/src/gui/qgstabwidget.h b/src/gui/qgstabwidget.h index b3b48504738..e4987654481 100644 --- a/src/gui/qgstabwidget.h +++ b/src/gui/qgstabwidget.h @@ -17,6 +17,7 @@ #define QGSTABWIDGET_H #include +#include "qgis_gui.h" /** \ingroup gui * The QgsTabWidget class is the same as the QTabWidget but with additional methods to diff --git a/src/gui/qgstaskmanagerwidget.h b/src/gui/qgstaskmanagerwidget.h index daf05c20100..246c5a50644 100644 --- a/src/gui/qgstaskmanagerwidget.h +++ b/src/gui/qgstaskmanagerwidget.h @@ -21,6 +21,7 @@ #include "qgstaskmanager.h" #include #include +#include "qgis_gui.h" class QgsTaskManager; class QgsTask; diff --git a/src/gui/qgstextannotationitem.cpp b/src/gui/qgstextannotationitem.cpp index d65915ac990..6c4651c7a46 100644 --- a/src/gui/qgstextannotationitem.cpp +++ b/src/gui/qgstextannotationitem.cpp @@ -69,7 +69,7 @@ void QgsTextAnnotationItem::paint( QPainter * painter ) { //QTextDocument::drawContents will draw text outside of the painter's clip region //when it is passed a clip rectangle. So, we need to intersect it with the - //painter's clip region to prevent text drawn outside clipped region (eg, outside composer maps, see #10400) + //painter's clip region to prevent text drawn outside clipped region (e.g., outside composer maps, see #10400) clipRect = clipRect.intersected( painter->clipRegion().boundingRect() ); } //draw text document diff --git a/src/gui/qgstextannotationitem.h b/src/gui/qgstextannotationitem.h index 0f402ab9a4a..33400619239 100644 --- a/src/gui/qgstextannotationitem.h +++ b/src/gui/qgstextannotationitem.h @@ -20,6 +20,7 @@ #include "qgsannotationitem.h" #include +#include "qgis_gui.h" /** \ingroup gui * An annotation item that displays formated text*/ diff --git a/src/gui/qgstextformatwidget.cpp b/src/gui/qgstextformatwidget.cpp index 089780523ff..dab25a3a832 100644 --- a/src/gui/qgstextformatwidget.cpp +++ b/src/gui/qgstextformatwidget.cpp @@ -1205,7 +1205,7 @@ void QgsTextFormatWidget::updateSvgWidgets( const QString& svgPath ) bool fillParam = false, outlineParam = false, outlineWidthParam = false; if ( validSVG ) { - QgsSvgCache::instance()->containsParams( resolvedPath, fillParam, fill, outlineParam, outline, outlineWidthParam, outlineWidth ); + QgsApplication::svgCache()->containsParams( resolvedPath, fillParam, fill, outlineParam, outline, outlineWidthParam, outlineWidth ); } mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || outlineParam || outlineWidthParam ) ); diff --git a/src/gui/qgstextformatwidget.h b/src/gui/qgstextformatwidget.h index 5ea021168a9..ae31943b6c3 100644 --- a/src/gui/qgstextformatwidget.h +++ b/src/gui/qgstextformatwidget.h @@ -22,6 +22,7 @@ #include "qgsstringutils.h" #include "qgisgui.h" #include +#include "qgis_gui.h" class QgsMapCanvas; class QgsCharacterSelectorDialog; diff --git a/src/gui/qgstextpreview.h b/src/gui/qgstextpreview.h index 7f1304c4e11..48e848aa0e5 100644 --- a/src/gui/qgstextpreview.h +++ b/src/gui/qgstextpreview.h @@ -18,6 +18,7 @@ #include "qgstextrenderer.h" #include +#include "qgis_gui.h" /** \class QgsTextPreview * \ingroup gui diff --git a/src/gui/qgstreewidgetitem.h b/src/gui/qgstreewidgetitem.h index 70304919312..f6470921bc9 100644 --- a/src/gui/qgstreewidgetitem.h +++ b/src/gui/qgstreewidgetitem.h @@ -21,6 +21,7 @@ #include #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsTreeWidgetItem diff --git a/src/gui/qgsunitselectionwidget.h b/src/gui/qgsunitselectionwidget.h index e752021d099..eac1e0b3f36 100644 --- a/src/gui/qgsunitselectionwidget.h +++ b/src/gui/qgsunitselectionwidget.h @@ -24,6 +24,7 @@ #include "qgssymbol.h" #include "ui_qgsunitselectionwidget.h" #include "ui_qgsmapunitscalewidgetbase.h" +#include "qgis_gui.h" class QgsMapCanvas; diff --git a/src/gui/qgsuserinputdockwidget.cpp b/src/gui/qgsuserinputdockwidget.cpp index d3ac7b30efd..7cb2d2c82d6 100644 --- a/src/gui/qgsuserinputdockwidget.cpp +++ b/src/gui/qgsuserinputdockwidget.cpp @@ -33,10 +33,6 @@ QgsUserInputDockWidget::QgsUserInputDockWidget( QWidget *parent ) hide(); } -QgsUserInputDockWidget::~QgsUserInputDockWidget() -{ -} - void QgsUserInputDockWidget::addUserInputWidget( QWidget *widget ) { QFrame* line = nullptr; diff --git a/src/gui/qgsuserinputdockwidget.h b/src/gui/qgsuserinputdockwidget.h index 4d39931e2d8..0b7e9b351d9 100644 --- a/src/gui/qgsuserinputdockwidget.h +++ b/src/gui/qgsuserinputdockwidget.h @@ -20,6 +20,7 @@ #include "qgsdockwidget.h" #include +#include "qgis_gui.h" class QFrame; class QBoxLayout; @@ -36,7 +37,6 @@ class GUI_EXPORT QgsUserInputDockWidget : public QgsDockWidget Q_OBJECT public: QgsUserInputDockWidget( QWidget* parent = nullptr ); - ~QgsUserInputDockWidget(); /** Add a widget to be displayed in the dock. * @param widget widget to add. Ownership is not transferred. @@ -44,7 +44,7 @@ class GUI_EXPORT QgsUserInputDockWidget : public QgsDockWidget void addUserInputWidget( QWidget* widget ); protected: - //! will not display the dock if it contains no widget + // will not display the dock if it contains no widget void paintEvent( QPaintEvent *event ) override; private slots: diff --git a/src/gui/qgsvariableeditorwidget.cpp b/src/gui/qgsvariableeditorwidget.cpp index 88392dc4319..b18bdc66f16 100644 --- a/src/gui/qgsvariableeditorwidget.cpp +++ b/src/gui/qgsvariableeditorwidget.cpp @@ -132,9 +132,9 @@ QgsExpressionContextScope* QgsVariableEditorWidget::editableScope() const return mContext->scope( mEditableScopeIndex ); } -QgsStringMap QgsVariableEditorWidget::variablesInActiveScope() const +QVariantMap QgsVariableEditorWidget::variablesInActiveScope() const { - QgsStringMap variables; + QVariantMap variables; if ( !mContext || mEditableScopeIndex < 0 || mEditableScopeIndex >= mContext->scopeCount() ) { return variables; @@ -146,7 +146,7 @@ QgsStringMap QgsVariableEditorWidget::variablesInActiveScope() const if ( scope->isReadOnly( variable ) ) continue; - variables.insert( variable, scope->variable( variable ).toString() ); + variables.insert( variable, scope->variable( variable ) ); } return variables; diff --git a/src/gui/qgsvariableeditorwidget.h b/src/gui/qgsvariableeditorwidget.h index 58d9c0bf21d..a828ea07705 100644 --- a/src/gui/qgsvariableeditorwidget.h +++ b/src/gui/qgsvariableeditorwidget.h @@ -20,6 +20,7 @@ #include #include #include +#include "qgis_gui.h" class QTableWidget; class QgsExpressionContextScope; @@ -80,7 +81,7 @@ class GUI_EXPORT QgsVariableEditorWidget : public QWidget QgsExpressionContextScope* editableScope() const; /** Sets the setting group for the widget. QgsVariableEditorWidget widgets with - * the same setting group will synchronise their settings, eg the size + * the same setting group will synchronise their settings, e.g., the size * of columns in the tree widget. * @param group setting group * @see settingGroup() @@ -88,7 +89,7 @@ class GUI_EXPORT QgsVariableEditorWidget : public QWidget void setSettingGroup( const QString &group ) { mSettingGroup = group; } /** Returns the setting group for the widget. QgsVariableEditorWidget widgets with - * the same setting group will synchronise their settings, eg the size + * the same setting group will synchronise their settings, e.g., the size * of columns in the tree widget. * @returns setting group name * @see setSettingGroup() @@ -99,7 +100,7 @@ class GUI_EXPORT QgsVariableEditorWidget : public QWidget * returned. This method can be used to retrieve the variables edited an added by * users via the widget. */ - QgsStringMap variablesInActiveScope() const; + QVariantMap variablesInActiveScope() const; public slots: diff --git a/src/gui/qgsvertexmarker.h b/src/gui/qgsvertexmarker.h index 701e925fd32..ed77f89a5ca 100644 --- a/src/gui/qgsvertexmarker.h +++ b/src/gui/qgsvertexmarker.h @@ -18,6 +18,7 @@ #include "qgsmapcanvasitem.h" #include "qgspoint.h" +#include "qgis_gui.h" class QPainter; diff --git a/src/gui/raster/qgshillshaderendererwidget.cpp b/src/gui/raster/qgshillshaderendererwidget.cpp index a9203095d5b..79cd00cf5b7 100644 --- a/src/gui/raster/qgshillshaderendererwidget.cpp +++ b/src/gui/raster/qgshillshaderendererwidget.cpp @@ -68,11 +68,6 @@ QgsHillshadeRendererWidget::QgsHillshadeRendererWidget( QgsRasterLayer *layer, c connect( mMultiDirection, SIGNAL( toggled( bool ) ), this, SIGNAL( widgetChanged() ) ); } -QgsHillshadeRendererWidget::~QgsHillshadeRendererWidget() -{ - -} - QgsRasterRenderer *QgsHillshadeRendererWidget::renderer() { if ( !mRasterLayer ) diff --git a/src/gui/raster/qgshillshaderendererwidget.h b/src/gui/raster/qgshillshaderendererwidget.h index 6d472e30ef2..02b67d4bde6 100644 --- a/src/gui/raster/qgshillshaderendererwidget.h +++ b/src/gui/raster/qgshillshaderendererwidget.h @@ -23,6 +23,7 @@ #include #include "qgsrasterrendererwidget.h" +#include "qgis_gui.h" /** * @brief Renderer widget for the hill shade renderer. @@ -41,8 +42,6 @@ class GUI_EXPORT QgsHillshadeRendererWidget: public QgsRasterRendererWidget, pri */ QgsHillshadeRendererWidget( QgsRasterLayer* layer, const QgsRectangle &extent = QgsRectangle() ); - ~QgsHillshadeRendererWidget(); - /** * Factory method to create the renderer for this type. */ diff --git a/src/gui/raster/qgsmultibandcolorrendererwidget.cpp b/src/gui/raster/qgsmultibandcolorrendererwidget.cpp index 2d840f22d83..a55f9557473 100644 --- a/src/gui/raster/qgsmultibandcolorrendererwidget.cpp +++ b/src/gui/raster/qgsmultibandcolorrendererwidget.cpp @@ -81,20 +81,9 @@ QgsMultiBandColorRendererWidget::QgsMultiBandColorRendererWidget( QgsRasterLayer onBandChanged( 0 ); // reset mMinMaxWidget bands connect( mContrastEnhancementAlgorithmComboBox, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( widgetChanged() ) ); - connect( mRedMinLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( widgetChanged() ) ); - connect( mRedMaxLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( widgetChanged() ) ); - connect( mGreenMaxLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( widgetChanged() ) ); - connect( mGreenMinLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( widgetChanged() ) ); - connect( mBlueMaxLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( widgetChanged() ) ); - connect( mBlueMinLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( widgetChanged() ) ); - } } -QgsMultiBandColorRendererWidget::~QgsMultiBandColorRendererWidget() -{ -} - QgsRasterRenderer* QgsMultiBandColorRendererWidget::renderer() { if ( !mRasterLayer ) @@ -267,6 +256,7 @@ void QgsMultiBandColorRendererWidget::minMaxModified() mContrastEnhancementAlgorithmComboBox->findData(( int ) QgsContrastEnhancement::StretchToMinimumMaximum ) ); } mMinMaxWidget->userHasSetManualMinMaxValues(); + emit widgetChanged(); } } diff --git a/src/gui/raster/qgsmultibandcolorrendererwidget.h b/src/gui/raster/qgsmultibandcolorrendererwidget.h index 64018357ee6..15eb267d197 100644 --- a/src/gui/raster/qgsmultibandcolorrendererwidget.h +++ b/src/gui/raster/qgsmultibandcolorrendererwidget.h @@ -20,6 +20,7 @@ #include "qgsrasterrendererwidget.h" #include "ui_qgsmultibandcolorrendererwidgetbase.h" +#include "qgis_gui.h" class QgsContrastEnhancement; class QgsMultiBandColorRenderer; @@ -38,7 +39,6 @@ class GUI_EXPORT QgsMultiBandColorRendererWidget: public QgsRasterRendererWidget public: QgsMultiBandColorRendererWidget( QgsRasterLayer* layer, const QgsRectangle &extent = QgsRectangle() ); static QgsRasterRendererWidget* create( QgsRasterLayer* layer, const QgsRectangle &theExtent ) { return new QgsMultiBandColorRendererWidget( layer, theExtent ); } - ~QgsMultiBandColorRendererWidget(); QgsRasterRenderer* renderer() override; void setMapCanvas( QgsMapCanvas* canvas ) override; diff --git a/src/gui/raster/qgspalettedrendererwidget.cpp b/src/gui/raster/qgspalettedrendererwidget.cpp index 9c3b3e50e30..2876435ff93 100644 --- a/src/gui/raster/qgspalettedrendererwidget.cpp +++ b/src/gui/raster/qgspalettedrendererwidget.cpp @@ -59,11 +59,6 @@ QgsPalettedRendererWidget::QgsPalettedRendererWidget( QgsRasterLayer* layer, con } } -QgsPalettedRendererWidget::~QgsPalettedRendererWidget() -{ - -} - QgsRasterRenderer* QgsPalettedRendererWidget::renderer() { int nColors = mTreeWidget->topLevelItemCount(); diff --git a/src/gui/raster/qgspalettedrendererwidget.h b/src/gui/raster/qgspalettedrendererwidget.h index ac3ce13a332..f33dc5f8770 100644 --- a/src/gui/raster/qgspalettedrendererwidget.h +++ b/src/gui/raster/qgspalettedrendererwidget.h @@ -20,6 +20,7 @@ #include "qgsrasterrendererwidget.h" #include "ui_qgspalettedrendererwidgetbase.h" +#include "qgis_gui.h" class QgsRasterLayer; @@ -34,7 +35,6 @@ class GUI_EXPORT QgsPalettedRendererWidget: public QgsRasterRendererWidget, priv QgsPalettedRendererWidget( QgsRasterLayer* layer, const QgsRectangle &extent = QgsRectangle() ); static QgsRasterRendererWidget* create( QgsRasterLayer* layer, const QgsRectangle &theExtent ) { return new QgsPalettedRendererWidget( layer, theExtent ); } - ~QgsPalettedRendererWidget(); QgsRasterRenderer* renderer() override; diff --git a/src/gui/raster/qgsrasterhistogramwidget.cpp b/src/gui/raster/qgsrasterhistogramwidget.cpp index 17b9ab12f90..7e6c8d4621e 100644 --- a/src/gui/raster/qgsrasterhistogramwidget.cpp +++ b/src/gui/raster/qgsrasterhistogramwidget.cpp @@ -243,11 +243,6 @@ QgsRasterHistogramWidget::QgsRasterHistogramWidget( QgsRasterLayer* lyr, QWidget } // QgsRasterHistogramWidget ctor - -QgsRasterHistogramWidget::~QgsRasterHistogramWidget() -{ -} - void QgsRasterHistogramWidget::setRendererWidget( const QString& name, QgsRasterRendererWidget* rendererWidget ) { mRendererName = name; diff --git a/src/gui/raster/qgsrasterhistogramwidget.h b/src/gui/raster/qgsrasterhistogramwidget.h index 29b021e654b..733a5574e46 100644 --- a/src/gui/raster/qgsrasterhistogramwidget.h +++ b/src/gui/raster/qgsrasterhistogramwidget.h @@ -20,6 +20,7 @@ #include "ui_qgsrasterhistogramwidgetbase.h" #include "qgsmaplayerconfigwidget.h" +#include "qgis_gui.h" class QgsRasterLayer; class QgsRasterRendererWidget; @@ -43,7 +44,6 @@ class GUI_EXPORT QgsRasterHistogramWidget : public QgsMapLayerConfigWidget, priv public: QgsRasterHistogramWidget( QgsRasterLayer *lyr, QWidget *parent = nullptr ); - ~QgsRasterHistogramWidget(); //! Save the histogram as an image to disk bool histoSaveAsImage( const QString& theFilename, int width = 600, int height = 600, int quality = -1 ); diff --git a/src/gui/raster/qgsrasterminmaxwidget.cpp b/src/gui/raster/qgsrasterminmaxwidget.cpp index 5b174a817af..89adcbf1c74 100644 --- a/src/gui/raster/qgsrasterminmaxwidget.cpp +++ b/src/gui/raster/qgsrasterminmaxwidget.cpp @@ -34,6 +34,7 @@ QgsRasterMinMaxWidget::QgsRasterMinMaxWidget( QgsRasterLayer* theLayer, QWidget , mLayer( theLayer ) , mCanvas( nullptr ) , mLastRectangleValid( false ) + , mBandsChanged( false ) { QgsDebugMsg( "Entered." ); setupUi( this ); @@ -42,10 +43,6 @@ QgsRasterMinMaxWidget::QgsRasterMinMaxWidget( QgsRasterLayer* theLayer, QWidget setFromMinMaxOrigin( defaultMinMaxOrigin ); } -QgsRasterMinMaxWidget::~QgsRasterMinMaxWidget() -{ -} - void QgsRasterMinMaxWidget::setMapCanvas( QgsMapCanvas* canvas ) { mCanvas = canvas; @@ -56,6 +53,12 @@ QgsMapCanvas* QgsRasterMinMaxWidget::mapCanvas() return mCanvas; } +void QgsRasterMinMaxWidget::setBands( const QList & theBands ) +{ + mBandsChanged = theBands != mBands; + mBands = theBands; +} + QgsRectangle QgsRasterMinMaxWidget::extent() { const int nExtentIdx = mStatisticsExtentCombo->currentIndex(); @@ -178,7 +181,8 @@ void QgsRasterMinMaxWidget::doComputations() QgsRasterMinMaxOrigin newMinMaxOrigin = minMaxOrigin(); if ( mLastRectangleValid && mLastRectangle == myExtent && - mLastMinMaxOrigin == newMinMaxOrigin ) + mLastMinMaxOrigin == newMinMaxOrigin && + !mBandsChanged ) { QgsDebugMsg( "Does not need to redo statistics computations" ); return; @@ -187,6 +191,7 @@ void QgsRasterMinMaxWidget::doComputations() mLastRectangleValid = true; mLastRectangle = myExtent; mLastMinMaxOrigin = newMinMaxOrigin; + mBandsChanged = false; Q_FOREACH ( int myBand, mBands ) { diff --git a/src/gui/raster/qgsrasterminmaxwidget.h b/src/gui/raster/qgsrasterminmaxwidget.h index 04820341a67..7290c09662d 100644 --- a/src/gui/raster/qgsrasterminmaxwidget.h +++ b/src/gui/raster/qgsrasterminmaxwidget.h @@ -24,6 +24,7 @@ #include "qgsraster.h" #include "qgsrasterminmaxorigin.h" #include "qgscontrastenhancement.h" +#include "qgis_gui.h" class QgsMapCanvas; class QgsRasterLayer; @@ -36,7 +37,6 @@ class GUI_EXPORT QgsRasterMinMaxWidget: public QWidget, private Ui::QgsRasterMin Q_OBJECT public: QgsRasterMinMaxWidget( QgsRasterLayer* theLayer, QWidget *parent = nullptr ); - ~QgsRasterMinMaxWidget(); /** Sets the extent to use for minimum and maximum value calculation. * @param theExtent extent in raster layer's CRS @@ -61,7 +61,7 @@ class GUI_EXPORT QgsRasterMinMaxWidget: public QWidget, private Ui::QgsRasterMin */ QgsMapCanvas* mapCanvas(); - void setBands( const QList & theBands ) { mBands = theBands; } + void setBands( const QList & theBands ); /** Return the extent selected by the user. * Either an empty extent for 'full' or the current visible extent. @@ -125,6 +125,8 @@ class GUI_EXPORT QgsRasterMinMaxWidget: public QWidget, private Ui::QgsRasterMin bool mLastRectangleValid; QgsRectangle mLastRectangle; QgsRasterMinMaxOrigin mLastMinMaxOrigin; + + bool mBandsChanged; }; #endif // QGSRASTERMINMAXWIDGET_H diff --git a/src/gui/raster/qgsrasterrendererwidget.h b/src/gui/raster/qgsrasterrendererwidget.h index 9117d266ecb..d89dea02f08 100644 --- a/src/gui/raster/qgsrasterrendererwidget.h +++ b/src/gui/raster/qgsrasterrendererwidget.h @@ -21,6 +21,7 @@ #include "qgsrectangle.h" #include +#include "qgis_gui.h" class QgsRasterLayer; class QgsRasterRenderer; @@ -43,8 +44,6 @@ class GUI_EXPORT QgsRasterRendererWidget: public QWidget , mCanvas( nullptr ) {} - virtual ~QgsRasterRendererWidget() {} - virtual QgsRasterRenderer* renderer() = 0; void setRasterLayer( QgsRasterLayer* layer ) { mRasterLayer = layer; } diff --git a/src/gui/raster/qgsrastertransparencywidget.cpp b/src/gui/raster/qgsrastertransparencywidget.cpp index 1df1eafff4a..299e13b829a 100644 --- a/src/gui/raster/qgsrastertransparencywidget.cpp +++ b/src/gui/raster/qgsrastertransparencywidget.cpp @@ -62,10 +62,6 @@ QgsRasterTransparencyWidget::QgsRasterTransparencyWidget( QgsRasterLayer *layer, } } -QgsRasterTransparencyWidget::~QgsRasterTransparencyWidget() -{ -} - void QgsRasterTransparencyWidget::syncToLayer() { QgsRasterDataProvider* provider = mRasterLayer->dataProvider(); diff --git a/src/gui/raster/qgsrastertransparencywidget.h b/src/gui/raster/qgsrastertransparencywidget.h index 2539edfc36c..24343d2ed7f 100644 --- a/src/gui/raster/qgsrastertransparencywidget.h +++ b/src/gui/raster/qgsrastertransparencywidget.h @@ -20,6 +20,7 @@ #include "ui_qgsrastertransparencywidget.h" #include "qgsmaplayerconfigwidget.h" +#include "qgis_gui.h" class QgsRasterLayer; class QgsRasterRenderer; @@ -40,7 +41,6 @@ class GUI_EXPORT QgsRasterTransparencyWidget : public QgsMapLayerConfigWidget, p * @brief Widget to control a layers transparency and related options */ QgsRasterTransparencyWidget( QgsRasterLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0 ); - ~QgsRasterTransparencyWidget(); public slots: diff --git a/src/gui/raster/qgsrendererrasterpropertieswidget.cpp b/src/gui/raster/qgsrendererrasterpropertieswidget.cpp index 3b84ec2b964..5a50e7a858d 100644 --- a/src/gui/raster/qgsrendererrasterpropertieswidget.cpp +++ b/src/gui/raster/qgsrendererrasterpropertieswidget.cpp @@ -33,17 +33,19 @@ #include "qgssinglebandgrayrenderer.h" +#include "qgsmessagelog.h" + static void _initRendererWidgetFunctions() { static bool initialized = false; if ( initialized ) return; - QgsRasterRendererRegistry::instance()->insertWidgetFunction( QStringLiteral( "paletted" ), QgsPalettedRendererWidget::create ); - QgsRasterRendererRegistry::instance()->insertWidgetFunction( QStringLiteral( "multibandcolor" ), QgsMultiBandColorRendererWidget::create ); - QgsRasterRendererRegistry::instance()->insertWidgetFunction( QStringLiteral( "singlebandpseudocolor" ), QgsSingleBandPseudoColorRendererWidget::create ); - QgsRasterRendererRegistry::instance()->insertWidgetFunction( QStringLiteral( "singlebandgray" ), QgsSingleBandGrayRendererWidget::create ); - QgsRasterRendererRegistry::instance()->insertWidgetFunction( QStringLiteral( "hillshade" ), QgsHillshadeRendererWidget::create ); + QgsApplication::rasterRendererRegistry()->insertWidgetFunction( QStringLiteral( "paletted" ), QgsPalettedRendererWidget::create ); + QgsApplication::rasterRendererRegistry()->insertWidgetFunction( QStringLiteral( "multibandcolor" ), QgsMultiBandColorRendererWidget::create ); + QgsApplication::rasterRendererRegistry()->insertWidgetFunction( QStringLiteral( "singlebandpseudocolor" ), QgsSingleBandPseudoColorRendererWidget::create ); + QgsApplication::rasterRendererRegistry()->insertWidgetFunction( QStringLiteral( "singlebandgray" ), QgsSingleBandGrayRendererWidget::create ); + QgsApplication::rasterRendererRegistry()->insertWidgetFunction( QStringLiteral( "hillshade" ), QgsHillshadeRendererWidget::create ); initialized = true; } @@ -109,11 +111,6 @@ QgsRendererRasterPropertiesWidget::QgsRendererRasterPropertiesWidget( QgsMapLaye connect( mRasterLayer, SIGNAL( styleChanged() ), this, SLOT( refreshAfterSyleChanged() ) ); } -QgsRendererRasterPropertiesWidget::~QgsRendererRasterPropertiesWidget() -{ - -} - void QgsRendererRasterPropertiesWidget::setMapCanvas( QgsMapCanvas *canvas ) { mMapCanvas = canvas; @@ -196,9 +193,9 @@ void QgsRendererRasterPropertiesWidget::syncToLayer( QgsRasterLayer* layer ) cboRenderers->blockSignals( true ); cboRenderers->clear(); QgsRasterRendererRegistryEntry entry; - Q_FOREACH ( const QString& name, QgsRasterRendererRegistry::instance()->renderersList() ) + Q_FOREACH ( const QString& name, QgsApplication::rasterRendererRegistry()->renderersList() ) { - if ( QgsRasterRendererRegistry::instance()->rendererData( name, entry ) ) + if ( QgsApplication::rasterRendererRegistry()->rendererData( name, entry ) ) { if (( mRasterLayer->rasterType() != QgsRasterLayer::ColorLayer && entry.name != QLatin1String( "singlebandcolordata" ) ) || ( mRasterLayer->rasterType() == QgsRasterLayer::ColorLayer && entry.name == QLatin1String( "singlebandcolordata" ) ) ) @@ -324,15 +321,40 @@ void QgsRendererRasterPropertiesWidget::setRendererWidget( const QString &render { QgsDebugMsg( "rendererName = " + rendererName ); QgsRasterRendererWidget* oldWidget = mRendererWidget; + QgsRasterRenderer* oldRenderer = mRasterLayer->renderer(); + + int alphaBand = -1; + double opacity = 1; + if ( oldRenderer ) + { + // Retain alpha band and opacity when switching renderer + alphaBand = oldRenderer->alphaBand(); + opacity = oldRenderer->opacity(); + } QgsRasterRendererRegistryEntry rendererEntry; - if ( QgsRasterRendererRegistry::instance()->rendererData( rendererName, rendererEntry ) ) + if ( QgsApplication::rasterRendererRegistry()->rendererData( rendererName, rendererEntry ) ) { - if ( rendererEntry.widgetCreateFunction ) //single band color data renderer e.g. has no widget + if ( rendererEntry.widgetCreateFunction ) // Single band color data renderer e.g. has no widget { QgsDebugMsg( "renderer has widgetCreateFunction" ); // Current canvas extent (used to calc min/max) in layer CRS QgsRectangle myExtent = mMapCanvas->mapSettings().outputExtentToLayerExtent( mRasterLayer, mMapCanvas->extent() ); + if ( oldWidget ) + { + if ( rendererName == "singlebandgray" ) + { + whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( QgsRaster::SingleBandGray, mRasterLayer->dataProvider() ) ); + whileBlocking( mRasterLayer )->setDefaultContrastEnhancement(); + } + else if ( rendererName == "multibandcolor" ) + { + whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( QgsRaster::MultiBandColor, mRasterLayer->dataProvider() ) ); + whileBlocking( mRasterLayer )->setDefaultContrastEnhancement(); + } + } + mRasterLayer->renderer()->setAlphaBand( alphaBand ); + mRasterLayer->renderer()->setOpacity( opacity ); mRendererWidget = rendererEntry.widgetCreateFunction( mRasterLayer, myExtent ); mRendererWidget->setMapCanvas( mMapCanvas ); connect( mRendererWidget, SIGNAL( widgetChanged() ), this, SIGNAL( widgetChanged() ) ); @@ -340,15 +362,17 @@ void QgsRendererRasterPropertiesWidget::setRendererWidget( const QString &render stackedWidget->setCurrentWidget( mRendererWidget ); if ( oldWidget ) { - //compare used bands in new and old renderer and reset transparency dialog if different + // Compare used bands in new and old renderer and reset transparency dialog if different QgsRasterRenderer* oldRenderer = oldWidget->renderer(); QgsRasterRenderer* newRenderer = mRendererWidget->renderer(); QList oldBands = oldRenderer->usesBands(); QList newBands = newRenderer->usesBands(); + // if ( oldBands != newBands ) // { // populateTransparencyTable( newRenderer ); // } + delete oldRenderer; delete newRenderer; } diff --git a/src/gui/raster/qgsrendererrasterpropertieswidget.h b/src/gui/raster/qgsrendererrasterpropertieswidget.h index 89b049b7961..49e2d1d9817 100644 --- a/src/gui/raster/qgsrendererrasterpropertieswidget.h +++ b/src/gui/raster/qgsrendererrasterpropertieswidget.h @@ -21,6 +21,7 @@ #include "ui_qgsrendererrasterpropswidgetbase.h" #include "qgsmaplayerconfigwidget.h" +#include "qgis_gui.h" class QgsRasterLayer; @@ -42,8 +43,7 @@ class GUI_EXPORT QgsRendererRasterPropertiesWidget : public QgsMapLayerConfigWid * @param canvas The canvas object used to calculate the max and min values from the extent. * @param parent Parent object */ - QgsRendererRasterPropertiesWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0 ); - ~QgsRendererRasterPropertiesWidget(); + QgsRendererRasterPropertiesWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent = nullptr ); /** Sets the map canvas associated with the dialog. This allows the widget to retrieve the current * map scale and other properties from the canvas. diff --git a/src/gui/raster/qgssinglebandgrayrendererwidget.cpp b/src/gui/raster/qgssinglebandgrayrendererwidget.cpp index e31625f5b66..d92fe668a46 100644 --- a/src/gui/raster/qgssinglebandgrayrendererwidget.cpp +++ b/src/gui/raster/qgssinglebandgrayrendererwidget.cpp @@ -74,15 +74,9 @@ QgsSingleBandGrayRendererWidget::QgsSingleBandGrayRendererWidget( QgsRasterLayer connect( mGradientComboBox, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( widgetChanged() ) ); connect( mContrastEnhancementComboBox, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( widgetChanged() ) ); - connect( mMaxLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( widgetChanged() ) ); - connect( mMinLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( widgetChanged() ) ); } } -QgsSingleBandGrayRendererWidget::~QgsSingleBandGrayRendererWidget() -{ -} - QgsRasterRenderer* QgsSingleBandGrayRendererWidget::renderer() { if ( !mRasterLayer ) @@ -142,6 +136,7 @@ void QgsSingleBandGrayRendererWidget::minMaxModified() mContrastEnhancementComboBox->findData(( int ) QgsContrastEnhancement::StretchToMinimumMaximum ) ); } mMinMaxWidget->userHasSetManualMinMaxValues(); + emit widgetChanged(); } } @@ -216,4 +211,4 @@ void QgsSingleBandGrayRendererWidget::setMax( const QString& value, int ) mDisableMinMaxWidgetRefresh = true; mMaxLineEdit->setText( value ); mDisableMinMaxWidgetRefresh = false; -} \ No newline at end of file +} diff --git a/src/gui/raster/qgssinglebandgrayrendererwidget.h b/src/gui/raster/qgssinglebandgrayrendererwidget.h index 8e9a314fb65..1555f9a768e 100644 --- a/src/gui/raster/qgssinglebandgrayrendererwidget.h +++ b/src/gui/raster/qgssinglebandgrayrendererwidget.h @@ -20,6 +20,7 @@ #include "qgsrasterrendererwidget.h" #include "ui_qgssinglebandgrayrendererwidgetbase.h" +#include "qgis_gui.h" class QgsRasterMinMaxWidget; @@ -31,7 +32,6 @@ class GUI_EXPORT QgsSingleBandGrayRendererWidget: public QgsRasterRendererWidget Q_OBJECT public: QgsSingleBandGrayRendererWidget( QgsRasterLayer* layer, const QgsRectangle &extent = QgsRectangle() ); - ~QgsSingleBandGrayRendererWidget(); static QgsRasterRendererWidget* create( QgsRasterLayer* layer, const QgsRectangle &theExtent ) { return new QgsSingleBandGrayRendererWidget( layer, theExtent ); } diff --git a/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp b/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp index f0e670af2ba..c75001a8e7c 100644 --- a/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp +++ b/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp @@ -86,11 +86,8 @@ QgsSingleBandPseudoColorRendererWidget::QgsSingleBandPseudoColorRendererWidget( mMinMaxContainerWidget->setLayout( layout ); layout->addWidget( mMinMaxWidget ); - connect( mMinMaxWidget, &QgsRasterMinMaxWidget::widgetChanged, - this, &QgsSingleBandPseudoColorRendererWidget::widgetChanged ); - - connect( mMinMaxWidget, &QgsRasterMinMaxWidget::load, - this, &QgsSingleBandPseudoColorRendererWidget::loadMinMax ); + connect( mMinMaxWidget, &QgsRasterMinMaxWidget::widgetChanged, this, &QgsSingleBandPseudoColorRendererWidget::widgetChanged ); + connect( mMinMaxWidget, &QgsRasterMinMaxWidget::load, this, &QgsSingleBandPseudoColorRendererWidget::loadMinMax ); //fill available bands into combo box int nBands = provider->bandCount(); @@ -99,14 +96,15 @@ QgsSingleBandPseudoColorRendererWidget::QgsSingleBandPseudoColorRendererWidget( mBandComboBox->addItem( displayBandName( i ), i ); } - mColorInterpolationComboBox->addItem( tr( "Discrete" ), QgsColorRampShader::DISCRETE ); - mColorInterpolationComboBox->addItem( tr( "Linear" ), QgsColorRampShader::INTERPOLATED ); - mColorInterpolationComboBox->addItem( tr( "Exact" ), QgsColorRampShader::EXACT ); - mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QgsColorRampShader::INTERPOLATED ) ); + mColorInterpolationComboBox->addItem( tr( "Discrete" ), QgsColorRampShader::Discrete ); + mColorInterpolationComboBox->addItem( tr( "Linear" ), QgsColorRampShader::Interpolated ); + mColorInterpolationComboBox->addItem( tr( "Exact" ), QgsColorRampShader::Exact ); + mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QgsColorRampShader::Interpolated ) ); - mClassificationModeComboBox->addItem( tr( "Continuous" ), Continuous ); - mClassificationModeComboBox->addItem( tr( "Equal interval" ), EqualInterval ); - mClassificationModeComboBox->addItem( tr( "Quantile" ), Quantile ); + mClassificationModeComboBox->addItem( tr( "Continuous" ), QgsColorRampShader::Continuous ); + mClassificationModeComboBox->addItem( tr( "Equal interval" ), QgsColorRampShader::EqualInterval ); + mClassificationModeComboBox->addItem( tr( "Quantile" ), QgsColorRampShader::Quantile ); + mClassificationModeComboBox->setCurrentIndex( mClassificationModeComboBox->findData( QgsColorRampShader::Continuous ) ); mNumberOfEntriesSpinBox->setValue( 5 ); // some default @@ -136,14 +134,12 @@ QgsSingleBandPseudoColorRendererWidget::QgsSingleBandPseudoColorRendererWidget( connect( mClipCheckBox, SIGNAL( toggled( bool ) ), this, SIGNAL( widgetChanged() ) ); } -QgsSingleBandPseudoColorRendererWidget::~QgsSingleBandPseudoColorRendererWidget() -{ -} - QgsRasterRenderer* QgsSingleBandPseudoColorRendererWidget::renderer() { QgsRasterShader* rasterShader = new QgsRasterShader(); - QgsColorRampShader* colorRampShader = new QgsColorRampShader(); + QgsColorRampShader* colorRampShader = new QgsColorRampShader( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) ); + colorRampShader->setColorRampType( static_cast< QgsColorRampShader::Type >( mColorInterpolationComboBox->currentData().toInt() ) ); + colorRampShader->setClassificationMode( static_cast< QgsColorRampShader::ClassificationMode >( mClassificationModeComboBox->currentData().toInt() ) ); colorRampShader->setClip( mClipCheckBox->isChecked() ); //iterate through mColormapTreeWidget and set colormap info of layer @@ -167,10 +163,6 @@ QgsRasterRenderer* QgsSingleBandPseudoColorRendererWidget::renderer() qSort( colorRampItems ); colorRampShader->setColorRampItemList( colorRampItems ); - QgsColorRampShader::ColorRamp_TYPE interpolation = static_cast< QgsColorRampShader::ColorRamp_TYPE >( mColorInterpolationComboBox->currentData().toInt() ); - colorRampShader->setColorRampType( interpolation ); - - if ( !btnColorRamp->isNull() ) { colorRampShader->setSourceColorRamp( btnColorRamp->colorRamp() ); @@ -180,7 +172,6 @@ QgsRasterRenderer* QgsSingleBandPseudoColorRendererWidget::renderer() int bandNumber = mBandComboBox->currentData().toInt(); QgsSingleBandPseudoColorRenderer *renderer = new QgsSingleBandPseudoColorRenderer( mRasterLayer->dataProvider(), bandNumber, rasterShader ); - renderer->setClassificationMin( lineEditValue( mMinLineEdit ) ); renderer->setClassificationMax( lineEditValue( mMaxLineEdit ) ); renderer->setMinMaxOrigin( mMinMaxWidget->minMaxOrigin() ); @@ -206,8 +197,8 @@ void QgsSingleBandPseudoColorRendererWidget::setMapCanvas( QgsMapCanvas* canvas */ void QgsSingleBandPseudoColorRendererWidget::autoLabel() { - QgsColorRampShader::ColorRamp_TYPE interpolation = static_cast< QgsColorRampShader::ColorRamp_TYPE >( mColorInterpolationComboBox->currentData().toInt() ); - bool discrete = interpolation == QgsColorRampShader::DISCRETE; + QgsColorRampShader::Type interpolation = static_cast< QgsColorRampShader::Type >( mColorInterpolationComboBox->currentData().toInt() ); + bool discrete = interpolation == QgsColorRampShader::Discrete; QString unit = mUnitLineEdit->text(); QString label; int topLevelItemCount = mColormapTreeWidget->topLevelItemCount(); @@ -252,8 +243,8 @@ void QgsSingleBandPseudoColorRendererWidget::autoLabel() //! Extract the unit out of the current labels and set the unit field. void QgsSingleBandPseudoColorRendererWidget::setUnitFromLabels() { - QgsColorRampShader::ColorRamp_TYPE interpolation = static_cast< QgsColorRampShader::ColorRamp_TYPE >( mColorInterpolationComboBox->currentData().toInt() ); - bool discrete = interpolation == QgsColorRampShader::DISCRETE; + QgsColorRampShader::Type interpolation = static_cast< QgsColorRampShader::Type >( mColorInterpolationComboBox->currentData().toInt() ); + bool discrete = interpolation == QgsColorRampShader::Discrete; QStringList allSuffixes; QString label; int topLevelItemCount = mColormapTreeWidget->topLevelItemCount(); @@ -346,201 +337,51 @@ void QgsSingleBandPseudoColorRendererWidget::on_mDeleteEntryButton_clicked() void QgsSingleBandPseudoColorRendererWidget::classify() { - int bandComboIndex = mBandComboBox->currentIndex(); - if ( bandComboIndex == -1 || !mRasterLayer ) + QScopedPointer< QgsColorRamp > ramp( btnColorRamp->colorRamp() ); + if ( !ramp ) { return; } - //int bandNr = mBandComboBox->itemData( bandComboIndex ).toInt(); - //QgsRasterBandStats myRasterBandStats = mRasterLayer->dataProvider()->bandStatistics( bandNr ); - int numberOfEntries; + QgsSingleBandPseudoColorRenderer *pr = new QgsSingleBandPseudoColorRenderer( mRasterLayer->dataProvider(), mBandComboBox->currentData().toInt(), nullptr ); + pr->setClassificationMin( lineEditValue( mMinLineEdit ) ); + pr->setClassificationMax( lineEditValue( mMaxLineEdit ) ); + pr->createShader( ramp.data(), static_cast< QgsColorRampShader::Type >( mColorInterpolationComboBox->currentData().toInt() ), static_cast< QgsColorRampShader::ClassificationMode >( mClassificationModeComboBox->currentData().toInt() ), mNumberOfEntriesSpinBox->value(), mClipCheckBox->isChecked(), minMaxWidget()->extent() ); - QgsColorRampShader::ColorRamp_TYPE interpolation = static_cast< QgsColorRampShader::ColorRamp_TYPE >( mColorInterpolationComboBox->currentData().toInt() ); - bool discrete = interpolation == QgsColorRampShader::DISCRETE; - - QList entryValues; - QVector entryColors; - - double min = lineEditValue( mMinLineEdit ); - double max = lineEditValue( mMaxLineEdit ); - - QScopedPointer< QgsColorRamp > colorRamp( btnColorRamp->colorRamp() ); - - if ( mClassificationModeComboBox->currentData().toInt() == Continuous ) + const QgsRasterShader* rasterShader = pr->shader(); + if ( rasterShader ) { - if ( colorRamp.data() && colorRamp->count() > 1 ) + const QgsColorRampShader* colorRampShader = dynamic_cast( rasterShader->rasterShaderFunction() ); + if ( colorRampShader ) { - numberOfEntries = colorRamp->count(); - entryValues.reserve( numberOfEntries ); - if ( discrete ) + mColormapTreeWidget->clear(); + + const QList colorRampItemList = colorRampShader->colorRampItemList(); + QList::const_iterator it = colorRampItemList.constBegin(); + for ( ; it != colorRampItemList.end(); ++it ) { - double intervalDiff = max - min; - - // remove last class when ColorRamp is gradient and discrete, as they are implemented with an extra stop - QgsGradientColorRamp* colorGradientRamp = dynamic_cast( colorRamp.data() ); - if ( colorGradientRamp != NULL && colorGradientRamp->isDiscrete() ) - { - numberOfEntries--; - } - else - { - // if color ramp is continuous scale values to get equally distributed classes. - // Doesn't work perfectly when stops are non equally distributed. - intervalDiff *= ( numberOfEntries - 1 ) / ( double )numberOfEntries; - } - - // skip first value (always 0.0) - for ( int i = 1; i < numberOfEntries; ++i ) - { - double value = colorRamp->value( i ); - entryValues.push_back( min + value * intervalDiff ); - } - entryValues.push_back( std::numeric_limits::infinity() ); - } - else - { - for ( int i = 0; i < numberOfEntries; ++i ) - { - double value = colorRamp->value( i ); - entryValues.push_back( min + value * ( max - min ) ); - } - } - // for continuous mode take original color map colors - for ( int i = 0; i < numberOfEntries; ++i ) - { - int idx = i; - entryColors.push_back( colorRamp->color( colorRamp->value( idx ) ) ); - } - } - } - else // for other classification modes interpolate colors linearly - { - numberOfEntries = mNumberOfEntriesSpinBox->value(); - if ( numberOfEntries < 2 ) - return; // < 2 classes is not useful, shouldn't happen, but if it happens save it from crashing - - if ( mClassificationModeComboBox->currentData().toInt() == Quantile ) - { // Quantile - int bandNr = mBandComboBox->itemData( bandComboIndex ).toInt(); - //QgsRasterHistogram rasterHistogram = mRasterLayer->dataProvider()->histogram( bandNr ); - - double cut1 = std::numeric_limits::quiet_NaN(); - double cut2 = std::numeric_limits::quiet_NaN(); - - QgsRectangle extent = mMinMaxWidget->extent(); - int sampleSize = mMinMaxWidget->sampleSize(); - - // set min and max from histogram, used later to calculate number of decimals to display - mRasterLayer->dataProvider()->cumulativeCut( bandNr, 0.0, 1.0, min, max, extent, sampleSize ); - - entryValues.reserve( numberOfEntries ); - if ( discrete ) - { - double intervalDiff = 1.0 / ( numberOfEntries ); - for ( int i = 1; i < numberOfEntries; ++i ) - { - mRasterLayer->dataProvider()->cumulativeCut( bandNr, 0.0, i * intervalDiff, cut1, cut2, extent, sampleSize ); - entryValues.push_back( cut2 ); - } - entryValues.push_back( std::numeric_limits::infinity() ); - } - else - { - double intervalDiff = 1.0 / ( numberOfEntries - 1 ); - for ( int i = 0; i < numberOfEntries; ++i ) - { - mRasterLayer->dataProvider()->cumulativeCut( bandNr, 0.0, i * intervalDiff, cut1, cut2, extent, sampleSize ); - entryValues.push_back( cut2 ); - } - } - } - else // EqualInterval - { - entryValues.reserve( numberOfEntries ); - if ( discrete ) - { - // in discrete mode the lowest value is not an entry and the highest - // value is inf, there are ( numberOfEntries ) of which the first - // and last are not used. - double intervalDiff = ( max - min ) / ( numberOfEntries ); - - for ( int i = 1; i < numberOfEntries; ++i ) - { - entryValues.push_back( min + i * intervalDiff ); - } - entryValues.push_back( std::numeric_limits::infinity() ); - } - else - { - //because the highest value is also an entry, there are (numberOfEntries - 1) intervals - double intervalDiff = ( max - min ) / ( numberOfEntries - 1 ); - - for ( int i = 0; i < numberOfEntries; ++i ) - { - entryValues.push_back( min + i * intervalDiff ); - } - } - } - - if ( !colorRamp.data() || colorRamp->count() == 1 ) - { - //hard code color range from blue -> red (previous default) - int colorDiff = 0; - if ( numberOfEntries != 0 ) - { - colorDiff = ( int )( 255 / numberOfEntries ); - } - - entryColors.reserve( numberOfEntries ); - for ( int i = 0; i < numberOfEntries; ++i ) - { - QColor currentColor; - int idx = i; - currentColor.setRgb( colorDiff*idx, 0, 255 - colorDiff * idx ); - entryColors.push_back( currentColor ); - } - } - else - { - entryColors.reserve( numberOfEntries ); - for ( int i = 0; i < numberOfEntries; ++i ) - { - int idx = i; - entryColors.push_back( colorRamp->color((( double ) idx ) / ( numberOfEntries - 1 ) ) ); + QgsTreeWidgetItemObject* newItem = new QgsTreeWidgetItemObject( mColormapTreeWidget ); + newItem->setText( ValueColumn, QString::number( it->value, 'g', 15 ) ); + newItem->setBackground( ColorColumn, QBrush( it->color ) ); + newItem->setText( LabelColumn, it->label ); + newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable ); + connect( newItem, SIGNAL( itemEdited( QTreeWidgetItem*, int ) ), + this, SLOT( mColormapTreeWidget_itemEdited( QTreeWidgetItem*, int ) ) ); } + mClipCheckBox->setChecked( colorRampShader->clip() ); } } - mColormapTreeWidget->clear(); - - QList::const_iterator value_it = entryValues.begin(); - QVector::const_iterator color_it = entryColors.begin(); - - // calculate a reasonable number of decimals to display - double maxabs = log10( qMax( qAbs( max ), qAbs( min ) ) ); - int nDecimals = qRound( qMax( 3.0 + maxabs - log10( max - min ), maxabs <= 15.0 ? maxabs + 0.49 : 0.0 ) ); - - for ( ; value_it != entryValues.end(); ++value_it, ++color_it ) - { - QgsTreeWidgetItemObject* newItem = new QgsTreeWidgetItemObject( mColormapTreeWidget ); - newItem->setText( ValueColumn, QString::number( *value_it, 'g', nDecimals ) ); - newItem->setBackground( ColorColumn, QBrush( *color_it ) ); - newItem->setText( LabelColumn, QString() ); - newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable ); - connect( newItem, SIGNAL( itemEdited( QTreeWidgetItem*, int ) ), - this, SLOT( mColormapTreeWidget_itemEdited( QTreeWidgetItem*, int ) ) ); - } autoLabel(); emit widgetChanged(); } void QgsSingleBandPseudoColorRendererWidget::on_mClassificationModeComboBox_currentIndexChanged( int index ) { - Mode mode = static_cast< Mode >( mClassificationModeComboBox->itemData( index ).toInt() ); - mNumberOfEntriesSpinBox->setEnabled( mode != Continuous ); - mMinLineEdit->setEnabled( mode != Quantile ); - mMaxLineEdit->setEnabled( mode != Quantile ); + QgsColorRampShader::ClassificationMode mode = static_cast< QgsColorRampShader::ClassificationMode >( mClassificationModeComboBox->itemData( index ).toInt() ); + mNumberOfEntriesSpinBox->setEnabled( mode != QgsColorRampShader::Continuous ); + mMinLineEdit->setEnabled( mode != QgsColorRampShader::Quantile ); + mMaxLineEdit->setEnabled( mode != QgsColorRampShader::Quantile ); } void QgsSingleBandPseudoColorRendererWidget::applyColorRamp() @@ -562,7 +403,7 @@ void QgsSingleBandPseudoColorRendererWidget::applyColorRamp() mClassificationModeComboBox->setEnabled( enableContinuous ); if ( !enableContinuous ) { - mClassificationModeComboBox->setCurrentIndex( mClassificationModeComboBox->findData( EqualInterval ) ); + mClassificationModeComboBox->setCurrentIndex( mClassificationModeComboBox->findData( QgsColorRampShader::EqualInterval ) ); } classify(); @@ -599,7 +440,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mLoadFromBandButton_clicked() if ( !colorRampList.isEmpty() ) { populateColormapTreeWidget( colorRampList ); - mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QgsColorRampShader::INTERPOLATED ) ); + mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QgsColorRampShader::Interpolated ) ); } else { @@ -643,15 +484,15 @@ void QgsSingleBandPseudoColorRendererWidget::on_mLoadFromFileButton_clicked() { if ( inputStringComponents[1].trimmed().toUpper().compare( QLatin1String( "INTERPOLATED" ), Qt::CaseInsensitive ) == 0 ) { - mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QgsColorRampShader::INTERPOLATED ) ); + mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QgsColorRampShader::Interpolated ) ); } else if ( inputStringComponents[1].trimmed().toUpper().compare( QLatin1String( "DISCRETE" ), Qt::CaseInsensitive ) == 0 ) { - mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QgsColorRampShader::DISCRETE ) ); + mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QgsColorRampShader::Discrete ) ); } else { - mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QgsColorRampShader::EXACT ) ); + mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QgsColorRampShader::Exact ) ); } } else @@ -716,16 +557,16 @@ void QgsSingleBandPseudoColorRendererWidget::on_mExportToFileButton_clicked() QTextStream outputStream( &outputFile ); outputStream << "# " << tr( "QGIS Generated Color Map Export File" ) << '\n'; outputStream << "INTERPOLATION:"; - QgsColorRampShader::ColorRamp_TYPE interpolation = static_cast< QgsColorRampShader::ColorRamp_TYPE >( mColorInterpolationComboBox->currentData().toInt() ); + QgsColorRampShader::Type interpolation = static_cast< QgsColorRampShader::Type >( mColorInterpolationComboBox->currentData().toInt() ); switch ( interpolation ) { - case QgsColorRampShader::INTERPOLATED: + case QgsColorRampShader::Interpolated: outputStream << "INTERPOLATED\n"; break; - case QgsColorRampShader::DISCRETE: + case QgsColorRampShader::Discrete: outputStream << "DISCRETE\n"; break; - case QgsColorRampShader::EXACT: + case QgsColorRampShader::Exact: outputStream << "EXACT\n"; break; } @@ -852,6 +693,9 @@ void QgsSingleBandPseudoColorRendererWidget::setFromRenderer( const QgsRasterRen } setUnitFromLabels(); mClipCheckBox->setChecked( colorRampShader->clip() ); + + mClassificationModeComboBox->setCurrentIndex( mClassificationModeComboBox->findData( colorRampShader->classificationMode() ) ); + mNumberOfEntriesSpinBox->setValue( colorRampShader->colorRampItemList().count() ); // some default } } setLineEditValue( mMinLineEdit, pr->classificationMin() ); @@ -870,23 +714,23 @@ void QgsSingleBandPseudoColorRendererWidget::on_mBandComboBox_currentIndexChange void QgsSingleBandPseudoColorRendererWidget::on_mColorInterpolationComboBox_currentIndexChanged( int index ) { - QgsColorRampShader::ColorRamp_TYPE interpolation = static_cast< QgsColorRampShader::ColorRamp_TYPE >( mColorInterpolationComboBox->itemData( index ).toInt() ); + QgsColorRampShader::Type interpolation = static_cast< QgsColorRampShader::Type >( mColorInterpolationComboBox->itemData( index ).toInt() ); - mClipCheckBox->setEnabled( interpolation == QgsColorRampShader::INTERPOLATED ); + mClipCheckBox->setEnabled( interpolation == QgsColorRampShader::Interpolated ); QString valueLabel; QString valueToolTip; switch ( interpolation ) { - case QgsColorRampShader::INTERPOLATED: + case QgsColorRampShader::Interpolated: valueLabel = tr( "Value" ); valueToolTip = tr( "Value for color stop" ); break; - case QgsColorRampShader::DISCRETE: + case QgsColorRampShader::Discrete: valueLabel = tr( "Value <=" ); valueToolTip = tr( "Maximum value for class" ); break; - case QgsColorRampShader::EXACT: + case QgsColorRampShader::Exact: valueLabel = tr( "Value =" ); valueToolTip = tr( "Value for color" ); break; @@ -924,6 +768,7 @@ void QgsSingleBandPseudoColorRendererWidget::loadMinMax( int theBandNo, double t mMaxLineEdit->setText( QString::number( theMax ) ); } mDisableMinMaxWidgetRefresh = false; + classify(); } void QgsSingleBandPseudoColorRendererWidget::setLineEditValue( QLineEdit * theLineEdit, double theValue ) diff --git a/src/gui/raster/qgssinglebandpseudocolorrendererwidget.h b/src/gui/raster/qgssinglebandpseudocolorrendererwidget.h index ffcc3554766..a1dd6f5677f 100644 --- a/src/gui/raster/qgssinglebandpseudocolorrendererwidget.h +++ b/src/gui/raster/qgssinglebandpseudocolorrendererwidget.h @@ -22,6 +22,7 @@ #include "qgscolorrampshader.h" #include "qgsrasterrenderer.h" #include "ui_qgssinglebandpseudocolorrendererwidgetbase.h" +#include "qgis_gui.h" class QgsRasterMinMaxWidget; @@ -36,15 +37,7 @@ class GUI_EXPORT QgsSingleBandPseudoColorRendererWidget: public QgsRasterRendere public: - enum Mode - { - Continuous = 1, // Using breaks from color palette - EqualInterval = 2, - Quantile = 3 - }; - QgsSingleBandPseudoColorRendererWidget( QgsRasterLayer* layer, const QgsRectangle &extent = QgsRectangle() ); - ~QgsSingleBandPseudoColorRendererWidget(); static QgsRasterRendererWidget* create( QgsRasterLayer* layer, const QgsRectangle &theExtent ) { return new QgsSingleBandPseudoColorRendererWidget( layer, theExtent ); } QgsRasterRenderer* renderer() override; diff --git a/src/gui/symbology-ng/characterwidget.h b/src/gui/symbology-ng/characterwidget.h index 9ae4658aa14..2817753d25d 100644 --- a/src/gui/symbology-ng/characterwidget.h +++ b/src/gui/symbology-ng/characterwidget.h @@ -52,6 +52,7 @@ #include #include #include +#include "qgis_gui.h" QT_BEGIN_NAMESPACE class QMouseEvent; diff --git a/src/gui/symbology-ng/qgs25drendererwidget.h b/src/gui/symbology-ng/qgs25drendererwidget.h index 5cc17b33745..d14896c0438 100644 --- a/src/gui/symbology-ng/qgs25drendererwidget.h +++ b/src/gui/symbology-ng/qgs25drendererwidget.h @@ -18,6 +18,7 @@ #include "ui_qgs25drendererwidgetbase.h" #include "qgsrendererwidget.h" +#include "qgis_gui.h" class Qgs25DRenderer; diff --git a/src/gui/symbology-ng/qgsarrowsymbollayerwidget.h b/src/gui/symbology-ng/qgsarrowsymbollayerwidget.h index 811e365bd8e..2112d7e274a 100644 --- a/src/gui/symbology-ng/qgsarrowsymbollayerwidget.h +++ b/src/gui/symbology-ng/qgsarrowsymbollayerwidget.h @@ -17,6 +17,7 @@ #include "ui_qgsarrowsymbollayerwidgetbase.h" #include "qgssymbollayerwidget.h" +#include "qgis_gui.h" class QgsArrowSymbolLayer; @@ -40,9 +41,7 @@ class GUI_EXPORT QgsArrowSymbolLayerWidget: public QgsSymbolLayerWidget, private */ static QgsSymbolLayerWidget* create( const QgsVectorLayer* layer ) { return new QgsArrowSymbolLayerWidget( layer ); } - //! Set the symbol layer virtual void setSymbolLayer( QgsSymbolLayer* layer ) override; - //! Get the current symbol layer virtual QgsSymbolLayer* symbolLayer() override; private: diff --git a/src/gui/symbology-ng/qgsbrushstylecombobox.h b/src/gui/symbology-ng/qgsbrushstylecombobox.h index b201abc0b0a..81c7cf2dd94 100644 --- a/src/gui/symbology-ng/qgsbrushstylecombobox.h +++ b/src/gui/symbology-ng/qgsbrushstylecombobox.h @@ -17,6 +17,7 @@ #define QGSBRUSHSTYLECOMBOBOX_H #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsBrushStyleComboBox diff --git a/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp b/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp index 2ec47020a26..cb63d60ff3e 100644 --- a/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp +++ b/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp @@ -629,7 +629,7 @@ void QgsCategorizedSymbolRendererWidget::addCategories() QgsExpression* expression = new QgsExpression( attrName ); QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ) << QgsExpressionContextUtils::layerScope( mLayer ); @@ -1008,7 +1008,7 @@ QgsExpressionContext QgsCategorizedSymbolRendererWidget::createExpressionContext { QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ); if ( mContext.mapCanvas() ) diff --git a/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.h b/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.h index 1c60d5ce4b0..b3ab963afea 100644 --- a/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.h +++ b/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.h @@ -24,6 +24,7 @@ class QgsCategorizedSymbolRenderer; class QgsRendererCategory; #include "ui_qgscategorizedsymbolrendererv2widget.h" +#include "qgis_gui.h" ///@cond PRIVATE diff --git a/src/gui/symbology-ng/qgscptcitycolorrampdialog.cpp b/src/gui/symbology-ng/qgscptcitycolorrampdialog.cpp index d0b22fbe474..fd9f5f6772b 100644 --- a/src/gui/symbology-ng/qgscptcitycolorrampdialog.cpp +++ b/src/gui/symbology-ng/qgscptcitycolorrampdialog.cpp @@ -121,10 +121,6 @@ QgsCptCityColorRampDialog::QgsCptCityColorRampDialog( const QgsCptCityColorRamp& } -QgsCptCityColorRampDialog::~QgsCptCityColorRampDialog() -{ -} - void QgsCptCityColorRampDialog::setRamp( const QgsCptCityColorRamp& ramp ) { mRamp = ramp; diff --git a/src/gui/symbology-ng/qgscptcitycolorrampdialog.h b/src/gui/symbology-ng/qgscptcitycolorrampdialog.h index 5453b140284..01cf565d8bb 100644 --- a/src/gui/symbology-ng/qgscptcitycolorrampdialog.h +++ b/src/gui/symbology-ng/qgscptcitycolorrampdialog.h @@ -25,6 +25,7 @@ #include #include #include +#include "qgis_gui.h" class QgsCptCityColorRamp; class TreeFilterProxyModel; @@ -48,7 +49,6 @@ class GUI_EXPORT QgsCptCityColorRampDialog : public QDialog, private Ui::QgsCptC * @param parent parent widget */ QgsCptCityColorRampDialog( const QgsCptCityColorRamp& ramp, QWidget* parent = nullptr ); - ~QgsCptCityColorRampDialog(); /** Returns a color ramp representing the current settings from the dialog. * @see setRamp() diff --git a/src/gui/symbology-ng/qgsdashspacedialog.cpp b/src/gui/symbology-ng/qgsdashspacedialog.cpp index 4fd3acb025c..c8b88a84c69 100644 --- a/src/gui/symbology-ng/qgsdashspacedialog.cpp +++ b/src/gui/symbology-ng/qgsdashspacedialog.cpp @@ -50,11 +50,6 @@ QgsDashSpaceDialog::QgsDashSpaceDialog( const QVector& v, QWidget* parent } } -QgsDashSpaceDialog::~QgsDashSpaceDialog() -{ - -} - void QgsDashSpaceDialog::on_mAddButton_clicked() { //add new (default) item diff --git a/src/gui/symbology-ng/qgsdashspacedialog.h b/src/gui/symbology-ng/qgsdashspacedialog.h index 82b77c2844f..f5006fe4232 100644 --- a/src/gui/symbology-ng/qgsdashspacedialog.h +++ b/src/gui/symbology-ng/qgsdashspacedialog.h @@ -17,6 +17,7 @@ #define QGSDASHSPACEDIALOG_H #include "ui_qgsdashspacedialogbase.h" +#include "qgis_gui.h" /** \ingroup gui * A dialog to enter a custom dash space pattern for lines @@ -26,7 +27,6 @@ class GUI_EXPORT QgsDashSpaceDialog: public QDialog, private Ui::QgsDashSpaceDia Q_OBJECT public: QgsDashSpaceDialog( const QVector& v, QWidget * parent = nullptr, Qt::WindowFlags f = 0 ); - ~QgsDashSpaceDialog(); QVector dashDotVector() const; diff --git a/src/gui/symbology-ng/qgsellipsesymbollayerwidget.h b/src/gui/symbology-ng/qgsellipsesymbollayerwidget.h index e5e66d3da1c..bc2929b3c8c 100644 --- a/src/gui/symbology-ng/qgsellipsesymbollayerwidget.h +++ b/src/gui/symbology-ng/qgsellipsesymbollayerwidget.h @@ -17,6 +17,7 @@ #include "ui_widget_ellipse.h" #include "qgssymbollayerwidget.h" +#include "qgis_gui.h" class QgsEllipseSymbolLayer; diff --git a/src/gui/symbology-ng/qgsgraduatedhistogramwidget.cpp b/src/gui/symbology-ng/qgsgraduatedhistogramwidget.cpp index 9e4e2ea0846..292801fc61c 100644 --- a/src/gui/symbology-ng/qgsgraduatedhistogramwidget.cpp +++ b/src/gui/symbology-ng/qgsgraduatedhistogramwidget.cpp @@ -68,11 +68,6 @@ QgsGraduatedHistogramWidget::QgsGraduatedHistogramWidget( QWidget *parent ) #endif } - -QgsGraduatedHistogramWidget::~QgsGraduatedHistogramWidget() -{ -} - void QgsGraduatedHistogramWidget::setRenderer( QgsGraduatedSymbolRenderer *renderer ) { mRenderer = renderer; diff --git a/src/gui/symbology-ng/qgsgraduatedhistogramwidget.h b/src/gui/symbology-ng/qgsgraduatedhistogramwidget.h index 7faa163ebff..3b07a5062b3 100644 --- a/src/gui/symbology-ng/qgsgraduatedhistogramwidget.h +++ b/src/gui/symbology-ng/qgsgraduatedhistogramwidget.h @@ -18,6 +18,7 @@ #define QGSGRADUATEDHISTOGRAMWIDGET_H #include "qgshistogramwidget.h" +#include "qgis_gui.h" class QwtPlotPicker; class QgsGraduatedHistogramEventFilter; @@ -40,7 +41,6 @@ class GUI_EXPORT QgsGraduatedHistogramWidget : public QgsHistogramWidget * @param parent parent widget */ QgsGraduatedHistogramWidget( QWidget *parent = nullptr ); - ~QgsGraduatedHistogramWidget(); /** Sets the QgsGraduatedSymbolRenderer renderer associated with the histogram. * The histogram will fetch the ranges from the renderer before every refresh. @@ -96,8 +96,6 @@ class GUI_EXPORT QgsGraduatedHistogramEventFilter: public QObject QgsGraduatedHistogramEventFilter( QwtPlot *plot ); - virtual ~QgsGraduatedHistogramEventFilter() {} - virtual bool eventFilter( QObject* object, QEvent* event ) override; signals: diff --git a/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.cpp b/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.cpp index c8248956a1e..9008bd3baa4 100644 --- a/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.cpp +++ b/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.cpp @@ -394,7 +394,7 @@ QgsExpressionContext QgsGraduatedSymbolRendererWidget::createExpressionContext() { QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ); if ( mContext.mapCanvas() ) diff --git a/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.h b/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.h index ab6ef8db9d8..15008c2f374 100644 --- a/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.h +++ b/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.h @@ -22,6 +22,7 @@ #include #include "ui_qgsgraduatedsymbolrendererv2widget.h" +#include "qgis_gui.h" /// @cond PRIVATE diff --git a/src/gui/symbology-ng/qgsheatmaprendererwidget.cpp b/src/gui/symbology-ng/qgsheatmaprendererwidget.cpp index a44a6256bf9..be2e179b8af 100644 --- a/src/gui/symbology-ng/qgsheatmaprendererwidget.cpp +++ b/src/gui/symbology-ng/qgsheatmaprendererwidget.cpp @@ -37,7 +37,7 @@ QgsExpressionContext QgsHeatmapRendererWidget::createExpressionContext() const { QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ); if ( mContext.mapCanvas() ) diff --git a/src/gui/symbology-ng/qgsheatmaprendererwidget.h b/src/gui/symbology-ng/qgsheatmaprendererwidget.h index 47d53e29613..30017477c58 100644 --- a/src/gui/symbology-ng/qgsheatmaprendererwidget.h +++ b/src/gui/symbology-ng/qgsheatmaprendererwidget.h @@ -17,6 +17,7 @@ #include "ui_qgsheatmaprendererwidgetbase.h" #include "qgsrendererwidget.h" +#include "qgis_gui.h" class QMenu; class QgsHeatmapRenderer; @@ -44,9 +45,7 @@ class GUI_EXPORT QgsHeatmapRendererWidget : public QgsRendererWidget, private Ui */ QgsHeatmapRendererWidget( QgsVectorLayer* layer, QgsStyle* style, QgsFeatureRenderer* renderer ); - //! @returns the current feature renderer virtual QgsFeatureRenderer* renderer() override; - virtual void setContext( const QgsSymbolWidgetContext& context ) override; private: diff --git a/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.cpp b/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.cpp index f2afc1eea4e..b37ef3f7f73 100644 --- a/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.cpp +++ b/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.cpp @@ -68,7 +68,7 @@ QgsInvertedPolygonRendererWidget::QgsInvertedPolygonRendererWidget( QgsVectorLay int currentEmbeddedIdx = 0; //insert possible renderer types - QStringList rendererList = QgsRendererRegistry::instance()->renderersList( QgsRendererAbstractMetadata::PolygonLayer ); + QStringList rendererList = QgsApplication::rendererRegistry()->renderersList( QgsRendererAbstractMetadata::PolygonLayer ); QStringList::const_iterator it = rendererList.constBegin(); int idx = 0; mRendererComboBox->blockSignals( true ); @@ -76,7 +76,7 @@ QgsInvertedPolygonRendererWidget::QgsInvertedPolygonRendererWidget( QgsVectorLay { if ( *it != QLatin1String( "invertedPolygonRenderer" ) ) //< an inverted renderer cannot contain another inverted renderer { - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( *it ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( *it ); mRendererComboBox->addItem( m->icon(), m->visibleName(), /* data */ *it ); const QgsFeatureRenderer* embeddedRenderer = mRenderer->embeddedRenderer(); if ( embeddedRenderer && embeddedRenderer->type() == m->name() ) @@ -120,7 +120,7 @@ void QgsInvertedPolygonRendererWidget::setContext( const QgsSymbolWidgetContext& void QgsInvertedPolygonRendererWidget::on_mRendererComboBox_currentIndexChanged( int index ) { QString rendererId = mRendererComboBox->itemData( index ).toString(); - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( rendererId ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( rendererId ); if ( m ) { mEmbeddedRendererWidget.reset( m->createRendererWidget( mLayer, mStyle, const_cast( mRenderer->embeddedRenderer() )->clone() ) ); diff --git a/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.h b/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.h index f66263fbfa5..d9ac56066fe 100644 --- a/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.h +++ b/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.h @@ -18,6 +18,7 @@ #include "ui_qgsinvertedpolygonrendererwidgetbase.h" #include "qgsinvertedpolygonrenderer.h" #include "qgsrendererwidget.h" +#include "qgis_gui.h" class QMenu; @@ -46,7 +47,6 @@ class GUI_EXPORT QgsInvertedPolygonRendererWidget : public QgsRendererWidget, pr */ QgsInvertedPolygonRendererWidget( QgsVectorLayer* layer, QgsStyle* style, QgsFeatureRenderer* renderer ); - //! @returns the current feature renderer virtual QgsFeatureRenderer* renderer() override; void setContext( const QgsSymbolWidgetContext& context ) override; diff --git a/src/gui/symbology-ng/qgslayerpropertieswidget.cpp b/src/gui/symbology-ng/qgslayerpropertieswidget.cpp index 6c862c74fe6..a7ada965f0e 100644 --- a/src/gui/symbology-ng/qgslayerpropertieswidget.cpp +++ b/src/gui/symbology-ng/qgslayerpropertieswidget.cpp @@ -35,11 +35,12 @@ #include "qgspanelwidget.h" #include "qgsdatadefined.h" #include "qgsmapcanvas.h" +#include "qgsproject.h" #include "qgsvectorlayer.h" static bool _initWidgetFunction( const QString& name, QgsSymbolLayerWidgetFunc f ) { - QgsSymbolLayerRegistry* reg = QgsSymbolLayerRegistry::instance(); + QgsSymbolLayerRegistry* reg = QgsApplication::symbolLayerRegistry(); QgsSymbolLayerAbstractMetadata* abstractMetadata = reg->symbolLayerMetadata( name ); if ( !abstractMetadata ) @@ -171,17 +172,17 @@ void QgsLayerPropertiesWidget::setDockMode( bool dockMode ) void QgsLayerPropertiesWidget::populateLayerTypes() { - QStringList symbolLayerIds = QgsSymbolLayerRegistry::instance()->symbolLayersForType( mSymbol->type() ); + QStringList symbolLayerIds = QgsApplication::symbolLayerRegistry()->symbolLayersForType( mSymbol->type() ); Q_FOREACH ( const QString& symbolLayerId, symbolLayerIds ) - cboLayerType->addItem( QgsSymbolLayerRegistry::instance()->symbolLayerMetadata( symbolLayerId )->visibleName(), symbolLayerId ); + cboLayerType->addItem( QgsApplication::symbolLayerRegistry()->symbolLayerMetadata( symbolLayerId )->visibleName(), symbolLayerId ); if ( mSymbol->type() == QgsSymbol::Fill ) { - QStringList lineLayerIds = QgsSymbolLayerRegistry::instance()->symbolLayersForType( QgsSymbol::Line ); + QStringList lineLayerIds = QgsApplication::symbolLayerRegistry()->symbolLayersForType( QgsSymbol::Line ); Q_FOREACH ( const QString& lineLayerId, lineLayerIds ) { - QgsSymbolLayerAbstractMetadata* layerInfo = QgsSymbolLayerRegistry::instance()->symbolLayerMetadata( lineLayerId ); + QgsSymbolLayerAbstractMetadata* layerInfo = QgsApplication::symbolLayerRegistry()->symbolLayerMetadata( lineLayerId ); if ( layerInfo->type() != QgsSymbol::Hybrid ) { QString visibleName = layerInfo->visibleName(); @@ -201,7 +202,7 @@ void QgsLayerPropertiesWidget::updateSymbolLayerWidget( QgsSymbolLayer* layer ) stackedWidget->removeWidget( stackedWidget->currentWidget() ); } - QgsSymbolLayerRegistry* pReg = QgsSymbolLayerRegistry::instance(); + QgsSymbolLayerRegistry* pReg = QgsApplication::symbolLayerRegistry(); QString layerType = layer->layerType(); QgsSymbolLayerAbstractMetadata* am = pReg->symbolLayerMetadata( layerType ); @@ -231,7 +232,7 @@ QgsExpressionContext QgsLayerPropertiesWidget::createExpressionContext() const QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ); if ( mContext.mapCanvas() ) @@ -286,7 +287,7 @@ void QgsLayerPropertiesWidget::layerTypeChanged() return; // get creation function for new layer from registry - QgsSymbolLayerRegistry* pReg = QgsSymbolLayerRegistry::instance(); + QgsSymbolLayerRegistry* pReg = QgsApplication::symbolLayerRegistry(); QgsSymbolLayerAbstractMetadata* am = pReg->symbolLayerMetadata( newLayerType ); if ( !am ) // check whether the metadata is assigned return; diff --git a/src/gui/symbology-ng/qgslayerpropertieswidget.h b/src/gui/symbology-ng/qgslayerpropertieswidget.h index c1aed7d18c5..82abb63022b 100644 --- a/src/gui/symbology-ng/qgslayerpropertieswidget.h +++ b/src/gui/symbology-ng/qgslayerpropertieswidget.h @@ -31,6 +31,7 @@ class SymbolLayerItem; #include #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsLayerPropertiesWidget @@ -42,14 +43,14 @@ class GUI_EXPORT QgsLayerPropertiesWidget : public QgsPanelWidget, protected Qgs public: QgsLayerPropertiesWidget( QgsSymbolLayer* layer, const QgsSymbol* symbol, const QgsVectorLayer* vl, QWidget* parent = nullptr ); - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ diff --git a/src/gui/symbology-ng/qgsnullsymbolrendererwidget.h b/src/gui/symbology-ng/qgsnullsymbolrendererwidget.h index 6fab073bf8c..bb3f1a17d93 100644 --- a/src/gui/symbology-ng/qgsnullsymbolrendererwidget.h +++ b/src/gui/symbology-ng/qgsnullsymbolrendererwidget.h @@ -16,6 +16,7 @@ #define QGSNULLSYMBOLRENDERERWIDGET_H #include "qgsrendererwidget.h" +#include "qgis_gui.h" class QgsNullSymbolRenderer; class QgsSymbolSelectorDialog; diff --git a/src/gui/symbology-ng/qgspenstylecombobox.h b/src/gui/symbology-ng/qgspenstylecombobox.h index c4d987c185f..01e5c751459 100644 --- a/src/gui/symbology-ng/qgspenstylecombobox.h +++ b/src/gui/symbology-ng/qgspenstylecombobox.h @@ -17,6 +17,7 @@ #define QGSPENSTYLECOMBOBOX_H #include +#include "qgis_gui.h" /** \ingroup gui * \class QgsPenStyleComboBox diff --git a/src/gui/symbology-ng/qgspointclusterrendererwidget.cpp b/src/gui/symbology-ng/qgspointclusterrendererwidget.cpp index 9e9f471e6fd..5aace9e75da 100644 --- a/src/gui/symbology-ng/qgspointclusterrendererwidget.cpp +++ b/src/gui/symbology-ng/qgspointclusterrendererwidget.cpp @@ -62,13 +62,13 @@ QgsPointClusterRendererWidget::QgsPointClusterRendererWidget( QgsVectorLayer* la blockAllSignals( true ); //insert possible renderer types - QStringList rendererList = QgsRendererRegistry::instance()->renderersList( QgsRendererAbstractMetadata::PointLayer ); + QStringList rendererList = QgsApplication::rendererRegistry()->renderersList( QgsRendererAbstractMetadata::PointLayer ); QStringList::const_iterator it = rendererList.constBegin(); for ( ; it != rendererList.constEnd(); ++it ) { if ( *it != QLatin1String( "pointDisplacement" ) && *it != QLatin1String( "pointCluster" ) && *it != QLatin1String( "heatmapRenderer" ) ) { - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( *it ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( *it ); mRendererComboBox->addItem( m->icon(), m->visibleName(), *it ); } } @@ -114,7 +114,7 @@ void QgsPointClusterRendererWidget::setContext( const QgsSymbolWidgetContext& co void QgsPointClusterRendererWidget::on_mRendererComboBox_currentIndexChanged( int index ) { QString rendererId = mRendererComboBox->itemData( index ).toString(); - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( rendererId ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( rendererId ); if ( m ) { // unfortunately renderer conversion is only available through the creation of a widget... @@ -130,7 +130,7 @@ void QgsPointClusterRendererWidget::on_mRendererSettingsButton_clicked() if ( !mRenderer ) return; - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( mRenderer->embeddedRenderer()->type() ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( mRenderer->embeddedRenderer()->type() ); if ( m ) { QgsRendererWidget* w = m->createRendererWidget( mLayer, mStyle, mRenderer->embeddedRenderer()->clone() ); diff --git a/src/gui/symbology-ng/qgspointclusterrendererwidget.h b/src/gui/symbology-ng/qgspointclusterrendererwidget.h index aab4aabfc49..4b7ebe6766d 100644 --- a/src/gui/symbology-ng/qgspointclusterrendererwidget.h +++ b/src/gui/symbology-ng/qgspointclusterrendererwidget.h @@ -20,6 +20,7 @@ #include "ui_qgspointclusterrendererwidgetbase.h" #include "qgsrendererwidget.h" +#include "qgis_gui.h" class QgsPointClusterRenderer; diff --git a/src/gui/symbology-ng/qgspointdisplacementrendererwidget.cpp b/src/gui/symbology-ng/qgspointdisplacementrendererwidget.cpp index aeaeeffa0b6..f1c697ab897 100644 --- a/src/gui/symbology-ng/qgspointdisplacementrendererwidget.cpp +++ b/src/gui/symbology-ng/qgspointdisplacementrendererwidget.cpp @@ -86,13 +86,13 @@ QgsPointDisplacementRendererWidget::QgsPointDisplacementRendererWidget( QgsVecto } //insert possible renderer types - QStringList rendererList = QgsRendererRegistry::instance()->renderersList( QgsRendererAbstractMetadata::PointLayer ); + QStringList rendererList = QgsApplication::rendererRegistry()->renderersList( QgsRendererAbstractMetadata::PointLayer ); QStringList::const_iterator it = rendererList.constBegin(); for ( ; it != rendererList.constEnd(); ++it ) { if ( *it != QLatin1String( "pointDisplacement" ) && *it != QLatin1String( "pointCluster" ) && *it != QLatin1String( "heatmapRenderer" ) ) { - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( *it ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( *it ); mRendererComboBox->addItem( m->icon(), m->visibleName(), *it ); } } @@ -184,7 +184,7 @@ void QgsPointDisplacementRendererWidget::on_mLabelFieldComboBox_currentIndexChan void QgsPointDisplacementRendererWidget::on_mRendererComboBox_currentIndexChanged( int index ) { QString rendererId = mRendererComboBox->itemData( index ).toString(); - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( rendererId ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( rendererId ); if ( m ) { // unfortunately renderer conversion is only available through the creation of a widget... @@ -209,7 +209,7 @@ void QgsPointDisplacementRendererWidget::on_mRendererSettingsButton_clicked() if ( !mRenderer ) return; - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( mRenderer->embeddedRenderer()->type() ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( mRenderer->embeddedRenderer()->type() ); if ( m ) { QgsRendererWidget* w = m->createRendererWidget( mLayer, mStyle, mRenderer->embeddedRenderer()->clone() ); diff --git a/src/gui/symbology-ng/qgspointdisplacementrendererwidget.h b/src/gui/symbology-ng/qgspointdisplacementrendererwidget.h index 801f5503271..bdce2336ac0 100644 --- a/src/gui/symbology-ng/qgspointdisplacementrendererwidget.h +++ b/src/gui/symbology-ng/qgspointdisplacementrendererwidget.h @@ -20,6 +20,7 @@ #include "ui_qgspointdisplacementrendererwidgetbase.h" #include "qgsrendererwidget.h" +#include "qgis_gui.h" class QgsPointDisplacementRenderer; diff --git a/src/gui/symbology-ng/qgsrendererpropertiesdialog.cpp b/src/gui/symbology-ng/qgsrendererpropertiesdialog.cpp index faa2936d0e7..8695bc1e1cc 100644 --- a/src/gui/symbology-ng/qgsrendererpropertiesdialog.cpp +++ b/src/gui/symbology-ng/qgsrendererpropertiesdialog.cpp @@ -41,7 +41,7 @@ static bool _initRenderer( const QString& name, QgsRendererWidgetFunc f, const QString& iconName = QString() ) { - QgsRendererRegistry* reg = QgsRendererRegistry::instance(); + QgsRendererRegistry* reg = QgsApplication::rendererRegistry(); QgsRendererAbstractMetadata* am = reg->rendererMetadata( name ); if ( !am ) return false; @@ -103,7 +103,7 @@ QgsRendererPropertiesDialog::QgsRendererPropertiesDialog( QgsVectorLayer* layer, // initialize registry's widget functions _initRendererWidgetFunctions(); - QgsRendererRegistry* reg = QgsRendererRegistry::instance(); + QgsRendererRegistry* reg = QgsApplication::rendererRegistry(); QStringList renderers = reg->renderersList( mLayer ); Q_FOREACH ( const QString& name, renderers ) { @@ -238,7 +238,7 @@ void QgsRendererPropertiesDialog::rendererChanged() } QgsRendererWidget* w = nullptr; - QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( rendererName ); + QgsRendererAbstractMetadata* m = QgsApplication::rendererRegistry()->rendererMetadata( rendererName ); if ( m ) w = m->createRendererWidget( mLayer, mStyle, oldRenderer ); delete oldRenderer; diff --git a/src/gui/symbology-ng/qgsrendererpropertiesdialog.h b/src/gui/symbology-ng/qgsrendererpropertiesdialog.h index 15818a45984..0a26f72a887 100644 --- a/src/gui/symbology-ng/qgsrendererpropertiesdialog.h +++ b/src/gui/symbology-ng/qgsrendererpropertiesdialog.h @@ -22,6 +22,7 @@ #include "ui_qgsrendererv2propsdialogbase.h" #include "qgsfeaturerequest.h" +#include "qgis_gui.h" class QKeyEvent; @@ -132,7 +133,7 @@ class GUI_EXPORT QgsRendererPropertiesDialog : public QDialog, private Ui::QgsRe */ void connectValueChanged( const QList &widgets, const char *slot ); - //! Reimplements dialog keyPress event so we can ignore it + // Reimplements dialog keyPress event so we can ignore it void keyPressEvent( QKeyEvent * event ) override; QgsVectorLayer* mLayer; diff --git a/src/gui/symbology-ng/qgsrendererwidget.cpp b/src/gui/symbology-ng/qgsrendererwidget.cpp index bd276826de3..031ca5a2498 100644 --- a/src/gui/symbology-ng/qgsrendererwidget.cpp +++ b/src/gui/symbology-ng/qgsrendererwidget.cpp @@ -20,6 +20,7 @@ #include "qgsexpressionbuilderdialog.h" #include "qgsmapcanvas.h" #include "qgspanelwidget.h" +#include "qgsproject.h" #include "qgsdatadefined.h" #include @@ -309,7 +310,7 @@ QgsExpressionContext QgsDataDefinedValueDialog::createExpressionContext() const { QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ); if ( mContext.mapCanvas() ) { diff --git a/src/gui/symbology-ng/qgsrendererwidget.h b/src/gui/symbology-ng/qgsrendererwidget.h index f009127a36f..3d13de4ae74 100644 --- a/src/gui/symbology-ng/qgsrendererwidget.h +++ b/src/gui/symbology-ng/qgsrendererwidget.h @@ -44,22 +44,20 @@ class GUI_EXPORT QgsRendererWidget : public QgsPanelWidget public: QgsRendererWidget( QgsVectorLayer* layer, QgsStyle* style ); - virtual ~QgsRendererWidget() {} - //! return pointer to the renderer (no transfer of ownership) virtual QgsFeatureRenderer* renderer() = 0; //! show a dialog with renderer's symbol level settings void showSymbolLevelsDialog( QgsFeatureRenderer* r ); - /** Sets the context in which the renderer widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the renderer widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ virtual void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the renderer widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the renderer widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ @@ -139,6 +137,7 @@ class QgsFields; #include "ui_widget_set_dd_value.h" #include "qgssizescalewidget.h" +#include "qgis_gui.h" /** \ingroup gui Utility classes for "en masse" size definition @@ -155,16 +154,15 @@ class GUI_EXPORT QgsDataDefinedValueDialog : public QDialog, public Ui::QgsDataD * @param label value label */ QgsDataDefinedValueDialog( const QList& symbolList, QgsVectorLayer * layer, const QString & label ); - virtual ~QgsDataDefinedValueDialog() {} - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ diff --git a/src/gui/symbology-ng/qgsrulebasedrendererwidget.cpp b/src/gui/symbology-ng/qgsrulebasedrendererwidget.cpp index d4d6d9281dd..64e2cad8fe0 100644 --- a/src/gui/symbology-ng/qgsrulebasedrendererwidget.cpp +++ b/src/gui/symbology-ng/qgsrulebasedrendererwidget.cpp @@ -41,6 +41,7 @@ #include "modeltest.h" #endif + QgsRendererWidget* QgsRuleBasedRendererWidget::create( QgsVectorLayer* layer, QgsStyle* style, QgsFeatureRenderer* renderer ) { return new QgsRuleBasedRendererWidget( layer, style, renderer ); @@ -519,20 +520,8 @@ void QgsRuleBasedRendererWidget::countFeatures() QgsRenderContext renderContext; renderContext.setRendererScale( 0 ); // ignore scale - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::atlasScope( nullptr ); - if ( mContext.mapCanvas() ) - { - context << QgsExpressionContextUtils::mapSettingsScope( mContext.mapCanvas()->mapSettings() ) - << new QgsExpressionContextScope( mContext.mapCanvas()->expressionContextScope() ); - } - else - { - context << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); - } - context << QgsExpressionContextUtils::layerScope( mLayer ); + QgsExpressionContext context( mContext.globalProjectAtlasMapLayerScopes( mLayer ) ); + // additional scopes Q_FOREACH ( const QgsExpressionContextScope& scope, mContext.additionalExpressionContextScopes() ) { @@ -668,11 +657,6 @@ QgsRendererRulePropsWidget::QgsRendererRulePropsWidget( QgsRuleBasedRenderer::Ru connect( mScaleRangeWidget, SIGNAL( rangeChanged( double, double ) ), this, SIGNAL( widgetChanged() ) ); } -QgsRendererRulePropsWidget::~QgsRendererRulePropsWidget() -{ - -} - QgsRendererRulePropsDialog::QgsRendererRulePropsDialog( QgsRuleBasedRenderer::Rule *rule, QgsVectorLayer *layer, QgsStyle *style, QWidget *parent, const QgsSymbolWidgetContext& context ) : QDialog( parent ) { @@ -717,22 +701,10 @@ void QgsRendererRulePropsDialog::accept() QDialog::accept(); } + void QgsRendererRulePropsWidget::buildExpression() { - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::atlasScope( nullptr ); - if ( mContext.mapCanvas() ) - { - context << QgsExpressionContextUtils::mapSettingsScope( mContext.mapCanvas()->mapSettings() ) - << new QgsExpressionContextScope( mContext.mapCanvas()->expressionContextScope() ); - } - else - { - context << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); - } - context << QgsExpressionContextUtils::layerScope( mLayer ); + QgsExpressionContext context( mContext.globalProjectAtlasMapLayerScopes( mLayer ) ); // additional scopes Q_FOREACH ( const QgsExpressionContextScope& scope, mContext.additionalExpressionContextScopes() ) @@ -755,20 +727,8 @@ void QgsRendererRulePropsWidget::testFilter() return; } - QgsExpressionContext context; - context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::atlasScope( nullptr ); - if ( mContext.mapCanvas() ) - { - context << QgsExpressionContextUtils::mapSettingsScope( mContext.mapCanvas()->mapSettings() ) - << new QgsExpressionContextScope( mContext.mapCanvas()->expressionContextScope() ); - } - else - { - context << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); - } - context << QgsExpressionContextUtils::layerScope( mLayer ); + QgsExpressionContext context( mContext.globalProjectAtlasMapLayerScopes( mLayer ) ); + // additional scopes Q_FOREACH ( const QgsExpressionContextScope& scope, mContext.additionalExpressionContextScopes() ) { diff --git a/src/gui/symbology-ng/qgsrulebasedrendererwidget.h b/src/gui/symbology-ng/qgsrulebasedrendererwidget.h index f099616da24..11f8dfde9ba 100644 --- a/src/gui/symbology-ng/qgsrulebasedrendererwidget.h +++ b/src/gui/symbology-ng/qgsrulebasedrendererwidget.h @@ -55,9 +55,7 @@ class GUI_EXPORT QgsRuleBasedRendererModel : public QAbstractItemModel int role = Qt::DisplayRole ) const override; virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const override; virtual int columnCount( const QModelIndex & = QModelIndex() ) const override; - //! provide model index for parent's child item virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override; - //! provide parent model index virtual QModelIndex parent( const QModelIndex &index ) const override; // editing support @@ -174,6 +172,7 @@ class GUI_EXPORT QgsRuleBasedRendererWidget : public QgsRendererWidget, private #include #include "ui_qgsrendererrulepropsdialogbase.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsRendererRulePropsWidget @@ -193,7 +192,6 @@ class GUI_EXPORT QgsRendererRulePropsWidget : public QgsPanelWidget, private Ui: * @param context the symbol widget context */ QgsRendererRulePropsWidget( QgsRuleBasedRenderer::Rule* rule, QgsVectorLayer* layer, QgsStyle* style, QWidget* parent = nullptr, const QgsSymbolWidgetContext& context = QgsSymbolWidgetContext() ); - ~QgsRendererRulePropsWidget(); /** * Return the current set rule. diff --git a/src/gui/symbology-ng/qgssinglesymbolrendererwidget.h b/src/gui/symbology-ng/qgssinglesymbolrendererwidget.h index 586e102c0fe..4b6687165ce 100644 --- a/src/gui/symbology-ng/qgssinglesymbolrendererwidget.h +++ b/src/gui/symbology-ng/qgssinglesymbolrendererwidget.h @@ -16,6 +16,7 @@ #define QGSSINGLESYMBOLRENDERERV2WIDGET_H #include "qgsrendererwidget.h" +#include "qgis_gui.h" class QgsSingleSymbolRenderer; class QgsSymbolSelectorWidget; diff --git a/src/gui/symbology-ng/qgssizescalewidget.cpp b/src/gui/symbology-ng/qgssizescalewidget.cpp index c0280bc7996..d26128468dc 100644 --- a/src/gui/symbology-ng/qgssizescalewidget.cpp +++ b/src/gui/symbology-ng/qgssizescalewidget.cpp @@ -77,7 +77,7 @@ QgsExpressionContext QgsSizeScaleWidget::createExpressionContext() const { QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ); if ( mapCanvas() ) @@ -270,7 +270,7 @@ void QgsSizeScaleWidget::computeFromLayerTriggered() QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ) << QgsExpressionContextUtils::layerScope( mLayer ); diff --git a/src/gui/symbology-ng/qgssizescalewidget.h b/src/gui/symbology-ng/qgssizescalewidget.h index d55d550b008..0ba216fc9ea 100644 --- a/src/gui/symbology-ng/qgssizescalewidget.h +++ b/src/gui/symbology-ng/qgssizescalewidget.h @@ -22,6 +22,7 @@ #include "ui_widget_size_scale.h" #include #include +#include "qgis_gui.h" class QgsVectorLayer; class QgsSymbol; diff --git a/src/gui/symbology-ng/qgssmartgroupeditordialog.cpp b/src/gui/symbology-ng/qgssmartgroupeditordialog.cpp index 55a895c4788..bd34ae4a2f6 100644 --- a/src/gui/symbology-ng/qgssmartgroupeditordialog.cpp +++ b/src/gui/symbology-ng/qgssmartgroupeditordialog.cpp @@ -91,10 +91,6 @@ QgsSmartGroupEditorDialog::QgsSmartGroupEditorDialog( QgsStyle* style, QWidget* connect( mAddConditionBtn, SIGNAL( clicked() ), this, SLOT( addCondition() ) ); } -QgsSmartGroupEditorDialog::~QgsSmartGroupEditorDialog() -{ -} - QString QgsSmartGroupEditorDialog::smartgroupName() { return mNameLineEdit->text(); diff --git a/src/gui/symbology-ng/qgssmartgroupeditordialog.h b/src/gui/symbology-ng/qgssmartgroupeditordialog.h index 0a6d09b3e86..a7b2ee0140b 100644 --- a/src/gui/symbology-ng/qgssmartgroupeditordialog.h +++ b/src/gui/symbology-ng/qgssmartgroupeditordialog.h @@ -17,6 +17,7 @@ #define QGSSMARTGROUPEDITORDIALOG_H #include "ui_qgssmartgroupconditionwidget.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsSmartGroupCondition @@ -71,7 +72,6 @@ class GUI_EXPORT QgsSmartGroupEditorDialog : public QDialog, private Ui::QgsSmar public: QgsSmartGroupEditorDialog( QgsStyle* style, QWidget* parent = nullptr ); - ~QgsSmartGroupEditorDialog(); //! returns the value from mNameLineEdit QString smartgroupName(); diff --git a/src/gui/symbology-ng/qgsstyleexportimportdialog.h b/src/gui/symbology-ng/qgsstyleexportimportdialog.h index 007e35123c9..b838334591d 100644 --- a/src/gui/symbology-ng/qgsstyleexportimportdialog.h +++ b/src/gui/symbology-ng/qgsstyleexportimportdialog.h @@ -26,6 +26,7 @@ #include #include "ui_qgsstyleexportimportdialogbase.h" +#include "qgis_gui.h" class QgsStyle; class QgsStyleGroupSelectionDialog; diff --git a/src/gui/symbology-ng/qgsstylegroupselectiondialog.cpp b/src/gui/symbology-ng/qgsstylegroupselectiondialog.cpp index ae15608f8e8..2a70eb4e45d 100644 --- a/src/gui/symbology-ng/qgsstylegroupselectiondialog.cpp +++ b/src/gui/symbology-ng/qgsstylegroupselectiondialog.cpp @@ -73,12 +73,6 @@ QgsStyleGroupSelectionDialog::QgsStyleGroupSelectionDialog( QgsStyle *style, QWi connect( groupTree->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( groupTreeSelectionChanged( const QItemSelection&, const QItemSelection& ) ) ); } - -QgsStyleGroupSelectionDialog::~QgsStyleGroupSelectionDialog() -{ -} - - void QgsStyleGroupSelectionDialog::setBold( QStandardItem* item ) { QFont font = item->font(); diff --git a/src/gui/symbology-ng/qgsstylegroupselectiondialog.h b/src/gui/symbology-ng/qgsstylegroupselectiondialog.h index 988efaddcc1..29c22048191 100644 --- a/src/gui/symbology-ng/qgsstylegroupselectiondialog.h +++ b/src/gui/symbology-ng/qgsstylegroupselectiondialog.h @@ -20,6 +20,7 @@ #include #include #include "ui_qgsstylegroupselectiondialogbase.h" +#include "qgis_gui.h" class QgsStyle; @@ -33,7 +34,6 @@ class GUI_EXPORT QgsStyleGroupSelectionDialog : public QDialog, private Ui::Symb public: QgsStyleGroupSelectionDialog( QgsStyle* style, QWidget *parent = nullptr ); - ~QgsStyleGroupSelectionDialog(); //! Set bold font for item void setBold( QStandardItem *item ); diff --git a/src/gui/symbology-ng/qgsstylemanagerdialog.h b/src/gui/symbology-ng/qgsstylemanagerdialog.h index ea0ad7330f2..6b6477351fa 100644 --- a/src/gui/symbology-ng/qgsstylemanagerdialog.h +++ b/src/gui/symbology-ng/qgsstylemanagerdialog.h @@ -23,6 +23,7 @@ #include "ui_qgsstylemanagerdialogbase.h" #include "qgscontexthelp.h" +#include "qgis_gui.h" class QgsStyle; diff --git a/src/gui/symbology-ng/qgsstylesavedialog.cpp b/src/gui/symbology-ng/qgsstylesavedialog.cpp index 4087ebe66ec..d11cfd7ca85 100644 --- a/src/gui/symbology-ng/qgsstylesavedialog.cpp +++ b/src/gui/symbology-ng/qgsstylesavedialog.cpp @@ -38,8 +38,6 @@ QgsStyleSaveDialog::QgsStyleSaveDialog( QWidget* parent, QgsStyle::StyleEntity t } } -QgsStyleSaveDialog::~QgsStyleSaveDialog() { } - QString QgsStyleSaveDialog::name() const { return mName->text(); diff --git a/src/gui/symbology-ng/qgsstylesavedialog.h b/src/gui/symbology-ng/qgsstylesavedialog.h index 8fb4b2cd922..fc49ce3eb99 100644 --- a/src/gui/symbology-ng/qgsstylesavedialog.h +++ b/src/gui/symbology-ng/qgsstylesavedialog.h @@ -22,6 +22,7 @@ #include "ui_qgsstylesavedialog.h" #include "qgsstyle.h" +#include "qgis_gui.h" /** \ingroup gui * \brief a dialog for setting properties of a newly saved style. @@ -39,8 +40,6 @@ class GUI_EXPORT QgsStyleSaveDialog: public QDialog, private Ui::QgsStyleSaveDia */ QgsStyleSaveDialog( QWidget* parent = nullptr, QgsStyle::StyleEntity type = QgsStyle::SymbolEntity ); - ~QgsStyleSaveDialog(); - //! returns the text value of the name element QString name() const; diff --git a/src/gui/symbology-ng/qgssvgselectorwidget.cpp b/src/gui/symbology-ng/qgssvgselectorwidget.cpp index b5af97e82c7..339d15b2139 100644 --- a/src/gui/symbology-ng/qgssvgselectorwidget.cpp +++ b/src/gui/symbology-ng/qgssvgselectorwidget.cpp @@ -242,7 +242,7 @@ QPixmap QgsSvgSelectorListModel::createPreview( const QString& entry ) const bool fillParam, fillOpacityParam, outlineParam, outlineWidthParam, outlineOpacityParam; bool hasDefaultFillColor = false, hasDefaultFillOpacity = false, hasDefaultOutlineColor = false, hasDefaultOutlineWidth = false, hasDefaultOutlineOpacity = false; - QgsSvgCache::instance()->containsParams( entry, fillParam, hasDefaultFillColor, fill, + QgsApplication::svgCache()->containsParams( entry, fillParam, hasDefaultFillColor, fill, fillOpacityParam, hasDefaultFillOpacity, fillOpacity, outlineParam, hasDefaultOutlineColor, outline, outlineWidthParam, hasDefaultOutlineWidth, outlineWidth, @@ -259,7 +259,7 @@ QPixmap QgsSvgSelectorListModel::createPreview( const QString& entry ) const outlineWidth = 0.2; bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size) - const QImage& img = QgsSvgCache::instance()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache ); + const QImage& img = QgsApplication::svgCache()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache ); return QPixmap::fromImage( img ); } diff --git a/src/gui/symbology-ng/qgssvgselectorwidget.h b/src/gui/symbology-ng/qgssvgselectorwidget.h index 89f3c0a203a..1f7709ea563 100644 --- a/src/gui/symbology-ng/qgssvgselectorwidget.h +++ b/src/gui/symbology-ng/qgssvgselectorwidget.h @@ -28,6 +28,7 @@ #include #include #include +#include "qgis_gui.h" class QCheckBox; class QLayout; diff --git a/src/gui/symbology-ng/qgssymbollayerwidget.cpp b/src/gui/symbology-ng/qgssymbollayerwidget.cpp index 640ce1c2ee6..00a57cae7a0 100644 --- a/src/gui/symbology-ng/qgssymbollayerwidget.cpp +++ b/src/gui/symbology-ng/qgssymbollayerwidget.cpp @@ -56,22 +56,7 @@ QgsExpressionContext QgsSymbolLayerWidget::createExpressionContext() const if ( mContext.expressionContext() ) return *mContext.expressionContext(); - QgsExpressionContext expContext; - expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::atlasScope( nullptr ); - - if ( mContext.mapCanvas() ) - { - expContext << QgsExpressionContextUtils::mapSettingsScope( mContext.mapCanvas()->mapSettings() ) - << new QgsExpressionContextScope( mContext.mapCanvas()->expressionContextScope() ); - } - else - { - expContext << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); - } - - expContext << QgsExpressionContextUtils::layerScope( vectorLayer() ); + QgsExpressionContext expContext( mContext.globalProjectAtlasMapLayerScopes( vectorLayer() ) ); QgsExpressionContextScope* symbolScope = QgsExpressionContextUtils::updateSymbolScope( nullptr, new QgsExpressionContextScope() ); if ( const QgsSymbolLayer* symbolLayer = const_cast< QgsSymbolLayerWidget* >( this )->symbolLayer() ) @@ -1841,7 +1826,7 @@ void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer* QColor defaultFill, defaultOutline; double defaultOutlineWidth, defaultFillOpacity, defaultOutlineOpacity; bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultOutlineColor, hasDefaultOutlineWidth, hasDefaultOutlineOpacity; - QgsSvgCache::instance()->containsParams( layer->path(), hasFillParam, hasDefaultFillColor, defaultFill, + QgsApplication::svgCache()->containsParams( layer->path(), hasFillParam, hasDefaultFillColor, defaultFill, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasOutlineParam, hasDefaultOutlineColor, defaultOutline, hasOutlineWidthParam, hasDefaultOutlineWidth, defaultOutlineWidth, @@ -2334,7 +2319,7 @@ void QgsSVGFillSymbolLayerWidget::updateParamGui( bool resetValues ) QColor defaultFill, defaultOutline; double defaultOutlineWidth, defaultFillOpacity, defaultOutlineOpacity; bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultOutlineColor, hasDefaultOutlineWidth, hasDefaultOutlineOpacity; - QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, hasDefaultFillColor, defaultFill, + QgsApplication::svgCache()->containsParams( mSVGLineEdit->text(), hasFillParam, hasDefaultFillColor, defaultFill, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasOutlineParam, hasDefaultOutlineColor, defaultOutline, hasOutlineWidthParam, hasDefaultOutlineWidth, defaultOutlineWidth, diff --git a/src/gui/symbology-ng/qgssymbollayerwidget.h b/src/gui/symbology-ng/qgssymbollayerwidget.h index 6e8cb831179..ac15cec4f27 100644 --- a/src/gui/symbology-ng/qgssymbollayerwidget.h +++ b/src/gui/symbology-ng/qgssymbollayerwidget.h @@ -39,19 +39,18 @@ class GUI_EXPORT QgsSymbolLayerWidget : public QWidget, protected QgsExpressionC , mVectorLayer( vl ) , mMapCanvas( nullptr ) {} - virtual ~QgsSymbolLayerWidget() {} virtual void setSymbolLayer( QgsSymbolLayer* layer ) = 0; virtual QgsSymbolLayer* symbolLayer() = 0; - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ @@ -715,6 +714,7 @@ class GUI_EXPORT QgsCentroidFillSymbolLayerWidget : public QgsSymbolLayerWidget, #include "ui_qgsgeometrygeneratorwidgetbase.h" +#include "qgis_gui.h" class QgsGeometryGeneratorSymbolLayer; diff --git a/src/gui/symbology-ng/qgssymbollevelsdialog.h b/src/gui/symbology-ng/qgssymbollevelsdialog.h index d4282a74a2f..347a076ffa5 100644 --- a/src/gui/symbology-ng/qgssymbollevelsdialog.h +++ b/src/gui/symbology-ng/qgssymbollevelsdialog.h @@ -22,6 +22,7 @@ #include "qgsrenderer.h" #include "ui_qgssymbollevelsdialogbase.h" +#include "qgis_gui.h" /** \ingroup gui * \class QgsSymbolLevelsDialog diff --git a/src/gui/symbology-ng/qgssymbolselectordialog.cpp b/src/gui/symbology-ng/qgssymbolselectordialog.cpp index 927610bb457..368fd734012 100644 --- a/src/gui/symbology-ng/qgssymbolselectordialog.cpp +++ b/src/gui/symbology-ng/qgssymbolselectordialog.cpp @@ -175,7 +175,7 @@ class SymbolLayerItem : public QStandardItem if ( role == Qt::DisplayRole || role == Qt::EditRole ) { if ( mIsLayer ) - return QgsSymbolLayerRegistry::instance()->symbolLayerMetadata( mLayer->layerType() )->visibleName(); + return QgsApplication::symbolLayerRegistry()->symbolLayerMetadata( mLayer->layerType() )->visibleName(); else { switch ( mSymbol->type() ) @@ -273,10 +273,6 @@ QgsSymbolSelectorWidget::QgsSymbolSelectorWidget( QgsSymbol* symbol, QgsStyle* s setPanelTitle( tr( "Symbol selector" ) ); } -QgsSymbolSelectorWidget::~QgsSymbolSelectorWidget() -{ -} - QMenu* QgsSymbolSelectorWidget::advancedMenu() { if ( !mAdvancedMenu ) @@ -522,7 +518,7 @@ void QgsSymbolSelectorWidget::addLayer() ? static_cast( parentSymbol )->dataDefinedWidth() : QgsDataDefined() ; - QgsSymbolLayer* newLayer = QgsSymbolLayerRegistry::instance()->defaultSymbolLayer( parentSymbol->type() ); + QgsSymbolLayer* newLayer = QgsApplication::symbolLayerRegistry()->defaultSymbolLayer( parentSymbol->type() ); if ( insertIdx == -1 ) parentSymbol->appendSymbolLayer( newLayer ); else diff --git a/src/gui/symbology-ng/qgssymbolselectordialog.h b/src/gui/symbology-ng/qgssymbolselectordialog.h index 65fc711fc6b..47f90e1a5bd 100644 --- a/src/gui/symbology-ng/qgssymbolselectordialog.h +++ b/src/gui/symbology-ng/qgssymbolselectordialog.h @@ -27,6 +27,7 @@ #include #include #include +#include "qgis_gui.h" class QgsStyle; class QgsSymbol; @@ -95,19 +96,18 @@ class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::Qgs * @param parent */ QgsSymbolSelectorWidget( QgsSymbol* symbol, QgsStyle* style, const QgsVectorLayer* vl, QWidget* parent = nullptr ); - ~QgsSymbolSelectorWidget(); //! return menu for "advanced" button - create it if doesn't exist and show the advanced button QMenu* advancedMenu(); - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ @@ -254,14 +254,14 @@ class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog //! return menu for "advanced" button - create it if doesn't exist and show the advanced button QMenu* advancedMenu(); - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ @@ -274,7 +274,7 @@ class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog QgsSymbol* symbol(); protected: - //! Reimplements dialog keyPress event so we can ignore it + // Reimplements dialog keyPress event so we can ignore it void keyPressEvent( QKeyEvent * e ) override; void loadSymbol(); diff --git a/src/gui/symbology-ng/qgssymbolslistwidget.cpp b/src/gui/symbology-ng/qgssymbolslistwidget.cpp index dbfb25ff09b..ce2a6c3ef2d 100644 --- a/src/gui/symbology-ng/qgssymbolslistwidget.cpp +++ b/src/gui/symbology-ng/qgssymbolslistwidget.cpp @@ -471,22 +471,7 @@ QgsExpressionContext QgsSymbolsListWidget::createExpressionContext() const return QgsExpressionContext( *mContext.expressionContext() ); //otherwise create a default symbol context - QgsExpressionContext expContext; - expContext << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope() - << QgsExpressionContextUtils::atlasScope( nullptr ); - - if ( mContext.mapCanvas() ) - { - expContext << QgsExpressionContextUtils::mapSettingsScope( mContext.mapCanvas()->mapSettings() ) - << new QgsExpressionContextScope( mContext.mapCanvas()->expressionContextScope() ); - } - else - { - expContext << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); - } - - expContext << QgsExpressionContextUtils::layerScope( layer() ); + QgsExpressionContext expContext( mContext.globalProjectAtlasMapLayerScopes( layer() ) ); // additional scopes Q_FOREACH ( const QgsExpressionContextScope& scope, mContext.additionalExpressionContextScopes() ) diff --git a/src/gui/symbology-ng/qgssymbolslistwidget.h b/src/gui/symbology-ng/qgssymbolslistwidget.h index 2ad3ba79103..a6a4e922123 100644 --- a/src/gui/symbology-ng/qgssymbolslistwidget.h +++ b/src/gui/symbology-ng/qgssymbolslistwidget.h @@ -21,6 +21,7 @@ #include "qgssymbolwidgetcontext.h" #include +#include "qgis_gui.h" class QgsSymbol; class QgsStyle; @@ -37,17 +38,17 @@ class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListW public: QgsSymbolsListWidget( QgsSymbol* symbol, QgsStyle* style, QMenu* menu, QWidget* parent, const QgsVectorLayer * layer = nullptr ); - //! Destructor + virtual ~QgsSymbolsListWidget(); - /** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @param context symbol widget context * @see context() * @note added in QGIS 3.0 */ void setContext( const QgsSymbolWidgetContext& context ); - /** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts. + /** Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * @see setContext() * @note added in QGIS 3.0 */ diff --git a/src/gui/symbology-ng/qgssymbolwidgetcontext.cpp b/src/gui/symbology-ng/qgssymbolwidgetcontext.cpp index a0419149c06..2bd7c3ccb1b 100644 --- a/src/gui/symbology-ng/qgssymbolwidgetcontext.cpp +++ b/src/gui/symbology-ng/qgssymbolwidgetcontext.cpp @@ -13,6 +13,8 @@ * * ***************************************************************************/ #include "qgssymbolwidgetcontext.h" +#include "qgsmapcanvas.h" +#include "qgsproject.h" QgsSymbolWidgetContext::QgsSymbolWidgetContext() : mMapCanvas( nullptr ) @@ -75,3 +77,23 @@ QList QgsSymbolWidgetContext::additionalExpressionCon { return mAdditionalScopes; } + +QList QgsSymbolWidgetContext::globalProjectAtlasMapLayerScopes( const QgsMapLayer* layer ) const +{ + QList scopes; + scopes << QgsExpressionContextUtils::globalScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) + << QgsExpressionContextUtils::atlasScope( nullptr ); + if ( mMapCanvas ) + { + scopes << QgsExpressionContextUtils::mapSettingsScope( mMapCanvas->mapSettings() ) + << new QgsExpressionContextScope( mMapCanvas->expressionContextScope() ); + } + else + { + scopes << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); + } + if ( layer ) + scopes << QgsExpressionContextUtils::layerScope( layer ); + return scopes; +} diff --git a/src/gui/symbology-ng/qgssymbolwidgetcontext.h b/src/gui/symbology-ng/qgssymbolwidgetcontext.h index 4f284910b8e..fe9e260517d 100644 --- a/src/gui/symbology-ng/qgssymbolwidgetcontext.h +++ b/src/gui/symbology-ng/qgssymbolwidgetcontext.h @@ -16,13 +16,14 @@ #define QGSSYMBOLWIDGETCONTEXT_H #include "qgsexpressioncontext.h" +#include "qgis_gui.h" class QgsMapCanvas; /** \ingroup gui * \class QgsSymbolWidgetContext - * Contains settings which reflect the context in which a symbol (or renderer) widget is shown, eg the + * Contains settings which reflect the context in which a symbol (or renderer) widget is shown, e.g., the * map canvas and relevant expression contexts. * * \note added in QGIS 3.0 @@ -79,6 +80,12 @@ class GUI_EXPORT QgsSymbolWidgetContext // clazy:exclude=rule-of-three */ QList< QgsExpressionContextScope > additionalExpressionContextScopes() const; + /** Returns list of scopes: global, project, atlas, map, layer. + * Ownership is transferred to the caller. + * @note added in QGIS 3.0 + */ + QList globalProjectAtlasMapLayerScopes( const QgsMapLayer* layer ) const; + private: QgsMapCanvas* mMapCanvas; diff --git a/src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.cpp b/src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.cpp index 323de98a04c..69a60a07464 100644 --- a/src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.cpp +++ b/src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.cpp @@ -37,10 +37,6 @@ QgsVectorFieldSymbolLayerWidget::QgsVectorFieldSymbolLayerWidget( const QgsVecto } } -QgsVectorFieldSymbolLayerWidget::~QgsVectorFieldSymbolLayerWidget() -{ -} - void QgsVectorFieldSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer* layer ) { if ( layer->layerType() != QLatin1String( "VectorField" ) ) diff --git a/src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.h b/src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.h index a122f57a401..1072b640094 100644 --- a/src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.h +++ b/src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.h @@ -17,6 +17,7 @@ #include "qgssymbollayerwidget.h" #include "ui_widget_vectorfield.h" +#include "qgis_gui.h" class QgsVectorFieldSymbolLayer; @@ -28,7 +29,6 @@ class GUI_EXPORT QgsVectorFieldSymbolLayerWidget: public QgsSymbolLayerWidget, p Q_OBJECT public: QgsVectorFieldSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr ); - ~QgsVectorFieldSymbolLayerWidget(); static QgsSymbolLayerWidget* create( const QgsVectorLayer* vl ) { return new QgsVectorFieldSymbolLayerWidget( vl ); } diff --git a/src/helpviewer/CMakeLists.txt b/src/helpviewer/CMakeLists.txt index a9cea162c6a..14f1c9aa7a7 100644 --- a/src/helpviewer/CMakeLists.txt +++ b/src/helpviewer/CMakeLists.txt @@ -56,6 +56,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../core ${CMAKE_CURRENT_SOURCE_DIR}/../core/geometry ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src/core ) INCLUDE_DIRECTORIES(SYSTEM ${SQLITE3_INCLUDE_DIR} diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index a699bda1f20..15a9d864008 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -6,8 +6,6 @@ ENDIF() SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR}) SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR}) -ADD_SUBDIRECTORY(interpolation) -ADD_SUBDIRECTORY(oracle_raster) ADD_SUBDIRECTORY(coordinate_capture) ADD_SUBDIRECTORY(evis) ADD_SUBDIRECTORY(spatialquery) diff --git a/src/plugins/compass/CMakeLists.txt b/src/plugins/compass/CMakeLists.txt index 9e13b877d73..10b03ec09f7 100644 --- a/src/plugins/compass/CMakeLists.txt +++ b/src/plugins/compass/CMakeLists.txt @@ -30,10 +30,12 @@ QT5_ADD_RESOURCES(COMPASS_RCC_SRCS ${COMPASS_RCCS}) ADD_LIBRARY (compassplugin MODULE ${COMPASS_SRCS} ${COMPASS_MOC_SRCS} ${COMPASS_RCC_SRCS} ${COMPASS_UIS_H}) INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR} - ../../core ../../core/raster - ../../gui - .. + ${CMAKE_CURRENT_BINARY_DIR} + ../../core ../../core/raster + ../../gui + .. + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) TARGET_LINK_LIBRARIES(compassplugin diff --git a/src/plugins/coordinate_capture/CMakeLists.txt b/src/plugins/coordinate_capture/CMakeLists.txt index 25727254699..9aa045fabe4 100644 --- a/src/plugins/coordinate_capture/CMakeLists.txt +++ b/src/plugins/coordinate_capture/CMakeLists.txt @@ -28,13 +28,15 @@ QT5_ADD_RESOURCES(coordinatecapture_RCC_SRCS ${coordinatecapture_RCCS}) ADD_LIBRARY (coordinatecaptureplugin MODULE ${coordinatecapture_SRCS} ${coordinatecapture_MOC_SRCS} ${coordinatecapture_RCC_SRCS}) INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/../../ui/ - ../../core - ../../core/geometry - ../../core/raster - ../../gui - .. + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/../../ui/ + ../../core + ../../core/geometry + ../../core/raster + ../../gui + .. + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) INCLUDE_DIRECTORIES(SYSTEM ${GEOS_INCLUDE_DIR} diff --git a/src/plugins/coordinate_capture/coordinatecapture.h b/src/plugins/coordinate_capture/coordinatecapture.h index b99f154374f..8c51c70651b 100644 --- a/src/plugins/coordinate_capture/coordinatecapture.h +++ b/src/plugins/coordinate_capture/coordinatecapture.h @@ -80,7 +80,7 @@ class CoordinateCapture: public QObject, public QgisPlugin * @param theInterface Pointer to the QgisInterface object. */ explicit CoordinateCapture( QgisInterface * theInterface ); - //! Destructor + virtual ~CoordinateCapture(); public slots: diff --git a/src/plugins/evis/CMakeLists.txt b/src/plugins/evis/CMakeLists.txt index 39129c4e53d..6844f52c1a5 100644 --- a/src/plugins/evis/CMakeLists.txt +++ b/src/plugins/evis/CMakeLists.txt @@ -49,21 +49,23 @@ QT5_ADD_RESOURCES(evis_RCC_SRCS ${evis_RCCS}) ADD_LIBRARY (evis MODULE ${evis_SRCS} ${evis_MOC_SRCS} ${evis_RCC_SRCS} ${evis_UIS_H}) INCLUDE_DIRECTORIES(SYSTEM - ${GDAL_INCLUDE_DIR} - ${GEOS_INCLUDE_DIR} - ${QT_INCLUDE_DIR} + ${GDAL_INCLUDE_DIR} + ${GEOS_INCLUDE_DIR} + ${QT_INCLUDE_DIR} ) INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/databaseconnection - ${CMAKE_CURRENT_SOURCE_DIR}/eventbrowser - ${CMAKE_CURRENT_SOURCE_DIR}/idtool - ${CMAKE_CURRENT_SOURCE_DIR}/../../gui - ${CMAKE_CURRENT_SOURCE_DIR}/../../core - ${CMAKE_CURRENT_SOURCE_DIR}/../../core/geometry - ${CMAKE_CURRENT_SOURCE_DIR}/../../core/raster - ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/databaseconnection + ${CMAKE_CURRENT_SOURCE_DIR}/eventbrowser + ${CMAKE_CURRENT_SOURCE_DIR}/idtool + ${CMAKE_CURRENT_SOURCE_DIR}/../../gui + ${CMAKE_CURRENT_SOURCE_DIR}/../../core + ${CMAKE_CURRENT_SOURCE_DIR}/../../core/geometry + ${CMAKE_CURRENT_SOURCE_DIR}/../../core/raster + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) TARGET_LINK_LIBRARIES(evis diff --git a/src/plugins/evis/databaseconnection/evisdatabaseconnectiongui.cpp b/src/plugins/evis/databaseconnection/evisdatabaseconnectiongui.cpp index b407ec7e4d1..aac530cde1e 100644 --- a/src/plugins/evis/databaseconnection/evisdatabaseconnectiongui.cpp +++ b/src/plugins/evis/databaseconnection/evisdatabaseconnectiongui.cpp @@ -84,9 +84,6 @@ eVisDatabaseConnectionGui::eVisDatabaseConnectionGui( QList* th pbtnLoadPredefinedQueries->setToolTip( tr( "Open File" ) ); } -/** -* Destructor -*/ eVisDatabaseConnectionGui::~eVisDatabaseConnectionGui() { QSettings settings; @@ -417,7 +414,7 @@ void eVisDatabaseConnectionGui::on_pbtnLoadPredefinedQueries_clicked() } else { - teditConsole->append( tr( "Error: Unabled to open file [%1]" ).arg( myFilename ) ); + teditConsole->append( tr( "Error: Unable to open file [%1]" ).arg( myFilename ) ); } } } diff --git a/src/plugins/evis/databaseconnection/evisdatabaseconnectiongui.h b/src/plugins/evis/databaseconnection/evisdatabaseconnectiongui.h index 8f43a679255..8e0d5861e13 100644 --- a/src/plugins/evis/databaseconnection/evisdatabaseconnectiongui.h +++ b/src/plugins/evis/databaseconnection/evisdatabaseconnectiongui.h @@ -52,7 +52,6 @@ class eVisDatabaseConnectionGui : public QDialog, private Ui::eVisDatabaseConnec //! \brief Constructor eVisDatabaseConnectionGui( QList*, QWidget* parent = nullptr, Qt::WindowFlags fl = 0 ); - //! \brief Destructor ~eVisDatabaseConnectionGui(); private: diff --git a/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp b/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp index 6ffa28a52cc..5dd15a580f4 100644 --- a/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp +++ b/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp @@ -548,7 +548,7 @@ void eVisGenericEventBrowserGui::displayImage() //keep the extent the same just center the map canvas in the display so our feature is in the middle QgsRectangle myRect( myPoint.x() - ( mCanvas->extent().width() / 2 ), myPoint.y() - ( mCanvas->extent().height() / 2 ), myPoint.x() + ( mCanvas->extent().width() / 2 ), myPoint.y() + ( mCanvas->extent().height() / 2 ) ); - // only change the extents if the point is beyond the current extents to minimise repaints + // only change the extents if the point is beyond the current extents to minimize repaints if ( !mCanvas->extent().contains( myPoint ) ) { mCanvas->setExtent( myRect ); diff --git a/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.h b/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.h index 21403f61351..8c89cbfb97f 100644 --- a/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.h +++ b/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.h @@ -61,7 +61,6 @@ class eVisGenericEventBrowserGui : public QDialog, private Ui::eVisGenericEventB //! \brief Constructor called when new browser is requested by the eVisEventIdTool eVisGenericEventBrowserGui( QWidget* parent, QgsMapCanvas* canvas, Qt::WindowFlags fl ); - //! \Brief Destructor ~eVisGenericEventBrowserGui(); protected: diff --git a/src/plugins/evis/eventbrowser/evisimagedisplaywidget.cpp b/src/plugins/evis/eventbrowser/evisimagedisplaywidget.cpp index 62743338260..c8892ff5c20 100644 --- a/src/plugins/evis/eventbrowser/evisimagedisplaywidget.cpp +++ b/src/plugins/evis/eventbrowser/evisimagedisplaywidget.cpp @@ -97,14 +97,7 @@ eVisImageDisplayWidget::eVisImageDisplayWidget( QWidget* parent, Qt::WindowFlags //setup http connection mHttpBuffer = new QBuffer(); -#if QT_VERSION < 0x050000 - mHttpConnection = new QHttp(); -#endif mHttpBuffer->open( QBuffer::ReadWrite ); -// TODO -#if QT_VERSION < 0x050000 - connect( mHttpConnection, SIGNAL( requestFinished( int, bool ) ), this, SLOT( displayUrlImage( int, bool ) ) ); -#endif //initialize remaining variables mScaleByHeight = false; @@ -119,9 +112,6 @@ eVisImageDisplayWidget::~eVisImageDisplayWidget() delete mImageLabel; delete mImage; delete mHttpBuffer; -#if QT_VERSION < 0x050000 - delete mHttpConnection; -#endif delete pbtnZoomIn; delete pbtnZoomOut; delete pbtnZoomFull; @@ -199,11 +189,6 @@ void eVisImageDisplayWidget::displayImage() void eVisImageDisplayWidget::displayUrlImage( const QString& url ) { Q_UNUSED( url ); -#if QT_VERSION < 0x050000 - QUrl myUrl( url ); - mHttpConnection->setHost( myUrl.host() ); - mCurrentHttpImageRequestId = mHttpConnection->get( myUrl.path().replace( '\\', '/' ), mHttpBuffer ); -#endif } /** diff --git a/src/plugins/evis/eventbrowser/evisimagedisplaywidget.h b/src/plugins/evis/eventbrowser/evisimagedisplaywidget.h index 512a1ca6ff4..a6b2159fb95 100644 --- a/src/plugins/evis/eventbrowser/evisimagedisplaywidget.h +++ b/src/plugins/evis/eventbrowser/evisimagedisplaywidget.h @@ -32,10 +32,6 @@ #include #include #include -// TODO: Update to QNetworkAccessManager -#if QT_VERSION < 0x050000 -#include -#endif #include @@ -55,7 +51,6 @@ class eVisImageDisplayWidget : public QWidget //! \brief Constructor eVisImageDisplayWidget( QWidget* parent = nullptr, Qt::WindowFlags fl = 0 ); - //! \brief Destructor ~eVisImageDisplayWidget(); //! \brief Load an image from disk and display @@ -94,12 +89,6 @@ class eVisImageDisplayWidget : public QWidget //! \brief Pointer to the http buffer QBuffer* mHttpBuffer; -// TODO: Update to QNetworkAccessManager -#if QT_VERSION < 0x050000 - //! \brief Pointer to the http connection if needed - QHttp* mHttpConnection; -#endif - //! \brief This is a point to the actual image being displayed QPixmap* mImage; diff --git a/src/plugins/evis/evis.h b/src/plugins/evis/evis.h index 0938b29a8f6..ee575ce9b84 100644 --- a/src/plugins/evis/evis.h +++ b/src/plugins/evis/evis.h @@ -94,7 +94,6 @@ class eVis: public QObject, public QgisPlugin //! Constructor explicit eVis( QgisInterface * theInterface ); - //! Destructor */ ~eVis(); public slots: diff --git a/src/plugins/geometry_checker/CMakeLists.txt b/src/plugins/geometry_checker/CMakeLists.txt index 48a39fbdab4..30077873c04 100644 --- a/src/plugins/geometry_checker/CMakeLists.txt +++ b/src/plugins/geometry_checker/CMakeLists.txt @@ -84,16 +84,18 @@ QT5_ADD_RESOURCES(geometrychecker_RCC_SRCS ${geometrychecker_RCCS}) ADD_LIBRARY (geometrycheckerplugin MODULE ${geometrychecker_HDRS} ${geometrychecker_SRCS} ${geometrychecker_MOC_SRCS} ${geometrychecker_RCC_SRCS} ${geometrychecker_UIS_H}) INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR} - ../../core - ../../core/geometry - ../../core/symbology-ng - ../../gui - .. + ${CMAKE_CURRENT_BINARY_DIR} + ../../core + ../../core/geometry + ../../core/symbology-ng + ../../gui + .. + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) INCLUDE_DIRECTORIES(SYSTEM - ${GEOS_INCLUDE_DIR} - ${GDAL_INCLUDE_DIR} + ${GEOS_INCLUDE_DIR} + ${GDAL_INCLUDE_DIR} ) TARGET_LINK_LIBRARIES(geometrycheckerplugin diff --git a/src/plugins/geometry_checker/checks/qgsgeometrycheck.h b/src/plugins/geometry_checker/checks/qgsgeometrycheck.h index 404fbd88459..8520fa4b164 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometrycheck.h +++ b/src/plugins/geometry_checker/checks/qgsgeometrycheck.h @@ -75,7 +75,6 @@ class QgsGeometryCheck : public QObject : mCheckType( checkType ) , mFeaturePool( featurePool ) {} - virtual ~QgsGeometryCheck() {} virtual void collectErrors( QList& errors, QStringList& messages, QAtomicInt* progressCounter = nullptr, const QgsFeatureIds& ids = QgsFeatureIds() ) const = 0; virtual void fixError( QgsGeometryCheckError* error, int method, int mergeAttributeIndex, Changes& changes ) const = 0; virtual const QStringList& getResolutionMethods() const = 0; @@ -107,6 +106,9 @@ class QgsGeometryCheckError const QVariant& value = QVariant(), ValueType valueType = ValueOther ); virtual ~QgsGeometryCheckError(); + + const QgsGeometryCheckError& operator=( const QgsGeometryCheckError& ) = delete; + const QgsGeometryCheck* check() const { return mCheck; } QgsFeatureId featureId() const { return mFeatureId; } virtual QgsAbstractGeometry* geometry(); @@ -160,8 +162,6 @@ class QgsGeometryCheckError Status mStatus; QString mResolutionMessage; - private: - const QgsGeometryCheckError& operator=( const QgsGeometryCheckError& ); }; Q_DECLARE_METATYPE( QgsGeometryCheckError* ) diff --git a/src/plugins/geometry_checker/qgsgeometrycheckfactory.h b/src/plugins/geometry_checker/qgsgeometrycheckfactory.h index 49802b82245..b0f869b3088 100644 --- a/src/plugins/geometry_checker/qgsgeometrycheckfactory.h +++ b/src/plugins/geometry_checker/qgsgeometrycheckfactory.h @@ -25,7 +25,7 @@ class QgsMapSettings; class QgsGeometryCheckFactory { public: - virtual ~QgsGeometryCheckFactory() {} + virtual ~QgsGeometryCheckFactory() = default; virtual void restorePrevious( Ui::QgsGeometryCheckerSetupTab& /*ui*/ ) const = 0; virtual bool checkApplicability( Ui::QgsGeometryCheckerSetupTab& /*ui*/, QgsWkbTypes::GeometryType /*geomType*/ ) const = 0; virtual QgsGeometryCheck* createInstance( QgsFeaturePool* featurePool, const Ui::QgsGeometryCheckerSetupTab& ui, double mapToLayerUnits ) const = 0; diff --git a/src/plugins/georeferencer/CMakeLists.txt b/src/plugins/georeferencer/CMakeLists.txt index 806f388c625..b7e151d8466 100644 --- a/src/plugins/georeferencer/CMakeLists.txt +++ b/src/plugins/georeferencer/CMakeLists.txt @@ -75,20 +75,23 @@ QT5_ADD_RESOURCES(GEOREF_RCC_SRCS ${GEOREF_RCCS}) ADD_LIBRARY (georefplugin MODULE ${GEOREF_SRCS} ${GEOREF_MOC_SRCS} ${GEOREF_RCC_SRCS} ${GEOREF_UIS_H}) INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/../../ui - ../../core ../../core/geometry ../../core/raster ../../core/composer - ../../gui ../../gui/editorwidgets ../../gui/layertree - .. + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/../../ui + ../../core ../../core/geometry ../../core/raster ../../core/composer + ../../gui ../../gui/editorwidgets ../../gui/layertree + .. + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui + ${CMAKE_BINARY_DIR}/src/app ) INCLUDE_DIRECTORIES(SYSTEM - ${GSL_INCLUDE_DIR} - ${QGIS_INCLUDE_DIR} - ${GDAL_INCLUDE_DIR} - ${GEOS_INCLUDE_DIR} - ${QT_QTXML_INCLUDE_DIR} - ${QWT_INCLUDE_DIR} + ${GSL_INCLUDE_DIR} + ${QGIS_INCLUDE_DIR} + ${GDAL_INCLUDE_DIR} + ${GEOS_INCLUDE_DIR} + ${QT_QTXML_INCLUDE_DIR} + ${QWT_INCLUDE_DIR} ) TARGET_LINK_LIBRARIES(georefplugin diff --git a/src/plugins/georeferencer/qgsgeorefplugin.h b/src/plugins/georeferencer/qgsgeorefplugin.h index 9e8217dd71b..d5805b71569 100644 --- a/src/plugins/georeferencer/qgsgeorefplugin.h +++ b/src/plugins/georeferencer/qgsgeorefplugin.h @@ -75,7 +75,7 @@ class QgsGeorefPlugin: public QObject, public QgisPlugin * @param Pointer to the QgisIface object. */ explicit QgsGeorefPlugin( QgisInterface * ); - //! Destructor + virtual ~ QgsGeorefPlugin(); public slots: diff --git a/src/plugins/georeferencer/qgsgeorefplugingui.cpp b/src/plugins/georeferencer/qgsgeorefplugingui.cpp index 496ddfc41a6..51b252252ce 100644 --- a/src/plugins/georeferencer/qgsgeorefplugingui.cpp +++ b/src/plugins/georeferencer/qgsgeorefplugingui.cpp @@ -1522,7 +1522,7 @@ bool QgsGeorefPluginGui::writePDFMapFile( const QString& fileName, const QgsGeor double paperHeight = s.value( QStringLiteral( "/Plugin-GeoReferencer/Config/HeightPDFMap" ), "420" ).toDouble(); //create composition - QgsComposition* composition = new QgsComposition( mCanvas->mapSettings() ); + QgsComposition* composition = new QgsComposition( mCanvas->mapSettings(), QgsProject::instance() ); if ( mapRatio >= 1 ) { composition->setPaperSize( paperHeight, paperWidth ); @@ -1589,7 +1589,7 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG } //create composition A4 with 300 dpi - QgsComposition* composition = new QgsComposition( mCanvas->mapSettings() ); + QgsComposition* composition = new QgsComposition( mCanvas->mapSettings(), QgsProject::instance() ); composition->setPaperSize( 210, 297 ); //A4 composition->setPrintResolution( 300 ); composition->setNumPages( 2 ); diff --git a/src/plugins/georeferencer/qgsgeoreftransform.cpp b/src/plugins/georeferencer/qgsgeoreftransform.cpp index d4bd44bc8db..71f5c93fad7 100644 --- a/src/plugins/georeferencer/qgsgeoreftransform.cpp +++ b/src/plugins/georeferencer/qgsgeoreftransform.cpp @@ -33,7 +33,6 @@ class QgsLinearGeorefTransform : public QgsGeorefTransformInterface { public: QgsLinearGeorefTransform() : mParameters() {} - ~QgsLinearGeorefTransform() {} bool getOriginScale( QgsPoint &origin, double &scaleX, double &scaleY ) const; @@ -113,7 +112,6 @@ class QgsProjectiveGeorefTransform : public QgsGeorefTransformInterface { public: QgsProjectiveGeorefTransform() : mParameters() {} - ~QgsProjectiveGeorefTransform() {} bool updateParametersFromGCPs( const QVector &mapCoords, const QVector &pixelCoords ) override; int getMinimumGCPCount() const override; diff --git a/src/plugins/georeferencer/qgsimagewarper.cpp b/src/plugins/georeferencer/qgsimagewarper.cpp index 54e3616d252..2274e56d3eb 100644 --- a/src/plugins/georeferencer/qgsimagewarper.cpp +++ b/src/plugins/georeferencer/qgsimagewarper.cpp @@ -29,12 +29,6 @@ #include "qgsgeoreftransform.h" #include "qgslogger.h" -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 -#define TO8F(x) (x).toUtf8().constData() -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#endif - bool QgsImageWarper::mWarpCanceled = false; QgsImageWarper::QgsImageWarper( QWidget *theParent ) @@ -48,7 +42,7 @@ bool QgsImageWarper::openSrcDSAndGetWarpOpt( const QString &input, ResamplingMet { // Open input file GDALAllRegister(); - hSrcDS = GDALOpen( TO8F( input ), GA_ReadOnly ); + hSrcDS = GDALOpen( input.toUtf8().constData(), GA_ReadOnly ); if ( !hSrcDS ) return false; @@ -85,7 +79,7 @@ bool QgsImageWarper::createDestinationDataset( const QString &outputName, GDALDa char **papszOptions = nullptr; papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", compression.toLatin1() ); hDstDS = GDALCreate( driver, - TO8F( outputName ), resX, resY, + outputName.toUtf8().constData(), resX, resY, GDALGetRasterCount( hSrcDS ), GDALGetRasterDataType( GDALGetRasterBand( hSrcDS, 1 ) ), papszOptions ); diff --git a/src/plugins/georeferencer/qgsrasterchangecoords.cpp b/src/plugins/georeferencer/qgsrasterchangecoords.cpp index 276f2e285a7..3d9693ad329 100644 --- a/src/plugins/georeferencer/qgsrasterchangecoords.cpp +++ b/src/plugins/georeferencer/qgsrasterchangecoords.cpp @@ -20,12 +20,6 @@ #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 -#define TO8F(x) (x).toUtf8().constData() -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#endif - QgsRasterChangeCoords::QgsRasterChangeCoords() : mHasCrs( false ) , mUL_X( 0. ) @@ -38,7 +32,7 @@ QgsRasterChangeCoords::QgsRasterChangeCoords() void QgsRasterChangeCoords::setRaster( const QString &fileRaster ) { GDALAllRegister(); - GDALDatasetH hDS = GDALOpen( TO8F( fileRaster ), GA_ReadOnly ); + GDALDatasetH hDS = GDALOpen( fileRaster.toUtf8().constData(), GA_ReadOnly ); double adfGeoTransform[6]; if ( GDALGetProjectionRef( hDS ) && GDALGetGeoTransform( hDS, adfGeoTransform ) == CE_None ) //if ( false ) diff --git a/src/plugins/globe/CMakeLists.txt b/src/plugins/globe/CMakeLists.txt index 12b7b39c61e..88f990c72dd 100644 --- a/src/plugins/globe/CMakeLists.txt +++ b/src/plugins/globe/CMakeLists.txt @@ -57,17 +57,19 @@ QT5_ADD_RESOURCES(GLOBE_PLUGIN_RCC_SRCS ${GLOBE_PLUGIN_RCCS}) ADD_LIBRARY (globeplugin SHARED ${GLOBE_PLUGIN_SRCS} ${GLOBE_PLUGIN_MOC_SRCS} ${GLOBE_PLUGIN_RCC_SRCS} ${GLOBE_PLUGIN_UIS_H} ${GLOBE_PLUGIN_HDRS}) INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR} - ${OSGEARTH_INCLUDE_DIR} - ${OSG_INCLUDE_DIR} - ${GEOS_INCLUDE_DIR} - ${SIP_INCLUDE_DIR} - ../../core - ../../core/geometry - ../../core/raster - ../../core/symbology-ng - ../../gui - .. + ${CMAKE_CURRENT_BINARY_DIR} + ${OSGEARTH_INCLUDE_DIR} + ${OSG_INCLUDE_DIR} + ${GEOS_INCLUDE_DIR} + ${SIP_INCLUDE_DIR} + ../../core + ../../core/geometry + ../../core/raster + ../../core/symbology-ng + ../../gui + .. + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) TARGET_LINK_LIBRARIES(globeplugin diff --git a/src/plugins/gps_importer/CMakeLists.txt b/src/plugins/gps_importer/CMakeLists.txt index 00526f32d8f..a0fcab5b7dc 100644 --- a/src/plugins/gps_importer/CMakeLists.txt +++ b/src/plugins/gps_importer/CMakeLists.txt @@ -35,18 +35,20 @@ QT5_ADD_RESOURCES(GPS_RCC_SRCS ${GPS_RCCS}) ADD_LIBRARY (gpsimporterplugin MODULE ${GPS_SRCS} ${GPS_MOC_SRCS} ${GPS_RCC_SRCS} ${GPS_UIS_H}) INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${QEXTSERIALPORT_INCLUDE_DIR} - ../../core - ../../core/geometry - ../../core/gps - ../../gui - .. + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${QEXTSERIALPORT_INCLUDE_DIR} + ../../core + ../../core/geometry + ../../core/gps + ../../gui + .. + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui ) INCLUDE_DIRECTORIES(SYSTEM - ${EXPAT_INCLUDE_DIR} - ${PROJ_INCLUDE_DIR} + ${EXPAT_INCLUDE_DIR} + ${PROJ_INCLUDE_DIR} ) TARGET_LINK_LIBRARIES(gpsimporterplugin diff --git a/src/plugins/gps_importer/qgsgpsplugin.h b/src/plugins/gps_importer/qgsgpsplugin.h index 0defa96fad9..b3e014a0d6e 100644 --- a/src/plugins/gps_importer/qgsgpsplugin.h +++ b/src/plugins/gps_importer/qgsgpsplugin.h @@ -41,7 +41,7 @@ class QgsGPSPlugin: public QObject, public QgisPlugin */ explicit QgsGPSPlugin( QgisInterface * ); - //! Destructor + virtual ~QgsGPSPlugin(); public slots: diff --git a/src/plugins/grass/CMakeLists.txt b/src/plugins/grass/CMakeLists.txt index b33ff80e98f..1d8faf579b4 100644 --- a/src/plugins/grass/CMakeLists.txt +++ b/src/plugins/grass/CMakeLists.txt @@ -5,7 +5,6 @@ ADD_SUBDIRECTORY(scripts) if (HAVE_OPENPTY) ADD_DEFINITIONS(-DHAVE_OPENPTY) ENDIF (HAVE_OPENPTY) -ADD_DEFINITIONS("-DGRASS_EXPORT=${DLLIMPORT} -DGRASS_LIB_EXPORT=${DLLIMPORT}") IF (WIN32) ADD_DEFINITIONS(-DHAVE_GETPT) @@ -163,6 +162,9 @@ INCLUDE_DIRECTORIES( ../../gui/layertree ../../providers/grass ${CMAKE_CURRENT_BINARY_DIR}/../../ui + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui + ${CMAKE_BINARY_DIR}/src/app ) INCLUDE_DIRECTORIES(SYSTEM ${GDAL_INCLUDE_DIR} @@ -182,6 +184,10 @@ MACRO(ADD_GRASSPLUGIN GRASS_BUILD_VERSION) QT5_WRAP_CPP (GRASS_PLUGIN_MOC_SRCS ${GRASS_PLUGIN_MOC_HDRS}) QT5_ADD_RESOURCES(GRASS_PLUGIN_RCC_SRCS ${GRASS_PLUGIN_RCCS}) + INCLUDE_DIRECTORIES( + ${CMAKE_BINARY_DIR}/src/providers/grass/${GRASS_BUILD_VERSION} + ) + ADD_LIBRARY (grassplugin${GRASS_BUILD_VERSION} MODULE ${GRASS_PLUGIN_SRCS} ${GRASS_PLUGIN_MOC_SRCS} diff --git a/src/plugins/grass/qgsgrasseditrenderer.cpp b/src/plugins/grass/qgsgrasseditrenderer.cpp index 96e845f4123..a3b9f97da1e 100644 --- a/src/plugins/grass/qgsgrasseditrenderer.cpp +++ b/src/plugins/grass/qgsgrasseditrenderer.cpp @@ -231,7 +231,7 @@ QgsFeatureRenderer* QgsGrassEditRenderer::create( QDomElement& element ) { QString rendererType = elem.attribute( QStringLiteral( "type" ) ); QgsDebugMsg( "childElem.tagName() = " + childElem.tagName() + " rendererType = " + rendererType ); - QgsRendererAbstractMetadata* meta = QgsRendererRegistry::instance()->rendererMetadata( rendererType ); + QgsRendererAbstractMetadata* meta = QgsApplication::rendererRegistry()->rendererMetadata( rendererType ); if ( meta ) { QgsFeatureRenderer* subRenderer = meta->createRenderer( elem ); diff --git a/src/plugins/grass/qgsgrassmapcalc.h b/src/plugins/grass/qgsgrassmapcalc.h index 0cbaaf29f34..3d89530c2ea 100644 --- a/src/plugins/grass/qgsgrassmapcalc.h +++ b/src/plugins/grass/qgsgrassmapcalc.h @@ -43,7 +43,7 @@ class QgsGrassMapcalc: public QMainWindow, private Ui::QgsGrassMapcalcBase, QgisInterface *iface, QWidget * parent = 0, Qt::WindowFlags f = 0 ); - //! Destructor + ~QgsGrassMapcalc(); // Current tool @@ -87,7 +87,7 @@ class QgsGrassMapcalc: public QMainWindow, private Ui::QgsGrassMapcalcBase, //! Grow canvas and move items void growCanvas( int left, int right, int top, int bottom ); - //! Grow automaticaly if an item is near border + //! Grow automatically if an item is near border void autoGrow(); void resizeCanvas( int width, int height ); @@ -238,7 +238,7 @@ class QgsGrassMapcalcFunction /* Number of inputs */ int mInputCount; - /* Identification name, eg. 'if(x,a,b)' */ + /* Identification name, e.g., 'if(x,a,b)' */ //QString mName; /* Label used in combobox and objects */ diff --git a/src/plugins/grass/qgsgrassmodule.h b/src/plugins/grass/qgsgrassmodule.h index cf3a5938e92..75e194155ce 100644 --- a/src/plugins/grass/qgsgrassmodule.h +++ b/src/plugins/grass/qgsgrassmodule.h @@ -51,7 +51,7 @@ class QgsGrassModule : public QWidget, private Ui::QgsGrassModuleBase QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisInterface *iface, bool direct, QWidget *parent = 0, Qt::WindowFlags f = 0 ); - //! Destructor + ~QgsGrassModule(); QString translate( QString string ); diff --git a/src/plugins/grass/qgsgrassmoduleinput.h b/src/plugins/grass/qgsgrassmoduleinput.h index fad2da97bf7..8de12c2452e 100644 --- a/src/plugins/grass/qgsgrassmoduleinput.h +++ b/src/plugins/grass/qgsgrassmoduleinput.h @@ -101,7 +101,6 @@ class QgsGrassModuleInputProxy : public QSortFilterProxyModel public: explicit QgsGrassModuleInputProxy( QgsGrassModuleInputModel *sourceModel, QgsGrassObject::Type type, QObject *parent = 0 ); - ~QgsGrassModuleInputProxy() {} protected: bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override; @@ -243,7 +242,7 @@ class QgsGrassModuleInput : public QgsGrassModuleGroupBoxItem QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent = 0 ); - //! Destructor + ~QgsGrassModuleInput(); //! Retruns list of options which will be passed to module diff --git a/src/plugins/grass/qgsgrassmoduleoptions.h b/src/plugins/grass/qgsgrassmoduleoptions.h index 70c7aba7b61..1ec4ce0d601 100644 --- a/src/plugins/grass/qgsgrassmoduleoptions.h +++ b/src/plugins/grass/qgsgrassmoduleoptions.h @@ -55,7 +55,7 @@ class QgsGrassModuleOptions QgsGrassTools *tools, QgsGrassModule *module, QgisInterface *iface, bool direct ); - //! Destructor + virtual ~QgsGrassModuleOptions(); //! Get module options as list of arguments for QProcess @@ -149,7 +149,7 @@ class QgsGrassModuleStandardOptions: public QWidget, public QgsGrassModuleOption QString xname, QDomElement confDocElem, bool direct, QWidget * parent = 0, Qt::WindowFlags f = 0 ); - //! Destructor + ~QgsGrassModuleStandardOptions(); //! Get module options as list of arguments for QProcess diff --git a/src/plugins/grass/qgsgrassmoduleparam.cpp b/src/plugins/grass/qgsgrassmoduleparam.cpp index a62e03a3926..7b8ea91a74d 100644 --- a/src/plugins/grass/qgsgrassmoduleparam.cpp +++ b/src/plugins/grass/qgsgrassmoduleparam.cpp @@ -1024,29 +1024,7 @@ QStringList QgsGrassModuleGdalInput::options() if ( !mOgrLayerOption.isEmpty() && mOgrLayers[current].size() > 0 ) { opt = mOgrLayerOption + "="; - // GDAL 1.4.0 supports schemas (r9998) -#if GDAL_VERSION_NUM >= 1400 opt += mOgrLayers[current]; -#else - // Handle older versions of gdal gracefully - // OGR does not support schemas !!! - if ( current >= 0 && current < mUri.size() ) - { - QStringList l = mOgrLayers[current].split( "." ); - opt += l.at( 1 ); - - // Currently only PostGIS is using layer - // -> layer -> PostGIS -> warning - if ( mOgrLayers[current].length() > 0 ) - { - QMessageBox::warning( 0, tr( "Warning" ), - tr( "PostGIS driver in OGR does not support schemas!
    " - "Only the table name will be used.
    " - "It can result in wrong input if more tables of the same name
    " - "are present in the database." ) ); - } - } -#endif //GDAL_VERSION_NUM list.push_back( opt ); } diff --git a/src/plugins/grass/qgsgrassmoduleparam.h b/src/plugins/grass/qgsgrassmoduleparam.h index 5b9ec6d5715..4618b4a4eb6 100644 --- a/src/plugins/grass/qgsgrassmoduleparam.h +++ b/src/plugins/grass/qgsgrassmoduleparam.h @@ -59,7 +59,7 @@ class QgsGrassModuleCheckBox : public QCheckBox */ QgsGrassModuleCheckBox( const QString & text, QWidget * parent = 0 ); - //! Destructor + virtual ~QgsGrassModuleCheckBox(); void resizeEvent( QResizeEvent * event ) override; @@ -93,7 +93,7 @@ class QgsGrassModuleParam QgsGrassModuleParam( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct ); - //! Destructor + virtual ~QgsGrassModuleParam(); //! Is the item hidden @@ -184,7 +184,7 @@ class QgsGrassModuleGroupBoxItem : public QGroupBox, public QgsGrassModuleParam QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent = 0 ); - //! Destructor + virtual ~QgsGrassModuleGroupBoxItem(); void resizeEvent( QResizeEvent * event ) override; @@ -250,7 +250,7 @@ class QgsGrassModuleOption : public QgsGrassModuleMultiParam QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent = 0 ); - //! Destructor + ~QgsGrassModuleOption(); //! Control option @@ -356,7 +356,7 @@ class QgsGrassModuleFlag : public QgsGrassModuleCheckBox, public QgsGrassModuleP QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent = 0 ); - //! Destructor + ~QgsGrassModuleFlag(); //! Retruns list of options which will be passed to module @@ -384,7 +384,7 @@ class QgsGrassModuleGdalInput : public QgsGrassModuleGroupBoxItem QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent = 0 ); - //! Destructor + ~QgsGrassModuleGdalInput(); //! Reimplemented @@ -446,7 +446,7 @@ class QgsGrassModuleField : public QgsGrassModuleOption QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent = 0 ); - //! Destructor + ~QgsGrassModuleField(); }; @@ -471,7 +471,7 @@ class QgsGrassModuleVectorField : public QgsGrassModuleMultiParam QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent = 0 ); - //! Destructor + ~QgsGrassModuleVectorField(); //! Retruns list of options which will be passed to module @@ -536,7 +536,7 @@ class QgsGrassModuleSelection : public QgsGrassModuleGroupBoxItem QDomNode &gnode, bool direct, QWidget * parent = 0 ); - //! Destructor + ~QgsGrassModuleSelection(); //! Retruns list of options which will be passed to module @@ -602,7 +602,7 @@ class QgsGrassModuleFile : public QgsGrassModuleGroupBoxItem QDomNode &gnode, bool direct, QWidget *parent = 0 ); - //! Destructor + ~QgsGrassModuleFile(); //! File type diff --git a/src/plugins/grass/qgsgrassnewmapset.h b/src/plugins/grass/qgsgrassnewmapset.h index 14885fe13b8..ec44e04739b 100644 --- a/src/plugins/grass/qgsgrassnewmapset.h +++ b/src/plugins/grass/qgsgrassnewmapset.h @@ -55,7 +55,7 @@ class QgsGrassNewMapset : public QWizard, private Ui::QgsGrassNewMapsetBase QgsGrassPlugin *plugin, QWidget * parent = 0, Qt::WindowFlags f = 0 ); - //! Destructor + ~QgsGrassNewMapset(); //! Next page diff --git a/src/plugins/grass/qgsgrassplugin.cpp b/src/plugins/grass/qgsgrassplugin.cpp index b7701762609..1953001fb1e 100644 --- a/src/plugins/grass/qgsgrassplugin.cpp +++ b/src/plugins/grass/qgsgrassplugin.cpp @@ -289,9 +289,9 @@ void QgsGrassPlugin::initGui() qGisInterface->addDockWidget( Qt::RightDockWidgetArea, mTools ); // add edit renderer immediately so that if project was saved during editing, the layer can be loaded - if ( !QgsRendererRegistry::instance()->renderersList().contains( QStringLiteral( "grassEdit" ) ) ) + if ( !QgsApplication::rendererRegistry()->renderersList().contains( QStringLiteral( "grassEdit" ) ) ) { - QgsRendererRegistry::instance()->addRenderer( new QgsRendererMetadata( QStringLiteral( "grassEdit" ), + QgsApplication::rendererRegistry()->addRenderer( new QgsRendererMetadata( QStringLiteral( "grassEdit" ), QObject::tr( "GRASS edit" ), QgsGrassEditRenderer::create, QIcon( QgsApplication::defaultThemePath() + "rendererGrassSymbol.svg" ), diff --git a/src/plugins/grass/qgsgrassplugin.h b/src/plugins/grass/qgsgrassplugin.h index 2508a4fcc68..a8f123bcfa2 100644 --- a/src/plugins/grass/qgsgrassplugin.h +++ b/src/plugins/grass/qgsgrassplugin.h @@ -78,7 +78,7 @@ class QgsGrassPlugin : public QObject, public QgisPlugin * Return the plugin type */ virtual int type(); - //! Destructor + virtual ~QgsGrassPlugin(); //! Get an icon from the active theme if possible diff --git a/src/plugins/grass/qgsgrassregion.h b/src/plugins/grass/qgsgrassregion.h index 362fc7f6b65..368293a41e2 100644 --- a/src/plugins/grass/qgsgrassregion.h +++ b/src/plugins/grass/qgsgrassregion.h @@ -50,7 +50,7 @@ class QgsGrassRegion: public QWidget, private Ui::QgsGrassRegionBase QgsGrassRegion( QgisInterface *iface, QWidget * parent = 0, Qt::WindowFlags f = 0 ); - //! Destructor + ~QgsGrassRegion(); public slots: diff --git a/src/plugins/grass/qgsgrassselect.h b/src/plugins/grass/qgsgrassselect.h index 8b4e0c7a01f..fe9a8c6af10 100644 --- a/src/plugins/grass/qgsgrassselect.h +++ b/src/plugins/grass/qgsgrassselect.h @@ -29,7 +29,7 @@ class QgsGrassSelect: public QDialog, private Ui::QgsGrassSelectBase //! Constructor //QgsGrassSelect(QWidget *parent = 0, int type = VECTOR ); QgsGrassSelect( QWidget *parent, int type = VECTOR ); - //! Destructor + ~QgsGrassSelect(); enum TYPE diff --git a/src/plugins/grass/qgsgrasstools.h b/src/plugins/grass/qgsgrasstools.h index 7ac5c36319c..32858221ab8 100644 --- a/src/plugins/grass/qgsgrasstools.h +++ b/src/plugins/grass/qgsgrasstools.h @@ -44,7 +44,7 @@ class QgsGrassTools: public QgsDockWidget, public Ui::QgsGrassToolsBase QgsGrassTools( QgisInterface *iface, QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 ); - //! Destructor + ~QgsGrassTools(); //! Append item to model or parent diff --git a/src/plugins/grass/qgsgrassutils.h b/src/plugins/grass/qgsgrassutils.h index ea1b978076a..8038909c39f 100644 --- a/src/plugins/grass/qgsgrassutils.h +++ b/src/plugins/grass/qgsgrassutils.h @@ -33,7 +33,7 @@ class QgsGrassUtils //! Constructor QgsGrassUtils(); - //! Destructor + ~QgsGrassUtils(); public: @@ -62,7 +62,7 @@ class QgsGrassElementDialog: public QObject //! Constructor explicit QgsGrassElementDialog( QWidget *parent ); - //! Destructor + ~QgsGrassElementDialog(); public: diff --git a/src/plugins/grass/qtermwidget/BlockArray.h b/src/plugins/grass/qtermwidget/BlockArray.h index 4fee62343c6..7eb24edf191 100644 --- a/src/plugins/grass/qtermwidget/BlockArray.h +++ b/src/plugins/grass/qtermwidget/BlockArray.h @@ -40,7 +40,6 @@ struct Block { size_t size; }; -// /////////////////////////////////////////////////////// class BlockArray { public: diff --git a/src/plugins/grass/qtermwidget/Emulation.h b/src/plugins/grass/qtermwidget/Emulation.h index 3037a04be26..d934c04dd06 100644 --- a/src/plugins/grass/qtermwidget/Emulation.h +++ b/src/plugins/grass/qtermwidget/Emulation.h @@ -359,14 +359,14 @@ signals: *

  • 2 - Set session title to @p newTitle
  • *
  • 11 - Set the session's default background color to @p newTitle, * where @p newTitle can be an HTML-style string ("#RRGGBB") or a named - * color (eg 'red', 'blue'). + * color (e.g., 'red', 'blue'). * See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more * details. *
  • *
  • 31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)
  • *
  • 32 - Sets the icon associated with the session. @p newTitle is the name * of the icon to use, which can be the name of any icon in the current KDE icon - * theme (eg: 'konsole', 'kate', 'folder_home')
  • + * theme (e.g., 'konsole', 'kate', 'folder_home') * * @param newTitle Specifies the new title */ diff --git a/src/plugins/grass/qtermwidget/Filter.cpp b/src/plugins/grass/qtermwidget/Filter.cpp index 8b7d22e4441..1364f1bffa6 100644 --- a/src/plugins/grass/qtermwidget/Filter.cpp +++ b/src/plugins/grass/qtermwidget/Filter.cpp @@ -459,8 +459,8 @@ void UrlFilter::HotSpot::activate(const QString& actionName) { if ( kind == StandardUrl ) { - // if the URL path does not include the protocol ( eg. "www.kde.org" ) then - // prepend http:// ( eg. "www.kde.org" --> "http://www.kde.org" ) + // if the URL path does not include the protocol ( e.g., "www.kde.org" ) then + // prepend http:// ( e.g., "www.kde.org" --> "http://www.kde.org" ) if (!url.contains(QLatin1String("://"))) { url.prepend("http://"); diff --git a/src/plugins/grass/qtermwidget/Filter.h b/src/plugins/grass/qtermwidget/Filter.h index 4c3b8ef5450..a7e69b25ffa 100644 --- a/src/plugins/grass/qtermwidget/Filter.h +++ b/src/plugins/grass/qtermwidget/Filter.h @@ -98,8 +98,8 @@ public: /** Returns the column on endLine() where the hotspot area ends */ int endColumn() const; /** - * Returns the type of the hotspot. This is usually used as a hint for views on how to represent - * the hotspot graphically. eg. Link hotspots are typically underlined when the user mouses over them + * Returns the type of the hotspot. This is usually used as a hint for views on how to represent + * the hotspot graphically. For example, Link hotspots are typically underlined when the user mouses over them */ Type type() const; /** diff --git a/src/plugins/grass/qtermwidget/KeyboardTranslator.cpp b/src/plugins/grass/qtermwidget/KeyboardTranslator.cpp index f104711d489..dfa35e093b2 100644 --- a/src/plugins/grass/qtermwidget/KeyboardTranslator.cpp +++ b/src/plugins/grass/qtermwidget/KeyboardTranslator.cpp @@ -229,7 +229,7 @@ void KeyboardTranslatorWriter::writeEntry( const KeyboardTranslator::Entry& entr // and flags are optional, if a particular modifier or state is not specified it is // assumed not to be a part of the sequence. The key sequence may contain whitespace // -// eg: "key Up+Shift : scrollLineUp" +// e.g.: "key Up+Shift : scrollLineUp" // "key Next-Shift : "\E[6~" // // (lines containing only whitespace are ignored, parseLine assumes that comments have diff --git a/src/plugins/grass/qtermwidget/KeyboardTranslator.h b/src/plugins/grass/qtermwidget/KeyboardTranslator.h index c63060d3bbf..50462feccc0 100644 --- a/src/plugins/grass/qtermwidget/KeyboardTranslator.h +++ b/src/plugins/grass/qtermwidget/KeyboardTranslator.h @@ -162,7 +162,7 @@ public: * Returns the character sequence associated with this entry, * with any non-printable characters replaced with escape sequences. * - * eg. \\E for Escape, \\t for tab, \\n for new line. + * e.g., \\E for Escape, \\t for tab, \\n for new line. * * @param expandWildCards See text() * @param modifiers See text() diff --git a/src/plugins/grass/qtermwidget/Session.cpp b/src/plugins/grass/qtermwidget/Session.cpp index 3c237cd8bbe..8ca4f594f88 100644 --- a/src/plugins/grass/qtermwidget/Session.cpp +++ b/src/plugins/grass/qtermwidget/Session.cpp @@ -295,7 +295,7 @@ void Session::run() // is not set then fall back to /bin/sh // here we expect full path. If there is no fullpath let's expect it's - // a custom shell (eg. python, etc.) available in the PATH. + // a custom shell (e.g., python, etc.) available in the PATH. if (exec.startsWith(QLatin1String("/"))) { QFile excheck(exec); @@ -371,7 +371,7 @@ void Session::runEmptyPTY() void Session::setUserTitle( int what, const QString & caption ) { - //set to true if anything is actually changed (eg. old _nameTitle != new _nameTitle ) + //set to true if anything is actually changed (e.g., old _nameTitle != new _nameTitle ) bool modified = false; // (btw: what=0 changes _userTitle and icon, what=1 only icon, what=2 only _nameTitle diff --git a/src/plugins/grass/qtermwidget/Session.h b/src/plugins/grass/qtermwidget/Session.h index 5cdae552dca..396a1d0d038 100644 --- a/src/plugins/grass/qtermwidget/Session.h +++ b/src/plugins/grass/qtermwidget/Session.h @@ -162,9 +162,9 @@ public: * Sets the format used by this session for tab titles. * * @param context The context whoose format should be set. - * @param format The tab title format. This may be a mixture + * @param format The tab title format. This may be a mixture * of plain text and dynamic elements denoted by a '%' character - * followed by a letter. (eg. %d for directory). The dynamic + * followed by a letter (e.g., %d for directory). The dynamic * elements available depend on the @p context */ void setTabTitleFormat(TabTitleContext context , const QString & format); diff --git a/src/plugins/grass/qtermwidget/ShellCommand.h b/src/plugins/grass/qtermwidget/ShellCommand.h index 3a5804aca1e..419503afecd 100644 --- a/src/plugins/grass/qtermwidget/ShellCommand.h +++ b/src/plugins/grass/qtermwidget/ShellCommand.h @@ -33,8 +33,8 @@ namespace Konsole { * ShellCommand can be used to: * *