25#include <QInputDialog>
29#include <QRegularExpression>
30#include <QRegularExpressionValidator>
33#include "moc_qgsrasterpyramidsoptionswidget.cpp"
37 , mProvider( provider )
45 connect( cbxPyramidsLevelsCustom, &QCheckBox::toggled,
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled );
46 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged );
48 mSaveOptionsWidget->setProvider( provider );
54void QgsRasterPyramidsOptionsWidget::updateUi()
57 const QString prefix = mProvider +
"/driverOptions/_pyramids/";
61 tmpStr = mySettings.
value( prefix +
"format",
"external" ).toString();
62 if ( tmpStr == QLatin1String(
"internal" ) )
64 else if ( tmpStr == QLatin1String(
"external_erdas" ) )
70 cboResamplingMethod->clear();
72 for (
const QPair<QString, QString> &method : methods )
74 cboResamplingMethod->addItem( method.second, method.first );
76 const QString defaultMethod = mySettings.
value( prefix +
"resampling",
"AVERAGE" ).toString();
77 const int idx = cboResamplingMethod->findData( defaultMethod );
78 cboResamplingMethod->setCurrentIndex( idx );
81 lePyramidsLevels->setEnabled( cbxPyramidsLevelsCustom->isChecked() );
82 lePyramidsLevels->setValidator(
new QRegularExpressionValidator( QRegularExpression(
"(\\d*)(\\s\\d*)*" ), lePyramidsLevels ) );
83 connect( lePyramidsLevels, &QLineEdit::textEdited,
this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
86 if ( mOverviewCheckBoxes.isEmpty() )
90 mOverviewCheckBoxes.clear();
92 for (
const int i : constOverviewList )
94 mOverviewCheckBoxes[i] =
new QCheckBox( QString::number( i ),
this );
95 connect( mOverviewCheckBoxes[i], &QCheckBox::toggled,
this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
96 layoutPyramidsLevels->addWidget( mOverviewCheckBoxes[i] );
101 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
102 it.value()->setChecked(
false );
104 tmpStr = mySettings.
value( prefix +
"overviewList",
"" ).toString();
105 const QStringList constSplit = tmpStr.split(
' ', Qt::SkipEmptyParts );
106 for (
const QString &lev : constSplit )
108 if ( mOverviewCheckBoxes.contains( lev.toInt() ) )
109 mOverviewCheckBoxes[lev.toInt()]->setChecked(
true );
113 mSaveOptionsWidget->updateProfiles();
122 return cboResamplingMethod->currentData().toString();
128 const QString prefix = mProvider +
"/driverOptions/_pyramids/";
137 tmpStr = QStringLiteral(
"external" );
140 tmpStr = QStringLiteral(
"internal" );
143 tmpStr = QStringLiteral(
"external_erdas" );
146 mySettings.
setValue( prefix +
"format", tmpStr );
148 mySettings.
setValue( prefix +
"overviewStr", lePyramidsLevels->text().trimmed() );
152 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
154 if ( it.value()->isChecked() )
155 tmpStr += QString::number( it.key() ) +
' ';
157 mySettings.
setValue( prefix +
"overviewList", tmpStr.trimmed() );
159 mSaveOptionsWidget->apply();
164 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
165 it.value()->setChecked( checked );
168void QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled(
bool toggled )
171 lePyramidsLevels->setEnabled( toggled );
172 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
173 it.value()->setEnabled( !toggled );
177void QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged(
int )
181 mSaveOptionsWidget->setPyramidsFormat( format );
184void QgsRasterPyramidsOptionsWidget::setOverviewList()
186 mOverviewList.clear();
189 if ( cbxPyramidsLevelsCustom->isChecked() )
192 const QStringList constSplit = lePyramidsLevels->text().trimmed().split(
' ', Qt::SkipEmptyParts );
193 for (
const QString &lev : constSplit )
196 const int tmpInt = lev.toInt();
201 mOverviewList << tmpInt;
207 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
209 if ( it.value()->isChecked() )
210 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.
Stores settings for use within QGIS.
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)