capitaldivisionasker.cpp 2.52 KB
Newer Older
1
2
/***************************************************************************
 *   Copyright (C) 2004 by Albert Astals Cid                               *
3
 *   aacid@kde.org                                                         *
4
5
6
7
8
9
10
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

Albert Astals Cid's avatar
Albert Astals Cid committed
11
12
#include "capitaldivisionasker.h"

David Gil's avatar
David Gil committed
13
#include <klocalizedstring.h>
14
15
16
17
18

#include <qradiobutton.h>
 
#include "map.h"

Albert Astals Cid's avatar
Albert Astals Cid committed
19
capitalDivisionAsker::capitalDivisionAsker(QWidget *parent, KGmap *m, QWidget *w, uint count) : boxAsker(parent, m, w, count)
20
21
22
23
{
	init();
}

24
bool capitalDivisionAsker::nextBoxAskerQuestionHook(const QString &division, int i, bool isAnswer)
25
{
26
	bool b;
Albert Astals Cid's avatar
Albert Astals Cid committed
27
28
	if (isAnswer)
	{
29
		p_capital = p_map -> getDivisionCapital(division);
30
		p_currentAnswer.setQuestion(i18nc("@item:intable column Question, %1 is capital name", "%1", p_capital));
31
		p_currentAnswer.setCorrectAnswer(i18nc("@option:radio <City> is the capital of...", "%1", i18nc(p_map -> getFileName().toUtf8(), division.toUtf8())));
Albert Astals Cid's avatar
Albert Astals Cid committed
32

33
		setQuestion(i18nc("@title:group", p_map->getCapitalToDivisionQuestionPattern().toUtf8(), p_capital));
34
		p_radioButtons[i] -> setText(i18nc("@option:radio <City> is the capital of...", "%1", i18nc(p_map -> getFileName().toUtf8(), division.toUtf8())));
35
		b = true;
Albert Astals Cid's avatar
Albert Astals Cid committed
36
	}
37
38
39
40
41
42
43
44
45
46
47
	else
	{
		// There are crazy countries like Norway where two different divisions
		// have the same capital, avoid asking
		// Oslo is the capital of ...
		// Oslo (true)
		// Akershus (true)
		// Buskerud
		// Hedmark
		if (p_map -> getDivisionCapital(division) != p_capital)
		{
48
			p_radioButtons[i] -> setText(i18nc("@option:radio <City> is the capital of...", "%1", i18nc(p_map -> getFileName().toUtf8(), division.toUtf8())));
49
50
51
52
53
			b = true;
		}
		else b = false;
	}
	return b;
Albert Astals Cid's avatar
Albert Astals Cid committed
54
55
56
57
}

void capitalDivisionAsker::setAnswerHook(int userSays)
{
58
	p_currentAnswer.setAnswer(p_radioButtons[userSays] -> text());
Albert Astals Cid's avatar
Albert Astals Cid committed
59
60
61
62
}

QString capitalDivisionAsker::getQuestionHook() const
{
63
	QString divisionType = i18nc(p_map -> getFileName().toUtf8(), p_map->getDivisionsString().toUtf8());
64
65
	return i18nc("@title", p_map->getCapitalToDivisionTitle().toUtf8());
	//return i18nc("@title", p_map->getCapitalToDivisionTitle().toUtf8(), divisionType);
66
}