27 #include <QHeaderView> 28 #include <QResizeEvent> 29 #include <QMessageBox> 36 QFont f = teProjection->font();
37 f.setPointSize( f.pointSize() - 2 );
38 teProjection->setFont( f );
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 );
49 mAreaCanvas->setVisible( mShowMap );
51 if ( QDialog *dlg = qobject_cast<QDialog *>( parent ) )
60 lstCoordinateSystems->header()->setSectionResizeMode( AuthidColumn, QHeaderView::Stretch );
61 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
62 lstCoordinateSystems->header()->setSectionResizeMode( QgisCrsIdColumn, QHeaderView::Fixed );
65 lstCoordinateSystems->setColumnHidden( QgisCrsIdColumn,
true );
67 lstRecent->header()->setSectionResizeMode( AuthidColumn, QHeaderView::Stretch );
68 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
69 lstRecent->header()->setSectionResizeMode( QgisCrsIdColumn, QHeaderView::Fixed );
72 lstRecent->setColumnHidden( QgisCrsIdColumn,
true );
76 mCheckBoxNoProjection->setHidden(
true );
77 mCheckBoxNoProjection->setEnabled(
false );
79 connect( mCheckBoxNoProjection, &QCheckBox::toggled,
this, [ = ](
bool checked )
81 if ( mCheckBoxNoProjection->isEnabled() )
83 mFrameProjections->setDisabled( checked );
90 if ( !mPushProjectionToFront )
96 long crsId = selectedCrsId();
101 mRecentProjections.removeAll( QString::number( crsId ) );
102 mRecentProjections.prepend( QString::number( crsId ) );
104 while ( mRecentProjections.size() > 8 )
106 mRecentProjections.removeLast();
111 settings.
setValue( QStringLiteral(
"/UI/recentProjections" ), mRecentProjections );
115 QStringList projectionsProj4;
116 QStringList projectionsAuthId;
117 for (
int i = 0; i < mRecentProjections.size(); i++ )
129 settings.
setValue( QStringLiteral(
"/UI/recentProjectionsProj4" ), projectionsProj4 );
130 settings.
setValue( QStringLiteral(
"/UI/recentProjectionsAuthId" ), projectionsAuthId );
135 lstCoordinateSystems->header()->resizeSection( NameColumn, event->size().width() - 240 );
136 lstCoordinateSystems->header()->resizeSection( AuthidColumn, 240 );
137 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
139 lstRecent->header()->resizeSection( NameColumn, event->size().width() - 240 );
140 lstRecent->header()->resizeSection( AuthidColumn, 240 );
141 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
151 loadCrsList( &mCrsFilter );
152 loadUserCrsList( &mCrsFilter );
154 if ( !mRecentProjListDone )
156 for (
int i = mRecentProjections.size() - 1; i >= 0; i-- )
157 insertRecent( mRecentProjections.at( i ).toLong() );
158 mRecentProjListDone =
true;
167 QWidget::showEvent( event );
171 QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter )
173 QString sqlExpression = QStringLiteral(
"1" );
174 QMap<QString, QStringList> authParts;
177 return sqlExpression;
197 const auto authIds { *crsFilter };
198 for (
const QString &auth_id : authIds )
200 QStringList parts = auth_id.split(
':' );
202 if ( parts.size() < 2 )
205 authParts[ parts.at( 0 ).toUpper()].append( parts.at( 1 ).toUpper() );
208 if ( authParts.isEmpty() )
209 return sqlExpression;
211 if ( !authParts.isEmpty() )
213 QString prefix = QStringLiteral(
" AND (" );
214 for (
auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
216 sqlExpression += QStringLiteral(
"%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
219 it.value().join( QStringLiteral(
"','" ) ) );
220 prefix = QStringLiteral(
" OR " );
222 sqlExpression +=
')';
227 return sqlExpression;
230 void QgsProjectionSelectionTreeWidget::applySelection(
int column, QString value )
232 if ( !mProjListDone || !mUserProjListDone )
235 mSearchColumn = column;
236 mSearchValue = value;
240 if ( column == QgsProjectionSelectionTreeWidget::None )
243 column = mSearchColumn;
244 value = mSearchValue;
246 mSearchColumn = QgsProjectionSelectionTreeWidget::None;
247 mSearchValue.clear();
250 if ( column == QgsProjectionSelectionTreeWidget::None )
253 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( value, Qt::MatchExactly | Qt::MatchRecursive, column );
254 if ( !nodes.isEmpty() )
256 QgsDebugMsgLevel( QStringLiteral(
"found %1,%2" ).arg( column ).arg( value ), 4 );
257 lstCoordinateSystems->setCurrentItem( nodes.first() );
261 QgsDebugMsgLevel( QStringLiteral(
"nothing found for %1,%2" ).arg( column ).arg( value ), 4 );
263 lstCoordinateSystems->clearSelection();
264 lstRecent->clearSelection();
265 teProjection->clear();
269 void QgsProjectionSelectionTreeWidget::insertRecent(
long crsId )
271 if ( !mProjListDone || !mUserProjListDone )
274 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( QString::number( crsId ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
275 if ( nodes.isEmpty() )
278 lstRecent->insertTopLevelItem( 0,
new QTreeWidgetItem( lstRecent, QStringList()
279 << nodes.first()->text( NameColumn )
280 << nodes.first()->text( AuthidColumn )
281 << nodes.first()->text( QgisCrsIdColumn ) ) );
285 QString QgsProjectionSelectionTreeWidget::selectedName()
288 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
289 return lvi ? lvi->text( NameColumn ) : QString();
296 mCheckBoxNoProjection->setChecked(
true );
300 mCheckBoxNoProjection->setChecked(
false );
301 applySelection( AuthidColumn, crs.
authid() );
307 mAreaCanvas->setCanvasRect( rect );
312 return mAreaCanvas->canvasRect();
316 QString QgsProjectionSelectionTreeWidget::selectedProj4String()
324 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
325 if ( !item || item->text( QgisCrsIdColumn ).isEmpty() )
328 long srsId = item->text( QgisCrsIdColumn ).toLong();
333 QString QgsProjectionSelectionTreeWidget::selectedWktString()
335 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
336 if ( !item || item->text( QgisCrsIdColumn ).isEmpty() )
339 long srsId = item->text( QgisCrsIdColumn ).toLong();
344 QString QgsProjectionSelectionTreeWidget::getSelectedExpression(
const QString &expression )
const 353 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
354 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
361 QString databaseFileName;
365 if ( !QFileInfo::exists( databaseFileName ) )
372 databaseFileName = mSrsDatabaseFileName;
381 int rc = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
385 "Because of this the projection selector will not work…" ).arg( databaseFileName ),
391 const char *tail =
nullptr;
392 sqlite3_stmt *stmt =
nullptr;
393 QString sql = QStringLiteral(
"select %1 from tbl_srs where srs_id=%2" )
395 lvi->text( QgisCrsIdColumn ) );
397 QgsDebugMsgLevel( QStringLiteral(
"Finding selected attribute using : %1" ).arg( sql ), 4 );
398 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
400 QString attributeValue;
401 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
404 attributeValue = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
408 sqlite3_finalize( stmt );
410 sqlite3_close( database );
413 return attributeValue;
418 if ( mCheckBoxNoProjection->isEnabled() && mCheckBoxNoProjection->isChecked() )
421 int srid = getSelectedExpression( QStringLiteral(
"srs_id" ) ).toLong();
430 mCheckBoxNoProjection->setVisible( show );
431 mCheckBoxNoProjection->setEnabled( show );
434 mFrameProjections->setDisabled( mCheckBoxNoProjection->isChecked() );
441 mAreaCanvas->setVisible( show );
446 return !mCheckBoxNoProjection->isHidden();
456 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
457 if ( mCheckBoxNoProjection->isChecked() )
460 return item && !item->text( QgisCrsIdColumn ).isEmpty();
463 long QgsProjectionSelectionTreeWidget::selectedCrsId()
465 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
467 if ( item && !item->text( QgisCrsIdColumn ).isEmpty() )
468 return lstCoordinateSystems->currentItem()->text( QgisCrsIdColumn ).toLong();
476 mCrsFilter = crsFilter;
477 mProjListDone =
false;
478 mUserProjListDone =
false;
479 lstCoordinateSystems->clear();
482 void QgsProjectionSelectionTreeWidget::loadUserCrsList( QSet<QString> *crsFilter )
484 if ( mUserProjListDone )
487 QgsDebugMsgLevel( QStringLiteral(
"Fetching user projection list..." ), 4 );
490 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
494 mUserProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"User Defined Coordinate Systems" ) ) );
496 QFont fontTemp = mUserProjList->font( 0 );
497 fontTemp.setItalic(
true );
498 fontTemp.setBold(
true );
499 mUserProjList->setFont( 0, fontTemp );
509 if ( !QFileInfo::exists( databaseFileName ) )
511 QgsDebugMsg( QStringLiteral(
"Users qgis.db not found...skipping" ) );
512 mUserProjListDone =
true;
517 const char *tail =
nullptr;
518 sqlite3_stmt *stmt =
nullptr;
520 int result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
527 showDBMissingWarning( databaseFileName );
532 QString sql = QStringLiteral(
"select description, srs_id from vw_srs where %1" ).arg( sqlFilter );
534 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
536 if ( result == SQLITE_OK )
538 QTreeWidgetItem *newItem =
nullptr;
539 while ( sqlite3_step( stmt ) == SQLITE_ROW )
541 newItem =
new QTreeWidgetItem( mUserProjList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
547 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
548 newItem->setText( AuthidColumn, QStringLiteral(
"USER:%1" ).arg( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ).toInt() ) );
552 sqlite3_finalize( stmt );
553 sqlite3_close( database );
555 mUserProjListDone =
true;
558 void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
564 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
570 mGeoList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Geographic Coordinate Systems" ) ) );
572 QFont fontTemp = mGeoList->font( 0 );
573 fontTemp.setItalic(
true );
574 fontTemp.setBold(
true );
575 mGeoList->setFont( 0, fontTemp );
579 mProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Projected Coordinate Systems" ) ) );
581 fontTemp = mProjList->font( 0 );
582 fontTemp.setItalic(
true );
583 fontTemp.setBold(
true );
584 mProjList->setFont( 0, fontTemp );
592 if ( !QFileInfo::exists( mSrsDatabaseFileName ) )
594 mProjListDone =
true;
600 int rc = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
605 showDBMissingWarning( mSrsDatabaseFileName );
609 const char *tail =
nullptr;
610 sqlite3_stmt *stmt =
nullptr;
614 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" )
617 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
619 if ( rc == SQLITE_OK )
621 QTreeWidgetItem *newItem =
nullptr;
624 QString previousSrsType;
625 QTreeWidgetItem *previousSrsTypeNode =
nullptr;
627 while ( sqlite3_step( stmt ) == SQLITE_ROW )
630 int isGeo = sqlite3_column_int( stmt, 3 );
635 newItem =
new QTreeWidgetItem( mGeoList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
638 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
641 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
646 QTreeWidgetItem *node =
nullptr;
647 QString srsType = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 4 ) );
648 if ( srsType.isEmpty() )
649 srsType = tr(
"Other" );
653 if ( srsType == previousSrsType )
655 node = previousSrsTypeNode;
660 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( srsType, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
661 if ( nodes.isEmpty() )
665 node =
new QTreeWidgetItem( mProjList, QStringList( srsType ) );
666 QFont fontTemp = node->font( 0 );
667 fontTemp.setItalic(
true );
668 node->setFont( 0, fontTemp );
672 node = nodes.first();
675 previousSrsType = srsType;
676 previousSrsTypeNode = node;
679 newItem =
new QTreeWidgetItem( node, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
681 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
683 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
685 newItem->parent()->setExpanded(
true );
689 newItem->setData( 0, RoleDeprecated, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 6 ) ) );
690 newItem->setHidden( cbxHideDeprecated->isChecked() );
692 mProjList->setExpanded(
true );
696 sqlite3_finalize( stmt );
698 sqlite3_close( database );
700 mProjListDone =
true;
704 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
714 lstCoordinateSystems->scrollToItem( current );
718 if ( current->childCount() == 0 )
723 updateBoundsPreview();
725 QList<QTreeWidgetItem *> nodes = lstRecent->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly, QgisCrsIdColumn );
726 if ( !nodes.isEmpty() )
728 QgsDebugMsgLevel( QStringLiteral(
"found srs %1 in recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
729 lstRecent->setCurrentItem( nodes.first() );
733 QgsDebugMsgLevel( QStringLiteral(
"srs %1 not recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
734 lstRecent->clearSelection();
735 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
741 current->setSelected(
false );
742 teProjection->clear();
743 lstRecent->clearSelection();
747 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current,
int column )
761 if ( current->childCount() == 0 )
765 void QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
775 lstRecent->scrollToItem( current );
777 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
778 if ( !nodes.isEmpty() )
779 lstCoordinateSystems->setCurrentItem( nodes.first() );
782 void QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked( QTreeWidgetItem *current,
int column )
794 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
795 if ( !nodes.isEmpty() )
799 void QgsProjectionSelectionTreeWidget::updateFilter()
801 QString filterTxtCopy = leSearch->text();
802 filterTxtCopy.replace( QRegExp(
"\\s+" ), QStringLiteral(
".*" ) );
803 QRegExp re( filterTxtCopy, Qt::CaseInsensitive );
805 const bool hideDeprecated = cbxHideDeprecated->isChecked();
807 auto filterTreeWidget = [ = ]( QTreeWidget * tree )
809 QTreeWidgetItemIterator itr( tree );
812 if ( ( *itr )->childCount() == 0 )
814 if ( hideDeprecated && ( *itr )->data( 0, RoleDeprecated ).toBool() )
816 ( *itr )->setHidden(
true );
817 if ( ( *itr )->isSelected() )
819 ( *itr )->setSelected(
false );
820 teProjection->clear();
823 else if ( ( *itr )->text( NameColumn ).contains( re )
824 || ( *itr )->text( AuthidColumn ).contains( re )
827 ( *itr )->setHidden(
false );
828 QTreeWidgetItem *parent = ( *itr )->parent();
831 parent->setExpanded(
true );
832 parent->setHidden(
false );
833 parent = parent->parent();
838 ( *itr )->setHidden(
true );
843 ( *itr )->setHidden(
true );
850 filterTreeWidget( lstRecent );
853 filterTreeWidget( lstCoordinateSystems );
860 mPushProjectionToFront =
true;
864 long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch(
const QString &sql )
873 const char *tail =
nullptr;
874 sqlite3_stmt *stmt =
nullptr;
881 if ( QFileInfo::exists( databaseFileName ) )
883 result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
890 showDBMissingWarning( databaseFileName );
894 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
896 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
898 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
899 srsId = srsIdString.toLong();
901 sqlite3_finalize( stmt );
902 sqlite3_close( database );
909 result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
912 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
918 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
920 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
922 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
923 srsId = srsIdString.toLong();
927 sqlite3_finalize( stmt );
928 sqlite3_close( database );
933 void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
935 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
936 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
944 QString extentString = tr(
"Extent not known" );
945 mAreaCanvas->setPreviewRect( rect );
948 extentString = QStringLiteral(
"%1, %2, %3, %4" )
955 const QString extentHtml = QStringLiteral(
"<dt><b>%1</b></dt><dd>%2</dd>" ).arg( tr(
"Extent" ), extentString );
956 const QString wktString = tr(
"<dt><b>%1</b></dt><dd><code>%2</code></dd>" ).arg( tr(
"WKT" ), selectedWktString().replace(
'\n', QStringLiteral(
"<br>" ) ).replace(
' ', QStringLiteral(
" " ) ) );
957 const QString proj4String = tr(
"<dt><b>%1</b></dt><dd><code>%2</code></dd>" ).arg( tr(
"Proj4" ), selectedProj4String() );
960 const int smallerPointSize = std::max( font().pointSize() - 1, 8 );
962 const int smallerPointSize = std::max( font().pointSize() - 2, 6 );
965 teProjection->setText( QStringLiteral(
"<div style=\"font-size: %1pt\"><h3>%2</h3><dl>" ).arg( smallerPointSize ).arg( selectedName() ) + wktString + proj4String + extentHtml + QStringLiteral(
"</dl></div>" ) );
968 QStringList QgsProjectionSelectionTreeWidget::authorities()
971 const char *tail =
nullptr;
972 sqlite3_stmt *stmt =
nullptr;
974 int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
977 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
979 return QStringList();
982 QString sql = QStringLiteral(
"select distinct auth_name from tbl_srs" );
983 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
985 QStringList authorities;
986 if ( result == SQLITE_OK )
988 while ( sqlite3_step( stmt ) == SQLITE_ROW )
990 authorities << QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
996 sqlite3_finalize( stmt );
997 sqlite3_close( database );
1002 QString QgsProjectionSelectionTreeWidget::sqlSafeString(
const QString &theSQL )
const 1004 QString retval = theSQL;
1005 retval.replace(
'\\', QLatin1String(
"\\\\" ) );
1006 retval.replace(
'\"', QLatin1String(
"\\\"" ) );
1007 retval.replace(
'\'', QLatin1String(
"\\'" ) );
1008 retval.replace(
'%', QLatin1String(
"\\%" ) );
1012 void QgsProjectionSelectionTreeWidget::showDBMissingWarning(
const QString &fileName )
1015 QMessageBox::critical(
this, tr(
"Resource Location Error" ),
1016 tr(
"Error reading database file from: \n %1\n" 1017 "Because of this the projection selector will not work…" )
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.
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.
Full WKT2 string, conforming to ISO 19162:2015(E) / OGC 12-063r5 with all possible nodes and new keyw...
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Internal ID used by QGIS in the local SQLite database.
#define QgsDebugMsgLevel(str, level)
static QStringList recentProjections()
Returns a list of recently used projections.
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).
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.
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).
QgsRectangle bounds() const
Returns the approximate bounds for the region the CRS is usable within.
QString authid() const
Returns the authority identifier for the CRS.
static QgsCoordinateReferenceSystem fromSrsId(long srsId)
Creates a CRS from a specified QGIS SRS ID.
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.