Skip to content

Commit

Permalink
Add auxiliary storage mechanism in project
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Oct 9, 2017
1 parent 072c0f2 commit de49831
Show file tree
Hide file tree
Showing 10 changed files with 572 additions and 2 deletions.
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -421,5 +421,6 @@
%Include layertree/qgslayertreeregistrybridge.sip
%Include qgsuserprofilemanager.sip
%Include symbology/qgsarrowsymbollayer.sip
%Include qgsauxiliarystorage.sip
%Include composer/qgscomposerutils.sip
%Include qgsuserprofile.sip
7 changes: 7 additions & 0 deletions python/core/qgsarchive.sip
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ class QgsProjectArchive : QgsArchive
:return: true if the file is well removed, false otherwise
:rtype: bool
%End

QString auxiliaryStorageFile() const;
%Docstring
Returns the current .qgd auxiliary storage file or an empty string if
there's none
:rtype: str
%End
};

/************************************************************************
Expand Down
112 changes: 112 additions & 0 deletions python/core/qgsauxiliarystorage.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsauxiliarystorage.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/







class QgsAuxiliaryStorage
{
%Docstring


Class providing some utility methods to manage auxiliary storage.

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsauxiliarystorage.h"
%End
public:

QgsAuxiliaryStorage( const QgsProject &project, bool copy = true );
%Docstring
Constructor.

\param project The project for which the auxiliary storage has to be used
\param copy Parameter indicating if a copy of the database has to be used
%End

QgsAuxiliaryStorage( const QString &filename = QString(), bool copy = true );
%Docstring
Constructor.

\param filename The path of the database
\param copy Parameter indicating if a copy of the database has to be used
%End

virtual ~QgsAuxiliaryStorage();
%Docstring
Destructor.
%End

bool isValid() const;
%Docstring
Returns the status of the auxiliary storage currently definied.

:return: true if the auxiliary storage is valid, false otherwise
:rtype: bool
%End

QString fileName() const;
%Docstring
Returns the target filename of the database.
:rtype: str
%End

QString currentFileName() const;
%Docstring
Returns the path of current database used. It may be different from the
target filename if the auxiliary storage is opened in copy mode.
:rtype: str
%End

bool saveAs( const QString &filename ) const;
%Docstring
Saves the current database to a new path.

:return: true if everything is saved, false otherwise
:rtype: bool
%End

bool saveAs( const QgsProject &project ) const;
%Docstring
Saves the current database to a new path for a specific project.
Actually, the current filename of the project is used to deduce the
path of the database to save.

:return: true if everything is saved, false otherwise
:rtype: bool
%End

bool save() const;
%Docstring
Saves the current database.

:return: true if everything is saved, false otherwise
:rtype: bool
%End

static QString extension();
%Docstring
Returns the extension used for auxiliary databases.
:rtype: str
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsauxiliarystorage.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ SET(QGIS_CORE_SRCS
qgsattributes.cpp
qgsattributetableconfig.cpp
qgsattributeeditorelement.cpp
qgsauxiliarystorage.cpp
qgsbearingutils.cpp
qgsbrowsermodel.cpp
qgscachedfeatureiterator.cpp
Expand Down
15 changes: 15 additions & 0 deletions src/core/qgsarchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "qgsarchive.h"
#include "qgsziputils.h"
#include "qgsmessagelog.h"
#include "qgsauxiliarystorage.h"
#include <iostream>

QgsArchive::QgsArchive()
Expand Down Expand Up @@ -136,3 +137,17 @@ bool QgsProjectArchive::clearProjectFile()
{
return removeFile( projectFile() );
}

QString QgsProjectArchive::auxiliaryStorageFile() const
{
const QString extension = QgsAuxiliaryStorage::extension();

Q_FOREACH ( const QString &file, files() )
{
const QFileInfo fileInfo( file );
if ( fileInfo.suffix().compare( extension, Qt::CaseInsensitive ) == 0 )
return file;
}

return QString();
}
6 changes: 6 additions & 0 deletions src/core/qgsarchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ class CORE_EXPORT QgsProjectArchive : public QgsArchive
* \returns true if the file is well removed, false otherwise
*/
bool clearProjectFile();

/**
* Returns the current .qgd auxiliary storage file or an empty string if
* there's none
*/
QString auxiliaryStorageFile() const;
};

#endif
Loading

0 comments on commit de49831

Please sign in to comment.