QModelIndex GraphModel::index(int row, int column, const QModelIndex &parent) const { if (!hasIndex(row, column, parent)) { return QModelIndex(); } GraphItem *parentItem = NULL; if (!parent.isValid()) { parentItem = rootItem; } else { parentItem = static_cast<GraphItem*>(parent.internalPointer()); } GraphItem *childItem = parentItem->Child(row); if (childItem) { return createIndex(row, column, childItem); } return QModelIndex(); }
QModelIndex GraphModel::index(int row, int column, const QModelIndex &parent) const { if (!hasIndex(row, column, parent)) { return QModelIndex(); } GraphItem *parentItem = ParentItem(parent); GraphItem *childItem = parentItem->Child(row); if (childItem) { return createIndex(row, column, childItem); } return QModelIndex(); }