From 89cab5f2f09c5253d3bc31e08810d439f2d527e2 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 15 Aug 2008 12:22:19 +0000 Subject: [PATCH] prepare keduvocidentifier to contain the tenses svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=847457 --- keduvocdocument/keduvocidentifier.cpp | 48 +++++++++++++-------------- keduvocdocument/keduvocidentifier.h | 31 +++++++++-------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/keduvocdocument/keduvocidentifier.cpp b/keduvocdocument/keduvocidentifier.cpp index 7339b52..4df78fc 100644 --- a/keduvocdocument/keduvocidentifier.cpp +++ b/keduvocdocument/keduvocidentifier.cpp @@ -1,15 +1,5 @@ /*************************************************************************** - - C++ Implementation: keduvocidentifier - - ----------------------------------------------------------------------- - - begin : Mi Aug 29 2007 - - copyright : (C) 2007 Frederik Gladhorn - - ----------------------------------------------------------------------- - + Copyright 2007-2008 Frederik Gladhorn ***************************************************************************/ /*************************************************************************** @@ -42,20 +32,16 @@ public: QString m_type; /** I, you, he, she, it... */ - KEduVocPersonalPronoun m_personalPronouns; + KEduVocPersonalPronoun m_personalPronouns; /** the for english ;) der, die, das ... in german */ - KEduVocArticle m_articles; + KEduVocArticle m_articles; /** Future, present and past... and many more */ - QSet < QString > m_tenses; - - /** Size hint for the width of this column - has to go somewere. Here at least we have the headers... */ - int m_sizeHint; + QStringList m_tenses; }; - KEduVocIdentifier::KEduVocIdentifier() : d( new Private ) { @@ -63,13 +49,11 @@ KEduVocIdentifier::KEduVocIdentifier() d->m_locale = "en"; } - KEduVocIdentifier::~KEduVocIdentifier() { delete d; } - KEduVocIdentifier::KEduVocIdentifier( const KEduVocIdentifier &other ) : d( new Private ) { @@ -78,22 +62,22 @@ KEduVocIdentifier::KEduVocIdentifier( const KEduVocIdentifier &other ) d->m_articles = other.d->m_articles; d->m_personalPronouns = other.d->m_personalPronouns; d->m_comment = other.d->m_comment; - d->m_sizeHint = other.d->m_sizeHint; d->m_tenses = other.d->m_tenses; d->m_type = other.d->m_type; } - KEduVocIdentifier& KEduVocIdentifier::operator= ( const KEduVocIdentifier &other ) { d->m_locale = other.d->m_locale; d->m_name = other.d->m_name; d->m_articles = other.d->m_articles; d->m_personalPronouns = other.d->m_personalPronouns; + d->m_comment = other.d->m_comment; + d->m_tenses = other.d->m_tenses; + d->m_type = other.d->m_type; return *this; } - QString KEduVocIdentifier::name() const { return d->m_name; @@ -114,7 +98,6 @@ void KEduVocIdentifier::setLocale(const QString & locale) d->m_locale = locale; } - void KEduVocIdentifier::setArticle( const KEduVocArticle& articles ) { d->m_articles = articles; @@ -134,3 +117,20 @@ void KEduVocIdentifier::setPersonalPronouns( const KEduVocPersonalPronoun & pron { d->m_personalPronouns = pronouns; } + +const QString& KEduVocIdentifier::tense(int tenseIndex) const +{ + Q_ASSERT(d->m_tenses.size() > tenseIndex); + return d->m_tenses.value(tenseIndex); +} + +void KEduVocIdentifier::setTense(int tenseIndex, const QString& tense) +{ + Q_ASSERT(d->m_tenses.size() >= tenseIndex); + if (tenseIndex == d->m_tenses.size()) { + d->m_tenses.append(tense); + } else { + d->m_tenses[tenseIndex] = tense; + } +} + diff --git a/keduvocdocument/keduvocidentifier.h b/keduvocdocument/keduvocidentifier.h index eef95df..1212d2d 100644 --- a/keduvocdocument/keduvocidentifier.h +++ b/keduvocdocument/keduvocidentifier.h @@ -1,15 +1,5 @@ /*************************************************************************** - - C++ Interface: keduvocidentifier - - ----------------------------------------------------------------------- - - begin : Mi Aug 29 2007 - - copyright : (C) 2007 Frederik Gladhorn - - ----------------------------------------------------------------------- - + Copyright 2007-2008 Frederik Gladhorn ***************************************************************************/ /*************************************************************************** @@ -35,8 +25,6 @@ /** Class to store meta information about a language or any other category in the vocabulary. - - @author */ class KEDUVOCDOCUMENT_EXPORT KEduVocIdentifier { @@ -87,7 +75,6 @@ public: */ void setLocale( const QString& name ); - /** * Articles (a, the in English, el, la,... in Spanish) * @returns articles @@ -100,7 +87,6 @@ public: */ void setArticle( const KEduVocArticle& article ); - /** * Get the personal pronouns for this identifier * @returns a KEduVocPersonalPronoun containing the personal pronouns @@ -113,10 +99,23 @@ public: */ void setPersonalPronouns( const KEduVocPersonalPronoun &pronouns ); + /** + * Returns the name of tense number @p tenseIndex + * @param tenseIndex desired tense + * @return name of the tense + */ + const QString& tense(int tenseIndex) const; + + /** + * Sets the name of a tense for this language + * @param tenseIndex + * @param tense + */ + void setTense(int tenseIndex, const QString& tense); + private: class Private; Private * const d; - }; #endif -- 2.47.3