+
+////////////////////////////////////////////////////////////////////////////////
+// ScoreDialogSingle based on QDialog
+// Usage: edit scorecard data for single hole
+////////////////////////////////////////////////////////////////////////////////
+ScoreDialogSingle::ScoreDialogSingle(QWidget *parent) : QDialog(parent)
+{
+ TRACE;
+ resize(800, 400);
+ QFont font;
+ font.setPointSize(fontSize);
+ setFont(font);
+
+ QWidget *centralWidget = new QWidget(this);
+
+ createTable();
+ createButton();
+
+ createLayout(centralWidget);
+}
+
+ScoreDialogSingle::~ScoreDialogSingle()
+{
+ //if (centralWidget)
+ // delete centralWidget;
+ if (leftLayout)
+ delete leftLayout;
+ if (rightLayout)
+ delete rightLayout;
+ //if (mainLayout)
+ // delete mainLayout;
+ if (table)
+ delete table;
+}
+
+void ScoreDialogSingle::createLayout(QWidget *parent)
+{
+ TRACE;
+ leftLayout = new QVBoxLayout;
+ leftLayout->addWidget(table);
+
+ QDialogButtonBox * buttonBoxUp = new QDialogButtonBox(Qt::Vertical);
+ buttonBoxUp->addButton(pushButtonUp, QDialogButtonBox::ActionRole);
+ buttonBoxUp->addButton(pushButtonDown, QDialogButtonBox::ActionRole);
+ buttonBoxUp->addButton(pushButtonNext, QDialogButtonBox::ActionRole);
+
+ QDialogButtonBox * buttonBoxDown = new QDialogButtonBox(Qt::Vertical);
+ buttonBoxDown->addButton(pushButtonFinish, QDialogButtonBox::ActionRole);
+
+ rightLayout = new QVBoxLayout;
+ rightLayout->addWidget(buttonBoxUp);
+ rightLayout->addStretch();
+ rightLayout->addWidget(buttonBoxDown);
+
+ QHBoxLayout *mainLayout = new QHBoxLayout(parent);
+ mainLayout->addLayout(leftLayout);
+ mainLayout->addLayout(rightLayout);
+ setLayout(mainLayout);
+}
+
+void ScoreDialogSingle::createTable(QWidget *parent)
+{
+ TRACE;
+ table = new QTableWidget(5, 5, parent);
+
+ table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
+ table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
+ table->horizontalHeader()->hide();
+
+ table->setStyleSheet(defaultStyleSheet);
+
+ QStringList headers;
+ headers << "" << "Par" << "HCP" << "Score" << "" << "Par" << "HCP" << "Score";
+ table->setVerticalHeaderLabels(headers);
+}
+
+void ScoreDialogSingle::createButton(QWidget *parent)
+{
+ TRACE;
+ Q_UNUSED(parent);
+ pushButtonUp = new QPushButton(tr("+"));
+ connect(pushButtonUp, SIGNAL(clicked()), this, SLOT(up()));
+
+ pushButtonDown = new QPushButton(tr("-"));
+ connect(pushButtonDown, SIGNAL(clicked()), this, SLOT(down()));
+
+ pushButtonNext = new QPushButton(tr("Next"));
+ connect(pushButtonNext, SIGNAL(clicked()), this, SLOT(next()));
+
+ pushButtonFinish = new QPushButton(tr("Finish"));
+ connect(pushButtonFinish, SIGNAL(clicked()), this, SLOT(finish()));
+}