Skip to content

Commit 1d30112

Browse files
authored
Merge pull request #7750 from opengisch/revert_variant
Revert obsolete QVariantList properties added while dissecting (now gone) top crasher
2 parents f9931ef + e7d1705 commit 1d30112

16 files changed

Lines changed: 29 additions & 150 deletions

src/core/featuremodel.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -126,36 +126,6 @@ void FeatureModel::setFeatures( const QList<QgsFeature> &features )
126126
endResetModel();
127127
}
128128

129-
QVariantList FeatureModel::featuresVariant() const
130-
{
131-
QVariantList featuresVariant;
132-
133-
featuresVariant.reserve( mFeatures.size() );
134-
for ( const QgsFeature &feature : mFeatures )
135-
{
136-
// Pack the custom QgsFeature object into a QVariant safely
137-
featuresVariant.append( QVariant::fromValue( feature ) );
138-
}
139-
140-
return featuresVariant;
141-
}
142-
143-
void FeatureModel::setFeaturesVariant( const QVariantList &features )
144-
{
145-
QList<QgsFeature> featuresList;
146-
featuresList.reserve( features.size() );
147-
148-
for ( const QVariant &variant : features )
149-
{
150-
if ( variant.canConvert<QgsFeature>() )
151-
{
152-
featuresList.append( variant.value<QgsFeature>() );
153-
}
154-
}
155-
156-
setFeatures( featuresList );
157-
}
158-
159129
void FeatureModel::setCurrentLayer( QgsVectorLayer *layer )
160130
{
161131
if ( layer == mLayer )

src/core/featuremodel.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class FeatureModel : public QAbstractListModel
3535
Q_OBJECT
3636
Q_PROPERTY( FeatureModel::ModelModes modelMode READ modelMode WRITE setModelMode NOTIFY modelModeChanged )
3737
Q_PROPERTY( QgsFeature feature READ feature WRITE setFeature NOTIFY featureChanged )
38-
Q_PROPERTY( QVariantList features READ featuresVariant WRITE setFeaturesVariant NOTIFY featuresChanged )
38+
Q_PROPERTY( QList<QgsFeature> features READ features WRITE setFeatures NOTIFY featuresChanged )
3939
Q_PROPERTY( QgsFeature linkedParentFeature READ linkedParentFeature WRITE setLinkedParentFeature NOTIFY linkedParentFeatureChanged )
4040
Q_PROPERTY( QgsRelation linkedRelation READ linkedRelation WRITE setLinkedRelation NOTIFY linkedRelationChanged )
4141
Q_PROPERTY( QString linkedRelationOrderingField READ linkedRelationOrderingField WRITE setLinkedRelationOrderingField NOTIFY linkedRelationOrderingFieldChanged )
@@ -84,17 +84,10 @@ class FeatureModel : public QAbstractListModel
8484

8585
void setFeature( const QgsFeature &feature );
8686

87-
/**
88-
* Return the feature wrapped in a QVariant for passing it around in QML
89-
*/
9087
QgsFeature feature() const;
9188

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

94-
QVariantList featuresVariant() const;
95-
96-
void setFeaturesVariant( const QVariantList &features );
97-
9891
/**
9992
* Return the features list for passing it around in QML
10093
*/

src/core/gridmodel.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,11 @@ void GridModel::update()
449449
{
450450
if ( currentLine.intersects( topBorder, &intersectionPoint ) )
451451
{
452-
mAnnotations << QVariant::fromValue( GridAnnotation( GridAnnotation::Top, intersectionPoint, xPos ) );
452+
mAnnotations << GridAnnotation( GridAnnotation::Top, intersectionPoint, xPos );
453453
}
454454
if ( currentLine.intersects( bottomBorder, &intersectionPoint ) )
455455
{
456-
mAnnotations << QVariant::fromValue( GridAnnotation( GridAnnotation::Bottom, intersectionPoint, xPos ) );
456+
mAnnotations << GridAnnotation( GridAnnotation::Bottom, intersectionPoint, xPos );
457457
}
458458
}
459459

@@ -478,11 +478,11 @@ void GridModel::update()
478478
{
479479
if ( currentLine.intersects( leftBorder, &intersectionPoint ) )
480480
{
481-
mAnnotations << QVariant::fromValue( GridAnnotation( GridAnnotation::Left, intersectionPoint, yPos ) );
481+
mAnnotations << GridAnnotation( GridAnnotation::Left, intersectionPoint, yPos );
482482
}
483483
if ( currentLine.intersects( rightBorder, &intersectionPoint ) )
484484
{
485-
mAnnotations << QVariant::fromValue( GridAnnotation( GridAnnotation::Right, intersectionPoint, yPos ) );
485+
mAnnotations << GridAnnotation( GridAnnotation::Right, intersectionPoint, yPos );
486486
}
487487
}
488488

src/core/gridmodel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class QFIELD_CORE_EXPORT GridModel : public QObject
7777
Q_PROPERTY( QString majorLinesPath READ majorLinesPath NOTIFY majorLinesChanged )
7878
Q_PROPERTY( QString minorLinesPath READ minorLinesPath NOTIFY minorLinesChanged )
7979
Q_PROPERTY( QString markersPath READ markersPath NOTIFY markersChanged )
80-
Q_PROPERTY( QVariantList annotations READ annotations NOTIFY annotationsChanged )
80+
Q_PROPERTY( QList<GridAnnotation> annotations READ annotations NOTIFY annotationsChanged )
8181

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

171171
//! Returns the grid annotations
172-
QVariantList annotations() const { return mAnnotations; }
172+
QList<GridAnnotation> annotations() const { return mAnnotations; }
173173

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

322322
bool mPrepareAnnotations = false;
323-
QVariantList mAnnotations;
323+
QList<GridAnnotation> mAnnotations;
324324

325325
bool mAutoColor = false;
326326
QColor mMajorLineColor = QColor( 0, 0, 0, 100 );

src/core/linepolygonshape.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ void LinePolygonShape::createPolylines()
5656
if ( mGeometry && !geometry.isEmpty() && geometry.type() != Qgis::GeometryType::Point )
5757
{
5858
geometry = geometry.simplify( mMapSettings->mapUnitsPerPoint() );
59+
geometry = geometry.makeValid();
60+
5961
geomType = geometry.type();
6062
switch ( geomType )
6163
{

src/core/linepolygonshape.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class LinePolygonShape : public QQuickItem
3838
Q_PROPERTY( QgsGeometryWrapper *geometry READ geometry WRITE setGeometry NOTIFY qgsGeometryChanged )
3939

4040
//! List of polylines representing the geometry
41-
Q_PROPERTY( QVariantList polylines READ polylines NOTIFY polylinesChanged )
41+
Q_PROPERTY( QList<QPolygonF> polylines READ polylines NOTIFY polylinesChanged )
4242
//! The geometry type associated to the polylines
4343
Q_PROPERTY( Qgis::GeometryType polylinesType READ polylinesType NOTIFY polylinesTypeChanged )
4444

@@ -58,7 +58,7 @@ class LinePolygonShape : public QQuickItem
5858
void setLineWidth( float width );
5959

6060
//! \copydoc polylines
61-
QVariantList polylines() const { return mPolylines; }
61+
QList<QPolygonF> polylines() const { return mPolylines; }
6262

6363
//! \copydoc polylinesType
6464
Qgis::GeometryType polylinesType() const { return mPolylinesType; }
@@ -91,7 +91,7 @@ class LinePolygonShape : public QQuickItem
9191
QgsGeometryWrapper *mGeometry = nullptr;
9292
QgsPoint mGeometryCorner;
9393
double mGeometryMUPP = 0.0;
94-
QVariantList mPolylines;
94+
QList<QPolygonF> mPolylines;
9595
Qgis::GeometryType mPolylinesType = Qgis::GeometryType::Null;
9696
};
9797

src/core/multifeaturelistmodel.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,6 @@ QList<QgsFeature> MultiFeatureListModel::selectedFeatures()
219219
return mSourceModel->selectedFeatures();
220220
}
221221

222-
QVariantList MultiFeatureListModel::selectedFeaturesVariant()
223-
{
224-
QVariantList featuresVariant;
225-
const QList<QgsFeature> features = mSourceModel->selectedFeatures();
226-
227-
featuresVariant.reserve( features.size() );
228-
for ( const QgsFeature &feature : features )
229-
{
230-
// Pack the custom QgsFeature object into a QVariant safely
231-
featuresVariant.append( QVariant::fromValue( feature ) );
232-
}
233-
234-
return featuresVariant;
235-
}
236-
237222
QgsVectorLayer *MultiFeatureListModel::selectedLayer()
238223
{
239224
return mFilterLayer.data();

src/core/multifeaturelistmodel.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MultiFeatureListModel : public QSortFilterProxyModel
3333
Q_OBJECT
3434

3535
Q_PROPERTY( int count READ count NOTIFY countChanged )
36-
Q_PROPERTY( QVariantList selectedFeatures READ selectedFeaturesVariant NOTIFY selectedCountChanged )
36+
Q_PROPERTY( QList<QgsFeature> selectedFeatures READ selectedFeatures NOTIFY selectedCountChanged )
3737
Q_PROPERTY( QgsVectorLayer *selectedLayer READ selectedLayer NOTIFY selectedLayerChanged )
3838
Q_PROPERTY( int selectedCount READ selectedCount NOTIFY selectedCountChanged )
3939
Q_PROPERTY( bool canEditAttributesSelection READ canEditAttributesSelection NOTIFY selectedCountChanged )
@@ -176,11 +176,6 @@ class MultiFeatureListModel : public QSortFilterProxyModel
176176
*/
177177
QList<QgsFeature> selectedFeatures();
178178

179-
/**
180-
* Returns the list of currently selected features as a QVariantList object.
181-
*/
182-
QVariantList selectedFeaturesVariant();
183-
184179
/**
185180
* Returns the vector layer within which one or more features are currently selected
186181
*/

src/core/processing/processingalgorithm.cpp

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -91,36 +91,6 @@ void ProcessingAlgorithm::setInPlaceFeatures( const QList<QgsFeature> &features
9191
}
9292
}
9393

94-
QVariantList ProcessingAlgorithm::inPlaceFeaturesVariant() const
95-
{
96-
QVariantList featuresVariant;
97-
98-
featuresVariant.reserve( mInPlaceFeatures.size() );
99-
for ( const QgsFeature &feature : mInPlaceFeatures )
100-
{
101-
// Pack the custom QgsFeature object into a QVariant safely
102-
featuresVariant.append( QVariant::fromValue( feature ) );
103-
}
104-
105-
return featuresVariant;
106-
}
107-
108-
void ProcessingAlgorithm::setInPlaceFeaturesVariant( const QVariantList &features )
109-
{
110-
QList<QgsFeature> featuresList;
111-
featuresList.reserve( features.size() );
112-
113-
for ( const QVariant &variant : features )
114-
{
115-
if ( variant.canConvert<QgsFeature>() )
116-
{
117-
featuresList.append( variant.value<QgsFeature>() );
118-
}
119-
}
120-
121-
setInPlaceFeatures( featuresList );
122-
}
123-
12494
void ProcessingAlgorithm::setParameters( const QVariantMap &parameters )
12595
{
12696
if ( mAlgorithmParameters == parameters )
@@ -235,7 +205,7 @@ bool ProcessingAlgorithm::run( bool previewMode )
235205
{
236206
for ( const QgsFeature &outputFeature : outputFeatures )
237207
{
238-
mPreviewGeometries << QVariant::fromValue( outputFeature.geometry() );
208+
mPreviewGeometries << outputFeature.geometry();
239209
}
240210

241211
emit previewGeometriesChanged();
@@ -326,7 +296,7 @@ bool ProcessingAlgorithm::run( bool previewMode )
326296
{
327297
for ( const QgsFeature &previewFeature : outputFeatures )
328298
{
329-
mPreviewGeometries << QVariant::fromValue( previewFeature.geometry() );
299+
mPreviewGeometries << previewFeature.geometry();
330300
}
331301

332302
emit previewGeometriesChanged();

src/core/processing/processingalgorithm.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class ProcessingAlgorithm : public QObject
4545

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

5050
Q_PROPERTY( bool preview READ preview WRITE setPreview NOTIFY previewChanged )
51-
Q_PROPERTY( QVariantList previewGeometries READ previewGeometries NOTIFY previewGeometriesChanged )
51+
Q_PROPERTY( QList<QgsGeometry> previewGeometries READ previewGeometries NOTIFY previewGeometriesChanged )
5252

5353
public:
5454
explicit ProcessingAlgorithm( QObject *parent = nullptr );
@@ -98,16 +98,6 @@ class ProcessingAlgorithm : public QObject
9898
*/
9999
void setInPlaceFeatures( const QList<QgsFeature> &features );
100100

101-
/**
102-
* Returns the vector \a layer for in-place algorithm filter as a QVariantList.
103-
*/
104-
QVariantList inPlaceFeaturesVariant() const;
105-
106-
/**
107-
* Sets the vector \a layer for in-place algorithm filter from a QVariantList.
108-
*/
109-
void setInPlaceFeaturesVariant( const QVariantList &features );
110-
111101
/**
112102
* Returns the algorithm parameters as a map of parameter names as keys and values.
113103
*/
@@ -133,7 +123,7 @@ class ProcessingAlgorithm : public QObject
133123
/**
134124
* Returns a list of geometries previewing the algorithm result using current parameters.
135125
*/
136-
QVariantList previewGeometries() const { return mPreviewGeometries; }
126+
QList<QgsGeometry> previewGeometries() const { return mPreviewGeometries; }
137127

138128
/**
139129
* Executes the algorithm.
@@ -180,7 +170,7 @@ class ProcessingAlgorithm : public QObject
180170
QList<QgsFeature> mInPlaceFeatures;
181171

182172
bool mPreview = false;
183-
QVariantList mPreviewGeometries;
173+
QList<QgsGeometry> mPreviewGeometries;
184174
};
185175

186176
#endif // PROCESSINGALGORITHM

0 commit comments

Comments
 (0)