Skip to content

Commit

Permalink
Merge branch 'master' into enhancement/measurementTool
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Oct 14, 2024
2 parents 8a6e67b + a066b22 commit cf05463
Show file tree
Hide file tree
Showing 24 changed files with 195 additions and 312 deletions.
4 changes: 2 additions & 2 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "<p>Mergin Maps mobile app is a QGIS powered app for Android and iOS devices.</p>",
"license": "GPLv3",
"title": "Mergin Maps mobile app",
"version": "2024.5.0",
"version": "2024.4.1",
"upload_type": "software",
"publication_date": "2022-02-24",
"creators": [
Expand Down Expand Up @@ -39,7 +39,7 @@
"related_identifiers": [
{
"scheme": "url",
"identifier": "https://github.com/MerginMaps/mobile/tree/2024.5.0",
"identifier": "https://github.com/MerginMaps/mobile/tree/2024.4.1",
"relation": "isSupplementTo"
},
{
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cff-version: 2024.5.0
cff-version: 2024.4.1
message: "If you use this software, please cite it as below."
authors:
- family-names: "Martin"
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ cmake_minimum_required(VERSION 3.22)

# TODO automatically change with the scripts/update version script
set(MM_VERSION_MAJOR "2024")
set(MM_VERSION_MINOR "5")
set(MM_VERSION_PATCH "0")
set(MM_VERSION_MINOR "4")
set(MM_VERSION_PATCH "1")
set(QT_VERSION_DEFAULT "6.6.3")

# Note: we cannot set this for non-android build, since CMake will start looking for
Expand Down
2 changes: 0 additions & 2 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ set(MM_SRCS
compass.cpp
featurelayerpair.cpp
featuresmodel.cpp
featuresproxymodel.cpp
fieldsmodel.cpp
guidelinecontroller.cpp
identifykit.cpp
Expand Down Expand Up @@ -138,7 +137,6 @@ set(MM_HDRS
enumhelper.h
featurelayerpair.h
featuresmodel.h
featuresproxymodel.h
fieldsmodel.h
guidelinecontroller.h
identifykit.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package uk.co.lutraconsulting;

import android.util.Log;
import android.os.Build;

import android.content.Intent;
import android.content.Context;
Expand Down Expand Up @@ -46,7 +47,12 @@ public void registerBroadcastReceiver( Context context ) {
intentFilter.addAction( TRACKING_ALIVE_STATUS_ACTION );

// Set this as the receiver of POSITION_UPDATE and STATUS_MESSAGE intent actions
context.registerReceiver( serviceMessageReceiver, intentFilter );
if ( Build.VERSION.SDK_INT >= 34 ) { // Android 14 ( Upside Down Cake )
context.registerReceiver( serviceMessageReceiver, intentFilter, Context.RECEIVER_EXPORTED );
}
else {
context.registerReceiver( serviceMessageReceiver, intentFilter );
}
}

public void unregisterBroadcastReceiver( Context context ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.content.Intent;
import android.app.PendingIntent;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;

import android.app.Notification;
import android.app.NotificationChannel;
Expand Down Expand Up @@ -65,7 +66,7 @@ public void onCreate() {
File file = new File( getFilesDir(), "tracking_updates.txt" );

sendStatusUpdateMessage( "Tracking file path:" + file.getAbsolutePath() );

try {
// Open the FileOutputStream in append mode
positionUpdatesStream = new FileOutputStream(file, true);
Expand Down Expand Up @@ -166,7 +167,12 @@ public int onStartCommand( Intent intent, int flags, int startId ) {

Notification notification = notificationBuilder.build();

startForeground( SERVICE_ID, notification );
if ( Build.VERSION.SDK_INT >= 34) { // Android 14 ( Upside Down Cake )
startForeground( SERVICE_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION );
}
else {
startForeground( SERVICE_ID, notification );
}

sendStatusUpdateMessage( "Position tracking: Started the foreground service!" );

Expand Down
42 changes: 14 additions & 28 deletions app/featuresmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ QVariant FeaturesModel::data( const QModelIndex &index, int role ) const
case LayerName: return pair.layer() ? pair.layer()->name() : QString();
case LayerIcon: return pair.layer() ? InputUtils::loadIconFromLayer( pair.layer() ) : QString();
case Qt::DisplayRole: return featureTitle( pair );
case SortValue: return sortValue( pair );
}

return QVariant();
Expand Down Expand Up @@ -178,15 +177,6 @@ QVariant FeaturesModel::featureTitle( const FeatureLayerPair &featurePair ) cons
return title;
}

QVariant FeaturesModel::sortValue( const FeatureLayerPair &featurePair ) const
{
QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( featurePair.layer() ) );
context.setFeature( featurePair.feature() );
QgsExpression expr( mSortExpression );
QVariant result = expr.evaluate( &context );
return result;
}

QString FeaturesModel::searchResultPair( const FeatureLayerPair &pair ) const
{
if ( mSearchExpression.isEmpty() )
Expand Down Expand Up @@ -261,6 +251,20 @@ void FeaturesModel::setupFeatureRequest( QgsFeatureRequest &request )
request.setFilterExpression( buildSearchExpression() );
}

if ( mUseAttributeTableSortOrder && mLayer && !mLayer->attributeTableConfig().sortExpression().isEmpty() )
{
// get a context with global, project and layer scopes
// QGIS docs are not very clear, but this context is also used for evaluation of the request's 'order by' expressions too
QgsExpressionContext context = mLayer->createExpressionContext();
request.setExpressionContext( context );
request.setOrderBy( QgsFeatureRequest::OrderBy(
{
QgsFeatureRequest::OrderByClause(
mLayer->attributeTableConfig().sortExpression(),
mLayer->attributeTableConfig().sortOrder() == Qt::AscendingOrder )
} ) );
}

request.setLimit( FEATURES_LIMIT );
}

Expand Down Expand Up @@ -290,7 +294,6 @@ QHash<int, QByteArray> FeaturesModel::roleNames() const
roleNames[SearchResult] = QStringLiteral( "SearchResult" ).toLatin1();
roleNames[LayerName] = QStringLiteral( "LayerName" ).toLatin1();
roleNames[LayerIcon] = QStringLiteral( "LayerIcon" ).toLatin1();
roleNames[SortValue] = QStringLiteral( "SortValue" ).toLatin1();
return roleNames;
}

Expand Down Expand Up @@ -363,7 +366,6 @@ void FeaturesModel::setLayer( QgsVectorLayer *newLayer )
}

mLayer = newLayer;
setupSorting();
emit layerChanged( mLayer );

if ( mLayer )
Expand All @@ -384,19 +386,3 @@ QgsVectorLayer *FeaturesModel::layer() const
{
return mLayer;
}

void FeaturesModel::setupSorting()
{
mSortExpression = mLayer ? mLayer->attributeTableConfig().sortExpression() : QString();
mSortOrder = mLayer ? mLayer->attributeTableConfig().sortOrder() : Qt::AscendingOrder;
}

bool FeaturesModel::sortingEnabled() const
{
return !mSortExpression.isEmpty();
}

Qt::SortOrder FeaturesModel::sortOrder() const
{
return mSortOrder;
}
22 changes: 6 additions & 16 deletions app/featuresmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class FeaturesModel : public QAbstractListModel
// Name of the property is intentionally `count` so that it matches ListModel's count property
Q_PROPERTY( int count READ count NOTIFY countChanged )

// Returns if the model should be sorted according to the layer's attribute table configuration sort order
Q_PROPERTY( bool useAttributeTableSortOrder MEMBER mUseAttributeTableSortOrder )

public:

enum ModelRoles
Expand All @@ -64,7 +67,6 @@ class FeaturesModel : public QAbstractListModel
SearchResult, // pair of attribute and its value by which the feature was found, empty if search expression is empty
LayerName,
LayerIcon,
SortValue,
};
Q_ENUM( ModelRoles );

Expand Down Expand Up @@ -118,15 +120,6 @@ class FeaturesModel : public QAbstractListModel

int layerFeaturesCount() const;

//! Populates the sort expression and sort order for the model
virtual void setupSorting();

//! Returns true if there is a sort expression set for the model
bool sortingEnabled() const;

//! Returns the order in witch the model should be sorted
Qt::SortOrder sortOrder() const;

signals:

void featuresLimitChanged( int featuresLimit );
Expand All @@ -149,9 +142,6 @@ class FeaturesModel : public QAbstractListModel

virtual QVariant featureTitle( const FeatureLayerPair &featurePair ) const;

QString mSortExpression;
Qt::SortOrder mSortOrder = Qt::AscendingOrder;

private slots:
void onFutureFinished();

Expand All @@ -164,9 +154,6 @@ class FeaturesModel : public QAbstractListModel
//! Returns found attribute and its value from search expression for feature
QString searchResultPair( const FeatureLayerPair &feat ) const;

//! Evaluates the sort expression and returns the value used for this feature when sorting the model
QVariant sortValue( const FeatureLayerPair &featurePair ) const;

const int FEATURES_LIMIT = 10000; //!< Number of maximum features loaded from layer

FeatureLayerPairs mFeatures;
Expand All @@ -176,6 +163,9 @@ class FeaturesModel : public QAbstractListModel
QAtomicInt mNextSearchId = 0;
QFutureWatcher<QgsFeatureList> mSearchResultWatcher;
bool mFetchingResults = false;
bool mUseAttributeTableSortOrder = false;

friend class TestModels;
};

#endif // FEATURESMODEL_H
48 changes: 0 additions & 48 deletions app/featuresproxymodel.cpp

This file was deleted.

47 changes: 0 additions & 47 deletions app/featuresproxymodel.h

This file was deleted.

8 changes: 4 additions & 4 deletions app/i18n/input_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<context>
<name>FeaturesModel</name>
<message>
<location filename="../featuresmodel.cpp" line="165"/>
<location filename="../featuresmodel.cpp" line="164"/>
<source>Unknown title</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -735,7 +735,7 @@ Won&apos;t be added to the project.</source>
<context>
<name>MMFeaturesListPage</name>
<message>
<location filename="../qml/layers/MMFeaturesListPage.qml" line="96"/>
<location filename="../qml/layers/MMFeaturesListPage.qml" line="94"/>
<source>Add feature</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -2791,12 +2791,12 @@ only allows up to %1 downloaded projects.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../main.cpp" line="539"/>
<location filename="../main.cpp" line="537"/>
<source>Report submitted. Please contact us on %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../main.cpp" line="544"/>
<location filename="../main.cpp" line="542"/>
<source>Failed to submit report. Please check your internet connection.</source>
<translation type="unfinished"></translation>
</message>
Expand Down
Binary file modified app/i18n/input_hu.qm
Binary file not shown.
Binary file modified app/i18n/input_sl.qm
Binary file not shown.
Loading

0 comments on commit cf05463

Please sign in to comment.