Qt 5.2.0 is now minimal requirement to build the code.
--HG-- branch : release
This commit is contained in:
parent
3f1b042d6c
commit
a3056dc7e2
|
@ -25,8 +25,8 @@ The standalone binary packages support the following platforms:
|
||||||
Windows XP SP2 (32-bit) or later
|
Windows XP SP2 (32-bit) or later
|
||||||
Ubuntu Linux 14.04 (32-bit/64-bit) or later
|
Ubuntu Linux 14.04 (32-bit/64-bit) or later
|
||||||
OpenSUSE 13.02 (32-bit/64-bit) or later
|
OpenSUSE 13.02 (32-bit/64-bit) or later
|
||||||
Fedora 20 (32-bit/64-bit) or later
|
Fedora 24 (32-bit/64-bit) or later
|
||||||
Mac OS X 10.7 (64-bit) or later
|
Mac OS X 10.8 (64-bit) or later
|
||||||
|
|
||||||
Building the sources requires Qt 5.2.0 or later.
|
Building the sources requires Qt 5.2.0 or later.
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ Prerequisites:
|
||||||
* Qt 5.2.0 or later (On Unix development packages needed)
|
* Qt 5.2.0 or later (On Unix development packages needed)
|
||||||
* mercurial (only for working with repository)
|
* mercurial (only for working with repository)
|
||||||
* On Unix:
|
* On Unix:
|
||||||
- g++ (at least GCC 4.6 is needed and GCC 4.8 is recommended) or
|
- g++ (at least GCC 4.7 is needed and GCC 4.8 is recommended) or
|
||||||
clang (clang 3.4 recommended)
|
clang (clang 3.4 recommended)
|
||||||
- xpdf package (tool pdftops).
|
- xpdf package (tool pdftops).
|
||||||
* On Windows:
|
* On Windows:
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
include(common.pri)
|
include(common.pri)
|
||||||
|
|
||||||
#Check if Qt version >= 5.0.0
|
#Check if Qt version >= 5.2.0
|
||||||
!minQtVersion(5, 0, 0) {
|
!minQtVersion(5, 2, 0) {
|
||||||
message("Cannot build Valentina with Qt version $${QT_VERSION}.")
|
message("Cannot build Valentina with Qt version $${QT_VERSION}.")
|
||||||
error("Use at least Qt 5.0.0.")
|
error("Use at least Qt 5.2.0.")
|
||||||
}
|
}
|
||||||
|
|
||||||
#These checks need because we can quote all paths that contain space.
|
#These checks need because we can quote all paths that contain space.
|
||||||
|
|
14
dist/OBS_debian/debian.control
vendored
14
dist/OBS_debian/debian.control
vendored
|
@ -3,19 +3,19 @@ Section: graphics
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Maintainer: Roman Telezhynskyi <dismine@gmail.com>
|
Maintainer: Roman Telezhynskyi <dismine@gmail.com>
|
||||||
Build-Depends: debhelper (>= 8.0.0),
|
Build-Depends: debhelper (>= 8.0.0),
|
||||||
qtbase5-dev (>= 5.0.0),
|
qtbase5-dev (>= 5.2.0),
|
||||||
libqt5svg5-dev (>= 5.0.0),
|
libqt5svg5-dev (>= 5.2.0),
|
||||||
g++ (>= 4.6.0),
|
g++ (>= 4.7.0),
|
||||||
qt5-default (>= 5.0.0),
|
qt5-default (>= 5.2.0),
|
||||||
qttools5-dev-tools (>= 5.0.0),
|
qttools5-dev-tools (>= 5.2.0),
|
||||||
libqt5xmlpatterns5-dev (>= 5.0.0)
|
libqt5xmlpatterns5-dev (>= 5.2.0)
|
||||||
Standards-Version: 3.9.5
|
Standards-Version: 3.9.5
|
||||||
Homepage: http://www.valentina-project.org/
|
Homepage: http://www.valentina-project.org/
|
||||||
Vcs-Browser: https://bitbucket.org/dismine/valentina
|
Vcs-Browser: https://bitbucket.org/dismine/valentina
|
||||||
|
|
||||||
Package: valentina
|
Package: valentina
|
||||||
Architecture: i386 amd64
|
Architecture: i386 amd64
|
||||||
Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.0.0) | libqt5core5 (>= 5.0.0), libqt5gui5 (>= 5.0.0) | libqt5gui5-gles (>= 5.0.0), libqt5printsupport5 (>= 5.0.0), libqt5svg5 (>= 5.0.0), libqt5widgets5 (>= 5.0.0), libqt5xml5 (>= 5.0.0), libqt5xmlpatterns5 (>= 5.0.0), libstdc++6 (>= 4.6), xpdf
|
Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.2.0) | libqt5core5 (>= 5.2.0), libqt5gui5 (>= 5.2.0) | libqt5gui5-gles (>= 5.2.0), libqt5printsupport5 (>= 5.2.0), libqt5svg5 (>= 5.2.0), libqt5widgets5 (>= 5.2.0), libqt5xml5 (>= 5.2.0), libqt5xmlpatterns5 (>= 5.2.0), libstdc++6 (>= 4.6), xpdf
|
||||||
Description: Pattern making program.
|
Description: Pattern making program.
|
||||||
Valentina is a cross-platform patternmaking program which allows designers
|
Valentina is a cross-platform patternmaking program which allows designers
|
||||||
to create and model patterns of clothing. This software allows pattern
|
to create and model patterns of clothing. This software allows pattern
|
||||||
|
|
14
dist/debian/control
vendored
14
dist/debian/control
vendored
|
@ -3,19 +3,19 @@ Section: graphics
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Maintainer: Roman Telezhynskyi <dismine@gmail.com>
|
Maintainer: Roman Telezhynskyi <dismine@gmail.com>
|
||||||
Build-Depends: debhelper (>= 8.0.0),
|
Build-Depends: debhelper (>= 8.0.0),
|
||||||
qtbase5-dev (>= 5.0.0),
|
qtbase5-dev (>= 5.2.0),
|
||||||
libqt5svg5-dev (>= 5.0.0),
|
libqt5svg5-dev (>= 5.2.0),
|
||||||
g++ (>= 4.6.0),
|
g++ (>= 4.7.0),
|
||||||
qt5-default (>= 5.0.0),
|
qt5-default (>= 5.2.0),
|
||||||
qttools5-dev-tools (>= 5.0.0),
|
qttools5-dev-tools (>= 5.2.0),
|
||||||
libqt5xmlpatterns5-dev (>= 5.0.0)
|
libqt5xmlpatterns5-dev (>= 5.2.0)
|
||||||
Standards-Version: 3.9.5
|
Standards-Version: 3.9.5
|
||||||
Homepage: http://www.valentina-project.org/
|
Homepage: http://www.valentina-project.org/
|
||||||
Vcs-Browser: https://bitbucket.org/dismine/valentina
|
Vcs-Browser: https://bitbucket.org/dismine/valentina
|
||||||
|
|
||||||
Package: valentina
|
Package: valentina
|
||||||
Architecture: i386 amd64
|
Architecture: i386 amd64
|
||||||
Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.0.0) | libqt5core5 (>= 5.0.0), libqt5gui5 (>= 5.0.0) | libqt5gui5-gles (>= 5.0.0), libqt5printsupport5 (>= 5.0.0), libqt5svg5 (>= 5.0.0), libqt5widgets5 (>= 5.0.0), libqt5xml5 (>= 5.0.0), libqt5xmlpatterns5 (>= 5.0.0), libstdc++6 (>= 4.6), xpdf
|
Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.2.0) | libqt5core5 (>= 5.2.0), libqt5gui5 (>= 5.2.0) | libqt5gui5-gles (>= 5.2.0), libqt5printsupport5 (>= 5.2.0), libqt5svg5 (>= 5.2.0), libqt5widgets5 (>= 5.2.0), libqt5xml5 (>= 5.2.0), libqt5xmlpatterns5 (>= 5.2.0), libstdc++6 (>= 4.6), xpdf
|
||||||
Description: Pattern making program.
|
Description: Pattern making program.
|
||||||
Valentina is a cross-platform patternmaking program which allows designers
|
Valentina is a cross-platform patternmaking program which allows designers
|
||||||
to create and model patterns of clothing. This software allows pattern
|
to create and model patterns of clothing. This software allows pattern
|
||||||
|
|
14
dist/rpm/valentina.spec
vendored
14
dist/rpm/valentina.spec
vendored
|
@ -8,7 +8,7 @@ Requires(postun): desktop-file-utils
|
||||||
|
|
||||||
# Fedora specifics
|
# Fedora specifics
|
||||||
%if 0%{?fedora_version} > 0
|
%if 0%{?fedora_version} > 0
|
||||||
BuildRequires: qt5-qtbase-devel >= 5.0.0
|
BuildRequires: qt5-qtbase-devel >= 5.2.0
|
||||||
BuildRequires: pkgconfig(Qt5Svg)
|
BuildRequires: pkgconfig(Qt5Svg)
|
||||||
BuildRequires: pkgconfig(Qt5Core)
|
BuildRequires: pkgconfig(Qt5Core)
|
||||||
BuildRequires: pkgconfig(Qt5Gui)
|
BuildRequires: pkgconfig(Qt5Gui)
|
||||||
|
@ -16,13 +16,13 @@ BuildRequires: pkgconfig(Qt5Network)
|
||||||
BuildRequires: pkgconfig(Qt5PrintSupport)
|
BuildRequires: pkgconfig(Qt5PrintSupport)
|
||||||
BuildRequires: pkgconfig(Qt5Widgets)
|
BuildRequires: pkgconfig(Qt5Widgets)
|
||||||
BuildRequires: pkgconfig(Qt5Xml)
|
BuildRequires: pkgconfig(Qt5Xml)
|
||||||
BuildRequires: qt5-qtxmlpatterns-devel >= 5.0.0
|
BuildRequires: qt5-qtxmlpatterns-devel >= 5.2.0
|
||||||
BuildRequires: qt5-qtsvg-devel >= 5.0.0
|
BuildRequires: qt5-qtsvg-devel >= 5.2.0
|
||||||
BuildRequires: qt5-qttools-devel >= 5.0.0
|
BuildRequires: qt5-qttools-devel >= 5.2.0
|
||||||
|
|
||||||
Requires: qt5-qtsvg >= 5.0.0
|
Requires: qt5-qtsvg >= 5.2.0
|
||||||
Requires: qt5-qtbase-gui >= 5.0.0
|
Requires: qt5-qtbase-gui >= 5.2.0
|
||||||
Requires: qt5-qtxmlpatterns >= 5.0.0
|
Requires: qt5-qtxmlpatterns >= 5.2.0
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
# SUSE Specifics
|
# SUSE Specifics
|
||||||
|
|
|
@ -45,7 +45,7 @@ int main(int argc, char *argv[])
|
||||||
Q_INIT_RESOURCE(schema);
|
Q_INIT_RESOURCE(schema);
|
||||||
Q_INIT_RESOURCE(flags);
|
Q_INIT_RESOURCE(flags);
|
||||||
|
|
||||||
QT_REQUIRE_VERSION(argc, argv, "5.0.0")
|
QT_REQUIRE_VERSION(argc, argv, "5.2.0")
|
||||||
|
|
||||||
qt_qhash_seed.store(0); // Lock producing random attribute order in XML
|
qt_qhash_seed.store(0); // Lock producing random attribute order in XML
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ int main(int argc, char *argv[])
|
||||||
Q_INIT_RESOURCE(icons);
|
Q_INIT_RESOURCE(icons);
|
||||||
Q_INIT_RESOURCE(toolicon);
|
Q_INIT_RESOURCE(toolicon);
|
||||||
|
|
||||||
QT_REQUIRE_VERSION(argc, argv, "5.0.0")
|
QT_REQUIRE_VERSION(argc, argv, "5.2.0")
|
||||||
|
|
||||||
qt_qhash_seed.store(0); // Lock producing random attribute order in XML
|
qt_qhash_seed.store(0); // Lock producing random attribute order in XML
|
||||||
|
|
||||||
|
|
|
@ -1,423 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/
|
|
||||||
**
|
|
||||||
** This file is part of the QtCore module of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:LGPL$
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** 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, Nokia gives you certain additional
|
|
||||||
** rights. These rights are described in the Nokia 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.
|
|
||||||
**
|
|
||||||
** Other Usage
|
|
||||||
** Alternatively, this file may be used in accordance with the terms and
|
|
||||||
** conditions contained in a signed written agreement between you and Nokia.
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "qsavefile.h"
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
|
||||||
#include "qsavefile_p.h"
|
|
||||||
|
|
||||||
#include <QtCore/QFileInfo>
|
|
||||||
#include <QtCore/QTemporaryFile>
|
|
||||||
|
|
||||||
QSaveFilePrivate::QSaveFilePrivate()
|
|
||||||
: fileName(), tempFile(0), error(QFile::NoError)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QSaveFilePrivate::~QSaveFilePrivate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\class QSaveFile
|
|
||||||
\brief The QSaveFile class provides an interface for safely writing to files.
|
|
||||||
|
|
||||||
\ingroup io
|
|
||||||
|
|
||||||
\reentrant
|
|
||||||
|
|
||||||
QSaveFile is an I/O device for writing text and binary files, without losing
|
|
||||||
existing data if the writing operation fails.
|
|
||||||
|
|
||||||
While writing, the contents will be written to a temporary file, and if
|
|
||||||
no error happened, commit() will move it to the final file. This ensures that
|
|
||||||
no data at the final file is lost in case an error happens while writing,
|
|
||||||
and no partially-written file is ever present at the final location. Always
|
|
||||||
use QSaveFile when saving entire documents to disk.
|
|
||||||
|
|
||||||
QSaveFile automatically detects errors while writing, such as the full partition
|
|
||||||
situation, where write() cannot write all the bytes. It will remember that
|
|
||||||
an error happened, and will discard the temporary file in commit().
|
|
||||||
|
|
||||||
Much like with QFile, the file is opened with open(). Data is usually read
|
|
||||||
and written using QDataStream or QTextStream, but you can also call the
|
|
||||||
QIODevice-inherited functions read(), readLine(), readAll(), write().
|
|
||||||
|
|
||||||
Unlike QFile, calling close() is not allowed. commit() replaces it. If commit()
|
|
||||||
was not called and the QSaveFile instance is destroyed, the temporary file is
|
|
||||||
discarded.
|
|
||||||
|
|
||||||
\sa QTextStream, QDataStream, QFileInfo, QDir, QFile, QTemporaryFile
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\internal
|
|
||||||
*/
|
|
||||||
QSaveFile::QSaveFile()
|
|
||||||
: QIODevice(), d_ptr(new QSaveFilePrivate)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
/*!
|
|
||||||
Constructs a new file object with the given \a parent.
|
|
||||||
*/
|
|
||||||
QSaveFile::QSaveFile(QObject *parent)
|
|
||||||
: QIODevice(parent), d_ptr(new QSaveFilePrivate)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
/*!
|
|
||||||
Constructs a new file object to represent the file with the given \a name.
|
|
||||||
*/
|
|
||||||
QSaveFile::QSaveFile(const QString &name)
|
|
||||||
: QIODevice(0), d_ptr(new QSaveFilePrivate)
|
|
||||||
{
|
|
||||||
Q_D(QSaveFile);
|
|
||||||
d->fileName = name;
|
|
||||||
}
|
|
||||||
/*!
|
|
||||||
Constructs a new file object with the given \a parent to represent the
|
|
||||||
file with the specified \a name.
|
|
||||||
*/
|
|
||||||
QSaveFile::QSaveFile(const QString &name, QObject *parent)
|
|
||||||
: QIODevice(parent), d_ptr(new QSaveFilePrivate)
|
|
||||||
{
|
|
||||||
Q_D(QSaveFile);
|
|
||||||
d->fileName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Destroys the file object, discarding the saved contents unless commit() was called.
|
|
||||||
*/
|
|
||||||
QSaveFile::~QSaveFile()
|
|
||||||
{
|
|
||||||
Q_D(QSaveFile);
|
|
||||||
if (d->tempFile) {
|
|
||||||
d->tempFile->setAutoRemove(true);
|
|
||||||
delete d->tempFile;
|
|
||||||
}
|
|
||||||
QIODevice::close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns false since temporary files support random access.
|
|
||||||
|
|
||||||
\sa QIODevice::isSequential()
|
|
||||||
*/
|
|
||||||
bool QSaveFile::isSequential() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns the file error status.
|
|
||||||
|
|
||||||
The I/O device status returns an error code. For example, if open()
|
|
||||||
returns false, or a read/write operation returns -1, this function can
|
|
||||||
be called to find out the reason why the operation failed.
|
|
||||||
|
|
||||||
Unlike QFile which clears the error on the next operation, QSaveFile remembers
|
|
||||||
the error until the file is closed, in order to discard the file contents in close().
|
|
||||||
|
|
||||||
\sa unsetError()
|
|
||||||
*/
|
|
||||||
|
|
||||||
QFile::FileError QSaveFile::error() const
|
|
||||||
{
|
|
||||||
return d_func()->error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Sets the file's error to QFile::NoError.
|
|
||||||
|
|
||||||
This will make QSaveFile forget that an error happened during saving, so you
|
|
||||||
probably don't want to call this, unless you're really sure that you want to
|
|
||||||
save the file anyway.
|
|
||||||
|
|
||||||
\sa error()
|
|
||||||
*/
|
|
||||||
void QSaveFile::unsetError()
|
|
||||||
{
|
|
||||||
d_func()->error = QFile::NoError;
|
|
||||||
setErrorString(QString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns the name set by setFileName() or to the QSaveFile
|
|
||||||
constructor.
|
|
||||||
|
|
||||||
\sa setFileName()
|
|
||||||
*/
|
|
||||||
QString QSaveFile::fileName() const
|
|
||||||
{
|
|
||||||
return d_func()->fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Sets the \a name of the file. The name can have no path, a
|
|
||||||
relative path, or an absolute path.
|
|
||||||
|
|
||||||
\sa QFile::setFileName(), fileName()
|
|
||||||
*/
|
|
||||||
void QSaveFile::setFileName(const QString &name)
|
|
||||||
{
|
|
||||||
d_func()->fileName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Opens the file using OpenMode \a mode, returning true if successful;
|
|
||||||
otherwise false.
|
|
||||||
|
|
||||||
Important: the \a mode must be QIODevice::WriteOnly.
|
|
||||||
It may also have additional flags, such as QIODevice::Text and QIODevice::Unbuffered.
|
|
||||||
|
|
||||||
QIODevice::ReadWrite and QIODevice::Append are not supported at the moment.
|
|
||||||
|
|
||||||
\sa QIODevice::OpenMode, setFileName()
|
|
||||||
*/
|
|
||||||
bool QSaveFile::open(OpenMode mode)
|
|
||||||
{
|
|
||||||
Q_D(QSaveFile);
|
|
||||||
if (isOpen()) {
|
|
||||||
qWarning("QSaveFile::open: File (%s) already open", qPrintable(fileName()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
unsetError();
|
|
||||||
if ((mode & (ReadOnly | WriteOnly)) == 0) {
|
|
||||||
qWarning("QSaveFile::open: Open mode not specified");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// In the future we could implement Append and ReadWrite by copying from the existing file to the temp file...
|
|
||||||
if ((mode & ReadOnly) || (mode & Append)) {
|
|
||||||
qWarning("QSaveFile::open: Unsupported open mode %d", int(mode));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if existing file is writable
|
|
||||||
QFileInfo existingFile(d->fileName);
|
|
||||||
if (existingFile.exists() && !existingFile.isWritable()) {
|
|
||||||
d->error = QFile::WriteError;
|
|
||||||
setErrorString(QSaveFile::tr("Existing file %1 is not writable").arg(d->fileName));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
d->tempFile = new QTemporaryFile;
|
|
||||||
d->tempFile->setAutoRemove(false);
|
|
||||||
d->tempFile->setFileTemplate(d->fileName);
|
|
||||||
if (!d->tempFile->open()) {
|
|
||||||
d->error = d->tempFile->error();
|
|
||||||
setErrorString(d->tempFile->errorString());
|
|
||||||
delete d->tempFile;
|
|
||||||
d->tempFile = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
QIODevice::open(mode);
|
|
||||||
if (existingFile.exists())
|
|
||||||
d->tempFile->setPermissions(existingFile.permissions());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\reimp
|
|
||||||
Cannot be called.
|
|
||||||
Call commit() instead.
|
|
||||||
*/
|
|
||||||
Q_NORETURN void QSaveFile::close()
|
|
||||||
{
|
|
||||||
qFatal("QSaveFile::close called");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Commits the changes to disk, if all previous writes were successful.
|
|
||||||
|
|
||||||
It is mandatory to call this at the end of the saving operation, otherwise the file will be
|
|
||||||
discarded.
|
|
||||||
|
|
||||||
If an error happened during writing, deletes the temporary file and returns false.
|
|
||||||
Otherwise, renames it to the final fileName and returns true on success.
|
|
||||||
Finally, closes the device.
|
|
||||||
|
|
||||||
\sa cancelWriting()
|
|
||||||
*/
|
|
||||||
bool QSaveFile::commit()
|
|
||||||
{
|
|
||||||
Q_D(QSaveFile);
|
|
||||||
if (!d->tempFile)
|
|
||||||
return false;
|
|
||||||
Q_ASSERT(isOpen());
|
|
||||||
QIODevice::close(); // flush and close
|
|
||||||
if (d->error != QFile::NoError) {
|
|
||||||
d->tempFile->remove();
|
|
||||||
unsetError();
|
|
||||||
delete d->tempFile;
|
|
||||||
d->tempFile = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->tempFile->close();
|
|
||||||
|
|
||||||
if (!d->tempFile->rename(d->fileName)) {
|
|
||||||
d->error = d->tempFile->error();
|
|
||||||
setErrorString(d->tempFile->errorString());
|
|
||||||
d->tempFile->remove();
|
|
||||||
delete d->tempFile;
|
|
||||||
d->tempFile = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
delete d->tempFile;
|
|
||||||
d->tempFile = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Sets an error code so that commit() discards the temporary file.
|
|
||||||
|
|
||||||
Further write operations are possible after calling this method, but none
|
|
||||||
of it will have any effect, the written file will be discarded.
|
|
||||||
|
|
||||||
\sa commit()
|
|
||||||
*/
|
|
||||||
void QSaveFile::cancelWriting()
|
|
||||||
{
|
|
||||||
if (!isOpen())
|
|
||||||
return;
|
|
||||||
d_func()->error = QFile::WriteError;
|
|
||||||
setErrorString(QSaveFile::tr("Writing canceled by application"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns the size of the file.
|
|
||||||
\sa QFile::size()
|
|
||||||
*/
|
|
||||||
qint64 QSaveFile::size() const
|
|
||||||
{
|
|
||||||
Q_D(const QSaveFile);
|
|
||||||
return d->tempFile ? d->tempFile->size() : qint64(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\reimp
|
|
||||||
*/
|
|
||||||
qint64 QSaveFile::pos() const
|
|
||||||
{
|
|
||||||
Q_D(const QSaveFile);
|
|
||||||
return d->tempFile ? d->tempFile->pos() : qint64(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\reimp
|
|
||||||
*/
|
|
||||||
bool QSaveFile::seek(qint64 offset)
|
|
||||||
{
|
|
||||||
Q_D(QSaveFile);
|
|
||||||
return d->tempFile ? d->tempFile->seek(offset) : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\reimp
|
|
||||||
*/
|
|
||||||
bool QSaveFile::atEnd() const
|
|
||||||
{
|
|
||||||
Q_D(const QSaveFile);
|
|
||||||
return d->tempFile ? d->tempFile->atEnd() : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Flushes any buffered data to the file. Returns true if successful;
|
|
||||||
otherwise returns false.
|
|
||||||
*/
|
|
||||||
bool QSaveFile::flush()
|
|
||||||
{
|
|
||||||
Q_D(QSaveFile);
|
|
||||||
if (d->tempFile) {
|
|
||||||
if (!d->tempFile->flush()) {
|
|
||||||
d->error = d->tempFile->error();
|
|
||||||
setErrorString(d->tempFile->errorString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns the file handle of the temporary file.
|
|
||||||
|
|
||||||
\sa QFile::handle()
|
|
||||||
*/
|
|
||||||
int QSaveFile::handle() const
|
|
||||||
{
|
|
||||||
Q_D(const QSaveFile);
|
|
||||||
return d->tempFile ? d->tempFile->handle() : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\reimp
|
|
||||||
*/
|
|
||||||
qint64 QSaveFile::readData(char *data, qint64 maxlen)
|
|
||||||
{
|
|
||||||
Q_D(QSaveFile);
|
|
||||||
return d->tempFile ? d->tempFile->read(data, maxlen) : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\reimp
|
|
||||||
*/
|
|
||||||
qint64 QSaveFile::writeData(const char *data, qint64 len)
|
|
||||||
{
|
|
||||||
Q_D(QSaveFile);
|
|
||||||
if (!d->tempFile)
|
|
||||||
return -1;
|
|
||||||
const qint64 written = d->tempFile->write(data, len);
|
|
||||||
if (written != len) {
|
|
||||||
d->error = QFile::WriteError;
|
|
||||||
setErrorString(QSaveFile::tr("Partial write. Partition full?"));
|
|
||||||
}
|
|
||||||
return written;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\reimp
|
|
||||||
*/
|
|
||||||
qint64 QSaveFile::readLineData(char *data, qint64 maxlen)
|
|
||||||
{
|
|
||||||
Q_D(QSaveFile);
|
|
||||||
return d->tempFile ? d->tempFile->readLine(data, maxlen) : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
|
|
@ -1,109 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/
|
|
||||||
**
|
|
||||||
** This file is part of the QtCore module of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:LGPL$
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** 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, Nokia gives you certain additional
|
|
||||||
** rights. These rights are described in the Nokia 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.
|
|
||||||
**
|
|
||||||
** Other Usage
|
|
||||||
** Alternatively, this file may be used in accordance with the terms and
|
|
||||||
** conditions contained in a signed written agreement between you and Nokia.
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef QSAVEFILE_H
|
|
||||||
#define QSAVEFILE_H
|
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
|
||||||
|
|
||||||
#include <QtCore/QFile>
|
|
||||||
#include <QtCore/QString>
|
|
||||||
|
|
||||||
#ifdef open
|
|
||||||
#error qsavefile.h must be included before any header file that defines open
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class QSaveFilePrivate;
|
|
||||||
|
|
||||||
class QSaveFile : public QIODevice
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_DECLARE_PRIVATE(QSaveFile)
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QSaveFile();
|
|
||||||
explicit QSaveFile(const QString &name);
|
|
||||||
explicit QSaveFile(QObject *parent);
|
|
||||||
QSaveFile(const QString &name, QObject *parent);
|
|
||||||
~QSaveFile();
|
|
||||||
|
|
||||||
QFile::FileError error() const;
|
|
||||||
void unsetError();
|
|
||||||
|
|
||||||
QString fileName() const;
|
|
||||||
void setFileName(const QString &name);
|
|
||||||
|
|
||||||
bool isSequential() const;
|
|
||||||
|
|
||||||
virtual bool open(OpenMode flags);
|
|
||||||
bool commit();
|
|
||||||
|
|
||||||
void cancelWriting();
|
|
||||||
|
|
||||||
qint64 size() const;
|
|
||||||
qint64 pos() const;
|
|
||||||
bool seek(qint64 offset);
|
|
||||||
bool atEnd() const;
|
|
||||||
bool flush();
|
|
||||||
|
|
||||||
bool resize(qint64 sz);
|
|
||||||
|
|
||||||
int handle() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
qint64 readData(char *data, qint64 maxlen);
|
|
||||||
qint64 writeData(const char *data, qint64 len);
|
|
||||||
qint64 readLineData(char *data, qint64 maxlen);
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual void close();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Q_DISABLE_COPY(QSaveFile)
|
|
||||||
|
|
||||||
QSaveFilePrivate* const d_ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // // QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
|
||||||
#endif // QSAVEFILE_H
|
|
|
@ -1,78 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/
|
|
||||||
**
|
|
||||||
** This file is part of the QtCore module of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:LGPL$
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** 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, Nokia gives you certain additional
|
|
||||||
** rights. These rights are described in the Nokia 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.
|
|
||||||
**
|
|
||||||
** Other Usage
|
|
||||||
** Alternatively, this file may be used in accordance with the terms and
|
|
||||||
** conditions contained in a signed written agreement between you and Nokia.
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef QSAVEFILE_P_H
|
|
||||||
#define QSAVEFILE_P_H
|
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
|
||||||
|
|
||||||
//
|
|
||||||
// W A R N I N G
|
|
||||||
// -------------
|
|
||||||
//
|
|
||||||
// This file is not part of the Qt API. It exists purely as an
|
|
||||||
// implementation detail. This header file may change from version to
|
|
||||||
// version without notice, or even be removed.
|
|
||||||
//
|
|
||||||
// We mean it.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <QtCore/QTemporaryFile>
|
|
||||||
|
|
||||||
class QSaveFilePrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QSaveFilePrivate();
|
|
||||||
~QSaveFilePrivate();
|
|
||||||
|
|
||||||
QString fileName;
|
|
||||||
QTemporaryFile *tempFile;
|
|
||||||
|
|
||||||
QFile::FileError error;
|
|
||||||
private:
|
|
||||||
Q_DISABLE_COPY(QSaveFilePrivate)
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
|
||||||
#endif // QSAVEFILE_P_H
|
|
||||||
|
|
|
@ -37,20 +37,9 @@ HEADERS += \
|
||||||
$$PWD/diagnostic.h
|
$$PWD/diagnostic.h
|
||||||
|
|
||||||
# Qt's versions
|
# Qt's versions
|
||||||
# 5.0.0, 5.0.1, 5.0.2
|
|
||||||
# 5.1.0, 5.1.1
|
|
||||||
# 5.2.0, 5.2.1
|
# 5.2.0, 5.2.1
|
||||||
# 5.3.0, 5.3.1, 5.3.2
|
# 5.3.0, 5.3.1, 5.3.2
|
||||||
|
|
||||||
contains(QT_VERSION, ^5\\.0\\.[0-2]$) { # Since Qt 5.1.0
|
|
||||||
HEADERS += \
|
|
||||||
$$PWD/backport/qsavefile.h \
|
|
||||||
$$PWD/backport/qsavefile_p.h
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
$$PWD/backport/qsavefile.cpp
|
|
||||||
}
|
|
||||||
|
|
||||||
contains(QT_VERSION, ^5\\.[0-1]\\.[0-2]$) { # Since Qt 5.2.0
|
contains(QT_VERSION, ^5\\.[0-1]\\.[0-2]$) { # Since Qt 5.2.0
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/backport/qcommandlineoption.h \
|
$$PWD/backport/qcommandlineoption.h \
|
||||||
|
|
Loading…
Reference in New Issue
Block a user