Skip to content

Commit

Permalink
Rename PositioningModel to PositioningInformationModel.
Browse files Browse the repository at this point in the history
 because PositioningModel is a bit generic.
  • Loading branch information
mohsenD98 committed Sep 1, 2024
1 parent 6b90761 commit ef1bb47
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set(QFIELD_CORE_SRCS
positioning/positioning.cpp
positioning/positioningdevicemodel.cpp
positioning/geofencer.cpp
positioning/positioningmodel.cpp
positioning/positioninginformationmodel.cpp
processing/processingalgorithm.cpp
processing/processingalgorithmparametersmodel.cpp
processing/processingalgorithmsmodel.cpp
Expand Down Expand Up @@ -153,7 +153,7 @@ set(QFIELD_CORE_HDRS
positioning/tcpreceiver.h
positioning/udpreceiver.h
positioning/geofencer.h
positioning/positioningmodel.h
positioning/positioninginformationmodel.h
processing/processingalgorithm.h
processing/processingalgorithmparametersmodel.h
processing/processingalgorithmsmodel.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#include "coordinatereferencesystemutils.h"
#include "geometryutils.h"
#include "positioningmodel.h"
#include "positioninginformationmodel.h"

#include <QVariant>
#include <qgsunittypes.h>

PositioningModel::PositioningModel( QObject *parent )
PositioningInformationModel::PositioningInformationModel( QObject *parent )
: QStandardItemModel( parent )
{
connect( this, &QStandardItemModel::dataChanged, this, &PositioningModel::onDataChanged );
connect( this, &QStandardItemModel::dataChanged, this, &PositioningInformationModel::onDataChanged );
}

void PositioningModel::setupConnections()
void PositioningInformationModel::setupConnections()
{
connect( mPositioningSource, &Positioning::positionInformationChanged, this, &PositioningModel::refreshData );
connect( mPositioningSource, &Positioning::positionInformationChanged, this, &PositioningInformationModel::refreshData );
}

void PositioningModel::refreshData()
void PositioningInformationModel::refreshData()
{
if ( !mPositioningSource )
{
Expand Down Expand Up @@ -57,7 +57,7 @@ void PositioningModel::refreshData()
}
}

void PositioningModel::getCoordinateLabels( QString &coord1Label, QString &coord2Label, bool coordinatesIsXY, bool isGeographic )
void PositioningInformationModel::getCoordinateLabels( QString &coord1Label, QString &coord2Label, bool coordinatesIsXY, bool isGeographic )
{
if ( isGeographic )
{
Expand All @@ -71,7 +71,7 @@ void PositioningModel::getCoordinateLabels( QString &coord1Label, QString &coord
}
}

void PositioningModel::getCoordinateValues( QString &coord1Value, QString &coord2Value, const QgsPoint &coordinates, bool coordinatesIsXY, bool isGeographic )
void PositioningInformationModel::getCoordinateValues( QString &coord1Value, QString &coord2Value, const QgsPoint &coordinates, bool coordinatesIsXY, bool isGeographic )
{
if ( coordinatesIsXY )
{
Expand Down Expand Up @@ -99,7 +99,7 @@ void PositioningModel::getCoordinateValues( QString &coord1Value, QString &coord
}
}

QString PositioningModel::getAltitude( double distanceUnitFactor, const QString &distanceUnitAbbreviation )
QString PositioningInformationModel::getAltitude( double distanceUnitFactor, const QString &distanceUnitAbbreviation )
{
if ( positioningSource()->positionInformation().elevationValid() )
{
Expand Down Expand Up @@ -127,22 +127,22 @@ QString PositioningModel::getAltitude( double distanceUnitFactor, const QString
return tr( "N/A" );
}

QString PositioningModel::getSpeed()
QString PositioningInformationModel::getSpeed()
{
return positioningSource()->positionInformation().speedValid() ? QLocale::system().toString( positioningSource()->positionInformation().speed(), 'f', 3 ) + " m/s" : tr( "N/A" );
}

QString PositioningModel::getHorizontalAccuracy( double distanceUnitFactor, const QString &distanceUnitAbbreviation )
QString PositioningInformationModel::getHorizontalAccuracy( double distanceUnitFactor, const QString &distanceUnitAbbreviation )
{
return positioningSource()->positionInformation().haccValid() ? QLocale::system().toString( positioningSource()->positionInformation().hacc() * distanceUnitFactor, 'f', 3 ) + ' ' + distanceUnitAbbreviation : tr( "N/A" );
}

QString PositioningModel::getVerticalAccuracy( double distanceUnitFactor, const QString &distanceUnitAbbreviation )
QString PositioningInformationModel::getVerticalAccuracy( double distanceUnitFactor, const QString &distanceUnitAbbreviation )
{
return positioningSource()->positionInformation().vaccValid() ? QLocale::system().toString( positioningSource()->positionInformation().vacc() * distanceUnitFactor, 'f', 3 ) + ' ' + distanceUnitAbbreviation : tr( "N/A" );
}

void PositioningModel::updateInfo( const QString &name, const QVariant &value )
void PositioningInformationModel::updateInfo( const QString &name, const QVariant &value )
{
for ( int row = 0; row < rowCount(); ++row )
{
Expand All @@ -161,7 +161,7 @@ void PositioningModel::updateInfo( const QString &name, const QVariant &value )
}


bool PositioningModel::setData( const QModelIndex &index, const QVariant &value, int role )
bool PositioningInformationModel::setData( const QModelIndex &index, const QVariant &value, int role )
{
QStandardItem *rowItem = item( index.row() );
if ( !rowItem )
Expand Down Expand Up @@ -197,65 +197,65 @@ bool PositioningModel::setData( const QModelIndex &index, const QVariant &value,
return false;
}

QHash<int, QByteArray> PositioningModel::roleNames() const
QHash<int, QByteArray> PositioningInformationModel::roleNames() const
{
QHash<int, QByteArray> names = QStandardItemModel::roleNames();
names[NameRole] = "Name";
names[ValueRole] = "Value";
return names;
}

void PositioningModel::onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles )
void PositioningInformationModel::onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles )
{
Q_UNUSED( bottomRight )
Q_UNUSED( roles )
}

Positioning *PositioningModel::positioningSource() const
Positioning *PositioningInformationModel::positioningSource() const
{
return mPositioningSource;
}

void PositioningModel::setPositioningSource( Positioning *newPositioningSource )
void PositioningInformationModel::setPositioningSource( Positioning *newPositioningSource )
{
if ( mPositioningSource == newPositioningSource )
return;
mPositioningSource = newPositioningSource;
emit positioningSourceChanged();
}

double PositioningModel::antennaHeight() const
double PositioningInformationModel::antennaHeight() const
{
return mAntennaHeight;
}

void PositioningModel::setAntennaHeight( double newAntennaHeight )
void PositioningInformationModel::setAntennaHeight( double newAntennaHeight )
{
if ( qFuzzyCompare( mAntennaHeight, newAntennaHeight ) )
return;
mAntennaHeight = newAntennaHeight;
emit antennaHeightChanged();
}

Qgis::DistanceUnit PositioningModel::distanceUnits() const
Qgis::DistanceUnit PositioningInformationModel::distanceUnits() const
{
return mDistanceUnits;
}

void PositioningModel::setDistanceUnits( Qgis::DistanceUnit newDistanceUnits )
void PositioningInformationModel::setDistanceUnits( Qgis::DistanceUnit newDistanceUnits )
{
if ( mDistanceUnits == newDistanceUnits )
return;
mDistanceUnits = newDistanceUnits;
emit distanceUnitsChanged();
}

QgsCoordinateReferenceSystem PositioningModel::coordinateDisplayCrs() const
QgsCoordinateReferenceSystem PositioningInformationModel::coordinateDisplayCrs() const
{
return mCoordinateDisplayCrs;
}

void PositioningModel::setCoordinateDisplayCrs( const QgsCoordinateReferenceSystem &newCoordinateDisplayCrs )
void PositioningInformationModel::setCoordinateDisplayCrs( const QgsCoordinateReferenceSystem &newCoordinateDisplayCrs )
{
if ( mCoordinateDisplayCrs == newCoordinateDisplayCrs )
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QObject>
#include <QStandardItemModel>

class PositioningModel : public QStandardItemModel
class PositioningInformationModel : public QStandardItemModel
{
Q_OBJECT

Expand All @@ -22,7 +22,7 @@ class PositioningModel : public QStandardItemModel
ValueRole = Qt::UserRole + 1,
};

PositioningModel( QObject *parent = nullptr );
PositioningInformationModel( QObject *parent = nullptr );

bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
QHash<int, QByteArray> roleNames() const override;
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgismobileapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
#include "platformutilities.h"
#include "positioning.h"
#include "positioningdevicemodel.h"
#include "positioningmodel.h"
#include "positioninginformationmodel.h"
#include "positioningutils.h"
#include "printlayoutlistmodel.h"
#include "processingalgorithm.h"
Expand Down Expand Up @@ -503,7 +503,7 @@ void QgisMobileapp::initDeclarative( QQmlEngine *engine )
qmlRegisterType<Navigation>( "org.qfield", 1, 0, "Navigation" );
qmlRegisterType<NavigationModel>( "org.qfield", 1, 0, "NavigationModel" );
qmlRegisterType<Positioning>( "org.qfield", 1, 0, "Positioning" );
qmlRegisterType<PositioningModel>( "org.qfield", 1, 0, "PositioningModel" );
qmlRegisterType<PositioningInformationModel>( "org.qfield", 1, 0, "PositioningInformationModel" );
qmlRegisterType<PositioningDeviceModel>( "org.qfield", 1, 0, "PositioningDeviceModel" );
qmlRegisterType<AudioRecorder>( "org.qfield", 1, 0, "AudioRecorder" );
qmlRegisterType<BarcodeDecoder>( "org.qfield", 1, 0, "BarcodeDecoder" );
Expand Down
10 changes: 5 additions & 5 deletions src/qml/PositioningInformationView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import Theme
Rectangle {
id: positioningInformationView

property alias positionSource: positioningModel.positioningSource
property alias antennaHeight: positioningModel.antennaHeight
property alias positionSource: positioningInformationModel.positioningSource
property alias antennaHeight: positioningInformationModel.antennaHeight

property color backgroundColor: "transparent"
property color alternateBackgroundColor: Theme.positionBackgroundColor
Expand All @@ -28,8 +28,8 @@ Rectangle {
readonly property real numberOfColumns: parent.width / cellWidth

flow: GridView.FlowTopToBottom
model: PositioningModel {
id: positioningModel
model: PositioningInformationModel {
id: positioningInformationModel
distanceUnits: projectInfo.distanceUnits
coordinateDisplayCrs: projectInfo.coordinateDisplayCrs
}
Expand All @@ -49,7 +49,7 @@ Rectangle {
ScrollBar.vertical: QfScrollBar {
}
Component.onCompleted: {
positioningModel.setupConnections();
positioningInformationModel.setupConnections();
}
delegate: Rectangle {
readonly property real currentColumn: parseInt(index / (grid.count / grid.numberOfColumns))
Expand Down

0 comments on commit ef1bb47

Please sign in to comment.