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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
#!/usr/bin/env kjscmd
// Populates the sidebar listview
function setup_sidebar( builtins, special, qt, kde, all )
{
var qobjects = Factory.constructors().sort();
for ( var i=0; i < qobjects.length ; i++ ) {
all.insertItem( qobjects[i] );
if ( /^Q/.test(qobjects[i]) )
qt.insertItem( qobjects[i] );
else if ( /^K/.test(qobjects[i]) )
kde.insertItem( qobjects[i] );
else
special.insertItem( qobjects[i] );
}
qt.insertItem( 'Qt' );
builtins.insertItem( 'System' );
builtins.insertItem( 'StdIcons' );
builtins.insertItem( 'Factory' );
builtins.insertItem( 'StdDirs' );
builtins.insertItem( 'StdAction' );
}
//
// Main
//
// Create the UI
var mw = new KMainWindow(this);
var ac = mw.actionCollection();
var split = new TQSplitter( mw );
mw.setCentralWidget( split );
side = new TQToolBox( split, 'sidebar' );
view = new TQTabWidget( split, 'mainview' );
// Load the view
jsview = Factory.createROPart( "text/html", view, "js" );
cppview = Factory.createROPart( "text/html", view, "cpp" );
js = view.child(4);
cpp = view.child(6);
view.addTab( js, '&Javascript' );
view.addTab( cpp, '&C++' );
view.set_class = function( clazz )
{
var nm;
clazz = clazz.replace( '^[^QK]*', '' );
if ( /^Q/.test(clazz) )
nm = 'http://doc.trolltech.com/3.2/' + clazz.toLowerCase() + '.html';
else if ( /^K/.test(clazz) )
nm = 'http://developer.kde.org/documentation/library/cvs-api/tdeui/html/class' + clazz + '.html';
cppview.openURL( nm );
// JS docs
jsview.openStream( 'text/html', 'file:///index.html' );
jsview.writeStream( '<html>' );
jsview.writeStream( '<head>' );
jsview.writeStream( '<style type="text/css"><!--' );
jsview.writeStream( 'h1 { text-align: center; background-color: #ccccff; }' );
jsview.writeStream( 'h2 { background-color: #eeeeff; }' );
jsview.writeStream( 'h3 { background-color: #eeeeff; }' );
jsview.writeStream( 'th { background-color: #cccccc; }' );
jsview.writeStream( 'td { background-color: #eeeeee; }' );
jsview.writeStream( 'table { font-family: sans-serif; font-size: 8pt }' );
jsview.writeStream( '--></style>' );
jsview.writeStream( '</head>' );
jsview.writeStream( '<body>' );
jsview.writeStream( '<h1>' + clazz + '</h1>' );
try {
var obj = eval('new '+clazz+'(this)');
jsview.writeStream( dump(obj) );
}
catch ( err ) {
try {
var obj = eval(clazz);
jsview.writeStream( dump(obj) );
}
catch ( err2 ) {
jsview.writeStream( '<font color="red">Error dumping object: ' + err + '<hr>' + err2 + '</font>' );
}
}
jsview.writeStream( '</body>' );
jsview.writeStream( '</html>' );
jsview.closeStream();
}
view.setup = function()
{
// JS docs
jsview.openStream( 'text/html', 'file:///index.html' );
jsview.writeStream( '<html>' );
jsview.writeStream( '<head>' );
jsview.writeStream( '<style type="text/css"><!--' );
jsview.writeStream( 'h1 { text-align: center; background-color: #ccccff; }' );
jsview.writeStream( 'h2 { background-color: #eeeeff; }' );
jsview.writeStream( 'h3 { background-color: #eeeeff; }' );
jsview.writeStream( 'table { font-family: sans-serif; font-size: 8pt }' );
jsview.writeStream( '--></style>' );
jsview.writeStream( '</head>' );
jsview.writeStream( '<body>' );
jsview.writeStream( '<h1>Script Reference</h1>' );
jsview.writeStream( '</body>' );
jsview.writeStream( '</html>' );
jsview.closeStream();
// C++ docs
cppview.openStream( 'text/html', 'file:///index.html' );
cppview.writeStream( '<html>' );
cppview.writeStream( '<head>' );
cppview.writeStream( '<style type="text/css"><!--' );
cppview.writeStream( 'h1 { text-align: center; background-color: #ccccff; }' );
cppview.writeStream( 'h2 { background-color: #ccccff; }' );
cppview.writeStream( 'h3 { background-color: #ddddff; }' );
cppview.writeStream( 'table { font-family: sans-serif; font-size: 8pt }' );
cppview.writeStream( '--></style>' );
cppview.writeStream( '</head>' );
cppview.writeStream( '<body>' );
cppview.writeStream( '<h1>C++ Reference</h1>' );
cppview.writeStream( '</body>' );
cppview.writeStream( '</html>' );
cppview.closeStream();
jsview.connect( jsview.child(0), 'openURLRequest(const KURL&,const KParts::URLArgs&)', 'openURL(const KURL&)' );
cppview.connect( cppview.child(0), 'openURLRequest(const KURL&,const KParts::URLArgs&)', 'openURL(const KURL&)' );
}
// Setup the sidebar
builtinside = new KListView( side, 'builtinside' );
builtinside.addColumn( 'Class' );
builtinside.resizeMode = 2; // LastColumn
builtinside.changed = function()
{
var item = this.selectedItem();
view.set_class( item.text(0) );
}
specialside = new KListView( side, 'specialsidebar' );
specialside.addColumn( 'Class' );
specialside.resizeMode = 2; // LastColumn
specialside.changed = function()
{
var item = this.selectedItem();
view.set_class( item.text(0) );
}
qtside = new KListView( side, 'qtsidebar' );
qtside.addColumn( 'Class' );
qtside.resizeMode = 2; // LastColumn
qtside.changed = function()
{
var item = this.selectedItem();
view.set_class( item.text(0) );
}
kdeside = new KListView( side, 'kdesidebar' );
kdeside.addColumn( 'Class' );
kdeside.resizeMode = 2; // LastColumn
kdeside.changed = function()
{
var item = this.selectedItem();
view.set_class( item.text(0) );
}
allside = new KListView( side, 'allsidebar' );
allside.addColumn( 'Class' );
allside.resizeMode = 2; // LastColumn
allside.changed = function()
{
var item = this.selectedItem();
view.set_class( item.text(0) );
}
side.addItem( builtinside, '&Builtins' );
side.addItem( specialside, 'K&JSEmbed' );
side.addItem( kdeside, '&KDE' );
side.addItem( qtside, '&Qt' );
side.addItem( allside, '&All' );
setup_sidebar( builtinside, specialside, qtside, kdeside, allside );
kdeside.connect( kdeside, 'selectionChanged()', kdeside, 'changed' );
qtside.connect( qtside, 'selectionChanged()', qtside, 'changed' );
specialside.connect( specialside, 'selectionChanged()', specialside, 'changed' );
builtinside.connect( builtinside, 'selectionChanged()', builtinside, 'changed' );
allside.connect( allside, 'selectionChanged()', allside, 'changed' );
//
// Activate XMLGUI and show the window
//
var quitAction = StdAction.quit( 0, 0, mw.actionCollection() );
mw.connect( quitAction, 'activated()', this, 'exit');
mw.createGUI( 'stdactionsui.rc' );
side.maximumWidth = 250;
mw.resize( 800, 550 );
mw.show();
//
// Connect together
//
view.setup();
application.exec();
|