Id Id::fromSetting(const QVariant &variant) { const QByteArray ba = variant.toString().toUtf8(); if (ba.isEmpty()) return Id(); return Id(theId(ba)); }
bool RegTreeCtrl::TreeNode::DeleteChild(TreeNode *child) { int index = m_aChildren.Index(child); wxCHECK_MSG( index != wxNOT_FOUND, false, wxT("our child in tree should be in m_aChildren") ); m_aChildren.RemoveAt((size_t)index); bool ok; if ( child->IsKey() ) { // must close key before deleting it child->OnCollapse(); ok = Key().DeleteKey(child->m_strName); } else { ok = Key().DeleteValue(child->m_strName); } if ( ok ) { wxTreeItemId theId(child->Id()); // Temp variable seems necessary for BC++ m_pTree->Delete(theId); Refresh(); } return ok; }
void RegTreeCtrl::TreeNode::Refresh() { if ( !IsKey() ) return; wxTreeItemId theId(Id()); // Temp variable seems necessary for BC++ bool wasExpanded = m_pTree->IsExpanded(theId); if ( wasExpanded ) m_pTree->Collapse(theId); OnCollapse(); m_pTree->SetItemHasChildren(theId); if ( wasExpanded ) { m_pTree->Expand(theId); OnExpand(); } }
// ---------------------------------------------------------------------------- // TreeNode implementation // ---------------------------------------------------------------------------- bool RegTreeCtrl::TreeNode::OnExpand() { // we add children only once if ( !m_aChildren.IsEmpty() ) { // we've been already expanded return true; } if ( IsRoot() ) { // we're the root key m_pTree->AddStdKeys(); return true; } if ( Parent()->IsRoot() ) { // we're a standard key m_pKey = new wxRegKey(m_strName, m_viewMode); } else { // we're a normal key m_pKey = new wxRegKey(*(Parent()->m_pKey), m_strName); } if ( !m_pKey->Open() ) { wxLogError(wxT("The key '%s' can't be opened."), FullName()); return false; } // if we're empty, we shouldn't be expandable at all bool isEmpty = true; // enumeration variables long l; wxString str; bool bCont; // enumerate all subkeys bCont = m_pKey->GetFirstKey(str, l); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while ( bCont ) { m_pTree->InsertNewTreeNode( this, str, RegImageList::ClosedKey, NULL, m_viewMode); bCont = m_pKey->GetNextKey(str, l); // we have at least this key... isEmpty = false; } // enumerate all values bCont = m_pKey->GetFirstValue(str, l); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while ( bCont ) { wxString strItem; if (str.empty()) strItem = wxT("<default>"); else strItem = str; strItem += wxT(" = "); // determine the appropriate icon RegImageList::Icon icon; switch ( m_pKey->GetValueType(str) ) { case wxRegKey::Type_String: case wxRegKey::Type_Expand_String: case wxRegKey::Type_Multi_String: { wxString strValue; icon = RegImageList::TextValue; m_pKey->QueryValue(str, strValue); strItem += strValue; } break; case wxRegKey::Type_None: // @@ handle the error... icon = RegImageList::BinaryValue; break; case wxRegKey::Type_Dword: { long l; m_pKey->QueryValue(str, &l); strItem << l; } // fall through default: icon = RegImageList::BinaryValue; } m_pTree->InsertNewTreeNode(this, str, icon, &strItem, m_viewMode); bCont = m_pKey->GetNextValue(str, l); // we have at least this value... isEmpty = false; } if ( isEmpty ) { // this is for the case when our last child was just deleted wxTreeItemId theId(Id()); // Temp variable seems necessary for BC++ m_pTree->Collapse(theId); // we won't be expanded any more m_pTree->SetItemHasChildren(theId, false); } return true; }
Id Id::fromName(const QByteArray &name) { return Id(theId(name)); }
Id Id::fromString(const QString &name) { if (name.isEmpty()) return Id(); return Id(theId(name.toUtf8())); }
/*! Constructs an id given its associated \a name. The internal representation will be unspecified, but consistent within a \QC process. */ Id::Id(const char *name) : m_id(theId(name, 0)) {}
static quintptr theId(const QByteArray &ba) { return theId(ba.constData(), ba.size()); }
/*! \overload */ Id::Id(const QByteArray &name) : m_id(theId(name)) {}