31 #include <QHeaderView> 32 #include <QResizeEvent> 33 #include <QMessageBox> 40 connect( lstCoordinateSystems, &QTreeWidget::itemDoubleClicked,
this, &QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked );
41 connect( lstRecent, &QTreeWidget::itemDoubleClicked,
this, &QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked );
42 connect( lstCoordinateSystems, &QTreeWidget::currentItemChanged,
this, &QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged );
43 connect( lstRecent, &QTreeWidget::currentItemChanged,
this, &QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged );
44 connect( cbxHideDeprecated, &QCheckBox::stateChanged,
this, &QgsProjectionSelectionTreeWidget::cbxHideDeprecated_stateChanged );
45 connect( leSearch, &QgsFilterLineEdit::textChanged,
this, &QgsProjectionSelectionTreeWidget::leSearch_textChanged );
52 QColor rectColor = QColor( 185, 84, 210, 60 );
53 mPreviewBand2->
setColor( rectColor );
57 mVertexMarker->
setColor( QColor( 185, 84, 210 ) );
61 mAreaCanvas->setDestinationCrs( srs );
65 mAreaCanvas->setLayers( mLayers );
67 mAreaCanvas->setPreviewJobsEnabled(
true );
68 mAreaCanvas->setVisible( mShowMap );
70 if ( QDialog *dlg = qobject_cast<QDialog *>( parent ) )
79 lstCoordinateSystems->header()->setSectionResizeMode( AuthidColumn, QHeaderView::Stretch );
80 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
81 lstCoordinateSystems->header()->setSectionResizeMode( QgisCrsIdColumn, QHeaderView::Fixed );
84 lstCoordinateSystems->setColumnHidden( QgisCrsIdColumn,
true );
86 lstRecent->header()->setSectionResizeMode( AuthidColumn, QHeaderView::Stretch );
87 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
88 lstRecent->header()->setSectionResizeMode( QgisCrsIdColumn, QHeaderView::Fixed );
91 lstRecent->setColumnHidden( QgisCrsIdColumn,
true );
95 mCheckBoxNoProjection->setHidden(
true );
97 connect( mCheckBoxNoProjection, &QCheckBox::toggled, mFrameProjections, &QFrame::setDisabled );
102 qDeleteAll( mLayers );
104 delete mPreviewBand2;
105 delete mVertexMarker;
107 if ( !mPushProjectionToFront )
113 long crsId = selectedCrsId();
118 mRecentProjections.removeAll( QString::number( crsId ) );
119 mRecentProjections.prepend( QString::number( crsId ) );
121 while ( mRecentProjections.size() > 8 )
123 mRecentProjections.removeLast();
128 settings.
setValue( QStringLiteral(
"/UI/recentProjections" ), mRecentProjections );
132 QStringList projectionsProj4;
133 QStringList projectionsAuthId;
134 for (
int i = 0; i < mRecentProjections.size(); i++ )
146 settings.
setValue( QStringLiteral(
"/UI/recentProjectionsProj4" ), projectionsProj4 );
147 settings.
setValue( QStringLiteral(
"/UI/recentProjectionsAuthId" ), projectionsAuthId );
152 lstCoordinateSystems->header()->resizeSection( NameColumn, event->size().width() - 240 );
153 lstCoordinateSystems->header()->resizeSection( AuthidColumn, 240 );
154 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
156 lstRecent->header()->resizeSection( NameColumn, event->size().width() - 240 );
157 lstRecent->header()->resizeSection( AuthidColumn, 240 );
158 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
165 loadCrsList( &mCrsFilter );
166 loadUserCrsList( &mCrsFilter );
168 if ( !mRecentProjListDone )
170 for (
int i = mRecentProjections.size() - 1; i >= 0; i-- )
171 insertRecent( mRecentProjections.at( i ).toLong() );
172 mRecentProjListDone =
true;
181 QWidget::showEvent( event );
184 QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter )
186 QString sqlExpression = QStringLiteral(
"1" );
187 QMap<QString, QStringList> authParts;
190 return sqlExpression;
210 Q_FOREACH (
const QString &auth_id, *crsFilter )
212 QStringList parts = auth_id.split(
':' );
214 if ( parts.size() < 2 )
217 authParts[ parts.at( 0 ).toUpper()].append( parts.at( 1 ).toUpper() );
220 if ( authParts.isEmpty() )
221 return sqlExpression;
223 if ( !authParts.isEmpty() )
225 QString prefix = QStringLiteral(
" AND (" );
226 for (
auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
228 sqlExpression += QStringLiteral(
"%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
231 it.value().join( QStringLiteral(
"','" ) ) );
232 prefix = QStringLiteral(
" OR " );
234 sqlExpression +=
')';
239 return sqlExpression;
242 void QgsProjectionSelectionTreeWidget::applySelection(
int column, QString value )
244 if ( !mProjListDone || !mUserProjListDone )
247 mSearchColumn = column;
248 mSearchValue = value;
252 if ( column == QgsProjectionSelectionTreeWidget::None )
255 column = mSearchColumn;
256 value = mSearchValue;
258 mSearchColumn = QgsProjectionSelectionTreeWidget::None;
259 mSearchValue.clear();
262 if ( column == QgsProjectionSelectionTreeWidget::None )
265 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( value, Qt::MatchExactly | Qt::MatchRecursive, column );
266 if ( !nodes.isEmpty() )
269 lstCoordinateSystems->setCurrentItem( nodes.first() );
273 QgsDebugMsgLevel( QString(
"nothing found for %1,%2" ).arg( column ).arg( value ), 4 );
275 lstCoordinateSystems->clearSelection();
276 lstRecent->clearSelection();
277 teProjection->clear();
282 void QgsProjectionSelectionTreeWidget::insertRecent(
long crsId )
284 if ( !mProjListDone || !mUserProjListDone )
287 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( QString::number( crsId ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
288 if ( nodes.isEmpty() )
291 lstRecent->insertTopLevelItem( 0,
new QTreeWidgetItem( lstRecent, QStringList()
292 << nodes.first()->text( NameColumn )
293 << nodes.first()->text( AuthidColumn )
294 << nodes.first()->text( QgisCrsIdColumn ) ) );
298 QString QgsProjectionSelectionTreeWidget::selectedName()
301 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
302 return lvi ? lvi->text( NameColumn ) : QString();
309 mCheckBoxNoProjection->setChecked(
true );
313 mCheckBoxNoProjection->setChecked(
false );
314 applySelection( AuthidColumn, crs.
authid() );
322 mPreviewBand2->show();
324 mVertexMarker->show();
333 QString QgsProjectionSelectionTreeWidget::selectedProj4String()
341 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
342 if ( !item || item->text( QgisCrsIdColumn ).isEmpty() )
343 return QLatin1String(
"" );
345 QString srsId = item->text( QgisCrsIdColumn );
354 QString databaseFileName;
358 if ( !QFileInfo::exists( databaseFileName ) )
363 databaseFileName = mSrsDatabaseFileName;
369 int rc = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
372 showDBMissingWarning( databaseFileName );
373 return QLatin1String(
"" );
377 const char *tail =
nullptr;
378 sqlite3_stmt *stmt =
nullptr;
379 QString sql = QStringLiteral(
"select parameters from tbl_srs where srs_id=%1" ).arg( srsId );
383 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
386 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
388 projString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
392 sqlite3_finalize( stmt );
394 sqlite3_close( database );
396 Q_ASSERT( !projString.isEmpty() );
401 QString QgsProjectionSelectionTreeWidget::getSelectedExpression(
const QString &expression )
const 410 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
411 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
418 QString databaseFileName;
422 if ( !QFileInfo::exists( databaseFileName ) )
429 databaseFileName = mSrsDatabaseFileName;
438 int rc = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
442 "Because of this the projection selector will not work…" ).arg( databaseFileName ),
448 const char *tail =
nullptr;
449 sqlite3_stmt *stmt =
nullptr;
450 QString sql = QStringLiteral(
"select %1 from tbl_srs where srs_id=%2" )
452 lvi->text( QgisCrsIdColumn ) );
454 QgsDebugMsgLevel( QString(
"Finding selected attribute using : %1" ).arg( sql ), 4 );
455 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
457 QString attributeValue;
458 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
461 attributeValue = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
465 sqlite3_finalize( stmt );
467 sqlite3_close( database );
470 return attributeValue;
475 if ( mCheckBoxNoProjection->isChecked() )
478 int srid = getSelectedExpression( QStringLiteral(
"srs_id" ) ).toLong();
487 mCheckBoxNoProjection->setHidden( !show );
493 mAreaCanvas->setVisible( show );
499 return !mCheckBoxNoProjection->isHidden();
509 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
510 if ( mCheckBoxNoProjection->isChecked() )
513 return item && !item->text( QgisCrsIdColumn ).isEmpty();
516 long QgsProjectionSelectionTreeWidget::selectedCrsId()
518 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
520 if ( item && !item->text( QgisCrsIdColumn ).isEmpty() )
521 return lstCoordinateSystems->currentItem()->text( QgisCrsIdColumn ).toLong();
529 mCrsFilter = crsFilter;
530 mProjListDone =
false;
531 mUserProjListDone =
false;
532 lstCoordinateSystems->clear();
535 void QgsProjectionSelectionTreeWidget::loadUserCrsList( QSet<QString> *crsFilter )
537 if ( mUserProjListDone )
543 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
547 mUserProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"User Defined Coordinate Systems" ) ) );
549 QFont fontTemp = mUserProjList->font( 0 );
550 fontTemp.setItalic(
true );
551 fontTemp.setBold(
true );
552 mUserProjList->setFont( 0, fontTemp );
562 if ( !QFileInfo::exists( databaseFileName ) )
564 QgsDebugMsg(
"Users qgis.db not found...skipping" );
565 mUserProjListDone =
true;
570 const char *tail =
nullptr;
571 sqlite3_stmt *stmt =
nullptr;
573 int result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
580 showDBMissingWarning( databaseFileName );
585 QString sql = QStringLiteral(
"select description, srs_id from vw_srs where %1" ).arg( sqlFilter );
587 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
589 if ( result == SQLITE_OK )
591 QTreeWidgetItem *newItem =
nullptr;
592 while ( sqlite3_step( stmt ) == SQLITE_ROW )
594 newItem =
new QTreeWidgetItem( mUserProjList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
600 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
601 newItem->setText( AuthidColumn, QStringLiteral(
"USER:%1" ).arg( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ).toInt() ) );
605 sqlite3_finalize( stmt );
606 sqlite3_close( database );
608 mUserProjListDone =
true;
611 void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
617 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
623 mGeoList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Geographic Coordinate Systems" ) ) );
625 QFont fontTemp = mGeoList->font( 0 );
626 fontTemp.setItalic(
true );
627 fontTemp.setBold(
true );
628 mGeoList->setFont( 0, fontTemp );
632 mProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Projected Coordinate Systems" ) ) );
634 fontTemp = mProjList->font( 0 );
635 fontTemp.setItalic(
true );
636 fontTemp.setBold(
true );
637 mProjList->setFont( 0, fontTemp );
645 if ( !QFileInfo::exists( mSrsDatabaseFileName ) )
647 mProjListDone =
true;
653 int rc = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
658 showDBMissingWarning( mSrsDatabaseFileName );
662 const char *tail =
nullptr;
663 sqlite3_stmt *stmt =
nullptr;
667 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" )
670 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
672 if ( rc == SQLITE_OK )
674 QTreeWidgetItem *newItem =
nullptr;
677 QString previousSrsType( QLatin1String(
"" ) );
678 QTreeWidgetItem *previousSrsTypeNode =
nullptr;
680 while ( sqlite3_step( stmt ) == SQLITE_ROW )
683 int isGeo = sqlite3_column_int( stmt, 3 );
688 newItem =
new QTreeWidgetItem( mGeoList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
691 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
694 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
699 QTreeWidgetItem *node =
nullptr;
700 QString srsType = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 4 ) );
703 if ( srsType == previousSrsType )
705 node = previousSrsTypeNode;
710 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( srsType, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
711 if ( nodes.isEmpty() )
715 node =
new QTreeWidgetItem( mProjList, QStringList( srsType ) );
716 QFont fontTemp = node->font( 0 );
717 fontTemp.setItalic(
true );
718 node->setFont( 0, fontTemp );
722 node = nodes.first();
725 previousSrsType = srsType;
726 previousSrsTypeNode = node;
729 newItem =
new QTreeWidgetItem( node, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
731 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
733 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
735 newItem->parent()->setExpanded(
true );
739 newItem->setData( 0, Qt::UserRole, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 6 ) ) );
740 newItem->setHidden( cbxHideDeprecated->isChecked() );
742 mProjList->setExpanded(
true );
746 sqlite3_finalize( stmt );
748 sqlite3_close( database );
750 mProjListDone =
true;
754 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
764 lstCoordinateSystems->scrollToItem( current );
768 if ( current->childCount() == 0 )
773 teSelected->setText( selectedName() );
774 updateBoundsPreview();
776 QList<QTreeWidgetItem *> nodes = lstRecent->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly, QgisCrsIdColumn );
777 if ( !nodes.isEmpty() )
779 QgsDebugMsgLevel( QString(
"found srs %1 in recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
780 lstRecent->setCurrentItem( nodes.first() );
784 QgsDebugMsgLevel( QString(
"srs %1 not recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
785 lstRecent->clearSelection();
786 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
792 current->setSelected(
false );
793 teProjection->clear();
795 lstRecent->clearSelection();
799 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current,
int column )
813 if ( current->childCount() == 0 )
817 void QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
827 lstRecent->scrollToItem( current );
829 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
830 if ( !nodes.isEmpty() )
831 lstCoordinateSystems->setCurrentItem( nodes.first() );
834 void QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked( QTreeWidgetItem *current,
int column )
846 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
847 if ( !nodes.isEmpty() )
851 void QgsProjectionSelectionTreeWidget::hideDeprecated( QTreeWidgetItem *item )
853 if ( item->data( 0, Qt::UserRole ).toBool() )
855 item->setHidden( cbxHideDeprecated->isChecked() );
856 if ( item->isSelected() && item->isHidden() )
858 item->setSelected(
false );
859 teProjection->clear();
864 for (
int i = 0; i < item->childCount(); i++ )
865 hideDeprecated( item->child( i ) );
868 void QgsProjectionSelectionTreeWidget::cbxHideDeprecated_stateChanged()
870 for (
int i = 0; i < lstCoordinateSystems->topLevelItemCount(); i++ )
871 hideDeprecated( lstCoordinateSystems->topLevelItem( i ) );
874 void QgsProjectionSelectionTreeWidget::leSearch_textChanged(
const QString &filterTxt )
876 QString filterTxtCopy = filterTxt;
877 filterTxtCopy.replace( QRegExp(
"\\s+" ), QStringLiteral(
".*" ) );
878 QRegExp re( filterTxtCopy, Qt::CaseInsensitive );
881 QTreeWidgetItemIterator itr( lstRecent );
884 if ( ( *itr )->childCount() == 0 )
886 if ( ( *itr )->text( NameColumn ).contains( re )
887 || ( *itr )->text( AuthidColumn ).contains( re )
890 ( *itr )->setHidden(
false );
891 QTreeWidgetItem *parent = ( *itr )->parent();
894 parent->setExpanded(
true );
895 parent->setHidden(
false );
896 parent = parent->parent();
901 ( *itr )->setHidden(
true );
906 ( *itr )->setHidden(
true );
912 QTreeWidgetItemIterator it( lstCoordinateSystems );
915 if ( ( *it )->childCount() == 0 )
917 if ( ( *it )->text( NameColumn ).contains( re )
918 || ( *it )->text( AuthidColumn ).contains( re )
921 ( *it )->setHidden(
false );
922 QTreeWidgetItem *parent = ( *it )->parent();
925 parent->setExpanded(
true );
926 parent->setHidden(
false );
927 parent = parent->parent();
932 ( *it )->setHidden(
true );
937 ( *it )->setHidden(
true );
947 mPushProjectionToFront =
true;
951 long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch(
const QString &sql )
960 const char *tail =
nullptr;
961 sqlite3_stmt *stmt =
nullptr;
968 if ( QFileInfo::exists( databaseFileName ) )
970 result = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
977 showDBMissingWarning( databaseFileName );
981 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
983 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
985 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
986 srsId = srsIdString.toLong();
988 sqlite3_finalize( stmt );
989 sqlite3_close( database );
996 result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
999 QgsDebugMsg( QString(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
1005 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
1007 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
1009 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
1010 srsId = srsIdString.toLong();
1014 sqlite3_finalize( stmt );
1015 sqlite3_close( database );
1020 void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
1022 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
1023 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
1046 mPreviewBand->
setColor( QColor( 255, 0, 0, 65 ) );
1048 extent.
scale( 1.1 );
1049 mAreaCanvas->setExtent( extent );
1050 mAreaCanvas->refresh();
1051 mPreviewBand->show();
1052 QString extentString = tr(
"Extent: %1, %2, %3, %4" )
1056 .arg( rect.
yMaximum(), 0,
'f', 2 );
1057 QString proj4String = tr(
"Proj4: %1" ).arg( selectedProj4String() );
1058 teProjection->setText( extentString +
"\n" + proj4String );
1062 mPreviewBand->hide();
1063 mAreaCanvas->zoomToFullExtent();
1064 QString extentString = tr(
"Extent: Extent not known" );
1065 QString proj4String = tr(
"Proj4: %1" ).arg( selectedProj4String() );
1066 teProjection->setText( extentString +
"\n" + proj4String );
1070 QStringList QgsProjectionSelectionTreeWidget::authorities()
1073 const char *tail =
nullptr;
1074 sqlite3_stmt *stmt =
nullptr;
1076 int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
1079 QgsDebugMsg( QString(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
1081 return QStringList();
1084 QString sql = QStringLiteral(
"select distinct auth_name from tbl_srs" );
1085 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
1087 QStringList authorities;
1088 if ( result == SQLITE_OK )
1090 while ( sqlite3_step( stmt ) == SQLITE_ROW )
1092 authorities << QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
1098 sqlite3_finalize( stmt );
1099 sqlite3_close( database );
1104 QString QgsProjectionSelectionTreeWidget::sqlSafeString(
const QString &theSQL )
const 1106 QString retval = theSQL;
1107 retval.replace(
'\\', QLatin1String(
"\\\\" ) );
1108 retval.replace(
'\"', QLatin1String(
"\\\"" ) );
1109 retval.replace(
'\'', QLatin1String(
"\\'" ) );
1110 retval.replace(
'%', QLatin1String(
"\\%" ) );
1114 void QgsProjectionSelectionTreeWidget::showDBMissingWarning(
const QString &fileName )
1117 QMessageBox::critical(
this, tr(
"Resource Location Error" ),
1118 tr(
"Error reading database file from: \n %1\n" 1119 "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.
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.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning)
add a message to the instance (and create it if necessary)
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.
void setValue(const QString &key, const QVariant &value, const QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
#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)
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.
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.