Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit d29210ab authored by Inge Wallin's avatar Inge Wallin

Fix bug 341139: Version 1.1.1 doesn't save data if confidence levels had been removed from units

This is done by marking a document as changed if any confidence levels are
reset.  This in turn is made possible by storing a pointer to the document in
the top level lesson.
parent bc315695
add_subdirectory(tests)
#add_subdirectory(tests)
########### next target ###############
......
......@@ -16,6 +16,7 @@
#include "keduvoccontainer.h"
#include "keduvocdocument.h"
#include "keduvocexpression.h"
#include <KDebug>
......@@ -31,6 +32,11 @@ public:
QString m_name;
bool m_inPractice;
// The containing document. This is only set for the top lesson, so to
// get to the document, you need to follow the parent pointer to the top
// container.
KEduVocDocument *m_document;
// other lessons in the tree
KEduVocContainer *m_parentContainer;
QList < KEduVocContainer * > m_childContainers;
......@@ -49,6 +55,23 @@ KEduVocContainer::Private::~Private()
qDeleteAll(m_childContainers);
}
// This is a private constructor only used by KEduVocDocument when creating
// the top level lesson.
KEduVocContainer::KEduVocContainer(const QString& name, EnumContainerType type,
KEduVocDocument *document)
: d( new Private )
{
d->m_parentContainer = 0;
d->m_name = name;
d->m_inPractice = true;
d->m_type = type;
d->m_childLessonEntriesValid = false;
d->m_document = document;
}
KEduVocContainer::KEduVocContainer(const QString& name, EnumContainerType type, KEduVocContainer *parent)
: d( new Private )
{
......@@ -57,6 +80,8 @@ KEduVocContainer::KEduVocContainer(const QString& name, EnumContainerType type,
d->m_inPractice = true;
d->m_type = type;
d->m_childLessonEntriesValid = false;
d->m_document = 0;
}
KEduVocContainer::KEduVocContainer( const KEduVocContainer &other )
......@@ -74,6 +99,17 @@ KEduVocContainer::~KEduVocContainer()
delete d;
}
KEduVocDocument *KEduVocContainer::document() const
{
KEduVocContainer *cont = (KEduVocContainer *)this;
while (cont->d->m_parentContainer) {
cont = cont->d->m_parentContainer;
}
Q_ASSERT(cont->d->m_document);
return cont->d->m_document;
}
void KEduVocContainer::appendChildContainer(KEduVocContainer * child)
{
d->m_childContainers.append(child);
......@@ -280,4 +316,6 @@ void KEduVocContainer::resetGrades(int translation, EnumEntriesRecursive recursi
foreach (KEduVocExpression *entry, entries(recursive)) {
entry->resetGrades(translation);
}
document()->setModified(true);
}
......@@ -24,6 +24,7 @@
#include <KDE/KUrl>
#include <QtCore/QList>
class KEduVocDocument;
class KEduVocExpression;
/** class to store information about a container - that can be a lesson or word types */
......@@ -45,7 +46,8 @@ public:
};
/** default constructor */
explicit KEduVocContainer(const QString& name, EnumContainerType type, KEduVocContainer *parent = 0);
explicit KEduVocContainer(const QString& name, EnumContainerType type,
KEduVocContainer *parent = 0);
void appendChildContainer(KEduVocContainer *child);
void insertChildContainer(int row, KEduVocContainer *child);
......@@ -84,6 +86,9 @@ public:
/** assignment operator */
KEduVocContainer& operator= ( const KEduVocContainer& );
/** @return the containing KEduVocDocument */
KEduVocDocument *document() const;
/** set the container name
* @param name text to set for the name
*/
......@@ -155,6 +160,9 @@ protected:
*/
void updateChildLessonEntries();
// Used by KEduVocLesson when the Document creates the top level lesson.
explicit KEduVocContainer(const QString& name, EnumContainerType type,
KEduVocDocument *document);
private:
class Private;
Private * const d;
......
......@@ -130,7 +130,9 @@ KEduVocDocument::KEduVocDocumentPrivate::~KEduVocDocumentPrivate()
void KEduVocDocument::KEduVocDocumentPrivate::init()
{
delete m_lessonContainer;
m_lessonContainer = new KEduVocLesson(i18nc("The top level lesson which contains all other lessons of the document.", "Document Lesson"));
m_lessonContainer = new KEduVocLesson(i18nc("The top level lesson which contains all other lessons of the document.",
"Document Lesson"),
q);
m_lessonContainer->setContainerType(KEduVocLesson::Lesson);
delete m_wordTypeContainer;
m_wordTypeContainer = new KEduVocWordType(i18n( "Word types" ));
......@@ -186,7 +188,8 @@ KEduVocDocument::ErrorCode KEduVocDocument::KEduVocDocumentPrivate::initializeKA
KEduVocDocument::KEduVocDocument( QObject *parent )
: QObject( parent ), d( new KEduVocDocumentPrivate( this ) )
: QObject(parent)
, d(new KEduVocDocumentPrivate(this))
{
}
......
......@@ -34,6 +34,13 @@ KEduVocLesson::KEduVocLesson(const QString& name, KEduVocContainer *parent)
{
}
// Private constructor only used by KEduVocDocument when creating the top level lesson.
KEduVocLesson::KEduVocLesson(const QString& name, KEduVocDocument *document)
: KEduVocContainer(name, Lesson, document)
, d(new Private)
{
}
KEduVocLesson::KEduVocLesson( const KEduVocLesson &other )
: KEduVocContainer(other), d( new Private )
......@@ -48,6 +55,8 @@ KEduVocLesson::~KEduVocLesson()
delete d;
}
QList<KEduVocExpression*> KEduVocLesson::entries(EnumEntriesRecursive recursive)
{
if (recursive == Recursive) {
......
......@@ -74,6 +74,11 @@ public:
*/
void removeEntry(KEduVocExpression* entry);
private:
friend class KEduVocDocument;
// This constructor is used by KEduVocDocument when creating the top level lesson.
explicit KEduVocLesson(const QString& name, KEduVocDocument *document);
private:
class Private;
Private * const d;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment