Use Home Club setting in new score dialog
[scorecard] / src / score-dialog.h
index f595b3a..80a3d67 100644 (file)
@@ -1,7 +1,16 @@
+/*
+ * Copyright (C) 2009 Sakari Poussa
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2.
+ */
+
 #ifndef SCORE_DIALOG_H
 #define SCORE_DIALOG_H
 
 #include <QDialog>
+#include <QMainWindow>
 #include <QTableWidget>
 #include <QListWidget>
 #include <QComboBox>
 #include <QPushButton>
 #include <QDateEdit>
 #include <QLayout>
+#ifdef Q_WS_MAEMO_5
+#include <QtMaemo5/QMaemo5ValueButton>
+#include <QtMaemo5/QMaemo5DatePickSelector>
+#endif
 
 #include "data.h"
+#include "table-model.h"
 
-class SelectDialog: public QDialog
+class ScoreWindow: public QMainWindow
 {
-  Q_OBJECT
+    Q_OBJECT;
+
+public:
+    ScoreWindow(QWidget *parent = 0);
+    ~ScoreWindow();
 
- public:
-  SelectDialog(QWidget *parent = 0);
+    void setup(Score * score, Course * course);
+
+private:
+    ScoreTableModel *model;
+};
+
+
+class SelectDialog: public QDialog
+{
+    Q_OBJECT;
 
-  void results(QString &club, QString &course, QString &date);
-  void init(QList<Club *> &list);
+public:
+    SelectDialog(QWidget *parent = 0);
+    
+    void results(QString &club, QString &course, QString &date);
+    void init(QList<Club *> &list);
 
 private slots:
-  void next(void);
+    void next(void);
 
- private:
+private:
 
-  bool validate(void);
-  void reject(void);
+    bool validate(void);
+    void reject(void);
 
-  void comboBoxCourseUpdate(void);
-  void createLayout(QWidget *parent = 0);
+    void comboBoxCourseUpdate(void);
+    void createLayout(QWidget *parent = 0);
 
-  // Widgets
-  QListWidget  *listClub;
-  QLineEdit    *lineEditDate;
-  QDateEdit    *date;
-  QLabel       *labelClub;
-  QLabel       *labelCourse;
-  QPushButton  *pushButtonNext;
+    // Widgets
+    QListWidget  *listWidgetClub;
+#ifdef Q_WS_MAEMO_5
+    QMaemo5ValueButton *dateButton;
+#else
+    QLineEdit    *lineEditDate;
+    QDateEdit    *date;
+#endif
+    QLabel       *labelClub;
+    QLabel       *labelCourse;
+    QPushButton  *pushButtonNext;
 
   // Layouts
-  QVBoxLayout *leftLayout;
-  QVBoxLayout *rightLayout;
+    QVBoxLayout *leftLayout;
+    QVBoxLayout *rightLayout;
 
-  QList<Club *> clubList;
+    QList<Club *> clubList;
 };
 
 class ScoreDialog: public QDialog
@@ -54,7 +87,8 @@ class ScoreDialog: public QDialog
 
 public:
   ScoreDialog(QWidget *parent = 0);
-  void init(Course *course);
+  ~ScoreDialog();
+  void init(Course *course, Score *score = 0);
   void results(QVector<QString> &scores);
   bool validate(void);
 
@@ -71,6 +105,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,