void CourseDialog::init(Course *course)
{
QTableWidgetItem *par, *hcp;
+ QColor fgColor(Qt::white);
+ QColor bgColor(Qt::black);
for (int i=0; i<18; i++) {
if (course) {
QTableWidgetItem *len = new QTableWidgetItem("");
QTableWidgetItem *holeNum = new QTableWidgetItem(QString::number(i+1));
- QColor bgColor(Qt::gray);
+ holeNum->setTextColor(fgColor);
holeNum->setBackgroundColor(bgColor);
holeNum->setTextAlignment(Qt::AlignCenter);
table->setItem(7, i-9, len);
}
}
-
}
void CourseDialog::up(void)
createStatusBar();
createLayout(centralWidget);
-
}
void MainWindow::loadSettings(void)
connect(lastButton, SIGNAL(clicked()), this, SLOT(lastButtonClicked()));
scoreTableModel = new ScoreTableModel();
- scoreTableModel->setScore(scoreList);
- scoreTableModel->setClub(clubList);
table->showGrid();
table->setModel(scoreTableModel);
+ QItemSelectionModel selectionModel();
+ table->setSelectionMode(QAbstractItemView::NoSelection);
+
+ scoreTableModel->setScore(scoreList);
+ scoreTableModel->setClub(clubList);
// Fill out all the space with the tables
table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
}
}
else {
+ // New club and course
club = new Club(clubName);
course = new Course(courseName, par, hcp);
club->addCourse(course);
// TODO: does this really work? No mem leaks?
scoreTableModel->setClub(clubList);
-
}
}
}
void ScoreDialog::init(Course *course, Score *score)
{
QTableWidgetItem *par, *hcp, *scoreItem, *holeNum;
- QColor bgColor(Qt::gray);
+ QColor fgColor(Qt::white);
+ QColor bgColor(Qt::black);
for (int i = 0; i < 18; i++) {
par = new QTableWidgetItem(course->getPar(i));
scoreItem = new QTableWidgetItem("");
holeNum = new QTableWidgetItem(QString::number(i+1));
+ holeNum->setTextColor(fgColor);
holeNum->setBackgroundColor(bgColor);
par->setTextAlignment(Qt::AlignCenter);
QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
{
- if (!index.isValid())
- return QVariant();
+ // TODO: move away from the stack
+ QColor colorHoleBg(Qt::black);
+ QColor colorHoleFg(Qt::white);
+ QColor colorBirdie(Qt::yellow);
+ QColor colorPar(Qt::green);
+ QColor colorBogey(Qt::darkGreen);
+ QColor colorDoubleBogey(Qt::cyan);
+ QColor colorBad(Qt::white);
+ QColor colorSubTotal(Qt::lightGray);
+ QColor colorTotal(Qt::gray);
- if (!course || !score)
+ if (!index.isValid())
return QVariant();
int row = index.row();
//
// COLORS
//
- QColor colorHoleBg(Qt::black);
- QColor colorHoleFg(Qt::white);
- QColor colorBirdie(Qt::yellow);
- QColor colorPar(Qt::green);
- QColor colorBogey(Qt::darkGreen);
- QColor colorDoubleBogey(Qt::cyan);
- QColor colorBad(Qt::white);
- QColor colorSubTotal(Qt::lightGray);
- QColor colorTotal(Qt::gray);
-
if (role == Qt::ForegroundRole) {
if (row == ROW_HOLE || row == ROW_HOLE_2) {
QBrush brush(colorHoleFg);
return brush;
}
- if (row == ROW_SCORE || row == ROW_SCORE_2) {
+ if (score && course && (row == ROW_SCORE || row == ROW_SCORE_2)) {
int par;
int shots;
if (row == ROW_SCORE) {
return QString("In");
// In/Out for par
- if (row == ROW_PAR)
+ if (score && course && row == ROW_PAR)
return course->getTotal(TotalOut);
- if (row == ROW_PAR_2)
+ if (score && course && row == ROW_PAR_2)
return course->getTotal(TotalIn);
// In/Out for score
- if (row == ROW_SCORE)
+ if (score && row == ROW_SCORE)
return score->getTotal(TotalOut);
- if (row == ROW_SCORE_2)
+ if (score && row == ROW_SCORE_2)
return score->getTotal(TotalIn);
}
if (row == ROW_HOLE_2)
return QString("Tot");
// Total score
- if (row == ROW_PAR_2)
+ if (score && course && row == ROW_PAR_2)
return course->getTotal(Total);
- if (row == ROW_SCORE_2)
+ if (score && row == ROW_SCORE_2)
return score->getTotal(Total);
}
else {
case ROW_HOLE_2:
return col + 10;
case ROW_PAR:
- return course->getPar(col);
+ if (score && course)
+ return course->getPar(col);
case ROW_PAR_2:
- return course->getPar(col + 9);
+ if (score && course)
+ return course->getPar(col + 9);
case ROW_HCP:
- return course->getHcp(col);
- case ROW_HCP_2:
- return course->getHcp(col + 9);
- case ROW_SCORE:
- return score->getScore(col);
+ if (score && course)
+ return course->getHcp(col);
+ case ROW_HCP_2:
+ if (score && course)
+ return course->getHcp(col + 9);
+ case ROW_SCORE:
+ if (score)
+ return score->getScore(col);
case ROW_SCORE_2:
- return score->getScore(col + 9);
+ if (score)
+ return score->getScore(col + 9);
}
}
}