diff options
author | Topi Reinio <topi.reinio@qt.io> | 2021-03-15 22:01:15 +0100 |
---|---|---|
committer | Topi Reinio <topi.reinio@qt.io> | 2021-03-17 14:53:20 +0100 |
commit | 5dd444d42a4843f23d7d1dace642a13d10f750bb (patch) | |
tree | b69c631ec52959769b51ff285b7d61d354444072 /src/qdoc/qmlvisitor.cpp | |
parent | b7fd470a5b0fad2193bcfcb415e35f393250722d (diff) | |
download | qttools-5dd444d42a4843f23d7d1dace642a13d10f750bb.tar.gz |
qdoc: Re-implement \default command
Marking a QML property as a default property is now done with \qmldefault
command; repurpose the \default command to set a default value for a
property.
The default value is visible in the detailed property documentation as
an extra 'default: <value>' attribute. The value is taken as-is from
the argument passed to the command.
Fixes: QTBUG-81525
Change-Id: I7a4395e6e96046facfc3d75cc62a3bd01d04935b
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc/qmlvisitor.cpp')
-rw-r--r-- | src/qdoc/qmlvisitor.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qdoc/qmlvisitor.cpp b/src/qdoc/qmlvisitor.cpp index fd55cec73..fb2c15c2d 100644 --- a/src/qdoc/qmlvisitor.cpp +++ b/src/qdoc/qmlvisitor.cpp @@ -445,6 +445,16 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::SourceLocation, Node *node, Doc &d QmlTypeNode *qmlType = static_cast<QmlTypeNode *>(node); qmlType->setQmlBaseName(args[0].first); } + } else if (command == COMMAND_DEFAULT) { + if (!node->isQmlProperty()) { + doc.location().warning(QStringLiteral("Ignored '\\%1', applies only to '\\%2'") + .arg(command, COMMAND_QMLPROPERTY)); + } else if (args.isEmpty() || args[0].first.isEmpty()) { + doc.location().warning(QStringLiteral("Expected an argument for '\\%1' (maybe you meant '\\%2'?)") + .arg(command, COMMAND_QMLDEFAULT)); + } else { + static_cast<QmlPropertyNode *>(node)->setDefaultValue(args[0].first); + } } else if (command == COMMAND_QMLDEFAULT) { node->markDefault(); } else if (command == COMMAND_QMLREADONLY) { |