Warning, file /education/parley/src/practice/examplesentencebackendmode.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2010 Frederik Gladhorn <gladhorn@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "examplesentencebackendmode.h" 0007 0008 #include <KLocalizedString> 0009 0010 using namespace Practice; 0011 0012 ExampleSentenceBackendMode::ExampleSentenceBackendMode(AbstractFrontend *frontend, QObject *parent, SessionManagerBase *sessionManager, KEduVocDocument *doc) 0013 : WrittenBackendMode(frontend, parent, sessionManager, doc) 0014 { 0015 } 0016 0017 bool ExampleSentenceBackendMode::setTestEntry(TestEntry *current) 0018 { 0019 Practice::WrittenBackendMode::setTestEntry(current); 0020 QString sentence = current->entry()->translation(current->languageTo())->example(); 0021 if (sentence.isEmpty()) { 0022 return false; 0023 } 0024 0025 QString answer = current->entry()->translation(current->languageTo())->text(); 0026 int pos = -1; 0027 while ((pos = sentence.indexOf(answer)) >= 0) { 0028 sentence.remove(pos, answer.length()); 0029 sentence.insert(pos, QLatin1String("<font color=\"#FF0000\"><b>...</b></font>")); 0030 } 0031 m_frontend->setQuestion(sentence); 0032 return true; 0033 }