diff options
author | Jake Petroules <jake.petroules@petroules.com> | 2014-02-26 21:13:52 -0500 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-02-28 12:36:33 +0100 |
commit | 5c01bb69986801bd717639a2612bf48c5701ebb3 (patch) | |
tree | 400beb7d8f48fe77049be1372c1edeaac94f7ba6 /src | |
parent | 4de0b752405ac287e42f05b7f9bc3f99432a83fa (diff) |
Introduce PropertyList functions isEmpty and clear.
These functions test whether the PropertyList object has any data
loaded, and clears any existing data from the object, respectively.
Change-Id: I9dfa0e7629dccd3090fc0d5de33481c8e7caf424
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/corelib/jsextensions/propertylist.h | 2 | ||||
-rw-r--r-- | src/lib/corelib/jsextensions/propertylist.mm | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/corelib/jsextensions/propertylist.h b/src/lib/corelib/jsextensions/propertylist.h index 1b211af99..69a8696dd 100644 --- a/src/lib/corelib/jsextensions/propertylist.h +++ b/src/lib/corelib/jsextensions/propertylist.h @@ -50,6 +50,8 @@ public: static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine); PropertyList(QScriptContext *context); ~PropertyList(); + Q_INVOKABLE bool isEmpty() const; + Q_INVOKABLE void clear(); Q_INVOKABLE void readFromString(const QString &input); Q_INVOKABLE void readFromFile(const QString &filePath); Q_INVOKABLE void writeToFile(const QString &filePath, const QString &plistFormat); diff --git a/src/lib/corelib/jsextensions/propertylist.mm b/src/lib/corelib/jsextensions/propertylist.mm index ac0323e2c..4c35a3911 100644 --- a/src/lib/corelib/jsextensions/propertylist.mm +++ b/src/lib/corelib/jsextensions/propertylist.mm @@ -109,6 +109,22 @@ PropertyList::PropertyList(QScriptContext *context) Q_ASSERT(thisObject().engine() == engine()); } +bool PropertyList::isEmpty() const +{ + Q_ASSERT(thisObject().engine() == engine()); + PropertyList *p = qscriptvalue_cast<PropertyList*>(thisObject()); + return !p->d->propertyListObject; +} + +void PropertyList::clear() +{ + Q_ASSERT(thisObject().engine() == engine()); + PropertyList *p = qscriptvalue_cast<PropertyList*>(thisObject()); + [p->d->propertyListObject release]; + p->d->propertyListObject = nil; + p->d->propertyListFormat = 0; +} + void PropertyList::readFromString(const QString &input) { Q_ASSERT(thisObject().engine() == engine()); |