#include "Airport.h"
#include "regExp.h"
#include "Dict.h"
#include "AutoCompleteComBoxWidget.h"
#include "CheckComboBoxWidget.h"

#include "charcode.h"

QX_REGISTER_CPP_USER(Airport)

namespace qx {

    template <>
    void register_class(QxClass<Airport> & t)
    {
        qx::IxDataMember * pData = NULL; Q_UNUSED(pData);
        qx::IxSqlRelation * pRelation = NULL; Q_UNUSED(pRelation);
        qx::IxFunction * pFct = NULL; Q_UNUSED(pFct);
        qx::IxValidator * pValidator = NULL; Q_UNUSED(pValidator);

        t.setName("T_CM_AIRPORT");

        pData = t.id(& Airport::m_ID, "ID", 0);
        pData->setDescription("编号");
        pData->setAutoIncrement(true);

        pData = t.data(& Airport::m_NAME, "NAME", 0, true, true);
        pData->setDescription("名称");
        pData->setRequired(true);

        pData = t.data(& Airport::m_LONGITUDE, "LONGITUDE", 0, true, true);
        pData->setDescription("经度");
        pData->setMaxValue(180.0);
        pData->setMinValue(-180.0);
        pData->setPrecision(6);    //默认即是6位

        pData = t.data(& Airport::m_LATITUDE, "LATITUDE", 0, true, true);
        pData->setDescription("纬度");
        pData->setMaxValue(90.0);
        pData->setMinValue(-90.0);

        pData = t.data(& Airport::m_HEIGHT, "HEIGHT", 0, true, true);
        pData->setDescription("高度");
        pData->setPropertyBag("regExp",REGEXP_DOUBLE(4,2));

        pData = t.data(& Airport::m_NATION, "NATION", 0, true, true);
        pData->setDescription("国别");
        pData->setPropertyBag("dict",Dict::nationDict);
//        pData->setPropertyBag("type",AutoCompleteComBoxWidget::type);
        pData->setPropertyBag("type",CheckComboBoxWidget::type);

        pData = t.data(& Airport::m_ISDELETE, "ISDELETE", 0, true, true);
        pData->setDescription("是否删除");
        pData->setPropertyBag("notShow",true);
        pData->setPropertyBag("notInput",true);
        qx::QxSoftDelete SoftDelete;
        SoftDelete.setColumnName("ISDELETE");
        SoftDelete.setMode(qx::QxSoftDelete::mode_flag);
        t.setSoftDelete(SoftDelete);

        pData = t.data(& Airport::m_IMPORTTIME, "IMPORTTIME", 0, true, true);
        pData->setDescription("更新时间");
        pData->setPropertyBag("notInput",true);
        pData->setPropertyBag("notEditAble",true);

        pData = t.data(& Airport::m_NOTE, "NOTE", 0, true, true);
        pData->setDescription("备注");

        qx::QxValidatorX<Airport> * pAllValidator = t.getAllValidator(); Q_UNUSED(pAllValidator);
    }

} // namespace qx

Airport::Airport() : m_ID(0.0), m_LONGITUDE(0.0), m_LATITUDE(0.0), m_HEIGHT(0.0) { ; }

Airport::Airport(const double & id) : m_ID(id), m_LONGITUDE(0.0), m_LATITUDE(0.0), m_HEIGHT(0.0) { ; }

Airport::~Airport() { ; }

double Airport::getID() const { return m_ID; }

QString Airport::getNAME() const { return m_NAME; }

double Airport::getLONGITUDE() const { return m_LONGITUDE; }

double Airport::getLATITUDE() const { return m_LATITUDE; }

double Airport::getHEIGHT() const { return m_HEIGHT; }

QString Airport::getNATION() const{ return m_NATION; }

QString Airport::getISDELETE() const { return m_ISDELETE; }

QDateTime Airport::getIMPORTTIME() const { return m_IMPORTTIME; }

QString Airport::getNOTE() const { return m_NOTE; }

void Airport::setID(const double & val) { m_ID = val; }

void Airport::setNAME(const QString & val) { m_NAME = val; }

void Airport::setLONGITUDE(const double & val) { m_LONGITUDE = val; }

void Airport::setLATITUDE(const double & val) { m_LATITUDE = val; }

void Airport::setHEIGHT(const double & val) { m_HEIGHT = val; }

void Airport::setNATION(const QString & val) { m_NATION = val; }

void Airport::setISDELETE(const QString & val) { m_ISDELETE = val; }

void Airport::setIMPORTTIME(const QDateTime & val) { m_IMPORTTIME = val; }

void Airport::setNOTE(const QString & val) { m_NOTE = val; }

