last-svn-commit-761-gf54c0a6 demo/viewer/xml_widget.cc: Fix data tracking of selected objects.

--- scribo/ChangeLog | 5 ++ scribo/demo/viewer/xml_widget.cc | 117 ++++++++++++++++++-------------------- 2 files changed, 60 insertions(+), 62 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 03705c9..4c39daf 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,10 @@ 2011-02-05 Guillaume Lazzara <z@lrde.epita.fr> + * demo/viewer/xml_widget.cc: Fix data tracking of selected + objects. + +2011-02-05 Guillaume Lazzara <z@lrde.epita.fr> + Display baseline and meanline in Scribo viewer. * demo/viewer/common.hh: Add new enums. diff --git a/scribo/demo/viewer/xml_widget.cc b/scribo/demo/viewer/xml_widget.cc index c45177b..1f2bc83 100644 --- a/scribo/demo/viewer/xml_widget.cc +++ b/scribo/demo/viewer/xml_widget.cc @@ -50,21 +50,14 @@ XmlWidget::select(QString id, QString name) { QDomNode n = node_map_[item_map_[id]]; - if (name.contains("Text line")) - { - n = n.firstChild(); - while (!n.isNull() && !n.toElement().tagName().contains("line")) - n = n.nextSibling(); - } - if (!n.isNull()) - { - QTreeWidgetItem* item = node_map_.key(n); + { + QTreeWidgetItem* item = node_map_.key(n); - tree_->setCurrentItem(item, 0); - item->setExpanded(true); - check_item(item); - } + tree_->setCurrentItem(item, 0); + item->setExpanded(true); + check_item(item); + } } void @@ -73,17 +66,17 @@ XmlWidget::check_item (QTreeWidgetItem* item) QDomNode node = node_map_[item]; if (node.hasAttributes()) + { + property_->clear(); + QDomNamedNodeMap attributes = node.toElement().attributes(); + + for (int i = 0; i < attributes.count(); ++i) { - property_->clear(); - QDomNamedNodeMap attributes = node.toElement().attributes(); - - for (int i = 0; i < attributes.count(); ++i) - { - QStringList values; - values << attributes.item(i).toAttr().name() << attributes.item(i).toAttr().value(); - property_->addTopLevelItem(new QTreeWidgetItem(values)); - } + QStringList values; + values << attributes.item(i).toAttr().name() << attributes.item(i).toAttr().value(); + property_->addTopLevelItem(new QTreeWidgetItem(values)); } + } property_->resizeColumnToContents(0); } @@ -91,42 +84,42 @@ XmlWidget::check_item (QTreeWidgetItem* item) void XmlWidget::NFS(QDomNode node, QTreeWidgetItem* item) { if (!node.isNull()) + { + QString append; + if (node.toElement().tagName().contains("point")) + { + QString x = node.toElement().attribute("x", "0"); + QString y = node.toElement().attribute("y", "0"); + append.append(" = (" + x + ", " + y + ")"); + } + + QTreeWidgetItem* child = + new QTreeWidgetItem(QStringList(node.toElement().tagName() + node.nodeValue() + append)); + + if (node.hasAttributes()) + { + QString id = node.toElement().attribute("id", "none"); + item_map_[id] = child; + } + + node_map_[child] = node; + item->addChild(child); + + QDomNode sibling = node.firstChild(); + while (!sibling.isNull()) { - QString append; - if (node.toElement().tagName().contains("point")) - { - QString x = node.toElement().attribute("x", "0"); - QString y = node.toElement().attribute("y", "0"); - append.append(" = (" + x + ", " + y + ")"); - } - - QTreeWidgetItem* child = - new QTreeWidgetItem(QStringList(node.toElement().tagName() + node.nodeValue() + append)); - - if (node.hasAttributes()) - { - QString id = node.toElement().attribute("id", "none"); - item_map_[id] = child; - } - - node_map_[child] = node; - item->addChild(child); - - QDomNode sibling = node.firstChild(); - while (!sibling.isNull()) - { - if (!sibling.toElement().tagName().contains("data")) - NFS(sibling, child); - else - { - QTreeWidgetItem* child_son = - new QTreeWidgetItem(QStringList("data = base64-encoded")); - - child->addChild(child_son); - } - sibling = sibling.nextSibling(); - } + if (!sibling.toElement().tagName().contains("data")) + NFS(sibling, child); + else + { + QTreeWidgetItem* child_son = + new QTreeWidgetItem(QStringList("data = base64-encoded")); + + child->addChild(child_son); + } + sibling = sibling.nextSibling(); } + } } void XmlWidget::fill_widget(QString xml) @@ -147,17 +140,17 @@ void XmlWidget::fill_widget(QString xml) QDomElement root = doc.documentElement(); QTreeWidgetItem* root_item= - new QTreeWidgetItem(QStringList(root.tagName())); + new QTreeWidgetItem(QStringList(root.tagName())); tree_->addTopLevelItem(root_item); root = root.firstChild().toElement(); while (!root.isNull()) - { - ++i; - NFS(root, root_item); - root = root.nextSibling().toElement(); - } + { + ++i; + NFS(root, root_item); + root = root.nextSibling().toElement(); + } } void -- 1.5.6.5
participants (1)
-
Guillaume Lazzara