Skip to content

Commit b8323a9

Browse files
committedAug 3, 2018
Hide extra options from Make Permanent dialog
We don't want to e.g. allow users to change the CRS or drop fields in this dialog.
1 parent f8afc50 commit b8323a9

File tree

5 files changed

+46
-12
lines changed

5 files changed

+46
-12
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7240,7 +7240,7 @@ void QgisApp::makeMemoryLayerPermanent( QgsVectorLayer *layer )
72407240
}
72417241
};
72427242

7243-
saveAsVectorFileGeneral( layer, true, false, onSuccess, onFailure );
7243+
saveAsVectorFileGeneral( layer, true, false, onSuccess, onFailure, 0, tr( "Save Scratch Layer" ) );
72447244
}
72457245

72467246
void QgisApp::saveAsLayerDefinition()
@@ -7383,17 +7383,18 @@ void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOpt
73837383
saveAsVectorFileGeneral( vlayer, symbologyOption, onlySelected, onSuccess, onFailure );
73847384
}
73857385

7386-
void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOption, bool onlySelected, const std::function<void( const QString &, bool, const QString &, const QString &, const QString & )> &onSuccess, const std::function<void ( int, const QString & )> &onFailure )
7386+
void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOption, bool onlySelected, const std::function<void( const QString &, bool, const QString &, const QString &, const QString & )> &onSuccess, const std::function<void ( int, const QString & )> &onFailure, int options, const QString &dialogTitle )
73877387
{
73887388
QgsCoordinateReferenceSystem destCRS;
73897389

7390-
int options = QgsVectorLayerSaveAsDialog::AllOptions;
73917390
if ( !symbologyOption )
73927391
{
73937392
options &= ~QgsVectorLayerSaveAsDialog::Symbology;
73947393
}
73957394

73967395
QgsVectorLayerSaveAsDialog *dialog = new QgsVectorLayerSaveAsDialog( vlayer, options, this );
7396+
if ( !dialogTitle.isEmpty() )
7397+
dialog->setWindowTitle( dialogTitle );
73977398

73987399
dialog->setMapCanvas( mMapCanvas );
73997400
dialog->setIncludeZ( QgsWkbTypes::hasZ( vlayer->wkbType() ) );

‎src/app/qgisapp.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class QgsLayoutQptDropHandler;
156156
#include "qgsoptionswidgetfactory.h"
157157
#include "qgsattributetablefiltermodel.h"
158158
#include "qgsmasterlayoutinterface.h"
159+
#include "ogr/qgsvectorlayersaveasdialog.h"
159160
#include "ui_qgisapp.h"
160161
#include "qgis_app.h"
161162

@@ -1841,7 +1842,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
18411842
bool addToCanvas,
18421843
const QString &layerName,
18431844
const QString &encoding,
1844-
const QString &vectorFileName )> &onSuccess, const std::function< void ( int error, const QString &errorMessage ) > &onFailure );
1845+
const QString &vectorFileName )> &onSuccess, const std::function< void ( int error, const QString &errorMessage ) > &onFailure,
1846+
int dialogOptions = QgsVectorLayerSaveAsDialog::AllOptions,
1847+
const QString &dialogTitle = QString() );
18451848

18461849
//! Sets project properties, including map untis
18471850
void projectProperties( const QString &currentPage = QString() );

