Move QTemporaryFileEngine to private header

This is needed by QSaveFile.

Move QTemporaryFilePrivate to that header too, to avoid any confusion.

Change-Id: I8dce8a4fb853a9823c49ec565867432331e748cd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
David Faure 2013-01-14 09:48:17 +01:00 committed by The Qt Project
parent ad893943cf
commit ad265c55be
3 changed files with 107 additions and 50 deletions

View File

@ -24,6 +24,7 @@ HEADERS += \
io/qtextstream.h \
io/qtemporarydir.h \
io/qtemporaryfile.h \
io/qtemporaryfile_p.h \
io/qresource_p.h \
io/qresource_iterator_p.h \
io/qstandardpaths.h \

View File

@ -44,10 +44,9 @@
#ifndef QT_NO_TEMPORARYFILE
#include "qplatformdefs.h"
#include "private/qtemporaryfile_p.h"
#include "private/qfile_p.h"
#include "private/qfsfileengine_p.h"
#include "private/qsystemerror_p.h"
#include "private/qfilesystemengine_p.h"
#if !defined(Q_OS_WIN)
#include "private/qcore_unix_p.h" // overrides QT_OPEN
@ -218,37 +217,6 @@ static bool createFileFromTemplate(NativeFileHandle &file,
}
//************* QTemporaryFileEngine
class QTemporaryFileEngine : public QFSFileEngine
{
Q_DECLARE_PRIVATE(QFSFileEngine)
public:
QTemporaryFileEngine(const QString &file, bool fileIsTemplate = true)
: QFSFileEngine(), filePathIsTemplate(fileIsTemplate),
filePathWasTemplate(fileIsTemplate)
{
Q_D(QFSFileEngine);
d->fileEntry = QFileSystemEntry(file);
if (!filePathIsTemplate)
QFSFileEngine::setFileName(file);
}
~QTemporaryFileEngine();
bool isReallyOpen();
void setFileName(const QString &file);
void setFileTemplate(const QString &fileTemplate);
bool open(QIODevice::OpenMode flags);
bool remove();
bool rename(const QString &newName);
bool renameOverwrite(const QString &newName);
bool close();
bool filePathIsTemplate;
bool filePathWasTemplate;
};
QTemporaryFileEngine::~QTemporaryFileEngine()
{
QFSFileEngine::close();
@ -414,19 +382,6 @@ bool QTemporaryFileEngine::close()
}
//************* QTemporaryFilePrivate
class QTemporaryFilePrivate : public QFilePrivate
{
Q_DECLARE_PUBLIC(QTemporaryFile)
protected:
QTemporaryFilePrivate();
~QTemporaryFilePrivate();
QAbstractFileEngine *engine() const;
bool autoRemove;
QString templateName;
};
QTemporaryFilePrivate::QTemporaryFilePrivate() : autoRemove(true)
{
@ -447,7 +402,7 @@ QAbstractFileEngine *QTemporaryFilePrivate::engine() const
return fileEngine;
}
static QString defaultTemplateName()
QString QTemporaryFilePrivate::defaultTemplateName()
{
QString baseName;
#if defined(QT_BUILD_CORE_LIB)
@ -513,7 +468,7 @@ QTemporaryFile::QTemporaryFile()
: QFile(*new QTemporaryFilePrivate)
{
Q_D(QTemporaryFile);
d->templateName = defaultTemplateName();
d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
QTemporaryFile::QTemporaryFile(const QString &templateName)
@ -536,7 +491,7 @@ QTemporaryFile::QTemporaryFile()
: QFile(*new QTemporaryFilePrivate, 0)
{
Q_D(QTemporaryFile);
d->templateName = defaultTemplateName();
d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
/*!
@ -572,7 +527,7 @@ QTemporaryFile::QTemporaryFile(QObject *parent)
: QFile(*new QTemporaryFilePrivate, parent)
{
Q_D(QTemporaryFile);
d->templateName = defaultTemplateName();
d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
/*!

View File

@ -0,0 +1,101 @@
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTEMPORARYFILE_P_H
#define QTEMPORARYFILE_P_H
#include "private/qfsfileengine_p.h"
#include "private/qfilesystemengine_p.h"
#include "private/qfile_p.h"
QT_BEGIN_NAMESPACE
class QTemporaryFilePrivate : public QFilePrivate
{
Q_DECLARE_PUBLIC(QTemporaryFile)
protected:
QTemporaryFilePrivate();
~QTemporaryFilePrivate();
QAbstractFileEngine *engine() const;
bool autoRemove;
QString templateName;
static QString defaultTemplateName();
};
class QTemporaryFileEngine : public QFSFileEngine
{
Q_DECLARE_PRIVATE(QFSFileEngine)
public:
QTemporaryFileEngine(const QString &file, bool fileIsTemplate = true)
: QFSFileEngine(), filePathIsTemplate(fileIsTemplate),
filePathWasTemplate(fileIsTemplate)
{
Q_D(QFSFileEngine);
d->fileEntry = QFileSystemEntry(file);
if (!filePathIsTemplate)
QFSFileEngine::setFileName(file);
}
~QTemporaryFileEngine();
bool isReallyOpen();
void setFileName(const QString &file);
void setFileTemplate(const QString &fileTemplate);
bool open(QIODevice::OpenMode flags);
bool remove();
bool rename(const QString &newName);
bool renameOverwrite(const QString &newName);
bool close();
bool filePathIsTemplate;
bool filePathWasTemplate;
};
QT_END_NAMESPACE
#endif /* QTEMPORARYFILE_P_H */