/***************************************************************************
                            QDataBrowser.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_QDataBrowser.h>
#include <qtobjc/QDataBrowser.h>
#include <qtobjc/QSqlCursor.h>
#include <qtobjc/QSqlError.h>
#include <qtobjc/QSqlForm.h>
#include <qtobjc/QSqlIndex.h>


@implementation  QDataBrowser


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

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

- (int) boundary
{
	return (int) qt_QDataBrowser_boundary((qt_QDataBrowser *)[self qt]);
}

- setBoundaryChecking: (BOOL)active
{
	qt_QDataBrowser_setBoundaryChecking((qt_QDataBrowser *)[self qt], (int)active);
	return self;
}

- (BOOL) boundaryChecking
{
	return (BOOL) qt_QDataBrowser_boundaryChecking((qt_QDataBrowser *)[self qt]);
}

- setSort: (QSqlIndex*)sort
{
	qt_QDataBrowser_setSort((qt_QDataBrowser *)[self qt], (qt_QSqlIndex*) [sort qt]);
	return self;
}

- setSortWithStringList: (NSArray *)sort
{
static qt_QStringList * _qlist_sort = 0L;
	qt_QDataBrowser_setSort1((qt_QDataBrowser *)[self qt], (qt_QStringList*) [sort toQStringList: (void *)&_qlist_sort]);
	return self;
}

- (NSArray *) sort
{
static qt_QStringList * _qlist = 0L;
	_qlist = qt_QDataBrowser_sort((qt_QDataBrowser *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

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

- (NSString *) filter
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QDataBrowser_filter((qt_QDataBrowser *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setSqlCursor: (QSqlCursor*)cursor autoDelete: (BOOL)autoDelete
{
	qt_QDataBrowser_setSqlCursor((qt_QDataBrowser *)[self qt], (qt_QSqlCursor*) [cursor qt], (int)autoDelete);
	return self;
}

- setSqlCursor: (QSqlCursor*)cursor 
{
	qt_QDataBrowser_setSqlCursor((qt_QDataBrowser *)[self qt], (qt_QSqlCursor*) [cursor qt], 0);
	return self;
}

- (QSqlCursor*) sqlCursor
{
	return (QSqlCursor*) [QtSupport objectForQtKey: qt_QDataBrowser_sqlCursor((qt_QDataBrowser *)[self qt]) withClass: [QSqlCursor class] allocatedInObjcWorld: YES];
}

- setForm: (QSqlForm*)form
{
	qt_QDataBrowser_setForm((qt_QDataBrowser *)[self qt], (qt_QSqlForm*) [form qt]);
	return self;
}

- (QSqlForm*) form
{
	return (QSqlForm*) [QtSupport objectForQtKey: qt_QDataBrowser_form((qt_QDataBrowser *)[self qt]) withClass: [QSqlForm class] allocatedInObjcWorld: YES];
}

- setConfirmEdits: (BOOL)confirm
{
	qt_QDataBrowser_setConfirmEdits((qt_QDataBrowser *)[self qt], (int)confirm);
	return self;
}

- setConfirmInsert: (BOOL)confirm
{
	qt_QDataBrowser_setConfirmInsert((qt_QDataBrowser *)[self qt], (int)confirm);
	return self;
}

- setConfirmUpdate: (BOOL)confirm
{
	qt_QDataBrowser_setConfirmUpdate((qt_QDataBrowser *)[self qt], (int)confirm);
	return self;
}

- setConfirmDelete: (BOOL)confirm
{
	qt_QDataBrowser_setConfirmDelete((qt_QDataBrowser *)[self qt], (int)confirm);
	return self;
}

- setConfirmCancels: (BOOL)confirm
{
	qt_QDataBrowser_setConfirmCancels((qt_QDataBrowser *)[self qt], (int)confirm);
	return self;
}

- (BOOL) confirmEdits
{
	return (BOOL) qt_QDataBrowser_confirmEdits((qt_QDataBrowser *)[self qt]);
}

- (BOOL) confirmInsert
{
	return (BOOL) qt_QDataBrowser_confirmInsert((qt_QDataBrowser *)[self qt]);
}

- (BOOL) confirmUpdate
{
	return (BOOL) qt_QDataBrowser_confirmUpdate((qt_QDataBrowser *)[self qt]);
}

- (BOOL) confirmDelete
{
	return (BOOL) qt_QDataBrowser_confirmDelete((qt_QDataBrowser *)[self qt]);
}

- (BOOL) confirmCancels
{
	return (BOOL) qt_QDataBrowser_confirmCancels((qt_QDataBrowser *)[self qt]);
}

- setReadOnly: (BOOL)active
{
	qt_QDataBrowser_setReadOnly((qt_QDataBrowser *)[self qt], (int)active);
	return self;
}

- (BOOL) isReadOnly
{
	return (BOOL) qt_QDataBrowser_isReadOnly((qt_QDataBrowser *)[self qt]);
}

- setAutoEdit: (BOOL)autoEdit
{
	qt_QDataBrowser_setAutoEdit((qt_QDataBrowser *)[self qt], (int)autoEdit);
	return self;
}

- (BOOL) autoEdit
{
	return (BOOL) qt_QDataBrowser_autoEdit((qt_QDataBrowser *)[self qt]);
}

- (BOOL) seek: (int)i relative: (BOOL)relative
{
	return (BOOL) qt_QDataBrowser_seek((qt_QDataBrowser *)[self qt], (int)i, (int)relative);
}

- (BOOL) seek: (int)i 
{
	return (BOOL) qt_QDataBrowser_seek((qt_QDataBrowser *)[self qt], (int)i, 0);
}

- refresh
{
	qt_QDataBrowser_refresh((qt_QDataBrowser *)[self qt]);
	return self;
}

- insert
{
	qt_QDataBrowser_insert((qt_QDataBrowser *)[self qt]);
	return self;
}

- update
{
	qt_QDataBrowser_update((qt_QDataBrowser *)[self qt]);
	return self;
}

- del
{
	qt_QDataBrowser_del((qt_QDataBrowser *)[self qt]);
	return self;
}

- first
{
	qt_QDataBrowser_first((qt_QDataBrowser *)[self qt]);
	return self;
}

- last
{
	qt_QDataBrowser_last((qt_QDataBrowser *)[self qt]);
	return self;
}

- next
{
	qt_QDataBrowser_next((qt_QDataBrowser *)[self qt]);
	return self;
}

- prev
{
	qt_QDataBrowser_prev((qt_QDataBrowser *)[self qt]);
	return self;
}

- readFields
{
	qt_QDataBrowser_readFields((qt_QDataBrowser *)[self qt]);
	return self;
}

- writeFields
{
	qt_QDataBrowser_writeFields((qt_QDataBrowser *)[self qt]);
	return self;
}

- clearValues
{
	qt_QDataBrowser_clearValues((qt_QDataBrowser *)[self qt]);
	return self;
}

- updateBoundary
{
	qt_QDataBrowser_updateBoundary((qt_QDataBrowser *)[self qt]);
	return self;
}

- (BOOL) insertCurrent
{
	return (BOOL) qt_QDataBrowser_insertCurrent((qt_QDataBrowser *)[self qt]);
}

- (BOOL) updateCurrent
{
	return (BOOL) qt_QDataBrowser_updateCurrent((qt_QDataBrowser *)[self qt]);
}

- (BOOL) deleteCurrent
{
	return (BOOL) qt_QDataBrowser_deleteCurrent((qt_QDataBrowser *)[self qt]);
}

- (BOOL) currentEdited
{
	return (BOOL) qt_QDataBrowser_currentEdited((qt_QDataBrowser *)[self qt]);
}

- (int) confirmEdit: (int)m
{
	return (int) qt_QDataBrowser_confirmEdit((qt_QDataBrowser *)[self qt], (int)m);
}

- (int) confirmCancel: (int)m
{
	return (int) qt_QDataBrowser_confirmCancel((qt_QDataBrowser *)[self qt], (int)m);
}

- handleError: (QSqlError*)error
{
	qt_QDataBrowser_handleError((qt_QDataBrowser *)[self qt], (qt_QSqlError*) [error qt]);
	return self;
}

+ (int) Unknown
{
	return (int) QDATABROWSER_Unknown;
}

+ (int) None
{
	return (int) QDATABROWSER_None;
}

+ (int) BeforeBeginning
{
	return (int) QDATABROWSER_BeforeBeginning;
}

+ (int) Beginning
{
	return (int) QDATABROWSER_Beginning;
}

+ (int) End
{
	return (int) QDATABROWSER_End;
}

+ (int) AfterEnd
{
	return (int) QDATABROWSER_AfterEnd;
}

@end
