Warning, file /education/parley/src/practice/flashcardbackendmode.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: 2009 Frederik Gladhorn <gladhorn@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "flashcardbackendmode.h" 0007 0008 #include <KLocalizedString> 0009 0010 using namespace Practice; 0011 0012 FlashCardBackendMode::FlashCardBackendMode(AbstractFrontend *frontend, QObject *parent) 0013 : AbstractBackendMode(frontend, parent) 0014 { 0015 } 0016 0017 bool FlashCardBackendMode::setTestEntry(TestEntry *current) 0018 { 0019 Practice::AbstractBackendMode::setTestEntry(current); 0020 m_current = current; 0021 m_currentHint.clear(); 0022 m_solutionVisible = false; 0023 m_frontend->showQuestion(); 0024 return true; 0025 } 0026 0027 void FlashCardBackendMode::checkAnswer() 0028 { 0029 Q_EMIT showSolution(); 0030 } 0031 0032 void FlashCardBackendMode::hintAction() 0033 { 0034 QString solution = m_current->entry()->translation(m_current->languageTo())->text(); 0035 m_currentHint = solution.left(m_currentHint.size() + 1); 0036 if (m_currentHint.size() == solution.size()) { 0037 // show solution 0038 m_frontend->showSolution(); 0039 m_solutionVisible = true; 0040 } else { 0041 m_frontend->setHint(m_currentHint); 0042 } 0043 }