2e35bfbab3a0c112dc8c95b385fa5142d5e4dbc9
[scorecard] / src / score-dialog.h
1 /*
2  * Copyright (C) 2009 Sakari Poussa
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 2.
7  */
8
9 #ifndef SCORE_DIALOG_H
10 #define SCORE_DIALOG_H
11
12 #include <QDialog>
13 #include <QMainWindow>
14 #include <QTableWidget>
15 #include <QListWidget>
16 #include <QComboBox>
17 #include <QLabel>
18 #include <QPushButton>
19 #include <QDateEdit>
20 #include <QLayout>
21 #ifdef Q_WS_MAEMO_5
22 #include <QtMaemo5/QMaemo5ValueButton>
23 #include <QtMaemo5/QMaemo5DatePickSelector>
24 #endif
25
26 #include "data.h"
27 #include "table-model.h"
28
29 class ScoreWindow: public QMainWindow
30 {
31     Q_OBJECT;
32
33 public:
34     ScoreWindow(QWidget *parent = 0);
35     ~ScoreWindow();
36
37     void setup(Score * score, Course * course);
38
39 private:
40     ScoreTableModel *model;
41 };
42
43
44 class SelectDialog: public QDialog
45 {
46     Q_OBJECT;
47
48 public:
49     SelectDialog(QWidget *parent = 0);
50     
51     void results(QString &club, QString &course, QString &date);
52     void init(QList<Club *> &list);
53
54 private slots:
55     void next(void);
56
57 private:
58
59     bool validate(void);
60     void reject(void);
61
62     void comboBoxCourseUpdate(void);
63     void createLayout(QWidget *parent = 0);
64
65     // Widgets
66     QListWidget  *listClub;
67 #ifdef Q_WS_MAEMO_5
68     QMaemo5ValueButton *dateButton;
69 #else
70     QLineEdit    *lineEditDate;
71     QDateEdit    *date;
72 #endif
73     QLabel       *labelClub;
74     QLabel       *labelCourse;
75     QPushButton  *pushButtonNext;
76
77   // Layouts
78     QVBoxLayout *leftLayout;
79     QVBoxLayout *rightLayout;
80
81     QList<Club *> clubList;
82 };
83
84 class ScoreDialog: public QDialog
85 {
86   Q_OBJECT
87
88 public:
89   ScoreDialog(QWidget *parent = 0);
90   ~ScoreDialog();
91   void init(Course *course, Score *score = 0);
92   void results(QVector<QString> &scores);
93   bool validate(void);
94
95 private slots:
96   void up(void);
97   void down(void);
98   void next(void);
99   void finish(void);
100
101 private:
102
103   void createTable(QWidget *parent = 0);
104   void createButton(QWidget *parent = 0);
105   void createLayout(QWidget *parent = 0);
106   void setDefaultScore(QTableWidget *table);
107   void moveToNextCell(QTableWidgetItem *item);
108   void showNote(QString msg);
109   
110   enum { ROWS = 8, COLS = 9 };
111   enum { ROW_HOLE = 0, ROW_PAR = 1, ROW_HCP = 2, ROW_SCORE = 3, 
112          ROW_HOLE_2 = 4, ROW_PAR_2 = 5, ROW_HCP_2 = 6, ROW_SCORE_2 = 7};
113
114   void reject(void);
115
116   // Widgets
117   QTableWidget *table;
118
119   QPushButton  *pushButtonFinish;
120   QPushButton  *pushButtonUp;
121   QPushButton  *pushButtonDown;
122   QPushButton  *pushButtonNext;
123
124   // Layouts
125   QVBoxLayout *leftLayout;
126   QVBoxLayout *rightLayout;
127 };
128 #endif