// Fill out all the space with the tables
table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
+ table->verticalHeader()->setAutoFillBackground(true);
table->horizontalHeader()->hide();
}
void MainWindow::createMenus()
{
- menu = menuBar()->addMenu(tr("fremantle"));
+ menu = menuBar()->addMenu("");
#if 0
menu->addAction(viewScoreAct);
menu->addAction(viewCourseAct);
QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
{
// TODO: move away from the stack
- QColor colorHoleBg(Qt::black);
- QColor colorHoleFg(Qt::white);
+ QColor colorHoleBg(Qt::darkGray);
+ QColor colorHoleFg(Qt::yellow);
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);
+ QColor colorDoubleBogey(Qt::red);
+ QColor colorBad(Qt::red);
+ QColor colorSubTotal(Qt::black);
+ QColor colorTotal(Qt::black);
if (!index.isValid())
return QVariant();
//
// COLORS
//
- if (role == Qt::ForegroundRole) {
- if (row == ROW_HOLE || row == ROW_HOLE_2) {
- QBrush brush(colorHoleFg);
- return brush;
- }
- }
if (role == Qt::BackgroundRole) {
// Hole numbers 1-18
if (row == ROW_HOLE || row == ROW_HOLE_2) {
QBrush brush(colorHoleBg);
return brush;
}
-
if (score && course && (row == ROW_SCORE || row == ROW_SCORE_2)) {
int par;
int shots;
QBrush brush(colorDoubleBogey);
return brush;
}
+ if (shots > (par+2)) {
+ // Very bad
+ QBrush brush(colorBad);
+ return brush;
+ }
}
}
return QVariant();
QVariant ScoreTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
- if (role != Qt::DisplayRole)
- return QVariant();
-
- // TODO: how to diff between the two table views (no index?)
-
- if (orientation == Qt::Horizontal)
- if (section >= 0 && section <= 8)
- return QString("%1").arg(section+1);
- else if (section == 9)
- return QString(""); // was: I/O
- else
- return QString(""); // was: Tot
- else {
- switch(section) {
- case ROW_PAR:
- case ROW_PAR_2:
- return QString("Par");
- case ROW_HCP:
- case ROW_HCP_2:
- return QString("HCP");
- case ROW_SCORE:
- case ROW_SCORE_2:
- return QString("Score");
- }
+ // Only vertical header -- horizontal is hidden
+ if (orientation == Qt::Horizontal)
+ return QVariant();
+
+#if 1
+ if (role == Qt::BackgroundRole) {
+ QColor colorHoleBg(Qt::darkGray);
+ QBrush brush(colorHoleBg);
+ return brush;
+ }
+#endif
+ if (role == Qt::DisplayRole) {
+ switch(section) {
+ case ROW_PAR:
+ case ROW_PAR_2:
+ return QString("Par");
+ case ROW_HCP:
+ case ROW_HCP_2:
+ return QString("HCP");
+ case ROW_SCORE:
+ case ROW_SCORE_2:
+ return QString("Score");
}
return QVariant();
+ }
+
+ return QVariant();
}