forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.13' into master
Change-Id: I8a2dca29595a0770f4162786b15a145f3f4133af
This commit is contained in:
@@ -32,7 +32,7 @@ namespace ClangRefactoring {
|
||||
BaseClangQueryTextEditorWidget::BaseClangQueryTextEditorWidget(QWidget *parent)
|
||||
: TextEditor::TextEditorWidget(parent)
|
||||
{
|
||||
setupFallBackEditor(Core::Id());
|
||||
setupFallBackEditor(Utils::Id());
|
||||
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
||||
setHighlightCurrentLine(false);
|
||||
setLineNumbersVisible(false);
|
||||
|
||||
@@ -343,8 +343,8 @@ void CMakeToolItemModel::removeCMakeTool(const Utils::Id &id)
|
||||
CMakeToolTreeItem *treeItem = cmakeToolItem(id);
|
||||
QTC_ASSERT(treeItem, return);
|
||||
|
||||
destroyItem(treeItem);
|
||||
m_removedItems.append(id);
|
||||
destroyItem(treeItem);
|
||||
}
|
||||
|
||||
void CMakeToolItemModel::apply()
|
||||
|
||||
@@ -154,8 +154,10 @@ void TabWidget::slotContextMenuRequested(const QPoint &pos)
|
||||
AppOutputPane::RunControlTab::RunControlTab(RunControl *runControl, Core::OutputWindow *w) :
|
||||
runControl(runControl), window(w)
|
||||
{
|
||||
if (runControl && w)
|
||||
w->setLineParsers(runControl->createOutputParsers());
|
||||
if (runControl && w) {
|
||||
w->reset();
|
||||
runControl->setupFormatter(w->outputFormatter());
|
||||
}
|
||||
}
|
||||
|
||||
AppOutputPane::AppOutputPane() :
|
||||
@@ -405,7 +407,8 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
||||
if (tab.runControl)
|
||||
tab.runControl->initiateFinish();
|
||||
tab.runControl = rc;
|
||||
tab.window->setLineParsers(rc->createOutputParsers());
|
||||
tab.window->reset();
|
||||
rc->setupFormatter(tab.window->outputFormatter());
|
||||
|
||||
handleOldOutput(tab.window);
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/detailswidget.h>
|
||||
#include <utils/fileinprojectfinder.h>
|
||||
#include <utils/outputformatter.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
@@ -824,7 +825,7 @@ void RunControlPrivate::showError(const QString &msg)
|
||||
q->appendMessage(msg + '\n', ErrorMessageFormat);
|
||||
}
|
||||
|
||||
QList<Utils::OutputLineParser *> RunControl::createOutputParsers() const
|
||||
void RunControl::setupFormatter(OutputFormatter *formatter) const
|
||||
{
|
||||
QList<Utils::OutputLineParser *> parsers = OutputFormatterFactory::createFormatters(target());
|
||||
if (const auto customParsersAspect
|
||||
@@ -834,7 +835,11 @@ QList<Utils::OutputLineParser *> RunControl::createOutputParsers() const
|
||||
parsers << parser;
|
||||
}
|
||||
}
|
||||
return parsers;
|
||||
formatter->setLineParsers(parsers);
|
||||
Utils::FileInProjectFinder fileFinder;
|
||||
fileFinder.setProjectDirectory(project()->projectDirectory());
|
||||
fileFinder.setProjectFiles(project()->files(Project::AllFiles));
|
||||
formatter->setFileFinder(fileFinder);
|
||||
}
|
||||
|
||||
Utils::Id RunControl::runMode() const
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
namespace Utils {
|
||||
class MacroExpander;
|
||||
class OutputLineParser;
|
||||
class OutputFormatter;
|
||||
} // Utils
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -238,7 +239,7 @@ public:
|
||||
Utils::FilePath targetFilePath() const;
|
||||
Utils::FilePath projectFilePath() const;
|
||||
|
||||
QList<Utils::OutputLineParser *> createOutputParsers() const;
|
||||
void setupFormatter(Utils::OutputFormatter *formatter) const;
|
||||
Utils::Id runMode() const;
|
||||
|
||||
const Runnable &runnable() const;
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "choosetexturepropertydialog.h"
|
||||
#include "nodemetainfo.h"
|
||||
#include "ui_choosetexturepropertydialog.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
// This dialog displays all texture properties of an object and allows the user to choose one
|
||||
ChooseTexturePropertyDialog::ChooseTexturePropertyDialog(const ModelNode &node, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::ChooseTexturePropertyDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setWindowTitle(tr("Select Texture Property"));
|
||||
m_ui->label->setText(tr("Set texture to property:"));
|
||||
setFixedSize(size());
|
||||
|
||||
connect(m_ui->listProps, &QListWidget::itemClicked, this, [this](QListWidgetItem *item) {
|
||||
m_selectedProperty = item->isSelected() ? item->data(Qt::DisplayRole).toByteArray() : QByteArray();
|
||||
});
|
||||
|
||||
connect(m_ui->listProps, &QListWidget::itemDoubleClicked, this, [this](QListWidgetItem *item) {
|
||||
Q_UNUSED(item)
|
||||
QDialog::accept();
|
||||
});
|
||||
|
||||
fillList(node);
|
||||
}
|
||||
|
||||
ChooseTexturePropertyDialog::~ChooseTexturePropertyDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
TypeName ChooseTexturePropertyDialog::selectedProperty() const
|
||||
{
|
||||
return m_selectedProperty;
|
||||
}
|
||||
|
||||
void ChooseTexturePropertyDialog::fillList(const ModelNode &node)
|
||||
{
|
||||
// Fill the list with all properties of type Texture
|
||||
const auto metaInfo = node.metaInfo();
|
||||
const auto propNames = metaInfo.propertyNames();
|
||||
const TypeName textureProp("QtQuick3D.Texture");
|
||||
QStringList nameList;
|
||||
for (const auto &propName : propNames) {
|
||||
if (metaInfo.propertyTypeName(propName) == textureProp)
|
||||
nameList.append(QString::fromLatin1(propName));
|
||||
}
|
||||
|
||||
if (!nameList.isEmpty()) {
|
||||
QString defaultProp = nameList.first();
|
||||
|
||||
nameList.sort();
|
||||
for (const auto &propName : qAsConst(nameList)) {
|
||||
QListWidgetItem *newItem = new QListWidgetItem(propName);
|
||||
m_ui->listProps->addItem(newItem);
|
||||
}
|
||||
|
||||
// Select the default prop
|
||||
m_ui->listProps->setCurrentRow(nameList.indexOf(defaultProp));
|
||||
m_selectedProperty = defaultProp.toLatin1();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <modelnode.h>
|
||||
#include <nodeinstanceglobal.h>
|
||||
|
||||
#include <QtWidgets/qdialog.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
namespace Ui {
|
||||
class ChooseTexturePropertyDialog;
|
||||
}
|
||||
|
||||
class ChooseTexturePropertyDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChooseTexturePropertyDialog(const ModelNode &node, QWidget *parent = 0);
|
||||
~ChooseTexturePropertyDialog();
|
||||
|
||||
TypeName selectedProperty() const;
|
||||
|
||||
private:
|
||||
void fillList(const ModelNode &node);
|
||||
|
||||
Ui::ChooseTexturePropertyDialog *m_ui;
|
||||
TypeName m_selectedProperty;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QmlDesigner::ChooseTexturePropertyDialog</class>
|
||||
<widget class="QDialog" name="QmlDesigner::ChooseTexturePropertyDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>250</width>
|
||||
<height>250</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1000</width>
|
||||
<height>1000</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listProps"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>QmlDesigner::ChooseTexturePropertyDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>240</x>
|
||||
<y>240</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>QmlDesigner::ChooseTexturePropertyDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>240</x>
|
||||
<y>240</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -5,7 +5,8 @@ SOURCES += navigatorview.cpp \
|
||||
navigatorwidget.cpp \
|
||||
nameitemdelegate.cpp \
|
||||
iconcheckboxitemdelegate.cpp \
|
||||
navigatortreeview.cpp
|
||||
navigatortreeview.cpp \
|
||||
choosetexturepropertydialog.cpp
|
||||
|
||||
HEADERS += navigatorview.h \
|
||||
navigatortreemodel.h \
|
||||
@@ -13,6 +14,9 @@ HEADERS += navigatorview.h \
|
||||
nameitemdelegate.h \
|
||||
iconcheckboxitemdelegate.h \
|
||||
navigatortreeview.h \
|
||||
navigatormodelinterface.h
|
||||
navigatormodelinterface.h \
|
||||
choosetexturepropertydialog.h
|
||||
|
||||
RESOURCES += navigator.qrc
|
||||
|
||||
FORMS += choosetexturepropertydialog.ui
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "navigatortreemodel.h"
|
||||
#include "navigatorview.h"
|
||||
#include "choosetexturepropertydialog.h"
|
||||
#include "qmldesignerplugin.h"
|
||||
|
||||
#include <bindingproperty.h>
|
||||
@@ -51,6 +52,7 @@
|
||||
#include <QApplication>
|
||||
#include <QPointF>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <coreplugin/messagebox.h>
|
||||
|
||||
@@ -649,6 +651,10 @@ void NavigatorTreeModel::handleItemLibraryImageDrop(const QMimeData *mimeData, i
|
||||
|
||||
// create a texture
|
||||
newModelNode = QmlItemNode::createQmlObjectNode(m_view, itemLibraryEntry, {}, targetProp, false);
|
||||
|
||||
// Rename the node based on source image
|
||||
QFileInfo fi(imagePath);
|
||||
newModelNode.setIdWithoutRefactoring(m_view->generateNewId(fi.baseName(), "textureImage"));
|
||||
return newModelNode.isValid();
|
||||
}
|
||||
return false;
|
||||
@@ -656,16 +662,21 @@ void NavigatorTreeModel::handleItemLibraryImageDrop(const QMimeData *mimeData, i
|
||||
|
||||
if (targetNode.isSubclassOf("QtQuick3D.Material")) {
|
||||
// if dropping an image on a default material, create a texture instead of image
|
||||
m_view->executeInTransaction("NavigatorTreeModel::handleItemLibraryImageDrop", [&] {
|
||||
if (createTextureNode(targetProperty)) {
|
||||
// Automatically set the texture to default property
|
||||
// TODO: allow the user to choose which map property to set the texture for (QDS-2326)
|
||||
if (targetNode.isSubclassOf("QtQuick3D.DefaultMaterial"))
|
||||
targetNode.bindingProperty("diffuseMap").setExpression(newModelNode.validId());
|
||||
else if (targetNode.isSubclassOf("QtQuick3D.PrincipledMaterial"))
|
||||
targetNode.bindingProperty("baseColorMap").setExpression(newModelNode.validId());
|
||||
}
|
||||
});
|
||||
ChooseTexturePropertyDialog *dialog = nullptr;
|
||||
if (targetNode.isSubclassOf("QtQuick3D.DefaultMaterial") || targetNode.isSubclassOf("QtQuick3D.PrincipledMaterial")) {
|
||||
// Show texture property selection dialog
|
||||
dialog = new ChooseTexturePropertyDialog(targetNode, Core::ICore::dialogParent());
|
||||
dialog->exec();
|
||||
}
|
||||
if (!dialog || dialog->result() == QDialog::Accepted) {
|
||||
m_view->executeInTransaction("NavigatorTreeModel::handleItemLibraryImageDrop", [&] {
|
||||
if (createTextureNode(targetProperty) && dialog) {
|
||||
// Automatically set the texture to selected property
|
||||
targetNode.bindingProperty(dialog->selectedProperty()).setExpression(newModelNode.validId());
|
||||
}
|
||||
});
|
||||
}
|
||||
delete dialog;
|
||||
} else if (targetNode.isSubclassOf("QtQuick3D.TextureInput")) {
|
||||
// If dropping an image on a TextureInput, create a texture on the same level as
|
||||
// TextureInput, as the TextureInput doesn't support Texture children (QTBUG-86219)
|
||||
|
||||
@@ -276,6 +276,7 @@ static QList<QByteArray> prepareNonMcuProperties()
|
||||
{
|
||||
QList<QByteArray> result;
|
||||
|
||||
//Builtins:
|
||||
const QList<QByteArray> itemProperties = {"layer", "opacity", "gradient", "smooth", "antialiasing",
|
||||
"border", "baselineOffset", "focus", "activeFocusOnTab"};
|
||||
const QList<QByteArray> mouseAreaProperties = {"propagateComposedEvents", "preventStealing", "cursorShape",
|
||||
@@ -296,6 +297,19 @@ static QList<QByteArray> prepareNonMcuProperties()
|
||||
"highlightResizeDuration", "preferredHighlightBegin", "layoutDirection",
|
||||
"preferredHighlightEnd", "highlightFollowsCurrentItem", "keyNavigationWraps",
|
||||
"snapMode", "highlightMoveVelocity", "highlightResizeVelocity"};
|
||||
//Animations:
|
||||
const QList<QByteArray> animationProperties = {"paused"};
|
||||
|
||||
//QtQuick.Controls:
|
||||
const QList<QByteArray> controlProperties = {"focusPolicy", "hoverEnabled", "wheelEnabled"};
|
||||
const QList<QByteArray> abstractButtonProperties = {"display", "autoExclusive"};
|
||||
const QList<QByteArray> buttonProperties = {"flat", "highlighted"};
|
||||
const QList<QByteArray> dialProperties = {}; //nothing in propeditor
|
||||
const QList<QByteArray> progressBarProperties = {"indeterminate"};
|
||||
const QList<QByteArray> radioButton = {}; //nothing in propeditor
|
||||
const QList<QByteArray> sliderProperties = {"live", "snapMode", "touchDragThreshold"};
|
||||
const QList<QByteArray> swipeViewProperties = {}; //nothing in propeditor
|
||||
const QList<QByteArray> switchProperties = {}; //nothing in propeditor
|
||||
|
||||
result.append(itemProperties);
|
||||
result.append(mouseAreaProperties);
|
||||
@@ -305,13 +319,25 @@ static QList<QByteArray> prepareNonMcuProperties()
|
||||
result.append(paddingProperties);
|
||||
result.append(columnRowProperties);
|
||||
result.append(listViewProperties);
|
||||
|
||||
result.append(animationProperties);
|
||||
result.append(controlProperties);
|
||||
result.append(abstractButtonProperties);
|
||||
result.append(buttonProperties);
|
||||
result.append(dialProperties);
|
||||
result.append(progressBarProperties);
|
||||
result.append(radioButton);
|
||||
result.append(sliderProperties);
|
||||
result.append(swipeViewProperties);
|
||||
result.append(switchProperties);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool PropertyEditorValue::isAvailable() const
|
||||
{
|
||||
if (!m_modelNode.isValid())
|
||||
return true;
|
||||
|
||||
const QList<QByteArray> nonMcuProperties = prepareNonMcuProperties();
|
||||
|
||||
const QByteArray fontPrefix = {"font"};
|
||||
|
||||
@@ -160,6 +160,7 @@ public:
|
||||
ModelNode modelNodeForId(const QString &id);
|
||||
bool hasId(const QString &id) const;
|
||||
QString generateNewId(const QString &prefixName) const;
|
||||
QString generateNewId(const QString &prefixName, const QString &fallbackPrefix) const;
|
||||
|
||||
ModelNode modelNodeForInternalId(qint32 internalId) const;
|
||||
bool hasModelNodeForInternalId(qint32 internalId) const;
|
||||
|
||||
@@ -504,40 +504,36 @@ QString firstCharToLower(const QString &string)
|
||||
return resultString;
|
||||
}
|
||||
|
||||
QString AbstractView::generateNewId(const QString &prefixName) const
|
||||
QString AbstractView::generateNewId(const QString &prefixName, const QString &fallbackPrefix) const
|
||||
{
|
||||
QString fixedPrefix = firstCharToLower(prefixName);
|
||||
fixedPrefix.remove(' ');
|
||||
|
||||
bool forceSuffix = false;
|
||||
|
||||
if (!ModelNode::isValidId(fixedPrefix))
|
||||
forceSuffix = true;
|
||||
// First try just the prefixName without number as postfix, then continue with 2 and further
|
||||
// as postfix until id does not already exist.
|
||||
// Properties of the root node are not allowed for ids, because they are available in the
|
||||
// complete context without qualification.
|
||||
|
||||
int counter = 0;
|
||||
|
||||
/* First try just the prefixName without number as postfix, then continue with 2 and further as postfix
|
||||
* until id does not already exist.
|
||||
* Properties of the root node are not allowed for ids, because they are available in the complete context
|
||||
* without qualification.
|
||||
* The id "item" is explicitly not allowed, because it is too likely to clash.
|
||||
*/
|
||||
QString newBaseId = QString(QStringLiteral("%1")).arg(firstCharToLower(prefixName));
|
||||
newBaseId.remove(QRegularExpression(QStringLiteral("[^a-zA-Z0-9_]")));
|
||||
|
||||
QString newId = QString(QStringLiteral("%1")).arg(firstCharToLower(prefixName));
|
||||
if (forceSuffix)
|
||||
QString(QStringLiteral("%1%2")).arg(firstCharToLower(prefixName)).arg(1);
|
||||
if (newBaseId.isEmpty())
|
||||
newBaseId = fallbackPrefix;
|
||||
|
||||
newId.remove(QRegularExpression(QStringLiteral("[^a-zA-Z0-9_]")));
|
||||
QString newId = newBaseId;
|
||||
|
||||
while (!ModelNode::isValidId(newId) || hasId(newId) || rootModelNode().hasProperty(newId.toUtf8()) || newId == "item") {
|
||||
counter += 1;
|
||||
newId = QString(QStringLiteral("%1%2")).arg(firstCharToLower(prefixName)).arg(counter);
|
||||
newId.remove(QRegularExpression(QStringLiteral("[^a-zA-Z0-9_]")));
|
||||
while (!ModelNode::isValidId(newId) || hasId(newId) || rootModelNode().hasProperty(newId.toUtf8())) {
|
||||
++counter;
|
||||
newId = QString(QStringLiteral("%1%2")).arg(firstCharToLower(newBaseId)).arg(counter);
|
||||
}
|
||||
|
||||
return newId;
|
||||
}
|
||||
|
||||
QString AbstractView::generateNewId(const QString &prefixName) const
|
||||
{
|
||||
return generateNewId(prefixName, QStringLiteral("element"));
|
||||
}
|
||||
|
||||
ModelNode AbstractView::modelNodeForInternalId(qint32 internalId) const
|
||||
{
|
||||
return ModelNode(model()->d->nodeForInternalId(internalId), model(), this);
|
||||
|
||||
@@ -106,7 +106,8 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
|
||||
newQmlItemNode = QmlItemNode(view->createModelNode("QtQuick.Image", metaInfo.majorVersion(), metaInfo.minorVersion(), propertyPairList));
|
||||
parentproperty.reparentHere(newQmlItemNode);
|
||||
|
||||
newQmlItemNode.setId(view->generateNewId(QLatin1String("image")));
|
||||
QFileInfo fi(relativeImageName);
|
||||
newQmlItemNode.setId(view->generateNewId(fi.baseName(), "image"));
|
||||
|
||||
newQmlItemNode.modelNode().variantProperty("fillMode").setEnumeration("Image.PreserveAspectFit");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user