Simplify temporary JSON Objects

This commit is contained in:
Anton Thomasson 2021-05-13 19:53:25 +02:00
parent 580bbdfdbb
commit 126940f8ea
2 changed files with 5 additions and 13 deletions

View file

@ -102,22 +102,15 @@ QJsonValue IppMsg::consume_value(quint8 tag, Bytestream& data)
{ {
qint32 x, y; qint32 x, y;
qint8 units; qint8 units;
QJsonObject tmp_res;
data >> tmp_len >> x >> y >> units; data >> tmp_len >> x >> y >> units;
tmp_res.insert("x", x); value = QJsonObject {{"x", x}, {"y", y}, {"units", units}};
tmp_res.insert("y", y);
tmp_res.insert("units", units);
value = tmp_res;
break; break;
} }
case IntegerRange: case IntegerRange:
{ {
qint32 low, high; qint32 low, high;
data >> tmp_len >> low >> high; data >> tmp_len >> low >> high;
QJsonObject tmp_range; value = QJsonObject {{"low", low}, {"high", high}};
tmp_range.insert("low", low);
tmp_range.insert("high", high);
value = tmp_range;
break; break;
} }
case OctetStringUnknown: case OctetStringUnknown:

View file

@ -434,10 +434,9 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysUseMediaC
if(attrs.contains("printer-resolution")) if(attrs.contains("printer-resolution"))
{ {
QJsonObject tmpObj; QJsonObject tmpObj {{"units", PrinterResolutionRef.toObject()["units"]},
tmpObj["units"] = PrinterResolutionRef.toObject()["units"]; {"x", (int)HwResX},
tmpObj["x"] = (int)HwResX; {"y", (int)HwResY}};
tmpObj["y"] = (int)HwResY;
attrs["printer-resolution"] = QJsonObject { {"tag", IppMsg::Resolution}, {"value", tmpObj} }; attrs["printer-resolution"] = QJsonObject { {"tag", IppMsg::Resolution}, {"value", tmpObj} };
} }
} }