Add club-master.xml r/o file for distributed courses. User added courses go to club...
[scorecard] / src / main-window.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 #include <QMainWindow>
10 #include <QTableView>
11 #include <QListView>
12 #include <QPushButton>
13 #include <QTextEdit>
14 #include <QVBoxLayout>
15 #include <QItemSelectionModel>
16 #include <QList>
17 #include <QLabel>
18 #include <QActionGroup>
19 #include <QXmlDefaultHandler>
20
21 #include "data.h"
22 #include "table-model.h"
23 #include "list-model.h"
24
25 class MainWindow : public QMainWindow
26 {
27   Q_OBJECT
28
29 public:
30   MainWindow(QMainWindow *parent = 0);
31   void createLayoutTable(QWidget *parent = 0);
32   void createLayoutList(QWidget *parent = 0);
33   void createListView(QList<Score *> &, QList <Club *> &);
34   void updateTitleBar(QString & msg);
35   void loadScoreFile(QString &fileName, QList<Score *> &scoreList);
36   void loadClubFile(QString &fileName, QList<Club *> &clubList, bool readOnly = false);
37   void saveScoreFile(QString &fileName, QList<Score *> &scoreList);
38   void saveClubFile(QString &fileName, QList<Club *> &clubList);
39
40 signals:
41   void dataChanged();
42
43 private slots:
44   void clickedList(const QModelIndex &index);
45
46   void newScore();
47   void deleteScore();
48   void editScore();
49   void newCourse();
50   void deleteCourse();
51   void editCourse();
52   void viewStatistics();
53   void listScores();
54   void listCourses();
55
56 private:
57
58   void loadSettings(void);
59   Club * findClub(QString &name);
60   Course * findCourse(const QString &clubName, const QString &courseName);
61   Course * findCourse();
62   Score * findScore(QString & clubName, QString & courseName);
63                                
64   void showNote(QString msg);
65   void getStat(QTextEdit *);
66
67   void viewScore(Score * score, Course * course);
68   void viewCourse(Course * course);
69
70   QList<Score *> scoreList;
71   QList<Club *> clubList;
72
73   ScoreTableModel *scoreTableModel;
74   ScoreListModel *scoreListModel;
75   CourseListModel *courseListModel;
76
77   QAbstractItemModel *tableModel;
78   QItemSelectionModel *selectionModel;
79
80   QTableView *table;
81   QListView *list;
82
83   // Layouts
84   QWidget *centralWidget;
85
86   // Menus
87   QMenu *menu;
88
89   // Actions
90   QAction *newScoreAction;
91   QAction *newCourseAction;
92   QAction *statAction;
93
94   QActionGroup *filterGroup;
95   QAction *listScoreAction;
96   QAction *listCourseAction;
97
98   void createMenus();
99   void createActions();
100
101   // Windows
102   QMainWindow *scoreWin;
103   QMainWindow *courseWin;
104 };