File indexing completed on 2024-04-21 03:48:21

0001 /*
0002  * C++ Interface: keduvockvtml1compability_p
0003  * SPDX-FileCopyrightText: 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #ifndef KEDUVOCKVTMLCOMPABILITY_H
0007 #define KEDUVOCKVTMLCOMPABILITY_H
0008 
0009 #include <QMap>
0010 #include <QSet>
0011 #include <QString>
0012 
0013 // internal types, indented are subtypes
0014 
0015 #define QM_VERB "v" // go
0016 // #define   QM_VERB_IRR     "ir"
0017 // #define   QM_VERB_REG     "re"
0018 #define QM_NOUN "n" // table, coffee
0019 // #define   QM_NOUN_F       "f"
0020 // #define   QM_NOUN_M       "m"
0021 // #define   QM_NOUN_S       "s"
0022 #define QM_NAME "nm"
0023 // #define QM_ART            "ar"   // article
0024 // #define   QM_ART_DEF      "def"  // definite    a/an
0025 // #define   QM_ART_IND      "ind"  // indefinite  the
0026 #define QM_ADJ "aj" // adjective   expensive, good
0027 // #define QM_ADV            "av"   // adverb      today, strongly
0028 // #define QM_PRON           "pr"   // pronoun     you, she
0029 // #define   QM_PRON_POS     "pos"  // possessive  my, your
0030 // #define   QM_PRON_PER     "per"  // personal
0031 // #define QM_PHRASE         "ph"
0032 // #define QM_NUM            "num"  // numeral
0033 // #define   QM_NUM_ORD      "ord"  // ordinal     first, second
0034 // #define   QM_NUM_CARD     "crd"  // cardinal    one, two
0035 // #define QM_INFORMAL       "ifm"
0036 // #define QM_FIG            "fig"
0037 // #define QM_CON            "con"  // conjunction  and, but
0038 // #define QM_PREP           "pre"  // preposition behind, between
0039 // #define QM_QUEST          "qu"   // question    who, what
0040 
0041 // type delimiters
0042 
0043 #define QM_USER_TYPE "#" // designates number of user type
0044 #define QM_TYPE_DIV ":" // divide main from subtype
0045 
0046 // usage delimiters (also declared in UsageManager.h)
0047 
0048 #define UL_USER_USAGE "#" // designates number of user type
0049 
0050 class KEduVocWordType;
0051 
0052 /**
0053  * @file keduvockvtmlcompability.h
0054  * contains defines and constants necessary for reading kvtml files prior to KDE4. kvtml version 1.
0055  */
0056 class KEduVocKvtmlCompability
0057 {
0058 public:
0059     /**
0060      * Constructor, initialize the map.
0061      */
0062     KEduVocKvtmlCompability();
0063 
0064     ///// TYPES
0065     /**
0066      * Get the type from an old type definition
0067      * @param parent the parent word type
0068      * @param typeSubtypeString the old string containing everything
0069      * @return type
0070      */
0071     KEduVocWordType *typeFromOldFormat(KEduVocWordType *parent, const QString &typeSubtypeString) const;
0072 
0073     /**
0074      * To write old docs: convert a nice new type to the ugly old style.
0075      * @param mainType type
0076      * @param subType subtype
0077      * @return old type string
0078      */
0079     QString oldType(const QString &mainType, const QString &subType) const;
0080 
0081     void addUserdefinedTense(const QString &tense);
0082     QString tenseFromKvtml1(const QString &oldTense);
0083     QStringList documentTenses() const;
0084     QString oldTense(const QString &tense);
0085 
0086     void setupWordTypes(KEduVocWordType *parent);
0087 
0088 private:
0089     //////////// TYPES /////////////////
0090     void initOldTypeLists();
0091 
0092     QMap<QString, QString> m_oldMainTypeNames;
0093     QMap<QString, QString> m_oldSubTypeNames;
0094     int m_userdefinedTypeCounter;
0095 
0096     ///////////TENSES/CONJUGATIONS///////
0097     void initOldTenses();
0098 
0099     QMap<QString, QString> m_oldTenses;
0100     int m_userdefinedTenseCounter;
0101     QSet<QString> m_tenses;
0102 
0103     /// # defines user defined usage/word type/tense
0104     static const QString KVTML_1_USER_DEFINED;
0105     /// : separates usages/word types
0106     static const QString KVTML_1_SEPERATOR;
0107 };
0108 
0109 #endif // KEDUVOCKVTMLCOMPABILITY_H