24 #include <QInputDialog>
25 #include <QMessageBox>
27 #include <QMouseEvent>
33 , mProvider( provider )
36 connect( cbxPyramidsLevelsCustom, &QCheckBox::toggled,
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled );
37 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged );
39 mSaveOptionsWidget->setProvider( provider );
46 void QgsRasterPyramidsOptionsWidget::updateUi()
49 QString prefix = mProvider +
"/driverOptions/_pyramids/";
53 tmpStr = mySettings.
value( prefix +
"format",
"external" ).toString();
54 if ( tmpStr == QLatin1String(
"internal" ) )
55 cbxPyramidsFormat->setCurrentIndex( INTERNAL );
56 else if ( tmpStr == QLatin1String(
"external_erdas" ) )
57 cbxPyramidsFormat->setCurrentIndex( ERDAS );
59 cbxPyramidsFormat->setCurrentIndex( GTIFF );
62 cboResamplingMethod->clear();
64 for (
const QPair<QString, QString> &method : methods )
66 cboResamplingMethod->addItem( method.second, method.first );
68 QString defaultMethod = mySettings.
value( prefix +
"resampling",
"AVERAGE" ).toString();
69 int idx = cboResamplingMethod->findData( defaultMethod );
70 cboResamplingMethod->setCurrentIndex( idx );
73 lePyramidsLevels->setEnabled( cbxPyramidsLevelsCustom->isChecked() );
74 lePyramidsLevels->setValidator(
new QRegExpValidator( QRegExp(
"(\\d*)(\\s\\d*)*" ), lePyramidsLevels ) );
75 connect( lePyramidsLevels, &QLineEdit::textEdited,
76 this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
79 if ( mOverviewCheckBoxes.isEmpty() )
83 mOverviewCheckBoxes.clear();
85 for (
int i : constOverviewList )
87 mOverviewCheckBoxes[ i ] =
new QCheckBox( QString::number( i ),
this );
88 connect( mOverviewCheckBoxes[ i ], &QCheckBox::toggled,
89 this, &QgsRasterPyramidsOptionsWidget::setOverviewList );
90 layoutPyramidsLevels->addWidget( mOverviewCheckBoxes[ i ] );
95 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
96 it.value()->setChecked(
false );
98 tmpStr = mySettings.
value( prefix +
"overviewList",
"" ).toString();
99 const auto constSplit = tmpStr.split(
' ', QString::SkipEmptyParts );
100 for (
const QString &lev : constSplit )
102 if ( mOverviewCheckBoxes.contains( lev.toInt() ) )
103 mOverviewCheckBoxes[ lev.toInt()]->setChecked(
true );
107 mSaveOptionsWidget->updateProfiles();
109 connect( cbxPyramidsFormat,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
111 connect( cboResamplingMethod,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
119 return cboResamplingMethod->currentData().toString();
125 QString prefix = mProvider +
"/driverOptions/_pyramids/";
129 if ( cbxPyramidsFormat->currentIndex() == INTERNAL )
130 tmpStr = QStringLiteral(
"internal" );
131 else if ( cbxPyramidsFormat->currentIndex() == ERDAS )
132 tmpStr = QStringLiteral(
"external_erdas" );
134 tmpStr = QStringLiteral(
"external" );
135 mySettings.
setValue( prefix +
"format", tmpStr );
137 mySettings.
setValue( prefix +
"overviewStr", lePyramidsLevels->text().trimmed() );
141 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
143 if ( it.value()->isChecked() )
144 tmpStr += QString::number( it.key() ) +
' ';
146 mySettings.
setValue( prefix +
"overviewList", tmpStr.trimmed() );
148 mSaveOptionsWidget->apply();
153 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
154 it.value()->setChecked( checked );
157 void QgsRasterPyramidsOptionsWidget::cbxPyramidsLevelsCustom_toggled(
bool toggled )
160 lePyramidsLevels->setEnabled( toggled );
161 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
162 it.value()->setEnabled( ! toggled );
166 void QgsRasterPyramidsOptionsWidget::cbxPyramidsFormat_currentIndexChanged(
int index )
168 mSaveOptionsWidget->setEnabled( index != ERDAS );
182 QgsDebugMsg( QStringLiteral(
"Should not happen !" ) );
186 mSaveOptionsWidget->setPyramidsFormat( format );
189 void QgsRasterPyramidsOptionsWidget::setOverviewList()
192 mOverviewList.clear();
195 if ( cbxPyramidsLevelsCustom->isChecked() )
198 const auto constSplit = lePyramidsLevels->text().trimmed().split(
' ', QString::SkipEmptyParts );
199 for (
const QString &lev : constSplit )
202 int tmpInt = lev.toInt();
205 QgsDebugMsg(
"tmpInt= " + QString::number( tmpInt ) );
207 mOverviewList << tmpInt;
213 for (
auto it = mOverviewCheckBoxes.constBegin(); it != mOverviewCheckBoxes.constEnd(); ++it )
215 if ( it.value()->isChecked() )
216 mOverviewList << it.key();