Merge remote-tracking branch 'origin/6.0'

Change-Id: I9d25a7ac39b3619856fc8d8a6be6f91a403b3969
This commit is contained in:
Eike Ziller
2021-09-30 09:03:12 +02:00
77 changed files with 1058 additions and 556 deletions

View File

@@ -20,6 +20,7 @@ macro.Q3DS = "Qt 3D Studio"
macro.QA = "Qt Assistant"
macro.QB = "Qt Bridge"
macro.QBPS = "Qt Bridge for Adobe Photoshop"
macro.QBXD = "Qt Bridge for Adobe XD"
macro.QBSK = "Qt Bridge for Sketch"
macro.QBF = "Qt Bridge for Figma"
macro.QC = "$IDE_DISPLAY_NAME"

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -52,11 +52,13 @@
\row
\li \inlineimage ai-logo.png
\li \inlineimage ps-logo.png
\li \inlineimage xd-logo.png
\li \inlineimage sketch-logo.png
\li \inlineimage figma-logo.png
\row
\li \l{Exporting Designs from Adobe Illustrator}{Adobe Illustrator}
\li \l{Exporting Designs from Adobe Photoshop}{Adobe Photoshop}
\li \l{Exporting Designs from Adobe XD}{Adobe XD}
\li \l{Exporting Designs from Sketch}{Sketch}
\li \l{Exporting Designs from Figma}{Figma}
\endtable

View File

@@ -26,7 +26,7 @@
/*!
\previouspage qtbridge-ps-setup.html
\page qtbridge-ps-using.html
\nextpage sketchqtbridge.html
\nextpage xdqtbridge.html
\title Using \QBPS

View File

@@ -26,7 +26,7 @@
// Note: The \page value is hard-coded as a link in Qt Bridge for Sketch.
/*!
\previouspage qtbridge-ps-using.html
\previouspage qtbridge-xd-using.html
\page sketchqtbridge.html
\nextpage qtbridge-sketch-setup.html

View File

@@ -0,0 +1,58 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Design Studio documentation.
**
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/
// Note: The \page value is hard-coded as a link in Qt Bridge for Adobe XD.
/*!
\previouspage qtbridge-ps-using.html
\page xdqtbridge.html
\nextpage qtbridge-xd-setup.html
\title Exporting Designs from Adobe XD
\note This is a \e {Technical Preview} release of the \QBXD. Some design
elements might not be exported and imported into \QDS as expected.
You can use \QBXD to export designs from Adobe XD to \e {.qtbridge}
format that you can \l{Importing 2D Assets}{import} to projects in \QDS.
\image qt-bridge-xd.png
The following topics describe setting up and using \QBXD:
\list
\li \l{Setting Up Qt Bridge for Adobe XD}
You must install and set up the \QBXD export plugin before you can use
it to export designs.
\li \l{Using Qt Bridge for Adobe XD}
To get the best results when you use \QB to export designs from
Adobe XD, you should follow the guidelines for working with
Adobe XD and organizing your assets.
\endlist
*/

View File

@@ -0,0 +1,57 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Bridge documentation.
**
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/
/*!
\previouspage xdqtbridge.html
\page qtbridge-xd-setup.html
\nextpage qtbridge-xd-using.html
\title Setting Up \QBXD
You can purchase a \QBXD license from the \l{https://marketplace.qt.io/}
{Qt Marketplace}, and then use the Qt Installer to have the \QBXD
plugin package copied to the following path in your Qt installation
folder:
\list
\li On Windows:
\c {Tools\QtDesignStudio\xd_bridge\qtbridge.xdx}
\li On \macos:
\c {QtDesignStudio/xd_bridge/qtbridge.xdx}.
\endlist
\note Install Adobe XD before installing the plugin.
To install the \QBXD plugin to Adobe XD, double-click \c qtbridge.xdx in the
\c xd_bridge folder in the installation directory of \QDS. Adobe XD will
automatically install \QBXD.
\note Since the plugin is not distributed through Adobe's marketplace, during
the installation Adobe XD might warn about the third-party developer.
\image qt-bridge-xd-warn.png
You can launch the plugin from \uicontrol Plugins > \uicontrol {\QB}.
*/

View File

@@ -0,0 +1,219 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Bridge documentation.
**
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/
/*!
\previouspage qtbridge-xd-setup.html
\page qtbridge-xd-using.html
\nextpage sketchqtbridge.html
\title Using \QBXD
\section1 Organizing Assets
To get the best results when you use \QBXD to export designs from Adobe XD
to \QDS, follow these guidelines when working with Adobe XD:
\list
\li Arrange your design into \e artboards and organize it into groups and
layers that are imported into \QDS as separate files.
\li Use descriptive and unique IDs to avoid duplicate asset names and IDs
in the generated UI.
\endlist
To use the fonts that you use in Adobe XD also in \QDS, you need to import
them to \QDS as assets. \QDS deploys them to devices when you preview the
UI. For more information, see \l{Using Custom Fonts}.
\section2 Supported Design Elements
You can export the following parts of your design using \QBXD:
\list
\li Artboard
\li Group
\li Shapes (Rectangle, Ellipse, Polygon, Line, Pen)
\li Text
\endlist
The following design elements might not be exported as expected.
\list
\li Components
\li Prototype
\li Repeat Grid
\endlist
\section2 Using Artboards
The hierarchical relationships between artboards and layers are preserved
when you export designs from Adobe XD and import them into \QDS. The
relationships are the basis of how the Items are organized in the generated
code in \QDS.
An artboard can only be exported as a component or skipped. A component will
be imported as a separate file that contains the artwork and text on the
artboard.
\section2 Annotate Layers for Export
With \QBXD, layers can be annotated to hint how each layer or group must be
exported. \uicontrol The {Home} panel displays and allows layer annotation for
export:
\image qt-bridge-xd-home.png
\list 1
\li \QBXD automatically proposes identifiers for all groups and layers
that you can change in the \uicontrol {ID} field. Use unique and
descriptive IDs to avoid duplicate IDs when the layer and the
respective artwork is imported into \QDS. Even though the importer
in \QDS is capable of fixing duplicate IDs, doing so will generate
warnings. It is recommend that you should manually check all the
IDs to make them unique and descriptive.
\li In the \uicontrol {Export As} field, select the export type for the
group or layer:
\list
\li \uicontrol Component exports the layer as a separate UI file
that contains all the exportable artwork and text in it. Only
Artboards can be exported as components.
\li \uicontrol Child exports each asset of the selected group
or layer a separate PNG file, with references
to the images in the component file.
\li \uicontrol Merged merges the rendition of the selected groups
and layers into the rendition of parent artboard or group as
one item.
\li \uicontrol Skipped completely skips the selected layer.
\endlist
\li In the \uicontrol {Component} field, specify the component or
\l {Shapes}{Qt Quick Studio Component} to morph this
layer into. The component that is generated during import will be
of this type. For example, if you drew a rectangle, you can export
it as a \l {basic-rectangle}{Rectangle} component.
You can provide the import statement of the module where the
component is defined in the \uicontrol {Imports} field.
\note The implicit properties except position and size are not
applied when the \uicontrol {Component} is defined. For example, all text
properties will be ignored if \uicontrol {Component} is defined
for a text layer, but explicit properties defined in the \uicontrol
{Properties} field will be applied.
\li In the \uicontrol {Imports} field, enter additional import statements
to have them added to the generated code file. For example, to use
Qt Quick Controls 2.3, you need the import statement
\c {QtQuick.Controls 2.3} and to use Qt Quick Studio Components 1.0,
you need the import statement \c {QtQuick.Studio.Components 1.0}.
You can also import a module as an alias.
\li In the \uicontrol {Properties} field, specify properties for the
component. You can add and modify properties in \QDS.
\li Select the \uicontrol Clip check box to enable clipping in the
component generated from the layer. The generated component will clip
its own painting, as well as the painting of its children, to its
bounding rectangle.
\li Select the \uicontrol Visible check box to determine the visibility
of the layer in the generated UI in \QDS.
\li Select \uicontrol Export to export the document into a .qtbridge
archive.
\endlist
\section2 Export Defaults
\QBXD assigns the following defaults to the layers:
By default:
\list
\li Artboards are exported as \e components.
\li Immediate children of an Artboard and Text layers are exported as
\e child.
\li Any layer not falling under the aforementioned criteria is exported
as \e merged.
\li Images are exported as PNGs by default with no Hi-DPI images.
\li \uicontrol Visible is set to \c true.
\endlist
All the assets and metadata are copied to the directory you specified. This
might take a little while depending on the complexity of your project.
You can now create a project in \QDS and import the assets to it, as
described in \l {Creating Projects} and \l{Importing Designs}.
\section1 \QBXD Settings
Select \uicontrol Settings to change the export settings.
\image qt-bridge-xd-menu.png
\image qt-bridge-xd-settings.png
\list 1
\li Select \uicontrol {Reset All} to remove all of the \QB data
stored in the document. Use \uicontrol {Edit} > \uicontrol {Undo}
to restore the data if you accidentally removed it.
\li You can export images into PNG, JPG or SVG format. In the section
\uicontrol {Export Formats}, select the image format to
export.
\li Depending on the image format selected for export, the
\uicontrol {Format Options} allows fine tuning the exported
image.
\list
\li Select \uicontrol {Hi-DPI Assets} to generate Hi-DPI
images alongside normal scale images. Being a vector format,
this option is not available for SVG format.
\li Select \uicontrol {SVG Minify} to minify the SVG.
\li Select \uicontrol {JPG Quality} to specify the JPG
compression quality in the range [1, 100].
\endlist
\endlist
\section1 Suggestions and Tips
You can export assets using the default settings and make all the changes
later in \QDS. If you are familiar with the \l{QML Syntax Basics}
{QML syntax}, you can modify the settings to tailor the generated code to
a certain degree. For example, you can specify the component or
\l {Shapes}{Qt Quick Studio Component} to use for a component or
layer. If you have drawn an arc that you mean to animate, you can export it
as an \l Arc component to avoid having to replace the arc image with an Arc
component in \QDS. Or you could export a button as a Qt Quick Controls
\l Button component.
\list
\li Name the layers in exactly the same way as your IDs, to be able to
find artwork later, especially as the export files can grow very
large and complicated as they approach the level of a complete UI
project.
\li Make sure to skip all artboards that you don't want to be part of
the final UI to avoid cluttering the \QDS project. You can select
multiple artboards on a page and then select \uicontrol Skip in \QBXD
to skip them.
\li Store all assets in the scalable vector graphics (SVG) format to be
able to easily rescale them for different screen sizes and resolutions.
You can export assets into JPG, PNG, or SVG format and select options
for optimizing them during the export.
\endlist
*/

View File

@@ -153,6 +153,11 @@
\li \l{Setting Up Qt Bridge for Adobe Photoshop}
\li \l{Using Qt Bridge for Adobe Photoshop}
\endlist
\li \l{Exporting Designs from Adobe XD}
\list
\li \l{Setting Up Qt Bridge for Adobe XD}
\li \l{Using Qt Bridge for Adobe XD}
\endlist
\li \l{Exporting Designs from Sketch}
\list
\li \l{Setting Up Qt Bridge for Sketch}

View File

