return d->m_lessonDescriptions.count();
}
+bool KEduVocDocument::deleteLesson(int lessonIndex, int deleteMode)
+{ // too bad we count from one!
+ lessonIndex++;
+ for (int ent = 0; ent < entryCount(); ent++) {
+ if (entry(ent)->lesson() == lessonIndex) {
+ if (deleteMode == DeleteEmptyLesson)
+ return false; // stop if there are vocabs left in the lesson
+ if (deleteMode == DeleteEntriesAndLesson)
+ // delete entries of this lesson with this lesson
+ removeEntry(ent);
+ }
+ }//for entries
+
+ // for all above this lesson number - reduce lesson by one.
+ for (int ent = 0; ent < entryCount(); ent++) {
+ if (entry(ent)->lesson() > lessonIndex) {
+ entry(ent)->setLesson(entry(ent)->lesson()-1);
+ }
+ } // reduce lesson
+
+ // finally just remove the lesson name
+ d->m_lessonDescriptions.removeAt(lessonIndex-1); // because of the damned 0 arghh
+ return true;
+}
+
void KEduVocDocument::setLessonDescriptions(const QStringList &names)
{
* @returns the number of lessons defined
*/
int lessonCount() const;
+ /**
+ * Delete a lesson.
+ * @param lessonIndex which lesson
+ * @param deleteMode either KVocDocument::DeleteEmptyLesson (delete only if empty) or KVocDocument::DeleteEntriesAndLesson (delete including vocabulary in that lesson)
+ * @returns if the deletion was successfull. If there are vocabularies in the lesson, but DeleteEmptyLesson, this will return false and not delete the lesson.
+ */
+ bool deleteLesson(int lessonIndex, int deleteMode);
/**
* Sets the description of the lesson
Writing
};
+ enum LessonDeletion {
+ DeleteEmptyLesson,
+ DeleteEntriesAndLesson
+ };
+
/**
* Create a string with the supported document types, that can be used
* as filter in KFileDialog. It includes also an entry to match all the
void docModified (bool mod);
private:
+ // The private data of this - see KEduVocDocument::Private, implemented in keduvocdocument.cpp
class Private;
Private* const d;