#include "course-dialog.h"
#include "score-common.h"
+#include "table-model.h"
+////////////////////////////////////////////////////////////////////////////////
+// CourseWindow based on QMainWindow
+////////////////////////////////////////////////////////////////////////////////
+CourseWindow::CourseWindow(QWidget *parent) : QMainWindow(parent)
+{
+#ifdef Q_WS_MAEMO_5
+ setAttribute(Qt::WA_Maemo5StackedWindow);
+#endif
+
+ QAction *editAction = new QAction(tr("Edit"), this);
+ connect(editAction, SIGNAL(triggered()), parent, SLOT(editCourse()));
+ menuBar()->addAction(editAction);
+
+ QAction *delAction = new QAction(tr("Delete"), this);
+ connect(delAction, SIGNAL(triggered()), parent, SLOT(deleteCourse()));
+ menuBar()->addAction(delAction);
+
+ model = new CourseTableModel;
+
+ QTableView * table = new QTableView;
+ table->showGrid();
+ table->setSelectionMode(QAbstractItemView::NoSelection);
+ table->setStyleSheet(defaultStyleSheet);
+ table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
+ table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
+ table->horizontalHeader()->hide();
+ table->setModel(model);
+
+ QWidget *central = new QWidget(this);
+ setCentralWidget(central);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(table);
+
+ central->setLayout(layout);
+}
+
+void CourseWindow::setup(Course *course)
+{
+ QString title = QString("Course: %1, Par - %2").arg(course->getName()).arg(course->getTotal(Total));
+ setWindowTitle(title);
+
+ model->set(course);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// CourseSelectDialog based on QDialog
+////////////////////////////////////////////////////////////////////////////////
CourseSelectDialog::CourseSelectDialog(QWidget *parent) : QDialog(parent)
{
QWidget *centralWidget = new QWidget(this);
connect(pushButtonNext, SIGNAL(clicked()), this, SLOT(next()));
+ QDialogButtonBox * buttonBox = new QDialogButtonBox(Qt::Vertical);
+ buttonBox->addButton(pushButtonNext, QDialogButtonBox::ActionRole);
+
leftLayout = new QVBoxLayout;
leftLayout->addWidget(lineEditClub);
leftLayout->addWidget(lineEditCourse);
rightLayout = new QVBoxLayout;
rightLayout->addStretch();
- rightLayout->addWidget(pushButtonNext);
+ rightLayout->addWidget(buttonBox);
QHBoxLayout *mainLayout = new QHBoxLayout(parent);
mainLayout->addLayout(leftLayout);
}
////////////////////////////////////////////////////////////////////////////////
+// CourseDialog based on QDialog
////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-
CourseDialog::CourseDialog(QWidget *parent) : QDialog(parent)
{
resize(800, 400);
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(pushButtonUp);
- rightLayout->addWidget(pushButtonDown);
- rightLayout->addWidget(pushButtonNext);
+ rightLayout->addWidget(buttonBoxUp);
rightLayout->addStretch();
- rightLayout->addWidget(pushButtonFinish);
+ rightLayout->addWidget(buttonBoxDown);
QHBoxLayout *mainLayout = new QHBoxLayout(parent);
mainLayout->addLayout(leftLayout);
void CourseDialog::createButton(QWidget *parent)
{
+ Q_UNUSED(parent);
pushButtonUp = new QPushButton(tr("+"));
connect(pushButtonUp, SIGNAL(clicked()), this, SLOT(up()));
table->horizontalHeader()->hide();
table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
- table->setStyleSheet(ScoreColor::styleSheet());
+ table->setStyleSheet(defaultStyleSheet);
}
void CourseDialog::init(Course *course)
QTableWidgetItem *len = new QTableWidgetItem("");
QTableWidgetItem *holeNum = new QTableWidgetItem(QString::number(i+1));
- holeNum->setBackgroundColor(ScoreColor::holeBg());
+ holeNum->setForeground(ScoreColor::holeBg());
+ holeNum->setFlags(Qt::NoItemFlags);
holeNum->setTextAlignment(Qt::AlignCenter);
par->setTextAlignment(Qt::AlignCenter);
hcp->setTextAlignment(Qt::AlignCenter);
len->setTextAlignment(Qt::AlignCenter);
+ // len is not in use - here just to confuse ;(
+ len->setFlags(Qt::NoItemFlags);
if (i < 9) {
table->setItem(0, i, holeNum);
table->setItem(7, i-9, len);
}
}
+ table->setCurrentCell(1, 0);
}
void CourseDialog::up(void)