@@ -40,10 +40,10 @@
\image studio-qtquick-3d-components.png "Qt Quick 3D components in Library"
You can add a camera to your scene by dragging-and-dropping one from
Add a camera by dragging-and-dropping one of the camera components from
\l Library > \uicontrol Components > \uicontrol {Qt Quick 3D} > \uicontrol
{Qt Quick 3D} to \l {3D Editor} or to a 3D view in \l Navigator.
If the cameras are not displayed in \uicontrol Library, you should add the
If the cameras are not displayed in \uicontrol Library, add the
\uicontrol QtQuick3D module to your project, as described in
\l {Adding and Removing Modules}.
@@ -51,20 +51,21 @@
projection:
\list
\li \l{PerspectiveCamera}{Camera Perspective} - is the standard camera
type, which uses field of view and near and far clip planes to
specify the projection.
\li \l{OrthographicCamera}{Camera Orthographic} - renders all contents
with no perspective. It is ideal for rendering 2D elements, because
\li \l{PerspectiveCamera}{Camera Perspective} is the standard camera
type, which gives a realistic projection of the scene since distant
objects are perceived as smaller. It uses field of view and near and
far clip planes to specify the projection.
\li \l{OrthographicCamera}{Camera Orthographic} renders all contents
with no perspective. It is ideal for rendering 2D elements because
your images are guaranteed to be the right size on the screen, and
you can use the z position of components to bring them closer to or
take them farther from the camera (\e z-sorting) with no
foreshortening artifacts.
\li \l{FrustumCamera}{Camera Frustum} - enables finer grain control of
\li \l{FrustumCamera}{Camera Frustum} enables finer grain control of
how the frustum is defined, by setting the number of degrees between
the top and bottom or left and right edges of the camera frustum.
This is useful when creating asymmetrical frustums.
\li \l{CustomCamera}{Camera Custom} - provides full control over how
\li \l{CustomCamera}{Camera Custom} provides full control over how
the projection matrix is created.
\endlist
@@ -84,6 +85,10 @@
\section1 Setting Camera Field of View
\note If you select \uicontrol {Qt 5} as the \uicontrol {Target Qt Version}
when \l {Creating Projects}{creating your project}, the camera properties
will be slightly different.
The camera frustum can be obtained by taking a frustum (that is, a
truncation with parallel planes) of the cone of vision that a camera or eye
would have to the rectangular viewports typically used in computer graphics.
@@ -108,12 +113,26 @@
This value is the number of degrees between the top and bottom edges
of the camera frustum.
The horizontal FOV determines the number of degrees between the left and
right edges of the camera frustum. It is automatically calculated based on
the aspect ratio of the scene when the FOV orientation is set to vertical.
You can set the orientation to horizontal to translate FOV values from
graphics tools such as Maya and Blender, which use horizontal FOV by
default.
The \uicontrol {FOV orientation} property specifies either a
\uicontrol Vertical (the default setting) or a \uicontrol Horizontal
orientation for the field of view. The horizontal FOV determines the number
of degrees between the left and right edges of the camera frustum. It is
automatically calculated based on the aspect ratio of the scene when the
FOV orientation is set to vertical. You can set the orientation to horizontal
to translate FOV values from graphics tools such as Maya and Blender, which
use horizontal FOV by default.
The \uicontrol {Horizontal magnification} and \uicontrol {Vertical magnification}
properties determine the horizontal and vertical magnification of the camera
frustum.
\note The \uicontrol {Horizontal magnification} and
\uicontrol {Vertical magnification} properties are not available in Qt 5.
The \uicontrol {Frustum culling enabled} property determines whether the
objects outside the camera frustum will be culled, which means they will not
be passed to the renderer.
\note The \uicontrol {Frustum culling enabled} property is not available in
Qt 5.
The default values are intended to cause anything within the view
of the camera to be rendered. Aside from special clipping effects, you

View File

