| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/util/qqmlpropertymap.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | - | |||||||
| 8 | class QQmlPropertyMapMetaObject : public QQmlOpenMetaObject | - | ||||||
| 9 | { | - | ||||||
| 10 | public: | - | ||||||
| 11 | QQmlPropertyMapMetaObject(QQmlPropertyMap *obj, QQmlPropertyMapPrivate *objPriv, const QMetaObject *staticMetaObject); | - | ||||||
| 12 | - | |||||||
| 13 | protected: | - | ||||||
| 14 | QVariant propertyWriteValue(int, const QVariant &) override; | - | ||||||
| 15 | void propertyWritten(int index) override; | - | ||||||
| 16 | void propertyCreated(int, QMetaPropertyBuilder &) override; | - | ||||||
| 17 | int createProperty(const char *, const char *) override; | - | ||||||
| 18 | - | |||||||
| 19 | const QString &propertyName(int index); | - | ||||||
| 20 | - | |||||||
| 21 | private: | - | ||||||
| 22 | QQmlPropertyMap *map; | - | ||||||
| 23 | QQmlPropertyMapPrivate *priv; | - | ||||||
| 24 | }; | - | ||||||
| 25 | - | |||||||
| 26 | class QQmlPropertyMapPrivate : public QObjectPrivate | - | ||||||
| 27 | { | - | ||||||
| 28 | inline QQmlPropertyMap* q_func() { return static_cast<QQmlPropertyMap *>(q_ptr); } inline const QQmlPropertyMap* q_func() const { return static_cast<const QQmlPropertyMap *>(q_ptr); } friend class QQmlPropertyMap; | - | ||||||
| 29 | public: | - | ||||||
| 30 | QQmlPropertyMapMetaObject *mo; | - | ||||||
| 31 | QStringList keys; | - | ||||||
| 32 | - | |||||||
| 33 | QVariant updateValue(const QString &key, const QVariant &input); | - | ||||||
| 34 | void emitChanged(const QString &key, const QVariant &value); | - | ||||||
| 35 | bool validKeyName(const QString& name); | - | ||||||
| 36 | - | |||||||
| 37 | const QString &propertyName(int index) const; | - | ||||||
| 38 | }; | - | ||||||
| 39 | - | |||||||
| 40 | bool QQmlPropertyMapPrivate::validKeyName(const QString& name) | - | ||||||
| 41 | { | - | ||||||
| 42 | - | |||||||
| 43 | return executed 100 times by 1 test: name != QLatin1String("keys")return name != QLatin1String("keys") && name != QLatin1String("valueChanged") && name != QLatin1String("QObject") && name != QLatin1String("destroyed") && name != QLatin1String("deleteLater");Executed by:
executed 100 times by 1 test: return name != QLatin1String("keys") && name != QLatin1String("valueChanged") && name != QLatin1String("QObject") && name != QLatin1String("destroyed") && name != QLatin1String("deleteLater");Executed by:
| 100 | ||||||
| 44 | && name != QLatin1String("valueChanged") executed 100 times by 1 test: return name != QLatin1String("keys") && name != QLatin1String("valueChanged") && name != QLatin1String("QObject") && name != QLatin1String("destroyed") && name != QLatin1String("deleteLater");Executed by:
| 100 | ||||||
| 45 | && name != QLatin1String("QObject") executed 100 times by 1 test: return name != QLatin1String("keys") && name != QLatin1String("valueChanged") && name != QLatin1String("QObject") && name != QLatin1String("destroyed") && name != QLatin1String("deleteLater");Executed by:
| 100 | ||||||
| 46 | && name != QLatin1String("destroyed") executed 100 times by 1 test: return name != QLatin1String("keys") && name != QLatin1String("valueChanged") && name != QLatin1String("QObject") && name != QLatin1String("destroyed") && name != QLatin1String("deleteLater");Executed by:
| 100 | ||||||
| 47 | && name != QLatin1String("deleteLater"); executed 100 times by 1 test: return name != QLatin1String("keys") && name != QLatin1String("valueChanged") && name != QLatin1String("QObject") && name != QLatin1String("destroyed") && name != QLatin1String("deleteLater");Executed by:
| 100 | ||||||
| 48 | } | - | ||||||
| 49 | - | |||||||
| 50 | QVariant QQmlPropertyMapPrivate::updateValue(const QString &key, const QVariant &input) | - | ||||||
| 51 | { | - | ||||||
| 52 | QQmlPropertyMap * const q = q_func(); | - | ||||||
| 53 | return executed 10 times by 1 test: q->updateValue(key, input);return q->updateValue(key, input);Executed by:
executed 10 times by 1 test: return q->updateValue(key, input);Executed by:
| 10 | ||||||
| 54 | } | - | ||||||
| 55 | - | |||||||
| 56 | void QQmlPropertyMapPrivate::emitChanged(const QString &key, const QVariant &value) | - | ||||||
| 57 | { | - | ||||||
| 58 | QQmlPropertyMap * const q = q_func(); | - | ||||||
| 59 | q->valueChanged(key, value); | - | ||||||
| 60 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||
| 61 | - | |||||||
| 62 | const QString &QQmlPropertyMapPrivate::propertyName(int index) const | - | ||||||
| 63 | { | - | ||||||
| 64 | ((index < keys.size()) ? static_cast<void>(0) : qt_assert("index < keys.size()", __FILE__, 107)); | - | ||||||
| 65 | return executed 20 times by 1 test: keys[index];return keys[index];Executed by:
executed 20 times by 1 test: return keys[index];Executed by:
| 20 | ||||||
| 66 | } | - | ||||||
| 67 | - | |||||||
| 68 | QQmlPropertyMapMetaObject::QQmlPropertyMapMetaObject(QQmlPropertyMap *obj, QQmlPropertyMapPrivate *objPriv, const QMetaObject *staticMetaObject) | - | ||||||
| 69 | : QQmlOpenMetaObject(obj, staticMetaObject) | - | ||||||
| 70 | { | - | ||||||
| 71 | map = obj; | - | ||||||
| 72 | priv = objPriv; | - | ||||||
| 73 | } executed 68 times by 6 tests: end of blockExecuted by:
| 68 | ||||||
| 74 | - | |||||||
| 75 | QVariant QQmlPropertyMapMetaObject::propertyWriteValue(int index, const QVariant &input) | - | ||||||
| 76 | { | - | ||||||
| 77 | return executed 10 times by 1 test: priv->updateValue(priv->propertyName(index), input);return priv->updateValue(priv->propertyName(index), input);Executed by:
executed 10 times by 1 test: return priv->updateValue(priv->propertyName(index), input);Executed by:
| 10 | ||||||
| 78 | } | - | ||||||
| 79 | - | |||||||
| 80 | void QQmlPropertyMapMetaObject::propertyWritten(int index) | - | ||||||
| 81 | { | - | ||||||
| 82 | priv->emitChanged(priv->propertyName(index), value(index)); | - | ||||||
| 83 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||
| 84 | - | |||||||
| 85 | void QQmlPropertyMapMetaObject::propertyCreated(int, QMetaPropertyBuilder &b) | - | ||||||
| 86 | { | - | ||||||
| 87 | priv->keys.append(QString::fromUtf8(b.name())); | - | ||||||
| 88 | } executed 46 times by 1 test: end of blockExecuted by:
| 46 | ||||||
| 89 | - | |||||||
| 90 | int QQmlPropertyMapMetaObject::createProperty(const char *name, const char *value) | - | ||||||
| 91 | { | - | ||||||
| 92 | if (!priv->validKeyName(QString::fromUtf8(name))
| 0-46 | ||||||
| 93 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||
| 94 | return executed 46 times by 1 test: QQmlOpenMetaObject::createProperty(name, value);return QQmlOpenMetaObject::createProperty(name, value);Executed by:
executed 46 times by 1 test: return QQmlOpenMetaObject::createProperty(name, value);Executed by:
| 46 | ||||||
| 95 | } | - | ||||||
| 96 | QQmlPropertyMap::QQmlPropertyMap(QObject *parent) | - | ||||||
| 97 | : QQmlPropertyMap(&staticMetaObject, parent) | - | ||||||
| 98 | { | - | ||||||
| 99 | } executed 54 times by 5 tests: end of blockExecuted by:
| 54 | ||||||
| 100 | - | |||||||
| 101 | - | |||||||
| 102 | - | |||||||
| 103 | - | |||||||
| 104 | QQmlPropertyMap::~QQmlPropertyMap() | - | ||||||
| 105 | { | - | ||||||
| 106 | } | - | ||||||
| 107 | - | |||||||
| 108 | - | |||||||
| 109 | - | |||||||
| 110 | - | |||||||
| 111 | void QQmlPropertyMap::clear(const QString &key) | - | ||||||
| 112 | { | - | ||||||
| 113 | QQmlPropertyMapPrivate * const d = d_func(); | - | ||||||
| 114 | d->mo->setValue(key.toUtf8(), QVariant()); | - | ||||||
| 115 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||
| 116 | - | |||||||
| 117 | - | |||||||
| 118 | - | |||||||
| 119 | - | |||||||
| 120 | - | |||||||
| 121 | - | |||||||
| 122 | - | |||||||
| 123 | QVariant QQmlPropertyMap::value(const QString &key) const | - | ||||||
| 124 | { | - | ||||||
| 125 | const QQmlPropertyMapPrivate * const d = d_func(); | - | ||||||
| 126 | return executed 44 times by 1 test: d->mo->value(key.toUtf8());return d->mo->value(key.toUtf8());Executed by:
executed 44 times by 1 test: return d->mo->value(key.toUtf8());Executed by:
| 44 | ||||||
| 127 | } | - | ||||||
| 128 | - | |||||||
| 129 | - | |||||||
| 130 | - | |||||||
| 131 | - | |||||||
| 132 | - | |||||||
| 133 | - | |||||||
| 134 | void QQmlPropertyMap::insert(const QString &key, const QVariant &value) | - | ||||||
| 135 | { | - | ||||||
| 136 | QQmlPropertyMapPrivate * const d = d_func(); | - | ||||||
| 137 | - | |||||||
| 138 | if (d->validKeyName(key)
| 6-48 | ||||||
| 139 | d->mo->setValue(key.toUtf8(), value); | - | ||||||
| 140 | } executed 48 times by 1 test: else {end of blockExecuted by:
| 48 | ||||||
| 141 | QMessageLogger(__FILE__, 233, __PRETTY_FUNCTION__).warning() << "Creating property with name" | - | ||||||
| 142 | << key | - | ||||||
| 143 | << "is not permitted, conflicts with internal symbols."; | - | ||||||
| 144 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||
| 145 | } | - | ||||||
| 146 | - | |||||||
| 147 | - | |||||||
| 148 | - | |||||||
| 149 | - | |||||||
| 150 | - | |||||||
| 151 | - | |||||||
| 152 | - | |||||||
| 153 | QStringList QQmlPropertyMap::keys() const | - | ||||||
| 154 | { | - | ||||||
| 155 | const QQmlPropertyMapPrivate * const d = d_func(); | - | ||||||
| 156 | return executed 20 times by 1 test: d->keys;return d->keys;Executed by:
executed 20 times by 1 test: return d->keys;Executed by:
| 20 | ||||||
| 157 | } | - | ||||||
| 158 | - | |||||||
| 159 | - | |||||||
| 160 | - | |||||||
| 161 | - | |||||||
| 162 | - | |||||||
| 163 | - | |||||||
| 164 | int QQmlPropertyMap::count() const | - | ||||||
| 165 | { | - | ||||||
| 166 | const QQmlPropertyMapPrivate * const d = d_func(); | - | ||||||
| 167 | return executed 10 times by 1 test: d->keys.count();return d->keys.count();Executed by:
executed 10 times by 1 test: return d->keys.count();Executed by:
| 10 | ||||||
| 168 | } | - | ||||||
| 169 | - | |||||||
| 170 | - | |||||||
| 171 | - | |||||||
| 172 | - | |||||||
| 173 | - | |||||||
| 174 | - | |||||||
| 175 | int QQmlPropertyMap::size() const | - | ||||||
| 176 | { | - | ||||||
| 177 | const QQmlPropertyMapPrivate * const d = d_func(); | - | ||||||
| 178 | return executed 2 times by 1 test: d->keys.size();return d->keys.size();Executed by:
executed 2 times by 1 test: return d->keys.size();Executed by:
| 2 | ||||||
| 179 | } | - | ||||||
| 180 | - | |||||||
| 181 | - | |||||||
| 182 | - | |||||||
| 183 | - | |||||||
| 184 | - | |||||||
| 185 | - | |||||||
| 186 | - | |||||||
| 187 | bool QQmlPropertyMap::isEmpty() const | - | ||||||
| 188 | { | - | ||||||
| 189 | const QQmlPropertyMapPrivate * const d = d_func(); | - | ||||||
| 190 | return executed 6 times by 1 test: d->keys.isEmpty();return d->keys.isEmpty();Executed by:
executed 6 times by 1 test: return d->keys.isEmpty();Executed by:
| 6 | ||||||
| 191 | } | - | ||||||
| 192 | - | |||||||
| 193 | - | |||||||
| 194 | - | |||||||
| 195 | - | |||||||
| 196 | - | |||||||
| 197 | - | |||||||
| 198 | bool QQmlPropertyMap::contains(const QString &key) const | - | ||||||
| 199 | { | - | ||||||
| 200 | const QQmlPropertyMapPrivate * const d = d_func(); | - | ||||||
| 201 | return executed 16 times by 1 test: d->keys.contains(key);return d->keys.contains(key);Executed by:
executed 16 times by 1 test: return d->keys.contains(key);Executed by:
| 16 | ||||||
| 202 | } | - | ||||||
| 203 | QVariant &QQmlPropertyMap::operator[](const QString &key) | - | ||||||
| 204 | { | - | ||||||
| 205 | - | |||||||
| 206 | QQmlPropertyMapPrivate * const d = d_func(); | - | ||||||
| 207 | QByteArray utf8key = key.toUtf8(); | - | ||||||
| 208 | if (!d->keys.contains(key)
| 2-4 | ||||||
| 209 | insert(key, QVariant()); executed 4 times by 1 test: insert(key, QVariant());Executed by:
| 4 | ||||||
| 210 | - | |||||||
| 211 | return executed 6 times by 1 test: d->mo->valueRef(utf8key);return d->mo->valueRef(utf8key);Executed by:
executed 6 times by 1 test: return d->mo->valueRef(utf8key);Executed by:
| 6 | ||||||
| 212 | } | - | ||||||
| 213 | - | |||||||
| 214 | - | |||||||
| 215 | - | |||||||
| 216 | - | |||||||
| 217 | - | |||||||
| 218 | - | |||||||
| 219 | QVariant QQmlPropertyMap::operator[](const QString &key) const | - | ||||||
| 220 | { | - | ||||||
| 221 | return executed 4 times by 1 test: value(key);return value(key);Executed by:
executed 4 times by 1 test: return value(key);Executed by:
| 4 | ||||||
| 222 | } | - | ||||||
| 223 | QVariant QQmlPropertyMap::updateValue(const QString &key, const QVariant &input) | - | ||||||
| 224 | { | - | ||||||
| 225 | (void)key; | - | ||||||
| 226 | return executed 6 times by 1 test: input;return input;Executed by:
executed 6 times by 1 test: return input;Executed by:
| 6 | ||||||
| 227 | } | - | ||||||
| 228 | - | |||||||
| 229 | - | |||||||
| 230 | QQmlPropertyMap::QQmlPropertyMap(const QMetaObject *staticMetaObject, QObject *parent) | - | ||||||
| 231 | : QObject(*(new QQmlPropertyMapPrivate), parent) | - | ||||||
| 232 | { | - | ||||||
| 233 | QQmlPropertyMapPrivate * const d = d_func(); | - | ||||||
| 234 | d->mo = new QQmlPropertyMapMetaObject(this, d, staticMetaObject); | - | ||||||
| 235 | } executed 68 times by 6 tests: end of blockExecuted by:
| 68 | ||||||
| 236 | - | |||||||
| Switch to Source code | Preprocessed file |