mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-07 00:03:52 -05:00
Update documentation and sip binding
This commit is contained in:
parent
d23137e5d6
commit
75811ef76b
@ -127,6 +127,7 @@
|
|||||||
%Include qgsvirtuallayerdefinitionutils.sip
|
%Include qgsvirtuallayerdefinitionutils.sip
|
||||||
%Include qgsmapthemecollection.sip
|
%Include qgsmapthemecollection.sip
|
||||||
%Include qgsxmlutils.sip
|
%Include qgsxmlutils.sip
|
||||||
|
%Include qgsarchive.sip
|
||||||
%Include qgsziputils.sip
|
%Include qgsziputils.sip
|
||||||
%Include qgsvector.sip
|
%Include qgsvector.sip
|
||||||
%Include auth/qgsauthcertutils.sip
|
%Include auth/qgsauthcertutils.sip
|
||||||
|
|||||||
126
python/core/qgsarchive.sip
Normal file
126
python/core/qgsarchive.sip
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/qgsarchive.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class QgsArchive
|
||||||
|
{
|
||||||
|
%Docstring
|
||||||
|
Class allowing to manage the zip/unzip actions on project
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include "qgsarchive.h"
|
||||||
|
%End
|
||||||
|
public:
|
||||||
|
|
||||||
|
QgsArchive();
|
||||||
|
%Docstring
|
||||||
|
Constructor
|
||||||
|
%End
|
||||||
|
|
||||||
|
QgsArchive( const QgsArchive &other );
|
||||||
|
%Docstring
|
||||||
|
Copy constructor
|
||||||
|
%End
|
||||||
|
|
||||||
|
|
||||||
|
~QgsArchive();
|
||||||
|
%Docstring
|
||||||
|
Destructor
|
||||||
|
%End
|
||||||
|
|
||||||
|
bool zip( const QString &zipFilename );
|
||||||
|
%Docstring
|
||||||
|
Zip the content of this archive
|
||||||
|
\param zipFilename The name of the zip to generate
|
||||||
|
:return: false if something goes wrong, true otherwise
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
|
bool zip();
|
||||||
|
%Docstring
|
||||||
|
Zip the content of this archive. THe current filename is used.
|
||||||
|
:return: false if something goes wrong, true otherwise
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
|
bool unzip( const QString &zipFilename );
|
||||||
|
%Docstring
|
||||||
|
Clear the current content of this archive and unzip. If a project file
|
||||||
|
is found in the content, then this archive may be considered as a valid
|
||||||
|
one. Files are unzipped in the temporary directory.
|
||||||
|
\param zipFilename The zip file to unzip
|
||||||
|
:return: true if a project file has been found, false otherwise
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
|
bool unzip();
|
||||||
|
%Docstring
|
||||||
|
Clear the current content of this archive and unzip. If a project file
|
||||||
|
is found in the content, then this archive may be considered as a valid
|
||||||
|
one. Files are unzipped in the temporary directory. The current filename
|
||||||
|
is used.
|
||||||
|
:return: true if a project file has been found, false otherwise
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
%Docstring
|
||||||
|
Clear the current content of this archive and create a new temporary
|
||||||
|
directory.
|
||||||
|
%End
|
||||||
|
|
||||||
|
void addFile( const QString &filename );
|
||||||
|
%Docstring
|
||||||
|
Add a new file to this archive. During a zip action, this file will be
|
||||||
|
part of the resulting zipped file.
|
||||||
|
\param filename A file to add when zipping this archive
|
||||||
|
%End
|
||||||
|
|
||||||
|
void setFileName( const QString &filename );
|
||||||
|
%Docstring
|
||||||
|
Set the filename to use when zipping/unzipping this archive.
|
||||||
|
\param filename The zip filename
|
||||||
|
%End
|
||||||
|
|
||||||
|
QString filename() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the current zip filename.
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
|
QString projectFile() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the current .qgs project file or an empty string if there's none
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
|
QStringList files() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the list of files within this archive
|
||||||
|
:rtype: list of str
|
||||||
|
%End
|
||||||
|
|
||||||
|
QString dir() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the current temporary directory.
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/qgsarchive.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
@ -615,7 +615,15 @@ Returns the number of registered layers.
|
|||||||
bool unzip( const QString &filename );
|
bool unzip( const QString &filename );
|
||||||
%Docstring
|
%Docstring
|
||||||
Unzip a project
|
Unzip a project
|
||||||
\param filename The project filename to unzip
|
\param filename The zip file to unzip
|
||||||
|
:return: true if unzip is well performed, false otherwise
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
|
bool unzip();
|
||||||
|
%Docstring
|
||||||
|
Unzip a project with the current zip filename
|
||||||
:return: true if unzip is well performed, false otherwise
|
:return: true if unzip is well performed, false otherwise
|
||||||
.. versionadded:: 3.0
|
.. versionadded:: 3.0
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
@ -632,18 +640,29 @@ Returns the number of registered layers.
|
|||||||
|
|
||||||
bool zip();
|
bool zip();
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Zip the project with the current zip filename
|
||||||
|
:return: true if zip is well performed, false otherwise
|
||||||
|
.. versionadded:: 3.0
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
%End
|
%End
|
||||||
|
|
||||||
QString zipFileName() const;
|
QString zipFileName() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Returns the current zip filename or an empty string if none.
|
||||||
|
.. versionadded:: 3.0
|
||||||
:rtype: str
|
:rtype: str
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setZipFileName( const QString &filename );
|
void setZipFileName( const QString &filename );
|
||||||
|
%Docstring
|
||||||
|
Sets the current zip filename.
|
||||||
|
\param filename The zip filename
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
bool unzipped() const;
|
bool unzipped() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Returns true if the project comes from a zip archive, false otherwise.
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
|||||||
@ -25,10 +25,24 @@ QgsArchive::QgsArchive()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsArchive::~QgsArchive()
|
QgsArchive::QgsArchive( const QgsArchive &other )
|
||||||
|
: mDir( new QTemporaryDir() )
|
||||||
|
, mFiles( other.mFiles )
|
||||||
|
, mFilename( other.mFilename )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QgsArchive &QgsArchive::operator=( const QgsArchive &other )
|
||||||
|
{
|
||||||
|
if ( this != &other )
|
||||||
|
{
|
||||||
|
mFilename = other.mFilename;
|
||||||
|
mFiles = other.mFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
QString QgsArchive::dir() const
|
QString QgsArchive::dir() const
|
||||||
{
|
{
|
||||||
return mDir->path();
|
return mDir->path();
|
||||||
@ -41,6 +55,14 @@ void QgsArchive::clear()
|
|||||||
mFiles.clear();
|
mFiles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QgsArchive::zip()
|
||||||
|
{
|
||||||
|
if ( mFilename.isEmpty() )
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return zip( mFilename );
|
||||||
|
}
|
||||||
|
|
||||||
bool QgsArchive::zip( const QString &filename )
|
bool QgsArchive::zip( const QString &filename )
|
||||||
{
|
{
|
||||||
// create a temporary path
|
// create a temporary path
|
||||||
@ -75,6 +97,14 @@ bool QgsArchive::zip( const QString &filename )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QgsArchive::unzip()
|
||||||
|
{
|
||||||
|
if ( mFilename.isEmpty() )
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return unzip( mFilename );
|
||||||
|
}
|
||||||
|
|
||||||
bool QgsArchive::unzip( const QString &filename )
|
bool QgsArchive::unzip( const QString &filename )
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|||||||
@ -36,30 +36,94 @@ class CORE_EXPORT QgsArchive
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for QgsArchive
|
* Constructor
|
||||||
*/
|
*/
|
||||||
QgsArchive();
|
QgsArchive();
|
||||||
~QgsArchive();
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy constructor
|
||||||
|
*/
|
||||||
|
QgsArchive( const QgsArchive &other );
|
||||||
|
|
||||||
|
QgsArchive &operator=( const QgsArchive &other );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
|
~QgsArchive() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zip the content of this archive
|
||||||
|
* \param zipFilename The name of the zip to generate
|
||||||
|
* \returns false if something goes wrong, true otherwise
|
||||||
|
*/
|
||||||
bool zip( const QString &zipFilename );
|
bool zip( const QString &zipFilename );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zip the content of this archive. THe current filename is used.
|
||||||
|
* \returns false if something goes wrong, true otherwise
|
||||||
|
*/
|
||||||
|
bool zip();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the current content of this archive and unzip. If a project file
|
||||||
|
* is found in the content, then this archive may be considered as a valid
|
||||||
|
* one. Files are unzipped in the temporary directory.
|
||||||
|
* \param zipFilename The zip file to unzip
|
||||||
|
* \returns true if a project file has been found, false otherwise
|
||||||
|
*/
|
||||||
bool unzip( const QString &zipFilename );
|
bool unzip( const QString &zipFilename );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the current content of this archive and unzip. If a project file
|
||||||
|
* is found in the content, then this archive may be considered as a valid
|
||||||
|
* one. Files are unzipped in the temporary directory. The current filename
|
||||||
|
* is used.
|
||||||
|
* \returns true if a project file has been found, false otherwise
|
||||||
|
*/
|
||||||
|
bool unzip();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the current content of this archive and create a new temporary
|
||||||
|
* directory.
|
||||||
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new file to this archive. During a zip action, this file will be
|
||||||
|
* part of the resulting zipped file.
|
||||||
|
* \param filename A file to add when zipping this archive
|
||||||
|
*/
|
||||||
void addFile( const QString &filename );
|
void addFile( const QString &filename );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the filename to use when zipping/unzipping this archive.
|
||||||
|
* \param filename The zip filename
|
||||||
|
*/
|
||||||
void setFileName( const QString &filename );
|
void setFileName( const QString &filename );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current zip filename.
|
||||||
|
*/
|
||||||
QString filename() const;
|
QString filename() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current .qgs project file or an empty string if there's none
|
||||||
|
*/
|
||||||
QString projectFile() const;
|
QString projectFile() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of files within this archive
|
||||||
|
*/
|
||||||
QStringList files() const;
|
QStringList files() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current temporary directory.
|
||||||
|
*/
|
||||||
QString dir() const;
|
QString dir() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifndef SIP_RUN
|
||||||
// used when unzip is performed
|
// used when unzip is performed
|
||||||
std::unique_ptr<QTemporaryDir> mDir;
|
std::unique_ptr<QTemporaryDir> mDir;
|
||||||
|
|
||||||
@ -68,6 +132,7 @@ class CORE_EXPORT QgsArchive
|
|||||||
|
|
||||||
// zip filename
|
// zip filename
|
||||||
QString mFilename;
|
QString mFilename;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -2071,6 +2071,11 @@ QList<QgsMapLayer *> QgsProject::mapLayersByName( const QString &layerName ) con
|
|||||||
return mLayerStore->mapLayersByName( layerName );
|
return mLayerStore->mapLayersByName( layerName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QgsProject::unzip()
|
||||||
|
{
|
||||||
|
return unzip( mArchive->filename() );
|
||||||
|
}
|
||||||
|
|
||||||
bool QgsProject::unzip( const QString &filename )
|
bool QgsProject::unzip( const QString &filename )
|
||||||
{
|
{
|
||||||
clearError();
|
clearError();
|
||||||
|
|||||||
@ -578,12 +578,19 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unzip a project
|
* Unzip a project
|
||||||
* \param filename The project filename to unzip
|
* \param filename The zip file to unzip
|
||||||
* \returns true if unzip is well performed, false otherwise
|
* \returns true if unzip is well performed, false otherwise
|
||||||
* \since QGIS 3.0
|
* \since QGIS 3.0
|
||||||
*/
|
*/
|
||||||
bool unzip( const QString &filename );
|
bool unzip( const QString &filename );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unzip a project with the current zip filename
|
||||||
|
* \returns true if unzip is well performed, false otherwise
|
||||||
|
* \since QGIS 3.0
|
||||||
|
*/
|
||||||
|
bool unzip();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zip the project
|
* Zip the project
|
||||||
* \param filename The zip filename
|
* \param filename The zip filename
|
||||||
@ -592,12 +599,29 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
|
|||||||
*/
|
*/
|
||||||
bool zip( const QString &filename );
|
bool zip( const QString &filename );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zip the project with the current zip filename
|
||||||
|
* \returns true if zip is well performed, false otherwise
|
||||||
|
* \since QGIS 3.0
|
||||||
|
*/
|
||||||
bool zip();
|
bool zip();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current zip filename or an empty string if none.
|
||||||
|
* \since QGIS 3.0
|
||||||
|
*/
|
||||||
QString zipFileName() const;
|
QString zipFileName() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current zip filename.
|
||||||
|
* \param filename The zip filename
|
||||||
|
* \since QGIS 3.0
|
||||||
|
*/
|
||||||
void setZipFileName( const QString &filename );
|
void setZipFileName( const QString &filename );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the project comes from a zip archive, false otherwise.
|
||||||
|
*/
|
||||||
bool unzipped() const;
|
bool unzipped() const;
|
||||||
|
|
||||||
#ifndef SIP_RUN
|
#ifndef SIP_RUN
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user