/***************************************************************************
                            KDirWatch.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_KDirWatch.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KDirWatch.h>

@implementation  KDirWatch


- initWithObject: (QObject *)parent name: (NSString *)name
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KDirWatch((qt_QObject *) [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_KDirWatch(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 parent] == nil) {
			kde_del_KDirWatch((kde_KDirWatch *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- addDir: (NSString *)path watchFiles: (BOOL)watchFiles recursive: (BOOL)recursive
{
static qt_QString * _qstring_path = 0L;
	kde_KDirWatch_addDir((kde_KDirWatch *)[self qt], (qt_QString *) [path toQString: &_qstring_path], (int)watchFiles, (int)recursive);
	return self;
}

- addDir: (NSString *)path 
{
static qt_QString * _qstring_path = 0L;
	kde_KDirWatch_addDir((kde_KDirWatch *)[self qt], (qt_QString *) [path toQString: &_qstring_path], 0, 0);
	return self;
}

- addFile: (NSString *)file
{
static qt_QString * _qstring_file = 0L;
	kde_KDirWatch_addFile((kde_KDirWatch *)[self qt], (qt_QString *) [file toQString: &_qstring_file]);
	return self;
}

- (NSDate *) ctime: (NSString *)path
{
static qt_QDateTime * _qdate = 0L;
static qt_QString * _qstring_path = 0L;
	_qdate = kde_KDirWatch_ctime((kde_KDirWatch *)[self qt], (qt_QString *) [path toQString: &_qstring_path]);
	return (NSDate *) [[NSDate alloc] initWithQDateTime: _qdate];
}

- removeDir: (NSString *)path
{
static qt_QString * _qstring_path = 0L;
	kde_KDirWatch_removeDir((kde_KDirWatch *)[self qt], (qt_QString *) [path toQString: &_qstring_path]);
	return self;
}

- removeFile: (NSString *)file
{
static qt_QString * _qstring_file = 0L;
	kde_KDirWatch_removeFile((kde_KDirWatch *)[self qt], (qt_QString *) [file toQString: &_qstring_file]);
	return self;
}

- (BOOL) stopDirScan: (NSString *)path
{
static qt_QString * _qstring_path = 0L;
	return (BOOL) kde_KDirWatch_stopDirScan((kde_KDirWatch *)[self qt], (qt_QString *) [path toQString: &_qstring_path]);
}

- (BOOL) restartDirScan: (NSString *)path
{
static qt_QString * _qstring_path = 0L;
	return (BOOL) kde_KDirWatch_restartDirScan((kde_KDirWatch *)[self qt], (qt_QString *) [path toQString: &_qstring_path]);
}

- startScan: (BOOL)notify skippedToo: (BOOL)skippedToo
{
	kde_KDirWatch_startScan((kde_KDirWatch *)[self qt], (int)notify, (int)skippedToo);
	return self;
}

- startScan
{
	kde_KDirWatch_startScan((kde_KDirWatch *)[self qt], 0, 0);
	return self;
}

- stopScan
{
	kde_KDirWatch_stopScan((kde_KDirWatch *)[self qt]);
	return self;
}

- (BOOL) isStopped
{
	return (BOOL) kde_KDirWatch_isStopped((kde_KDirWatch *)[self qt]);
}

- (BOOL) contains: (NSString *)path
{
static qt_QString * _qstring_path = 0L;
	return (BOOL) kde_KDirWatch_contains((kde_KDirWatch *)[self qt], (qt_QString *) [path toQString: &_qstring_path]);
}

//- setDirCreated: (NSString *)arg1
//{
//static qt_QString * _qstring_arg1 = 0L;
//	kde_KDirWatch_setDirCreated((kde_KDirWatch *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
//	return self;
//}

//- setDirDirty: (NSString *)arg1
//{
//static qt_QString * _qstring_arg1 = 0L;
//	kde_KDirWatch_setDirDirty((kde_KDirWatch *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
//	return self;
//}

//- setDirDeleted: (NSString *)arg1
//{
//static qt_QString * _qstring_arg1 = 0L;
//	kde_KDirWatch_setDirDeleted((kde_KDirWatch *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
//	return self;
//}

//- setFileCreated: (NSString *)arg1
//{
//static qt_QString * _qstring_arg1 = 0L;
//	kde_KDirWatch_setFileCreated((kde_KDirWatch *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
//	return self;
//}

//- setFileDirty: (NSString *)arg1
//{
//static qt_QString * _qstring_arg1 = 0L;
//	kde_KDirWatch_setFileDirty((kde_KDirWatch *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
//	return self;
//}

//- setFileDeleted: (NSString *)arg1
//{
//static qt_QString * _qstring_arg1 = 0L;
//	kde_KDirWatch_setFileDeleted((kde_KDirWatch *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
//	return self;
//}

+ statistics
{
	kde_KDirWatch_statistics();
	return self;
}

+ (KDirWatch*) self
{
	return (KDirWatch*) [QtSupport objectForQtKey: kde_KDirWatch_self() withClass: [KDirWatch class] allocatedInObjcWorld: YES];
}

@end
