You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.7 KiB
C++
63 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <QtXml/QDomDocument>
|
|
#include "iUnitItem.h"
|
|
|
|
// 单位组
|
|
class I_UNITSHARED_EXPORT iUnitGroup : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit iUnitGroup(QWidget *parent = 0);
|
|
~iUnitGroup();
|
|
|
|
public:
|
|
|
|
// 解析
|
|
void parseInfo(const QDomElement& e); //解析xml
|
|
void writeInfo(QDomElement& e,QDomDocument &doc); //写入xml
|
|
void copyFrom(iUnitGroup* p);
|
|
|
|
/// @brief 单位转换函数
|
|
/// @param sUnitSrc 源单位
|
|
/// @param dValueSrc 源数值
|
|
/// @param sUnitDest 目的单位
|
|
/// @param dValueDest 目的数值,即转换后的数值
|
|
/// @param nDigit 转换后,需要的小数位数,可能未配置
|
|
bool convert(QString sUnitSrc, double dValueSrc,
|
|
QString sUnitDest, double& dValueDest, int &nDigit);
|
|
bool convert(QString sUnitSrc, VecDouble vecValueSrc,
|
|
QString sUnitDest, VecDouble& vecValueDest, int &nDigit);
|
|
static bool convert(const double dValueSrc, double& dValueDest, \
|
|
const double k_src, const double b_src, \
|
|
const double k_dest, const double b_dest);
|
|
|
|
// 查找是否还有某个单位
|
|
int indexOf(QString sUnit);
|
|
|
|
// 获取某个单位对象体
|
|
iUnitItem* getUnitItem(QString sUnit);
|
|
|
|
// 获取所有的单位名称
|
|
QStringList getAllUnitNames(QStringList* ptrListUnitIDs = nullptr);
|
|
|
|
// 获取该单位组的基准单位
|
|
QString getUnitBase();
|
|
|
|
void clear();
|
|
|
|
public:
|
|
|
|
QString m_sID; //ID
|
|
QString m_sName; //名称
|
|
QString m_sType; //类型
|
|
QString m_sIcon; //图标
|
|
QString m_sTips; //备注说明
|
|
|
|
vecUnitItemPtr m_vecUnitItems;
|
|
};
|
|
|
|
typedef QVector<iUnitGroup*> vecUnitGroupPtr;
|