From b6715c6c05dea4c4e4b57def769b68e44d671cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Thu, 10 Jan 2013 15:06:07 +0100 Subject: [PATCH] HintsDialog: display the cost of each hint (optional) --- qt/hints_dialog.cpp | 20 +++++++++++++++----- qt/hints_dialog.h | 7 +++++-- qt/topping_widget.cpp | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/qt/hints_dialog.cpp b/qt/hints_dialog.cpp index d50f8b0..1566f72 100644 --- a/qt/hints_dialog.cpp +++ b/qt/hints_dialog.cpp @@ -49,12 +49,16 @@ struct CostComparator : public binary_functionsetToolTip(qfl(m_hint.getDescription())); layout->addWidget(label); @@ -77,15 +81,21 @@ void HintWidget::buttonClicked() -HintsDialog::HintsDialog(QWidget *parent) - : QDialog(parent), m_move(NULL) +HintsDialog::HintsDialog(QWidget *parent, bool iShowCosts) + : QDialog(parent), m_move(NULL), m_showCosts(iShowCosts) { initializeHints(); QVBoxLayout *vLayout = new QVBoxLayout(this); + if (m_showCosts) + { + QLabel *label = new QLabel(_q("Each hint has a corresponding cost, seen as a time penalty.")); + label->setWordWrap(true); + vLayout->addWidget(label); + } Q_FOREACH(const AbstractHint *hint, m_allHints) { - HintWidget *hintWidget = new HintWidget(*hint); + HintWidget *hintWidget = new HintWidget(*hint, m_showCosts); QObject::connect(hintWidget, SIGNAL(hintRequested(const AbstractHint&)), this, SLOT(showHint(const AbstractHint&))); vLayout->addWidget(hintWidget); diff --git a/qt/hints_dialog.h b/qt/hints_dialog.h index dbf42bf..58ea04a 100644 --- a/qt/hints_dialog.h +++ b/qt/hints_dialog.h @@ -43,7 +43,9 @@ class HintWidget: public QWidget DEFINE_LOGGER(); public: - explicit HintWidget(const AbstractHint &iHint, QWidget *parent = 0); + explicit HintWidget(const AbstractHint &iHint, + bool iShowCosts, + QWidget *parent = 0); const AbstractHint & getHint() const { return m_hint; } @@ -68,7 +70,7 @@ class HintsDialog: public QDialog DEFINE_LOGGER(); public: - explicit HintsDialog(QWidget *parent = 0); + explicit HintsDialog(QWidget *parent = 0, bool iShowCosts = false); ~HintsDialog(); public slots: @@ -84,6 +86,7 @@ private slots: private: const Move *m_move; vector m_allHints; + bool m_showCosts; /// Initialize the m_allHints vector void initializeHints(); diff --git a/qt/topping_widget.cpp b/qt/topping_widget.cpp index 526ec8e..c6f53b9 100644 --- a/qt/topping_widget.cpp +++ b/qt/topping_widget.cpp @@ -48,7 +48,7 @@ ToppingWidget::ToppingWidget(QWidget *parent, PlayModel &iPlayModel, PublicGame { setupUi(this); - m_hintsDialog = new HintsDialog(this); + m_hintsDialog = new HintsDialog(this, true); QObject::connect(m_hintsDialog, SIGNAL(hintUsed(const AbstractHint&)), this, SLOT(hintUsed(const AbstractHint&)));