Properly handle field names that have multiple indices by publishing
child nodes for them. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42372 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -597,6 +597,26 @@ BMessageValueNode::BMessageFieldNode::GetType() const
|
|||||||
status_t
|
status_t
|
||||||
BMessageValueNode::BMessageFieldNode::CreateChildren()
|
BMessageValueNode::BMessageFieldNode::CreateChildren()
|
||||||
{
|
{
|
||||||
|
Type* type = NULL;
|
||||||
|
status_t error = fParent->_GetTypeForTypeCode(fFieldType, type);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
for (int32 i = 0; i < fFieldCount; i++) {
|
||||||
|
BMessageFieldNodeChild* child = new(std::nothrow)
|
||||||
|
BMessageFieldNodeChild(fParent, type, fName, fFieldType, fFieldCount, i);
|
||||||
|
|
||||||
|
if (child == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
if (fContainer != NULL)
|
||||||
|
child->SetContainer(fContainer);
|
||||||
|
|
||||||
|
fChildren.AddItem(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fContainer != NULL)
|
||||||
|
fContainer->NotifyValueNodeChildrenCreated(this);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,13 +624,13 @@ BMessageValueNode::BMessageFieldNode::CreateChildren()
|
|||||||
int32
|
int32
|
||||||
BMessageValueNode::BMessageFieldNode::CountChildren() const
|
BMessageValueNode::BMessageFieldNode::CountChildren() const
|
||||||
{
|
{
|
||||||
return 0;
|
return fChildren.CountItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueNodeChild*
|
ValueNodeChild*
|
||||||
BMessageValueNode::BMessageFieldNode::ChildAt(int32 index) const
|
BMessageValueNode::BMessageFieldNode::ChildAt(int32 index) const
|
||||||
{
|
{
|
||||||
return NULL;
|
return fChildren.ItemAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -618,7 +638,7 @@ status_t
|
|||||||
BMessageValueNode::BMessageFieldNode::ResolvedLocationAndValue(
|
BMessageValueNode::BMessageFieldNode::ResolvedLocationAndValue(
|
||||||
ValueLoader* loader, ValueLocation *& _location, Value*& _value)
|
ValueLoader* loader, ValueLocation *& _location, Value*& _value)
|
||||||
{
|
{
|
||||||
_location = fParent->Location();
|
_location = NULL;
|
||||||
_value = NULL;
|
_value = NULL;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -630,17 +650,22 @@ BMessageValueNode::BMessageFieldNode::ResolvedLocationAndValue(
|
|||||||
|
|
||||||
BMessageValueNode::BMessageFieldNodeChild::BMessageFieldNodeChild(
|
BMessageValueNode::BMessageFieldNodeChild::BMessageFieldNodeChild(
|
||||||
BMessageValueNode* parent, Type* nodeType, const BString &name,
|
BMessageValueNode* parent, Type* nodeType, const BString &name,
|
||||||
type_code type, int32 count)
|
type_code type, int32 count, int32 index)
|
||||||
:
|
:
|
||||||
ValueNodeChild(),
|
ValueNodeChild(),
|
||||||
fName(name),
|
fName(name),
|
||||||
|
fPresentationName(name),
|
||||||
fType(nodeType),
|
fType(nodeType),
|
||||||
fParent(parent),
|
fParent(parent),
|
||||||
fFieldType(type),
|
fFieldType(type),
|
||||||
fFieldCount(count)
|
fFieldCount(count),
|
||||||
|
fFieldIndex(index)
|
||||||
{
|
{
|
||||||
fParent->AcquireReference();
|
fParent->AcquireReference();
|
||||||
fType->AcquireReference();
|
fType->AcquireReference();
|
||||||
|
|
||||||
|
if (fFieldIndex >= 0)
|
||||||
|
fPresentationName.SetToFormat("[%ld]", fFieldIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -654,7 +679,7 @@ BMessageValueNode::BMessageFieldNodeChild::~BMessageFieldNodeChild()
|
|||||||
const BString&
|
const BString&
|
||||||
BMessageValueNode::BMessageFieldNodeChild::Name() const
|
BMessageValueNode::BMessageFieldNodeChild::Name() const
|
||||||
{
|
{
|
||||||
return fName;
|
return fPresentationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -675,7 +700,7 @@ BMessageValueNode::BMessageFieldNodeChild::Parent() const
|
|||||||
bool
|
bool
|
||||||
BMessageValueNode::BMessageFieldNodeChild::IsInternal() const
|
BMessageValueNode::BMessageFieldNodeChild::IsInternal() const
|
||||||
{
|
{
|
||||||
return false;
|
return fFieldCount > 1 && fFieldIndex == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -702,5 +727,8 @@ BMessageValueNode::BMessageFieldNodeChild::ResolveLocation(
|
|||||||
if (_location == NULL)
|
if (_location == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
return fParent->_FindDataLocation(fName, fFieldType, 0, *_location);
|
return fParent->_FindDataLocation(fName, fFieldType, fFieldIndex >= 0
|
||||||
|
? fFieldIndex : 0, *_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ private:
|
|||||||
BMessageValueNode* fParent;
|
BMessageValueNode* fParent;
|
||||||
type_code fFieldType;
|
type_code fFieldType;
|
||||||
int32 fFieldCount;
|
int32 fFieldCount;
|
||||||
|
ChildNodeList fChildren;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -105,7 +106,8 @@ public:
|
|||||||
BMessageValueNode* parent,
|
BMessageValueNode* parent,
|
||||||
Type* nodeType,
|
Type* nodeType,
|
||||||
const BString &name,
|
const BString &name,
|
||||||
type_code type, int32 count);
|
type_code type, int32 count,
|
||||||
|
int32 index = -1);
|
||||||
|
|
||||||
virtual ~BMessageFieldNodeChild();
|
virtual ~BMessageFieldNodeChild();
|
||||||
|
|
||||||
@@ -122,10 +124,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BString fName;
|
BString fName;
|
||||||
|
BString fPresentationName;
|
||||||
Type* fType;
|
Type* fType;
|
||||||
BMessageValueNode* fParent;
|
BMessageValueNode* fParent;
|
||||||
type_code fFieldType;
|
type_code fFieldType;
|
||||||
int32 fFieldCount;
|
int32 fFieldCount;
|
||||||
|
int32 fFieldIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BMESSAGE_VALUE_NODE_H
|
#endif // BMESSAGE_VALUE_NODE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user