/***************************************************************************
                            KDirOperator.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_KDirOperator.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KDirOperator.h>
#include <kdeobjc/KDirLister.h>
#include <qtobjc/QPoint.h>

#include <kdeobjc/KConfig.h>
#include <kdeobjc/KFileItem.h>
#include <kdeobjc/KFileView.h>
#include <kdeobjc/KURL.h>


@implementation  KDirOperator


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

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

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

- (BOOL) showHiddenFiles
{
	return (BOOL) kde_KDirOperator_showHiddenFiles((kde_KDirOperator *)[self qt]);
}

- close
{
	kde_KDirOperator_close((kde_KDirOperator *)[self qt]);
	return self;
}

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

- (NSString *) nameFilter
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KDirOperator_nameFilter((kde_KDirOperator *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setMimeFilter: (NSArray *)mimetypes
{
static qt_QStringList * _qlist_mimetypes = 0L;
	kde_KDirOperator_setMimeFilter((kde_KDirOperator *)[self qt], (qt_QStringList*) [mimetypes toQStringList: (void *)&_qlist_mimetypes]);
	return self;
}

- (NSArray *) mimeFilter
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KDirOperator_mimeFilter((kde_KDirOperator *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- clearFilter
{
	kde_KDirOperator_clearFilter((kde_KDirOperator *)[self qt]);
	return self;
}

- (KURL*) url
{
	return (KURL*) [QtSupport objectForQtKey: kde_KDirOperator_url((kde_KDirOperator *)[self qt]) withClass: [KURL class] allocatedInObjcWorld: YES];
}

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

- setCurrentItem: (NSString *)filename
{
static qt_QString * _qstring_filename = 0L;
	kde_KDirOperator_setCurrentItem((kde_KDirOperator *)[self qt], (qt_QString *) [filename toQString: &_qstring_filename]);
	return self;
}

- setView: (KFileView*)view
{
	kde_KDirOperator_setView((kde_KDirOperator *)[self qt], (kde_KFileView*) [view qt]);
	return self;
}

- (KFileView*) view
{
	return (KFileView*) [QtSupport objectForQtKey: kde_KDirOperator_view((kde_KDirOperator *)[self qt]) withClass: [KFileView class] allocatedInObjcWorld: YES];
}

- (QWidget*) viewWidget
{
	return (QWidget*) [QtSupport objectForQtKey: kde_KDirOperator_viewWidget((kde_KDirOperator *)[self qt]) withClass: [QWidget class] allocatedInObjcWorld: YES];
}

- setPredefinedView: (int)view
{
	kde_KDirOperator_setView1((kde_KDirOperator *)[self qt], (int)view);
	return self;
}

- setSorting: (int)arg1
{
	kde_KDirOperator_setSorting((kde_KDirOperator *)[self qt], (int)arg1);
	return self;
}

- (int) sorting
{
	return (int) kde_KDirOperator_sorting((kde_KDirOperator *)[self qt]);
}

- (BOOL) isRoot
{
	return (BOOL) kde_KDirOperator_isRoot((kde_KDirOperator *)[self qt]);
}

- (KDirLister*) dirLister
{
	return (KDirLister*) [QtSupport objectForQtKey: kde_KDirOperator_dirLister((kde_KDirOperator *)[self qt]) withClass: [KDirLister class] allocatedInObjcWorld: YES];
}

- (KProgress*) progressBar
{
	return (KProgress*) [QtSupport objectForQtKey: kde_KDirOperator_progressBar((kde_KDirOperator *)[self qt]) withClass: [KProgress class] allocatedInObjcWorld: YES];
}

- setMode: (int)m
{
	kde_KDirOperator_setMode((kde_KDirOperator *)[self qt], (int)m);
	return self;
}

- (int) mode
{
	return (int) kde_KDirOperator_mode((kde_KDirOperator *)[self qt]);
}

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

- (NSArray *) selectedItems
{
static kde_KFileItemList * _qlist = 0L;
	_qlist = kde_KDirOperator_selectedItems((kde_KDirOperator *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithKFileItemList: _qlist];
}

- (BOOL) isSelected: (KFileItem*)item
{
	return (BOOL) kde_KDirOperator_isSelected((kde_KDirOperator *)[self qt], (kde_KFileItem*) [item qt]);
}

- (int) numDirs
{
	return (int) kde_KDirOperator_numDirs((kde_KDirOperator *)[self qt]);
}

- (int) numFiles
{
	return (int) kde_KDirOperator_numFiles((kde_KDirOperator *)[self qt]);
}

- (KCompletion*) completionObject
{
	return (KCompletion*) [QtSupport objectForQtKey: kde_KDirOperator_completionObject((kde_KDirOperator *)[self qt]) withClass: [KCompletion class] allocatedInObjcWorld: YES];
}

- (KCompletion*) dirCompletionObject
{
	return (KCompletion*) [QtSupport objectForQtKey: kde_KDirOperator_dirCompletionObject((kde_KDirOperator *)[self qt]) withClass: [KCompletion class] allocatedInObjcWorld: YES];
}

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

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

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

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

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

- setOnlyDoubleClickSelectsFiles: (BOOL)enable
{
	kde_KDirOperator_setOnlyDoubleClickSelectsFiles((kde_KDirOperator *)[self qt], (int)enable);
	return self;
}

- (BOOL) onlyDoubleClickSelectsFiles
{
	return (BOOL) kde_KDirOperator_onlyDoubleClickSelectsFiles((kde_KDirOperator *)[self qt]);
}

- (BOOL) mkdir: (NSString *)directory enterDirectory: (BOOL)enterDirectory
{
static qt_QString * _qstring_directory = 0L;
	return (BOOL) kde_KDirOperator_mkdir((kde_KDirOperator *)[self qt], (qt_QString *) [directory toQString: &_qstring_directory], (int)enterDirectory);
}

- (BOOL) mkdir: (NSString *)directory 
{
static qt_QString * _qstring_directory = 0L;
	return (BOOL) kde_KDirOperator_mkdir((kde_KDirOperator *)[self qt], (qt_QString *) [directory toQString: &_qstring_directory], 1);
}

- (DeleteJob*) del: (NSArray *)items ask: (BOOL)ask showProgress: (BOOL)showProgress
{
static kde_KFileItemList * _qlist_items = 0L;
	return (DeleteJob*) [QtSupport objectForQtKey: kde_KDirOperator_del((kde_KDirOperator *)[self qt], (kde_KFileItemList*) [items toKFileItemList: (void *)&_qlist_items], (int)ask, (int)showProgress) withClass: [DeleteJob class] allocatedInObjcWorld: YES];
}

- (DeleteJob*) del: (NSArray *)items 
{
static kde_KFileItemList * _qlist_items = 0L;
	return (DeleteJob*) [QtSupport objectForQtKey: kde_KDirOperator_del((kde_KDirOperator *)[self qt], (kde_KFileItemList*) [items toKFileItemList: (void *)&_qlist_items], 1, 1) withClass: [DeleteJob class] allocatedInObjcWorld: YES];
}

- clearHistory
{
	kde_KDirOperator_clearHistory((kde_KDirOperator *)[self qt]);
	return self;
}

- setEnableDirHighlighting: (BOOL)enable
{
	kde_KDirOperator_setEnableDirHighlighting((kde_KDirOperator *)[self qt], (int)enable);
	return self;
}

- (BOOL) dirHighlighting
{
	return (BOOL) kde_KDirOperator_dirHighlighting((kde_KDirOperator *)[self qt]);
}

- (BOOL) dirOnlyMode
{
	return (BOOL) kde_KDirOperator_dirOnlyMode((kde_KDirOperator *)[self qt]);
}

- back
{
	kde_KDirOperator_back((kde_KDirOperator *)[self qt]);
	return self;
}

- forward
{
	kde_KDirOperator_forward((kde_KDirOperator *)[self qt]);
	return self;
}

- home
{
	kde_KDirOperator_home((kde_KDirOperator *)[self qt]);
	return self;
}

- cdUp
{
	kde_KDirOperator_cdUp((kde_KDirOperator *)[self qt]);
	return self;
}

- updateDir
{
	kde_KDirOperator_updateDir((kde_KDirOperator *)[self qt]);
	return self;
}

- rereadDir
{
	kde_KDirOperator_rereadDir((kde_KDirOperator *)[self qt]);
	return self;
}

- mkdir
{
	kde_KDirOperator_mkdir1((kde_KDirOperator *)[self qt]);
	return self;
}

- deleteSelected
{
	kde_KDirOperator_deleteSelected((kde_KDirOperator *)[self qt]);
	return self;
}

- updateSelectionDependentActions
{
	kde_KDirOperator_updateSelectionDependentActions((kde_KDirOperator *)[self qt]);
	return self;
}

- (NSString *) makeCompletion: (NSString *)arg1
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_arg1 = 0L;
	_qstring = kde_KDirOperator_makeCompletion((kde_KDirOperator *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
	return [NSString fromQString: _qstring];
}

- (NSString *) makeDirCompletion: (NSString *)arg1
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_arg1 = 0L;
	_qstring = kde_KDirOperator_makeDirCompletion((kde_KDirOperator *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
	return [NSString fromQString: _qstring];
}

+ (BOOL) dirOnlyMode: (unsigned int)mode
{
	return (BOOL) kde_KDirOperator_dirOnlyMode1((unsigned int)mode);
}

- (KFileView*) createView: (QWidget *)parent view: (int)view
{
	return (KFileView*) [QtSupport objectForQtKey: kde_KDirOperator_createView((kde_KDirOperator *)[self qt], (qt_QWidget *) [parent qt], (int)view) withClass: [KFileView class] allocatedInObjcWorld: YES];
}

- setDirLister: (KDirLister*)lister
{
	kde_KDirOperator_setDirLister((kde_KDirOperator *)[self qt], (kde_KDirLister*) [lister qt]);
	return self;
}

- setupActions
{
	kde_KDirOperator_setupActions((kde_KDirOperator *)[self qt]);
	return self;
}

- updateSortActions
{
	kde_KDirOperator_updateSortActions((kde_KDirOperator *)[self qt]);
	return self;
}

- updateViewActions
{
	kde_KDirOperator_updateViewActions((kde_KDirOperator *)[self qt]);
	return self;
}

- setupMenu
{
	kde_KDirOperator_setupMenu((kde_KDirOperator *)[self qt]);
	return self;
}

- prepareCompletionObjects
{
	kde_KDirOperator_prepareCompletionObjects((kde_KDirOperator *)[self qt]);
	return self;
}

- (BOOL) checkPreviewSupport
{
	return (BOOL) kde_KDirOperator_checkPreviewSupport((kde_KDirOperator *)[self qt]);
}

- resetCursor
{
	kde_KDirOperator_resetCursor((kde_KDirOperator *)[self qt]);
	return self;
}

- pathChanged
{
	kde_KDirOperator_pathChanged((kde_KDirOperator *)[self qt]);
	return self;
}

- insertNewFiles: (NSArray *)newone
{
static kde_KFileItemList * _qlist_newone = 0L;
	kde_KDirOperator_insertNewFiles((kde_KDirOperator *)[self qt], (kde_KFileItemList*) [newone toKFileItemList: (void *)&_qlist_newone]);
	return self;
}

- itemDeleted: (KFileItem*)arg1
{
	kde_KDirOperator_itemDeleted((kde_KDirOperator *)[self qt], (kde_KFileItem*) [arg1 qt]);
	return self;
}

- selectDir: (KFileItem*)item
{
	kde_KDirOperator_selectDir((kde_KDirOperator *)[self qt], (kde_KFileItem*) [item qt]);
	return self;
}

- selectFile: (KFileItem*)item
{
	kde_KDirOperator_selectFile((kde_KDirOperator *)[self qt], (kde_KFileItem*) [item qt]);
	return self;
}

- highlightFile: (KFileItem*)i
{
	kde_KDirOperator_highlightFile((kde_KDirOperator *)[self qt], (kde_KFileItem*) [i qt]);
	return self;
}

- activatedMenu: (KFileItem*)arg1 pos: (QPoint*)pos
{
	kde_KDirOperator_activatedMenu((kde_KDirOperator *)[self qt], (kde_KFileItem*) [arg1 qt], (qt_QPoint*) [pos qt]);
	return self;
}

- sortByName
{
	kde_KDirOperator_sortByName((kde_KDirOperator *)[self qt]);
	return self;
}

- sortBySize
{
	kde_KDirOperator_sortBySize((kde_KDirOperator *)[self qt]);
	return self;
}

- sortByDate
{
	kde_KDirOperator_sortByDate((kde_KDirOperator *)[self qt]);
	return self;
}

- sortReversed
{
	kde_KDirOperator_sortReversed((kde_KDirOperator *)[self qt]);
	return self;
}

- toggleDirsFirst
{
	kde_KDirOperator_toggleDirsFirst((kde_KDirOperator *)[self qt]);
	return self;
}

- toggleIgnoreCase
{
	kde_KDirOperator_toggleIgnoreCase((kde_KDirOperator *)[self qt]);
	return self;
}

- slotCompletionMatch: (NSString *)match
{
static qt_QString * _qstring_match = 0L;
	kde_KDirOperator_slotCompletionMatch((kde_KDirOperator *)[self qt], (qt_QString *) [match toQString: &_qstring_match]);
	return self;
}

@end
