/***************************************************************************
                            KFileDetailView.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_KFileView.h>
#include <kdec/kde_KFileDetailView.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KFileDetailView.h>
#include <kdeobjc/KFileListViewItem.h>

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



@implementation  KFileDetailView


- initWithWidget: (QWidget *)parent name: (NSString *)name
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KFileDetailView((qt_QWidget *) [parent qt], (char*) [name cString])];
		[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_KFileDetailView((kde_KFileDetailView *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (QWidget*) widget
{
	return (QWidget*) [QtSupport objectForQtKey: kde_KFileDetailView_widget((kde_KFileDetailView *)[self qt]) withClass: [QWidget class] allocatedInObjcWorld: YES];
}

- clearView
{
	kde_KFileDetailView_clearView((kde_KFileDetailView *)[self qt]);
	return self;
}

- setAutoUpdate: (BOOL)arg1
{
	kde_KFileDetailView_setAutoUpdate((kde_KFileDetailView *)[self qt], (int)arg1);
	return self;
}

- setSelectionMode: (int)sm
{
	kde_KFileDetailView_setSelectionMode((kde_KFileDetailView *)[self qt], (int)sm);
	return self;
}

- updateView: (BOOL)arg1
{
	kde_KFileDetailView_updateView((kde_KFileDetailView *)[self qt], (int)arg1);
	return self;
}

- updateFileView: (KFileItem*)arg1
{
	kde_KFileDetailView_updateView1((kde_KFileDetailView *)[self qt], (kde_KFileItem*) [arg1 qt]);
	return self;
}

- removeFileItem: (KFileItem*)arg1
{
	kde_KFileDetailView_removeItem((kde_KFileDetailView *)[self qt], (kde_KFileItem*) [arg1 qt]);
	return self;
}

- listingCompleted
{
	kde_KFileDetailView_listingCompleted((kde_KFileDetailView *)[self qt]);
	return self;
}

- setSelected: (KFileItem*)arg1 bool: (BOOL)arg2
{
	kde_KFileDetailView_setSelected((kde_KFileDetailView *)[self qt], (kde_KFileItem*) [arg1 qt], (int)arg2);
	return self;
}

- (BOOL) isSelected: (KFileItem*)i
{
	return (BOOL) kde_KFileDetailView_isSelected((kde_KFileDetailView *)[self qt], (kde_KFileItem*) [i qt]);
}

- clearSelection
{
	kde_KFileDetailView_clearSelection((kde_KFileDetailView *)[self qt]);
	return self;
}

- selectAll
{
	kde_KFileDetailView_selectAll((kde_KFileDetailView *)[self qt]);
	return self;
}

- invertSelection
{
	kde_KFileDetailView_invertSelection((kde_KFileDetailView *)[self qt]);
	return self;
}

- setCurrentItem: (KFileItem*)arg1
{
	kde_KFileDetailView_setCurrentItem((kde_KFileDetailView *)[self qt], (kde_KFileItem*) [arg1 qt]);
	return self;
}

- (KFileItem*) currentFileItem
{
	return (KFileItem*) [QtSupport objectForQtKey: kde_KFileDetailView_currentFileItem((kde_KFileDetailView *)[self qt]) withClass: [KFileItem class] allocatedInObjcWorld: YES];
}

- (KFileItem*) firstFileItem
{
	return (KFileItem*) [QtSupport objectForQtKey: kde_KFileDetailView_firstFileItem((kde_KFileDetailView *)[self qt]) withClass: [KFileItem class] allocatedInObjcWorld: YES];
}

- (KFileItem*) nextItem: (KFileItem*)arg1
{
	return (KFileItem*) [QtSupport objectForQtKey: kde_KFileDetailView_nextItem((kde_KFileDetailView *)[self qt], (kde_KFileItem*) [arg1 qt]) withClass: [KFileItem class] allocatedInObjcWorld: YES];
}

- (KFileItem*) prevItem: (KFileItem*)arg1
{
	return (KFileItem*) [QtSupport objectForQtKey: kde_KFileDetailView_prevItem((kde_KFileDetailView *)[self qt], (kde_KFileItem*) [arg1 qt]) withClass: [KFileItem class] allocatedInObjcWorld: YES];
}

- insertFileItem: (KFileItem*)i
{
	kde_KFileDetailView_insertItem((kde_KFileDetailView *)[self qt], (kde_KFileItem*) [i qt]);
	return self;
}

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

- ensureItemVisible: (KFileItem*)arg1
{
	kde_KFileDetailView_ensureItemVisible((kde_KFileDetailView *)[self qt], (kde_KFileItem*) [arg1 qt]);
	return self;
}

- mimeTypeDeterminationFinished
{
	kde_KFileDetailView_mimeTypeDeterminationFinished((kde_KFileDetailView *)[self qt]);
	return self;
}

- determineIcon: (KFileListViewItem*)item
{
	kde_KFileDetailView_determineIcon((kde_KFileDetailView *)[self qt], (kde_KFileListViewItem*) [item qt]);
	return self;
}

- (QScrollView*) scrollWidget
{
	return (QScrollView*) [QtSupport objectForQtKey: kde_KFileDetailView_scrollWidget((kde_KFileDetailView *)[self qt]) withClass: [QScrollView class] allocatedInObjcWorld: YES];
}

- slotSelectionChanged
{
	kde_KFileDetailView_slotSelectionChanged((kde_KFileDetailView *)[self qt]);
	return self;
}

@end

@implementation KFileDetailView (KFileViewImplementation)

- addItemList: (NSArray *)list
{
static kde_KFileItemList * _qlist_list = 0L;
	kde_KFileView_addItemList(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItemList*) [list toKFileItemList: (void *)&_qlist_list]);
	return self;
}

- (QWidget*) widget
{
	return (QWidget*) [QtSupport objectForQtKey: kde_KFileView_widget(kde_KFileDetailView_KFileView([self qt])) withClass: [QWidget class] allocatedInObjcWorld: YES];
}

//- (QWidget*) widget
//{
//	return (QWidget*) [QtSupport objectForQtKey: kde_KFileView_widget1(kde_KFileDetailView_KFileView([self qt])) withClass: [QWidget class] allocatedInObjcWorld: YES];
//}

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

- setCurrentItem: (KFileItem*)item
{
	kde_KFileView_setCurrentItem1(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItem*) [item qt]);
	return self;
}

- (KFileItem*) currentFileItem
{
	return (KFileItem*) [QtSupport objectForQtKey: kde_KFileView_currentFileItem(kde_KFileDetailView_KFileView([self qt])) withClass: [KFileItem class] allocatedInObjcWorld: YES];
}

- clear
{
	kde_KFileView_clear(kde_KFileDetailView_KFileView([self qt]));
	return self;
}

- updateView: (BOOL)f
{
	kde_KFileView_updateView(kde_KFileDetailView_KFileView([self qt]), (int)f);
	return self;
}

- updateView
{
	kde_KFileView_updateView(kde_KFileDetailView_KFileView([self qt]), 1);
	return self;
}

- updateFileView: (KFileItem*)arg1
{
	kde_KFileView_updateView1(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItem*) [arg1 qt]);
	return self;
}

- removeFileItem: (KFileItem*)item
{
	kde_KFileView_removeItem(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItem*) [item qt]);
	return self;
}

- (int) sorting
{
	return (int) kde_KFileView_sorting(kde_KFileDetailView_KFileView([self qt]));
}

- setSorting: (int)sort
{
	kde_KFileView_setSorting(kde_KFileDetailView_KFileView([self qt]), (int)sort);
	return self;
}

- (BOOL) isReversed
{
	return (BOOL) kde_KFileView_isReversed(kde_KFileDetailView_KFileView([self qt]));
}

- sortReversed
{
	kde_KFileView_sortReversed(kde_KFileDetailView_KFileView([self qt]));
	return self;
}

- (unsigned int) count
{
	return (unsigned int) kde_KFileView_count(kde_KFileDetailView_KFileView([self qt]));
}

- (unsigned int) numFiles
{
	return (unsigned int) kde_KFileView_numFiles(kde_KFileDetailView_KFileView([self qt]));
}

- (unsigned int) numDirs
{
	return (unsigned int) kde_KFileView_numDirs(kde_KFileDetailView_KFileView([self qt]));
}

- setSelectionMode: (int)sm
{
	kde_KFileView_setSelectionMode(kde_KFileDetailView_KFileView([self qt]), (int)sm);
	return self;
}

- (int) selectionMode
{
	return (int) kde_KFileView_selectionMode(kde_KFileDetailView_KFileView([self qt]));
}

- setViewMode: (int)vm
{
	kde_KFileView_setViewMode(kde_KFileDetailView_KFileView([self qt]), (int)vm);
	return self;
}

- (int) viewMode
{
	return (int) kde_KFileView_viewMode(kde_KFileDetailView_KFileView([self qt]));
}

- (NSString *) viewName
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KFileView_viewName(kde_KFileDetailView_KFileView([self qt]));
	return [NSString fromQString: _qstring];
}

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

- setParentView: (KFileView*)parent
{
	kde_KFileView_setParentView(kde_KFileDetailView_KFileView([self qt]), (kde_KFileView*) [parent qt]);
	return self;
}

- insertFileItem: (KFileItem*)i
{
	kde_KFileView_insertItem(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItem*) [i qt]);
	return self;
}

- clearView
{
	kde_KFileView_clearView(kde_KFileDetailView_KFileView([self qt]));
	return self;
}

- ensureItemVisible: (KFileItem*)i
{
	kde_KFileView_ensureItemVisible(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItem*) [i qt]);
	return self;
}

- clearSelection
{
	kde_KFileView_clearSelection(kde_KFileDetailView_KFileView([self qt]));
	return self;
}

- selectAll
{
	kde_KFileView_selectAll(kde_KFileDetailView_KFileView([self qt]));
	return self;
}

- invertSelection
{
	kde_KFileView_invertSelection(kde_KFileDetailView_KFileView([self qt]));
	return self;
}

- setSelected: (KFileItem*)arg1 enable: (BOOL)enable
{
	kde_KFileView_setSelected(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItem*) [arg1 qt], (int)enable);
	return self;
}

- (BOOL) isSelected: (KFileItem*)arg1
{
	return (BOOL) kde_KFileView_isSelected(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItem*) [arg1 qt]);
}

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

- (NSArray *) items
{
static kde_KFileItemList * _qlist = 0L;
	_qlist = kde_KFileView_items(kde_KFileDetailView_KFileView([self qt]));
	return (NSArray *) [NSMutableArray arrayWithKFileItemList: _qlist];
}

- (KFileItem*) firstFileItem
{
	return (KFileItem*) [QtSupport objectForQtKey: kde_KFileView_firstFileItem(kde_KFileDetailView_KFileView([self qt])) withClass: [KFileItem class] allocatedInObjcWorld: YES];
}

- (KFileItem*) nextItem: (KFileItem*)arg1
{
	return (KFileItem*) [QtSupport objectForQtKey: kde_KFileView_nextItem(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItem*) [arg1 qt]) withClass: [KFileItem class] allocatedInObjcWorld: YES];
}

- (KFileItem*) prevItem: (KFileItem*)arg1
{
	return (KFileItem*) [QtSupport objectForQtKey: kde_KFileView_prevItem(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItem*) [arg1 qt]) withClass: [KFileItem class] allocatedInObjcWorld: YES];
}

- setOnlyDoubleClickSelectsFiles: (BOOL)enable
{
	kde_KFileView_setOnlyDoubleClickSelectsFiles(kde_KFileDetailView_KFileView([self qt]), (int)enable);
	return self;
}

- (BOOL) onlyDoubleClickSelectsFiles
{
	return (BOOL) kde_KFileView_onlyDoubleClickSelectsFiles(kde_KFileDetailView_KFileView([self qt]));
}

- (BOOL) updateNumbers: (KFileItem*)i
{
	return (BOOL) kde_KFileView_updateNumbers(kde_KFileDetailView_KFileView([self qt]), (kde_KFileItem*) [i qt]);
}

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

- (KFileViewSignaler*) signaler
{
	return (KFileViewSignaler*) [QtSupport objectForQtKey: kde_KFileView_signaler(kde_KFileDetailView_KFileView([self qt])) withClass: [KFileViewSignaler class] allocatedInObjcWorld: YES];
}

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

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

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

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

+ (NSString *) sortingKey: (NSString *)value isDir: (BOOL)isDir sortSpec: (int)sortSpec
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_value = 0L;
	_qstring = kde_KFileView_sortingKey((qt_QString *) [value toQString: &_qstring_value], (int)isDir, (int)sortSpec);
	return [NSString fromQString: _qstring];
}

@end
