/***************************************************************************
                            KCModule.m -  description
                             -------------------
    begin                : Fri Mar  8 13:55:08 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar  8 13:55:08 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <kdec/kde_KCModule.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KCModule.h>
#include <kdeobjc/KInstance.h>


@implementation  KCModule


- initWithWidget: (QWidget *)parent name: (NSString *)name args: (NSArray *)args
{
static qt_QStringList * _qlist_args = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KCModule((qt_QWidget *) [parent qt], (char*) [name cString], (qt_QStringList*) [args toQStringList: (void *)&_qlist_args])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

//- init
//{
//	if ([self qt] == 0L) {
//		[self setQt: kde_new_KCModule(0, 0, qt_new_QStringList())];
//		[self setAllocatedInObjcWorld: YES];
//		[QtSupport setObject: self forQtKey: [self qt]];
//	}
//	[super init];
///	return self;
//}

- initWithInstance: (KInstance*)instance parent: (QWidget *)parent args: (NSArray *)args
{
static qt_QStringList * _qlist_args = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KCModule1((kde_KInstance*) [instance qt], (qt_QWidget *) [parent qt], (qt_QStringList*) [args toQStringList: (void *)&_qlist_args])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

//- initWithInstance: (KInstance*)instance
//{
//	if ([self qt] == 0L) {
//		[self setQt: kde_new_KCModule1((kde_KInstance*) [instance qt], 0, [KCModule QStringList()])];
//		[self setAllocatedInObjcWorld: YES];
//		[QtSupport setObject: self forQtKey: [self qt]];
//	}
//	[super init];
//	return self;
//}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld] && [self parentWidget: YES] == nil) {
			kde_del_KCModule((kde_KCModule *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- load
{
	kde_KCModule_load((kde_KCModule *)[self qt]);
	return self;
}

- save
{
	kde_KCModule_save((kde_KCModule *)[self qt]);
	return self;
}

- defaults
{
	kde_KCModule_defaults((kde_KCModule *)[self qt]);
	return self;
}

- sysdefaults
{
	kde_KCModule_sysdefaults((kde_KCModule *)[self qt]);
	return self;
}

- (NSString *) quickHelp
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KCModule_quickHelp((kde_KCModule *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (KAboutData*) aboutData
{
	return (KAboutData*) [QtSupport objectForQtKey: kde_KCModule_aboutData((kde_KCModule *)[self qt]) withClass: [KAboutData class] allocatedInObjcWorld: YES];
}

- (int) buttons
{
	return (int) kde_KCModule_buttons((kde_KCModule *)[self qt]);
}

- (NSString *) rootOnlyMsg
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KCModule_rootOnlyMsg((kde_KCModule *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (BOOL) useRootOnlyMsg
{
	return (BOOL) kde_KCModule_useRootOnlyMsg((kde_KCModule *)[self qt]);
}

- (KInstance*) instance
{
	return (KInstance*) [QtSupport objectForQtKey: kde_KCModule_instance((kde_KCModule *)[self qt]) withClass: [KInstance class] allocatedInObjcWorld: YES];
}

- setButtons: (int)btn
{
	kde_KCModule_setButtons((kde_KCModule *)[self qt], (int)btn);
	return self;
}

- setRootOnlyMsg: (NSString *)msg
{
static qt_QString * _qstring_msg = 0L;
	kde_KCModule_setRootOnlyMsg((kde_KCModule *)[self qt], (qt_QString *) [msg toQString: &_qstring_msg]);
	return self;
}

- setUseRootOnlyMsg: (BOOL)on
{
	kde_KCModule_setUseRootOnlyMsg((kde_KCModule *)[self qt], (int)on);
	return self;
}

+ (int) Help
{
	return (int) KCMODULE_Help;
}

+ (int) Default
{
	return (int) KCMODULE_Default;
}

+ (int) Apply
{
	return (int) KCMODULE_Apply;
}

+ (int) Reset
{
	return (int) KCMODULE_Reset;
}

+ (int) Cancel
{
	return (int) KCMODULE_Cancel;
}

+ (int) Ok
{
	return (int) KCMODULE_Ok;
}

+ (int) SysDefault
{
	return (int) KCMODULE_SysDefault;
}

@end
