From 9dd406aba3cbfa068f5f5b5c5fab33118050b950 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 30 Aug 2007 10:22:03 +0000 Subject: [PATCH] Begin of a class KEduVocIdentifier. 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 --- keduvocdocument/CMakeLists.txt | 2 + keduvocdocument/keduvoccsvreader.cpp | 7 +- keduvocdocument/keduvocdocument.cpp | 57 +++++++---- keduvocdocument/keduvocdocument.h | 18 ++-- keduvocdocument/keduvocidentifier.cpp | 111 ++++++++++++++++++++++ keduvocdocument/keduvocidentifier.h | 60 ++++++++++++ keduvocdocument/keduvockvtml2reader.cpp | 23 ++--- keduvocdocument/keduvockvtml2writer.cpp | 4 +- keduvocdocument/keduvockvtmlreader.cpp | 74 ++++++--------- keduvocdocument/keduvockvtmlreader.h | 11 ++- keduvocdocument/keduvockvtmlwriter.cpp | 22 ++--- keduvocdocument/keduvocpaukerreader.cpp | 4 +- keduvocdocument/keduvocvokabelnreader.cpp | 9 +- keduvocdocument/keduvocwqlreader.cpp | 10 +- keduvocdocument/keduvocxdxfreader.cpp | 19 ++-- keduvocdocument/sharedkvtmlfiles.cpp | 2 +- 16 files changed, 315 insertions(+), 118 deletions(-) create mode 100644 keduvocdocument/keduvocidentifier.cpp create mode 100644 keduvocdocument/keduvocidentifier.h diff --git a/keduvocdocument/CMakeLists.txt b/keduvocdocument/CMakeLists.txt index e7eb9ae..28bd198 100644 --- a/keduvocdocument/CMakeLists.txt +++ b/keduvocdocument/CMakeLists.txt @@ -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 diff --git a/keduvocdocument/keduvoccsvreader.cpp b/keduvocdocument/keduvoccsvreader.cpp index 24b679d..d888b94 100644 --- a/keduvocdocument/keduvoccsvreader.cpp +++ b/keduvocdocument/keduvoccsvreader.cpp @@ -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; } diff --git a/keduvocdocument/keduvocdocument.cpp b/keduvocdocument/keduvocdocument.cpp index 7164db6..a6dc68b 100644 --- a/keduvocdocument/keduvocdocument.cpp +++ b/keduvocdocument/keduvocdocument.cpp @@ -70,7 +70,8 @@ public: bool m_sortLesson; // save these to document - QStringList m_identifiers; //0= origin, 1,.. translations + QList m_identifiers; + int m_currentLesson; QList m_extraSizeHints; QList 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" diff --git a/keduvocdocument/keduvocdocument.h b/keduvocdocument/keduvocdocument.h index 1dbcf94..74cd020 100644 --- a/keduvocdocument/keduvocdocument.h +++ b/keduvocdocument/keduvocdocument.h @@ -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 index 0000000..d1dd3d0 --- /dev/null +++ b/keduvocdocument/keduvocidentifier.cpp @@ -0,0 +1,111 @@ +/*************************************************************************** + + C++ Implementation: keduvocidentifier + + ----------------------------------------------------------------------- + + begin : Mi Aug 29 2007 + + copyright : (C) 2007 Frederik Gladhorn + + ----------------------------------------------------------------------- + + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 + +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 index 0000000..32ecd71 --- /dev/null +++ b/keduvocdocument/keduvocidentifier.h @@ -0,0 +1,60 @@ +/*************************************************************************** + + C++ Interface: keduvocidentifier + + ----------------------------------------------------------------------- + + begin : Mi Aug 29 2007 + + copyright : (C) 2007 Frederik Gladhorn + + ----------------------------------------------------------------------- + + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 +#include +#include + + +/** +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 diff --git a/keduvocdocument/keduvockvtml2reader.cpp b/keduvocdocument/keduvockvtml2reader.cpp index 5853223..fa37fe0 100644 --- a/keduvocdocument/keduvockvtml2reader.cpp +++ b/keduvocdocument/keduvockvtml2reader.cpp @@ -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 ); diff --git a/keduvocdocument/keduvockvtml2writer.cpp b/keduvocdocument/keduvockvtml2writer.cpp index f198baf..2544c16 100644 --- a/keduvocdocument/keduvockvtml2writer.cpp +++ b/keduvocdocument/keduvockvtml2writer.cpp @@ -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 ); diff --git a/keduvocdocument/keduvockvtmlreader.cpp b/keduvocdocument/keduvockvtmlreader.cpp index 42f8b7c..ee748a2 100644 --- a/keduvocdocument/keduvockvtmlreader.cpp +++ b/keduvocdocument/keduvockvtmlreader.cpp @@ -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, QListidentifierCount() <= 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" diff --git a/keduvocdocument/keduvockvtmlreader.h b/keduvocdocument/keduvockvtmlreader.h index 4970cf5..5d9f17b 100644 --- a/keduvocdocument/keduvockvtmlreader.h +++ b/keduvocdocument/keduvockvtmlreader.h @@ -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 &curr_conjug ); - bool readOptions( QDomElement &domElementParent ); +// bool readOptions( QDomElement &domElementParent ); bool readType( QDomElement &domElementParent ); bool readTense( QDomElement &domElementParent ); bool readUsage( QDomElement &domElementParent ); diff --git a/keduvocdocument/keduvockvtmlwriter.cpp b/keduvocdocument/keduvockvtmlwriter.cpp index 4595d5a..44941a0 100644 --- a/keduvocdocument/keduvockvtmlwriter.cpp +++ b/keduvocdocument/keduvockvtmlwriter.cpp @@ -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 " ); diff --git a/keduvocdocument/keduvocpaukerreader.cpp b/keduvocdocument/keduvocpaukerreader.cpp index d102710..2ed69c4 100644 --- a/keduvocdocument/keduvocpaukerreader.cpp +++ b/keduvocdocument/keduvocpaukerreader.cpp @@ -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(); diff --git a/keduvocdocument/keduvocvokabelnreader.cpp b/keduvocdocument/keduvocvokabelnreader.cpp index af0ff58..ce342c9 100644 --- a/keduvocdocument/keduvocvokabelnreader.cpp +++ b/keduvocdocument/keduvocvokabelnreader.cpp @@ -7,6 +7,7 @@ begin : Wed Jun 15 19:32:00 PDT 2005 copyright : (C) 2005, 2007 Peter Hedlund + (C) 2007 Frederik Gladhorn ----------------------------------------------------------------------- @@ -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 ) diff --git a/keduvocdocument/keduvocwqlreader.cpp b/keduvocdocument/keduvocwqlreader.cpp index ba857f0..73a9f8d 100644 --- a/keduvocdocument/keduvocwqlreader.cpp +++ b/keduvocdocument/keduvocwqlreader.cpp @@ -3,6 +3,7 @@ ----------------------------------------------------------------------- copyright : (C) 2004, 2007 Peter Hedlund (C) 2005 Eric Pignet + (C) 2007 Frederik Gladhorn ***************************************************************************/ @@ -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(); diff --git a/keduvocdocument/keduvocxdxfreader.cpp b/keduvocdocument/keduvocxdxfreader.cpp index f5d272b..f3b5243 100644 --- a/keduvocdocument/keduvocxdxfreader.cpp +++ b/keduvocdocument/keduvocxdxfreader.cpp @@ -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(); diff --git a/keduvocdocument/sharedkvtmlfiles.cpp b/keduvocdocument/sharedkvtmlfiles.cpp index 6862d15..98a2c8b 100644 --- a/keduvocdocument/sharedkvtmlfiles.cpp +++ b/keduvocdocument/sharedkvtmlfiles.cpp @@ -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 ); -- 2.47.3