int KisModelIndexConverterShowAll::rowCount(QModelIndex parent) { if(!parent.isValid()) return 1; KisNodeDummy *parentDummy = dummyFromIndex(parent); return parentDummy->childCount(); }
KisNodeDummy* KisModelIndexConverterShowAll::dummyFromRow(int row, QModelIndex parent) { Q_ASSERT(parent.isValid() || !row); if(!parent.isValid()) return m_dummiesFacade->rootDummy(); KisNodeDummy *parentDummy = dummyFromIndex(parent); int rowCount = parentDummy->childCount(); int index = rowCount - row - 1; return parentDummy->at(index); }
QModelIndex KisModelIndexConverterShowAll::indexFromDummy(KisNodeDummy *dummy) { int row = 0; KisNodeDummy *parentDummy = dummy->parent(); if(parentDummy) { int rowCount = parentDummy->childCount(); int index = parentDummy->indexOf(dummy); row = rowCount - index - 1; } return m_model->createIndex(row, 0, (void*)dummy); }