‎src/gui/ogr/qgsvectorlayersaveasdialog.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QgsVectorLayer *layer, i
5050
, mAttributeTableItemChangedSlotEnabled( true )
5151
, mReplaceRawFieldValuesStateChangedSlotEnabled( true )
5252
, mActionOnExistingFile( QgsVectorFileWriter::CreateOrOverwriteFile )
53+
, mOptions( static_cast< Options >( options ) )
5354
{
5455
if ( layer )
5556
{
@@ -58,14 +59,34 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QgsVectorLayer *layer, i
5859
}
5960
setup();
6061

61-
if ( !( options & Symbology ) )
62+
if ( !( mOptions & Symbology ) )
6263
{
6364
mSymbologyExportLabel->hide();
6465
mSymbologyExportComboBox->hide();
6566
mScaleLabel->hide();
6667
mScaleWidget->hide();
6768
}
6869

70+
if ( !( mOptions & DestinationCrs ) )
71+
{
72+
mCrsLabel->hide();
73+
mCrsSelector->hide();
74+
}
75+
if ( !( mOptions & Fields ) )
76+
mAttributesSelection->hide();
77+
78+
if ( !( mOptions & SelectedOnly ) )
79+
mSelectedOnly->hide();
80+
81+
if ( !( mOptions & AddToCanvas ) )
82+
mAddToCanvas->hide();
83+
84+
if ( !( mOptions & GeometryType ) )
85+
mGeometryGroupBox->hide();
86+
87+
if ( !( mOptions & Extent ) )
88+
mExtentGroupBox->hide();
89+
6990
mSelectedOnly->setEnabled( layer && layer->selectedFeatureCount() != 0 );
7091
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( true );
7192
}
@@ -376,12 +397,13 @@ void QgsVectorLayerSaveAsDialog::mFormatComboBox_currentIndexChanged( int idx )
376397
}
377398
else
378399
{
379-
mAttributesSelection->setVisible( true );
400+
if ( mOptions & Fields )
401+
mAttributesSelection->setVisible( true );
380402
fieldsAsDisplayedValues = ( sFormat == QLatin1String( "CSV" ) || sFormat == QLatin1String( "XLS" ) || sFormat == QLatin1String( "XLSX" ) || sFormat == QLatin1String( "ODS" ) );
381403
}
382404

383405
// Show symbology options only for some formats
384-
if ( QgsVectorFileWriter::supportsFeatureStyles( sFormat ) )
406+
if ( QgsVectorFileWriter::supportsFeatureStyles( sFormat ) && ( mOptions & Symbology ) )
385407
{
386408
mSymbologyExportLabel->setVisible( true );
387409
mSymbologyExportComboBox->setVisible( true );
@@ -878,7 +900,7 @@ QgsWkbTypes::Type QgsVectorLayerSaveAsDialog::geometryType() const
878900
return QgsWkbTypes::Unknown;
879901
}
880902

881-
return ( QgsWkbTypes::Type )currentIndexData;
903+
return static_cast< QgsWkbTypes::Type >( currentIndexData );
882904
}
883905

884906
bool QgsVectorLayerSaveAsDialog::automaticGeometryType() const

‎src/gui/ogr/qgsvectorlayersaveasdialog.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,18 @@ class GUI_EXPORT QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVec
3838
Q_OBJECT
3939

4040
public:
41-
// bitmask of options to be shown
41+
42+
//! Bitmask of options to be shown
4243
enum Options
4344
{
44-
Symbology = 1,
45-
AllOptions = ~0
45+
Symbology = 1, //!< Show symbology options
46+
DestinationCrs = 1 << 2, //!< Show destination CRS (reprojection) option
47+
Fields = 1 << 3, //!< Show field customisation group
48+
AddToCanvas = 1 << 4, //!< Show add to map option
49+
SelectedOnly = 1 << 5, //!< Show selected features only option
50+
GeometryType = 1 << 6, //!< Show geometry group
51+
Extent = 1 << 7, //!< Show extent group
52+
AllOptions = ~0 //!< Show all options
4653
};
4754

4855
QgsVectorLayerSaveAsDialog( long srsid, QWidget *parent = nullptr, Qt::WindowFlags fl = nullptr );
@@ -156,6 +163,7 @@ class GUI_EXPORT QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVec
156163
bool mAttributeTableItemChangedSlotEnabled;
157164
bool mReplaceRawFieldValuesStateChangedSlotEnabled;
158165
QgsVectorFileWriter::ActionOnExistingFile mActionOnExistingFile;
166+
Options mOptions = AllOptions;
159167
};
160168

161169
#endif // QGSVECTORLAYERSAVEASDIALOG_H

‎src/ui/qgsvectorlayersaveasdialogbase.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<widget class="QWidget" name="widget" native="true">
2525
<layout class="QGridLayout" name="gridLayout_4">
2626
<item row="3" column="0">
27-
<widget class="QLabel" name="label_3">
27+
<widget class="QLabel" name="mCrsLabel">
2828
<property name="text">
2929
<string>CRS</string>
3030
</property>

0 commit comments

Comments
 (0)
Please sign in to comment.