]> Git trees. - libqmvoc.git/commitdiff
Begin of a class KEduVocIdentifier.
authorFrederik Gladhorn <gladhorn@kde.org>
Thu, 30 Aug 2007 10:22:03 +0000 (10:22 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Thu, 30 Aug 2007 10:22:03 +0000 (10:22 +0000)
So far it only contains name and locale.
From now on:
 - locale = two letter language code, en, es, de,...
 - name = description of the contents - English, Spanish, Famous people, Definition, Muscle in latin,...

Next will be to move the articles and personal pronouns into the identifier class.
Eventually the tenses should be kept there as well.

Adapted all readers/writers.
Appending identifiers should always give sane default values.

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=706410

16 files changed:
keduvocdocument/CMakeLists.txt
keduvocdocument/keduvoccsvreader.cpp
keduvocdocument/keduvocdocument.cpp
keduvocdocument/keduvocdocument.h
keduvocdocument/keduvocidentifier.cpp [new file with mode: 0644]
keduvocdocument/keduvocidentifier.h [new file with mode: 0644]
keduvocdocument/keduvockvtml2reader.cpp
keduvocdocument/keduvockvtml2writer.cpp
keduvocdocument/keduvockvtmlreader.cpp
keduvocdocument/keduvockvtmlreader.h
keduvocdocument/keduvockvtmlwriter.cpp
keduvocdocument/keduvocpaukerreader.cpp
keduvocdocument/keduvocvokabelnreader.cpp
keduvocdocument/keduvocwqlreader.cpp
keduvocdocument/keduvocxdxfreader.cpp
keduvocdocument/sharedkvtmlfiles.cpp

index e7eb9ae94ae665cb394e478a3a1fa80d39353fd4..28bd198cc990bd2ee8d0c3f860668a6e78249af1 100644 (file)
@@ -6,6 +6,7 @@ set(keduvocdocument_LIB_SRCS
    keduvoccsvreader.cpp
    keduvoccsvwriter.cpp
    keduvocdocument.cpp
+   keduvocidentifier.cpp
    keduvocexpression.cpp
    keduvoctranslation.cpp
    keduvoclesson.cpp
@@ -47,6 +48,7 @@ install(TARGETS keduvocdocument  DESTINATION ${LIB_INSTALL_DIR} )
 install(FILES
    libkeduvocdocument_export.h
    keduvocdocument.h
+   keduvocidentifier.h
    keduvocexpression.h
    keduvocgrade.h
    keduvocgrammar.h
index 24b679de0e374c41b24733322e6e127808bfbd8b..d888b94d123a4c5a655b11cfaade8a420dc42ad5 100644 (file)
@@ -65,10 +65,9 @@ bool KEduVocCsvReader::readDoc( KEduVocDocument *doc )
     }
 
     for ( int j = 0; j < languageCount; j++ )
-        if ( j == 0 )
-            m_doc->appendIdentifier( i18nc( "@title:column the original language column", "Original" ) );
-        else
-            m_doc->appendIdentifier( i18nc( "@title:column one of the translation columns", "Translation %1", j ) );
+    {
+        m_doc->appendIdentifier();
+    }
 
     return true;
 }
index 7164db6bd880229b7600ac11506e1c639b0e724f..a6dc68b0c96dce7a63a5e2ab38723bee177735df 100644 (file)
@@ -70,7 +70,8 @@ public:
     bool                      m_sortLesson;
 
     // save these to document
-    QStringList               m_identifiers;      //0= origin, 1,.. translations
+    QList<KEduVocIdentifier>  m_identifiers;
+
     int                       m_currentLesson;
     QList<int>                m_extraSizeHints;
     QList<int>                m_sizeHints;
@@ -607,32 +608,29 @@ void KEduVocDocument::removeEntry( int index )
 }
 
 
