Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/entityproperties.cc')
-rw-r--r--src/entityproperties.cc25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/entityproperties.cc b/src/entityproperties.cc
index bbef6c9..e9ed1d0 100644
--- a/src/entityproperties.cc
+++ b/src/entityproperties.cc
@@ -19,12 +19,15 @@ EntityProperties::~EntityProperties()
{
}
-void EntityProperties::add_subsection_header(const QString &header)
+void EntityProperties::add_subsection_header(const QString &header, const QString &comment)
{
if (properties_subsections.size()) {
properties_subsections += '\n';
}
-
+
+ if (comment.size())
+ properties_subsections += comment;
+
properties_subsections += '[';
properties_subsections += header;
properties_subsections += ']';
@@ -32,8 +35,11 @@ void EntityProperties::add_subsection_header(const QString &header)
}
-void EntityProperties::add_subsection_value(const QString &key, const QString &value)
+void EntityProperties::add_subsection_value(const QString &key, const QString &value, const QString &comment)
{
+ if (comment.size())
+ properties_subsections += comment;
+
properties_subsections += key;
properties_subsections += '=';
properties_subsections += value;
@@ -42,6 +48,19 @@ void EntityProperties::add_subsection_value(const QString &key, const QString &v
void EntityProperties::save(QTextStream &textstream)
{
+ // comments
+ if (comment().size()) {
+ // QTextStream operates on QString, not on QString const
+ QString commentbuffer = comment();
+ QTextStream commentstream(&commentbuffer);
+ QString line;
+ while (!commentstream.atEnd()) {
+ line = commentstream.readLine(1024);
+ textstream << line << '\n';
+ }
+ textstream << '\n';
+ }
+
textstream << "[" << type() << "]" << '\n';
if (label().size())
textstream << "label=" << label() << '\n';