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