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 );
78 connect( mCheckBoxNoProjection, &QCheckBox::toggled,
this, [ = ]
83 connect( mCheckBoxNoProjection, &QCheckBox::toggled,
this, [ = ](
bool checked )
85 if ( mCheckBoxNoProjection->isEnabled() )
87 mFrameProjections->setDisabled( checked );
92 mSplitter->restoreState( settings.value( QStringLiteral(
"Windows/ProjectionSelector/splitterState" ) ).toByteArray() );
97 if ( !mPushProjectionToFront )
103 long crsId = selectedCrsId();
108 settings.
setValue( QStringLiteral(
"Windows/ProjectionSelector/splitterState" ), mSplitter->saveState() );
115 lstCoordinateSystems->header()->resizeSection( NameColumn, event->size().width() - 240 );
116 lstCoordinateSystems->header()->resizeSection( AuthidColumn, 240 );
117 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
119 lstRecent->header()->resizeSection( NameColumn, event->size().width() - 240 );
120 lstRecent->header()->resizeSection( AuthidColumn, 240 );
121 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
131 loadCrsList( &mCrsFilter );
132 loadUserCrsList( &mCrsFilter );
134 if ( !mRecentProjListDone )
138 mRecentProjListDone =
true;
142 mBlockSignals =
true;
144 mBlockSignals =
false;
149 QWidget::showEvent( event );
153 QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter )
155 QString sqlExpression = QStringLiteral(
"1" );
156 QMap<QString, QStringList> authParts;
159 return sqlExpression;
179 const auto authIds { *crsFilter };
180 for (
const QString &auth_id : authIds )
182 QStringList parts = auth_id.split(
':' );
184 if ( parts.size() < 2 )
187 authParts[ parts.at( 0 ).toUpper()].append( parts.at( 1 ).toUpper() );
190 if ( authParts.isEmpty() )
191 return sqlExpression;
193 if ( !authParts.isEmpty() )
195 QString prefix = QStringLiteral(
" AND (" );
196 for (
auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
198 sqlExpression += QStringLiteral(
"%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
201 it.value().join( QLatin1String(
"','" ) ) );
202 prefix = QStringLiteral(
" OR " );
204 sqlExpression +=
')';
209 return sqlExpression;
212 void QgsProjectionSelectionTreeWidget::applySelection(
int column, QString value )
214 if ( !mProjListDone || !mUserProjListDone )
217 mSearchColumn = column;
218 mSearchValue = value;
222 if ( column == QgsProjectionSelectionTreeWidget::None )
225 column = mSearchColumn;
226 value = mSearchValue;
228 mSearchColumn = QgsProjectionSelectionTreeWidget::None;
229 mSearchValue.clear();
232 if ( column == QgsProjectionSelectionTreeWidget::None )
235 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( value, Qt::MatchExactly | Qt::MatchRecursive, column );
236 if ( !nodes.isEmpty() )
238 QgsDebugMsgLevel( QStringLiteral(
"found %1,%2" ).arg( column ).arg( value ), 4 );
239 lstCoordinateSystems->setCurrentItem( nodes.first() );
243 QgsDebugMsgLevel( QStringLiteral(
"nothing found for %1,%2" ).arg( column ).arg( value ), 4 );
245 lstCoordinateSystems->clearSelection();
246 lstRecent->clearSelection();
247 teProjection->clear();
253 if ( !mProjListDone || !mUserProjListDone )
256 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( QString::number(
crs.
srsid() ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
257 if ( nodes.isEmpty() )
260 lstRecent->insertTopLevelItem( 0,
new QTreeWidgetItem( lstRecent, QStringList()
261 << nodes.first()->text( NameColumn )
262 << nodes.first()->text( AuthidColumn )
263 << nodes.first()->text( QgisCrsIdColumn ) ) );
267 QString QgsProjectionSelectionTreeWidget::selectedName()
270 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
271 return lvi ? lvi->text( NameColumn ) : QString();
278 mCheckBoxNoProjection->setChecked(
true );
282 bool changed =
false;
285 changed = mDeferredLoadCrs !=
crs;
286 mDeferredLoadCrs =
crs;
288 mBlockSignals =
true;
289 mCheckBoxNoProjection->setChecked(
false );
290 mBlockSignals =
false;
293 applySelection( AuthidColumn,
crs.
authid() );
295 loadUnknownCrs(
crs );
305 mAreaCanvas->setCanvasRect( rect );
310 return mAreaCanvas->canvasRect();
313 QString QgsProjectionSelectionTreeWidget::getSelectedExpression(
const QString &expression )
const
322 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
323 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
330 QString databaseFileName;
334 if ( !QFileInfo::exists( databaseFileName ) )
341 databaseFileName = mSrsDatabaseFileName;
350 int rc = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
354 "Because of this the projection selector will not work…" ).arg( databaseFileName ),
360 const char *tail =
nullptr;
361 sqlite3_stmt *stmt =
nullptr;
362 QString sql = QStringLiteral(
"select %1 from tbl_srs where srs_id=%2" )
364 lvi->text( QgisCrsIdColumn ) );
366 QgsDebugMsgLevel( QStringLiteral(
"Finding selected attribute using : %1" ).arg( sql ), 4 );
367 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
369 QString attributeValue;
370 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
373 attributeValue = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
377 sqlite3_finalize( stmt );
379 sqlite3_close( database );
382 return attributeValue;
387 if ( mCheckBoxNoProjection->isEnabled() && mCheckBoxNoProjection->isChecked() )
390 if ( !mInitialized && mDeferredLoadCrs.
isValid() )
391 return mDeferredLoadCrs;
393 const QString srsIdString = getSelectedExpression( QStringLiteral(
"srs_id" ) );
394 if ( !srsIdString.isEmpty() )
396 int srid = srsIdString.toLong();
405 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
406 if ( lvi && lvi->data( 0, RoleWkt ).isValid() )
408 else if ( lvi && lvi->data( 0, RoleProj ).isValid() )
417 mCheckBoxNoProjection->setVisible( show );
418 mCheckBoxNoProjection->setEnabled( show );
421 mFrameProjections->setDisabled( mCheckBoxNoProjection->isChecked() );
428 mAreaCanvas->setVisible( show );
433 return !mCheckBoxNoProjection->isHidden();
438 mCheckBoxNoProjection->setText( text );
448 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
449 if ( mCheckBoxNoProjection->isChecked() )
451 else if ( !mInitialized && mDeferredLoadCrs.
isValid() )
454 return item && ( !item->text( QgisCrsIdColumn ).isEmpty() || item->data( 0, RoleWkt ).isValid() );
457 long QgsProjectionSelectionTreeWidget::selectedCrsId()
459 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
461 if ( item && !item->text( QgisCrsIdColumn ).isEmpty() )
462 return lstCoordinateSystems->currentItem()->text( QgisCrsIdColumn ).toLong();
470 mCrsFilter = crsFilter;
471 mProjListDone =
false;
472 mUserProjListDone =
false;
473 lstCoordinateSystems->clear();
476 void QgsProjectionSelectionTreeWidget::loadUserCrsList( QSet<QString> *crsFilter )
478 if ( mUserProjListDone )
481 QgsDebugMsgLevel( QStringLiteral(
"Fetching user projection list..." ), 4 );
484 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
488 mUserProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"User Defined Coordinate Systems" ) ) );
490 QFont fontTemp = mUserProjList->font( 0 );
491 fontTemp.setItalic(
true );
492 fontTemp.setBold(
true );
493 mUserProjList->setFont( 0, fontTemp );
503 if ( !QFileInfo::exists( databaseFileName ) )
505 QgsDebugMsg( QStringLiteral(
"Users qgis.db not found...skipping" ) );
506 mUserProjListDone =
true;
511 const char *tail =
nullptr;
512 sqlite3_stmt *stmt =
nullptr;
514 int result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
521 showDBMissingWarning( databaseFileName );
526 QString sql = QStringLiteral(
"select description, srs_id from vw_srs where %1" ).arg( sqlFilter );
528 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
530 if ( result == SQLITE_OK )
532 QTreeWidgetItem *newItem =
nullptr;
533 while ( sqlite3_step( stmt ) == SQLITE_ROW )
535 newItem =
new QTreeWidgetItem( mUserProjList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
541 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
542 newItem->setText( AuthidColumn, QStringLiteral(
"USER:%1" ).arg( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ).toInt() ) );
546 sqlite3_finalize( stmt );
547 sqlite3_close( database );
549 mUserProjListDone =
true;
552 void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
558 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
564 mGeoList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Geographic Coordinate Systems" ) ) );
566 QFont fontTemp = mGeoList->font( 0 );
567 fontTemp.setItalic(
true );
568 fontTemp.setBold(
true );
569 mGeoList->setFont( 0, fontTemp );
573 mProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Projected Coordinate Systems" ) ) );
575 fontTemp = mProjList->font( 0 );
576 fontTemp.setItalic(
true );
577 fontTemp.setBold(
true );
578 mProjList->setFont( 0, fontTemp );
586 if ( !QFileInfo::exists( mSrsDatabaseFileName ) )
588 mProjListDone =
true;
594 int rc = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
599 showDBMissingWarning( mSrsDatabaseFileName );
603 const char *tail =
nullptr;
604 sqlite3_stmt *stmt =
nullptr;
608 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" )
611 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
613 if ( rc == SQLITE_OK )
615 QTreeWidgetItem *newItem =
nullptr;
618 QString previousSrsType;
619 QTreeWidgetItem *previousSrsTypeNode =
nullptr;
621 while ( sqlite3_step( stmt ) == SQLITE_ROW )
624 int isGeo = sqlite3_column_int( stmt, 3 );
629 newItem =
new QTreeWidgetItem( mGeoList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
632 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
635 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
640 QTreeWidgetItem *node =
nullptr;
641 QString srsType = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 4 ) );
642 if ( srsType.isEmpty() )
643 srsType = tr(
"Other" );
647 if ( srsType == previousSrsType )
649 node = previousSrsTypeNode;
654 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( srsType, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
655 if ( nodes.isEmpty() )
659 node =
new QTreeWidgetItem( mProjList, QStringList( srsType ) );
660 QFont fontTemp = node->font( 0 );
661 fontTemp.setItalic(
true );
662 node->setFont( 0, fontTemp );
666 node = nodes.first();
669 previousSrsType = srsType;
670 previousSrsTypeNode = node;
673 newItem =
new QTreeWidgetItem( node, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
675 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
677 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
679 newItem->parent()->setExpanded(
true );
683 newItem->setData( 0, RoleDeprecated, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 6 ) ) );
684 newItem->setHidden( cbxHideDeprecated->isChecked() );
686 mProjList->setExpanded(
true );
690 sqlite3_finalize( stmt );
692 sqlite3_close( database );
694 mProjListDone =
true;
701 mUnknownList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Custom Coordinate Systems" ) ) );
702 QFont fontTemp = mUnknownList->font( 0 );
703 fontTemp.setItalic(
true );
704 fontTemp.setBold(
true );
705 mUnknownList->setFont( 0, fontTemp );
709 QTreeWidgetItem *newItem =
new QTreeWidgetItem( mUnknownList, QStringList(
crs.
description().isEmpty() ? QObject::tr(
"Custom CRS" ) :
crs.
description() ) );
711 newItem->setData( 0, RoleProj,
crs.
toProj() );
713 lstCoordinateSystems->setCurrentItem( newItem );
717 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
727 lstCoordinateSystems->scrollToItem( current );
731 if ( current->childCount() == 0 )
734 if ( !mBlockSignals )
737 updateBoundsPreview();
739 const QString crsId = current->text( QgisCrsIdColumn );
740 if ( !crsId.isEmpty() )
742 QList<QTreeWidgetItem *> nodes = lstRecent->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly, QgisCrsIdColumn );
743 if ( !nodes.isEmpty() )
745 QgsDebugMsgLevel( QStringLiteral(
"found srs %1 in recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
746 lstRecent->setCurrentItem( nodes.first() );
750 QgsDebugMsgLevel( QStringLiteral(
"srs %1 not recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
751 lstRecent->clearSelection();
752 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
757 lstRecent->clearSelection();
758 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
764 current->setSelected(
false );
765 teProjection->clear();
766 lstRecent->clearSelection();
770 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current,
int column )
784 if ( current->childCount() == 0 )
788 void QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
798 lstRecent->scrollToItem( current );
800 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
801 if ( !nodes.isEmpty() )
802 lstCoordinateSystems->setCurrentItem( nodes.first() );
805 void QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked( QTreeWidgetItem *current,
int column )
817 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
818 if ( !nodes.isEmpty() )
822 void QgsProjectionSelectionTreeWidget::updateFilter()
824 QString filterTxtCopy = leSearch->text();
825 filterTxtCopy.replace( QRegExp(
"\\s+" ), QStringLiteral(
".*" ) );
826 QRegExp re( filterTxtCopy, Qt::CaseInsensitive );
828 const bool hideDeprecated = cbxHideDeprecated->isChecked();
830 auto filterTreeWidget = [ = ]( QTreeWidget * tree )
832 QTreeWidgetItemIterator itr( tree );
835 if ( ( *itr )->childCount() == 0 )
837 if ( hideDeprecated && ( *itr )->data( 0, RoleDeprecated ).toBool() )
839 ( *itr )->setHidden(
true );
840 if ( ( *itr )->isSelected() )
842 ( *itr )->setSelected(
false );
843 teProjection->clear();
846 else if ( ( *itr )->text( NameColumn ).contains( re )
847 || ( *itr )->text( AuthidColumn ).contains( re )
850 ( *itr )->setHidden(
false );
851 QTreeWidgetItem *parent = ( *itr )->parent();
854 parent->setExpanded(
true );
855 parent->setHidden(
false );
856 parent = parent->parent();
861 ( *itr )->setHidden(
true );
866 ( *itr )->setHidden(
true );
873 filterTreeWidget( lstRecent );
876 filterTreeWidget( lstCoordinateSystems );
883 mPushProjectionToFront =
true;
887 long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch(
const QString &sql )
896 const char *tail =
nullptr;
897 sqlite3_stmt *stmt =
nullptr;
904 if ( QFileInfo::exists( databaseFileName ) )
906 result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
913 showDBMissingWarning( databaseFileName );
917 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
919 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
921 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
922 srsId = srsIdString.toLong();
924 sqlite3_finalize( stmt );
925 sqlite3_close( database );
932 result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
935 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
941 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
943 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
945 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
946 srsId = srsIdString.toLong();
950 sqlite3_finalize( stmt );
951 sqlite3_close( database );
956 void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
958 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
959 if ( !lvi || ( lvi->text( QgisCrsIdColumn ).isEmpty() && !lvi->data( 0, RoleWkt ).isValid() ) )
967 QString extentString = tr(
"Extent not known" );
968 mAreaCanvas->setPreviewRect( rect );
971 extentString = QStringLiteral(
"%1, %2, %3, %4" )
978 const QString extentHtml = QStringLiteral(
"<dt><b>%1</b></dt><dd>%2</dd>" ).arg( tr(
"Extent" ), extentString );
979 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(
" " ) ) );
980 const QString proj4String = tr(
"<dt><b>%1</b></dt><dd><code>%2</code></dd>" ).arg( tr(
"Proj4" ), currentCrs.
toProj() );
983 const int smallerPointSize = std::max( font().pointSize() - 1, 8 );
985 const int smallerPointSize = std::max( font().pointSize() - 2, 6 );
988 teProjection->setText( QStringLiteral(
"<div style=\"font-size: %1pt\"><h3>%2</h3><dl>" ).arg( smallerPointSize ).arg( selectedName() ) + wktString + proj4String + extentHtml + QStringLiteral(
"</dl></div>" ) );
991 QStringList QgsProjectionSelectionTreeWidget::authorities()
994 const char *tail =
nullptr;
995 sqlite3_stmt *stmt =
nullptr;
997 int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
1000 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
1002 return QStringList();
1005 QString sql = QStringLiteral(
"select distinct auth_name from tbl_srs" );
1006 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
1008 QStringList authorities;
1009 if ( result == SQLITE_OK )
1011 while ( sqlite3_step( stmt ) == SQLITE_ROW )
1013 authorities << QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
1019 sqlite3_finalize( stmt );
1020 sqlite3_close( database );
1025 QString QgsProjectionSelectionTreeWidget::sqlSafeString(
const QString &theSQL )
const
1027 QString retval = theSQL;
1028 retval.replace(
'\\', QLatin1String(
"\\\\" ) );
1029 retval.replace(
'\"', QLatin1String(
"\\\"" ) );
1030 retval.replace(
'\'', QLatin1String(
"\\'" ) );
1031 retval.replace(
'%', QLatin1String(
"\\%" ) );
1035 void QgsProjectionSelectionTreeWidget::showDBMissingWarning(
const QString &fileName )
1038 QMessageBox::critical(
this, tr(
"Resource Location Error" ),
1039 tr(
"Error reading database file from: \n %1\n"
1040 "Because of this the projection selector will not work…" )