summaryrefslogtreecommitdiffstats
path: root/ktouch/src/ktouchlecture.h
blob: 3eb6ba545e5bae1982d1077290a8c982dd2c2a6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/***************************************************************************
 *   ktouchlecture.h                                                       *
 *   ---------------                                                       *
 *   Copyright (C) 2000 by Håvard Frøiland, 2003 by Andreas Nicolai        *
 *   ghorwin@users.sourceforge.net                                         *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifndef KTOUCHLECTURE_H
#define KTOUCHLECTURE_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

class QWidget;
class QDomDocument;
class KURL;

#include <tqvaluevector.h>
#include "ktouchleveldata.h"

/// This class handles the lecture data and provides the lines to type.
///
/// It contains the level data (see KTouchLevelData). A lecture object
/// contains <b>ALWAYS</b> at least one lecture.<p>
/// The lecture data can be read and written using the member functions 
/// readLecture() and writeLecture().<p>
/// During a training session the program will occasionally need a new
/// line of text. You can retrieve the data of a certain level using
/// the member function level() and then the line in this level (see
/// KTouchLevelData).
class KTouchLecture {
  public:
    /// Default Constructor
    KTouchLecture() { createDefault(); }
    /// Creates a default mini-lecture.
    void createDefault();
    /// Loads a lecture from file (returns true if successful).
    bool load(TQWidget * window, const KURL& url);
    /// Loads a lecture (in XML format) from file (returns true if successful).
    bool loadXML(TQWidget * window, const KURL& url);
    // /// Saves the lecture data to file (returns true if successful).
    // bool save(TQWidget * window, const KURL& url) const;
    /// Saves the lecture data to file (returns true if successful).
    bool saveXML(TQWidget * window, const KURL& url) const;
    /// Returns the number of levels in the lecture.
    unsigned int levelCount()       const { return m_lectureData.size(); }
    /// Returns a reference to the data of the level.
    /// If the level number is out of range the function will always return
    /// the level 0.
    const KTouchLevelData& level(unsigned int levelNum) const;
    /// Returns the title of the lecture.
    const TQString& title() const { return m_title; }
    /// Sets the title of the lecture.
    void setTitle(const TQString& title) { m_title = title; }

    TQString                         m_title;        	///< The title of the lecture.
    TQString                         m_comment;      	///< A comment.
    TQString                         m_fontSuggestions;  ///< Font suggestions for this lecture.

  private:
    /// Loads a lecture from file
    bool readLecture(TQTextStream& in);
    /// Loads a lecture from file into an XML document
    bool readLecture(TQDomDocument& doc);
    /// Saves the lecture data to the current lecture URL
    void writeLecture(TQTextStream& out) const;
    /// Saves the lecture data in the XML document
    void writeLecture(TQDomDocument& doc) const;
  
    TQValueVector<KTouchLevelData>   m_lectureData;  	///< The lecture data.
    
    /// The editor should be able to handle the internal lecture data (it's for convenience actually).
    friend class KTouchLectureEditor;
};

#endif  // KTOUCHLECTURE_H