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:
|
||||
using Results = QList<AST::SourceLocation>;
|
||||
|
||||
FindImplementationVisitor(Document::Ptr doc, const ContextPtr &context)
|
||||
FindImplementationVisitor(const Document::Ptr &doc, const ContextPtr &context)
|
||||
: m_document(doc)
|
||||
, m_context(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)) {
|
||||
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,
|
||||
TypeName layoutType,
|
||||
const TypeName &layoutType,
|
||||
LessThan lessThan)
|
||||
{
|
||||
if (!selectionContext.view()
|
||||
@@ -578,7 +578,7 @@ static PropertyNameList sortedPropertyNameList(const PropertyNameList &nameList)
|
||||
return sortedPropertyNameList;
|
||||
}
|
||||
|
||||
static QString toUpper(const QString signal)
|
||||
static QString toUpper(const QString &signal)
|
||||
{
|
||||
QString ret = signal;
|
||||
ret[0] = signal.at(0).toUpper();
|
||||
|
@@ -135,7 +135,7 @@ QString DesignDocumentView::toText() const
|
||||
//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()));
|
||||
inputModel->setFileUrl(model()->fileUrl());
|
||||
|
@@ -47,7 +47,7 @@ public:
|
||||
void fromClipboard();
|
||||
|
||||
QString toText() const;
|
||||
void fromText(QString text);
|
||||
void fromText(const QString &text);
|
||||
|
||||
static Model *pasteToModel();
|
||||
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);
|
||||
|
@@ -401,8 +401,8 @@ QString PropertyEditorQmlBackend::propertyEditorResourcesPath() {
|
||||
return Core::ICore::resourcePath() + QStringLiteral("/qmldesigner/propertyEditorQmlSources");
|
||||
}
|
||||
|
||||
QString PropertyEditorQmlBackend::templateGeneration(NodeMetaInfo type,
|
||||
NodeMetaInfo superType,
|
||||
QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type,
|
||||
const NodeMetaInfo &superType,
|
||||
const QmlObjectNode &objectNode)
|
||||
{
|
||||
if (!templateConfiguration() || !templateConfiguration()->isValid())
|
||||
|
@@ -68,7 +68,7 @@ public:
|
||||
PropertyEditorValue *propertyValueForName(const QString &propertyName);
|
||||
|
||||
static QString propertyEditorResourcesPath();
|
||||
static QString templateGeneration(NodeMetaInfo type, NodeMetaInfo superType,
|
||||
static QString templateGeneration(const NodeMetaInfo &type, const NodeMetaInfo &superType,
|
||||
const QmlObjectNode &objectNode);
|
||||
|
||||
static QUrl getQmlFileUrl(const TypeName &relativeTypeName, const NodeMetaInfo &info = NodeMetaInfo());
|
||||
|
@@ -39,7 +39,7 @@ class NodeState;
|
||||
|
||||
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)) {
|
||||
node.setAuxiliaryData(auxDataString + propertyName, node.variantProperty(propertyName).value());
|
||||
|
@@ -199,7 +199,7 @@ bool TextEditorWidget::eventFilter( QObject *, QEvent *event)
|
||||
| Qt::MetaModifier;
|
||||
|
||||
QKeySequence keySqeuence(keyEvent->key() | (keyEvent->modifiers() & relevantModifiers));
|
||||
for (QKeySequence overrideSequence : overrideSequences)
|
||||
for (const QKeySequence &overrideSequence : overrideSequences)
|
||||
if (keySqeuence.matches(overrideSequence)) {
|
||||
keyEvent->accept();
|
||||
return true;
|
||||
|
@@ -54,7 +54,7 @@ class QMLDESIGNERCORE_EXPORT NodeMetaInfo
|
||||
{
|
||||
public:
|
||||
NodeMetaInfo();
|
||||
NodeMetaInfo(Model *model, TypeName type, int maj, int min);
|
||||
NodeMetaInfo(Model *model, const TypeName &type, int maj, int min);
|
||||
|
||||
~NodeMetaInfo();
|
||||
|
||||
|
@@ -50,8 +50,8 @@ namespace Internal {
|
||||
struct TypeDescription
|
||||
{
|
||||
QString className;
|
||||
int minorVersion;
|
||||
int majorVersion;
|
||||
int minorVersion{};
|
||||
int majorVersion{};
|
||||
};
|
||||
|
||||
} //Internal
|
||||
@@ -736,7 +736,7 @@ const CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() const
|
||||
// get the qml object value that's available in the document
|
||||
const QmlJS::Imports *importsPtr = context()->imports(document());
|
||||
if (importsPtr) {
|
||||
const QList<QmlJS::Import> imports = importsPtr->all();
|
||||
const QList<QmlJS::Import> &imports = importsPtr->all();
|
||||
foreach (const QmlJS::Import &import, imports) {
|
||||
if (import.info.path() != QString::fromUtf8(module))
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
for (int i = path.size() - 1; i >= 0; --i) {
|
||||
|
@@ -90,7 +90,7 @@ int QmlTimelineKeyframeGroup::getSupposedTargetIndex(qreal newFrame) const
|
||||
{
|
||||
const NodeListProperty nodeListProperty = modelNode().defaultNodeListProperty();
|
||||
int i = 0;
|
||||
for (auto node : nodeListProperty.toModelNodeList()) {
|
||||
for (const auto &node : nodeListProperty.toModelNodeList()) {
|
||||
if (node.hasVariantProperty("frame")) {
|
||||
const qreal currentFrame = node.variantProperty("frame").value().toReal();
|
||||
if (!qFuzzyCompare(currentFrame, newFrame)) { //Ignore the frame itself
|
||||
|
@@ -468,7 +468,7 @@ QString RewriterView::auxiliaryDataAsQML() const
|
||||
QString str = "Designer {\n ";
|
||||
|
||||
int columnCount = 0;
|
||||
for (const auto node : allModelNodes()) {
|
||||
for (const auto &node : allModelNodes()) {
|
||||
QHash<PropertyName, QVariant> data = node.auxiliaryData();
|
||||
if (!data.isEmpty()) {
|
||||
hasAuxData = true;
|
||||
@@ -918,13 +918,11 @@ QString RewriterView::getRawAuxiliaryData() const
|
||||
|
||||
const QString oldText = m_textModifier->text();
|
||||
|
||||
QString newText = oldText;
|
||||
|
||||
int startIndex = newText.indexOf(annotationsStart());
|
||||
int endIndex = newText.indexOf(annotationsEnd());
|
||||
int startIndex = oldText.indexOf(annotationsStart());
|
||||
int endIndex = oldText.indexOf(annotationsEnd());
|
||||
|
||||
if (startIndex > 0 && endIndex > 0)
|
||||
return newText.mid(startIndex, endIndex - startIndex + annotationsEnd().length());
|
||||
return oldText.mid(startIndex, endIndex - startIndex + annotationsEnd().length());
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -957,14 +955,14 @@ void RewriterView::writeAuxiliaryData()
|
||||
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)
|
||||
return;
|
||||
|
||||
for (auto child : node->children())
|
||||
for (const auto &child : node->children())
|
||||
checkNode(child, view);
|
||||
}
|
||||
|
||||
@@ -975,7 +973,7 @@ static QString fixUpIllegalChars(const QString &str)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void checkNode(QmlJS::SimpleReaderNode::Ptr node, RewriterView *view)
|
||||
static void checkNode(const QmlJS::SimpleReaderNode::Ptr &node, RewriterView *view)
|
||||
{
|
||||
if (!node)
|
||||
return;
|
||||
|
@@ -374,13 +374,13 @@ QWidget *ViewManager::widget(const QString &uniqueId) const
|
||||
|
||||
void ViewManager::disableWidgets()
|
||||
{
|
||||
for (auto view : views())
|
||||
for (const auto &view : views())
|
||||
view->disableWidget();
|
||||
}
|
||||
|
||||
void ViewManager::enableWidgets()
|
||||
{
|
||||
for (auto view : views())
|
||||
for (const auto &view : views())
|
||||
view->enableWidget();
|
||||
}
|
||||
|
||||
|
@@ -66,7 +66,7 @@ static ModelNode pathModelNode(FormEditorItem *formEditorItem)
|
||||
|
||||
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;
|
||||
propertyList.append(PropertyPair("x", cubicSegment.fourthControlX()));
|
||||
@@ -76,7 +76,7 @@ void PathItem::writeLinePath(ModelNode pathNode, const CubicSegment &cubicSegmen
|
||||
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;
|
||||
propertyList.append(PropertyPair("controlX", cubicSegment.quadraticControlX()));
|
||||
@@ -88,7 +88,7 @@ void PathItem::writeQuadPath(ModelNode pathNode, const CubicSegment &cubicSegmen
|
||||
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;
|
||||
propertyList.append(PropertyPair("control1X", cubicSegment.secondControlX()));
|
||||
@@ -102,7 +102,7 @@ void PathItem::writeCubicPath(ModelNode pathNode, const CubicSegment &cubicSegme
|
||||
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);
|
||||
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) {
|
||||
QList<QPair<PropertyName, QVariant> > propertyList;
|
||||
@@ -943,8 +943,8 @@ void PathItem::removeEditPoint(const ControlPoint &controlPoint)
|
||||
m_cubicSegments.removeOne(cubicSegments.constFirst());
|
||||
} else if (cubicSegments.count() == 2){
|
||||
CubicSegment mergedCubicSegment = CubicSegment::create();
|
||||
CubicSegment firstCubicSegment = cubicSegments.at(0);
|
||||
CubicSegment secondCubicSegment = cubicSegments.at(1);
|
||||
const CubicSegment &firstCubicSegment = cubicSegments.at(0);
|
||||
const CubicSegment &secondCubicSegment = cubicSegments.at(1);
|
||||
mergedCubicSegment.setFirstControlPoint(firstCubicSegment.firstControlPoint());
|
||||
mergedCubicSegment.setSecondControlPoint(firstCubicSegment.secondControlPoint());
|
||||
mergedCubicSegment.setThirdControlPoint(secondCubicSegment.thirdControlPoint());
|
||||
|
@@ -99,11 +99,11 @@ public:
|
||||
protected:
|
||||
void updateBoundingRect();
|
||||
QRectF instanceBoundingRect() const;
|
||||
void writeLinePath(ModelNode pathNode, const CubicSegment &cubicSegment);
|
||||
void writeQuadPath(ModelNode pathNode, const CubicSegment &cubicSegment);
|
||||
void writeCubicPath(ModelNode pathNode, const CubicSegment &cubicSegment);
|
||||
void writePathAttributes(ModelNode pathNode, const QMap<QString, QVariant> &attributes);
|
||||
void writePathPercent(ModelNode pathNode, double percent);
|
||||
void writeLinePath(const ModelNode &pathNode, const CubicSegment &cubicSegment);
|
||||
void writeQuadPath(const ModelNode &pathNode, const CubicSegment &cubicSegment);
|
||||
void writeCubicPath(const ModelNode &pathNode, const CubicSegment &cubicSegment);
|
||||
void writePathAttributes(const ModelNode &pathNode, const QMap<QString, QVariant> &attributes);
|
||||
void writePathPercent(const ModelNode &pathNode, double percent);
|
||||
void readControlPoints();
|
||||
void splitCubicSegment(CubicSegment &cubicSegment, double t);
|
||||
void closePath();
|
||||
|
Reference in New Issue
Block a user