new colors and menu settings to adapt new qt libs
authorSakari Poussa <spoussa@gmail.com>
Sun, 8 Nov 2009 21:50:51 +0000 (23:50 +0200)
committerSakari Poussa <spoussa@gmail.com>
Sun, 8 Nov 2009 21:50:51 +0000 (23:50 +0200)
src/course-dialog.cpp
src/main-window.cpp
src/score-dialog.cpp
src/table-model.cpp

index e51e335..b14b444 100644 (file)
@@ -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) {
index c575116..d622f56 100644 (file)
@@ -135,6 +135,7 @@ 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();
 }
 
@@ -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);
index d0b6d51..086c012 100644 (file)
@@ -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));
index e2f3d8d..6ef8bc8 100644 (file)
@@ -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();
 }