fadc94ff3bfe4741f7cf1cae9d3bf54f111be3e0
[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 <QTableWidget>
14 #include <QListWidget>
15 #include <QComboBox>
16 #include <QLabel>
17 #include <QPushButton>
18 #include <QDateEdit>
19 #include <QLayout>
20 #ifdef Q_WS_MAEMO_5
21 #include <QtMaemo5/QMaemo5ValueButton>
22 #include <QtMaemo5/QMaemo5DatePickSelector>
23 #endif
24
25 #include "data.h"
26
27 class SelectDialog: public QDialog
28 {
29   Q_OBJECT
30
31  public:
32   SelectDialog(QWidget *parent = 0);
33
34   void results(QString &club, QString &course, QString &date);
35   void init(QList<Club *> &list);
36
37 private slots:
38   void next(void);
39
40  private:
41
42   bool validate(void);
43   void reject(void);
44
45   void comboBoxCourseUpdate(void);
46   void createLayout(QWidget *parent = 0);
47
48   // Widgets
49   QListWidget  *listClub;
50 #ifdef Q_WS_MAEMO_5
51   QMaemo5ValueButton *dateButton;
52 #else
53   QLineEdit    *lineEditDate;
54   QDateEdit    *date;
55 #endif
56   QLabel       *labelClub;
57   QLabel       *labelCourse;
58   QPushButton  *pushButtonNext;
59
60   // Layouts
61   QVBoxLayout *leftLayout;
62   QVBoxLayout *rightLayout;
63
64   QList<Club *> clubList;
65 };
66
67 class ScoreDialog: public QDialog
68 {
69   Q_OBJECT
70
71 public:
72   ScoreDialog(QWidget *parent = 0);
73   void init(Course *course, Score *score = 0);
74   void results(QVector<QString> &scores);
75   bool validate(void);
76
77 private slots:
78   void up(void);
79   void down(void);
80   void next(void);
81   void finish(void);
82
83 private:
84
85   void createTable(QWidget *parent = 0);
86   void createButton(QWidget *parent = 0);
87   void createLayout(QWidget *parent = 0);
88   void setDefaultScore(QTableWidget *table);
89   void moveToNextCell(QTableWidgetItem *item);
90   
91   enum { ROWS = 8, COLS = 9 };
92   enum { ROW_HOLE = 0, ROW_PAR = 1, ROW_HCP = 2, ROW_SCORE = 3, 
93          ROW_HOLE_2 = 4, ROW_PAR_2 = 5, ROW_HCP_2 = 6, ROW_SCORE_2 = 7};
94
95   void reject(void);
96
97   // Widgets
98   QTableWidget *table;
99
100   QPushButton  *pushButtonFinish;
101   QPushButton  *pushButtonUp;
102   QPushButton  *pushButtonDown;
103   QPushButton  *pushButtonNext;
104
105   // Layouts
106   QVBoxLayout *leftLayout;
107   QVBoxLayout *rightLayout;
108 };
109 #endif