From: Frederik Gladhorn Date: Sun, 24 Feb 2008 19:45:58 +0000 (+0000) Subject: move xml reading/writing into the individual classes X-Git-Tag: v4.0.71~39 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=5bd8c65b6f7329d3bdeb546a6e3aa918a40c7b68;p=libqmvoc.git move xml reading/writing into the individual classes svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=778866 --- diff --git a/keduvocdocument/keduvocdeclension.cpp b/keduvocdocument/keduvocdeclension.cpp index 16c4dfb..55d7037 100644 --- a/keduvocdocument/keduvocdeclension.cpp +++ b/keduvocdocument/keduvocdeclension.cpp @@ -87,7 +87,7 @@ bool KEduVocDeclension::isEmpty() return d->m_declensions.isEmpty(); } -void KEduVocDeclension::toXML(QDomElement & parent) +void KEduVocDeclension::toKVTML2(QDomElement & parent) { if (isEmpty()) { return; @@ -99,7 +99,7 @@ void KEduVocDeclension::toXML(QDomElement & parent) QDomElement numberElement = domDoc.createElement( KVTML_GRAMMATICAL_NUMBER[num] ); for ( KEduVocDeclension::DeclensionCase dcase = KEduVocDeclension::Nominative; dcase < KEduVocDeclension::DeclensionCaseMAX; dcase = KEduVocDeclension::DeclensionCase(dcase +1) ) { QDomElement caseElement = domDoc.createElement( KVTML_DECLENSION_CASE[dcase] ); - declension(num, dcase).toXML(caseElement); + declension(num, dcase).toKVTML2(caseElement); if (caseElement.hasChildNodes()) { numberElement.appendChild(caseElement); diff --git a/keduvocdocument/keduvocdeclension.h b/keduvocdocument/keduvocdeclension.h index c120fe5..70c3f6e 100644 --- a/keduvocdocument/keduvocdeclension.h +++ b/keduvocdocument/keduvocdeclension.h @@ -97,7 +97,8 @@ public: bool isEmpty(); - void toXML(QDomElement& parent); + void fromKVTML2(QDomElement& parent); + void toKVTML2(QDomElement& parent); static int indexOf(DeclensionNumber number, DeclensionCase decCase); diff --git a/keduvocdocument/keduvockvtml2reader.cpp b/keduvocdocument/keduvockvtml2reader.cpp index 247cd69..52d1c76 100644 --- a/keduvocdocument/keduvockvtml2reader.cpp +++ b/keduvocdocument/keduvockvtml2reader.cpp @@ -307,12 +307,9 @@ bool KEduVocKvtml2Reader::readEntry( QDomElement &entryElement ) bool KEduVocKvtml2Reader::readTranslation( QDomElement &translationElement, KEduVocExpression *expr, int index ) { - QDomElement currentElement = translationElement.firstChildElement( KVTML_TEXT ); - if ( !currentElement.isNull() ) { - expr->translation(index)->setText( currentElement.text() ); - } + expr->translation(index)->fromKVTML2(translationElement); - currentElement = translationElement.firstChildElement( KVTML_COMMENT ); + QDomElement currentElement = translationElement.firstChildElement( KVTML_COMMENT ); if ( !currentElement.isNull() ) { expr->translation(index)->setComment( currentElement.text() ); } diff --git a/keduvocdocument/keduvockvtml2writer.cpp b/keduvocdocument/keduvockvtml2writer.cpp index ff89493..1e2317d 100644 --- a/keduvocdocument/keduvockvtml2writer.cpp +++ b/keduvocdocument/keduvockvtml2writer.cpp @@ -374,7 +374,7 @@ bool KEduVocKvtml2Writer::writeEntries( QDomElement &entriesElement ) bool KEduVocKvtml2Writer::writeTranslation( QDomElement &translationElement, KEduVocTranslation* translation ) { // so far only for KEduVocWord - text and grades - translation->toXML(translationElement); + translation->toKVTML2(translationElement); ///@todo move into translation->toXML() diff --git a/keduvocdocument/keduvoctext.cpp b/keduvocdocument/keduvoctext.cpp index 4909911..cf1feb2 100644 --- a/keduvocdocument/keduvoctext.cpp +++ b/keduvocdocument/keduvoctext.cpp @@ -170,7 +170,7 @@ bool KEduVocText::operator ==(const KEduVocText & other) const d->m_practiceDate == other.d->m_practiceDate; } -void KEduVocText::toXML(QDomElement& parent) +void KEduVocText::toKVTML2(QDomElement& parent) { QDomDocument domDoc = parent.ownerDocument(); if (text().isEmpty()) { @@ -199,3 +199,8 @@ void KEduVocText::toXML(QDomElement& parent) parent.appendChild( gradeElement ); } } + +void KEduVocText::fromKVTML2(QDomElement & parent) +{ + setText( parent.firstChildElement( KVTML_TEXT ).text() ); +} diff --git a/keduvocdocument/keduvoctext.h b/keduvocdocument/keduvoctext.h index 91d3cad..5260a33 100644 --- a/keduvocdocument/keduvoctext.h +++ b/keduvocdocument/keduvoctext.h @@ -153,7 +153,8 @@ public: */ void setPracticeDate( const QDateTime & date ); - void toXML(QDomElement& parent); + void fromKVTML2(QDomElement& parent); + void toKVTML2(QDomElement& parent); private: class KEduVocTextPrivate; diff --git a/keduvocdocument/keduvoctranslation.cpp b/keduvocdocument/keduvoctranslation.cpp index 830789b..5bae3c8 100644 --- a/keduvocdocument/keduvoctranslation.cpp +++ b/keduvocdocument/keduvoctranslation.cpp @@ -95,8 +95,8 @@ KEduVocTranslation::KEduVocTranslation(KEduVocExpression* entry, const QString & } KEduVocTranslation::KEduVocTranslation( const KEduVocTranslation &other ) - : d( new KEduVocTranslationPrivate(other.d->m_entry) ), - KEduVocText(other) + : KEduVocText(other), + d( new KEduVocTranslationPrivate(other.d->m_entry) ) { d->m_wordType = other.d->m_wordType; d->m_comment = other.d->m_comment; @@ -358,12 +358,12 @@ void KEduVocTranslation::setDeclension(KEduVocDeclension * declension) d->m_declension = declension; } -void KEduVocTranslation::toXML(QDomElement & parent) +void KEduVocTranslation::toKVTML2(QDomElement & parent) { kDebug() << "Write translation xml."; - KEduVocText::toXML(parent); + KEduVocText::toKVTML2(parent); if (d->m_declension) { - d->m_declension->toXML(parent); + d->m_declension->toKVTML2(parent); } } diff --git a/keduvocdocument/keduvoctranslation.h b/keduvocdocument/keduvoctranslation.h index f90b8ec..3096365 100644 --- a/keduvocdocument/keduvoctranslation.h +++ b/keduvocdocument/keduvoctranslation.h @@ -235,7 +235,8 @@ public: */ bool operator== ( const KEduVocTranslation &translation ) const; - void toXML(QDomElement& parent); +// void fromKVTML2(QDomElement& parent); + void toKVTML2(QDomElement& parent); private: class KEduVocTranslationPrivate;