зеркало из https://github.com/mozilla/pjs.git
Nodes now track their correct indentation levels (from the content model).
This commit is contained in:
Родитель
4406d09257
Коммит
9fe4aa6738
|
@ -80,15 +80,21 @@ void nsHTDataModel::SetContentRootDelegate(nsIContent* pContent)
|
|||
|
||||
// Reconstruct our visibility list (so that all items that are visible
|
||||
// are instantiated). Need to only look for folder and item children. All other children should be ignored.
|
||||
AddNodesToArray(mContentRoot);
|
||||
AddNodesToArray(mContentRoot, 0);
|
||||
}
|
||||
|
||||
void nsHTDataModel::AddNodesToArray(nsIContent* pContent)
|
||||
void nsHTDataModel::AddNodesToArray(nsIContent* pContent, PRUint32 indentLevel)
|
||||
{
|
||||
// Add this child to the array (unless it is the root node).
|
||||
nsHierarchicalDataItem* pDataItem = CreateDataItemWithContentNode(pContent);
|
||||
if (pContent != mContentRoot)
|
||||
{
|
||||
// Add to our array
|
||||
mVisibleItemArray.AppendElement(pDataItem);
|
||||
// Set the correct indent level for the item.
|
||||
pDataItem->SetIndentationLevel(indentLevel);
|
||||
indentLevel++;
|
||||
}
|
||||
else mRootNode = pDataItem;
|
||||
|
||||
nsHTItem* pItem = (nsHTItem*)(pDataItem->GetImplData());
|
||||
|
@ -110,7 +116,7 @@ void nsHTDataModel::AddNodesToArray(nsIContent* pContent)
|
|||
pContent->ChildAt(i, child);
|
||||
if (child)
|
||||
{
|
||||
AddNodesToArray(child);
|
||||
AddNodesToArray(child, indentLevel);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(child);
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
nsIImageGroup* GetImageGroup() const { NS_ADDREF(mImageGroup); return mImageGroup; }
|
||||
|
||||
protected:
|
||||
void AddNodesToArray(nsIContent* pContent);
|
||||
void AddNodesToArray(nsIContent* pContent, PRUint32 indentLevel);
|
||||
// This recursive function is called to add nodes to the visibility array.
|
||||
|
||||
enum { cDMImageLoaded = 0 } ;
|
||||
|
|
|
@ -26,6 +26,7 @@ nsHTItem::nsHTItem(nsIContent* pContent, nsHierarchicalDataModel* pDataModel)
|
|||
NS_ADDREF(pContent);
|
||||
mContentNode = pContent;
|
||||
mDataModel = pDataModel;
|
||||
mIndentationLevel = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -41,7 +42,12 @@ PRBool nsHTItem::IsExpandedDelegate() const
|
|||
|
||||
PRUint32 nsHTItem::GetIndentationLevelDelegate() const
|
||||
{
|
||||
return 0;
|
||||
return mIndentationLevel;
|
||||
}
|
||||
|
||||
void nsHTItem::SetIndentationLevelDelegate(PRUint32 n)
|
||||
{
|
||||
mIndentationLevel = n;
|
||||
}
|
||||
|
||||
nsIContent* nsHTItem::FindChildWithName(const nsString& name) const
|
||||
|
|
|
@ -31,13 +31,15 @@ public:
|
|||
|
||||
virtual PRBool IsExpandedDelegate() const;
|
||||
virtual PRUint32 GetIndentationLevelDelegate() const;
|
||||
|
||||
virtual void SetIndentationLevelDelegate(PRUint32 n);
|
||||
|
||||
public:
|
||||
nsIContent* FindChildWithName(const nsString& name) const; // Caller must release the content ptr.
|
||||
|
||||
protected:
|
||||
nsHierarchicalDataModel* mDataModel;
|
||||
nsIContent* mContentNode;
|
||||
PRUint32 mIndentationLevel;
|
||||
};
|
||||
|
||||
#endif /* nsHTItem_h___ */
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
// the concrete implementation.
|
||||
virtual PRBool IsExpanded() const { return IsExpandedDelegate(); };
|
||||
virtual PRUint32 GetIndentationLevel() const { return GetIndentationLevelDelegate(); };
|
||||
virtual void SetIndentationLevel(PRUint32 n) { SetIndentationLevelDelegate(n); };
|
||||
// End of delegated functions
|
||||
|
||||
virtual void GetItemStyle(nsIDeviceContext* dc,
|
||||
|
|
|
@ -35,7 +35,9 @@ public:
|
|||
virtual ~nsHierarchicalDataItem() {};
|
||||
|
||||
virtual PRBool IsExpanded() const = 0;
|
||||
|
||||
virtual PRUint32 GetIndentationLevel() const = 0;
|
||||
virtual void SetIndentationLevel(PRUint32 n) = 0;
|
||||
|
||||
public:
|
||||
void* GetImplData() { return mImplData; }
|
||||
|
|
Загрузка…
Ссылка в новой задаче