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,
82 this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
85 if ( mOverviewCheckBoxes.isEmpty() )
89 mOverviewCheckBoxes.clear();
91 for (
const int i : constOverviewList )
93 mOverviewCheckBoxes[ i ] =
new QCheckBox( QString::number( i ),
this );
94 connect( mOverviewCheckBoxes[ i ], &QCheckBox::toggled,
95 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();
115 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
117 connect( cboResamplingMethod,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
125 return cboResamplingMethod->currentData().toString();
131 const QString prefix = mProvider +
"/driverOptions/_pyramids/";
140 tmpStr = QStringLiteral(
"external" );
143 tmpStr = QStringLiteral(
"internal" );
146 tmpStr = QStringLiteral(
"external_erdas" );
149 mySettings.
setValue( prefix +
"format", tmpStr );
151 mySettings.
setValue( prefix +
"overviewStr", lePyramidsLevels->text().trimmed() );
155 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
157 if ( it.value()->isChecked() )
158 tmpStr += QString::number( it.key() ) +
' ';
160 mySettings.
setValue( prefix +
"overviewList", tmpStr.trimmed() );
162 mSaveOptionsWidget->apply();
167 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
168 it.value()->setChecked( checked );
171void QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled(
bool toggled )
174 lePyramidsLevels->setEnabled( toggled );
175 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
176 it.value()->setEnabled( ! toggled );
180void QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged(
int )
184 mSaveOptionsWidget->setPyramidsFormat( format );
187void QgsRasterPyramidsOptionsWidget::setOverviewList()
190 mOverviewList.clear();
193 if ( cbxPyramidsLevelsCustom->isChecked() )
196 const QStringList constSplit = lePyramidsLevels->text().trimmed().split(
' ', Qt::SkipEmptyParts );
197 for (
const QString &lev : constSplit )
200 const int tmpInt = lev.toInt();
205 mOverviewList << tmpInt;
211 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
213 if ( it.value()->isChecked() )
214 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)