23#ifdef ENABLE_MODELTEST
28 : QAbstractItemModel( parent )
29 , mColumnCount( subclassColumnCount )
31#ifdef ENABLE_MODELTEST
32 new ModelTest(
this,
this );
43 if ( !
index.isValid() )
45 return Qt::ItemFlags();
48 return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
57 if (
index.column() == 0 )
97 return createIndex( row, column );
102 return QModelIndex();
107 if ( !
index.isValid() )
110 return mCrs.value(
index.row() );
115 const int currentRow = mCrs.indexOf(
crs );
116 if ( currentRow > 0 )
119 beginMoveRows( QModelIndex(), currentRow, currentRow, QModelIndex(), 0 );
120 mCrs.removeAt( currentRow );
121 mCrs.insert( 0,
crs );
124 else if ( currentRow < 0 )
127 beginInsertRows( QModelIndex(), 0, 0 );
128 mCrs.insert( 0,
crs );
135 const int currentRow = mCrs.indexOf(
crs );
136 if ( currentRow >= 0 )
138 beginRemoveRows( QModelIndex(), currentRow, currentRow );
139 mCrs.removeAt( currentRow );
144void QgsRecentCoordinateReferenceSystemsModel::recentCrsCleared()
158 : QSortFilterProxyModel( parent )
161 setSourceModel( mModel );
162 setDynamicSortFilter(
true );
186 if ( mFilterDeprecated == filter )
189 mFilterDeprecated = filter;
195 mFilterString = filter;
204 const QModelIndex sourceIndex = mModel->
index( sourceRow, 0, sourceParent );
241 if ( !mFilterString.trimmed().isEmpty() )
243 if ( !(
crs.
description().contains( mFilterString, Qt::CaseInsensitive )
244 ||
crs.
authid().contains( mFilterString, Qt::CaseInsensitive ) ) )
253 const QModelIndex sourceIndex = mapToSource( index );
254 return mModel->
crs( sourceIndex );
CrsType
Coordinate reference system types.
@ Compound
Compound (horizontal + vertical) CRS.
@ Projected
Projected CRS.
@ DerivedProjected
Derived projected CRS.
@ Engineering
Engineering CRS.
@ Geographic3d
3D geopraphic CRS
@ Geographic2d
2D geographic CRS
@ Geocentric
Geocentric CRS.
static QgsCoordinateReferenceSystemRegistry * coordinateReferenceSystemRegistry()
Returns the application's coordinate reference system (CRS) registry, which handles known CRS definit...
@ 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)
void recentCrsRemoved(const QgsCoordinateReferenceSystem &crs)
Emitted when a recently used CRS has been removed from the recent CRS list.
void recentCrsCleared()
Emitted when the list of recently used CRS has been cleared.
void recentCrsPushed(const QgsCoordinateReferenceSystem &crs)
Emitted when a recently used CRS has been pushed to the top of the recent CRS list.
QList< QgsCoordinateReferenceSystem > recentCrs()
Returns a list of recently used CRS.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString userFriendlyIdentifier(Qgis::CrsIdentifierType type=Qgis::CrsIdentifierType::MediumString) const
Returns a user friendly identifier for the CRS.
Qgis::CrsType type() const
Returns the type of the CRS.
bool isDeprecated() const
Returns true if the CRS is considered deprecated.
A model for display of recently used coordinate reference systems.
Qt::ItemFlags flags(const QModelIndex &index) const override
QgsCoordinateReferenceSystem crs(const QModelIndex &index) const
Returns the CRS for the corresponding index.
QModelIndex parent(const QModelIndex &index) const override
QVariant data(const QModelIndex &index, int role) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QgsRecentCoordinateReferenceSystemsModel(QObject *parent=nullptr, int subclassColumnCount=1)
Constructor for QgsRecentCoordinateReferenceSystemsModel, with the specified parent object.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
int columnCount(const QModelIndex &=QModelIndex()) const override
@ AuthId
CRS authority ID.
@ Crs
Coordinate reference system.
QgsCoordinateReferenceSystem crs(const QModelIndex &index) const
Returns the CRS for the corresponding index.
void setFilters(QgsCoordinateReferenceSystemProxyModel::Filters filters)
Set filters that affect how CRS are filtered.
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
QgsCoordinateReferenceSystemProxyModel::Filters filters() const
Returns any filters that affect how CRS are filtered.
QgsRecentCoordinateReferenceSystemsProxyModel(QObject *parent=nullptr, int subclassColumnCount=1)
Constructor for QgsRecentCoordinateReferenceSystemsProxyModel, with the given parent object.
void setFilterString(const QString &filter)
Sets a filter string, such that only coordinate reference systems matching the specified string will ...
void setFilterDeprecated(bool filter)
Sets whether deprecated CRS should be filtered from the results.
QgsRecentCoordinateReferenceSystemsModel * recentCoordinateReferenceSystemsModel()
Returns the underlying source model.
const QgsCoordinateReferenceSystem & crs