2 // C++ Interface: doctreeviewimpl
7 // Author: Robert Vogl <voglrobe@lapislazuli>, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
12 #ifndef DOCTREEVIEWIMPL_H
13 #define DOCTREEVIEWIMPL_H
19 #include <QContextMenuEvent>
20 #include <QTextStream>
24 #include <k3listview.h>
27 // App specific includes
29 #include "DocTreeView.h"
31 // forward declarations
33 class ContextMenuHandler
;
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.
44 class DocTreeViewImpl
: public DocTreeView
47 DocTreeViewImpl(QWidget
* parent
=0, const char* name
=0, Qt::WFlags fl
=0);
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
);
60 * Saves the document to a XML file.
65 * Saves the document to a XML file and allows the user to define a name.
70 * Cleans up the interal document data structures.
75 * Creates an empty XML document that conatins one editable DocBook \p Paragraph.
76 * Usually called after clean() and initial startup.
78 void createEmptyDocument();
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
);
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();
95 * Signals a stop-talking-request from the user.
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
);
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();
129 void slotNewReleaseInfo();
131 void slotNewParagraph();
132 void slotNewSection_1();
133 void slotNewSection_2();
134 void slotNewSection_3();
135 void slotNewSection_4();
136 void slotNewSection_5();
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
144 * Displays the content of the selected Node either in RTF or
145 * plain text format (depending on the Edit Mode flag, childs
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
);
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
);
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
;
195 ParaSaxParser
*m_parasaxparser
;