/***************************************************************************
                            QAccel.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_QAccel.h>
#include <qtobjc/QAccel.h>
#include <qtobjc/QWidget.h>
#include <qtobjc/QKeySequence.h>

@class QKeySequence;

@implementation  QAccel


- initWithWidget: (QWidget *)parent name: (NSString *)name
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QAccel((qt_QWidget *) [parent qt], (char*) [name cString])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithWidget: (QWidget *)parent 
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QAccel((qt_QWidget *) [parent qt], 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- initWithWidget: (QWidget *)watch parent: (QObject *)parent 
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QAccel1((qt_QWidget *) [watch qt], (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_QAccel((qt_QAccel *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (BOOL) isEnabled
{
	return (BOOL) qt_QAccel_isEnabled((qt_QAccel *)[self qt]);
}

- setEnabled: (BOOL)arg1
{
	qt_QAccel_setEnabled((qt_QAccel *)[self qt], (int)arg1);
	return self;
}

- (unsigned int) count
{
	return (unsigned int) qt_QAccel_count((qt_QAccel *)[self qt]);
}

- (int) insertKeySequenceItem: (QKeySequence*)key identifier: (int)identifier
{
	return (int) qt_QAccel_insertItem((qt_QAccel *)[self qt], (qt_QKeySequence*) [key qt], (int)identifier);
}

- (int) insertKeySequenceItem: (QKeySequence*)key 
{
	return (int) qt_QAccel_insertItem((qt_QAccel *)[self qt], (qt_QKeySequence*) [key qt], -1);
}

- removeIntItem: (int)identifier
{
	qt_QAccel_removeItem((qt_QAccel *)[self qt], (int)identifier);
	return self;
}

- clear
{
	qt_QAccel_clear((qt_QAccel *)[self qt]);
	return self;
}

- (QKeySequence*) key: (int)identifier
{
	return (QKeySequence*) [QtSupport objectForQtKey: qt_QAccel_key((qt_QAccel *)[self qt], (int)identifier) withClass: [QKeySequence class] allocatedInObjcWorld: YES];
}

- (int) findKey: (QKeySequence*)key
{
	return (int) qt_QAccel_findKey((qt_QAccel *)[self qt], (qt_QKeySequence*) [key qt]);
}

- (BOOL) isItemEnabled: (int)identifier
{
	return (BOOL) qt_QAccel_isItemEnabled((qt_QAccel *)[self qt], (int)identifier);
}

- setItemEnabled: (int)identifier enable: (BOOL)enable
{
	qt_QAccel_setItemEnabled((qt_QAccel *)[self qt], (int)identifier, (int)enable);
	return self;
}

- (BOOL) connectItem: (int)identifier receiver: (QObject *)receiver slot: (NSString *)member
{
	return (BOOL) qt_QAccel_connectItem((qt_QAccel *)[self qt], (int)identifier, (qt_QObject *) [receiver qt], (char*) [member cString]);
}

- (BOOL) disconnectItem: (int)identifier receiver: (QObject *)receiver slot: (NSString *)member
{
	return (BOOL) qt_QAccel_disconnectItem((qt_QAccel *)[self qt], (int)identifier, (qt_QObject *) [receiver qt], (char*) [member cString]);
}

- repairEventFilter
{
	qt_QAccel_repairEventFilter((qt_QAccel *)[self qt]);
	return self;
}

- setWhatsThis: (int)identifier string: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	qt_QAccel_setWhatsThis((qt_QAccel *)[self qt], (int)identifier, (qt_QString *) [arg1 toQString: &_qstring_arg1]);
	return self;
}

- (NSString *) whatsThis: (int)identifier
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QAccel_whatsThis((qt_QAccel *)[self qt], (int)identifier);
	return [NSString fromQString: _qstring];
}

- setIgnoreWhatsThis: (BOOL)arg1
{
	qt_QAccel_setIgnoreWhatsThis((qt_QAccel *)[self qt], (int)arg1);
	return self;
}

- (BOOL) ignoreWhatsThis
{
	return (BOOL) qt_QAccel_ignoreWhatsThis((qt_QAccel *)[self qt]);
}

+ (QKeySequence*) shortcutKey: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	return (QKeySequence*) [QtSupport objectForQtKey: qt_QAccel_shortcutKey((qt_QString *) [arg1 toQString: &_qstring_arg1]) withClass: [QKeySequence class] allocatedInObjcWorld: YES];
}

+ (NSString *) keyToString: (QKeySequence*)k
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QAccel_keyToString((qt_QKeySequence*) [k qt]);
	return [NSString fromQString: _qstring];
}

+ (QKeySequence*) stringToKey: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	return (QKeySequence*) [QtSupport objectForQtKey: qt_QAccel_stringToKey((qt_QString *) [arg1 toQString: &_qstring_arg1]) withClass: [QKeySequence class] allocatedInObjcWorld: YES];
}

- (BOOL) eventFilter: (QObject *)arg1 event: (QEvent *)arg2
{
	return (BOOL) qt_QAccel_eventFilter((qt_QAccel *)[self qt], (qt_QObject *) [arg1 qt], (qt_QEvent *) [arg2 qt]);
}

@end
