Compare commits

...

16 Commits

Author SHA1 Message Date
Stefanos Natsis
1ed3db1067
Merge 09ce65b93f4b8f43343ad1e9d512849b255e6487 into 74549aad26c3358101e88477d9dfa1caae013d72 2025-07-01 13:43:05 +03:00
Juergen E. Fischer
74549aad26 Reapply "Allow free naming of project properties (#60855)"
This reverts commit fb11239112adfc321b3bbacbb20da888a7a37c23.
2025-07-01 09:08:44 +00:00
Juergen E. Fischer
eac401c009 if a plugin supports qt6 it should also support QGIS4 (fixes #62359) 2025-07-01 09:07:26 +00:00
Loïc Bartoletti
1f0166d35e
Merge pull request #62365 from benoitdm-oslandia/fix/cgibin_dir
fix: update default cgi-bin installation paths according to OS
2025-07-01 07:26:25 +02:00
Loïc Bartoletti
ada589bb1d
Merge pull request #62052 from martin-s42/visitPointsByRegularDistance-segfault-fix
fix segfault due to calling qgsDoubleNear with tollerance that can ne…
2025-07-01 06:59:03 +02:00
Alexander Bruy
08dd318614
Merge pull request #62463 from qgis/m-kuhn-patch-2
Add qtimageformats
2025-06-30 12:19:41 +01:00
Matthias Kuhn
89dbd40b8f
Add qtimageformats 2025-06-29 13:02:03 +02:00
bdm-oslandia
b1c8ef3265 fixup! fix: update default cgi-bin installation paths according to OS 2025-06-27 09:35:48 +02:00
uclaros
09ce65b93f fix test 2025-06-26 14:34:21 +03:00
uclaros
8d122f0778 Add tests 2025-06-26 12:10:12 +03:00
uclaros
79a76da7d9 Merge branch 'master' into fix-maptool-shape-not-enough-points 2025-06-25 17:40:05 +03:00
bdm-oslandia
f4cf09d4b0 fixup! fix: update default cgi-bin installation paths according to OS 2025-06-25 08:29:52 +02:00
bdm-oslandia
9db58e3726 fixup! fix: update default cgi-bin installation paths according to OS 2025-06-24 17:37:57 +02:00
bdm-oslandia
551aa20f20 fix: update default cgi-bin installation paths according to OS 2025-06-23 10:44:49 +02:00
uclaros
68dbf86a59 Don't let shape tool finish prematurely 2025-06-19 18:19:19 +03:00
Martin Siegert
a156c43f7b
fix segfault due to calling qgsDoubleNear with tollerance that can never been reached
see issue #60772: function interpolatePoint in qgsabstractprofilesurfacegenerator.cpp:157 can return a nullpointer causing a segfault because qgsDoubleNear in visitPointsByRegularDistance in qgslinestring.cpp is called with a tolerance that is too small so that qgsDoubleNear always returns false. Solution: scale epsilon by the size of the numbers to be compared.
2025-05-29 13:37:03 -07:00
29 changed files with 576 additions and 138 deletions

View File

@ -979,7 +979,31 @@ if (WITH_CORE)
else()
# UNIX
set (DEFAULT_BIN_SUBDIR bin)
set (DEFAULT_CGIBIN_SUBDIR bin)
# From https://www.cyberciti.biz/faq/how-do-i-find-the-url-for-my-cgi-bin/
execute_process(COMMAND lsb_release -a OUTPUT_VARIABLE LSB_RELEASE_A)
if(EXISTS "/etc/fedora-release")
# in /var/www/cgi-bin
set (DEFAULT_CGIBIN_SUBDIR www/cgi-bin)
elseif (${CMAKE_HOST_SYSTEM_NAME} MATCHES "FreeBSD")
# in /usr/local/www/cgi-bin/
set (DEFAULT_CGIBIN_SUBDIR www/cgi-bin)
elseif (${CMAKE_HOST_SYSTEM_NAME} MATCHES "BSD")
# in /usr/local/libexec/cgi-bin/
set (DEFAULT_CGIBIN_SUBDIR libexec/cgi-bin)
elseif ("${LSB_RELEASE_A}" MATCHES "Ubuntu" OR "${LSB_RELEASE_A}" MATCHES "Debian" OR "${LSB_RELEASE_A}" MATCHES "Mint")
# in /usr/lib/cgi-bin/
set (DEFAULT_CGIBIN_SUBDIR lib/cgi-bin)
else()
# others: Red Hat/CentOS/Rocky/Alma Linux
# in /var/www/cgi-bin/
set (DEFAULT_CGIBIN_SUBDIR www/cgi-bin)
endif()
set (DEFAULT_LIB_SUBDIR lib${LIB_SUFFIX})
set (DEFAULT_DATA_SUBDIR share/qgis)
set (DEFAULT_LIBEXEC_SUBDIR lib${LIB_SUFFIX}/qgis)

View File

@ -659,6 +659,9 @@ class Repositories(QObject):
.strip()
)
if not qgisMaximumVersion:
if qgisMinimumVersion[0] == "3" and supports_qt6:
qgisMaximumVersion = "4.99"
else:
qgisMaximumVersion = qgisMinimumVersion[0] + ".99"
# if compatible, add the plugin to the list
if not pluginNodes.item(i).firstChildElement(
@ -845,6 +848,9 @@ class Plugins(QObject):
qgisMinimumVersion = "0"
qgisMaximumVersion = pluginMetadata("qgisMaximumVersion").strip()
if not qgisMaximumVersion:
if qgisMinimumVersion[0] == "3" and supports_qt6:
qgisMaximumVersion = "4.99"
else:
qgisMaximumVersion = qgisMinimumVersion[0] + ".99"
# if compatible, add the plugin to the list
if not isCompatible(

View File

@ -63,6 +63,9 @@ bool QgsMapToolShapeCircle2Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e, Q
}
else if ( e->button() == Qt::RightButton )
{
if ( mCircle.isEmpty() )
return false;
mPoints.append( mParentTool->mapPoint( *e ) );
addCircleToParentTool();
return true;

View File

@ -100,6 +100,9 @@ bool QgsMapToolShapeCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEven
}
else if ( e->button() == Qt::RightButton )
{
if ( mPoints.size() < 4 || mCircle.isEmpty() )
return false;
addCircleToParentTool();
return true;
}

View File

@ -65,6 +65,9 @@ bool QgsMapToolShapeCircle3Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e, Q
}
else if ( e->button() == Qt::RightButton )
{
if ( mCircle.isEmpty() )
return false;
mPoints.append( mParentTool->mapPoint( *e ) );
addCircleToParentTool();
return true;

View File

@ -92,6 +92,9 @@ bool QgsMapToolShapeCircle3Tangents::cadCanvasReleaseEvent( QgsMapMouseEvent *e,
}
else if ( e->button() == Qt::RightButton )
{
if ( mCircle.isEmpty() )
return false;
if ( match.isValid() && ( mPoints.size() == 4 ) )
{
match.edgePoints( p1, p2 );

View File

@ -68,6 +68,9 @@ bool QgsMapToolShapeCircleCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *
}
else if ( e->button() == Qt::RightButton )
{
if ( mCircle.isEmpty() )
return false;
mPoints.append( point );
addCircleToParentTool();
return true;

View File

@ -106,6 +106,9 @@ bool QgsMapToolShapeCircularStringRadius::cadCanvasReleaseEvent( QgsMapMouseEven
}
else if ( e->button() == Qt::RightButton )
{
if ( mPoints.size() < 3 )
return false;
if ( !( mPoints.size() % 2 ) )
mPoints.removeLast();
addCurveToParentTool();

View File

@ -68,6 +68,9 @@ bool QgsMapToolShapeEllipseCenter2Points::cadCanvasReleaseEvent( QgsMapMouseEven
}
else if ( e->button() == Qt::RightButton )
{
if ( mEllipse.isEmpty() )
return false;
addEllipseToParentTool();
return true;
}

View File

@ -68,6 +68,9 @@ bool QgsMapToolShapeEllipseCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent
}
else if ( e->button() == Qt::RightButton )
{
if ( mEllipse.isEmpty() )
return false;
addEllipseToParentTool();
return true;
}

View File

@ -74,6 +74,9 @@ bool QgsMapToolShapeEllipseExtent::cadCanvasReleaseEvent( QgsMapMouseEvent *e, Q
}
else if ( e->button() == Qt::RightButton )
{
if ( mEllipse.isEmpty() )
return false;
addEllipseToParentTool();
return true;
}

View File

@ -74,6 +74,9 @@ bool QgsMapToolShapeEllipseFoci::cadCanvasReleaseEvent( QgsMapMouseEvent *e, Qgs
}
else if ( e->button() == Qt::RightButton )
{
if ( mEllipse.isEmpty() )
return false;
addEllipseToParentTool();
return true;
}

View File

@ -115,6 +115,9 @@ bool QgsMapToolShapeRectangle3Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e
}
else if ( e->button() == Qt::RightButton )
{
if ( !mRectangle.isValid() )
return false;
addRectangleToParentTool();
return true;
}

View File

@ -70,6 +70,9 @@ bool QgsMapToolShapeRectangleCenter::cadCanvasReleaseEvent( QgsMapMouseEvent *e,
}
else if ( e->button() == Qt::RightButton )
{
if ( !mRectangle.isValid() )
return false;
mPoints.append( point );
addRectangleToParentTool();
return true;

View File

@ -68,6 +68,9 @@ bool QgsMapToolShapeRectangleExtent::cadCanvasReleaseEvent( QgsMapMouseEvent *e,
}
else if ( e->button() == Qt::RightButton )
{
if ( !mRectangle.isValid() )
return false;
mPoints.append( point );
addRectangleToParentTool();
return true;

View File

@ -78,6 +78,9 @@ bool QgsMapToolShapeRegularPolygon2Points::cadCanvasReleaseEvent( QgsMapMouseEve
}
else if ( e->button() == Qt::RightButton )
{
if ( mRegularPolygon.isEmpty() )
return false;
mPoints.append( point );
addRegularPolygonToParentTool();
return true;

View File

@ -75,6 +75,9 @@ bool QgsMapToolShapeRegularPolygonCenterCorner::cadCanvasReleaseEvent( QgsMapMou
}
else if ( e->button() == Qt::RightButton )
{
if ( mRegularPolygon.isEmpty() )
return false;
mPoints.append( point );
addRegularPolygonToParentTool();
return true;

View File

@ -77,6 +77,9 @@ bool QgsMapToolShapeRegularPolygonCenterPoint::cadCanvasReleaseEvent( QgsMapMous
}
else if ( e->button() == Qt::RightButton )
{
if ( mRegularPolygon.isEmpty() )
return false;
mPoints.append( point );
addRegularPolygonToParentTool();
return true;

View File

@ -727,19 +727,25 @@ bool QgsPluginRegistry::checkPythonPlugin( const QString &packageName )
bool QgsPluginRegistry::isPythonPluginCompatible( const QString &packageName ) const
{
#ifdef WITH_BINDINGS
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
bool supportsQgis4 = true;
const QString supportsQt6 = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "supportsQt6" ) ).trimmed();
if ( supportsQt6.compare( QLatin1String( "YES" ), Qt::CaseInsensitive ) != 0 && supportsQt6.compare( QLatin1String( "TRUE" ), Qt::CaseInsensitive ) != 0 )
{
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
if ( !getenv( "QGIS_DISABLE_SUPPORTS_QT6_CHECK" ) )
{
return false;
}
}
#endif
supportsQgis4 = false;
}
const QString minVersion = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "qgisMinimumVersion" ) );
// try to read qgisMaximumVersion. Note checkQgisVersion can cope with "__error__" value.
const QString maxVersion = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "qgisMaximumVersion" ) );
QString maxVersion = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "qgisMaximumVersion" ) );
if ( maxVersion == QLatin1String( "__error__" ) && minVersion.startsWith( QLatin1String( "3." ) ) && supportsQgis4 )
{
maxVersion = QLatin1String( "4.99.0" );
}
return minVersion != QLatin1String( "__error__" ) && checkQgisVersion( minVersion, maxVersion );
#else
Q_UNUSED( packageName )

