/***************************************************************************
                            QFileDialog.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_QStringList.h>
#include <qtc/qt_QFileDialog.h>
#include <qtobjc/QFileDialog.h>

@implementation  QFileDialog


- initWithText: (NSString *)dirName filter: (NSString *)filter parent: (QWidget *)parent name: (NSString *)name modal: (BOOL)modal
{
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_dirName = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QFileDialog((qt_QString *) [dirName toQString: &_qstring_dirName], (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;
}

- initWithText: (NSString *)dirName 
{
static qt_QString * _qstring_dirName = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QFileDialog((qt_QString *) [dirName toQString: &_qstring_dirName], qt_QString_null(), 0, 0, 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

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

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

- (NSString *) selectedFilter
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileDialog_selectedFilter((qt_QFileDialog *)[self qt]);
	return [NSString fromQString: _qstring];
}

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

- setSelectedFilter: (int)arg1
{
	qt_QFileDialog_setSelectedFilter1((qt_QFileDialog *)[self qt], (int)arg1);
	return self;
}

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

- selectAll: (BOOL)b
{
	qt_QFileDialog_selectAll((qt_QFileDialog *)[self qt], (int)b);
	return self;
}

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

- (NSString *) dirPath
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileDialog_dirPath((qt_QFileDialog *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setDir: (QDir *)arg1
{
	qt_QFileDialog_setDir((qt_QFileDialog *)[self qt], (qt_QDir *) [arg1 qt]);
	return self;
}

- (QDir*) dir
{
	return (QDir*) [QtSupport objectForQtKey: qt_QFileDialog_dir((qt_QFileDialog *)[self qt]) withClass: [QDir class] allocatedInObjcWorld: YES];
}

- setShowHiddenFiles: (BOOL)s
{
	qt_QFileDialog_setShowHiddenFiles((qt_QFileDialog *)[self qt], (int)s);
	return self;
}

- (BOOL) showHiddenFiles
{
	return (BOOL) qt_QFileDialog_showHiddenFiles((qt_QFileDialog *)[self qt]);
}

- rereadDir
{
	qt_QFileDialog_rereadDir((qt_QFileDialog *)[self qt]);
	return self;
}

- resortDir
{
	qt_QFileDialog_resortDir((qt_QFileDialog *)[self qt]);
	return self;
}

- setMode: (int)arg1
{
	qt_QFileDialog_setMode((qt_QFileDialog *)[self qt], (int)arg1);
	return self;
}

- (int) mode
{
	return (int) qt_QFileDialog_mode((qt_QFileDialog *)[self qt]);
}

- setViewMode: (int)m
{
	qt_QFileDialog_setViewMode((qt_QFileDialog *)[self qt], (int)m);
	return self;
}

- (int) viewMode
{
	return (int) qt_QFileDialog_viewMode((qt_QFileDialog *)[self qt]);
}

- setPreviewMode: (int)m
{
	qt_QFileDialog_setPreviewMode((qt_QFileDialog *)[self qt], (int)m);
	return self;
}

- (int) previewMode
{
	return (int) qt_QFileDialog_previewMode((qt_QFileDialog *)[self qt]);
}

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

- (BOOL) isInfoPreviewEnabled
{
	return (BOOL) qt_QFileDialog_isInfoPreviewEnabled((qt_QFileDialog *)[self qt]);
}

- (BOOL) isContentsPreviewEnabled
{
	return (BOOL) qt_QFileDialog_isContentsPreviewEnabled((qt_QFileDialog *)[self qt]);
}

- setInfoPreviewEnabled: (BOOL)arg1
{
	qt_QFileDialog_setInfoPreviewEnabled((qt_QFileDialog *)[self qt], (int)arg1);
	return self;
}

- setContentsPreviewEnabled: (BOOL)arg1
{
	qt_QFileDialog_setContentsPreviewEnabled((qt_QFileDialog *)[self qt], (int)arg1);
	return self;
}

- setInfoPreview: (QWidget *)w preview: (QFilePreview*)preview
{
	qt_QFileDialog_setInfoPreview((qt_QFileDialog *)[self qt], (qt_QWidget *) [w qt], (qt_QFilePreview*) [preview qt]);
	return self;
}

- setContentsPreview: (QWidget *)w preview: (QFilePreview*)preview
{
	qt_QFileDialog_setContentsPreview((qt_QFileDialog *)[self qt], (qt_QWidget *) [w qt], (qt_QFilePreview*) [preview qt]);
	return self;
}

- (QUrl*) url
{
	return (QUrl*) [QtSupport objectForQtKey: qt_QFileDialog_url((qt_QFileDialog *)[self qt]) withClass: [QUrl class] allocatedInObjcWorld: YES];
}

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

- done: (int)arg1
{
	qt_QFileDialog_done((qt_QFileDialog *)[self qt], (int)arg1);
	return self;
}

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

- setUrl: (QUrlOperator*)url
{
	qt_QFileDialog_setUrl((qt_QFileDialog *)[self qt], (qt_QUrlOperator*) [url qt]);
	return self;
}

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

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

//- setFilters: (NSString *)arg1
//{
//	qt_QFileDialog_setFilters1((qt_QFileDialog *)[self qt], (char**) [arg1 cString]);
//	return self;
//}

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

+ (NSString *) getOpenFileName: (NSString *)initially filter: (NSString *)filter parent: (QWidget *)parent name: (NSString *)name caption: (NSString *)caption selectedFilter: (NSString *)selectedFilter resolveSymlinks: (BOOL)resolveSymlinks
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_selectedFilter = 0L;
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_initially = 0L;
	_qstring = qt_QFileDialog_getOpenFileName((qt_QString *) [initially toQString: &_qstring_initially], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (char*) [name cString], (qt_QString *) [caption toQString: &_qstring_caption], (qt_QString*) [selectedFilter toQString: &_qstring_selectedFilter], (int)resolveSymlinks);
	return [NSString fromQString: _qstring];
}

+ (NSString *) getOpenFileName: (NSString *)initially filter: (NSString *)filter parent: (QWidget *)parent name: (NSString *)name
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_initially = 0L;
	_qstring = qt_QFileDialog_getOpenFileName((qt_QString *) [initially toQString: &_qstring_initially], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (char*) [name cString], qt_QString_null(), qt_QString_null(), 0);
	return [NSString fromQString: _qstring];
}

+ (NSString *) getSaveFileName: (NSString *)initially filter: (NSString *)filter parent: (QWidget *)parent name: (NSString *)name caption: (NSString *)caption selectedFilter: (NSString *)selectedFilter resolveSymlinks: (BOOL)resolveSymlinks
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_selectedFilter = 0L;
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_initially = 0L;
	_qstring = qt_QFileDialog_getSaveFileName((qt_QString *) [initially toQString: &_qstring_initially], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (char*) [name cString], (qt_QString *) [caption toQString: &_qstring_caption], (qt_QString*) [selectedFilter toQString: &_qstring_selectedFilter], (int)resolveSymlinks);
	return [NSString fromQString: _qstring];
}

+ (NSString *) getSaveFileName: (NSString *)initially filter: (NSString *)filter parent: (QWidget *)parent name: (NSString *)name
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_filter = 0L;
static qt_QString * _qstring_initially = 0L;
	_qstring = qt_QFileDialog_getSaveFileName((qt_QString *) [initially toQString: &_qstring_initially], (qt_QString *) [filter toQString: &_qstring_filter], (qt_QWidget *) [parent qt], (char*) [name cString], qt_QString_null(), qt_QString_null(), 0);
	return [NSString fromQString: _qstring];
}

+ (NSString *) getExistingDirectory: (NSString *)dir parent: (QWidget *)parent name: (NSString *)name caption: (NSString *)caption dirOnly: (BOOL)dirOnly resolveSymlinks: (BOOL)resolveSymlinks
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_dir = 0L;
	_qstring = qt_QFileDialog_getExistingDirectory((qt_QString *) [dir toQString: &_qstring_dir], (qt_QWidget *) [parent qt], (char*) [name cString], (qt_QString *) [caption toQString: &_qstring_caption], (int)dirOnly, (int)resolveSymlinks);
	return [NSString fromQString: _qstring];
}

+ (NSArray *) getOpenFileNames: (NSString *)filter dir: (NSString *)dir parent: (QWidget *)parent name: (NSString *)name caption: (NSString *)caption selectedFilter: (NSString *)selectedFilter resolveSymlinks: (BOOL)resolveSymlinks
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_selectedFilter = 0L;
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_dir = 0L;
static qt_QString * _qstring_filter = 0L;
	_qlist = qt_QFileDialog_getOpenFileNames((qt_QString *) [filter toQString: &_qstring_filter], (qt_QString *) [dir toQString: &_qstring_dir], (qt_QWidget *) [parent qt], (char*) [name cString], (qt_QString *) [caption toQString: &_qstring_caption], (qt_QString*) [selectedFilter toQString: &_qstring_selectedFilter], (int)resolveSymlinks);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

+ setIconProvider: (QFileIconProvider*)arg1
{
	qt_QFileDialog_setIconProvider((qt_QFileIconProvider*) [arg1 qt]);
	return self;
}

+ (QFileIconProvider*) iconProvider
{
	return (QFileIconProvider*) [QtSupport objectForQtKey: qt_QFileDialog_iconProvider() withClass: [QFileIconProvider class] allocatedInObjcWorld: YES];
}

- addWidgets: (QLabel *)arg1 widget: (QWidget *)arg2 pushbutton: (QPushButton*)arg3
{
	qt_QFileDialog_addWidgets((qt_QFileDialog *)[self qt], (qt_QLabel *) [arg1 qt], (qt_QWidget *) [arg2 qt], (qt_QPushButton*) [arg3 qt]);
	return self;
}

- addToolButton: (QButton *)b separator: (BOOL)separator
{
	qt_QFileDialog_addToolButton((qt_QFileDialog *)[self qt], (qt_QButton *) [b qt], (int)separator);
	return self;
}

- addToolButton: (QButton *)b 
{
	qt_QFileDialog_addToolButton((qt_QFileDialog *)[self qt], (qt_QButton *) [b qt], 0);
	return self;
}

- addLeftWidget: (QWidget *)w
{
	qt_QFileDialog_addLeftWidget((qt_QFileDialog *)[self qt], (qt_QWidget *) [w qt]);
	return self;
}

- addRightWidget: (QWidget *)w
{
	qt_QFileDialog_addRightWidget((qt_QFileDialog *)[self qt], (qt_QWidget *) [w qt]);
	return self;
}

+ (int) AnyFile
{
	return (int) QFILEDIALOG_AnyFile;
}

+ (int) ExistingFile
{
	return (int) QFILEDIALOG_ExistingFile;
}

+ (int) Directory
{
	return (int) QFILEDIALOG_Directory;
}

+ (int) ExistingFiles
{
	return (int) QFILEDIALOG_ExistingFiles;
}

+ (int) DirectoryOnly
{
	return (int) QFILEDIALOG_DirectoryOnly;
}

+ (int) Detail
{
	return (int) QFILEDIALOG_Detail;
}

+ (int) List
{
	return (int) QFILEDIALOG_List;
}

+ (int) NoPreview
{
	return (int) QFILEDIALOG_NoPreview;
}

+ (int) Contents
{
	return (int) QFILEDIALOG_Contents;
}

+ (int) Info
{
	return (int) QFILEDIALOG_Info;
}

@end
