| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qqmldebugserviceinterfaces_p.h" |
| 5 | |
| 6 | QT_BEGIN_NAMESPACE |
| 7 | |
| 8 | const QString QV4DebugService::s_key = QStringLiteral("V8Debugger"); |
| 9 | const QString QQmlEngineDebugService::s_key = QStringLiteral("QmlDebugger"); |
| 10 | const QString QQmlInspectorService::s_key = QStringLiteral("QmlInspector"); |
| 11 | const QString QQmlProfilerService::s_key = QStringLiteral("CanvasFrameRate"); |
| 12 | const QString QDebugMessageService::s_key = QStringLiteral("DebugMessages"); |
| 13 | const QString QQmlEngineControlService::s_key = QStringLiteral("EngineControl"); |
| 14 | const QString QQmlNativeDebugService::s_key = QStringLiteral("NativeQmlDebugger"); |
| 15 | #if QT_CONFIG(translation) |
| 16 | const QString QQmlDebugTranslationService::s_key = QStringLiteral("DebugTranslation"); |
| 17 | #endif |
| 18 | |
| 19 | QV4DebugService::~QV4DebugService() |
| 20 | = default; |
| 21 | QQmlEngineDebugService::~QQmlEngineDebugService() |
| 22 | = default; |
| 23 | QQmlInspectorService::~QQmlInspectorService() |
| 24 | = default; |
| 25 | QQmlProfilerService::~QQmlProfilerService() |
| 26 | = default; |
| 27 | QDebugMessageService::~QDebugMessageService() |
| 28 | = default; |
| 29 | QQmlEngineControlService::~QQmlEngineControlService() |
| 30 | = default; |
| 31 | QQmlNativeDebugService::~QQmlNativeDebugService() |
| 32 | = default; |
| 33 | |
| 34 | static QQmlDebugStatesDelegate *(*statesDelegateFactory)() = nullptr; |
| 35 | void QQmlEngineDebugService::setStatesDelegateFactory(QQmlDebugStatesDelegate *(*factory)()) |
| 36 | { |
| 37 | statesDelegateFactory = factory; |
| 38 | } |
| 39 | |
| 40 | QQmlDebugStatesDelegate *QQmlEngineDebugService::createStatesDelegate() |
| 41 | { |
| 42 | return statesDelegateFactory ? statesDelegateFactory() : nullptr; |
| 43 | } |
| 44 | |
| 45 | #if QT_CONFIG(translation) |
| 46 | QQmlDebugTranslationService::~QQmlDebugTranslationService() |
| 47 | = default; |
| 48 | |
| 49 | const TranslationBindingInformation TranslationBindingInformation::create( |
| 50 | const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, |
| 51 | const QV4::CompiledData::Binding *binding, QObject *scopeObject, |
| 52 | QQmlRefPointer<QQmlContextData> ctxt) |
| 53 | { |
| 54 | QQmlTranslation translation; |
| 55 | if (binding->type() == QV4::CompiledData::Binding::Type_TranslationById) { |
| 56 | const QV4::CompiledData::TranslationData data = |
| 57 | compilationUnit->unitData()->translations()[binding->value.translationDataIndex]; |
| 58 | const QString id = compilationUnit->stringAt(index: data.stringIndex); |
| 59 | const int n = data.number; |
| 60 | |
| 61 | translation = QQmlTranslation(QQmlTranslation::QsTrIdData(id, n)); |
| 62 | } else { |
| 63 | Q_ASSERT(binding->type() == QV4::CompiledData::Binding::Type_Translation); |
| 64 | |
| 65 | const QV4::CompiledData::TranslationData data = |
| 66 | compilationUnit->unitData()->translations()[binding->value.translationDataIndex]; |
| 67 | const QString text = compilationUnit->stringAt(index: data.stringIndex); |
| 68 | const QString comment = compilationUnit->stringAt(index: data.commentIndex); |
| 69 | const bool hasContext |
| 70 | = data.contextIndex != QV4::CompiledData::TranslationData::NoContextIndex; |
| 71 | const int n = data.number; |
| 72 | |
| 73 | translation = QQmlTranslation( |
| 74 | QQmlTranslation::QsTrData( |
| 75 | hasContext |
| 76 | ? compilationUnit->stringAt(index: data.contextIndex) |
| 77 | : QQmlTranslation::contextFromQmlFilename( |
| 78 | qmlFilename: compilationUnit->fileName()), |
| 79 | text, comment, n)); |
| 80 | } |
| 81 | |
| 82 | return { .compilationUnit: compilationUnit, |
| 83 | .scopeObject: scopeObject, |
| 84 | .ctxt: ctxt, |
| 85 | |
| 86 | .propertyName: compilationUnit->stringAt(index: binding->propertyNameIndex), |
| 87 | .translation: translation, |
| 88 | |
| 89 | .line: binding->location.line(), |
| 90 | .column: binding->location.column() }; |
| 91 | } |
| 92 | #endif |
| 93 | |
| 94 | QT_END_NAMESPACE |
| 95 | |
| 96 | #include "moc_qqmldebugserviceinterfaces_p.cpp" |
| 97 |
Definitions
Learn Advanced QML with KDAB
Find out more
