1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

OP-1538 Added table format + colors

This commit is contained in:
Laurent Lalanne 2014-10-13 21:52:12 +02:00
parent 638588c182
commit 80fb6565b3

View File

@ -280,64 +280,65 @@ void UAVObjectBrowserWidget::splitterMoved()
QString UAVObjectBrowserWidget::createObjectDescription(UAVObject *object)
{
QString indent("        ");
QString description;
description.append("<html><head></head><body style=\" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;\">");
description.append("<b>").append(tr("Name:")).append(" </b>").append(object->getName())
.append("<br>");
description.append("<b>").append(tr("Type:")).append(" </b>")
.append(object->isSettingsObject() ? tr("Settings") : object->isMetaDataObject() ? tr("Metadata") : tr("Data"))
.append(indent);
description.append("<b>").append(tr("Category:")).append(" </b>").append(object->getCategory())
.append("<p>");
description.append("<b>").append(tr("Description:")).append(" </b>").append(object->getDescription().replace("@ref", ""))
.append("<hr><br>");
description.append("<b>").append(tr("Fields:")).append(" </b>")
.append("<br>");
description.append("<table border='0' width='99%' cellpadding='5' cellspacing='0'><tbody><tr bgcolor='#ffcc00'>");
description.append("<td nowrap='nowrap'><b>").append(tr("Name:")).append(" </b>").append(object->getName());
description.append("<br><b>").append(tr("Type:")).append(" </b>")
.append(object->isSettingsObject() ? tr("Settings") : object->isMetaDataObject() ? tr("Metadata") : tr("Data"));
description.append("<br><b>").append(tr("Category:")).append(" </b>").append(object->getCategory());
description.append("</td><td colspan='3' rowspan='1' valign='middle'><b>");
description.append(tr("Description:")).append(" </b>").append(object->getDescription().replace("@ref", ""))
.append("</td></tr><tr><td colspan='4' rowspan='1' valign='middle'><hr></td></tr>");
description.append("<tr><td><b>").append(tr("Fields:")).append(" </b></td>");
int fields = 0;
foreach (UAVObjectField *field, object->getFields()) {
description.append(indent).append("<b>").append(tr("Name:")).append(" </b>").append(field->getName())
.append(indent);
fields++;
description.append("</tr><tr><td nowrap='nowrap' ").append(fields & 1 ? "bgcolor='#ffcc99'>" : "bgcolor='#ff9900'>");
description.append("<b>").append(tr("Name:")).append(" </b>").append(field->getName())
.append("</td><td").append(fields & 1 ? " bgcolor='#ffcc99'>" : " bgcolor='#ff9900'>");
description.append("<b>").append(tr("Size:")).append(" </b>").append(tr("%1 bytes").arg(field->getNumBytes()))
.append(indent);
.append("</td>");
description.append("<b>").append(tr("Type:")).append(" </b>").append(field->getTypeAsString());
description.append("<td").append(fields & 1 ? " bgcolor='#ffcc99'>" : " bgcolor='#ff9900'>");
description.append(tr("<b>Type:")).append(" </b>").append(field->getTypeAsString());
int elements = field->getNumElements();
if (elements > 1) {
description.append("[").append(QString("%1").arg(field->getNumElements())).append("]");
}
description.append(indent).append("<b>").append(tr("Unit:")).append(" </b>").append(field->getUnits());
description.append("</td><td").append(fields & 1 ? " bgcolor='#ffcc99'>" : " bgcolor='#ff9900'>");
description.append("<b>").append(tr("Unit:")).append(" </b>").append(field->getUnits());
description.append("<br>");
description.append("</td></tr>");
if (field->getDescription() != "") {
description.append(indent).append("<b>").append(tr("Description:")).append(" </b>").append(field->getDescription());
description.append("<br>");
description.append("<tr><td").append(fields & 1 ? " bgcolor='#ffcc99'>" : " bgcolor='#ff9900'>");
description.append("<b>").append(tr("Description:")).append(" </b>").append(field->getDescription());
description.append("</td></tr>");
}
if (elements > 1) {
description.append(indent).append("<b>").append(tr("Elements:")).append(" </b>").append("<br>");
description.append("<tr><td></td><td>").append("<b>").append(tr("Elements:")).append(" </b>").append("</td><td>");
QStringList names = field->getElementNames();
for (uint i = 0; i < field->getNumElements(); i++) {
description.append(indent).append(indent).append("<b>").append(tr("Name:")).append(" </b>").append(names.at(i))
.append(indent);
description.append( i == 0 ? tr("<b>Name: </b>") : " | ").append(names.at(i));
if (field->getMinLimit(i).toString() != "" && field->getMaxLimit(i).toString() != "") {
description.append("<b>").append(tr("Limits:")).append(" </b>")
.append(QString("%1 - %2").arg(field->getMinLimit(i).toString(), field->getMaxLimit(i).toString()));
description.append(QString(" %1 - %2 ").arg(field->getMinLimit(i).toString(), field->getMaxLimit(i).toString()));
}
description.append("<br>");
}
description.append("<p>");
description.append("</td></tr>");
} else {
if (field->getMinLimit(0).toString() != "" && field->getMaxLimit(0).toString() != "") {
description.append(indent).append("<b>").append(tr("Limits:")).append(" </b>")
.append(QString("%1 - %2").arg(field->getMinLimit(0).toString(), field->getMaxLimit(0).toString()));
description.append("<p>");
description.append("<tr><td>").append(tr("<b> Limits: </b>")).append(" </b>")
.append(QString(" %1 - %2 ").arg(field->getMinLimit(0).toString(), field->getMaxLimit(0).toString()));
description.append("</td></tr>");
}
}
}
description.append("</body></html>");
description.append("</tbody></table></body></html>");
return description;
}