And some more colors. Seems to be hard to change HeaderView background
authorSakari Poussa <spoussa@gmail.com>
Thu, 17 Dec 2009 21:36:00 +0000 (23:36 +0200)
committerSakari Poussa <spoussa@gmail.com>
Thu, 17 Dec 2009 21:36:00 +0000 (23:36 +0200)
scorecard.pro
src/main-window.cpp
src/table-model.cpp
src/table-model.h

index b074d32..36a7b74 100644 (file)
@@ -13,6 +13,7 @@ QT      += xml
 RESOURCES = scorecard.qrc
 
 HEADERS  = \
+src/score-common.h \
 src/main-window.h \
 src/score-dialog.h \
 src/course-dialog.h \
index 525d070..2296b9e 100644 (file)
@@ -135,8 +135,8 @@ void MainWindow::createTableView(QList<Score *> &scoreList, QList <Club *> &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();
+  table->verticalHeader()->setStyleSheet("background-color: yellow; color : gray }");
 }
 
 void MainWindow::createActions()
index 370d4ce..2a8e3c0 100644 (file)
 #include <QBrush>
 #include <QFont>
 #include "table-model.h"
+#include "score-common.h"
 
-QString empty("");
-#define SC_BLUE_THEME
-QColor colorHoleBg(26, 26, 26);
-QColor colorHoleFg(Qt::yellow);
-QColor colorBirdie(00, 0x99, 00);
-QColor colorPar(Qt::black);
-#ifdef SC_ORANGE_THEME
-QColor colorBogey(0xfc, 0xaf, 0x3e);
-QColor colorDoubleBogey(0xf5, 0x79, 0x00);
-QColor colorBad(0xce, 0x5c, 0x00);
-#endif
-#ifdef SC_BLUE_THEME
-QColor colorBogey(0x20, 0x4a, 0x87);
-QColor colorDoubleBogey(0x34, 0x65, 0xa4);
-QColor colorBad(0x72, 0x9f, 0xcf);
-#endif
-QColor colorSubTotal(Qt::black);
-QColor colorTotal(Qt::black);
-
-Qt::ItemFlags ScoreTableModel::flags (const QModelIndex & index)
+Qt::ItemFlags ScoreTableModel::flags (const QModelIndex &)
 {
   return 0;
 }
@@ -177,12 +159,12 @@ void ScoreTableModel::prev()
   }
 }
 
-int ScoreTableModel::rowCount(const QModelIndex & parent) const
+int ScoreTableModel::rowCount(const QModelIndex &) const
 {
   return 8;
 }
  
-int ScoreTableModel::columnCount(const QModelIndex & parent) const
+int ScoreTableModel::columnCount(const QModelIndex &) const
 {
   return 9 + 2; // 2 for in/out and tot columns
 }
@@ -240,17 +222,17 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
        shots = score->getScore(col + 9).toInt();
       }
 
-      if (col == 10 && row == ROW_SCORE_2) {
+      if (col == (COLS+1) && row == ROW_SCORE_2) {
        // Total score
        QBrush brush(colorTotal);
        return brush;
       }
-      if (col == 9) {
+      if (col == COLS) {
        // In and Out scores
        QBrush brush(colorSubTotal);
        return brush;
       }
-      if (col < 9) {
+      if (col < COLS) {
        if (shots == par) {
          // Par
          QBrush brush(colorPar);
@@ -284,7 +266,7 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
   // FONT
   //
   if (role == Qt::FontRole) {
-    if (row == ROW_SCORE_2 && col == 10) {
+    if (row == ROW_SCORE_2 && col == (COLS+1)) {
        QFont font;
        font.setBold(true);
        return font;
@@ -295,7 +277,7 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
   //
   if (role == Qt::DisplayRole) {
 
-    if (col == 9) {
+    if (col == COLS) {
       // In/out label
       if (row == ROW_HOLE)
        return QString("Out");
@@ -315,7 +297,7 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
        return score->getTotal(TotalIn);
       
     }
-    else if (col == 10) {
+    else if (col == (COLS+1)) {
       // Total label
       if (row == ROW_HOLE_2)
        return QString("Tot");
@@ -356,7 +338,7 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
   return QVariant();
 }
 
-int ScoreTableModel::setItem(int row, int col, int data)
+int ScoreTableModel::setItem(int row, int col, int)
 {
   emit dataChanged(createIndex(row, col), createIndex(row, col));
   return 1;
@@ -368,13 +350,6 @@ QVariant ScoreTableModel::headerData(int section, Qt::Orientation orientation, i
   if (orientation == Qt::Horizontal)
     return QVariant();
 
-#if 0
-  if (role == Qt::BackgroundRole) {
-    QColor colorHoleBg(Qt::darkGray);
-    QBrush brush(colorHoleBg);
-    return brush;
-  }
-#endif
   if (role == Qt::DisplayRole) {
     switch(section) {
     case ROW_PAR: 
index 0c1c60b..9c6cb7c 100644 (file)
@@ -61,9 +61,20 @@ public:
 
  private:
   int currentMode;
-  enum { ROWS = 8, COLS = 9 };
-  enum { ROW_HOLE = 0, ROW_PAR = 1, ROW_HCP = 2, ROW_SCORE = 3, 
-        ROW_HOLE_2 = 4, ROW_PAR_2 = 5, ROW_HCP_2 = 6, ROW_SCORE_2 = 7};
+  enum { 
+    ROWS = 8, 
+    COLS = 9 
+  };
+  enum { 
+    ROW_HOLE = 0, 
+    ROW_PAR = 1, 
+    ROW_HCP = 2, 
+    ROW_SCORE = 3, 
+    ROW_HOLE_2 = 4, 
+    ROW_PAR_2 = 5, 
+    ROW_HCP_2 = 6, 
+    ROW_SCORE_2 = 7
+  };
 
   QList<Score *> scoreList;
   QList<Club *> clubList;