-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a FeaturesProxyModel to conditionally sort features list an…
…d value relations MMFeaturesListPage is sorted according to the layer's QgsAttributeTableConfig MMFormValueRelationEditor is sorted by value when the widget has the OrderByValue config set
- Loading branch information
Showing
14 changed files
with
175 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "featuresproxymodel.h" | ||
|
||
FeaturesProxyModel::FeaturesProxyModel( QObject *parent ) : QSortFilterProxyModel( parent ) | ||
{ | ||
} | ||
|
||
void FeaturesProxyModel::initialize() | ||
{ | ||
setSourceModel( mModel ); | ||
|
||
// don't sort if there is no sort expression for the layer | ||
if ( mModel->sortingEnabled() ) | ||
{ | ||
setSortRole( FeaturesModel::SortValue ); | ||
setSortCaseSensitivity( Qt::CaseInsensitive ); | ||
sort( 0, mModel->sortOrder() ); | ||
} | ||
} | ||
|
||
FeaturesModel *FeaturesProxyModel::featuresSourceModel() const | ||
{ | ||
return mModel; | ||
} | ||
|
||
void FeaturesProxyModel::setFeaturesSourceModel( FeaturesModel *sourceModel ) | ||
{ | ||
if ( mModel == sourceModel ) | ||
return; | ||
|
||
mModel = sourceModel; | ||
QObject::connect( mModel, &FeaturesModel::fetchingResultsChanged, this, [ = ]( bool pending ) { if ( !pending ) initialize(); } ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef FEATURESPROXYMODEL_H | ||
#define FEATURESPROXYMODEL_H | ||
|
||
#include <QObject> | ||
#include <QSortFilterProxyModel> | ||
|
||
#include "inputconfig.h" | ||
#include "featuresmodel.h" | ||
|
||
/** | ||
* \brief The FeaturesProxyModel class used as a proxy sort model for the \see FeaturesModel class. | ||
* | ||
* FeaturesProxyModel is a QML type with required property of FeatureSourceModel. Without source model, this model does nothing (is not initialized). | ||
* After setting source model, this model starts sorting and allows filtering (search) from view. | ||
*/ | ||
class FeaturesProxyModel : public QSortFilterProxyModel | ||
{ | ||
Q_OBJECT | ||
|
||
Q_PROPERTY( FeaturesModel *featuresSourceModel READ featuresSourceModel WRITE setFeaturesSourceModel ) | ||
|
||
public: | ||
explicit FeaturesProxyModel( QObject *parent = nullptr ); | ||
~FeaturesProxyModel() override {}; | ||
|
||
FeaturesModel *featuresSourceModel() const; | ||
|
||
public slots: | ||
void setFeaturesSourceModel( FeaturesModel *sourceModel ); | ||
|
||
private: | ||
void initialize(); | ||
|
||
FeaturesModel *mModel = nullptr; // not owned by this, needs to be set in order to proxy model to work | ||
|
||
Qt::SortOrder mSortOrder = Qt::SortOrder::AscendingOrder; | ||
QString mSortExpression; | ||
|
||
friend class TestModels; | ||
}; | ||
|
||
#endif // FEATURESPROXYMODEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4302331
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS - version 24.7.643011 just submitted!