BOOL CPropDlg::OnInitDialog() { CDialog::OnInitDialog(); SetWindowText(L"Properties - " + m_titleDesc); // Full-row selection is more intuitive // m_propList.SetExtendedStyle(m_propList.GetExtendedStyle() | LVS_EX_FULLROWSELECT); // Set up the name/value colums for the property list. // m_propList.InsertColumn(0, L"Name", LVCFMT_LEFT, 128); m_propList.InsertColumn(1, L"Value", LVCFMT_LEFT, 384); CArray<DISPID> aDispIDs; CArray<CStringW> asNames, asValues; GetObjectProperties(m_object, aDispIDs, asNames, asValues); ASSERT(aDispIDs.GetSize() == asNames.GetSize()); ASSERT(aDispIDs.GetSize() == asValues.GetSize()); for (int iItemCnt = 0; iItemCnt < aDispIDs.GetSize(); iItemCnt++) { int listItem = m_propList.InsertItem(0, asNames[iItemCnt]); m_propList.SetItemData(listItem, (DWORD_PTR)aDispIDs[iItemCnt]); m_propList.SetItemText(listItem, 1, asValues[iItemCnt]); } if (m_propList.GetItemCount() > 0) m_propList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED); // Set up resizing // m_resizeHelper.Init(m_hWnd); m_resizeHelper.Fix(IDC_PROPLIST, DlgResizeHelper::kLeftRight, DlgResizeHelper::kTopBottom); m_resizeHelper.Fix(IDC_PROPERTIES_BUTTON, DlgResizeHelper::kWidthRight, DlgResizeHelper::kHeightTop); m_resizeHelper.Fix(IDOK, DlgResizeHelper::kWidthRight, DlgResizeHelper::kHeightTop); updateButtons(); return TRUE; }
/* Add a new PBTreeNode based upon the supplied DBus object_path */ PBTreeNode* PBTreeNode::AddNode(PBTreeNode* parentNode, \ const QDBusObjectPath &object_path) { PBTreeNode* pbtn = NULL; // special case for the root node if(parentNode->object_path.path().isNull()) { // We ARE the parentNode this time pbtn = parentNode; } else { pbtn = new PBTreeNode(); } pbtn->object_path = object_path; pbtn->parent=parentNode; // The introspected string describing this object const QString intro_xml = GetIntrospectXml(object_path); pbtn->introspection=new QDomDocument(intro_xml); pbtn->xmlstring = intro_xml; /* We fill in all the children. * * We do this by creating a new child node for each node in intro_xml, * and then introspecting these child nodes until we get nothing more */ QDomDocument doc; doc.setContent(intro_xml); QDomElement xmlnode=doc.documentElement(); QDomElement child=xmlnode.firstChildElement(); while(!child.isNull()) { // Is this a node? if (child.tagName() == "node") { // Yes, so we should introspect that as well QString child_path; if (object_path.path() == "/") { child_path = object_path.path() + child.attribute("name"); } else { child_path = object_path.path() + "/" + child.attribute("name"); } QDBusObjectPath child_object_path(child_path); PBTreeNode* node = AddNode(pbtn,child_object_path); if (node) { pbtn->children.append(node); } } // Is this an interface? if (child.tagName() == "interface") { QString iface_name = child.attribute("name"); // we dont need properties from freedesktop interfaces if (iface_name != ofDIntrospectableName && \ iface_name != ofDPropertiesName) { QVariantMap properties; properties = GetObjectProperties(object_path, iface_name); if (!properties.empty()) { PBObjectInterface *iface = \ new PBObjectInterface(iface_name,properties); pbtn->interfaces.append(iface); } } } child = child.nextSiblingElement(); } return pbtn; }