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
167
168
169
170
171
172
173
174
175
176
177
|
/***************************************************************************
structtreeview.h - description
-------------------
begin : Sat Apr 29 2000
copyright : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky <pdima@mail.univ.kiev.ua>
(C) 2002, 2003 Andras Mantia <amantia@kde.org>
***************************************************************************/
/***************************************************************************
* *
* 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 STRUCTTREEVIEW_H
#define STRUCTTREEVIEW_H
#include <tqmap.h>
#include <tqvaluelist.h>
#include <klistview.h>
/**view class of document structure
*@author Andras Mantia & Paulo Moura Guedes & Yacovlev Alexander & Dmitry Poplavsky
*/
class KPopupMenu;
class KConfig;
class KURL;
class TQTime;
class Node;
class StructTreeTag;
class Parser;
class Document;
struct DTDStruct;
class StructTreeView : public KListView {
Q_OBJECT
TQ_OBJECT
public:
/**
* since this class is a singleton you must use this function to access it
*
* the parameters are only used at the first call to create the class
*
*/
static StructTreeView* const ref(TQWidget *parent = 0L, const char *name = 0L)
{
static StructTreeView *m_ref;
if (!m_ref) m_ref = new StructTreeView (parent, name);
return m_ref;
}
~StructTreeView();
void setFollowCursor(bool);
bool followCursor() { return followCursorFlag; }
/** Show the element in tree according to cursor position (x,y) */
void showTagAtPos(Node *node);
/** Delete the items */
void deleteList(bool groupOnly);
void setParsingDTDs(const TQStringList &parsingDTDList);
void showMessage(const TQString& message);
bool useOpenLevelSetting;
public slots: // Public slots
/** repaint document structure */
void slotReparse(Document *w, Node* node, int openLevel = 3,bool groupOnly=false);
void slotMouseClicked(int button, TQListViewItem*, const TQPoint&, int);
void slotDoubleClicked( TQListViewItem * );
// slots for RBM menu
void slotReparseMenuItem();
void slotSelectTag();
void slotGotoTag( TQListViewItem *item );
void slotGotoClosingTag();
/** Recursively open the tree and all its subtrees */
void slotOpenSubTree();
/** Recursively close the tree and all its subtrees */
void slotCloseSubTree();
void changeFollowCursor() { setFollowCursor(!followCursorFlag); }
/** No descriptions */
void slotCollapsed(TQListViewItem *item);
/** No descriptions */
void slotExpanded(TQListViewItem *);
void slotOpenFile();
void slotNodeTreeChanged();
void slotRemoveTags();
signals:
void newCursorPosition( int col, int row );
void selectTagArea(Node* node);
void selectArea(int col1, int row1, int col2, int row2 );
void needReparse();
void onTag( const TQString &tag );
void showGroupsForDTEP(const TQString& dtep, bool show);
void openFile(const KURL&);
void openImage(const KURL&);
void showProblemMessage(const TQString&);
void clearProblemOutput();
private:
/** The constructor is private because we use singleton pattern.
* If you need the class use StructTreeView::ref() for
* construction and reference
*/
StructTreeView(TQWidget *parent=0, const char *name=0);
/** builds the structure tree */
void buildTree(Node *baseNode, int openLevel, bool groupOnly);
/** Do the recursive opening or closing of the trees */
void setOpenSubTree(TQListViewItem *it, bool open);
/** Make ctrl have the same behavior has shift */
void setContiguousSelectedItems();
void copySelectedItems(TQListViewItem* parent, TQListViewItem* after);
void moveSelectedItems(TQListViewItem* parent, TQListViewItem* after);
private:
int followCursorId;
bool followCursorFlag;
KPopupMenu *popupMenu;
KPopupMenu *emptyAreaMenu;
KPopupMenu *dtdMenu;
StructTreeTag *lastTag;
KConfig *config;
TQStringList dtdList;
TQValueList<const DTDStruct*> m_parsingDTDList;
int openFileMenuId;
TQMap<TQString, uint> groupIds;
bool m_dirty;
StructTreeTag *top;
TQValueList<StructTreeTag*> groups;
uint groupsCount;
bool topOpened;
TQValueList<bool> groupOpened;
mutable TQListViewItem* m_marker; //track that has the drag/drop marker under it
TQListViewItem* m_draggedItem;
// mutable TQWidget* m_thisWidget; // non const this hack for acceptDrag
protected: // Protected methods
/** Do a reparse before showing. */
virtual void showEvent(TQShowEvent*);
/** Clear the problem output when hiding. */
virtual void hideEvent(TQHideEvent*);
// drag functions
virtual bool acceptDrag(TQDropEvent* e) const;
virtual void startDrag();
virtual void contentsMousePressEvent(TQMouseEvent* e);
protected slots: // Protected slots
/** The treeview DTD has changed to id. */
void slotDTDChanged(int id);
void slotMouseClickedVPL(int button, TQListViewItem*, const TQPoint&, int);
virtual void slotDropped(TQDropEvent* e, TQListViewItem* parent, TQListViewItem* after);
protected: // Protected attributes
Document *write;
TQTime *timer;
};
#endif
|