View File

@ -1532,6 +1532,7 @@ void QgsLineString::visitPointsByRegularDistance( const double distance, const s
double pZ = std::numeric_limits<double>::quiet_NaN();
double pM = std::numeric_limits<double>::quiet_NaN();
double nextPointDistance = distance;
const double eps = 4 * nextPointDistance * std::numeric_limits<double>::epsilon ();
for ( int i = 1; i < totalPoints; ++i )
{
double thisX = *x++;
@ -1540,7 +1541,7 @@ void QgsLineString::visitPointsByRegularDistance( const double distance, const s
double thisM = m ? *m++ : 0.0;
const double segmentLength = QgsGeometryUtilsBase::distance2D( thisX, thisY, prevX, prevY );
while ( nextPointDistance < distanceTraversed + segmentLength || qgsDoubleNear( nextPointDistance, distanceTraversed + segmentLength ) )
while ( nextPointDistance < distanceTraversed + segmentLength || qgsDoubleNear( nextPointDistance, distanceTraversed + segmentLength, eps ) )
{
// point falls on this segment - truncate to segment length if qgsDoubleNear test was actually > segment length
const double distanceToPoint = std::min( nextPointDistance - distanceTraversed, segmentLength );

View File

@ -116,21 +116,6 @@ QStringList makeKeyTokens_( const QString &scope, const QString &key )
// be sure to include the canonical root node
keyTokens.push_front( QStringLiteral( "properties" ) );
//check validy of keys since an invalid xml name will will be dropped upon saving the xml file. If not valid, we print a message to the console.
for ( int i = 0; i < keyTokens.size(); ++i )
{
const QString keyToken = keyTokens.at( i );
//invalid chars in XML are found at http://www.w3.org/TR/REC-xml/#NT-NameChar
//note : it seems \x10000-\xEFFFF is valid, but it when added to the regexp, a lot of unwanted characters remain
const thread_local QRegularExpression sInvalidRegexp = QRegularExpression( QStringLiteral( "([^:A-Z_a-z\\x{C0}-\\x{D6}\\x{D8}-\\x{F6}\\x{F8}-\\x{2FF}\\x{370}-\\x{37D}\\x{37F}-\\x{1FFF}\\x{200C}-\\x{200D}\\x{2070}-\\x{218F}\\x{2C00}-\\x{2FEF}\\x{3001}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFFD}\\-\\.0-9\\x{B7}\\x{0300}-\\x{036F}\\x{203F}-\\x{2040}]|^[^:A-Z_a-z\\x{C0}-\\x{D6}\\x{D8}-\\x{F6}\\x{F8}-\\x{2FF}\\x{370}-\\x{37D}\\x{37F}-\\x{1FFF}\\x{200C}-\\x{200D}\\x{2070}-\\x{218F}\\x{2C00}-\\x{2FEF}\\x{3001}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFFD}])" ) );
if ( keyToken.contains( sInvalidRegexp ) )
{
const QString errorString = QObject::tr( "Entry token invalid : '%1'. The token will not be saved to file." ).arg( keyToken );
QgsMessageLog::logMessage( errorString, QString(), Qgis::MessageLevel::Critical );
}
}
return keyTokens;
}
@ -1322,20 +1307,20 @@ void dump_( const QgsProjectPropertyKey &topQgsPropertyKey )
* scope. "layers" is a list containing three string values.
*
* \code{.xml}
* <properties>
* <fsplugin>
* <foo type="int" >42</foo>
* <baz type="int" >1</baz>
* <layers type="QStringList" >
* <properties name="properties">
* <properties name="fsplugin">
* <properties name="foo" type="int" >42</properties>
* <properties name="baz" type="int" >1</properties>
* <properties name="layers" type="QStringList">
* <value>railroad</value>
* <value>airport</value>
* </layers>
* <xyqzzy type="int" >1</xyqzzy>
* <bar type="double" >123.456</bar>
* <feature_types type="QStringList" >
* </properties>
* <properties name="xyqzzy" type="int" >1</properties>
* <properties name="bar" type="double" >123.456</properties>
* <properties name="feature_types" type="QStringList">
* <value>type</value>
* </feature_types>
* </fsplugin>
* </properties>
* </properties>
* </properties>
* \endcode
*
@ -3992,10 +3977,25 @@ bool QgsProject::createEmbeddedLayer( const QString &layerId, const QString &pro
const QDomElement propertiesElem = sProjectDocument.documentElement().firstChildElement( QStringLiteral( "properties" ) );
if ( !propertiesElem.isNull() )
{
const QDomElement absElem = propertiesElem.firstChildElement( QStringLiteral( "Paths" ) ).firstChildElement( QStringLiteral( "Absolute" ) );
if ( !absElem.isNull() )
QDomElement e = propertiesElem.firstChildElement( QStringLiteral( "Paths" ) );
if ( e.isNull() )
{
useAbsolutePaths = absElem.text().compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
e = propertiesElem.firstChildElement( QStringLiteral( "properties" ) );
while ( !e.isNull() && e.attribute( QStringLiteral( "name" ) ) != QStringLiteral( "Paths" ) )
e = e.nextSiblingElement( QStringLiteral( "properties" ) );
e = e.firstChildElement( QStringLiteral( "properties" ) );
while ( !e.isNull() && e.attribute( QStringLiteral( "name" ) ) != QStringLiteral( "Absolute" ) )
e = e.nextSiblingElement( QStringLiteral( "properties" ) );
}
else
{
e = e.firstChildElement( QStringLiteral( "Absolute" ) );
}
if ( !e.isNull() )
{
useAbsolutePaths = e.text().compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
}
}

View File

@ -236,12 +236,12 @@ bool QgsProjectPropertyValue::writeXml( QString const &nodeName,
QDomElement &keyElement,
QDomDocument &document )
{
QDomElement valueElement = document.createElement( nodeName );
QDomElement valueElement = document.createElement( QStringLiteral( "properties" ) );
// remember the type so that we can rebuild it when the project is read in
valueElement.setAttribute( QStringLiteral( "name" ), nodeName );
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 <value></value> tag.
@ -362,33 +362,41 @@ bool QgsProjectPropertyKey::readXml( const QDomNode &keyNode )
while ( i < subkeys.count() )
{
const QDomNode subkey = subkeys.item( i );
QString name;
if ( subkey.nodeName() == QStringLiteral( "properties" ) &&
subkey.hasAttributes() && // if we have attributes
subkey.isElement() && // and we're an element
subkey.toElement().hasAttribute( QStringLiteral( "name" ) ) ) // and we have a "name" attribute
name = subkey.toElement().attribute( QStringLiteral( "name" ) );
else
name = subkey.nodeName();
// if the current node is an element that has a "type" attribute,
// then we know it's a leaf node; i.e., a subkey _value_, and not
// a subkey
if ( subkeys.item( i ).hasAttributes() && // if we have attributes
subkeys.item( i ).isElement() && // and we're an element
subkeys.item( i ).toElement().hasAttribute( QStringLiteral( "type" ) ) ) // and we have a "type" attribute
if ( subkey.hasAttributes() && // if we have attributes
subkey.isElement() && // and we're an element
subkey.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 QgsProjectPropertyValue );
//
delete mProperties.take( name );
mProperties.insert( name, new QgsProjectPropertyValue );
QDomNode subkey = subkeys.item( i );
if ( !mProperties[subkeys.item( i ).nodeName()]->readXml( subkey ) )
if ( !mProperties[name]->readXml( subkey ) )
{
QgsDebugError( QStringLiteral( "unable to parse key value %1" ).arg( subkeys.item( i ).nodeName() ) );
QgsDebugError( QStringLiteral( "unable to parse key value %1" ).arg( name ) );
}
}
else // otherwise it's a subkey, so just recurse on down the remaining keys
{
addKey( subkeys.item( i ).nodeName() );
addKey( name );
QDomNode subkey = subkeys.item( i );
if ( !mProperties[subkeys.item( i ).nodeName()]->readXml( subkey ) )
if ( !mProperties[name]->readXml( subkey ) )
{
QgsDebugError( QStringLiteral( "unable to parse subkey %1" ).arg( subkeys.item( i ).nodeName() ) );
QgsDebugError( QStringLiteral( "unable to parse subkey %1" ).arg( name ) );
}
}
@ -408,7 +416,8 @@ bool QgsProjectPropertyKey::writeXml( QString const &nodeName, QDomElement &elem
// 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.
QDomElement keyElement = document.createElement( nodeName ); // Dom element for this property key
QDomElement keyElement = document.createElement( "properties" ); // Dom element for this property key
keyElement.toElement().setAttribute( QStringLiteral( "name" ), nodeName );
if ( ! mProperties.isEmpty() )
{

View File

@ -30,6 +30,8 @@
#include "qgsmaptoolshapecircle2points.h"
#include "qgsmaptoolshapecircle3points.h"
#include "qgsmaptoolshapecirclecenterpoint.h"
#include "qgsmaptoolshapecircle3tangents.h"
#include "qgsmaptoolshapecircle2tangentspoint.h"
class TestQgsMapToolCircle : public QObject
@ -45,6 +47,11 @@ class TestQgsMapToolCircle : public QObject
void testCircle_data();
void testCircle();
void testDrawCircleFrom2PointsNotEnoughPoints();
void testDrawCircleFrom3PointsNotEnoughPoints();
void testDrawCircleFromCenterPointNotEnoughPoints();
void testDrawCircleFrom3TangentsNotEnoughPoints();
void testDrawCircleFrom2TangentsNotEnoughPoints();
private:
void resetMapTool( QgsMapToolShapeMetadata *metadata );
@ -334,7 +341,6 @@ QgsFeatureId TestQgsMapToolCircle::drawCircleFromCenterPointWithDeletedVertex()
return utils.newFeatureId();
}
void TestQgsMapToolCircle::testCircle_data()
{
QTest::addColumn<QString>( "wktGeometry" );
@ -392,6 +398,107 @@ void TestQgsMapToolCircle::testCircle()
QCOMPARE( wktGeometry, wktExpected );
}
void TestQgsMapToolCircle::testDrawCircleFrom2PointsNotEnoughPoints()
{
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
mCanvas->setCurrentLayer( layer );
layer->startEditing();
const long long count = layer->featureCount();
QgsMapToolShapeCircle2PointsMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
layer->rollBack();
}
void TestQgsMapToolCircle::testDrawCircleFrom3PointsNotEnoughPoints()
{
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
mCanvas->setCurrentLayer( layer );
layer->startEditing();
const long long count = layer->featureCount();
QgsMapToolShapeCircle3PointsMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseMove( 1, 1 );
utils.mouseClick( 1, 1, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
layer->rollBack();
}
void TestQgsMapToolCircle::testDrawCircleFromCenterPointNotEnoughPoints()
{
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
mCanvas->setCurrentLayer( layer );
layer->startEditing();
const long long count = layer->featureCount();
QgsMapToolShapeCircleCenterPointMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
layer->rollBack();
}
void TestQgsMapToolCircle::testDrawCircleFrom3TangentsNotEnoughPoints()
{
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
mCanvas->setCurrentLayer( layer );
layer->startEditing();
const long long count = layer->featureCount();
QgsMapToolShapeCircle3TangentsMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 2, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
layer->rollBack();
}
void TestQgsMapToolCircle::testDrawCircleFrom2TangentsNotEnoughPoints()
{
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
mCanvas->setCurrentLayer( layer );
layer->startEditing();
const long long count = layer->featureCount();
QgsMapToolShapeCircle2TangentsPointMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 2, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
layer->rollBack();
}
QGSTEST_MAIN( TestQgsMapToolCircle )
#include "testqgsmaptoolcircle.moc"

View File

@ -41,6 +41,7 @@ class TestQgsMapToolCircularString : public QObject
void testAddCircularStringCurvePoint();
void testAddCircularStringRadius();
void testAddCircularStringRadiusWithDeletedVertex();
void testAddCircularStringRadiusNotEnoughPoints();
void testAddCircularStringAfterClassicDigitizing();
private:
@ -175,6 +176,34 @@ void TestQgsMapToolCircularString::testAddCircularStringRadiusWithDeletedVertex(
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
}
void TestQgsMapToolCircularString::testAddCircularStringRadiusNotEnoughPoints()
{
const long long count = mLayer->featureCount();
mLayer->startEditing();
QgsMapToolShapeCircularStringRadiusMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 1, 1, Qt::LeftButton );
utils.mouseMove( 2, 2 );
utils.mouseClick( 2, 2, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 1, 1, Qt::LeftButton );
utils.mouseClick( 2, 2, Qt::LeftButton );
utils.mouseMove( 1, 2 );
utils.mouseClick( 1, 2, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
mLayer->rollBack();
}
void TestQgsMapToolCircularString::testAddCircularStringAfterClassicDigitizing()
{
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 333 );

View File

@ -46,6 +46,11 @@ class TestQgsMapToolEllipse : public QObject
void testEllipse_data();
void testEllipse();
void testEllipseFromCenterAndPointNotEnoughPoints();
void testEllipseFromCenterAnd2PointsNotEnoughPoints();
void testEllipseFromExtentNotEnoughPoints();
void testEllipseFromFociNotEnoughPoints();
private:
QgisApp *mQgisApp = nullptr;
QgsMapToolCapture *mMapTool = nullptr;
@ -450,6 +455,115 @@ void TestQgsMapToolEllipse::testEllipse()
QCOMPARE( wktGeometry, wktExpected );
}
void TestQgsMapToolEllipse::testEllipseFromCenterAndPointNotEnoughPoints()
{
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
mCanvas->setCurrentLayer( layer );
layer->startEditing();
const long long count = layer->featureCount();
QgsMapToolShapeEllipseCenterPointMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
layer->rollBack();
}
void TestQgsMapToolEllipse::testEllipseFromCenterAnd2PointsNotEnoughPoints()
{
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
mCanvas->setCurrentLayer( layer );
layer->startEditing();
const long long count = layer->featureCount();
QgsMapToolShapeEllipseCenter2PointsMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseMove( 1, 1 );
utils.mouseClick( 1, 1, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseMove( 1, 1 );
utils.mouseClick( 1, 1, Qt::LeftButton );
utils.mouseClick( 1, 1, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
layer->rollBack();
}
void TestQgsMapToolEllipse::testEllipseFromExtentNotEnoughPoints()
{
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
mCanvas->setCurrentLayer( layer );
layer->startEditing();
const long long count = layer->featureCount();
QgsMapToolShapeEllipseExtentMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
layer->rollBack();
}
void TestQgsMapToolEllipse::testEllipseFromFociNotEnoughPoints()
{
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
mCanvas->setCurrentLayer( layer );
layer->startEditing();
const long long count = layer->featureCount();
QgsMapToolShapeEllipseFociMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseMove( 1, 1 );
utils.mouseClick( 1, 1, Qt::LeftButton );
utils.mouseClick( 1, 1, Qt::RightButton );
QCOMPARE( layer->featureCount(), count );
layer->rollBack();
}
QGSTEST_MAIN( TestQgsMapToolEllipse )
#include "testqgsmaptoolellipse.moc"

View File

@ -43,12 +43,16 @@ class TestQgsMapToolRectangle : public QObject
void testRectangleFromCenter();
void testRectangleFromCenterWithDeletedVertex();
void testRectangleFromCenterNotEnoughPoints();
void testRectangleFromExtent();
void testRectangleFromExtentWithDeletedVertex();
void testRectangleFromExtentNotEnoughPoints();
void testRectangleFrom3PointsDistance();
void testRectangleFrom3PointsDistanceWithDeletedVertex();
void testRectangleFrom3PointsDistanceNotEnoughPoints();
void testRectangleFrom3PointsProjected();
void testRectangleFrom3PointsProjectedWithDeletedVertex();
void testRectangleFrom3PointsProjectedNotEnoughPoints();
private:
void resetMapTool( QgsMapToolShapeMetadata *metadata );
@ -157,6 +161,27 @@ void TestQgsMapToolRectangle::testRectangleFromCenterWithDeletedVertex()
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
}
void TestQgsMapToolRectangle::testRectangleFromCenterNotEnoughPoints()
{
const long long count = mLayer->featureCount();
mLayer->startEditing();
QgsMapToolShapeRectangleCenterMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
mLayer->rollBack();
}
void TestQgsMapToolRectangle::testRectangleFromExtent()
{
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 222 );
@ -210,6 +235,27 @@ void TestQgsMapToolRectangle::testRectangleFromExtentWithDeletedVertex()
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
}
void TestQgsMapToolRectangle::testRectangleFromExtentNotEnoughPoints()
{
const long long count = mLayer->featureCount();
mLayer->startEditing();
QgsMapToolShapeRectangleExtentMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
mLayer->rollBack();
}
void TestQgsMapToolRectangle::testRectangleFrom3PointsDistance()
{
@ -268,6 +314,35 @@ void TestQgsMapToolRectangle::testRectangleFrom3PointsDistanceWithDeletedVertex(
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
}
void TestQgsMapToolRectangle::testRectangleFrom3PointsDistanceNotEnoughPoints()
{
const long long count = mLayer->featureCount();
mLayer->startEditing();
QgsMapToolShapeRectangle3PointsMetadata md( QgsMapToolShapeRectangle3PointsMetadata::CreateMode::Distance );
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseMove( 1, 1 );
utils.mouseClick( 1, 1, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 1, 1, Qt::LeftButton );
utils.mouseClick( 1, 1, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
mLayer->rollBack();
}
void TestQgsMapToolRectangle::testRectangleFrom3PointsProjected()
{
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 111 );
@ -324,5 +399,34 @@ void TestQgsMapToolRectangle::testRectangleFrom3PointsProjectedWithDeletedVertex
mLayer->rollBack();
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
}
void TestQgsMapToolRectangle::testRectangleFrom3PointsProjectedNotEnoughPoints()
{
const long long count = mLayer->featureCount();
mLayer->startEditing();
QgsMapToolShapeRectangle3PointsMetadata md( QgsMapToolShapeRectangle3PointsMetadata::CreateMode::Projected );
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseMove( 1, 1 );
utils.mouseClick( 1, 1, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 1, 1, Qt::LeftButton );
utils.mouseClick( 1, 1, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
mLayer->rollBack();
}
QGSTEST_MAIN( TestQgsMapToolRectangle )
#include "testqgsmaptoolrectangle.moc"

View File

@ -43,10 +43,13 @@ class TestQgsMapToolRegularPolygon : public QObject
void testRegularPolygonFrom2Points();
void testRegularPolygonFrom2PointsWithDeletedVertex();
void testRegularPolygonFrom2PointsNotEnoughPoints();
void testRegularPolygonFromCenterAndPoint();
void testRegularPolygonFromCenterAndPointWithDeletedVertex();
void testRegularPolygonFromCenterAndCroner();
void testRegularPolygonFromCenterAndCronerWithDeletedVertex();
void testRegularPolygonFromCenterAndPointNotEnoughPoints();
void testRegularPolygonFromCenterAndCorner();
void testRegularPolygonFromCenterAndCornerWithDeletedVertex();
void testRegularPolygonFromCenterAndCornerNotEnoughPoints();
private:
void resetMapTool( QgsMapToolShapeMetadata *metadata );
@ -150,6 +153,27 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFrom2PointsWithDeletedVerte
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
}
void TestQgsMapToolRegularPolygon::testRegularPolygonFrom2PointsNotEnoughPoints()
{
const long long count = mLayer->featureCount();
mLayer->startEditing();
QgsMapToolShapeRegularPolygon2PointsMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
mLayer->rollBack();
}
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndPoint()
{
@ -200,8 +224,29 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndPointWithDelet
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
}
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndPointNotEnoughPoints()
{
const long long count = mLayer->featureCount();
mLayer->startEditing();
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCroner()
QgsMapToolShapeRegularPolygonCenterPointMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
mLayer->rollBack();
}
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCorner()
{
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 111 );
mLayer->startEditing();
@ -224,7 +269,8 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCroner()
mLayer->rollBack();
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
}
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCronerWithDeletedVertex()
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCornerWithDeletedVertex()
{
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 111 );
mLayer->startEditing();
@ -250,6 +296,27 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCronerWithDele
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
}
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCornerNotEnoughPoints()
{
const long long count = mLayer->featureCount();
mLayer->startEditing();
QgsMapToolShapeRegularPolygonCenterCornerMetadata md;
resetMapTool( &md );
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
utils.keyClick( Qt::Key_Escape );
utils.mouseClick( 0, 0, Qt::LeftButton );
utils.mouseClick( 0, 0, Qt::RightButton );
QCOMPARE( mLayer->featureCount(), count );
mLayer->rollBack();
}
QGSTEST_MAIN( TestQgsMapToolRegularPolygon )
#include "testqgsmaptoolregularpolygon.moc"

View File

@ -65,84 +65,6 @@ class TestQgsProject(QgisTestCase):
QgisTestCase.__init__(self, methodName)
self.messageCaught = False
def test_makeKeyTokens_(self):
# see http://www.w3.org/TR/REC-xml/#d0e804 for a list of valid characters
invalidTokens = []
validTokens = []
# all test tokens will be generated by prepending or inserting characters to this token
validBase = "valid"
# some invalid characters, not allowed anywhere in a token
# note that '/' must not be added here because it is taken as a separator by makeKeyTokens_()
invalidChars = "+*,;<>|!$%()=?#\x01"
# generate the characters that are allowed at the start of a token (and at every other position)
validStartChars = ":_"
charRanges = [
(ord("a"), ord("z")),
(ord("A"), ord("Z")),
(0x00F8, 0x02FF),
(0x0370, 0x037D),
(0x037F, 0x1FFF),
(0x200C, 0x200D),
(0x2070, 0x218F),
(0x2C00, 0x2FEF),
(0x3001, 0xD7FF),
(0xF900, 0xFDCF),
(0xFDF0, 0xFFFD),
# (0x10000, 0xEFFFF), while actually valid, these are not yet accepted by makeKeyTokens_()
]
for r in charRanges:
for c in range(r[0], r[1]):
validStartChars += chr(c)
# generate the characters that are only allowed inside a token, not at the start
validInlineChars = "-.\xB7"
charRanges = [
(ord("0"), ord("9")),
(0x0300, 0x036F),
(0x203F, 0x2040),
]
for r in charRanges:
for c in range(r[0], r[1]):
validInlineChars += chr(c)
# test forbidden start characters
for c in invalidChars + validInlineChars:
invalidTokens.append(c + validBase)
# test forbidden inline characters
for c in invalidChars:
invalidTokens.append(validBase[:4] + c + validBase[4:])
# test each allowed start character
for c in validStartChars:
validTokens.append(c + validBase)
# test each allowed inline character
for c in validInlineChars:
validTokens.append(validBase[:4] + c + validBase[4:])
logger = QgsApplication.messageLog()
logger.messageReceived.connect(self.catchMessage)
prj = QgsProject.instance()
for token in validTokens:
self.messageCaught = False
prj.readEntry("test", token)
myMessage = f"valid token '{token}' not accepted"
assert not self.messageCaught, myMessage
for token in invalidTokens:
self.messageCaught = False
prj.readEntry("test", token)
myMessage = f"invalid token '{token}' accepted"
assert self.messageCaught, myMessage
logger.messageReceived.disconnect(self.catchMessage)
def catchMessage(self):
self.messageCaught = True

View File

@ -84,6 +84,7 @@
]
},
"qtdeclarative",
"qtimageformats",
"qtkeychain-qt6",
"qtlocation",
"qtquickcontrols2",