Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fixes to build against latest QGIS 3.35 #5013

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/core/bookmarkmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,44 @@ QVariant BookmarkModel::data( const QModelIndex &index, int role ) const
switch ( role )
{
case BookmarkModel::BookmarkId:
#if _QGIS_VERSION_INT >= 33500
return mModel->data( sourceIndex, static_cast<int>( QgsBookmarkManagerModel::CustomRole::Id ) );
#else
return mModel->data( sourceIndex, QgsBookmarkManagerModel::RoleId );
#endif

case BookmarkModel::BookmarkName:
#if _QGIS_VERSION_INT >= 33500
return mModel->data( sourceIndex, static_cast<int>( QgsBookmarkManagerModel::CustomRole::Name ) );
#else
return mModel->data( sourceIndex, QgsBookmarkManagerModel::RoleName );
#endif

case BookmarkModel::BookmarkGroup:
#if _QGIS_VERSION_INT >= 33500
return mModel->data( sourceIndex, static_cast<int>( QgsBookmarkManagerModel::CustomRole::Group ) );
#else
return mModel->data( sourceIndex, QgsBookmarkManagerModel::RoleGroup );
#endif

case BookmarkModel::BookmarkPoint:
{
#if _QGIS_VERSION_INT >= 33500
QgsReferencedRectangle rect = mModel->data( sourceIndex, static_cast<int>( QgsBookmarkManagerModel::CustomRole::Extent ) ).value<QgsReferencedRectangle>();
#else
QgsReferencedRectangle rect = mModel->data( sourceIndex, QgsBookmarkManagerModel::RoleExtent ).value<QgsReferencedRectangle>();
#endif
QgsGeometry geom( new QgsPoint( rect.center() ) );
return geom;
}

case BookmarkModel::BookmarkCrs:
{
#if _QGIS_VERSION_INT >= 33500
QgsReferencedRectangle rect = mModel->data( sourceIndex, static_cast<int>( QgsBookmarkManagerModel::CustomRole::Extent ) ).value<QgsReferencedRectangle>();
#else
QgsReferencedRectangle rect = mModel->data( sourceIndex, QgsBookmarkManagerModel::RoleExtent ).value<QgsReferencedRectangle>();
#endif
return rect.crs();
}

Expand Down Expand Up @@ -96,7 +116,11 @@ void BookmarkModel::setExtentFromBookmark( const QModelIndex &index )
if ( !sourceIndex.isValid() || !mMapSettings )
return;

#if _QGIS_VERSION_INT >= 33500
QgsReferencedRectangle rect = mModel->data( sourceIndex, static_cast<int>( QgsBookmarkManagerModel::CustomRole::Extent ) ).value<QgsReferencedRectangle>();
#else
QgsReferencedRectangle rect = mModel->data( sourceIndex, QgsBookmarkManagerModel::RoleExtent ).value<QgsReferencedRectangle>();
#endif

QgsCoordinateTransform transform( rect.crs(), mMapSettings->destinationCrs(), QgsProject::instance()->transformContext() );
QgsRectangle transformedRect;
Expand Down
8 changes: 6 additions & 2 deletions src/core/layertreemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,12 @@ QVariant FlatLayerTreeModelBase::data( const QModelIndex &index, int role ) cons
if ( layer && layer->renderer() )
{
bool ok = false;
return layer->renderer()->legendKeyToExpression( symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString(),
layer, ok );
#if _QGIS_VERSION_INT >= 33500
const QString ruleKey = symbolNode->data( static_cast<int>( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString();
#else
const QString ruleKey = symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString();
#endif
return layer->renderer()->legendKeyToExpression( ruleKey, layer, ok );
}
}
return QString();
Expand Down
5 changes: 4 additions & 1 deletion src/core/locator/locatormodelsuperbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ LocatorActionsModel *LocatorModelSuperBridge::contextMenuActionsModel( const int
const QModelIndex index = proxyModel()->index( row, 0 );
if ( !index.isValid() )
return nullptr;

#if _QGIS_VERSION_INT >= 33500
const QList<QgsLocatorResult::ResultAction> actions = proxyModel()->data( index, static_cast<int>( QgsLocatorModel::CustomRole::ResultActions ) ).value<QList<QgsLocatorResult::ResultAction>>();
#else
const QList<QgsLocatorResult::ResultAction> actions = proxyModel()->data( index, QgsLocatorModel::ResultActionsRole ).value<QList<QgsLocatorResult::ResultAction>>();
#endif
int r = 0;
LocatorActionsModel *model = new LocatorActionsModel( static_cast<int>( actions.count() ), 1 );
for ( auto action : actions )
Expand Down
13 changes: 13 additions & 0 deletions src/core/sensorlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,21 @@ SensorListModel::SensorListModel( QObject *parent )
QHash<int, QByteArray> SensorListModel::roleNames() const
{
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
#if _QGIS_VERSION_INT >= 33500
roles[static_cast<int>( QgsSensorModel::CustomRole::SensorId )] = "SensorId";
roles[static_cast<int>( QgsSensorModel::CustomRole::SensorType )] = "SensorType";
roles[static_cast<int>( QgsSensorModel::CustomRole::SensorName )] = "SensorName";
roles[static_cast<int>( QgsSensorModel::CustomRole::SensorStatus )] = "SensorStatus";
roles[static_cast<int>( QgsSensorModel::CustomRole::SensorLastValue )] = "SensorLastValue";
roles[static_cast<int>( QgsSensorModel::CustomRole::SensorLastTimestamp )] = "SensorLastTimestamp";
#else
roles[QgsSensorModel::SensorId] = "SensorId";
roles[QgsSensorModel::SensorType] = "SensorType";
roles[QgsSensorModel::SensorName] = "SensorName";
roles[QgsSensorModel::SensorStatus] = "SensorStatus";
roles[QgsSensorModel::SensorLastValue] = "SensorLastValue";
roles[QgsSensorModel::SensorLastTimestamp] = "SensorLastTimestamp";
#endif
return roles;
}

Expand Down Expand Up @@ -83,7 +92,11 @@ bool SensorListModel::filterAcceptsRow( int source_row, const QModelIndex &sourc
{
if ( mShowConnectedOnly )
{
#if _QGIS_VERSION_INT >= 33500
return mSensorModel->data( mSensorModel->index( source_row, 0 ), static_cast<int>( QgsSensorModel::CustomRole::SensorStatus ) ).value<Qgis::DeviceConnectionStatus>() == Qgis::DeviceConnectionStatus::Connected;
#else
return mSensorModel->data( mSensorModel->index( source_row, 0 ), QgsSensorModel::SensorStatus ).value<Qgis::DeviceConnectionStatus>() == Qgis::DeviceConnectionStatus::Connected;
#endif
}

return true;
Expand Down
Loading