- Use QDialogButtonBox to get correct layout for buttons
authorSakari Poussa <spoussa@gmail.com>
Sun, 9 May 2010 16:54:54 +0000 (19:54 +0300)
committerSakari Poussa <spoussa@gmail.com>
Sun, 9 May 2010 16:54:54 +0000 (19:54 +0300)
- Set NoItemsFlags for items that are not selectable
- Set current cell in new course dialog
- Make new score select dialog bigger (4 rows)
- Apply style sheets for stat, new course and new score dialogs
- Show Maemo5 info note on new score dialog

TODO
src/course-dialog.cpp
src/main-window.cpp
src/score-dialog.cpp
src/score-dialog.h

diff --git a/TODO b/TODO
index e55c238..88819d6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,7 +4,6 @@ TODO General:
 - 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
 - Settings
 - Use syslog
 - Year filters and maybe more, must be easy to apply
index a4ebc57..5abbd7b 100644 (file)
@@ -33,13 +33,16 @@ void CourseSelectDialog::createLayout(QWidget *parent)
 
   connect(pushButtonNext, SIGNAL(clicked()), this, SLOT(next()));
 
+  QDialogButtonBox * buttonBox = new QDialogButtonBox(Qt::Vertical);
+  buttonBox->addButton(pushButtonNext, QDialogButtonBox::ActionRole);
+
   leftLayout = new QVBoxLayout;
   leftLayout->addWidget(lineEditClub);
   leftLayout->addWidget(lineEditCourse);
 
   rightLayout = new QVBoxLayout;
   rightLayout->addStretch();
-  rightLayout->addWidget(pushButtonNext);
+  rightLayout->addWidget(buttonBox);
 
   QHBoxLayout *mainLayout = new QHBoxLayout(parent);
   mainLayout->addLayout(leftLayout);
@@ -96,12 +99,18 @@ void CourseDialog::createLayout(QWidget *parent)
   leftLayout = new QVBoxLayout;
   leftLayout->addWidget(table);
 
+  QDialogButtonBox * buttonBoxUp = new QDialogButtonBox(Qt::Vertical);
+  buttonBoxUp->addButton(pushButtonUp, QDialogButtonBox::ActionRole);
+  buttonBoxUp->addButton(pushButtonDown, QDialogButtonBox::ActionRole);
+  buttonBoxUp->addButton(pushButtonNext, QDialogButtonBox::ActionRole);
+
+  QDialogButtonBox * buttonBoxDown = new QDialogButtonBox(Qt::Vertical);
+  buttonBoxDown->addButton(pushButtonFinish, QDialogButtonBox::ActionRole);
+
   rightLayout = new QVBoxLayout;
-  rightLayout->addWidget(pushButtonUp);
-  rightLayout->addWidget(pushButtonDown);
-  rightLayout->addWidget(pushButtonNext);
+  rightLayout->addWidget(buttonBoxUp);
   rightLayout->addStretch();
-  rightLayout->addWidget(pushButtonFinish);
+  rightLayout->addWidget(buttonBoxDown);
 
   QHBoxLayout *mainLayout = new QHBoxLayout(parent);
   mainLayout->addLayout(leftLayout);
@@ -135,7 +144,7 @@ void CourseDialog::createTable(QWidget *parent)
   table->horizontalHeader()->hide();
   table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
   table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
-  //table->setStyleSheet(ScoreColor::styleSheet());
+  table->setStyleSheet(ScoreStyle::style());
 }
 
 void CourseDialog::init(Course *course)
@@ -154,12 +163,15 @@ void CourseDialog::init(Course *course)
     QTableWidgetItem *len = new QTableWidgetItem("");
 
     QTableWidgetItem *holeNum = new QTableWidgetItem(QString::number(i+1));
-    holeNum->setBackgroundColor(ScoreColor::holeBg());
+    holeNum->setForeground(ScoreColor::holeBg());
+    holeNum->setFlags(Qt::NoItemFlags);
 
     holeNum->setTextAlignment(Qt::AlignCenter);
     par->setTextAlignment(Qt::AlignCenter);
     hcp->setTextAlignment(Qt::AlignCenter);
     len->setTextAlignment(Qt::AlignCenter);
+    // len is not in use - here just to confuse ;(
+    len->setFlags(Qt::NoItemFlags);
     
     if (i < 9) {
       table->setItem(0, i, holeNum);
@@ -174,6 +186,7 @@ void CourseDialog::init(Course *course)
       table->setItem(7, i-9, len);
     }
   }
+  table->setCurrentCell(1, 0);
 }
 
 void CourseDialog::up(void)
index 1481e23..ad0875c 100644 (file)
@@ -590,7 +590,8 @@ void MainWindow::viewStatistics()
   QTableView *table = new QTableView;
   table->showGrid();
   table->setSelectionMode(QAbstractItemView::NoSelection);
-  table->setStyleSheet(ScoreStyle::headerView());
+  //table->setStyleSheet(ScoreStyle::headerView());
+  table->setStyleSheet(ScoreStyle::style());
   table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
   table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
   table->verticalHeader()->setAutoFillBackground(true);
index d49884e..281691d 100644 (file)
@@ -8,12 +8,17 @@
 
 #include <QtGui>
 #include <QInputContext>
