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#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
105 const QStringList constSplit = tmpStr.split(
' ', QString::SkipEmptyParts );
107 const QStringList constSplit = tmpStr.split(
' ', Qt::SkipEmptyParts );
109 for (
const QString &lev : constSplit )
111 if ( mOverviewCheckBoxes.contains( lev.toInt() ) )
112 mOverviewCheckBoxes[ lev.toInt()]->setChecked(
true );
116 mSaveOptionsWidget->updateProfiles();
118 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
120 connect( cboResamplingMethod,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
128 return cboResamplingMethod->currentData().toString();
134 const QString prefix = mProvider +
"/driverOptions/_pyramids/";
143 tmpStr = QStringLiteral(
"external" );
146 tmpStr = QStringLiteral(
"internal" );
149 tmpStr = QStringLiteral(
"external_erdas" );
152 mySettings.
setValue( prefix +
"format", tmpStr );
154 mySettings.
setValue( prefix +
"overviewStr", lePyramidsLevels->text().trimmed() );
158 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
160 if ( it.value()->isChecked() )
161 tmpStr += QString::number( it.key() ) +
' ';
163 mySettings.
setValue( prefix +
"overviewList", tmpStr.trimmed() );
165 mSaveOptionsWidget->apply();
170 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
171 it.value()->setChecked( checked );
174void QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled(
bool toggled )
177 lePyramidsLevels->setEnabled( toggled );
178 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
179 it.value()->setEnabled( ! toggled );
183void QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged(
int )
187 mSaveOptionsWidget->setPyramidsFormat( format );
190void QgsRasterPyramidsOptionsWidget::setOverviewList()
193 mOverviewList.clear();
196 if ( cbxPyramidsLevelsCustom->isChecked() )
199#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
200 const QStringList constSplit = lePyramidsLevels->text().trimmed().split(
' ', QString::SkipEmptyParts );
202 const QStringList constSplit = lePyramidsLevels->text().trimmed().split(
' ', Qt::SkipEmptyParts );
204 for (
const QString &lev : constSplit )
207 const int tmpInt = lev.toInt();
212 mOverviewList << tmpInt;
218 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
220 if ( it.value()->isChecked() )
221 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)