File indexing completed on 2022-10-04 13:56:35

0001 /*
0002  * SPDX-FileCopyrightText: 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
0003  * SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 #include "keduvocpersonalpronoun.h"
0006 #include "keduvoccommon_p.h"
0007 
0008 #include <QMap>
0009 
0010 class KEduVocPersonalPronoun::Private
0011 {
0012 public:
0013     Private();
0014 
0015     bool m_maleFemaleDifferent;
0016     bool m_neutralExists;
0017     bool m_dualExists;
0018     QMap<KEduVocWordFlags, QString> m_personalpronouns;
0019 };
0020 
0021 
0022 KEduVocPersonalPronoun::Private::Private()
0023 {
0024     m_maleFemaleDifferent = false;
0025     m_neutralExists = false;
0026     m_dualExists = false;
0027 }
0028 
0029 KEduVocPersonalPronoun::KEduVocPersonalPronoun()
0030         : d( new Private )
0031 {}
0032 
0033 
0034 KEduVocPersonalPronoun::KEduVocPersonalPronoun( const KEduVocPersonalPronoun& other )
0035         : d( new Private )
0036 {
0037     d->m_maleFemaleDifferent = other.d->m_maleFemaleDifferent;
0038     d->m_neutralExists = other.d->m_neutralExists;
0039     d->m_personalpronouns = other.d->m_personalpronouns;
0040     d->m_dualExists = other.d->m_dualExists;
0041 }
0042 
0043 
0044 KEduVocPersonalPronoun::~KEduVocPersonalPronoun()
0045 {
0046     delete d;
0047 }
0048 
0049 
0050 KEduVocPersonalPronoun& KEduVocPersonalPronoun::operator = ( const KEduVocPersonalPronoun& other )
0051 {
0052     d->m_maleFemaleDifferent = other.d->m_maleFemaleDifferent;
0053     d->m_neutralExists = other.d->m_neutralExists;
0054     d->m_personalpronouns = other.d->m_personalpronouns;
0055     d->m_dualExists = other.d->m_dualExists;
0056     return *this;
0057 }
0058 
0059 
0060 bool KEduVocPersonalPronoun::operator ==(const KEduVocPersonalPronoun& other) const
0061 {
0062     return d->m_personalpronouns == other.d->m_personalpronouns &&
0063         d->m_maleFemaleDifferent == other.d->m_maleFemaleDifferent &&
0064         d->m_neutralExists == other.d->m_neutralExists &&
0065         d->m_dualExists == other.d->m_dualExists;
0066 }
0067 
0068 
0069 QString KEduVocPersonalPronoun::personalPronoun(KEduVocWordFlags flags) const
0070 {
0071         QString p = d->m_personalpronouns.value(flags & (KEduVocWordFlag::persons | KEduVocWordFlag::numbers| KEduVocWordFlag::genders));
0072         if (p.isEmpty() && !(flags & KEduVocWordFlag::genders) && d->m_maleFemaleDifferent && d->m_neutralExists)
0073         {
0074            //initial flag lookup failed, adding neuter gender flag
0075            flags |= KEduVocWordFlag::Neuter;
0076            p = d->m_personalpronouns.value(flags & (KEduVocWordFlag::persons | KEduVocWordFlag::numbers| KEduVocWordFlag::genders));
0077         }
0078         return p;
0079 }
0080 
0081 void KEduVocPersonalPronoun::setPersonalPronoun(const QString & personalpronoun, KEduVocWordFlags flags)
0082 {
0083         d->m_personalpronouns[flags & (KEduVocWordFlag::persons | KEduVocWordFlag::numbers| KEduVocWordFlag::genders)] = personalpronoun;
0084 }
0085 
0086 
0087 bool KEduVocPersonalPronoun::maleFemaleDifferent() const
0088 {
0089     return d->m_maleFemaleDifferent;
0090 }
0091 
0092 void KEduVocPersonalPronoun::setMaleFemaleDifferent(bool different)
0093 {
0094     d->m_maleFemaleDifferent = different;
0095 }
0096 
0097 bool KEduVocPersonalPronoun::neutralExists() const
0098 {
0099     return d->m_neutralExists;
0100 }
0101 
0102 void KEduVocPersonalPronoun::setNeutralExists(bool exists)
0103 {
0104     d->m_neutralExists = exists;
0105 }
0106 
0107 bool KEduVocPersonalPronoun::dualExists() const
0108 {
0109     return d->m_dualExists;
0110 }
0111 
0112 void KEduVocPersonalPronoun::setDualExists(bool exists)
0113 {
0114     d->m_dualExists = exists;
0115 }
0116