MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / restore

Method restore

src/plugins/codeporting/configwidget.cpp:228–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228bool ConfigWidget::restore()
229{
230 QString cfgFilePath = configFilePath();
231
232 QFile file(cfgFilePath);
233 if (!file.open(QIODevice::ReadOnly))
234 return false;
235
236 QByteArray data = file.readAll();
237 file.close();
238
239 QJsonParseError parseError;
240 QJsonDocument doc = QJsonDocument::fromJson(data, &parseError);
241 if (QJsonParseError::NoError != parseError.error) {
242 return false;
243 }
244
245 if (!doc.isObject())
246 return false;
247
248 QJsonObject rootObject = doc.object();
249 for (auto key : rootObject.keys()) {
250 if (!rootObject.value(key).isArray() || !rootObject.keys().contains("Configure"))
251 continue;
252
253 if (rootObject.keys().contains("Configure")) {
254 QJsonArray valueArray = rootObject.value("Configure").toArray();
255
256 for (QJsonValue value : valueArray) {
257 QJsonObject obj = value.toObject();
258 d->cfgParam.srcCPU = obj.value(kSrcCPU).toString();
259 d->cfgParam.targetCPU = obj.value(kTargetCPU).toString();
260 }
261 }
262 }
263 return true;
264}
265
266QString ConfigWidget::configFilePath()
267{

Callers 15

drawBackgroundMethod · 0.80
drawTextFragmentMethod · 0.80
paintMethod · 0.80
paintGraphMethod · 0.80
paintTagBranchMethod · 0.80
paintPrStatusMethod · 0.80
paintMethod · 0.80
drawBackgroundMethod · 0.80
drawExpandArrowMethod · 0.80
paintMethod · 0.80
paintSeparatorMethod · 0.80

Calls 9

readAllMethod · 0.80
toArrayMethod · 0.80
openMethod · 0.45
closeMethod · 0.45
objectMethod · 0.45
keysMethod · 0.45
valueMethod · 0.45
containsMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected