|
41 | 41 | #define ELLIPS_FLAT "NONE" |
42 | 42 | #define ELLIPS_FLAT_DESC "None / Planimetric" |
43 | 43 |
|
| 44 | +#define CPL_SUPRESS_CPLUSPLUS |
| 45 | +#include <gdal.h> |
44 | 46 | /** |
45 | 47 | * \class QgsOptions - Set user options and preferences |
46 | 48 | * Constructor |
@@ -431,6 +433,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) : |
431 | 433 |
|
432 | 434 | restoreGeometry( settings.value( "/Windows/Options/geometry" ).toByteArray() ); |
433 | 435 | tabWidget->setCurrentIndex( settings.value( "/Windows/Options/row" ).toInt() ); |
| 436 | + |
| 437 | + loadGdalDriverList(); |
| 438 | + |
434 | 439 | } |
435 | 440 |
|
436 | 441 | //! Destructor |
@@ -744,6 +749,10 @@ void QgsOptions::saveOptions() |
744 | 749 | // |
745 | 750 | settings.setValue( "locale/userLocale", cboLocale->currentText() ); |
746 | 751 | settings.setValue( "locale/overrideFlag", grpLocale->isChecked() ); |
| 752 | + |
| 753 | + |
| 754 | + // Gdal skip driver list |
| 755 | + saveGdalDriverList(); |
747 | 756 | } |
748 | 757 |
|
749 | 758 |
|
@@ -1010,3 +1019,57 @@ void QgsOptions::on_mClearCache_clicked() |
1010 | 1019 | QgsNetworkAccessManager::instance()->cache()->clear(); |
1011 | 1020 | #endif |
1012 | 1021 | } |
| 1022 | + |
| 1023 | +void QgsOptions::loadGdalDriverList() |
| 1024 | +{ |
| 1025 | + QStringList mySkippedDrivers = QgsApplication::skippedGdalDrivers(); |
| 1026 | + GDALDriverH myGdalDriver; // current driver |
| 1027 | + QString myGdalDriverDescription; |
| 1028 | + QStringList myDrivers; |
| 1029 | + for ( int i = 0; i < GDALGetDriverCount(); ++i ) |
| 1030 | + { |
| 1031 | + myGdalDriver = GDALGetDriver( i ); |
| 1032 | + |
| 1033 | + Q_CHECK_PTR( myGdalDriver ); |
| 1034 | + |
| 1035 | + if ( !myGdalDriver ) |
| 1036 | + { |
| 1037 | + QgsLogger::warning( "unable to get driver " + QString::number( i ) ); |
| 1038 | + continue; |
| 1039 | + } |
| 1040 | + myGdalDriverDescription = GDALGetDescription( myGdalDriver ); |
| 1041 | + myDrivers << myGdalDriverDescription; |
| 1042 | + } |
| 1043 | + QStringListIterator myIterator( myDrivers ); |
| 1044 | + myDrivers.sort(); |
| 1045 | + while (myIterator.hasNext()) |
| 1046 | + { |
| 1047 | + QString myName = myIterator.next(); |
| 1048 | + QListWidgetItem * mypItem = new QListWidgetItem( myName ); |
| 1049 | + if ( mySkippedDrivers.contains( myName ) ) |
| 1050 | + { |
| 1051 | + mypItem->setCheckState( Qt::Unchecked ); |
| 1052 | + } |
| 1053 | + else |
| 1054 | + { |
| 1055 | + mypItem->setCheckState( Qt::Checked ); |
| 1056 | + } |
| 1057 | + lstGdalDrivers->addItem( mypItem ); |
| 1058 | + } |
| 1059 | +} |
| 1060 | + |
| 1061 | +void QgsOptions::saveGdalDriverList() |
| 1062 | +{ |
| 1063 | + for ( int i=0; i < lstGdalDrivers->count(); i++ ) |
| 1064 | + { |
| 1065 | + QListWidgetItem * mypItem = lstGdalDrivers->item( i ); |
| 1066 | + if ( mypItem->checkState() == Qt::Unchecked ) |
| 1067 | + { |
| 1068 | + QgsApplication::skipGdalDriver( mypItem->text() ); |
| 1069 | + } |
| 1070 | + else |
| 1071 | + { |
| 1072 | + QgsApplication::restoreGdalDriver( mypItem->text() ); |
| 1073 | + } |
| 1074 | + } |
| 1075 | +} |
0 commit comments