Skip to content
Permalink
Browse files

adapt raster save as dialog to changes in collapsible group box

  • Loading branch information
etiennesky committed Sep 10, 2012
1 parent 0179e38 commit 1080d978c40ffd221801afe8f763f67640465d30
@@ -84,15 +84,11 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLa
{
mPyramidsOptionsWidget->createOptionsWidget()->setType( QgsRasterFormatSaveOptionsWidget::ProfileLineEdit );

// init. pyramids button group
for ( int i = -2, j = 0 ; i >= -4 ; i--, j++ )
mPyramidsButtonGroup->setId( mPyramidsButtonGroup->button( i ), j );
// TODO enable "use existing", has no effect for now, because using Create() in gdal provider
// if ( ! mDataProvider->hasPyramids() )
// mPyramidsButtonGroup->button( QgsRasterDataProvider::CopyExisting )->setEnabled( false );
mPyramidsButtonGroup->button( QgsRasterDataProvider::CopyExisting )->setEnabled( false );
mPyramidsButtonGroup->button( QgsRasterDataProvider::PyramidsFlagNo )->click();
mPyramidsButtonGroup->button( QgsRasterDataProvider::PyramidsFlagNo )->setChecked( true );
mPyramidsUseExistingCheckBox->setEnabled( false );
mPyramidsUseExistingCheckBox->setVisible( false );

populatePyramidsLevels();
connect( mPyramidsOptionsWidget, SIGNAL( overviewListChanged() ),
@@ -111,12 +107,10 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLa
okButton->setEnabled( false );
}


// this should scroll down to make widget visible, but it's not happening
// (at least part of it is visible)...
connect( mCreateOptionsGroupBox, SIGNAL( expanded( QWidget* ) ),
connect( mCreateOptionsGroupBox, SIGNAL( collapsedStateChanged( QWidget* ) ),
this, SLOT( groupBoxExpanded( QWidget* ) ) );

}

void QgsRasterLayerSaveAsDialog::setValidators()
@@ -236,7 +230,7 @@ QString QgsRasterLayerSaveAsDialog::outputFormat() const

QStringList QgsRasterLayerSaveAsDialog::createOptions() const
{
return mCreateOptionsWidget ? mCreateOptionsWidget->options() : QStringList();
return mCreateOptionsGroupBox->isChecked() ? mCreateOptionsWidget->options() : QStringList();
}

QgsRectangle QgsRasterLayerSaveAsDialog::outputRectangle() const
@@ -535,6 +529,12 @@ void QgsRasterLayerSaveAsDialog::on_mRawModeRadioButton_toggled( bool checked )
mNoDataGroupBox->setEnabled( checked && mDataProvider->bandCount() == 1 );
}

void QgsRasterLayerSaveAsDialog::groupBoxExpanded( QWidget * widget )
{
if ( !mCreateOptionsGroupBox->isCollapsed() )
mScrollArea->ensureWidgetVisible( widget );
}

void QgsRasterLayerSaveAsDialog::on_mAddNoDataManuallyToolButton_clicked()
{
addNoDataRow( std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN() );
@@ -658,31 +658,15 @@ void QgsRasterLayerSaveAsDialog::on_mTileModeCheckBox_toggled( bool toggled )
// enable pyramids
if ( ! mPyramidsGroupBox->isChecked() )
mPyramidsGroupBox->setChecked( true );
if ( mPyramidsButtonGroup->checkedId() == QgsRasterDataProvider::PyramidsFlagNo )
{
mPyramidsButtonGroup->button( QgsRasterDataProvider::PyramidsFlagYes )->click();
mPyramidsButtonGroup->button( QgsRasterDataProvider::PyramidsFlagYes )->setChecked( true );
}
if ( mPyramidsGroupBox->isCollapsed() )
mPyramidsGroupBox->setCollapsed( false );
mPyramidsOptionsWidget->checkAllLevels( true );
}
}

void QgsRasterLayerSaveAsDialog::on_mPyramidsButtonGroup_buttonClicked( int id )
void QgsRasterLayerSaveAsDialog::on_mPyramidsGroupBox_toggled( bool toggled )
{
if ( id == QgsRasterDataProvider::PyramidsFlagNo || id == QgsRasterDataProvider::CopyExisting )
{
mPyramidsOptionsWidget->setEnabled( false );
mPyramidResolutionsLabel->setEnabled( false );
mPyramidResolutionsLineEdit->setEnabled( false );
}
else if ( id == QgsRasterDataProvider::PyramidsFlagYes )
{
mPyramidsOptionsWidget->setEnabled( true );
mPyramidResolutionsLabel->setEnabled( true );
mPyramidResolutionsLineEdit->setEnabled( true );
}
else
QgsDebugMsg( QString( "invalid button id %1" ).arg( id ) );
Q_UNUSED( toggled );
populatePyramidsLevels();
}

@@ -691,14 +675,14 @@ void QgsRasterLayerSaveAsDialog::populatePyramidsLevels()
// if selection != "Build pyramids", get pyramids from actual layer
QString text;

