SVN_SILENT made messages (.desktop file)
[kdeaccessibility.git] / ksayit / src / doctreeviewimpl.h
blob03af8f2f0f8cc9ce027b5aa17f1499a7f84a5aad
1 //
2 // C++ Interface: doctreeviewimpl
3 //
4 // Description:
5 //
6 //
7 // Author: Robert Vogl <voglrobe@lapislazuli>, (C) 2004
8 //
9 // Copyright: See COPYING file that comes with this distribution
12 #ifndef DOCTREEVIEWIMPL_H
13 #define DOCTREEVIEWIMPL_H
15 // Qt includes
16 #include <QString>
17 #include <qdom.h>
18 //Added by qt3to4:
19 #include <QContextMenuEvent>
20 #include <QTextStream>
22 // KDE includes
23 #include <kurl.h>
24 #include <k3listview.h>
25 #include <kmenu.h>
27 // App specific includes
28 #include "Types.h"
29 #include "DocTreeView.h"
31 // forward declarations
32 class ParaSaxParser;
33 class ContextMenuHandler;
36 /**
37 This class implements the TreeView object.\n
38 It takes a XML/DocBook file, parses it and builds up a hierarchical
39 \p QListView structure corresponding to the structure of the document.
40 The objective of this class is to maintain the document and provide
41 all required methods to access or manipulate its content.
42 @author Robert Vogl
44 class DocTreeViewImpl : public DocTreeView
46 public:
47 DocTreeViewImpl(QWidget* parent=0, const char* name=0, Qt::WFlags fl=0);
49 ~DocTreeViewImpl();
51 /**
52 * Tries to open and parse the given file. If the file is not identified as a
53 * valid XML/DocBook file, it will be packed as a \p CDATA block into a \p para element
54 * of a simple DocBook'ish XML file.
55 * \param url The URL of the file.
57 void openFile(const KUrl &url);
59 /**
60 * Saves the document to a XML file.
62 void saveFile();
64 /**
65 * Saves the document to a XML file and allows the user to define a name.
67 void saveFileAs();
69 /**
70 * Cleans up the interal document data structures.
72 void clear();
74 /**
75 * Creates an empty XML document that conatins one editable DocBook \p Paragraph.
76 * Usually called after clean() and initial startup.
78 void createEmptyDocument();
80 /**
81 * Stores the given text in the current node.
82 * \param text The new content of the current DOM node.
84 void setNodeContent(QString &text);
86 /**
87 * Starting from the current selected node it travels recursively
88 * through all childs and collects the content of all corresponding
89 * DOM nodes. After sending the text to the TTS system the speech synthesis
90 * process will be started.
92 void sayActiveNodeAndChilds();
94 /**
95 * Signals a stop-talking-request from the user.
97 void stop();
99 /**
100 * Controls the Edit Mode.
101 * \param mode If true, Edit Mode ON,\n if false, Edit Mode OFF.
103 void setEditMode(bool mode);
106 * Sets the item active designated by the ID.
107 * \param ID The ID (column 3) of the TreeView item.
108 * \returns <tt>QString()</tt> if the operation was successfull,\n
109 * an error message, if the item was not found.
111 QString selectItemByID(const QString &ID, const QString title);
114 * Enables/disables the contextmenus
116 void enableContextMenus( bool enabled );
118 public slots:
119 void slotRenameItem(); // reimplemented from base classes
120 void slotDeleteItem();
121 void slotNewBookInfo();
122 void slotNewChapter();
123 void slotNewKeywordSet();
124 void slotNewKeyword();
125 void slotNewAbstract();
126 void slotNewAuthorGroup();
127 void slotNewAuthor();
128 void slotNewDate();
129 void slotNewReleaseInfo();
130 void slotNewTitle();
131 void slotNewParagraph();
132 void slotNewSection_1();
133 void slotNewSection_2();
134 void slotNewSection_3();
135 void slotNewSection_4();
136 void slotNewSection_5();
138 protected slots:
140 * Reimplemented from base class.
141 * Called whenever the active node has been changed.\n
142 * Makes the former selected item persistent (maybe it has
143 * been changed).\n
144 * Displays the content of the selected Node either in RTF or
145 * plain text format (depending on the Edit Mode flag, childs
146 * present or not).\n
147 * Informs the BookmarkManager about the new item.
149 * \param item The new active item of the TreeView.
151 void slotItemClicked(Q3ListViewItem *item);
154 * Reimplemented from QWidget class.
156 void contextMenuEvent(QContextMenuEvent *e);
158 private: // Methods
159 // a selection of DocBook elements
160 void parseBook(const QDomElement &element, ListViewInterface *item);
161 void parseBookInfo(const QDomElement &element, ListViewInterface *item);
162 void parseAuthorGroup(const QDomElement &element, ListViewInterface *item);
163 void parseAuthor(const QDomElement &element, ListViewInterface *item);
164 void parseKeywordSet(const QDomElement &element, ListViewInterface *item);
165 void parseAbstract(const QDomElement &element, ListViewInterface *item);
166 void parseChapter(const QDomElement &element, ListViewInterface *item);
167 void parseSect1(const QDomElement &element, ListViewInterface *item);
168 void parseSect2(const QDomElement &element, ListViewInterface *item);
169 void parseSect3(const QDomElement &element, ListViewInterface *item);
170 void parseSect4(const QDomElement &element, ListViewInterface *item);
171 void parseSect5(const QDomElement &element, ListViewInterface *item);
172 void parsePara(const QDomElement &element, ListViewInterface *item);
174 // helpers
175 void recursiveTextCollector(ListViewInterface* item, QTextStream &msg, bool header=true);
176 void recursiveSayNodes(ListViewInterface* item);
177 void recursiveBuildItemIdentifier(ListViewInterface* item, QTextStream &idstring);
178 void makeCurrentNodePersistent();
179 int newIndexFirstChild();
180 int newIndexLastChild();
181 void findHighestIndex(ListViewInterface* item, int &index);
182 QString getItemTitle( ListViewInterface *item);
185 private: // Attributes
186 ContextMenuHandler *m_contextmenuhandler;
187 KMenu *m_contextmenu;
188 QDomDocument m_domTree;
189 ListViewInterface *m_rootItem;
190 ListViewInterface *m_currentItem;
191 QString m_changedContent;
192 int m_idCounter;
193 bool m_stopped;
194 KUrl m_url;
195 ParaSaxParser *m_parasaxparser;
196 bool m_editMode;
203 #endif