/***************************************************************************
                            QSqlField.cpp -  description
                             -------------------
    begin                : Wed Nov 21 17:05:56 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 17:05:56 2001, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
***************************************************************************/

#define _BOOL_H_
#include <qsqlfield.h>
#include <qstring.h>
#include <qcstring.h>

#include <qtjava/QtSupport.h>
#include <qtjava/QSqlField.h>

class QSqlFieldJBridge : public QSqlField
{
public:
	QSqlFieldJBridge(const QString& fieldName, QVariant::Type type) : QSqlField(fieldName, type) {}
	QSqlFieldJBridge(const QSqlField& other) : QSqlField(other) {}
	~QSqlFieldJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlField_newQSqlField__Ljava_lang_String_2I(JNIEnv *env, jobject obj, jstring fieldName, jint type)
{
static QString * _qstring_fieldName = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QSqlFieldJBridge((QString&) * (QString *) QtSupport::toQString(env, fieldName, &_qstring_fieldName), (QVariant::Type) type));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlField_newQSqlField__(JNIEnv *env, jobject obj)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QSqlFieldJBridge(QString::null, QVariant::Invalid));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlField_newQSqlField__Lorg_kde_qt_QSqlField_2(JNIEnv *env, jobject obj, jobject other)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QSqlFieldJBridge((QSqlField&) *(QSqlField *) QtSupport::getQt(env, other)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlField_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj)) {
		delete (QSqlField*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlField_setValue(JNIEnv *env, jobject obj, jobject value)
{
	((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->setValue((QVariant&) *(QVariant *) QtSupport::getQt(env, value));
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QSqlField_value(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new  QVariant (((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->value()), "org.kde.qt.QVariant", TRUE);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlField_setName(JNIEnv *env, jobject obj, jstring name)
{
static QString * _qstring_name = 0;
	((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->setName((QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name));
	return;
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QSqlField_name(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->name();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlField_setNull(JNIEnv *env, jobject obj)
{
	((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->setNull();
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QSqlField_isNull(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->isNull();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlField_setReadOnly(JNIEnv *env, jobject obj, jboolean readOnly)
{
	((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->setReadOnly((bool) readOnly);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QSqlField_isReadOnly(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->isReadOnly();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlField_clear__Z(JNIEnv *env, jobject obj, jboolean nullify)
{
	((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->clear((bool) nullify);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlField_clear__(JNIEnv *env, jobject obj)
{
	((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->clear(TRUE);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QSqlField_type(JNIEnv *env, jobject obj)
{
	return (jint) ((QSqlFieldJBridge*) QtSupport::getQt(env, obj))->type();
}