if ( mPyramidsButtonGroup->checkedId() != QgsRasterDataProvider::PyramidsFlagNo )
if ( mPyramidsGroupBox->isChecked() )
{
QList<QgsRasterPyramid> myPyramidList;
if ( mPyramidsButtonGroup->checkedId() == QgsRasterDataProvider::CopyExisting )
if ( mPyramidsUseExistingCheckBox->isChecked() )
{
myPyramidList = mDataProvider->buildPyramidList();
}
else if ( mPyramidsButtonGroup->checkedId() == QgsRasterDataProvider::PyramidsFlagYes )
else
{
if ( ! mPyramidsOptionsWidget->overviewList().isEmpty() )
myPyramidList = mDataProvider->buildPyramidList( mPyramidsOptionsWidget->overviewList() );
@@ -708,8 +692,7 @@ void QgsRasterLayerSaveAsDialog::populatePyramidsLevels()
myRasterPyramidIterator != myPyramidList.end();
++myRasterPyramidIterator )
{
if ( mPyramidsButtonGroup->checkedId() == QgsRasterDataProvider::PyramidsFlagYes
|| myRasterPyramidIterator->exists )
if ( myRasterPyramidIterator->exists )
{
text += QString::number( myRasterPyramidIterator->xDim ) + QString( "x" ) +
QString::number( myRasterPyramidIterator->yDim ) + " ";
@@ -753,6 +736,9 @@ void QgsRasterLayerSaveAsDialog::adjustNoDataCellWidth( int row, int column )
QList<QgsRasterNuller::NoData> QgsRasterLayerSaveAsDialog::noData() const
{
QList<QgsRasterNuller::NoData> noDataList;
if ( ! mNoDataGroupBox->isChecked() )
return noDataList;

for ( int r = 0 ; r < mNoDataTableWidget->rowCount(); r++ )
{
QgsRasterNuller::NoData noData;
@@ -762,3 +748,19 @@ QList<QgsRasterNuller::NoData> QgsRasterLayerSaveAsDialog::noData() const
}
return noDataList;
}

QList<int> QgsRasterLayerSaveAsDialog::overviewList() const
{
return mPyramidsGroupBox->isChecked() ? mPyramidsOptionsWidget->overviewList() : QList<int>();
}

QgsRasterDataProvider::RasterBuildPyramids QgsRasterLayerSaveAsDialog::buildPyramidsFlag() const
{
if ( ! mPyramidsGroupBox->isChecked() )
return QgsRasterDataProvider::PyramidsFlagNo;
else if ( mPyramidsUseExistingCheckBox->isChecked() )
return QgsRasterDataProvider::CopyExisting;
else
return QgsRasterDataProvider::PyramidsFlagYes;
}

@@ -58,14 +58,12 @@ class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRast
QgsRectangle outputRectangle() const;
QList<QgsRasterNuller::NoData> noData() const;

QList< int > overviewList() const { return mPyramidsOptionsWidget->overviewList(); }
QgsRasterDataProvider::RasterBuildPyramids buildPyramidsFlag() const
{ return ( QgsRasterDataProvider::RasterBuildPyramids ) mPyramidsButtonGroup->checkedId(); }
QList< int > overviewList() const;
QgsRasterDataProvider::RasterBuildPyramids buildPyramidsFlag() const;
QString pyramidsResampling() const { return mPyramidsOptionsWidget->resamplingMethod(); }
QgsRasterDataProvider::RasterPyramidsFormat pyramidsFormat() const
{ return mPyramidsOptionsWidget->pyramidsFormat(); }


void hideFormat();
void hideOutput();

@@ -94,14 +92,14 @@ class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRast

void on_mCrsComboBox_currentIndexChanged( int ) { crsChanged(); }

void groupBoxExpanded( QWidget * widget ) { mScrollArea->ensureWidgetVisible( widget ); }
void groupBoxExpanded( QWidget * widget );
void on_mAddNoDataManuallyToolButton_clicked();
void on_mLoadTransparentNoDataToolButton_clicked();
void on_mRemoveSelectedNoDataToolButton_clicked();
void on_mRemoveAllNoDataToolButton_clicked();
void noDataCellTextEdited( const QString & text );
void on_mTileModeCheckBox_toggled( bool toggled );
void on_mPyramidsButtonGroup_buttonClicked( int id );
void on_mPyramidsGroupBox_toggled( bool toggled );
void populatePyramidsLevels();

private:
@@ -30,8 +30,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>536</width>
<height>947</height>
<width>550</width>
<height>738</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
@@ -476,9 +476,6 @@
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="mMaximumSizeXLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Maximum number of columns in one tile.</string>
</property>
@@ -489,19 +486,13 @@
</item>
<item>
<widget class="QLineEdit" name="mMaximumSizeXLineEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Maximum number of columns in one tile.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mMaximumSizeYLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Maximum number of rows in one tile.</string>
</property>
@@ -512,19 +503,13 @@
</item>
<item>
<widget class="QLineEdit" name="mMaximumSizeYLineEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Maximum number of rows in one tile.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mTileModeCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Create VRT</string>
</property>
@@ -535,9 +520,6 @@
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mNoDataGroupBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -659,45 +641,8 @@
<layout class="QGridLayout" name="gridLayout_3">
<item row="3" column="0">
<widget class="QgsRasterPyramidsOptionsWidget" name="mPyramidsOptionsWidget" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>No pyramids</string>
</property>
<attribute name="buttonGroup">
<string notr="true">mPyramidsButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>Build pyramids</string>
</property>
<attribute name="buttonGroup">
<string notr="true">mPyramidsButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_3">
<property name="text">
<string>Use existing</string>
</property>
<attribute name="buttonGroup">
<string notr="true">mPyramidsButtonGroup</string>
</attribute>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="Line" name="line">
<property name="orientation">
@@ -751,6 +696,13 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="mPyramidsUseExistingCheckBox">
<property name="text">
<string>Use existing</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -841,7 +793,4 @@
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="mPyramidsButtonGroup"/>
</buttongroups>
</ui>

0 comments on commit 1080d97

Please sign in to comment.
You can’t perform that action at this time.