Commit 7ffef258 authored by Laurent Garnier's avatar Laurent Garnier
Browse files

Adding optional tags for (english) question patterns and titles to kgm format,...

Adding optional tags for (english) question patterns and titles to kgm format, to give answer to bug 209889

svn path=/trunk/KDE/kdeedu/kgeography/; revision=1035761
parent 52d011de
......@@ -2,6 +2,10 @@
<mapFile>world_continents.png</mapFile>
<name>World continents (from North Pole)</name>
<divisionsName>Continents</divisionsName>
<divisionToCapitalPattern>What is the highest summit of %1 ?</divisionToCapitalPattern>
<divisionToCapitalTitle>Continents by highest summit</divisionToCapitalTitle>
<capitalToDivisionPattern>Which has %1 as highest summit ?</capitalToDivisionPattern>
<capitalToDivisionTitle>Highest summit of continents</capitalToDivisionTitle>
<author>Laurent Garnier</author>
<division>
<name>Frontier</name>
......
......@@ -31,7 +31,7 @@ bool capitalDivisionAsker::nextBoxAskerQuestionHook(const QString &division, int
p_currentAnswer.setCorrectAnswer(i18nc("@option:radio <City> is the capital of...", "%1", i18nc(p_map -> getFileName().toUtf8(), division.toUtf8())));
QString capitalName = i18nc(p_map -> getFileName().toUtf8(), p_capital.toUtf8());
setQuestion(i18nc("@title:group", "%1 is the capital of...", capitalName));
setQuestion(i18nc("@title:group", p_map->getCapitalToDivisionQuestionPattern().toUtf8(), capitalName));
p_rb[i] -> setText(i18nc("@option:radio <City> is the capital of...", "%1", i18nc(p_map -> getFileName().toUtf8(), division.toUtf8())));
b = true;
}
......@@ -62,5 +62,6 @@ void capitalDivisionAsker::setAnswerHook(int userSays)
QString capitalDivisionAsker::getQuestionHook() const
{
QString divisionType = i18nc(p_map -> getFileName().toUtf8(), p_map->getDivisionsString().toUtf8());
return i18nc("@title", "%1 by Capital", divisionType);
return i18nc("@title", p_map->getCapitalToDivisionTitle().toUtf8());
//return i18nc("@title", p_map->getCapitalToDivisionTitle().toUtf8(), divisionType);
}
......@@ -28,7 +28,7 @@ bool divisionCapitalAsker::nextBoxAskerQuestionHook(const QString &division, int
if (isAnswer)
{
QString divisionName = i18nc(p_map -> getFileName().toUtf8(), division.toUtf8());
setQuestion(i18nc("@title:group", "The capital of %1 is...", divisionName));
setQuestion(i18nc("@title:group", p_map->getDivisionToCapitalQuestionPattern().toUtf8(), divisionName));
p_currentAnswer.setQuestion(i18nc("@item:intable column Question, %1 is region name", "%1", i18nc(p_map -> getFileName().toUtf8(), division.toUtf8())));
p_capital = p_map -> getDivisionCapital(division);
p_currentAnswer.setCorrectAnswer(i18nc("@option:radio The capital of <Region> is...", "%1", i18nc(p_map -> getFileName().toUtf8(), p_capital.toUtf8())));
......@@ -78,5 +78,5 @@ void divisionCapitalAsker::setAnswerHook(int userSays)
QString divisionCapitalAsker::getQuestionHook() const
{
QString divisionType = i18nc(p_map -> getFileName().toUtf8(), p_map->getDivisionsString().toUtf8());
return i18nc("@title", "Capital of %1", divisionType);
return i18nc("@title", p_map->getDivisionToCapitalTitle().toUtf8());
}
......@@ -379,8 +379,8 @@ void kgeography::setMap(KGmap *m)
p_askMap->setText(i18n("&Location of %1", divisionType));
p_askPlaceMap->setText(i18n("&Place %1 in the Map", divisionType));
p_askCapitalDivisions->setText(i18n("%1 by Capital", divisionType));
p_askDivisionCapitals->setText(i18n("&Capitals of %1", divisionType));
p_askCapitalDivisions->setText(i18nc("@title", p_map->getCapitalToDivisionTitle().toUtf8()));
p_askDivisionCapitals->setText(i18nc("@title", p_map->getDivisionToCapitalTitle().toUtf8()));
p_askFlagDivisions->setText(i18n("%1 by Flag", divisionType));
p_askDivisionFlags->setText(i18n("&Flags of %1", divisionType));
......
......@@ -22,6 +22,8 @@
KGmap::KGmap()
{
p_capitalToDivisionPattern = "%1 is the capital of...";
p_divisionToCapitalPattern = "The capital of %1 is...";
}
KGmap::~KGmap()
......@@ -68,6 +70,26 @@ void KGmap::setAuthor(const QString &s)
p_author = s;
}
void KGmap::setCapitalToDivisionQuestionPattern(const QString &str)
{
p_capitalToDivisionPattern = str;
}
void KGmap::setDivisionToCapitalQuestionPattern(const QString &str)
{
p_divisionToCapitalPattern = str;
}
void KGmap::setCapitalToDivisionTitle(const QString &str)
{
p_capitalToDivisionTitle = str;
}
void KGmap::setDivisionToCapitalTitle(const QString &str)
{
p_divisionToCapitalTitle = str;
}
uint KGmap::count(division::askMode am) const
{
uint count = 0;
......@@ -93,6 +115,26 @@ QStringList KGmap::getDivisionFalseCapitals(const QString &divisionName) const
return getDivision(divisionName) -> getFalseCapitals();
}
QString KGmap::getCapitalToDivisionQuestionPattern() const
{
return p_capitalToDivisionPattern;
}
QString KGmap::getDivisionToCapitalQuestionPattern() const
{
return p_divisionToCapitalPattern;
}
QString KGmap::getCapitalToDivisionTitle() const
{
return p_capitalToDivisionTitle;
}
QString KGmap::getDivisionToCapitalTitle() const
{
return p_divisionToCapitalTitle;
}
QString KGmap::getFile() const
{
return p_file;
......
......@@ -29,6 +29,10 @@ class KGmap
void setName(const QString &s);
void setDivisionsString(const QString &s);
void setAuthor(const QString &s);
void setCapitalToDivisionQuestionPattern(const QString &str);
void setDivisionToCapitalQuestionPattern(const QString &str);
void setCapitalToDivisionTitle(const QString &str);
void setDivisionToCapitalTitle(const QString &str);
// return the number of askable divisions
uint count(division::askMode am) const;
......@@ -46,6 +50,10 @@ class KGmap
QString getAuthor() const;
QColor getColor(const QString &s) const;
const QList<division*> getIgnoredDivisions(division::askMode am) const;
QString getCapitalToDivisionQuestionPattern() const;
QString getDivisionToCapitalQuestionPattern() const;
QString getCapitalToDivisionTitle() const;
QString getDivisionToCapitalTitle() const;
private:
division *getDivision(const QString &divisionName) const;
......@@ -55,6 +63,10 @@ class KGmap
QString p_name, p_file, p_mapFile;
QString p_divisionsString;
QString p_capitalToDivisionPattern;
QString p_divisionToCapitalPattern;
QString p_capitalToDivisionTitle;
QString p_divisionToCapitalTitle;
QString p_author;
};
......
......@@ -14,6 +14,7 @@
#include <QFileInfo>
#include <klocale.h>
#include <kdebug.h>
#include "division.h"
#include "map.h"
......@@ -49,7 +50,49 @@ KGmap *mapReader::parseMap(const QString &path)
}
// Divisions string
kgmap -> setDivisionsString( getElementString("divisionsName", root, Mandatory) );
QString divisionKindName = getElementString("divisionsName", root, Mandatory);
kgmap -> setDivisionsString(divisionKindName);
QString pat = getElementString("capitalToDivisionPattern", root, Optional);
if ( pat.contains('%') )
{
kgmap->setCapitalToDivisionQuestionPattern(pat);
}
else if ( ! pat.isEmpty() )
{
kDebug() << "capitalToDivisionPattern element should contain one '%%' in map " << kgmap->getName();
}
pat = getElementString("divisionToCapitalPattern", root, Optional);
if ( pat.contains('%') )
{
kgmap->setDivisionToCapitalQuestionPattern(pat);
}
else if ( ! pat.isEmpty() )
{
kDebug() << "divisionToCapitalPattern element should contain one '%%' in map " << kgmap->getName();
}
QString title = getElementString("capitalToDivisionTitle", root, Optional);
if ( ! title.isEmpty() )
{
kgmap->setCapitalToDivisionTitle(title);
}
else
{
kgmap->setCapitalToDivisionTitle(i18n("%1 by Capital", divisionKindName));
}
title = getElementString("divisionToCapitalTitle", root, Optional);
if ( ! title.isEmpty() )
{
kgmap->setDivisionToCapitalTitle(title);
}
else
{
kgmap->setDivisionToCapitalTitle(i18n("&Capitals of %1", divisionKindName));
}
// Author string
kgmap -> setAuthor( getElementString("author", root, Mandatory) );
......
......@@ -6802,6 +6802,10 @@ i18nc("world.kgm", "Greenland (Denmark)");
i18nc("world.kgm", "Nuuk");
i18nc("world_continents.kgm", "World continents (from North Pole)");
i18nc("world_continents.kgm", "Continents");
i18nc("@title:group", "What is the highest summit of %1 ?");
i18nc("@title", "Continents by highest summit");
i18nc("@title:group", "Which has %1 as highest summit ?");
i18nc("@title", "Highest summit of continents");
i18nc("world_continents.kgm", "Frontier");
i18nc("world_continents.kgm", "Water");
i18nc("world_continents.kgm", "Africa");
......
......@@ -179,7 +179,7 @@ void placeAsker::setCurrentDivision(const QString& division)
for (int y = minY; y < maxY; y++)
{
if (p_mapImage->pixel(x,y) == divColor)
p_currentDivisionImage->setPixel(x - minX, y - minY, p_mapImage->pixel(x,y));
p_currentDivisionImage->setPixel(x - minX, y - minY, divColor);
}
}
}
......
......@@ -83,6 +83,22 @@ int main(int argc, char *argv[])
{
os << "i18nc(\"" << *it << "\", \"" << n.firstChild().nodeValue() << "\");\n";
}
else if (n.nodeName() == "divisionToCapitalPattern")
{
os << "i18nc(\"@title:group\", \"" << n.firstChild().nodeValue() << "\");\n";
}
else if (n.nodeName() == "capitalToDivisionPattern")
{
os << "i18nc(\"@title:group\", \"" << n.firstChild().nodeValue() << "\");\n";
}
else if (n.nodeName() == "divisionToCapitalTitle")
{
os << "i18nc(\"@title\", \"" << n.firstChild().nodeValue() << "\");\n";
}
else if (n.nodeName() == "capitalToDivisionTitle")
{
os << "i18nc(\"@title\", \"" << n.firstChild().nodeValue() << "\");\n";
}
}
f -> close();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment