Skip to content

Commit

Permalink
Fix compilation against QGIS 3.34
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn authored and github-actions[bot] committed Oct 28, 2023
1 parent 5f86cfb commit de548ab
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/distancearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bool DistanceArea::lengthValid() const
return false;

case Qgis::GeometryType::Line:
FALLTHROUGH
[[fallthrough]];
case Qgis::GeometryType::Polygon:
return mRubberbandModel->vertexCount() >= 2;

Expand Down Expand Up @@ -184,7 +184,7 @@ bool DistanceArea::perimeterValid() const
switch ( mRubberbandModel->geometryType() )
{
case Qgis::GeometryType::Point:
FALLTHROUGH
[[fallthrough]];
case Qgis::GeometryType::Line:
return false;

Expand Down
21 changes: 21 additions & 0 deletions src/core/locator/activelayerfeatureslocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,13 @@ void ActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, cons
result.displayString = QStringLiteral( "@%1" ).arg( field );
result.group = mLayerName;
result.description = tr( "Limit the search to the field '%1'" ).arg( field );
#if _QGIS_VERSION_INT >= 33300
result.setUserData( QVariantMap( { { QStringLiteral( "type" ), QVariant::fromValue( ResultType::FieldRestriction ) },
{ QStringLiteral( "search_text" ), QStringLiteral( "%1 @%2 " ).arg( prefix(), field ) } } ) );
#else
result.userData = QVariantMap( { { QStringLiteral( "type" ), QVariant::fromValue( ResultType::FieldRestriction ) },
{ QStringLiteral( "search_text" ), QStringLiteral( "%1 @%2 " ).arg( prefix(), field ) } } );
#endif
result.score = 1;
emit resultFetched( result );
}
Expand All @@ -220,7 +225,11 @@ void ActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, cons
result.displayString = mDispExpression.evaluate( &mContext ).toString();
result.group = mLayerName;

