Commit ddb743b7 authored by Hartmut Riesenbeck's avatar Hartmut Riesenbeck

Non const references methods in KEduVocTranslation are set deprecated

Two methods which returns non const refereces to private member values
of KEduVocTranslation have been set as deprecated. Alternative
getter/setter methods were added. The usage of the deprecated methods
in the library were refactored to new methods.

REVIEW: 128212
parent 5b8c42f1
......@@ -523,7 +523,7 @@ bool KEduVocKvtml2Writer::writeTranslation( QDomElement &translationElement, KEd
}
// multiplechoice
if ( !translation->multipleChoice().isEmpty() ) {
if (!translation->getMultipleChoice().isEmpty()) {
QDomElement multipleChoiceElement = m_domDoc.createElement( KVTML_MULTIPLECHOICE );
writeMultipleChoice( multipleChoiceElement, translation );
translationElement.appendChild( multipleChoiceElement );
......@@ -595,7 +595,7 @@ bool KEduVocKvtml2Writer::writeMultipleChoice( QDomElement &multipleChoiceElemen
</multiplechoice>
*/
{
foreach ( const QString &choice, translation->multipleChoice() ) {
foreach (const QString &choice, translation->getMultipleChoice()) {
multipleChoiceElement.appendChild( newTextElement( KVTML_CHOICE, choice ) );
}
return true;
......
......@@ -287,18 +287,39 @@ void KEduVocTranslation::setConjugation( const QString& tense, const KEduVocConj
}
KEduVocConjugation& KEduVocTranslation::conjugation( const QString& tense )
KEduVocConjugation& KEduVocTranslation::conjugation(const QString &tense)
{
return d->m_conjugations[tense];
}
QStringList & KEduVocTranslation::multipleChoice()
KEduVocConjugation KEduVocTranslation::getConjugation(const QString &tense) const
{
if (d->m_conjugations.contains(tense)) {
return d->m_conjugations[tense];
}
return KEduVocConjugation();
}
QStringList& KEduVocTranslation::multipleChoice()
{
return d->m_multipleChoice;
}
QStringList KEduVocTranslation::getMultipleChoice() const
{
return d->m_multipleChoice;
}
void KEduVocTranslation::setMultipleChoice(const QStringList &choices)
{
d->m_multipleChoice = choices;
}
QString KEduVocTranslation::pronunciation() const
{
return d->m_pronunciation;
......@@ -503,7 +524,7 @@ void KEduVocTranslation::toKVTML2(QDomElement & parent)
// conjugation
foreach ( const QString &tense, conjugationTenses() ) {
QDomElement conjugationElement = parent.ownerDocument().createElement( KVTML_CONJUGATION );
conjugation(tense).toKVTML2(conjugationElement, tense);
getConjugation(tense).toKVTML2(conjugationElement, tense);
if (conjugationElement.hasChildNodes()) {
parent.appendChild( conjugationElement );
}
......
......@@ -147,11 +147,19 @@ public:
void setLeitnerBox( KEduVocLeitnerBox* leitnerBox );
/**
* This method is deprecated, please use @see getConjugation() @see setConjugation()
* Returns a conjugation if available
* @param tense tense of the requested conjugation
* @return the conjugation
*/
KEduVocConjugation& conjugation( const QString& tense );
KEDUVOCDOCUMENT_DEPRECATED KEduVocConjugation& conjugation(const QString &tense);
/**
* Returns a conjugation if available
* @param tense tense of the requested conjugation
* @return the conjugation
*/
KEduVocConjugation getConjugation(const QString &tense) const;
/** adds conjugations or replaces them, if they exist.
* @param conjugation conjugation
......@@ -202,14 +210,22 @@ public:
KEduVocText article() const;
void setArticle(const KEduVocText& article);
/** Returns multiple choice if available
*/
QStringList & multipleChoice();
/**
* This method is deprecated, please use @see getMultipleChoice() @see setMultipleChoice()
* Returns multiple choice if available
*/
KEDUVOCDOCUMENT_DEPRECATED QStringList& multipleChoice();
/**
* Returns multiple choice if available
* @return list of multiple choice answers
*/
QStringList getMultipleChoice() const;
/** Sets multiple choice
* @param mc multiple choice block
*/
// void setMultipleChoice( const QStringList &mc );
* @param choices multiple choice block
*/
void setMultipleChoice(const QStringList &choices);
/** Get the sound url for this translation if it exists */
QUrl soundUrl();
......
......@@ -700,7 +700,9 @@ bool KEduVocKvtml2Reader::readMultipleChoice( QDomElement &multipleChoiceElement
{
currentElement = choiceNodes.item( i ).toElement();
if ( currentElement.parentNode() == multipleChoiceElement ) {
translation->multipleChoice().append( currentElement.text() );
QStringList choices = translation->getMultipleChoice();
choices.append(currentElement.text());
translation->setMultipleChoice(choices);
}
}
return true;
......
......@@ -717,32 +717,35 @@ bool KEduVocKvtmlReader::readMultipleChoice( QDomElement &domElementParent, KEdu
{
QDomElement currentElement;
QStringList choices = translation->getMultipleChoice();
currentElement = domElementParent.firstChildElement( KV_MC_1 );
if ( !currentElement.isNull() ) {
translation->multipleChoice().append( currentElement.text() );
choices.append(currentElement.text());
}
currentElement = domElementParent.firstChildElement( KV_MC_2 );
if ( !currentElement.isNull() ) {
translation->multipleChoice().append( currentElement.text() );
choices.append(currentElement.text());
}
currentElement = domElementParent.firstChildElement( KV_MC_3 );
if ( !currentElement.isNull() ) {
translation->multipleChoice().append( currentElement.text() );
choices.append(currentElement.text());
}
currentElement = domElementParent.firstChildElement( KV_MC_4 );
if ( !currentElement.isNull() ) {
translation->multipleChoice().append( currentElement.text() );
choices.append(currentElement.text());
}
currentElement = domElementParent.firstChildElement( KV_MC_5 );
if ( !currentElement.isNull() ) {
translation->multipleChoice().append( currentElement.text() );
choices.append(currentElement.text());
}
translation->setMultipleChoice(choices);
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment