]> Git trees. - libqmvoc.git/commitdiff
Move KEduVocConjugation into its own file.
authorFrederik Gladhorn <gladhorn@kde.org>
Tue, 28 Aug 2007 18:17:36 +0000 (18:17 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Tue, 28 Aug 2007 18:17:36 +0000 (18:17 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=705851

keduvocdocument/CMakeLists.txt
keduvocdocument/keduvocconjugation.cpp [new file with mode: 0644]
keduvocdocument/keduvocconjugation.h [new file with mode: 0644]
keduvocdocument/keduvocdocument.h
keduvocdocument/keduvocgrammar.cpp
keduvocdocument/keduvocgrammar.h
keduvocdocument/keduvockvtmlwriter.h
keduvocdocument/keduvoctranslation.h

index 96a1af714d819699930dc8299bd458a267c41ff8..e7eb9ae94ae665cb394e478a3a1fa80d39353fd4 100644 (file)
@@ -11,6 +11,7 @@ set(keduvocdocument_LIB_SRCS
    keduvoclesson.cpp
    keduvocgrade.cpp
    keduvocgrammar.cpp
+   keduvocconjugation.cpp
    keduvocwordtype.cpp
    keduvockvtmlreader.cpp
    keduvockvtml2reader.cpp
@@ -49,6 +50,7 @@ install(FILES
    keduvocexpression.h
    keduvocgrade.h
    keduvocgrammar.h
+   keduvocconjugation.h
    keduvoclesson.h
    keduvocmultiplechoice.h
    keduvoctranslation.h
diff --git a/keduvocdocument/keduvocconjugation.cpp b/keduvocdocument/keduvocconjugation.cpp
new file mode 100644 (file)
index 0000000..0cc9a8c
--- /dev/null
@@ -0,0 +1,508 @@
+/***************************************************************************
+
+    C++ Implementation: keduvocconjugation
+
+    -----------------------------------------------------------------------
+
+    begin         : Di Aug 28 2007
+
+    copyright     : (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
+
+    -----------------------------------------------------------------------
+
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "keduvocconjugation.h"
+#include "keduvoccommon_p.h"
+#include <KLocalizedString>
+
+class KEduVocConjugation::Private
+{
+public:
+  Private()
+  {
+  }
+
+  QString verbName; // added to have something to compare in operator ==, assumes that there is always only one
+                    // KEduVocConjugation per verb
+
+  struct conjug_name_t
+  {
+    const char *abbrev;
+    const char *name;
+  };
+
+  struct conjug_t
+  {
+     conjug_t() {
+        p3common = false;
+        s3common = false;
+     }
+
+     QString type;
+     bool    p3common;
+     bool    s3common;
+     QString pers1_sing;
+     QString pers2_sing;
+     QString pers3_m_sing;
+     QString pers3_f_sing;
+     QString pers3_n_sing;
+     QString pers1_plur;
+     QString pers2_plur;
+     QString pers3_m_plur;
+     QString pers3_f_plur;
+     QString pers3_n_plur;
+  };
+
+  typedef QList<conjug_t> conjug_tList;
+  conjug_tList conjugations;
+
+  static conjug_name_t names[];
+  static QStringList userTenses;
+};
+
+
+KEduVocConjugation::Private::conjug_name_t
+
+KEduVocConjugation::Private::names [] =
+{
+  { CONJ_SIMPLE_PRESENT,    I18N_NOOP("Simple Present") },
+  { CONJ_PRESENT_PROGR,     I18N_NOOP("Present Progressive") },
+  { CONJ_PRESENT_PERFECT,   I18N_NOOP("Present Perfect") },
+
+  { CONJ_SIMPLE_PAST,       I18N_NOOP("Simple Past") },
+  { CONJ_PAST_PROGR,        I18N_NOOP("Past Progressive") },
+  { CONJ_PAST_PARTICIPLE,   I18N_NOOP("Past Participle") },
+
+  { CONJ_FUTURE,            I18N_NOOP("Future") }
+};
+
+
+QStringList KEduVocConjugation::Private::userTenses;
+
+
+
+KEduVocConjugation::KEduVocConjugation()
+  : d(new Private)
+{
+}
+
+
+KEduVocConjugation::KEduVocConjugation(const KEduVocConjugation& rhs)
+  : d(new Private(*rhs.d))
+{
+}
+
+
+KEduVocConjugation::~KEduVocConjugation()
+{
+  delete d;
+}
+
+
+KEduVocConjugation& KEduVocConjugation::operator =(const KEduVocConjugation& a)
+{
+  *d = *a.d;
+  return *this;
+}
+
+
+bool KEduVocConjugation::operator ==(const KEduVocConjugation& a) const
+{
+  return d->verbName == a.getVerbName();
+}
+
+
+QString KEduVocConjugation::getVerbName() const
+{
+  return d->verbName;
+}
+
+int KEduVocConjugation::entryCount() const
+{
+  return d->conjugations.count();
+}
+
+
+QList<KEduVocTenseRelation> KEduVocConjugation::getRelation ()
+{
+  QList<KEduVocTenseRelation> vec;
+
+  for (int i = 0; i < numInternalNames(); i++) {
+    vec.append(KEduVocTenseRelation(Private::names[i].abbrev, i18n(Private::names[i].name)));
+  }
+
+  for (int i = 0; i < Private::userTenses.count(); i++) {
+    QString s;
+    s.setNum(i + 1);
+    s.prepend(UL_USER_TENSE);
+    vec.append(KEduVocTenseRelation(s, Private::userTenses[i]));
+  }
+
+  return vec;
+}
+
+
+void KEduVocConjugation::setTenseNames(const QStringList& names)
+{
+  Private::userTenses = names;
+}
+
+
+QString KEduVocConjugation::getName(const QString &abbrev)
+{
+  if (abbrev.length() >= 2 && QString(abbrev[0]) == QString(UL_USER_TENSE)) {
+    QString s = abbrev;
+    s.remove(0, 1);
+    int i = s.toInt() - 1;
+
+    if (i < Private::userTenses.count() )
+      return Private::userTenses[i];
+    else
+      return "";
+  }
+  else {
+    for (int i = 0; i < numInternalNames(); i++)
+      if (Private::names[i].abbrev == abbrev) {
+        return i18n(Private::names[i].name);
+      }
+  }
+
+  return "";
+}
+
+
+QString KEduVocConjugation::getName(int idx)
+{
+  if (idx < numInternalNames())
+    return i18n(Private::names[idx].name);
+  else if (idx < tenseCount())
+    return Private::userTenses[idx-numInternalNames()];
+  else
+    return "";
+}
+
+
+QString KEduVocConjugation::getAbbrev(const QString &name)
+{
+  for (int i = 0; i < Private::userTenses.count(); i++)
+    if (Private::userTenses[i] == name) {
+      QString s;
+      s.setNum(i + 1);
+      s.prepend(UL_USER_TENSE);
+      return s;
+    }
+
+  for (int i = 0; i < numInternalNames(); i++)
+    if (Private::names[i].name == name)
+      return Private::names[i].abbrev;
+
+  return "";
+}
+
+
+QString KEduVocConjugation::getAbbrev(int idx)
+{
+  if (idx < numInternalNames() )
+    return Private::names[idx].abbrev;
+
+  else if (idx < tenseCount()) {
+    QString s;
+    s.setNum(idx - numInternalNames() + 1);
+    s.prepend(UL_USER_TENSE);
+    return s;
+  }
+
+  else
+    return "";
+}
+
+
+int KEduVocConjugation::numInternalNames()
+{
+  return sizeof(Private::names) / sizeof(Private::names[0]);
+}
+
+
+int KEduVocConjugation::tenseCount()
+{
+  return numInternalNames() + Private::userTenses.size();
+}
+
+
+QString KEduVocConjugation::getType(int idx)
+{
+  if (idx >= d->conjugations.count())
+    return "";
+
+  return d->conjugations[idx].type;
+}
+
+
+void KEduVocConjugation::setType(int idx, const QString & type)
+{
+  if (idx >= d->conjugations.size())
+    return;
+
+  d->conjugations[idx].type = type;
+}
+
+
+void KEduVocConjugation::cleanUp()
+{
+  for (int i = d->conjugations.count() - 1; i >= 0; i--) {
+    const Private::conjug_t *ctp = &d->conjugations[i];
+    if (   ctp->pers1_sing.simplified().isEmpty()
+        && ctp->pers2_sing.simplified().isEmpty()
+        && ctp->pers3_m_sing.simplified().isEmpty()
+        && ctp->pers3_f_sing.simplified().isEmpty()
+        && ctp->pers3_n_sing.simplified().isEmpty()
+        && ctp->pers1_plur.simplified().isEmpty()
+        && ctp->pers2_plur.simplified().isEmpty()
+        && ctp->pers3_m_plur.simplified().isEmpty()
+        && ctp->pers3_f_plur.simplified().isEmpty()
+        && ctp->pers3_n_plur.simplified().isEmpty()
+       )
+     d->conjugations.removeAt(i);
+  }
+}
+
+
+bool KEduVocConjugation::isEmpty(int idx)
+{
+  if (idx < d->conjugations.count()) {
+    const Private::conjug_t *ctp = &d->conjugations[idx];
+    return ctp->pers1_sing.simplified().isEmpty()
+        && ctp->pers2_sing.simplified().isEmpty()
+        && ctp->pers3_m_sing.simplified().isEmpty()
+        && ctp->pers3_f_sing.simplified().isEmpty()
+        && ctp->pers3_n_sing.simplified().isEmpty()
+        && ctp->pers1_plur.simplified().isEmpty()
+        && ctp->pers2_plur.simplified().isEmpty()
+        && ctp->pers3_m_plur.simplified().isEmpty()
+        && ctp->pers3_f_plur.simplified().isEmpty()
+        && ctp->pers3_n_plur.simplified().isEmpty();
+  }
+  return true;
+}
+
+
+#define _GET_CON_(elem, type, default) \
+   for (int i = 0; i < d->conjugations.size(); i++) \
+     if (d->conjugations[i].type == type) \
+        return d->conjugations[i].elem; \
+   return default;
+
+
+bool KEduVocConjugation::pers3SingularCommon(const QString &type) const
+{
+  _GET_CON_(s3common, type, false);
+}
+
+
+bool KEduVocConjugation::pers3PluralCommon(const QString &type) const
+{
+  _GET_CON_(p3common, type, false);
+}
+
+
+QString KEduVocConjugation::pers1Singular(const QString &type) const
+{
+  _GET_CON_(pers1_sing, type, "");
+}
+
+
+QString KEduVocConjugation::pers2Singular(const QString &type) const
+{
+  _GET_CON_(pers2_sing, type, "");
+}
+
+
+QString KEduVocConjugation::pers3FemaleSingular(const QString &type) const
+{
+  _GET_CON_(pers3_f_sing, type, "");
+}
+
+
+QString KEduVocConjugation::pers3MaleSingular(const QString &type) const
+{
+  _GET_CON_(pers3_m_sing, type, "");
+}
+
+
+QString KEduVocConjugation::pers3NaturalSingular(const QString &type) const
+{
+  _GET_CON_(pers3_n_sing, type, "");
+}
+
+
+QString KEduVocConjugation::pers1Plural(const QString &type) const
+{
+  _GET_CON_(pers1_plur, type, "");
+}
+
+
+QString KEduVocConjugation::pers2Plural(const QString &type) const
+{
+  _GET_CON_(pers2_plur, type, "");
+}
+
+
+QString KEduVocConjugation::pers3FemalePlural(const QString &type) const
+{
+  _GET_CON_(pers3_f_plur, type, "");
+}
+
+
+QString KEduVocConjugation::pers3MalePlural(const QString &type) const
+{
+  _GET_CON_(pers3_m_plur, type, "");
+}
+
+
+QString KEduVocConjugation::pers3NaturalPlural(const QString &type) const
+{
+  _GET_CON_(pers3_n_plur, type, "");
+}
+
+
+#undef _GET_CON_
+
+
+#define _SET_CON_(elem, type, str) \
+   for (int i = 0; i < d->conjugations.size(); i++) \
+     if (d->conjugations[i].type == type) { \
+       d->conjugations[i].elem = str; \
+       return; \
+     } \
+   Private::conjug_t ct; \
+   ct.type = type; \
+   ct.elem = str; \
+   d->conjugations.append(ct);
+
+
+void KEduVocConjugation::setPers3PluralCommon(const QString &type, bool f)
+{
+  _SET_CON_(p3common, type, f);
+}
+
+
+void KEduVocConjugation::setPers3SingularCommon(const QString &type, bool f)
+{
+  _SET_CON_(s3common, type, f);
+}
+
+
+void KEduVocConjugation::setPers1Singular(const QString &type, const QString &str)
+{
+  _SET_CON_(pers1_sing, type, str);
+}
+
+
+void KEduVocConjugation::setPers2Singular(const QString &type, const QString &str)
+{
+  _SET_CON_(pers2_sing, type, str);
+}
+
+
+void KEduVocConjugation::setPers3FemaleSingular(const QString &type, const QString &str)
+{
+  _SET_CON_(pers3_f_sing, type, str);
+}
+
+
+void KEduVocConjugation::setPers3MaleSingular(const QString &type, const QString &str)
+{
+  _SET_CON_(pers3_m_sing, type, str);
+}
+
+
+void KEduVocConjugation::setPers3NaturalSingular(const QString &type, const QString &str)
+{
+  _SET_CON_(pers3_n_sing, type, str);
+}
+
+
+void KEduVocConjugation::setPers1Plural(const QString &type, const QString &str)
+{
+  _SET_CON_(pers1_plur, type, str);
+}
+
+
+void KEduVocConjugation::setPers2Plural(const QString &type, const QString &str)
+{
+  _SET_CON_(pers2_plur, type, str);
+}
+
+
+void KEduVocConjugation::setPers3FemalePlural(const QString &type, const QString &str)
+{
+  _SET_CON_(pers3_f_plur, type, str);
+}
+
+
+void KEduVocConjugation::setPers3MalePlural(const QString &type, const QString &str)
+{
+  _SET_CON_(pers3_m_plur, type, str);
+}
+
+
+void KEduVocConjugation::setPers3NaturalPlural(const QString &type, const QString &str)
+{
+  _SET_CON_(pers3_n_plur, type, str);
+}
+
+#undef _SET_CON_
+
+
+//==============================================================
+class KEduVocTenseRelation::Private
+{
+  public:
+    QString shortId;
+    QString longId;
+};
+
+KEduVocTenseRelation::KEduVocTenseRelation()
+: d(new Private)
+{
+}
+
+KEduVocTenseRelation::KEduVocTenseRelation (const QString & _short, const QString & _long)
+: d(new Private)
+{
+  d->shortId = _short;
+  d->longId = _long;
+}
+
+KEduVocTenseRelation::~KEduVocTenseRelation()
+{
+  delete d;
+}
+
+KEduVocTenseRelation &KEduVocTenseRelation::operator=(const KEduVocTenseRelation &other)
+{
+  d->shortId = other.shortStr();
+  d->longId = other.longStr();
+  return *this;
+}
+
+QString KEduVocTenseRelation::shortStr() const
+{
+  return d->shortId;
+}
+
+QString KEduVocTenseRelation::longStr()  const
+{
+  return d->longId;
+}
+
diff --git a/keduvocdocument/keduvocconjugation.h b/keduvocdocument/keduvocconjugation.h
new file mode 100644 (file)
index 0000000..957f9f9
--- /dev/null
@@ -0,0 +1,143 @@
+/***************************************************************************
+
+    C++ Interface: keduvocconjugation
+
+    -----------------------------------------------------------------------
+
+    begin         : Di Aug 28 2007
+
+    copyright     : (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
+
+    -----------------------------------------------------------------------
+
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+
+#ifndef KEDUVOCCONJUGATION_H
+#define KEDUVOCCONJUGATION_H
+
+#include "libkeduvocdocument_export.h"
+
+#include <QtCore/QStringList>
+
+
+#define CONJ_PREFIX            "--"   // definition of prefixes (I, you, ..)
+
+#define UL_USER_TENSE          "#"   // designates number of user tense
+
+
+class KEDUVOCDOCUMENT_EXPORT KEduVocTenseRelation
+{
+public:
+  /** default constructor */
+  KEduVocTenseRelation();
+  KEduVocTenseRelation (const QString & _short, const QString & _long);
+
+  /** default destructor, deletes the d-pointer */
+  ~KEduVocTenseRelation();
+
+  QString shortStr() const;
+  QString longStr()  const;
+
+  KEduVocTenseRelation &operator=(const KEduVocTenseRelation &other);
+
+private:
+  class Private;
+  Private * const d;
+};
+
+
+/**
+ * The conjugation of a verb
+ */
+class KEDUVOCDOCUMENT_EXPORT KEduVocConjugation
+{
+public:
+
+  /**
+   * The constructor
+   */
+  explicit KEduVocConjugation();
+
+  KEduVocConjugation(const KEduVocConjugation& rhs);
+
+  ~KEduVocConjugation();
+
+  /**
+   * @return
+   */
+  int entryCount() const;
+
+  /**
+   * @return
+   */
+  static QList<KEduVocTenseRelation> getRelation();
+
+  /**
+   * @param names
+   */
+  static void setTenseNames(const QStringList& names);
+
+  static QString getName(const QString &abbrev);
+  static QString getName(int index);
+  static QString getAbbrev(const QString &name);
+  static QString getAbbrev(int index);
+  static int numInternalNames();
+  static int tenseCount();
+
+  QString getVerbName() const;
+
+  QString getType(int index);
+  void setType(int index, const QString & type);
+  void cleanUp();
+  bool isEmpty(int idx);
+
+  QString pers1Singular(const QString &type) const;
+  QString pers2Singular(const QString &type) const;
+  bool    pers3SingularCommon(const QString &type) const;
+  QString pers3FemaleSingular(const QString &type) const;
+  QString pers3MaleSingular(const QString &type) const;
+  QString pers3NaturalSingular(const QString &type) const;
+
+  QString pers1Plural(const QString &type) const;
+  QString pers2Plural(const QString &type) const;
+  bool    pers3PluralCommon(const QString &type) const;
+  QString pers3FemalePlural(const QString &type) const;
+  QString pers3MalePlural(const QString &type) const;
+  QString pers3NaturalPlural(const QString &type) const;
+
+  void setPers1Singular(const QString &type, const QString &str);
+  void setPers2Singular(const QString &type, const QString &str);
+  void setPers3SingularCommon(const QString &type, bool f);
+  void setPers3FemaleSingular(const QString &type, const QString &str);
+  void setPers3MaleSingular(const QString &type, const QString &str);
+  void setPers3NaturalSingular(const QString &type, const QString &str);
+
+  void setPers1Plural(const QString &type, const QString &str);
+  void setPers2Plural(const QString &type, const QString &str);
+  void setPers3PluralCommon(const QString &type, bool f);
+  void setPers3FemalePlural(const QString &type, const QString &str);
+  void setPers3MalePlural(const QString &type, const QString &str);
+  void setPers3NaturalPlural(const QString &type, const QString &str);
+
+  KEduVocConjugation& operator = (const KEduVocConjugation& a);
+  bool operator == (const KEduVocConjugation& a) const;
+
+private:
+  class Private;
+  Private* const d;
+};
+
+
+
+#endif // KEDUVOCCONJUGATION_H
+
index f39b42d1fe0b435eda5765caad2706ff4a95acb0..8f83321fdb40bc6a143a8324bae75a78fcf46539 100644 (file)
@@ -22,6 +22,7 @@
 #include "libkeduvocdocument_export.h"
 
 #include "keduvocgrammar.h"
+#include "keduvocconjugation.h"
 
 #include <QtCore/QObject>
 #include <QtCore/QList>
index d6077c22520e5e6940ce4d8293df80724faf38a4..df83a7ccc3d9ef5730c520ffc64b5aa67b8d1b41 100644 (file)
@@ -9,6 +9,7 @@
     copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
                 (C) 2001 The KDE-EDU team
                 (C) 2004, 2005, 2007 Peter Hedlund <peter.hedlund@kdemail.net>
+                (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
 
     -----------------------------------------------------------------------
 
 
 #include "keduvocgrammar.h"
 
-#include "keduvoccommon_p.h"
-
-#include <klocale.h>
-
-class KEduVocConjugation::Private
-{
-public:
-  Private()
-  {
-  }
-
-  QString verbName; // added to have something to compare in operator ==, assumes that there is always only one
-                    // KEduVocConjugation per verb
-
-  struct conjug_name_t
-  {
-    const char *abbrev;
-    const char *name;
-  };
-
-  struct conjug_t
-  {
-     conjug_t() {
-        p3common = false;
-        s3common = false;
-     }
-
-     QString type;
-     bool    p3common;
-     bool    s3common;
-     QString pers1_sing;
-     QString pers2_sing;
-     QString pers3_m_sing;
-     QString pers3_f_sing;
-     QString pers3_n_sing;
-     QString pers1_plur;
-     QString pers2_plur;
-     QString pers3_m_plur;
-     QString pers3_f_plur;
-     QString pers3_n_plur;
-  };
-
-  typedef QList<conjug_t> conjug_tList;
-  conjug_tList conjugations;
-
-  static conjug_name_t names[];
-  static QStringList userTenses;
-};
-
-
-KEduVocConjugation::Private::conjug_name_t
-KEduVocConjugation::Private::names [] =
-{
-  { CONJ_SIMPLE_PRESENT,    I18N_NOOP("Simple Present") },
-  { CONJ_PRESENT_PROGR,     I18N_NOOP("Present Progressive") },
-  { CONJ_PRESENT_PERFECT,   I18N_NOOP("Present Perfect") },
-
-  { CONJ_SIMPLE_PAST,       I18N_NOOP("Simple Past") },
-  { CONJ_PAST_PROGR,        I18N_NOOP("Past Progressive") },
-  { CONJ_PAST_PARTICIPLE,   I18N_NOOP("Past Participle") },
-
-  { CONJ_FUTURE,            I18N_NOOP("Future") }
-};
-
-
-QStringList KEduVocConjugation::Private::userTenses;
-
-
-//================================================================
 
 class KEduVocComparison::Private
 {
@@ -134,7 +66,7 @@ KEduVocComparison &KEduVocComparison::operator=(const KEduVocComparison& other)
   setL1(other.l1());
   setL2(other.l2());
   setL3(other.l3());
-  
+
   return *this;
 }
 
@@ -157,32 +89,32 @@ bool KEduVocComparison::operator ==(const KEduVocComparison& a) const
 }
 
 void KEduVocComparison::setL1(const QString &s)
-{ 
-  d->ls1 = s; 
+{
+  d->ls1 = s;
 }
 
-void KEduVocComparison::setL2(const QString &s) 
-{ 
-  d->ls2 = s; 
+void KEduVocComparison::setL2(const QString &s)
+{
+  d->ls2 = s;
 }
 
-void KEduVocComparison::setL3(const QString &s) 
-{ 
-  d->ls3 = s; 
+void KEduVocComparison::setL3(const QString &s)
+{
+  d->ls3 = s;
 }
 
-QString KEduVocComparison::l1() const 
-{ 
-  return d->ls1; 
+QString KEduVocComparison::l1() const
+{
+  return d->ls1;
 }
-QString KEduVocComparison::l2() const 
-{ 
-  return d->ls2; 
+QString KEduVocComparison::l2() const
+{
+  return d->ls2;
 }
 
-QString KEduVocComparison::l3() const 
-{ 
-  return d->ls3; 
+QString KEduVocComparison::l3() const
+{
+  return d->ls3;
 }
 
 
@@ -218,7 +150,7 @@ KEduVocArticle &KEduVocArticle::operator=(const KEduVocArticle& other)
   d->mal_indef = other.d->mal_indef;
   d->nat_def = other.d->nat_def;
   d->nat_indef = other.d->nat_indef;
-  
+
   return *this;
 }
 
@@ -282,420 +214,4 @@ void KEduVocArticle::getNatural(QString *def, QString *indef) const
     *indef = d->nat_indef;
 }
 
-//==============================================================
-class KEduVocTenseRelation::Private
-{
-  public:
-    QString shortId;
-    QString longId;
-};
-
-KEduVocTenseRelation::KEduVocTenseRelation()
-: d(new Private)
-{
-}
-
-KEduVocTenseRelation::KEduVocTenseRelation (const QString & _short, const QString & _long)
-: d(new Private)
-{
-  d->shortId = _short;
-  d->longId = _long;
-}
-
-KEduVocTenseRelation::~KEduVocTenseRelation()
-{
-  delete d;
-}
-
-KEduVocTenseRelation &KEduVocTenseRelation::operator=(const KEduVocTenseRelation &other)
-{
-  d->shortId = other.shortStr();
-  d->longId = other.longStr();
-  return *this;
-}
-
-QString KEduVocTenseRelation::shortStr() const 
-{ 
-  return d->shortId; 
-}
-
-QString KEduVocTenseRelation::longStr()  const 
-{ 
-  return d->longId;  
-}
-
-
-//==============================================================
-
-
-KEduVocConjugation::KEduVocConjugation()
-  : d(new Private)
-{
-}
-
-
-KEduVocConjugation::KEduVocConjugation(const KEduVocConjugation& rhs)
-  : d(new Private(*rhs.d))
-{
-}
-
-
-KEduVocConjugation::~KEduVocConjugation()
-{
-  delete d;
-}
-
-
-KEduVocConjugation& KEduVocConjugation::operator =(const KEduVocConjugation& a)
-{
-  *d = *a.d;
-  return *this;
-}
-
-
-bool KEduVocConjugation::operator ==(const KEduVocConjugation& a) const
-{
-  return d->verbName == a.getVerbName();
-}
-
-
-QString KEduVocConjugation::getVerbName() const
-{
-  return d->verbName;
-}
-
-int KEduVocConjugation::entryCount() const
-{
-  return d->conjugations.count();
-}
-
-
-QList<KEduVocTenseRelation> KEduVocConjugation::getRelation ()
-{
-  QList<KEduVocTenseRelation> vec;
-
-  for (int i = 0; i < numInternalNames(); i++) {
-    vec.append(KEduVocTenseRelation(Private::names[i].abbrev, i18n(Private::names[i].name)));
-  }
-
-  for (int i = 0; i < Private::userTenses.count(); i++) {
-    QString s;
-    s.setNum(i + 1);
-    s.prepend(UL_USER_TENSE);
-    vec.append(KEduVocTenseRelation(s, Private::userTenses[i]));
-  }
-
-  return vec;
-}
-
-
-void KEduVocConjugation::setTenseNames(const QStringList& names)
-{
-  Private::userTenses = names;
-}
-
-
-QString KEduVocConjugation::getName(const QString &abbrev)
-{
-  if (abbrev.length() >= 2 && QString(abbrev[0]) == QString(UL_USER_TENSE)) {
-    QString s = abbrev;
-    s.remove(0, 1);
-    int i = s.toInt() - 1;
-
-    if (i < Private::userTenses.count() )
-      return Private::userTenses[i];
-    else
-      return "";
-  }
-  else {
-    for (int i = 0; i < numInternalNames(); i++)
-      if (Private::names[i].abbrev == abbrev) {
-        return i18n(Private::names[i].name);
-      }
-  }
-
-  return "";
-}
-
-
-QString KEduVocConjugation::getName(int idx)
-{
-  if (idx < numInternalNames())
-    return i18n(Private::names[idx].name);
-  else if (idx < tenseCount())
-    return Private::userTenses[idx-numInternalNames()];
-  else
-    return "";
-}
-
-
-QString KEduVocConjugation::getAbbrev(const QString &name)
-{
-  for (int i = 0; i < Private::userTenses.count(); i++)
-    if (Private::userTenses[i] == name) {
-      QString s;
-      s.setNum(i + 1);
-      s.prepend(UL_USER_TENSE);
-      return s;
-    }
-
-  for (int i = 0; i < numInternalNames(); i++)
-    if (Private::names[i].name == name)
-      return Private::names[i].abbrev;
-
-  return "";
-}
-
-
-QString KEduVocConjugation::getAbbrev(int idx)
-{
-  if (idx < numInternalNames() )
-    return Private::names[idx].abbrev;
-
-  else if (idx < tenseCount()) {
-    QString s;
-    s.setNum(idx - numInternalNames() + 1);
-    s.prepend(UL_USER_TENSE);
-    return s;
-  }
-
-  else
-    return "";
-}
-
-
-int KEduVocConjugation::numInternalNames()
-{
-  return sizeof(Private::names) / sizeof(Private::names[0]);
-}
-
-
-int KEduVocConjugation::tenseCount()
-{
-  return numInternalNames() + Private::userTenses.size();
-}
-
-
-QString KEduVocConjugation::getType(int idx)
-{
-  if (idx >= d->conjugations.count())
-    return "";
-
-  return d->conjugations[idx].type;
-}
-
-
-void KEduVocConjugation::setType(int idx, const QString & type)
-{
-  if (idx >= d->conjugations.size())
-    return;
-
-  d->conjugations[idx].type = type;
-}
-
-
-void KEduVocConjugation::cleanUp()
-{
-  for (int i = d->conjugations.count() - 1; i >= 0; i--) {
-    const Private::conjug_t *ctp = &d->conjugations[i];
-    if (   ctp->pers1_sing.simplified().isEmpty()
-        && ctp->pers2_sing.simplified().isEmpty()
-        && ctp->pers3_m_sing.simplified().isEmpty()
-        && ctp->pers3_f_sing.simplified().isEmpty()
-        && ctp->pers3_n_sing.simplified().isEmpty()
-        && ctp->pers1_plur.simplified().isEmpty()
-        && ctp->pers2_plur.simplified().isEmpty()
-        && ctp->pers3_m_plur.simplified().isEmpty()
-        && ctp->pers3_f_plur.simplified().isEmpty()
-        && ctp->pers3_n_plur.simplified().isEmpty()
-       )
-     d->conjugations.removeAt(i);
-  }
-}
-
-
-bool KEduVocConjugation::isEmpty(int idx)
-{
-  if (idx < d->conjugations.count()) {
-    const Private::conjug_t *ctp = &d->conjugations[idx];
-    return ctp->pers1_sing.simplified().isEmpty()
-        && ctp->pers2_sing.simplified().isEmpty()
-        && ctp->pers3_m_sing.simplified().isEmpty()
-        && ctp->pers3_f_sing.simplified().isEmpty()
-        && ctp->pers3_n_sing.simplified().isEmpty()
-        && ctp->pers1_plur.simplified().isEmpty()
-        && ctp->pers2_plur.simplified().isEmpty()
-        && ctp->pers3_m_plur.simplified().isEmpty()
-        && ctp->pers3_f_plur.simplified().isEmpty()
-        && ctp->pers3_n_plur.simplified().isEmpty();
-  }
-  return true;
-}
-
-
-#define _GET_CON_(elem, type, default) \
-   for (int i = 0; i < d->conjugations.size(); i++) \
-     if (d->conjugations[i].type == type) \
-        return d->conjugations[i].elem; \
-   return default;
-
-
-bool KEduVocConjugation::pers3SingularCommon(const QString &type) const
-{
-  _GET_CON_(s3common, type, false);
-}
-
-
-bool KEduVocConjugation::pers3PluralCommon(const QString &type) const
-{
-  _GET_CON_(p3common, type, false);
-}
-
-
-QString KEduVocConjugation::pers1Singular(const QString &type) const
-{
-  _GET_CON_(pers1_sing, type, "");
-}
-
-
-QString KEduVocConjugation::pers2Singular(const QString &type) const
-{
-  _GET_CON_(pers2_sing, type, "");
-}
-
-
-QString KEduVocConjugation::pers3FemaleSingular(const QString &type) const
-{
-  _GET_CON_(pers3_f_sing, type, "");
-}
-
-
-QString KEduVocConjugation::pers3MaleSingular(const QString &type) const
-{
-  _GET_CON_(pers3_m_sing, type, "");
-}
-
-
-QString KEduVocConjugation::pers3NaturalSingular(const QString &type) const
-{
-  _GET_CON_(pers3_n_sing, type, "");
-}
-
-
-QString KEduVocConjugation::pers1Plural(const QString &type) const
-{
-  _GET_CON_(pers1_plur, type, "");
-}
-
-
-QString KEduVocConjugation::pers2Plural(const QString &type) const
-{
-  _GET_CON_(pers2_plur, type, "");
-}
-
-
-QString KEduVocConjugation::pers3FemalePlural(const QString &type) const
-{
-  _GET_CON_(pers3_f_plur, type, "");
-}
-
-
-QString KEduVocConjugation::pers3MalePlural(const QString &type) const
-{
-  _GET_CON_(pers3_m_plur, type, "");
-}
-
-
-QString KEduVocConjugation::pers3NaturalPlural(const QString &type) const
-{
-  _GET_CON_(pers3_n_plur, type, "");
-}
-
-
-#undef _GET_CON_
-
-
-#define _SET_CON_(elem, type, str) \
-   for (int i = 0; i < d->conjugations.size(); i++) \
-     if (d->conjugations[i].type == type) { \
-       d->conjugations[i].elem = str; \
-       return; \
-     } \
-   Private::conjug_t ct; \
-   ct.type = type; \
-   ct.elem = str; \
-   d->conjugations.append(ct);
-
-
-void KEduVocConjugation::setPers3PluralCommon(const QString &type, bool f)
-{
-  _SET_CON_(p3common, type, f);
-}
-
-
-void KEduVocConjugation::setPers3SingularCommon(const QString &type, bool f)
-{
-  _SET_CON_(s3common, type, f);
-}
-
-
-void KEduVocConjugation::setPers1Singular(const QString &type, const QString &str)
-{
-  _SET_CON_(pers1_sing, type, str);
-}
-
-
-void KEduVocConjugation::setPers2Singular(const QString &type, const QString &str)
-{
-  _SET_CON_(pers2_sing, type, str);
-}
-
-
-void KEduVocConjugation::setPers3FemaleSingular(const QString &type, const QString &str)
-{
-  _SET_CON_(pers3_f_sing, type, str);
-}
-
-
-void KEduVocConjugation::setPers3MaleSingular(const QString &type, const QString &str)
-{
-  _SET_CON_(pers3_m_sing, type, str);
-}
-
-
-void KEduVocConjugation::setPers3NaturalSingular(const QString &type, const QString &str)
-{
-  _SET_CON_(pers3_n_sing, type, str);
-}
-
-
-void KEduVocConjugation::setPers1Plural(const QString &type, const QString &str)
-{
-  _SET_CON_(pers1_plur, type, str);
-}
-
-
-void KEduVocConjugation::setPers2Plural(const QString &type, const QString &str)
-{
-  _SET_CON_(pers2_plur, type, str);
-}
-
-
-void KEduVocConjugation::setPers3FemalePlural(const QString &type, const QString &str)
-{
-  _SET_CON_(pers3_f_plur, type, str);
-}
-
-
-void KEduVocConjugation::setPers3MalePlural(const QString &type, const QString &str)
-{
-  _SET_CON_(pers3_m_plur, type, str);
-}
-
-
-void KEduVocConjugation::setPers3NaturalPlural(const QString &type, const QString &str)
-{
-  _SET_CON_(pers3_n_plur, type, str);
-}
 
-#undef _SET_CON_
index bd9c44053613f2a6b7f5c6c5ec7742879468e176..64b8ccc3aa39e29c3f52e5ff28509e4ec9b81f96 100644 (file)
@@ -9,6 +9,7 @@
     copyright    : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
                    (C) 2001 The KDE-EDU team
                    (C) 2005, 2007 Peter Hedlund <peter.hedlund@kdemail.net>
+                   (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
 
     -----------------------------------------------------------------------
 
@@ -30,9 +31,9 @@
 
 #include <QtCore/QStringList>
 
-#define CONJ_PREFIX            "--"   // definition of prefixes (I, you, ..)
-
-#define UL_USER_TENSE          "#"   // designates number of user tense
+// #define CONJ_PREFIX            "--"   // definition of prefixes (I, you, ..)
+//
+// #define UL_USER_TENSE          "#"   // designates number of user tense
 
 /**
  * Class representing the articles of a language
@@ -47,8 +48,8 @@ public:
    * The constructor without arguments
    */
   explicit KEduVocArticle();
-  
-  /** copy constructor for d-pointer safety 
+
+  /** copy constructor for d-pointer safety
    * @param other article object to copy
    */
   KEduVocArticle(const KEduVocArticle &other);
@@ -68,7 +69,7 @@ public:
    * default destructor, deletes the d pointer
    */
   ~KEduVocArticle();
-  
+
   /**
    * Sets the female articles
    * @param def const reference to a QString with the definite female article
@@ -101,13 +102,13 @@ public:
    * @param indef pointer to the indefinite form
    */
   void getMale   (QString *def, QString *indef) const;
-  
+
   /** get the neutral articles
    * @param def pointer to the definite form
    * @param indef pointer to the indefinite form
    */
   void getNatural(QString *def, QString *indef) const;
-  
+
   /**
    * assignment operator for d-pointer copying
    */
@@ -127,8 +128,8 @@ public:
    * The constructor without arguments
    */
   explicit KEduVocComparison();
-  
-  /** copy constructor 
+
+  /** copy constructor
    * @param other comparison object to copy
    */
   KEduVocComparison(const KEduVocComparison &other);
@@ -143,7 +144,7 @@ public:
 
   /** default destructor, deletes the d-pointer */
   ~KEduVocComparison();
-  
+
   /** set the first comparison
    @param s value to set
    */
@@ -178,7 +179,7 @@ public:
    * @returns true if empty, false otherwise
    */
   bool isEmpty() const;
-  
+
   /** clear the comparison */
   void clear();
 
@@ -200,105 +201,4 @@ private:
 };
 
 
-class KEDUVOCDOCUMENT_EXPORT KEduVocTenseRelation
-{
-public:
-  /** default constructor */
-  KEduVocTenseRelation();
-  KEduVocTenseRelation (const QString & _short, const QString & _long);
-  
-  /** default destructor, deletes the d-pointer */
-  ~KEduVocTenseRelation();
-
-  QString shortStr() const;
-  QString longStr()  const;
-
-  KEduVocTenseRelation &operator=(const KEduVocTenseRelation &other);
-
-private:
-  class Private;
-  Private * const d;
-};
-
-/**
- * The conjugation of a verb
- */
-class KEDUVOCDOCUMENT_EXPORT KEduVocConjugation
-{
-public:
-
-  /**
-   * The constructor
-   */
-  explicit KEduVocConjugation();
-
-  KEduVocConjugation(const KEduVocConjugation& rhs);
-
-  ~KEduVocConjugation();
-
-  /**
-   * @return
-   */
-  int entryCount() const;
-
-  /**
-   * @return 
-   */
-  static QList<KEduVocTenseRelation> getRelation();
-
-  /**
-   * @param names
-   */
-  static void setTenseNames(const QStringList& names);
-
-  static QString getName(const QString &abbrev);
-  static QString getName(int index);
-  static QString getAbbrev(const QString &name);
-  static QString getAbbrev(int index);
-  static int numInternalNames();
-  static int tenseCount();
-
-  QString getVerbName() const;
-
-  QString getType(int index);
-  void setType(int index, const QString & type);
-  void cleanUp();
-  bool isEmpty(int idx);
-
-  QString pers1Singular(const QString &type) const;
-  QString pers2Singular(const QString &type) const;
-  bool    pers3SingularCommon(const QString &type) const;
-  QString pers3FemaleSingular(const QString &type) const;
-  QString pers3MaleSingular(const QString &type) const;
-  QString pers3NaturalSingular(const QString &type) const;
-
-  QString pers1Plural(const QString &type) const;
-  QString pers2Plural(const QString &type) const;
-  bool    pers3PluralCommon(const QString &type) const;
-  QString pers3FemalePlural(const QString &type) const;
-  QString pers3MalePlural(const QString &type) const;
-  QString pers3NaturalPlural(const QString &type) const;
-
-  void setPers1Singular(const QString &type, const QString &str);
-  void setPers2Singular(const QString &type, const QString &str);
-  void setPers3SingularCommon(const QString &type, bool f);
-  void setPers3FemaleSingular(const QString &type, const QString &str);
-  void setPers3MaleSingular(const QString &type, const QString &str);
-  void setPers3NaturalSingular(const QString &type, const QString &str);
-
-  void setPers1Plural(const QString &type, const QString &str);
-  void setPers2Plural(const QString &type, const QString &str);
-  void setPers3PluralCommon(const QString &type, bool f);
-  void setPers3FemalePlural(const QString &type, const QString &str);
-  void setPers3MalePlural(const QString &type, const QString &str);
-  void setPers3NaturalPlural(const QString &type, const QString &str);
-
-  KEduVocConjugation& operator = (const KEduVocConjugation& a);
-  bool operator == (const KEduVocConjugation& a) const;
-
-private:
-  class Private;
-  Private* const d;
-};
-
 #endif // KEDUVOCGRAMMAR_H
index 830402254411bddd65b6ebd993cfa489a5adccef..25a0ba948a3b93c308cd43d24de0466642a12edf 100644 (file)
@@ -25,6 +25,7 @@
 #include <QtCore/QFile>
 
 #include "keduvocgrammar.h"
+#include "keduvocconjugation.h"
 #include "keduvocmultiplechoice.h"
 #include "keduvockvtmlcompability.h"
 
index 921ee7d54adbcb8ad534f7d8304d0a76936de259..d4c6b400084f9758705ed770b6ca94fac395c478 100644 (file)
@@ -22,6 +22,7 @@
 #include <QtCore/QString>
 
 #include "keduvocgrammar.h"
+#include "keduvocconjugation.h"
 #include "keduvocmultiplechoice.h"
 
 class KEduVocGrade;
@@ -56,7 +57,7 @@ public:
      * @return the translation
      */
     QString text () const;
-       
+
     /**
      * Sets the translation
      * @param expr