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 );
98 mCheckBoxNoProjection->setEnabled(
false );
100 connect( mCheckBoxNoProjection, &QCheckBox::toggled,
this, [ = ](
bool checked )
102 if ( mCheckBoxNoProjection->isEnabled() )
104 mFrameProjections->setDisabled( checked );
111 qDeleteAll( mLayers );
113 delete mPreviewBand2;
114 delete mVertexMarker;
116 if ( !mPushProjectionToFront )
122 long crsId = selectedCrsId();
127 mRecentProjections.removeAll( QString::number( crsId ) );
128 mRecentProjections.prepend( QString::number( crsId ) );
130 while ( mRecentProjections.size() > 8 )
132 mRecentProjections.removeLast();
137 settings.
setValue( QStringLiteral(
"/UI/recentProjections" ), mRecentProjections );
141 QStringList projectionsProj4;
142 QStringList projectionsAuthId;
143 for (
int i = 0; i < mRecentProjections.size(); i++ )
155 settings.
setValue( QStringLiteral(
"/UI/recentProjectionsProj4" ), projectionsProj4 );
156 settings.
setValue( QStringLiteral(
"/UI/recentProjectionsAuthId" ), projectionsAuthId );
161 lstCoordinateSystems->header()->resizeSection( NameColumn, event->size().width() - 240 );
162 lstCoordinateSystems->header()->resizeSection( AuthidColumn, 240 );
163 lstCoordinateSystems->header()->resizeSection( QgisCrsIdColumn, 0 );
165 lstRecent->header()->resizeSection( NameColumn, event->size().width() - 240 );
166 lstRecent->header()->resizeSection( AuthidColumn, 240 );
167 lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
174 loadCrsList( &mCrsFilter );
175 loadUserCrsList( &mCrsFilter );
177 if ( !mRecentProjListDone )
179 for (
int i = mRecentProjections.size() - 1; i >= 0; i-- )
180 insertRecent( mRecentProjections.at( i ).toLong() );
181 mRecentProjListDone =
true;
190 QWidget::showEvent( event );
193 QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter )
195 QString sqlExpression = QStringLiteral(
"1" );
196 QMap<QString, QStringList> authParts;
199 return sqlExpression;
219 Q_FOREACH (
const QString &auth_id, *crsFilter )
221 QStringList parts = auth_id.split(
':' );
223 if ( parts.size() < 2 )
226 authParts[ parts.at( 0 ).toUpper()].append( parts.at( 1 ).toUpper() );
229 if ( authParts.isEmpty() )
230 return sqlExpression;
232 if ( !authParts.isEmpty() )
234 QString prefix = QStringLiteral(
" AND (" );
235 for (
auto it = authParts.constBegin(); it != authParts.constEnd(); ++it )
237 sqlExpression += QStringLiteral(
"%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
240 it.value().join( QStringLiteral(
"','" ) ) );
241 prefix = QStringLiteral(
" OR " );
243 sqlExpression +=
')';
248 return sqlExpression;
251 void QgsProjectionSelectionTreeWidget::applySelection(
int column, QString value )
253 if ( !mProjListDone || !mUserProjListDone )
256 mSearchColumn = column;
257 mSearchValue = value;
261 if ( column == QgsProjectionSelectionTreeWidget::None )
264 column = mSearchColumn;
265 value = mSearchValue;
267 mSearchColumn = QgsProjectionSelectionTreeWidget::None;
268 mSearchValue.clear();
271 if ( column == QgsProjectionSelectionTreeWidget::None )
274 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( value, Qt::MatchExactly | Qt::MatchRecursive, column );
275 if ( !nodes.isEmpty() )
277 QgsDebugMsgLevel( QStringLiteral(
"found %1,%2" ).arg( column ).arg( value ), 4 );
278 lstCoordinateSystems->setCurrentItem( nodes.first() );
282 QgsDebugMsgLevel( QStringLiteral(
"nothing found for %1,%2" ).arg( column ).arg( value ), 4 );
284 lstCoordinateSystems->clearSelection();
285 lstRecent->clearSelection();
286 teProjection->clear();
291 void QgsProjectionSelectionTreeWidget::insertRecent(
long crsId )
293 if ( !mProjListDone || !mUserProjListDone )
296 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( QString::number( crsId ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
297 if ( nodes.isEmpty() )
300 lstRecent->insertTopLevelItem( 0,
new QTreeWidgetItem( lstRecent, QStringList()
301 << nodes.first()->text( NameColumn )
302 << nodes.first()->text( AuthidColumn )
303 << nodes.first()->text( QgisCrsIdColumn ) ) );
307 QString QgsProjectionSelectionTreeWidget::selectedName()
310 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
311 return lvi ? lvi->text( NameColumn ) : QString();
318 mCheckBoxNoProjection->setChecked(
true );
322 mCheckBoxNoProjection->setChecked(
false );
323 applySelection( AuthidColumn, crs.
authid() );
331 mPreviewBand2->show();
333 mVertexMarker->show();
342 QString QgsProjectionSelectionTreeWidget::selectedProj4String()
350 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
351 if ( !item || item->text( QgisCrsIdColumn ).isEmpty() )
354 QString srsId = item->text( QgisCrsIdColumn );
363 QString databaseFileName;
367 if ( !QFileInfo::exists( databaseFileName ) )
372 databaseFileName = mSrsDatabaseFileName;
378 int rc = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
381 showDBMissingWarning( databaseFileName );
386 const char *tail =
nullptr;
387 sqlite3_stmt *stmt =
nullptr;
388 QString sql = QStringLiteral(
"select parameters from tbl_srs where srs_id=%1" ).arg( srsId );
392 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
395 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
397 projString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
401 sqlite3_finalize( stmt );
403 sqlite3_close( database );
405 Q_ASSERT( !projString.isEmpty() );
410 QString QgsProjectionSelectionTreeWidget::getSelectedExpression(
const QString &expression )
const 419 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
420 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
427 QString databaseFileName;
431 if ( !QFileInfo::exists( databaseFileName ) )
438 databaseFileName = mSrsDatabaseFileName;
447 int rc = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
451 "Because of this the projection selector will not work…" ).arg( databaseFileName ),
457 const char *tail =
nullptr;
458 sqlite3_stmt *stmt =
nullptr;
459 QString sql = QStringLiteral(
"select %1 from tbl_srs where srs_id=%2" )
461 lvi->text( QgisCrsIdColumn ) );
463 QgsDebugMsgLevel( QStringLiteral(
"Finding selected attribute using : %1" ).arg( sql ), 4 );
464 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
466 QString attributeValue;
467 if ( rc == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
470 attributeValue = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
474 sqlite3_finalize( stmt );
476 sqlite3_close( database );
479 return attributeValue;
484 if ( mCheckBoxNoProjection->isEnabled() && mCheckBoxNoProjection->isChecked() )
487 int srid = getSelectedExpression( QStringLiteral(
"srs_id" ) ).toLong();
496 mCheckBoxNoProjection->setVisible( show );
497 mCheckBoxNoProjection->setEnabled( show );
500 mFrameProjections->setDisabled( mCheckBoxNoProjection->isChecked() );
507 mAreaCanvas->setVisible( show );
513 return !mCheckBoxNoProjection->isHidden();
523 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
524 if ( mCheckBoxNoProjection->isChecked() )
527 return item && !item->text( QgisCrsIdColumn ).isEmpty();
530 long QgsProjectionSelectionTreeWidget::selectedCrsId()
532 QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
534 if ( item && !item->text( QgisCrsIdColumn ).isEmpty() )
535 return lstCoordinateSystems->currentItem()->text( QgisCrsIdColumn ).toLong();
543 mCrsFilter = crsFilter;
544 mProjListDone =
false;
545 mUserProjListDone =
false;
546 lstCoordinateSystems->clear();
549 void QgsProjectionSelectionTreeWidget::loadUserCrsList( QSet<QString> *crsFilter )
551 if ( mUserProjListDone )
554 QgsDebugMsgLevel( QStringLiteral(
"Fetching user projection list..." ), 4 );
557 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
561 mUserProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"User Defined Coordinate Systems" ) ) );
563 QFont fontTemp = mUserProjList->font( 0 );
564 fontTemp.setItalic(
true );
565 fontTemp.setBold(
true );
566 mUserProjList->setFont( 0, fontTemp );
576 if ( !QFileInfo::exists( databaseFileName ) )
578 QgsDebugMsg( QStringLiteral(
"Users qgis.db not found...skipping" ) );
579 mUserProjListDone =
true;
584 const char *tail =
nullptr;
585 sqlite3_stmt *stmt =
nullptr;
587 int result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
594 showDBMissingWarning( databaseFileName );
599 QString sql = QStringLiteral(
"select description, srs_id from vw_srs where %1" ).arg( sqlFilter );
601 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
603 if ( result == SQLITE_OK )
605 QTreeWidgetItem *newItem =
nullptr;
606 while ( sqlite3_step( stmt ) == SQLITE_ROW )
608 newItem =
new QTreeWidgetItem( mUserProjList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
614 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
615 newItem->setText( AuthidColumn, QStringLiteral(
"USER:%1" ).arg( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ).toInt() ) );
619 sqlite3_finalize( stmt );
620 sqlite3_close( database );
622 mUserProjListDone =
true;
625 void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
631 QString sqlFilter = ogcWmsCrsFilterAsSqlExpression( crsFilter );
637 mGeoList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Geographic Coordinate Systems" ) ) );
639 QFont fontTemp = mGeoList->font( 0 );
640 fontTemp.setItalic(
true );
641 fontTemp.setBold(
true );
642 mGeoList->setFont( 0, fontTemp );
646 mProjList =
new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr(
"Projected Coordinate Systems" ) ) );
648 fontTemp = mProjList->font( 0 );
649 fontTemp.setItalic(
true );
650 fontTemp.setBold(
true );
651 mProjList->setFont( 0, fontTemp );
659 if ( !QFileInfo::exists( mSrsDatabaseFileName ) )
661 mProjListDone =
true;
667 int rc = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
672 showDBMissingWarning( mSrsDatabaseFileName );
676 const char *tail =
nullptr;
677 sqlite3_stmt *stmt =
nullptr;
681 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" )
684 rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
686 if ( rc == SQLITE_OK )
688 QTreeWidgetItem *newItem =
nullptr;
691 QString previousSrsType;
692 QTreeWidgetItem *previousSrsTypeNode =
nullptr;
694 while ( sqlite3_step( stmt ) == SQLITE_ROW )
697 int isGeo = sqlite3_column_int( stmt, 3 );
702 newItem =
new QTreeWidgetItem( mGeoList, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
705 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
708 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
713 QTreeWidgetItem *node =
nullptr;
714 QString srsType = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 4 ) );
717 if ( srsType == previousSrsType )
719 node = previousSrsTypeNode;
724 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( srsType, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
725 if ( nodes.isEmpty() )
729 node =
new QTreeWidgetItem( mProjList, QStringList( srsType ) );
730 QFont fontTemp = node->font( 0 );
731 fontTemp.setItalic(
true );
732 node->setFont( 0, fontTemp );
736 node = nodes.first();
739 previousSrsType = srsType;
740 previousSrsTypeNode = node;
743 newItem =
new QTreeWidgetItem( node, QStringList( QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) ) ) );
745 newItem->setText( AuthidColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 2 ) ) );
747 newItem->setText( QgisCrsIdColumn, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 1 ) ) );
749 newItem->parent()->setExpanded(
true );
753 newItem->setData( 0, RoleDeprecated, QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 6 ) ) );
754 newItem->setHidden( cbxHideDeprecated->isChecked() );
756 mProjList->setExpanded(
true );
760 sqlite3_finalize( stmt );
762 sqlite3_close( database );
764 mProjListDone =
true;
768 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
778 lstCoordinateSystems->scrollToItem( current );
782 if ( current->childCount() == 0 )
787 teSelected->setText( selectedName() );
788 updateBoundsPreview();
790 QList<QTreeWidgetItem *> nodes = lstRecent->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly, QgisCrsIdColumn );
791 if ( !nodes.isEmpty() )
793 QgsDebugMsgLevel( QStringLiteral(
"found srs %1 in recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
794 lstRecent->setCurrentItem( nodes.first() );
798 QgsDebugMsgLevel( QStringLiteral(
"srs %1 not recent" ).arg( current->text( QgisCrsIdColumn ) ), 4 );
799 lstRecent->clearSelection();
800 lstCoordinateSystems->setFocus( Qt::OtherFocusReason );
806 current->setSelected(
false );
807 teProjection->clear();
809 lstRecent->clearSelection();
813 void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current,
int column )
827 if ( current->childCount() == 0 )
831 void QgsProjectionSelectionTreeWidget::lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
841 lstRecent->scrollToItem( current );
843 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
844 if ( !nodes.isEmpty() )
845 lstCoordinateSystems->setCurrentItem( nodes.first() );
848 void QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked( QTreeWidgetItem *current,
int column )
860 QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly | Qt::MatchRecursive, QgisCrsIdColumn );
861 if ( !nodes.isEmpty() )
865 void QgsProjectionSelectionTreeWidget::updateFilter()
867 QString filterTxtCopy = leSearch->text();
868 filterTxtCopy.replace( QRegExp(
"\\s+" ), QStringLiteral(
".*" ) );
869 QRegExp re( filterTxtCopy, Qt::CaseInsensitive );
871 const bool hideDeprecated = cbxHideDeprecated->isChecked();
873 auto filterTreeWidget = [ = ]( QTreeWidget * tree )
875 QTreeWidgetItemIterator itr( tree );
878 if ( ( *itr )->childCount() == 0 )
880 if ( hideDeprecated && ( *itr )->data( 0, RoleDeprecated ).toBool() )
882 ( *itr )->setHidden(
true );
883 if ( ( *itr )->isSelected() )
885 ( *itr )->setSelected(
false );
886 teProjection->clear();
890 else if ( ( *itr )->text( NameColumn ).contains( re )
891 || ( *itr )->text( AuthidColumn ).contains( re )
894 ( *itr )->setHidden(
false );
895 QTreeWidgetItem *parent = ( *itr )->parent();
898 parent->setExpanded(
true );
899 parent->setHidden(
false );
900 parent = parent->parent();
905 ( *itr )->setHidden(
true );
910 ( *itr )->setHidden(
true );
917 filterTreeWidget( lstRecent );
920 filterTreeWidget( lstCoordinateSystems );
927 mPushProjectionToFront =
true;
931 long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch(
const QString &sql )
940 const char *tail =
nullptr;
941 sqlite3_stmt *stmt =
nullptr;
948 if ( QFileInfo::exists( databaseFileName ) )
950 result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
957 showDBMissingWarning( databaseFileName );
961 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
963 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
965 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
966 srsId = srsIdString.toLong();
968 sqlite3_finalize( stmt );
969 sqlite3_close( database );
976 result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
979 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
985 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
987 if ( result == SQLITE_OK && sqlite3_step( stmt ) == SQLITE_ROW )
989 QString srsIdString = QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
990 srsId = srsIdString.toLong();
994 sqlite3_finalize( stmt );
995 sqlite3_close( database );
1000 void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
1002 QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
1003 if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
1026 mPreviewBand->
setColor( QColor( 255, 0, 0, 65 ) );
1028 extent.
scale( 1.1 );
1029 mAreaCanvas->setExtent( extent );
1030 mAreaCanvas->refresh();
1031 mPreviewBand->show();
1032 QString extentString = tr(
"Extent: %1, %2, %3, %4" )
1036 .arg( rect.
yMaximum(), 0,
'f', 2 );
1037 QString proj4String = tr(
"Proj4: %1" ).arg( selectedProj4String() );
1038 teProjection->setText( extentString +
"\n" + proj4String );
1042 mPreviewBand->hide();
1043 mAreaCanvas->zoomToFullExtent();
1044 QString extentString = tr(
"Extent: Extent not known" );
1045 QString proj4String = tr(
"Proj4: %1" ).arg( selectedProj4String() );
1046 teProjection->setText( extentString +
"\n" + proj4String );
1050 QStringList QgsProjectionSelectionTreeWidget::authorities()
1053 const char *tail =
nullptr;
1054 sqlite3_stmt *stmt =
nullptr;
1056 int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, nullptr );
1059 QgsDebugMsg( QStringLiteral(
"Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
1061 return QStringList();
1064 QString sql = QStringLiteral(
"select distinct auth_name from tbl_srs" );
1065 result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
1067 QStringList authorities;
1068 if ( result == SQLITE_OK )
1070 while ( sqlite3_step( stmt ) == SQLITE_ROW )
1072 authorities << QString::fromUtf8( (
char * )sqlite3_column_text( stmt, 0 ) );
1078 sqlite3_finalize( stmt );
1079 sqlite3_close( database );
1084 QString QgsProjectionSelectionTreeWidget::sqlSafeString(
const QString &theSQL )
const 1086 QString retval = theSQL;
1087 retval.replace(
'\\', QLatin1String(
"\\\\" ) );
1088 retval.replace(
'\"', QLatin1String(
"\\\"" ) );
1089 retval.replace(
'\'', QLatin1String(
"\\'" ) );
1090 retval.replace(
'%', QLatin1String(
"\\%" ) );
1094 void QgsProjectionSelectionTreeWidget::showDBMissingWarning(
const QString &fileName )
1097 QMessageBox::critical(
this, tr(
"Resource Location Error" ),
1098 tr(
"Error reading database file from: \n %1\n" 1099 "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.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
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)
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
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.
double area() const
Returns the area of the rectangle.
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.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
#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).
QgsPointXY center() const
Returns the center point of the rectangle.
A class for marking vertices of features using e.g.
static QString pkgDataPath()
Returns the common root path of all application data directories.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
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.
This class represents a coordinate reference system (CRS).
QString authid() const
Returns the authority identifier for the CRS.
static QString srsDatabaseFilePath()
Returns the path to the srs.db file.
void setColor(const QColor &color)
Sets the color for the rubberband.
void setColor(const QColor &color)
Sets the stroke color for the marker.
Represents a vector layer which manages a vector based data sets.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
void setIconType(int iconType)
QString toProj4() const
Returns a Proj4 string representation of this CRS.
QgsRectangle bounds() const
Returns the approximate bounds for the region the CRS is usable within.