forked from qt-creator/qt-creator
QmlDesigner: Fix clazy warnings
Use const & Change-Id: Iaa540194e45871500dc80a55cd2cb6beeeee45b5 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -44,7 +44,7 @@ class FindImplementationVisitor: protected AST::Visitor
|
|||||||
public:
|
public:
|
||||||
using Results = QList<AST::SourceLocation>;
|
using Results = QList<AST::SourceLocation>;
|
||||||
|
|
||||||
FindImplementationVisitor(Document::Ptr doc, const ContextPtr &context)
|
FindImplementationVisitor(const Document::Ptr &doc, const ContextPtr &context)
|
||||||
: m_document(doc)
|
: m_document(doc)
|
||||||
, m_context(context)
|
, m_context(context)
|
||||||
, m_scopeChain(doc, context)
|
, m_scopeChain(doc, context)
|
||||||
|
@@ -379,7 +379,7 @@ void resetZ(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void backupPropertyAndRemove(ModelNode node, const PropertyName &propertyName)
|
static inline void backupPropertyAndRemove(const ModelNode &node, const PropertyName &propertyName)
|
||||||
{
|
{
|
||||||
if (node.hasVariantProperty(propertyName)) {
|
if (node.hasVariantProperty(propertyName)) {
|
||||||
node.setAuxiliaryData(auxDataString + propertyName, node.variantProperty(propertyName).value());
|
node.setAuxiliaryData(auxDataString + propertyName, node.variantProperty(propertyName).value());
|
||||||
@@ -480,7 +480,7 @@ bool compareByGrid(const ModelNode &node1, const ModelNode &node2)
|
|||||||
|
|
||||||
|
|
||||||
static void layoutHelperFunction(const SelectionContext &selectionContext,
|
static void layoutHelperFunction(const SelectionContext &selectionContext,
|
||||||
TypeName layoutType,
|
const TypeName &layoutType,
|
||||||
LessThan lessThan)
|
LessThan lessThan)
|
||||||
{
|
{
|
||||||
if (!selectionContext.view()
|
if (!selectionContext.view()
|
||||||
@@ -578,7 +578,7 @@ static PropertyNameList sortedPropertyNameList(const PropertyNameList &nameList)
|
|||||||
return sortedPropertyNameList;
|
return sortedPropertyNameList;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString toUpper(const QString signal)
|
static QString toUpper(const QString &signal)
|
||||||
{
|
{
|
||||||
QString ret = signal;
|
QString ret = signal;
|
||||||
ret[0] = signal.at(0).toUpper();
|
ret[0] = signal.at(0).toUpper();
|
||||||
|
@@ -135,7 +135,7 @@ QString DesignDocumentView::toText() const
|
|||||||
//get the text of the root item without imports
|
//get the text of the root item without imports
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignDocumentView::fromText(QString text)
|
void DesignDocumentView::fromText(const QString &text)
|
||||||
{
|
{
|
||||||
QScopedPointer<Model> inputModel(Model::create("QtQuick.Rectangle", 1, 0, model()));
|
QScopedPointer<Model> inputModel(Model::create("QtQuick.Rectangle", 1, 0, model()));
|
||||||
inputModel->setFileUrl(model()->fileUrl());
|
inputModel->setFileUrl(model()->fileUrl());
|
||||||
|
@@ -47,7 +47,7 @@ public:
|
|||||||
void fromClipboard();
|
void fromClipboard();
|
||||||
|
|
||||||
QString toText() const;
|
QString toText() const;
|
||||||
void fromText(QString text);
|
void fromText(const QString &text);
|
||||||
|
|
||||||
static Model *pasteToModel();
|
static Model *pasteToModel();
|
||||||
static void copyModelNodes(const QList<ModelNode> &nodesToCopy);
|
static void copyModelNodes(const QList<ModelNode> &nodesToCopy);
|
||||||
|
@@ -88,7 +88,7 @@ void CustomFileSystemModel::setFilter(QDir::Filters)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString filterMetaIcons(const QString fileName)
|
QString filterMetaIcons(const QString &fileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
QFileInfo info(fileName);
|
QFileInfo info(fileName);
|
||||||
|
@@ -401,8 +401,8 @@ QString PropertyEditorQmlBackend::propertyEditorResourcesPath() {
|
|||||||
return Core::ICore::resourcePath() + QStringLiteral("/qmldesigner/propertyEditorQmlSources");
|
return Core::ICore::resourcePath() + QStringLiteral("/qmldesigner/propertyEditorQmlSources");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PropertyEditorQmlBackend::templateGeneration(NodeMetaInfo type,
|
QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type,
|
||||||
NodeMetaInfo superType,
|
const NodeMetaInfo &superType,
|
||||||
const QmlObjectNode &objectNode)
|
const QmlObjectNode &objectNode)
|
||||||
{
|
{
|
||||||
if (!templateConfiguration() || !templateConfiguration()->isValid())
|
if (!templateConfiguration() || !templateConfiguration()->isValid())
|
||||||
|
@@ -68,7 +68,7 @@ public:
|
|||||||
PropertyEditorValue *propertyValueForName(const QString &propertyName);
|
PropertyEditorValue *propertyValueForName(const QString &propertyName);
|
||||||
|
|
||||||
static QString propertyEditorResourcesPath();
|
static QString propertyEditorResourcesPath();
|
||||||
static QString templateGeneration(NodeMetaInfo type, NodeMetaInfo superType,
|
static QString templateGeneration(const NodeMetaInfo &type, const NodeMetaInfo &superType,
|
||||||
const QmlObjectNode &objectNode);
|
const QmlObjectNode &objectNode);
|
||||||
|
|
||||||
static QUrl getQmlFileUrl(const TypeName &relativeTypeName, const NodeMetaInfo &info = NodeMetaInfo());
|
static QUrl getQmlFileUrl(const TypeName &relativeTypeName, const NodeMetaInfo &info = NodeMetaInfo());
|
||||||
|
@@ -39,7 +39,7 @@ class NodeState;
|
|||||||
|
|
||||||
const PropertyName auxDataString("anchors_");
|
const PropertyName auxDataString("anchors_");
|
||||||
|
|
||||||
static inline void backupPropertyAndRemove(ModelNode node, const PropertyName &propertyName)
|
static inline void backupPropertyAndRemove(const ModelNode &node, const PropertyName &propertyName)
|
||||||
{
|
{
|
||||||
if (node.hasVariantProperty(propertyName)) {
|
if (node.hasVariantProperty(propertyName)) {
|
||||||
node.setAuxiliaryData(auxDataString + propertyName, node.variantProperty(propertyName).value());
|
node.setAuxiliaryData(auxDataString + propertyName, node.variantProperty(propertyName).value());
|
||||||
|
@@ -199,7 +199,7 @@ bool TextEditorWidget::eventFilter( QObject *, QEvent *event)
|
|||||||
| Qt::MetaModifier;
|
| Qt::MetaModifier;
|
||||||
|
|
||||||
QKeySequence keySqeuence(keyEvent->key() | (keyEvent->modifiers() & relevantModifiers));
|
QKeySequence keySqeuence(keyEvent->key() | (keyEvent->modifiers() & relevantModifiers));
|
||||||
for (QKeySequence overrideSequence : overrideSequences)
|
for (const QKeySequence &overrideSequence : overrideSequences)
|
||||||
if (keySqeuence.matches(overrideSequence)) {
|
if (keySqeuence.matches(overrideSequence)) {
|
||||||
keyEvent->accept();
|
keyEvent->accept();
|
||||||
return true;
|
return true;
|
||||||
|
@@ -54,7 +54,7 @@ class QMLDESIGNERCORE_EXPORT NodeMetaInfo
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NodeMetaInfo();
|
NodeMetaInfo();
|
||||||
NodeMetaInfo(Model *model, TypeName type, int maj, int min);
|
NodeMetaInfo(Model *model, const TypeName &type, int maj, int min);
|
||||||
|
|
||||||
~NodeMetaInfo();
|
~NodeMetaInfo();
|
||||||
|
|
||||||
|
@@ -50,8 +50,8 @@ namespace Internal {
|
|||||||
struct TypeDescription
|
struct TypeDescription
|
||||||
{
|
{
|
||||||
QString className;
|
QString className;
|
||||||
int minorVersion;
|
int minorVersion{};
|
||||||
int majorVersion;
|
int majorVersion{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} //Internal
|
} //Internal
|
||||||
@@ -736,7 +736,7 @@ const CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() const
|
|||||||
// get the qml object value that's available in the document
|
// get the qml object value that's available in the document
|
||||||
const QmlJS::Imports *importsPtr = context()->imports(document());
|
const QmlJS::Imports *importsPtr = context()->imports(document());
|
||||||
if (importsPtr) {
|
if (importsPtr) {
|
||||||
const QList<QmlJS::Import> imports = importsPtr->all();
|
const QList<QmlJS::Import> &imports = importsPtr->all();
|
||||||
foreach (const QmlJS::Import &import, imports) {
|
foreach (const QmlJS::Import &import, imports) {
|
||||||
if (import.info.path() != QString::fromUtf8(module))
|
if (import.info.path() != QString::fromUtf8(module))
|
||||||
continue;
|
continue;
|
||||||
@@ -1317,7 +1317,7 @@ NodeMetaInfo::NodeMetaInfo() : m_privateData(new Internal::NodeMetaInfoPrivate()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeMetaInfo::NodeMetaInfo(Model *model, TypeName type, int maj, int min) : m_privateData(Internal::NodeMetaInfoPrivate::create(model, type, maj, min))
|
NodeMetaInfo::NodeMetaInfo(Model *model, const TypeName &type, int maj, int min) : m_privateData(Internal::NodeMetaInfoPrivate::create(model, type, maj, min))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -105,7 +105,7 @@ bool BaseTextEditModifier::renameId(const QString &oldId, const QString &newId)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QmlJS::AST::UiObjectDefinition *getObjectDefinition(QList<QmlJS::AST::Node *> path, QmlJS::AST::UiQualifiedId *qualifiedId)
|
static QmlJS::AST::UiObjectDefinition *getObjectDefinition(const QList<QmlJS::AST::Node *> &path, QmlJS::AST::UiQualifiedId *qualifiedId)
|
||||||
{
|
{
|
||||||
QmlJS::AST::UiObjectDefinition *object = nullptr;
|
QmlJS::AST::UiObjectDefinition *object = nullptr;
|
||||||
for (int i = path.size() - 1; i >= 0; --i) {
|
for (int i = path.size() - 1; i >= 0; --i) {
|
||||||
|
@@ -90,7 +90,7 @@ int QmlTimelineKeyframeGroup::getSupposedTargetIndex(qreal newFrame) const
|
|||||||
{
|
{
|
||||||
const NodeListProperty nodeListProperty = modelNode().defaultNodeListProperty();
|
const NodeListProperty nodeListProperty = modelNode().defaultNodeListProperty();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto node : nodeListProperty.toModelNodeList()) {
|
for (const auto &node : nodeListProperty.toModelNodeList()) {
|
||||||
if (node.hasVariantProperty("frame")) {
|
if (node.hasVariantProperty("frame")) {
|
||||||
const qreal currentFrame = node.variantProperty("frame").value().toReal();
|
const qreal currentFrame = node.variantProperty("frame").value().toReal();
|
||||||
if (!qFuzzyCompare(currentFrame, newFrame)) { //Ignore the frame itself
|
if (!qFuzzyCompare(currentFrame, newFrame)) { //Ignore the frame itself
|
||||||
|
@@ -468,7 +468,7 @@ QString RewriterView::auxiliaryDataAsQML() const
|
|||||||
QString str = "Designer {\n ";
|
QString str = "Designer {\n ";
|
||||||
|
|
||||||
int columnCount = 0;
|
int columnCount = 0;
|
||||||
for (const auto node : allModelNodes()) {
|
for (const auto &node : allModelNodes()) {
|
||||||
QHash<PropertyName, QVariant> data = node.auxiliaryData();
|
QHash<PropertyName, QVariant> data = node.auxiliaryData();
|
||||||
if (!data.isEmpty()) {
|
if (!data.isEmpty()) {
|
||||||
hasAuxData = true;
|
hasAuxData = true;
|
||||||
@@ -918,13 +918,11 @@ QString RewriterView::getRawAuxiliaryData() const
|
|||||||
|
|
||||||
const QString oldText = m_textModifier->text();
|
const QString oldText = m_textModifier->text();
|
||||||
|
|
||||||
QString newText = oldText;
|
int startIndex = oldText.indexOf(annotationsStart());
|
||||||
|
int endIndex = oldText.indexOf(annotationsEnd());
|
||||||
int startIndex = newText.indexOf(annotationsStart());
|
|
||||||
int endIndex = newText.indexOf(annotationsEnd());
|
|
||||||
|
|
||||||
if (startIndex > 0 && endIndex > 0)
|
if (startIndex > 0 && endIndex > 0)
|
||||||
return newText.mid(startIndex, endIndex - startIndex + annotationsEnd().length());
|
return oldText.mid(startIndex, endIndex - startIndex + annotationsEnd().length());
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -957,14 +955,14 @@ void RewriterView::writeAuxiliaryData()
|
|||||||
changeSet.apply(&tc);
|
changeSet.apply(&tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkNode(QmlJS::SimpleReaderNode::Ptr node, RewriterView *view);
|
static void checkNode(const QmlJS::SimpleReaderNode::Ptr &node, RewriterView *view);
|
||||||
|
|
||||||
static void checkChildNodes(QmlJS::SimpleReaderNode::Ptr node, RewriterView *view)
|
static void checkChildNodes(const QmlJS::SimpleReaderNode::Ptr &node, RewriterView *view)
|
||||||
{
|
{
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto child : node->children())
|
for (const auto &child : node->children())
|
||||||
checkNode(child, view);
|
checkNode(child, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -975,7 +973,7 @@ static QString fixUpIllegalChars(const QString &str)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkNode(QmlJS::SimpleReaderNode::Ptr node, RewriterView *view)
|
static void checkNode(const QmlJS::SimpleReaderNode::Ptr &node, RewriterView *view)
|
||||||
{
|
{
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
|
@@ -374,13 +374,13 @@ QWidget *ViewManager::widget(const QString &uniqueId) const
|
|||||||
|
|
||||||
void ViewManager::disableWidgets()
|
void ViewManager::disableWidgets()
|
||||||
{
|
{
|
||||||
for (auto view : views())
|
for (const auto &view : views())
|
||||||
view->disableWidget();
|
view->disableWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewManager::enableWidgets()
|
void ViewManager::enableWidgets()
|
||||||
{
|
{
|
||||||
for (auto view : views())
|
for (const auto &view : views())
|
||||||
view->enableWidget();
|
view->enableWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ static ModelNode pathModelNode(FormEditorItem *formEditorItem)
|
|||||||
|
|
||||||
using PropertyPair = QPair<PropertyName, QVariant>;
|
using PropertyPair = QPair<PropertyName, QVariant>;
|
||||||
|
|
||||||
void PathItem::writeLinePath(ModelNode pathNode, const CubicSegment &cubicSegment)
|
void PathItem::writeLinePath(const ModelNode &pathNode, const CubicSegment &cubicSegment)
|
||||||
{
|
{
|
||||||
QList<PropertyPair> propertyList;
|
QList<PropertyPair> propertyList;
|
||||||
propertyList.append(PropertyPair("x", cubicSegment.fourthControlX()));
|
propertyList.append(PropertyPair("x", cubicSegment.fourthControlX()));
|
||||||
@@ -76,7 +76,7 @@ void PathItem::writeLinePath(ModelNode pathNode, const CubicSegment &cubicSegmen
|
|||||||
pathNode.nodeListProperty("pathElements").reparentHere(lineNode);
|
pathNode.nodeListProperty("pathElements").reparentHere(lineNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::writeQuadPath(ModelNode pathNode, const CubicSegment &cubicSegment)
|
void PathItem::writeQuadPath(const ModelNode &pathNode, const CubicSegment &cubicSegment)
|
||||||
{
|
{
|
||||||
QList<QPair<PropertyName, QVariant> > propertyList;
|
QList<QPair<PropertyName, QVariant> > propertyList;
|
||||||
propertyList.append(PropertyPair("controlX", cubicSegment.quadraticControlX()));
|
propertyList.append(PropertyPair("controlX", cubicSegment.quadraticControlX()));
|
||||||
@@ -88,7 +88,7 @@ void PathItem::writeQuadPath(ModelNode pathNode, const CubicSegment &cubicSegmen
|
|||||||
pathNode.nodeListProperty("pathElements").reparentHere(lineNode);
|
pathNode.nodeListProperty("pathElements").reparentHere(lineNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::writeCubicPath(ModelNode pathNode, const CubicSegment &cubicSegment)
|
void PathItem::writeCubicPath(const ModelNode &pathNode, const CubicSegment &cubicSegment)
|
||||||
{
|
{
|
||||||
QList<QPair<PropertyName, QVariant> > propertyList;
|
QList<QPair<PropertyName, QVariant> > propertyList;
|
||||||
propertyList.append(PropertyPair("control1X", cubicSegment.secondControlX()));
|
propertyList.append(PropertyPair("control1X", cubicSegment.secondControlX()));
|
||||||
@@ -102,7 +102,7 @@ void PathItem::writeCubicPath(ModelNode pathNode, const CubicSegment &cubicSegme
|
|||||||
pathNode.nodeListProperty("pathElements").reparentHere(lineNode);
|
pathNode.nodeListProperty("pathElements").reparentHere(lineNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::writePathAttributes(ModelNode pathNode, const QMap<QString, QVariant> &attributes)
|
void PathItem::writePathAttributes(const ModelNode &pathNode, const QMap<QString, QVariant> &attributes)
|
||||||
{
|
{
|
||||||
QMapIterator<QString, QVariant> attributesIterator(attributes);
|
QMapIterator<QString, QVariant> attributesIterator(attributes);
|
||||||
while (attributesIterator.hasNext()) {
|
while (attributesIterator.hasNext()) {
|
||||||
@@ -116,7 +116,7 @@ void PathItem::writePathAttributes(ModelNode pathNode, const QMap<QString, QVari
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::writePathPercent(ModelNode pathNode, double percent)
|
void PathItem::writePathPercent(const ModelNode& pathNode, double percent)
|
||||||
{
|
{
|
||||||
if (percent >= 0.0) {
|
if (percent >= 0.0) {
|
||||||
QList<QPair<PropertyName, QVariant> > propertyList;
|
QList<QPair<PropertyName, QVariant> > propertyList;
|
||||||
@@ -943,8 +943,8 @@ void PathItem::removeEditPoint(const ControlPoint &controlPoint)
|
|||||||
m_cubicSegments.removeOne(cubicSegments.constFirst());
|
m_cubicSegments.removeOne(cubicSegments.constFirst());
|
||||||
} else if (cubicSegments.count() == 2){
|
} else if (cubicSegments.count() == 2){
|
||||||
CubicSegment mergedCubicSegment = CubicSegment::create();
|
CubicSegment mergedCubicSegment = CubicSegment::create();
|
||||||
CubicSegment firstCubicSegment = cubicSegments.at(0);
|
const CubicSegment &firstCubicSegment = cubicSegments.at(0);
|
||||||
CubicSegment secondCubicSegment = cubicSegments.at(1);
|
const CubicSegment &secondCubicSegment = cubicSegments.at(1);
|
||||||
mergedCubicSegment.setFirstControlPoint(firstCubicSegment.firstControlPoint());
|
mergedCubicSegment.setFirstControlPoint(firstCubicSegment.firstControlPoint());
|
||||||
mergedCubicSegment.setSecondControlPoint(firstCubicSegment.secondControlPoint());
|
mergedCubicSegment.setSecondControlPoint(firstCubicSegment.secondControlPoint());
|
||||||
mergedCubicSegment.setThirdControlPoint(secondCubicSegment.thirdControlPoint());
|
mergedCubicSegment.setThirdControlPoint(secondCubicSegment.thirdControlPoint());
|
||||||
|
@@ -99,11 +99,11 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void updateBoundingRect();
|
void updateBoundingRect();
|
||||||
QRectF instanceBoundingRect() const;
|
QRectF instanceBoundingRect() const;
|
||||||
void writeLinePath(ModelNode pathNode, const CubicSegment &cubicSegment);
|
void writeLinePath(const ModelNode &pathNode, const CubicSegment &cubicSegment);
|
||||||
void writeQuadPath(ModelNode pathNode, const CubicSegment &cubicSegment);
|
void writeQuadPath(const ModelNode &pathNode, const CubicSegment &cubicSegment);
|
||||||
void writeCubicPath(ModelNode pathNode, const CubicSegment &cubicSegment);
|
void writeCubicPath(const ModelNode &pathNode, const CubicSegment &cubicSegment);
|
||||||
void writePathAttributes(ModelNode pathNode, const QMap<QString, QVariant> &attributes);
|
void writePathAttributes(const ModelNode &pathNode, const QMap<QString, QVariant> &attributes);
|
||||||
void writePathPercent(ModelNode pathNode, double percent);
|
void writePathPercent(const ModelNode &pathNode, double percent);
|
||||||
void readControlPoints();
|
void readControlPoints();
|
||||||
void splitCubicSegment(CubicSegment &cubicSegment, double t);
|
void splitCubicSegment(CubicSegment &cubicSegment, double t);
|
||||||
void closePath();
|
void closePath();
|
||||||
|
Reference in New Issue
Block a user