1 /* ColorCode, a free MasterMind clone with built in solver
2  * Copyright (C) 2009  Dirk Laebisch
3  * http://www.laebisch.com/
4  *
5  * ColorCode is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * ColorCode is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with ColorCode. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef GAMETABLESDIALOG_H
20 #define GAMETABLESDIALOG_H
21 
22 #include <QtGui>
23 #include <QDialog>
24 
25 class GamesListModel;
26 class GameTableView;
27 class CCGame;
28 
29 namespace Ui
30 {
31     class GameTablesDialog;
32 }
33 
34 class GameTablesDialog : public QDialog
35 {
36     Q_OBJECT
37 
38 public:
39     static const int TABIX_INPUT;
40     static const int TABIX_PREVIOUS;
41     static const int TABIX_BOOKMARKS;
42     static const int TABIX_HIGHSCORES;
43 
44     GameTablesDialog(QWidget* parent = 0, Qt::WindowFlags f = Qt::Dialog);
45     ~GameTablesDialog();
46     void ShowTab(int tabix);
47 
48     GameTableView* mPrevTableView;
49     GameTableView* mSavedTableView;
50     GameTableView* mHighTableView;
51 
52 public slots:
53     void ShowInputSlot();
54     void ShowPrevSlot();
55     void ShowSavedSlot();
56     void ShowHighSlot();
57     void HoverRowSlot(const int row);
58     void ReadSettingsGamesSlot();
59     void SetSettingsSlot();
60     void InsertHighScoreSlot(CCGame* g);
61     void InsertPrevGameSlot(CCGame* g);
62     void InsertSavedGameSlot(CCGame* g);
63     void NewGameInputSlot(CCGame* g);
64     void OkBtnSlot();
65     void ClearListSlot();
66 
67     void CurrentTabChanged(int ix);
68     virtual void reject();
69 
70 signals:
71     void NewGameInputSignal(CCGame* g);
72 
73 protected:
74     void changeEvent(QEvent *e);
75     virtual void closeEvent(QCloseEvent* e);
76 
77 private:
78     void Init();
79     void SetRowHeight();
80     GamesListModel* GetCurModel() const;
81     GameTableView* GetCurView() const;
82     void SetGameProperties(const CCGame* g);
83     QString FormatDuration(const uint dur) const;
84 
85     CCGame* mLastGameProperties;
86 
87     Ui::GameTablesDialog *ui;
88 
89 private slots:
90     void GameNoInpChangedSlot(const QString &txt);
91     void PlayInputSlot();
92     void ValidNameCommitSlot();
93 
94 };
95 
96 #endif // GAMETABLESDIALOG_H
97