Use common colors and style sheets for all windows and dialogs
authorSakari Poussa <spoussa@gmail.com>
Sat, 26 Dec 2009 11:00:29 +0000 (13:00 +0200)
committerSakari Poussa <spoussa@gmail.com>
Sat, 26 Dec 2009 11:00:29 +0000 (13:00 +0200)
TODO
src/course-dialog.cpp
src/main-window.cpp
src/score-dialog.cpp
src/table-model.cpp

diff --git a/TODO b/TODO
index 3bd8e45..0d02784 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,11 @@
 TOP Items
 
 TODO General:
+- Always: when enterin ultiple scores, course does not update on
+  mainwiew. Window title is correct, but par/hcp info is not from the
+  same course. Next/prev few times corrects the problem.
+- New score dialog should be the same as main view (f.ex showing
+  subtotals, totals, and score colors).
 - edit course table is selectable (chk others)
 - split club/course DB in master and user
 - If course is in the score but not in course, navogating away from
@@ -12,6 +17,8 @@ TODO General:
   - Seems to be bug in the Qt/Maemo
 - Date picker button (widget is missing)
 - Use syslog
+- Year filters and maybe more, must be easy to apply
+
 
 TODO Hildon 2.2
 - Replace LineEdit w/ HildonEntry
index 9b6273b..fff235e 100644 (file)
@@ -13,8 +13,7 @@
 #include <QtGui/QTableWidget>
 
 #include "course-dialog.h"
-#include "cell-delegate.h"
-
+#include "score-common.h"
 
 CourseSelectDialog::CourseSelectDialog(QWidget *parent) : QDialog(parent)
 {
@@ -135,13 +134,12 @@ void CourseDialog::createTable(QWidget *parent)
   table->horizontalHeader()->hide();
   table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
   table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
+  table->setStyleSheet(ScoreColor::styleSheet());
 }
 
 void CourseDialog::init(Course *course)
 {
   QTableWidgetItem *par, *hcp;
-  QColor fgColor(Qt::white);
-  QColor bgColor(Qt::darkGray);
 
   for (int i=0; i<18; i++) {
     if (course) {
@@ -155,8 +153,7 @@ void CourseDialog::init(Course *course)
     QTableWidgetItem *len = new QTableWidgetItem("");
 
     QTableWidgetItem *holeNum = new QTableWidgetItem(QString::number(i+1));
-    holeNum->setTextColor(fgColor);
-    holeNum->setBackgroundColor(bgColor);
+    holeNum->setBackgroundColor(ScoreColor::holeBg());
 
     holeNum->setTextAlignment(Qt::AlignCenter);
     par->setTextAlignment(Qt::AlignCenter);
index 2296b9e..a7b1a88 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <QtGui>
 
+#include "score-common.h"
 #include "main-window.h"
 #include "score-dialog.h"
 #include "course-dialog.h"
@@ -126,6 +127,8 @@ void MainWindow::createTableView(QList<Score *> &scoreList, QList <Club *> &club
 
   table->showGrid();
 
+  table->setStyleSheet(ScoreColor::styleSheet());
+
   table->setModel(scoreTableModel);
   table->setSelectionMode(QAbstractItemView::NoSelection);
 
@@ -136,7 +139,7 @@ void MainWindow::createTableView(QList<Score *> &scoreList, QList <Club *> &club
   table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
   table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
   table->horizontalHeader()->hide();
-  table->verticalHeader()->setStyleSheet("background-color: yellow; color : gray }");
+  //table->verticalHeader()->setStyleSheet("color : gray }");
 }
 
 void MainWindow::createActions()
index 443bfd2..4b42593 100644 (file)
@@ -10,6 +10,7 @@
 #include <QInputContext>
 
 #include "score-dialog.h"
+#include "score-common.h"
 
 SelectDialog::SelectDialog(QWidget *parent) : QDialog(parent)
 {
@@ -152,6 +153,8 @@ void ScoreDialog::createTable(QWidget *parent)
   table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
   table->horizontalHeader()->hide();
 
+  table->setStyleSheet(ScoreColor::styleSheet());
+
   QStringList headers;
   headers << "" << "Par" << "HCP" << "Score" << "" << "Par" << "HCP" << "Score";
   table->setVerticalHeaderLabels(headers);
@@ -175,8 +178,6 @@ void ScoreDialog::createButton(QWidget *parent)
 void ScoreDialog::init(Course *course, Score *score)
 {
   QTableWidgetItem *par, *hcp, *scoreItem, *holeNum;
-  QColor fgColor(Qt::white);
-  QColor bgColor(Qt::darkGray);
 
   for (int i = 0; i < 18; i++) {
     par = new QTableWidgetItem(course->getPar(i));
@@ -187,8 +188,7 @@ void ScoreDialog::init(Course *course, Score *score)
       scoreItem = new QTableWidgetItem("");
     holeNum = new QTableWidgetItem(QString::number(i+1));
 
-    holeNum->setTextColor(fgColor);
-    holeNum->setBackgroundColor(bgColor);
+    holeNum->setBackgroundColor(ScoreColor::holeBg());
 
     par->setTextAlignment(Qt::AlignCenter);
     hcp->setTextAlignment(Qt::AlignCenter);
index 2a8e3c0..6c490ed 100644 (file)
@@ -12,6 +12,8 @@
 #include "table-model.h"
 #include "score-common.h"
 
+QString empty("");
+
 Qt::ItemFlags ScoreTableModel::flags (const QModelIndex &)
 {
   return 0;
@@ -207,8 +209,8 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
     // Hole numbers 1-18. All hole nums, in, out and tot cell but not
     // the empty cell.
     if ((row == ROW_HOLE && col != 10) || row == ROW_HOLE_2) {
-       QBrush brush(colorHoleBg);
-       return brush;
+      QBrush brush(ScoreColor::holeBg());
+      return brush;
     }
     if (score && course && (row == ROW_SCORE || row == ROW_SCORE_2)) {
       int par;
@@ -224,38 +226,38 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
 
       if (col == (COLS+1) && row == ROW_SCORE_2) {
        // Total score
-       QBrush brush(colorTotal);
+       QBrush brush(ScoreColor::total());
        return brush;
       }
       if (col == COLS) {
        // In and Out scores
-       QBrush brush(colorSubTotal);
+       QBrush brush(ScoreColor::subTotal());
        return brush;
       }
       if (col < COLS) {
        if (shots == par) {
          // Par
-         QBrush brush(colorPar);
+         QBrush brush(ScoreColor::par());
          return brush;
        }
        if (shots == (par-1)) {
          // Birdie
-         QBrush brush(colorBirdie);
+         QBrush brush(ScoreColor::birdie());
          return brush;
        }
        if (shots == (par+1)) {
          // Bogey
-         QBrush brush(colorBogey);
+         QBrush brush(ScoreColor::bogey());
          return brush;
        }
        if (shots == (par+2)) {
          // Double Bogey
-         QBrush brush(colorDoubleBogey);
+         QBrush brush(ScoreColor::doubleBogey());
          return brush;
        }
        if (shots > (par+2)) {
          // Very bad
-         QBrush brush(colorBad);
+         QBrush brush(ScoreColor::bad());
          return brush;
        }
       }