From: Frederik Gladhorn Date: Sun, 26 Aug 2007 11:18:36 +0000 (+0000) Subject: Reading of old types implemented. X-Git-Tag: v3.93.0~55 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=436db6b081a5ea0465a823aa137f21e23a553e1d;p=libqmvoc.git Reading of old types implemented. svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=704821 --- diff --git a/keduvocdocument/keduvockvtmlreader.cpp b/keduvocdocument/keduvockvtmlreader.cpp index 86c3660..e59dea1 100644 --- a/keduvocdocument/keduvockvtmlreader.cpp +++ b/keduvocdocument/keduvockvtmlreader.cpp @@ -152,6 +152,8 @@ bool KEduVocKvtmlReader::readBody(QDomElement &domElementParent) return false; } + // initialize the list of predefined types + m_doc->wordTypes()->createOldWordTypeLists(); currentElement = domElementParent.firstChildElement(KV_TYPE_GRP); if (!currentElement.isNull()) { result = readType(currentElement); @@ -963,7 +965,6 @@ bool KEduVocKvtmlReader::readExpressionChildAttributes( QDomElement &domElementE if (!attribute.isNull()) { QString oldType = attribute.value(); - if (oldType.length() >= 2 && type.left(1) == QM_USER_TYPE) { // they started counting at 1 @@ -988,7 +989,6 @@ bool KEduVocKvtmlReader::readExpressionChildAttributes( QDomElement &domElementE type = m_doc->wordTypes()->mainTypeFromOldFormat(oldType); subType = m_doc->wordTypes()->subTypeFromOldFormat(oldType); - } // not user defined - preset types } @@ -1022,7 +1022,6 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) bool active; QString lang; QString textstr; - QString exprtype; QString q_org; QString q_trans; QString query_id; @@ -1105,7 +1104,6 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) type = m_doc->wordTypes()->mainTypeFromOldFormat(oldType); subType = m_doc->wordTypes()->subTypeFromOldFormat(oldType); - } // not user defined - preset types } @@ -1127,7 +1125,6 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) } while (!currentElement.isNull()) { - type = exprtype; // seems like type can be in the paren element and overwritten in the children here :( //----------- // Attributes @@ -1238,8 +1235,12 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) mc.clear(); } - expr.translation(i).setType(type); - expr.translation(i).setType(subType); + if (!type.isEmpty()) { + expr.translation(i).setType(type); + if (!subType.isEmpty()) { + expr.translation(i).setSubType(subType); + } + } if (!remark.isEmpty() ) expr.translation(i).setComment (remark); diff --git a/keduvocdocument/keduvocwordtype.cpp b/keduvocdocument/keduvocwordtype.cpp index f735fdf..c155717 100644 --- a/keduvocdocument/keduvocwordtype.cpp +++ b/keduvocdocument/keduvocwordtype.cpp @@ -170,17 +170,17 @@ void KEduVocWordType::initOldTypeLists() d->m_oldMainTypeNames.insert("fig", i18n("Figuratively")); d->m_oldSubTypeNames.clear(); - d->m_oldSubTypeNames.insert("ord", i18n("Numeral Ordinal")); - d->m_oldSubTypeNames.insert("crd", i18n("Numeral Cardinal")); - d->m_oldSubTypeNames.insert("def", i18n("Article Definite")); - d->m_oldSubTypeNames.insert("ind", i18n("Article Indefinite")); - d->m_oldSubTypeNames.insert("re", i18n("Verb Regular")); - d->m_oldSubTypeNames.insert("ir", i18n("Verb Irregular")); - d->m_oldSubTypeNames.insert("pos", i18n("Pronoun Possessive")); - d->m_oldSubTypeNames.insert("per", i18n("Pronoun Personal")); - d->m_oldSubTypeNames.insert("m", i18n("Noun Male")); - d->m_oldSubTypeNames.insert("f", i18n("Noun Female")); - d->m_oldSubTypeNames.insert("s", i18n("Noun Neutral")); + d->m_oldSubTypeNames.insert("ord", i18n("Ordinal")); + d->m_oldSubTypeNames.insert("crd", i18n("Cardinal")); + d->m_oldSubTypeNames.insert("def", i18n("Definite")); + d->m_oldSubTypeNames.insert("ind", i18n("Indefinite")); + d->m_oldSubTypeNames.insert("re", i18n("Regular")); + d->m_oldSubTypeNames.insert("ir", i18n("Irregular")); + d->m_oldSubTypeNames.insert("pos", i18n("Possessive")); + d->m_oldSubTypeNames.insert("per", i18n("Personal")); + d->m_oldSubTypeNames.insert("m", i18n("Male")); + d->m_oldSubTypeNames.insert("f", i18n("Female")); + d->m_oldSubTypeNames.insert("s", i18n("Neutral")); } @@ -212,42 +212,47 @@ QString KEduVocWordType::oldType(const QString & mainType, const QString & subTy */ -void KEduVocWordType::createSampleData() +void KEduVocWordType::createOldWordTypeLists() { - //d->m_wordTypeList.clear(); - - // for now let's create some fantasy word types: - + kDebug() << "Creating word type lists for compability with kvtml-1."; + // first the special types which cannot be deleted: addType("Noun", "noun", "This holds the words of type noun. You can rename it but not delete since the article training relies on it!"); - int noun = mainTypeIndex("Noun"); addSubType("Noun", "Male", "noun male", "This holds the words of type noun male. You can rename it but not delete since the article training relies on it!"); addSubType("Noun", "Female", "noun female", "This holds the words of type noun female. You can rename it but not delete since the article training relies on it!"); addSubType("Noun", "Neutral", "noun neutral", "This holds the words of type noun neutral. You can rename it but not delete since the article training relies on it!"); - addType("Verb", "verb", "This holds the words of type verb. You can rename it but not delete since the article training relies on it!"); addSubType("Verb", "Regular", "regular", "This holds the words of type regular verbs. You can rename it but not delete since the article training relies on it!"); addSubType("Verb", "Irregular", "irregular", "This holds the words of type irregular verbs. You can rename it but not delete since the article training relies on it!"); - addType("Adjective", "adjective", "This holds the words of type adjective. You can rename it but not delete since the article training relies on it!"); addType("Adverb", "adverb", "This holds the words of type adverb. You can rename it but not delete since the article training relies on it!"); addType("Question"); addType("Name"); - - addType("Rot"); - addType("Blau"); - addType("Violett"); - addType("Rosa"); - addType("Gelb"); - + addType("Article"); + addSubType("Article", "Definite"); + addSubType("Article", "Indefinite"); + + addType("Pronoun"); + addSubType("Pronoun", "Possessive"); + addSubType("Pronoun", "Personal"); + + addType("Phrase"); + addType("Numeral"); + addSubType("Numeral", "Ordinal"); + addSubType("Numeral", "Cardinal"); + + addType("Conjunction"); + addType("Preposition"); + addType("Informal"); + addType("Figuratively"); } diff --git a/keduvocdocument/keduvocwordtype.h b/keduvocdocument/keduvocwordtype.h index 5b95d8d..00cdc79 100644 --- a/keduvocdocument/keduvocwordtype.h +++ b/keduvocdocument/keduvocwordtype.h @@ -50,10 +50,7 @@ public: /** assignment operator */ KEduVocWordType& operator=(const KEduVocWordType& other); - /** will be gone when we have it inside the lib */ -// void setDocument(KEduVocDocument *doc); - void createSampleData(); - + void createOldWordTypeLists(); /** * Create a new word type in the list of known types