]> Git trees. - libqmvoc.git/commitdiff
When adding entries with a lesson set, add them to that lesson automatically.
authorFrederik Gladhorn <gladhorn@kde.org>
Fri, 14 Sep 2007 22:43:26 +0000 (22:43 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Fri, 14 Sep 2007 22:43:26 +0000 (22:43 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=712626

keduvocdocument/keduvocdocument.cpp
keduvocdocument/keduvoctranslation.cpp

index 03ba47c0790dbc60d124b063d6c348f46386d0ec..682225db1db138ff9c89c8b35e480dc312c5e7cf 100644 (file)
@@ -163,13 +163,16 @@ void KEduVocDocument::appendEntry( KEduVocExpression *expression )
 void KEduVocDocument::insertEntry( KEduVocExpression *expression, int index )
 {
     d->m_vocabulary.insert( index, *expression );
-    
+
     // now we need to go fix the entryids that are greater than index in the lessons
     for (int i = 0; i < d->m_lessons.size(); ++i)
     {
         d->m_lessons[i].incrementEntriesAbove(index);
     }
-    
+    // if the expression is added and the lesson already exists (not at doc loading time, but added later) make sure it ends up in the lesson as well.
+    if ( expression->lesson() > 0 && expression->lesson() < d->m_lessons.count() ) {
+        d->m_lessons[expression->lesson()].addEntry(index);
+    }
     setModified();
 }
 
@@ -624,12 +627,12 @@ void KEduVocDocument::removeEntry( int index )
     if ( index >= 0 && index < d->m_vocabulary.size() ) {
         d->m_vocabulary.removeAt( index );
     }
-    
+
     // now we need to go fix the entryids that are greater than index in the lessons
     for (int i = 0; i < d->m_lessons.size(); ++i)
     {
         d->m_lessons[i].decrementEntriesAbove(index);
-    }    
+    }
 }
 
 
index 413b6b55ceb5059b15c32a964502b15eec2d1b3a..2580c0ab74dc8464e306f848e28df766a13846a3 100644 (file)
@@ -375,7 +375,7 @@ QString KEduVocTranslation::imageUrl()
     return d->m_imageUrl;
 }
 
-/** set the image url for this translation 
+/** set the image url for this translation
  * @param url               url of the image
  */
 void KEduVocTranslation::setImageUrl(const QString &url)