File indexing completed on 2024-04-21 03:41:51
0001 /*************************************************************************** 0002 * Copyright (C) 2004 by Albert Astals Cid * 0003 * aacid@kde.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #include "capitaldivisionasker.h" 0012 0013 #include <KLocalizedString> 0014 0015 #include <QRadioButton> 0016 0017 #include "map.h" 0018 0019 capitalDivisionAsker::capitalDivisionAsker(QWidget *parent, KGmap *m, QWidget *w, uint count) : boxAsker(parent, m, w, count) 0020 { 0021 init(); 0022 } 0023 0024 bool capitalDivisionAsker::nextBoxAskerQuestionHook(const division *div, int i, bool isAnswer) 0025 { 0026 bool b; 0027 if (isAnswer) 0028 { 0029 const QString divisionName = div -> getName(); 0030 p_capital = div -> getCapital(); 0031 p_currentAnswer.setQuestion(i18nc("@item:intable column Question, %1 is capital name", "%1", p_capital)); 0032 p_currentAnswer.setCorrectAnswer(i18nc("@option:radio <City> is the capital of...", "%1", divisionName)); 0033 0034 setQuestion(p_map->getCapitalToDivisionQuestionPattern().subs(p_capital).toString()); 0035 p_radioButtons[i] -> setText(i18nc("@option:radio <City> is the capital of...", "%1", divisionName)); 0036 b = true; 0037 } 0038 else 0039 { 0040 // There are crazy countries like Norway where two different divisions 0041 // have the same capital, avoid asking 0042 // Oslo is the capital of ... 0043 // Oslo (true) 0044 // Akershus (true) 0045 // Buskerud 0046 // Hedmark 0047 if (div -> getCapital() != p_capital) 0048 { 0049 const QString divisionName = div -> getName(); 0050 p_radioButtons[i] -> setText(i18nc("@option:radio <City> is the capital of...", "%1", divisionName)); 0051 b = true; 0052 } 0053 else b = false; 0054 } 0055 return b; 0056 } 0057 0058 void capitalDivisionAsker::setAnswerHook(int userSays) 0059 { 0060 p_currentAnswer.setAnswer(p_radioButtons[userSays] -> text()); 0061 } 0062 0063 QString capitalDivisionAsker::getQuestionHook() const 0064 { 0065 return p_map->getCapitalToDivisionTitle(); 0066 }