diff --git a/Valentina.pro b/Valentina.pro index 7134680c9..f0422e73b 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -1,9 +1,9 @@ include(Valentina.pri) #version check qt -!minQtVersion(5, 2, 1) { +!minQtVersion(5, 0, 2) { message("Cannot build Valentina with Qt version $${QT_VERSION}.") - error("Use at least Qt 5.2.1.") + error("Use at least Qt 5.0.2.") } TEMPLATE = subdirs diff --git a/src/app/app.pro b/src/app/app.pro index cd2f3978d..b69041e3e 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -43,6 +43,7 @@ include(widgets/widgets.pri) include(xml/xml.pri) include(undocommands/undocommands.pri) include(visualization/visualization.pri) +include(core/core.pri) INCLUDEPATH += "$${PWD}/widgets" diff --git a/src/app/container/calculator.cpp b/src/app/container/calculator.cpp index e6653a7d7..4bd488acb 100644 --- a/src/app/container/calculator.cpp +++ b/src/app/container/calculator.cpp @@ -29,7 +29,7 @@ #include "calculator.h" #include #include -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include "vcontainer.h" using namespace qmu; diff --git a/src/app/container/varclength.cpp b/src/app/container/varclength.cpp index cbd815e1d..2015f14c7 100644 --- a/src/app/container/varclength.cpp +++ b/src/app/container/varclength.cpp @@ -28,7 +28,7 @@ #include "varclength.h" #include "../geometry/vabstractcurve.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- VArcLength::VArcLength() diff --git a/src/app/container/vcontainer.cpp b/src/app/container/vcontainer.cpp index 3d3536316..027cf3308 100644 --- a/src/app/container/vcontainer.cpp +++ b/src/app/container/vcontainer.cpp @@ -28,7 +28,7 @@ #include "vcontainer.h" #include -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include "../geometry/varc.h" #include "../geometry/vsplinepath.h" #include diff --git a/src/app/container/vcurvelength.cpp b/src/app/container/vcurvelength.cpp index 1709066e5..9205e7452 100644 --- a/src/app/container/vcurvelength.cpp +++ b/src/app/container/vcurvelength.cpp @@ -28,7 +28,7 @@ #include "vcurvelength.h" #include "vcurvelength_p.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include "../geometry/vabstractcurve.h" //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/container/vformula.cpp b/src/app/container/vformula.cpp index 222ae5d75..edfc8a96c 100644 --- a/src/app/container/vformula.cpp +++ b/src/app/container/vformula.cpp @@ -29,7 +29,7 @@ #include "vformula.h" #include "../container/calculator.h" #include "../container/vcontainer.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" //VFormula //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/container/vlineangle.cpp b/src/app/container/vlineangle.cpp index 10a93f306..aceba1c51 100644 --- a/src/app/container/vlineangle.cpp +++ b/src/app/container/vlineangle.cpp @@ -29,7 +29,7 @@ #include "vlineangle.h" #include "vlineangle_p.h" #include "../geometry/vpointf.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include diff --git a/src/app/container/vlinelength.cpp b/src/app/container/vlinelength.cpp index cc9b9ea14..7146b3f23 100644 --- a/src/app/container/vlinelength.cpp +++ b/src/app/container/vlinelength.cpp @@ -29,7 +29,7 @@ #include "vlinelength.h" #include "vlinelength_p.h" #include "../geometry/vpointf.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include diff --git a/src/app/container/vmeasurement.cpp b/src/app/container/vmeasurement.cpp index bb6ceceaa..f71921b4e 100644 --- a/src/app/container/vmeasurement.cpp +++ b/src/app/container/vmeasurement.cpp @@ -28,7 +28,7 @@ #include "vmeasurement.h" #include "vmeasurement_p.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include "../xml/vabstractmeasurements.h" //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/container/vsplinelength.cpp b/src/app/container/vsplinelength.cpp index 45d277b10..2cb194c7e 100644 --- a/src/app/container/vsplinelength.cpp +++ b/src/app/container/vsplinelength.cpp @@ -28,7 +28,7 @@ #include "vsplinelength.h" #include "../geometry/vabstractcurve.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- VSplineLength::VSplineLength() diff --git a/src/app/container/vvariable.cpp b/src/app/container/vvariable.cpp index fa4ce0c00..83589a89c 100644 --- a/src/app/container/vvariable.cpp +++ b/src/app/container/vvariable.cpp @@ -28,7 +28,7 @@ #include "vvariable.h" #include "vvariable_p.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include "../xml/vabstractmeasurements.h" //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/core/core.pri b/src/app/core/core.pri new file mode 100644 index 000000000..31aa5f04b --- /dev/null +++ b/src/app/core/core.pri @@ -0,0 +1,13 @@ +HEADERS += \ + core/vapplication.h \ + core/vtranslation.h \ + core/undoevent.h \ + core/qcommandlineoption.h \ + core/qcommandlineparser.h + +SOURCES += \ + core/vapplication.cpp \ + core/vtranslation.cpp \ + core/undoevent.cpp \ + core/qcommandlineoption.cpp \ + core/qcommandlineparser.cpp diff --git a/src/app/core/qcommandlineoption.cpp b/src/app/core/qcommandlineoption.cpp new file mode 100644 index 000000000..b0bcd15b0 --- /dev/null +++ b/src/app/core/qcommandlineoption.cpp @@ -0,0 +1,311 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Laszlo Papp +** Copyright (C) 2013 David Faure +** 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$ +** +****************************************************************************/ + +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 1) + +#include "qcommandlineoption.h" + +#include + +class QCommandLineOptionPrivate : public QSharedData +{ +public: + inline QCommandLineOptionPrivate() + { } + + void setNames(const QStringList &nameList); + + //! The list of names used for this option. + QStringList names; + + //! The documentation name for the value, if one is expected + //! Example: "-o " means valueName == "file" + QString valueName; + + //! The description used for this option. + QString description; + + //! The list of default values used for this option. + QStringList defaultValues; +}; + +/*! + \since 5.2 + \class QCommandLineOption + \brief The QCommandLineOption class defines a possible command-line option. + \inmodule QtCore + \ingroup shared + \ingroup tools + + This class is used to describe an option on the command line. It allows + different ways of defining the same option with multiple aliases possible. + It is also used to describe how the option is used - it may be a flag (e.g. \c{-v}) + or take an argument (e.g. \c{-o file}). + + Examples: + \snippet code/src_corelib_tools_qcommandlineoption.cpp 0 + + \sa QCommandLineParser +*/ + +/*! + Constructs a command line option object with the given arguments. + + The name of the option is set to \a name. + The name can be either short or long. If the name is one character in + length, it is considered a short name. Option names must not be empty, + must not start with a dash or a slash character, must not contain a \c{=} + and cannot be repeated. + + The description is set to \a description. It is customary to add a "." + at the end of the description. + + In addition, the \a valueName can be set if the option expects a value. + The default value for the option is set to \a defaultValue. + + \sa setDescription(), setValueName(), setDefaultValues() +*/ +QCommandLineOption::QCommandLineOption(const QString &name, const QString &description, + const QString &valueName, + const QString &defaultValue) + : d(new QCommandLineOptionPrivate) +{ + d->setNames(QStringList(name)); + setValueName(valueName); + setDescription(description); + setDefaultValue(defaultValue); +} + +/*! + Constructs a command line option object with the given arguments. + + This overload allows to set multiple names for the option, for instance + \c{o} and \c{output}. + + The names of the option are set to \a names. + The names can be either short or long. Any name in the list that is one + character in length is a short name. Option names must not be empty, + must not start with a dash or a slash character, must not contain a \c{=} + and cannot be repeated. + + The description is set to \a description. It is customary to add a "." + at the end of the description. + + In addition, the \a valueName can be set if the option expects a value. + The default value for the option is set to \a defaultValue. + + \sa setDescription(), setValueName(), setDefaultValues() +*/ +QCommandLineOption::QCommandLineOption(const QStringList &names, const QString &description, + const QString &valueName, + const QString &defaultValue) + : d(new QCommandLineOptionPrivate) +{ + d->setNames(names); + setValueName(valueName); + setDescription(description); + setDefaultValue(defaultValue); +} + +/*! + Constructs a QCommandLineOption object that is a copy of the QCommandLineOption + object \a other. + + \sa operator=() +*/ +QCommandLineOption::QCommandLineOption(const QCommandLineOption &other) + : d(other.d) +{ +} + +/*! + Destroys the command line option object. +*/ +QCommandLineOption::~QCommandLineOption() +{ +} + +/*! + Makes a copy of the \a other object and assigns it to this QCommandLineOption + object. +*/ +QCommandLineOption &QCommandLineOption::operator=(const QCommandLineOption &other) +{ + d = other.d; + return *this; +} + +/*! + Returns the names set for this option. + */ +QStringList QCommandLineOption::names() const +{ + return d->names; +} + +void QCommandLineOptionPrivate::setNames(const QStringList &nameList) +{ + QStringList newNames; + newNames.reserve(nameList.size()); + if (nameList.isEmpty()) + qWarning("QCommandLineOption: Options must have at least one name"); + Q_FOREACH (const QString &name, nameList) { + if (name.isEmpty()) { + qWarning("QCommandLineOption: Option names cannot be empty"); + } else { + const QChar c = name.at(0); + if (c == QLatin1Char('-')) + qWarning("QCommandLineOption: Option names cannot start with a '-'"); + else if (c == QLatin1Char('/')) + qWarning("QCommandLineOption: Option names cannot start with a '/'"); + else if (name.contains(QLatin1Char('='))) + qWarning("QCommandLineOption: Option names cannot contain a '='"); + else + newNames.append(name); + } + } + // commit + names.swap(newNames); +} + +/*! + Sets the name of the expected value, for the documentation, to \a valueName. + + Options without a value assigned have a boolean-like behavior: + either the user specifies --option or they don't. + + Options with a value assigned need to set a name for the expected value, + for the documentation of the option in the help output. An option with names \c{o} and \c{output}, + and a value name of \c{file} will appear as \c{-o, --output }. + + Call QCommandLineParser::argument() if you expect the option to be present + only once, and QCommandLineParser::arguments() if you expect that option + to be present multiple times. + + \sa valueName() + */ +void QCommandLineOption::setValueName(const QString &valueName) +{ + d->valueName = valueName; +} + +/*! + Returns the name of the expected value. + + If empty, the option doesn't take a value. + + \sa setValueName() + */ +QString QCommandLineOption::valueName() const +{ + return d->valueName; +} + +/*! + Sets the description used for this option to \a description. + + It is customary to add a "." at the end of the description. + + The description is used by QCommandLineParser::showHelp(). + + \sa description() + */ +void QCommandLineOption::setDescription(const QString &description) +{ + d->description = description; +} + +/*! + Returns the description set for this option. + + \sa setDescription() + */ +QString QCommandLineOption::description() const +{ + return d->description; +} + +/*! + Sets the default value used for this option to \a defaultValue. + + The default value is used if the user of the application does not specify + the option on the command line. + + If \a defaultValue is empty, the option has no default values. + + \sa defaultValues() setDefaultValues() + */ +void QCommandLineOption::setDefaultValue(const QString &defaultValue) +{ + QStringList newDefaultValues; + if (!defaultValue.isEmpty()) { + newDefaultValues.reserve(1); + newDefaultValues << defaultValue; + } + // commit: + d->defaultValues.swap(newDefaultValues); +} + +/*! + Sets the list of default values used for this option to \a defaultValues. + + The default values are used if the user of the application does not specify + the option on the command line. + + \sa defaultValues() setDefaultValue() + */ +void QCommandLineOption::setDefaultValues(const QStringList &defaultValues) +{ + d->defaultValues = defaultValues; +} + +/*! + Returns the default values set for this option. + + \sa setDefaultValues() + */ +QStringList QCommandLineOption::defaultValues() const +{ + return d->defaultValues; +} + +#endif //QT_VERSION < QT_VERSION_CHECK(5, 2, 1) diff --git a/src/app/core/qcommandlineoption.h b/src/app/core/qcommandlineoption.h new file mode 100644 index 000000000..32476e7ee --- /dev/null +++ b/src/app/core/qcommandlineoption.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Laszlo Papp +** 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 QCOMMANDLINEOPTION_H +#define QCOMMANDLINEOPTION_H + +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 1) + +#include +#include + +class QCommandLineOptionPrivate; + +class QCommandLineOption +{ +public: + explicit QCommandLineOption(const QString &name, const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString()); + explicit QCommandLineOption(const QStringList &names, const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString()); + QCommandLineOption(const QCommandLineOption &other); + + ~QCommandLineOption(); + + QCommandLineOption &operator=(const QCommandLineOption &other); + + QStringList names() const; + + void setValueName(const QString &name); + QString valueName() const; + + void setDescription(const QString &description); + QString description() const; + + void setDefaultValue(const QString &defaultValue); + void setDefaultValues(const QStringList &defaultValues); + QStringList defaultValues() const; + +private: + QSharedDataPointer d; +}; + +#endif //QT_VERSION < QT_VERSION_CHECK(5, 2, 1) + +#endif // QCOMMANDLINEOPTION_H diff --git a/src/app/core/qcommandlineparser.cpp b/src/app/core/qcommandlineparser.cpp new file mode 100644 index 000000000..39f6c1fb5 --- /dev/null +++ b/src/app/core/qcommandlineparser.cpp @@ -0,0 +1,948 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Laszlo Papp +** Copyright (C) 2013 David Faure +** 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$ +** +****************************************************************************/ + +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 1) + +#include "qcommandlineparser.h" + +#include +#include +#include +#include +#include + +typedef QHash NameHash_t; + +class QCommandLineParserPrivate +{ +public: + inline QCommandLineParserPrivate() + : singleDashWordOptionMode(QCommandLineParser::ParseAsCompactedShortOptions), + builtinVersionOption(false), + builtinHelpOption(false), + needsParsing(true) + { } + + bool parse(const QStringList &args); + void checkParsed(const char *method); + QStringList aliases(const QString &name) const; + QString helpText() const; + bool registerFoundOption(const QString &optionName); + bool parseOptionValue(const QString &optionName, const QString &argument, + QStringList::const_iterator *argumentIterator, + QStringList::const_iterator argsEnd); + + //! Error text set when parse() returns false + QString errorText; + + //! The command line options used for parsing + QList commandLineOptionList; + + //! Hash mapping option names to their offsets in commandLineOptionList and optionArgumentList. + NameHash_t nameHash; + + //! Option values found (only for options with a value) + QHash optionValuesHash; + + //! Names of options found on the command line. + QStringList optionNames; + + //! Arguments which did not belong to any option. + QStringList positionalArgumentList; + + //! Names of options which were unknown. + QStringList unknownOptionNames; + + //! Application description + QString description; + + //! Documentation for positional arguments + struct PositionalArgumentDefinition + { + QString name; + QString description; + QString syntax; + }; + QVector positionalArgumentDefinitions; + + //! The parsing mode for "-abc" + QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode; + + //! Whether addVersionOption was called + bool builtinVersionOption; + + //! Whether addHelpOption was called + bool builtinHelpOption; + + //! True if parse() needs to be called + bool needsParsing; +}; + +QStringList QCommandLineParserPrivate::aliases(const QString &optionName) const +{ + const NameHash_t::const_iterator it = nameHash.find(optionName); + if (it == nameHash.end()) { + qWarning("QCommandLineParser: option not defined: \"%s\"", qPrintable(optionName)); + return QStringList(); + } + return commandLineOptionList.at(*it).names(); +} + +/*! + \since 5.2 + \class QCommandLineParser + \inmodule QtCore + \ingroup tools + + \brief The QCommandLineParser class provides a means for handling the + command line options. + + QCoreApplication provides the command-line arguments as a simple list of strings. + QCommandLineParser provides the ability to define a set of options, parse the + command-line arguments, and store which options have actually been used, as + well as option values. + + Any argument that isn't an option (i.e. doesn't start with a \c{-}) is stored + as a "positional argument". + + The parser handles short names, long names, more than one name for the same + option, and option values. + + Options on the command line are recognized as starting with a single or + double \c{-} character(s). + The option \c{-} (single dash alone) is a special case, often meaning standard + input, and not treated as an option. The parser will treat everything after the + option \c{--} (double dash) as positional arguments. + + Short options are single letters. The option \c{v} would be specified by + passing \c{-v} on the command line. In the default parsing mode, short options + can be written in a compact form, for instance \c{-abc} is equivalent to \c{-a -b -c}. + The parsing mode for can be set to ParseAsLongOptions, in which case \c{-abc} + will be parsed as the long option \c{abc}. + + Long options are more than one letter long and cannot be compacted together. + The long option \c{verbose} would be passed as \c{--verbose} or \c{-verbose}. + + Passing values to options can be done using the assignment operator: \c{-v=value} + \c{--verbose=value}, or a space: \c{-v value} \c{--verbose value}, i.e. the next + argument is used as value (even if it starts with a \c{-}). + + The parser does not support optional values - if an option is set to + require a value, one must be present. If such an option is placed last + and has no value, the option will be treated as if it had not been + specified. + + The parser does not automatically support negating or disabling long options + by using the format \c{--disable-option} or \c{--no-option}. However, it is + possible to handle this case explicitly by making an option with \c{no-option} + as one of its names, and handling the option explicitly. + + Example: + \snippet code/src_corelib_tools_qcommandlineparser_main.cpp 0 + + Known limitation: the parsing of Qt options inside QCoreApplication and subclasses + happens before QCommandLineParser exists, so it can't take it into account. This + means any option value that looks like a builtin Qt option, will be treated by + QCoreApplication as a builtin Qt option. Example: \c{--profile -reverse} will + lead to QGuiApplication seeing the -reverse option set, and removing it from + QCoreApplication::arguments() before QCommandLineParser defines the \c{profile} + option and parses the command line. + + \sa QCommandLineOption, QCoreApplication +*/ + +/*! + Constructs a command line parser object. +*/ +QCommandLineParser::QCommandLineParser() + : d(new QCommandLineParserPrivate) +{ +} + +/*! + Destroys the command line parser object. +*/ +QCommandLineParser::~QCommandLineParser() +{ + delete d; +} + +/*! + \enum QCommandLineParser::SingleDashWordOptionMode + + This enum describes the way the parser interprets command-line + options that use a single dash followed by multiple letters, as as \c{-abc}. + + \value ParseAsCompactedShortOptions \c{-abc} is interpreted as \c{-a -b -c}, + i.e. as three short options that have been compacted on the command-line, + if none of the options take a value. If \c{a} takes a value, then it + is interpreted as \c{-a bc}, i.e. the short option \c{a} followed by the value \c{bc}. + This is typically used in tools that behave like compilers, in order + to handle options such as \c{-DDEFINE=VALUE} or \c{-I/include/path}. + This is the default parsing mode. New applications are recommended to + use this mode. + + \value ParseAsLongOptions \c{-abc} is interpreted as \c{--abc}, + i.e. as the long option named \c{abc}. This is how Qt's own tools + (uic, rcc...) have always been parsing arguments. This mode should be + used for preserving compatibility in applications that were parsing + arguments in such a way. + + \sa setSingleDashWordOptionMode() +*/ + +/*! + Sets the parsing mode to \a singleDashWordOptionMode. + This must be called before process() or parse(). +*/ +void QCommandLineParser::setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode) +{ + d->singleDashWordOptionMode = singleDashWordOptionMode; +} + +/*! + Adds the option \a option to look for while parsing. + + Returns \c true if adding the option was successful; otherwise returns \c false. + + Adding the option fails if there is no name attached to the option, or + the option has a name that clashes with an option name added before. + */ +bool QCommandLineParser::addOption(const QCommandLineOption &option) +{ + QStringList optionNames = option.names(); + + if (!optionNames.isEmpty()) { + Q_FOREACH (const QString &name, optionNames) { + if (d->nameHash.contains(name)) + return false; + } + + d->commandLineOptionList.append(option); + + const int offset = d->commandLineOptionList.size() - 1; + Q_FOREACH (const QString &name, optionNames) + d->nameHash.insert(name, offset); + + return true; + } + + return false; +} + +/*! + Adds the \c{-v} / \c{--version} option, which displays the version string of the application. + + This option is handled automatically by QCommandLineParser. + + You can set the actual version string by using QCoreApplication::setApplicationVersion(). + + Returns the option instance, which can be used to call isSet(). +*/ +QCommandLineOption QCommandLineParser::addVersionOption() +{ + QCommandLineOption opt(QStringList() << "v" << "version", tr("Displays version information.")); + addOption(opt); + d->builtinVersionOption = true; + return opt; +} + +/*! + Adds the help option (\c{-h}, \c{--help} and \c{-?} on Windows) + This option is handled automatically by QCommandLineParser. + + Remember to use setApplicationDescription to set the application description, + which will be displayed when this option is used. + + Example: + \snippet code/src_corelib_tools_qcommandlineparser_main.cpp 0 + + Returns the option instance, which can be used to call isSet(). +*/ +QCommandLineOption QCommandLineParser::addHelpOption() +{ + QCommandLineOption opt(QStringList() +#ifdef Q_OS_WIN + << "?" +#endif + << "h" + << "help", tr("Displays this help.")); + addOption(opt); + d->builtinHelpOption = true; + return opt; +} + +/*! + Sets the application \a description shown by helpText(). +*/ +void QCommandLineParser::setApplicationDescription(const QString &description) +{ + d->description = description; +} + +/*! + Returns the application description set in setApplicationDescription(). +*/ +QString QCommandLineParser::applicationDescription() const +{ + return d->description; +} + +/*! + Defines an additional argument to the application, for the benefit of the help text. + + The argument \a name and \a description will appear under the \c{Arguments:} section + of the help. If \a syntax is specified, it will be appended to the Usage line, otherwise + the \a name will be appended. + + Example: + \snippet code/src_corelib_tools_qcommandlineparser.cpp 2 + + \sa addHelpOption(), helpText() +*/ +void QCommandLineParser::addPositionalArgument(const QString &name, const QString &description, const QString &syntax) +{ + QCommandLineParserPrivate::PositionalArgumentDefinition arg; + arg.name = name; + arg.description = description; + arg.syntax = syntax.isEmpty() ? name : syntax; + d->positionalArgumentDefinitions.append(arg); +} + +/*! + Clears the definitions of additional arguments from the help text. + + This is only needed for the special case of tools which support multiple commands + with different options. Once the actual command has been identified, the options + for this command can be defined, and the help text for the command can be adjusted + accordingly. + + Example: + \snippet code/src_corelib_tools_qcommandlineparser.cpp 3 +*/ +void QCommandLineParser::clearPositionalArguments() +{ + d->positionalArgumentDefinitions.clear(); +} + +/*! + Parses the command line \a arguments. + + Most programs don't need to call this, a simple call to process() is enough. + + parse() is more low-level, and only does the parsing. The application will have to + take care of the error handling, using errorText() if parse() returns \c false. + This can be useful for instance to show a graphical error message in graphical programs. + + Calling parse() instead of process() can also be useful in order to ignore unknown + options temporarily, because more option definitions will be provided later on + (depending on one of the arguments), before calling process(). + + Don't forget that \a arguments must start with the name of the executable (ignored, though). + + Returns \c false in case of a parse error (unknown option or missing value); returns \c true otherwise. + + \sa process() +*/ +bool QCommandLineParser::parse(const QStringList &arguments) +{ + return d->parse(arguments); +} + +/*! + Returns a translated error text for the user. + This should only be called when parse() returns \c false. +*/ +QString QCommandLineParser::errorText() const +{ + if (!d->errorText.isEmpty()) + return d->errorText; + if (d->unknownOptionNames.count() == 1) + return tr("Unknown option '%1'.").arg(d->unknownOptionNames.first()); + if (d->unknownOptionNames.count() > 1) + return tr("Unknown options: %1.").arg(d->unknownOptionNames.join(", ")); + return QString(); +} + +/*! + Processes the command line \a arguments. + + In addition to parsing the options (like parse()), this function also handles the builtin + options and handles errors. + + The builtin options are \c{--version} if addVersionOption was called and \c{--help} if addHelpOption was called. + + When invoking one of these options, or when an error happens (for instance an unknown option was + passed), the current process will then stop, using the exit() function. + + \sa QCoreApplication::arguments(), parse() + */ +void QCommandLineParser::process(const QStringList &arguments) +{ + if (!d->parse(arguments)) { + fprintf(stderr, "%s\n", qPrintable(errorText())); + ::exit(EXIT_FAILURE); + } + + if (d->builtinVersionOption && isSet("version")) { + printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion())); + ::exit(EXIT_SUCCESS); + } + + if (d->builtinHelpOption && isSet("help")) + showHelp(EXIT_SUCCESS); +} + +/*! + \overload + + The command line is obtained from the QCoreApplication instance \a app. + */ +void QCommandLineParser::process(const QCoreApplication &app) +{ + // QCoreApplication::arguments() is static, but the app instance must exist so we require it as parameter + Q_UNUSED(app); + process(QCoreApplication::arguments()); +} + +void QCommandLineParserPrivate::checkParsed(const char *method) +{ + if (needsParsing) + qWarning("QCommandLineParser: call process() or parse() before %s", method); +} + +/*! + \internal + Looks up the option \a optionName (found on the command line) and register it as found. + Returns \c true on success. + */ +bool QCommandLineParserPrivate::registerFoundOption(const QString &optionName) +{ + if (nameHash.contains(optionName)) { + optionNames.append(optionName); + return true; + } else { + unknownOptionNames.append(optionName); + return false; + } +} + +/*! + \internal + \brief Parse the value for a given option, if it was defined to expect one. + + The value is taken from the next argument, or after the equal sign in \a argument. + + \param optionName the short option name + \param argument the argument from the command line currently parsed. Only used for -k=value parsing. + \param argumentIterator iterator to the currently parsed argument. Incremented if the next argument contains the value. + \param argsEnd args.end(), to check if ++argumentIterator goes out of bounds + Returns \c true on success. + */ +bool QCommandLineParserPrivate::parseOptionValue(const QString &optionName, const QString &argument, + QStringList::const_iterator *argumentIterator, QStringList::const_iterator argsEnd) +{ + const QLatin1Char assignChar('='); + const NameHash_t::const_iterator nameHashIt = nameHash.constFind(optionName); + if (nameHashIt != nameHash.constEnd()) { + const int assignPos = argument.indexOf(assignChar); + const NameHash_t::mapped_type optionOffset = *nameHashIt; + const bool withValue = !commandLineOptionList.at(optionOffset).valueName().isEmpty(); + if (withValue) { + if (assignPos == -1) { + ++(*argumentIterator); + if (*argumentIterator == argsEnd) { + errorText = QCommandLineParser::tr("Missing value after '%1'.").arg(argument); + return false; + } + optionValuesHash[optionOffset].append(*(*argumentIterator)); + } else { + optionValuesHash[optionOffset].append(argument.mid(assignPos + 1)); + } + } else { + if (assignPos != -1) { + errorText = QCommandLineParser::tr("Unexpected value after '%1'.").arg(argument.left(assignPos)); + return false; + } + } + } + return true; +} + +/*! + \internal + + Parse the list of arguments \a args, and fills in + optionNames, optionValuesHash, unknownOptionNames, positionalArguments, and errorText. + + Any results from a previous parse operation are removed. + + The parser will not look for further options once it encounters the option + \c{--}; this does not include when \c{--} follows an option that requires a value. + */ +bool QCommandLineParserPrivate::parse(const QStringList &args) +{ + needsParsing = false; + bool error = false; + + const QString doubleDashString("--"); + const QLatin1Char dashChar('-'); + const QLatin1Char assignChar('='); + + bool doubleDashFound = false; + errorText.clear(); + positionalArgumentList.clear(); + optionNames.clear(); + unknownOptionNames.clear(); + optionValuesHash.clear(); + + if (args.isEmpty()) { + qWarning("QCommandLineParser: argument list cannot be empty, it should contain at least the executable name"); + return false; + } + + QStringList::const_iterator argumentIterator = args.begin(); + ++argumentIterator; // skip executable name + + for (; argumentIterator != args.end() ; ++argumentIterator) { + QString argument = *argumentIterator; + + if (doubleDashFound) { + positionalArgumentList.append(argument); + } else if (argument.startsWith(doubleDashString)) { + if (argument.length() > 2) { + QString optionName = argument.mid(2).section(assignChar, 0, 0); + if (registerFoundOption(optionName)) { + if (!parseOptionValue(optionName, argument, &argumentIterator, args.end())) + error = true; + } else { + error = true; + } + } else { + doubleDashFound = true; + } + } else if (argument.startsWith(dashChar)) { + if (argument.size() == 1) { // single dash ("stdin") + positionalArgumentList.append(argument); + continue; + } + switch (singleDashWordOptionMode) { + case QCommandLineParser::ParseAsCompactedShortOptions: + { + QString optionName; + bool valueFound = false; + for (int pos = 1 ; pos < argument.size(); ++pos) { + optionName = argument.mid(pos, 1); + if (!registerFoundOption(optionName)) { + error = true; + } else { + const NameHash_t::const_iterator nameHashIt = nameHash.constFind(optionName); + Q_ASSERT(nameHashIt != nameHash.constEnd()); // checked by registerFoundOption + const NameHash_t::mapped_type optionOffset = *nameHashIt; + const bool withValue = !commandLineOptionList.at(optionOffset).valueName().isEmpty(); + if (withValue) { + if (pos + 1 < argument.size()) { + if (argument.at(pos + 1) == assignChar) + ++pos; + optionValuesHash[optionOffset].append(argument.mid(pos + 1)); + valueFound = true; + } + break; + } + if (pos + 1 < argument.size() && argument.at(pos + 1) == assignChar) + break; + } + } + if (!valueFound && !parseOptionValue(optionName, argument, &argumentIterator, args.end())) + error = true; + break; + } + case QCommandLineParser::ParseAsLongOptions: + { + const QString optionName = argument.mid(1).section(assignChar, 0, 0); + if (registerFoundOption(optionName)) { + if (!parseOptionValue(optionName, argument, &argumentIterator, args.end())) + error = true; + } else { + error = true; + } + break; + } + } + } else { + positionalArgumentList.append(argument); + } + if (argumentIterator == args.end()) + break; + } + return !error; +} + +/*! + Checks whether the option \a name was passed to the application. + + Returns \c true if the option \a name was set, false otherwise. + + The name provided can be any long or short name of any option that was + added with \c addOption(). All the options names are treated as being + equivalent. If the name is not recognized or that option was not present, + false is returned. + + Example: + \snippet code/src_corelib_tools_qcommandlineparser.cpp 0 + */ + +bool QCommandLineParser::isSet(const QString &name) const +{ + d->checkParsed("isSet"); + if (d->optionNames.contains(name)) + return true; + const QStringList aliases = d->aliases(name); + Q_FOREACH (const QString &optionName, d->optionNames) { + if (aliases.contains(optionName)) + return true; + } + return false; +} + +/*! + Returns the option value found for the given option name \a optionName, or + an empty string if not found. + + The name provided can be any long or short name of any option that was + added with \c addOption(). All the option names are treated as being + equivalent. If the name is not recognized or that option was not present, an + empty string is returned. + + For options found by the parser, the last value found for + that option is returned. If the option wasn't specified on the command line, + the default value is returned. + + An empty string is returned if the option does not take a value. + + \sa values(), QCommandLineOption::setDefaultValue(), QCommandLineOption::setDefaultValues() + */ + +QString QCommandLineParser::value(const QString &optionName) const +{ + d->checkParsed("value"); + const QStringList valueList = values(optionName); + + if (!valueList.isEmpty()) + return valueList.last(); + + return QString(); +} + +/*! + Returns a list of option values found for the given option name \a + optionName, or an empty list if not found. + + The name provided can be any long or short name of any option that was + added with \c addOption(). All the options names are treated as being + equivalent. If the name is not recognized or that option was not present, an + empty list is returned. + + For options found by the parser, the list will contain an entry for + each time the option was encountered by the parser. If the option wasn't + specified on the command line, the default values are returned. + + An empty list is returned if the option does not take a value. + + \sa value(), QCommandLineOption::setDefaultValue(), QCommandLineOption::setDefaultValues() + */ + +QStringList QCommandLineParser::values(const QString &optionName) const +{ + d->checkParsed("values"); + const NameHash_t::const_iterator it = d->nameHash.constFind(optionName); + if (it != d->nameHash.constEnd()) { + const int optionOffset = *it; + QStringList values = d->optionValuesHash.value(optionOffset); + if (values.isEmpty()) + values = d->commandLineOptionList.at(optionOffset).defaultValues(); + return values; + } + + qWarning("QCommandLineParser: option not defined: \"%s\"", qPrintable(optionName)); + return QStringList(); +} + +/*! + \overload + Checks whether the \a option was passed to the application. + + Returns \c true if the \a option was set, false otherwise. + + This is the recommended way to check for options with no values. + + Example: + \snippet code/src_corelib_tools_qcommandlineparser.cpp 1 +*/ +bool QCommandLineParser::isSet(const QCommandLineOption &option) const +{ + // option.names() might be empty if the constructor failed + return !option.names().isEmpty() && isSet(option.names().first()); +} + +/*! + \overload + Returns the option value found for the given \a option, or + an empty string if not found. + + For options found by the parser, the last value found for + that option is returned. If the option wasn't specified on the command line, + the default value is returned. + + An empty string is returned if the option does not take a value. + + \sa values(), QCommandLineOption::setDefaultValue(), QCommandLineOption::setDefaultValues() +*/ +QString QCommandLineParser::value(const QCommandLineOption &option) const +{ + return value(option.names().first()); +} + +/*! + \overload + Returns a list of option values found for the given \a option, + or an empty list if not found. + + For options found by the parser, the list will contain an entry for + each time the option was encountered by the parser. If the option wasn't + specified on the command line, the default values are returned. + + An empty list is returned if the option does not take a value. + + \sa value(), QCommandLineOption::setDefaultValue(), QCommandLineOption::setDefaultValues() +*/ +QStringList QCommandLineParser::values(const QCommandLineOption &option) const +{ + return values(option.names().first()); +} + +/*! + Returns a list of positional arguments. + + These are all of the arguments that were not recognized as part of an + option. + */ + +QStringList QCommandLineParser::positionalArguments() const +{ + d->checkParsed("positionalArguments"); + return d->positionalArgumentList; +} + +/*! + Returns a list of option names that were found. + + This returns a list of all the recognized option names found by the + parser, in the order in which they were found. For any long options + that were in the form {--option=value}, the value part will have been + dropped. + + The names in this list do not include the preceding dash characters. + Names may appear more than once in this list if they were encountered + more than once by the parser. + + Any entry in the list can be used with \c value() or with + \c values() to get any relevant option values. + */ + +QStringList QCommandLineParser::optionNames() const +{ + d->checkParsed("optionNames"); + return d->optionNames; +} + +/*! + Returns a list of unknown option names. + + This list will include both long an short name options that were not + recognized. For any long options that were in the form {--option=value}, + the value part will have been dropped and only the long name is added. + + The names in this list do not include the preceding dash characters. + Names may appear more than once in this list if they were encountered + more than once by the parser. + + \sa optionNames() + */ + +QStringList QCommandLineParser::unknownOptionNames() const +{ + d->checkParsed("unknownOptionNames"); + return d->unknownOptionNames; +} + +/*! + Displays the help information, and exits the application. + This is automatically triggered by the --help option, but can also + be used to display the help when the user is not invoking the + application correctly. + The exit code is set to \a exitCode. It should be set to 0 if the + user requested to see the help, and to any other value in case of + an error. + + \sa helpText() +*/ +void QCommandLineParser::showHelp(int exitCode) +{ + fprintf(stdout, "%s", qPrintable(d->helpText())); + ::exit(exitCode); +} + +/*! + Returns a string containing the complete help information. + + \sa showHelp() +*/ +QString QCommandLineParser::helpText() const +{ + return d->helpText(); +} + +static QString wrapText(const QString &names, int longestOptionNameString, const QString &description) +{ + const QLatin1Char nl('\n'); + QString text = QString(" ") + names.leftJustified(longestOptionNameString) + QLatin1Char(' '); + const int indent = text.length(); + int lineStart = 0; + int lastBreakable = -1; + const int max = 79 - indent; + int x = 0; + const int len = description.length(); + + for (int i = 0; i < len; ++i) { + ++x; + const QChar c = description.at(i); + if (c.isSpace()) + lastBreakable = i; + + int breakAt = -1; + int nextLineStart = -1; + if (x > max && lastBreakable != -1) { + // time to break and we know where + breakAt = lastBreakable; + nextLineStart = lastBreakable + 1; + } else if ((x > max - 1 && lastBreakable == -1) || i == len - 1) { + // time to break but found nowhere [-> break here], or end of last line + breakAt = i + 1; + nextLineStart = breakAt; + } else if (c == nl) { + // forced break + breakAt = i; + nextLineStart = i + 1; + } + + if (breakAt != -1) { + const int numChars = breakAt - lineStart; + //qDebug() << "breakAt=" << description.at(breakAt) << "breakAtSpace=" << breakAtSpace << lineStart << "to" << breakAt << description.mid(lineStart, numChars); + if (lineStart > 0) + text += QString(indent, QLatin1Char(' ')); + text += description.mid(lineStart, numChars) + nl; + x = 0; + lastBreakable = -1; + lineStart = nextLineStart; + if (lineStart < len && description.at(lineStart).isSpace()) + ++lineStart; // don't start a line with a space + i = lineStart; + } + } + + return text; +} + +QString QCommandLineParserPrivate::helpText() const +{ + const QLatin1Char nl('\n'); + QString text; + const QString exeName = QCoreApplication::instance()->arguments().first(); + QString usage = exeName; + if (!commandLineOptionList.isEmpty()) { + usage += QLatin1Char(' '); + usage += QCommandLineParser::tr("[options]"); + } + Q_FOREACH (const PositionalArgumentDefinition &arg, positionalArgumentDefinitions) { + usage += QLatin1Char(' '); + usage += arg.syntax; + } + text += QCommandLineParser::tr("Usage: %1").arg(usage) + nl; + if (!description.isEmpty()) + text += description + nl; + text += nl; + if (!commandLineOptionList.isEmpty()) + text += QCommandLineParser::tr("Options:") + nl; + QStringList optionNameList; + int longestOptionNameString = 0; + Q_FOREACH (const QCommandLineOption &option, commandLineOptionList) { + QStringList optionNames; + Q_FOREACH (const QString &optionName, option.names()) { + if (optionName.length() == 1) + optionNames.append(QLatin1Char('-') + optionName); + else + optionNames.append(QString("--") + optionName); + } + QString optionNamesString = optionNames.join(", "); + if (!option.valueName().isEmpty()) + optionNamesString += QString(" <") + option.valueName() + QLatin1Char('>'); + optionNameList.append(optionNamesString); + longestOptionNameString = qMax(longestOptionNameString, optionNamesString.length()); + } + ++longestOptionNameString; + for (int i = 0; i < commandLineOptionList.count(); ++i) { + const QCommandLineOption &option = commandLineOptionList.at(i); + text += wrapText(optionNameList.at(i), longestOptionNameString, option.description()); + } + if (!positionalArgumentDefinitions.isEmpty()) { + if (!commandLineOptionList.isEmpty()) + text += nl; + text += QCommandLineParser::tr("Arguments:") + nl; + Q_FOREACH (const PositionalArgumentDefinition &arg, positionalArgumentDefinitions) { + text += wrapText(arg.name, longestOptionNameString, arg.description); + } + } + return text; +} + +#endif //QT_VERSION < QT_VERSION_CHECK(5, 2, 1) diff --git a/src/app/core/qcommandlineparser.h b/src/app/core/qcommandlineparser.h new file mode 100644 index 000000000..b7a8f3418 --- /dev/null +++ b/src/app/core/qcommandlineparser.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Laszlo Papp +** 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 QCOMMANDLINEPARSER_H +#define QCOMMANDLINEPARSER_H + +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 1) + +#include +#include + +#include "qcommandlineoption.h" + +class QCommandLineParserPrivate; +class QCoreApplication; + +class QCommandLineParser +{ + Q_DECLARE_TR_FUNCTIONS(QCommandLineParser) +public: + QCommandLineParser(); + ~QCommandLineParser(); + + enum SingleDashWordOptionMode { + ParseAsCompactedShortOptions, + ParseAsLongOptions + }; + void setSingleDashWordOptionMode(SingleDashWordOptionMode parsingMode); + + bool addOption(const QCommandLineOption &commandLineOption); + + QCommandLineOption addVersionOption(); + QCommandLineOption addHelpOption(); + void setApplicationDescription(const QString &description); + QString applicationDescription() const; + void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString()); + void clearPositionalArguments(); + + void process(const QStringList &arguments); + void process(const QCoreApplication &app); + + bool parse(const QStringList &arguments); + QString errorText() const; + + bool isSet(const QString &name) const; + QString value(const QString &name) const; + QStringList values(const QString &name) const; + + bool isSet(const QCommandLineOption &option) const; + QString value(const QCommandLineOption &option) const; + QStringList values(const QCommandLineOption &option) const; + + QStringList positionalArguments() const; + QStringList optionNames() const; + QStringList unknownOptionNames() const; + + void showHelp(int exitCode = 0); + QString helpText() const; + +private: + Q_DISABLE_COPY(QCommandLineParser) + + QCommandLineParserPrivate * const d; +}; + +#endif //QT_VERSION < QT_VERSION_CHECK(5, 2, 1) + +#endif // QCOMMANDLINEPARSER_H diff --git a/src/app/widgets/undoevent.cpp b/src/app/core/undoevent.cpp similarity index 100% rename from src/app/widgets/undoevent.cpp rename to src/app/core/undoevent.cpp diff --git a/src/app/widgets/undoevent.h b/src/app/core/undoevent.h similarity index 100% rename from src/app/widgets/undoevent.h rename to src/app/core/undoevent.h diff --git a/src/app/widgets/vapplication.cpp b/src/app/core/vapplication.cpp similarity index 99% rename from src/app/widgets/vapplication.cpp rename to src/app/core/vapplication.cpp index 20239b4c4..c42f4db3e 100644 --- a/src/app/widgets/vapplication.cpp +++ b/src/app/core/vapplication.cpp @@ -40,8 +40,6 @@ #include #include -#include - const qreal VApplication::PrintDPI = 96.0; #define DefWidth 1.2//mm diff --git a/src/app/widgets/vapplication.h b/src/app/core/vapplication.h similarity index 100% rename from src/app/widgets/vapplication.h rename to src/app/core/vapplication.h diff --git a/src/app/widgets/vtranslation.cpp b/src/app/core/vtranslation.cpp similarity index 100% rename from src/app/widgets/vtranslation.cpp rename to src/app/core/vtranslation.cpp diff --git a/src/app/widgets/vtranslation.h b/src/app/core/vtranslation.h similarity index 100% rename from src/app/widgets/vtranslation.h rename to src/app/core/vtranslation.h diff --git a/src/app/dialogs/app/configpages/communitypage.cpp b/src/app/dialogs/app/configpages/communitypage.cpp index 2ff7f4901..9ebab2e36 100644 --- a/src/app/dialogs/app/configpages/communitypage.cpp +++ b/src/app/dialogs/app/configpages/communitypage.cpp @@ -28,7 +28,7 @@ #include "communitypage.h" #include "../../../options.h" -#include "../../../widgets/vapplication.h" +#include "../../../core/vapplication.h" #include #include #include diff --git a/src/app/dialogs/app/configpages/configurationpage.cpp b/src/app/dialogs/app/configpages/configurationpage.cpp index 6e844f420..ab2f5d37b 100644 --- a/src/app/dialogs/app/configpages/configurationpage.cpp +++ b/src/app/dialogs/app/configpages/configurationpage.cpp @@ -28,7 +28,7 @@ #include "configurationpage.h" #include "../../../options.h" -#include "../../../widgets/vapplication.h" +#include "../../../core/vapplication.h" #include #include #include diff --git a/src/app/dialogs/app/configpages/pathpage.cpp b/src/app/dialogs/app/configpages/pathpage.cpp index 4bcee938e..1215d998a 100644 --- a/src/app/dialogs/app/configpages/pathpage.cpp +++ b/src/app/dialogs/app/configpages/pathpage.cpp @@ -28,7 +28,7 @@ #include "pathpage.h" #include "../../../options.h" -#include "../../../widgets/vapplication.h" +#include "../../../core/vapplication.h" #include #include #include diff --git a/src/app/dialogs/app/configpages/patternpage.cpp b/src/app/dialogs/app/configpages/patternpage.cpp index 4609fd7c4..d063d25e5 100644 --- a/src/app/dialogs/app/configpages/patternpage.cpp +++ b/src/app/dialogs/app/configpages/patternpage.cpp @@ -28,7 +28,7 @@ #include "patternpage.h" #include "../../../options.h" -#include "../../../widgets/vapplication.h" +#include "../../../core/vapplication.h" #include "../../../widgets/vmaingraphicsview.h" #include #include diff --git a/src/app/dialogs/app/dialogindividualmeasurements.cpp b/src/app/dialogs/app/dialogindividualmeasurements.cpp index 97dee6324..9055eddd0 100644 --- a/src/app/dialogs/app/dialogindividualmeasurements.cpp +++ b/src/app/dialogs/app/dialogindividualmeasurements.cpp @@ -34,7 +34,7 @@ #include #include #include -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/app/dialogpatternproperties.cpp b/src/app/dialogs/app/dialogpatternproperties.cpp index d040d08f6..51e68a418 100644 --- a/src/app/dialogs/app/dialogpatternproperties.cpp +++ b/src/app/dialogs/app/dialogpatternproperties.cpp @@ -30,7 +30,7 @@ #include "ui_dialogpatternproperties.h" #include #include "../../xml/vpattern.h" -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #define MAX_HEIGHTS 18 #define MAX_SIZES 18 diff --git a/src/app/dialogs/app/dialogstandardmeasurements.cpp b/src/app/dialogs/app/dialogstandardmeasurements.cpp index 9aa2a418f..fb0385b24 100644 --- a/src/app/dialogs/app/dialogstandardmeasurements.cpp +++ b/src/app/dialogs/app/dialogstandardmeasurements.cpp @@ -32,7 +32,7 @@ #include #include #include "../../xml/vstandardmeasurements.h" -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/app/dialogundo.cpp b/src/app/dialogs/app/dialogundo.cpp index d863e7fe7..8e5e1223e 100644 --- a/src/app/dialogs/app/dialogundo.cpp +++ b/src/app/dialogs/app/dialogundo.cpp @@ -28,7 +28,7 @@ #include "dialogundo.h" #include "ui_dialogundo.h" -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #include "../../exception/vexceptionundo.h" #include #include diff --git a/src/app/dialogs/tools/dialogline.cpp b/src/app/dialogs/tools/dialogline.cpp index 56c606437..2fd77ef24 100644 --- a/src/app/dialogs/tools/dialogline.cpp +++ b/src/app/dialogs/tools/dialogline.cpp @@ -32,7 +32,7 @@ #include "../../geometry/vpointf.h" #include "../../container/vcontainer.h" #include "../../visualization/vistoolline.h" -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #include "../../widgets/vmaingraphicsscene.h" #include "../../tools/vabstracttool.h" diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 004797b6e..f9ff808d6 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -34,7 +34,7 @@ #include "../../geometry/vsplinepath.h" #include "../../tools/vabstracttool.h" #include "../../../libs/qmuparser/qmuparsererror.h" -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #include "../../xml/vdomdocument.h" #include #include diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index 7a1f4ca14..fc94d2a03 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -34,7 +34,7 @@ #include #include #include -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #include #include diff --git a/src/app/geometry/vabstractcurve.cpp b/src/app/geometry/vabstractcurve.cpp index d8a056bf7..6c7bef2d2 100644 --- a/src/app/geometry/vabstractcurve.cpp +++ b/src/app/geometry/vabstractcurve.cpp @@ -29,7 +29,6 @@ #include "vabstractcurve.h" #include -#include VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode) :VGObject(type, idObject, mode) diff --git a/src/app/geometry/varc.cpp b/src/app/geometry/varc.cpp index 6d97b2c3d..3a032d52d 100644 --- a/src/app/geometry/varc.cpp +++ b/src/app/geometry/varc.cpp @@ -33,10 +33,6 @@ #include #include -#ifdef Q_OS_WIN32 -# include // for M_PI on Windows -#endif /*Q_OS_WIN32*/ - #include "../container/vformula.h" diff --git a/src/app/geometry/vequidistant.cpp b/src/app/geometry/vequidistant.cpp index 5e6ae7349..28e640f7a 100644 --- a/src/app/geometry/vequidistant.cpp +++ b/src/app/geometry/vequidistant.cpp @@ -31,7 +31,7 @@ #include "vpointf.h" #include "vspline.h" #include "vsplinepath.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include #include #include "../container/vcontainer.h" diff --git a/src/app/geometry/vspline.cpp b/src/app/geometry/vspline.cpp index 57d76ce62..a0371729c 100644 --- a/src/app/geometry/vspline.cpp +++ b/src/app/geometry/vspline.cpp @@ -31,10 +31,6 @@ #include #include -#ifdef Q_OS_WIN32 -# include // for M_PI on Windows -#endif /*Q_OS_WIN32*/ - //--------------------------------------------------------------------------------------------------------------------- /** * @brief VSpline default constructor diff --git a/src/app/main.cpp b/src/app/main.cpp index 5557fbff6..22a59940c 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -27,11 +27,17 @@ *************************************************************************/ #include "mainwindow.h" -#include "widgets/vapplication.h" +#include "core/vapplication.h" #include #include #include -#include + +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 1) + #include "core/qcommandlineparser.h" +#else + #include +#endif + #include #include "tablewindow.h" #include "version.h" diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index e5684830a..fa5a99c2a 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -38,8 +38,8 @@ #include "version.h" #include "xml/vstandardmeasurements.h" #include "xml/vindividualmeasurements.h" -#include "widgets/vapplication.h" -#include "widgets/undoevent.h" +#include "core/vapplication.h" +#include "core/undoevent.h" #include "undocommands/renamepp.h" #include "vtooloptionspropertybrowser.h" diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp index 90394f4fe..b7206576c 100644 --- a/src/app/tablewindow.cpp +++ b/src/app/tablewindow.cpp @@ -31,7 +31,7 @@ #include "widgets/vtablegraphicsview.h" #include #include -#include "widgets/vapplication.h" +#include "core/vapplication.h" #ifdef Q_OS_WIN # define PDFTOPS "pdftops.exe" diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp index 6c1eee49c..916e0b326 100644 --- a/src/app/tools/drawTools/vtooltriangle.cpp +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -31,8 +31,6 @@ #include "../../geometry/vpointf.h" #include "../../visualization/vistooltriangle.h" -#include - const QString VToolTriangle::ToolType = QStringLiteral("triangle"); //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/nodeDetails/vabstractnode.cpp b/src/app/tools/nodeDetails/vabstractnode.cpp index 8a9a10ec2..13ea1b71b 100644 --- a/src/app/tools/nodeDetails/vabstractnode.cpp +++ b/src/app/tools/nodeDetails/vabstractnode.cpp @@ -30,7 +30,7 @@ #include #include "../../xml/vpattern.h" #include "../../undocommands/adddetnode.h" -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject"); const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool"); diff --git a/src/app/tools/nodeDetails/vnodearc.cpp b/src/app/tools/nodeDetails/vnodearc.cpp index 829d86b22..0e51c5755 100644 --- a/src/app/tools/nodeDetails/vnodearc.cpp +++ b/src/app/tools/nodeDetails/vnodearc.cpp @@ -28,7 +28,7 @@ #include "vnodearc.h" -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #include "../../geometry/varc.h" #include #include diff --git a/src/app/tools/nodeDetails/vnodepoint.cpp b/src/app/tools/nodeDetails/vnodepoint.cpp index cce6c8629..2fe4673e8 100644 --- a/src/app/tools/nodeDetails/vnodepoint.cpp +++ b/src/app/tools/nodeDetails/vnodepoint.cpp @@ -28,7 +28,7 @@ #include "vnodepoint.h" -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #include "../../geometry/vpointf.h" #include "../../visualization/vgraphicssimpletextitem.h" #include diff --git a/src/app/tools/nodeDetails/vnodespline.cpp b/src/app/tools/nodeDetails/vnodespline.cpp index 73227ca84..a875ebf46 100644 --- a/src/app/tools/nodeDetails/vnodespline.cpp +++ b/src/app/tools/nodeDetails/vnodespline.cpp @@ -28,7 +28,7 @@ #include "vnodespline.h" -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #include "../../geometry/vspline.h" #include #include diff --git a/src/app/tools/nodeDetails/vnodesplinepath.cpp b/src/app/tools/nodeDetails/vnodesplinepath.cpp index 5047aea9d..b1f523b0b 100644 --- a/src/app/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/app/tools/nodeDetails/vnodesplinepath.cpp @@ -28,7 +28,7 @@ #include "vnodesplinepath.h" -#include "../../widgets/vapplication.h" +#include "../../core/vapplication.h" #include "../../geometry/vsplinepath.h" #include #include diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index 96d83100f..35c4c811e 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -30,7 +30,7 @@ #include #include #include "../undocommands/deltool.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include "../geometry/vpointf.h" #include "../undocommands/savetooloptions.h" diff --git a/src/app/undocommands/addtocalc.cpp b/src/app/undocommands/addtocalc.cpp index 1e6afddb9..9074bd8c9 100644 --- a/src/app/undocommands/addtocalc.cpp +++ b/src/app/undocommands/addtocalc.cpp @@ -29,7 +29,7 @@ #include "addtocalc.h" #include "../xml/vpattern.h" #include "../tools/vabstracttool.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include "../widgets/vmaingraphicsscene.h" #include "../widgets/vmaingraphicsview.h" diff --git a/src/app/undocommands/movedetail.cpp b/src/app/undocommands/movedetail.cpp index e7f671098..bfe53d144 100644 --- a/src/app/undocommands/movedetail.cpp +++ b/src/app/undocommands/movedetail.cpp @@ -31,7 +31,7 @@ #include #include "../xml/vpattern.h" #include "../tools/vabstracttool.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- MoveDetail::MoveDetail(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, diff --git a/src/app/undocommands/movespoint.cpp b/src/app/undocommands/movespoint.cpp index cf8227c47..0cc37f090 100644 --- a/src/app/undocommands/movespoint.cpp +++ b/src/app/undocommands/movespoint.cpp @@ -31,7 +31,7 @@ #include #include "../xml/vpattern.h" #include "../tools/vabstracttool.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, diff --git a/src/app/visualization/vcontrolpointspline.cpp b/src/app/visualization/vcontrolpointspline.cpp index 6f86a79a3..fce8b63c1 100644 --- a/src/app/visualization/vcontrolpointspline.cpp +++ b/src/app/visualization/vcontrolpointspline.cpp @@ -32,7 +32,7 @@ #include #include #include -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/visualization/vgraphicssimpletextitem.cpp b/src/app/visualization/vgraphicssimpletextitem.cpp index 3cc8af990..4589e2b3c 100644 --- a/src/app/visualization/vgraphicssimpletextitem.cpp +++ b/src/app/visualization/vgraphicssimpletextitem.cpp @@ -33,7 +33,7 @@ #include #include -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/visualization/vistoolendline.cpp b/src/app/visualization/vistoolendline.cpp index 267f2de14..d27d7be9c 100644 --- a/src/app/visualization/vistoolendline.cpp +++ b/src/app/visualization/vistoolendline.cpp @@ -32,7 +32,6 @@ #include "../tools/vabstracttool.h" #include -#include //--------------------------------------------------------------------------------------------------------------------- VisToolEndLine::VisToolEndLine(const VContainer *data, QGraphicsItem *parent) diff --git a/src/app/visualization/vistooltriangle.cpp b/src/app/visualization/vistooltriangle.cpp index b01509759..815733464 100644 --- a/src/app/visualization/vistooltriangle.cpp +++ b/src/app/visualization/vistooltriangle.cpp @@ -30,7 +30,6 @@ #include "../geometry/vpointf.h" #include "../container/vcontainer.h" #include "../tools/drawTools/vtooltriangle.h" -#include //--------------------------------------------------------------------------------------------------------------------- VisToolTriangle::VisToolTriangle(const VContainer *data, QGraphicsItem *parent) diff --git a/src/app/visualization/visualization.h b/src/app/visualization/visualization.h index 4f702f2cb..4ec34e60e 100644 --- a/src/app/visualization/visualization.h +++ b/src/app/visualization/visualization.h @@ -31,7 +31,7 @@ #include #include -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include "../widgets/vmaingraphicsscene.h" class VContainer; diff --git a/src/app/visualization/vsimplecurve.cpp b/src/app/visualization/vsimplecurve.cpp index 21403bd13..92ba03fba 100644 --- a/src/app/visualization/vsimplecurve.cpp +++ b/src/app/visualization/vsimplecurve.cpp @@ -27,7 +27,7 @@ *************************************************************************/ #include "vsimplecurve.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include #include #include diff --git a/src/app/widgets/vitem.cpp b/src/app/widgets/vitem.cpp index dfb5f6cec..6543f1d2c 100644 --- a/src/app/widgets/vitem.cpp +++ b/src/app/widgets/vitem.cpp @@ -30,7 +30,7 @@ #include #include -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index b450291f2..2de4e8d18 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -28,7 +28,7 @@ #include "vtooloptionspropertybrowser.h" #include "tools/drawTools/drawtools.h" -#include "widgets/vapplication.h" +#include "core/vapplication.h" #include "widgets/vmaingraphicsview.h" #include "visualization/vgraphicssimpletextitem.h" #include "visualization/vcontrolpointspline.h" diff --git a/src/app/widgets/widgets.pri b/src/app/widgets/widgets.pri index 4c2ac1298..30bd948db 100644 --- a/src/app/widgets/widgets.pri +++ b/src/app/widgets/widgets.pri @@ -3,11 +3,8 @@ HEADERS += \ widgets/vmaingraphicsview.h \ widgets/vmaingraphicsscene.h \ widgets/vitem.h \ - widgets/vapplication.h \ widgets/doubledelegate.h \ widgets/textdelegate.h \ - widgets/vtranslation.h \ - widgets/undoevent.h \ widgets/vtooloptionspropertybrowser.h \ widgets/vformulapropertyeditor.h \ widgets/vformulaproperty.h @@ -17,11 +14,8 @@ SOURCES += \ widgets/vmaingraphicsview.cpp \ widgets/vmaingraphicsscene.cpp \ widgets/vitem.cpp \ - widgets/vapplication.cpp \ widgets/doubledelegate.cpp \ widgets/textdelegate.cpp \ - widgets/vtranslation.cpp \ - widgets/undoevent.cpp \ widgets/vtooloptionspropertybrowser.cpp \ widgets/vformulapropertyeditor.cpp \ widgets/vformulaproperty.cpp diff --git a/src/app/xml/vindividualmeasurements.cpp b/src/app/xml/vindividualmeasurements.cpp index 45ea957dd..cf5ad0b96 100644 --- a/src/app/xml/vindividualmeasurements.cpp +++ b/src/app/xml/vindividualmeasurements.cpp @@ -27,7 +27,7 @@ *************************************************************************/ #include "vindividualmeasurements.h" -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" #include const QString VIndividualMeasurements::TagFamily_name = QStringLiteral("family-name"); diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index afb6e24eb..617c80633 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -37,7 +37,7 @@ #include "../exception/vexceptionconversionerror.h" #include "../exception/vexceptionemptyparameter.h" #include "../exception/vexceptionundo.h" -#include "../widgets/undoevent.h" +#include "../core/undoevent.h" #include "vstandardmeasurements.h" #include "vindividualmeasurements.h" #include "../../libs/qmuparser/qmuparsererror.h" @@ -45,7 +45,6 @@ #include #include -#include const QString VPattern::TagPattern = QStringLiteral("pattern"); const QString VPattern::TagCalculation = QStringLiteral("calculation"); diff --git a/src/app/xml/vstandardmeasurements.cpp b/src/app/xml/vstandardmeasurements.cpp index ee5441aa5..43124da00 100644 --- a/src/app/xml/vstandardmeasurements.cpp +++ b/src/app/xml/vstandardmeasurements.cpp @@ -28,7 +28,7 @@ #include "vstandardmeasurements.h" #include -#include "../widgets/vapplication.h" +#include "../core/vapplication.h" const QString VStandardMeasurements::TagDescription = QStringLiteral("description"); const QString VStandardMeasurements::TagId = QStringLiteral("id"); diff --git a/src/libs/qmuparser/qmuparser.cpp b/src/libs/qmuparser/qmuparser.cpp index 157d509f9..df8cf9328 100644 --- a/src/libs/qmuparser/qmuparser.cpp +++ b/src/libs/qmuparser/qmuparser.cpp @@ -22,12 +22,7 @@ #include "qmuparser.h" -#ifdef Q_OS_WIN32 -# include // for M_PI on Windows -#endif /*Q_OS_WIN32*/ - #include -#include using namespace std; diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index 5b6da2a6f..26e3c83a6 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -21,11 +21,6 @@ ******************************************************************************************************/ #include "qmuparserbase.h" -#include - -#ifdef Q_OS_WIN32 -# include // for M_PI on Windows -#endif /*Q_OS_WIN32*/ #include #ifdef QMUP_USE_OPENMP diff --git a/src/libs/qmuparser/qmuparserbytecode.cpp b/src/libs/qmuparser/qmuparserbytecode.cpp index 026949300..e0ed1f710 100644 --- a/src/libs/qmuparser/qmuparserbytecode.cpp +++ b/src/libs/qmuparser/qmuparserbytecode.cpp @@ -24,15 +24,8 @@ #include #include - -#ifdef Q_OS_WIN32 -# include // for M_PI on Windows -#endif /*Q_OS_WIN32*/ - #include #include "qmuparsertoken.h" -#include - namespace qmu { diff --git a/src/libs/qmuparser/qmuparsertest.cpp b/src/libs/qmuparser/qmuparsertest.cpp index f00bfa86e..faa4a48ad 100644 --- a/src/libs/qmuparser/qmuparsertest.cpp +++ b/src/libs/qmuparser/qmuparsertest.cpp @@ -22,10 +22,6 @@ #include "qmuparsertest.h" -#ifdef Q_OS_WIN32 -# include // for M_PI on Windows -#endif /*Q_OS_WIN32*/ - #include #include #include "qmuparsererror.h"