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();
68 cboResamplingMethod->addItem( method.second, method.first );
70 cboResamplingMethod->setCurrentIndex( cboResamplingMethod->findData(
71 mySettings.
value( prefix +
"resampling",
"AVERAGE" ).
toString() ) );
74 lePyramidsLevels->setEnabled( cbxPyramidsLevelsCustom->isChecked() );
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 )
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 ) )
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();
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() )
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();
189 mOverviewList << tmpInt;
195 foreach (
int i, mOverviewCheckBoxes.
keys() )
197 if ( mOverviewCheckBoxes[ i ]->isChecked() )
bool contains(const Key &key) const
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QList< Key > keys() const
void setValue(const QString &key, const QVariant &value)
QString number(int n, int base)
int toInt(bool *ok, int base) const
QVariant value(const QString &key, const QVariant &defaultValue) const
static QList< QPair< QString, QString > > pyramidResamplingMethods(QString providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)