/***************************************************************************
                            KRootProp.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_KRootProp.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KRootProp.h>
#include <qtobjc/QColor.h>
#include <qtobjc/QFont.h>


@implementation  KRootProp

- (void *) qt
{
	return _qt;
}

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

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

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


- initWithText: (NSString *)rProp
{
static qt_QString * _qstring_rProp = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KRootProp((qt_QString *) [rProp toQString: &_qstring_rProp])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

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

- setProp: (NSString *)rProp
{
static qt_QString * _qstring_rProp = 0L;
	kde_KRootProp_setProp((kde_KRootProp *)[self qt], (qt_QString *) [rProp toQString: &_qstring_rProp]);
	return self;
}

- setProp
{
	kde_KRootProp_setProp((kde_KRootProp *)[self qt], "");
	return self;
}

- (NSString *) prop
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KRootProp_prop((kde_KRootProp *)[self qt]);
	return [NSString fromQString: _qstring];
}

- destroy
{
	kde_KRootProp_destroy((kde_KRootProp *)[self qt]);
	return self;
}

- (NSString *) readEntry: (NSString *)rKey pDefault: (NSString *)pDefault
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_pDefault = 0L;
static qt_QString * _qstring_rKey = 0L;
	_qstring = kde_KRootProp_readEntry((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], (qt_QString *) [pDefault toQString: &_qstring_pDefault]);
	return [NSString fromQString: _qstring];
}

- (int) readNumEntry: (NSString *)rKey nDefault: (int)nDefault
{
static qt_QString * _qstring_rKey = 0L;
	return (int) kde_KRootProp_readNumEntry((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], (int)nDefault);
}

- (int) readNumEntry: (NSString *)rKey 
{
static qt_QString * _qstring_rKey = 0L;
	return (int) kde_KRootProp_readNumEntry((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], 0);
}

- (QFont*) readFontEntry: (NSString *)rKey pDefault: (QFont *)pDefault
{
static qt_QString * _qstring_rKey = 0L;
	return (QFont*) [QtSupport objectForQtKey: kde_KRootProp_readFontEntry((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], (qt_QFont *) [pDefault qt]) withClass: [QFont class] allocatedInObjcWorld: YES];
}

- (QFont*) readFontEntry: (NSString *)rKey 
{
static qt_QString * _qstring_rKey = 0L;
	return (QFont*) [QtSupport objectForQtKey: kde_KRootProp_readFontEntry((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], 0) withClass: [QFont class] allocatedInObjcWorld: YES];
}

- (QColor*) readColorEntry: (NSString *)rKey pDefault: (QColor*)pDefault
{
static qt_QString * _qstring_rKey = 0L;
	return (QColor*) [QtSupport objectForQtKey: kde_KRootProp_readColorEntry((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], (qt_QColor*) [pDefault qt]) withClass: [QColor class] allocatedInObjcWorld: YES];
}

- (QColor*) readColorEntry: (NSString *)rKey 
{
static qt_QString * _qstring_rKey = 0L;
	return (QColor*) [QtSupport objectForQtKey: kde_KRootProp_readColorEntry((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], 0) withClass: [QColor class] allocatedInObjcWorld: YES];
}

- (NSString *) writeEntry: (NSString *)rKey rValue: (NSString *)rValue
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_rValue = 0L;
static qt_QString * _qstring_rKey = 0L;
	_qstring = kde_KRootProp_writeEntry((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], (qt_QString *) [rValue toQString: &_qstring_rValue]);
	return [NSString fromQString: _qstring];
}

- (NSString *) writeEntry: (NSString *)rKey nValue: (int)nValue
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_rKey = 0L;
	_qstring = kde_KRootProp_writeEntry1((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], (int)nValue);
	return [NSString fromQString: _qstring];
}

- (NSString *) writeEntry: (NSString *)rKey rFont: (QFont *)rFont
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_rKey = 0L;
	_qstring = kde_KRootProp_writeEntry2((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], (qt_QFont *) [rFont qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) writeEntry: (NSString *)rKey rColor: (QColor *)rColor
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_rKey = 0L;
	_qstring = kde_KRootProp_writeEntry3((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey], (qt_QColor *) [rColor qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) removeEntry: (NSString *)rKey
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_rKey = 0L;
	_qstring = kde_KRootProp_removeEntry((kde_KRootProp *)[self qt], (qt_QString *) [rKey toQString: &_qstring_rKey]);
	return [NSString fromQString: _qstring];
}

- (NSArray *) listEntries
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KRootProp_listEntries((kde_KRootProp *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- sync
{
	kde_KRootProp_sync((kde_KRootProp *)[self qt]);
	return self;
}

@end
