17#ifndef QGSCOORDINATEREFERENCESYSTEMMODEL_H
18#define QGSCOORDINATEREFERENCESYSTEMMODEL_H
25#include <QAbstractItemModel>
26#include <QSortFilterProxyModel>
30class QgsCoordinateReferenceSystemModelGroupNode;
41class GUI_EXPORT QgsCoordinateReferenceSystemModelNode
53 virtual ~QgsCoordinateReferenceSystemModelNode();
58 virtual NodeType nodeType()
const = 0;
63 QgsCoordinateReferenceSystemModelNode *parent() {
return mParent; }
68 QList<QgsCoordinateReferenceSystemModelNode *> children() {
return mChildren; }
73 QList<QgsCoordinateReferenceSystemModelNode *> children()
const {
return mChildren; }
79 QgsCoordinateReferenceSystemModelNode *takeChild( QgsCoordinateReferenceSystemModelNode *node );
85 void addChildNode( QgsCoordinateReferenceSystemModelNode *node );
90 void deleteChildren();
97 QgsCoordinateReferenceSystemModelGroupNode *getChildGroupNode(
const QString &
id );
101 QgsCoordinateReferenceSystemModelNode *mParent =
nullptr;
102 QList<QgsCoordinateReferenceSystemModelNode *> mChildren;
112class GUI_EXPORT QgsCoordinateReferenceSystemModelGroupNode :
public QgsCoordinateReferenceSystemModelNode
120 QgsCoordinateReferenceSystemModelGroupNode(
const QString &name,
const QIcon &icon,
const QString &
id );
125 QString id()
const {
return mId; }
130 QString name()
const {
return mName; }
135 QIcon icon()
const {
return mIcon; }
137 NodeType nodeType()
const override {
return NodeGroup; }
153class GUI_EXPORT QgsCoordinateReferenceSystemModelCrsNode :
public QgsCoordinateReferenceSystemModelNode
162 QgsCoordinateReferenceSystemModelCrsNode(
const QgsCrsDbRecord &record );
164 NodeType nodeType()
const override {
return NodeCrs; }
178 void setWkt(
const QString &wkt ) { mWkt = wkt; }
187 QString wkt()
const {
return mWkt; }
196 void setProj(
const QString &proj ) { mProj = proj; }
205 QString proj()
const {
return mProj; }
233 RoleNodeType = Qt::UserRole,
234 RoleName = Qt::UserRole + 1,
235 RoleAuthId = Qt::UserRole + 2,
236 RoleDeprecated = Qt::UserRole + 3,
237 RoleType = Qt::UserRole + 4,
238 RoleGroupId = Qt::UserRole + 5,
239 RoleWkt = Qt::UserRole + 6,
240 RoleProj = Qt::UserRole + 7,
248 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
249 QVariant data(
const QModelIndex &index,
int role )
const override;
250 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
251 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
252 int columnCount(
const QModelIndex & = QModelIndex() )
const override;
253 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
254 QModelIndex parent(
const QModelIndex &index )
const override;
269 QModelIndex authIdToIndex(
const QString &authId )
const;
274 void userCrsAdded(
const QString &
id );
275 void userCrsRemoved(
long id );
276 void userCrsChanged(
const QString &
id );
280 QgsCoordinateReferenceSystemModelCrsNode *addRecord(
const QgsCrsDbRecord &record );
282 QgsCoordinateReferenceSystemModelNode *index2node(
const QModelIndex &index )
const;
283 QModelIndex node2index( QgsCoordinateReferenceSystemModelNode *node )
const;
284 QModelIndex indexOfParentTreeNode( QgsCoordinateReferenceSystemModelNode *parentNode )
const;
287 std::unique_ptr< QgsCoordinateReferenceSystemModelGroupNode > mRootNode;
289 QList< QgsCrsDbRecord > mCrsDbRecords;
309 FilterHorizontal = 1 << 1,
310 FilterVertical = 1 << 2,
311 FilterCompound = 1 << 3,
313 Q_DECLARE_FLAGS( Filters, Filter )
342 Filters filters()
const {
return mFilters; }
350 void setFilterString(
const QString &filter );
365 void setFilterAuthIds(
const QSet< QString > &filter );
379 void setFilterDeprecated(
bool filter );
388 bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent )
const override;
389 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
394 QString mFilterString;
395 QSet< QString > mFilterAuthIds;
396 bool mFilterDeprecated =
false;
397 Filters mFilters = Filters();
A tree model for display of known coordinate reference systems.
Roles
Custom roles used by the model.
A sort/filter proxy model for coordinate reference systems.
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.
Filter
Available filter flags for filtering the model.
QString filterString() const
Returns the current filter string, if set.
This class represents a coordinate reference system (CRS).
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)
const QgsCoordinateReferenceSystem & crs