MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / readStyle

Method readStyle

bt_editor/models/BehaviorTreeNodeModel.cpp:311–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311void BehaviorTreeDataModel::readStyle()
312{
313 QFile style_file(":/NodesStyle.json");
314
315 if (!style_file.open(QIODevice::ReadOnly))
316 {
317 qWarning("Couldn't open NodesStyle.json");
318 return;
319 }
320
321 QByteArray bytearray = style_file.readAll();
322 style_file.close();
323 QJsonParseError error;
324 QJsonDocument json_doc( QJsonDocument::fromJson( bytearray, &error ));
325
326 if(json_doc.isNull()){
327 qDebug()<<"Failed to create JSON doc: " << error.errorString();
328 return;
329 }
330 if(!json_doc.isObject()){
331 qDebug()<<"JSON is not an object.";
332 return;
333 }
334
335 QJsonObject toplevel_object = json_doc.object();
336
337 if(toplevel_object.isEmpty()){
338 qDebug()<<"JSON object is empty.";
339 return;
340 }
341 QString model_type_name( QString::fromStdString(toStr(_model.type)) );
342
343 for (const auto& model_name: { model_type_name, _model.registration_ID} )
344 {
345 if( toplevel_object.contains(model_name) )
346 {
347 auto category_style = toplevel_object[ model_name ].toObject() ;
348 if( category_style.contains("icon"))
349 {
350 _style_icon = category_style["icon"].toString();
351 }
352 if( category_style.contains("caption_color"))
353 {
354 _style_caption_color = category_style["caption_color"].toString();
355 }
356 if( category_style.contains("caption_alias"))
357 {
358 _style_caption_alias = category_style["caption_alias"].toString();
359 }
360 }
361 }
362}
363
364const QString& BehaviorTreeDataModel::registrationName() const
365{

Callers

nothing calls this directly

Calls 1

toStrFunction · 0.85

Tested by

no test coverage detected