/***************************************************************************
                            QSettings.m -  description
                             -------------------
    begin                : Wed Nov 21 12:08:37 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 12:08:37 2001, 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 <qtc/qt_QSettings.h>
#include <qtobjc/QSettings.h>

@implementation  QSettings

- (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: qt_new_QSettings()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- (BOOL) writeEntry: (NSString *)arg1 bool: (BOOL)arg2
{
static qt_QString * _qstring_arg1 = 0L;
	return (BOOL) qt_QSettings_writeEntry((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (int)arg2);
}

- (BOOL) writeEntry: (NSString *)arg1 double: (double)arg2
{
static qt_QString * _qstring_arg1 = 0L;
	return (BOOL) qt_QSettings_writeEntry1((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (double)arg2);
}

- (BOOL) writeEntry: (NSString *)arg1 int: (int)arg2
{
static qt_QString * _qstring_arg1 = 0L;
	return (BOOL) qt_QSettings_writeEntry2((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (int)arg2);
}

- (BOOL) writeEntry: (NSString *)arg1 string: (NSString *)arg2
{
static qt_QString * _qstring_arg1 = 0L;
	return (BOOL) qt_QSettings_writeEntry3((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (char*) [arg2 cString]);
}

//- (BOOL) writeEntry: (NSString *)arg1 string: (NSString *)arg2
//{
//static qt_QString * _qstring_arg2 = 0L;
//static qt_QString * _qstring_arg1 = 0L;
//	return (BOOL) qt_QSettings_writeEntry4((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (qt_QString *) [arg2 toQString: &_qstring_arg2]);
//}

- (BOOL) writeEntry: (NSString *)arg1 array: (NSArray *)arg2
{
static qt_QStringList * _qlist_arg2 = 0L;
static qt_QString * _qstring_arg1 = 0L;
	return (BOOL) qt_QSettings_writeEntry5((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (qt_QStringList*) [arg2 toQStringList: (void *)&_qlist_arg2]);
}

- (BOOL) writeEntry: (NSString *)arg1 array: (NSArray *)arg2 sep: (unichar *)sep
{
static qt_QStringList * _qlist_arg2 = 0L;
static qt_QString * _qstring_arg1 = 0L;
	return (BOOL) qt_QSettings_writeEntry6((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (qt_QStringList*) [arg2 toQStringList: (void *)&_qlist_arg2], (qt_QChar*)sep);
}

- (NSArray *) entryList: (NSString *)arg1
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_arg1 = 0L;
	_qlist = qt_QSettings_entryList((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- (NSArray *) subkeyList: (NSString *)arg1
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_arg1 = 0L;
	_qlist = qt_QSettings_subkeyList((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- (NSArray *) readListEntry: (NSString *)arg1 int: (int*)arg2
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_arg1 = 0L;
	_qlist = qt_QSettings_readListEntry((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (int*)arg2);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- (NSArray *) readListEntry: (NSString *)arg1 sep: (unichar *)sep int: (int*)arg2
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_arg1 = 0L;
	_qlist = qt_QSettings_readListEntry1((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (qt_QChar*)sep, (int*)arg2);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- (NSString *) readEntry: (NSString *)arg1 def: (NSString *)def int: (int*)arg2
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_def = 0L;
static qt_QString * _qstring_arg1 = 0L;
	_qstring = qt_QSettings_readEntry((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (qt_QString *) [def toQString: &_qstring_def], (int*)arg2);
	return [NSString fromQString: _qstring];
}

- (int) readNumEntry: (NSString *)arg1 def: (int)def int: (int*)arg2
{
static qt_QString * _qstring_arg1 = 0L;
	return (int) qt_QSettings_readNumEntry((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (int)def, (int*)arg2);
}

- (int) readNumEntry: (NSString *)arg1 
{
static qt_QString * _qstring_arg1 = 0L;
	return (int) qt_QSettings_readNumEntry((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], 0, 0);
}

- (double) readDoubleEntry: (NSString *)arg1 def: (double)def int: (int*)arg2
{
static qt_QString * _qstring_arg1 = 0L;
	return (double) qt_QSettings_readDoubleEntry((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (double)def, (int*)arg2);
}

- (double) readDoubleEntry: (NSString *)arg1 
{
static qt_QString * _qstring_arg1 = 0L;
	return (double) qt_QSettings_readDoubleEntry((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], 0, 0);
}

- (BOOL) readBoolEntry: (NSString *)arg1 def: (BOOL)def int: (int*)arg2
{
static qt_QString * _qstring_arg1 = 0L;
	return (BOOL) qt_QSettings_readBoolEntry((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (int)def, (int*)arg2);
}

- (BOOL) readBoolEntry: (NSString *)arg1 
{
static qt_QString * _qstring_arg1 = 0L;
	return (BOOL) qt_QSettings_readBoolEntry((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], 0, 0);
}

- (BOOL) removeEntry: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	return (BOOL) qt_QSettings_removeEntry((qt_QSettings *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
}

- insertSearchPath: (int)arg1 string: (NSString *)arg2
{
static qt_QString * _qstring_arg2 = 0L;
	qt_QSettings_insertSearchPath((qt_QSettings *)[self qt], (int)arg1, (qt_QString *) [arg2 toQString: &_qstring_arg2]);
	return self;
}

- removeSearchPath: (int)arg1 string: (NSString *)arg2
{
static qt_QString * _qstring_arg2 = 0L;
	qt_QSettings_removeSearchPath((qt_QSettings *)[self qt], (int)arg1, (qt_QString *) [arg2 toQString: &_qstring_arg2]);
	return self;
}

+ (int) Unix
{
	return (int) QSETTINGS_Unix;
}

+ (int) Windows
{
	return (int) QSETTINGS_Windows;
}

+ (int) Mac
{
	return (int) QSETTINGS_Mac;
}

@end
