Skip to content
Permalink
Browse files

Initialize raster save as dialog

  • Loading branch information
mhugent committed Jul 11, 2012
1 parent 67cd3f5 commit b5be6668792929895d2323c1cb4d8fd4e9d7c51b
@@ -3770,7 +3770,7 @@ void QgisApp::saveAsRasterFile()
return;
}

QgsRasterLayerSaveAsDialog d;
QgsRasterLayerSaveAsDialog d( rasterLayer->dataProvider() );
d.exec();
}

@@ -1,10 +1,80 @@
#include "qgsrasterlayersaveasdialog.h"
#include "qgsrasterdataprovider.h"

QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterDataProvider* sourceProvider,
QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f ),
mDataProvider( sourceProvider )

QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f )
{
setupUi( this );
setValidators();

//fill reasonable default values depending on the provider
if ( mDataProvider )
{
if ( mDataProvider->capabilities() & QgsRasterDataProvider::ExactResolution )
{
int xSize = mDataProvider->xSize();
int ySize = mDataProvider->ySize();
mColumnsLineEdit->setText( QString::number( xSize ) );
mRowsLineEdit->setText( QString::number( ySize ) );
mMaximumSizeXLineEdit->setText( QString::number( xSize ) );
mMaximumSizeYLineEdit->setText( QString::number( ySize ) );
}
else //wms
{
mTileModeCheckBox->setChecked( true );
mColumnsLineEdit->setText( QString::number( 10000 ) );
mRowsLineEdit->setText( QString::number( 10000 ) );
mMaximumSizeXLineEdit->setText( QString::number( 2000 ) );
mMaximumSizeYLineEdit->setText( QString::number( 2000 ) );
}
}
}

void QgsRasterLayerSaveAsDialog::setValidators()
{
mColumnsLineEdit->setValidator( new QIntValidator( this ) );
mRowsLineEdit->setValidator( new QIntValidator( this ) );
mMaximumSizeXLineEdit->setValidator( new QIntValidator( this ) );
mMaximumSizeYLineEdit->setValidator( new QIntValidator( this ) );
}

QgsRasterLayerSaveAsDialog::~QgsRasterLayerSaveAsDialog()
{
}

int QgsRasterLayerSaveAsDialog::nColumns() const
{
return mColumnsLineEdit->text().toInt();
}

int QgsRasterLayerSaveAsDialog::nRows() const
{
return mRowsLineEdit->text().toInt();
}

int QgsRasterLayerSaveAsDialog::maximumTileSizeX() const
{
return mMaximumSizeXLineEdit->text().toInt();
}

int QgsRasterLayerSaveAsDialog::maximumTileSizeY() const
{
return mMaximumSizeYLineEdit->text().toInt();
}

bool QgsRasterLayerSaveAsDialog::tileMode() const
{
return mTileModeCheckBox->isChecked();
}

QString QgsRasterLayerSaveAsDialog::outputFileName() const
{
return mSaveAsLineEdit->text();
}

QString QgsRasterLayerSaveAsDialog::outputFormat() const
{
return ""; //soon...
}
@@ -3,11 +3,26 @@

#include "ui_qgsrasterlayersaveasdialogbase.h"

class QgsRasterDataProvider;

class QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRasterLayerSaveAsDialogBase
{
public:
QgsRasterLayerSaveAsDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 );
QgsRasterLayerSaveAsDialog( QgsRasterDataProvider* sourceProvider, QWidget* parent = 0, Qt::WindowFlags f = 0 );
~QgsRasterLayerSaveAsDialog();

int nColumns() const;
int nRows() const;
int maximumTileSizeX() const;
int maximumTileSizeY() const;
bool tileMode() const;
QString outputFileName() const;
QString outputFormat() const;

private:
QgsRasterDataProvider* mDataProvider;

void setValidators();
};

#endif // QGSRASTERLAYERSAVEASDIALOG_H
@@ -50,7 +50,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Browse</string>
<string>Browse...</string>
</property>
</widget>
</item>
@@ -85,7 +85,7 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="mMaximumSizeXComboBox"/>
<widget class="QLineEdit" name="mMaximumSizeXLineEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mMaximumSizeXLabel">

0 comments on commit b5be666

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