17#ifndef QGSCOORDINATEREFERENCESYSTEMMODEL_H
18#define QGSCOORDINATEREFERENCESYSTEMMODEL_H
25#include <QAbstractItemModel>
27#include <QSortFilterProxyModel>
30class QgsCoordinateReferenceSystemModelGroupNode;
41class GUI_EXPORT QgsCoordinateReferenceSystemModelNode
51 virtual ~QgsCoordinateReferenceSystemModelNode();
56 virtual NodeType nodeType()
const = 0;
61 QgsCoordinateReferenceSystemModelNode *parent() {
return mParent; }
66 QList<QgsCoordinateReferenceSystemModelNode *> children() {
return mChildren; }
71 QList<QgsCoordinateReferenceSystemModelNode *> children()
const {
return mChildren; }
77 QgsCoordinateReferenceSystemModelNode *takeChild( QgsCoordinateReferenceSystemModelNode *node );
85 QgsCoordinateReferenceSystemModelNode *addChildNode( std::unique_ptr< QgsCoordinateReferenceSystemModelNode > node );
90 void deleteChildren();
97 QgsCoordinateReferenceSystemModelGroupNode *getChildGroupNode(
const QString &
id );
100 QgsCoordinateReferenceSystemModelNode *mParent =
nullptr;
101 QList<QgsCoordinateReferenceSystemModelNode *> mChildren;
110class GUI_EXPORT QgsCoordinateReferenceSystemModelGroupNode :
public QgsCoordinateReferenceSystemModelNode
116 QgsCoordinateReferenceSystemModelGroupNode(
const QString &name,
const QIcon &icon,
const QString &
id );
121 QString id()
const {
return mId; }
126 QString name()
const {
return mName; }
131 QIcon icon()
const {
return mIcon; }
133 NodeType nodeType()
const override {
return NodeGroup; }
147class GUI_EXPORT QgsCoordinateReferenceSystemModelCrsNode :
public QgsCoordinateReferenceSystemModelNode
154 QgsCoordinateReferenceSystemModelCrsNode(
const QgsCrsDbRecord &record );
156 NodeType nodeType()
const override {
return NodeCrs; }
161 const QgsCrsDbRecord &record()
const {
return mRecord; }
170 void setWkt(
const QString &wkt ) { mWkt = wkt; }
179 QString wkt()
const {
return mWkt; }
188 void setProj(
const QString &proj ) { mProj = proj; }
197 QString proj()
const {
return mProj; }
205 void setGroup(
const QString &group ) { mGroup = group; }
213 QString group()
const {
return mGroup; }
221 void setProjection(
const QString &projection ) { mProjection = projection; }
229 QString projection()
const {
return mProjection; }
232 const QgsCrsDbRecord mRecord;
271 Group = Qt::UserRole + 8,
272 Projection = Qt::UserRole + 9,
282 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
283 QVariant data(
const QModelIndex &index,
int role )
const override;
284 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
285 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
286 int columnCount(
const QModelIndex & = QModelIndex() )
const override;
287 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
288 QModelIndex parent(
const QModelIndex &index )
const override;
303 QModelIndex authIdToIndex(
const QString &authId )
const;
308 void userCrsAdded(
const QString &
id );
309 void userCrsRemoved(
long id );
310 void userCrsChanged(
const QString &
id );
313 QgsCoordinateReferenceSystemModelCrsNode *addRecord(
const QgsCrsDbRecord &record );
315 QgsCoordinateReferenceSystemModelNode *index2node(
const QModelIndex &index )
const;
316 QModelIndex node2index( QgsCoordinateReferenceSystemModelNode *node )
const;
317 QModelIndex indexOfParentTreeNode( QgsCoordinateReferenceSystemModelNode *parentNode )
const;
320 std::unique_ptr<QgsCoordinateReferenceSystemModelGroupNode> mRootNode;
322 QList<QgsCrsDbRecord> mCrsDbRecords;
381 void setFilterString(
const QString &filter );
396 void setFilterAuthIds(
const QSet<QString> &filter );
410 void setFilterDeprecated(
bool filter );
419 bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent )
const override;
420 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
424 QString mFilterString;
425 QSet<QString> mFilterAuthIds;
426 bool mFilterDeprecated =
false;
427 Filters mFilters = Filters();
A tree model for display of known coordinate reference systems.
QgsCoordinateReferenceSystemModel(QObject *parent=nullptr)
Constructor for QgsCoordinateReferenceSystemModel, with the specified parent object.
CustomRole
Custom model roles.
bool filterDeprecated() const
Returns whether deprecated CRS will be filtered from the results.
QSet< QString > filterAuthIds() const
Returns the current filter list of auth ID strings, if set.
QgsCoordinateReferenceSystemProxyModel(QObject *parent=nullptr)
Constructor for QgsCoordinateReferenceSystemProxyModel, with the given parent object.
Filters filters() const
Returns any filters that affect how CRS are filtered.
Filter
Available filter flags for filtering the model.
@ FilterVertical
Include vertical CRS (excludes compound CRS containing a vertical component).
@ FilterCompound
Include compound CRS.
@ FilterHorizontal
Include horizontal CRS (excludes compound CRS containing a horizontal component).
QgsCoordinateReferenceSystemModel * coordinateReferenceSystemModel()
Returns the underlying source model.
QString filterString() const
Returns the current filter string, if set.
void setFilters(QgsCoordinateReferenceSystemProxyModel::Filters filters)
Set filters that affect how CRS are filtered.
Represents a coordinate reference system (CRS).
#define SIP_ENUM_BASETYPE(type)
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)