Debian Codegraph @

src/qbrew.h

raw symbols SCIP
1 /***************************************************************************
2 qbrew.h
3 -------------------
4 Controller class for QBrew
5 -------------------
6 Copyright 2006-2008 David Johnson
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 1. Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright
17 notice, this list of conditions and the following disclaimer in the
18 documentation and/or other materials provided with the distribution.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 ***************************************************************************/
32
33 #ifndef QBREW_H
34 #define QBREW_H
35
36 #include <QMainWindow>
37
38 #include "ui_mainwindow.h"
39 #include "configstate.h"
40
41 class QCloseEvent;
42 class QTimer;
43
44 class AlcoholTool;
45 class Configure;
46 class Data;
47 class DatabaseTool;
48 class HelpViewer;
49 class HydrometerTool;
50 class Recipe;
51 class TextPrinter;
52 class View;
53
54 class QBrew : public QMainWindow {
55 Q_OBJECT
56 public:
57 ~QBrew();
58 // return pointer to the singleton
59 static QBrew *instance();
60 // initialize qbrew
61 void initialize(const QString &filename = "");
62
63 // return out the base dir for the help documents
64 QString docBase();
65 // return the base dir for the data files
66 QString dataBase();
67
68 private slots:
69 // generate a new recipe
70 void fileNew();
71 // open a recipe
72 void fileOpen(const QString &filename = "");
73 // open a recent recipe
74 void fileRecent();
75 // save a recipe
76 void fileSave();
77 // save a recipe under a different filename
78 void fileSaveAs();
79 // export the recipe to non-native format
80 void fileExport();
81 // print preview
82 void filePrintPreview();
83 // print the recipe
84 void filePrint();
85
86 // show the alcohol tool
87 void toolsAlcohol();
88 // show the hydrometer tool
89 void toolsHydrometer();
90 // show the database tool
91 void toolsDatabase();
92
93 // toggle the statusbar
94 void optionsStatusbar(bool on);
95 // display the setup dialog
96 void optionsConfigure();
97
98 // displays help contents
99 void helpContents();
100 // displays primer
101 void helpPrimer();
102 // displays context help cursor
103 void helpContext();
104 // shows an about dialog for QBrew
105 void helpAbout();
106
107 // received if view widgets have changed
108 void recipeModified();
109
110 // setup recent file menu
111 void recentMenuShow();
112
113 // apply states from config dialog
114 void applyGeneralState(const GenConfigState &state);
115 void applyRecipeState(const RecipeConfigState &state);
116 void applyCalcState(const CalcConfigState &state);
117 void saveConfig();
118
119 // autosave timer
120 void autoSave();
121
122 private:
123 // singleton
124 QBrew();
125 QBrew(const QBrew&);
126 QBrew &operator=(const QBrew&);
127
128 // filter events
129 bool eventFilter(QObject *obj, QEvent *event);
130
131 // initialize actions
132 void initActions();
133 // initialize autosave
134 void initAutoSave();
135
136 // catch the close event
137 void closeEvent(QCloseEvent *e);
138
139 // query user to save the current file
140 int querySave();
141 // query to overwrite existing file
142 int queryOverwrite(const QString filename);
143 // add a file to recent file menu
144 void addRecent(const QString &filename);
145 // open a named file
146 bool openFile(const QString &filename);
147 // save a file
148 bool saveFile(const QString &filename);
149 // backup the file
150 bool backupFile();
151
152 // set window caption from file name
153 void setFileCaption(const QString &filename);
154
155 // read in configuration
156 void readConfig();
157 // write out configuration
158 void writeConfig();
159 // restore application state
160 void restoreState();
161 // save application state
162 void saveState();
163
164 private:
165 static QBrew *instance_;
166
167 Ui::MainWindow ui;
168
169 Data *data_;
170 Recipe *recipe_;
171 View *view_;
172
173 AlcoholTool* alcoholtool_;
174 DatabaseTool* databasetool_;
175 HydrometerTool* hydrometertool_;
176 Configure* configure_;
177 HelpViewer* handbook_;
178 HelpViewer* primer_;
179
180 ConfigState state_;
181 QString filename_;
182 bool newflag_;
183 bool backed_;
184
185 QTimer *autosave_;
186 QString autosavename_;
187 TextPrinter *textprinter_;
188 };
189
190 #endif // QBREW_H