diff options
| author | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-12 03:37:33 +0200 |
|---|---|---|
| committer | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-12 03:37:33 +0200 |
| commit | 78a0f5f0ccf9f3ace910210021190980bd6359e4 (patch) | |
| tree | ca268c6dce721ab859dff43bee8672ddfe42b7c3 /symbol.cpp | |
| parent | e27c60705740483291323c0b90faaf7f165cec4d (diff) | |
| download | symedit-78a0f5f0ccf9f3ace910210021190980bd6359e4.tar.gz symedit-78a0f5f0ccf9f3ace910210021190980bd6359e4.zip | |
UI fixes.
Diffstat (limited to 'symbol.cpp')
| -rw-r--r-- | symbol.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
@@ -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. |
