/***************************************************************************
                            QTranslator.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_QTranslator.h>
#include <qtobjc/QTranslator.h>
#include <qtobjc/QTranslatorMessage.h>

@implementation  QTranslator


- initWithObject: (QObject *)parent name: (NSString *)name
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QTranslator((qt_QObject *) [parent qt], (char*) [name cString])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithObject: (QObject *)parent 
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QTranslator((qt_QObject *) [parent qt], 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld] && [self parent] == nil) {
			qt_del_QTranslator((qt_QTranslator *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (NSString *) find: (NSString *)context sourceText: (NSString *)sourceText comment: (NSString *)comment
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QTranslator_find((qt_QTranslator *)[self qt], (char*) [context cString], (char*) [sourceText cString], (char*) [comment cString]);
	return [NSString fromQString: _qstring];
}

- (QTranslatorMessage*) findMessage: (NSString *)arg1 string: (NSString *)arg2 string: (NSString *)arg3
{
	return (QTranslatorMessage*) [QtSupport objectForQtKey: qt_QTranslator_findMessage((qt_QTranslator *)[self qt], (char*) [arg1 cString], (char*) [arg2 cString], (char*) [arg3 cString]) withClass: [QTranslatorMessage class] allocatedInObjcWorld: YES];
}

- (BOOL) load: (NSString *)filename directory: (NSString *)directory search_delimiters: (NSString *)search_delimiters suffix: (NSString *)suffix
{
static qt_QString * _qstring_suffix = 0L;
static qt_QString * _qstring_search_delimiters = 0L;
static qt_QString * _qstring_directory = 0L;
static qt_QString * _qstring_filename = 0L;
	return (BOOL) qt_QTranslator_load((qt_QTranslator *)[self qt], (qt_QString *) [filename toQString: &_qstring_filename], (qt_QString *) [directory toQString: &_qstring_directory], (qt_QString *) [search_delimiters toQString: &_qstring_search_delimiters], (qt_QString *) [suffix toQString: &_qstring_suffix]);
}

- (BOOL) load: (NSString *)filename 
{
static qt_QString * _qstring_filename = 0L;
	return (BOOL) qt_QTranslator_load((qt_QTranslator *)[self qt], (qt_QString *) [filename toQString: &_qstring_filename], qt_QString_null(), qt_QString_null(), qt_QString_null());
}

- clear
{
	qt_QTranslator_clear((qt_QTranslator *)[self qt]);
	return self;
}

- (BOOL) save: (NSString *)filename mode: (int)mode
{
static qt_QString * _qstring_filename = 0L;
	return (BOOL) qt_QTranslator_save((qt_QTranslator *)[self qt], (qt_QString *) [filename toQString: &_qstring_filename], (int)mode);
}

- (BOOL) save: (NSString *)filename 
{
static qt_QString * _qstring_filename = 0L;
	return (BOOL) qt_QTranslator_save((qt_QTranslator *)[self qt], (qt_QString *) [filename toQString: &_qstring_filename], [QTranslator Everything]);
}

- insert: (QTranslatorMessage*)arg1
{
	qt_QTranslator_insert((qt_QTranslator *)[self qt], (qt_QTranslatorMessage*) [arg1 qt]);
	return self;
}

- insert: (NSString *)context sourceText: (NSString *)sourceText translation: (NSString *)translation
{
static qt_QString * _qstring_translation = 0L;
	qt_QTranslator_insert1((qt_QTranslator *)[self qt], (char*) [context cString], (char*) [sourceText cString], (qt_QString *) [translation toQString: &_qstring_translation]);
	return self;
}

- remove: (QTranslatorMessage*)arg1
{
	qt_QTranslator_remove((qt_QTranslator *)[self qt], (qt_QTranslatorMessage*) [arg1 qt]);
	return self;
}

- remove: (NSString *)context sourceText: (NSString *)sourceText
{
	qt_QTranslator_remove1((qt_QTranslator *)[self qt], (char*) [context cString], (char*) [sourceText cString]);
	return self;
}

- (BOOL) contains: (NSString *)arg1 string: (NSString *)arg2 comment: (NSString *)comment
{
	return (BOOL) qt_QTranslator_contains((qt_QTranslator *)[self qt], (char*) [arg1 cString], (char*) [arg2 cString], (char*) [comment cString]);
}

- (BOOL) contains: (NSString *)arg1 string: (NSString *)arg2 
{
	return (BOOL) qt_QTranslator_contains((qt_QTranslator *)[self qt], (char*) [arg1 cString], (char*) [arg2 cString], 0);
}

- squeeze: (int)arg1
{
	qt_QTranslator_squeeze((qt_QTranslator *)[self qt], (int)arg1);
	return self;
}

- squeeze
{
	qt_QTranslator_squeeze((qt_QTranslator *)[self qt], [QTranslator Everything]);
	return self;
}

- unsqueeze
{
	qt_QTranslator_unsqueeze((qt_QTranslator *)[self qt]);
	return self;
}

+ (int) Everything
{
	return (int) QTRANSLATOR_Everything;
}

+ (int) Stripped
{
	return (int) QTRANSLATOR_Stripped;
}

@end
