LibKEduVocDocument

keduvocarticle.cpp
1/*
2 * SPDX-FileCopyrightText: 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
3 * SPDX-FileCopyrightText: 2004, 2005, 2007 Peter Hedlund <peter.hedlund@kdemail.net>
4 * SPDX-FileCopyrightText: 2007-2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#include "keduvocarticle.h"
9
10#include <QMap>
11
12class KEduVocArticle::Private
13{
14public:
16};
17
19 : d(new Private)
20{
21}
22
24 : d(new Private)
25{
26 d->m_articles = other.d->m_articles;
27}
28
30{
31 d->m_articles = other.d->m_articles;
32 return *this;
33}
34
36 const QString &fem_indef,
37 const QString &mal_def,
38 const QString &mal_indef,
39 const QString &neu_def,
40 const QString &neu_indef)
41 : d(new Private)
42{
43 setArticle(mal_def, KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Masculine);
44 setArticle(fem_def, KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Feminine);
45 setArticle(neu_def, KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Neuter);
46
47 setArticle(mal_indef, KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Masculine);
48 setArticle(fem_indef, KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Feminine);
49 setArticle(neu_indef, KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Neuter);
50}
51
53{
54 delete d;
55}
56
57QString KEduVocArticle::article(KEduVocWordFlags flags)
58{
59 return d->m_articles.value(flags & (KEduVocWordFlag::genders | KEduVocWordFlag::numbers | KEduVocWordFlag::Definite | KEduVocWordFlag::Indefinite));
60}
61
62void KEduVocArticle::setArticle(const QString &article, KEduVocWordFlags flags)
63{
64 d->m_articles[flags & (KEduVocWordFlag::genders | KEduVocWordFlag::numbers | KEduVocWordFlag::Definite | KEduVocWordFlag::Indefinite)] = article;
65}
66
67bool KEduVocArticle::isArticle(const QString &article) const
68{
69 return d->m_articles.values().contains(article);
70}
71
72bool KEduVocArticle::isEmpty()
73{
74 // we don't count empty strings as articles
75 foreach (const QString &s, d->m_articles) {
76 if (!s.isEmpty())
77 return false;
78 }
79 return true;
80}
Class representing the articles of a language.
KEduVocArticle & operator=(const KEduVocArticle &other)
assignment operator for d-pointer copying
KEduVocArticle()
The constructor without arguments.
~KEduVocArticle()
default destructor, deletes the d pointer
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:06:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.