@@ -25,9 +25,15 @@
#include "qmljssimplereader.h"
#include "parser/qmljsparser_p.h"
#include "parser/qmljslexer_p.h"
#ifdef QT_CREATOR
#include "parser/qmljsengine_p.h"
#include "parser/qmljslexer_p.h"
#include "parser/qmljsparser_p.h"
#else
#include "parser/qqmljsengine_p.h"
#include "parser/qqmljslexer_p.h"
#include "qqmljsparser_p.h"
#endif
#include "qmljsutils.h"
@@ -37,308 +43,331 @@
static Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader", QtWarningMsg)
namespace QmlJS{
QVariant SimpleReaderNode::property(const QString &name) const
namespace QmlJS
{
return m_properties.value(name);
}
#ifdef QT_CREATOR
using UiQualifiedId = QmlJS::AST::UiQualifiedId;
#else
using UiQualifiedId = QQmlJS::AST::UiQualifiedId;
#endif
QStringList SimpleReaderNode::propertyNames() const
{
return m_properties.keys();
}
SimpleReaderNode::PropertyHash SimpleReaderNode::properties() const
{
return m_properties;
}
bool SimpleReaderNode::isRoot() const
{
return m_parentNode.isNull();
}
bool SimpleReaderNode::isValid() const
{
return !m_name.isEmpty();
}
SimpleReaderNode::Ptr SimpleReaderNode::invalidNode()
{
return Ptr(new SimpleReaderNode);
}
SimpleReaderNode::WeakPtr SimpleReaderNode::parent() const
{
return m_parentNode;
}
QString SimpleReaderNode::name() const
{
return m_name;
}
SimpleReaderNode::SimpleReaderNode()
{
}
SimpleReaderNode::SimpleReaderNode(const QString &name, WeakPtr parent)
: m_name(name), m_parentNode(parent)
{
}
SimpleReaderNode::Ptr SimpleReaderNode::create(const QString &name, WeakPtr parent)
{
Ptr newNode(new SimpleReaderNode(name, parent));
newNode->m_weakThis = newNode;
if (parent)
parent.toStrongRef().data()->m_children.append(newNode);
return newNode;
}
const SimpleReaderNode::List SimpleReaderNode::children() const
{
return m_children;
}
void SimpleReaderNode::setProperty(const QString &name, const QVariant &value)
{
m_properties.insert(name, value);
}
SimpleAbstractStreamReader::SimpleAbstractStreamReader()
{
}
bool SimpleAbstractStreamReader::readFile(const QString &fileName)
{
QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) {
QByteArray source = file.readAll();
file.close();
return readFromSource(QString::fromLocal8Bit(source));
static SourceLocation toSourceLocation(SourceLocation first, SourceLocation last)
{
first.length = last.end() - first.begin();
return first;
}
addError(tr("Cannot find file %1.").arg(fileName));
return false;
}
bool SimpleAbstractStreamReader::readFromSource(const QString &source)
{
m_errors.clear();
m_currentSourceLocation = SourceLocation();
m_source = source;
Engine engine;
Lexer lexer(&engine);
Parser parser(&engine);
lexer.setCode(source, /*line = */ 1, /*qmlMode = */true);
if (!parser.parse()) {
QString errorMessage = QString::fromLatin1("%1:%2: %3").arg(
QString::number(parser.errorLineNumber()),
QString::number(parser.errorColumnNumber()),
parser.errorMessage());
addError(errorMessage);
return false;
static SourceLocation toSourceLocation(UiQualifiedId * qualifiedId)
{
SourceLocation first = qualifiedId->firstSourceLocation();
SourceLocation last;
for (UiQualifiedId *iter = qualifiedId; iter; iter = iter->next) {
if (iter->lastSourceLocation().isValid())
last = iter->lastSourceLocation();
}
return toSourceLocation(first, last);
}
return readDocument(parser.ast());
}
QStringList SimpleAbstractStreamReader::errors() const
{
return m_errors;
}
SimpleReaderNode::Property SimpleReaderNode::property(const QString &name) const
{
return m_properties.value(name);
}
void SimpleAbstractStreamReader::addError(const QString &error, const SourceLocation &sourceLocation)
{
m_errors << QString::fromLatin1("%1:%2: %3\n").arg(
QString::number(sourceLocation.startLine),
QString::number(sourceLocation.startColumn),
error);
}
QStringList SimpleReaderNode::propertyNames() const { return m_properties.keys(); }
SourceLocation SimpleAbstractStreamReader::currentSourceLocation() const
{
return m_currentSourceLocation;
}
SimpleReaderNode::PropertyHash SimpleReaderNode::properties() const { return m_properties; }
bool SimpleAbstractStreamReader::readDocument(AST::UiProgram *ast)
{
if (!ast) {
addError(tr("Could not parse document."));
bool SimpleReaderNode::isRoot() const { return m_parentNode.isNull(); }
bool SimpleReaderNode::isValid() const { return !m_name.isEmpty(); }
SimpleReaderNode::Ptr SimpleReaderNode::invalidNode() { return Ptr(new SimpleReaderNode); }
SimpleReaderNode::WeakPtr SimpleReaderNode::parent() const { return m_parentNode; }
QString SimpleReaderNode::name() const { return m_name; }
SourceLocation SimpleReaderNode::nameLocation() const { return m_nameLocation; }
SimpleReaderNode::SimpleReaderNode() {}
SimpleReaderNode::SimpleReaderNode(const QString &name,
const SourceLocation &nameLocation,
WeakPtr parent)
: m_name(name)
, m_nameLocation(nameLocation)
, m_parentNode(parent)
{}
SimpleReaderNode::Ptr SimpleReaderNode::create(const QString &name,
const SourceLocation &nameLocation,
WeakPtr parent)
{
Ptr newNode(new SimpleReaderNode(name, nameLocation, parent));
newNode->m_weakThis = newNode;
if (parent)
parent.toStrongRef().data()->m_children.append(newNode);
return newNode;
}
const SimpleReaderNode::List SimpleReaderNode::children() const { return m_children; }
void SimpleReaderNode::setProperty(const QString &name,
const SourceLocation &nameLocation,
const QVariant &value,
const SourceLocation &valueLocation)
{
m_properties.insert(name, {value, nameLocation, valueLocation});
}
SimpleAbstractStreamReader::SimpleAbstractStreamReader() {}
SimpleAbstractStreamReader::~SimpleAbstractStreamReader() {}
bool SimpleAbstractStreamReader::readFile(const QString &fileName)
{
QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) {
QByteArray source = file.readAll();
file.close();
return readFromSource(QString::fromLocal8Bit(source));
}
addError(tr("Cannot find file %1.").arg(fileName));
return false;
}
AST::UiObjectDefinition *uiObjectDefinition = AST::cast<AST::UiObjectDefinition *>(ast->members->member);
if (!uiObjectDefinition) {
addError(tr("Expected document to contain a single object definition."));
return false;
}
readChild(uiObjectDefinition);
bool SimpleAbstractStreamReader::readFromSource(const QString &source)
{
m_errors.clear();
m_currentSourceLocation = SourceLocation();
m_source.clear();
m_source = source;
return errors().isEmpty();
}
Engine engine;
Lexer lexer(&engine);
Parser parser(&engine);
void SimpleAbstractStreamReader::readChildren(AST::UiObjectDefinition *uiObjectDefinition)
{
Q_ASSERT(uiObjectDefinition);
lexer.setCode(source, /*line = */ 1, /*qmlMode = */ true);
for (AST::UiObjectMemberList *it = uiObjectDefinition->initializer->members; it; it = it->next) {
AST::UiObjectMember *member = it->member;
AST::UiObjectDefinition *uiObjectDefinition = AST::cast<AST::UiObjectDefinition *>(member);
if (uiObjectDefinition)
readChild(uiObjectDefinition);
}
}
void SimpleAbstractStreamReader::readChild(AST::UiObjectDefinition *uiObjectDefinition)
{
Q_ASSERT(uiObjectDefinition);
setSourceLocation(uiObjectDefinition->firstSourceLocation());
elementStart(toString(uiObjectDefinition->qualifiedTypeNameId));
readProperties(uiObjectDefinition);
readChildren(uiObjectDefinition);
elementEnd();
}
void SimpleAbstractStreamReader::readProperties(AST::UiObjectDefinition *uiObjectDefinition)
{
Q_ASSERT(uiObjectDefinition);
for (AST::UiObjectMemberList *it = uiObjectDefinition->initializer->members; it; it = it->next) {
AST::UiObjectMember *member = it->member;
AST::UiScriptBinding *scriptBinding = AST::cast<AST::UiScriptBinding *>(member);
if (scriptBinding)
readProperty(scriptBinding);
}
}
void SimpleAbstractStreamReader::readProperty(AST::UiScriptBinding *uiScriptBinding)
{
Q_ASSERT(uiScriptBinding);
setSourceLocation(uiScriptBinding->firstSourceLocation());
const QString name = toString(uiScriptBinding->qualifiedId);
const QVariant value = parsePropertyScriptBinding(uiScriptBinding);
propertyDefinition(name, value);
}
QVariant SimpleAbstractStreamReader::parsePropertyScriptBinding(AST::UiScriptBinding *uiScriptBinding)
{
Q_ASSERT(uiScriptBinding);
AST::ExpressionStatement *expStmt = AST::cast<AST::ExpressionStatement *>(uiScriptBinding->statement);
if (!expStmt) {
addError(tr("Expected expression statement after colon."), uiScriptBinding->statement->firstSourceLocation());
return QVariant();
if (!parser.parse()) {
QString errorMessage = QString::fromLatin1("%1:%2: %3")
.arg(QString::number(parser.errorLineNumber()),
QString::number(parser.errorColumnNumber()),
parser.errorMessage());
addError(errorMessage);
return false;
}
return readDocument(parser.ast());
}
return parsePropertyExpression(expStmt->expression);
}
QStringList SimpleAbstractStreamReader::errors() const { return m_errors; }
QVariant SimpleAbstractStreamReader::parsePropertyExpression(AST::ExpressionNode *expressionNode)
{
Q_ASSERT(expressionNode);
AST::ArrayPattern *arrayLiteral = AST::cast<AST::ArrayPattern *>(expressionNode);
if (arrayLiteral) {
QList<QVariant> variantList;
for (AST::PatternElementList *it = arrayLiteral->elements; it; it = it->next)
variantList << parsePropertyExpression(it->element->initializer);
return variantList;
void SimpleAbstractStreamReader::addError(const QString &error,
const SourceLocation &sourceLocation)
{
m_errors << QString::fromLatin1("%1:%2: %3\n")
.arg(QString::number(sourceLocation.startLine),
QString::number(sourceLocation.startColumn),
error);
}
AST::StringLiteral *stringLiteral = AST::cast<AST::StringLiteral *>(expressionNode);
if (stringLiteral)
return stringLiteral->value.toString();
SourceLocation SimpleAbstractStreamReader::currentSourceLocation() const
{
return m_currentSourceLocation;
}
AST::TrueLiteral *trueLiteral = AST::cast<AST::TrueLiteral *>(expressionNode);
if (trueLiteral)
return true;
bool SimpleAbstractStreamReader::readDocument(AST::UiProgram * ast)
{
if (!ast) {
addError(tr("Could not parse document."));
return false;
}
AST::FalseLiteral *falseLiteral = AST::cast<AST::FalseLiteral *>(expressionNode);
if (falseLiteral)
return false;
AST::UiObjectDefinition *uiObjectDefinition = AST::cast<AST::UiObjectDefinition *>(
ast->members->member);
if (!uiObjectDefinition) {
addError(tr("Expected document to contain a single object definition."));
return false;
}
readChild(uiObjectDefinition);
AST::NumericLiteral *numericLiteral = AST::cast<AST::NumericLiteral *>(expressionNode);
if (numericLiteral)
return numericLiteral->value;
m_source.clear();
return textAt(expressionNode->firstSourceLocation(), expressionNode->lastSourceLocation());
}
return errors().isEmpty();
}
void SimpleAbstractStreamReader::setSourceLocation(const SourceLocation &sourceLocation)
{
m_currentSourceLocation = sourceLocation;
}
void SimpleAbstractStreamReader::readChildren(AST::UiObjectDefinition * uiObjectDefinition)
{
Q_ASSERT(uiObjectDefinition);
QString SimpleAbstractStreamReader::textAt(const SourceLocation &from,
const SourceLocation &to)
{
return m_source.mid(from.offset, to.end() - from.begin());
}
for (AST::UiObjectMemberList *it = uiObjectDefinition->initializer->members; it;
it = it->next) {
AST::UiObjectMember *member = it->member;
AST::UiObjectDefinition *uiObjectDefinition = AST::cast<AST::UiObjectDefinition *>(
member);
if (uiObjectDefinition)
readChild(uiObjectDefinition);
}
}
SimpleReader::SimpleReader()
{
}
void SimpleAbstractStreamReader::readChild(AST::UiObjectDefinition * uiObjectDefinition)
{
Q_ASSERT(uiObjectDefinition);
SimpleReaderNode::Ptr SimpleReader::readFile(const QString &fileName)
{
SimpleAbstractStreamReader::readFile(fileName);
return m_rootNode;
}
setSourceLocation(uiObjectDefinition->firstSourceLocation());
SimpleReaderNode::Ptr SimpleReader::readFromSource(const QString &source)
{
SimpleAbstractStreamReader::readFromSource(source);
return m_rootNode;
}
elementStart(toString(uiObjectDefinition->qualifiedTypeNameId),
toSourceLocation(uiObjectDefinition->qualifiedTypeNameId));
void SimpleReader::elementStart(const QString &name)
{
qCDebug(simpleReaderLog) << "elementStart()" << name;
readProperties(uiObjectDefinition);
readChildren(uiObjectDefinition);
SimpleReaderNode::Ptr newNode = SimpleReaderNode::create(name, m_currentNode);
elementEnd();
}
if (newNode->isRoot())
m_rootNode = newNode;
void SimpleAbstractStreamReader::readProperties(AST::UiObjectDefinition * uiObjectDefinition)
{
Q_ASSERT(uiObjectDefinition);
Q_ASSERT(newNode->isValid());
for (AST::UiObjectMemberList *it = uiObjectDefinition->initializer->members; it;
it = it->next) {
AST::UiObjectMember *member = it->member;
AST::UiScriptBinding *scriptBinding = AST::cast<AST::UiScriptBinding *>(member);
if (scriptBinding)
readProperty(scriptBinding);
}
}
m_currentNode = newNode;
}
void SimpleAbstractStreamReader::readProperty(AST::UiScriptBinding * uiScriptBinding)
{
Q_ASSERT(uiScriptBinding);
void SimpleReader::elementEnd()
{
Q_ASSERT(m_currentNode);
setSourceLocation(uiScriptBinding->firstSourceLocation());
qCDebug(simpleReaderLog) << "elementEnd()" << m_currentNode.toStrongRef().data()->name();
const QString name = toString(uiScriptBinding->qualifiedId);
auto nameLoc = toSourceLocation(uiScriptBinding->qualifiedId);
auto value = parsePropertyScriptBinding(uiScriptBinding);
m_currentNode = m_currentNode.toStrongRef().data()->parent();
}
propertyDefinition(name, nameLoc, value.first, value.second);
}
void SimpleReader::propertyDefinition(const QString &name, const QVariant &value)
{
Q_ASSERT(m_currentNode);
std::pair<QVariant, SourceLocation> SimpleAbstractStreamReader::parsePropertyScriptBinding(
AST::UiScriptBinding * uiScriptBinding)
{
Q_ASSERT(uiScriptBinding);
qCDebug(simpleReaderLog) << "propertyDefinition()" << m_currentNode.toStrongRef().data()->name() << name << value;
AST::ExpressionStatement *expStmt = AST::cast<AST::ExpressionStatement *>(
uiScriptBinding->statement);
if (!expStmt) {
addError(tr("Expected expression statement after colon."),
uiScriptBinding->statement->firstSourceLocation());
return std::make_pair(QVariant(), SourceLocation());
}
if (m_currentNode.toStrongRef().data()->propertyNames().contains(name))
addError(tr("Property is defined twice."), currentSourceLocation());
return std::make_pair(parsePropertyExpression(expStmt->expression),
toSourceLocation(expStmt->firstSourceLocation(),
expStmt->lastSourceLocation()));
}
m_currentNode.toStrongRef().data()->setProperty(name, value);
}
QVariant SimpleAbstractStreamReader::parsePropertyExpression(AST::ExpressionNode
* expressionNode)
{
Q_ASSERT(expressionNode);
AST::ArrayPattern *arrayLiteral = AST::cast<AST::ArrayPattern *>(expressionNode);
if (arrayLiteral) {
QList<QVariant> variantList;
for (AST::PatternElementList *it = arrayLiteral->elements; it; it = it->next)
variantList << parsePropertyExpression(it->element->initializer);
return variantList;
}
AST::StringLiteral *stringLiteral = AST::cast<AST::StringLiteral *>(expressionNode);
if (stringLiteral)
return stringLiteral->value.toString();
AST::TrueLiteral *trueLiteral = AST::cast<AST::TrueLiteral *>(expressionNode);
if (trueLiteral)
return true;
AST::FalseLiteral *falseLiteral = AST::cast<AST::FalseLiteral *>(expressionNode);
if (falseLiteral)
return false;
AST::NumericLiteral *numericLiteral = AST::cast<AST::NumericLiteral *>(expressionNode);
if (numericLiteral)
return numericLiteral->value;
return textAt(expressionNode->firstSourceLocation(), expressionNode->lastSourceLocation());
}
void SimpleAbstractStreamReader::setSourceLocation(const SourceLocation &sourceLocation)
{
m_currentSourceLocation = sourceLocation;
}
QString SimpleAbstractStreamReader::textAt(const SourceLocation &from, const SourceLocation &to)
{
return m_source.mid(from.offset, to.end() - from.begin());
}
SimpleReader::SimpleReader() {}
SimpleReaderNode::Ptr SimpleReader::readFile(const QString &fileName)
{
SimpleAbstractStreamReader::readFile(fileName);
return m_rootNode;
}
SimpleReaderNode::Ptr SimpleReader::readFromSource(const QString &source)
{
SimpleAbstractStreamReader::readFromSource(source);
return m_rootNode;
}
void SimpleReader::elementStart(const QString &name, const SourceLocation &nameLocation)
{
qCDebug(simpleReaderLog) << "elementStart()" << name;
SimpleReaderNode::Ptr newNode = SimpleReaderNode::create(name, nameLocation, m_currentNode);
if (newNode->isRoot())
m_rootNode = newNode;
Q_ASSERT(newNode->isValid());
m_currentNode = newNode;
}
void SimpleReader::elementEnd()
{
Q_ASSERT(m_currentNode);
qCDebug(simpleReaderLog) << "elementEnd()" << m_currentNode.toStrongRef().data()->name();
m_currentNode = m_currentNode.toStrongRef().data()->parent();
}
void SimpleReader::propertyDefinition(const QString &name,
const SourceLocation &nameLocation,
const QVariant &value,
const SourceLocation &valueLocation)
{
Q_ASSERT(m_currentNode);
qCDebug(simpleReaderLog) << "propertyDefinition()"
<< m_currentNode.toStrongRef().data()->name() << name << value;
if (m_currentNode.toStrongRef().data()->propertyNames().contains(name)) {
auto previousSourceLoc = m_currentNode.toStrongRef().data()->property(name).nameLocation;
addError(tr("Property is defined twice, previous definition at %1:%2")
.arg(QString::number(previousSourceLoc.startLine),
QString::number(previousSourceLoc.startColumn)),
currentSourceLocation());
}
m_currentNode.toStrongRef().data()->setProperty(name, nameLocation, value, valueLocation);
}
} // namespace QmlJS

View File

@@ -26,13 +26,18 @@
#pragma once
#include <qmljs/qmljs_global.h>
#include <qmljs/parser/qmljsastfwd_p.h>
#ifdef QT_CREATOR
#include <qmljs/parser/qmljsastfwd_p.h>
#else
#include <parser/qqmljsastfwd_p.h>
#endif
#include <QHash>
#include <QList>
#include <QStringList>
#include <QSharedPointer>
#include <QStringList>
#include <QVariant>
#include <QWeakPointer>
// for Q_DECLARE_TR_FUNCTIONS
@@ -40,15 +45,31 @@
namespace QmlJS {
#ifndef QT_CREATOR
using SourceLocation = QQmlJS::SourceLocation;
#endif
class QMLJS_EXPORT SimpleReaderNode
{
public:
struct Property
{
QVariant value;
SourceLocation nameLocation;
SourceLocation valueLocation;
bool isValid() const { return !value.isNull() && value.isValid(); }
bool isDefaultValue() const
{
return !value.isNull() && !nameLocation.isValid() && !valueLocation.isValid();
}
};
typedef QSharedPointer<SimpleReaderNode> Ptr;
typedef QWeakPointer<SimpleReaderNode> WeakPtr;
typedef QHash<QString, QVariant> PropertyHash;
typedef QHash<QString, Property> PropertyHash;
typedef QList<Ptr> List;
QVariant property(const QString &name) const;
Property property(const QString &name) const;
QStringList propertyNames() const;
PropertyHash properties() const;
bool isRoot() const;
@@ -56,16 +77,21 @@ public:
static Ptr invalidNode();
WeakPtr parent() const;
QString name() const;
SourceLocation nameLocation() const;
const List children() const;
protected:
SimpleReaderNode();
SimpleReaderNode(const QString &name, WeakPtr parent);
static Ptr create(const QString &name, WeakPtr parent);
void setProperty(const QString &name, const QVariant &value);
SimpleReaderNode(const QString &name, const SourceLocation &nameLocation, WeakPtr parent);
static Ptr create(const QString &name, const SourceLocation &nameLocation, WeakPtr parent);
void setProperty(const QString &name,
const SourceLocation &nameLocation,
const QVariant &value,
const SourceLocation &valueLocation);
private:
const QString m_name;
const SourceLocation m_nameLocation;
PropertyHash m_properties;
const WeakPtr m_parentNode;
List m_children;
@@ -74,12 +100,17 @@ private:
friend class SimpleReader;
};
#ifndef QT_CREATOR
using namespace QQmlJS;
#endif
class QMLJS_EXPORT SimpleAbstractStreamReader
{
Q_DECLARE_TR_FUNCTIONS(QmlJS::SimpleAbstractStreamReader)
public:
SimpleAbstractStreamReader();
virtual ~SimpleAbstractStreamReader();
bool readFile(const QString &fileName);
bool readFromSource(const QString &source);
QStringList errors() const;
@@ -88,9 +119,13 @@ protected:
void addError(const QString &error, const SourceLocation &sourceLocation = SourceLocation());
SourceLocation currentSourceLocation() const;
virtual void elementStart(const QString &name) = 0;
virtual void elementStart(const QString &name, const SourceLocation &nameLocation) = 0;
virtual void elementEnd() = 0;
virtual void propertyDefinition(const QString &name, const QVariant &value) = 0;
virtual void propertyDefinition(const QString &name,
const SourceLocation &nameLocation,
const QVariant &value,
const SourceLocation &valueLocation)
= 0;
private:
bool readDocument(AST::UiProgram *ast);
@@ -98,7 +133,8 @@ private:
void readChild(AST::UiObjectDefinition *uiObjectDefinition);
void readProperties(AST::UiObjectDefinition *ast);
void readProperty(AST::UiScriptBinding *uiScriptBinding);
QVariant parsePropertyScriptBinding(AST::UiScriptBinding *ExpressionNode);
std::pair<QVariant, SourceLocation> parsePropertyScriptBinding(
AST::UiScriptBinding *ExpressionNode);
QVariant parsePropertyExpression(AST::ExpressionNode *expressionNode);
void setSourceLocation(const SourceLocation &sourceLocation);
QString textAt(const SourceLocation &from, const SourceLocation &to);
@@ -118,9 +154,12 @@ public:
SimpleReaderNode::Ptr readFromSource(const QString &source);
protected:
void elementStart(const QString &name) override;
void elementStart(const QString &name, const SourceLocation &nameLocation) override;
void elementEnd() override;
void propertyDefinition(const QString &name, const QVariant &value) override;
void propertyDefinition(const QString &name,
const SourceLocation &nameLocation,
const QVariant &value,
const SourceLocation &valueLocation) override;
private:
SimpleReaderNode::Ptr m_rootNode;

View File

@@ -80,6 +80,16 @@ QString FileWizardPage::fileName() const
return d->m_ui.nameLineEdit->text();
}
FilePath FileWizardPage::filePath() const
{
return d->m_ui.pathChooser->filePath();
}
void FileWizardPage::setFilePath(const FilePath &filePath)
{
d->m_ui.pathChooser->setFilePath(filePath);
}
QString FileWizardPage::path() const
{
return d->m_ui.pathChooser->filePath().toString();
@@ -87,7 +97,7 @@ QString FileWizardPage::path() const
void FileWizardPage::setPath(const QString &path)
{
d->m_ui.pathChooser->setPath(path);
d->m_ui.pathChooser->setFilePath(FilePath::fromString(path));
}
void FileWizardPage::setFileName(const QString &name)

View File

@@ -27,6 +27,7 @@
#include "utils_global.h"
#include "filepath.h"
#include "wizardpage.h"
namespace Utils {
@@ -44,7 +45,9 @@ public:
~FileWizardPage() override;
QString fileName() const;
QString path() const;
QString path() const; // Deprecated: Use filePath()
Utils::FilePath filePath() const;
bool isComplete() const override;
@@ -64,8 +67,9 @@ signals:
void pathChanged();
public slots:
void setPath(const QString &path);
void setPath(const QString &path); // Deprecated: Use setFilePath
void setFileName(const QString &name);
void setFilePath(const Utils::FilePath &filePath);
private:
void slotValidChanged();

View File

@@ -1298,11 +1298,6 @@ void ClangdTestHighlighting::test()
"check if and how we want to support this", Abort);
QEXPECT_FAIL("old-style signal with complex parameter (signal parameter part 3)",
"check if and how we want to support this", Abort);
QEXPECT_FAIL("alias template instantiation (type)", "FIXME: clangd doesn't report this", Abort);
QEXPECT_FAIL("alias template instantiation (opening angle bracket)",
"FIXME: This construct does not appear in the AST", Abort);
QEXPECT_FAIL("alias template instantiation (closing angle bracket)",
"FIXME: This construct does not appear in the AST", Abort);
QEXPECT_FAIL("function template specialization (opening angle bracket 1)",
"specialization appears as a normal function in the AST", Abort);
QEXPECT_FAIL("function template specialization (closing angle bracket 1)",

View File

@@ -54,5 +54,6 @@
<file>completion/preprocessorKeywordsCompletion2.cpp</file>
<file>completion/preprocessorKeywordsCompletion3.cpp</file>
<file>completion/privateFuncDefCompletion.cpp</file>
<file>highlighting/highlightingmarks.h</file>
</qresource>
</RCC>

View File

@@ -86,11 +86,11 @@ Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const FilePath &path, QWidge
if (flags().testFlag(ForceCapitalLetterForFileName))
dialogParameterFlags |= WizardDialogParameters::ForceCapitalLetterForFileName;
Utils::Wizard *wizard = create(parent, WizardDialogParameters(path.toString(),
platform,
requiredFeatures(),
dialogParameterFlags,
extraValues));
Wizard *wizard = create(parent, WizardDialogParameters(path,
platform,
requiredFeatures(),
dialogParameterFlags,
extraValues));
QTC_CHECK(wizard);
return wizard;
}
@@ -287,21 +287,17 @@ BaseFileWizardFactory::OverwriteResult BaseFileWizardFactory::promptOverwrite(Ge
\a baseName already has one.
*/
QString BaseFileWizardFactory::buildFileName(const QString &path,
const QString &baseName,
const QString &extension)
FilePath BaseFileWizardFactory::buildFileName(const FilePath &path,
const QString &baseName,
const QString &extension)
{
QString rc = path;
const QChar slash = QLatin1Char('/');
if (!rc.isEmpty() && !rc.endsWith(slash))
rc += slash;
rc += baseName;
FilePath rc = path.pathAppended(baseName);
// Add extension unless user specified something else
const QChar dot = QLatin1Char('.');
const QChar dot = '.';
if (!extension.isEmpty() && !baseName.contains(dot)) {
if (!extension.startsWith(dot))
rc += dot;
rc += extension;
rc = rc.stringAppended(dot);
rc = rc.stringAppended(extension);
}
if (debugWizard)
qDebug() << Q_FUNC_INFO << rc;

View File

@@ -30,6 +30,8 @@
#include <coreplugin/iwizardfactory.h>
#include <utils/filepath.h>
#include <QList>
#include <QVariantMap>
@@ -54,7 +56,7 @@ public:
};
Q_DECLARE_FLAGS(DialogParameterFlags, DialogParameterEnum)
explicit WizardDialogParameters(const QString &defaultPath, Utils::Id platform,
explicit WizardDialogParameters(const Utils::FilePath &defaultPath, Utils::Id platform,
const QSet<Utils::Id> &requiredFeatures, DialogParameterFlags flags,
const QVariantMap &extraValues)
: m_defaultPath(defaultPath),
@@ -64,23 +66,14 @@ public:
m_extraValues(extraValues)
{}
QString defaultPath() const
{ return m_defaultPath; }
Utils::Id selectedPlatform() const
{ return m_selectedPlatform; }
QSet<Utils::Id> requiredFeatures() const
{ return m_requiredFeatures; }
DialogParameterFlags flags() const
{ return m_parameterFlags; }
QVariantMap extraValues() const
{ return m_extraValues; }
Utils::FilePath defaultPath() const { return m_defaultPath; }
Utils::Id selectedPlatform() const { return m_selectedPlatform; }
QSet<Utils::Id> requiredFeatures() const { return m_requiredFeatures; }
DialogParameterFlags flags() const { return m_parameterFlags; }
QVariantMap extraValues() const { return m_extraValues; }
private:
QString m_defaultPath;
Utils::FilePath m_defaultPath;
Utils::Id m_selectedPlatform;
QSet<Utils::Id> m_requiredFeatures;
DialogParameterFlags m_parameterFlags;
@@ -94,7 +87,7 @@ class CORE_EXPORT BaseFileWizardFactory : public IWizardFactory
friend class BaseFileWizard;
public:
static QString buildFileName(const QString &path, const QString &baseName, const QString &extension);
static Utils::FilePath buildFileName(const Utils::FilePath &path, const QString &baseName, const QString &extension);
protected:
virtual BaseFileWizard *create(QWidget *parent, const WizardDialogParameters &parameters) const = 0;

View File

@@ -32,6 +32,8 @@
#include <QDebug>
using namespace Utils;
namespace Designer {
namespace Internal {
@@ -58,7 +60,7 @@ QString FormClassWizard::formSuffix() const
Core::BaseFileWizard *FormClassWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const
{
auto wizardDialog = new FormClassWizardDialog(this, parent);
wizardDialog->setPath(parameters.defaultPath());
wizardDialog->setFilePath(parameters.defaultPath());
return wizardDialog;
}
@@ -73,9 +75,9 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e
}
// header
const QString formFileName = buildFileName(params.path, params.uiFile, formSuffix());
const QString headerFileName = buildFileName(params.path, params.headerFile, headerSuffix());
const QString sourceFileName = buildFileName(params.path, params.sourceFile, sourceSuffix());
const FilePath formFileName = buildFileName(params.path, params.uiFile, formSuffix());
const FilePath headerFileName = buildFileName(params.path, params.headerFile, headerSuffix());
const FilePath sourceFileName = buildFileName(params.path, params.sourceFile, sourceSuffix());
Core::GeneratedFile headerFile(headerFileName);
headerFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
@@ -102,5 +104,5 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e
return Core::GeneratedFiles() << headerFile << sourceFile << uiFile;
}
}
}
} // Internal
} // Designer

View File

@@ -26,9 +26,13 @@
#include "formclasswizarddialog.h"
#include "formclasswizardpage.h"
#include "formclasswizardparameters.h"
#include <cppeditor/abstracteditorsupport.h>
#include <designer/formtemplatewizardpage.h>
#include <qtsupport/codegenerator.h>
#include <utils/filepath.h>
using namespace Utils;
enum { FormPageId, ClassPageId };
@@ -52,14 +56,14 @@ FormClassWizardDialog::FormClassWizardDialog(const Core::BaseFileWizardFactory *
addPage(p);
}
QString FormClassWizardDialog::path() const
FilePath FormClassWizardDialog::filePath() const
{
return m_classPage->path();
return m_classPage->filePath();
}
void FormClassWizardDialog::setPath(const QString &p)
void FormClassWizardDialog::setFilePath(const FilePath &p)
{
m_classPage->setPath(p);
m_classPage->setFilePath(p);
}
void FormClassWizardDialog::initializePage(int id)

View File

@@ -45,8 +45,8 @@ public:
explicit FormClassWizardDialog(const Core::BaseFileWizardFactory *factory, QWidget *parent = nullptr);
QString path() const;
void setPath(const QString &);
Utils::FilePath filePath() const;
void setFilePath(const Utils::FilePath &);
Designer::FormClassWizardParameters parameters() const;

View File

@@ -32,9 +32,8 @@
#include <coreplugin/icore.h>
#include <cppeditor/cppeditorconstants.h>
#include <utils/mimetypes/mimedatabase.h>
#
#include <QDebug>
#include <QDebug>
#include <QMessageBox>
namespace Designer {
@@ -88,20 +87,20 @@ void FormClassWizardPage::setClassName(const QString &suggestedClassName)
slotValidChanged();
}
QString FormClassWizardPage::path() const
Utils::FilePath FormClassWizardPage::filePath() const
{
return m_ui->newClassWidget->path();
return m_ui->newClassWidget->filePath();
}
void FormClassWizardPage::setPath(const QString &p)
void FormClassWizardPage::setFilePath(const Utils::FilePath &p)
{
m_ui->newClassWidget->setPath(p);
m_ui->newClassWidget->setFilePath(p);
}
void FormClassWizardPage::getParameters(FormClassWizardParameters *p) const
{
p->className = m_ui->newClassWidget->className();
p->path = path();
p->path = filePath();
p->sourceFile = m_ui->newClassWidget->sourceFileName();
p->headerFile = m_ui->newClassWidget->headerFileName();
p->uiFile = m_ui->newClassWidget-> formFileName();

View File

@@ -27,6 +27,8 @@
#include <QWizardPage>
namespace Utils { class FilePath; }
namespace Designer {
class FormClassWizardParameters;
@@ -49,8 +51,8 @@ public:
bool validatePage() override;
void setClassName(const QString &suggestedClassName);
void setPath(const QString &);
QString path() const;
void setFilePath(const Utils::FilePath &);
Utils::FilePath filePath() const;
// Fill out applicable parameters
void getParameters(FormClassWizardParameters *) const;

View File

@@ -25,7 +25,8 @@
#pragma once
#include <QString>
#include <utils/filepath.h>
#include <QMetaType>
namespace Designer {
@@ -39,7 +40,7 @@ class FormClassWizardParameters
public:
QString uiTemplate;
QString className;
QString path;
Utils::FilePath path;
QString sourceFile;
QString headerFile;
QString uiFile;

View File

@@ -29,6 +29,8 @@
#include <QFileDialog>
#include <QDebug>
using namespace Utils;
enum { debugNewClassWidget = 0 };
/*! \class Utils::NewClassWidget
@@ -171,14 +173,14 @@ QString NewClassWidget::formFileName() const
return d->m_ui.formFileLineEdit->text();
}
QString NewClassWidget::path() const
FilePath NewClassWidget::filePath() const
{
return d->m_ui.pathChooser->filePath().toString();
return d->m_ui.pathChooser->filePath();
}
void NewClassWidget::setPath(const QString &path)
void NewClassWidget::setFilePath(const FilePath &path)
{
d->m_ui.pathChooser->setPath(path);
d->m_ui.pathChooser->setFilePath(path);
}
QString NewClassWidget::sourceExtension() const
@@ -305,21 +307,21 @@ static QString ensureSuffix(QString f, const QString &extension)
}
// If a non-empty name was passed, expand to directory and suffix
static QString expandFileName(const QDir &dir, const QString &name, const QString &extension)
static FilePath expandFileName(const FilePath &dir, const QString &name, const QString &extension)
{
if (name.isEmpty())
return QString();
return dir.absoluteFilePath(ensureSuffix(name, extension));
return {};
return dir / ensureSuffix(name, extension);
}
QStringList NewClassWidget::files() const
Utils::FilePaths NewClassWidget::files() const
{
QStringList rc;
const QDir dir = QDir(path());
rc.push_back(expandFileName(dir, headerFileName(), headerExtension()));
rc.push_back(expandFileName(dir, sourceFileName(), sourceExtension()));
rc.push_back(expandFileName(dir, formFileName(), formExtension()));
return rc;
const FilePath dir = filePath();
return {
expandFileName(dir, headerFileName(), headerExtension()),
expandFileName(dir, sourceFileName(), sourceExtension()),
expandFileName(dir, formFileName(), formExtension()),
};
}
} // namespace Internal

View File

@@ -25,6 +25,8 @@
#pragma once
#include <utils/filepath.h>
#include <QWidget>
namespace Designer {
@@ -52,14 +54,14 @@ public:
QString sourceFileName() const;
QString headerFileName() const;
QString formFileName() const;
QString path() const;
Utils::FilePath filePath() const;
QString sourceExtension() const;
QString headerExtension() const;
QString formExtension() const;
bool isValid(QString *error = nullptr) const;
QStringList files() const;
Utils::FilePaths files() const;
signals:
void validChanged();
@@ -72,7 +74,7 @@ public slots:
* valid class name.
*/
void setClassName(const QString &suggestedName);
void setPath(const QString &path);
void setFilePath(const Utils::FilePath &filePath);
void setSourceExtension(const QString &e);
void setHeaderExtension(const QString &e);
void setLowerCaseFiles(bool v);

View File

@@ -473,6 +473,18 @@ IDeviceWidget *DockerDevice::createWidget()
return new DockerDeviceWidget(sharedFromThis());
}
Tasks DockerDevice::validate() const
{
Tasks result;
if (d->m_data.mounts.isEmpty()) {
result << Task(Task::Error,
tr("The Docker device has not set up shared directories."
"This will not work for building."),
{}, -1, {});
}
return result;
}
// DockerDevice

View File

@@ -62,6 +62,7 @@ public:
static Ptr create(const DockerDeviceData &data) { return Ptr(new DockerDevice(data)); }
ProjectExplorer::IDeviceWidget *createWidget() override;
QVector<ProjectExplorer::Task> validate() const override;
bool canCreateProcess() const override { return true; }
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const override;

View File

@@ -59,8 +59,7 @@ FilesSelectionWizardPage::FilesSelectionWizardPage(GenericProjectWizardDialog *g
void FilesSelectionWizardPage::initializePage()
{
m_filesWidget->resetModel(Utils::FilePath::fromString(m_genericProjectWizardDialog->path()),
Utils::FilePaths());
m_filesWidget->resetModel(m_genericProjectWizardDialog->filePath(), Utils::FilePaths());
}
void FilesSelectionWizardPage::cleanupPage()

View File

@@ -46,13 +46,14 @@
#include <QPixmap>
#include <QStyle>
using namespace Utils;
namespace GenericProjectManager {
namespace Internal {
static const char *const ConfigFileTemplate =
const char ConfigFileTemplate[] =
"// Add predefined macros for your project here. For example:\n"
"// #define THE_ANSWER 42\n"
;
"// #define THE_ANSWER 42\n";
//////////////////////////////////////////////////////////////////////////////
//
@@ -79,24 +80,24 @@ GenericProjectWizardDialog::GenericProjectWizardDialog(const Core::BaseFileWizar
addPage(m_secondPage);
}
QString GenericProjectWizardDialog::path() const
FilePath GenericProjectWizardDialog::filePath() const
{
return m_firstPage->path();
return m_firstPage->filePath();
}
Utils::FilePaths GenericProjectWizardDialog::selectedPaths() const
FilePaths GenericProjectWizardDialog::selectedPaths() const
{
return m_secondPage->selectedPaths();
}
Utils::FilePaths GenericProjectWizardDialog::selectedFiles() const
FilePaths GenericProjectWizardDialog::selectedFiles() const
{
return m_secondPage->selectedFiles();
}
void GenericProjectWizardDialog::setPath(const QString &path)
void GenericProjectWizardDialog::setFilePath(const FilePath &path)
{
m_firstPage->setPath(path);
m_firstPage->setFilePath(path);
}
QString GenericProjectWizardDialog::projectName() const
@@ -129,7 +130,7 @@ Core::BaseFileWizard *GenericProjectWizard::create(QWidget *parent,
{
auto wizard = new GenericProjectWizardDialog(this, parent);
wizard->setPath(parameters.defaultPath());
wizard->setFilePath(parameters.defaultPath());
foreach (QWizardPage *p, wizard->extensionPages())
wizard->addPage(p);
@@ -143,15 +144,14 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
Q_UNUSED(errorMessage)
auto wizard = qobject_cast<const GenericProjectWizardDialog *>(w);
const QString projectPath = wizard->path();
const QDir dir(projectPath);
const FilePath projectPath = wizard->filePath();
const QString projectName = wizard->projectName();
const QString creatorFileName = QFileInfo(dir, projectName + QLatin1String(".creator")).absoluteFilePath();
const QString filesFileName = QFileInfo(dir, projectName + QLatin1String(".files")).absoluteFilePath();
const QString includesFileName = QFileInfo(dir, projectName + QLatin1String(".includes")).absoluteFilePath();
const QString configFileName = QFileInfo(dir, projectName + QLatin1String(".config")).absoluteFilePath();
const QString cxxflagsFileName = QFileInfo(dir, projectName + QLatin1String(".cxxflags")).absoluteFilePath();
const QString cflagsFileName = QFileInfo(dir, projectName + QLatin1String(".cflags")).absoluteFilePath();
const FilePath creatorFileName = projectPath.pathAppended(projectName + ".creator");
const FilePath filesFileName = projectPath.pathAppended(projectName + ".files");
const FilePath includesFileName = projectPath.pathAppended(projectName + ".includes");
const FilePath configFileName = projectPath.pathAppended(projectName + ".config");
const FilePath cxxflagsFileName = projectPath.pathAppended(projectName + ".cxxflags");
const FilePath cflagsFileName = projectPath.pathAppended(projectName + ".cflags");
const QStringList paths = Utils::transform(wizard->selectedPaths(), &Utils::FilePath::toString);
Utils::MimeType headerTy = Utils::mimeTypeForName(QLatin1String("text/x-chdr"));
@@ -159,6 +159,7 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
QStringList nameFilters = headerTy.globPatterns();
QStringList includePaths;
const QDir dir(projectPath.toString());
foreach (const QString &path, paths) {
QFileInfo fileInfo(path);
QDir thisDir(fileInfo.absoluteFilePath());

View File

@@ -44,8 +44,8 @@ class GenericProjectWizardDialog : public Core::BaseFileWizard
public:
explicit GenericProjectWizardDialog(const Core::BaseFileWizardFactory *factory, QWidget *parent = nullptr);
QString path() const;
void setPath(const QString &path);
Utils::FilePath filePath() const;
void setFilePath(const Utils::FilePath &path);
Utils::FilePaths selectedFiles() const;
Utils::FilePaths selectedPaths() const;

View File

@@ -983,7 +983,7 @@ void GitClient::requestReload(const QString &documentId, const QString &source,
QTC_ASSERT(document, return);
GitBaseDiffEditorController *controller = factory(document);
QTC_ASSERT(controller, return);
controller->setVcsBinary(settings().binaryPath.filePath());
controller->setVcsBinary(settings().gitExecutable());
controller->setVcsTimeoutS(settings().timeout.value());
controller->setProcessEnvironment(processEnvironment());
controller->setWorkingDirectory(workingDirectory);

View File

@@ -25,6 +25,7 @@
#include "gitsettings.h"
#include <utils/environment.h>
#include <utils/layoutbuilder.h>
#include <vcsbase/vcsbaseconstants.h>
@@ -140,6 +141,12 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
errorMessage->clear();
FilePath binPath = binaryPath.filePath();
if (!binPath.isAbsolutePath()) {
Environment env = Environment::systemEnvironment();
if (!path.filePath().isEmpty())
env.prependOrSetPath(path.filePath().toString());
binPath = env.searchInPath(binPath.toString());
}
if (binPath.isEmpty()) {
if (ok)
*ok = false;

View File

@@ -36,6 +36,7 @@
#include <QStandardPaths>
using namespace ProjectExplorer;
using namespace Utils;
namespace IncrediBuild {
namespace Internal {
@@ -45,11 +46,11 @@ QList<Utils::Id> CMakeCommandBuilder::migratableSteps() const
return {CMakeProjectManager::Constants::CMAKE_BUILD_STEP_ID};
}
QString CMakeCommandBuilder::defaultCommand() const
FilePath CMakeCommandBuilder::defaultCommand() const
{
const QString defaultCMake = "cmake";
const QString cmake = QStandardPaths::findExecutable(defaultCMake);
return cmake.isEmpty() ? defaultCMake : cmake;
return FilePath::fromString(cmake.isEmpty() ? defaultCMake : cmake);
}
QString CMakeCommandBuilder::defaultArguments() const

View File

@@ -41,7 +41,7 @@ private:
QList<Utils::Id> migratableSteps() const final;
QString id() const final { return "CMakeCommandBuilder"; }
QString displayName() const final { return tr("CMake"); }
QString defaultCommand() const final;
Utils::FilePath defaultCommand() const final;
QString defaultArguments() const final;
QString setMultiProcessArg(QString args) final;
};

View File

@@ -25,27 +25,27 @@
#include "commandbuilder.h"
using namespace Utils;
namespace IncrediBuild {
namespace Internal {
namespace Constants {
const QLatin1String CUSTOMCOMMANDBUILDER_COMMAND("IncrediBuild.BuildConsole.%1.Command");
const QLatin1String CUSTOMCOMMANDBUILDER_ARGS("IncrediBuild.BuildConsole.%1.Arguments");
} // namespace Constants
const char CUSTOMCOMMANDBUILDER_COMMAND[] = "IncrediBuild.BuildConsole.%1.Command";
const char CUSTOMCOMMANDBUILDER_ARGS[] = "IncrediBuild.BuildConsole.%1.Arguments";
void CommandBuilder::fromMap(const QVariantMap &map)
{
m_command = map.value(QString(Constants::CUSTOMCOMMANDBUILDER_COMMAND).arg(id())).toString();
m_args = map.value(QString(Constants::CUSTOMCOMMANDBUILDER_ARGS).arg(id())).toString();
m_command = FilePath::fromVariant(map.value(QString(CUSTOMCOMMANDBUILDER_COMMAND).arg(id())));
m_args = map.value(QString(CUSTOMCOMMANDBUILDER_ARGS).arg(id())).toString();
}
void CommandBuilder::toMap(QVariantMap *map) const
{
(*map)[QString(Constants::CUSTOMCOMMANDBUILDER_COMMAND).arg(id())] = QVariant(m_command);
(*map)[QString(Constants::CUSTOMCOMMANDBUILDER_ARGS).arg(id())] = QVariant(m_args);
(*map)[QString(CUSTOMCOMMANDBUILDER_COMMAND).arg(id())] = m_command.toVariant();
(*map)[QString(CUSTOMCOMMANDBUILDER_ARGS).arg(id())] = QVariant(m_args);
}
void CommandBuilder::setCommand(const QString &command)
void CommandBuilder::setCommand(const FilePath &command)
{
m_command = command;
}

View File

@@ -50,20 +50,20 @@ public:
virtual void fromMap(const QVariantMap &map);
virtual void toMap(QVariantMap *map) const;
virtual QString defaultCommand() const { return QString(); }
virtual Utils::FilePath defaultCommand() const { return {}; }
virtual QString defaultArguments() const { return QString(); }
virtual QString setMultiProcessArg(QString args) { return args; }
QString command() const { return m_command; }
void setCommand(const QString &command);
QString effectiveCommand() const { return m_command.isEmpty() ? defaultCommand() : m_command; }
Utils::FilePath command() const { return m_command; }
void setCommand(const Utils::FilePath &command);
Utils::FilePath effectiveCommand() const { return m_command.isEmpty() ? defaultCommand() : m_command; }
QString arguments() { return m_args.isEmpty() ? defaultArguments() : m_args; }
void setArguments(const QString &arguments);
private:
ProjectExplorer::BuildStep *m_buildStep{};
QString m_command;
Utils::FilePath m_command;
QString m_args;
};

View File

@@ -101,7 +101,7 @@ QString CommandBuilderAspect::fullCommandFlag(bool keepJobNum) const
argsLine = d->m_activeCommandBuilder->setMultiProcessArg(argsLine);
QString fullCommand("\"%1\" %2");
fullCommand = fullCommand.arg(d->m_activeCommandBuilder->effectiveCommand(), argsLine);
fullCommand = fullCommand.arg(d->m_activeCommandBuilder->effectiveCommand().toUserOutput(), argsLine);
return fullCommand;
}
@@ -153,7 +153,7 @@ void CommandBuilderAspect::addToLayout(LayoutBuilder &builder)
d->makePathChooser->setBaseDirectory(PathChooser::homePath());
d->makePathChooser->setHistoryCompleter("IncrediBuild.BuildConsole.MakeCommand.History");
connect(d->makePathChooser, &PathChooser::rawPathChanged, this, [this] {
d->m_activeCommandBuilder->setCommand(d->makePathChooser->rawPath());
d->m_activeCommandBuilder->setCommand(d->makePathChooser->rawFilePath());
updateGui();
});
}
@@ -212,9 +212,9 @@ void CommandBuilderAspect::updateGui()
d->commandBuilder->setCurrentText(d->m_activeCommandBuilder->displayName());
const QString defaultCommand = d->m_activeCommandBuilder->defaultCommand();
d->makePathChooser->setPath(d->m_activeCommandBuilder->command());
d->makePathChooser->setDefaultValue(defaultCommand);
const FilePath defaultCommand = d->m_activeCommandBuilder->defaultCommand();
d->makePathChooser->setFilePath(d->m_activeCommandBuilder->command());
d->makePathChooser->setDefaultValue(defaultCommand.toUserOutput());
const QString defaultArgs = d->m_activeCommandBuilder->defaultArguments();
d->makeArgumentsLineEdit->setPlaceholderText(defaultArgs);

View File

@@ -41,6 +41,7 @@
#include <QRegularExpression>
using namespace ProjectExplorer;
using namespace Utils;
namespace IncrediBuild {
namespace Internal {
@@ -50,35 +51,32 @@ QList<Utils::Id> MakeCommandBuilder::migratableSteps() const
return {QmakeProjectManager::Constants::MAKESTEP_BS_ID};
}
QString MakeCommandBuilder::defaultCommand() const
Utils::FilePath MakeCommandBuilder::defaultCommand() const
{
BuildConfiguration *buildConfig = buildStep()->buildConfiguration();
if (buildConfig) {
Target *target = buildStep()->target();
if (target) {
ToolChain *toolChain = ToolChainKitAspect::toolChain(target->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
if (toolChain)
return toolChain->makeCommand(buildConfig->environment()).toUserOutput();
if (Target *target = buildStep()->target()) {
if (ToolChain *toolChain = ToolChainKitAspect::cxxToolChain(target->kit()))
return toolChain->makeCommand(buildConfig->environment());
}
}
return QString();
return {};
}
QString MakeCommandBuilder::setMultiProcessArg(QString args)
{
QString cmd = command();
QFileInfo fileInfo(cmd);
const FilePath cmd = command();
// jom -j 200
if (fileInfo.baseName().compare("jom", Qt::CaseSensitivity::CaseInsensitive) == 0) {
if (cmd.baseName().compare("jom", Qt::CaseSensitivity::CaseInsensitive) == 0) {
QRegularExpression regExp("\\s*\\-j\\s+\\d+");
args.remove(regExp);
args.append(" -j 200");
}
// make -j200
else if ((fileInfo.baseName().compare("make", Qt::CaseSensitivity::CaseInsensitive) == 0)
|| (fileInfo.baseName().compare("gmake", Qt::CaseSensitivity::CaseInsensitive) == 0)) {
else if ((cmd.baseName().compare("make", Qt::CaseSensitivity::CaseInsensitive) == 0)
|| (cmd.baseName().compare("gmake", Qt::CaseSensitivity::CaseInsensitive) == 0)) {
QRegularExpression regExp("\\s*\\-j\\d+");
args.remove(regExp);
args.append(" -j200");

View File

@@ -41,7 +41,7 @@ private:
QList<Utils::Id> migratableSteps() const final;
QString id() const final { return "MakeCommandBuilder"; }
QString displayName() const final { return tr("Make"); }
QString defaultCommand() const final;
Utils::FilePath defaultCommand() const final;
QString setMultiProcessArg(QString args) final;
};

View File

@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef MCUSUPPORTVERSIONDETECTION_H
#define MCUSUPPORTVERSIONDETECTION_H
#pragma once
#include <QObject>
@@ -47,7 +46,7 @@ public:
McuPackageExecutableVersionDetector(const QString &detectionPath,
const QStringList &detectionArgs,
const QString &detectionRegExp);
virtual QString parseVersion(const QString &packagePath) const;
QString parseVersion(const QString &packagePath) const final;
private:
const QString m_detectionPath;
const QStringList m_detectionArgs;
@@ -62,7 +61,7 @@ public:
const QString &elementName,
const QString &versionAttribute,
const QString &versionRegExp);
QString parseVersion(const QString &packagePath) const;
QString parseVersion(const QString &packagePath) const final;
private:
const QString m_filePattern;
const QString m_versionElement;
@@ -75,7 +74,7 @@ class McuPackageDirectoryVersionDetector : public McuPackageVersionDetector
{
public:
McuPackageDirectoryVersionDetector(const QString &filePattern, const QString &versionRegExp, const bool isFile);
QString parseVersion(const QString &packagePath) const;
QString parseVersion(const QString &packagePath) const final;
private:
const QString m_filePattern;
const QString m_versionRegExp;
@@ -87,12 +86,10 @@ class McuPackagePathVersionDetector : public McuPackageVersionDetector
{
public:
McuPackagePathVersionDetector(const QString &versionRegExp);
QString parseVersion(const QString &packagePath) const;
QString parseVersion(const QString &packagePath) const final;
private:
const QString m_versionRegExp;
};
} // Internal
} // McuSupport
#endif // MCUSUPPORTVERSIONDETECTION_H

View File

@@ -64,7 +64,7 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFacto
Core::BaseFileWizard(factory, parameters.extraValues(), parent),
d(std::make_unique<BaseProjectWizardDialogPrivate>(new ProjectIntroPage))
{
setFilePath(FilePath::fromString(parameters.defaultPath()));
setFilePath(parameters.defaultPath());
setSelectedPlatform(parameters.selectedPlatform());
setRequiredFeatures(parameters.requiredFeatures());
init();
@@ -77,7 +77,7 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFacto
Core::BaseFileWizard(factory, parameters.extraValues(), parent),
d(std::make_unique<BaseProjectWizardDialogPrivate>(introPage, introId))
{
setFilePath(FilePath::fromString(parameters.defaultPath()));
setFilePath(parameters.defaultPath());
setSelectedPlatform(parameters.selectedPlatform());
setRequiredFeatures(parameters.requiredFeatures());
init();
@@ -157,9 +157,9 @@ ProjectIntroPage *BaseProjectWizardDialog::introPage() const
return d->introPage;
}
QString BaseProjectWizardDialog::uniqueProjectName(const QString &path)
QString BaseProjectWizardDialog::uniqueProjectName(const FilePath &path)
{
const QDir pathDir(path);
const QDir pathDir(path.toString());
//: File path suggestion for a new project. If you choose
//: to translate it, make sure it is a valid path name without blanks
//: and using only ascii chars.

View File

@@ -60,7 +60,7 @@ public:
Utils::FilePath filePath() const;
// Generate a new project name (untitled<n>) in path.
static QString uniqueProjectName(const QString &path);
static QString uniqueProjectName(const Utils::FilePath &path);
void addExtensionPages(const QList<QWizardPage *> &wizardPageList);
void setIntroDescription(const QString &d);

View File

@@ -166,7 +166,7 @@ BaseFileWizard *CustomWizard::create(QWidget *parent, const WizardDialogParamete
d->m_context->reset();
auto customPage = new CustomWizardPage(d->m_context, parameters());
customPage->setPath(p.defaultPath());
customPage->setFilePath(p.defaultPath());
if (parameters()->firstPageId >= 0)
wizard->setPage(parameters()->firstPageId, customPage);
else
@@ -506,7 +506,7 @@ BaseFileWizard *CustomProjectWizard::create(QWidget *parent,
}
void CustomProjectWizard::initProjectWizardDialog(BaseProjectWizardDialog *w,
const QString &defaultPath,
const FilePath &defaultPath,
const QList<QWizardPage *> &extensionPages) const
{
const CustomWizardParametersPtr pa = parameters();
@@ -526,7 +526,7 @@ void CustomProjectWizard::initProjectWizardDialog(BaseProjectWizardDialog *w,
}
for (QWizardPage *ep : extensionPages)
w->addPage(ep);
w->setFilePath(FilePath::fromString(defaultPath));
w->setFilePath(defaultPath);
w->setProjectName(BaseProjectWizardDialog::uniqueProjectName(defaultPath));
connect(w, &BaseProjectWizardDialog::projectParametersChanged,

View File

@@ -141,7 +141,7 @@ protected:
bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage) const override;
void initProjectWizardDialog(BaseProjectWizardDialog *w, const QString &defaultPath,
void initProjectWizardDialog(BaseProjectWizardDialog *w, const Utils::FilePath &defaultPath,
const QList<QWizardPage *> &extensionPages) const;
private:

View File

@@ -437,9 +437,9 @@ FilePath CustomWizardPage::filePath() const
return m_pathChooser->filePath();
}
void CustomWizardPage::setPath(const QString &path)
void CustomWizardPage::setFilePath(const FilePath &path)
{
m_pathChooser->setPath(path);
m_pathChooser->setFilePath(path);
}
bool CustomWizardPage::isComplete() const

View File

@@ -127,7 +127,7 @@ public:
QWidget *parent = nullptr);
Utils::FilePath filePath() const;
void setPath(const QString &path);
void setFilePath(const Utils::FilePath &path);
bool isComplete() const override;

View File

@@ -532,6 +532,11 @@ bool IDevice::isCompatibleWith(const Kit *k) const
return DeviceTypeKitAspect::deviceTypeId(k) == type();
}
QVector<Task> IDevice::validate() const
{
return {};
}
void IDevice::addDeviceAction(const DeviceAction &deviceAction)
{
d->deviceActions.append(deviceAction);

View File

@@ -65,6 +65,7 @@ class DeviceProcess;
class DeviceProcessList;
class Kit;
class Runnable;
class Task;
namespace Internal { class IDevicePrivate; }
@@ -159,6 +160,7 @@ public:
Utils::Id id() const;
virtual bool isCompatibleWith(const Kit *k) const;
virtual QVector<Task> validate() const;
QString displayType() const;
Utils::OsType osType() const;

View File

@@ -98,6 +98,7 @@ static FolderNavigationWidgetFactory *m_instance = nullptr;
QVector<FolderNavigationWidgetFactory::RootDirectory>
FolderNavigationWidgetFactory::m_rootDirectories;
Utils::FilePath FolderNavigationWidgetFactory::m_fallbackSyncFilePath;
static QWidget *createHLine()
{
@@ -653,7 +654,8 @@ int FolderNavigationWidget::bestRootForFile(const Utils::FilePath &filePath)
int commonLength = 0;
for (int i = 1; i < m_rootSelector->count(); ++i) {
const auto root = m_rootSelector->itemData(i).value<Utils::FilePath>();
if (filePath.isChildOf(root) && root.toString().size() > commonLength) {
if ((filePath == root || filePath.isChildOf(root))
&& root.toString().size() > commonLength) {
index = i;
commonLength = root.toString().size();
}
@@ -893,6 +895,8 @@ Core::NavigationView FolderNavigationWidgetFactory::createWidget()
&FolderNavigationWidgetFactory::rootDirectoryRemoved,
fnw,
&FolderNavigationWidget::removeRootDirectory);
if (!Core::EditorManager::currentDocument() && !m_fallbackSyncFilePath.isEmpty())
fnw->syncWithFilePath(m_fallbackSyncFilePath);
Core::NavigationView n;
n.widget = fnw;
@@ -965,6 +969,11 @@ void FolderNavigationWidgetFactory::removeRootDirectory(const QString &id)
emit m_instance->rootDirectoryRemoved(id);
}
void FolderNavigationWidgetFactory::setFallbackSyncFilePath(const FilePath &filePath)
{
m_fallbackSyncFilePath = filePath;
}
int FolderNavigationWidgetFactory::rootIndex(const QString &id)
{
return Utils::indexOf(m_rootDirectories,

View File

@@ -77,6 +77,10 @@ public:
static void insertRootDirectory(const RootDirectory &directory);
static void removeRootDirectory(const QString &id);
static void setFallbackSyncFilePath(const Utils::FilePath &filePath);
static const Utils::FilePath &fallbackSyncFilePath();
signals:
void rootDirectoryAdded(const RootDirectory &directory);
void rootDirectoryRemoved(const QString &id);
@@ -87,6 +91,7 @@ private:
void registerActions();
static QVector<RootDirectory> m_rootDirectories;
static Utils::FilePath m_fallbackSyncFilePath;
};
class FolderNavigationWidget : public QWidget

View File

@@ -47,17 +47,17 @@ void JsonFilePage::initializePage()
if (fileName().isEmpty())
setFileName(wiz->stringValue(QLatin1String("InitialFileName")));
if (path().isEmpty())
if (filePath().isEmpty())
setPath(wiz->stringValue(QLatin1String("InitialPath")));
setDefaultSuffix(wiz->stringValue("DefaultSuffix"));
}
bool JsonFilePage::validatePage()
{
if (path().isEmpty() || fileName().isEmpty())
if (filePath().isEmpty() || fileName().isEmpty())
return false;
const FilePath dir = FilePath::fromString(path());
const FilePath dir = filePath();
if (!dir.isDir())
return false;

View File

@@ -34,7 +34,7 @@
#include <utils/algorithm.h>
#include <utils/displayname.h>
#include <utils/fileutils.h>
#include <utils/filepath.h>
#include <utils/icon.h>
#include <utils/macroexpander.h>
#include <utils/optional.h>
@@ -42,10 +42,7 @@
#include <utils/stringutils.h>
#include <utils/utilsicons.h>
#include <QApplication>
#include <QFileInfo>
#include <QIcon>
#include <QStyle>
#include <QTextStream>
#include <QUuid>

View File

@@ -1005,6 +1005,9 @@ Tasks DeviceKitAspect::validate(const Kit *k) const
else if (!dev->isCompatibleWith(k))
result.append(BuildSystemTask(Task::Error, tr("Device is incompatible with this kit.")));
if (dev)
result.append(dev->validate());
return result;
}

View File

@@ -386,6 +386,8 @@ void SessionManager::setStartupProject(Project *startupProject)
ModeManager::activateMode(Constants::MODE_SESSION);
ModeManager::setFocusToCurrentMode();
}
FolderNavigationWidgetFactory::setFallbackSyncFilePath(
startupProject ? startupProject->projectFilePath().parentDir() : FilePath());
emit m_instance->startupProjectChanged(startupProject);
}

View File

@@ -148,8 +148,8 @@ public:
addPage(m_secondPage);
}
QString path() const { return m_firstPage->path(); }
void setPath(const QString &path) { m_firstPage->setPath(path); }
Utils::FilePath projectDir() const { return m_firstPage->filePath(); }
void setProjectDir(const Utils::FilePath &path) { m_firstPage->setFilePath(path); }
FilePaths selectedFiles() const { return m_secondPage->selectedFiles(); }
FilePaths selectedPaths() const { return m_secondPage->selectedPaths(); }
QString qtModules() const { return m_secondPage->qtModules(); }
@@ -162,8 +162,7 @@ public:
void FilesSelectionWizardPage::initializePage()
{
m_filesWidget->resetModel(FilePath::fromString(m_simpleProjectWizardDialog->path()),
FilePaths());
m_filesWidget->resetModel(m_simpleProjectWizardDialog->projectDir(), FilePaths());
}
SimpleProjectWizard::SimpleProjectWizard()
@@ -187,7 +186,7 @@ BaseFileWizard *SimpleProjectWizard::create(QWidget *parent,
const WizardDialogParameters &parameters) const
{
auto wizard = new SimpleProjectWizardDialog(this, parent);
wizard->setPath(parameters.defaultPath());
wizard->setProjectDir(parameters.defaultPath());
for (QWizardPage *p : wizard->extensionPages())
wizard->addPage(p);
@@ -199,7 +198,7 @@ GeneratedFiles generateQmakeFiles(const SimpleProjectWizardDialog *wizard,
QString *errorMessage)
{
Q_UNUSED(errorMessage)
const QString projectPath = wizard->path();
const QString projectPath = wizard->projectDir().toString();
const QDir dir(projectPath);
const QString projectName = wizard->projectName();
const FilePath proFileName = Utils::FilePath::fromString(QFileInfo(dir, projectName + ".pro").absoluteFilePath());
@@ -257,8 +256,7 @@ GeneratedFiles generateCmakeFiles(const SimpleProjectWizardDialog *wizard,
QString *errorMessage)
{
Q_UNUSED(errorMessage)
const QString projectPath = wizard->path();
const QDir dir(projectPath);
const QDir dir(wizard->projectDir().toString());
const QString projectName = wizard->projectName();
const FilePath projectFileName = Utils::FilePath::fromString(QFileInfo(dir, "CMakeLists.txt").absoluteFilePath());
const QStringList paths = Utils::transform(wizard->selectedPaths(), &FilePath::toString);

View File

@@ -34,6 +34,7 @@
#include <utils/utilsicons.h>
#include <QApplication>
#include <QThread>
using namespace Utils;
@@ -155,6 +156,7 @@ void TaskHub::addTask(Task task)
QTC_ASSERT(!task.description().isEmpty(), return);
QTC_ASSERT(!task.isNull(), return);
QTC_ASSERT(task.m_mark.isNull(), return);
QTC_ASSERT(QThread::currentThread() == qApp->thread(), return);
if (task.file.isEmpty() || task.line <= 0)
task.line = -1;

View File

@@ -32,19 +32,17 @@
#include <QDateTime>
#include <QDebug>
using namespace Utils;
namespace QmakeProjectManager {
namespace Internal {
// ----------- QtProjectParameters
QtProjectParameters::QtProjectParameters() = default;
QString QtProjectParameters::projectPath() const
FilePath QtProjectParameters::projectPath() const
{
QString rc = path;
if (!rc.isEmpty())
rc += QLatin1Char('/');
rc += fileName;
return rc;
return path / fileName;
}
// Write out a QT module line.

View File

@@ -25,6 +25,8 @@
#pragma once
#include <utils/filepath.h>
#include <QStringList>
QT_BEGIN_NAMESPACE
@@ -41,14 +43,15 @@ QString createMacro(const QString &name, const QString &suffix);
// Base parameters for application project generation with functionality to
// write a .pro-file section.
struct QtProjectParameters {
struct QtProjectParameters
{
enum Type { ConsoleApp, GuiApp, StaticLibrary, SharedLibrary, QtPlugin, EmptyProject };
enum QtVersionSupport { SupportQt4And5, SupportQt4Only, SupportQt5Only };
enum Flags { WidgetsRequiredFlag = 0x1 };
QtProjectParameters();
// Return project path as "path/name"
QString projectPath() const;
Utils::FilePath projectPath() const;
void writeProFile(QTextStream &) const;
static void writeProFileHeader(QTextStream &);
@@ -62,7 +65,7 @@ struct QtProjectParameters {
QtVersionSupport qtVersionSupport = SupportQt4And5;
QString fileName;
QString target;
QString path;
Utils::FilePath path;
QStringList selectedModules;
QStringList deselectedModules;
QString targetDirectory;

View File

@@ -36,6 +36,8 @@
#include <QCoreApplication>
using namespace Utils;
namespace QmakeProjectManager {
namespace Internal {
@@ -70,8 +72,8 @@ Core::GeneratedFiles SubdirsProjectWizard::generateFiles(const QWizard *w,
{
const auto *wizard = qobject_cast< const SubdirsProjectWizardDialog *>(w);
const QtProjectParameters params = wizard->parameters();
const QString projectPath = params.projectPath();
const QString profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, params.fileName, profileSuffix());
const FilePath projectPath = params.projectPath();
const FilePath profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, params.fileName, profileSuffix());
Core::GeneratedFile profile(profileName);
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute | Core::GeneratedFile::OpenEditorAttribute);
@@ -85,10 +87,10 @@ bool SubdirsProjectWizard::postGenerateFiles(const QWizard *w, const Core::Gener
const auto *wizard = qobject_cast< const SubdirsProjectWizardDialog *>(w);
if (QtWizard::qt4ProjectPostGenerateFiles(wizard, files, errorMessage)) {
const QtProjectParameters params = wizard->parameters();
const QString projectPath = params.projectPath();
const QString profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, params.fileName, profileSuffix());
const FilePath projectPath = params.projectPath();
const FilePath profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, params.fileName, profileSuffix());
QVariantMap map;
map.insert(QLatin1String(ProjectExplorer::Constants::PREFERRED_PROJECT_NODE), profileName);
map.insert(QLatin1String(ProjectExplorer::Constants::PREFERRED_PROJECT_NODE), profileName.toVariant());
map.insert(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS),
Utils::transform<QStringList>(wizard->selectedKits(), &Utils::Id::toString));
IWizardFactory::requestNewItemDialog(tr("New Subproject", "Title of dialog"),
@@ -96,7 +98,7 @@ bool SubdirsProjectWizard::postGenerateFiles(const QWizard *w, const Core::Gener
[](Core::IWizardFactory *f) {
return f->supportedProjectTypes().contains(Constants::QMAKEPROJECT_ID);
}),
Utils::FilePath::fromString(wizard->parameters().projectPath()),
wizard->parameters().projectPath(),
map);
} else {
return false;

View File

@@ -55,7 +55,7 @@ QtProjectParameters SubdirsProjectWizardDialog::parameters() const
QtProjectParameters rc;
rc.type = QtProjectParameters::EmptyProject;
rc.fileName = projectName();
rc.path = filePath().toString();
rc.path = filePath();
return rc;
}

View File

@@ -595,9 +595,9 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type,
for (const QmlJS::SimpleReaderNode::Ptr &node : nodes) {
if (node->propertyNames().contains("separateSection"))
separateSectionTypes.append(variantToStringList(node->property("typeNames")));
separateSectionTypes.append(variantToStringList(node->property("typeNames").value));
allTypes.append(variantToStringList(node->property("typeNames")));
allTypes.append(variantToStringList(node->property("typeNames").value));
}
const QList<PropertyName> allProperties = type.propertyNames();
@@ -666,8 +666,8 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type,
QString filledTemplate;
for (const QmlJS::SimpleReaderNode::Ptr &n : nodes) {
// Check if we have a template for the type
if (variantToStringList(n->property(QStringLiteral("typeNames"))).contains(QString::fromLatin1(typeName))) {
const QString fileName = propertyTemplatesPath() + n->property(QStringLiteral("sourceFile")).toString();
if (variantToStringList(n->property(QStringLiteral("typeNames")).value).contains(QString::fromLatin1(typeName))) {
const QString fileName = propertyTemplatesPath() + n->property(QStringLiteral("sourceFile")).value.toString();
QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) {
QString source = QString::fromUtf8(file.readAll());
@@ -682,7 +682,7 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type,
};
// QML specfics preparation
QStringList imports = variantToStringList(templateConfiguration()->property(QStringLiteral("imports")));
QStringList imports = variantToStringList(templateConfiguration()->property(QStringLiteral("imports")).value);
QString qmlTemplate = imports.join(QLatin1Char('\n')) + QLatin1Char('\n');
bool emptyTemplate = true;

View File

@@ -54,9 +54,12 @@ public:
void setQualifcation(const TypeName &qualification);
protected:
void elementStart(const QString &name) override;
void elementStart(const QString &name, const QmlJS::SourceLocation &nameLocation) override;
void elementEnd() override;
void propertyDefinition(const QString &name, const QVariant &value) override;
void propertyDefinition(const QString &name,
const QmlJS::SourceLocation &nameLocation,
const QVariant &value,
const QmlJS::SourceLocation &valueLocation) override;
private:
enum ParserSate { Error,

View File

@@ -87,7 +87,7 @@ void MetaInfoReader::setQualifcation(const TypeName &qualification)
m_qualication = qualification;
}
void MetaInfoReader::elementStart(const QString &name)
void MetaInfoReader::elementStart(const QString &name, const QmlJS::SourceLocation &nameLocation)
{
switch (parserState()) {
case ParsingDocument: setParserState(readDocument(name)); break;
@@ -128,7 +128,10 @@ void MetaInfoReader::elementEnd()
}
}
void MetaInfoReader::propertyDefinition(const QString &name, const QVariant &value)
void MetaInfoReader::propertyDefinition(const QString &name,
const QmlJS::SourceLocation &nameLocation,
const QVariant &value,
const QmlJS::SourceLocation &valueLocation)
{
switch (parserState()) {
case ParsingType: readTypeProperty(name, value); break;

View File

@@ -1161,7 +1161,7 @@ void checkNode(const QmlJS::SimpleReaderNode::Ptr &node, RewriterView *view)
if (!node->propertyNames().contains("i"))
return;
const int index = node->property("i").toInt();
const int index = node->property("i").value.toInt();
const ModelNode modelNode = view->getNodeForCanonicalIndex(index);
@@ -1174,7 +1174,7 @@ void checkNode(const QmlJS::SimpleReaderNode::Ptr &node, RewriterView *view)
if (i.key() != "i") {
const PropertyName name = fixUpIllegalChars(i.key()).toUtf8();
if (!modelNode.hasAuxiliaryData(name))
modelNode.setAuxiliaryData(name, i.value());
modelNode.setAuxiliaryData(name, i.value().value);
}
}

View File

@@ -37,20 +37,20 @@ namespace QmlDesigner {
static QString readProperty(const QString property, const QmlJS::SimpleReaderNode::Ptr &node)
{
const QVariant propertyVar = node->property(property);
const auto propertyVar = node->property(property);
if (!propertyVar.isNull() && propertyVar.isValid())
return propertyVar.value<QString>();
if (propertyVar.isValid())
return propertyVar.value.value<QString>();
return {};
}
static QStringList readPropertyList(const QString &property, const QmlJS::SimpleReaderNode::Ptr &node)
{
const QVariant propertyVar = node->property(property);
const auto propertyVar = node->property(property);
if (!propertyVar.isNull() && propertyVar.isValid())
return propertyVar.value<QStringList>();
if (propertyVar.isValid())
return propertyVar.value.value<QStringList>();
return {};
}
@@ -99,30 +99,31 @@ void DesignerMcuManager::readMetadata()
return;
}
const QVariant defaultVersion = metadata->property("defaultVersion");
if (!defaultVersion.isNull() && defaultVersion.isValid()) {
const QmlJS::SimpleReaderNode::Property defaultVersion = metadata->property("defaultVersion");
if (defaultVersion.isValid()) {
for (const auto& version : versions) {
Version newVersion;
const QVariant vId = version->property("id");
if (vId.isNull() || !vId.isValid())
const auto vId = version->property("id");
if (!vId.isValid())
continue;
const QVariant vName = version->property("name");
if (!vName.isNull() && vName.isValid())
newVersion.name = vName.value<QString>();
const auto vName = version->property("name");
if (vName.isValid())
newVersion.name = vName.value.value<QString>();
else
continue;
const QVariant vPath = version->property("path");
if (!vPath.isNull() && vPath.isValid())
newVersion.fileName = vPath.value<QString>();
const auto vPath = version->property("path");
if (vPath.isValid())
newVersion.fileName = vPath.value.value<QString>();
else
continue;
m_versionsList.push_back(newVersion);
if (vId == defaultVersion)
if (vId.value == defaultVersion.value)
m_defaultVersion = newVersion;
}
}
@@ -172,10 +173,10 @@ void DesignerMcuManager::readVersionData(const DesignerMcuManager::Version &vers
if (child->propertyNames().contains("allowedProperties")) {
ItemProperties allowedProperties;
const QVariant childrenPropertyVar = child->property("allowChildren");
const auto childrenPropertyVar = child->property("allowChildren");
if (!childrenPropertyVar.isNull() && childrenPropertyVar.isValid())
allowedProperties.allowChildren = childrenPropertyVar.toBool();
if (childrenPropertyVar.isValid())
allowedProperties.allowChildren = childrenPropertyVar.value.toBool();
allowedProperties.properties = readPropertyList("allowedProperties", child);

View File

@@ -39,24 +39,30 @@ namespace {
QmlProjectManager::FileFilterBaseItem *setupFileFilterItem(QmlProjectManager::FileFilterBaseItem *fileFilterItem, const QmlJS::SimpleReaderNode::Ptr &node)
{
const QVariant directoryProperty = node->property(QLatin1String("directory"));
const auto directoryProperty = node->property(QLatin1String("directory"));
if (directoryProperty.isValid())
fileFilterItem->setDirectory(directoryProperty.toString());
fileFilterItem->setDirectory(directoryProperty.value.toString());
const QVariant recursiveProperty = node->property(QLatin1String("recursive"));
const auto recursiveProperty = node->property(QLatin1String("recursive"));
if (recursiveProperty.isValid())
fileFilterItem->setRecursive(recursiveProperty.toBool());
fileFilterItem->setRecursive(recursiveProperty.value.toBool());
const QVariant pathsProperty = node->property(QLatin1String("paths"));
const auto pathsProperty = node->property(QLatin1String("paths"));
if (pathsProperty.isValid())
fileFilterItem->setPathsProperty(pathsProperty.toStringList());
fileFilterItem->setPathsProperty(pathsProperty.value.toStringList());
const QVariant filterProperty = node->property(QLatin1String("filter"));
// "paths" and "files" have the same functionality
const auto filesProperty = node->property(QLatin1String("files"));
if (filesProperty.isValid())
fileFilterItem->setPathsProperty(filesProperty.value.toStringList());
const auto filterProperty = node->property(QLatin1String("filter"));
if (filterProperty.isValid())
fileFilterItem->setFilter(filterProperty.toString());
fileFilterItem->setFilter(filterProperty.value.toString());
if (debug)
qDebug() << "directory:" << directoryProperty << "recursive" << recursiveProperty << "paths" << pathsProperty;
qDebug() << "directory:" << directoryProperty.value << "recursive" << recursiveProperty.value
<< "paths" << pathsProperty.value << "files" << filesProperty.value;
return fileFilterItem;
}
@@ -81,36 +87,36 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FilePath &fi
if (rootNode->name() == QLatin1String("Project")) {
auto projectItem = new QmlProjectItem;
const QVariant mainFileProperty = rootNode->property(QLatin1String("mainFile"));
const auto mainFileProperty = rootNode->property(QLatin1String("mainFile"));
if (mainFileProperty.isValid())
projectItem->setMainFile(mainFileProperty.toString());
projectItem->setMainFile(mainFileProperty.value.toString());
const QVariant importPathsProperty = rootNode->property(QLatin1String("importPaths"));
const auto importPathsProperty = rootNode->property(QLatin1String("importPaths"));
if (importPathsProperty.isValid())
projectItem->setImportPaths(importPathsProperty.toStringList());
projectItem->setImportPaths(importPathsProperty.value.toStringList());
const QVariant fileSelectorsProperty = rootNode->property(QLatin1String("fileSelectors"));
const auto fileSelectorsProperty = rootNode->property(QLatin1String("fileSelectors"));
if (fileSelectorsProperty.isValid())
projectItem->setFileSelectors(fileSelectorsProperty.toStringList());
projectItem->setFileSelectors(fileSelectorsProperty.value.toStringList());
const QVariant forceFreeTypeProperty = rootNode->property("forceFreeType");
const auto forceFreeTypeProperty = rootNode->property("forceFreeType");
if (forceFreeTypeProperty.isValid())
projectItem->setForceFreeType(forceFreeTypeProperty.toBool());
projectItem->setForceFreeType(forceFreeTypeProperty.value.toBool());
const QVariant targetDirectoryPropery = rootNode->property("targetDirectory");
const auto targetDirectoryPropery = rootNode->property("targetDirectory");
if (targetDirectoryPropery.isValid())
projectItem->setTargetDirectory(targetDirectoryPropery.toString());
projectItem->setTargetDirectory(targetDirectoryPropery.value.toString());
const QVariant qtForMCUProperty = rootNode->property("qtForMCUs");
if (qtForMCUProperty.isValid() && qtForMCUProperty.toBool())
projectItem->setQtForMCUs(qtForMCUProperty.toBool());
const auto qtForMCUProperty = rootNode->property("qtForMCUs");
if (qtForMCUProperty.isValid() && qtForMCUProperty.value.toBool())
projectItem->setQtForMCUs(qtForMCUProperty.value.toBool());
const QVariant qt6ProjectProperty = rootNode->property("qt6Project");
if (qt6ProjectProperty.isValid() && qt6ProjectProperty.toBool())
projectItem->setQt6Project(qt6ProjectProperty.toBool());
const auto qt6ProjectProperty = rootNode->property("qt6Project");
if (qt6ProjectProperty.isValid() && qt6ProjectProperty.value.toBool())
projectItem->setQt6Project(qt6ProjectProperty.value.toBool());
if (debug)
qDebug() << "importPath:" << importPathsProperty << "mainFile:" << mainFileProperty;
qDebug() << "importPath:" << importPathsProperty.value << "mainFile:" << mainFileProperty.value;
foreach (const QmlJS::SimpleReaderNode::Ptr &childNode, rootNode->children()) {
if (debug)
@@ -132,7 +138,7 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FilePath &fi
const auto properties = childNode->properties();
auto i = properties.constBegin();
while (i != properties.constEnd()) {
projectItem->addToEnviroment(i.key(), i.value().toString());
projectItem->addToEnviroment(i.key(), i.value().value.toString());
++i;
}
} else {

View File

@@ -58,15 +58,22 @@ ProMessageHandler::~ProMessageHandler()
Core::MessageManager::writeFlashing(m_messages);
}
static void addTask(Task::TaskType type,
const QString &description,
const Utils::FilePath &file = {},
int line = -1)
{
QMetaObject::invokeMethod(TaskHub::instance(), [=]() {
TaskHub::addTask(BuildSystemTask(type, description, file, line));
});
}
void ProMessageHandler::message(int type, const QString &msg, const QString &fileName, int lineNo)
{
if ((type & CategoryMask) == ErrorMessage && ((type & SourceMask) == SourceParser || m_verbose)) {
// parse error in qmake files
if (m_exact) {
TaskHub::addTask(
BuildSystemTask(Task::Error, msg, Utils::FilePath::fromString(fileName), lineNo));
addTask(Task::Error, msg, Utils::FilePath::fromString(fileName), lineNo);
} else {
appendMessage(format(fileName, lineNo, msg));
}
@@ -79,9 +86,9 @@ void ProMessageHandler::fileMessage(int type, const QString &msg)
if (!m_verbose)
return;
if (m_exact && type == QMakeHandler::ErrorMessage)
TaskHub::addTask(BuildSystemTask(Task::Error, msg));
addTask(Task::Error, msg);
else if (m_exact && type == QMakeHandler::WarningMessage)
TaskHub::addTask(BuildSystemTask(Task::Warning, msg));
addTask(Task::Warning, msg);
else
appendMessage(msg);
}

View File

@@ -8546,14 +8546,14 @@ static void checkNode(QmlJS::SimpleReaderNode::Ptr node, TestRewriterView *view)
{
QVERIFY(node);
QVERIFY(node->propertyNames().contains("i"));
const int internalId = node->property("i").toInt();
const int internalId = node->property("i").value.toInt();
const ModelNode modelNode = view->modelNodeForInternalId(internalId);
QVERIFY(modelNode.isValid());
auto properties = node->properties();
for (auto i = properties.begin(); i != properties.end(); ++i) {
if (i.key() != "i")
QCOMPARE(i.value(), modelNode.auxiliaryData(i.key().toUtf8()));
QCOMPARE(i.value().value, modelNode.auxiliaryData(i.key().toUtf8()));
}
checkChildNodes(node, view);

View File

@@ -77,13 +77,13 @@ void tst_SimpleReader::testWellFormed()
QCOMPARE(rootNode->properties().count(), 1);
QVERIFY(rootNode->properties().contains("propertyBlah"));
QCOMPARE(rootNode->property("property01").toBool(), false);
QCOMPARE(rootNode->property("property01").value.toBool(), false);
QVERIFY(rootNode->children().first()->isValid());
QVERIFY(!rootNode->children().first()->isRoot());
QVERIFY(rootNode->children().first()->properties().contains("property01"));
QCOMPARE(rootNode->children().first()->property("property01").toInt(), 10);
QCOMPARE(rootNode->children().first()->property("property01").value.toInt(), 10);
SimpleReaderNode::Ptr secondChild = rootNode->children().at(1);
@@ -93,7 +93,7 @@ void tst_SimpleReader::testWellFormed()
QCOMPARE(secondChild->name(), QLatin1String("ChildNode"));
QVERIFY(secondChild->properties().contains("propertyString"));
QCOMPARE(secondChild->property("propertyString").toString(), QLatin1String("str"));
QCOMPARE(secondChild->property("propertyString").value.toString(), QLatin1String("str"));
QCOMPARE(secondChild->children().count(), 1);
@@ -105,7 +105,7 @@ void tst_SimpleReader::testWellFormed()
QCOMPARE(innerChild->name(), QLatin1String("InnerChild"));
QVERIFY(innerChild->properties().contains("test"));
QCOMPARE(innerChild->property("test").toString(), QLatin1String("test"));
QCOMPARE(innerChild->property("test").value.toString(), QLatin1String("test"));
weak01 = rootNode;
weak02 = secondChild;
@@ -170,7 +170,7 @@ void tst_SimpleReader::testIllFormed02()
QCOMPARE(firstChild->properties().count(), 1);
QVERIFY(firstChild->properties().contains("property01"));
QCOMPARE(firstChild->property("property01").toString(), QLatin1String("20"));
QCOMPARE(firstChild->property("property01").value.toString(), QLatin1String("20"));
}
void tst_SimpleReader::testArrays()
@@ -194,7 +194,7 @@ void tst_SimpleReader::testArrays()
QVERIFY(rootNode->isValid());
QVERIFY(rootNode->isRoot());
QCOMPARE(rootNode->property("propertyArray"), variant);
QCOMPARE(rootNode->property("propertyArray").value, variant);
SimpleReaderNode::Ptr firstChild = rootNode->children().at(0);
@@ -202,13 +202,13 @@ void tst_SimpleReader::testArrays()
QVERIFY(firstChild);
QVERIFY(firstChild->isValid());
QVERIFY(!firstChild->isRoot());
QCOMPARE(firstChild->property("propertyArray"), variant);
QCOMPARE(firstChild->property("propertyArray").value, variant);
QList<QVariant> variantList2;
variantList2 << QVariant(QLatin1String("string03")) << variant;
const QVariant variant2 = variantList2;
QCOMPARE(firstChild->property("propertyArrayMixed"), variant2);
QCOMPARE(firstChild->property("propertyArrayMixed").value, variant2);
}
void tst_SimpleReader::testBug01()