Commit a2688e00 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos Committed by Albert Astals Cid

Add location name in results table

In "Location of Countries" quiz, the table of results displays only the
color of the user answer. As mentioned in bug report, in maps with many
countries, it could be useful to display the name of the location
selected by the user. So, results table has been enhanced displaying
location names as well.

BUGS: 141442
parent 36df67a2
......@@ -66,7 +66,6 @@ void userAnswer::putWidgets(QWidget *w, QGridLayout *lay, int row, int margin) c
if (i == 0) v = &p_question;
else if (i == 1) v = &p_answer;
else v = &p_correctAnswer;
if (v -> type() == QVariant::String)
{
QLabel *l;
......@@ -87,6 +86,34 @@ void userAnswer::putWidgets(QWidget *w, QGridLayout *lay, int row, int margin) c
lay -> setMargin(2);
lay -> setSpacing(2);
widgets[i] = aux;
}
else if (v -> type() == QVariant::List)
{
QVariantList vl = v->value<QVariantList>();
QVariant vi;
QWidget *aux = new QWidget(w);
QHBoxLayout *lay = new QHBoxLayout(aux);
QLabel *coloredLabel = new QLabel(aux);
lay -> addWidget(coloredLabel);
coloredLabel-> setAutoFillBackground(true);
coloredLabel-> setMargin(margin);
lay -> setMargin(2);
lay -> setSpacing(2);
for (int i=0; i<vl.count(); i++)
{
vi = vl[i];
if(vi.type() == QVariant::Color)
{
coloredLabel -> setPalette(QPalette(vi.value<QColor>()));
}
if(vi.type() == QVariant::String)
{
coloredLabel -> setText(vi.value<QString>());
}
}
widgets[i] = aux;
}
else if (v -> type() == QVariant::Pixmap)
{
......
......@@ -232,3 +232,8 @@ bool KGmap::getDivisionCanAsk(const QString &div, division::askMode am) const
{
return getDivision(div) -> canAsk(am);
}
division *KGmap::getDivisionByRgb(QRgb c) const
{
return getDivision(c);
}
......@@ -55,6 +55,10 @@ class KGmap
QString getDivisionToCapitalQuestionPattern() const;
QString getCapitalToDivisionTitle() const;
QString getDivisionToCapitalTitle() const;
/**
* Public alternative of getDivision(QRgb c)
*/
division *getDivisionByRgb(QRgb c) const;
private:
division *getDivision(const QString &divisionName) const;
......
......@@ -162,7 +162,26 @@ void mapAsker::handleMapClick(QRgb c, const QPoint &p)
else if (!aux.isEmpty())
{
p_currentAnswer.setCorrectAnswer(QColor(correctRgb));
p_currentAnswer.setAnswer(QColor(colorSeen));
QVariantList vAnswer;
QColor vColor = QColor(colorSeen);
QRgb vColorRgb = vColor.toRgb().rgb();
vAnswer.append(vColor);
QString vDivisionName;
QRgb origColor;
division * vDivision;
if (kgeographySettings::self()->colorDisguise() == kgeographySettings::EnumColorDisguise::Scramble)
{
int i = p_shuffledColormap.indexOf(vColorRgb);
origColor = p_originalColormap[i];
vDivision = p_map->getDivisionByRgb(origColor);
}
else
{
vDivision = p_map->getDivisionByRgb(vColorRgb);
}
vDivisionName = i18nc(p_map -> getFileName().toUtf8(), vDivision->getName().toUtf8());
vAnswer.append(vDivisionName);
p_currentAnswer.setAnswer(vAnswer);
questionAnswered(aux == correctDivision);
nextQuestion();
}
......
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