aboutsummaryrefslogtreecommitdiff
path: root/symbol.cpp
diff options
context:
space:
mode:
authorMikko Syrjä <mikko@3d-system.fi>2019-02-12 03:37:33 +0200
committerMikko Syrjä <mikko@3d-system.fi>2019-02-12 03:37:33 +0200
commit78a0f5f0ccf9f3ace910210021190980bd6359e4 (patch)
treeca268c6dce721ab859dff43bee8672ddfe42b7c3 /symbol.cpp
parente27c60705740483291323c0b90faaf7f165cec4d (diff)
downloadsymedit-78a0f5f0ccf9f3ace910210021190980bd6359e4.tar.gz
symedit-78a0f5f0ccf9f3ace910210021190980bd6359e4.zip
UI fixes.
Diffstat (limited to 'symbol.cpp')
-rw-r--r--symbol.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/symbol.cpp b/symbol.cpp
index 604f91e..9a56d19 100644
--- a/symbol.cpp
+++ b/symbol.cpp
@@ -11,7 +11,7 @@
\param point Item position.
*/
SymEditSymbol::Item::Item(int operation, QPoint point)
- : Operation(operation), Point(point), Fill(false)
+ : Operation(operation), Point(point), Fill(false), Align(9)
{
}
@@ -41,7 +41,7 @@ void SymEditSymbol::Load(const QString& buffer)
x = string.mid(1, comma - 1).toInt();
y = string.mid(comma + 1).toInt();
}
- else
+ else // single parameter
x = y = string.mid(1).toInt();
Item item(operation, QPoint(x, y));
Items.push_back(item);
@@ -51,14 +51,29 @@ void SymEditSymbol::Load(const QString& buffer)
//! Save symbol to string.
/*!
\param buffer String buffer.
+ \return Reference to buffer.
*/
-void SymEditSymbol::Save(QString& buffer) const
+QString& SymEditSymbol::Save(QString& buffer) const
{
+ auto appendvalue = [](QString& buffer, const QPoint& point, int count)
+ {
+ QString value;
+ buffer.append(value.setNum(point.x()));
+ if ( count > 1 )
+ buffer.append(',').append(value.setNum(point.y()));
+ buffer.append(';');
+ };
+
buffer.clear();
- for ( const auto& item : Items )
+ for ( const auto& item : Items ) switch ( item.Operation )
{
- //##
+ case 'D': appendvalue(buffer.append('D'), item.Point, 2); break;
+ case 'U': appendvalue(buffer.append('U'), item.Point, 2); break;
+ case 'R': appendvalue(buffer.append('R'), item.Point, 1); break;
}
+ if ( !buffer.isEmpty() && buffer.back() == ';' )
+ buffer.chop(1);
+ return buffer;
}
//! Add symbol item.