From ae2858133ebe92da16e5aab05f0b138de7cf514c Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 1 Feb 2013 17:32:44 -0600 Subject: Fix prior commit --- kjsembed/qtbindings/qchecklistitem_imp.cpp | 587 +++++++++++++++++++++ kjsembed/qtbindings/qchecklistitem_imp.h | 139 +++++ kjsembed/qtbindings/qchectdelistitem_imp.cpp | 587 --------------------- kjsembed/qtbindings/qchectdelistitem_imp.h | 139 ----- qtjava/javalib/examples/checklists/CheckLists.java | 171 ++++++ qtjava/javalib/examples/checklists/Main.java | 31 ++ .../javalib/examples/chectdelists/CheckLists.java | 171 ------ qtjava/javalib/examples/chectdelists/Main.java | 31 -- .../examples/qt-examples/checklists/checklists.rb | 147 ++++++ .../examples/qt-examples/checklists/main.rb | 15 + .../qt-examples/chectdelists/chectdelists.rb | 147 ------ .../examples/qt-examples/chectdelists/main.rb | 15 - 12 files changed, 1090 insertions(+), 1090 deletions(-) create mode 100644 kjsembed/qtbindings/qchecklistitem_imp.cpp create mode 100644 kjsembed/qtbindings/qchecklistitem_imp.h delete mode 100644 kjsembed/qtbindings/qchectdelistitem_imp.cpp delete mode 100644 kjsembed/qtbindings/qchectdelistitem_imp.h create mode 100644 qtjava/javalib/examples/checklists/CheckLists.java create mode 100644 qtjava/javalib/examples/checklists/Main.java delete mode 100644 qtjava/javalib/examples/chectdelists/CheckLists.java delete mode 100644 qtjava/javalib/examples/chectdelists/Main.java create mode 100644 qtruby/rubylib/examples/qt-examples/checklists/checklists.rb create mode 100755 qtruby/rubylib/examples/qt-examples/checklists/main.rb delete mode 100644 qtruby/rubylib/examples/qt-examples/chectdelists/chectdelists.rb delete mode 100755 qtruby/rubylib/examples/qt-examples/chectdelists/main.rb diff --git a/kjsembed/qtbindings/qchecklistitem_imp.cpp b/kjsembed/qtbindings/qchecklistitem_imp.cpp new file mode 100644 index 00000000..9aa28e41 --- /dev/null +++ b/kjsembed/qtbindings/qchecklistitem_imp.cpp @@ -0,0 +1,587 @@ + + + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include "qchecklistitem_imp.h" +#include "qlistviewitem_imp.h" +/** + * Namespace containing the KJSEmbed library. + */ +namespace KJSEmbed { +namespace Bindings { + + KJS::Object TQCheckListItemLoader::createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const + { + if ( args.size() == 0 ) { + // FALL THRU + } else { + JSOpaqueProxy * arg0 = JSProxy::toOpaqueProxy( args[ 0 ].imp() ); + TQString arg1 = ( args.size() >= 2 ) ? args[ 1 ].toString( exec ).qstring() : TQString::null; + JSOpaqueProxy *prx = 0; + + if ( arg0 ) { + if ( arg0->typeName() == "TQListViewItem" ) { + TQListViewItem * parent = arg0->toNative(); + prx = new JSOpaqueProxy( new TQCheckListItem( parent, arg1 ), "TQCheckListItem" ); + } else { + return KJS::Object(); + } + } else { + JSObjectProxy *arg0 = JSProxy::toObjectProxy( args[ 0 ].imp() ); + if ( arg0 ) { + TQListView * parent = ( TQListView * ) ( arg0->widget() ); + prx = new JSOpaqueProxy( new TQCheckListItem( parent, arg1 ), "TQCheckListItem" ); + } else { + return KJS::Object(); + } + } + prx->setOwner( JSProxy::Native ); + KJS::Object proxyObj( prx ); + addBindings(jspart, exec, proxyObj ); + return proxyObj; + } + return KJS::Object(); + } + void TQCheckListItemLoader::addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy ) const + { + TQListViewItemImp::addBindings( exec, proxy ); + TQCheckListItemImp::addBindings( exec, proxy ); + } + +} +TQCheckListItemImp::TQCheckListItemImp( KJS::ExecState *exec, int mid, bool constructor ) + : JSProxyImp(exec), id(mid), cons(constructor) +{ +} + +TQCheckListItemImp::~TQCheckListItemImp() +{ +} + +void TQCheckListItemImp::addBindings( KJS::ExecState *exec, KJS::Object &object ) +{ + JSProxy::MethodTable methods[] = { + + { Method_paintCell_10, "paintCell" }, + { Method_paintFocus_11, "paintFocus" }, + { Method_width_12, "width" }, + { Method_setup_13, "setup" }, + { Method_setOn_14, "setOn" }, + { Method_isOn_15, "isOn" }, + { Method_type_16, "type" }, + { Method_text_17, "text" }, + { Method_text_18, "text" }, + { Method_setTristate_19, "setTristate" }, + { Method_isTristate_20, "isTristate" }, + { Method_state_21, "state" }, + { Method_setState_22, "setState" }, + { Method_rtti_23, "rtti" }, + { 0, 0 } + }; + + int idx = 0; + TQCString lastName; + + while( methods[idx].id ) { + if ( lastName != methods[idx].name ) { + TQCheckListItemImp *meth = new TQCheckListItemImp( exec, methods[idx].id ); + object.put( exec , methods[idx].name, KJS::Object(meth) ); + lastName = methods[idx].name; + } + ++idx; + } + + + // + // Define the enum constants + // + struct EnumValue { + const char *id; + int val; + }; + + EnumValue enums[] = { + + // enum Type + { "RadioButton", TQCheckListItem::RadioButton }, + { "CheckBox", TQCheckListItem::CheckBox }, + { "Controller", TQCheckListItem::Controller }, + { "RadioButtonController", TQCheckListItem::RadioButtonController }, + { "CheckBoxController", TQCheckListItem::CheckBoxController }, + // enum ToggleState + { "Off", TQCheckListItem::Off }, + { "NoChange", TQCheckListItem::NoChange }, + { "On", TQCheckListItem::On }, + { 0, 0 } + }; + + int enumidx = 0; + do { + object.put( exec, enums[enumidx].id, KJS::Number(enums[enumidx].val), KJS::ReadOnly ); + ++enumidx; + } while( enums[enumidx].id ); + +} + +TQCheckListItem *TQCheckListItemImp::toTQCheckListItem( KJS::Object &self ) +{ + JSObjectProxy *ob = JSProxy::toObjectProxy( self.imp() ); + if ( ob ) { + TQObject *obj = ob->object(); + if ( obj ) + return dynamic_cast( obj ); + } + + JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() ); + if ( !op ) + return 0; + return op->toNative(); +} + + +KJS::Object TQCheckListItemImp::construct( KJS::ExecState *exec, const KJS::List &args ) +{ + switch( id ) { + + case Constructor_QCheckListItem_1: + return TQCheckListItem_1( exec, args ); + break; + + case Constructor_QCheckListItem_2: + return TQCheckListItem_2( exec, args ); + break; + + case Constructor_QCheckListItem_3: + return TQCheckListItem_3( exec, args ); + break; + + case Constructor_QCheckListItem_4: + return TQCheckListItem_4( exec, args ); + break; + + case Constructor_QCheckListItem_5: + return TQCheckListItem_5( exec, args ); + break; + + case Constructor_QCheckListItem_6: + return TQCheckListItem_6( exec, args ); + break; + + case Constructor_QCheckListItem_7: + return TQCheckListItem_7( exec, args ); + break; + + case Constructor_QCheckListItem_8: + return TQCheckListItem_8( exec, args ); + break; + + default: + break; + } + + TQString msg = i18n("TQCheckListItemCons has no constructor with id '%1'.").arg(id); + return throwError(exec, msg,KJS::ReferenceError); +} + + +KJS::Object TQCheckListItemImp::TQCheckListItem_1( KJS::ExecState *exec, const KJS::List &args ) +{ + + TQWidget *arg0 = extractTQWidget(exec,args,0); + + TQWidget *arg1 = extractTQWidget(exec,args,1); + + TQWidget *arg2 = extractTQWidget(exec,args,2); + + return KJS::Object( ); +} + +KJS::Object TQCheckListItemImp::TQCheckListItem_2( KJS::ExecState *exec, const KJS::List &args ) +{ + + // TODO + TQWidget *arg0 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg1 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg2 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg3 = extractTQWidget(exec,args,0); + return KJS::Object(); + +} + +KJS::Object TQCheckListItemImp::TQCheckListItem_3( KJS::ExecState *exec, const KJS::List &args ) +{ + + // TODO + TQWidget *arg0 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg1 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg2 = extractTQWidget(exec,args,0); + return KJS::Object(); + +} + +KJS::Object TQCheckListItemImp::TQCheckListItem_4( KJS::ExecState *exec, const KJS::List &args ) +{ + + // TODO + TQWidget *arg0 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg1 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg2 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg3 = extractTQWidget(exec,args,0); + return KJS::Object(); + +} + +KJS::Object TQCheckListItemImp::TQCheckListItem_5( KJS::ExecState *exec, const KJS::List &args ) +{ + + // TODO + TQWidget *arg0 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg1 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg2 = extractTQWidget(exec,args,0); + return KJS::Object(); + +} + +KJS::Object TQCheckListItemImp::TQCheckListItem_6( KJS::ExecState *exec, const KJS::List &args ) +{ + + // TODO + TQWidget *arg0 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg1 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg2 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg3 = extractTQWidget(exec,args,0); + return KJS::Object(); + +} + +KJS::Object TQCheckListItemImp::TQCheckListItem_7( KJS::ExecState *exec, const KJS::List &args ) +{ + + // TODO + TQWidget *arg0 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg1 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg2 = extractTQWidget(exec,args,0); + return KJS::Object(); + +} + +KJS::Object TQCheckListItemImp::TQCheckListItem_8( KJS::ExecState *exec, const KJS::List &args ) +{ + + // TODO + TQWidget *arg0 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg1 = extractTQWidget(exec,args,0); + + // TODO + TQWidget *arg2 = extractTQWidget(exec,args,0); + return KJS::Object(); + +} + +KJS::Value TQCheckListItemImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) +{ + instance = TQCheckListItemImp::toTQCheckListItem( self ); + + switch( id ) { + + case Method_paintCell_10: + return paintCell_10( exec, self, args ); + break; + + case Method_paintFocus_11: + return paintFocus_11( exec, self, args ); + break; + + case Method_width_12: + return width_12( exec, self, args ); + break; + + case Method_setup_13: + return setup_13( exec, self, args ); + break; + + case Method_setOn_14: + return setOn_14( exec, self, args ); + break; + + case Method_isOn_15: + return isOn_15( exec, self, args ); + break; + + case Method_type_16: + return type_16( exec, self, args ); + break; + + case Method_text_17: + return text_17( exec, self, args ); + break; + + case Method_text_18: + return text_18( exec, self, args ); + break; + + case Method_setTristate_19: + return setTristate_19( exec, self, args ); + break; + + case Method_isTristate_20: + return isTristate_20( exec, self, args ); + break; + + case Method_state_21: + return state_21( exec, self, args ); + break; + + case Method_setState_22: + return setState_22( exec, self, args ); + break; + + case Method_rtti_23: + return rtti_23( exec, self, args ); + break; + + default: + break; + } + + TQString msg = i18n( "TQCheckListItemImp has no method with id '%1'." ).arg( id ); + return throwError(exec, msg,KJS::ReferenceError); +} + + +KJS::Value TQCheckListItemImp::paintCell_10( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + // Unsupported parameter TQPainter * + return KJS::Value(); + + TQPainter * arg0; // Dummy + + // Unsupported parameter const TQColorGroup & + return KJS::Value(); +#if 0 + const TQColorGroup & arg1; // Dummy + + int arg2 = (args.size() >= 3) ? args[2].toInteger(exec) : -1; + + int arg3 = (args.size() >= 4) ? args[3].toInteger(exec) : -1; + + int arg4 = (args.size() >= 5) ? args[4].toInteger(exec) : -1; + + instance->paintCell( + arg0, + arg1, + arg2, + arg3, + arg4 ); + return KJS::Value(); // Returns void +#endif +} + +KJS::Value TQCheckListItemImp::paintFocus_11( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + // Unsupported parameter TQPainter * + return KJS::Value(); +#if 0 + TQPainter * arg0; // Dummy + + // Unsupported parameter const TQColorGroup & + return KJS::Value(); + + const TQColorGroup & arg1; // Dummy + + TQRect arg2 = extractTQRect(exec, args, 2); + + instance->paintFocus( + arg0, + arg1, + arg2 ); + return KJS::Value(); // Returns void +#endif +} + +KJS::Value TQCheckListItemImp::width_12( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + // Unsupported parameter const TQFontMetrics & + return KJS::Value(); +#if 0 + const TQFontMetrics & arg0; // Dummy + + // Unsupported parameter const TQListView * + return KJS::Value(); + + const TQListView * arg1; // Dummy + + int arg2 = (args.size() >= 3) ? args[2].toInteger(exec) : -1; + + int ret; + ret = instance->width( + arg0, + arg1, + arg2 ); + return KJS::Number( ret ); +#endif +} + +KJS::Value TQCheckListItemImp::setup_13( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + instance->setup( ); + return KJS::Value(); // Returns void + +} + +KJS::Value TQCheckListItemImp::setOn_14( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + bool arg0 = (args.size() >= 1) ? args[0].toBoolean(exec) : false; + + instance->setOn( + arg0 ); + return KJS::Value(); // Returns void + +} + +KJS::Value TQCheckListItemImp::isOn_15( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + bool ret; + ret = instance->isOn( ); + return KJS::Boolean( ret ); + +} + +KJS::Value TQCheckListItemImp::type_16( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + instance->type( ); + return KJS::Value(); // Returns 'Type' + +} + +KJS::Value TQCheckListItemImp::text_17( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + TQString ret; + ret = instance->text( ); + return KJS::String( ret ); + +} + +KJS::Value TQCheckListItemImp::text_18( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1; + + TQString ret; + ret = instance->text( + arg0 ); + return KJS::String( ret ); + +} + +KJS::Value TQCheckListItemImp::setTristate_19( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + bool arg0 = (args.size() >= 1) ? args[0].toBoolean(exec) : false; + + instance->setTristate( + arg0 ); + return KJS::Value(); // Returns void + +} + +KJS::Value TQCheckListItemImp::isTristate_20( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + bool ret; + ret = instance->isTristate( ); + return KJS::Boolean( ret ); + +} + +KJS::Value TQCheckListItemImp::state_21( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + instance->state( ); + return KJS::Value(); // Returns 'ToggleState' + +} + +KJS::Value TQCheckListItemImp::setState_22( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + // Unsupported parameter ToggleState + return KJS::Value(); +#if 0 + ToggleState arg0; // Dummy + + instance->setState( + arg0 ); + return KJS::Value(); // Returns void +#endif +} + +KJS::Value TQCheckListItemImp::rtti_23( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) +{ + + int ret; + ret = instance->rtti( ); + return KJS::Number( ret ); + +} + + +} // namespace KJSEmbed + +// Local Variables: +// c-basic-offset: 4 +// End: + + diff --git a/kjsembed/qtbindings/qchecklistitem_imp.h b/kjsembed/qtbindings/qchecklistitem_imp.h new file mode 100644 index 00000000..f9dca63f --- /dev/null +++ b/kjsembed/qtbindings/qchecklistitem_imp.h @@ -0,0 +1,139 @@ + + + +#ifndef KJSEMBED_QCheckListItem_H +#define KJSEMBED_QCheckListItem_H + +#include +#include + +#include +#include + +class TQCheckListItem; + +/** + * Namespace containing the KJSEmbed library. + */ +namespace KJSEmbed { +namespace Bindings { + + class TQCheckListItemLoader : public JSBindingBase + { + public: + KJS::Object createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const; + void addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy) const; + }; +} +/** + * Wrapper class for TQCheckListItem methods. + * + * @author Richard Moore, rich@kde.org + */ +class TQCheckListItemImp : public JSProxyImp +{ +public: + /** Enumerates the constructors supported by this class. */ + enum Constructors { + Constructor_QCheckListItem_1, + Constructor_QCheckListItem_2, + Constructor_QCheckListItem_3, + Constructor_QCheckListItem_4, + Constructor_QCheckListItem_5, + Constructor_QCheckListItem_6, + Constructor_QCheckListItem_7, + Constructor_QCheckListItem_8, + + LastConstuctor = -1 + }; + + /** Enumerates the methods supported by this class. */ + enum Methods { + + Method_paintCell_10, + Method_paintFocus_11, + Method_width_12, + Method_setup_13, + Method_setOn_14, + Method_isOn_15, + Method_type_16, + Method_text_17, + Method_text_18, + Method_setTristate_19, + Method_isTristate_20, + Method_state_21, + Method_setState_22, + Method_rtti_23, + Method_Last = -1 + }; + + TQCheckListItemImp( KJS::ExecState *exec, int id, bool constructor=false ); + ~TQCheckListItemImp(); + + static void addBindings( KJS::ExecState *exec, KJS::Object &object ); + + static TQCheckListItem *toTQCheckListItem( KJS::Object &object ); + + // + // Constructors implemented by this class. + // + + KJS::Object TQCheckListItem_1( KJS::ExecState *exec, const KJS::List &args ); + KJS::Object TQCheckListItem_2( KJS::ExecState *exec, const KJS::List &args ); + KJS::Object TQCheckListItem_3( KJS::ExecState *exec, const KJS::List &args ); + KJS::Object TQCheckListItem_4( KJS::ExecState *exec, const KJS::List &args ); + KJS::Object TQCheckListItem_5( KJS::ExecState *exec, const KJS::List &args ); + KJS::Object TQCheckListItem_6( KJS::ExecState *exec, const KJS::List &args ); + KJS::Object TQCheckListItem_7( KJS::ExecState *exec, const KJS::List &args ); + KJS::Object TQCheckListItem_8( KJS::ExecState *exec, const KJS::List &args ); + + // + // Methods implemented by this class. + // + + KJS::Value paintCell_10( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value paintFocus_11( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value width_12( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value setup_13( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value setOn_14( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value isOn_15( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value type_16( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value text_17( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value text_18( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value setTristate_19( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value isTristate_20( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value state_21( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value setState_22( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + KJS::Value rtti_23( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); + + // + // JS binding code. + // + + /** Returns true iff this object implements the construct function. */ + virtual bool implementsConstruct() const { return cons; } + + /** Invokes the construct function. */ + virtual KJS::Object construct( KJS::ExecState *exec, const KJS::List &args ); + + /** Returns true iff this object implements the call function. */ + virtual bool implementsCall() const { return !cons; } + + /** Invokes the call function. */ + virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ); + +private: + TQCheckListItem *instance; // Temp + int id; + bool cons; +}; + +} // namespace KJSEmbed + +#endif // KJSEMBED_QCheckListItem_H + +// Local Variables: +// c-basic-offset: 4 +// End: + + diff --git a/kjsembed/qtbindings/qchectdelistitem_imp.cpp b/kjsembed/qtbindings/qchectdelistitem_imp.cpp deleted file mode 100644 index 9aa28e41..00000000 --- a/kjsembed/qtbindings/qchectdelistitem_imp.cpp +++ /dev/null @@ -1,587 +0,0 @@ - - - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include "qchecklistitem_imp.h" -#include "qlistviewitem_imp.h" -/** - * Namespace containing the KJSEmbed library. - */ -namespace KJSEmbed { -namespace Bindings { - - KJS::Object TQCheckListItemLoader::createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const - { - if ( args.size() == 0 ) { - // FALL THRU - } else { - JSOpaqueProxy * arg0 = JSProxy::toOpaqueProxy( args[ 0 ].imp() ); - TQString arg1 = ( args.size() >= 2 ) ? args[ 1 ].toString( exec ).qstring() : TQString::null; - JSOpaqueProxy *prx = 0; - - if ( arg0 ) { - if ( arg0->typeName() == "TQListViewItem" ) { - TQListViewItem * parent = arg0->toNative(); - prx = new JSOpaqueProxy( new TQCheckListItem( parent, arg1 ), "TQCheckListItem" ); - } else { - return KJS::Object(); - } - } else { - JSObjectProxy *arg0 = JSProxy::toObjectProxy( args[ 0 ].imp() ); - if ( arg0 ) { - TQListView * parent = ( TQListView * ) ( arg0->widget() ); - prx = new JSOpaqueProxy( new TQCheckListItem( parent, arg1 ), "TQCheckListItem" ); - } else { - return KJS::Object(); - } - } - prx->setOwner( JSProxy::Native ); - KJS::Object proxyObj( prx ); - addBindings(jspart, exec, proxyObj ); - return proxyObj; - } - return KJS::Object(); - } - void TQCheckListItemLoader::addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy ) const - { - TQListViewItemImp::addBindings( exec, proxy ); - TQCheckListItemImp::addBindings( exec, proxy ); - } - -} -TQCheckListItemImp::TQCheckListItemImp( KJS::ExecState *exec, int mid, bool constructor ) - : JSProxyImp(exec), id(mid), cons(constructor) -{ -} - -TQCheckListItemImp::~TQCheckListItemImp() -{ -} - -void TQCheckListItemImp::addBindings( KJS::ExecState *exec, KJS::Object &object ) -{ - JSProxy::MethodTable methods[] = { - - { Method_paintCell_10, "paintCell" }, - { Method_paintFocus_11, "paintFocus" }, - { Method_width_12, "width" }, - { Method_setup_13, "setup" }, - { Method_setOn_14, "setOn" }, - { Method_isOn_15, "isOn" }, - { Method_type_16, "type" }, - { Method_text_17, "text" }, - { Method_text_18, "text" }, - { Method_setTristate_19, "setTristate" }, - { Method_isTristate_20, "isTristate" }, - { Method_state_21, "state" }, - { Method_setState_22, "setState" }, - { Method_rtti_23, "rtti" }, - { 0, 0 } - }; - - int idx = 0; - TQCString lastName; - - while( methods[idx].id ) { - if ( lastName != methods[idx].name ) { - TQCheckListItemImp *meth = new TQCheckListItemImp( exec, methods[idx].id ); - object.put( exec , methods[idx].name, KJS::Object(meth) ); - lastName = methods[idx].name; - } - ++idx; - } - - - // - // Define the enum constants - // - struct EnumValue { - const char *id; - int val; - }; - - EnumValue enums[] = { - - // enum Type - { "RadioButton", TQCheckListItem::RadioButton }, - { "CheckBox", TQCheckListItem::CheckBox }, - { "Controller", TQCheckListItem::Controller }, - { "RadioButtonController", TQCheckListItem::RadioButtonController }, - { "CheckBoxController", TQCheckListItem::CheckBoxController }, - // enum ToggleState - { "Off", TQCheckListItem::Off }, - { "NoChange", TQCheckListItem::NoChange }, - { "On", TQCheckListItem::On }, - { 0, 0 } - }; - - int enumidx = 0; - do { - object.put( exec, enums[enumidx].id, KJS::Number(enums[enumidx].val), KJS::ReadOnly ); - ++enumidx; - } while( enums[enumidx].id ); - -} - -TQCheckListItem *TQCheckListItemImp::toTQCheckListItem( KJS::Object &self ) -{ - JSObjectProxy *ob = JSProxy::toObjectProxy( self.imp() ); - if ( ob ) { - TQObject *obj = ob->object(); - if ( obj ) - return dynamic_cast( obj ); - } - - JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() ); - if ( !op ) - return 0; - return op->toNative(); -} - - -KJS::Object TQCheckListItemImp::construct( KJS::ExecState *exec, const KJS::List &args ) -{ - switch( id ) { - - case Constructor_QCheckListItem_1: - return TQCheckListItem_1( exec, args ); - break; - - case Constructor_QCheckListItem_2: - return TQCheckListItem_2( exec, args ); - break; - - case Constructor_QCheckListItem_3: - return TQCheckListItem_3( exec, args ); - break; - - case Constructor_QCheckListItem_4: - return TQCheckListItem_4( exec, args ); - break; - - case Constructor_QCheckListItem_5: - return TQCheckListItem_5( exec, args ); - break; - - case Constructor_QCheckListItem_6: - return TQCheckListItem_6( exec, args ); - break; - - case Constructor_QCheckListItem_7: - return TQCheckListItem_7( exec, args ); - break; - - case Constructor_QCheckListItem_8: - return TQCheckListItem_8( exec, args ); - break; - - default: - break; - } - - TQString msg = i18n("TQCheckListItemCons has no constructor with id '%1'.").arg(id); - return throwError(exec, msg,KJS::ReferenceError); -} - - -KJS::Object TQCheckListItemImp::TQCheckListItem_1( KJS::ExecState *exec, const KJS::List &args ) -{ - - TQWidget *arg0 = extractTQWidget(exec,args,0); - - TQWidget *arg1 = extractTQWidget(exec,args,1); - - TQWidget *arg2 = extractTQWidget(exec,args,2); - - return KJS::Object( ); -} - -KJS::Object TQCheckListItemImp::TQCheckListItem_2( KJS::ExecState *exec, const KJS::List &args ) -{ - - // TODO - TQWidget *arg0 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg1 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg2 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg3 = extractTQWidget(exec,args,0); - return KJS::Object(); - -} - -KJS::Object TQCheckListItemImp::TQCheckListItem_3( KJS::ExecState *exec, const KJS::List &args ) -{ - - // TODO - TQWidget *arg0 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg1 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg2 = extractTQWidget(exec,args,0); - return KJS::Object(); - -} - -KJS::Object TQCheckListItemImp::TQCheckListItem_4( KJS::ExecState *exec, const KJS::List &args ) -{ - - // TODO - TQWidget *arg0 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg1 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg2 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg3 = extractTQWidget(exec,args,0); - return KJS::Object(); - -} - -KJS::Object TQCheckListItemImp::TQCheckListItem_5( KJS::ExecState *exec, const KJS::List &args ) -{ - - // TODO - TQWidget *arg0 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg1 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg2 = extractTQWidget(exec,args,0); - return KJS::Object(); - -} - -KJS::Object TQCheckListItemImp::TQCheckListItem_6( KJS::ExecState *exec, const KJS::List &args ) -{ - - // TODO - TQWidget *arg0 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg1 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg2 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg3 = extractTQWidget(exec,args,0); - return KJS::Object(); - -} - -KJS::Object TQCheckListItemImp::TQCheckListItem_7( KJS::ExecState *exec, const KJS::List &args ) -{ - - // TODO - TQWidget *arg0 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg1 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg2 = extractTQWidget(exec,args,0); - return KJS::Object(); - -} - -KJS::Object TQCheckListItemImp::TQCheckListItem_8( KJS::ExecState *exec, const KJS::List &args ) -{ - - // TODO - TQWidget *arg0 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg1 = extractTQWidget(exec,args,0); - - // TODO - TQWidget *arg2 = extractTQWidget(exec,args,0); - return KJS::Object(); - -} - -KJS::Value TQCheckListItemImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) -{ - instance = TQCheckListItemImp::toTQCheckListItem( self ); - - switch( id ) { - - case Method_paintCell_10: - return paintCell_10( exec, self, args ); - break; - - case Method_paintFocus_11: - return paintFocus_11( exec, self, args ); - break; - - case Method_width_12: - return width_12( exec, self, args ); - break; - - case Method_setup_13: - return setup_13( exec, self, args ); - break; - - case Method_setOn_14: - return setOn_14( exec, self, args ); - break; - - case Method_isOn_15: - return isOn_15( exec, self, args ); - break; - - case Method_type_16: - return type_16( exec, self, args ); - break; - - case Method_text_17: - return text_17( exec, self, args ); - break; - - case Method_text_18: - return text_18( exec, self, args ); - break; - - case Method_setTristate_19: - return setTristate_19( exec, self, args ); - break; - - case Method_isTristate_20: - return isTristate_20( exec, self, args ); - break; - - case Method_state_21: - return state_21( exec, self, args ); - break; - - case Method_setState_22: - return setState_22( exec, self, args ); - break; - - case Method_rtti_23: - return rtti_23( exec, self, args ); - break; - - default: - break; - } - - TQString msg = i18n( "TQCheckListItemImp has no method with id '%1'." ).arg( id ); - return throwError(exec, msg,KJS::ReferenceError); -} - - -KJS::Value TQCheckListItemImp::paintCell_10( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - // Unsupported parameter TQPainter * - return KJS::Value(); - - TQPainter * arg0; // Dummy - - // Unsupported parameter const TQColorGroup & - return KJS::Value(); -#if 0 - const TQColorGroup & arg1; // Dummy - - int arg2 = (args.size() >= 3) ? args[2].toInteger(exec) : -1; - - int arg3 = (args.size() >= 4) ? args[3].toInteger(exec) : -1; - - int arg4 = (args.size() >= 5) ? args[4].toInteger(exec) : -1; - - instance->paintCell( - arg0, - arg1, - arg2, - arg3, - arg4 ); - return KJS::Value(); // Returns void -#endif -} - -KJS::Value TQCheckListItemImp::paintFocus_11( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - // Unsupported parameter TQPainter * - return KJS::Value(); -#if 0 - TQPainter * arg0; // Dummy - - // Unsupported parameter const TQColorGroup & - return KJS::Value(); - - const TQColorGroup & arg1; // Dummy - - TQRect arg2 = extractTQRect(exec, args, 2); - - instance->paintFocus( - arg0, - arg1, - arg2 ); - return KJS::Value(); // Returns void -#endif -} - -KJS::Value TQCheckListItemImp::width_12( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - // Unsupported parameter const TQFontMetrics & - return KJS::Value(); -#if 0 - const TQFontMetrics & arg0; // Dummy - - // Unsupported parameter const TQListView * - return KJS::Value(); - - const TQListView * arg1; // Dummy - - int arg2 = (args.size() >= 3) ? args[2].toInteger(exec) : -1; - - int ret; - ret = instance->width( - arg0, - arg1, - arg2 ); - return KJS::Number( ret ); -#endif -} - -KJS::Value TQCheckListItemImp::setup_13( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - instance->setup( ); - return KJS::Value(); // Returns void - -} - -KJS::Value TQCheckListItemImp::setOn_14( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - bool arg0 = (args.size() >= 1) ? args[0].toBoolean(exec) : false; - - instance->setOn( - arg0 ); - return KJS::Value(); // Returns void - -} - -KJS::Value TQCheckListItemImp::isOn_15( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - bool ret; - ret = instance->isOn( ); - return KJS::Boolean( ret ); - -} - -KJS::Value TQCheckListItemImp::type_16( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - instance->type( ); - return KJS::Value(); // Returns 'Type' - -} - -KJS::Value TQCheckListItemImp::text_17( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - TQString ret; - ret = instance->text( ); - return KJS::String( ret ); - -} - -KJS::Value TQCheckListItemImp::text_18( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1; - - TQString ret; - ret = instance->text( - arg0 ); - return KJS::String( ret ); - -} - -KJS::Value TQCheckListItemImp::setTristate_19( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - bool arg0 = (args.size() >= 1) ? args[0].toBoolean(exec) : false; - - instance->setTristate( - arg0 ); - return KJS::Value(); // Returns void - -} - -KJS::Value TQCheckListItemImp::isTristate_20( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - bool ret; - ret = instance->isTristate( ); - return KJS::Boolean( ret ); - -} - -KJS::Value TQCheckListItemImp::state_21( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - instance->state( ); - return KJS::Value(); // Returns 'ToggleState' - -} - -KJS::Value TQCheckListItemImp::setState_22( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - // Unsupported parameter ToggleState - return KJS::Value(); -#if 0 - ToggleState arg0; // Dummy - - instance->setState( - arg0 ); - return KJS::Value(); // Returns void -#endif -} - -KJS::Value TQCheckListItemImp::rtti_23( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ) -{ - - int ret; - ret = instance->rtti( ); - return KJS::Number( ret ); - -} - - -} // namespace KJSEmbed - -// Local Variables: -// c-basic-offset: 4 -// End: - - diff --git a/kjsembed/qtbindings/qchectdelistitem_imp.h b/kjsembed/qtbindings/qchectdelistitem_imp.h deleted file mode 100644 index f9dca63f..00000000 --- a/kjsembed/qtbindings/qchectdelistitem_imp.h +++ /dev/null @@ -1,139 +0,0 @@ - - - -#ifndef KJSEMBED_QCheckListItem_H -#define KJSEMBED_QCheckListItem_H - -#include -#include - -#include -#include - -class TQCheckListItem; - -/** - * Namespace containing the KJSEmbed library. - */ -namespace KJSEmbed { -namespace Bindings { - - class TQCheckListItemLoader : public JSBindingBase - { - public: - KJS::Object createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const; - void addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy) const; - }; -} -/** - * Wrapper class for TQCheckListItem methods. - * - * @author Richard Moore, rich@kde.org - */ -class TQCheckListItemImp : public JSProxyImp -{ -public: - /** Enumerates the constructors supported by this class. */ - enum Constructors { - Constructor_QCheckListItem_1, - Constructor_QCheckListItem_2, - Constructor_QCheckListItem_3, - Constructor_QCheckListItem_4, - Constructor_QCheckListItem_5, - Constructor_QCheckListItem_6, - Constructor_QCheckListItem_7, - Constructor_QCheckListItem_8, - - LastConstuctor = -1 - }; - - /** Enumerates the methods supported by this class. */ - enum Methods { - - Method_paintCell_10, - Method_paintFocus_11, - Method_width_12, - Method_setup_13, - Method_setOn_14, - Method_isOn_15, - Method_type_16, - Method_text_17, - Method_text_18, - Method_setTristate_19, - Method_isTristate_20, - Method_state_21, - Method_setState_22, - Method_rtti_23, - Method_Last = -1 - }; - - TQCheckListItemImp( KJS::ExecState *exec, int id, bool constructor=false ); - ~TQCheckListItemImp(); - - static void addBindings( KJS::ExecState *exec, KJS::Object &object ); - - static TQCheckListItem *toTQCheckListItem( KJS::Object &object ); - - // - // Constructors implemented by this class. - // - - KJS::Object TQCheckListItem_1( KJS::ExecState *exec, const KJS::List &args ); - KJS::Object TQCheckListItem_2( KJS::ExecState *exec, const KJS::List &args ); - KJS::Object TQCheckListItem_3( KJS::ExecState *exec, const KJS::List &args ); - KJS::Object TQCheckListItem_4( KJS::ExecState *exec, const KJS::List &args ); - KJS::Object TQCheckListItem_5( KJS::ExecState *exec, const KJS::List &args ); - KJS::Object TQCheckListItem_6( KJS::ExecState *exec, const KJS::List &args ); - KJS::Object TQCheckListItem_7( KJS::ExecState *exec, const KJS::List &args ); - KJS::Object TQCheckListItem_8( KJS::ExecState *exec, const KJS::List &args ); - - // - // Methods implemented by this class. - // - - KJS::Value paintCell_10( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value paintFocus_11( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value width_12( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value setup_13( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value setOn_14( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value isOn_15( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value type_16( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value text_17( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value text_18( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value setTristate_19( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value isTristate_20( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value state_21( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value setState_22( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - KJS::Value rtti_23( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args ); - - // - // JS binding code. - // - - /** Returns true iff this object implements the construct function. */ - virtual bool implementsConstruct() const { return cons; } - - /** Invokes the construct function. */ - virtual KJS::Object construct( KJS::ExecState *exec, const KJS::List &args ); - - /** Returns true iff this object implements the call function. */ - virtual bool implementsCall() const { return !cons; } - - /** Invokes the call function. */ - virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ); - -private: - TQCheckListItem *instance; // Temp - int id; - bool cons; -}; - -} // namespace KJSEmbed - -#endif // KJSEMBED_QCheckListItem_H - -// Local Variables: -// c-basic-offset: 4 -// End: - - diff --git a/qtjava/javalib/examples/checklists/CheckLists.java b/qtjava/javalib/examples/checklists/CheckLists.java new file mode 100644 index 00000000..5dc42300 --- /dev/null +++ b/qtjava/javalib/examples/checklists/CheckLists.java @@ -0,0 +1,171 @@ +/*************************************************************************** +* $Id$ +** +* Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +* This file is part of an example program for Qt. This example +* program may be used, distributed and modified without limitation. +** +****************************************************************************/ +import org.kde.qt.*; +import java.util.*; + +class CheckLists extends TQWidget +{ + +protected TQListView lv1, lv2; +protected TQLabel label; + +/* + Constructor + * + Create all child widgets of the CheckList Widget + */ + +CheckLists( ) +{ + this(null, null); +} + +CheckLists( TQWidget parent, String name ) +{ + super( parent, name ); + TQHBoxLayout lay = new TQHBoxLayout( this ); + lay.setMargin( 5 ); + + // create a widget which layouts its childs in a column + TQVBoxLayout vbox1 = new TQVBoxLayout( lay ); + vbox1.setMargin( 5 ); + + // First child: a Label + vbox1.addWidget( new TQLabel( "Check some items!", this ) ); + + // Second child: the ListView + lv1 = new TQListView( this ); + vbox1.addWidget( lv1 ); + lv1.addColumn( "Items" ); + lv1.setRootIsDecorated( true ); + + // create a list with 4 ListViewItems which will be parent items of other ListViewItems + ArrayList parentList = new ArrayList(); + + parentList.add( new TQListViewItem( lv1, "Parent Item 1" ) ); + parentList.add( new TQListViewItem( lv1, "Parent Item 2" ) ); + parentList.add( new TQListViewItem( lv1, "Parent Item 3" ) ); + parentList.add( new TQListViewItem( lv1, "Parent Item 4" ) ); + + TQListViewItem item = null; + int num = 1; + // go through the list of parent items... + for ( Iterator it = parentList.iterator(); it.hasNext(); num++ ) { + item = (TQListViewItem) it.next(); + item.setOpen( true ); + // ...and create 5 checkable child ListViewItems for each parent item + for ( int i = 1; i <= 5; i++ ) + new TQCheckListItem( item, i + ". Child of Parent " + num, TQCheckListItem.CheckBox ); + } + + // Create another widget for layouting + TQVBoxLayout tmp = new TQVBoxLayout( lay ); + tmp.setMargin( 5 ); + + // create a pushbutton + TQPushButton copy1 = new TQPushButton( " -> ", this ); + tmp.addWidget( copy1 ); + copy1.setMaximumWidth( copy1.sizeHint().width() ); + // connect the SIGNAL clicked() of the pushbutton with the SLOT copy1to2() + connect( copy1, SIGNAL(" clicked()"), this, SLOT(" copy1to2()") ); + + // another widget for layouting + TQVBoxLayout vbox2 = new TQVBoxLayout( lay ); + vbox2.setMargin( 5 ); + + // and another label + vbox2.addWidget( new TQLabel( "Check one item!", this ) ); + + // create the second listview + lv2 = new TQListView( this ); + vbox2.addWidget( lv2 ); + lv2.addColumn( "Items" ); + lv2.setRootIsDecorated( true ); + + // another widget needed for layouting only + tmp = new TQVBoxLayout( lay ); + tmp.setMargin( 5 ); + + // create another pushbutton... + TQPushButton copy2 = new TQPushButton( " -> ", this ); + lay.addWidget( copy2 ); + copy2.setMaximumWidth( copy2.sizeHint().width() ); + // ...and connect its clicked() SIGNAL to the copy2to3() SLOT + connect( copy2, SIGNAL(" clicked()"), this, SLOT(" copy2to3()") ); + + tmp = new TQVBoxLayout( lay ); + tmp.setMargin( 5 ); + + // and create a label which will be at the right of the window + label = new TQLabel( "No Item yet...", this ); + tmp.addWidget( label ); +} + +/* + SLOT copy1to2() + * + Copies all checked ListViewItems from the first ListView to + the second one, and inserts them as Radio-ListViewItem. + */ + +public void copy1to2() +{ + // create an iterator which operates on the first ListView + Iterator it = lv1.itemList().iterator(); + + lv2.clear(); + + // Insert first a controller Item into the second ListView. Always if Radio-ListViewItems + // are inserted into a Listview, the parent item of these MUST be a controller Item! + TQCheckListItem item = new TQCheckListItem( lv2, "Controller", TQCheckListItem.Controller ); + item.setOpen( true ); + + // iterate through the first ListView... + while ( it.hasNext() ) { + TQListViewItem current = (TQListViewItem) it.next(); + // ...check state of childs, and... + if ( current.parent() != null ) + // ...if the item is checked... + if ( ( (TQCheckListItem) current ).isOn() ) + // ...insert a Radio-ListViewItem with the same text into the second ListView + new TQCheckListItem( item, current.text( 0 ), TQCheckListItem.RadioButton ); + + } + if ( item.firstChild() != null ) + ( ( TQCheckListItem )item.firstChild() ).setOn( true ); +} + +/* + SLOT copy2to3() + * + Copies the checked item of the second ListView into the + Label at the right. + */ + +public void copy2to3() +{ + // create an iterator which operates on the second ListView + Iterator it = lv2.itemList().iterator(); + + label.setText( "No Item checked" ); + + // iterate through the second ListView... + while ( it.hasNext() ) { + TQListViewItem current = (TQListViewItem) it.next(); + // ...check state of childs, and... + if ( current.parent() != null ) + // ...if the item is checked... + if ( ( (TQCheckListItem) current ).isOn() ) + // ...set the text of the item to the label + label.setText( current.text( 0 ) ); + } +} +} + diff --git a/qtjava/javalib/examples/checklists/Main.java b/qtjava/javalib/examples/checklists/Main.java new file mode 100644 index 00000000..263073d3 --- /dev/null +++ b/qtjava/javalib/examples/checklists/Main.java @@ -0,0 +1,31 @@ +/*************************************************************************** +* $Id$ +** +* Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +* This file is part of an example program for Qt. This example +* program may be used, distributed and modified without limitation. +** +****************************************************************************/ +import org.kde.qt.*; + +public class Main { + +public static void main( String[] args ) +{ + TQApplication a = new TQApplication( args ); + + CheckLists checklists = new CheckLists(); + checklists.resize( 650, 350 ); + checklists.setCaption( "Qt Example - CheckLists" ); + a.setMainWidget( checklists ); + checklists.show(); + + a.exec(); + return; +} +static { + qtjava.initialize(); +} + +} diff --git a/qtjava/javalib/examples/chectdelists/CheckLists.java b/qtjava/javalib/examples/chectdelists/CheckLists.java deleted file mode 100644 index 5dc42300..00000000 --- a/qtjava/javalib/examples/chectdelists/CheckLists.java +++ /dev/null @@ -1,171 +0,0 @@ -/*************************************************************************** -* $Id$ -** -* Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -* This file is part of an example program for Qt. This example -* program may be used, distributed and modified without limitation. -** -****************************************************************************/ -import org.kde.qt.*; -import java.util.*; - -class CheckLists extends TQWidget -{ - -protected TQListView lv1, lv2; -protected TQLabel label; - -/* - Constructor - * - Create all child widgets of the CheckList Widget - */ - -CheckLists( ) -{ - this(null, null); -} - -CheckLists( TQWidget parent, String name ) -{ - super( parent, name ); - TQHBoxLayout lay = new TQHBoxLayout( this ); - lay.setMargin( 5 ); - - // create a widget which layouts its childs in a column - TQVBoxLayout vbox1 = new TQVBoxLayout( lay ); - vbox1.setMargin( 5 ); - - // First child: a Label - vbox1.addWidget( new TQLabel( "Check some items!", this ) ); - - // Second child: the ListView - lv1 = new TQListView( this ); - vbox1.addWidget( lv1 ); - lv1.addColumn( "Items" ); - lv1.setRootIsDecorated( true ); - - // create a list with 4 ListViewItems which will be parent items of other ListViewItems - ArrayList parentList = new ArrayList(); - - parentList.add( new TQListViewItem( lv1, "Parent Item 1" ) ); - parentList.add( new TQListViewItem( lv1, "Parent Item 2" ) ); - parentList.add( new TQListViewItem( lv1, "Parent Item 3" ) ); - parentList.add( new TQListViewItem( lv1, "Parent Item 4" ) ); - - TQListViewItem item = null; - int num = 1; - // go through the list of parent items... - for ( Iterator it = parentList.iterator(); it.hasNext(); num++ ) { - item = (TQListViewItem) it.next(); - item.setOpen( true ); - // ...and create 5 checkable child ListViewItems for each parent item - for ( int i = 1; i <= 5; i++ ) - new TQCheckListItem( item, i + ". Child of Parent " + num, TQCheckListItem.CheckBox ); - } - - // Create another widget for layouting - TQVBoxLayout tmp = new TQVBoxLayout( lay ); - tmp.setMargin( 5 ); - - // create a pushbutton - TQPushButton copy1 = new TQPushButton( " -> ", this ); - tmp.addWidget( copy1 ); - copy1.setMaximumWidth( copy1.sizeHint().width() ); - // connect the SIGNAL clicked() of the pushbutton with the SLOT copy1to2() - connect( copy1, SIGNAL(" clicked()"), this, SLOT(" copy1to2()") ); - - // another widget for layouting - TQVBoxLayout vbox2 = new TQVBoxLayout( lay ); - vbox2.setMargin( 5 ); - - // and another label - vbox2.addWidget( new TQLabel( "Check one item!", this ) ); - - // create the second listview - lv2 = new TQListView( this ); - vbox2.addWidget( lv2 ); - lv2.addColumn( "Items" ); - lv2.setRootIsDecorated( true ); - - // another widget needed for layouting only - tmp = new TQVBoxLayout( lay ); - tmp.setMargin( 5 ); - - // create another pushbutton... - TQPushButton copy2 = new TQPushButton( " -> ", this ); - lay.addWidget( copy2 ); - copy2.setMaximumWidth( copy2.sizeHint().width() ); - // ...and connect its clicked() SIGNAL to the copy2to3() SLOT - connect( copy2, SIGNAL(" clicked()"), this, SLOT(" copy2to3()") ); - - tmp = new TQVBoxLayout( lay ); - tmp.setMargin( 5 ); - - // and create a label which will be at the right of the window - label = new TQLabel( "No Item yet...", this ); - tmp.addWidget( label ); -} - -/* - SLOT copy1to2() - * - Copies all checked ListViewItems from the first ListView to - the second one, and inserts them as Radio-ListViewItem. - */ - -public void copy1to2() -{ - // create an iterator which operates on the first ListView - Iterator it = lv1.itemList().iterator(); - - lv2.clear(); - - // Insert first a controller Item into the second ListView. Always if Radio-ListViewItems - // are inserted into a Listview, the parent item of these MUST be a controller Item! - TQCheckListItem item = new TQCheckListItem( lv2, "Controller", TQCheckListItem.Controller ); - item.setOpen( true ); - - // iterate through the first ListView... - while ( it.hasNext() ) { - TQListViewItem current = (TQListViewItem) it.next(); - // ...check state of childs, and... - if ( current.parent() != null ) - // ...if the item is checked... - if ( ( (TQCheckListItem) current ).isOn() ) - // ...insert a Radio-ListViewItem with the same text into the second ListView - new TQCheckListItem( item, current.text( 0 ), TQCheckListItem.RadioButton ); - - } - if ( item.firstChild() != null ) - ( ( TQCheckListItem )item.firstChild() ).setOn( true ); -} - -/* - SLOT copy2to3() - * - Copies the checked item of the second ListView into the - Label at the right. - */ - -public void copy2to3() -{ - // create an iterator which operates on the second ListView - Iterator it = lv2.itemList().iterator(); - - label.setText( "No Item checked" ); - - // iterate through the second ListView... - while ( it.hasNext() ) { - TQListViewItem current = (TQListViewItem) it.next(); - // ...check state of childs, and... - if ( current.parent() != null ) - // ...if the item is checked... - if ( ( (TQCheckListItem) current ).isOn() ) - // ...set the text of the item to the label - label.setText( current.text( 0 ) ); - } -} -} - diff --git a/qtjava/javalib/examples/chectdelists/Main.java b/qtjava/javalib/examples/chectdelists/Main.java deleted file mode 100644 index 263073d3..00000000 --- a/qtjava/javalib/examples/chectdelists/Main.java +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** -* $Id$ -** -* Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -* This file is part of an example program for Qt. This example -* program may be used, distributed and modified without limitation. -** -****************************************************************************/ -import org.kde.qt.*; - -public class Main { - -public static void main( String[] args ) -{ - TQApplication a = new TQApplication( args ); - - CheckLists checklists = new CheckLists(); - checklists.resize( 650, 350 ); - checklists.setCaption( "Qt Example - CheckLists" ); - a.setMainWidget( checklists ); - checklists.show(); - - a.exec(); - return; -} -static { - qtjava.initialize(); -} - -} diff --git a/qtruby/rubylib/examples/qt-examples/checklists/checklists.rb b/qtruby/rubylib/examples/qt-examples/checklists/checklists.rb new file mode 100644 index 00000000..458dc127 --- /dev/null +++ b/qtruby/rubylib/examples/qt-examples/checklists/checklists.rb @@ -0,0 +1,147 @@ +require 'Qt' + +class CheckLists < TQt::Widget + slots 'copy1to2()', 'copy2to3()' + + # Constructor + # + # Create all child widgets of the CheckList Widget + def initialize + super() + + lay = TQt::HBoxLayout.new(self) + lay.setMargin(5) + + # create a widget which layouts its childs in a column + vbox1 = TQt::VBoxLayout.new(lay) + vbox1.setMargin(5) + + # First child: a Label + vbox1.addWidget(TQt::Label.new('Check some items!', self)) + + # Second child: the ListView + @lv1 = TQt::ListView.new(self) + vbox1.addWidget(@lv1) + @lv1.addColumn('Items') + @lv1.setRootIsDecorated(true) + + # create a list with 4 ListViewItems which will be parent items of other ListViewItems + parentList = Array.new + + + parentList.push(TQt::ListViewItem.new(@lv1, 'Parent Item 1')) + parentList.push(TQt::ListViewItem.new(@lv1, 'Parent Item 2')) + parentList.push(TQt::ListViewItem.new(@lv1, 'Parent Item 3')) + parentList.push(TQt::ListViewItem.new(@lv1, 'Parent Item 4')) + + item = 0 + num = 1 + # go through the list of parent items... + parentList.each {|item| + item.setOpen(true) + # ...and create 5 checkable child ListViewItems for each parent item + for i in 1..5 + str = sprintf('%s. Child of Parent %s', i, num) + TQt::CheckListItem.new(item, str, TQt::CheckListItem.CheckBox) + end + num = num + 1 + } + + # Create another widget for layouting + tmp = TQt::VBoxLayout.new(lay) + tmp.setMargin(5) + + # create a pushbutton + copy1 = TQt::PushButton.new(' -> ', self) + tmp.addWidget(copy1) + copy1.setMaximumWidth(copy1.sizeHint.width) + # connect the SIGNAL clicked() of the pushbutton with the SLOT copy1to2() + connect(copy1, SIGNAL('clicked()'), self, SLOT('copy1to2()')) + + # another widget for layouting + vbox2 = TQt::VBoxLayout.new(lay) + vbox2.setMargin(5) + + # and another label + vbox2.addWidget(TQt::Label.new('Check one item!', self)) + + # create the second listview + @lv2 = TQt::ListView.new(self) + vbox2.addWidget(@lv2) + @lv2.addColumn('Items') + @lv2.setRootIsDecorated(true) + + # another widget needed for layouting only + tmp = TQt::VBoxLayout.new(lay) + tmp.setMargin(5) + + # create another pushbutton... + copy2 = TQt::PushButton.new(' -> ', self) + lay.addWidget( copy2 ) + copy2.setMaximumWidth(copy2.sizeHint.width) + # ...and connect its clicked() SIGNAL to the copy2to3() SLOT + connect(copy2, SIGNAL('clicked()'), self, SLOT('copy2to3()')) + + tmp = TQt::VBoxLayout.new(lay) + tmp.setMargin(5) + + # and create a label which will be at the right of the window + @label = TQt::Label.new('No Item yet...', self) + tmp.addWidget(@label) + end + + # SLOT copy1to2() + # + # Copies all checked ListViewItems from the first ListView to + # the second one, and inserts them as Radio-ListViewItem. + def copy1to2 + @lv2.clear + it = TQt::ListViewItemIterator.new(@lv1) + # Insert first a controller Item into the second ListView. Always if Radio-ListViewItems + # are inserted into a Listview, the parent item of these MUST be a controller Item! + item = TQt::CheckListItem.new(@lv2, 'Controller', TQt::CheckListItem::Controller ); + item.setOpen(true); + + # iterate through the first ListView... + while (it.current) + # ...check state of childs, and... + if ( it.current.parent ) + # ...if the item is checked... + if (it.current.isOn) + # ...insert a Radio-ListViewItem with the same text into the second ListView + TQt::CheckListItem.new(item, it.current.text(0), TQt::CheckListItem::RadioButton) + end + end + it += 1 + end + + if (item.firstChild) + item.firstChild.setOn(true) + end + end + + + # SLOT copy2to3() + # + # Copies the checked item of the second ListView into the + # Label at the right. + def copy2to3 + # create an iterator which operates on the second ListView + it = TQt::ListViewItemIterator.new(@lv2) + + @label.setText('No Item checked') + + # iterate through the second ListView... + while (it.current) + # ...check state of childs, and... + if ( it.current.parent) + # ...if the item is checked... + if (it.current.isOn) + # ...set the text of the item to the label + @label.setText(it.current.text(0)) + end + end + it += 1 + end + end +end diff --git a/qtruby/rubylib/examples/qt-examples/checklists/main.rb b/qtruby/rubylib/examples/qt-examples/checklists/main.rb new file mode 100755 index 00000000..364f5cb7 --- /dev/null +++ b/qtruby/rubylib/examples/qt-examples/checklists/main.rb @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby + +require 'Qt' + +require 'checklists' + +a = TQt::Application.new(ARGV) + +checklists = CheckLists.new +checklists.resize(650, 350) +checklists.setCaption('QtRuby Example - CheckLists') +a.setMainWidget(checklists) +checklists.show + +a.exec() diff --git a/qtruby/rubylib/examples/qt-examples/chectdelists/chectdelists.rb b/qtruby/rubylib/examples/qt-examples/chectdelists/chectdelists.rb deleted file mode 100644 index 458dc127..00000000 --- a/qtruby/rubylib/examples/qt-examples/chectdelists/chectdelists.rb +++ /dev/null @@ -1,147 +0,0 @@ -require 'Qt' - -class CheckLists < TQt::Widget - slots 'copy1to2()', 'copy2to3()' - - # Constructor - # - # Create all child widgets of the CheckList Widget - def initialize - super() - - lay = TQt::HBoxLayout.new(self) - lay.setMargin(5) - - # create a widget which layouts its childs in a column - vbox1 = TQt::VBoxLayout.new(lay) - vbox1.setMargin(5) - - # First child: a Label - vbox1.addWidget(TQt::Label.new('Check some items!', self)) - - # Second child: the ListView - @lv1 = TQt::ListView.new(self) - vbox1.addWidget(@lv1) - @lv1.addColumn('Items') - @lv1.setRootIsDecorated(true) - - # create a list with 4 ListViewItems which will be parent items of other ListViewItems - parentList = Array.new - - - parentList.push(TQt::ListViewItem.new(@lv1, 'Parent Item 1')) - parentList.push(TQt::ListViewItem.new(@lv1, 'Parent Item 2')) - parentList.push(TQt::ListViewItem.new(@lv1, 'Parent Item 3')) - parentList.push(TQt::ListViewItem.new(@lv1, 'Parent Item 4')) - - item = 0 - num = 1 - # go through the list of parent items... - parentList.each {|item| - item.setOpen(true) - # ...and create 5 checkable child ListViewItems for each parent item - for i in 1..5 - str = sprintf('%s. Child of Parent %s', i, num) - TQt::CheckListItem.new(item, str, TQt::CheckListItem.CheckBox) - end - num = num + 1 - } - - # Create another widget for layouting - tmp = TQt::VBoxLayout.new(lay) - tmp.setMargin(5) - - # create a pushbutton - copy1 = TQt::PushButton.new(' -> ', self) - tmp.addWidget(copy1) - copy1.setMaximumWidth(copy1.sizeHint.width) - # connect the SIGNAL clicked() of the pushbutton with the SLOT copy1to2() - connect(copy1, SIGNAL('clicked()'), self, SLOT('copy1to2()')) - - # another widget for layouting - vbox2 = TQt::VBoxLayout.new(lay) - vbox2.setMargin(5) - - # and another label - vbox2.addWidget(TQt::Label.new('Check one item!', self)) - - # create the second listview - @lv2 = TQt::ListView.new(self) - vbox2.addWidget(@lv2) - @lv2.addColumn('Items') - @lv2.setRootIsDecorated(true) - - # another widget needed for layouting only - tmp = TQt::VBoxLayout.new(lay) - tmp.setMargin(5) - - # create another pushbutton... - copy2 = TQt::PushButton.new(' -> ', self) - lay.addWidget( copy2 ) - copy2.setMaximumWidth(copy2.sizeHint.width) - # ...and connect its clicked() SIGNAL to the copy2to3() SLOT - connect(copy2, SIGNAL('clicked()'), self, SLOT('copy2to3()')) - - tmp = TQt::VBoxLayout.new(lay) - tmp.setMargin(5) - - # and create a label which will be at the right of the window - @label = TQt::Label.new('No Item yet...', self) - tmp.addWidget(@label) - end - - # SLOT copy1to2() - # - # Copies all checked ListViewItems from the first ListView to - # the second one, and inserts them as Radio-ListViewItem. - def copy1to2 - @lv2.clear - it = TQt::ListViewItemIterator.new(@lv1) - # Insert first a controller Item into the second ListView. Always if Radio-ListViewItems - # are inserted into a Listview, the parent item of these MUST be a controller Item! - item = TQt::CheckListItem.new(@lv2, 'Controller', TQt::CheckListItem::Controller ); - item.setOpen(true); - - # iterate through the first ListView... - while (it.current) - # ...check state of childs, and... - if ( it.current.parent ) - # ...if the item is checked... - if (it.current.isOn) - # ...insert a Radio-ListViewItem with the same text into the second ListView - TQt::CheckListItem.new(item, it.current.text(0), TQt::CheckListItem::RadioButton) - end - end - it += 1 - end - - if (item.firstChild) - item.firstChild.setOn(true) - end - end - - - # SLOT copy2to3() - # - # Copies the checked item of the second ListView into the - # Label at the right. - def copy2to3 - # create an iterator which operates on the second ListView - it = TQt::ListViewItemIterator.new(@lv2) - - @label.setText('No Item checked') - - # iterate through the second ListView... - while (it.current) - # ...check state of childs, and... - if ( it.current.parent) - # ...if the item is checked... - if (it.current.isOn) - # ...set the text of the item to the label - @label.setText(it.current.text(0)) - end - end - it += 1 - end - end -end diff --git a/qtruby/rubylib/examples/qt-examples/chectdelists/main.rb b/qtruby/rubylib/examples/qt-examples/chectdelists/main.rb deleted file mode 100755 index 364f5cb7..00000000 --- a/qtruby/rubylib/examples/qt-examples/chectdelists/main.rb +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby - -require 'Qt' - -require 'checklists' - -a = TQt::Application.new(ARGV) - -checklists = CheckLists.new -checklists.resize(650, 350) -checklists.setCaption('QtRuby Example - CheckLists') -a.setMainWidget(checklists) -checklists.show - -a.exec() -- cgit v1.2.3