/***************************************************************************
                            KFileDialog.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_KFileDialog.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KFileDialog.h>
#include <kdeobjc/Job.h>
#include <kdeobjc/KConfig.h>
#include <kdeobjc/KFileItem.h>
#include <kdeobjc/KPreviewWidgetBase.h>
#include <kdeobjc/KURL.h>


@implementation  KFileDialog


- initWithText: (NSString *)startDir filter: (NSString *)filter parent: (QWidget *)parent name: (NSString *)name modal: (BOOL)modal
{
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_startDir = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KFileDialog((qt_QString *) [startDir toQString: &_qstring_startDir], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (char*) [name cString], (int)modal)];
		[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_KFileDialog((kde_KFileDialog *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (KURL*) selectedURL
{
	return (KURL*) [QtSupport objectForQtKey: kde_KFileDialog_selectedURL((kde_KFileDialog *)[self qt]) withClass: [KURL class] allocatedInObjcWorld: YES];
}

//- (NSArray *) selectedURLs
//{
//static kde_KURLList * _qlist = 0L;
//	_qlist = kde_KFileDialog_selectedURLs((kde_KFileDialog *)[self qt]);
//	return (NSArray *) [NSMutableArray arrayWithKURLList: _qlist];
//}

- (KURL*) baseURL
{
	return (KURL*) [QtSupport objectForQtKey: kde_KFileDialog_baseURL((kde_KFileDialog *)[self qt]) withClass: [KURL class] allocatedInObjcWorld: YES];
}

- (NSString *) selectedFile
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KFileDialog_selectedFile((kde_KFileDialog *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSArray *) selectedFiles
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KFileDialog_selectedFiles((kde_KFileDialog *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- setURL: (KURL*)url clearforward: (BOOL)clearforward
{
	kde_KFileDialog_setURL((kde_KFileDialog *)[self qt], (kde_KURL*) [url qt], (int)clearforward);
	return self;
}

- setURL: (KURL*)url 
{
	kde_KFileDialog_setURL((kde_KFileDialog *)[self qt], (kde_KURL*) [url qt], 1);
	return self;
}

- setSelection: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	kde_KFileDialog_setSelection((kde_KFileDialog *)[self qt], (qt_QString *) [name toQString: &_qstring_name]);
	return self;
}

- setOperationMode: (int)arg1
{
	kde_KFileDialog_setOperationMode((kde_KFileDialog *)[self qt], (int)arg1);
	return self;
}

- (int) operationMode
{
	return (int) kde_KFileDialog_operationMode((kde_KFileDialog *)[self qt]);
}

- setKeepLocation: (BOOL)keep
{
	kde_KFileDialog_setKeepLocation((kde_KFileDialog *)[self qt], (int)keep);
	return self;
}

- (BOOL) keepsLocation
{
	return (BOOL) kde_KFileDialog_keepsLocation((kde_KFileDialog *)[self qt]);
}

- setFilter: (NSString *)filter
{
static qt_QString * _qstring_filter = 0L;
	kde_KFileDialog_setFilter((kde_KFileDialog *)[self qt], (qt_QString *) [filter toQString: &_qstring_filter]);
	return self;
}

- (NSString *) currentFilter
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KFileDialog_currentFilter((kde_KFileDialog *)[self qt]);
	return [NSString fromQString: _qstring];
}

//- setFilterMimeType: (NSString *)label types: (KMimeType_List*)types defaultType: (KMimeType_Ptr*)defaultType
//{
//static qt_QString * _qstring_label = 0L;
//	kde_KFileDialog_setFilterMimeType((kde_KFileDialog *)[self qt], (qt_QString *) [label toQString: &_qstring_label], (kde_KMimeType_List*) [types qt], (kde_KMimeType_Ptr*) [defaultType qt]);
//	return self;
//}

//- (KMimeType_Ptr) currentFilterMimeType
//{
//	return (KMimeType_Ptr) kde_KFileDialog_currentFilterMimeType((kde_KFileDialog *)[self qt]);
//}

- setMimeFilter: (NSArray *)types defaultType: (NSString *)defaultType
{
static qt_QString * _qstring_defaultType = 0L;
static qt_QStringList * _qlist_types = 0L;
	kde_KFileDialog_setMimeFilter((kde_KFileDialog *)[self qt], (qt_QStringList*) [types toQStringList: (void *)&_qlist_types], (qt_QString *) [defaultType toQString: &_qstring_defaultType]);
	return self;
}

- setMimeFilter: (NSArray *)types 
{
static qt_QStringList * _qlist_types = 0L;
	kde_KFileDialog_setMimeFilter((kde_KFileDialog *)[self qt], (qt_QStringList*) [types toQStringList: (void *)&_qlist_types], qt_QString_null());
	return self;
}

- (NSString *) currentMimeFilter
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KFileDialog_currentMimeFilter((kde_KFileDialog *)[self qt]);
	return [NSString fromQString: _qstring];
}

- clearFilter
{
	kde_KFileDialog_clearFilter((kde_KFileDialog *)[self qt]);
	return self;
}

- setPreviewWidget: (QWidget *)w
{
	kde_KFileDialog_setPreviewWidget((kde_KFileDialog *)[self qt], (qt_QWidget *) [w qt]);
	return self;
}

- setPreviewWidgetBase: (KPreviewWidgetBase*)w
{
	kde_KFileDialog_setPreviewWidget1((kde_KFileDialog *)[self qt], (kde_KPreviewWidgetBase*) [w qt]);
	return self;
}

//- setMode: (int)m
//{
//	kde_KFileDialog_setMode((kde_KFileDialog *)[self qt], (int)m);
//	return self;
//}

- setMode: (unsigned int)m
{
	kde_KFileDialog_setMode1((kde_KFileDialog *)[self qt], (unsigned int)m);
	return self;
}

- (int) mode
{
	return (int) kde_KFileDialog_mode((kde_KFileDialog *)[self qt]);
}

- setLocationLabel: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	kde_KFileDialog_setLocationLabel((kde_KFileDialog *)[self qt], (qt_QString *) [text toQString: &_qstring_text]);
	return self;
}

- (KToolBar*) toolBar
{
	return (KToolBar*) [QtSupport objectForQtKey: kde_KFileDialog_toolBar((kde_KFileDialog *)[self qt]) withClass: [KToolBar class] allocatedInObjcWorld: YES];
}

- (KPushButton*) okButton
{
	return (KPushButton*) [QtSupport objectForQtKey: kde_KFileDialog_okButton((kde_KFileDialog *)[self qt]) withClass: [KPushButton class] allocatedInObjcWorld: YES];
}

- (KPushButton*) cancelButton
{
	return (KPushButton*) [QtSupport objectForQtKey: kde_KFileDialog_cancelButton((kde_KFileDialog *)[self qt]) withClass: [KPushButton class] allocatedInObjcWorld: YES];
}

- (KActionCollection*) actionCollection
{
	return (KActionCollection*) [QtSupport objectForQtKey: kde_KFileDialog_actionCollection((kde_KFileDialog *)[self qt]) withClass: [KActionCollection class] allocatedInObjcWorld: YES];
}

+ (NSString *) getOpenFileName: (NSString *)startDir filter: (NSString *)filter parent: (QWidget *)parent caption: (NSString *)caption
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_startDir = 0L;
	_qstring = kde_KFileDialog_getOpenFileName((qt_QString *) [startDir toQString: &_qstring_startDir], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (qt_QString *) [caption toQString: &_qstring_caption]);
	return [NSString fromQString: _qstring];
}

+ (NSArray *) getOpenFileNames: (NSString *)startDir filter: (NSString *)filter parent: (QWidget *)parent caption: (NSString *)caption
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_startDir = 0L;
	_qlist = kde_KFileDialog_getOpenFileNames((qt_QString *) [startDir toQString: &_qstring_startDir], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (qt_QString *) [caption toQString: &_qstring_caption]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

+ (KURL*) getOpenURL: (NSString *)startDir filter: (NSString *)filter parent: (QWidget *)parent caption: (NSString *)caption
{
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_startDir = 0L;
	return (KURL*) [QtSupport objectForQtKey: kde_KFileDialog_getOpenURL((qt_QString *) [startDir toQString: &_qstring_startDir], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (qt_QString *) [caption toQString: &_qstring_caption]) withClass: [KURL class] allocatedInObjcWorld: YES];
}

+ (KURL*) getOpenURL
{
	return (KURL*) [QtSupport objectForQtKey: kde_KFileDialog_getOpenURL(qt_QString_null(), qt_QString_null(), 0, qt_QString_null()) withClass: [KURL class] allocatedInObjcWorld: YES];
}

//+ (NSArray *) getOpenURLs: (NSString *)startDir filter: (NSString *)filter parent: (QWidget *)parent caption: (NSString *)caption
//{
//static kde_KURLList * _qlist = 0L;
//static qt_QString * _qstring_caption = 0L;
//static qt_QString * _qstring_filter = 0L;
//static qt_QString * _qstring_startDir = 0L;
//	_qlist = kde_KFileDialog_getOpenURLs((qt_QString *) [startDir toQString: &_qstring_startDir], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (qt_QString *) [caption toQString: &_qstring_caption]);
//	return (NSArray *) [NSMutableArray arrayWithKURLList: _qlist];
//}

+ (NSString *) getSaveFileName: (NSString *)startDir filter: (NSString *)filter parent: (QWidget *)parent caption: (NSString *)caption
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_startDir = 0L;
	_qstring = kde_KFileDialog_getSaveFileName((qt_QString *) [startDir toQString: &_qstring_startDir], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (qt_QString *) [caption toQString: &_qstring_caption]);
	return [NSString fromQString: _qstring];
}

+ (KURL*) getSaveURL: (NSString *)startDir filter: (NSString *)filter parent: (QWidget *)parent caption: (NSString *)caption
{
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_startDir = 0L;
	return (KURL*) [QtSupport objectForQtKey: kde_KFileDialog_getSaveURL((qt_QString *) [startDir toQString: &_qstring_startDir], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (qt_QString *) [caption toQString: &_qstring_caption]) withClass: [KURL class] allocatedInObjcWorld: YES];
}

+ (KURL*) getSaveURL
{
	return (KURL*) [QtSupport objectForQtKey: kde_KFileDialog_getSaveURL(qt_QString_null(), qt_QString_null(), 0, qt_QString_null()) withClass: [KURL class] allocatedInObjcWorld: YES];
}

+ (NSString *) getExistingDirectory: (NSString *)startDir parent: (QWidget *)parent caption: (NSString *)caption
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_startDir = 0L;
	_qstring = kde_KFileDialog_getExistingDirectory((qt_QString *) [startDir toQString: &_qstring_startDir], (qt_QWidget *) [parent qt], (qt_QString *) [caption toQString: &_qstring_caption]);
	return [NSString fromQString: _qstring];
}

+ (KURL*) getImageOpenURL: (NSString *)startDir parent: (QWidget *)parent caption: (NSString *)caption
{
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_startDir = 0L;
	return (KURL*) [QtSupport objectForQtKey: kde_KFileDialog_getImageOpenURL((qt_QString *) [startDir toQString: &_qstring_startDir], (qt_QWidget *) [parent qt], (qt_QString *) [caption toQString: &_qstring_caption]) withClass: [KURL class] allocatedInObjcWorld: YES];
}

+ (KURL*) getImageOpenURL
{
	return (KURL*) [QtSupport objectForQtKey: kde_KFileDialog_getImageOpenURL(qt_QString_null(), 0, qt_QString_null()) withClass: [KURL class] allocatedInObjcWorld: YES];
}

//- addDirEntry: (KFileItem*)entry disableUpdating: (BOOL)disableUpdating
//{
//	kde_KFileDialog_addDirEntry((kde_KFileDialog *)[self qt], (kde_KFileItem*) [entry qt], (int)disableUpdating);
//	return self;
//}

- initGUI
{
	kde_KFileDialog_initGUI((kde_KFileDialog *)[self qt]);
	return self;
}

- multiSelectionChanged
{
	kde_KFileDialog_multiSelectionChanged((kde_KFileDialog *)[self qt]);
	return self;
}

- readConfig: (KConfig*)arg1 group: (NSString *)group
{
static qt_QString * _qstring_group = 0L;
	kde_KFileDialog_readConfig((kde_KFileDialog *)[self qt], (kde_KConfig*) [arg1 qt], (qt_QString *) [group toQString: &_qstring_group]);
	return self;
}

- readConfig: (KConfig*)arg1 
{
	kde_KFileDialog_readConfig((kde_KFileDialog *)[self qt], (kde_KConfig*) [arg1 qt], qt_QString_null());
	return self;
}

- writeConfig: (KConfig*)arg1 group: (NSString *)group
{
static qt_QString * _qstring_group = 0L;
	kde_KFileDialog_writeConfig((kde_KFileDialog *)[self qt], (kde_KConfig*) [arg1 qt], (qt_QString *) [group toQString: &_qstring_group]);
	return self;
}

- writeConfig: (KConfig*)arg1 
{
	kde_KFileDialog_writeConfig((kde_KFileDialog *)[self qt], (kde_KConfig*) [arg1 qt], qt_QString_null());
	return self;
}

- readRecentFiles: (KConfig*)arg1
{
	kde_KFileDialog_readRecentFiles((kde_KFileDialog *)[self qt], (kde_KConfig*) [arg1 qt]);
	return self;
}

- saveRecentFiles: (KConfig*)arg1
{
	kde_KFileDialog_saveRecentFiles((kde_KFileDialog *)[self qt], (kde_KConfig*) [arg1 qt]);
	return self;
}

//- (NSArray *) tokenize: (NSString *)line
//{
//static kde_KURLList * _qlist = 0L;
//static qt_QString * _qstring_line = 0L;
//	_qlist = kde_KFileDialog_tokenize((kde_KFileDialog *)[self qt], (qt_QString *) [line toQString: &_qstring_line]);
//	return (NSArray *) [NSMutableArray arrayWithKURLList: _qlist];
//}

//- (NSArray *) parseSelectedURLs
//{
//static kde_KURLList * _qlist = 0L;
//	_qlist = kde_KFileDialog_parseSelectedURLs((kde_KFileDialog *)[self qt]);
//	return (NSArray *) [NSMutableArray arrayWithKURLList: _qlist];
//}

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

- urlEntered: (KURL*)arg1
{
	kde_KFileDialog_urlEntered((kde_KFileDialog *)[self qt], (kde_KURL*) [arg1 qt]);
	return self;
}

- enterURL: (KURL*)url
{
	kde_KFileDialog_enterURL((kde_KFileDialog *)[self qt], (kde_KURL*) [url qt]);
	return self;
}

- enterURLWithString: (NSString *)url
{
static qt_QString * _qstring_url = 0L;
	kde_KFileDialog_enterURL1((kde_KFileDialog *)[self qt], (qt_QString *) [url toQString: &_qstring_url]);
	return self;
}

- locationActivated: (NSString *)url
{
static qt_QString * _qstring_url = 0L;
	kde_KFileDialog_locationActivated((kde_KFileDialog *)[self qt], (qt_QString *) [url toQString: &_qstring_url]);
	return self;
}

- toolbarCallback: (int)arg1
{
	kde_KFileDialog_toolbarCallback((kde_KFileDialog *)[self qt], (int)arg1);
	return self;
}

- slotFilterChanged
{
	kde_KFileDialog_slotFilterChanged((kde_KFileDialog *)[self qt]);
	return self;
}

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

- fileHighlighted: (KFileItem*)i
{
	kde_KFileDialog_fileHighlighted1((kde_KFileDialog *)[self qt], (kde_KFileItem*) [i qt]);
	return self;
}

- fileSelected: (KFileItem*)i
{
	kde_KFileDialog_fileSelected1((kde_KFileDialog *)[self qt], (kde_KFileItem*) [i qt]);
	return self;
}

- slotStatResult: (Job*)job
{
	kde_KFileDialog_slotStatResult((kde_KFileDialog *)[self qt], (kde_Job*) [job qt]);
	return self;
}

- slotLoadingFinished
{
	kde_KFileDialog_slotLoadingFinished((kde_KFileDialog *)[self qt]);
	return self;
}

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

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

- updateStatusLine: (int)dirs files: (int)files
{
	kde_KFileDialog_updateStatusLine((kde_KFileDialog *)[self qt], (int)dirs, (int)files);
	return self;
}

- slotOk
{
	kde_KFileDialog_slotOk((kde_KFileDialog *)[self qt]);
	return self;
}

- accept
{
	kde_KFileDialog_accept((kde_KFileDialog *)[self qt]);
	return self;
}

- slotCancel
{
	kde_KFileDialog_slotCancel((kde_KFileDialog *)[self qt]);
	return self;
}

- addToRecentDocuments
{
	kde_KFileDialog_addToRecentDocuments((kde_KFileDialog *)[self qt]);
	return self;
}

+ (int) Other
{
	return (int) KFILEDIALOG_Other;
}

+ (int) Opening
{
	return (int) KFILEDIALOG_Opening;
}

+ (int) Saving
{
	return (int) KFILEDIALOG_Saving;
}

@end
