void FastoCommonModel::changeValue(const NDbValue& value) { QModelIndex ind = index(0, 0); if(!ind.isValid()){ return; } FastoCommonItem* child = common::utils_qt::item<FastoCommonItem*>(ind); if(!child){ return; } FastoCommonItem* root = dynamic_cast<FastoCommonItem*>(child->parent()); if(!root){ return; } const QString key = common::convertFromString<QString>(value.keyString()); const QString val = common::convertFromString<QString>(value.valueString()); for(int i = 0; i < root->childrenCount(); ++i){ FastoCommonItem* child = dynamic_cast<FastoCommonItem*>(root->child(i)); if(!child){ continue; } if(child->key() == key){ child->setValue(val); emit dataChanged(index(i, FastoCommonItem::eValue), index(i, FastoCommonItem::eType)); break; } } }
void FastoEditorOutput::layoutChanged() { clear(); if(!model_){ return; } QModelIndex index = model_->index(0, 0); if(!index.isValid()){ return; } FastoCommonItem* child = common::utils_qt::item<FastoCommonItem*>(index); if(!child){ return; } FastoCommonItem* root = dynamic_cast<FastoCommonItem*>(child->parent()); if(!root){ return; } QString result; for(int i = 0; i < root->childrenCount(); ++i){ FastoCommonItem* child = dynamic_cast<FastoCommonItem*>(root->child(i)); if(!child){ continue; } if(viewMethod_ == JSON){ QString json = toJson(child); result += common::escapedText(json); } else if(viewMethod_ == CSV){ QString csv = toCsv(child, delemitr_); result += common::escapedText(csv); } else if(viewMethod_ == RAW){ QString raw = toRaw(child); result += common::escapedText(raw); } else if(viewMethod_ == HEX){ QString hex = toHex(child); result += common::escapedText(hex); } else if(viewMethod_ == MSGPACK){ QString hex = fromHexMsgPack(child); result += common::escapedText(hex); } else if(viewMethod_ == GZIP){ QString gzip = fromGzip(child); result += common::escapedText(gzip); } } setText(result); }