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
117 QgsCoordinateReferenceSystemModelGroupNode(
const QString &name,
const QIcon &icon,
const QString &
id );
122 QString id()
const {
return mId; }
127 QString name()
const {
return mName; }
132 QIcon icon()
const {
return mIcon; }
134 NodeType nodeType()
const override {
return NodeGroup; }
148class GUI_EXPORT QgsCoordinateReferenceSystemModelCrsNode :
public QgsCoordinateReferenceSystemModelNode
156 QgsCoordinateReferenceSystemModelCrsNode(
const QgsCrsDbRecord &record );
158 NodeType nodeType()
const override {
return NodeCrs; }
163 const QgsCrsDbRecord &record()
const {
return mRecord; }
172 void setWkt(
const QString &wkt ) { mWkt = wkt; }
181 QString wkt()
const {
return mWkt; }
190 void setProj(
const QString &proj ) { mProj = proj; }
199 QString proj()
const {
return mProj; }
207 void setGroup(
const QString &group ) { mGroup = group; }
215 QString group()
const {
return mGroup; }
223 void setProjection(
const QString &projection ) { mProjection = projection; }
231 QString projection()
const {
return mProjection; }
234 const QgsCrsDbRecord mRecord;
273 Group = Qt::UserRole + 8,
274 Projection = Qt::UserRole + 9,
284 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
285 QVariant data(
const QModelIndex &index,
int role )
const override;
286 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
287 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
288 int columnCount(
const QModelIndex & = QModelIndex() )
const override;
289 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
290 QModelIndex parent(
const QModelIndex &index )
const override;
305 QModelIndex authIdToIndex(
const QString &authId )
const;
310 void userCrsAdded(
const QString &
id );
311 void userCrsRemoved(
long id );
312 void userCrsChanged(
const QString &
id );
315 QgsCoordinateReferenceSystemModelCrsNode *addRecord(
const QgsCrsDbRecord &record );
317 QgsCoordinateReferenceSystemModelNode *index2node(
const QModelIndex &index )
const;
318 QModelIndex node2index( QgsCoordinateReferenceSystemModelNode *node )
const;
319 QModelIndex indexOfParentTreeNode( QgsCoordinateReferenceSystemModelNode *parentNode )
const;
322 std::unique_ptr<QgsCoordinateReferenceSystemModelGroupNode> mRootNode;
324 QList<QgsCrsDbRecord> mCrsDbRecords;
383 void setFilterString(
const QString &filter );
398 void setFilterAuthIds(
const QSet<QString> &filter );
412 void setFilterDeprecated(
bool filter );
421 bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent )
const override;
422 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
426 QString mFilterString;
427 QSet<QString> mFilterAuthIds;
428 bool mFilterDeprecated =
false;
429 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)