#if _QGIS_VERSION_INT >= 33300
result.setUserData( QVariantList() << f.id() << mLayerId );
#else
result.userData = QVariantList() << f.id() << mLayerId;
#endif
result.score = static_cast<double>( searchString.length() ) / result.displayString.size();
result.actions << QgsLocatorResult::ResultAction( OpenForm, tr( "Open form" ), QStringLiteral( "ic_baseline-list_alt-24px" ) );
if ( mLayerIsSpatial )
Expand Down Expand Up @@ -274,7 +283,11 @@ void ActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, cons
continue; //not sure how this result slipped through...
result.group = mLayerName;
result.description = mDispExpression.evaluate( &mContext ).toString();
#if _QGIS_VERSION_INT >= 33300
result.setUserData( QVariantList() << f.id() << mLayerId );
#else
result.userData = QVariantList() << f.id() << mLayerId;
#endif
result.score = static_cast<double>( searchString.length() ) / result.displayString.size();
result.actions << QgsLocatorResult::ResultAction( OpenForm, tr( "Open form" ), QStringLiteral( "ic_baseline-list_alt-24px" ) );
if ( mLayerIsSpatial )
Expand All @@ -297,7 +310,11 @@ void ActiveLayerFeaturesLocatorFilter::triggerResult( const QgsLocatorResult &re

void ActiveLayerFeaturesLocatorFilter::triggerResultFromAction( const QgsLocatorResult &result, const int actionId )
{
#if _QGIS_VERSION_INT >= 33300
QVariantMap data = result.getUserData().toMap();
#else
QVariantMap data = result.userData.toMap();
#endif
switch ( data.value( QStringLiteral( "type" ) ).value<ResultType>() )
{
case ResultType::FieldRestriction:
Expand All @@ -308,7 +325,11 @@ void ActiveLayerFeaturesLocatorFilter::triggerResultFromAction( const QgsLocator

case ResultType::Feature:
{
#if _QGIS_VERSION_INT >= 33300
QVariantList dataList = result.getUserData().toList();
#else
QVariantList dataList = result.userData.toList();
#endif
QgsFeatureId fid = dataList.at( 0 ).toLongLong();
QString layerId = dataList.at( 1 ).toString();
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( QgsProject::instance()->mapLayer( layerId ) );
Expand Down
8 changes: 8 additions & 0 deletions src/core/locator/bookmarklocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ void BookmarkLocatorFilter::fetchResults( const QString &string, const QgsLocato
if ( result.score > 0 )
{
result.filter = this;
#if _QGIS_VERSION_INT >= 33300
result.setUserData( i );
#else
result.userData = i;
#endif

emit resultFetched( result );
}
Expand All @@ -64,7 +68,11 @@ void BookmarkLocatorFilter::triggerResult( const QgsLocatorResult &result )

void BookmarkLocatorFilter::triggerResultFromAction( const QgsLocatorResult &result, const int )
{
#if _QGIS_VERSION_INT >= 33300
const int row = result.getUserData().toInt();
#else
const int row = result.userData.toInt();
#endif

mLocatorBridge->bookmarks()->setExtentFromBookmark( mLocatorBridge->bookmarks()->index( row, 0 ) );

Expand Down
8 changes: 8 additions & 0 deletions src/core/locator/expressioncalculatorlocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ void ExpressionCalculatorLocatorFilter::fetchResults( const QString &string, con
QgsLocatorResult result;
result.filter = this;
result.displayString = tr( "Copy “%1” to clipboard" ).arg( resultString );
#if _QGIS_VERSION_INT >= 33300
result.setUserData( resultString );
#else
result.userData = resultString;
#endif
result.score = 1;
emit resultFetched( result );
}
Expand All @@ -72,7 +76,11 @@ void ExpressionCalculatorLocatorFilter::triggerResult( const QgsLocatorResult &r

void ExpressionCalculatorLocatorFilter::triggerResultFromAction( const QgsLocatorResult &result, const int actionId )
{
#if _QGIS_VERSION_INT >= 33300
QString resultString = result.getUserData().toString();
#else
QString resultString = result.userData.toString();
#endif

switch ( actionId )
{
Expand Down
8 changes: 8 additions & 0 deletions src/core/locator/featureslocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ void FeaturesLocatorFilter::fetchResults( const QString &string, const QgsLocato

result.displayString = preparedLayer->expression.evaluate( &( preparedLayer->context ) ).toString();

#if _QGIS_VERSION_INT >= 33300
result.setUserData( QVariantList() << f.id() << preparedLayer->layerId );
#else
result.userData = QVariantList() << f.id() << preparedLayer->layerId;
#endif
result.icon = preparedLayer->layerIcon;
result.score = static_cast<double>( string.length() ) / result.displayString.size();
result.actions << QgsLocatorResult::ResultAction( OpenForm, tr( "Open form" ), QStringLiteral( "ic_baseline-list_alt-24px" ) );
Expand Down Expand Up @@ -139,7 +143,11 @@ void FeaturesLocatorFilter::triggerResult( const QgsLocatorResult &result )

void FeaturesLocatorFilter::triggerResultFromAction( const QgsLocatorResult &result, const int actionId )
{
#if _QGIS_VERSION_INT >= 33300
QVariantList dataList = result.getUserData().toList();
#else
QVariantList dataList = result.userData.toList();
#endif
QgsFeatureId fid = dataList.at( 0 ).toLongLong();
QString layerId = dataList.at( 1 ).toString();
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( QgsProject::instance()->mapLayer( layerId ) );
Expand Down
12 changes: 12 additions & 0 deletions src/core/locator/gotolocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ void GotoLocatorFilter::fetchResults( const QString &string, const QgsLocatorCon
QgsLocatorResult result;
result.filter = this;
result.displayString = tr( "Go to %1%2 %3%4 (Map CRS, %5)" ).arg( locale.toString( firstNumber, 'g', 10 ), firstSuffix, locale.toString( secondNumber, 'g', 10 ), secondSuffix, currentCrs.userFriendlyIdentifier() );
#if _QGIS_VERSION_INT >= 33300
result.setUserData( data );
#else
result.userData = data;
#endif
result.score = 0.9;
emit resultFetched( result );
}
Expand Down Expand Up @@ -165,7 +169,11 @@ void GotoLocatorFilter::fetchResults( const QString &string, const QgsLocatorCon
QgsLocatorResult result;
result.filter = this;
result.displayString = tr( "Go to %1°N %2°E (%3)" ).arg( locale.toString( point.y(), 'g', 10 ), locale.toString( point.x(), 'g', 10 ), wgs84Crs.userFriendlyIdentifier() );
#if _QGIS_VERSION_INT >= 33300
result.setUserData( data );
#else
result.userData = data;
#endif
result.score = 1.0;
emit resultFetched( result );
}
Expand All @@ -180,7 +188,11 @@ void GotoLocatorFilter::triggerResult( const QgsLocatorResult &result )

void GotoLocatorFilter::triggerResultFromAction( const QgsLocatorResult &result, const int actionId )
{
#if _QGIS_VERSION_INT >= 33300
QVariantMap data = result.getUserData().toMap();
#else
QVariantMap data = result.userData.toMap();
#endif
QgsGeometry geom( QgsGeometry::fromPointXY( data[QStringLiteral( "point" )].value<QgsPointXY>() ) );

if ( actionId == Navigation )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qfieldcloudprojectsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ void QFieldCloudProjectsModel::projectUpload( const QString &projectId, const bo
case DeltaLocalStatus:
// delta file should be already sent!!!
Q_ASSERT( 0 );
FALLTHROUGH
[[fallthrough]];
case DeltaPendingStatus:
case DeltaBusyStatus:
// infinite retry, there should be one day, when we can get the status!
Expand Down

0 comments on commit de548ab

Please sign in to comment.