moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / ktouch / src / ktouchlecture.h
blobed484bf9a6ccfa7089f7596197bde68ef2c11ded
1 /***************************************************************************
2 * ktouchlecture.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 KTOUCHLECTURE_H
14 #define KTOUCHLECTURE_H
16 class QWidget;
17 class QDomDocument;
18 class KURL;
20 #include <qvaluevector.h>
21 #include "ktouchleveldata.h"
23 /// This class handles the lecture data and provides the lines to type.
24 ///
25 /// It contains the level data (see KTouchLevelData). A lecture object
26 /// contains <b>ALWAYS</b> at least one lecture.<p>
27 /// The lecture data can be read and written using the member functions
28 /// readLecture() and writeLecture().<p>
29 /// During a training session the program will occasionally need a new
30 /// line of text. You can retrieve the data of a certain level using
31 /// the member function level() and then the line in this level (see
32 /// KTouchLevelData).
33 class KTouchLecture {
34 public:
35 /// Default Constructor
36 KTouchLecture() { createDefault(); };
37 /// Creates a default mini-lecture.
38 void createDefault();
39 /// Loads a lecture from file (returns true if successful).
40 bool load(QWidget * window, const KURL& url);
41 /// Loads a lecture (in XML format) from file (returns true if successful).
42 bool loadXML(QWidget * window, const KURL& url);
43 // /// Saves the lecture data to file (returns true if successful).
44 // bool save(QWidget * window, const KURL& url) const;
45 /// Saves the lecture data to file (returns true if successful).
46 bool saveXML(QWidget * window, const KURL& url) const;
47 /// Returns the number of levels in the lecture.
48 unsigned int levelCount() const { return m_lectureData.size(); };
49 /// Returns a reference to the data of the level.
50 /// If the level number is out of range the function will always return
51 /// the level 0.
52 const KTouchLevelData& level(unsigned int levelNum) const;
53 /// Returns the title of the lecture.
54 const QString& title() const { return m_title; }
55 /// Sets the title of the lecture.
56 void setTitle(const QString& title) { m_title = title; }
58 QString m_title; ///< The title of the lecture.
59 QString m_comment; ///< A comment.
60 QString m_fontSuggestions; ///< Font suggestions for this lecture.
62 private:
63 /// Loads a lecture from file
64 bool readLecture(QTextStream& in);
65 /// Loads a lecture from file into an XML document
66 bool readLecture(QDomDocument& doc);
67 /// Saves the lecture data to the current lecture URL
68 void writeLecture(QTextStream& out) const;
69 /// Saves the lecture data in the XML document
70 void writeLecture(QDomDocument& doc) const;
72 QValueVector<KTouchLevelData> m_lectureData; ///< The lecture data.
74 /// The editor should be able to handle the internal lecture data (it's for convenience actually).
75 friend class KTouchLectureEditor;
78 #endif // KTOUCHLECTURE_H