3 #include <QMetaProperty>
4 #include <QScriptValueIterator>
13 QString item = base.isEmpty() ? subItem : base+
"."+subItem;
14 QString res = tr(
"<a href=\"qrc:/help/autohelp?%1\">%2</a>").arg(item).arg(item);
19 res.append(
"</td>\n<td width=\"75%\">\n");
22 res.append(tr(
"<p><i>%1</i></p>\n").arg(proto));
26 res.append(tr(
"<p>%1</p>\n").arg(doc));
35 "<table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"black\" width=\"100%\">\n"
37 "<td bgcolor=\"black\">\n"
38 "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"black\" width=\"100%\">\n";
56 QString itemName=
"Global";
61 val = globalObject().property(item);
72 res.append(tr(
"<h2>Documentation for %1</h2>\n").arg(itemName));
74 if (val.isFunction()) {
76 res.append(tr(
"<p><i>%1</i></p>\n").arg(proto));
80 res.append(tr(
"%1\n").arg(doc));
83 if (longDoc.length()) {
84 res.append(tr(
"%1\n").arg(longDoc));
86 }
else if (val.isObject()) {
87 res.append(tr(
"%1\n").arg(doc));
88 res.append(tr(
"%1\n").arg(longDoc));
90 QObject *qobj = val.toQObject();
93 res.append(tr(
"<h3>QObject class %1 name %2</h3>\n")
94 .arg(qobj->metaObject()->className())
95 .arg(qobj->objectName()));
97 const QMetaObject *meta = qobj->metaObject();
99 if (meta->propertyCount() > QObject::staticMetaObject.propertyCount()) {
100 res.append(tr(
"<h3>%1 Properties</h3>\n").arg(itemName));
103 for (
int i=QObject::staticMetaObject.propertyCount();
104 i<meta->propertyCount(); i++) {
105 const char* propName = meta->property(i).name();
106 QVariant val = qobj->property(propName);
109 res.append(tr(
"<tr bgcolor=\"#e0e0e0\">\n"));
111 res.append(tr(
"<tr bgcolor=\"white\">\n"));
113 res.append(tr(
"<td>%1</td><td>%2</td><td>%3</td>\n")
114 .arg(prefix+propName)
116 .arg(val.toString()));
120 res.append(tr(
"<td width=\"75%\">%1</td>\n").arg(doc));
122 res.append(
"</tr>\n");
128 if (qobj->dynamicPropertyNames().count()) {
129 res.append(tr(
"<h3>%1 User Defined Properties</h3>\n").arg(itemName));
132 QList<QByteArray> props = qobj->dynamicPropertyNames();
134 for (
int i=0; i<props.count(); i++) {
135 QString propName = props[i];
136 QVariant val = qobj->property(qPrintable(propName));
139 res.append(tr(
"<tr bgcolor=\"#e0e0e0\">\n"));
141 res.append(tr(
"<tr bgcolor=\"white\">\n"));
144 res.append(tr(
"<td>%1</td><td>%2</td><td>%3</td>\n")
145 .arg(prefix+propName)
147 .arg(val.toString()));
151 res.append(tr(
"<td width=\"75%\">%1</td>\n").arg(doc));
153 res.append(
"</tr>\n");
159 if (meta->methodCount() > QObject::staticMetaObject.methodCount()) {
160 res.append(tr(
"<h3>%1 Functions</h3>\n").arg(itemName));
163 for (
int i=QObject::staticMetaObject.methodCount();
164 i<meta->methodCount(); i++) {
165 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
166 QByteArray methodSig = meta->method(i).methodSignature();
168 const char* methodSig = meta->method(i).signature();
170 const char* returnType = meta->method(i).typeName();
171 QByteArray methodName = meta->method(i).name();
173 QMetaMethod::MethodType methodType = meta->method(i).methodType();
176 res.append(tr(
"<tr bgcolor=\"#e0e0e0\">\n"));
178 res.append(tr(
"<tr bgcolor=\"white\">\n"));
181 QList<QByteArray> parameterTypes = meta->method(i).parameterTypes();
182 QList<QByteArray> parameterNames = meta->method(i).parameterNames();
184 QString parameterPack =
"";
186 for (
int i=0; i<parameterTypes.count(); i++) {
188 parameterPack +=
", ";
190 parameterPack += parameterTypes.value(i) +
" " + parameterNames.value(i);
193 QString prototype = tr(
"%1 %2%3(%4)")
195 .arg(QString(prefix))
196 .arg(QString(methodName))
199 prototype.replace(QString(
"&"), QString(
"&"));
200 prototype.replace(QString(
"\""), QString(
"""));
201 prototype.replace(QString(
"'"), QString(
"'"));
202 prototype.replace(QString(
"<"), QString(
"<"));
203 prototype.replace(QString(
">"), QString(
">"));
205 res.append(tr(
"<td><i>%1</i></td>\n").arg(prototype));
211 switch (methodType) {
212 case QMetaMethod::Signal:
213 res.append(
"<i>Signal</i><br/>\n");
215 case QMetaMethod::Slot:
216 res.append(
"<i>Slot</i><br/>\n");
222 res.append(tr(
"%1<br/>\n").arg(proto));
223 res.append(tr(
"%1</td>\n").arg(doc));
225 res.append(tr(
"</tr>\n"));
231 QScriptValueIterator iter(val);
233 QMap<QString, QScriptValue> subObjects, properties, functions;
235 while (iter.hasNext()) {
238 QScriptValue v = iter.value();
239 QString n = iter.name();
241 if (v.isFunction()) {
242 functions.insert(n, v);
243 }
else if (v.isObject()) {
244 subObjects.insert(n, v);
246 properties.insert(n, v);
250 if (subObjects.count()) {
251 QMapIterator<QString,QScriptValue> obj_iter(subObjects);
253 res.append(tr(
"<h3>%1 Objects</h3>\n").arg(itemName));
258 while (obj_iter.hasNext()) {
262 res.append(tr(
"<tr bgcolor=\"#e0e0e0\">\n"));
264 res.append(tr(
"<tr bgcolor=\"white\">\n"));
267 res.append(tr(
"</tr>\n"));
273 if (properties.count()) {
274 QMapIterator<QString,QScriptValue> prop_iter(properties);
276 res.append(tr(
"<h3>%1 Properties</h3>\n").arg(itemName));
281 while (prop_iter.hasNext()) {
285 res.append(tr(
"<tr bgcolor=\"#e0e0e0\">\n"));
287 res.append(tr(
"<tr bgcolor=\"white\">\n"));
290 res.append(tr(
"</tr>\n"));
296 if (functions.count()) {
297 QMapIterator<QString,QScriptValue> func_iter(functions);
299 res.append(tr(
"<h3>%1 Functions</h3>\n").arg(itemName));
304 while (func_iter.hasNext()) {
308 res.append(tr(
"<tr bgcolor=\"#e0e0e0\">\n"));
310 res.append(tr(
"<tr bgcolor=\"white\">\n"));
313 res.append(tr(
"</tr>\n"));
330 while (iter.hasNext()) {
332 if (pattern.exactMatch(iter.key())) {
349 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
352 " <title>qxrd help</title>\n"
static QString get_Doc(QString name)
QString documentationText(QString item)
QcepScriptEngine(QObject *parent=0)
static QString get_LongDoc(QString name)
static QString get_Proto(QString name)
QByteArray helpText(QString item)
static QHash< QString, QString > docs()
QString documentationLink(QString base, QString subItem)