16 #include <QHBoxLayout> 38 mCrsComboBox->
setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
46 addProjectCrsOption();
56 addDefaultCrsOption();
72 connect( mCrsComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT( comboIndexChanged(
int ) ) );
89 long srsid = mCrsComboBox->
itemData( mCrsComboBox->
currentIndex(), Qt::UserRole + 1 ).toLongLong();
99 int optionIndex = mCrsComboBox->
findData( option );
101 if ( visible && optionIndex < 0 )
113 addProjectCrsOption();
118 addDefaultCrsOption();
127 else if ( !visible && optionIndex >= 0 )
142 if ( mDialog->
exec() )
157 void QgsProjectionSelectionWidget::comboIndexChanged(
int idx )
196 tr(
"invalid projection" ) );
206 if ( layerItemIndex > -1 )
217 if ( layerItemIndex > -1 )
225 void QgsProjectionSelectionWidget::addProjectCrsOption()
233 void QgsProjectionSelectionWidget::addDefaultCrsOption()
238 void QgsProjectionSelectionWidget::addRecentCrs()
242 Q_FOREACH (
const QString& projection, recentProjections )
244 long srsid = projection.
toLong();
247 if ( crsIsShown( srsid ) )
267 bool QgsProjectionSelectionWidget::crsIsShown(
const long srsid )
const 269 return srsid == mLayerCrs.
srsid() || srsid == mDefaultCrs.
srsid() || srsid == mProjectCrs.
srsid();
272 int QgsProjectionSelectionWidget::firstRecentCrsIndex()
const 274 for (
int i = 0; i < mCrsComboBox->
count(); ++i )
qlonglong toLongLong(bool *ok) const
void setContentsMargins(int left, int top, int right, int bottom)
QString readEntry(const QString &scope, const QString &key, const QString &def=QString::null, bool *ok=nullptr) const
QgsCoordinateReferenceSystem crsByOgcWmsCrs(const QString &ogcCrs) const
Returns the CRS from a given OGC WMS-format Coordinate Reference System string.
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
A generic dialog to prompt the user for a Coordinate Reference System.
QString tr(const char *sourceText, const char *disambiguation, int n)
void setItemText(int index, const QString &text)
void insertItem(int index, const QString &text, const QVariant &userData)
QgsCoordinateReferenceSystem crsBySrsId(long srsId) const
Returns the CRS from a specified QGIS SRS ID.
void addItem(const QString &text, const QVariant &userData)
int toInt(bool *ok) const
static QStringList recentProjections()
Returns a list of recently used projections.
QString description() const
Returns the descriptive name of the CRS, eg "WGS 84" or "GDA 94 / Vicgrid94".
void restoreOverrideCursor()
const QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority.
QVariant itemData(int index, int role) const
bool blockSignals(bool block)
long toLong(bool *ok, int base) const
QVariant value(const QString &key, const QVariant &defaultValue) const
void removeItem(int index)
int findData(const QVariant &data, int role, QFlags< Qt::MatchFlag > flags) const
void setSelectedCrsId(long theID)
void setItemData(int index, const QVariant &value, int role)
static QgsProject * instance()
Returns the QgsProject singleton instance.
Class for storing a coordinate reference system (CRS)
long srsid() const
Returns the SrsId, if available.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
static QgsCRSCache * instance()
Returns a pointer to the QgsCRSCache singleton.
void setSpacing(int spacing)
QString authid() const
Returns the authority identifier for the CRS, which includes both the authority (eg EPSG) and the CRS...
bool isValid() const
Returns whether this CRS is correctly initialized and usable.