23 #include <QInputDialog>
24 #include <QMessageBox>
26 #include <QMouseEvent>
32 : QWidget( parent ), mProvider( provider )
36 mSaveOptionsWidget->setProvider( provider );
48 void QgsRasterPyramidsOptionsWidget::updateUi()
51 QString prefix = mProvider +
"/driverOptions/_pyramids/";
55 tmpStr = mySettings.value( prefix +
"format",
"gtiff" ).toString();
56 if ( tmpStr ==
"internal" )
57 cbxPyramidsFormat->setCurrentIndex( 1 );
58 else if ( tmpStr ==
"external_erdas" )
59 cbxPyramidsFormat->setCurrentIndex( 2 );
61 cbxPyramidsFormat->setCurrentIndex( 0 );
64 cboResamplingMethod->clear();
65 QPair<QString, QString> method;
68 cboResamplingMethod->addItem( method.second, method.first );
70 cboResamplingMethod->setCurrentIndex( cboResamplingMethod->findData(
71 mySettings.value( prefix +
"resampling",
"AVERAGE" ).toString() ) );
74 lePyramidsLevels->setEnabled( cbxPyramidsLevelsCustom->isChecked() );
75 lePyramidsLevels->setValidator(
new QRegExpValidator( QRegExp(
"(\\d*)(\\s\\d*)*" ), lePyramidsLevels ) );
76 connect( lePyramidsLevels, SIGNAL( textEdited(
const QString & ) ),
77 this, SLOT( setOverviewList() ) );
80 if ( mOverviewCheckBoxes.isEmpty() )
83 overviewList << 2 << 4 << 8 << 16 << 32 << 64;
84 mOverviewCheckBoxes.clear();
85 foreach (
int i, overviewList )
87 mOverviewCheckBoxes[ i ] =
new QCheckBox( QString::number( i ),
this );
88 connect( mOverviewCheckBoxes[ i ], SIGNAL( toggled(
bool ) ),
89 this, SLOT( setOverviewList() ) );
90 layoutPyramidsLevels->addWidget( mOverviewCheckBoxes[ i ] );
95 foreach (
int i, mOverviewCheckBoxes.keys() )
96 mOverviewCheckBoxes[ i ]->setChecked(
false );
98 tmpStr = mySettings.value( prefix +
"overviewList",
"" ).toString();
99 foreach ( QString lev, tmpStr.split(
" ", QString::SkipEmptyParts ) )
101 if ( mOverviewCheckBoxes.contains( lev.toInt() ) )
102 mOverviewCheckBoxes[ lev.toInt()]->setChecked(
true );
106 mSaveOptionsWidget->updateProfiles();
108 connect( cbxPyramidsFormat, SIGNAL( currentIndexChanged(
int ) ),
110 connect( cboResamplingMethod, SIGNAL( currentIndexChanged(
int ) ),
112 connect( mSaveOptionsWidget, SIGNAL( optionsChanged() ),
118 return cboResamplingMethod->itemData( cboResamplingMethod->currentIndex() ).toString();
123 QSettings mySettings;
124 QString prefix = mProvider +
"/driverOptions/_pyramids/";
128 if ( cbxPyramidsFormat->currentIndex() == 1 )
130 else if ( cbxPyramidsFormat->currentIndex() == 2 )
131 tmpStr =
"external_erdas";
134 mySettings.setValue( prefix +
"format", tmpStr );
136 mySettings.setValue( prefix +
"overviewStr", lePyramidsLevels->text().trimmed() );
140 foreach (
int i, mOverviewCheckBoxes.keys() )
142 if ( mOverviewCheckBoxes[ i ]->isChecked() )
143 tmpStr += QString::number( i ) +
" ";
145 mySettings.setValue( prefix +
"overviewList", tmpStr.trimmed() );
147 mSaveOptionsWidget->apply();
152 foreach (
int i, mOverviewCheckBoxes.keys() )
153 mOverviewCheckBoxes[ i ]->setChecked( checked );
156 void QgsRasterPyramidsOptionsWidget::on_cbxPyramidsLevelsCustom_toggled(
bool toggled )
159 lePyramidsLevels->setEnabled( toggled );
160 foreach (
int i, mOverviewCheckBoxes.keys() )
161 mOverviewCheckBoxes[ i ]->setEnabled( ! toggled );
165 void QgsRasterPyramidsOptionsWidget::on_cbxPyramidsFormat_currentIndexChanged(
int index )
167 mSaveOptionsWidget->setEnabled( index != 2 );
171 void QgsRasterPyramidsOptionsWidget::setOverviewList()
175 mOverviewList.clear();
178 if ( cbxPyramidsLevelsCustom->isChecked() )
181 foreach ( QString lev, lePyramidsLevels->text().trimmed().split(
" ", QString::SkipEmptyParts ) )
184 int tmpInt = lev.toInt();
187 QgsDebugMsg(
"tmpInt= " + QString::number( tmpInt ) );
189 mOverviewList << tmpInt;
195 foreach (
int i, mOverviewCheckBoxes.keys() )
197 if ( mOverviewCheckBoxes[ i ]->isChecked() )