moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / ktouch / src / ktouchlectureeditor.h
blob0e8f806fcfe000cb9950cb9f4c75ae99dc90c427
1 /***************************************************************************
2 * ktouchlectureeditor.h *
3 * --------------------- *
4 * Copyright (C) 2000 by Håvard Frøiland, 2003 by Andreas Nicolai *
5 * ghorwin@users.sourceforge.net *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 ***************************************************************************/
13 #ifndef KTOUCHLECTUREEDITOR_H
14 #define KTOUCHLECTUREEDITOR_H
16 #include <qwidget.h>
17 #include <qfont.h>
18 #include <kurl.h>
20 #include "ktoucheditor_dlg.h"
21 #include "ktouchlecture.h"
23 /// This is the KTouch lecture editor dialog.
24 ///
25 /// The lecture edit dialog works like a standalone edit tool for editing lectures.
26 /// Upon opening of the dialog the 'open lecture' dialog box is shown where
27 /// the user can either select a local training lecture or load a lecture file.
28 /// Then the user can edit the lecture and save it (if desired under a different
29 /// file name).
30 /// The use of the editor is simple, just include ktouchlectureeditor.h and do
31 /// @code
32 /// KTouchLectureEditor dlg;
33 /// bool ok = dlg.startEditor(current_lecture);
34 /// // current_lecture should be the URL pointing to the current/default lecture or ""
35 /// @endcode
36 /// @see startLectureEditor() for details on the return value.
37 class KTouchLectureEditor : public KTouchEditorDlg {
38 Q_OBJECT
39 public:
40 /// Constructor
41 KTouchLectureEditor(QWidget *parent, const char* name = 0, bool modal = FALSE, WFlags fl = 0);
42 /// Destructor
43 ~KTouchLectureEditor() {};
44 /// Shows and executes the dialog (argument is the url to the default or
45 /// current lecture file).
46 /// @return Returns 'true' if the dialog was properly executed (thus reloading
47 /// of the lecture in KTouch is necessary) or 'false' if user canceled
48 /// the "Open request" dialog.
49 bool startEditor(const KURL& url);
51 private slots:
52 /// Called when the Font button was clicked.
53 void fontBtnClicked();
54 /// Called when the Open button was clicked.
55 void openBtnClicked();
56 /// Called when the Save button was clicked.
57 void saveBtnClicked();
58 /// Called when the Save As button was clicked.
59 void saveAsBtnClicked();
60 /// Called when the editor is closed.
61 void closeQuery() { if (saveModified()) accept(); };
62 /// Called when the editor is rejected (x clicked).
63 void reject() { closeQuery(); };
64 /// Will be called whenever some changes are made.
65 void setModified() { setModified(true); }
66 /// Will be called whenever another level has been selected.
67 void newSelection(QListViewItem* item);
68 /// Will be called whenever the new chars description is changed.
69 void newCharsChanged(const QString& text);
70 /// Will be called when the "New Level" button has been clicked.
71 void newLevel();
72 /// Will be called when the "Delete Level" button has been clicked.
73 void deleteLevel();
74 /// Will be called when the "Move Level Up" button has been clicked.
75 void moveUp();
76 /// Will be called when the "Move Level Down" button has been clicked.
77 void moveDown();
79 private:
80 /// Transfers data from the lecture object to the dialog.
81 void transfer_to_dialog();
82 /// Transfers data from the dialog to the lecture object.
83 void transfer_from_dialog();
84 /// Fills the level user interface with data from the current level (stored in m_level).
85 void showCurrentLevel();
86 /// Copies the content of the user interface into the vector with the level data.
87 void storeCurrentLevel();
88 /// Creates a default level and appends it to the already existing levels.
89 void createNewLevel();
90 /// Setups and opens the 'Open request dialog'. The url 'url' is used in the
91 /// open request dialog for the 'current' url selection. When the open request
92 /// dialog is closed the function attempts to load the lecture or if that failes
93 /// creates a new lecture.
94 /// @return The function returns the return code from the open request dialog, so
95 /// that one can react on a "cancel" choice.
96 int openLectureFile(const KURL& url);
97 /// Changes the state of the lecture file (flag==true means modified).
98 void setModified(bool flag);
99 /// If the lecture is modified the user is prompted to save it or throw away the changes.
100 /// If the user accepts the dialog the file is saved.
101 /// @return The function returns 'false' if the user aborted the save request, otherwise true.
102 bool saveModified();
104 KTouchLecture m_lecture; ///< The currently used lecture.
105 unsigned int m_level; ///< The current level number.
106 QListViewItem *m_currentItem; ///< The currently selected item in the list view.
107 bool m_selecting; ///< Flag to prevent the selection slot from selecting twice.
108 bool m_modified; ///< Flag indicating whether the lecture has been modified.
109 KURL m_currentURL; ///< URL of the current lecture.
112 #endif