16 #include <QHBoxLayout> 37 mCrsComboBox->
setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
45 addProjectCrsOption();
55 addDefaultCrsOption();
71 connect( mCrsComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT( comboIndexChanged(
int ) ) );
88 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() )
158 void QgsProjectionSelectionWidget::comboIndexChanged(
int idx )
198 tr(
"invalid projection" ) );
208 if ( layerItemIndex > -1 )
219 if ( layerItemIndex > -1 )
227 void QgsProjectionSelectionWidget::addProjectCrsOption()
235 void QgsProjectionSelectionWidget::addDefaultCrsOption()
240 void QgsProjectionSelectionWidget::addRecentCrs()
244 Q_FOREACH (
const QString& projection, recentProjections )
246 long srsid = projection.
toLong();
249 if ( crsIsShown( srsid ) )
270 bool QgsProjectionSelectionWidget::crsIsShown(
const long srsid )
const 272 return srsid == mLayerCrs.
srsid() || srsid == mDefaultCrs.
srsid() || srsid == mProjectCrs.
srsid();
275 int QgsProjectionSelectionWidget::firstRecentCrsIndex()
const 277 for (
int i = 0; i < mCrsComboBox->
count(); ++i )
qlonglong toLongLong(bool *ok) const
void setContentsMargins(int left, int top, int right, int bottom)
long srsid() const
Returns the SrsId, if available.
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)
void addItem(const QString &text, const QVariant &userData)
bool createFromOgcWmsCrs(QString theCrs)
Set up this CRS from the given OGC CRS.
QString readEntry(const QString &scope, const QString &key, const QString &def=QString::null, bool *ok=nullptr) const
bool createFromSrsId(const long theSrsId)
Set up this CRS by fetching the appropriate information from the sqlite backend.
int toInt(bool *ok) const
static QStringList recentProjections()
Returns a list of recently used projections.
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
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
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()
access to canonical QgsProject instance
Class for storing a coordinate reference system (CRS)
QString authid() const
Returns the authority identifier for the CRS, which includes both the authority (eg EPSG) and the CRS...
QString description() const
Returns the descriptive name of the CRS, eg "WGS 84" or "GDA 94 / Vicgrid94".
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
void setSpacing(int spacing)