31 #include <QHeaderView> 32 #include <QResizeEvent> 33 #include <QMessageBox> 40 leSearch->setShowSearchIcon(
true );
42 connect( lstCoordinateSystems, &QTreeWidget::itemDoubleClicked,
this, &QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked );
43 connect( lstRecent, &QTreeWidget::itemDoubleClicked,
this, &QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked );
44 connect( lstCoordinateSystems, &QTreeWidget::currentItemChanged,
this, &QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged );
45 connect( lstRecent, &QTreeWidget::currentItemChanged,
this, &QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged );
46 connect( cbxHideDeprecated, &QCheckBox::stateChanged,
this, &QgsProjectionSelectionTreeWidget::updateFilter );
47 connect( leSearch, &QgsFilterLineEdit::textChanged,
this, &QgsProjectionSelectionTreeWidget::updateFilter );
54 QColor rectColor = QColor( 185, 84, 210, 60 );
55 mPreviewBand2->
setColor( rectColor );
59 mVertexMarker->
setColor( QColor( 185, 84, 210 ) );
63 mAreaCanvas->setDestinationCrs( srs );
67 mAreaCanvas->setLayers( mLayers );
69 mAreaCanvas->setPreviewJobsEnabled(
true );
70 mAreaCanvas->setVisible( mShowMap );
72 if ( QDialog *dlg = qobject_cast<QDialog *>( parent ) )
81 lstCoordinateSystems->header()->setSectionResizeMode( AuthidColumn, QHeaderView::Stretch );
82 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
83 lstCoordinateSystems->header()->setSectionResizeMode( QgisCrsIdColumn, QHeaderView::Fixed );
86 lstCoordinateSystems->setColumnHidden( QgisCrsIdColumn,
true );
88 lstRecent->header()->setSectionResizeMode( AuthidColumn, QHeaderView::Stretch );
89 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
90 lstRecent->header()->setSectionResizeMode( QgisCrsIdColumn, QHeaderView::Fixed );
93 lstRecent->setColumnHidden( QgisCrsIdColumn,
true );
97 mCheckBoxNoProjection->setHidden(
true );
99 connect( mCheckBoxNoProjection, &QCheckBox::toggled, mFrameProjections, &QFrame::setDisabled );
104 qDeleteAll( mLayers );
106 delete mPreviewBand2;
107 delete mVertexMarker;
109 if ( !mPushProjectionToFront )
115 long crsId = selectedCrsId();
120 mRecentProjections.removeAll( QString::number( crsId ) );
121 mRecentProjections.prepend( QString::number( crsId ) );
123 while ( mRecentProjections.size() > 8 )
125 mRecentProjections.removeLast();
130 settings.
setValue( QStringLiteral(
"/UI/recentProjections" ), mRecentProjections );
134 QStringList projectionsProj4;
135 QStringList projectionsAuthId;
136 for (
int i = 0; i < mRecentProjections.size(); i++ )
148 settings.
setValue( QStringLiteral(
"/UI/recentProjectionsProj4" ), projectionsProj4 );
149 settings.
setValue( QStringLiteral(
"/UI/recentProjectionsAuthId" ), projectionsAuthId );
154 lstCoordinateSystems->header()->resizeSection( NameColumn, event->size().width() - 240 );
155 lstCoordinateSystems->header()->resizeSection( AuthidColumn, 240 );
156 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
158 lstRecent->header()->resizeSection( NameColumn, event->size().width() - 240 );
159 lstRecent->header()->resizeSection( AuthidColumn, 240 );
160 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
167 loadCrsList( &mCrsFilter );
168 loadUserCrsList( &mCrsFilter );
170 if ( !mRecentProjListDone )
172 for (
int i = mRecentProjections.size() - 1; i >= 0; i-- )
173 insertRecent( mRecentProjections.at( i ).toLong() );
174 mRecentProjListDone =
true;
183 QWidget::showEvent( event );
186 QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter )
188 QString sqlExpression = QStringLiteral(
"1" );
189 QMap<QString, QStringList> authParts;
192 return sqlExpression;
212 Q_FOREACH (
const QString &auth_id, *crsFilter )
214 QStringList parts = auth_id.split(
':' );
216 if ( parts.size() < 2 )
219 authParts[ parts.at( 0 ).toUpper()].append( parts.at( 1 ).toUpper() );
222 if ( authParts.isEmpty() )
223 return sqlExpression;
225 if ( !authParts.isEmpty() )
227 QString prefix = QStringLiteral(
" AND (" );
228 for (
auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
230 sqlExpression += QStringLiteral(
"%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
233 it.value().join( QStringLiteral(
"','" ) ) );
234 prefix = QStringLiteral(
" OR " );
236 sqlExpression +=
')';
241 return sqlExpression;
244 void QgsProjectionSelectionTreeWidget::applySelection(
int column, QString value )
246 if ( !mProjListDone || !mUserProjListDone )
249 mSearchColumn = column;
250 mSearchValue = value;
254 if ( column == QgsProjectionSelectionTreeWidget::None )
257 column = mSearchColumn;
258 value = mSearchValue;
260 mSearchColumn = QgsProjectionSelectionTreeWidget::None;
261 mSearchValue.clear();
264 if ( column == QgsProjectionSelectionTreeWidget::None )
267 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( value, Qt::MatchExactly | Qt::MatchRecursive, column );
268 if ( !nodes.isEmpty() )
271 lstCoordinateSystems->setCurrentItem( nodes.first() );
275 QgsDebugMsgLevel( QString(
"nothing found for %1,%2" ).arg( column ).arg( value ), 4 );
277 lstCoordinateSystems->clearSelection();
278 lstRecent->clearSelection();
279 teProjection->clear();
284 void QgsProjectionSelectionTreeWidget::insertRecent(
long crsId )
286 if ( !mProjListDone || !mUserProjListDone )
289 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( QString::number( crsId ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
290 if ( nodes.isEmpty() )
293 lstRecent->insertTopLevelItem( 0,
new QTreeWidgetItem( lstRecent, QStringList()
294 << nodes.first()->text( NameColumn )
295 << nodes.first()->text( AuthidColumn )
296 << nodes.first()->text( QgisCrsIdColumn ) ) );
300 QString QgsProjectionSelectionTreeWidget::selectedName()
303 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
304 return lvi ? lvi->text( NameColumn ) : QString();
311 mCheckBoxNoProjection->setChecked(
true );
315 mCheckBoxNoProjection->setChecked(
false );
316 applySelection( AuthidColumn, crs.
authid() );
324 mPreviewBand2->show();
326 mVertexMarker->show();
335 QString QgsProjectionSelectionTreeWidget::selectedProj4String()
343 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
344 if ( !item || item->text( QgisCrsIdColumn ).isEmpty() )
345 return QLatin1String(
"" );
347 QString srsId = item->text( QgisCrsIdColumn );
356 QString databaseFileName;
360 if ( !QFileInfo::exists( databaseFileName ) )
365 databaseFileName = mSrsDatabaseFileName;
371 int rc = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
374 showDBMissingWarning( databaseFileName );
375 return QLatin1String(
"" );
379 const char *tail =
nullptr;
380 sqlite3_stmt *stmt =
nullptr;
381 QString sql = QStringLiteral(
"select parameters from tbl_srs where srs_id=%1" ).arg( srsId );
385 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
388 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
390 projString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
394 sqlite3_finalize( stmt );
396 sqlite3_close( database );
398 Q_ASSERT( !projString.isEmpty() );
403 QString QgsProjectionSelectionTreeWidget::getSelectedExpression(
const QString &expression )
const 412 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
413 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
420 QString databaseFileName;
424 if ( !QFileInfo::exists( databaseFileName ) )
431 databaseFileName = mSrsDatabaseFileName;
440 int rc = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
444 "Because of this the projection selector will not work…" ).arg( databaseFileName ),
450 const char *tail =
nullptr;
451 sqlite3_stmt *stmt =
nullptr;
452 QString sql = QStringLiteral(
"select %1 from tbl_srs where srs_id=%2" )
454 lvi->text( QgisCrsIdColumn ) );
456 QgsDebugMsgLevel( QString(
"Finding selected attribute using : %1" ).arg( sql ), 4 );
457 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
459 QString attributeValue;
460 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
463 attributeValue = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
467 sqlite3_finalize( stmt );
469 sqlite3_close( database );
472 return attributeValue;
477 if ( mCheckBoxNoProjection->isChecked() )
480 int srid = getSelectedExpression( QStringLiteral(
"srs_id" ) ).toLong();
489 mCheckBoxNoProjection->setHidden( !show );
495 mAreaCanvas->setVisible( show );
501 return !mCheckBoxNoProjection->isHidden();
511 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
512 if ( mCheckBoxNoProjection->isChecked() )
515 return item && !item->text( QgisCrsIdColumn ).isEmpty();
518 long QgsProjectionSelectionTreeWidget::selectedCrsId()
520 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
522 if ( item && !item->text( QgisCrsIdColumn ).isEmpty() )
523 return lstCoordinateSystems->currentItem()->text( QgisCrsIdColumn ).toLong();
531 mCrsFilter = crsFilter;
532 mProjListDone =
false;
533 mUserProjListDone =
false;
534 lstCoordinateSystems->clear();
537 void QgsProjectionSelectionTreeWidget::loadUserCrsList( QSet<QString> *crsFilter )
539 if ( mUserProjListDone )
545 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
549 mUserProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"User Defined Coordinate Systems" ) ) );
551 QFont fontTemp = mUserProjList->font( 0 );
552 fontTemp.setItalic(
true );
553 fontTemp.setBold(
true );
554 mUserProjList->setFont( 0, fontTemp );
564 if ( !QFileInfo::exists( databaseFileName ) )
566 QgsDebugMsg(
"Users qgis.db not found...skipping" );
567 mUserProjListDone =
true;
572 const char *tail =
nullptr;
573 sqlite3_stmt *stmt =
nullptr;
575 int result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
582 showDBMissingWarning( databaseFileName );
587 QString sql = QStringLiteral(
"select description, srs_id from vw_srs where %1" ).arg( sqlFilter );
589 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
591 if ( result == SQLITE_OK )
593 QTreeWidgetItem *newItem =
nullptr;
594 while ( sqlite3_step( stmt ) == SQLITE_ROW )
596 newItem =
new QTreeWidgetItem( mUserProjList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
602 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
603 newItem->setText( AuthidColumn, QStringLiteral(
"USER:%1" ).arg( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ).toInt() ) );
607 sqlite3_finalize( stmt );
608 sqlite3_close( database );
610 mUserProjListDone =
true;
613 void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
619 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
625 mGeoList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Geographic Coordinate Systems" ) ) );
627 QFont fontTemp = mGeoList->font( 0 );
628 fontTemp.setItalic(
true );
629 fontTemp.setBold(
true );
630 mGeoList->setFont( 0, fontTemp );
634 mProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Projected Coordinate Systems" ) ) );
636 fontTemp = mProjList->font( 0 );
637 fontTemp.setItalic(
true );
638 fontTemp.setBold(
true );
639 mProjList->setFont( 0, fontTemp );
647 if ( !QFileInfo::exists( mSrsDatabaseFileName ) )
649 mProjListDone =
true;
655 int rc = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
660 showDBMissingWarning( mSrsDatabaseFileName );
664 const char *tail =
nullptr;
665 sqlite3_stmt *stmt =
nullptr;
669 QString sql = QStringLiteral(
"select description, srs_id, upper(auth_name||':'||auth_id), is_geo, name, parameters, deprecated from vw_srs where %1 order by name,description" )
672 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
674 if ( rc == SQLITE_OK )
676 QTreeWidgetItem *newItem =
nullptr;
679 QString previousSrsType( QLatin1String(
"" ) );
680 QTreeWidgetItem *previousSrsTypeNode =
nullptr;
682 while ( sqlite3_step( stmt ) == SQLITE_ROW )
685 int isGeo = sqlite3_column_int( stmt, 3 );
690 newItem =
new QTreeWidgetItem( mGeoList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
693 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
696 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
701 QTreeWidgetItem *node =
nullptr;
702 QString srsType = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 4 ) );
705 if ( srsType == previousSrsType )
707 node = previousSrsTypeNode;
712 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( srsType, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
713 if ( nodes.isEmpty() )
717 node =
new QTreeWidgetItem( mProjList, QStringList( srsType ) );
718 QFont fontTemp = node->font( 0 );
719 fontTemp.setItalic(
true );
720 node->setFont( 0, fontTemp );
724 node = nodes.first();
727 previousSrsType = srsType;
728 previousSrsTypeNode = node;
731 newItem =
new QTreeWidgetItem( node, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
733 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
735 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
737 newItem->parent()->setExpanded(
true );
741 newItem->setData( 0, RoleDeprecated, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 6 ) ) );
742 newItem->setHidden( cbxHideDeprecated->isChecked() );
744 mProjList->setExpanded(
true );
748 sqlite3_finalize( stmt );
750 sqlite3_close( database );
752 mProjListDone =
true;
756 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
766 lstCoordinateSystems->scrollToItem( current );
770 if ( current->childCount() == 0 )
775 teSelected->setText( selectedName() );
776 updateBoundsPreview();
778 QList<QTreeWidgetItem *> nodes = lstRecent->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly, QgisCrsIdColumn );
779 if ( !nodes.isEmpty() )
781 QgsDebugMsgLevel( QString(
"found srs %1 in recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
782 lstRecent->setCurrentItem( nodes.first() );
786 QgsDebugMsgLevel( QString(
"srs %1 not recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
787 lstRecent->clearSelection();
788 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
794 current->setSelected(
false );
795 teProjection->clear();
797 lstRecent->clearSelection();
801 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current,
int column )
815 if ( current->childCount() == 0 )
819 void QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
829 lstRecent->scrollToItem( current );
831 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
832 if ( !nodes.isEmpty() )
833 lstCoordinateSystems->setCurrentItem( nodes.first() );
836 void QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked( QTreeWidgetItem *current,
int column )
848 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
849 if ( !nodes.isEmpty() )
853 void QgsProjectionSelectionTreeWidget::updateFilter()
855 QString filterTxtCopy = leSearch->text();
856 filterTxtCopy.replace( QRegExp(
"\\s+" ), QStringLiteral(
".*" ) );
857 QRegExp re( filterTxtCopy, Qt::CaseInsensitive );
859 const bool hideDeprecated = cbxHideDeprecated->isChecked();
861 auto filterTreeWidget = [ = ]( QTreeWidget * tree )
863 QTreeWidgetItemIterator itr( tree );
866 if ( ( *itr )->childCount() == 0 )
868 if ( hideDeprecated && ( *itr )->data( 0, RoleDeprecated ).toBool() )
870 ( *itr )->setHidden(
true );
871 if ( ( *itr )->isSelected() )
873 ( *itr )->setSelected(
false );
874 teProjection->clear();
878 else if ( ( *itr )->text( NameColumn ).contains( re )
879 || ( *itr )->text( AuthidColumn ).contains( re )
882 ( *itr )->setHidden(
false );
883 QTreeWidgetItem *parent = ( *itr )->parent();
886 parent->setExpanded(
true );
887 parent->setHidden(
false );
888 parent = parent->parent();
893 ( *itr )->setHidden(
true );
898 ( *itr )->setHidden(
true );
905 filterTreeWidget( lstRecent );
908 filterTreeWidget( lstCoordinateSystems );
915 mPushProjectionToFront =
true;
919 long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch(
const QString &sql )
928 const char *tail =
nullptr;
929 sqlite3_stmt *stmt =
nullptr;
936 if ( QFileInfo::exists( databaseFileName ) )
938 result = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
945 showDBMissingWarning( databaseFileName );
949 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
951 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
953 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
954 srsId = srsIdString.toLong();
956 sqlite3_finalize( stmt );
957 sqlite3_close( database );
964 result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
967 QgsDebugMsg( QString(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
973 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
975 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
977 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
978 srsId = srsIdString.toLong();
982 sqlite3_finalize( stmt );
983 sqlite3_close( database );
988 void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
990 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
991 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
1014 mPreviewBand->
setColor( QColor( 255, 0, 0, 65 ) );
1016 extent.
scale( 1.1 );
1017 mAreaCanvas->setExtent( extent );
1018 mAreaCanvas->refresh();
1019 mPreviewBand->show();
1020 QString extentString = tr(
"Extent: %1, %2, %3, %4" )
1024 .arg( rect.
yMaximum(), 0,
'f', 2 );
1025 QString proj4String = tr(
"Proj4: %1" ).arg( selectedProj4String() );
1026 teProjection->setText( extentString +
"\n" + proj4String );
1030 mPreviewBand->hide();
1031 mAreaCanvas->zoomToFullExtent();
1032 QString extentString = tr(
"Extent: Extent not known" );
1033 QString proj4String = tr(
"Proj4: %1" ).arg( selectedProj4String() );
1034 teProjection->setText( extentString +
"\n" + proj4String );
1038 QStringList QgsProjectionSelectionTreeWidget::authorities()
1041 const char *tail =
nullptr;
1042 sqlite3_stmt *stmt =
nullptr;
1044 int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
1047 QgsDebugMsg( QString(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
1049 return QStringList();
1052 QString sql = QStringLiteral(
"select distinct auth_name from tbl_srs" );
1053 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
1055 QStringList authorities;
1056 if ( result == SQLITE_OK )
1058 while ( sqlite3_step( stmt ) == SQLITE_ROW )
1060 authorities << QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
1066 sqlite3_finalize( stmt );
1067 sqlite3_close( database );
1072 QString QgsProjectionSelectionTreeWidget::sqlSafeString(
const QString &theSQL )
const 1074 QString retval = theSQL;
1075 retval.replace(
'\\', QLatin1String(
"\\\\" ) );
1076 retval.replace(
'\"', QLatin1String(
"\\\"" ) );
1077 retval.replace(
'\'', QLatin1String(
"\\'" ) );
1078 retval.replace(
'%', QLatin1String(
"\\%" ) );
1082 void QgsProjectionSelectionTreeWidget::showDBMissingWarning(
const QString &fileName )
1085 QMessageBox::critical(
this, tr(
"Resource Location Error" ),
1086 tr(
"Error reading database file from: \n %1\n" 1087 "Because of this the projection selector will not work…" )
void setWidth(int width)
Sets the width of the line.
A rectangle specified with double values.
This class is a composition of two QSettings instances:
static QString qgisUserDatabaseFilePath()
Returns the path to the user qgis.db file.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QString toProj4() const
Returns a Proj4 string representation of this CRS.
void setPenWidth(int width)
A geometry is the spatial representation of a feature.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Internal ID used by QGIS in the local SQLite database.
void setToGeometry(const QgsGeometry &geom, QgsVectorLayer *layer)
Sets this rubber band to the geometry of an existing feature.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
#define QgsDebugMsgLevel(str, level)
static QStringList recentProjections()
Returns a list of recently used projections.
A class for drawing transient features (e.g.
void setCenter(const QgsPointXY &point)
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
A class for marking vertices of features using e.g.
static QString pkgDataPath()
Returns the common root path of all application data directories.
double area() const
Returns the area of the rectangle.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
const int USER_CRS_START_ID
Magick number that determines whether a projection crsid is a system (srs.db) or user (~/...
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
This class represents a coordinate reference system (CRS).
double xMinimum() const
Returns the x minimum value (left side of rectangle).
static QString srsDatabaseFilePath()
Returns the path to the srs.db file.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
void setColor(const QColor &color)
Sets the color for the rubberband.
QgsPointXY center() const
Returns the center point of the rectangle.
QgsRectangle bounds() const
Returns the approximate bounds for the region the CRS is usable within.
void setColor(const QColor &color)
Sets the stroke color for the marker.
Represents a vector layer which manages a vector based data sets.
void setIconType(int iconType)
QString authid() const
Returns the authority identifier for the CRS.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.