Commit 059122f2 authored by Adriaan de Groot's avatar Adriaan de Groot 💬
Browse files

gml files: reduce compiler warnings

 - be consistent(er) in using C++11 iteration (caveats apply)
 - processNone() and processEdge() don't need to be members
parent 7302ec33
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
using namespace GraphTheory; using namespace GraphTheory;
static QString processEdge(const EdgePtr &e);
static QString processNode(const NodePtr &n);
extern GmlParser::GmlGrammarHelper* phelper; extern GmlParser::GmlGrammarHelper* phelper;
K_PLUGIN_FACTORY_WITH_JSON( FilePluginFactory, K_PLUGIN_FACTORY_WITH_JSON( FilePluginFactory,
...@@ -94,7 +97,7 @@ void GmlFileFormat::writeFile(GraphDocumentPtr document) ...@@ -94,7 +97,7 @@ void GmlFileFormat::writeFile(GraphDocumentPtr document)
// out << QString("graph [\n directed %1 \n").arg(g->directed()?"1":"0"); // out << QString("graph [\n directed %1 \n").arg(g->directed()?"1":"0");
out << QString("id \"%1\" \n").arg("graph"); //TODO support export of name out << QString("id \"%1\" \n").arg("graph"); //TODO support export of name
foreach(NodePtr n, document->nodes()) { for(const NodePtr &n : document->nodes()) {
out << QString("node [\n id \"%1\" \n").arg(n->dynamicProperty("name").toString()); out << QString("node [\n id \"%1\" \n").arg(n->dynamicProperty("name").toString());
// foreach (QByteArray p, n->dynamicPropertyNames()){ // foreach (QByteArray p, n->dynamicPropertyNames()){
// out << p << " " << n->property(p).toString() << "\n"; // out << p << " " << n->property(p).toString() << "\n";
...@@ -103,7 +106,7 @@ void GmlFileFormat::writeFile(GraphDocumentPtr document) ...@@ -103,7 +106,7 @@ void GmlFileFormat::writeFile(GraphDocumentPtr document)
out << "]\n"; out << "]\n";
} }
for (auto const edge : document->edges()) { for (auto const &edge : document->edges()) {
out << "edge [\n"; out << "edge [\n";
// foreach (QByteArray p, e->dynamicPropertyNames()){ // foreach (QByteArray p, e->dynamicPropertyNames()){
// out << p << " " << e->property(p).toString() << "\n"; // out << p << " " << e->property(p).toString() << "\n";
...@@ -119,26 +122,26 @@ void GmlFileFormat::writeFile(GraphDocumentPtr document) ...@@ -119,26 +122,26 @@ void GmlFileFormat::writeFile(GraphDocumentPtr document)
} }
QString GmlFileFormat::processEdge(EdgePtr e) const static QString processEdge(const EdgePtr &e)
{ {
QString edge; QString edge;
edge.append(QString("source \"%1\"\n target \"%2\"\n").arg(e->from()->dynamicProperty("name").toString(), e->to()->dynamicProperty("name").toString())); edge.append(QString("source \"%1\"\n target \"%2\"\n").arg(e->from()->dynamicProperty("name").toString(), e->to()->dynamicProperty("name").toString()));
// edge.append (QString(" color \"%1\"\n").arg(e->color())); //Problem with comments (both starts by '#') // edge.append (QString(" color \"%1\"\n").arg(e->color())); //Problem with comments (both starts by '#')
foreach(const QString &property, e->dynamicProperties()) { for(const QString &property : e->dynamicProperties()) {
edge.append(QString("%1 %2\n").arg(property).arg(e->dynamicProperty(property).toString())); edge.append(QString("%1 %2\n").arg(property).arg(e->dynamicProperty(property).toString()));
} }
return edge; return edge;
} }
QString GmlFileFormat::processNode(NodePtr n) const static QString processNode(const NodePtr &n)
{ {
QString node; QString node;
node.append(QString(" x %1 \n y %2 \n").arg(n->x()).arg(n->y())); node.append(QString(" x %1 \n y %2 \n").arg(n->x()).arg(n->y()));
// node.append (QString(" color \"%1\"\n").arg(n->color())); //Problem with comments (both starts by '#') // node.append (QString(" color \"%1\"\n").arg(n->color())); //Problem with comments (both starts by '#')
foreach(const QString &property, n->dynamicProperties()) { for(const QString &property : n->dynamicProperties()) {
node.append(QString("%1 %2\n").arg(property).arg(n->dynamicProperty(property).toString())); node.append(QString("%1 %2\n").arg(property).arg(n->dynamicProperty(property).toString()));
} }
......
...@@ -50,10 +50,6 @@ public: ...@@ -50,10 +50,6 @@ public:
* \param file is url of a local file * \param file is url of a local file
*/ */
void readFile() Q_DECL_OVERRIDE; void readFile() Q_DECL_OVERRIDE;
private:
QString processNode(NodePtr node) const;
QString processEdge(EdgePtr edge) const;
}; };
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment