2012-10-10 19:31:40 +00:00
|
|
|
#include "modelitem.hpp"
|
|
|
|
|
2013-08-18 20:11:29 +00:00
|
|
|
EsxModel::ModelItem::ModelItem(ModelItem *parent)
|
2012-10-10 19:31:40 +00:00
|
|
|
: mParentItem(parent)
|
|
|
|
, QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-18 20:11:29 +00:00
|
|
|
EsxModel::ModelItem::~ModelItem()
|
2012-10-10 19:31:40 +00:00
|
|
|
{
|
|
|
|
qDeleteAll(mChildItems);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-18 20:11:29 +00:00
|
|
|
EsxModel::ModelItem *EsxModel::ModelItem::parent()
|
2012-10-10 19:31:40 +00:00
|
|
|
{
|
|
|
|
return mParentItem;
|
|
|
|
}
|
|
|
|
|
2013-08-18 20:11:29 +00:00
|
|
|
int EsxModel::ModelItem::row() const
|
2012-10-10 19:31:40 +00:00
|
|
|
{
|
|
|
|
if (mParentItem)
|
|
|
|
return 1;
|
|
|
|
//return mParentItem->childRow(const_cast<ModelItem*>(this));
|
|
|
|
//return mParentItem->mChildItems.indexOf(const_cast<ModelItem*>(this));
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-18 20:11:29 +00:00
|
|
|
int EsxModel::ModelItem::childCount() const
|
2012-10-10 19:31:40 +00:00
|
|
|
{
|
|
|
|
return mChildItems.count();
|
|
|
|
}
|
|
|
|
|
2013-08-18 20:11:29 +00:00
|
|
|
int EsxModel::ModelItem::childRow(ModelItem *child) const
|
2012-10-10 19:31:40 +00:00
|
|
|
{
|
|
|
|
Q_ASSERT(child);
|
|
|
|
|
|
|
|
return mChildItems.indexOf(child);
|
|
|
|
}
|
|
|
|
|
2013-08-18 20:11:29 +00:00
|
|
|
EsxModel::ModelItem *EsxModel::ModelItem::child(int row)
|
2012-10-10 19:31:40 +00:00
|
|
|
{
|
|
|
|
return mChildItems.value(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-18 20:11:29 +00:00
|
|
|
void EsxModel::ModelItem::appendChild(ModelItem *item)
|
2012-10-10 19:31:40 +00:00
|
|
|
{
|
|
|
|
mChildItems.append(item);
|
|
|
|
}
|
|
|
|
|
2013-08-18 20:11:29 +00:00
|
|
|
void EsxModel::ModelItem::removeChild(int row)
|
2012-10-10 19:31:40 +00:00
|
|
|
{
|
|
|
|
mChildItems.removeAt(row);
|
|
|
|
}
|