Appends an extra to an existing data-source doc, so a single doc can carry multiple loaded files (mirrors a multi-file session save).
| 156 | // Appends an extra <fileInfo> to an existing data-source doc, so a single doc |
| 157 | // can carry multiple loaded files (mirrors a multi-file session save). |
| 158 | void appendFileInfo( |
| 159 | QDomDocument& doc, const QString& filename, const QString& prefix = QString(), const QString& plugin_id = QString(), |
| 160 | const QString& plugin_json = QString()) { |
| 161 | QDomElement wrapper = doc.documentElement().firstChildElement(QStringLiteral("previouslyLoaded_Datafiles")); |
| 162 | QDomElement file_info = doc.createElement(QStringLiteral("fileInfo")); |
| 163 | file_info.setAttribute(QStringLiteral("filename"), filename); |
| 164 | file_info.setAttribute(QStringLiteral("prefix"), prefix); |
| 165 | if (!plugin_id.isEmpty()) { |
| 166 | QDomElement plugin = doc.createElement(QStringLiteral("plugin")); |
| 167 | plugin.setAttribute(QStringLiteral("ID"), plugin_id); |
| 168 | PJ::layout_xml::appendJsonAsCdata(doc, plugin, plugin_json); |
| 169 | file_info.appendChild(plugin); |
| 170 | } |
| 171 | wrapper.appendChild(file_info); |
| 172 | } |
| 173 | |
| 174 | TEST(ExtractDataSource, EmptyDocReturnsEmptyList) { |
| 175 | QDomDocument doc; |
no test coverage detected