]> Git trees. - libqmvoc.git/commitdiff
Add appendLesson and renameLesson functions.
authorFrederik Gladhorn <gladhorn@kde.org>
Mon, 26 Mar 2007 23:17:23 +0000 (23:17 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Mon, 26 Mar 2007 23:17:23 +0000 (23:17 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=646956

kdeeducore/keduvocdocument.cpp
kdeeducore/keduvocdocument.h

index e4a08b6ff672eeaf0111e553fc8602f391cb29a4..2e862d73fe46e38f0a01adb16f27ee6957cf2b4a 100644 (file)
@@ -1053,12 +1053,25 @@ QString KEduVocDocument::lessonDescription(int idx) const
   return d->m_lessonDescriptions[idx-1];
 }
 
-int KEduVocDocument::lessonIndex(const QString description) const
+int KEduVocDocument::lessonIndex(const QString &description) const
 {
   return d->m_lessonDescriptions.indexOf(description) +1;
 }
 
 
+int KEduVocDocument::appendLesson(const QString &lessonName)
+{
+  d->m_lessonDescriptions.append(lessonName);
+  return d->m_lessonDescriptions.count(); // counting from 1
+}
+
+
+void KEduVocDocument::renameLesson(const int lessonIndex, const QString &lessonName)
+{
+  d->m_lessonDescriptions.replace(lessonIndex-1, lessonName); // counting from 1
+}
+
+
 bool KEduVocDocument::lessonInQuery(int lessonIndex) const
 {
   if (d->m_lessonsInQuery.contains(lessonIndex))
index c53ab37d528c99a6e7a67d5ed77e328e9446c6ac..ab1cf97b0dc6f52f868c35508180c31abd7d4028 100644 (file)
@@ -463,7 +463,24 @@ public:
    * @returns the index of the lesson (from its name)
    * -1 if the lesson does not exist
    */
-  int lessonIndex(const QString description) const;
+  int lessonIndex(const QString &description) const;
+
+
+  /**
+   * Append a new lesson to the list of lessons.
+   * @param lessonName name for the new lesson
+   * @returns the index of the new lesson
+   */
+  int appendLesson(const QString &lessonName);
+
+
+  /**
+   * Rename a lesson.
+   * @param lessonIndex index of lesson
+   * @param lessonName new name for the lesson
+   */
+  void renameLesson(const int lessonIndex, const QString &lessonName);
+
 
   /**
    * Get list of ALL lessons that are selected for query.
@@ -496,8 +513,8 @@ public:
   void removeLessonFromQuery(int lessonIndex);
 
 
-
   /**
+   * All lesson descriptions as stringlist.
    * @returns                a list of defined lessons
    */
   QStringList lessonDescriptions() const;