From 4460f43972bd52c498161c64d4ddcc4da4c45d20 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 21 Feb 2012 20:06:17 +0000 Subject: Add support for zone properties, added framework to save files. --- src/entityproperties.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/entityproperties.cc') diff --git a/src/entityproperties.cc b/src/entityproperties.cc index 371746f..84a6bc4 100644 --- a/src/entityproperties.cc +++ b/src/entityproperties.cc @@ -39,4 +39,49 @@ void EntityProperties::add_subsection_value(const QString &key, const QString &v properties_subsections += '\n'; } +void EntityProperties::save(QTextStream &textstream) +{ + textstream << "[" << type() << "]" << '\n'; + if (label().size()) + textstream << "label=" << label() << '\n'; + if (name().size()) + textstream << "name=" << name() << '\n'; + + // other values + if (values().size()) { + textstream << values(); + } + + // info string + if (info().size()) { + textstream << '\n'; + + // QTextStream operates on QString, not on QString const + QString infobuffer = info(); + QTextStream infostream(&infobuffer); + QString line; + while (!infostream.atEnd()) { + line = infostream.readLine(1024); + textstream << "info=" << line << '\n'; + } + } + + if (subsections().size()) { + textstream << '\n'; + + QString subsectionbuffer = subsections(); + QTextStream subsectionstream(&subsectionbuffer); + QString line; + while (!subsectionstream.atEnd()) { + line = subsectionstream.readLine(1024); + if (line.size()) + textstream << '\t' << line << '\n'; + else + textstream << '\n'; + } + + } + + textstream << '\n'; +} } // namespace editor -- cgit v1.2.3