diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-05 04:00:03 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-05 04:00:03 (GMT) |
commit | f062be7569804461dad94d5b80dc0b87298fd5eb (patch) | |
tree | 9268f72004a03f46957ee03a6cb111a1b1fb8c87 | |
parent | 6089208e78bdcb0091c0ba0bc2fbd2a4fc0806de (diff) | |
download | Qt-f062be7569804461dad94d5b80dc0b87298fd5eb.zip Qt-f062be7569804461dad94d5b80dc0b87298fd5eb.tar.gz Qt-f062be7569804461dad94d5b80dc0b87298fd5eb.tar.bz2 |
Remove XML custom parser support
-rw-r--r-- | demos/declarative/phonebrowser/dummydata/PhonesModel.qml | 2 | ||||
-rw-r--r-- | doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml | 2 | ||||
-rw-r--r-- | examples/declarative/contacts/dummydata/contactModel.qml | 2 | ||||
-rw-r--r-- | examples/declarative/easing/easing.qml | 2 | ||||
-rw-r--r-- | examples/declarative/listview/dummydata/MyPetsModel.qml | 2 | ||||
-rw-r--r-- | examples/declarative/listview/dummydata/Recipies.qml | 2 | ||||
-rw-r--r-- | examples/declarative/velocity/velocity.qml | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 26 | ||||
-rw-r--r-- | src/declarative/qml/qmlcustomparser_p.h | 17 | ||||
-rw-r--r-- | src/declarative/qml/qmlinstruction.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlinstruction_p.h | 5 | ||||
-rw-r--r-- | src/declarative/qml/qmlvme.cpp | 21 | ||||
-rw-r--r-- | src/declarative/util/qmllistmodel.cpp | 180 |
13 files changed, 17 insertions, 249 deletions
diff --git a/demos/declarative/phonebrowser/dummydata/PhonesModel.qml b/demos/declarative/phonebrowser/dummydata/PhonesModel.qml index eb68fdb..8d9ed97 100644 --- a/demos/declarative/phonebrowser/dummydata/PhonesModel.qml +++ b/demos/declarative/phonebrowser/dummydata/PhonesModel.qml @@ -1,4 +1,4 @@ -ListModel2 { +ListModel { id: "PhonesModel" ListElement { diff --git a/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml b/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml index 5b973d7..44cdaf0 100644 --- a/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml +++ b/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml @@ -1,4 +1,4 @@ -ListModel2 { +ListModel { id: MenuModel ListElement { name: "Bill Jones" diff --git a/examples/declarative/contacts/dummydata/contactModel.qml b/examples/declarative/contacts/dummydata/contactModel.qml index 48b2fd9..53f6b7b 100644 --- a/examples/declarative/contacts/dummydata/contactModel.qml +++ b/examples/declarative/contacts/dummydata/contactModel.qml @@ -1,4 +1,4 @@ -ListModel2 { +ListModel { ListElement { firstName: "Aaron" lastName: "Kennedy" diff --git a/examples/declarative/easing/easing.qml b/examples/declarative/easing/easing.qml index 32c1b9b..af675d1 100644 --- a/examples/declarative/easing/easing.qml +++ b/examples/declarative/easing/easing.qml @@ -4,7 +4,7 @@ Rect { height: Layout.height color: "white" - ListModel2 { + ListModel { id: EasingTypes ListElement { type: "easeLinear" } ListElement { type: "easeInQuad" } diff --git a/examples/declarative/listview/dummydata/MyPetsModel.qml b/examples/declarative/listview/dummydata/MyPetsModel.qml index 1c96b7f..4d76ff4 100644 --- a/examples/declarative/listview/dummydata/MyPetsModel.qml +++ b/examples/declarative/listview/dummydata/MyPetsModel.qml @@ -1,6 +1,6 @@ // ListModel allows free form list models to be defined and populated. // Be sure to name the file the same as the id. -ListModel2 { +ListModel { id: MyListElementsModel ListElement { name: "Polly" diff --git a/examples/declarative/listview/dummydata/Recipies.qml b/examples/declarative/listview/dummydata/Recipies.qml index 8f464da..3f2ab48 100644 --- a/examples/declarative/listview/dummydata/Recipies.qml +++ b/examples/declarative/listview/dummydata/Recipies.qml @@ -1,4 +1,4 @@ -ListModel2 { +ListModel { id: Recipies ListElement { title: "Pancakes" diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml index ff95527..786f364 100644 --- a/examples/declarative/velocity/velocity.qml +++ b/examples/declarative/velocity/velocity.qml @@ -2,7 +2,7 @@ Rect { color: "lightSteelBlue" width: 800 height: 600 - ListModel2 { + ListModel { id: List ListElement { name: "Sunday" diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 37d7fa1..ec5903e 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -569,25 +569,13 @@ bool QmlCompiler::compileObject(Object *obj, int ctxt) } int createInstrIdx = output->bytecode.count(); - if (obj->type != -1 && output->types.at(obj->type).parser) { - QByteArray data = obj->custom; - int ref = output->indexForByteArray(data); - - QmlInstruction create; - create.type = QmlInstruction::CreateCustomObject; - create.line = obj->line; - create.createCustom.type = obj->type; - create.createCustom.data = ref; - output->bytecode << create; - } else { - // Create the object - QmlInstruction create; - create.type = QmlInstruction::CreateObject; - create.line = obj->line; - create.create.data = -1; - create.create.type = obj->type; - output->bytecode << create; - } + // Create the object + QmlInstruction create; + create.type = QmlInstruction::CreateObject; + create.line = obj->line; + create.create.data = -1; + create.create.type = obj->type; + output->bytecode << create; COMPILE_CHECK(compileDynamicPropertiesAndSignals(obj)); diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index 0e6a619..e4e6089 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -98,26 +98,9 @@ class Q_DECLARATIVE_EXPORT QmlCustomParser public: virtual ~QmlCustomParser() {} - virtual QByteArray compile(QXmlStreamReader&, bool *ok)=0; virtual QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok); - virtual QVariant create(const QByteArray &)=0; virtual void setCustomData(QObject *, const QByteArray &); - - struct Register { - Register(const char *name, QmlCustomParser *parser) { - qmlRegisterCustomParser(name, parser); - } - }; - template<typename T> - struct Define { - static Register instance; - }; }; -#define QML_DEFINE_CUSTOM_PARSER(name, parserClass) \ - template<> QmlCustomParser::Register QmlCustomParser::Define<parserClass>::instance(# name, new parserClass); -#define QML_DEFINE_CUSTOM_PARSER_NS(namespacestring, name, parserClass) \ - template<> QmlCustomParser::Register QmlCustomParser::Define<parserClass>::instance(namespacestring "/" # name, new parserClass); - #define QML_DEFINE_CUSTOM_TYPE(TYPE, NAME, CUSTOMTYPE) \ template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterCustomType<TYPE>(#NAME, #TYPE, new CUSTOMTYPE)); diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index 82924c8..52677c2 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -58,9 +58,6 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx) case QmlInstruction::CreateObject: qWarning() << idx << "\t" << line << "\t" << "CREATE\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className; break; - case QmlInstruction::CreateCustomObject: - qWarning() << idx << "\t" << line << "\t" << "CREATE_CUSTOM\t\t" << instr->createCustom.type << "\t" << instr->createCustom.data << "\t\t" << types.at(instr->create.type).className; - break; case QmlInstruction::SetId: qWarning() << idx << "\t" << line << "\t" << "SETID\t\t\t" << instr->setId.value << "\t" << instr->setId.save << "\t\t" << primitives.at(instr->setId.value); break; diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index 922fc61..462f9e4 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -63,7 +63,6 @@ public: // top of the stack. Init, /* init */ CreateObject, /* create */ - CreateCustomObject, /* createCustom */ SetId, /* setId */ SetDefault, CreateComponent, /* createComponent */ @@ -180,10 +179,6 @@ public: int data; } storeMeta; struct { - int type; - int data; - } createCustom; - struct { int value; int save; } setId; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index a3bfd62..ad3d1d5 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -277,27 +277,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in } break; - case QmlInstruction::CreateCustomObject: - { -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxCompilerTimer<QFxCompiler::InstrCreateCustomObject> cc; -#endif - QVariant v = - types.at(instr.createCustom.type).parser->create(datas.at(instr.createCustom.data)); - // XXX - QObject *o = QmlMetaType::toQObject(v); - if (!o) - VME_EXCEPTION("Unable to create" << types.at(instr.create.type).className); - QmlEngine::setContextForObject(o, QmlContext::activeContext()); - - if (!stack.isEmpty()) { - QObject *parent = stack.top(); - o->setParent(parent); - } - stack.push(o); - } - break; - case QmlInstruction::SetId: { #ifdef Q_ENABLE_PERFORMANCE_LOG diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 4837180..6ad0cb9 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -190,8 +190,6 @@ ModelObject::ModelObject(ModelNode *node) { } -QML_DECLARE_TYPE(ListModel); -QML_DEFINE_TYPE(ListModel,ListModel); ListModel::ListModel(QObject *parent) : QListModelInterface(parent), _rolesOk(false), _root(0) { @@ -304,14 +302,10 @@ int ListModel::count() const class ListModelParser : public QmlCustomParser { public: - virtual QByteArray compile(QXmlStreamReader& reader, bool *); QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok); - virtual QVariant create(const QByteArray &); - bool compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data); void setCustomData(QObject *, const QByteArray &); }; -QML_DEFINE_CUSTOM_PARSER(ListModel, ListModelParser); bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data) { @@ -462,13 +456,10 @@ void ListModelParser::setCustomData(QObject *obj, const QByteArray &d) } } -class ListModel2 : public ListModel -{ -Q_OBJECT -}; -QML_DECLARE_TYPE(ListModel2); -QML_DEFINE_CUSTOM_TYPE(ListModel2, ListModel2, ListModelParser); +QML_DECLARE_TYPE(ListModel); +QML_DEFINE_CUSTOM_TYPE(ListModel, ListModel, ListModelParser); +// ### FIXME class ListElement : public QObject { Q_OBJECT @@ -512,170 +503,5 @@ ModelNode::~ModelNode() if (modelCache) { delete modelCache; modelCache = 0; } } -QByteArray ListModelParser::compile(QXmlStreamReader& reader, bool *ok) -{ - *ok = true; - - QByteArray data; - QList<ListInstruction> instr; - int depth=0; - - while(!reader.atEnd() && depth >= 0) { - switch(reader.readNext()) { - case QXmlStreamReader::StartElement: - { - QStringRef name = reader.name(); - bool isType = name.at(0).isUpper(); - - if (isType) { - ListInstruction li; - li.type = ListInstruction::Push; - li.dataIdx = -1; - instr << li; - - for (int i = 0; i < reader.attributes().count(); ++i) { - const QXmlStreamAttribute &attr = reader.attributes().at(i); - QStringRef attrName = attr.name(); - QStringRef attrValue = attr.value(); - - ListInstruction li; - int ref = data.count(); - data.append(attrName.toString().toLatin1()); - data.append('\0'); - li.type = ListInstruction::Set; - li.dataIdx = ref; - instr << li; - - ref = data.count(); - data.append(attrValue.toString().toLatin1()); - data.append('\0'); - li.type = ListInstruction::Value; - li.dataIdx = ref; - instr << li; - - li.type = ListInstruction::Pop; - li.dataIdx = -1; - instr << li; - } - } else { - ListInstruction li; - int ref = data.count(); - data.append(name.toString().toLatin1()); - data.append('\0'); - li.type = ListInstruction::Set; - li.dataIdx = ref; - instr << li; - } - } - ++depth; - break; - case QXmlStreamReader::EndElement: - { - ListInstruction li; - li.type = ListInstruction::Pop; - li.dataIdx = -1; - instr << li; - --depth; - } - break; - case QXmlStreamReader::Characters: - if (!reader.isWhitespace()) { - int ref = data.count(); - QByteArray d = reader.text().toString().toLatin1(); - d.append('\0'); - data.append(d); - - ListInstruction li; - li.type = ListInstruction::Value; - li.dataIdx = ref; - instr << li; - } - break; - - case QXmlStreamReader::Invalid: - case QXmlStreamReader::NoToken: - case QXmlStreamReader::StartDocument: - case QXmlStreamReader::EndDocument: - case QXmlStreamReader::Comment: - case QXmlStreamReader::DTD: - case QXmlStreamReader::EntityReference: - case QXmlStreamReader::ProcessingInstruction: - break; - } - } - - if (reader.hasError()) - *ok = true; - - if (!*ok) - return QByteArray(); - - int size = sizeof(ListModelData) + - instr.count() * sizeof(ListInstruction) + - data.count(); - - QByteArray rv; - rv.resize(size); - - ListModelData *lmd = (ListModelData *)rv.data(); - lmd->dataOffset = sizeof(ListModelData) + - instr.count() * sizeof(ListInstruction); - lmd->instrCount = instr.count(); - for (int ii = 0; ii < instr.count(); ++ii) - lmd->instructions()[ii] = instr.at(ii); - ::memcpy(rv.data() + lmd->dataOffset, data.constData(), data.count()); - - return rv; -} - -QVariant ListModelParser::create(const QByteArray &d) -{ - ListModel *rv = new ListModel; - ModelNode *root = new ModelNode; - rv->_root = root; - QStack<ModelNode *> nodes; - nodes << root; - - const ListModelData *lmd = (const ListModelData *)d.constData(); - const char *data = ((const char *)lmd) + lmd->dataOffset; - - for (int ii = 0; ii < lmd->instrCount; ++ii) { - const ListInstruction &instr = lmd->instructions()[ii]; - - switch(instr.type) { - case ListInstruction::Push: - { - ModelNode *n = nodes.top(); - ModelNode *n2 = new ModelNode; - n->values << qVariantFromValue(n2); - nodes.push(n2); - } - break; - - case ListInstruction::Pop: - nodes.pop(); - break; - - case ListInstruction::Value: - { - ModelNode *n = nodes.top(); - n->values.append(QByteArray(data + instr.dataIdx)); - } - break; - - case ListInstruction::Set: - { - ModelNode *n = nodes.top(); - ModelNode *n2 = new ModelNode; - n->properties.insert(QLatin1String(data + instr.dataIdx), n2); - nodes.push(n2); - } - break; - } - } - - return QVariant::fromValue(rv); -} - QT_END_NAMESPACE #include "qmllistmodel.moc" |