diff options
Diffstat (limited to 'kvoctrain/kvoctrain/kvt-core/QueryManager.cpp')
-rw-r--r-- | kvoctrain/kvoctrain/kvt-core/QueryManager.cpp | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/kvoctrain/kvoctrain/kvt-core/QueryManager.cpp b/kvoctrain/kvoctrain/kvt-core/QueryManager.cpp index 7eb65e1a..f08246a5 100644 --- a/kvoctrain/kvoctrain/kvt-core/QueryManager.cpp +++ b/kvoctrain/kvoctrain/kvt-core/QueryManager.cpp @@ -50,40 +50,40 @@ struct t_type_rel static t_type_rel InternalTypeRelations [] = { - { QM_ADJ, I18N_NOOP("Adjective") }, + { TQM_ADJ, I18N_NOOP("Adjective") }, - { QM_ADV, I18N_NOOP("Adverb") }, + { TQM_ADV, I18N_NOOP("Adverb") }, - { QM_ART, I18N_NOOP("Article") }, - { QM_ART QM_TYPE_DIV QM_ART_DEF, I18N_NOOP("Article Definite") }, - { QM_ART QM_TYPE_DIV QM_ART_IND, I18N_NOOP("Article Indefinite") }, + { TQM_ART, I18N_NOOP("Article") }, + { TQM_ART TQM_TYPE_DIV TQM_ART_DEF, I18N_NOOP("Article Definite") }, + { TQM_ART TQM_TYPE_DIV TQM_ART_IND, I18N_NOOP("Article Indefinite") }, - { QM_CON, I18N_NOOP("Conjunction") }, + { TQM_CON, I18N_NOOP("Conjunction") }, - { QM_NAME, I18N_NOOP("Name") }, // old type "3" + { TQM_NAME, I18N_NOOP("Name") }, // old type "3" - { QM_NOUN, I18N_NOOP("Noun") }, // old type "2" - { QM_NOUN QM_TYPE_DIV QM_NOUN_M, I18N_NOOP("Noun Male") }, - { QM_NOUN QM_TYPE_DIV QM_NOUN_F, I18N_NOOP("Noun Female") }, - { QM_NOUN QM_TYPE_DIV QM_NOUN_S, I18N_NOOP("Noun Neutral") }, + { TQM_NOUN, I18N_NOOP("Noun") }, // old type "2" + { TQM_NOUN TQM_TYPE_DIV TQM_NOUN_M, I18N_NOOP("Noun Male") }, + { TQM_NOUN TQM_TYPE_DIV TQM_NOUN_F, I18N_NOOP("Noun Female") }, + { TQM_NOUN TQM_TYPE_DIV TQM_NOUN_S, I18N_NOOP("Noun Neutral") }, - { QM_NUM, I18N_NOOP("Numeral") }, - { QM_NUM QM_TYPE_DIV QM_NUM_ORD, I18N_NOOP("Numeral Ordinal") }, - { QM_NUM QM_TYPE_DIV QM_NUM_CARD, I18N_NOOP("Numeral Cardinal") }, + { TQM_NUM, I18N_NOOP("Numeral") }, + { TQM_NUM TQM_TYPE_DIV TQM_NUM_ORD, I18N_NOOP("Numeral Ordinal") }, + { TQM_NUM TQM_TYPE_DIV TQM_NUM_CARD, I18N_NOOP("Numeral Cardinal") }, - { QM_PHRASE, I18N_NOOP("Phrase") }, + { TQM_PHRASE, I18N_NOOP("Phrase") }, - { QM_PREP, I18N_NOOP("Preposition") }, + { TQM_PREP, I18N_NOOP("Preposition") }, - { QM_PRON, I18N_NOOP("Pronoun") }, - { QM_PRON QM_TYPE_DIV QM_PRON_POS, I18N_NOOP("Pronoun Possessive") }, - { QM_PRON QM_TYPE_DIV QM_PRON_PER, I18N_NOOP("Pronoun Personal") }, + { TQM_PRON, I18N_NOOP("Pronoun") }, + { TQM_PRON TQM_TYPE_DIV TQM_PRON_POS, I18N_NOOP("Pronoun Possessive") }, + { TQM_PRON TQM_TYPE_DIV TQM_PRON_PER, I18N_NOOP("Pronoun Personal") }, - { QM_QUEST, I18N_NOOP("Question") }, + { TQM_QUEST, I18N_NOOP("Question") }, - { QM_VERB, I18N_NOOP("Verb") }, // old type "1" - { QM_VERB QM_TYPE_DIV QM_VERB_IRR, I18N_NOOP("Verb Irregular") }, - { QM_VERB QM_TYPE_DIV QM_VERB_REG, I18N_NOOP("Verb Regular") }, + { TQM_VERB, I18N_NOOP("Verb") }, // old type "1" + { TQM_VERB TQM_TYPE_DIV TQM_VERB_IRR, I18N_NOOP("Verb Irregular") }, + { TQM_VERB TQM_TYPE_DIV TQM_VERB_REG, I18N_NOOP("Verb Regular") }, { 0, 0 } // the end }; @@ -93,19 +93,19 @@ TQString QueryManager::getSubType (const TQString & type) { int i; TQString t = type; - if ((i = t.find(QM_TYPE_DIV)) >= 0) { + if ((i = t.tqfind(TQM_TYPE_DIV)) >= 0) { t.remove(0, i+1); return t; } else - return TQString::null; + return TQString(); } TQString QueryManager::getMainType (const TQString & type) { int i; - if ((i = type.find(QM_TYPE_DIV)) >= 0) + if ((i = type.tqfind(TQM_TYPE_DIV)) >= 0) return type.left(i); else return type; @@ -238,7 +238,7 @@ QuerySelection QueryManager::select(kvoctrainDoc *doc, int act_lesson, int idx, bool QueryManager::validate(kvoctrainExpr *expr, int act_lesson, int idx, TQString query_type) { TQString qtype; - int pos = query_type.find (QM_TYPE_DIV); + int pos = query_type.tqfind (TQM_TYPE_DIV); if (pos >= 0) qtype = query_type.left (pos); else @@ -246,22 +246,22 @@ bool QueryManager::validate(kvoctrainExpr *expr, int act_lesson, int idx, TQStri TQString expr_type = expr->getType(idx); bool type_ok = false; - if (qtype == QM_NOUN) { - type_ok = expr_type == QM_NOUN QM_TYPE_DIV QM_NOUN_S - || expr_type == QM_NOUN QM_TYPE_DIV QM_NOUN_M - || expr_type == QM_NOUN QM_TYPE_DIV QM_NOUN_F; + if (qtype == TQM_NOUN) { + type_ok = expr_type == TQM_NOUN TQM_TYPE_DIV TQM_NOUN_S + || expr_type == TQM_NOUN TQM_TYPE_DIV TQM_NOUN_M + || expr_type == TQM_NOUN TQM_TYPE_DIV TQM_NOUN_F; } - else if (qtype == QM_VERB) { - type_ok = ( expr_type == QM_VERB - || expr_type == QM_VERB QM_TYPE_DIV QM_VERB_IRR - || expr_type == QM_VERB QM_TYPE_DIV QM_VERB_REG + else if (qtype == TQM_VERB) { + type_ok = ( expr_type == TQM_VERB + || expr_type == TQM_VERB TQM_TYPE_DIV TQM_VERB_IRR + || expr_type == TQM_VERB TQM_TYPE_DIV TQM_VERB_REG ) && expr->getConjugation(idx).numEntries() > 0; } - else if (qtype == QM_ADJ) { - type_ok = expr_type == QM_ADJ + else if (qtype == TQM_ADJ) { + type_ok = expr_type == TQM_ADJ && !expr->getComparison(idx).isEmpty(); } else @@ -315,16 +315,16 @@ QuerySelection QueryManager::select(kvoctrainDoc *doc, int act_lesson, int idx, bool QueryManager::validate(kvoctrainExpr *expr, int act_lesson, int idx, QueryType query_type) { bool type_ok = false; - if (query_type == QT_Synonym) { + if (query_type == TQT_Synonym) { type_ok = !expr->getSynonym(idx).stripWhiteSpace().isEmpty(); } - else if (query_type == QT_Antonym) { + else if (query_type == TQT_Antonym) { type_ok = !expr->getAntonym(idx).stripWhiteSpace().isEmpty(); } - else if (query_type == QT_Paraphrase) { + else if (query_type == TQT_Paraphrase) { type_ok = !expr->getParaphrase(idx).stripWhiteSpace().isEmpty(); } - else if (query_type == QT_Example) { + else if (query_type == TQT_Example) { type_ok = !expr->getExample(idx).stripWhiteSpace().isEmpty(); } @@ -393,14 +393,14 @@ vector<TypeRelation> QueryManager::getRelation (bool only_maintypes) for (int i = 0; i < (int) userTypes.size(); i++) { TQString s; s.setNum(i+1); - s.insert(0, QM_USER_TYPE); + s.insert(0, TQM_USER_TYPE); vec.push_back(TypeRelation(s, userTypes[i])); } t_type_rel *type = InternalTypeRelations; while (type->short_ref != 0) { - if (!only_maintypes || strstr (type->short_ref, QM_TYPE_DIV) == 0) + if (!only_maintypes || strstr (type->short_ref, TQM_TYPE_DIV) == 0) vec.push_back(TypeRelation(type->short_ref, i18n(type->long_ref))); type++; } @@ -411,14 +411,14 @@ vector<TypeRelation> QueryManager::getRelation (bool only_maintypes) TQString QueryManager::typeStr (const TQString id) { - if (id.left(1) == QM_USER_TYPE) { + if (id.left(1) == TQM_USER_TYPE) { TQString num = id; num.remove (0, 1); int i = num.toInt()-1; if (i >= 0 && i < (int) userTypes.size() ) return userTypes[i]; else - return TQString::null; + return TQString(); } else { t_type_rel *type = InternalTypeRelations; @@ -428,7 +428,7 @@ TQString QueryManager::typeStr (const TQString id) type++; } } - return TQString::null; + return TQString(); } @@ -648,7 +648,7 @@ void QueryManager::setLessonItemStr (const TQString & indices) int pos; TQString indices_copy = indices; lessonitems.clear(); - while ((pos = indices_copy.find(' ')) >= 0) { + while ((pos = indices_copy.tqfind(' ')) >= 0) { TQString s = indices_copy.left(pos); indices_copy.remove(0, pos+1); lessonitems.push_back(s.toInt()); |