| 192 | QJSEngine* AxCommandGroupWrapper::getEngine() const { return this->engine; } |
| 193 | |
| 194 | void AxCommandGroupWrapper::add(const QJSValue &value) |
| 195 | { |
| 196 | if (value.isUndefined() || value.isNull()) |
| 197 | return; |
| 198 | |
| 199 | if (value.isArray()) { |
| 200 | const int length = value.property("length").toInt(); |
| 201 | for (int i = 0; i < length; ++i) { |
| 202 | QJSValue item = value.property(i); |
| 203 | |
| 204 | QObject* obj = item.toQObject(); |
| 205 | if (auto* commandWrapper = qobject_cast<AxCommandWrappers*>(obj)) { |
| 206 | this->commands.append(commandWrapper->getCommand()); |
| 207 | } else { |
| 208 | Q_EMIT scriptError("Item at index " + QString::number(i) + " is not an Command"); |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | else { |
| 213 | QObject* obj = value.toQObject(); |
| 214 | if (auto* commandWrapper = qobject_cast<AxCommandWrappers*>(obj)) { |
| 215 | this->commands.append(commandWrapper->getCommand()); |
| 216 | } else { |
| 217 | Q_EMIT scriptError("Item is not an Command"); |
| 218 | } |
| 219 | } |
| 220 | } |
no test coverage detected