Skip to content
Permalink
Browse files

Set an attribute as private instead of protected

  • Loading branch information
pblottiere committed Jul 31, 2017
1 parent 74b3823 commit 86c63a15b6a88fde40dca3a631ca058e7977cf32
Showing with 30 additions and 15 deletions.
  1. +8 −2 python/core/qgsarchive.sip
  2. +14 −11 src/core/qgsarchive.cpp
  3. +8 −2 src/core/qgsarchive.h
@@ -67,6 +67,14 @@ class QgsArchive
\param filename A file to add when zipping this archive
%End

bool removeFile( const QString &filename );
%Docstring
Remove a file from this archive and from the filesystem.
\param filename The path of the file to remove
:return: true if the file has been removed from the filesystem, false otherwise
:rtype: bool
%End

QStringList files() const;
%Docstring
Returns the list of files within this archive
@@ -79,8 +87,6 @@ class QgsArchive
:rtype: str
%End

protected:

};

class QgsProjectArchive : QgsArchive
@@ -95,14 +95,26 @@ void QgsArchive::addFile( const QString &file )
mFiles.append( file );
}

bool QgsArchive::removeFile( const QString &file )
{
bool rc = false;

if ( !file.isEmpty() && mFiles.contains( file ) && QFile::exists( file ) )
rc = QFile::remove( file );

mFiles.removeOne( file );

return rc;
}

QStringList QgsArchive::files() const
{
return mFiles;
}

QString QgsProjectArchive::projectFile() const
{
Q_FOREACH ( const QString &file, mFiles )
Q_FOREACH ( const QString &file, files() )
{
QFileInfo fileInfo( file );
if ( fileInfo.suffix().compare( QLatin1String( "qgs" ), Qt::CaseInsensitive ) == 0 )
@@ -122,14 +134,5 @@ bool QgsProjectArchive::unzip( const QString &filename )

bool QgsProjectArchive::clearProjectFile()
{
bool rc = false;
QString file = projectFile();

if ( !file.isEmpty() && QFile::exists( file ) )
rc = QFile::remove( file );

if ( rc )
mFiles.removeOne( file );

return rc;
return removeFile( projectFile() );
}
@@ -80,6 +80,13 @@ class CORE_EXPORT QgsArchive
*/
void addFile( const QString &filename );

/**
* Remove a file from this archive and from the filesystem.
* \param filename The path of the file to remove
* \returns true if the file has been removed from the filesystem, false otherwise
*/
bool removeFile( const QString &filename );

/**
* Returns the list of files within this archive
*/
@@ -90,11 +97,10 @@ class CORE_EXPORT QgsArchive
*/
QString dir() const;

protected:
private:
// content of the archive
QStringList mFiles;

private:
// used when unzip is performed
std::unique_ptr<QTemporaryDir> mDir;
};

0 comments on commit 86c63a1

Please sign in to comment.
You can’t perform that action at this time.