Implement ranged container hooks for B{Object}List handler.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012, Rene Gollent, [email protected]
|
* Copyright 2012-2013, Rene Gollent, [email protected]
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -165,7 +165,8 @@ BListValueNode::BListValueNode(ValueNodeChild* nodeChild,
|
|||||||
fType(type),
|
fType(type),
|
||||||
fLoader(NULL),
|
fLoader(NULL),
|
||||||
fItemCountType(NULL),
|
fItemCountType(NULL),
|
||||||
fItemCount(0)
|
fItemCount(0),
|
||||||
|
fCountChildCreated(false)
|
||||||
{
|
{
|
||||||
fType->AcquireReference();
|
fType->AcquireReference();
|
||||||
}
|
}
|
||||||
@@ -304,19 +305,60 @@ BListValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
|||||||
status_t
|
status_t
|
||||||
BListValueNode::CreateChildren()
|
BListValueNode::CreateChildren()
|
||||||
{
|
{
|
||||||
if (fChildrenCreated)
|
return CreateChildrenInRange(0, kMaxArrayElementCount);
|
||||||
return B_OK;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
BListValueNode::CountChildren() const
|
||||||
|
{
|
||||||
|
return fChildren.CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ValueNodeChild*
|
||||||
|
BListValueNode::ChildAt(int32 index) const
|
||||||
|
{
|
||||||
|
return fChildren.ItemAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BListValueNode::IsRangedContainer() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BListValueNode::ClearChildren()
|
||||||
|
{
|
||||||
|
fChildren.MakeEmpty();
|
||||||
|
fCountChildCreated = false;
|
||||||
|
if (fContainer != NULL)
|
||||||
|
fContainer->NotifyValueNodeChildrenDeleted(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BListValueNode::CreateChildrenInRange(int32 lowIndex, int32 highIndex)
|
||||||
|
{
|
||||||
if (fLocationResolutionState != B_OK)
|
if (fLocationResolutionState != B_OK)
|
||||||
return fLocationResolutionState;
|
return fLocationResolutionState;
|
||||||
|
|
||||||
if (fItemCountType != NULL) {
|
if (lowIndex < 0)
|
||||||
|
lowIndex = 0;
|
||||||
|
if (highIndex >= fItemCount)
|
||||||
|
highIndex = fItemCount - 1;
|
||||||
|
|
||||||
|
if (!fCountChildCreated && fItemCountType != NULL) {
|
||||||
BListItemCountNodeChild* countChild = new(std::nothrow)
|
BListItemCountNodeChild* countChild = new(std::nothrow)
|
||||||
BListItemCountNodeChild(fItemCountLocation, this, fItemCountType);
|
BListItemCountNodeChild(fItemCountLocation, this, fItemCountType);
|
||||||
|
|
||||||
if (countChild == NULL)
|
if (countChild == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
fCountChildCreated = true;
|
||||||
countChild->SetContainer(fContainer);
|
countChild->SetContainer(fContainer);
|
||||||
fChildren.AddItem(countChild);
|
fChildren.AddItem(countChild);
|
||||||
}
|
}
|
||||||
@@ -343,7 +385,7 @@ BListValueNode::CreateChildren()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32 i = 0; i < fItemCount && i < kMaxArrayElementCount; i++)
|
for (int32 i = lowIndex; i <= highIndex; i++)
|
||||||
{
|
{
|
||||||
BListElementNodeChild* child =
|
BListElementNodeChild* child =
|
||||||
new(std::nothrow) BListElementNodeChild(this, i, type);
|
new(std::nothrow) BListElementNodeChild(this, i, type);
|
||||||
@@ -362,15 +404,12 @@ BListValueNode::CreateChildren()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
status_t
|
||||||
BListValueNode::CountChildren() const
|
BListValueNode::SupportedChildRange(int32& lowIndex, int32& highIndex) const
|
||||||
{
|
{
|
||||||
return fChildren.CountItems();
|
lowIndex = 0;
|
||||||
|
highIndex = fItemCount - 1;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ValueNodeChild*
|
|
||||||
BListValueNode::ChildAt(int32 index) const
|
|
||||||
{
|
|
||||||
return fChildren.ItemAt(index);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012, Rene Gollent, [email protected].
|
* Copyright 2012-2013, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef BLIST_VALUE_NODE_H
|
#ifndef BLIST_VALUE_NODE_H
|
||||||
@@ -36,6 +36,12 @@ public:
|
|||||||
virtual int32 CountChildren() const;
|
virtual int32 CountChildren() const;
|
||||||
virtual ValueNodeChild* ChildAt(int32 index) const;
|
virtual ValueNodeChild* ChildAt(int32 index) const;
|
||||||
|
|
||||||
|
virtual bool IsRangedContainer() const;
|
||||||
|
virtual void ClearChildren();
|
||||||
|
virtual status_t CreateChildrenInRange(int32 lowIndex,
|
||||||
|
int32 highIndex);
|
||||||
|
virtual status_t SupportedChildRange(int32& lowIndex,
|
||||||
|
int32& highIndex) const;
|
||||||
private:
|
private:
|
||||||
class BListElementNodeChild;
|
class BListElementNodeChild;
|
||||||
class BListItemCountNodeChild;
|
class BListItemCountNodeChild;
|
||||||
@@ -55,6 +61,7 @@ private:
|
|||||||
BVariant fItemCountLocation;
|
BVariant fItemCountLocation;
|
||||||
Type* fItemCountType;
|
Type* fItemCountType;
|
||||||
int32 fItemCount;
|
int32 fItemCount;
|
||||||
|
bool fCountChildCreated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user