File indexing completed on 2024-04-21 03:41:52
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 "divisionflagasker.h" 0012 0013 #include <KLocalizedString> 0014 0015 #include <QImage> 0016 #include <QRadioButton> 0017 0018 #include "map.h" 0019 0020 divisionFlagAsker::divisionFlagAsker(QWidget *parent, KGmap *m, QWidget *w, uint count) : boxAsker(parent, m, w, count) 0021 { 0022 init(); 0023 } 0024 0025 bool divisionFlagAsker::nextBoxAskerQuestionHook(const division *div, int i, bool isAnswer) 0026 { 0027 QSize pixmapSize(60, 40); 0028 QIcon icon(div -> getFlagForQuestion()); 0029 0030 if (isAnswer) 0031 { 0032 const QString divisionName = div -> getName(); 0033 setQuestion(i18nc("@title:group", "The flag of %1 is...", divisionName)); 0034 p_currentAnswer.setCorrectAnswer(icon.pixmap(QSize(60, 40))); 0035 p_currentAnswer.setQuestion(i18nc("@item:intable column Question, %1 is region name", "%1", divisionName)); 0036 } 0037 else 0038 { 0039 // There are some maps like the Pacific one where two divisions have the same flag 0040 if (icon.pixmap(pixmapSize).toImage() == p_radioButtons[p_position]->icon().pixmap(pixmapSize).toImage()) return false; 0041 } 0042 p_radioButtons[i] -> setIcon(icon); 0043 p_radioButtons[i] -> show(); 0044 p_radioButtons[i] -> setIconSize(pixmapSize); 0045 return true; 0046 } 0047 0048 void divisionFlagAsker::setAnswerHook(int userSays) 0049 { 0050 QIcon i = p_radioButtons[userSays] -> icon(); 0051 p_currentAnswer.setAnswer(i.pixmap(QSize(60, 40))); 0052 } 0053 0054 QString divisionFlagAsker::getQuestionHook() const 0055 { 0056 QString divisionType = p_map->getDivisionsString(); 0057 return i18nc("@title", "Flag of %1", divisionType); 0058 }