QModelIndex ProjectDirModel::index(int row, int column, const QModelIndex &parent) const { if (column != 0) return QModelIndex(); DvDirModelNode *parentNode = m_root; if (parent.isValid()) parentNode = getNode(parent); if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex(); DvDirModelNode *node = parentNode->getChild(row); return createIndex(row, column, node); }
void ProjectDirModel::refresh(const QModelIndex &index) { if (!index.isValid()) return; DvDirModelNode *node = getNode(index); if (!node) return; emit layoutAboutToBeChanged(); emit beginRemoveRows(index, 0, node->getChildCount()); node->refreshChildren(); emit endRemoveRows(); emit layoutChanged(); }
QModelIndex ProjectDirModel::childByName(const QModelIndex &parent, const std::wstring &name) const { if (!parent.isValid()) return QModelIndex(); DvDirModelNode *parentNode = getNode(parent); if (!parentNode) return QModelIndex(); int row = parentNode->rowByName(name); if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex(); DvDirModelNode *childNode = parentNode->getChild(row); return createIndex(row, 0, childNode); }
void ExportSceneDvDirModel::refresh(const QModelIndex &index) { DvDirModelNode *node; if (!index.isValid()) node = m_root; else node = getNode(index); if (!node) return; emit layoutAboutToBeChanged(); emit beginRemoveRows(index, 0, node->getChildCount()); node->refreshChildren(); emit endRemoveRows(); emit layoutChanged(); }
int ProjectDirModel::rowCount(const QModelIndex &parent) const { DvDirModelNode *node = getNode(parent); int childCount = node->getChildCount(); return childCount; }