summaryrefslogtreecommitdiffstats
path: root/kverbos/kverbos/kverbosdoc.h
blob: 0795e823aac013eda5873d0892d20c6b59c6f811 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/***************************************************************************
                          kverbosdoc.h  -  description
                             -------------------
    begin                : Fre Dez 14 19:28:09 CET 2001
    copyright            : (C) 2001 by Arnold Kraschinski
    email                : arnold.k67@gmx.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 KVERBOSDOC_H
#define KVERBOSDOC_H

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

// include files for QT
#include <tqfile.h>

// include files for KDE
#include <kurl.h>

// include files des Projektes
#include "verbspanish.h"

// forward declaration of the Kverbos classes
class KVerbosView;
class KVerbosUser;


/**
 *  KVerbosDoc provides a document object for a document-view model.
 *
 *  The KVerbosDoc class provides a document object that can be used in conjunction with
 *  the classes KVerbosApp and KVerbosView to create a document-view model for standard KDE
 *  applications based on KApplication and KMainWindow. Thereby, the document object
 *  is created by the KVerbosApp instance and contains the document structure with the
 *  according methods for manipulation of the document data by KVerbosView objects. Also,
 *  KVerbosDoc contains the methods for serialization of the document data from and to files.
 *
 *  Die Dokumentenklasse hält eine Liste der verfügbaren Verben vor. Aus dieser Liste wird
 *  eines ausgewählt, das gelernt werden soll. Die View-Klasse kann dieses Verb abfragen und
 *  in dem Lernfenster darstellen.
 *  Es gibt einige Situationen, die eine neuen Wahl dieses Verbes erforderlich machen:
 *  - zu Beginn des Programms, wenn die Klasse gebildet wird
 *  - wenn eine neue Verbendatei geladen wird
 *  - wenn die View-Klasse eine neue Wahl anfordert
 *    die View-Klasse merkt sich die Anzahl der richtig gelösten Verben.
 *
 *  @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
 *  @version KDevelop version 1.2 code generation
 */
class KVerbosDoc : public TQObject
{
  Q_OBJECT
  TQ_OBJECT
  public:
    /**
     * Constructor for the fileclass of the application
     */
    KVerbosDoc(TQWidget *parent, const char *name=0);
    /**
     * Destructor for the fileclass of the application
     */
    ~KVerbosDoc();

    /** adds a view to the document which represents the document contents. Usually this is your main view. */
    void addView(KVerbosView *view);
    /** removes a view from the list of currently connected views */
    void removeView(KVerbosView *view);
    /** sets the modified flag for the document after a modifying action on the view connected to the document.*/
    void setModified(bool _m=true){ modified=_m; }
    /** returns if the document is modified or not. Use this to determine if your document needs saving by the user on closing.*/
    bool isModified(){ return modified; }
    /** "save modified" - asks the user for saving if the document is modified */
    bool saveModified();
    /** deletes the document's contents */
    void deleteContents();
    /** initializes the document generally */
    bool newDocument();
    /** closes the acutal document */
    void closeDocument();
    /** loads the document by filename and format and emits the updateViews() signal
     *  Es werden bei der Datei die beiden Formate HTML-Datei und reine Textdatei unter-
     *  schieden
     */
    bool openDocument(const KURL& url, const char *format=0);
    bool openDocHTML(TQFile &f);
    bool openDocVERBOS(TQFile &f);
    /** saves the document under filename and format.
     *  Die Datei kann wahlweise im HTML-Format oder als normale Textdatei abgespeichert
     *  werden. Die HTML-Datei ist umfangreicher, weil der formatierende HTML-Code
     *  ergänzt werden muss.
     */
    bool saveDocument(const KURL& url, const char *format=0);
    bool saveDocHTML(TQFile &f);
    bool saveDocVERBOS(TQFile &f);
    /** sets a new user name, and deletes the old one. If the old one is different from
      * the default name DEFAULTUSER then some information is stored about the user. The
      * Program look if some information about the user is stored.
      */
    void setNewUser(const TQString n);
    /** returns a pointer to the actual user object */
    KVerbosUser* getUser() { return benutzer; }
    /** returns the KURL of the document */
    const KURL& URL() const;
    /** sets the URL of the document */
	  void setURL(const KURL& url);
	  /** es wird ein Verb der Liste hinzugefügt, ist emitStatus = true, wird auch
	   *  die Statuszeile entsprechend angepasst.
	   */
	  void appendVerb(const verbSpanish v, bool emitStatus = true);
	  /** prüft, ob die Liste des Dokumentes leer ist */
	  bool isEmpty() const;
	  /** Gibt einen Zeiger auf die Verbliste des Dokumentes zurück */
	  spanishVerbList* getList();
	  /** Gibt die Anzahl der Verben im Dokument zurück */
	  int getAnzahl() const { return verbList2.count(); }
	  /** Gibt die gewählte Zeit, die Formen des Verbes dazu und den spanischen
	    * und deutschen Infinitiv zurück
	    */
	  TQString getAuswahl(TQString s[][3], int &t);
	  /** feedback from the view class about the solution */
	  void solved(const bool b);
	private:
	  /** searches the verb given as a string in the list and returns a pointer to the verb */
	spanishVerbList::Iterator findVerb(const TQString& s);

  signals:
    /** wird emittiert, wenn sich die Anzahl der Verben im Dokument verändert hat */
    void anzahlVerbenGeaendert( int );
    void changeView();

  public slots:
    /**
     * calls tqrepaint() on all views connected to the document object and is called by the view by which the document has been changed.
     *  As this view normally repaints itself, it is excluded from the paintEvent.
     */
    void slotUpdateAllViews(KVerbosView *sender);

  public:
    /**
     *  the list of the views currently connected to the document
     */
    static TQPtrList<KVerbosView> *pViewList;

  private:
    /**
     *  the modified flag of the current document
     */
    bool modified;
    KURL doc_url;
    /** Die Liste der Verben */
    spanishVerbList verbList2;
    KVerbosUser* benutzer;
};

#endif // KVERBOSDOC_H