159 lines
2.4 KiB
C++
159 lines
2.4 KiB
C++
#include "DPData.h"
|
|
#include <QMetaProperty>
|
|
#include "global.h"
|
|
|
|
|
|
DPData::DPData()
|
|
{
|
|
}
|
|
|
|
DPData::~DPData()
|
|
{
|
|
if (_pDBDAO)
|
|
{
|
|
delete _pDBDAO;
|
|
_pDBDAO = nullptr;
|
|
}
|
|
qDeleteAll(_childrenMap);
|
|
_childrenMap.clear();
|
|
}
|
|
|
|
void DPData::saveToDao()
|
|
{
|
|
|
|
}
|
|
|
|
/*增加数据*/
|
|
bool DPData::addChild(DPData*)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/*删除一个下层对象*/
|
|
bool DPData::deleteChild(unsigned int)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/*从数据库加载一条数据*/
|
|
void DPData::loadData(DBPlatformSpace::DAO*)
|
|
{
|
|
}
|
|
|
|
/*保存*/
|
|
bool DPData::saveSelf()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/*删除本身*/
|
|
bool DPData::deleteSelf()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/*获取所有下层数据*/
|
|
void DPData::getAllChildren(DPData*, bool)
|
|
{}
|
|
|
|
|
|
void DPData::getNewProperty(json&, QVariantMap&)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
QVariantMap DPData::getProperties() const
|
|
{
|
|
QVariantMap properties;
|
|
const QMetaObject* metaObject = this->metaObject();
|
|
int count = metaObject->propertyCount();
|
|
for (int i = 0; i < count; ++i)
|
|
{
|
|
QMetaProperty metaProperty = metaObject->property(i);
|
|
const char* name = metaProperty.name();
|
|
QVariant value = property(name);
|
|
properties[name] = value;
|
|
}
|
|
return properties;
|
|
}
|
|
|
|
void DPData::setProperties(const QVariantMap& properties)
|
|
{
|
|
QStringList names = properties.keys();
|
|
for (QString name : names)
|
|
{
|
|
QVariant value = properties[name];
|
|
setProperty(CommonHelper::qstringToString(name), value);
|
|
}
|
|
}
|
|
|
|
void DPData::setNewData(json&)
|
|
{
|
|
}
|
|
|
|
void DPData::setEditData(json&)
|
|
{
|
|
}
|
|
|
|
DPData* DPData::getDataModelOwner(void)
|
|
{
|
|
DPData* pFather = _parent;
|
|
while (pFather)
|
|
{
|
|
if ((int)pFather->_baseType == g_TYPE_DATAMODEL)
|
|
{
|
|
return pFather;
|
|
}
|
|
pFather = pFather->_parent;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
DPData* DPData::getDataManager(void)
|
|
{
|
|
DPData* pModel = getDataModelOwner();
|
|
if (pModel)
|
|
{
|
|
return pModel->_parent->_parent;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
void DPData::toJson(json&, bool)
|
|
{
|
|
}
|
|
|
|
bool DPData::addScene(DPData*)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
|
|
bool DPData::deleteScene(int)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
//是否有 名称标识 或 显示名称 相同属性, 有则返回
|
|
DPData* DPData::hasSameNameChild(QString propertyName, QString name)
|
|
{
|
|
QMap<unsigned int, DPData*>::iterator it;
|
|
|
|
it = _childrenMap.begin();
|
|
while (it != _childrenMap.end())
|
|
{
|
|
QString n = (*it)->property(CommonHelper::qstringToString(propertyName)).toString();
|
|
if (n == name)
|
|
{
|
|
return *it;
|
|
}
|
|
it++;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
|
|
void DPData::setFileData(FileGenerate*, QStringList)
|
|
{
|
|
} |