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