#include "attrdefine.h" class PcbCamAttrDefineData : public QSharedData { public: PcbCamAttrDefineData() { } PcbCamAttrDefineData(const PcbCamAttrDefineData &other): QSharedData(other), dataType(other.dataType), name(other.name), prompt(other.prompt), entity(other.entity), defaultValue(other.defaultValue), minLength(other.minLength), maxLength(other.maxLength), options(other.options), deleted(other.deleted), units(other.units), index(other.index) { } ~PcbCamAttrDefineData() { } //数据类型 PcbCamAttrDefine::DataType dataType {PcbCamAttrDefine::Text}; //属性名称 QString name; //属性标题 QString prompt; //属性适用范围 PcbCamAttrDefine::Entity entity {PcbCamAttrDefine::Feature}; //默认值 QVariant defaultValue; //最小长度 uint minLength {0}; //最大长度 uint maxLength {100}; //选项列表 QStringList options; //暂时不知道干什么用的,规范文档里描述如下: //A semi colon (;) separated list of the values YES and NO.This //corresponds to the list of options, possibly causing an option to be //deleted (YES value) QStringList deleted; //属性单位 PcbCamAttrDefine::Units units {PcbCamAttrDefine::NoUnits}; //排序 int index {0}; }; PcbCamAttrDefine::PcbCamAttrDefine() : d(new PcbCamAttrDefineData) { } PcbCamAttrDefine::PcbCamAttrDefine(const PcbCamAttrDefine &rhs) : d(rhs.d) { } PcbCamAttrDefine &PcbCamAttrDefine::operator=(const PcbCamAttrDefine &rhs) { if (this != &rhs) d.operator=(rhs.d); return *this; } PcbCamAttrDefine::~PcbCamAttrDefine() { } PcbCamAttrDefine::DataType PcbCamAttrDefine::dataType() const { return d->dataType; } void PcbCamAttrDefine::setDataType(PcbCamAttrDefine::DataType iDataType) { d->dataType = iDataType; } QString PcbCamAttrDefine::name() const { return d->name; } void PcbCamAttrDefine::setName(const QString &iName) { d->name = iName; } QString PcbCamAttrDefine::prompt() const { return d->prompt; } void PcbCamAttrDefine::setPrompt(const QString &iPrompt) { d->prompt = iPrompt; } PcbCamAttrDefine::Entity PcbCamAttrDefine::entity() const { return d->entity; } void PcbCamAttrDefine::setEntity(PcbCamAttrDefine::Entity iEntity) { d->entity = iEntity; } QVariant PcbCamAttrDefine::defaultValue() const { return d->defaultValue; } void PcbCamAttrDefine::setDefaultValue(const QVariant &iValue) { d->defaultValue = iValue; } uint PcbCamAttrDefine::minLength() const { return d->minLength; } void PcbCamAttrDefine::setMinLength(uint iLen) { d->minLength = iLen; } uint PcbCamAttrDefine::maxLength() const { return d->maxLength; } void PcbCamAttrDefine::setMaxLength(uint iLen) { d->maxLength = iLen; } QStringList PcbCamAttrDefine::options() const { return d->options; } void PcbCamAttrDefine::setOptions(const QStringList &iOptions) { d->options = iOptions; } QStringList PcbCamAttrDefine::deleted() const { return d->deleted; } void PcbCamAttrDefine::setDeleted(const QStringList &iList) { d->deleted = iList; } PcbCamAttrDefine::Units PcbCamAttrDefine::units() const { return d->units; } void PcbCamAttrDefine::setUnits(PcbCamAttrDefine::Units iUnits) { d->units = iUnits; } int PcbCamAttrDefine::index() const { return d->index; } void PcbCamAttrDefine::setIndex(int iIndex) { d->index = iIndex; } PcbCamAttrDefine::DataType PcbCamAttrDefine::dataTypeFromString(const QString &iStr) { QString str = iStr.toUpper(); if (str == "BOOLEAN") { return PcbCamAttrDefine::Boolean; } else if (str == "OPTION") { return PcbCamAttrDefine::Option; } else if (str == "INTEGER") { return PcbCamAttrDefine::Integer; } else if (str == "FLOAT") { return PcbCamAttrDefine::Float; } return PcbCamAttrDefine::Text; } PcbCamAttrDefine::Entity PcbCamAttrDefine::entityFromString(const QString &iStr) { QStringList list = iStr.trimmed().toUpper().split(";", Qt::SkipEmptyParts); PcbCamAttrDefine::Entity entity; for (const QString &item : list) { if (item == "JOB"){ entity |= PcbCamAttrDefine::Job; } else if (item == "STEP"){ entity |= PcbCamAttrDefine::Step; } else if (item == "SYMBOL"){ entity |= PcbCamAttrDefine::Symbol; } else if (item == "LAYER"){ entity |= PcbCamAttrDefine::Layer; } else if (item == "STACKUP"){ entity |= PcbCamAttrDefine::Stackup; } else if (item == "WHEEL"){ entity |= PcbCamAttrDefine::Wheel; } else if (item == "FEATURE"){ entity |= PcbCamAttrDefine::Feature; } else if (item == "COMPONENT"){ entity |= PcbCamAttrDefine::Component; } else if (item == "ALL") { entity = PcbCamAttrDefine::All; } } return entity; }