Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Set an attribute as private instead of protected
  • Loading branch information
pblottiere committed Jul 31, 2017
1 parent 74b3823 commit 86c63a1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
10 changes: 8 additions & 2 deletions python/core/qgsarchive.sip
Expand Up @@ -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
Expand All @@ -79,8 +87,6 @@ class QgsArchive
:rtype: str
%End

protected:

};

class QgsProjectArchive : QgsArchive
Expand Down
25 changes: 14 additions & 11 deletions src/core/qgsarchive.cpp
Expand Up @@ -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 )
Expand All @@ -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() );
}
10 changes: 8 additions & 2 deletions src/core/qgsarchive.h
Expand Up @@ -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
*/
Expand All @@ -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;
};
Expand Down

0 comments on commit 86c63a1

Please sign in to comment.