summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2017-09-22 17:19:17 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2017-09-25 09:18:33 +0000
commitde6b61fd34e7e316607a1904605e895ca27bbcbd (patch)
treed9d93402b413968efb49dd0e367dbc07bcdd9aaf
parent4cb8667d20ff9f4af1451c54560ea864630f49b9 (diff)
qdoc/generator: demonstrate QOverload instead of complex syntax...v5.10.0-beta1
...for connecting to overloaded signals. Change-Id: I30ad6c371f01212dba8a6f9a905c766a961b32a1 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
-rw-r--r--src/qdoc/generator.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp
index 5ec9e4c58..bef912013 100644
--- a/src/qdoc/generator.cpp
+++ b/src/qdoc/generator.cpp
@@ -1632,10 +1632,11 @@ void Generator::generateOverloadedSignal(const Node* node, CodeMarker* marker)
objectName[0] = objectName[0].toLower();
}
-
- // We have an overloaded signal, show an example
- QString code = "connect(" + objectName + ", static_cast<" + func->returnType()
- + QLatin1Char('(') + func->parent()->name() + "::*)(";
+ // We have an overloaded signal, show an example. Note, for const
+ // overloaded signals one should use Q{Const,NonConst}Overload, but
+ // it is very unlikely that we will ever have public API overloading
+ // signals by const.
+ QString code = "connect(" + objectName + ", QOverload<";
for (int i = 0; i < func->parameters().size(); ++i) {
if (i != 0)
code += ", ";
@@ -1643,10 +1644,7 @@ void Generator::generateOverloadedSignal(const Node* node, CodeMarker* marker)
code += p.dataType() + p.rightType();
}
- code += QLatin1Char(')');
- if (func->isConst())
- code += " const";
- code += ">(&" + func->parent()->name() + "::" + func->name() + "),\n [=](";
+ code += ">::of(&" + func->parent()->name() + "::" + func->name() + "),\n [=](";
for (int i = 0; i < func->parameters().size(); ++i) {
if (i != 0)
@@ -1670,8 +1668,9 @@ void Generator::generateOverloadedSignal(const Node* node, CodeMarker* marker)
<< node->name()
<< Atom(Atom::FormattingRight,ATOM_FORMATTING_ITALIC)
<< " is overloaded in this class. "
- "To connect to this one using the function pointer syntax, you must "
- "specify the signal type in a static cast, as shown in this example:"
+ "To connect to this signal by using the function pointer syntax, Qt "
+ "provides a convenient helper for obtaining the function pointer as "
+ "shown in this example:"
<< Atom(Atom::Code, marker->markedUpCode(code, node, func->location()));
generateText(text, node, marker);