/***************************************************************************
                            KGuiItem.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_KGuiItem.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KGuiItem.h>
#include <qtobjc/QIconSet.h>


@implementation  KGuiItem

- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}


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

- initWithText: (NSString *)text iconName: (NSString *)iconName toolTip: (NSString *)toolTip whatsThis: (NSString *)whatsThis
{
static qt_QString * _qstring_whatsThis = 0L;
static qt_QString * _qstring_toolTip = 0L;
static qt_QString * _qstring_iconName = 0L;
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KGuiItem1((qt_QString *) [text toQString: &_qstring_text], (qt_QString *) [iconName toQString: &_qstring_iconName], (qt_QString *) [toolTip toQString: &_qstring_toolTip], (qt_QString *) [whatsThis toQString: &_qstring_whatsThis])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)text 
{
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KGuiItem1((qt_QString *) [text toQString: &_qstring_text], qt_QString_null(), qt_QString_null(), qt_QString_null())];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)text iconSet: (QIconSet*)iconSet toolTip: (NSString *)toolTip whatsThis: (NSString *)whatsThis
{
static qt_QString * _qstring_whatsThis = 0L;
static qt_QString * _qstring_toolTip = 0L;
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KGuiItem2((qt_QString *) [text toQString: &_qstring_text], (qt_QIconSet*) [iconSet qt], (qt_QString *) [toolTip toQString: &_qstring_toolTip], (qt_QString *) [whatsThis toQString: &_qstring_whatsThis])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)text iconSet: (QIconSet*)iconSet 
{
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KGuiItem2((qt_QString *) [text toQString: &_qstring_text], (qt_QIconSet*) [iconSet qt], qt_QString_null(), qt_QString_null())];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- copyWithZone: (NSZone *) zone
{
	KGuiItem * aCopy;
	aCopy = [[(KGuiItem *)[[self class] allocWithZone: zone] setQt: kde_new_KGuiItem3([self qt])] init];
	[aCopy setAllocatedInObjcWorld: YES];
	[QtSupport setObject: aCopy forQtKey: [aCopy qt]];
	return aCopy;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			kde_del_KGuiItem((kde_KGuiItem *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (NSString *) text
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KGuiItem_text((kde_KGuiItem *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) plainText
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KGuiItem_plainText((kde_KGuiItem *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (QIconSet*) iconSet
{
	return (QIconSet*) [QtSupport objectForQtKey: kde_KGuiItem_iconSet((kde_KGuiItem *)[self qt]) withClass: [QIconSet class] allocatedInObjcWorld: YES];
}

- (NSString *) iconName
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KGuiItem_iconName((kde_KGuiItem *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) toolTip
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KGuiItem_toolTip((kde_KGuiItem *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) whatsThis
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KGuiItem_whatsThis((kde_KGuiItem *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (BOOL) isEnabled
{
	return (BOOL) kde_KGuiItem_isEnabled((kde_KGuiItem *)[self qt]);
}

- (BOOL) hasIconSet
{
	return (BOOL) kde_KGuiItem_hasIconSet((kde_KGuiItem *)[self qt]);
}

- setText: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	kde_KGuiItem_setText((kde_KGuiItem *)[self qt], (qt_QString *) [text toQString: &_qstring_text]);
	return self;
}

- setIconSet: (QIconSet*)iconset
{
	kde_KGuiItem_setIconSet((kde_KGuiItem *)[self qt], (qt_QIconSet*) [iconset qt]);
	return self;
}

- setIconName: (NSString *)iconName
{
static qt_QString * _qstring_iconName = 0L;
	kde_KGuiItem_setIconName((kde_KGuiItem *)[self qt], (qt_QString *) [iconName toQString: &_qstring_iconName]);
	return self;
}

- setToolTip: (NSString *)tooltip
{
static qt_QString * _qstring_tooltip = 0L;
	kde_KGuiItem_setToolTip((kde_KGuiItem *)[self qt], (qt_QString *) [tooltip toQString: &_qstring_tooltip]);
	return self;
}

- setWhatsThis: (NSString *)whatsThis
{
static qt_QString * _qstring_whatsThis = 0L;
	kde_KGuiItem_setWhatsThis((kde_KGuiItem *)[self qt], (qt_QString *) [whatsThis toQString: &_qstring_whatsThis]);
	return self;
}

- setEnabled: (BOOL)enable
{
	kde_KGuiItem_setEnabled((kde_KGuiItem *)[self qt], (int)enable);
	return self;
}

@end
