moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kwordquiz / src / kwordquiz.h
blob52f5bddd68d26ff033c34da8fd5991044341f4c6
1 /***************************************************************************
2 kwordquiz.h - description
3 -------------------
4 begin : Wed Jul 24 20:12:30 PDT 2002
5 copyright : (C) 2002-2003 by Peter Hedlund
6 email : peter@peterandlinda.com
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef KWORDQUIZ_H
19 #define KWORDQUIZ_H
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
26 // include files for Qt
27 #include <qsignalmapper.h>
29 // include files for KDE
30 #include <kapplication.h>
31 #include <kmainwindow.h>
32 #include <kaction.h>
33 #include <kdirwatch.h>
34 #include <kurl.h>
36 // forward declaration of the KWordQuiz classes
37 #include "wqquiz.h"
38 class KWordQuizDoc;
39 class KWordQuizView;
40 class KWordQuizPrefs;
41 class QAView;
42 class MultipleView;
43 class FlashView;
45 /**
46 * The base class for KWordQuiz application windows. It sets up the main
47 * window and reads the config file as well as providing a menubar, toolbar
48 * and statusbar. An instance of KWordQuizView creates your center view, which is connected
49 * to the window's Doc object.
50 * KWordQuizApp reimplements the methods that KMainWindow provides for main window handling and supports
51 * full session management as well as using KActions.
52 * @see KMainWindow
53 * @see KApplication
54 * @see KConfig
56 * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
57 * @version KDevelop version 1.2 code generation
59 class KWordQuizApp : public KMainWindow
61 Q_OBJECT
63 friend class KWordQuizView;
65 public:
66 /** construtor of KWordQuizApp, calls all init functions to create the application.
68 KWordQuizApp(QWidget* parent=0, const char* name=0);
69 ~KWordQuizApp();
70 /** opens a file specified by commandline option
72 void openDocumentFile(const KURL& url=0);
73 /** returns a pointer to the current document connected to the KTMainWindow instance and is used by
74 * the View class to access the document object's methods
75 */
76 KWordQuizDoc *getDocument() const;
78 bool saveAsFileName();
79 protected:
80 /** save general Options like all bar positions and status as well as the geometry and the recent file list to the configuration
81 * file
82 */
83 void saveOptions();
84 /** read general Options again and initialize all variables like the recent file list
86 void readOptions();
87 /** initializes the KActions of the application */
89 void initActions();
90 /** sets up the statusbar for the main window by initialzing a statuslabel.
92 void initStatusBar();
93 /** initializes the document object of the main window that is connected to the view in initView().
94 * @see initView();
96 void initDocument();
97 /** creates the centerwidget of the KTMainWindow instance and sets it as the view
99 void initView();
100 /** queryClose is called by KTMainWindow on each closeEvent of a window. Against the
101 * default implementation (only returns true), this calles saveModified() on the document object to ask if the document shall
102 * be saved if Modified; on cancel the closeEvent is rejected.
103 * @see KTMainWindow#queryClose
104 * @see KTMainWindow#closeEvent
106 virtual bool queryClose();
107 /** queryExit is called by KTMainWindow when the last window of the application is going to be closed during the closeEvent().
108 * Against the default implementation that just returns true, this calls saveOptions() to save the settings of the last window's
109 * properties.
110 * @see KTMainWindow#queryExit
111 * @see KTMainWindow#closeEvent
113 virtual bool queryExit();
114 /** saves the window properties for each open window during session end to the session config file, including saving the currently
115 * opened file by a temporary filename provided by KApplication.
116 * @see KTMainWindow#saveProperties
118 virtual void saveProperties(KConfig *_cfg);
119 /** reads the session config file and restores the application's state including the last opened files and documents by reading the
120 * temporary files saved by saveProperties()
121 * @see KTMainWindow#readProperties
123 virtual void readProperties(KConfig *_cfg);
125 signals:
126 void settingsChanged();
128 public slots:
129 /** open a new application window by creating a new instance of KWordQuizApp */
130 void slotFileNew();
131 /** open a file and load it into the document*/
132 void slotFileOpen();
133 /** opens a file from the recent files menu */
134 void slotFileOpenRecent(const KURL& url);
135 /** save a document */
136 void slotFileSave();
137 /** save a document by a new filename*/
138 void slotFileSaveAs();
139 /** asks for saving if the file is modified, then closes the actual file and window*/
140 void slotFileClose();
141 /** print the actual file */
142 void slotFilePrint();
143 /** closes all open windows by calling close() on each memberList item until the list is empty, then quits the application.
144 * If queryClose() returns false because the user canceled the saveModified() dialog, the closing breaks.*/
145 void slotFileQuit();
147 /** undo the last command */
148 void slotEditUndo();
149 /** put the marked text/object into the clipboard and remove it from the document */
150 void slotEditCut();
151 /** put the marked text/object into the clipboard */
152 void slotEditCopy();
153 /** paste the clipboard into the document */
154 void slotEditPaste();
155 /** clear the grid selection */
156 void slotEditClear();
157 /** insert a new row */
158 void slotEditInsert();
159 /** delete selected row(s) */
160 void slotEditDelete();
161 /** mark word as blank */
162 void slotEditMarkBlank();
163 /** unmark word as blank */
164 void slotEditUnmarkBlank();
165 /** find and replace text */
166 void slotEditFind();
168 /** define vocabulary languages */
169 void slotVocabLanguages();
170 /** define vocabulary fonts */
171 void slotVocabFont();
172 /** define keyboard layouts */
173 void slotVocabKeyboard();
174 /** define special characters */
175 void slotVocabChar();
176 /** define row and column properties */
177 void slotVocabRC();
178 /** sort vocabulary */
179 void slotVocabSort();
180 /** shuffle the vocabulary */
181 void slotVocabShuffle();
183 void slotMode0();
184 /** mode 1 */
185 void slotMode1();
186 /** mode 2 */
187 void slotMode2();
188 /** mode 3 */
189 void slotMode3();
190 /** mode 4 */
191 void slotMode4();
192 /** mode 5 */
193 void slotMode5();
195 /** editor session */
196 void slotQuizEditor();
197 /** flashcard session */
198 void slotQuizFlash();
199 /** multiple choice session */
200 void slotQuizMultiple();
201 /** question and answer session */
202 void slotQuizQA();
204 /** configure notifications */
205 void slotConfigureNotifications();
206 /** configure kwordquiz */
207 void slotConfigure();
210 /** changes the statusbar contents for the standard label permanently, used to indicate current actions.
211 * @param text the text that is displayed in the statusbar */
212 void slotStatusMsg(const QString &text);
214 /** applies changes from the preferences dialog */
215 void slotApplyPreferences();
217 void slotUndoChange(const QString & text, bool enabled);
219 void slotInsertChar(int i);
221 void slotActionHighlighted(KAction *, bool);
223 void slotContextMenuRequested(int, int, const QPoint &);
224 private:
226 WQQuiz::QuizType m_quizType;
228 WQQuiz *m_quiz;
230 /** view is the main widget which represents your working area. The View
231 * class should handle all events of the view widget. It is kept empty so
232 * you can create your view according to your application's needs by
233 * changing the view class.
235 KWordQuizView *m_editView;
236 FlashView *m_flashView;
237 MultipleView *m_multipleView;
238 QAView *m_qaView;
240 KWordQuizPrefs *m_prefDialog;
242 /** doc represents your actual document and is created only once. It keeps
243 * information such as filename and does the serialization of your files.
245 KWordQuizDoc *doc;
247 // KAction pointers to enable/disable actions
248 KAction* fileNew;
249 KAction* fileOpen;
250 KRecentFilesAction* fileOpenRecent;
251 KAction* fileSave;
252 KAction* fileSaveAs;
253 KAction* fileClose;
254 KAction* filePrint;
255 KAction* fileQuit;
257 KAction* editUndo;
258 KAction* editCut;
259 KAction* editCopy;
260 KAction* editPaste;
261 KAction* editClear;
262 KAction* editInsert;
263 KAction* editDelete;
264 KAction* editMarkBlank;
265 KAction* editUnmarkBlank;
266 //KAction* editFind;
268 KAction* vocabLanguages;
269 KAction* vocabFont;
270 //KAction* vocabKeyboard;
271 KAction* vocabRC;
272 KAction* vocabSort;
273 KAction* vocabShuffle;
275 KToolBarPopupAction* mode;
276 KToggleAction* mode1;
277 KToggleAction* mode2;
278 KToggleAction* mode3;
279 KToggleAction* mode4;
280 KToggleAction* mode5;
282 KAction* quizEditor;
283 KAction* quizFlash;
284 KAction* quizMultiple;
285 KAction* quizQA;
287 KAction* quizCheck;
288 KAction* quizRestart;
289 KAction* quizRepeatErrors;
291 KAction* flashKnow;
292 KAction* flashDontKnow;
294 KAction* qaHint;
296 QSignalMapper* charMapper;
297 KAction* specialChar1;
298 KAction* specialChar2;
299 KAction* specialChar3;
300 KAction* specialChar4;
301 KAction* specialChar5;
302 KAction* specialChar6;
303 KAction* specialChar7;
304 KAction* specialChar8;
305 KAction* specialChar9;
307 KDirWatch * m_dirWatch;
309 void updateMode(int m);
310 void updateSession(WQQuiz::QuizType qt);
311 void updateActions(WQQuiz::QuizType qt);
312 void updateSpecialCharIcons();
313 QString charIcon(const QChar &);
314 void openURL(const KURL& url);
317 #endif // KWORDQUIZ_H