From 9f253355def947c7e2bfa76f9d830d4fa997a618 Mon Sep 17 00:00:00 2001 From: Sakari Poussa Date: Sun, 8 Nov 2009 23:50:51 +0200 Subject: [PATCH] new colors and menu settings to adapt new qt libs --- src/course-dialog.cpp | 2 +- src/main-window.cpp | 3 +- src/score-dialog.cpp | 2 +- src/table-model.cpp | 73 ++++++++++++++++++++++++------------------------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/course-dialog.cpp b/src/course-dialog.cpp index e51e335..b14b444 100644 --- a/src/course-dialog.cpp +++ b/src/course-dialog.cpp @@ -133,7 +133,7 @@ void CourseDialog::init(Course *course) { QTableWidgetItem *par, *hcp; QColor fgColor(Qt::white); - QColor bgColor(Qt::black); + QColor bgColor(Qt::darkGray); for (int i=0; i<18; i++) { if (course) { diff --git a/src/main-window.cpp b/src/main-window.cpp index c575116..d622f56 100644 --- a/src/main-window.cpp +++ b/src/main-window.cpp @@ -135,6 +135,7 @@ void MainWindow::createTableView(QList &scoreList, QList &club // 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(); } @@ -231,7 +232,7 @@ void MainWindow::createActions() void MainWindow::createMenus() { - menu = menuBar()->addMenu(tr("fremantle")); + menu = menuBar()->addMenu(""); #if 0 menu->addAction(viewScoreAct); menu->addAction(viewCourseAct); diff --git a/src/score-dialog.cpp b/src/score-dialog.cpp index d0b6d51..086c012 100644 --- a/src/score-dialog.cpp +++ b/src/score-dialog.cpp @@ -168,7 +168,7 @@ void ScoreDialog::init(Course *course, Score *score) { QTableWidgetItem *par, *hcp, *scoreItem, *holeNum; QColor fgColor(Qt::white); - QColor bgColor(Qt::black); + QColor bgColor(Qt::darkGray); for (int i = 0; i < 18; i++) { par = new QTableWidgetItem(course->getPar(i)); diff --git a/src/table-model.cpp b/src/table-model.cpp index e2f3d8d..6ef8bc8 100644 --- a/src/table-model.cpp +++ b/src/table-model.cpp @@ -179,15 +179,15 @@ QModelIndex ScoreTableModel::index(int row, int column, const QModelIndex &paren 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(); @@ -208,19 +208,12 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const // // 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; @@ -264,6 +257,11 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const QBrush brush(colorDoubleBogey); return brush; } + if (shots > (par+2)) { + // Very bad + QBrush brush(colorBad); + return brush; + } } } return QVariant(); @@ -352,31 +350,32 @@ int ScoreTableModel::setItem(int row, int col, int data) 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(); } -- 1.7.9.5