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

libkdeedu/keduvocdocument

keduvocexpression.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                         Vocabulary Expression for KDE Edu
00003     -----------------------------------------------------------------------
00004     copyright      : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
00005 
00006                      (C) 2005-2007 Peter Hedlund <peter.hedlund@kdemail.net>
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 #include "keduvocexpression.h"
00020 
00021 #include <KDebug>
00022 
00023 
00024 class KEduVocExpression::KEduVocExpressionPrivate
00025 {
00026 public:
00027     KEduVocExpressionPrivate( KEduVocExpression* qq )
00028             : q( qq )
00029     {
00030         init();
00031     }
00032 
00033     void init();
00034 
00035     bool operator== ( const KEduVocExpressionPrivate &p ) const;
00036 
00037     KEduVocExpression* q;
00038 
00039     int m_sortIndex;
00040     int m_lesson;
00041     bool m_active;
00042     int m_sizeHint;
00043 
00044     QMap <int, KEduVocTranslation> m_translations;
00045 };
00046 
00047 
00048 void KEduVocExpression::KEduVocExpressionPrivate::init()
00049 {
00050     m_translations.clear();
00051     m_active = true;
00052     m_lesson = -1;
00053     m_sortIndex = 0;
00054     m_sizeHint = 0;
00055 }
00056 
00057 
00058 bool KEduVocExpression::KEduVocExpressionPrivate::operator== ( const KEduVocExpression::KEduVocExpressionPrivate &p ) const
00059 {
00060     return
00061         m_translations == p.m_translations &&
00062         m_lesson == p.m_lesson &&
00063         m_sortIndex == p.m_sortIndex &&
00064         m_active == p.m_active;
00065 }
00066 
00067 
00068 KEduVocExpression::KEduVocExpression()
00069         : d( new KEduVocExpressionPrivate( this ) )
00070 {}
00071 
00072 KEduVocExpression::KEduVocExpression( const QString & expression, int lesson )
00073         : d( new KEduVocExpressionPrivate( this ) )
00074 {
00075     d->m_lesson = lesson;
00076     setTranslation( 0, expression.simplified() );
00077 }
00078 
00079 KEduVocExpression::KEduVocExpression( const QStringList & translations, int lesson )
00080         : d( new KEduVocExpressionPrivate( this ) )
00081 {
00082     d->m_lesson = lesson;
00083     foreach ( QString translation, translations ) {
00084         setTranslation(d->m_translations.count(), translation);
00085     }
00086 }
00087 
00088 KEduVocExpression::KEduVocExpression( const KEduVocExpression &expression )
00089         : d( new KEduVocExpressionPrivate( *expression.d ) )
00090 {}
00091 
00092 KEduVocExpression::~KEduVocExpression()
00093 {
00094     delete d;
00095 }
00096 
00097 
00098 void KEduVocExpression::removeTranslation( int index )
00099 {
00100     d->m_translations.remove( index );
00101 }
00102 
00103 
00104 void KEduVocExpression::setTranslation( int index, const QString & expr )
00105 {
00106     if ( index < 0 ) {
00107         return;
00108     }
00109 
00110     // if it exists already, only change the text, not the whole show!
00111     d->m_translations[index].setText(expr.simplified());
00112 }
00113 
00114 
00115 int KEduVocExpression::lesson() const
00116 {
00117     return d->m_lesson;
00118 }
00119 
00120 
00121 void KEduVocExpression::setLesson( int l )
00122 {
00123     d->m_lesson = l;
00124 }
00125 
00126 
00127 bool KEduVocExpression::isActive() const
00128 {
00129     return d->m_active;
00130 }
00131 
00132 
00133 void KEduVocExpression::setActive( bool flag )
00134 {
00135     d->m_active = flag;
00136 }
00137 
00138 int KEduVocExpression::sizeHint() const
00139 {
00140     return d->m_sizeHint;
00141 }
00142 
00143 void KEduVocExpression::setSizeHint( int sizeHint )
00144 {
00145     d->m_sizeHint = sizeHint;
00146 }
00147 
00148 void KEduVocExpression::resetGrades( int index )
00149 {
00150     if ( index == -1 ) { // clear grades for all languages
00151         foreach( int trans, d->m_translations.keys() ) {
00152             d->m_translations[trans].resetGrades();
00153         }
00154         return;
00155     }
00156 
00157     // only language index
00158     if ( d->m_translations.contains( index ) ) {
00159         d->m_translations[index].resetGrades();
00160     }
00161 }
00162 
00163 
00164 KEduVocExpression& KEduVocExpression::operator= ( const KEduVocExpression &expression )
00165 {
00166     *d = *expression.d;
00167     return *this;
00168 }
00169 
00170 
00171 bool KEduVocExpression::operator== ( const KEduVocExpression &expression ) const
00172 {
00173     return ( *d == *expression.d );
00174 }
00175 
00176 KEduVocTranslation& KEduVocExpression::translation( int index ) const
00177 {
00178     return d->m_translations[index];
00179 }
00180 
00181 QList< int > KEduVocExpression::translationIndices() const
00182 {
00183     return d->m_translations.keys();
00184 }
00185 

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