Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve documentation, function names
  • Loading branch information
nyalldawson committed May 15, 2023
1 parent 83d1e6c commit 5efa6c0
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 30 deletions.
41 changes: 32 additions & 9 deletions python/gui/auto_generated/ogr/qgsvectorlayersaveasdialog.sip.in
Expand Up @@ -46,41 +46,49 @@ Construct a new QgsVectorLayerSaveAsDialog

QString format() const;
%Docstring
The format in which the export should be written.
Returns the selected format in which the export should be written.

.. seealso:: :py:func:`QgsVectorFileWriter.filterForDriver`
%End

QString encoding() const;
%Docstring
The encoding of the target file.
Returns the selected encoding for the target file.
%End

QString filename() const;
QString fileName() const;
%Docstring
Returns the target filename.

.. seealso:: :py:func:`layerName`
%End

QString layername() const;
QString layerName() const;
%Docstring
Returns the target layer name
Returns the target layer name.

.. seealso:: :py:func:`fileName`
%End

QStringList datasourceOptions() const;
%Docstring
Returns a list of additional data source options which are passed to OGR.
Refer to the OGR documentation for the target format for available options.

.. seealso:: :py:func:`layerOptions`
%End

QStringList layerOptions() const;
%Docstring
Returns a list of additional layer options which are passed to OGR.
Refer to the OGR documentation for the target format for available options.

.. seealso:: :py:func:`datasourceOptions`
%End

QgsCoordinateReferenceSystem crs() const;
%Docstring
Returns the CRS chosen for export
Returns the CRS chosen for export.

.. versionadded:: 3.14
%End
Expand All @@ -89,14 +97,17 @@ Returns the CRS chosen for export
%Docstring
Returns a list of attributes which are selected for saving.
%End

QgsAttributeList attributesAsDisplayedValues() const;
%Docstring
Returns selected attributes that must be exported with their displayed values instead of their raw values. Added in QGIS 2.16
Returns selected attributes that must be exported with their displayed values instead of their raw values.

.. versionadded:: 2.16
%End

QStringList attributesExportNames() const;
%Docstring
Returns a list of export names for attributes
Returns a list of export names for attributes.
%End

bool addToCanvas() const;
Expand Down Expand Up @@ -151,11 +162,15 @@ Determines the extent to be exported.
void setOnlySelected( bool onlySelected );
%Docstring
Sets whether only selected features will be saved.

.. seealso:: :py:func:`onlySelected`
%End

bool onlySelected() const;
%Docstring
Returns whether only selected features will be saved.

.. seealso:: :py:func:`setOnlySelected`
%End

bool persistMetadata() const;
Expand Down Expand Up @@ -188,28 +203,36 @@ Returns ``True`` if geometry type is set to automatic.
Returns ``True`` if force multi geometry type is checked.

.. seealso:: :py:func:`includeZ`

.. seealso:: :py:func:`setForceMulti`
%End

void setForceMulti( bool checked );
%Docstring
Sets whether the force multi geometry checkbox should be checked.

.. seealso:: :py:func:`forceMulti`
%End

bool includeZ() const;
%Docstring
Returns ``True`` if include z dimension is checked.

.. seealso:: :py:func:`forceMulti`

.. seealso:: :py:func:`setIncludeZ`
%End

void setIncludeZ( bool checked );
%Docstring
Sets whether the include z dimension checkbox should be checked.

.. seealso:: :py:func:`includeZ`
%End

QgsVectorFileWriter::ActionOnExistingFile creationActionOnExistingFile() const;
%Docstring
Returns creation action
Returns the creation action.
%End

virtual void accept();
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -8441,7 +8441,7 @@ QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbology
if ( dialog->exec() == QDialog::Accepted )
{
QString encoding = dialog->encoding();
vectorFilename = dialog->filename();
vectorFilename = dialog->fileName();
QString format = dialog->format();
QStringList datasourceOptions = dialog->datasourceOptions();
bool autoGeometryType = dialog->automaticGeometryType();
Expand All @@ -8465,7 +8465,7 @@ QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbology

QgsVectorFileWriter::SaveVectorOptions options;
options.driverName = format;
options.layerName = dialog->layername();
options.layerName = dialog->layerName();
options.actionOnExistingFile = dialog->creationActionOnExistingFile();
options.fileEncoding = encoding;
options.ct = ct;
Expand Down
20 changes: 10 additions & 10 deletions src/gui/ogr/qgsvectorlayersaveasdialog.cpp
Expand Up @@ -307,12 +307,12 @@ QList<QPair<QLabel *, QWidget *> > QgsVectorLayerSaveAsDialog::createControls( c

void QgsVectorLayerSaveAsDialog::accept()
{
if ( QFile::exists( filename() ) )
if ( QFile::exists( fileName() ) )
{
QgsVectorFileWriter::EditionCapabilities caps =
QgsVectorFileWriter::editionCapabilities( filename() );
bool layerExists = QgsVectorFileWriter::targetLayerExists( filename(),
layername() );
QgsVectorFileWriter::editionCapabilities( fileName() );
bool layerExists = QgsVectorFileWriter::targetLayerExists( fileName(),
layerName() );
QMessageBox msgBox;
msgBox.setIcon( QMessageBox::Question );
msgBox.setWindowTitle( tr( "Save Vector Layer As" ) );
Expand Down Expand Up @@ -386,7 +386,7 @@ void QgsVectorLayerSaveAsDialog::accept()

if ( mActionOnExistingFile == QgsVectorFileWriter::AppendToLayerNoNewFields )
{
if ( QgsVectorFileWriter::areThereNewFieldsToCreate( filename(), layername(), mLayer, selectedAttributes() ) )
if ( QgsVectorFileWriter::areThereNewFieldsToCreate( fileName(), layerName(), mLayer, selectedAttributes() ) )
{
if ( QMessageBox::question( this,
tr( "Save Vector Layer As" ),
Expand All @@ -396,9 +396,9 @@ void QgsVectorLayerSaveAsDialog::accept()
}
}
}
else if ( mActionOnExistingFile == QgsVectorFileWriter::CreateOrOverwriteFile && QFile::exists( filename() ) )
else if ( mActionOnExistingFile == QgsVectorFileWriter::CreateOrOverwriteFile && QFile::exists( fileName() ) )
{
const QList<QgsProviderSublayerDetails> sublayers = QgsProviderRegistry::instance()->querySublayers( filename() );
const QList<QgsProviderSublayerDetails> sublayers = QgsProviderRegistry::instance()->querySublayers( fileName() );
QStringList layerList;
layerList.reserve( sublayers.size() );
for ( const QgsProviderSublayerDetails &sublayer : sublayers )
Expand All @@ -420,7 +420,7 @@ void QgsVectorLayerSaveAsDialog::accept()
}

QgsSettings settings;
settings.setValue( QStringLiteral( "UI/lastVectorFileFilterDir" ), QFileInfo( filename() ).absolutePath() );
settings.setValue( QStringLiteral( "UI/lastVectorFileFilterDir" ), QFileInfo( fileName() ).absolutePath() );
settings.setValue( QStringLiteral( "UI/lastVectorFormat" ), format() );
settings.setValue( QStringLiteral( "UI/encoding" ), encoding() );
QDialog::accept();
Expand Down Expand Up @@ -879,12 +879,12 @@ void QgsVectorLayerSaveAsDialog::mCrsSelector_crsChanged( const QgsCoordinateRef
mExtentGroupBox->setOutputCrs( mSelectedCrs );
}

QString QgsVectorLayerSaveAsDialog::filename() const
QString QgsVectorLayerSaveAsDialog::fileName() const
{
return mFilename->filePath();
}

QString QgsVectorLayerSaveAsDialog::layername() const
QString QgsVectorLayerSaveAsDialog::layerName() const
{
return leLayername->text();
}
Expand Down
47 changes: 38 additions & 9 deletions src/gui/ogr/qgsvectorlayersaveasdialog.h
Expand Up @@ -72,40 +72,50 @@ class GUI_EXPORT QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVec
QgsVectorLayerSaveAsDialog( QgsVectorLayer *layer, Options options = Option::AllOptions, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() );

/**
* The format in which the export should be written.
* Returns the selected format in which the export should be written.
*
* \see QgsVectorFileWriter::filterForDriver()
*/
QString format() const;

/**
* The encoding of the target file.
* Returns the selected encoding for the target file.
*/
QString encoding() const;

/**
* Returns the target filename.
*
* \see layerName()
*/
QString filename() const;
QString fileName() const;

/**
* Returns the target layer name
* Returns the target layer name.
*
* \see fileName()
*/
QString layername() const;
QString layerName() const;

/**
* Returns a list of additional data source options which are passed to OGR.
* Refer to the OGR documentation for the target format for available options.
*
* \see layerOptions()
*/
QStringList datasourceOptions() const;

/**
* Returns a list of additional layer options which are passed to OGR.
* Refer to the OGR documentation for the target format for available options.
*
* \see datasourceOptions()
*/
QStringList layerOptions() const;

/**
* Returns the CRS chosen for export
* Returns the CRS chosen for export.
*
* \since QGIS 3.14
*/
QgsCoordinateReferenceSystem crs() const;
Expand All @@ -114,11 +124,16 @@ class GUI_EXPORT QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVec
* Returns a list of attributes which are selected for saving.
*/
QgsAttributeList selectedAttributes() const;
//! Returns selected attributes that must be exported with their displayed values instead of their raw values. Added in QGIS 2.16

/**
* Returns selected attributes that must be exported with their displayed values instead of their raw values.
*
* \since QGIS 2.16
*/
QgsAttributeList attributesAsDisplayedValues() const;

/**
* Returns a list of export names for attributes
* Returns a list of export names for attributes.
*/
QStringList attributesExportNames() const;

Expand Down Expand Up @@ -170,11 +185,15 @@ class GUI_EXPORT QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVec

/**
* Sets whether only selected features will be saved.
*
* \see onlySelected()
*/
void setOnlySelected( bool onlySelected );

/**
* Returns whether only selected features will be saved.
*
* \see setOnlySelected()
*/
bool onlySelected() const;

Expand All @@ -201,27 +220,37 @@ class GUI_EXPORT QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVec

/**
* Returns TRUE if force multi geometry type is checked.
*
* \see includeZ()
* \see setForceMulti()
*/
bool forceMulti() const;

/**
* Sets whether the force multi geometry checkbox should be checked.
*
* \see forceMulti()
*/
void setForceMulti( bool checked );

/**
* Returns TRUE if include z dimension is checked.
*
* \see forceMulti()
* \see setIncludeZ()
*/
bool includeZ() const;

/**
* Sets whether the include z dimension checkbox should be checked.
*
* \see includeZ()
*/
void setIncludeZ( bool checked );

//! Returns creation action
/**
* Returns the creation action.
*/
QgsVectorFileWriter::ActionOnExistingFile creationActionOnExistingFile() const;

void accept() override;
Expand Down

0 comments on commit 5efa6c0

Please sign in to comment.