18#include "moc_qgsrecentcoordinatereferencesystemsmodel.cpp"
24#ifdef ENABLE_MODELTEST
29 : QAbstractItemModel( parent )
30 , mColumnCount( subclassColumnCount )
32#ifdef ENABLE_MODELTEST
33 new ModelTest(
this,
this );
44 if ( !
index.isValid() )
46 return Qt::ItemFlags();
49 return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
58 if (
index.column() == 0 )
98 return createIndex( row, column );
103 return QModelIndex();
108 if ( !
index.isValid() )
111 return mCrs.value(
index.row() );
116 const int currentRow = mCrs.indexOf(
crs );
117 if ( currentRow > 0 )
120 beginMoveRows( QModelIndex(), currentRow, currentRow, QModelIndex(), 0 );
121 mCrs.removeAt( currentRow );
122 mCrs.insert( 0,
crs );
125 else if ( currentRow < 0 )
128 beginInsertRows( QModelIndex(), 0, 0 );
129 mCrs.insert( 0,
crs );
136 const int currentRow = mCrs.indexOf(
crs );
137 if ( currentRow >= 0 )
139 beginRemoveRows( QModelIndex(), currentRow, currentRow );
140 mCrs.removeAt( currentRow );
145void QgsRecentCoordinateReferenceSystemsModel::recentCrsCleared()
159 : QSortFilterProxyModel( parent )
162 setSourceModel( mModel );
163 setDynamicSortFilter(
true );
187 if ( mFilterDeprecated == filter )
190 mFilterDeprecated = filter;
196 mFilterString = filter;
205 const QModelIndex sourceIndex = mModel->
index( sourceRow, 0, sourceParent );
242 if ( !mFilterString.trimmed().isEmpty() )
244 if ( !(
crs.
description().contains( mFilterString, Qt::CaseInsensitive )
245 ||
crs.
authid().contains( mFilterString, Qt::CaseInsensitive ) ) )
254 const QModelIndex sourceIndex = mapToSource( index );
255 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