Skip to content

Commit 86c63a1

Browse files
committedJul 31, 2017
Set an attribute as private instead of protected
1 parent 74b3823 commit 86c63a1

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed
 

‎python/core/qgsarchive.sip

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ class QgsArchive
6767
\param filename A file to add when zipping this archive
6868
%End
6969

70+
bool removeFile( const QString &filename );
71+
%Docstring
72+
Remove a file from this archive and from the filesystem.
73+
\param filename The path of the file to remove
74+
:return: true if the file has been removed from the filesystem, false otherwise
75+
:rtype: bool
76+
%End
77+
7078
QStringList files() const;
7179
%Docstring
7280
Returns the list of files within this archive
@@ -79,8 +87,6 @@ class QgsArchive
7987
:rtype: str
8088
%End
8189

82-
protected:
83-
8490
};
8591

8692
class QgsProjectArchive : QgsArchive

‎src/core/qgsarchive.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,26 @@ void QgsArchive::addFile( const QString &file )
9595
mFiles.append( file );
9696
}
9797

98+
bool QgsArchive::removeFile( const QString &file )
99+
{
100+
bool rc = false;
101+
102+
if ( !file.isEmpty() && mFiles.contains( file ) && QFile::exists( file ) )
103+
rc = QFile::remove( file );
104+
105+
mFiles.removeOne( file );
106+
107+
return rc;
108+
}
109+
98110
QStringList QgsArchive::files() const
99111
{
100112
return mFiles;
101113
}
102114

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

123135
bool QgsProjectArchive::clearProjectFile()
124136
{
125-
bool rc = false;
126-
QString file = projectFile();
127-
128-
if ( !file.isEmpty() && QFile::exists( file ) )
129-
rc = QFile::remove( file );
130-
131-
if ( rc )
132-
mFiles.removeOne( file );
133-
134-
return rc;
137+
return removeFile( projectFile() );
135138
}

‎src/core/qgsarchive.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ class CORE_EXPORT QgsArchive
8080
*/
8181
void addFile( const QString &filename );
8282

83+
/**
84+
* Remove a file from this archive and from the filesystem.
85+
* \param filename The path of the file to remove
86+
* \returns true if the file has been removed from the filesystem, false otherwise
87+
*/
88+
bool removeFile( const QString &filename );
89+
8390
/**
8491
* Returns the list of files within this archive
8592
*/
@@ -90,11 +97,10 @@ class CORE_EXPORT QgsArchive
9097
*/
9198
QString dir() const;
9299

93-
protected:
100+
private:
94101
// content of the archive
95102
QStringList mFiles;
96103

97-
private:
98104
// used when unzip is performed
99105
std::unique_ptr<QTemporaryDir> mDir;
100106
};

0 commit comments

Comments
 (0)
Please sign in to comment.