Skip to content
Permalink
Browse files

Wire in QgsRasterLayerSaveAsDialog in QgisApp

  • Loading branch information
mhugent committed Jul 11, 2012
1 parent b5be666 commit 1e6c400548f9b24e5a256af9202d8aaa60a4f825
@@ -158,6 +158,7 @@
#include "qgspythonrunner.h"
#include "qgsquerybuilder.h"
#include "qgsrastercalcdialog.h"
#include "qgsrasterfilewriter.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"
#include "qgsrasterrenderer.h"
@@ -3771,7 +3772,17 @@ void QgisApp::saveAsRasterFile()
}

QgsRasterLayerSaveAsDialog d( rasterLayer->dataProvider() );
d.exec();
if ( d.exec() == QDialog::Accepted )
{
QgsRasterFileWriter fileWriter( d.outputFileName() );
if ( d.tileMode() )
{
fileWriter.setTiledMode( true );
fileWriter.setMaxTileWidth( d.maximumTileSizeX() );
fileWriter.setMaxTileHeight( d.maximumTileSizeY() );
}
fileWriter.writeRaster( rasterLayer->dataProvider(), d.nColumns() );
}
}

void QgisApp::saveAsFile()
@@ -153,6 +153,7 @@ qgscredentialdialog.h
qgsowssourceselect.h
qgsprojectionselector.h
qgsquickprint.h
qgsrasterlayersaveasdialog.h
qgsludialog.h
qgsprojectbadlayerguihandler.h
qgslonglongvalidator.h
@@ -1,5 +1,6 @@
#include "qgsrasterlayersaveasdialog.h"
#include "qgsrasterdataprovider.h"
#include <QFileDialog>

QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterDataProvider* sourceProvider,
QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f ),
@@ -30,6 +31,12 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterDataProvider* s
mMaximumSizeYLineEdit->setText( QString::number( 2000 ) );
}
}

QPushButton* okButton = mButtonBox->button( QDialogButtonBox::Ok );
if ( okButton )
{
okButton->setEnabled( false );
}
}

void QgsRasterLayerSaveAsDialog::setValidators()
@@ -44,6 +51,35 @@ QgsRasterLayerSaveAsDialog::~QgsRasterLayerSaveAsDialog()
{
}

void QgsRasterLayerSaveAsDialog::on_mBrowseButton_clicked()
{
QString fileName;
if ( mTileModeCheckBox->isChecked() )
{
fileName = QFileDialog::getExistingDirectory( this, tr( "Select output directory" ) );
}
else
{
fileName = QFileDialog::getOpenFileName( this, tr( "Select output file" ) );
}

if ( !fileName.isEmpty() )
{
mSaveAsLineEdit->setText( fileName );
}
}

void QgsRasterLayerSaveAsDialog::on_mSaveAsLineEdit_textChanged( const QString& text )
{
QPushButton* okButton = mButtonBox->button( QDialogButtonBox::Ok );
if ( !okButton )
{
return;
}

okButton->setEnabled( QFile::exists( text ) );
}

int QgsRasterLayerSaveAsDialog::nColumns() const
{
return mColumnsLineEdit->text().toInt();
@@ -7,6 +7,7 @@ class QgsRasterDataProvider;

class QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRasterLayerSaveAsDialogBase
{
Q_OBJECT
public:
QgsRasterLayerSaveAsDialog( QgsRasterDataProvider* sourceProvider, QWidget* parent = 0, Qt::WindowFlags f = 0 );
~QgsRasterLayerSaveAsDialog();
@@ -19,6 +20,10 @@ class QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRasterLayerSave
QString outputFileName() const;
QString outputFormat() const;

private slots:
void on_mBrowseButton_clicked();
void on_mSaveAsLineEdit_textChanged( const QString& text );

private:
QgsRasterDataProvider* mDataProvider;

@@ -40,14 +40,14 @@
<item row="1" column="1">
<widget class="QLineEdit" name="mSaveAsLineEdit">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="mBrowseButton">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Browse...</string>
@@ -115,7 +115,7 @@
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<widget class="QDialogButtonBox" name="mButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -129,7 +129,7 @@
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<sender>mButtonBox</sender>
<signal>accepted()</signal>
<receiver>QgsRasterLayerSaveAsDialogBase</receiver>
<slot>accept()</slot>
@@ -145,7 +145,7 @@
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<sender>mButtonBox</sender>
<signal>rejected()</signal>
<receiver>QgsRasterLayerSaveAsDialogBase</receiver>
<slot>reject()</slot>

0 comments on commit 1e6c400

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