diff --git a/src/standalone/mavlinkgen/MAVLinkGen.cc b/src/standalone/mavlinkgen/MAVLinkGen.cc index bbec09b..5e17404 100644 --- a/src/standalone/mavlinkgen/MAVLinkGen.cc +++ b/src/standalone/mavlinkgen/MAVLinkGen.cc @@ -80,6 +80,7 @@ MAVLinkGen::MAVLinkGen(int &argc, char* argv[]) : QApplication(argc, argv) QMainWindow* window = new QMainWindow(); window->setCentralWidget(new XMLCommProtocolWidget(window)); window->setWindowTitle(applicationName() + " " + applicationVersion()); +// window->setBaseSize(qMin(1024, static_cast(QApplication::desktop()->width()*0.8f)), qMin(900, static_cast(QApplication::desktop()->height()*0.8f))); window->show(); } diff --git a/src/ui/XMLCommProtocolWidget.cc b/src/ui/XMLCommProtocolWidget.cc index 4cc9709..294a486 100644 --- a/src/ui/XMLCommProtocolWidget.cc +++ b/src/ui/XMLCommProtocolWidget.cc @@ -79,7 +79,9 @@ void XMLCommProtocolWidget::setXML(const QString& xml) } model = new DomModel(doc, this); 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(); } diff --git a/src/ui/mavlink/DomModel.cc b/src/ui/mavlink/DomModel.cc index e084e9a..36138c9 100644 --- a/src/ui/mavlink/DomModel.cc +++ b/src/ui/mavlink/DomModel.cc @@ -44,29 +44,79 @@ QVariant DomModel::data(const QModelIndex &index, int role) const if (attribute.nodeName() == "name") return attribute.nodeValue(); } } - if (node.nodeName() == "field") + else if (node.nodeName() == "field") { for (int i = 0; i < attributeMap.count(); ++i) { QDomNode attribute = attributeMap.item(i); 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 { return node.nodeName(); } } + break; case 1: + if (node.nodeName() == "description") + { + return node.nodeValue().split("\n").join(" "); + } + else + { for (int i = 0; i < attributeMap.count(); ++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()); + } + else if (attribute.nodeName() == "type") + { + return attribute.nodeValue(); + } } - return attributes.join(" "); - case 2: - return node.nodeValue().split("\n").join(" "); + } + 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: + { return QVariant(); + } } } @@ -84,11 +134,11 @@ QVariant DomModel::headerData(int section, Qt::Orientation orientation, if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { switch (section) { case 0: - return tr("Name"); + return tr("Name "); case 1: - return tr("Attributes"); - case 2: return tr("Value"); +// case 2: +// return tr("Description"); default: return QVariant(); } @@ -98,7 +148,7 @@ QVariant DomModel::headerData(int section, Qt::Orientation orientation, } QModelIndex DomModel::index(int row, int column, const QModelIndex &parent) -const + const { if (!hasIndex(row, column, parent)) return QModelIndex();