/***************************************************************************
                            KCompletion.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_KCompletion.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KCompletion.h>

@implementation  KCompletion


- init
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KCompletion()];
		[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) {
			kde_del_KCompletion((kde_KCompletion *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (NSString *) makeCompletion: (NSString *)string
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_string = 0L;
	_qstring = kde_KCompletion_makeCompletion((kde_KCompletion *)[self qt], (qt_QString *) [string toQString: &_qstring_string]);
	return [NSString fromQString: _qstring];
}

- (NSArray *) substringCompletion: (NSString *)string
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_string = 0L;
	_qlist = kde_KCompletion_substringCompletion((kde_KCompletion *)[self qt], (qt_QString *) [string toQString: &_qstring_string]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- (NSString *) previousMatch
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KCompletion_previousMatch((kde_KCompletion *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) nextMatch
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KCompletion_nextMatch((kde_KCompletion *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) lastMatch
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KCompletion_lastMatch((kde_KCompletion *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSArray *) items
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KCompletion_items((kde_KCompletion *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- setCompletionMode: (int)mode
{
	kde_KCompletion_setCompletionMode((kde_KCompletion *)[self qt], (int)mode);
	return self;
}

- (int) completionMode
{
	return (int) kde_KCompletion_completionMode((kde_KCompletion *)[self qt]);
}

- setOrder: (int)order
{
	kde_KCompletion_setOrder((kde_KCompletion *)[self qt], (int)order);
	return self;
}

- (int) order
{
	return (int) kde_KCompletion_order((kde_KCompletion *)[self qt]);
}

- setIgnoreCase: (BOOL)ignoreCase
{
	kde_KCompletion_setIgnoreCase((kde_KCompletion *)[self qt], (int)ignoreCase);
	return self;
}

- (BOOL) ignoreCase
{
	return (BOOL) kde_KCompletion_ignoreCase((kde_KCompletion *)[self qt]);
}

- (NSArray *) allMatches
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KCompletion_allMatches((kde_KCompletion *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- (NSArray *) allMatches: (NSString *)string
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_string = 0L;
	_qlist = kde_KCompletion_allMatches1((kde_KCompletion *)[self qt], (qt_QString *) [string toQString: &_qstring_string]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

//- (KCompletionMatches) allWeightedMatches
//{
//	return (KCompletionMatches) kde_KCompletion_allWeightedMatches((kde_KCompletion *)[self qt]);
//}

//- (KCompletionMatches) allWeightedMatches: (NSString *)string
//{
//static qt_QString * _qstring_string = 0L;
//	return (KCompletionMatches) kde_KCompletion_allWeightedMatches1((kde_KCompletion *)[self qt], (qt_QString *) [string toQString: &_qstring_string]);
//}

- setEnableSounds: (BOOL)enable
{
	kde_KCompletion_setEnableSounds((kde_KCompletion *)[self qt], (int)enable);
	return self;
}

- (BOOL) isSoundsEnabled
{
	return (BOOL) kde_KCompletion_isSoundsEnabled((kde_KCompletion *)[self qt]);
}

- (BOOL) hasMultipleMatches
{
	return (BOOL) kde_KCompletion_hasMultipleMatches((kde_KCompletion *)[self qt]);
}

- enableSounds
{
	kde_KCompletion_enableSounds((kde_KCompletion *)[self qt]);
	return self;
}

- disableSounds
{
	kde_KCompletion_disableSounds((kde_KCompletion *)[self qt]);
	return self;
}

- slotMakeCompletion: (NSString *)string
{
static qt_QString * _qstring_string = 0L;
	kde_KCompletion_slotMakeCompletion((kde_KCompletion *)[self qt], (qt_QString *) [string toQString: &_qstring_string]);
	return self;
}

- slotPreviousMatch
{
	kde_KCompletion_slotPreviousMatch((kde_KCompletion *)[self qt]);
	return self;
}

- slotNextMatch
{
	kde_KCompletion_slotNextMatch((kde_KCompletion *)[self qt]);
	return self;
}

- insertItems: (NSArray *)items
{
static qt_QStringList * _qlist_items = 0L;
	kde_KCompletion_insertItems((kde_KCompletion *)[self qt], (qt_QStringList*) [items toQStringList: (void *)&_qlist_items]);
	return self;
}

- setItems: (NSArray *)arg1
{
static qt_QStringList * _qlist_arg1 = 0L;
	kde_KCompletion_setItems((kde_KCompletion *)[self qt], (qt_QStringList*) [arg1 toQStringList: (void *)&_qlist_arg1]);
	return self;
}

- addTextItem: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	kde_KCompletion_addItem((kde_KCompletion *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
	return self;
}

- addTextItem: (NSString *)arg1 weight: (unsigned int)weight
{
static qt_QString * _qstring_arg1 = 0L;
	kde_KCompletion_addItem1((kde_KCompletion *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (unsigned int)weight);
	return self;
}

- removeTextItem: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	kde_KCompletion_removeItem((kde_KCompletion *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
	return self;
}

- clear
{
	kde_KCompletion_clear((kde_KCompletion *)[self qt]);
	return self;
}

- postProcessMatch: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	kde_KCompletion_postProcessMatch((kde_KCompletion *)[self qt], (qt_QString*) [arg1 toQString: &_qstring_arg1]);
	return self;
}

- postProcessMatches: (NSArray *)arg1
{
static qt_QStringList * _qlist_arg1 = 0L;
	kde_KCompletion_postProcessMatches((kde_KCompletion *)[self qt], (qt_QStringList*) [arg1 toQStringList: (void *)&_qlist_arg1]);
	return self;
}

//- postProcessCompletionMatches: (KCompletionMatches*)arg1
//{
//	kde_KCompletion_postProcessMatches1((kde_KCompletion *)[self qt], (KCompletionMatches*) arg1);
//	return self;
//}

+ (int) Sorted
{
	return (int) KCOMPLETION_Sorted;
}

+ (int) Insertion
{
	return (int) KCOMPLETION_Insertion;
}

+ (int) Weighted
{
	return (int) KCOMPLETION_Weighted;
}

@end