+#ifdef Q_WS_MAEMO_5
+#include <QMaemo5InformationBox>
+#endif
 
 #include "score-dialog.h"
 #include "score-common.h"
 
 SelectDialog::SelectDialog(QWidget *parent) : QDialog(parent)
 {
+  resize(800, 350);
+
   QWidget *centralWidget = new QWidget(this);
   createLayout(centralWidget);
 
@@ -27,6 +32,9 @@ void SelectDialog::createLayout(QWidget *parent)
 
   connect(pushButtonNext, SIGNAL(clicked()), this, SLOT(next()));
 
+  QDialogButtonBox * buttonBox = new QDialogButtonBox(Qt::Vertical);
+  buttonBox->addButton(pushButtonNext, QDialogButtonBox::ActionRole);
+
   leftLayout = new QVBoxLayout;
   leftLayout->addWidget(listClub);
 
@@ -47,7 +55,7 @@ void SelectDialog::createLayout(QWidget *parent)
 
   rightLayout = new QVBoxLayout;
   rightLayout->addStretch();
-  rightLayout->addWidget(pushButtonNext);
+  rightLayout->addWidget(buttonBox);
 
   QHBoxLayout *mainLayout = new QHBoxLayout(parent);
   mainLayout->addLayout(leftLayout);
@@ -147,12 +155,18 @@ void ScoreDialog::createLayout(QWidget *parent)
   leftLayout = new QVBoxLayout;
   leftLayout->addWidget(table);
 
+  QDialogButtonBox * buttonBoxUp = new QDialogButtonBox(Qt::Vertical);
+  buttonBoxUp->addButton(pushButtonUp, QDialogButtonBox::ActionRole);
+  buttonBoxUp->addButton(pushButtonDown, QDialogButtonBox::ActionRole);
+  buttonBoxUp->addButton(pushButtonNext, QDialogButtonBox::ActionRole);
+
+  QDialogButtonBox * buttonBoxDown = new QDialogButtonBox(Qt::Vertical);
+  buttonBoxDown->addButton(pushButtonFinish, QDialogButtonBox::ActionRole);
+
   rightLayout = new QVBoxLayout;
-  rightLayout->addWidget(pushButtonUp);
-  rightLayout->addWidget(pushButtonDown);
-  rightLayout->addWidget(pushButtonNext);
+  rightLayout->addWidget(buttonBoxUp);
   rightLayout->addStretch();
-  rightLayout->addWidget(pushButtonFinish);
+  rightLayout->addWidget(buttonBoxDown);
 
   QHBoxLayout *mainLayout = new QHBoxLayout(parent);
   mainLayout->addLayout(leftLayout);
@@ -168,7 +182,7 @@ void ScoreDialog::createTable(QWidget *parent)
   table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
   table->horizontalHeader()->hide();
 
-  //table->setStyleSheet(ScoreColor::styleSheet());
+  table->setStyleSheet(ScoreStyle::style());
 
   QStringList headers;
   headers << "" << "Par" << "HCP" << "Score" << "" << "Par" << "HCP" << "Score";
@@ -204,12 +218,17 @@ void ScoreDialog::init(Course *course, Score *score)
       scoreItem = new QTableWidgetItem("");
     holeNum = new QTableWidgetItem(QString::number(i+1));
 
-    holeNum->setBackgroundColor(ScoreColor::holeBg());
+    holeNum->setTextAlignment(Qt::AlignCenter);
+    holeNum->setFlags(Qt::NoItemFlags);
+    holeNum->setForeground(ScoreColor::holeBg());
 
     par->setTextAlignment(Qt::AlignCenter);
+    par->setFlags(Qt::NoItemFlags);
+
     hcp->setTextAlignment(Qt::AlignCenter);
+    hcp->setFlags(Qt::NoItemFlags);
+
     scoreItem->setTextAlignment(Qt::AlignCenter);
-    holeNum->setTextAlignment(Qt::AlignCenter);
 
     if (i < 9) {
       table->setItem(ROW_HOLE, i, holeNum);
@@ -346,14 +365,23 @@ bool ScoreDialog::validate(void)
 
 void ScoreDialog::finish(void)
 {
-  if (validate())
-    done(1);
-  else {
-    qDebug() << "ScoreDialog: invalid data, cancel or correct";
-  }
+    if (validate())
+        done(1);
+    else {
+        showNote("Invalid data - cancel or correct");
+    }
 }
 
 void ScoreDialog::reject(void)
 {
   done(0);
 }
+
+void ScoreDialog::showNote(QString msg)
+{
+#ifdef Q_WS_MAEMO_5
+    QMaemo5InformationBox::information(this, 
+                                       msg,
+                                       QMaemo5InformationBox::DefaultTimeout);
+#endif
+}
index fadc94f..dee7d52 100644 (file)
@@ -87,6 +87,7 @@ private:
   void createLayout(QWidget *parent = 0);
   void setDefaultScore(QTableWidget *table);
   void moveToNextCell(QTableWidgetItem *item);
+  void showNote(QString msg);
   
   enum { ROWS = 8, COLS = 9 };
   enum { ROW_HOLE = 0, ROW_PAR = 1, ROW_HCP = 2, ROW_SCORE = 3,