From 0fb6bd22be218809232ffec2a43cb67d7d412e3e Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sat, 9 Jun 2007 16:15:26 +0000 Subject: [PATCH] Start getting rid of the original concept - now calls to translation(0) are returning original(). The same for setTranslation(0). Of course this still has to change by removing m_original and making it m_translations[0]. But this already enables some redundant writer/reader code to be removed. svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=673258 --- kdeeducore/keduvocexpression.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kdeeducore/keduvocexpression.cpp b/kdeeducore/keduvocexpression.cpp index ab38d63..93a9800 100644 --- a/kdeeducore/keduvocexpression.cpp +++ b/kdeeducore/keduvocexpression.cpp @@ -485,8 +485,10 @@ void KEduVocExpression::addTranslation(const QString & expr, grade_t grade, grad QString KEduVocExpression::translation(int index) const { - if (index > d->m_translations.count() || index < 1) + if (index > d->m_translations.count() || index < 0) return ""; + if (index == 0) + return d->m_original; else return d->m_translations[index-1]; } @@ -564,9 +566,14 @@ void KEduVocExpression::removeTranslation(int index) void KEduVocExpression::setTranslation(int index, const QString & expr) { - if (index <= 0) + if (index < 0) return; + if (index == 0) { + d->m_original = expr.simplified(); + return; + } + // extend translations with empty strings if necessary if (d->m_translations.count() < index) for (int i = d->m_translations.count(); i < index; i++) -- 2.47.3