25#include <QInputDialog>
29#include <QRegularExpression>
30#include <QRegularExpressionValidator>
34#include "moc_qgsrasterpyramidsoptionswidget.cpp"
36using namespace Qt::StringLiterals;
40 , mProvider( provider )
48 connect( cbxPyramidsLevelsCustom, &QCheckBox::toggled,
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled );
49 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged );
51 mSaveOptionsWidget->setProvider( provider );
57void QgsRasterPyramidsOptionsWidget::updateUi()
60 const QString prefix = mProvider +
"/driverOptions/_pyramids/";
64 tmpStr = mySettings.
value( prefix +
"format",
"external" ).toString();
65 if ( tmpStr ==
"internal"_L1 )
67 else if ( tmpStr ==
"external_erdas"_L1 )
73 cboResamplingMethod->clear();
75 for (
const QPair<QString, QString> &method : methods )
77 cboResamplingMethod->addItem( method.second, method.first );
79 const QString defaultMethod = mySettings.
value( prefix +
"resampling",
"AVERAGE" ).toString();
80 const int idx = cboResamplingMethod->findData( defaultMethod );
81 cboResamplingMethod->setCurrentIndex( idx );
84 lePyramidsLevels->setEnabled( cbxPyramidsLevelsCustom->isChecked() );
85 lePyramidsLevels->setValidator(
new QRegularExpressionValidator( QRegularExpression(
"(\\d*)(\\s\\d*)*" ), lePyramidsLevels ) );
86 connect( lePyramidsLevels, &QLineEdit::textEdited,
this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
89 if ( mOverviewCheckBoxes.isEmpty() )
93 mOverviewCheckBoxes.clear();
95 for (
const int i : constOverviewList )
97 mOverviewCheckBoxes[i] =
new QCheckBox( QString::number( i ),
this );
98 connect( mOverviewCheckBoxes[i], &QCheckBox::toggled,
this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
99 layoutPyramidsLevels->addWidget( mOverviewCheckBoxes[i] );
104 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
105 it.value()->setChecked(
false );
107 tmpStr = mySettings.
value( prefix +
"overviewList",
"" ).toString();
108 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();
125 return cboResamplingMethod->currentData().toString();
131 const QString prefix = mProvider +
"/driverOptions/_pyramids/";
140 tmpStr = u
"external"_s;
143 tmpStr = u
"internal"_s;
146 tmpStr = u
"external_erdas"_s;
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 const bool visible = ( driverName !=
"COG"_L1 );
168 labelOverviewFormat->setVisible( visible );
169 cbxPyramidsFormat->setVisible( visible );
170 labelLevels->setVisible( visible );
171 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
172 it.value()->setVisible( visible );
173 cbxPyramidsLevelsCustom->setVisible( visible );
174 lePyramidsLevels->setVisible( visible );
179 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
180 it.value()->setChecked( checked );
183void QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled(
bool toggled )
186 lePyramidsLevels->setEnabled( toggled );
187 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
188 it.value()->setEnabled( !toggled );
192void QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged(
int )
196 mSaveOptionsWidget->setPyramidsFormat( format );
199void QgsRasterPyramidsOptionsWidget::setOverviewList()
201 mOverviewList.clear();
204 if ( cbxPyramidsLevelsCustom->isChecked() )
207 const QStringList constSplit = lePyramidsLevels->text().trimmed().split(
' ', Qt::SkipEmptyParts );
208 for (
const QString &lev : constSplit )
211 const int tmpInt = lev.toInt();
216 mOverviewList << tmpInt;
222 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
224 if ( it.value()->isChecked() )
225 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)