3 #include "findresultitem.h"
5 FindResultItem::FindResultItem(const QVector<QVariant> &data, FindResultItem *parent)
11 FindResultItem::~FindResultItem()
13 qDeleteAll(childItems);
16 FindResultItem *FindResultItem::child(int number)
18 return childItems.value(number);
21 int FindResultItem::childCount() const
23 return childItems.count();
26 int FindResultItem::childNumber() const
29 return parentItem->childItems.indexOf(const_cast<FindResultItem*>(this));
34 int FindResultItem::columnCount() const
36 return itemData.count();
39 QVariant FindResultItem::data(int column) const
41 return itemData.value(column);
44 bool FindResultItem::insertChildren(int position, int count, int columns)
46 if (position < 0 || position > childItems.size())
49 for (int row = 0; row < count; ++row) {
50 QVector<QVariant> data(columns);
51 FindResultItem *item = new FindResultItem(data, this);
52 childItems.insert(position, item);
58 bool FindResultItem::insertColumns(int position, int columns)
60 if (position < 0 || position > itemData.size())
63 for (int column = 0; column < columns; ++column)
64 itemData.insert(position, QVariant());
66 foreach (FindResultItem *child, childItems)
67 child->insertColumns(position, columns);
72 FindResultItem *FindResultItem::parent()
77 bool FindResultItem::removeChildren(int position, int count)
79 if (position < 0 || position + count > childItems.size())
82 for (int row = 0; row < count; ++row)
83 delete childItems.takeAt(position);
88 bool FindResultItem::removeColumns(int position, int columns)
90 if (position < 0 || position + columns > itemData.size())
93 for (int column = 0; column < columns; ++column)
94 itemData.remove(position);
96 foreach (FindResultItem *child, childItems)
97 child->removeColumns(position, columns);
102 bool FindResultItem::setData(int column, const QVariant &value)
104 if (column < 0 || column >= itemData.size())
107 itemData[column] = value;