|
29 | 29 | QgsTransformSettingsDialog::QgsTransformSettingsDialog( const QString &raster, const QString &output,
|
30 | 30 | int countGCPpoints, QWidget *parent )
|
31 | 31 | : QDialog( parent )
|
32 |
| - , mModifiedRaster( raster ) |
| 32 | + , mSourceRasterFile( raster ) |
33 | 33 | , mCountGCPpoints( countGCPpoints )
|
34 | 34 | {
|
35 | 35 | setupUi( this );
|
@@ -159,12 +159,19 @@ void QgsTransformSettingsDialog::accept()
|
159 | 159 | {
|
160 | 160 | //if the file path is relative, make it relative to the raster file directory
|
161 | 161 | QString outputRasterName = leOutputRaster->text();
|
162 |
| - QFileInfo rasterFileInfo( mModifiedRaster ); |
| 162 | + QFileInfo rasterFileInfo( mSourceRasterFile ); |
163 | 163 | QFileInfo outputFileInfo( rasterFileInfo.absoluteDir(), outputRasterName );
|
164 | 164 |
|
165 | 165 | if ( outputFileInfo.fileName().isEmpty() || !outputFileInfo.dir().exists() )
|
166 | 166 | {
|
167 |
| - QMessageBox::warning( this, tr( "Info" ), tr( "Invalid output file name" ) ); |
| 167 | + QMessageBox::warning( this, tr( "Destination Raster" ), tr( "Invalid output file name." ) ); |
| 168 | + leOutputRaster->setFocus(); |
| 169 | + return; |
| 170 | + } |
| 171 | + if ( outputFileInfo.filePath() == mSourceRasterFile ) |
| 172 | + { |
| 173 | + //can't overwrite input file |
| 174 | + QMessageBox::warning( this, tr( "Destination Raster" ), tr( "Input raster can not be overwritten." ) ); |
168 | 175 | leOutputRaster->setFocus();
|
169 | 176 | return;
|
170 | 177 | }
|
@@ -193,10 +200,14 @@ void QgsTransformSettingsDialog::accept()
|
193 | 200 |
|
194 | 201 | void QgsTransformSettingsDialog::on_tbnOutputRaster_clicked()
|
195 | 202 | {
|
196 |
| - QString selectedFile = generateModifiedRasterFileName( mModifiedRaster ); |
197 |
| - QString rasterFileName = QFileDialog::getSaveFileName( this, tr( "Save raster" ), |
198 |
| - selectedFile, "GeoTIFF (*.tif *.tiff *.TIF *.TIFF)" ); |
| 203 | + QString selectedFile = leOutputRaster->text(); |
| 204 | + if ( selectedFile.isEmpty() ) |
| 205 | + { |
| 206 | + selectedFile = generateModifiedRasterFileName( mSourceRasterFile ); |
| 207 | + } |
199 | 208 |
|
| 209 | + QString rasterFileName = QFileDialog::getSaveFileName( this, tr( "Destination Raster" ), |
| 210 | + selectedFile, "GeoTIFF (*.tif *.tiff *.TIF *.TIFF)" ); |
200 | 211 | if ( rasterFileName.isEmpty() )
|
201 | 212 | return;
|
202 | 213 |
|
|
0 commit comments