Skip to content
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
30 changes: 30 additions & 0 deletions src/core/featuremodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,36 @@ void FeatureModel::setFeatures( const QList<QgsFeature> &features )
endResetModel();
}

QVariantList FeatureModel::featuresVariant() const
{
QVariantList featuresVariant;

featuresVariant.reserve( mFeatures.size() );
for ( const QgsFeature &feature : mFeatures )
{
// Pack the custom QgsFeature object into a QVariant safely
featuresVariant.append( QVariant::fromValue( feature ) );
}

return featuresVariant;
}

void FeatureModel::setFeaturesVariant( const QVariantList &features )
{
QList<QgsFeature> featuresList;
featuresList.reserve( features.size() );

for ( const QVariant &variant : features )
{
if ( variant.canConvert<QgsFeature>() )
{
featuresList.append( variant.value<QgsFeature>() );
}
}

setFeatures( featuresList );
}

void FeatureModel::setCurrentLayer( QgsVectorLayer *layer )
{
if ( layer == mLayer )
Expand Down
6 changes: 5 additions & 1 deletion src/core/featuremodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FeatureModel : public QAbstractListModel
Q_OBJECT
Q_PROPERTY( FeatureModel::ModelModes modelMode READ modelMode WRITE setModelMode NOTIFY modelModeChanged )
Q_PROPERTY( QgsFeature feature READ feature WRITE setFeature NOTIFY featureChanged )
Q_PROPERTY( QList<QgsFeature> features READ features WRITE setFeatures NOTIFY featuresChanged )
Q_PROPERTY( QVariantList features READ featuresVariant WRITE setFeaturesVariant NOTIFY featuresChanged )
Q_PROPERTY( QgsFeature linkedParentFeature READ linkedParentFeature WRITE setLinkedParentFeature NOTIFY linkedParentFeatureChanged )
Q_PROPERTY( QgsRelation linkedRelation READ linkedRelation WRITE setLinkedRelation NOTIFY linkedRelationChanged )
Q_PROPERTY( QString linkedRelationOrderingField READ linkedRelationOrderingField WRITE setLinkedRelationOrderingField NOTIFY linkedRelationOrderingFieldChanged )
Expand Down Expand Up @@ -91,6 +91,10 @@ class FeatureModel : public QAbstractListModel

void setFeatures( const QList<QgsFeature> &features );

QVariantList featuresVariant() const;

void setFeaturesVariant( const QVariantList &features );

/**
* Return the features list for passing it around in QML
*/
Expand Down
8 changes: 4 additions & 4 deletions src/core/gridmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,11 @@ void GridModel::update()
{
if ( currentLine.intersects( topBorder, &intersectionPoint ) )
{
mAnnotations << GridAnnotation( GridAnnotation::Top, intersectionPoint, xPos );
mAnnotations << QVariant::fromValue( GridAnnotation( GridAnnotation::Top, intersectionPoint, xPos ) );
}
if ( currentLine.intersects( bottomBorder, &intersectionPoint ) )
{
mAnnotations << GridAnnotation( GridAnnotation::Bottom, intersectionPoint, xPos );
mAnnotations << QVariant::fromValue( GridAnnotation( GridAnnotation::Bottom, intersectionPoint, xPos ) );
}
}

Expand All @@ -478,11 +478,11 @@ void GridModel::update()
{
if ( currentLine.intersects( leftBorder, &intersectionPoint ) )
{
mAnnotations << GridAnnotation( GridAnnotation::Left, intersectionPoint, yPos );
mAnnotations << QVariant::fromValue( GridAnnotation( GridAnnotation::Left, intersectionPoint, yPos ) );
}
if ( currentLine.intersects( rightBorder, &intersectionPoint ) )
{
mAnnotations << GridAnnotation( GridAnnotation::Right, intersectionPoint, yPos );
mAnnotations << QVariant::fromValue( GridAnnotation( GridAnnotation::Right, intersectionPoint, yPos ) );
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/gridmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class QFIELD_CORE_EXPORT GridModel : public QObject
Q_PROPERTY( QString majorLinesPath READ majorLinesPath NOTIFY majorLinesChanged )
Q_PROPERTY( QString minorLinesPath READ minorLinesPath NOTIFY minorLinesChanged )
Q_PROPERTY( QString markersPath READ markersPath NOTIFY markersChanged )
Q_PROPERTY( QList<GridAnnotation> annotations READ annotations NOTIFY annotationsChanged )
Q_PROPERTY( QVariantList annotations READ annotations NOTIFY annotationsChanged )

Q_PROPERTY( bool autoColor READ autoColor WRITE setAutoColor NOTIFY autoColorChanged )
Q_PROPERTY( QColor majorLineColor READ majorLineColor WRITE setMajorLineColor NOTIFY majorLineColorChanged )
Expand Down Expand Up @@ -169,7 +169,7 @@ class QFIELD_CORE_EXPORT GridModel : public QObject
void setPrepareAnnotations( bool prepare );

//! Returns the grid annotations
QList<GridAnnotation> annotations() const { return mAnnotations; }
QVariantList annotations() const { return mAnnotations; }

/**
* Returns whether grid line and marker colors will be automatically assigned to
Expand Down Expand Up @@ -320,7 +320,7 @@ class QFIELD_CORE_EXPORT GridModel : public QObject
QString mMarkersPath;

bool mPrepareAnnotations = false;
QList<GridAnnotation> mAnnotations;
QVariantList mAnnotations;

bool mAutoColor = false;
QColor mMajorLineColor = QColor( 0, 0, 0, 100 );
Expand Down
15 changes: 15 additions & 0 deletions src/core/multifeaturelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,21 @@ QList<QgsFeature> MultiFeatureListModel::selectedFeatures()
return mSourceModel->selectedFeatures();
}

QVariantList MultiFeatureListModel::selectedFeaturesVariant()
{
QVariantList featuresVariant;
const QList<QgsFeature> features = mSourceModel->selectedFeatures();

featuresVariant.reserve( features.size() );
for ( const QgsFeature &feature : features )
{
// Pack the custom QgsFeature object into a QVariant safely
featuresVariant.append( QVariant::fromValue( feature ) );
}

return featuresVariant;
}

QgsVectorLayer *MultiFeatureListModel::selectedLayer()
{
return mFilterLayer.data();
Expand Down
7 changes: 6 additions & 1 deletion src/core/multifeaturelistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MultiFeatureListModel : public QSortFilterProxyModel
Q_OBJECT

Q_PROPERTY( int count READ count NOTIFY countChanged )
Q_PROPERTY( QList<QgsFeature> selectedFeatures READ selectedFeatures NOTIFY selectedCountChanged )
Q_PROPERTY( QVariantList selectedFeatures READ selectedFeaturesVariant NOTIFY selectedCountChanged )
Q_PROPERTY( QgsVectorLayer *selectedLayer READ selectedLayer NOTIFY selectedLayerChanged )
Q_PROPERTY( int selectedCount READ selectedCount NOTIFY selectedCountChanged )
Q_PROPERTY( bool canEditAttributesSelection READ canEditAttributesSelection NOTIFY selectedCountChanged )
Expand Down Expand Up @@ -175,6 +175,11 @@ class MultiFeatureListModel : public QSortFilterProxyModel
*/
QList<QgsFeature> selectedFeatures();

/**
* Returns the list of currently selected features as a QVariantList object.
*/
QVariantList selectedFeaturesVariant();

/**
* Returns the vector layer within which one or more features are currently selected
*/
Expand Down
34 changes: 32 additions & 2 deletions src/core/processing/processingalgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,36 @@ void ProcessingAlgorithm::setInPlaceFeatures( const QList<QgsFeature> &features
}
}

QVariantList ProcessingAlgorithm::inPlaceFeaturesVariant() const
{
QVariantList featuresVariant;

featuresVariant.reserve( mInPlaceFeatures.size() );
for ( const QgsFeature &feature : mInPlaceFeatures )
{
// Pack the custom QgsFeature object into a QVariant safely
featuresVariant.append( QVariant::fromValue( feature ) );
}

return featuresVariant;
}

void ProcessingAlgorithm::setInPlaceFeaturesVariant( const QVariantList &features )
{
QList<QgsFeature> featuresList;
featuresList.reserve( features.size() );

for ( const QVariant &variant : features )
{
if ( variant.canConvert<QgsFeature>() )
{
featuresList.append( variant.value<QgsFeature>() );
}
}

setInPlaceFeatures( featuresList );
}

void ProcessingAlgorithm::setParameters( const QVariantMap &parameters )
{
if ( mAlgorithmParameters == parameters )
Expand Down Expand Up @@ -205,7 +235,7 @@ bool ProcessingAlgorithm::run( bool previewMode )
{
for ( const QgsFeature &outputFeature : outputFeatures )
{
mPreviewGeometries << outputFeature.geometry();
mPreviewGeometries << QVariant::fromValue( outputFeature.geometry() );
}

emit previewGeometriesChanged();
Expand Down Expand Up @@ -296,7 +326,7 @@ bool ProcessingAlgorithm::run( bool previewMode )
{
for ( const QgsFeature &previewFeature : outputFeatures )
{
mPreviewGeometries << previewFeature.geometry();
mPreviewGeometries << QVariant::fromValue( previewFeature.geometry() );
}

emit previewGeometriesChanged();
Expand Down
18 changes: 14 additions & 4 deletions src/core/processing/processingalgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class ProcessingAlgorithm : public QObject

Q_PROPERTY( QVariantMap parameters READ parameters WRITE setParameters NOTIFY parametersChanged )
Q_PROPERTY( QgsVectorLayer *inPlaceLayer READ inPlaceLayer WRITE setInPlaceLayer NOTIFY inPlaceLayerChanged )
Q_PROPERTY( QList<QgsFeature> inPlaceFeatures READ inPlaceFeatures WRITE setInPlaceFeatures NOTIFY inPlaceFeaturesChanged )
Q_PROPERTY( QVariantList inPlaceFeatures READ inPlaceFeaturesVariant WRITE setInPlaceFeaturesVariant NOTIFY inPlaceFeaturesChanged )

Q_PROPERTY( bool preview READ preview WRITE setPreview NOTIFY previewChanged )
Q_PROPERTY( QList<QgsGeometry> previewGeometries READ previewGeometries NOTIFY previewGeometriesChanged )
Q_PROPERTY( QVariantList previewGeometries READ previewGeometries NOTIFY previewGeometriesChanged )

public:
explicit ProcessingAlgorithm( QObject *parent = nullptr );
Expand Down Expand Up @@ -98,6 +98,16 @@ class ProcessingAlgorithm : public QObject
*/
void setInPlaceFeatures( const QList<QgsFeature> &features );

/**
* Returns the vector \a layer for in-place algorithm filter as a QVariantList.
*/
QVariantList inPlaceFeaturesVariant() const;

/**
* Sets the vector \a layer for in-place algorithm filter from a QVariantList.
*/
void setInPlaceFeaturesVariant( const QVariantList &features );

/**
* Returns the algorithm parameters as a map of parameter names as keys and values.
*/
Expand All @@ -123,7 +133,7 @@ class ProcessingAlgorithm : public QObject
/**
* Returns a list of geometries previewing the algorithm result using current parameters.
*/
QList<QgsGeometry> previewGeometries() const { return mPreviewGeometries; }
QVariantList previewGeometries() const { return mPreviewGeometries; }

/**
* Executes the algorithm.
Expand Down Expand Up @@ -170,7 +180,7 @@ class ProcessingAlgorithm : public QObject
QList<QgsFeature> mInPlaceFeatures;

bool mPreview = false;
QList<QgsGeometry> mPreviewGeometries;
QVariantList mPreviewGeometries;
};

#endif // PROCESSINGALGORITHM
13 changes: 11 additions & 2 deletions src/core/qfieldcloud/qfieldcloudconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,18 @@ bool QFieldCloudConnection::isFetchingAvailableProviders() const
return mIsFetchingAvailableProviders;
}

QList<AuthenticationProvider> QFieldCloudConnection::availableProviders() const
QVariantList QFieldCloudConnection::availableProviders() const
{
return mAvailableProviders.values();
const QList<AuthenticationProvider> providers = mAvailableProviders.values();
QVariantList providersVariant;
providersVariant.reserve( providers.size() );

for ( const AuthenticationProvider &provider : providers )
{
providersVariant.append( QVariant::fromValue( provider ) );
}

return providersVariant;
}

void QFieldCloudConnection::getServerInformation()
Expand Down
4 changes: 2 additions & 2 deletions src/core/qfieldcloud/qfieldcloudconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class QFieldCloudConnection : public QObject

Q_PROPERTY( CloudUserInformation userInformation READ userInformation NOTIFY userInformationChanged )

Q_PROPERTY( QList<AuthenticationProvider> availableProviders READ availableProviders NOTIFY availableProvidersChanged )
Q_PROPERTY( QVariantList availableProviders READ availableProviders NOTIFY availableProvidersChanged )
Q_PROPERTY( bool isFetchingAvailableProviders READ isFetchingAvailableProviders NOTIFY isFetchingAvailableProvidersChanged )

Q_PROPERTY( CloudServerInformation serverInformation READ serverInformation NOTIFY serverInformationChanged )
Expand Down Expand Up @@ -175,7 +175,7 @@ class QFieldCloudConnection : public QObject
Q_INVOKABLE void getSubscriptionInformation( const QString &user );

Q_INVOKABLE void getServerInformation();
QList<AuthenticationProvider> availableProviders() const;
QVariantList availableProviders() const;
bool isFetchingAvailableProviders() const;

CloudServerInformation serverInformation() const { return mServerInformation; }
Expand Down
16 changes: 16 additions & 0 deletions src/core/trackingmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ bool TrackingModel::featureInTracking( QgsVectorLayer *layer, const QgsFeatureId
return false;
}

bool TrackingModel::featuresInTracking( QgsVectorLayer *layer, const QVariantList &features )
{
QList<QgsFeature> featuresList;

featuresList.reserve( features.size() );
for ( const QVariant &variant : features )
{
if ( variant.canConvert<QgsFeature>() )
{
featuresList.append( variant.value<QgsFeature>() );
}
}

return featuresInTracking( layer, featuresList );
}

bool TrackingModel::featuresInTracking( QgsVectorLayer *layer, const QList<QgsFeature> &features )
{
auto it = trackerIterator( layer );
Expand Down
4 changes: 3 additions & 1 deletion src/core/trackingmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class TrackingModel : public QAbstractItemModel
//! Returns TRUE if the \a featureId is attached to a vector \a layer tracking session.
Q_INVOKABLE bool featureInTracking( QgsVectorLayer *layer, QgsFeatureId featureId );
//! Returns TRUE if the list of \a features is attached to a vector \a layer tracking session.
Q_INVOKABLE bool featuresInTracking( QgsVectorLayer *layer, const QList<QgsFeature> &features );
Q_INVOKABLE bool featuresInTracking( QgsVectorLayer *layer, const QVariantList &features );
//! Returns TRUE if the list of \a features is attached to a vector \a layer tracking session.
bool featuresInTracking( QgsVectorLayer *layer, const QList<QgsFeature> &features );
//! Returns TRUE if the vector \a layer has a tracking session.
Q_INVOKABLE bool layerInTracking( QgsVectorLayer *layer ) const;
//! Returns TRUE if the vector \a layer has an active tracking session.
Expand Down
4 changes: 2 additions & 2 deletions src/qml/FeatureListForm.qml
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,8 @@ Pane {
}

onDeleteClicked: {
var selectedFeatures = featureFormList.selection.model.selectedFeatures;
var selectedFeature = selectedFeatures && selectedFeatures.length > 0 ? selectedFeatures[0] : null;
let selectedFeatures = featureFormList.selection.model.selectedFeatures;
let selectedFeature = selectedFeatures && selectedFeatures.length > 0 ? selectedFeatures[0] : null;
if (selectedFeature && featureFormList.selection.focusedLayer && trackingModel.featureInTracking(featureFormList.selection.focusedLayer, selectedFeature)) {
displayToast(qsTr("A number of features are being tracked, stop tracking to delete those"));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/qml/editorwidgets/ExternalResource.qml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ EditorWidgetBase {
id: audioAnalyzer
barCount: 80
onReady: bars => {
audioWaveformRepeater.model = bars;
audioWaveformRepeater.model = Array.from(bars);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ RelationEditorBase {
}

onReady: bars => {
availableBars[currentProcess] = bars;
availableBars[currentProcess] = Array.from(bars);
availableBarsChanged();
processQueue();
}
Expand Down
Loading