LibKEduVocDocument

keduvocmultiplechoice.cpp
1/*
2 * manage multiple choice suggestions for queries
3 * SPDX-FileCopyrightText: 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
4 * SPDX-FileCopyrightText: 2005 Peter Hedlund <peter.hedlund@kdemail.net>
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#include "keduvocmultiplechoice.h"
9
10class KEduVocMultipleChoice::KEduVocMultipleChoicePrivate
11{
12public:
13 QStringList m_choices;
14};
15
16KEduVocMultipleChoice::KEduVocMultipleChoice()
17 : d(new KEduVocMultipleChoicePrivate)
18{
19}
20
21KEduVocMultipleChoice::KEduVocMultipleChoice(const KEduVocMultipleChoice &other)
22 : d(new KEduVocMultipleChoicePrivate)
23{
24 d->m_choices = other.choices();
25}
26
27KEduVocMultipleChoice::KEduVocMultipleChoice(const QStringList &choices)
28 : d(new KEduVocMultipleChoicePrivate)
29{
30 foreach (const QString &choice, choices) {
31 // use appendChoice to check for empty entries
32 appendChoice(choice);
33 }
34}
35
36KEduVocMultipleChoice::~KEduVocMultipleChoice()
37{
38 delete d;
39}
40
41KEduVocMultipleChoice &KEduVocMultipleChoice::operator=(const KEduVocMultipleChoice &other)
42{
43 d->m_choices = other.choices();
44 return *this;
45}
46
47QStringList KEduVocMultipleChoice::choices() const
48{
49 return d->m_choices;
50}
51
52bool KEduVocMultipleChoice::isEmpty() const
53{
54 return d->m_choices.isEmpty();
55}
56
57void KEduVocMultipleChoice::clear()
58{
59 d->m_choices.clear();
60}
61
62QString KEduVocMultipleChoice::choice(int index) const
63{
64 QString choice;
65 if (d->m_choices.size() > index) {
66 choice = d->m_choices[index];
67 }
68 return choice;
69}
70
71unsigned KEduVocMultipleChoice::size() const
72{
73 return d->m_choices.size();
74}
75
76bool KEduVocMultipleChoice::operator==(const KEduVocMultipleChoice &choice) const
77{
78 return d->m_choices == choice.choices();
79}
80
81void KEduVocMultipleChoice::appendChoice(const QString &s)
82{
83 if (!s.isEmpty()) {
84 d->m_choices.append(s);
85 }
86}
void append(QList< T > &&value)
void clear()
bool isEmpty() const const
qsizetype size() const const
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.