The method CreateGroup.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-04-05 20:53:49 +03:00
parent ada64305c0
commit d73256f119
7 changed files with 66 additions and 11 deletions

View File

@ -1012,10 +1012,7 @@ void MainWindow::ClosedDialogGroup(int result)
DialogGroup *dialog = qobject_cast<DialogGroup*>(dialogTool);
SCASSERT(dialog != nullptr);
const QString name = dialog->GetName();
const QMap<quint32, quint32> group = dialog->GetGroup();
const quint32 id = pattern->getNextId();
doc->AddGroup(id, name, group);
doc->AddGroup(pattern->getNextId(), dialog->GetName(), dialog->GetGroup());
}
ArrowTool();
}

View File

@ -2882,7 +2882,7 @@ bool VPattern::IsDefCustom() const
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
return GetParametrBool(domElement, AttrCustom, QStringLiteral("false"));
return GetParametrBool(domElement, AttrCustom, falseStr);
}
else
{
@ -3051,7 +3051,7 @@ bool VPattern::IsReadOnly() const
return false;
}
return GetParametrBool(pattern, AttrReadOnly, QStringLiteral("false"));
return GetParametrBool(pattern, AttrReadOnly, falseStr);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -43,6 +43,8 @@ const QString VAbstractPattern::TagMeasurements = QStringLiteral("measurements")
const QString VAbstractPattern::TagIncrements = QStringLiteral("increments");
const QString VAbstractPattern::TagIncrement = QStringLiteral("increment");
const QString VAbstractPattern::TagDraw = QStringLiteral("draw");
const QString VAbstractPattern::TagGroups = QStringLiteral("groups");
const QString VAbstractPattern::TagItem = QStringLiteral("item");
const QString VAbstractPattern::TagPoint = QStringLiteral("point");
const QString VAbstractPattern::TagLine = QStringLiteral("line");
const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
@ -54,6 +56,9 @@ const QString VAbstractPattern::TagSizes = QStringLiteral("sizes");
const QString VAbstractPattern::TagUnit = QStringLiteral("unit");
const QString VAbstractPattern::AttrName = QStringLiteral("name");
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
const QString VAbstractPattern::AttrObject = QStringLiteral("object");
const QString VAbstractPattern::AttrTool = QStringLiteral("tool");
const QString VAbstractPattern::AttrType = QStringLiteral("type");
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
@ -593,7 +598,7 @@ QMap<GHeights, bool> VAbstractPattern::GetGradationHeights() const
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const QString defValue = QStringLiteral("true");
const QString defValue = trueStr;
switch (gTags.indexOf(domElement.tagName()))
{
case 0: // TagHeights
@ -759,7 +764,7 @@ QMap<GSizes, bool> VAbstractPattern::GetGradationSizes() const
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const QString defValue = QStringLiteral("true");
const QString defValue = trueStr;
switch (gTags.indexOf(domElement.tagName()))
{
case 0: // TagHeights
@ -1356,8 +1361,51 @@ QDomElement VAbstractPattern::GetDraw(const QString &name) const
return QDomElement();
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement VAbstractPattern::CreateGroups()
{
QDomElement draw;
if (GetActivDrawElement(draw))
{
QDomElement groups = draw.firstChildElement(TagGroups);
if (groups.isNull())
{
groups = createElement(TagGroups);
draw.appendChild(groups);
}
return groups;
}
return QDomElement();
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::AddGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &group)
{
if (id == NULL_ID || group.isEmpty())
{
return;
}
QDomElement groups = CreateGroups();
if (groups.isNull())
{
return;
}
groups.setAttribute(AttrId, id);
groups.setAttribute(AttrName, name);
groups.setAttribute(AttrVisible, trueStr);
auto i = group.constBegin();
while (i != group.constEnd())
{
QDomElement item = createElement(TagItem);
item.setAttribute(AttrObject, i.key());
item.setAttribute(AttrTool, i.value());
groups.appendChild(item);
++i;
}
}

View File

@ -114,6 +114,7 @@ public:
QDomElement GetDraw(const QString &name) const;
QDomElement CreateGroups();
void AddGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &group);
static const QString TagPattern;
@ -127,6 +128,8 @@ public:
static const QString TagIncrements;
static const QString TagIncrement;
static const QString TagDraw;
static const QString TagGroups;
static const QString TagItem;
static const QString TagPoint;
static const QString TagLine;
static const QString TagSpline;
@ -138,6 +141,9 @@ public:
static const QString TagUnit;
static const QString AttrName;
static const QString AttrVisible;
static const QString AttrObject;
static const QString AttrTool;
static const QString AttrType;
static const QString AttrAll;

View File

@ -255,7 +255,7 @@ bool VDomDocument::GetParametrBool(const QDomElement &domElement, const QString
//---------------------------------------------------------------------------------------------------------------------
NodeUsage VDomDocument::GetParametrUsage(const QDomElement &domElement, const QString &name) const
{
const bool value = GetParametrBool(domElement, name, QStringLiteral("true"));
const bool value = GetParametrBool(domElement, name, trueStr);
if (value)
{
return NodeUsage::InUse;
@ -271,11 +271,11 @@ void VDomDocument::SetParametrUsage(QDomElement &domElement, const QString &name
{
if (value == NodeUsage::InUse)
{
domElement.setAttribute(name, QStringLiteral("true"));
domElement.setAttribute(name, trueStr);
}
else
{
domElement.setAttribute(name, QStringLiteral("false"));
domElement.setAttribute(name, falseStr);
}
}

View File

@ -408,6 +408,8 @@ const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-clos
// From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This
// furthermore blows up the binary sizes.
const QString degreeSymbol = QStringLiteral("°");
const QString trueStr = QStringLiteral("true");
const QString falseStr = QStringLiteral("false");
//---------------------------------------------------------------------------------------------------------------------
void SetOverrideCursor(const QString &pixmapPath, int hotX, int hotY)

View File

@ -584,6 +584,8 @@ extern const QString cursorArrowOpenHand;
extern const QString cursorArrowCloseHand;
extern const QString degreeSymbol;
extern const QString trueStr;
extern const QString falseStr;
void SetOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1);
void RestoreOverrideCursor(const QString & pixmapPath);