MCPcopy Create free account
hub / github.com/KDE/labplot / generatePlot

Method generatePlot

src/frontend/PlotTemplateDialog.cpp:140–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140CartesianPlot* PlotTemplateDialog::generatePlot() {
141 const QString path = templatePath();
142 if (path.isEmpty()) {
143 updateErrorMessage(i18n("No templates found."));
144 return nullptr;
145 }
146
147 QFile file(path);
148 if (!file.exists()) {
149 updateErrorMessage(i18n("File does not exist."));
150 return nullptr;
151 }
152
153 if (!file.open(QIODevice::OpenModeFlag::ReadOnly)) {
154 updateErrorMessage(i18n("Unable to read the file"));
155 return nullptr;
156 }
157
158 XmlStreamReader reader(&file);
159
160 while (!(reader.isStartDocument() || reader.atEnd()))
161 reader.readNext();
162
163 if (reader.atEnd()) {
164 DEBUG("XML error: No start document token found");
165 updateErrorMessage(i18n("Failed to load the selected plot template"));
166 return nullptr;
167 }
168
169 reader.readNext();
170 if (!reader.isDTD()) {
171 DEBUG("XML error: No DTD token found");
172 updateErrorMessage(i18n("Failed to load the selected plot template"));
173 return nullptr;
174 }
175
176 reader.readNext();
177 if (!reader.isStartElement() || reader.name() != QLatin1String("PlotTemplate")) {
178 DEBUG("XML error: No PlotTemplate found");
179 updateErrorMessage(i18n("Failed to load the selected plot template"));
180 return nullptr;
181 }
182
183 bool ok;
184 int xmlVersion = reader.readAttributeInt(QLatin1String("xmlVersion"), &ok);
185 if (!ok) {
186 DEBUG("XML error: xmlVersion found");
187 updateErrorMessage(i18n("Failed to load the selected plot template"));
188 return nullptr;
189 }
190 Project::setXmlVersion(xmlVersion);
191 reader.readNext();
192
193 while (!((reader.isStartElement() && reader.name() == QLatin1String("cartesianPlot")) || reader.atEnd()))
194 reader.readNext();
195
196 if (reader.atEnd()) {
197 updateErrorMessage(i18n("XML error: No cartesianPlot found"));

Callers 1

addNewMethod · 0.80

Calls 11

existsMethod · 0.80
atEndMethod · 0.80
readAttributeIntMethod · 0.80
setIsLoadingMethod · 0.80
toStdStringMethod · 0.80
isEmptyMethod · 0.45
openMethod · 0.45
nameMethod · 0.45
loadMethod · 0.45
recalculateMethod · 0.45
retransformMethod · 0.45

Tested by

no test coverage detected