28 #include <QHeaderView>
29 #include <QResizeEvent>
30 #include <QMessageBox>
37 QFont f = teProjection->font();
38 f.setPointSize( f.pointSize() - 2 );
39 teProjection->setFont( f );
41 leSearch->setShowSearchIcon(
true );
43 connect( lstCoordinateSystems, &QTreeWidget::itemDoubleClicked,
this, &QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked );
44 connect( lstRecent, &QTreeWidget::itemDoubleClicked,
this, &QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked );
45 connect( lstCoordinateSystems, &QTreeWidget::currentItemChanged,
this, &QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged );
46 connect( lstRecent, &QTreeWidget::currentItemChanged,
this, &QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged );
47 connect( cbxHideDeprecated, &QCheckBox::stateChanged,
this, &QgsProjectionSelectionTreeWidget::updateFilter );
48 connect( leSearch, &QgsFilterLineEdit::textChanged,
this, &QgsProjectionSelectionTreeWidget::updateFilter );
50 mAreaCanvas->setVisible( mShowMap );
52 if ( QDialog *dlg = qobject_cast<QDialog *>( parent ) )
61 lstCoordinateSystems->header()->setSectionResizeMode( AuthidColumn, QHeaderView::Stretch );
62 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
63 lstCoordinateSystems->header()->setSectionResizeMode( QgisCrsIdColumn, QHeaderView::Fixed );
66 lstCoordinateSystems->setColumnHidden( QgisCrsIdColumn,
true );
68 lstRecent->header()->setSectionResizeMode( AuthidColumn, QHeaderView::Stretch );
69 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
70 lstRecent->header()->setSectionResizeMode( QgisCrsIdColumn, QHeaderView::Fixed );
73 lstRecent->setColumnHidden( QgisCrsIdColumn,
true );
77 mCheckBoxNoProjection->setHidden(
true );
78 mCheckBoxNoProjection->setEnabled(
false );
79 connect( mCheckBoxNoProjection, &QCheckBox::toggled,
this, [ = ]
87 connect( mCheckBoxNoProjection, &QCheckBox::toggled,
this, [ = ](
bool checked )
89 if ( mCheckBoxNoProjection->isEnabled() )
91 mFrameProjections->setDisabled( checked );
96 mSplitter->restoreState( settings.value( QStringLiteral(
"Windows/ProjectionSelector/splitterState" ) ).toByteArray() );
101 if ( !mPushProjectionToFront )
107 long crsId = selectedCrsId();
112 settings.
setValue( QStringLiteral(
"Windows/ProjectionSelector/splitterState" ), mSplitter->saveState() );
119 lstCoordinateSystems->header()->resizeSection( NameColumn, event->size().width() - 240 );
120 lstCoordinateSystems->header()->resizeSection( AuthidColumn, 240 );
121 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
123 lstRecent->header()->resizeSection( NameColumn, event->size().width() - 240 );
124 lstRecent->header()->resizeSection( AuthidColumn, 240 );
125 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
135 loadCrsList( &mCrsFilter );
136 loadUserCrsList( &mCrsFilter );
138 if ( !mRecentProjListDone )
142 mRecentProjListDone =
true;
146 mBlockSignals =
true;
148 mBlockSignals =
false;
153 QWidget::showEvent( event );
157 QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter )
159 QString sqlExpression = QStringLiteral(
"1" );
160 QMap<QString, QStringList> authParts;
163 return sqlExpression;
183 const auto authIds { *crsFilter };
184 for (
const QString &auth_id : authIds )
186 QStringList parts = auth_id.split(
':' );
188 if ( parts.size() < 2 )
191 authParts[ parts.at( 0 ).toUpper()].append( parts.at( 1 ).toUpper() );
194 if ( authParts.isEmpty() )
195 return sqlExpression;
197 if ( !authParts.isEmpty() )
199 QString prefix = QStringLiteral(
" AND (" );
200 for (
auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
202 sqlExpression += QStringLiteral(
"%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
205 it.value().join( QLatin1String(
"','" ) ) );
206 prefix = QStringLiteral(
" OR " );
208 sqlExpression +=
')';
213 return sqlExpression;
216 void QgsProjectionSelectionTreeWidget::applySelection(
int column, QString value )
218 if ( !mProjListDone || !mUserProjListDone )
221 mSearchColumn = column;
222 mSearchValue = value;
226 if ( column == QgsProjectionSelectionTreeWidget::None )
229 column = mSearchColumn;
230 value = mSearchValue;
232 mSearchColumn = QgsProjectionSelectionTreeWidget::None;
233 mSearchValue.clear();
236 if ( column == QgsProjectionSelectionTreeWidget::None )
239 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( value, Qt::MatchExactly | Qt::MatchRecursive, column );
240 if ( !nodes.isEmpty() )
242 QgsDebugMsgLevel( QStringLiteral(
"found %1,%2" ).arg( column ).arg( value ), 4 );
243 lstCoordinateSystems->setCurrentItem( nodes.first() );
247 QgsDebugMsgLevel( QStringLiteral(
"nothing found for %1,%2" ).arg( column ).arg( value ), 4 );
249 lstCoordinateSystems->clearSelection();
250 lstRecent->clearSelection();
251 teProjection->clear();
257 if ( !mProjListDone || !mUserProjListDone )
260 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( QString::number(
crs.
srsid() ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
261 if ( nodes.isEmpty() )
264 lstRecent->insertTopLevelItem( 0,
new QTreeWidgetItem( lstRecent, QStringList()
265 << nodes.first()->text( NameColumn )
266 << nodes.first()->text( AuthidColumn )
267 << nodes.first()->text( QgisCrsIdColumn ) ) );
271 QString QgsProjectionSelectionTreeWidget::selectedName()
274 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
275 return lvi ? lvi->text( NameColumn ) : QString();
282 mCheckBoxNoProjection->setChecked(
true );
286 bool changed =
false;
289 changed = mDeferredLoadCrs !=
crs;
290 mDeferredLoadCrs =
crs;
292 mBlockSignals =
true;
293 mCheckBoxNoProjection->setChecked(
false );
294 mBlockSignals =
false;
297 applySelection( AuthidColumn,
crs.
authid() );
299 loadUnknownCrs(
crs );
310 mAreaCanvas->setCanvasRect( rect );
315 return mAreaCanvas->canvasRect();
318 QString QgsProjectionSelectionTreeWidget::getSelectedExpression(
const QString &expression )
const
327 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
328 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
335 QString databaseFileName;
339 if ( !QFileInfo::exists( databaseFileName ) )
346 databaseFileName = mSrsDatabaseFileName;
355 int rc = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
359 "Because of this the projection selector will not work…" ).arg( databaseFileName ),
365 const char *tail =
nullptr;
366 sqlite3_stmt *stmt =
nullptr;
367 QString sql = QStringLiteral(
"select %1 from tbl_srs where srs_id=%2" )
369 lvi->text( QgisCrsIdColumn ) );
371 QgsDebugMsgLevel( QStringLiteral(
"Finding selected attribute using : %1" ).arg( sql ), 4 );
372 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
374 QString attributeValue;
375 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
378 attributeValue = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
382 sqlite3_finalize( stmt );
384 sqlite3_close( database );
387 return attributeValue;
392 if ( mCheckBoxNoProjection->isEnabled() && mCheckBoxNoProjection->isChecked() )
395 if ( !mInitialized && mDeferredLoadCrs.
isValid() )
396 return mDeferredLoadCrs;
398 const QString srsIdString = getSelectedExpression( QStringLiteral(
"srs_id" ) );
399 if ( !srsIdString.isEmpty() )
401 int srid = srsIdString.toLong();
410 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
411 if ( lvi && lvi->data( 0, RoleWkt ).isValid() )
413 else if ( lvi && lvi->data( 0, RoleProj ).isValid() )
422 mCheckBoxNoProjection->setVisible( show );
423 mCheckBoxNoProjection->setEnabled( show );
426 mFrameProjections->setDisabled( mCheckBoxNoProjection->isChecked() );
433 mAreaCanvas->setVisible( show );
438 return !mCheckBoxNoProjection->isHidden();
443 mCheckBoxNoProjection->setText( text );
453 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
454 if ( mCheckBoxNoProjection->isChecked() )
456 else if ( !mInitialized && mDeferredLoadCrs.
isValid() )
459 return item && ( !item->text( QgisCrsIdColumn ).isEmpty() || item->data( 0, RoleWkt ).isValid() );
462 long QgsProjectionSelectionTreeWidget::selectedCrsId()
464 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
466 if ( item && !item->text( QgisCrsIdColumn ).isEmpty() )
467 return lstCoordinateSystems->currentItem()->text( QgisCrsIdColumn ).toLong();
475 mCrsFilter = crsFilter;
476 mProjListDone =
false;
477 mUserProjListDone =
false;
478 lstCoordinateSystems->clear();
481 void QgsProjectionSelectionTreeWidget::loadUserCrsList( QSet<QString> *crsFilter )
483 if ( mUserProjListDone )
486 QgsDebugMsgLevel( QStringLiteral(
"Fetching user projection list..." ), 4 );
490 mUserProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"User Defined Coordinate Systems" ) ) );
491 mUserProjList->setFlags( mUserProjList->flags() & ~Qt::ItemIsSelectable );
493 QFont fontTemp = mUserProjList->font( 0 );
494 fontTemp.setItalic(
true );
495 fontTemp.setBold(
true );
496 mUserProjList->setFont( 0, fontTemp );
502 const QString authid = QStringLiteral(
"USER:%1" ).arg( details.id );
503 if ( crsFilter && !crsFilter->isEmpty() && !crsFilter->contains( authid ) && !crsFilter->contains( authid.toLower() ) )
506 QTreeWidgetItem *newItem =
new QTreeWidgetItem( mUserProjList, QStringList() << details.name );
507 newItem->setText( QgisCrsIdColumn, QString::number( details.id ) );
508 newItem->setText( AuthidColumn, authid );
511 mUserProjListDone =
true;
514 void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
520 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
526 mGeoList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Geographic Coordinate Systems" ) ) );
527 mGeoList->setFlags( mGeoList->flags() & ~Qt::ItemIsSelectable );
529 QFont fontTemp = mGeoList->font( 0 );
530 fontTemp.setItalic(
true );
531 fontTemp.setBold(
true );
532 mGeoList->setFont( 0, fontTemp );
536 mProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Projected Coordinate Systems" ) ) );
537 mProjList->setFlags( mProjList->flags() & ~Qt::ItemIsSelectable );
539 fontTemp = mProjList->font( 0 );
540 fontTemp.setItalic(
true );
541 fontTemp.setBold(
true );
542 mProjList->setFont( 0, fontTemp );
550 if ( !QFileInfo::exists( mSrsDatabaseFileName ) )
552 mProjListDone =
true;
558 int rc = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
563 showDBMissingWarning( mSrsDatabaseFileName );
567 const char *tail =
nullptr;
568 sqlite3_stmt *stmt =
nullptr;
572 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" )
575 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
577 if ( rc == SQLITE_OK )
579 QTreeWidgetItem *newItem =
nullptr;
582 QString previousSrsType;
583 QTreeWidgetItem *previousSrsTypeNode =
nullptr;
585 while ( sqlite3_step( stmt ) == SQLITE_ROW )
588 int isGeo = sqlite3_column_int( stmt, 3 );
593 newItem =
new QTreeWidgetItem( mGeoList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
596 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
599 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
604 QTreeWidgetItem *node =
nullptr;
605 QString srsType = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 4 ) );
606 if ( srsType.isEmpty() )
607 srsType = tr(
"Other" );
611 if ( srsType == previousSrsType )
613 node = previousSrsTypeNode;
618 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( srsType, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
619 if ( nodes.isEmpty() )
623 node =
new QTreeWidgetItem( mProjList, QStringList( srsType ) );
624 node->setFlags( node->flags() & ~Qt::ItemIsSelectable );
626 QFont fontTemp = node->font( 0 );
627 fontTemp.setItalic(
true );
628 node->setFont( 0, fontTemp );
632 node = nodes.first();
635 previousSrsType = srsType;
636 previousSrsTypeNode = node;
639 newItem =
new QTreeWidgetItem( node, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
641 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
643 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
645 newItem->parent()->setExpanded(
true );
649 newItem->setData( 0, RoleDeprecated, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 6 ) ) );
650 newItem->setHidden( cbxHideDeprecated->isChecked() );
652 mProjList->setExpanded(
true );
656 sqlite3_finalize( stmt );
658 sqlite3_close( database );
660 mProjListDone =
true;
667 mUnknownList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Custom Coordinate Systems" ) ) );
668 mUnknownList->setFlags( mUnknownList->flags() & ~Qt::ItemIsSelectable );
670 QFont fontTemp = mUnknownList->font( 0 );
671 fontTemp.setItalic(
true );
672 fontTemp.setBold(
true );
673 mUnknownList->setFont( 0, fontTemp );
677 QTreeWidgetItem *newItem =
new QTreeWidgetItem( mUnknownList, QStringList(
crs.
description().isEmpty() ? QObject::tr(
"Custom CRS" ) :
crs.
description() ) );
679 newItem->setData( 0, RoleProj,
crs.
toProj() );
681 lstCoordinateSystems->setCurrentItem( newItem );
685 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
695 lstCoordinateSystems->scrollToItem( current );
699 if ( current->childCount() == 0 )
702 if ( !mBlockSignals )
708 updateBoundsPreview();
710 const QString crsId = current->text( QgisCrsIdColumn );
711 if ( !crsId.isEmpty() )
713 QList<QTreeWidgetItem *> nodes = lstRecent->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly, QgisCrsIdColumn );
714 if ( !nodes.isEmpty() )
716 QgsDebugMsgLevel( QStringLiteral(
"found srs %1 in recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
717 lstRecent->setCurrentItem( nodes.first() );
721 QgsDebugMsgLevel( QStringLiteral(
"srs %1 not recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
722 lstRecent->clearSelection();
723 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
728 lstRecent->clearSelection();
729 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
735 current->setSelected(
false );
736 teProjection->clear();
737 lstRecent->clearSelection();
742 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current,
int column )
756 if ( current->childCount() == 0 )
760 void QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
770 lstRecent->scrollToItem( current );
772 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
773 if ( !nodes.isEmpty() )
774 lstCoordinateSystems->setCurrentItem( nodes.first() );
777 void QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked( QTreeWidgetItem *current,
int column )
789 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
790 if ( !nodes.isEmpty() )
794 void QgsProjectionSelectionTreeWidget::updateFilter()
796 QString filterTxtCopy = leSearch->text();
797 filterTxtCopy.replace( QRegExp(
"\\s+" ), QStringLiteral(
".*" ) );
798 QRegExp re( filterTxtCopy, Qt::CaseInsensitive );
800 const bool hideDeprecated = cbxHideDeprecated->isChecked();
802 auto filterTreeWidget = [ = ]( QTreeWidget * tree )
804 QTreeWidgetItemIterator itr( tree );
807 if ( ( *itr )->childCount() == 0 )
809 if ( hideDeprecated && ( *itr )->data( 0, RoleDeprecated ).toBool() )
811 ( *itr )->setHidden(
true );
812 if ( ( *itr )->isSelected() )
814 ( *itr )->setSelected(
false );
815 teProjection->clear();
818 else if ( ( *itr )->text( NameColumn ).contains( re )
819 || ( *itr )->text( AuthidColumn ).contains( re )
822 ( *itr )->setHidden(
false );
823 QTreeWidgetItem *parent = ( *itr )->parent();
826 parent->setExpanded(
true );
827 parent->setHidden(
false );
828 parent = parent->parent();
833 ( *itr )->setHidden(
true );
838 ( *itr )->setHidden(
true );
845 filterTreeWidget( lstRecent );
848 filterTreeWidget( lstCoordinateSystems );
855 mPushProjectionToFront =
true;
859 long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch(
const QString &sql )
868 const char *tail =
nullptr;
869 sqlite3_stmt *stmt =
nullptr;
876 if ( QFileInfo::exists( databaseFileName ) )
878 result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
885 showDBMissingWarning( databaseFileName );
889 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
891 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
893 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
894 srsId = srsIdString.toLong();
896 sqlite3_finalize( stmt );
897 sqlite3_close( database );
904 result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
907 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
913 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
915 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
917 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
918 srsId = srsIdString.toLong();
922 sqlite3_finalize( stmt );
923 sqlite3_close( database );
928 void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
930 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
931 if ( !lvi || ( lvi->text( QgisCrsIdColumn ).isEmpty() && !lvi->data( 0, RoleWkt ).isValid() ) )
939 QString extentString = tr(
"Extent not known" );
940 mAreaCanvas->setPreviewRect( rect );
943 extentString = QStringLiteral(
"%1, %2, %3, %4" )
950 const QString extentHtml = QStringLiteral(
"<dt><b>%1</b></dt><dd>%2</dd>" ).arg( tr(
"Extent" ), extentString );
951 const QString wktString = tr(
"<dt><b>%1</b></dt><dd><code>%2</code></dd>" ).arg( tr(
"WKT" ), currentCrs.
toWkt(
QgsCoordinateReferenceSystem::WKT_PREFERRED,
true ).replace(
'\n', QLatin1String(
"<br>" ) ).replace(
' ', QLatin1String(
" " ) ) );
952 const QString proj4String = tr(
"<dt><b>%1</b></dt><dd><code>%2</code></dd>" ).arg( tr(
"Proj4" ), currentCrs.
toProj() );
955 const int smallerPointSize = std::max( font().pointSize() - 1, 8 );
957 const int smallerPointSize = std::max( font().pointSize() - 2, 6 );
960 teProjection->setText( QStringLiteral(
"<div style=\"font-size: %1pt\"><h3>%2</h3><dl>" ).arg( smallerPointSize ).arg( selectedName() ) + wktString + proj4String + extentHtml + QStringLiteral(
"</dl></div>" ) );
963 QStringList QgsProjectionSelectionTreeWidget::authorities()
966 const char *tail =
nullptr;
967 sqlite3_stmt *stmt =
nullptr;
969 int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
972 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
974 return QStringList();
977 QString sql = QStringLiteral(
"select distinct auth_name from tbl_srs" );
978 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
980 QStringList authorities;
981 if ( result == SQLITE_OK )
983 while ( sqlite3_step( stmt ) == SQLITE_ROW )
985 authorities << QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
991 sqlite3_finalize( stmt );
992 sqlite3_close( database );
997 QString QgsProjectionSelectionTreeWidget::sqlSafeString(
const QString &theSQL )
const
999 QString retval = theSQL;
1000 retval.replace(
'\\', QLatin1String(
"\\\\" ) );
1001 retval.replace(
'\"', QLatin1String(
"\\\"" ) );
1002 retval.replace(
'\'', QLatin1String(
"\\'" ) );
1003 retval.replace(
'%', QLatin1String(
"\\%" ) );
1007 void QgsProjectionSelectionTreeWidget::showDBMissingWarning(
const QString &fileName )
1010 QMessageBox::critical(
this, tr(
"Resource Location Error" ),
1011 tr(
"Error reading database file from: \n %1\n"
1012 "Because of this the projection selector will not work…" )
static QgsCoordinateReferenceSystemRegistry * coordinateReferenceSystemRegistry()
Returns the application's coordinate reference system (CRS) registry, which handles known CRS definit...
static QString qgisUserDatabaseFilePath()
Returns the path to the user qgis.db file.
static QString srsDatabaseFilePath()
Returns the path to the srs.db file.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Contains details of a custom (user defined) CRS.
QList< QgsCoordinateReferenceSystemRegistry::UserCrsDetails > userCrsList() const
Returns a list containing the details of all registered custom (user-defined) CRSes.
This class represents a coordinate reference system (CRS).
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QgsRectangle bounds() const
Returns the approximate bounds for the region the CRS is usable within.
QString toProj() const
Returns a Proj string representation of this CRS.
static void pushRecentCoordinateReferenceSystem(const QgsCoordinateReferenceSystem &crs)
Pushes a recently used CRS to the top of the recent CRS list.
QString description() const
Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94".
static QgsCoordinateReferenceSystem fromProj(const QString &proj)
Creates a CRS from a proj style formatted string.
static QList< QgsCoordinateReferenceSystem > recentCoordinateReferenceSystems()
Returns a list of recently used CRS.
QString authid() const
Returns the authority identifier for the CRS.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
static QgsCoordinateReferenceSystem fromWkt(const QString &wkt)
Creates a CRS from a WKT spatial ref sys definition string.
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
long srsid() const
Returns the internal CRS ID, if available.
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 rectangle specified with double values.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
double area() const SIP_HOLDGIL
Returns the area of the rectangle.
This class is a composition of two QSettings instances:
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
const int USER_CRS_START_ID
Magick number that determines whether a projection crsid is a system (srs.db) or user (~/....
#define QgsDebugMsgLevel(str, level)
const QgsCoordinateReferenceSystem & crs