24#include "moc_qgsrecentcoordinatereferencesystemsmodel.cpp"
26#ifdef ENABLE_MODELTEST
31 : QAbstractItemModel(
parent )
32 , mColumnCount( subclassColumnCount )
34#ifdef ENABLE_MODELTEST
35 new ModelTest(
this,
this );
46 if ( !
index.isValid() )
48 return Qt::ItemFlags();
51 return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
60 if (
index.column() == 0 )
66 return crs.userFriendlyIdentifier();
100 return createIndex( row, column );
105 return QModelIndex();
110 if ( !
index.isValid() )
113 return mCrs.value(
index.row() );
118 const int currentRow = mCrs.indexOf(
crs );
119 if ( currentRow > 0 )
122 beginMoveRows( QModelIndex(), currentRow, currentRow, QModelIndex(), 0 );
123 mCrs.removeAt( currentRow );
124 mCrs.insert( 0,
crs );
127 else if ( currentRow < 0 )
130 beginInsertRows( QModelIndex(), 0, 0 );
131 mCrs.insert( 0,
crs );
138 const int currentRow = mCrs.indexOf(
crs );
139 if ( currentRow >= 0 )
141 beginRemoveRows( QModelIndex(), currentRow, currentRow );
142 mCrs.removeAt( currentRow );
147void QgsRecentCoordinateReferenceSystemsModel::recentCrsCleared()
160 : QSortFilterProxyModel( parent )
163 setSourceModel( mModel );
164 setDynamicSortFilter(
true );
188 if ( mFilterDeprecated == filter )
191 mFilterDeprecated = filter;
197 mFilterString = filter;
206 const QModelIndex sourceIndex = mModel->index( sourceRow, 0, sourceParent );
209 if ( mFilterDeprecated &&
crs.isDeprecated() )
243 if ( !mFilterString.trimmed().isEmpty() )
245 if ( !(
crs.description().contains( mFilterString, Qt::CaseInsensitive )
246 ||
crs.authid().contains( mFilterString, Qt::CaseInsensitive ) ) )
255 const QModelIndex sourceIndex = mapToSource( index );
256 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.
Represents a coordinate reference system (CRS).
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.