24 #include <QInputDialog> 25 #include <QMessageBox> 27 #include <QMouseEvent> 33 , mProvider( provider )
36 connect( cbxPyramidsLevelsCustom, &QCheckBox::toggled,
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled );
37 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged );
39 mSaveOptionsWidget->setProvider( provider );
46 void QgsRasterPyramidsOptionsWidget::updateUi()
49 QString prefix = mProvider +
"/driverOptions/_pyramids/";
53 tmpStr = mySettings.
value( prefix +
"format",
"external" ).toString();
54 if ( tmpStr == QLatin1String(
"internal" ) )
55 cbxPyramidsFormat->setCurrentIndex( INTERNAL );
56 else if ( tmpStr == QLatin1String(
"external_erdas" ) )
57 cbxPyramidsFormat->setCurrentIndex( ERDAS );
59 cbxPyramidsFormat->setCurrentIndex( GTIFF );
62 cboResamplingMethod->clear();
63 QPair<QString, QString> method;
66 cboResamplingMethod->addItem( method.second, method.first );
68 QString defaultMethod = mySettings.
value( prefix +
"resampling",
"AVERAGE" ).toString();
69 int idx = cboResamplingMethod->findData( defaultMethod );
70 cboResamplingMethod->setCurrentIndex( idx );
73 lePyramidsLevels->setEnabled( cbxPyramidsLevelsCustom->isChecked() );
74 lePyramidsLevels->setValidator(
new QRegExpValidator( QRegExp(
"(\\d*)(\\s\\d*)*" ), lePyramidsLevels ) );
75 connect( lePyramidsLevels, &QLineEdit::textEdited,
76 this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
79 if ( mOverviewCheckBoxes.isEmpty() )
82 overviewList << 2 << 4 << 8 << 16 << 32 << 64;
83 mOverviewCheckBoxes.clear();
84 Q_FOREACH (
int i, overviewList )
86 mOverviewCheckBoxes[ i ] =
new QCheckBox( QString::number( i ),
this );
87 connect( mOverviewCheckBoxes[ i ], &QCheckBox::toggled,
88 this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
89 layoutPyramidsLevels->addWidget( mOverviewCheckBoxes[ i ] );
94 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
95 it.value()->setChecked(
false );
97 tmpStr = mySettings.
value( prefix +
"overviewList",
"" ).toString();
98 Q_FOREACH (
const QString &lev, tmpStr.split(
' ', QString::SkipEmptyParts ) )
100 if ( mOverviewCheckBoxes.contains( lev.toInt() ) )
101 mOverviewCheckBoxes[ lev.toInt()]->setChecked(
true );
105 mSaveOptionsWidget->updateProfiles();
107 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
109 connect( cboResamplingMethod,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
117 return cboResamplingMethod->currentData().toString();
123 QString prefix = mProvider +
"/driverOptions/_pyramids/";
127 if ( cbxPyramidsFormat->currentIndex() == INTERNAL )
128 tmpStr = QStringLiteral(
"internal" );
129 else if ( cbxPyramidsFormat->currentIndex() == ERDAS )
130 tmpStr = QStringLiteral(
"external_erdas" );
132 tmpStr = QStringLiteral(
"external" );
133 mySettings.
setValue( prefix +
"format", tmpStr );
135 mySettings.
setValue( prefix +
"overviewStr", lePyramidsLevels->text().trimmed() );
139 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
141 if ( it.value()->isChecked() )
142 tmpStr += QString::number( it.key() ) +
' ';
144 mySettings.
setValue( prefix +
"overviewList", tmpStr.trimmed() );
146 mSaveOptionsWidget->apply();
151 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
152 it.value()->setChecked( checked );
155 void QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled(
bool toggled )
158 lePyramidsLevels->setEnabled( toggled );
159 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
160 it.value()->setEnabled( ! toggled );
164 void QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged(
int index )
166 mSaveOptionsWidget->setEnabled( index != ERDAS );
184 mSaveOptionsWidget->setPyramidsFormat( format );
187 void QgsRasterPyramidsOptionsWidget::setOverviewList()
190 mOverviewList.clear();
193 if ( cbxPyramidsLevelsCustom->isChecked() )
196 Q_FOREACH (
const QString &lev, lePyramidsLevels->text().trimmed().split(
' ', QString::SkipEmptyParts ) )
199 int tmpInt = lev.toInt();
202 QgsDebugMsg(
"tmpInt= " + QString::number( tmpInt ) );
204 mOverviewList << tmpInt;
210 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
212 if ( it.value()->isChecked() )
213 mOverviewList << it.key();
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
static QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.