LibKEduVocDocument

keduvoccontainer.h
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#ifndef KEDUVOCCONTAINER_H
8#define KEDUVOCCONTAINER_H
9
10#include "keduvocdocument_export.h"
11
12#include "keduvoctext.h"
13
14#include <QList>
15#include <QUrl>
16
17class KEduVocDocument;
19
20/** class to store information about a container - that can be a lesson or word types */
21class KEDUVOCDOCUMENT_EXPORT KEduVocContainer
22{
23 // make this a template?
24
25public:
26 enum EnumContainerType {
27 Container,
28 Lesson,
29 WordType,
30 Leitner,
31 };
32
33 enum EnumEntriesRecursive {
34 NotRecursive = 0,
35 Recursive = 1,
36 };
37
38 /** default constructor */
39 explicit KEduVocContainer(const QString &name, EnumContainerType type, KEduVocContainer *parent = nullptr);
40
41 void appendChildContainer(KEduVocContainer *child);
42 void insertChildContainer(int row, KEduVocContainer *child);
43 void deleteChildContainer(int row);
44 void removeChildContainer(int row);
45 KEduVocContainer *childContainer(int row);
46
47 /**
48 * Retrieve a child container by its name
49 * Returns 0 if no container is found
50 * @param name container name
51 * @return the child container
52 */
53 KEduVocContainer *childContainer(const QString &name);
54
55 QList<KEduVocContainer *> childContainers();
56
57 /**
58 * Find a child container
59 * @param name
60 * @return
61 */
62 // KEduVocContainer *childContainer(const QString& name);
63
64 int childContainerCount() const;
65
66 int row() const;
67 virtual KEduVocContainer *parent();
68
69 /** copy constructor for d-pointer safe copying */
71
72 /** destructor */
73 virtual ~KEduVocContainer();
74
75 /** assignment operator */
76 KEduVocContainer &operator=(const KEduVocContainer &);
77
78 /** @return the containing KEduVocDocument */
79 KEduVocDocument *document() const;
80
81 /** set the container name
82 * @param name text to set for the name
83 */
84 void setName(const QString &name);
85
86 /** get the container name */
87 QString name();
88
89 /** get a list of all entries in the container */
90 virtual QList<KEduVocExpression *> entries(EnumEntriesRecursive recursive = NotRecursive) = 0;
91 virtual int entryCount(EnumEntriesRecursive recursive = NotRecursive) = 0;
92 virtual KEduVocExpression *entry(int row, EnumEntriesRecursive recursive = NotRecursive) = 0;
93
94 /**
95 * Removes a translation. This has to be called when a language is removed from a document.
96 * @param translation
97 */
98 void removeTranslation(int translation);
99
100 bool inPractice();
101 void setInPractice(bool inPractice);
102
103 /** equality operator */
104 bool operator==(const KEduVocContainer &other) const;
105
106 /**
107 * The type of this container. @see EnumContainerType
108 * @return
109 */
110 KEduVocContainer::EnumContainerType containerType();
111
112 /**
113 * Set the type of container.
114 * For convenience by default this is taken over from the parent, so no need to set.
115 * @param type the new type
116 */
117 void setContainerType(KEduVocContainer::EnumContainerType type);
118
119 /** get the image url for this container if it exists */
120 QUrl imageUrl();
121
122 /** set the image url for this container
123 * @param url url of the image
124 */
125 void setImageUrl(const QUrl &url);
126
127 double averageGrade(int translation, EnumEntriesRecursive recursive);
128
129 int expressionsOfGrade(int translation, grade_t grade, EnumEntriesRecursive recursive);
130
131 /**
132 * Remove grades from all entries of this lessons
133 * @param translation which translation to remove. -1 for all.
134 * @param recursive whether to include child lessons
135 */
136 void resetGrades(int translation, EnumEntriesRecursive recursive);
137
138protected:
139 QList<KEduVocExpression *> entriesRecursive();
140
141 /**
142 * Set the child entry cache to invalid
143 */
144 void invalidateChildLessonEntries();
145
146 /**
147 * Recreate the cache of entries in this lesson's child lessons.
148 */
149 void updateChildLessonEntries();
150
151 // Used by KEduVocLesson when the Document creates the top level lesson.
152 explicit KEduVocContainer(const QString &name, EnumContainerType type, KEduVocDocument *document);
153
154private:
155 class Private;
156 Private *const d;
157};
158
159#endif
class to store information about a container - that can be a lesson or word types
virtual QList< KEduVocExpression * > entries(EnumEntriesRecursive recursive=NotRecursive)=0
get a list of all entries in the container
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.
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.