Check if point name unique.
--HG-- branch : feature
This commit is contained in:
parent
aee0c1fed6
commit
483c7a0e56
|
@ -37,6 +37,7 @@
|
||||||
quint32 VContainer::_id = NULL_ID;
|
quint32 VContainer::_id = NULL_ID;
|
||||||
qreal VContainer::_size = 50;
|
qreal VContainer::_size = 50;
|
||||||
qreal VContainer::_height = 176;
|
qreal VContainer::_height = 176;
|
||||||
|
QSet<const QString> VContainer::uniqueNames = QSet<const QString>();
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -138,6 +139,7 @@ quint32 VContainer::AddGObject(VGObject *obj)
|
||||||
{
|
{
|
||||||
SCASSERT(obj != nullptr);
|
SCASSERT(obj != nullptr);
|
||||||
QSharedPointer<VGObject> pointer(obj);
|
QSharedPointer<VGObject> pointer(obj);
|
||||||
|
uniqueNames.insert(obj->name());
|
||||||
return AddObject(d->gObjects, pointer);
|
return AddObject(d->gObjects, pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,6 +212,7 @@ void VContainer::Clear()
|
||||||
d->details.clear();
|
d->details.clear();
|
||||||
ClearVariables();
|
ClearVariables();
|
||||||
ClearGObjects();
|
ClearGObjects();
|
||||||
|
ClearUniqueNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -334,6 +337,7 @@ void VContainer::UpdateGObject(quint32 id, VGObject* obj)
|
||||||
SCASSERT(obj != nullptr);
|
SCASSERT(obj != nullptr);
|
||||||
QSharedPointer<VGObject> pointer(obj);
|
QSharedPointer<VGObject> pointer(obj);
|
||||||
UpdateObject(d->gObjects, id, pointer);
|
UpdateObject(d->gObjects, id, pointer);
|
||||||
|
uniqueNames.insert(obj->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -407,6 +411,12 @@ const QMap<QString, QSharedPointer<VLineAngle> > VContainer::DataAngleLines() co
|
||||||
return DataVar<VLineAngle>(VarType::LineAngle);
|
return DataVar<VLineAngle>(VarType::LineAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VContainer::IsUnique(const QString &name)
|
||||||
|
{
|
||||||
|
return !uniqueNames.contains(name);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VariableExist check if exist variable this same name.
|
* @brief VariableExist check if exist variable this same name.
|
||||||
|
@ -442,6 +452,12 @@ void VContainer::ClearDetails()
|
||||||
d->details.clear();
|
d->details.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VContainer::ClearUniqueNames()
|
||||||
|
{
|
||||||
|
uniqueNames.clear();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief SetSize set value of size
|
* @brief SetSize set value of size
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
@ -186,6 +187,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d->variables[name] = QSharedPointer<T>(var);
|
d->variables[name] = QSharedPointer<T>(var);
|
||||||
|
uniqueNames.insert(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateGObject(quint32 id, VGObject* obj);
|
void UpdateGObject(quint32 id, VGObject* obj);
|
||||||
|
@ -196,6 +198,7 @@ public:
|
||||||
void ClearCalculationGObjects();
|
void ClearCalculationGObjects();
|
||||||
void ClearVariables(const VarType &type = VarType::Unknown);
|
void ClearVariables(const VarType &type = VarType::Unknown);
|
||||||
void ClearDetails();
|
void ClearDetails();
|
||||||
|
static void ClearUniqueNames();
|
||||||
|
|
||||||
void SetSize(qreal size);
|
void SetSize(qreal size);
|
||||||
void SetSizeName(const QString &name);
|
void SetSizeName(const QString &name);
|
||||||
|
@ -221,6 +224,7 @@ public:
|
||||||
const QMap<QString, QSharedPointer<VArcLength> > DataLengthArcs() const;
|
const QMap<QString, QSharedPointer<VArcLength> > DataLengthArcs() const;
|
||||||
const QMap<QString, QSharedPointer<VLineAngle> > DataAngleLines() const;
|
const QMap<QString, QSharedPointer<VLineAngle> > DataAngleLines() const;
|
||||||
|
|
||||||
|
static bool IsUnique(const QString &name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -229,6 +233,7 @@ private:
|
||||||
static quint32 _id;
|
static quint32 _id;
|
||||||
static qreal _size;
|
static qreal _size;
|
||||||
static qreal _height;
|
static qreal _height;
|
||||||
|
static QSet<const QString> uniqueNames;
|
||||||
|
|
||||||
QSharedDataPointer<VContainerData> d;
|
QSharedDataPointer<VContainerData> d;
|
||||||
|
|
||||||
|
|
|
@ -369,13 +369,12 @@ void VToolOptionsPropertyBrowser::SetPointName(const QString &name)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.isEmpty())
|
if (name.isEmpty() || VContainer::IsUnique(name) == false)
|
||||||
{
|
{
|
||||||
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
|
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//TODO check if label name is unique
|
|
||||||
i->setName(name);
|
i->setName(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2326,6 +2326,10 @@ void VPattern::PrepareForParse(const Document &parse)
|
||||||
cursor = 0;
|
cursor = 0;
|
||||||
history.clear();
|
history.clear();
|
||||||
}
|
}
|
||||||
|
else if (parse == Document::LiteParse)
|
||||||
|
{
|
||||||
|
data->ClearUniqueNames();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user