11 #include "AbstractParentItem.h"
19 AbstractParentItem::AbstractParentItem(AbstractTreeItem *parent) :
20 AbstractTreeItem(parent) {
22 m_firstVisibleChild = NULL;
23 m_lastVisibleChild = NULL;
28 AbstractParentItem::~AbstractParentItem() {
30 for (
int i = 0; i < m_children->size(); i++) {
31 delete(*m_children)[i];
32 (*m_children)[i] = NULL;
38 if (m_firstVisibleChild) {
39 m_firstVisibleChild = NULL;
42 if (m_lastVisibleChild) {
43 m_lastVisibleChild = NULL;
48 AbstractTreeItem *AbstractParentItem::childAt(
int row)
const {
50 ASSERT(row >= 0 && row < m_children->size());
51 return m_children->value(row);
61 AbstractTreeItem *AbstractParentItem::getFirstVisibleChild()
const {
62 return m_firstVisibleChild;
66 AbstractTreeItem *AbstractParentItem::getLastVisibleChild()
const {
67 return m_lastVisibleChild;
71 int AbstractParentItem::indexOf(AbstractTreeItem *child)
const {
74 return m_children->indexOf(child);
78 int AbstractParentItem::childCount()
const {
80 return m_children->size();
84 void AbstractParentItem::addChild(AbstractTreeItem *child) {
87 ASSERT(!
dynamic_cast< RootItem *
>(child));
101 m_children->append(child);
102 child->setParent(
this);
112 void AbstractParentItem::setFirstVisibleChild(AbstractTreeItem *child) {
113 m_firstVisibleChild = child;
117 void AbstractParentItem::setLastVisibleChild(AbstractTreeItem *child) {
118 m_lastVisibleChild = child;