Commit 5901f591 authored by Adriaan de Groot's avatar Adriaan de Groot 💬
Browse files

Fix rocs1fileformattest: consider all default edge types "known"

All the default (well, both of them) edge types should be considered
"known" when loading a file, to prevent duplicating one of them.

This fixes the test, but leaves a different problem in place:
 - Older files of this filetype, created with a previous Rocs release,
   may have a corresponding ID which **isn't** the new bidirectional
   default edge type, and those will be loaded wrongly.
parent 8e85e3b7
Pipeline #5968 passed with stage
in 13 minutes and 19 seconds
......@@ -115,7 +115,7 @@ void TestRocs1FileFormat::serializeUnserializeTypesTest()
logEdgeTypes(document->edgeTypes());
QCOMPARE(document->nodeTypes().count(), 2);
QCOMPARE(document->edgeTypes().count(), 2);
QCOMPARE(document->edgeTypes().count(), 3);
}
//TODO move to Rocs project file test
......
......@@ -64,6 +64,15 @@ const QStringList Rocs1FileFormat::extensions() const
<< i18n("Rocs 1 Graph File Format (%1)", QString("*.graph"));
}
template<typename T>
void addTypes(QMap<int, T>& map, const QList<T>& list)
{
int id = 0;
for (const auto& t : list) {
map.insert(id++, t);
}
}
void Rocs1FileFormat::readFile()
{
GraphDocumentPtr document = GraphDocument::create();
......@@ -78,8 +87,9 @@ void Rocs1FileFormat::readFile()
QMap<int, NodePtr> nodeMap;
QMap<int, NodeTypePtr> nodeTypeMap;
QMap<int, EdgeTypePtr> edgeTypeMap;
nodeTypeMap.insert(0, document->nodeTypes().first());
edgeTypeMap.insert(0, document->edgeTypes().first());
addTypes(nodeTypeMap, document->nodeTypes());
addTypes(edgeTypeMap, document->edgeTypes());
QTextStream in(&fileHandle);
in.setCodec("UTF-8");
......
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