]> Git trees. - libqmvoc.git/commitdiff
Fix: delete of entries that had a wort type associated would kill the whole show.
authorFrederik Gladhorn <gladhorn@kde.org>
Sat, 17 May 2008 11:44:10 +0000 (11:44 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Sat, 17 May 2008 11:44:10 +0000 (11:44 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=808709

keduvocdocument/keduvocexpression.cpp
keduvocdocument/keduvocwordtype.cpp

index 466c0b9711db304f765f404d239a275a0efafc36..e606b53d4f42a06906298ddf65f77eb9156954d1 100644 (file)
@@ -93,10 +93,8 @@ KEduVocExpression::KEduVocExpression( const QStringList & translations)
 KEduVocExpression::KEduVocExpression(const KEduVocExpression & other)
     : d(new KEduVocExpressionPrivate(*other.d))
 {
-    kDebug() << "Expression copy constructor";
     foreach (int key, other.d->m_translations.keys()) {
         d->m_translations[key] = new KEduVocTranslation(*other.d->m_translations.value(key));
-        kDebug() << "copy translation: " << other.d->m_translations.value(key)->text();
         d->m_translations[key]->setEntry(this);
     }
 }
@@ -118,7 +116,6 @@ KEduVocExpression::~KEduVocExpression()
     delete d;
 }
 
-
 void KEduVocExpression::removeTranslation( int index )
 {
     delete d->m_translations.take(index);
@@ -183,7 +180,7 @@ bool KEduVocExpression::operator== ( const KEduVocExpression &expression ) const
 
 KEduVocTranslation* KEduVocExpression::translation( int index )
 {
-    if(d->m_translations.contains(index)) {
+    if(translationIndices().contains(index)) {
         return d->m_translations[index];
     }
     d->m_translations[index] = new KEduVocTranslation(this);
index da45c6d5abfdfa3f0b23cdefb221c7611db178df..e84241ce619cf0583fe60bd80a121c8b596c3943 100644 (file)
@@ -83,7 +83,17 @@ void KEduVocWordType::addTranslation(KEduVocTranslation* translation)
 
 void KEduVocWordType::removeTranslation(KEduVocTranslation* translation)
 {
-    d->m_translations.removeAt( d->m_translations.indexOf(translation));
+kDebug() << "Remove Translation from wt";
+
+    d->m_translations.removeAt( d->m_translations.indexOf(translation) );
+
+    // no lesson found - this entry is being deleted. remove all its siblings.
+    if (!translation->entry()->lesson()) {
+        int index = d->m_expressions.indexOf(translation->entry());
+        if (index != -1) {
+            d->m_expressions.removeAt(index);
+        }
+    }
 
     // remove from cache
     bool found = false;