Skip to content

Commit

Permalink
More fixes to build against latest QGIS 3.35
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Feb 7, 2024
1 parent d687869 commit 3855fbf
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
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

1 comment on commit 3855fbf

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.