Load from XML
| 1025 | |
| 1026 | //! Load from XML |
| 1027 | bool LollipopPlot::load(XmlStreamReader* reader, bool preview) { |
| 1028 | Q_D(LollipopPlot); |
| 1029 | |
| 1030 | if (!readBasicAttributes(reader)) |
| 1031 | return false; |
| 1032 | |
| 1033 | QXmlStreamAttributes attribs; |
| 1034 | QString str; |
| 1035 | bool firstLineRead = false; |
| 1036 | bool firstSymbolRead = false; |
| 1037 | |
| 1038 | while (!reader->atEnd()) { |
| 1039 | reader->readNext(); |
| 1040 | if (reader->isEndElement() && reader->name() == QLatin1String("lollipopPlot")) |
| 1041 | break; |
| 1042 | |
| 1043 | if (!reader->isStartElement()) |
| 1044 | continue; |
| 1045 | |
| 1046 | if (!preview && reader->name() == QLatin1String("comment")) { |
| 1047 | if (!readCommentElement(reader)) |
| 1048 | return false; |
| 1049 | } else if (!preview && reader->name() == QLatin1String("general")) { |
| 1050 | attribs = reader->attributes(); |
| 1051 | |
| 1052 | READ_INT_VALUE("orientation", orientation, LollipopPlot::Orientation); |
| 1053 | READ_INT_VALUE_DIRECT("plotRangeIndex", m_cSystemIndex, int); |
| 1054 | |
| 1055 | READ_DOUBLE_VALUE("xMin", xMin); |
| 1056 | READ_DOUBLE_VALUE("xMax", xMax); |
| 1057 | READ_DOUBLE_VALUE("yMin", yMin); |
| 1058 | READ_DOUBLE_VALUE("yMax", yMax); |
| 1059 | READ_COLUMN(xColumn); |
| 1060 | READ_INT_VALUE("legendVisible", legendVisible, bool); |
| 1061 | |
| 1062 | str = attribs.value(QStringLiteral("visible")).toString(); |
| 1063 | if (str.isEmpty()) |
| 1064 | reader->raiseMissingAttributeWarning(QStringLiteral("visible")); |
| 1065 | else |
| 1066 | d->setVisible(str.toInt()); |
| 1067 | } else if (reader->name() == QLatin1String("column")) { |
| 1068 | attribs = reader->attributes(); |
| 1069 | |
| 1070 | str = attribs.value(QStringLiteral("path")).toString(); |
| 1071 | if (!str.isEmpty()) |
| 1072 | d->dataColumnPaths << str; |
| 1073 | } else if (!preview && reader->name() == QLatin1String("line")) { |
| 1074 | if (!firstLineRead) { |
| 1075 | auto* line = d->lines.at(0); |
| 1076 | line->load(reader, preview); |
| 1077 | firstLineRead = true; |
| 1078 | } else { |
| 1079 | auto* line = d->addLine(KConfigGroup()); |
| 1080 | line->load(reader, preview); |
| 1081 | } |
| 1082 | } else if (!preview && reader->name() == QLatin1String("symbol")) { |
| 1083 | if (!firstSymbolRead) { |
| 1084 | auto* symbol = d->symbols.at(0); |
nothing calls this directly
no test coverage detected