• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

libkdeedu/keduvocdocument

keduvocgrammar.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003              manage grammar parts (articles, conjugation)
00004 
00005     -----------------------------------------------------------------------
00006 
00007     begin     : Sat Nov 27 09:50:53 MET 1999
00008 
00009     copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
00010 
00011                 (C) 2004, 2005, 2007 Peter Hedlund <peter.hedlund@kdemail.net>
00012                 (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
00013 
00014     -----------------------------------------------------------------------
00015 
00016  ***************************************************************************/
00017 
00018 /***************************************************************************
00019  *                                                                         *
00020  *   This program is free software; you can redistribute it and/or modify  *
00021  *   it under the terms of the GNU General Public License as published by  *
00022  *   the Free Software Foundation; either version 2 of the License, or     *
00023  *   (at your option) any later version.                                   *
00024  *                                                                         *
00025  ***************************************************************************/
00026 
00027 #include "keduvocgrammar.h"
00028 
00029 #include <QtCore/QMap>
00030 #include <KDebug>
00031 
00032 class KEduVocComparison::Private
00033 {
00034 public:
00035     QString ls1;
00036     QString ls2;
00037     QString ls3;
00038 };
00039 
00040 KEduVocComparison::KEduVocComparison()
00041         : d( new Private )
00042 {}
00043 
00044 KEduVocComparison::KEduVocComparison( const KEduVocComparison &other )
00045         : d( new Private )
00046 {
00047     setL1( other.l1() );
00048     setL2( other.l2() );
00049     setL3( other.l3() );
00050 }
00051 
00052 KEduVocComparison::KEduVocComparison( const QString &l1, const QString &l2, const QString &l3 )
00053         : d( new Private )
00054 {
00055     setL1( l1 );
00056     setL2( l2 );
00057     setL3( l3 );
00058 }
00059 
00060 KEduVocComparison::~KEduVocComparison()
00061 {
00062     delete d;
00063 }
00064 
00065 KEduVocComparison &KEduVocComparison::operator= ( const KEduVocComparison& other )
00066 {
00067     setL1( other.l1() );
00068     setL2( other.l2() );
00069     setL3( other.l3() );
00070 
00071     return *this;
00072 }
00073 
00074 bool KEduVocComparison::isEmpty() const
00075 {
00076     return d->ls1.simplified().isEmpty() && d->ls2.simplified().isEmpty() && d->ls3.simplified().isEmpty();
00077 }
00078 
00079 
00080 void KEduVocComparison::clear()
00081 {
00082     d->ls1 = "";
00083     d->ls2 = "";
00084     d->ls3 = "";
00085 }
00086 
00087 bool KEduVocComparison::operator == ( const KEduVocComparison& a ) const
00088 {
00089     return ( d->ls1 == a.l1() && d->ls2 == a.l2() && d->ls3 == a.l3() );
00090 }
00091 
00092 void KEduVocComparison::setL1( const QString &s )
00093 {
00094     d->ls1 = s;
00095 }
00096 
00097 void KEduVocComparison::setL2( const QString &s )
00098 {
00099     d->ls2 = s;
00100 }
00101 
00102 void KEduVocComparison::setL3( const QString &s )
00103 {
00104     d->ls3 = s;
00105 }
00106 
00107 QString KEduVocComparison::l1() const
00108 {
00109     return d->ls1;
00110 }
00111 QString KEduVocComparison::l2() const
00112 {
00113     return d->ls2;
00114 }
00115 
00116 QString KEduVocComparison::l3() const
00117 {
00118     return d->ls3;
00119 }
00120 
00121 
00122 
00123 
00124 //=================================================================
00125 
00126 class KEduVocArticle::Private
00127 {
00128 public:
00129     QMap <int, QString>    m_articles;
00130 };
00131 
00132 KEduVocArticle::KEduVocArticle()
00133         :d( new Private )
00134 {}
00135 
00136 KEduVocArticle::KEduVocArticle( const KEduVocArticle &other )
00137         :d( new Private )
00138 {
00139     d->m_articles = other.d->m_articles;
00140 }
00141 
00142 KEduVocArticle &KEduVocArticle::operator= ( const KEduVocArticle& other )
00143 {
00144     d->m_articles = other.d->m_articles;
00145     return *this;
00146 }
00147 
00148 KEduVocArticle::KEduVocArticle( const QString &fem_def, const QString &fem_indef, const QString &mal_def, const QString &mal_indef, const QString &neu_def, const QString &neu_indef )
00149         :d( new Private )
00150 {
00151     setArticle( mal_def, Singular, Definite, Masculine );
00152     setArticle( fem_def, Singular, Definite, Feminine );
00153     setArticle( neu_def, Singular, Definite, Neutral );
00154 
00155     setArticle( mal_indef, Singular, Indefinite, Masculine );
00156     setArticle( fem_indef, Singular, Indefinite, Feminine );
00157     setArticle( neu_indef, Singular, Indefinite, Neutral );
00158 }
00159 
00160 KEduVocArticle::~KEduVocArticle()
00161 {
00162     delete d;
00163 }
00164 
00165 
00166 QString KEduVocArticle::article(ArticleNumber number, ArticleDefiniteness definite, ArticleGender gender)
00167 {
00168     if ( d->m_articles.contains( indexOf(number, definite, gender) ) ) {
00169         return d->m_articles.value( indexOf(number, definite, gender) );
00170     }
00171     return QString();
00172 }
00173 
00174 void KEduVocArticle::setArticle(const QString & article, ArticleNumber number, ArticleDefiniteness definite, ArticleGender gender)
00175 {
00176     kDebug() << article << "#" << number << "def" << definite << "indef"  << gender << "index" << indexOf(number, definite, gender);
00177     d->m_articles[indexOf(number, definite, gender)] = article;
00178 }
00179 
00180 int KEduVocArticle::indexOf(ArticleNumber number, ArticleDefiniteness definite, ArticleGender gender)
00181 {
00182     return number + (definite * NumberMAX) + (gender * NumberMAX * DefinitenessMAX);
00183 }
00184 
00185 bool KEduVocArticle::isArticle(const QString & article) const
00186 {
00187     return d->m_articles.values().contains(article);
00188 }
00189 
00190 bool KEduVocArticle::isEmpty()
00191 {
00192     return d->m_articles.isEmpty();
00193 }
00194 

libkdeedu/keduvocdocument

Skip menu "libkdeedu/keduvocdocument"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal