23#include <QInputDialog>
29#include <QRegularExpressionValidator>
30#include <QRegularExpression>
34 , mProvider( provider )
42 connect( cbxPyramidsLevelsCustom, &QCheckBox::toggled,
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled );
43 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged );
45 mSaveOptionsWidget->setProvider( provider );
51void QgsRasterPyramidsOptionsWidget::updateUi()
54 const QString prefix = mProvider +
"/driverOptions/_pyramids/";
58 tmpStr = mySettings.
value( prefix +
"format",
"external" ).toString();
59 if ( tmpStr == QLatin1String(
"internal" ) )
61 else if ( tmpStr == QLatin1String(
"external_erdas" ) )
67 cboResamplingMethod->clear();
69 for (
const QPair<QString, QString> &method : methods )
71 cboResamplingMethod->addItem( method.second, method.first );
73 const QString defaultMethod = mySettings.
value( prefix +
"resampling",
"AVERAGE" ).toString();
74 const int idx = cboResamplingMethod->findData( defaultMethod );
75 cboResamplingMethod->setCurrentIndex( idx );
78 lePyramidsLevels->setEnabled( cbxPyramidsLevelsCustom->isChecked() );
79 lePyramidsLevels->setValidator(
new QRegularExpressionValidator( QRegularExpression(
"(\\d*)(\\s\\d*)*" ), lePyramidsLevels ) );
80 connect( lePyramidsLevels, &QLineEdit::textEdited,
81 this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
84 if ( mOverviewCheckBoxes.isEmpty() )
88 mOverviewCheckBoxes.clear();
90 for (
const int i : constOverviewList )
92 mOverviewCheckBoxes[ i ] =
new QCheckBox( QString::number( i ),
this );
93 connect( mOverviewCheckBoxes[ i ], &QCheckBox::toggled,
94 this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
95 layoutPyramidsLevels->addWidget( mOverviewCheckBoxes[ i ] );
100 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
101 it.value()->setChecked(
false );
103 tmpStr = mySettings.
value( prefix +
"overviewList",
"" ).toString();
104 const QStringList constSplit = tmpStr.split(
' ', Qt::SkipEmptyParts );
105 for (
const QString &lev : constSplit )
107 if ( mOverviewCheckBoxes.contains( lev.toInt() ) )
108 mOverviewCheckBoxes[ lev.toInt()]->setChecked(
true );
112 mSaveOptionsWidget->updateProfiles();
114 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
116 connect( cboResamplingMethod,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
124 return cboResamplingMethod->currentData().toString();
130 const QString prefix = mProvider +
"/driverOptions/_pyramids/";
139 tmpStr = QStringLiteral(
"external" );
142 tmpStr = QStringLiteral(
"internal" );
145 tmpStr = QStringLiteral(
"external_erdas" );
148 mySettings.
setValue( prefix +
"format", tmpStr );
150 mySettings.
setValue( prefix +
"overviewStr", lePyramidsLevels->text().trimmed() );
154 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
156 if ( it.value()->isChecked() )
157 tmpStr += QString::number( it.key() ) +
' ';
159 mySettings.
setValue( prefix +
"overviewList", tmpStr.trimmed() );
161 mSaveOptionsWidget->apply();
166 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
167 it.value()->setChecked( checked );
170void QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled(
bool toggled )
173 lePyramidsLevels->setEnabled( toggled );
174 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
175 it.value()->setEnabled( ! toggled );
179void QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged(
int )
183 mSaveOptionsWidget->setPyramidsFormat( format );
186void QgsRasterPyramidsOptionsWidget::setOverviewList()
189 mOverviewList.clear();
192 if ( cbxPyramidsLevelsCustom->isChecked() )
195 const QStringList constSplit = lePyramidsLevels->text().trimmed().split(
' ', Qt::SkipEmptyParts );
196 for (
const QString &lev : constSplit )
199 const int tmpInt = lev.toInt();
204 mOverviewList << tmpInt;
210 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
212 if ( it.value()->isChecked() )
213 mOverviewList << it.key();
RasterPyramidFormat
Raster pyramid formats.
@ GeoTiff
Geotiff .ovr (external)
@ Erdas
Erdas Image .aux (external)
static QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
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.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
#define QgsDebugMsgLevel(str, level)