/***************************************************************************
                            KKeyChooser.m -  description
                             -------------------
    begin                : Thu Mar 21 01:01:29 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Thu Mar 21 01:01:29 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_KKeyChooser.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KKeyChooser.h>
#include <kdeobjc/KAccel.h>
#include <kdeobjc/KActionCollection.h>
#include <kdeobjc/KConfigBase.h>
#include <kdeobjc/KGlobalAccel.h>
#include <kdeobjc/KShortcut.h>
#include <qtobjc/QFont.h>
#include <qtobjc/QListViewItem.h>


@implementation  KKeyChooser


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

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

- initWithActionCollection: (KActionCollection*)coll parent: (QWidget *)parent bAllowLetterShortcuts: (BOOL)bAllowLetterShortcuts
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKeyChooser1((kde_KActionCollection*) [coll qt], (qt_QWidget *) [parent qt], (int)bAllowLetterShortcuts)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithActionCollection: (KActionCollection*)coll parent: (QWidget *)parent 
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKeyChooser1((kde_KActionCollection*) [coll qt], (qt_QWidget *) [parent qt], 1)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithAccel: (KAccel*)actions parent: (QWidget *)parent bAllowLetterShortcuts: (BOOL)bAllowLetterShortcuts
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKeyChooser2((kde_KAccel*) [actions qt], (qt_QWidget *) [parent qt], (int)bAllowLetterShortcuts)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithAccel: (KAccel*)actions parent: (QWidget *)parent 
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKeyChooser2((kde_KAccel*) [actions qt], (qt_QWidget *) [parent qt], 1)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

//- initWithShortcutList: (KShortcutList*)arg1 parent: (QWidget *)parent type: (int)type bAllowLetterShortcuts: (BOOL)bAllowLetterShortcuts
//{
//	if ([self qt] == 0L) {
//		[self setQt: kde_new_KKeyChooser4((KShortcutList*) arg1, (qt_QWidget *) [parent qt], (int)type, (int)bAllowLetterShortcuts)];
//		[self setAllocatedInObjcWorld: YES];
//		[QtSupport setObject: self forQtKey: [self qt]];
//	}
//	[super init];
//	return self;
//}

//- initWithShortcutList: (KShortcutList*)arg1 parent: (QWidget *)parent
//{
//	if ([self qt] == 0L) {
//		[self setQt: kde_new_KKeyChooser4((KShortcutList*) arg1, (qt_QWidget *) [parent qt], [KKeyChooser Application], 1)];
//		[self setAllocatedInObjcWorld: YES];
//		[QtSupport setObject: self forQtKey: [self qt]];
//	}
//	[super init];
//	return self;
//}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld] && [self parentWidget: YES] == nil) {
			kde_del_KKeyChooser((kde_KKeyChooser *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (BOOL) insertActionCollection: (KActionCollection*)arg1
{
	return (BOOL) kde_KKeyChooser_insert((kde_KKeyChooser *)[self qt], (kde_KActionCollection*) [arg1 qt]);
}

- syncToConfig: (NSString *)sConfigGroup pConfig: (KConfigBase*)pConfig bClearUnset: (BOOL)bClearUnset
{
static qt_QString * _qstring_sConfigGroup = 0L;
	kde_KKeyChooser_syncToConfig((kde_KKeyChooser *)[self qt], (qt_QString *) [sConfigGroup toQString: &_qstring_sConfigGroup], (kde_KConfigBase*) [pConfig qt], (int)bClearUnset);
	return self;
}

- commitChanges
{
	kde_KKeyChooser_commitChanges((kde_KKeyChooser *)[self qt]);
	return self;
}

- save
{
	kde_KKeyChooser_save((kde_KKeyChooser *)[self qt]);
	return self;
}

- initWithAccel: (KAccel*)actions parent: (QWidget *)parent bCheckAgainstStdKeys: (BOOL)bCheckAgainstStdKeys bAllowLetterShortcuts: (BOOL)bAllowLetterShortcuts bAllowWinKey: (BOOL)bAllowWinKey
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKeyChooser5((kde_KAccel*) [actions qt], (qt_QWidget *) [parent qt], (int)bCheckAgainstStdKeys, (int)bAllowLetterShortcuts, (int)bAllowWinKey)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithAccel: (KAccel*)actions parent: (QWidget *)parent bCheckAgainstStdKeys: (BOOL)bCheckAgainstStdKeys bAllowLetterShortcuts: (BOOL)bAllowLetterShortcuts 
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKeyChooser5((kde_KAccel*) [actions qt], (qt_QWidget *) [parent qt], (int)bCheckAgainstStdKeys, (int)bAllowLetterShortcuts, 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithGlobalAccel: (KGlobalAccel*)actions parent: (QWidget *)parent bCheckAgainstStdKeys: (BOOL)bCheckAgainstStdKeys bAllowLetterShortcuts: (BOOL)bAllowLetterShortcuts bAllowWinKey: (BOOL)bAllowWinKey
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKeyChooser6((kde_KGlobalAccel*) [actions qt], (qt_QWidget *) [parent qt], (int)bCheckAgainstStdKeys, (int)bAllowLetterShortcuts, (int)bAllowWinKey)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithGlobalAccel: (KGlobalAccel*)actions parent: (QWidget *)parent bCheckAgainstStdKeys: (BOOL)bCheckAgainstStdKeys bAllowLetterShortcuts: (BOOL)bAllowLetterShortcuts 
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKeyChooser6((kde_KGlobalAccel*) [actions qt], (qt_QWidget *) [parent qt], (int)bCheckAgainstStdKeys, (int)bAllowLetterShortcuts, 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- allDefault
{
	kde_KKeyChooser_allDefault((kde_KKeyChooser *)[self qt]);
	return self;
}

- setPreferFourModifierKeys: (BOOL)preferFourModifierKeys
{
	kde_KKeyChooser_setPreferFourModifierKeys((kde_KKeyChooser *)[self qt], (int)preferFourModifierKeys);
	return self;
}

- listSync
{
	kde_KKeyChooser_listSync((kde_KKeyChooser *)[self qt]);
	return self;
}

- initGUI: (int)type bAllowLetterShortcuts: (BOOL)bAllowLetterShortcuts
{
	kde_KKeyChooser_initGUI((kde_KKeyChooser *)[self qt], (int)type, (int)bAllowLetterShortcuts);
	return self;
}

- (BOOL) insertAccel: (KAccel*)arg1
{
	return (BOOL) kde_KKeyChooser_insert1((kde_KKeyChooser *)[self qt], (kde_KAccel*) [arg1 qt]);
}

- (BOOL) insertGlobalAccel: (KGlobalAccel*)arg1
{
	return (BOOL) kde_KKeyChooser_insert2((kde_KKeyChooser *)[self qt], (kde_KGlobalAccel*) [arg1 qt]);
}

//- (BOOL) insert: (KShortcutList*)arg1
//{
//	return (BOOL) kde_KKeyChooser_insert3((kde_KKeyChooser *)[self qt], (KShortcutList*) arg1);
//}

- buildListView: (unsigned int)iList
{
	kde_KKeyChooser_buildListView((kde_KKeyChooser *)[self qt], (unsigned int)iList);
	return self;
}

- readGlobalKeys
{
	kde_KKeyChooser_readGlobalKeys((kde_KKeyChooser *)[self qt]);
	return self;
}

- updateButtons
{
	kde_KKeyChooser_updateButtons((kde_KKeyChooser *)[self qt]);
	return self;
}

- fontChange: (QFont *)_font
{
	kde_KKeyChooser_fontChange((kde_KKeyChooser *)[self qt], (qt_QFont *) [_font qt]);
	return self;
}

- setShortcut: (KShortcut*)cut
{
	kde_KKeyChooser_setShortcut((kde_KKeyChooser *)[self qt], (kde_KShortcut*) [cut qt]);
	return self;
}

- (BOOL) isKeyPresent: (KShortcut*)cut warnuser: (BOOL)warnuser
{
	return (BOOL) kde_KKeyChooser_isKeyPresent((kde_KKeyChooser *)[self qt], (kde_KShortcut*) [cut qt], (int)warnuser);
}

- (BOOL) isKeyPresent: (KShortcut*)cut 
{
	return (BOOL) kde_KKeyChooser_isKeyPresent((kde_KKeyChooser *)[self qt], (kde_KShortcut*) [cut qt], 1);
}

//- _warning: (KKeySequence*)seq sAction: (NSString *)sAction sTitle: (NSString *)sTitle
//{
//static qt_QString * _qstring_sTitle = 0L;
//static qt_QString * _qstring_sAction = 0L;
//	kde_KKeyChooser__warning((kde_KKeyChooser *)[self qt], (kde_KKeySequence*) [seq qt], (qt_QString *) [sAction toQString: &_qstring_sAction], (qt_QString *) [sTitle toQString: &_qstring_sTitle]);
//	return self;
//}

- virtual_hook: (int)identifier data: (void*)data
{
	kde_KKeyChooser_virtual_hook((kde_KKeyChooser *)[self qt], (int)identifier, (void*)data);
	return self;
}

- slotNoKey
{
	kde_KKeyChooser_slotNoKey((kde_KKeyChooser *)[self qt]);
	return self;
}

- slotDefaultKey
{
	kde_KKeyChooser_slotDefaultKey((kde_KKeyChooser *)[self qt]);
	return self;
}

- slotCustomKey
{
	kde_KKeyChooser_slotCustomKey((kde_KKeyChooser *)[self qt]);
	return self;
}

- slotListItemSelected: (QListViewItem *)item
{
	kde_KKeyChooser_slotListItemSelected((kde_KKeyChooser *)[self qt], (qt_QListViewItem *) [item qt]);
	return self;
}

- capturedShortcut: (KShortcut*)cut
{
	kde_KKeyChooser_capturedShortcut((kde_KKeyChooser *)[self qt], (kde_KShortcut*) [cut qt]);
	return self;
}

+ (int) Application
{
	return (int) KKEYCHOOSER_Application;
}

+ (int) ApplicationGlobal
{
	return (int) KKEYCHOOSER_ApplicationGlobal;
}

+ (int) Standard
{
	return (int) KKEYCHOOSER_Standard;
}

+ (int) Global
{
	return (int) KKEYCHOOSER_Global;
}

+ (int) NoKey
{
	return (int) KKEYCHOOSER_NoKey;
}

+ (int) DefaultKey
{
	return (int) KKEYCHOOSER_DefaultKey;
}

+ (int) CustomKey
{
	return (int) KKEYCHOOSER_CustomKey;
}

@end
