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 Q_FOREACH (
const QString &auth_id, *crsFilter )
214 QStringList parts = auth_id.split(
':' );
216 if ( parts.size() < 2 )
219 authParts[ parts.at( 0 ).toUpper()].append( parts.at( 1 ).toUpper() );
222 if ( authParts.isEmpty() )
223 return sqlExpression;
225 if ( !authParts.isEmpty() )
227 QString prefix = QStringLiteral(
" AND (" );
228 for (
auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
230 sqlExpression += QStringLiteral(
"%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
233 it.value().join( QStringLiteral(
"','" ) ) );
234 prefix = QStringLiteral(
" OR " );
236 sqlExpression +=
')';
241 return sqlExpression;
244 void QgsProjectionSelectionTreeWidget::applySelection(
int column, QString value )
246 if ( !mProjListDone || !mUserProjListDone )
249 mSearchColumn = column;
250 mSearchValue = value;
254 if ( column == QgsProjectionSelectionTreeWidget::None )
257 column = mSearchColumn;
258 value = mSearchValue;
260 mSearchColumn = QgsProjectionSelectionTreeWidget::None;
261 mSearchValue.clear();
264 if ( column == QgsProjectionSelectionTreeWidget::None )
267 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( value, Qt::MatchExactly | Qt::MatchRecursive, column );
268 if ( !nodes.isEmpty() )
270 QgsDebugMsgLevel( QStringLiteral(
"found %1,%2" ).arg( column ).arg( value ), 4 );
271 lstCoordinateSystems->setCurrentItem( nodes.first() );
275 QgsDebugMsgLevel( QStringLiteral(
"nothing found for %1,%2" ).arg( column ).arg( value ), 4 );
277 lstCoordinateSystems->clearSelection();
278 lstRecent->clearSelection();
279 teProjection->clear();
283 void QgsProjectionSelectionTreeWidget::insertRecent(
long crsId )
285 if ( !mProjListDone || !mUserProjListDone )
288 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( QString::number( crsId ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
289 if ( nodes.isEmpty() )
292 lstRecent->insertTopLevelItem( 0,
new QTreeWidgetItem( lstRecent, QStringList()
293 << nodes.first()->text( NameColumn )
294 << nodes.first()->text( AuthidColumn )
295 << nodes.first()->text( QgisCrsIdColumn ) ) );
299 QString QgsProjectionSelectionTreeWidget::selectedName()
302 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
303 return lvi ? lvi->text( NameColumn ) : QString();
310 mCheckBoxNoProjection->setChecked(
true );
314 mCheckBoxNoProjection->setChecked(
false );
315 applySelection( AuthidColumn, crs.
authid() );
323 mPreviewBand2->show();
325 mVertexMarker->show();
334 QString QgsProjectionSelectionTreeWidget::selectedProj4String()
342 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
343 if ( !item || item->text( QgisCrsIdColumn ).isEmpty() )
346 QString srsId = item->text( QgisCrsIdColumn );
355 QString databaseFileName;
359 if ( !QFileInfo::exists( databaseFileName ) )
364 databaseFileName = mSrsDatabaseFileName;
370 int rc = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
373 showDBMissingWarning( databaseFileName );
378 const char *tail =
nullptr;
379 sqlite3_stmt *stmt =
nullptr;
380 QString sql = QStringLiteral(
"select parameters from tbl_srs where srs_id=%1" ).arg( srsId );
384 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
387 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
389 projString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
393 sqlite3_finalize( stmt );
395 sqlite3_close( database );
397 Q_ASSERT( !projString.isEmpty() );
402 QString QgsProjectionSelectionTreeWidget::getSelectedExpression(
const QString &expression )
const 411 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
412 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
419 QString databaseFileName;
423 if ( !QFileInfo::exists( databaseFileName ) )
430 databaseFileName = mSrsDatabaseFileName;
439 int rc = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
443 "Because of this the projection selector will not work…" ).arg( databaseFileName ),
449 const char *tail =
nullptr;
450 sqlite3_stmt *stmt =
nullptr;
451 QString sql = QStringLiteral(
"select %1 from tbl_srs where srs_id=%2" )
453 lvi->text( QgisCrsIdColumn ) );
455 QgsDebugMsgLevel( QStringLiteral(
"Finding selected attribute using : %1" ).arg( sql ), 4 );
456 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
458 QString attributeValue;
459 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
462 attributeValue = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
466 sqlite3_finalize( stmt );
468 sqlite3_close( database );
471 return attributeValue;
476 if ( mCheckBoxNoProjection->isChecked() )
479 int srid = getSelectedExpression( QStringLiteral(
"srs_id" ) ).toLong();
488 mCheckBoxNoProjection->setHidden( !show );
494 mAreaCanvas->setVisible( show );
500 return !mCheckBoxNoProjection->isHidden();
510 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
511 if ( mCheckBoxNoProjection->isChecked() )
514 return item && !item->text( QgisCrsIdColumn ).isEmpty();
517 long QgsProjectionSelectionTreeWidget::selectedCrsId()
519 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
521 if ( item && !item->text( QgisCrsIdColumn ).isEmpty() )
522 return lstCoordinateSystems->currentItem()->text( QgisCrsIdColumn ).toLong();
530 mCrsFilter = crsFilter;
531 mProjListDone =
false;
532 mUserProjListDone =
false;
533 lstCoordinateSystems->clear();
536 void QgsProjectionSelectionTreeWidget::loadUserCrsList( QSet<QString> *crsFilter )
538 if ( mUserProjListDone )
541 QgsDebugMsgLevel( QStringLiteral(
"Fetching user projection list..." ), 4 );
544 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
548 mUserProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"User Defined Coordinate Systems" ) ) );
550 QFont fontTemp = mUserProjList->font( 0 );
551 fontTemp.setItalic(
true );
552 fontTemp.setBold(
true );
553 mUserProjList->setFont( 0, fontTemp );
563 if ( !QFileInfo::exists( databaseFileName ) )
565 QgsDebugMsg( QStringLiteral(
"Users qgis.db not found...skipping" ) );
566 mUserProjListDone =
true;
571 const char *tail =
nullptr;
572 sqlite3_stmt *stmt =
nullptr;
574 int result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
581 showDBMissingWarning( databaseFileName );
586 QString sql = QStringLiteral(
"select description, srs_id from vw_srs where %1" ).arg( sqlFilter );
588 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
590 if ( result == SQLITE_OK )
592 QTreeWidgetItem *newItem =
nullptr;
593 while ( sqlite3_step( stmt ) == SQLITE_ROW )
595 newItem =
new QTreeWidgetItem( mUserProjList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
601 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
602 newItem->setText( AuthidColumn, QStringLiteral(
"USER:%1" ).arg( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ).toInt() ) );
606 sqlite3_finalize( stmt );
607 sqlite3_close( database );
609 mUserProjListDone =
true;
612 void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
618 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
624 mGeoList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Geographic Coordinate Systems" ) ) );
626 QFont fontTemp = mGeoList->font( 0 );
627 fontTemp.setItalic(
true );
628 fontTemp.setBold(
true );
629 mGeoList->setFont( 0, fontTemp );
633 mProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Projected Coordinate Systems" ) ) );
635 fontTemp = mProjList->font( 0 );
636 fontTemp.setItalic(
true );
637 fontTemp.setBold(
true );
638 mProjList->setFont( 0, fontTemp );
646 if ( !QFileInfo::exists( mSrsDatabaseFileName ) )
648 mProjListDone =
true;
654 int rc = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
659 showDBMissingWarning( mSrsDatabaseFileName );
663 const char *tail =
nullptr;
664 sqlite3_stmt *stmt =
nullptr;
668 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" )
671 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
673 if ( rc == SQLITE_OK )
675 QTreeWidgetItem *newItem =
nullptr;
678 QString previousSrsType;
679 QTreeWidgetItem *previousSrsTypeNode =
nullptr;
681 while ( sqlite3_step( stmt ) == SQLITE_ROW )
684 int isGeo = sqlite3_column_int( stmt, 3 );
689 newItem =
new QTreeWidgetItem( mGeoList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
692 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
695 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
700 QTreeWidgetItem *node =
nullptr;
701 QString srsType = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 4 ) );
704 if ( srsType == previousSrsType )
706 node = previousSrsTypeNode;
711 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( srsType, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
712 if ( nodes.isEmpty() )
716 node =
new QTreeWidgetItem( mProjList, QStringList( srsType ) );
717 QFont fontTemp = node->font( 0 );
718 fontTemp.setItalic(
true );
719 node->setFont( 0, fontTemp );
723 node = nodes.first();
726 previousSrsType = srsType;
727 previousSrsTypeNode = node;
730 newItem =
new QTreeWidgetItem( node, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
732 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
734 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
736 newItem->parent()->setExpanded(
true );
740 newItem->setData( 0, RoleDeprecated, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 6 ) ) );
741 newItem->setHidden( cbxHideDeprecated->isChecked() );
743 mProjList->setExpanded(
true );
747 sqlite3_finalize( stmt );
749 sqlite3_close( database );
751 mProjListDone =
true;
755 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
765 lstCoordinateSystems->scrollToItem( current );
769 if ( current->childCount() == 0 )
774 updateBoundsPreview();
776 QList<QTreeWidgetItem *> nodes = lstRecent->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly, QgisCrsIdColumn );
777 if ( !nodes.isEmpty() )
779 QgsDebugMsgLevel( QStringLiteral(
"found srs %1 in recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
780 lstRecent->setCurrentItem( nodes.first() );
784 QgsDebugMsgLevel( QStringLiteral(
"srs %1 not recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
785 lstRecent->clearSelection();
786 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
792 current->setSelected(
false );
793 teProjection->clear();
794 lstRecent->clearSelection();
798 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current,
int column )
812 if ( current->childCount() == 0 )
816 void QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
826 lstRecent->scrollToItem( current );
828 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
829 if ( !nodes.isEmpty() )
830 lstCoordinateSystems->setCurrentItem( nodes.first() );
833 void QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked( QTreeWidgetItem *current,
int column )
845 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
846 if ( !nodes.isEmpty() )
850 void QgsProjectionSelectionTreeWidget::updateFilter()
852 QString filterTxtCopy = leSearch->text();
853 filterTxtCopy.replace( QRegExp(
"\\s+" ), QStringLiteral(
".*" ) );
854 QRegExp re( filterTxtCopy, Qt::CaseInsensitive );
856 const bool hideDeprecated = cbxHideDeprecated->isChecked();
858 auto filterTreeWidget = [ = ]( QTreeWidget * tree )
860 QTreeWidgetItemIterator itr( tree );
863 if ( ( *itr )->childCount() == 0 )
865 if ( hideDeprecated && ( *itr )->data( 0, RoleDeprecated ).toBool() )
867 ( *itr )->setHidden(
true );
868 if ( ( *itr )->isSelected() )
870 ( *itr )->setSelected(
false );
871 teProjection->clear();
874 else if ( ( *itr )->text( NameColumn ).contains( re )
875 || ( *itr )->text( AuthidColumn ).contains( re )
878 ( *itr )->setHidden(
false );
879 QTreeWidgetItem *parent = ( *itr )->parent();
882 parent->setExpanded(
true );
883 parent->setHidden(
false );
884 parent = parent->parent();
889 ( *itr )->setHidden(
true );
894 ( *itr )->setHidden(
true );
901 filterTreeWidget( lstRecent );
904 filterTreeWidget( lstCoordinateSystems );
911 mPushProjectionToFront =
true;
915 long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch(
const QString &sql )
924 const char *tail =
nullptr;
925 sqlite3_stmt *stmt =
nullptr;
932 if ( QFileInfo::exists( databaseFileName ) )
934 result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
941 showDBMissingWarning( databaseFileName );
945 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
947 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
949 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
950 srsId = srsIdString.toLong();
952 sqlite3_finalize( stmt );
953 sqlite3_close( database );
960 result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
963 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
969 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
971 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
973 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
974 srsId = srsIdString.toLong();
978 sqlite3_finalize( stmt );
979 sqlite3_close( database );
984 void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
986 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
987 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
995 QString extentString = tr(
"Extent not known" );
1011 mPreviewBand->
setColor( QColor( 255, 0, 0, 65 ) );
1013 extent.
scale( 1.1 );
1014 mAreaCanvas->setExtent( extent );
1015 mAreaCanvas->refresh();
1016 mPreviewBand->show();
1017 extentString = QStringLiteral(
"%1, %2, %3, %4" )
1021 .arg( rect.
yMaximum(), 0,
'f', 2 );
1026 mPreviewBand->hide();
1027 mAreaCanvas->zoomToFullExtent();
1030 QString extentHtml = QStringLiteral(
"<dt><b>%1</b></dt><dd>%2</dd>" ).arg( tr(
"Extent" ), extentString );
1031 QString proj4String = tr(
"<dt><b>%1</b></dt><dd>%2</dd>" ).arg( tr(
"Proj4" ), selectedProj4String() );
1032 teProjection->setText( QStringLiteral(
"<h3>%1</h3><dl>" ).arg( selectedName() ) + extentHtml + proj4String + QLatin1String(
"</dl>" ) );
1035 QStringList QgsProjectionSelectionTreeWidget::authorities()
1038 const char *tail =
nullptr;
1039 sqlite3_stmt *stmt =
nullptr;
1041 int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
1044 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
1046 return QStringList();
1049 QString sql = QStringLiteral(
"select distinct auth_name from tbl_srs" );
1050 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
1052 QStringList authorities;
1053 if ( result == SQLITE_OK )
1055 while ( sqlite3_step( stmt ) == SQLITE_ROW )
1057 authorities << QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
1063 sqlite3_finalize( stmt );
1064 sqlite3_close( database );
1069 QString QgsProjectionSelectionTreeWidget::sqlSafeString(
const QString &theSQL )
const 1071 QString retval = theSQL;
1072 retval.replace(
'\\', QLatin1String(
"\\\\" ) );
1073 retval.replace(
'\"', QLatin1String(
"\\\"" ) );
1074 retval.replace(
'\'', QLatin1String(
"\\'" ) );
1075 retval.replace(
'%', QLatin1String(
"\\%" ) );
1079 void QgsProjectionSelectionTreeWidget::showDBMissingWarning(
const QString &fileName )
1082 QMessageBox::critical(
this, tr(
"Resource Location Error" ),
1083 tr(
"Error reading database file from: \n %1\n" 1084 "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.