QTemporaryDir/File: cleanups (static internal function, QScopedPointer)
Change-Id: I61311d151e2ae94a22df58297bbfb7a636a01c4a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
ee18d6ea1f
commit
757ef710d8
@ -66,7 +66,6 @@ public:
|
|||||||
QTemporaryDirPrivate();
|
QTemporaryDirPrivate();
|
||||||
~QTemporaryDirPrivate();
|
~QTemporaryDirPrivate();
|
||||||
|
|
||||||
QString defaultTemplateName() const;
|
|
||||||
void create(const QString &templateName);
|
void create(const QString &templateName);
|
||||||
|
|
||||||
QString path;
|
QString path;
|
||||||
@ -84,7 +83,7 @@ QTemporaryDirPrivate::~QTemporaryDirPrivate()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QTemporaryDirPrivate::defaultTemplateName() const
|
static QString defaultTemplateName()
|
||||||
{
|
{
|
||||||
QString baseName;
|
QString baseName;
|
||||||
#if defined(QT_BUILD_CORE_LIB)
|
#if defined(QT_BUILD_CORE_LIB)
|
||||||
@ -167,14 +166,14 @@ void QTemporaryDirPrivate::create(const QString &templateName)
|
|||||||
QTemporaryDir::QTemporaryDir()
|
QTemporaryDir::QTemporaryDir()
|
||||||
: d_ptr(new QTemporaryDirPrivate)
|
: d_ptr(new QTemporaryDirPrivate)
|
||||||
{
|
{
|
||||||
d_ptr->create(d_ptr->defaultTemplateName());
|
d_ptr->create(defaultTemplateName());
|
||||||
}
|
}
|
||||||
|
|
||||||
QTemporaryDir::QTemporaryDir(const QString &templateName)
|
QTemporaryDir::QTemporaryDir(const QString &templateName)
|
||||||
: d_ptr(new QTemporaryDirPrivate)
|
: d_ptr(new QTemporaryDirPrivate)
|
||||||
{
|
{
|
||||||
if (templateName.isEmpty())
|
if (templateName.isEmpty())
|
||||||
d_ptr->create(d_ptr->defaultTemplateName());
|
d_ptr->create(defaultTemplateName());
|
||||||
else
|
else
|
||||||
d_ptr->create(templateName);
|
d_ptr->create(templateName);
|
||||||
}
|
}
|
||||||
@ -188,9 +187,8 @@ QTemporaryDir::QTemporaryDir(const QString &templateName)
|
|||||||
*/
|
*/
|
||||||
QTemporaryDir::~QTemporaryDir()
|
QTemporaryDir::~QTemporaryDir()
|
||||||
{
|
{
|
||||||
if (d_ptr->success && d_ptr->autoRemove)
|
if (d_ptr->autoRemove)
|
||||||
remove();
|
remove();
|
||||||
delete d_ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#define QTEMPORARYDIR_H
|
#define QTEMPORARYDIR_H
|
||||||
|
|
||||||
#include <QtCore/qdir.h>
|
#include <QtCore/qdir.h>
|
||||||
|
#include <QtCore/QScopedPointer>
|
||||||
|
|
||||||
QT_BEGIN_HEADER
|
QT_BEGIN_HEADER
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ public:
|
|||||||
QString path() const;
|
QString path() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTemporaryDirPrivate* const d_ptr;
|
QScopedPointer<QTemporaryDirPrivate> d_ptr;
|
||||||
|
|
||||||
Q_DISABLE_COPY(QTemporaryDir)
|
Q_DISABLE_COPY(QTemporaryDir)
|
||||||
};
|
};
|
||||||
|
@ -439,8 +439,6 @@ protected:
|
|||||||
QTemporaryFilePrivate();
|
QTemporaryFilePrivate();
|
||||||
~QTemporaryFilePrivate();
|
~QTemporaryFilePrivate();
|
||||||
|
|
||||||
QString defaultTemplateName() const;
|
|
||||||
|
|
||||||
bool autoRemove;
|
bool autoRemove;
|
||||||
QString templateName;
|
QString templateName;
|
||||||
};
|
};
|
||||||
@ -453,7 +451,7 @@ QTemporaryFilePrivate::~QTemporaryFilePrivate()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QTemporaryFilePrivate::defaultTemplateName() const
|
static QString defaultTemplateName()
|
||||||
{
|
{
|
||||||
QString baseName;
|
QString baseName;
|
||||||
#if defined(QT_BUILD_CORE_LIB)
|
#if defined(QT_BUILD_CORE_LIB)
|
||||||
@ -518,7 +516,7 @@ QTemporaryFile::QTemporaryFile()
|
|||||||
: QFile(*new QTemporaryFilePrivate)
|
: QFile(*new QTemporaryFilePrivate)
|
||||||
{
|
{
|
||||||
Q_D(QTemporaryFile);
|
Q_D(QTemporaryFile);
|
||||||
d->templateName = d->defaultTemplateName();
|
d->templateName = defaultTemplateName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QTemporaryFile::QTemporaryFile(const QString &templateName)
|
QTemporaryFile::QTemporaryFile(const QString &templateName)
|
||||||
@ -541,7 +539,7 @@ QTemporaryFile::QTemporaryFile()
|
|||||||
: QFile(*new QTemporaryFilePrivate, 0)
|
: QFile(*new QTemporaryFilePrivate, 0)
|
||||||
{
|
{
|
||||||
Q_D(QTemporaryFile);
|
Q_D(QTemporaryFile);
|
||||||
d->templateName = d->defaultTemplateName();
|
d->templateName = defaultTemplateName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -577,7 +575,7 @@ QTemporaryFile::QTemporaryFile(QObject *parent)
|
|||||||
: QFile(*new QTemporaryFilePrivate, parent)
|
: QFile(*new QTemporaryFilePrivate, parent)
|
||||||
{
|
{
|
||||||
Q_D(QTemporaryFile);
|
Q_D(QTemporaryFile);
|
||||||
d->templateName = d->defaultTemplateName();
|
d->templateName = defaultTemplateName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
Reference in New Issue
Block a user