]> Git trees. - libqmvoc.git/commitdiff
allow set conjugation by int index. minor cleanup.
authorFrederik Gladhorn <gladhorn@kde.org>
Sun, 6 Jan 2008 19:07:28 +0000 (19:07 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Sun, 6 Jan 2008 19:07:28 +0000 (19:07 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=758023

keduvocdocument/keduvocconjugation.cpp
keduvocdocument/keduvocconjugation.h
keduvocdocument/keduvockvtmlcompability.cpp
keduvocdocument/keduvockvtmlreader.cpp

index d0181f708431d83debff21824e4fe9238b4e7386..0c145d81c5c73ff70a0dfcce7e3f850490bb2bc1 100644 (file)
@@ -82,13 +82,19 @@ QString KEduVocConjugation::conjugation(ConjugationPerson person, ConjugationNum
 }
 
 void KEduVocConjugation::setConjugation(const QString & conjugation, ConjugationPerson person, ConjugationNumber number)
+{
+    setConjugation(conjugation, indexOf(person, number));
+}
+
+
+void KEduVocConjugation::setConjugation(const QString & conjugation, int index)
 {
     if ( !conjugation.isEmpty() ) {
-        d->m_conjugations[indexOf(person, number)] = conjugation;
+        d->m_conjugations[index] = conjugation;
     } else {
         // if we received an empty string, remove the element.
-        if ( d->m_conjugations.contains(indexOf(person, number)) ) {
-            d->m_conjugations.remove(indexOf(person, number));
+        if ( d->m_conjugations.contains(index) ) {
+            d->m_conjugations.remove(index);
         }
     }
 }
@@ -116,3 +122,5 @@ QList< int > KEduVocConjugation::keys()
     return d->m_conjugations.keys();
 }
 
+
+
index d93c5d88e70e58805da50437c3970a6f99342c1f..69726aa7abeb20e90aa27bade97c72f5b28522e8 100644 (file)
@@ -70,6 +70,7 @@ public:
     QString conjugation(ConjugationPerson person, ConjugationNumber number) const;
     QString conjugation(int index) const;
     void setConjugation(const QString& conjugation, ConjugationPerson person, ConjugationNumber number);
+    void setConjugation(const QString& conjugation, int index);
 
     QList<int> keys();
 
index 4f5f679834f3d108cbd165cc772e059e6b27096b..54dd549b30a22e3d49da0ac8366b062495c6cc41 100644 (file)
@@ -198,7 +198,7 @@ QString KEduVocKvtmlCompability::tenseFromKvtml1(const QString & oldTense)
     // in case the document got chaged, at least make up something as tense
     if (!m_oldTenses.keys().contains(oldTense)) {
         m_oldTenses[oldTense] = oldTense;
-        kDebug() << "Warning, tense not found in document!";
+        kDebug() << "Warning, tense " << oldTense << " not found in document!";
     }
     m_tenses.insert(m_oldTenses.value(oldTense));
     return m_oldTenses.value(oldTense);
index 00fa72634849b4e24406d2b6b3b8cb26363938e0..ffeffc2476c44745d3f2e7cad47c6d87535ea194 100644 (file)
@@ -637,17 +637,12 @@ bool KEduVocKvtmlReader::readTense( QDomElement &domElementParent )
 {
     QDomElement currentElement;
 
-    QDomNodeList entryList = domElementParent.elementsByTagName( KV_TENSE_DESC );
-    if ( entryList.length() <= 0 )
-        return false;
-
-    for ( int i = 0; i < entryList.count(); ++i ) {
-        currentElement = entryList.item( i ).toElement();
-        if ( currentElement.parentNode() == domElementParent ) {
-            m_compability.addUserdefinedTense( currentElement.text() );
-        }
+    currentElement = domElementParent.firstChildElement( KV_TENSE_DESC );
+    while ( !currentElement.isNull() ) {
+        kDebug() << "Reading user defined tense description: " << currentElement.text();
+        m_compability.addUserdefinedTense( currentElement.text() );
+        currentElement = currentElement.nextSiblingElement( KV_TENSE_DESC );
     }
-
     return true;
 }