LibKEduVocDocument

keduvoclesson.cpp
1/*
2 * SPDX-FileCopyrightText: 2007 Jeremy Whiting <jpwhiting@kde.org>
3 * SPDX-FileCopyrightText: 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#include "keduvoclesson.h"
8
9#include "keduvocexpression.h"
10
11#include <QList>
12
13/** private class to store information about a lesson */
14class KEduVocLesson::Private
15{
16public:
17 // entries
19};
20
22 : KEduVocContainer(name, Lesson, parent)
23 , d(new Private)
24{
25}
26
27// Private constructor only used by KEduVocDocument when creating the top level lesson.
29 : KEduVocContainer(name, Lesson, document)
30 , d(new Private)
31{
32}
33
35 : KEduVocContainer(other)
36 , d(new Private)
37{
38 d->m_entries = other.d->m_entries;
39}
40
42{
43 qDeleteAll(d->m_entries);
44 delete d;
45}
46
48{
49 if (recursive == Recursive) {
50 return entriesRecursive();
51 }
52 return d->m_entries;
53}
54
55int KEduVocLesson::entryCount(EnumEntriesRecursive recursive)
56{
57 if (recursive == Recursive) {
58 return entriesRecursive().count();
59 }
60 return d->m_entries.count();
61}
62
64{
65 insertEntry(d->m_entries.size(), entry);
66}
67
69{
70 Q_ASSERT(entry);
71 d->m_entries.insert(index, entry);
72 entry->setLesson(this);
74}
75
77{
78 Q_ASSERT(entry);
79 if (d->m_entries.indexOf(entry) == -1) {
80 // attempting to remove entry from lesson that does not contain it!
81 return;
82 }
83 d->m_entries.removeAt(d->m_entries.indexOf(entry));
85}
86
87KEduVocExpression *KEduVocLesson::entry(int row, EnumEntriesRecursive recursive)
88{
89 if (recursive == Recursive) {
90 return entriesRecursive().value(row);
91 }
92 return d->m_entries.value(row);
93}
class to store information about a container - that can be a lesson or word types
void invalidateChildLessonEntries()
Set the child entry cache to invalid.
The primary entry point to the hierarchy of objects describing vocabularies.
This class contains one vocabulary expression as an original with one or more translations.
class to store information about a lesson
int entryCount(EnumEntriesRecursive recursive=NotRecursive) override
get the number of entries in the lesson
void insertEntry(int index, KEduVocExpression *entry)
insert an entry at a specific position
KEduVocLesson(const QString &name, KEduVocContainer *parent=nullptr)
default constructor
void removeEntry(KEduVocExpression *entry)
remove an entry from the lesson
QList< KEduVocExpression * > entries(EnumEntriesRecursive recursive=NotRecursive) override
get a list of all entries in the lesson
~KEduVocLesson() override
destructor
void appendEntry(KEduVocExpression *entry)
append an entry to the lesson
qsizetype count() const const
qsizetype indexOf(const AT &value, qsizetype from) const const
iterator insert(const_iterator before, parameter_type value)
void removeAt(qsizetype i)
qsizetype size() const const
T value(qsizetype i) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.