Merge branch 'master' of /opt/src/sb1/qt/scorecard
[scorecard] / src / course-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 COURSE_DIALOG_H
10 #define COURSE_DIALOG_H
11
12 #include <QtGui>
13 #include <QDialog>
14 #include <QLabel>
15 #include <QGroupBox>
16 #include <QDialogButtonBox>
17 #include <QLineEdit>
18 #include <QDebug>
19
20 #include "data.h"
21 #include "table-model.h"
22
23 QT_BEGIN_NAMESPACE
24 class QTableWidget;
25 class QTableWidgetItem;
26 QT_END_NAMESPACE
27
28 class CourseWindow: public QMainWindow
29 {
30     Q_OBJECT;
31
32 public:
33     CourseWindow(QWidget *parent = 0);
34
35     void setup(Course *course);
36
37 private:
38     CourseTableModel *model;
39 };
40
41 class CourseSelectDialog: public QDialog
42 {
43   Q_OBJECT
44
45  public:
46   CourseSelectDialog(QWidget *parent = 0);
47
48   void results(QString &club, QString &course);
49
50 private slots:
51   void next(void);
52
53  private:
54
55   void createLayout(QWidget *parent);
56   bool validate(void);
57
58   QLineEdit    *lineEditClub;
59   QLineEdit    *lineEditCourse;
60   QLabel       *labelClub;
61   QLabel       *labelCourse;
62   QPushButton  *pushButtonNext;
63
64   // Layouts
65   QVBoxLayout *leftLayout;
66   QVBoxLayout *rightLayout;
67 };
68
69 class CourseDialog: public QDialog
70 {
71   Q_OBJECT
72
73  public:
74   CourseDialog(QWidget *w);
75   void results(QVector<QString> &, QVector<QString> &, QVector<QString> &);
76   bool validate();
77   void init(Course *course = 0);
78
79  private slots:
80   void up(void);
81   void down(void);
82   void next(void);
83   void finish(void);
84
85  private:
86   enum { ROW_HOLE = 0, ROW_PAR = 1, ROW_HCP = 2, ROW_LEN = 3, 
87          ROW_HOLE_2 = 4, ROW_PAR_2 = 5, ROW_HCP_2 = 6, ROW_LEN_2 = 7};
88   enum { ROWS = 8, COLS = 9, separator_row = 3 };
89
90   void createTable(QWidget *parent = 0);
91   void createButton(QWidget *parent = 0);
92   void createLayout(QWidget *parent = 0);
93   void moveToNextCell(QTableWidgetItem *item);
94
95   // Widgets
96   QTableWidget *table;
97
98   QPushButton *pushButtonUp;
99   QPushButton *pushButtonDown;
100   QPushButton *pushButtonNext;
101   QPushButton *pushButtonFinish;
102
103   // Layouts
104   QVBoxLayout *rightLayout;
105   QVBoxLayout *leftLayout;
106 };
107
108 #endif