1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include "modelitem.hpp"
ContentSelectorModel::ModelItem::ModelItem(ModelItem* parent)
: mParentItem(parent)
{
}
/*
ContentSelectorModel::ModelItem::ModelItem(const ModelItem *parent)
// : mParentItem(parent)
{
}
*/
ContentSelectorModel::ModelItem::~ModelItem()
{
qDeleteAll(mChildItems);
}
ContentSelectorModel::ModelItem* ContentSelectorModel::ModelItem::parent() const
{
return mParentItem;
}
bool ContentSelectorModel::ModelItem::hasFormat(const QString& mimetype) const
{
if (mimetype == "application/omwcontent")
return true;
return QMimeData::hasFormat(mimetype);
}
int ContentSelectorModel::ModelItem::row() const
{
if (mParentItem)
return 1;
// return mParentItem->childRow(const_cast<ModelItem*>(this));
// return mParentItem->mChildItems.indexOf(const_cast<ModelItem*>(this));
return -1;
}
int ContentSelectorModel::ModelItem::childCount() const
{
return mChildItems.count();
}
int ContentSelectorModel::ModelItem::childRow(ModelItem* child) const
{
Q_ASSERT(child);
return mChildItems.indexOf(child);
}
ContentSelectorModel::ModelItem* ContentSelectorModel::ModelItem::child(int row)
{
return mChildItems.value(row);
}
void ContentSelectorModel::ModelItem::appendChild(ModelItem* item)
{
mChildItems.append(item);
}
void ContentSelectorModel::ModelItem::removeChild(int row)
{
mChildItems.removeAt(row);
}
|