Browse Source

Made protocol generator much more usable, more UI tweaks needed to improve usability

QGC4.4
pixhawk 14 years ago
parent
commit
8883cb2308
  1. 1
      src/standalone/mavlinkgen/MAVLinkGen.cc
  2. 4
      src/ui/XMLCommProtocolWidget.cc
  3. 66
      src/ui/mavlink/DomModel.cc

1
src/standalone/mavlinkgen/MAVLinkGen.cc

@ -80,6 +80,7 @@ MAVLinkGen::MAVLinkGen(int &argc, char* argv[]) : QApplication(argc, argv)
QMainWindow* window = new QMainWindow(); QMainWindow* window = new QMainWindow();
window->setCentralWidget(new XMLCommProtocolWidget(window)); window->setCentralWidget(new XMLCommProtocolWidget(window));
window->setWindowTitle(applicationName() + " " + applicationVersion()); window->setWindowTitle(applicationName() + " " + applicationVersion());
// window->setBaseSize(qMin(1024, static_cast<int>(QApplication::desktop()->width()*0.8f)), qMin(900, static_cast<int>(QApplication::desktop()->height()*0.8f)));
window->show(); window->show();
} }

4
src/ui/XMLCommProtocolWidget.cc

@ -79,7 +79,9 @@ void XMLCommProtocolWidget::setXML(const QString& xml)
} }
model = new DomModel(doc, this); model = new DomModel(doc, this);
m_ui->xmlTreeView->setModel(model); m_ui->xmlTreeView->setModel(model);
m_ui->xmlTreeView->expandAll(); // Expand the tree so that message names are visible
m_ui->xmlTreeView->expandToDepth(1);
m_ui->xmlTreeView->hideColumn(2);
m_ui->xmlTreeView->repaint(); m_ui->xmlTreeView->repaint();
} }

66
src/ui/mavlink/DomModel.cc

@ -44,31 +44,81 @@ QVariant DomModel::data(const QModelIndex &index, int role) const
if (attribute.nodeName() == "name") return attribute.nodeValue(); if (attribute.nodeName() == "name") return attribute.nodeValue();
} }
} }
if (node.nodeName() == "field") else if (node.nodeName() == "field")
{ {
for (int i = 0; i < attributeMap.count(); ++i) { for (int i = 0; i < attributeMap.count(); ++i) {
QDomNode attribute = attributeMap.item(i); QDomNode attribute = attributeMap.item(i);
if (attribute.nodeName() == "name") return attribute.nodeValue(); if (attribute.nodeName() == "name") return attribute.nodeValue();
} }
} }
else if (node.nodeName() == "enum")
{
for (int i = 0; i < attributeMap.count(); ++i) {
QDomNode attribute = attributeMap.item(i);
if (attribute.nodeName() == "name") return attribute.nodeValue();
}
}
else if (node.nodeName() == "entry")
{
for (int i = 0; i < attributeMap.count(); ++i) {
QDomNode attribute = attributeMap.item(i);
if (attribute.nodeName() == "name") return attribute.nodeValue();
}
}
else if (node.nodeName() == "#text")
{
return node.nodeValue().split("\n").join(" ");
}
else else
{ {
return node.nodeName(); return node.nodeName();
} }
} }
break;
case 1: case 1:
if (node.nodeName() == "description")
{
return node.nodeValue().split("\n").join(" ");
}
else
{
for (int i = 0; i < attributeMap.count(); ++i) { for (int i = 0; i < attributeMap.count(); ++i) {
QDomNode attribute = attributeMap.item(i); QDomNode attribute = attributeMap.item(i);
attributes << attribute.nodeName() + "=\""
+attribute.nodeValue() + "\""; if (attribute.nodeName() == "id" || attribute.nodeName() == "index" || attribute.nodeName() == "value")
{
return QString("(# %1)").arg(attribute.nodeValue());
} }
return attributes.join(" "); else if (attribute.nodeName() == "type")
case 2: {
return node.nodeValue().split("\n").join(" "); return attribute.nodeValue();
}
}
}
break;
// case 2:
// {
//// if (node.nodeName() != "description")
//// {
//// for (int i = 0; i < attributeMap.count(); ++i) {
//// QDomNode attribute = attributeMap.item(i);
//// attributes << attribute.nodeName() + "=\""
//// +attribute.nodeValue() + "\"";
//// }
//// return attributes.join(" ");
//// }
//// else
//// {
//// return node.nodeValue().split("\n").join(" ");
//// }
// }
// break;
default: default:
{
return QVariant(); return QVariant();
} }
} }
}
Qt::ItemFlags DomModel::flags(const QModelIndex &index) const Qt::ItemFlags DomModel::flags(const QModelIndex &index) const
{ {
@ -86,9 +136,9 @@ QVariant DomModel::headerData(int section, Qt::Orientation orientation,
case 0: case 0:
return tr("Name "); return tr("Name ");
case 1: case 1:
return tr("Attributes");
case 2:
return tr("Value"); return tr("Value");
// case 2:
// return tr("Description");
default: default:
return QVariant(); return QVariant();
} }

Loading…
Cancel
Save