diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 90825e2392b2d70e43c7a25b8a3752299a933894 (patch) | |
tree | e33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/docs/examples/qdocviewer | |
download | tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kjsembed/docs/examples/qdocviewer')
-rwxr-xr-x | kjsembed/docs/examples/qdocviewer/docviewer.ui | 523 | ||||
-rw-r--r-- | kjsembed/docs/examples/qdocviewer/qdocviewer.js | 201 |
2 files changed, 724 insertions, 0 deletions
diff --git a/kjsembed/docs/examples/qdocviewer/docviewer.ui b/kjsembed/docs/examples/qdocviewer/docviewer.ui new file mode 100755 index 00000000..33db5ff2 --- /dev/null +++ b/kjsembed/docs/examples/qdocviewer/docviewer.ui @@ -0,0 +1,523 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>HelpUI</class> +<widget class="QMainWindow"> + <property name="name"> + <cstring>Form1</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>760</width> + <height>471</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>3</number> + </property> + <property name="spacing"> + <number>2</number> + </property> + <widget class="QLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QToolBox"> + <property name="name"> + <cstring>Navbar</cstring> + </property> + <property name="currentIndex"> + <number>5</number> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>StaticObjects</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Static Objects</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>StaticObjectList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>ObjectTypes</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Object Types</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>ObjectTypeList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>KJSEmbedObjects</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>KJSEmbed Objects</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>KJSEmbedObjectList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>QtObjects</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Qt Objects</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>QtObjectList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>KDEObjects</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>KDE Objects</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>KDEObjectList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>ExceptionTypes</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Exception Types</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>ExceptionTypeList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>UnconstructableTypes</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Unconstructable Types</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>UnconstructableTypeList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>Search</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Search</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>4</number> + </property> + <property name="spacing"> + <number>2</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLineEdit"> + <property name="name"> + <cstring>SearchLine</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>Search</cstring> + </property> + <property name="text"> + <string>Search</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QListBox"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>SearchResults</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + </widget> + </vbox> + </widget> + </widget> + <widget class="QTextBrowser"> + <property name="name"> + <cstring>HelpPage</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="textFormat"> + <enum>RichText</enum> + </property> + </widget> + </hbox> + </widget> + </grid> +</widget> +<menubar> + <property name="name"> + <cstring>MenuBar</cstring> + </property> + <item text="&File" name="fileMenu"> + <action name="fileSaveAction"/> + <separator/> + <action name="fileExitAction"/> + </item> + <item text="&Edit" name="editMenu"> + <separator/> + <action name="editCopyAction"/> + <action name="editPasteAction"/> + <separator/> + <action name="editFindAction"/> + </item> + <item text="&Help" name="helpMenu"> + <separator/> + <action name="helpAboutAction"/> + </item> +</menubar> +<toolbars> + <toolbar dock="2"> + <property name="name"> + <cstring>toolBar</cstring> + </property> + <property name="label"> + <string>Tools</string> + </property> + <action name="fileExitAction"/> + <action name="editCopyAction"/> + </toolbar> +</toolbars> +<actions> + <action> + <property name="name"> + <cstring>fileSaveAction</cstring> + </property> + <property name="iconSet"> + <iconset>image0</iconset> + </property> + <property name="text"> + <string>Save</string> + </property> + <property name="menuText"> + <string>&Save</string> + </property> + <property name="accel"> + <string>Ctrl+S</string> + </property> + </action> + <action> + <property name="name"> + <cstring>fileExitAction</cstring> + </property> + <property name="text"> + <string>Exit</string> + </property> + <property name="menuText"> + <string>E&xit</string> + </property> + <property name="accel"> + <string></string> + </property> + </action> + <action> + <property name="name"> + <cstring>editCopyAction</cstring> + </property> + <property name="iconSet"> + <iconset>image1</iconset> + </property> + <property name="text"> + <string>Copy</string> + </property> + <property name="menuText"> + <string>&Copy</string> + </property> + <property name="accel"> + <string>Ctrl+C</string> + </property> + </action> + <action> + <property name="name"> + <cstring>editPasteAction</cstring> + </property> + <property name="iconSet"> + <iconset>image2</iconset> + </property> + <property name="text"> + <string>Paste</string> + </property> + <property name="menuText"> + <string>&Paste</string> + </property> + <property name="accel"> + <string>Ctrl+V</string> + </property> + </action> + <action> + <property name="name"> + <cstring>editFindAction</cstring> + </property> + <property name="iconSet"> + <iconset>image3</iconset> + </property> + <property name="text"> + <string>Find</string> + </property> + <property name="menuText"> + <string>&Find...</string> + </property> + <property name="accel"> + <string>Ctrl+F</string> + </property> + </action> + <action> + <property name="name"> + <cstring>helpAboutAction</cstring> + </property> + <property name="text"> + <string>About</string> + </property> + <property name="menuText"> + <string>&About</string> + </property> + <property name="accel"> + <string></string> + </property> + </action> +</actions> +<images> + <image name="image0"> + <data format="PNG" length="217">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000a049444154789cd5954d0a802010859fd14668e18de662d222bc98376a21b4ac451992c66469e0b7f187f1f11c47052a218e762daddbfb9e99f6568f80b5364b8588ce35440400e80a398ce8f99034d2292cc37c8ebd530feb583a05e954341f8a027b2a7d3a1f09bf854dc5d5d953aa396e4f38cab199e2d2e108abe156f82e30977fcb4d8ff942d75dbebed2e143953a93f6caad3d6111f44b7d4f820ff9c0069bb51ecd122066740000000049454e44ae426082</data> + </image> + <image name="image1"> + <data format="PNG" length="248">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000bf49444154789cd593410a83301045df488ee51dbc8c3ba98bf46a9eabd385350d266362444a3f0c4266fcf3f824f06f12402b66da8c55f3de2212cf9d92cb98c0ba2d7c4544cf9a07638bbad53c4491235ecf7cc1623697a92540c11ff4fda75275015d24a9389e7d6f53df4fe4ccab323eea0f03c0c4b2a0712ce6add89b59b7661c3be095985f261679ee4ebcc22c9788551fe6a2cbc4969a894bcb6f23ee361aab62e252c57294dfbfb610bbf2c897b8a46cc6677eaa519571fa087ea83762da9aba45b637520000000049454e44ae426082</data> + </image> + <image name="image2"> + <data format="PNG" length="270">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000d549444154789cc5955d0a84300c8427e2a90a9e6c8b0f4b3dd982d7ca3e58d7fe4cd0ba5d7640024df265da0a057e2439c9eb8d9eaa8841a0c9aad8c82ab32f9c425be1e30e0dcf00c00308f0b3a7a07410a9d7142e00b42c5a5fab696b979b1c837fc0c316b6e4165b64f78d716359919bdc4570de47c04732dd5e5bcc35f0c97762ae787936dccf7513577e79f48c4b27aa0f1327b240f5117fcbe348aa33b6e0224b054d0746b8025e2e3b3e73cde0dd1c97f02e8ed9d0af1db381224bdf33eee698a934a0f617b45540d00bcf4ca08fc0dff406e325c198b16b67fb0000000049454e44ae426082</data> + </image> + <image name="image3"> + <data format="PNG" length="662">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000025d49444154789cd593a172db4010863f670a56ecc42278d0653693a0c21c68d6c2e60df21a818111349499c254a8329b55f0e089ddb15ba602b79d6692d699b6d399fee86e67e7db7f77efe07fd3e2c74bd775b3730eef3d5115002382b5166b2d5757578b1729bf02b76d3b0f8703b92d58aed7600400ef1ce3c70306a8aa8aebebeb57c117dfa06ddb525dd754efb600a82a49138a123532ec3ac42b9bcde655ce2ffabe9f87c340fde13dcb4d8daaa24e48ee12c6823808c107969b1a8a9ce3f1f8aa515c38e7c8ada5aa6b00c45f129c67d223938c88e6c860d118b1d592d139baae9bcf83a78965b5465134801b1d2e1f4945c0e350096408ea154490c2e0bd3fef5853c2e486a0019f4d84f58418418362b0408e8b23c924501093314dd359f01b809814112025144015f1964c0bbc1b484b07e4688880c029ebd78e4141f5b434fd76864c053f1e084b0f8580265440634044ce838bbcc03987a61350a3a2285e1d5a4414d0708aa598082162ad3d0fb6d6e287cfa498508d274050447370428c91af8d10fd4481608c390b5e00dcddddcd8e80a9de420248e804840856f03e02907d729465c9ba5ae3468731e6a79fe50260b55a6102c4ee40a6894c33f2cb0cb106512814f8f899b22cb9b9b959b8d1f1f8f848d334b46dfbe29bfe5eadeffbf9783c323a871881ecb4200d1151a8eb9aed76bb00188661eeba8efd7e8f3186ed76cb6ab57ae2fe591b5dd7cdde7b628c8808799e63ada5aaaa67b9bbdd6e6e9a06ef3d755d3f29fec7eafb7ebebdbd9dadb5735996f3fdfdfdfca2e3dfd5c3c3c3dc340dd334b1d96cfe1e184e63dceff7a494fe26f61fe90bbc4c5e59b8ac895e0000000049454e44ae426082</data> + </image> +</images> +<connections> + <connection> + <sender>fileExitAction</sender> + <signal>activated()</signal> + <receiver>Form1</receiver> + <slot>close()</slot> + </connection> +</connections> +<tabstops> + <tabstop>SearchLine</tabstop> + <tabstop>Search</tabstop> + <tabstop>SearchResults</tabstop> + <tabstop>HelpPage</tabstop> + <tabstop>StaticObjectList</tabstop> + <tabstop>ObjectTypeList</tabstop> + <tabstop>KJSEmbedObjectList</tabstop> + <tabstop>QtObjectList</tabstop> + <tabstop>KDEObjectList</tabstop> + <tabstop>ExceptionTypeList</tabstop> + <tabstop>UnconstructableTypeList</tabstop> +</tabstops> +<layoutdefaults spacing="2" margin="3"/> +</UI> diff --git a/kjsembed/docs/examples/qdocviewer/qdocviewer.js b/kjsembed/docs/examples/qdocviewer/qdocviewer.js new file mode 100644 index 00000000..41ae2835 --- /dev/null +++ b/kjsembed/docs/examples/qdocviewer/qdocviewer.js @@ -0,0 +1,201 @@ +#!/usr/bin/env qjscmd +// Populates the sidebar listview +function setup_sidebar( special, qt, 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 + special.insertItem( qobjects[i] ); + } +} + +function documentStaticObject( type ) +{ + HelpPage.text ="<h1>" + type + "</h1><HR>"; + try{ + var obj = eval( type ); + HelpPage.text += dump(obj); + } + catch (error) + { + HelpPage.text += "This object is not supported by this version of KJSEmbed"; + } +} + +function documentConstructableObject( type ) +{ + HelpPage.text ="<h1>" + type + "</h1><HR>"; + if ( type!= 'TextStream' ) + { + try { + HelpPage.text += dump(Factory.createObject( type )); + } + catch(x) { + HelpPage.text +='Bindings for the ' + type + ' class.<br /> This class is understood by the interpreter, but cannot be created from scripts.' + } + } +} + +function populateStaticObjects() +{ + StaticObjectList.clear(); + var statics = [ 'Factory', 'System', 'Global', 'StdDialog', + 'StdAction', 'StdDirs', 'StdIcons', 'Qt' ]; + for ( var idx = 0; idx < statics.length; idx++ ) + { + StaticObjectList.insertItem(statics[idx]); + } +} + +function populateExceptions() +{ + var expts = [ 'ReferenceError', 'EvalError', 'RangeError', 'TypeError' ]; + for ( var idx = 0; idx < expts.length; idx++ ) + { + ExceptionTypeList.insertItem(expts[idx]); + } +} + +function populateObjects() +{ + var tps = Factory.types().sort(); + QtObjectList.clear(); + KJSEmbedObjectList.clear(); + KDEObjectList.clear(); + ObjectTypeList.clear(); + + cons = Factory.constructors().sort(); + cons += 'Part'; + + for ( var i=0; i < tps.length; i++ ) { + + if ( /^Q/.test(tps[i]) ) { + QtObjectList.insertItem( tps[i] ); + } + else if ( /^KJSEmbed::/.test(tps[i]) ) { + if ( tps[i] != 'KJSEmbed::Bindings::JSDCOPInterface' ) { + KJSEmbedObjectList.insertItem( tps[i] ); + } + } + else if ( /^K/.test(tps[i]) ) { + KDEObjectList.insertItem( tps[i] ); + } + else { + ObjectTypeList.insertItem( tps[i] ); + } + } +} +// +// Main +// + +// Create the UI +var mw = Factory.loadui("docviewer.ui"); +//mw.qt_central_widget.HelpPage.text = dump(mw.qt_central_widget.Navbar.StaticObjects.StaticObjectList); +var HelpPage = mw.qt_central_widget.HelpPage; +var StaticObjectList = mw.qt_central_widget.Navbar.StaticObjects.StaticObjectList; +var ExceptionTypeList = mw.qt_central_widget.Navbar.ExceptionTypes.ExceptionTypeList; +var KDEObjectList = mw.qt_central_widget.Navbar.KDEObjects.KDEObjectList; +var QtObjectList = mw.qt_central_widget.Navbar.QtObjects.QtObjectList; +var KJSEmbedObjectList = mw.qt_central_widget.Navbar.KJSEmbedObjects.KJSEmbedObjectList; +var ObjectTypeList = mw.qt_central_widget.Navbar.ObjectTypes.ObjectTypeList; + +populateStaticObjects(); +populateExceptions(); +populateObjects(); + +mw.connect( StaticObjectList, 'highlighted(const QString&)', this, 'documentStaticObject' ); +mw.connect( ExceptionTypeList, 'highlighted(const QString&)', this, 'documentStaticObject' ); +mw.connect( KDEObjectList, 'highlighted(const QString&)', this, 'documentConstructableObject' ); +mw.connect( QtObjectList, 'highlighted(const QString&)', this, 'documentConstructableObject' ); +mw.connect( KJSEmbedObjectList, 'highlighted(const QString&)', this, 'documentConstructableObject' ); +mw.connect( ObjectTypeList, 'highlighted(const QString&)', this, 'documentConstructableObject' ); + + +mw.show(); +application.exec(); +/* + +side = new QTabWidget( split, 'sidebar' ); +view = new QTabWidget( split, 'mainview' ); + +// Load the view +js = new QTextEdit( view, 'js' ); +js.setReadOnly( true ); + +view.addTab( js, '&Javascript' ); + +view.set_class = function( clazz ) +{ + clazz = clazz.replace( '^[^QK]*', '' ); + + // JS docs + var s = ''; + + s = s + '<html>'; + s = s + '<body>'; + s = s + '<h1>' + clazz + '</h1>'; + + try { + var obj = eval('new '+clazz+'()'); + s = s + dump(obj); + } + catch ( err ) { + s = s + '<font color="red">Error dumping object: ' + err + '</font>'; + } + + s = s + '</body>'; + s = s + '</html>'; + + js.text = s; +} + +view.setup = function() +{ + // JS docs + var s = ''; + s = s + '<html>'; + s = s + '<body>'; + s = s + '<h1>Script Reference</h1>'; + s = s + '</body>'; + s = s + '</html>'; + + js.text = s; +} + +// Setup the sidebar +specialside = new QListBox( side, 'specialsidebar' ); +qtside = new QListBox( side, 'qtsidebar' ); +allside = new QListBox( side, 'allsidebar' ); + +side.addTab( specialside, '&Special' ); +side.addTab( qtside, '&Qt' ); +side.addTab( allside, '&All' ); + +setup_sidebar( specialside, qtside, allside ); + +qtside.connect( qtside, 'highlighted(const QString&)', view, 'set_class' ); +specialside.connect( specialside, 'highlighted(const QString&)', view, 'set_class' ); +allside.connect( allside, 'highlighted(const QString&)', view, 'set_class' ); + +// +// Show the window +// + +side.maximumWidth = 250; +mw.resize( 800, 550 ); + +mw.show(); + +// +// Connect together +// +view.setup(); + +application.exec(); +*/ |