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 );
94 if ( !mPushProjectionToFront )
100 long crsId = selectedCrsId();
109 lstCoordinateSystems->header()->resizeSection( NameColumn, event->size().width() - 240 );
110 lstCoordinateSystems->header()->resizeSection( AuthidColumn, 240 );
111 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
113 lstRecent->header()->resizeSection( NameColumn, event->size().width() - 240 );
114 lstRecent->header()->resizeSection( AuthidColumn, 240 );
115 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
125 loadCrsList( &mCrsFilter );
126 loadUserCrsList( &mCrsFilter );
128 if ( !mRecentProjListDone )
132 mRecentProjListDone =
true;
136 mBlockSignals =
true;
138 mBlockSignals =
false;
143 QWidget::showEvent( event );
147 QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter )
149 QString sqlExpression = QStringLiteral(
"1" );
150 QMap<QString, QStringList> authParts;
153 return sqlExpression;
173 const auto authIds { *crsFilter };
174 for (
const QString &auth_id : authIds )
176 QStringList parts = auth_id.split(
':' );
178 if ( parts.size() < 2 )
181 authParts[ parts.at( 0 ).toUpper()].append( parts.at( 1 ).toUpper() );
184 if ( authParts.isEmpty() )
185 return sqlExpression;
187 if ( !authParts.isEmpty() )
189 QString prefix = QStringLiteral(
" AND (" );
190 for (
auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
192 sqlExpression += QStringLiteral(
"%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
195 it.value().join( QStringLiteral(
"','" ) ) );
196 prefix = QStringLiteral(
" OR " );
198 sqlExpression +=
')';
203 return sqlExpression;
206 void QgsProjectionSelectionTreeWidget::applySelection(
int column, QString value )
208 if ( !mProjListDone || !mUserProjListDone )
211 mSearchColumn = column;
212 mSearchValue = value;
216 if ( column == QgsProjectionSelectionTreeWidget::None )
219 column = mSearchColumn;
220 value = mSearchValue;
222 mSearchColumn = QgsProjectionSelectionTreeWidget::None;
223 mSearchValue.clear();
226 if ( column == QgsProjectionSelectionTreeWidget::None )
229 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( value, Qt::MatchExactly | Qt::MatchRecursive, column );
230 if ( !nodes.isEmpty() )
232 QgsDebugMsgLevel( QStringLiteral(
"found %1,%2" ).arg( column ).arg( value ), 4 );
233 lstCoordinateSystems->setCurrentItem( nodes.first() );
237 QgsDebugMsgLevel( QStringLiteral(
"nothing found for %1,%2" ).arg( column ).arg( value ), 4 );
239 lstCoordinateSystems->clearSelection();
240 lstRecent->clearSelection();
241 teProjection->clear();
247 if ( !mProjListDone || !mUserProjListDone )
250 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( QString::number(
crs.
srsid() ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
251 if ( nodes.isEmpty() )
254 lstRecent->insertTopLevelItem( 0,
new QTreeWidgetItem( lstRecent, QStringList()
255 << nodes.first()->text( NameColumn )
256 << nodes.first()->text( AuthidColumn )
257 << nodes.first()->text( QgisCrsIdColumn ) ) );
261 QString QgsProjectionSelectionTreeWidget::selectedName()
264 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
265 return lvi ? lvi->text( NameColumn ) : QString();
272 mCheckBoxNoProjection->setChecked(
true );
276 bool changed =
false;
279 changed = mDeferredLoadCrs !=
crs;
280 mDeferredLoadCrs =
crs;
282 mBlockSignals =
true;
283 mCheckBoxNoProjection->setChecked(
false );
284 mBlockSignals =
false;
287 applySelection( AuthidColumn,
crs.
authid() );
289 loadUnknownCrs(
crs );
299 mAreaCanvas->setCanvasRect( rect );
304 return mAreaCanvas->canvasRect();
307 QString QgsProjectionSelectionTreeWidget::getSelectedExpression(
const QString &expression )
const
316 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
317 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
324 QString databaseFileName;
328 if ( !QFileInfo::exists( databaseFileName ) )
335 databaseFileName = mSrsDatabaseFileName;
344 int rc = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
348 "Because of this the projection selector will not work…" ).arg( databaseFileName ),
354 const char *tail =
nullptr;
355 sqlite3_stmt *stmt =
nullptr;
356 QString sql = QStringLiteral(
"select %1 from tbl_srs where srs_id=%2" )
358 lvi->text( QgisCrsIdColumn ) );
360 QgsDebugMsgLevel( QStringLiteral(
"Finding selected attribute using : %1" ).arg( sql ), 4 );
361 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
363 QString attributeValue;
364 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
367 attributeValue = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
371 sqlite3_finalize( stmt );
373 sqlite3_close( database );
376 return attributeValue;
381 if ( mCheckBoxNoProjection->isEnabled() && mCheckBoxNoProjection->isChecked() )
384 if ( !mInitialized && mDeferredLoadCrs.
isValid() )
385 return mDeferredLoadCrs;
387 const QString srsIdString = getSelectedExpression( QStringLiteral(
"srs_id" ) );
388 if ( !srsIdString.isEmpty() )
390 int srid = srsIdString.toLong();
399 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
400 if ( lvi && lvi->data( 0, RoleWkt ).isValid() )
402 else if ( lvi && lvi->data( 0, RoleProj ).isValid() )
411 mCheckBoxNoProjection->setVisible( show );
412 mCheckBoxNoProjection->setEnabled( show );
415 mFrameProjections->setDisabled( mCheckBoxNoProjection->isChecked() );
422 mAreaCanvas->setVisible( show );
427 return !mCheckBoxNoProjection->isHidden();
437 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
438 if ( mCheckBoxNoProjection->isChecked() )
440 else if ( !mInitialized && mDeferredLoadCrs.
isValid() )
443 return item && ( !item->text( QgisCrsIdColumn ).isEmpty() || item->data( 0, RoleWkt ).isValid() );
446 long QgsProjectionSelectionTreeWidget::selectedCrsId()
448 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
450 if ( item && !item->text( QgisCrsIdColumn ).isEmpty() )
451 return lstCoordinateSystems->currentItem()->text( QgisCrsIdColumn ).toLong();
459 mCrsFilter = crsFilter;
460 mProjListDone =
false;
461 mUserProjListDone =
false;
462 lstCoordinateSystems->clear();
465 void QgsProjectionSelectionTreeWidget::loadUserCrsList( QSet<QString> *crsFilter )
467 if ( mUserProjListDone )
470 QgsDebugMsgLevel( QStringLiteral(
"Fetching user projection list..." ), 4 );
473 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
477 mUserProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"User Defined Coordinate Systems" ) ) );
479 QFont fontTemp = mUserProjList->font( 0 );
480 fontTemp.setItalic(
true );
481 fontTemp.setBold(
true );
482 mUserProjList->setFont( 0, fontTemp );
492 if ( !QFileInfo::exists( databaseFileName ) )
494 QgsDebugMsg( QStringLiteral(
"Users qgis.db not found...skipping" ) );
495 mUserProjListDone =
true;
500 const char *tail =
nullptr;
501 sqlite3_stmt *stmt =
nullptr;
503 int result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
510 showDBMissingWarning( databaseFileName );
515 QString sql = QStringLiteral(
"select description, srs_id from vw_srs where %1" ).arg( sqlFilter );
517 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
519 if ( result == SQLITE_OK )
521 QTreeWidgetItem *newItem =
nullptr;
522 while ( sqlite3_step( stmt ) == SQLITE_ROW )
524 newItem =
new QTreeWidgetItem( mUserProjList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
530 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
531 newItem->setText( AuthidColumn, QStringLiteral(
"USER:%1" ).arg( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ).toInt() ) );
535 sqlite3_finalize( stmt );
536 sqlite3_close( database );
538 mUserProjListDone =
true;
541 void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
547 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
553 mGeoList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Geographic Coordinate Systems" ) ) );
555 QFont fontTemp = mGeoList->font( 0 );
556 fontTemp.setItalic(
true );
557 fontTemp.setBold(
true );
558 mGeoList->setFont( 0, fontTemp );
562 mProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Projected Coordinate Systems" ) ) );
564 fontTemp = mProjList->font( 0 );
565 fontTemp.setItalic(
true );
566 fontTemp.setBold(
true );
567 mProjList->setFont( 0, fontTemp );
575 if ( !QFileInfo::exists( mSrsDatabaseFileName ) )
577 mProjListDone =
true;
583 int rc = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
588 showDBMissingWarning( mSrsDatabaseFileName );
592 const char *tail =
nullptr;
593 sqlite3_stmt *stmt =
nullptr;
597 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" )
600 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
602 if ( rc == SQLITE_OK )
604 QTreeWidgetItem *newItem =
nullptr;
607 QString previousSrsType;
608 QTreeWidgetItem *previousSrsTypeNode =
nullptr;
610 while ( sqlite3_step( stmt ) == SQLITE_ROW )
613 int isGeo = sqlite3_column_int( stmt, 3 );
618 newItem =
new QTreeWidgetItem( mGeoList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
621 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
624 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
629 QTreeWidgetItem *node =
nullptr;
630 QString srsType = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 4 ) );
631 if ( srsType.isEmpty() )
632 srsType = tr(
"Other" );
636 if ( srsType == previousSrsType )
638 node = previousSrsTypeNode;
643 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( srsType, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
644 if ( nodes.isEmpty() )
648 node =
new QTreeWidgetItem( mProjList, QStringList( srsType ) );
649 QFont fontTemp = node->font( 0 );
650 fontTemp.setItalic(
true );
651 node->setFont( 0, fontTemp );
655 node = nodes.first();
658 previousSrsType = srsType;
659 previousSrsTypeNode = node;
662 newItem =
new QTreeWidgetItem( node, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
664 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
666 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
668 newItem->parent()->setExpanded(
true );
672 newItem->setData( 0, RoleDeprecated, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 6 ) ) );
673 newItem->setHidden( cbxHideDeprecated->isChecked() );
675 mProjList->setExpanded(
true );
679 sqlite3_finalize( stmt );
681 sqlite3_close( database );
683 mProjListDone =
true;
690 mUnknownList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Unknown Coordinate Systems" ) ) );
691 QFont fontTemp = mUnknownList->font( 0 );
692 fontTemp.setItalic(
true );
693 fontTemp.setBold(
true );
694 mUnknownList->setFont( 0, fontTemp );
698 QTreeWidgetItem *newItem =
new QTreeWidgetItem( mUnknownList, QStringList( QObject::tr(
"Unknown CRS" ) ) );
700 newItem->setData( 0, RoleProj,
crs.
toProj() );
702 lstCoordinateSystems->setCurrentItem( newItem );
706 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
716 lstCoordinateSystems->scrollToItem( current );
720 if ( current->childCount() == 0 )
723 if ( !mBlockSignals )
726 updateBoundsPreview();
728 const QString crsId = current->text( QgisCrsIdColumn );
729 if ( !crsId.isEmpty() )
731 QList<QTreeWidgetItem *> nodes = lstRecent->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly, QgisCrsIdColumn );
732 if ( !nodes.isEmpty() )
734 QgsDebugMsgLevel( QStringLiteral(
"found srs %1 in recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
735 lstRecent->setCurrentItem( nodes.first() );
739 QgsDebugMsgLevel( QStringLiteral(
"srs %1 not recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
740 lstRecent->clearSelection();
741 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
746 lstRecent->clearSelection();
747 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
753 current->setSelected(
false );
754 teProjection->clear();
755 lstRecent->clearSelection();
759 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current,
int column )
773 if ( current->childCount() == 0 )
777 void QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
787 lstRecent->scrollToItem( current );
789 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
790 if ( !nodes.isEmpty() )
791 lstCoordinateSystems->setCurrentItem( nodes.first() );
794 void QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked( QTreeWidgetItem *current,
int column )
806 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
807 if ( !nodes.isEmpty() )
811 void QgsProjectionSelectionTreeWidget::updateFilter()
813 QString filterTxtCopy = leSearch->text();
814 filterTxtCopy.replace( QRegExp(
"\\s+" ), QStringLiteral(
".*" ) );
815 QRegExp re( filterTxtCopy, Qt::CaseInsensitive );
817 const bool hideDeprecated = cbxHideDeprecated->isChecked();
819 auto filterTreeWidget = [ = ]( QTreeWidget * tree )
821 QTreeWidgetItemIterator itr( tree );
824 if ( ( *itr )->childCount() == 0 )
826 if ( hideDeprecated && ( *itr )->data( 0, RoleDeprecated ).toBool() )
828 ( *itr )->setHidden(
true );
829 if ( ( *itr )->isSelected() )
831 ( *itr )->setSelected(
false );
832 teProjection->clear();
835 else if ( ( *itr )->text( NameColumn ).contains( re )
836 || ( *itr )->text( AuthidColumn ).contains( re )
839 ( *itr )->setHidden(
false );
840 QTreeWidgetItem *parent = ( *itr )->parent();
843 parent->setExpanded(
true );
844 parent->setHidden(
false );
845 parent = parent->parent();
850 ( *itr )->setHidden(
true );
855 ( *itr )->setHidden(
true );
862 filterTreeWidget( lstRecent );
865 filterTreeWidget( lstCoordinateSystems );
872 mPushProjectionToFront =
true;
876 long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch(
const QString &sql )
885 const char *tail =
nullptr;
886 sqlite3_stmt *stmt =
nullptr;
893 if ( QFileInfo::exists( databaseFileName ) )
895 result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
902 showDBMissingWarning( databaseFileName );
906 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
908 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
910 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
911 srsId = srsIdString.toLong();
913 sqlite3_finalize( stmt );
914 sqlite3_close( database );
921 result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
924 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
930 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
932 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
934 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
935 srsId = srsIdString.toLong();
939 sqlite3_finalize( stmt );
940 sqlite3_close( database );
945 void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
947 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
948 if ( !lvi || ( lvi->text( QgisCrsIdColumn ).isEmpty() && !lvi->data( 0, RoleWkt ).isValid() ) )
956 QString extentString = tr(
"Extent not known" );
957 mAreaCanvas->setPreviewRect( rect );
960 extentString = QStringLiteral(
"%1, %2, %3, %4" )
967 const QString extentHtml = QStringLiteral(
"<dt><b>%1</b></dt><dd>%2</dd>" ).arg( tr(
"Extent" ), extentString );
968 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', QStringLiteral(
"<br>" ) ).replace(
' ', QStringLiteral(
" " ) ) );
969 const QString proj4String = tr(
"<dt><b>%1</b></dt><dd><code>%2</code></dd>" ).arg( tr(
"Proj4" ), currentCrs.
toProj() );
972 const int smallerPointSize = std::max( font().pointSize() - 1, 8 );
974 const int smallerPointSize = std::max( font().pointSize() - 2, 6 );
977 teProjection->setText( QStringLiteral(
"<div style=\"font-size: %1pt\"><h3>%2</h3><dl>" ).arg( smallerPointSize ).arg( selectedName() ) + wktString + proj4String + extentHtml + QStringLiteral(
"</dl></div>" ) );
980 QStringList QgsProjectionSelectionTreeWidget::authorities()
983 const char *tail =
nullptr;
984 sqlite3_stmt *stmt =
nullptr;
986 int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY,
nullptr );
989 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
991 return QStringList();
994 QString sql = QStringLiteral(
"select distinct auth_name from tbl_srs" );
995 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
997 QStringList authorities;
998 if ( result == SQLITE_OK )
1000 while ( sqlite3_step( stmt ) == SQLITE_ROW )
1002 authorities << QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
1008 sqlite3_finalize( stmt );
1009 sqlite3_close( database );
1014 QString QgsProjectionSelectionTreeWidget::sqlSafeString(
const QString &theSQL )
const
1016 QString retval = theSQL;
1017 retval.replace(
'\\', QLatin1String(
"\\\\" ) );
1018 retval.replace(
'\"', QLatin1String(
"\\\"" ) );
1019 retval.replace(
'\'', QLatin1String(
"\\'" ) );
1020 retval.replace(
'%', QLatin1String(
"\\%" ) );
1024 void QgsProjectionSelectionTreeWidget::showDBMissingWarning(
const QString &fileName )
1027 QMessageBox::critical(
this, tr(
"Resource Location Error" ),
1028 tr(
"Error reading database file from: \n %1\n"
1029 "Because of this the projection selector will not work…" )