diff options
author | David Faure <faure+bluesystems@kde.org> | 2013-01-14 09:48:17 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-14 23:44:15 +0100 |
commit | ad265c55beb596e28d6b28c16700795fa8555ee6 (patch) | |
tree | 7bc582035d71eb3d387fd1d367aadd144889027c | |
parent | ad893943cfe0434624a1e807ed19e95286e362cc (diff) |
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>
-rw-r--r-- | src/corelib/io/io.pri | 1 | ||||
-rw-r--r-- | src/corelib/io/qtemporaryfile.cpp | 55 | ||||
-rw-r--r-- | src/corelib/io/qtemporaryfile_p.h | 101 |
3 files changed, 107 insertions, 50 deletions
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index f57dcebe33..36c553acec 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -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 \ diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 161c64a73b..2f272e9a63 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -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(); } /*! diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h new file mode 100644 index 0000000000..7aed729a1c --- /dev/null +++ b/src/corelib/io/qtemporaryfile_p.h @@ -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 */ + |