/***************************************************************************
+* this file is from kdeedu project. Filename: keduvockvtmlcompability.cpp
+***************************************************************************/
- C++ Implementation: keduvockvtml1compability_p
+/***************************************************************************
+
+ C++ Implementation: qmvockvtml1compability_p
-----------------------------------------------------------------------
begin : Di Aug 28 2007
copyright : (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
+ (C) 2010, 2012 Reto Zingg <g.d0b3rm4n@gmail.com>
-----------------------------------------------------------------------
* *
***************************************************************************/
-#include "keduvockvtmlcompability.h"
-#include "keduvocwordtype.h"
+#include "qmvockvtmlcompability.h"
+#include "qmvocwordtype.h"
-#include <KLocale>
-#include <KDebug>
+// #include <KLocale>
+// #include <KDebug>
+#include <QDebug>
+#include <QStringList>
-const QString KEduVocKvtmlCompability::KVTML_1_USER_DEFINED = QString( "#" );
-const QString KEduVocKvtmlCompability::KVTML_1_SEPERATOR = QString( ":" );
+const QString QmVocKvtmlCompability::KVTML_1_USER_DEFINED = QString( "#" );
+const QString QmVocKvtmlCompability::KVTML_1_SEPERATOR = QString( ":" );
-KEduVocKvtmlCompability::KEduVocKvtmlCompability()
+QmVocKvtmlCompability::QmVocKvtmlCompability()
{
m_userdefinedTenseCounter = 0;
m_userdefinedTypeCounter = 0;
////////////////// TYPES /////////////////////////////////////////
-void KEduVocKvtmlCompability::initOldTypeLists()
+void QmVocKvtmlCompability::initOldTypeLists()
{
m_oldMainTypeNames.clear();
- m_oldMainTypeNames.insert( "v", i18nc( "@item:inlistbox The grammatical type of a word", "Verb" ) );
- m_oldMainTypeNames.insert( "n", i18nc( "@item:inlistbox The grammatical type of a word", "Noun" ) );
- m_oldMainTypeNames.insert( "nm", i18nc( "@item:inlistbox The grammatical type of a word", "Name" ) );
- m_oldMainTypeNames.insert( "ar", i18nc( "@item:inlistbox The grammatical type of a word", "Article" ) );
- m_oldMainTypeNames.insert( "aj", i18nc( "@item:inlistbox The grammatical type of a word", "Adjective" ) );
- m_oldMainTypeNames.insert( "av", i18nc( "@item:inlistbox The grammatical type of a word", "Adverb" ) );
- m_oldMainTypeNames.insert( "pr", i18nc( "@item:inlistbox The grammatical type of a word", "Pronoun" ) );
- m_oldMainTypeNames.insert( "ph", i18nc( "@item:inlistbox The grammatical type of an entry", "Phrase" ) );
- m_oldMainTypeNames.insert( "num", i18nc( "@item:inlistbox The grammatical type of a word", "Numeral" ) );
- m_oldMainTypeNames.insert( "con", i18nc( "@item:inlistbox The grammatical type of a word", "Conjunction" ) );
- m_oldMainTypeNames.insert( "pre", i18nc( "@item:inlistbox The grammatical type of a word", "Preposition" ) );
- m_oldMainTypeNames.insert( "qu", i18nc( "@item:inlistbox The grammatical type of an entry", "Question" ) );
+ m_oldMainTypeNames.insert( "v", "Verb" );
+ m_oldMainTypeNames.insert( "n", "Noun" );
+ m_oldMainTypeNames.insert( "nm", "Name" );
+ m_oldMainTypeNames.insert( "ar", "Article" );
+ m_oldMainTypeNames.insert( "aj", "Adjective" );
+ m_oldMainTypeNames.insert( "av", "Adverb" );
+ m_oldMainTypeNames.insert( "pr", "Pronoun" );
+ m_oldMainTypeNames.insert( "ph", "Phrase" );
+ m_oldMainTypeNames.insert( "num", "Numeral" );
+ m_oldMainTypeNames.insert( "con", "Conjunction" );
+ m_oldMainTypeNames.insert( "pre", "Preposition" );
+ m_oldMainTypeNames.insert( "qu", "Question" );
m_oldSubTypeNames.clear();
- m_oldSubTypeNames.insert( "ord", i18nc( "@item:inlistbox A subtype of the grammatical word type: Numeral Ordinal (first, second, third, ...)","Ordinal" ) );
- m_oldSubTypeNames.insert( "crd", i18nc( "@item:inlistbox A subtype of the grammatical word type: Numeral Cardinal (one, two, three, ...)","Cardinal" ) );
- m_oldSubTypeNames.insert( "def", i18nc( "@item:inlistbox A subtype of the grammatical word type: Article (the)","Definite" ) );
- m_oldSubTypeNames.insert( "ind", i18nc( "@item:inlistbox A subtype of the grammatical word type: Article (a)","Indefinite" ) );
- m_oldSubTypeNames.insert( "re", i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with regular conjugation","Regular" ) );
- m_oldSubTypeNames.insert( "ir", i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with irregular conjugation","Irregular" ) );
- m_oldSubTypeNames.insert( "pos", i18nc( "@item:inlistbox A subtype of the grammatical word type: Pronoun (my, your, his, her...)", "Possessive" ) );
- m_oldSubTypeNames.insert( "per", i18nc( "@item:inlistbox A subtype of the grammatical word type: Pronoun (I, you, he...)", "Personal" ) );
- m_oldSubTypeNames.insert( "m", i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Male" ) );
- m_oldSubTypeNames.insert( "f", i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Female" ) );
- m_oldSubTypeNames.insert( "s", i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Neutral" ) );
+ m_oldSubTypeNames.insert( "ord", "Ordinal" );
+ m_oldSubTypeNames.insert( "crd", "Cardinal" );
+ m_oldSubTypeNames.insert( "def", "Definite" );
+ m_oldSubTypeNames.insert( "ind", "Indefinite" );
+ m_oldSubTypeNames.insert( "re", "Regular" );
+ m_oldSubTypeNames.insert( "ir", "Irregular" );
+ m_oldSubTypeNames.insert( "pos", "Possessive" );
+ m_oldSubTypeNames.insert( "per", "Personal" );
+ m_oldSubTypeNames.insert( "m", "Male" );
+ m_oldSubTypeNames.insert( "f", "Female" );
+ m_oldSubTypeNames.insert( "s", "Neutral" );
}
-KEduVocWordType* KEduVocKvtmlCompability::typeFromOldFormat(KEduVocWordType* parent, const QString & typeSubtypeString ) const
+QmVocWordType* QmVocKvtmlCompability::typeFromOldFormat(QmVocWordType* parent, const QString & typeSubtypeString ) const
{
// check if it's user defined
if ( typeSubtypeString.length() >= 2 && typeSubtypeString.left( 1 ) == QM_USER_TYPE ) {
// they started counting at 1, we need to know which index we are dealing with:
int selfDefinedTypeIndex = typeSubtypeString.right( typeSubtypeString.count()-1 ).toInt() -1;
- return static_cast<KEduVocWordType*>(parent->childContainer(selfDefinedTypeIndex));
+ return static_cast<QmVocWordType*>(parent->childContainer(selfDefinedTypeIndex));
}
// assume the parent is set up to contain the old types correctly
QString typeName = m_oldMainTypeNames.value( mainType );
if ( typeName.isEmpty() ) {
- kDebug() << "Unknown old maintype: " << typeSubtypeString;
+ qDebug() << "Unknown old maintype: " << typeSubtypeString;
return 0;
}
QString subTypeName = m_oldSubTypeNames.value( subType );
- foreach (KEduVocContainer* wordType, parent->childContainers()) {
+ foreach (QmVocContainer* wordType, parent->childContainers()) {
if (wordType->name() == typeName) {
if (subType.isEmpty()) {
- return static_cast<KEduVocWordType*>(wordType);
+ return static_cast<QmVocWordType*>(wordType);
} else {
- foreach (KEduVocContainer* subWordType, wordType->childContainers()) {
+ foreach (QmVocContainer* subWordType, wordType->childContainers()) {
if (subWordType->name() == subTypeName) {
- return static_cast<KEduVocWordType*>(subWordType);
+ return static_cast<QmVocWordType*>(subWordType);
}
}
}
-void KEduVocKvtmlCompability::initOldTenses()
+void QmVocKvtmlCompability::initOldTenses()
{
- m_oldTenses["PrSi"] = i18n( "Simple Present" );
- m_oldTenses["PrPr"] = i18n( "Present Progressive" );
- m_oldTenses["PrPe"] = i18n( "Present Perfect" );
- m_oldTenses["PaSi"] = i18n( "Simple Past" );
- m_oldTenses["PaPr"] = i18n( "Past Progressive" );
- m_oldTenses["PaPa"] = i18n( "Past Participle" );
- m_oldTenses["FuSi"] = i18n( "Future" );
+ m_oldTenses["PrSi"] = "Simple Present" ;
+ m_oldTenses["PrPr"] = "Present Progressive" ;
+ m_oldTenses["PrPe"] = "Present Perfect" ;
+ m_oldTenses["PaSi"] = "Simple Past" ;
+ m_oldTenses["PaPr"] = "Past Progressive" ;
+ m_oldTenses["PaPa"] = "Past Participle" ;
+ m_oldTenses["FuSi"] = "Future" ;
}
-void KEduVocKvtmlCompability::addUserdefinedTense(const QString & tense)
+void QmVocKvtmlCompability::addUserdefinedTense(const QString & tense)
{
m_userdefinedTenseCounter++;
m_oldTenses[KVTML_1_USER_DEFINED + QString::number( m_userdefinedTenseCounter )] = tense;
m_tenses.insert(tense);
- kDebug() << " Add tense: " << KVTML_1_USER_DEFINED + QString::number( m_userdefinedTenseCounter ) << " - " << tense;
+ qDebug() << " Add tense: " << KVTML_1_USER_DEFINED + QString::number( m_userdefinedTenseCounter ) << " - " << tense;
}
-QString KEduVocKvtmlCompability::tenseFromKvtml1(const QString & oldTense)
+QString QmVocKvtmlCompability::tenseFromKvtml1(const QString & oldTense)
{
// in case the document got chaged, at least make up something as tense
if (!m_oldTenses.keys().contains(oldTense)) {
m_oldTenses[oldTense] = oldTense;
- kDebug() << "Warning, tense " << oldTense << " not found in document!";
+ qDebug() << "Warning, tense " << oldTense << " not found in document!";
}
m_tenses.insert(m_oldTenses.value(oldTense));
return m_oldTenses.value(oldTense);
}
-QStringList KEduVocKvtmlCompability::documentTenses() const
+QStringList QmVocKvtmlCompability::documentTenses() const
{
return m_tenses.values();
}
-QString KEduVocKvtmlCompability::oldTense(const QString & tense)
+QString QmVocKvtmlCompability::oldTense(const QString & tense)
{
///@todo writing of the user defined tenses is probably messed up
if ( !m_oldTenses.values().contains(tense) ) {
return m_oldTenses.key(tense);
}
-void KEduVocKvtmlCompability::setupWordTypes(KEduVocWordType * parent)
+void QmVocKvtmlCompability::setupWordTypes(QmVocWordType * parent)
{
QStringList wordTypeNames;
wordTypeNames
- << i18nc( "The grammatical type of a word", "Verb" ) // 0
- << i18nc( "The grammatical type of a word", "Noun" ) // 1
- << i18nc( "The grammatical type of a word", "Name" )
- << i18nc( "The grammatical type of a word", "Article" ) // 3
- << i18nc( "The grammatical type of a word", "Adjective" ) // 4
- << i18nc( "The grammatical type of a word", "Adverb" ) // 5
- << i18nc( "The grammatical type of a word", "Pronoun" ) // 6
- << i18nc( "The grammatical type of an entry", "Phrase" )
- << i18nc( "The grammatical type of a word", "Numeral" ) // 8
- << i18nc( "The grammatical type of a word", "Conjunction" )
- << i18nc( "The grammatical type of a word", "Preposition" )
- << i18nc( "The grammatical type of an entry", "Question" );
+ << "Verb" // 0
+ << "Noun" // 1
+ << "Name"
+ << "Article" // 3
+ << "Adjective" // 4
+ << "Adverb" // 5
+ << "Pronoun" // 6
+ << "Phrase"
+ << "Numeral" // 8
+ << "Conjunction"
+ << "Preposition"
+ << "Question" ;
foreach (const QString &typeName, wordTypeNames) {
- KEduVocWordType* wordType = new KEduVocWordType(typeName, parent);
+ QmVocWordType* wordType = new QmVocWordType(typeName, parent);
parent->appendChildContainer(wordType);
m_userdefinedTypeCounter++;
}
- static_cast<KEduVocWordType*>(parent->childContainer(4))->setWordType(KEduVocWordFlag::Adjective);
- static_cast<KEduVocWordType*>(parent->childContainer(5))->setWordType(KEduVocWordFlag::Adverb);
+ static_cast<QmVocWordType*>(parent->childContainer(4))->setWordType(QmVocWordFlag::Adjective);
+ static_cast<QmVocWordType*>(parent->childContainer(5))->setWordType(QmVocWordFlag::Adverb);
- KEduVocWordType* numeral = static_cast<KEduVocWordType*>(parent->childContainer(8));
- KEduVocWordType* wordType = new KEduVocWordType(
- i18nc( "@item:inlistbox A subtype of the grammatical word type: Numeral Ordinal (first, second, third, ...)","Ordinal" ), numeral);
- wordType->setWordType(KEduVocWordFlag::Adjective);
+ QmVocWordType* numeral = static_cast<QmVocWordType*>(parent->childContainer(8));
+ QmVocWordType* wordType = new QmVocWordType( "Ordinal", numeral);
+ wordType->setWordType(QmVocWordFlag::Adjective);
numeral->appendChildContainer(wordType);
- wordType = new KEduVocWordType(
- i18nc( "@item:inlistbox A subtype of the grammatical word type: Numeral Cardinal (one, two, three, ...)","Cardinal" ), numeral);
+ wordType = new QmVocWordType( "Cardinal" , numeral);
- wordType->setWordType(KEduVocWordFlag::Adjective);
+ wordType->setWordType(QmVocWordFlag::Adjective);
numeral->appendChildContainer(wordType);
- KEduVocWordType* article = static_cast<KEduVocWordType*>(parent->childContainer(3));
- wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Article (the)","Definite" ), article);
- wordType->setWordType(KEduVocWordFlag::Article | KEduVocWordFlag::Definite);
+ QmVocWordType* article = static_cast<QmVocWordType*>(parent->childContainer(3));
+ wordType = new QmVocWordType( "Definite" , article);
+ wordType->setWordType(QmVocWordFlag::Article | QmVocWordFlag::Definite);
article->appendChildContainer(wordType);
- wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Article (a)","Indefinite" ), article);
- wordType->setWordType(KEduVocWordFlag::Article | KEduVocWordFlag::Indefinite);
+ wordType = new QmVocWordType( "Indefinite" , article);
+ wordType->setWordType(QmVocWordFlag::Article | QmVocWordFlag::Indefinite);
article->appendChildContainer(wordType);
- KEduVocWordType* verb = static_cast<KEduVocWordType*>(parent->childContainer(0));
- verb->setWordType(KEduVocWordFlag::Verb);
- wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with regular conjugation","Regular" ), verb);
- wordType->setWordType(KEduVocWordFlag::Verb | KEduVocWordFlag::Regular);
+ QmVocWordType* verb = static_cast<QmVocWordType*>(parent->childContainer(0));
+ verb->setWordType(QmVocWordFlag::Verb);
+ wordType = new QmVocWordType( "Regular" , verb);
+ wordType->setWordType(QmVocWordFlag::Verb | QmVocWordFlag::Regular);
verb->appendChildContainer(wordType);
- wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with irregular conjugation","Irregular" ), verb);
+ wordType = new QmVocWordType( "Irregular" , verb);
verb->appendChildContainer(wordType);
- wordType->setWordType(KEduVocWordFlag::Verb | KEduVocWordFlag::Irregular);
+ wordType->setWordType(QmVocWordFlag::Verb | QmVocWordFlag::Irregular);
- KEduVocWordType* noun = static_cast<KEduVocWordType*>(parent->childContainer(1));
- noun->setWordType(KEduVocWordFlag::Noun);
- wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Male" ), noun);
+ QmVocWordType* noun = static_cast<QmVocWordType*>(parent->childContainer(1));
+ noun->setWordType(QmVocWordFlag::Noun);
+ wordType = new QmVocWordType( "Male" , noun);
noun->appendChildContainer(wordType);
- wordType->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Masculine);
- wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Female" ), noun);
+ wordType->setWordType(QmVocWordFlag::Noun | QmVocWordFlag::Masculine);
+ wordType = new QmVocWordType( "Female" , noun);
noun->appendChildContainer(wordType);
- wordType->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Feminine);
- wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Neutral" ), noun);
+ wordType->setWordType(QmVocWordFlag::Noun | QmVocWordFlag::Feminine);
+ wordType = new QmVocWordType( "Neutral" , noun);
noun->appendChildContainer(wordType);
- wordType->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Neuter);
+ wordType->setWordType(QmVocWordFlag::Noun | QmVocWordFlag::Neuter);
- KEduVocWordType* pronoun = static_cast<KEduVocWordType*>(parent->childContainer(6));
- wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Pronoun (my, your, his, her...)", "Possessive" ), pronoun);
- wordType->setWordType(KEduVocWordFlag::Pronoun);
+ QmVocWordType* pronoun = static_cast<QmVocWordType*>(parent->childContainer(6));
+ wordType = new QmVocWordType( "Possessive" , pronoun);
+ wordType->setWordType(QmVocWordFlag::Pronoun);
pronoun->appendChildContainer(wordType);
- wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Pronoun (I, you, he...)", "Personal" ), pronoun);
- wordType->setWordType(KEduVocWordFlag::Pronoun);
+ wordType = new QmVocWordType( "Personal" , pronoun);
+ wordType->setWordType(QmVocWordFlag::Pronoun);
pronoun->appendChildContainer(wordType);
}