diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 (patch) | |
tree | d3bb9f5d25a2dc09ca81adecf39621d871534297 /kgeography/src/answersdialog.cpp | |
download | tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.tar.gz tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kgeography/src/answersdialog.cpp')
-rw-r--r-- | kgeography/src/answersdialog.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/kgeography/src/answersdialog.cpp b/kgeography/src/answersdialog.cpp new file mode 100644 index 00000000..a9925b6d --- /dev/null +++ b/kgeography/src/answersdialog.cpp @@ -0,0 +1,95 @@ +/*************************************************************************** + * Copyright (C) 2004-2005 by Albert Astals Cid * + * tsdgeos@terra.es * + * * + * 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. * + ***************************************************************************/ + +#include <klocale.h> + +#include <qlabel.h> +#include <qlayout.h> +#include <qscrollview.h> + +#include "answer.h" +#include "answersdialog.h" + +answersDialog::answersDialog(QWidget *parent, const QValueVector<userAnswer> &userAnswers, QString question, int correctAnswers) : KDialogBase(parent, 0, true, i18n("Your Answers Were"), Ok) +{ + QLabel *l1, *l2, *l3; + QFont boldFont, bigFont; + uint totalAnswers; + totalAnswers = userAnswers.count(); + + p_sv = new QScrollView(this); + setMainWidget(p_sv); + + p_container = new QWidget(p_sv -> viewport()); + p_sv -> viewport() -> setPaletteBackgroundColor(p_container -> paletteBackgroundColor()); + + QGridLayout *lay = new QGridLayout(p_container); + lay -> setColStretch(0, 1); + lay -> setColStretch(4, 1); + lay -> setRowStretch(totalAnswers + 4, 1); + + // Title + bigFont = p_container -> font(); + bigFont.setPointSize(24); + l1 = new QLabel(question, p_container); + l1 -> setFont(bigFont); + l1 -> setAlignment(Qt::AlignCenter); + lay->addMultiCellWidget(l1, 0, 0, 0, 4); + + // Headers + boldFont = p_container -> font(); + boldFont.setBold(true); + + l1 = new QLabel(i18n("Question"), p_container); + l1 -> setFont(boldFont); + l2 = new QLabel(i18n("Your Answer"), p_container); + l2 -> setFont(boldFont); + l3 = new QLabel(i18n("Correct Answer"), p_container); + l3 -> setFont(boldFont); + l1 -> setMargin(KDialog::marginHint() / 2); + l2 -> setMargin(KDialog::marginHint() / 2); + l3 -> setMargin(KDialog::marginHint() / 2); + lay->addWidget(l1, 1, 1); + lay->addWidget(l2, 1, 2); + lay->addWidget(l3, 1, 3); + + for(uint i = 0; i < totalAnswers; i++) + { + userAnswers[i].putWidgets(p_container, lay, i + 2); + } + + lay -> addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), totalAnswers + 3, 2); + + l1 = new QLabel(i18n("You answered correctly %1 out of %2 questions.").arg(correctAnswers).arg(totalAnswers), p_container); + l1 -> setAlignment(Qt::AlignCenter); + lay->addMultiCellWidget(l1, totalAnswers + 4, totalAnswers + 4, 0, 4); + + p_sv -> addChild(p_container); + resize(500, 500); +} + +void answersDialog::showEvent(QShowEvent *) +{ + positionContainer(); +} + +void answersDialog::resizeEvent(QResizeEvent *) +{ + positionContainer(); +} + +void answersDialog::positionContainer() +{ + int x = p_sv -> viewport() -> width() - p_container -> width(); + x = x / 2; + if (x < 0) x = 0; + p_sv -> moveChild(p_container, x, 0); +} + |