31 #include <QHeaderView> 32 #include <QResizeEvent> 33 #include <QMessageBox> 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 );
54 QColor rectColor = QColor( 185, 84, 210, 60 );
55 mPreviewBand2->
setColor( rectColor );
59 mVertexMarker->
setColor( QColor( 185, 84, 210 ) );
63 mAreaCanvas->setDestinationCrs( srs );
67 mAreaCanvas->setLayers( mLayers );
69 mAreaCanvas->setPreviewJobsEnabled(
true );
70 mAreaCanvas->setVisible( mShowMap );
72 if ( QDialog *dlg = qobject_cast<QDialog *>( parent ) )
81 lstCoordinateSystems->header()->setSectionResizeMode( AuthidColumn, QHeaderView::Stretch );
82 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
83 lstCoordinateSystems->header()->setSectionResizeMode( QgisCrsIdColumn, QHeaderView::Fixed );
86 lstCoordinateSystems->setColumnHidden( QgisCrsIdColumn,
true );
88 lstRecent->header()->setSectionResizeMode( AuthidColumn, QHeaderView::Stretch );
89 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
90 lstRecent->header()->setSectionResizeMode( QgisCrsIdColumn, QHeaderView::Fixed );
93 lstRecent->setColumnHidden( QgisCrsIdColumn,
true );
97 mCheckBoxNoProjection->setHidden(
true );
99 connect( mCheckBoxNoProjection, &QCheckBox::toggled, mFrameProjections, &QFrame::setDisabled );
104 qDeleteAll( mLayers );
106 delete mPreviewBand2;
107 delete mVertexMarker;
109 if ( !mPushProjectionToFront )
115 long crsId = selectedCrsId();
120 mRecentProjections.removeAll( QString::number( crsId ) );
121 mRecentProjections.prepend( QString::number( crsId ) );
123 while ( mRecentProjections.size() > 8 )
125 mRecentProjections.removeLast();
130 settings.
setValue( QStringLiteral(
"/UI/recentProjections" ), mRecentProjections );
134 QStringList projectionsProj4;
135 QStringList projectionsAuthId;
136 for (
int i = 0; i < mRecentProjections.size(); i++ )
148 settings.
setValue( QStringLiteral(
"/UI/recentProjectionsProj4" ), projectionsProj4 );
149 settings.
setValue( QStringLiteral(
"/UI/recentProjectionsAuthId" ), projectionsAuthId );
154 lstCoordinateSystems->header()->resizeSection( NameColumn, event->size().width() - 240 );
155 lstCoordinateSystems->header()->resizeSection( AuthidColumn, 240 );
156 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
158 lstRecent->header()->resizeSection( NameColumn, event->size().width() - 240 );
159 lstRecent->header()->resizeSection( AuthidColumn, 240 );
160 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
167 loadCrsList( &mCrsFilter );
168 loadUserCrsList( &mCrsFilter );
170 if ( !mRecentProjListDone )
172 for (
int i = mRecentProjections.size() - 1; i >= 0; i-- )
173 insertRecent( mRecentProjections.at( i ).toLong() );
174 mRecentProjListDone =
true;
183 QWidget::showEvent( event );
186 QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter )
188 QString sqlExpression = QStringLiteral(
"1" );
189 QMap<QString, QStringList> authParts;
192 return sqlExpression;
212 const auto authIds { *crsFilter };
213 for (
const QString &auth_id : authIds )
215 QStringList parts = auth_id.split(
':' );
217 if ( parts.size() < 2 )
220 authParts[ parts.at( 0 ).toUpper()].append( parts.at( 1 ).toUpper() );
223 if ( authParts.isEmpty() )
224 return sqlExpression;
226 if ( !authParts.isEmpty() )
228 QString prefix = QStringLiteral(
" AND (" );
229 for (
auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
231 sqlExpression += QStringLiteral(
"%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
234 it.value().join( QStringLiteral(
"','" ) ) );
235 prefix = QStringLiteral(
" OR " );
237 sqlExpression +=
')';
242 return sqlExpression;
245 void QgsProjectionSelectionTreeWidget::applySelection(
int column, QString value )
247 if ( !mProjListDone || !mUserProjListDone )
250 mSearchColumn = column;
251 mSearchValue = value;
255 if ( column == QgsProjectionSelectionTreeWidget::None )
258 column = mSearchColumn;
259 value = mSearchValue;
261 mSearchColumn = QgsProjectionSelectionTreeWidget::None;
262 mSearchValue.clear();
265 if ( column == QgsProjectionSelectionTreeWidget::None )
268 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( value, Qt::MatchExactly | Qt::MatchRecursive, column );
269 if ( !nodes.isEmpty() )
271 QgsDebugMsgLevel( QStringLiteral(
"found %1,%2" ).arg( column ).arg( value ), 4 );
272 lstCoordinateSystems->setCurrentItem( nodes.first() );
276 QgsDebugMsgLevel( QStringLiteral(
"nothing found for %1,%2" ).arg( column ).arg( value ), 4 );
278 lstCoordinateSystems->clearSelection();
279 lstRecent->clearSelection();
280 teProjection->clear();
284 void QgsProjectionSelectionTreeWidget::insertRecent(
long crsId )
286 if ( !mProjListDone || !mUserProjListDone )
289 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( QString::number( crsId ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
290 if ( nodes.isEmpty() )
293 lstRecent->insertTopLevelItem( 0,
new QTreeWidgetItem( lstRecent, QStringList()
294 << nodes.first()->text( NameColumn )
295 << nodes.first()->text( AuthidColumn )
296 << nodes.first()->text( QgisCrsIdColumn ) ) );
300 QString QgsProjectionSelectionTreeWidget::selectedName()
303 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
304 return lvi ? lvi->text( NameColumn ) : QString();
311 mCheckBoxNoProjection->setChecked(
true );
315 mCheckBoxNoProjection->setChecked(
false );
316 applySelection( AuthidColumn, crs.
authid() );
324 mPreviewBand2->show();
326 mVertexMarker->show();
335 QString QgsProjectionSelectionTreeWidget::selectedProj4String()
343 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
344 if ( !item || item->text( QgisCrsIdColumn ).isEmpty() )
347 QString srsId = item->text( QgisCrsIdColumn );
356 QString databaseFileName;
360 if ( !QFileInfo::exists( databaseFileName ) )
365 databaseFileName = mSrsDatabaseFileName;
371 int rc = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
374 showDBMissingWarning( databaseFileName );
379 const char *tail =
nullptr;
380 sqlite3_stmt *stmt =
nullptr;
381 QString sql = QStringLiteral(
"select parameters from tbl_srs where srs_id=%1" ).arg( srsId );
385 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
388 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
390 projString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
394 sqlite3_finalize( stmt );
396 sqlite3_close( database );
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().constData(), &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( QStringLiteral(
"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 )
540 QgsDebugMsgLevel( QStringLiteral(
"Fetching user projection list..." ), 4 );
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( QStringLiteral(
"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().constData(), &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;
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 ) );
701 if ( srsType.isEmpty() )
702 srsType = tr(
"Other" );
706 if ( srsType == previousSrsType )
708 node = previousSrsTypeNode;
713 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( srsType, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
714 if ( nodes.isEmpty() )
718 node =
new QTreeWidgetItem( mProjList, QStringList( srsType ) );
719 QFont fontTemp = node->font( 0 );
720 fontTemp.setItalic(
true );
721 node->setFont( 0, fontTemp );
725 node = nodes.first();
728 previousSrsType = srsType;
729 previousSrsTypeNode = node;
732 newItem =
new QTreeWidgetItem( node, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
734 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
736 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
738 newItem->parent()->setExpanded(
true );
742 newItem->setData( 0, RoleDeprecated, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 6 ) ) );
743 newItem->setHidden( cbxHideDeprecated->isChecked() );
745 mProjList->setExpanded(
true );
749 sqlite3_finalize( stmt );
751 sqlite3_close( database );
753 mProjListDone =
true;
757 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
767 lstCoordinateSystems->scrollToItem( current );
771 if ( current->childCount() == 0 )
776 updateBoundsPreview();
778 QList<QTreeWidgetItem *> nodes = lstRecent->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly, QgisCrsIdColumn );
779 if ( !nodes.isEmpty() )
781 QgsDebugMsgLevel( QStringLiteral(
"found srs %1 in recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
782 lstRecent->setCurrentItem( nodes.first() );
786 QgsDebugMsgLevel( QStringLiteral(
"srs %1 not recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
787 lstRecent->clearSelection();
788 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
794 current->setSelected(
false );
795 teProjection->clear();
796 lstRecent->clearSelection();
800 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current,
int column )
814 if ( current->childCount() == 0 )
818 void QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
828 lstRecent->scrollToItem( current );
830 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
831 if ( !nodes.isEmpty() )
832 lstCoordinateSystems->setCurrentItem( nodes.first() );
835 void QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked( QTreeWidgetItem *current,
int column )
847 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
848 if ( !nodes.isEmpty() )
852 void QgsProjectionSelectionTreeWidget::updateFilter()
854 QString filterTxtCopy = leSearch->text();
855 filterTxtCopy.replace( QRegExp(
"\\s+" ), QStringLiteral(
".*" ) );
856 QRegExp re( filterTxtCopy, Qt::CaseInsensitive );
858 const bool hideDeprecated = cbxHideDeprecated->isChecked();
860 auto filterTreeWidget = [ = ]( QTreeWidget * tree )
862 QTreeWidgetItemIterator itr( tree );
865 if ( ( *itr )->childCount() == 0 )
867 if ( hideDeprecated && ( *itr )->data( 0, RoleDeprecated ).toBool() )
869 ( *itr )->setHidden(
true );
870 if ( ( *itr )->isSelected() )
872 ( *itr )->setSelected(
false );
873 teProjection->clear();
876 else if ( ( *itr )->text( NameColumn ).contains( re )
877 || ( *itr )->text( AuthidColumn ).contains( re )
880 ( *itr )->setHidden(
false );
881 QTreeWidgetItem *parent = ( *itr )->parent();
884 parent->setExpanded(
true );
885 parent->setHidden(
false );
886 parent = parent->parent();
891 ( *itr )->setHidden(
true );
896 ( *itr )->setHidden(
true );
903 filterTreeWidget( lstRecent );
906 filterTreeWidget( lstCoordinateSystems );
913 mPushProjectionToFront =
true;
917 long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch(
const QString &sql )
926 const char *tail =
nullptr;
927 sqlite3_stmt *stmt =
nullptr;
934 if ( QFileInfo::exists( databaseFileName ) )
936 result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
943 showDBMissingWarning( databaseFileName );
947 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
949 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
951 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
952 srsId = srsIdString.toLong();
954 sqlite3_finalize( stmt );
955 sqlite3_close( database );
962 result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
965 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
971 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
973 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
975 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
976 srsId = srsIdString.toLong();
980 sqlite3_finalize( stmt );
981 sqlite3_close( database );
986 void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
988 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
989 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
997 QString extentString = tr(
"Extent not known" );
1013 mPreviewBand->
setColor( QColor( 255, 0, 0, 65 ) );
1015 extent.
scale( 1.1 );
1016 mAreaCanvas->setExtent( extent );
1017 mAreaCanvas->refresh();
1018 mPreviewBand->show();
1019 extentString = QStringLiteral(
"%1, %2, %3, %4" )
1023 .arg( rect.
yMaximum(), 0,
'f', 2 );
1028 mPreviewBand->hide();
1029 mAreaCanvas->zoomToFullExtent();
1032 QString extentHtml = QStringLiteral(
"<dt><b>%1</b></dt><dd>%2</dd>" ).arg( tr(
"Extent" ), extentString );
1033 QString proj4String = tr(
"<dt><b>%1</b></dt><dd>%2</dd>" ).arg( tr(
"Proj4" ), selectedProj4String() );
1034 teProjection->setText( QStringLiteral(
"<h3>%1</h3><dl>" ).arg( selectedName() ) + extentHtml + proj4String + QLatin1String(
"</dl>" ) );
1037 QStringList QgsProjectionSelectionTreeWidget::authorities()
1040 const char *tail =
nullptr;
1041 sqlite3_stmt *stmt =
nullptr;
1043 int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
1046 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
1048 return QStringList();
1051 QString sql = QStringLiteral(
"select distinct auth_name from tbl_srs" );
1052 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
1054 QStringList authorities;
1055 if ( result == SQLITE_OK )
1057 while ( sqlite3_step( stmt ) == SQLITE_ROW )
1059 authorities << QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
1065 sqlite3_finalize( stmt );
1066 sqlite3_close( database );
1071 QString QgsProjectionSelectionTreeWidget::sqlSafeString(
const QString &theSQL )
const 1073 QString retval = theSQL;
1074 retval.replace(
'\\', QLatin1String(
"\\\\" ) );
1075 retval.replace(
'\"', QLatin1String(
"\\\"" ) );
1076 retval.replace(
'\'', QLatin1String(
"\\'" ) );
1077 retval.replace(
'%', QLatin1String(
"\\%" ) );
1081 void QgsProjectionSelectionTreeWidget::showDBMissingWarning(
const QString &fileName )
1084 QMessageBox::critical(
this, tr(
"Resource Location Error" ),
1085 tr(
"Error reading database file from: \n %1\n" 1086 "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.
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.
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.
Internal ID used by QGIS in the local SQLite database.
void setToGeometry(const QgsGeometry &geom, QgsVectorLayer *layer)
Sets this rubber band to geom.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
#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)
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 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.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
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.