-int KEduVocDocument::indexOfIdentifier( const QString &lang ) const
+int KEduVocDocument::indexOfIdentifier( const QString& name ) const
 {
-    QStringList::const_iterator first = d->m_identifiers.begin();
-    int count = 0;
-    while ( first != d->m_identifiers.end() ) {
-        if ( *first == lang )
-            return count;
-        first++;
-        count++;
+    for ( int i=0; i < d->m_identifiers.count(); i++ ) {
+        if ( d->m_identifiers.value(i).name() == name ) {
+            return i;
+        }
     }
     return -1;
 }
 
 
-QString KEduVocDocument::identifier( int index ) const
+KEduVocIdentifier& KEduVocDocument::identifier( int index )
 {
-    if ( index >= d->m_identifiers.size() || index < 0 )
-        return "";
-    else
-        return d->m_identifiers[index];
+    if ( index < 0 || index >= d->m_identifiers.size() ) {
+        kError() << "Invalid identifier index: " << index;
+    }
+    return d->m_identifiers[index];
 }
 
 
-void KEduVocDocument::setIdentifier( int idx, const QString &id )
+void KEduVocDocument::setIdentifier( int idx, const KEduVocIdentifier &id )
 {
-    if ( idx < d->m_identifiers.size() && idx >= 0 ) {
+    if ( idx >= 0 && idx < d->m_identifiers.size() ) {
         d->m_identifiers[idx] = id;
     }
 }
@@ -771,7 +769,7 @@ void KEduVocDocument::setSizeHint( int idx, const int width )
 
 void KEduVocDocument::removeIdentifier( int index )
 {
-    if ( index < d->m_identifiers.size() && index >= 1 ) {
+    if ( index < d->m_identifiers.size() && index >= 0 ) {
         d->m_identifiers.removeAt( index );
         for ( int i = 0; i < d->m_vocabulary.count(); i++ )
             d->m_vocabulary[i].removeTranslation( index );
@@ -863,12 +861,31 @@ int KEduVocDocument::identifierCount() const
     return d->m_identifiers.count();  // number of translations
 }
 
-int KEduVocDocument::appendIdentifier( const QString & id )
+int KEduVocDocument::appendIdentifier( const KEduVocIdentifier& id )
 {
+    int i = d->m_identifiers.size();
     d->m_identifiers.append( id );
-    return d->m_identifiers.size() - 1;
+    if ( id.name().isEmpty() ) {
+        if ( i == 0 ) {
+            identifier(i).setName(i18nc("The name of the first language/column of vocabulary, if we have to guess it.", "Original"));
+        } else {
+            identifier(i).setName(i18nc( "The name of the second, third ... language/column of vocabulary, if we have to guess it.", "Translation %1", i ) );
+        }
+    }
+
+    return i;
 }
 
+
+// int KEduVocDocument::appendIdentifier(const QString & name)
+// {
+//     KEduVocIdentifier identifier;
+//     identifier.setName(name);
+//     return appendIdentifier(identifier);
+// }
+
+
+
 //QString KEduVocDocument::lessonDescription(int idx) const
 //{
 //  if (idx == 0)
@@ -1352,6 +1369,4 @@ void KEduVocDocument::removeUsage( const QString &name )
 }
 
 
-
-
 #include "keduvocdocument.moc"
index 1dbcf94792df49eccefe4353dc5e1f3d1bb86682..74cd020bcb49551b1393edcee224d38f1ae3ef98 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "libkeduvocdocument_export.h"
 
+#include "keduvocidentifier.h"
 #include "keduvocgrammar.h"
 #include "keduvocconjugation.h"
 
@@ -229,10 +230,12 @@ public:
     /**
      * Appends a new identifier (usually a language)
      *
-     * @param id         the identifier to append
+     * @param name the identifier to append
      * @returns the identifier number
      */
-    int appendIdentifier( const QString & id );
+//     int appendIdentifier( const QString& name );
+
+    int appendIdentifier( const KEduVocIdentifier & identifier = KEduVocIdentifier());
 
     /**
      * Sets the identifier of translation
@@ -240,7 +243,7 @@ public:
      * @param index            number of translation 0..x
      * @param lang             thr language identifier: en=english, de=german, ...
      */
-    void setIdentifier( int index, const QString &lang );
+    void setIdentifier( int index, const KEduVocIdentifier& lang );
 
     /**
      * Returns the identifier of translation @p index
@@ -248,12 +251,13 @@ public:
      * @param index            number of translation 0..x
      * @returns                the language identifier: en=english, de=german, ...
      */
-    QString identifier( int index ) const;
+//     QString identifier( int index ) const;
+    KEduVocIdentifier& identifier( int index );
 
     /**
-     * Removes identifier an the according translation in all entries
+     * Removes identifier and the according translations in all entries
      *
-     * @param index            number of translation 1..x
+     * @param index            number of translation 0..x
      */
     void removeIdentifier( int index );
 
@@ -263,7 +267,7 @@ public:
      * @param lang             identifier of language
      * @returns                index of identifier, 0 = original, 1..n = translation, -1 = not found
      */
-    int indexOfIdentifier( const QString &lang ) const;
+    int indexOfIdentifier( const QString &name ) const;
 
     // *** type methods ***
 
diff --git a/keduvocdocument/keduvocidentifier.cpp b/keduvocdocument/keduvocidentifier.cpp
new file mode 100644 (file)
index 0000000..d1dd3d0
--- /dev/null
@@ -0,0 +1,111 @@
+/***************************************************************************
+
+    C++ Implementation: keduvocidentifier
+
+    -----------------------------------------------------------------------
+
+    begin         : Mi Aug 29 2007
+
+    copyright     : (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
+
+    -----------------------------------------------------------------------
+
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+#include "keduvocidentifier.h"
+
+#include <KLocalizedString>
+
+class KEduVocIdentifier::Private
+{
+public:
+    /// the name: English, Anatomy, Fruit salad
+    QString m_name;
+    /// the locale: en, de, es, ...
+    QString m_locale;
+
+    /**
+     * Let the user provide some additional informatioin about the language.
+     * This could be Traditional/Simplified for chinese to differentiate between them.
+     */
+    QString m_comment;
+
+    /** not sure yet: language|other|??? */
+    QString m_type;
+
+    /** I, you, he, she, it... */
+    KEduVocConjugation  m_personalPronouns;
+
+    /** the for english ;)
+       der, die, das ... in german */
+    KEduVocArticle      m_articles;
+
+    /** Future, present and past... and many more */
+    QSet < QString >    m_tenses;
+
+    /** Size hint for the width of this column - has to go somewere. Here at least we have the headers... */
+    int m_sizeHint;
+};
+
+
+KEduVocIdentifier::KEduVocIdentifier()
+: d( new Private )
+{
+    d->m_name = i18nc("A default title for a single column of vocabulary. Will hardly be used. Should be very generic.", "Title");
+    ///@todo maybe the user locale would be more appropriate
+    d->m_locale = "en";
+}
+
+
+KEduVocIdentifier::~KEduVocIdentifier()
+{
+    delete d;
+}
+
+
+KEduVocIdentifier::KEduVocIdentifier( const KEduVocIdentifier &other )
+: d( new Private )
+{
+///@todo
+    d->m_locale = other.d->m_locale;
+    d->m_name = other.d->m_name;
+
+}
+
+
+KEduVocIdentifier& KEduVocIdentifier::operator= ( const KEduVocIdentifier &other )
+{
+    d->m_locale = other.d->m_locale;
+    d->m_name = other.d->m_name;
+    return *this;
+}
+
+
+QString KEduVocIdentifier::name() const
+{
+    return d->m_name;
+}
+
+void KEduVocIdentifier::setName(const QString & name)
+{
+    d->m_name = name;
+}
+
+QString KEduVocIdentifier::locale() const
+{
+    return d->m_locale;
+}
+
+void KEduVocIdentifier::setLocale(const QString & locale)
+{
+    d->m_locale = locale;
+}
+
diff --git a/keduvocdocument/keduvocidentifier.h b/keduvocdocument/keduvocidentifier.h
new file mode 100644 (file)
index 0000000..32ecd71
--- /dev/null
@@ -0,0 +1,60 @@
+/***************************************************************************
+
+    C++ Interface: keduvocidentifier
+
+    -----------------------------------------------------------------------
+
+    begin         : Mi Aug 29 2007
+
+    copyright     : (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
+
+    -----------------------------------------------------------------------
+
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+#ifndef KEDUVOCIDENTIFIER_H
+#define KEDUVOCIDENTIFIER_H
+
+#include "libkeduvocdocument_export.h"
+
+#include "keduvocconjugation.h"
+#include "keduvocgrammar.h"
+
+#include <QtCore/QList>
+#include <QtCore/QString>
+#include <QtCore/QSet>
+
+
+/**
+Class to store meta information about a language or any other category in the vocabulary.
+
+ @author
+*/
+class KEDUVOCDOCUMENT_EXPORT KEduVocIdentifier
+{
+public:
+    KEduVocIdentifier();
+    KEduVocIdentifier( const KEduVocIdentifier &other );
+    ~KEduVocIdentifier();
+    KEduVocIdentifier& operator= ( const KEduVocIdentifier &other );
+
+    QString name() const;
+    void setName( const QString& name );
+    QString locale() const;
+    void setLocale( const QString& name );
+
+private:
+    class Private;
+    Private * const d;
+
+};
+
+#endif
index 58532231cc747d615b39a7fbd94d173175621b71..fa37fe0b6ea59b4fdb7b8bd7062524a801df9211 100644 (file)
@@ -214,24 +214,21 @@ bool KEduVocKvtml2Reader::readIdentifier( QDomElement &identifierElement )
         return false;
     }
 
-    QDomElement currentElement = identifierElement.firstChildElement( KVTML_IDENTIFIERTYPE );
-    if ( !currentElement.isNull() ) {
-        // TODO: do something with the type
+    // generate empty identifiers in the doc
+    for ( int i = m_doc->identifierCount(); i <= id; i++ ) {
+        m_doc->appendIdentifier( KEduVocIdentifier() );
     }
 
+    // the first element, create the identifier, even if empty
+    QDomElement currentElement = identifierElement.firstChildElement( KVTML_NAME );
+    m_doc->identifier(id).setName( currentElement.text() );
+
     currentElement = identifierElement.firstChildElement( KVTML_LOCALE );
-    if ( !currentElement.isNull() ) {
-        // TODO: do we want to use this for the identifier, or the name?
-        int index = m_doc->appendIdentifier( currentElement.text() );
-        if ( index != id ) {
-            m_errorMessage = i18n( "identifiers out of order" );
-            return false;
-        }
-    }
+    m_doc->identifier(id).setLocale( currentElement.text() );
 
-    currentElement = identifierElement.firstChildElement( KVTML_NAME );
+    currentElement = identifierElement.firstChildElement( KVTML_IDENTIFIERTYPE );
     if ( !currentElement.isNull() ) {
-        // TODO: do something with the name
+        // TODO: do something with the type
     }
 
     currentElement = identifierElement.firstChildElement( KVTML_SIZEHINT );
index f198baf9bbb598c53a83f795c3887d25cc79fe08..2544c164391fea62799ab8dc0b7d79d6c6da04ec 100644 (file)
@@ -143,7 +143,9 @@ bool KEduVocKvtml2Writer::writeIdentifiers( QDomElement &identifiersElement )
 
         // record the identifier as the locale for now
         // TODO: when support for more parts of the identifier is in the document class (name, type, etc.) store those here as well
-        identifier.appendChild( newTextElement( KVTML_LOCALE, m_doc->identifier( i ) ) );
+        identifier.appendChild( newTextElement( KVTML_NAME, m_doc->identifier( i ).name() ) );
+
+        identifier.appendChild( newTextElement( KVTML_LOCALE, m_doc->identifier( i ).locale() ) );
 
         // record articles
         QDomElement article = m_domDoc.createElement( KVTML_ARTICLE );
index 42f8b7c2399c6c8e5d5b353113b90049a82f1c75..ee748a282c7629ecd6b3a6c5643395e7c05f9a6e 100644 (file)
@@ -277,20 +277,8 @@ bool KEduVocKvtmlReader::readArticle( QDomElement &domElementParent )
             QString lang;
             attribute = currentElement.attributeNode( KV_LANG );
 
-            if ( m_doc->identifierCount() <= i ) {
-                // first entry
-                if ( !attribute.isNull() )       // no definition in first entry
-                    lang = attribute.value();
-                else
-                    lang = "original";
-                m_doc->appendIdentifier( lang );
-//kDebug() << " Identifier " << i << " is " << lang;
-            } else {
-                if ( !attribute.isNull() && attribute.value() != m_doc->identifier( i ) ) {
-                    // different originals ?
-                    m_errorMessage = i18n( "Ambiguous definition of language code" );
-                    return false;
-                }
+            if (!addLanguage(i, attribute.value())) {
+                return false;
             }
 
             //---------
@@ -423,20 +411,10 @@ bool KEduVocKvtmlReader::readConjug( QDomElement &domElementParent, QList<KEduVo
             QString lang;
             QDomAttr domAttrLang = domElementConjugChild.attributeNode( KV_LANG ); // "l"
 
-            if ( m_doc->identifierCount() <= count ) {
-                // first entry
-                if ( !domAttrLang.isNull() )          // no definition in first entry
-                    lang = domAttrLang.value();
-                else
-                    lang = "original";
-                m_doc->appendIdentifier( lang );
-            } else {
-                if ( !domAttrLang.isNull() && domAttrLang.value() != m_doc->identifier( count ) ) {
-                    // different originals ?
-                    m_errorMessage = i18n( "Ambiguous definition of language code" );
-                    return false;
-                }
+            if (!addLanguage(count, domAttrLang.value())) {
+                return false;
             }
+
         } else if ( domElementConjugChild.tagName() == KV_CON_TYPE ) {                    // this means reading translations KV_CON_TYPE == "t"
             //----------
             // Attribute
@@ -1070,26 +1048,10 @@ bool KEduVocKvtmlReader::readExpression( QDomElement &domElementParent )
         if ( m_doc->entryCount() == 0 ) { // this is because in kvtml the languages are saved in the FIRST ENTRY ONLY.
 //kDebug() << " Read Expression with identifiers: " << lang;
             // new translation
-            if ( lang.isEmpty() ) {
-                if ( i == 0 ) {
-                    lang = "original";
-                } else {
-                    // no definition in first entry ?
-                    lang.setNum( m_doc->identifierCount() );
-                    lang.prepend( "translation " );
-                }
-
-            }
-            if ( m_doc->identifierCount() <= i )
-                m_doc->appendIdentifier( lang );
-        } else {
-            if ( lang != m_doc->identifier( i ) && !lang.isEmpty() ) {
-                // different language ?
-                m_errorMessage = i18n( "ambiguous definition of language code" );
+            if (!addLanguage(i, attribute.value())) {
                 return false;
             }
         }
-
         //---------
         // Children
 
@@ -1198,4 +1160,28 @@ bool KEduVocKvtmlReader::readExpression( QDomElement &domElementParent )
     return true;
 }
 
+
+bool KEduVocKvtmlReader::addLanguage( int languageId, const QString& language)
+{
+    if ( m_doc->identifierCount() <= languageId ) {
+        m_doc->appendIdentifier();
+        // first entry
+        if ( !language.isEmpty() ) {      // no definition in first entry
+            m_doc->identifier(languageId).setLocale(language);
+            m_doc->identifier(languageId).setName(language);
+        }
+    } else {
+        if ( !language.isEmpty() ) {
+            if ( language != m_doc->identifier( languageId ).locale() ) {
+                // different originals ?
+                m_errorMessage = i18n( "Ambiguous definition of language code" );
+                return false;
+            }
+        }
+    }
+}
+
+
+
+
 #include "keduvockvtmlreader.moc"
index 4970cf5e5d831fbf6bc3ee3f7a0589269a8dd420..5d9f17b0b7f4206f20bf17e2c229cb00915c6e91 100644 (file)
@@ -45,10 +45,19 @@ public:
 
     bool readDoc( KEduVocDocument *doc );
 
+    /**
+     * Attempt to add a language/locale. Language/locale are set to the same value.
+     * No error if already there with the same value.
+     * @param languageId idenifier number
+     * @param language name
+     * @return true if successful
+     */
+    bool addLanguage( int languageId, const QString& language);
+
     bool readLesson( QDomElement &domElementParent );
     bool readArticle( QDomElement &domElementParent );
     bool readConjug( QDomElement &domElementParent, QList<KEduVocConjugation> &curr_conjug );
-    bool readOptions( QDomElement &domElementParent );
+//     bool readOptions( QDomElement &domElementParent );
     bool readType( QDomElement &domElementParent );
     bool readTense( QDomElement &domElementParent );
     bool readUsage( QDomElement &domElementParent );
index 4595d5a92599dcc2b1ed5c58f783694465e3dcb2..44941a0d7b91f250a88c3257fb53b325f9c20edd 100644 (file)
@@ -120,7 +120,7 @@ bool KEduVocKvtmlWriter::writeDoc( KEduVocDocument *doc, const QString &generato
             QString s;
             domElementOriginal.setAttribute( KV_SIZEHINT, m_doc->sizeHint( 0 ) );
 
-            s = m_doc->identifier( 0 ).simplified();
+            s = m_doc->identifier( 0 ).name().simplified();
             if ( s.isEmpty() )
                 s = "original";
             domElementOriginal.setAttribute( KV_LANG, s );
@@ -188,7 +188,7 @@ bool KEduVocKvtmlWriter::writeDoc( KEduVocDocument *doc, const QString &generato
                 QString s;
                 domElementTranslation.setAttribute( KV_SIZEHINT, m_doc->sizeHint( trans ) );
 
-                s = m_doc->identifier( trans ).simplified();
+                s = m_doc->identifier( trans ).name().simplified();
                 if ( s.isEmpty() ) {
                     s.setNum( trans );
                     s.prepend( "translation " );
@@ -340,23 +340,23 @@ bool KEduVocKvtmlWriter::writeArticle( QDomDocument &domDoc, QDomElement &domEle
     QString indef;
     QString s;
 
-    for ( int lfn = 0; lfn < qMin( m_doc->articleCount(), m_doc->identifierCount() ); lfn++ )
+    for ( int i = 0; i < qMin( m_doc->articleCount(), m_doc->identifierCount() ); i++ )
     {
         QDomElement domElementEntry = domDoc.createElement( KV_ART_ENTRY );
-        if ( lfn == 0 ) {
-            s = m_doc->identifier( 0 ).simplified();
+        if ( i == 0 ) {
+            s = m_doc->identifier( 0 ).name().simplified();
             if ( s.isEmpty() )
                 s = "original";
         } else {
-            s = m_doc->identifier( lfn ).simplified();
+            s = m_doc->identifier( i ).name().simplified();
             if ( s.isEmpty() ) {
-                s.setNum( lfn );
+                s.setNum( i );
                 s.prepend( "translation " );
             }
         }
         domElementEntry.setAttribute( KV_LANG, s );
 
-        m_doc->article( lfn ).getFemale( &def, &indef );
+        m_doc->article( i ).getFemale( &def, &indef );
         if ( !def.isEmpty() ) {
             QDomElement domElementFD = domDoc.createElement( KV_ART_FD );
             QDomText domTextFD = domDoc.createTextNode( def );
@@ -372,7 +372,7 @@ bool KEduVocKvtmlWriter::writeArticle( QDomDocument &domDoc, QDomElement &domEle
             domElementEntry.appendChild( domElementFI );
         }
 
-        m_doc->article( lfn ).getMale( &def, &indef );
+        m_doc->article( i ).getMale( &def, &indef );
         if ( !def.isEmpty() ) {
             QDomElement domElementMD = domDoc.createElement( KV_ART_MD );
             QDomText domTextMD = domDoc.createTextNode( def );
@@ -388,7 +388,7 @@ bool KEduVocKvtmlWriter::writeArticle( QDomDocument &domDoc, QDomElement &domEle
             domElementEntry.appendChild( domElementMI );
         }
 
-        m_doc->article( lfn ).getNatural( &def, &indef );
+        m_doc->article( i ).getNatural( &def, &indef );
         if ( !def.isEmpty() ) {
             QDomElement domElementND = domDoc.createElement( KV_ART_ND );
             QDomText domTextND = domDoc.createTextNode( def );
@@ -629,7 +629,7 @@ bool KEduVocKvtmlWriter::writeConjugHeader( QDomDocument &domDoc, QDomElement &d
     for ( int ent = 0; ent < qMin( curr_conjug.count(), m_doc->identifierCount() ); ent++ ) {
         QDomElement domElementEntry = domDoc.createElement( KV_CON_ENTRY );
 
-        s = m_doc->identifier( ent ).simplified();
+        s = m_doc->identifier( ent ).name().simplified();
         if ( s.isEmpty() ) {
             s.setNum( ent );
             s.prepend( "translation " );
index d102710291ef405138c6dc6a6bb846a9e34e342d..2ed69c485ecc1f176e76a554ef0e62134d172238 100644 (file)
@@ -66,8 +66,8 @@ void KEduVocPaukerReader::readPauker()
 {
     m_doc->setAuthor( "http://pauker.sf.net" );
     ///Pauker does not provide any column titles
-    m_doc->appendIdentifier( i18n( "Front Side" ) );
-    m_doc->appendIdentifier( i18n( "Reverse Side" ) );
+    m_doc->appendIdentifier();
+    m_doc->appendIdentifier();
 
     while ( !atEnd() ) {
         readNext();
index af0ff5824f83985fad0988477e4f464df60ad112..ce342c9eaab771829f0cc69da5e7bb495e53a34e 100644 (file)
@@ -7,6 +7,7 @@
     begin        : Wed Jun 15 19:32:00 PDT 2005
 
     copyright    : (C) 2005, 2007 Peter Hedlund <peter.hedlund@kdemail.net>
+                   (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
 
     -----------------------------------------------------------------------
 
@@ -90,8 +91,12 @@ bool KEduVocVokabelnReader::readDoc( KEduVocDocument *doc )
     lang1 = inputStream.readLine();
     languages = lang1.split( "\"," );
 
-    m_doc->appendIdentifier( languages[0].mid( 1 ) );
-    m_doc->appendIdentifier( languages[1].mid( 1 ) );
+    m_doc->appendIdentifier();
+    m_doc->identifier(0).setLocale( languages[0].mid( 1 ) );
+    m_doc->identifier(0).setName( languages[0].mid( 1 ) );
+    m_doc->appendIdentifier();
+    m_doc->identifier(1).setLocale( languages[1].mid( 1 ) );
+    m_doc->identifier(1).setName( languages[1].mid( 1 ) );
 
     keepGoing = true;
     while ( keepGoing )
index ba857f08251a68767829f7333ad9ffcbeaf038e2..73a9f8d724aa794f9df6e74b720f5a0a7a8bb16b 100644 (file)
@@ -3,6 +3,7 @@
     -----------------------------------------------------------------------
     copyright     : (C) 2004, 2007 Peter Hedlund <peter.hedlund@kdemail.net>
                     (C) 2005 Eric Pignet
+                    (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
 
  ***************************************************************************/
 
@@ -140,8 +141,13 @@ bool KEduVocWqlReader::readDoc( KEduVocDocument *doc )
     p = s.indexOf( "   [", 0 );
     s = s.left( p );
     s = s.simplified();
-    m_doc->appendIdentifier( s );
-    m_doc->appendIdentifier( inputStream.readLine() );
+    m_doc->appendIdentifier();
+    m_doc->identifier(0).setLocale( s );
+    m_doc->identifier(0).setName( s );
+    s = inputStream.readLine();
+    m_doc->appendIdentifier();
+    m_doc->identifier(1).setLocale( s );
+    m_doc->identifier(1).setName( s );
 
     while ( !s.isNull() ) {
         s = inputStream.readLine();
index f5d272b5a4c31e2a54418246c21344d1f45cd3c0..f3b5243a073a69702d8b64997042e97a37b9cb35 100644 (file)
@@ -66,16 +66,17 @@ void KEduVocXdxfReader::readXdxf()
 {
     ///The language attributes are required and should be ISO 639-2 codes, but you never know...
     QStringRef id1 = attributes().value( "lang_from" );
-    if ( !id1.isNull() )
-        m_doc->appendIdentifier( id1.toString().toLower() );
-    else
-        m_doc->appendIdentifier( i18nc( "@title:column the original language column", "Original" ) );
-
+    m_doc->appendIdentifier();
+    if ( !id1.isNull() ) {
+        m_doc->identifier(0).setLocale( id1.toString().toLower() );
+        m_doc->identifier(0).setName( id1.toString().toLower() );
+    }
     QStringRef id2 = attributes().value( "lang_to" );
-    if ( !id2.isNull() )
-        m_doc->appendIdentifier( id2.toString().toLower() );
-    else
-        m_doc->appendIdentifier( i18nc( "@title:column one of the translation columns", "Translation" ) );
+    m_doc->appendIdentifier();
+    if ( !id2.isNull() ) {
+        m_doc->identifier(1).setLocale( id2.toString().toLower() );
+        m_doc->identifier(1).setName( id2.toString().toLower() );
+    }
 
     while ( !atEnd() ) {
         readNext();
index 6862d15a377070575de6494012d2aba1d68c791a..98a2c8b6e7ec32ed6773cc8cb3049e7772df8bab 100644 (file)
@@ -166,7 +166,7 @@ void SharedKvtmlFiles::sortDownloadedFiles()
         // open the file
         doc->open( fileUrl );
 
-        QString locale = doc->identifier( 0 );
+        QString locale = doc->identifier( 0 ).name();
 
         // make sure the locale sub-folder exists
         KUrl pathUrl( fileUrl );