19#include "moc_qgsrasterpyramidsoptionswidget.cpp"
24#include <QInputDialog>
30#include <QRegularExpressionValidator>
31#include <QRegularExpression>
35 , mProvider( provider )
43 connect( cbxPyramidsLevelsCustom, &QCheckBox::toggled,
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled );
44 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged );
46 mSaveOptionsWidget->setProvider( provider );
52void QgsRasterPyramidsOptionsWidget::updateUi()
55 const QString prefix = mProvider +
"/driverOptions/_pyramids/";
59 tmpStr = mySettings.
value( prefix +
"format",
"external" ).toString();
60 if ( tmpStr == QLatin1String(
"internal" ) )
62 else if ( tmpStr == QLatin1String(
"external_erdas" ) )
68 cboResamplingMethod->clear();
70 for (
const QPair<QString, QString> &method : methods )
72 cboResamplingMethod->addItem( method.second, method.first );
74 const QString defaultMethod = mySettings.
value( prefix +
"resampling",
"AVERAGE" ).toString();
75 const int idx = cboResamplingMethod->findData( defaultMethod );
76 cboResamplingMethod->setCurrentIndex( idx );
79 lePyramidsLevels->setEnabled( cbxPyramidsLevelsCustom->isChecked() );
80 lePyramidsLevels->setValidator(
new QRegularExpressionValidator( QRegularExpression(
"(\\d*)(\\s\\d*)*" ), lePyramidsLevels ) );
81 connect( lePyramidsLevels, &QLineEdit::textEdited,
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,
this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
94 layoutPyramidsLevels->addWidget( mOverviewCheckBoxes[i] );
99 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
100 it.value()->setChecked(
false );
102 tmpStr = mySettings.
value( prefix +
"overviewList",
"" ).toString();
103 const QStringList constSplit = tmpStr.split(
' ', Qt::SkipEmptyParts );
104 for (
const QString &lev : constSplit )
106 if ( mOverviewCheckBoxes.contains( lev.toInt() ) )
107 mOverviewCheckBoxes[lev.toInt()]->setChecked(
true );
111 mSaveOptionsWidget->updateProfiles();
120 return cboResamplingMethod->currentData().toString();
126 const QString prefix = mProvider +
"/driverOptions/_pyramids/";
135 tmpStr = QStringLiteral(
"external" );
138 tmpStr = QStringLiteral(
"internal" );
141 tmpStr = QStringLiteral(
"external_erdas" );
144 mySettings.
setValue( prefix +
"format", tmpStr );
146 mySettings.
setValue( prefix +
"overviewStr", lePyramidsLevels->text().trimmed() );
150 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
152 if ( it.value()->isChecked() )
153 tmpStr += QString::number( it.key() ) +
' ';
155 mySettings.
setValue( prefix +
"overviewList", tmpStr.trimmed() );
157 mSaveOptionsWidget->apply();
162 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
163 it.value()->setChecked( checked );
166void QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled(
bool toggled )
169 lePyramidsLevels->setEnabled( toggled );
170 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
171 it.value()->setEnabled( !toggled );
175void QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged(
int )
179 mSaveOptionsWidget->setPyramidsFormat( format );
182void QgsRasterPyramidsOptionsWidget::setOverviewList()
184 mOverviewList.clear();
187 if ( cbxPyramidsLevelsCustom->isChecked() )
190 const QStringList constSplit = lePyramidsLevels->text().trimmed().split(
' ', Qt::SkipEmptyParts );
191 for (
const QString &lev : constSplit )
194 const int tmpInt = lev.toInt();
199 mOverviewList << tmpInt;
205 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
207 if ( it.value()->isChecked() )
208 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)