Esempio n. 1
0
int ZObjsModel::rowCount(const QModelIndex &parent) const
{
  ZObjsItem *parentItem;
  if (parent.column() > 0)
    return 0;

  if (!parent.isValid()) {
    parentItem = m_rootItem;
    return parentItem->childCount();
  } else {
    parentItem = static_cast<ZObjsItem*>(parent.internalPointer());
    return parentItem->childCount();
  }
}
Esempio n. 2
0
std::set<Swc_Tree_Node*> ZSwcNodeObjsModel::getSwcTreeNodeSet(
    const QModelIndex &index) const
{
  std::set<Swc_Tree_Node*> nodeSet;
  if (index.isValid()) {
    ZObjsItem *item = static_cast<ZObjsItem*>(index.internalPointer());
    if (item->parent() == m_rootItem) {
      int childNumber = item->childCount();
      for (int i = 0; i < childNumber; ++i) {
        ZObjsItem *childItem = item->child(i);
        Swc_Tree_Node *tn = static_cast<Swc_Tree_Node*>(childItem->getActuralData());
        if (tn != NULL) {
          nodeSet.insert(tn);
        }
      }
    } else {
      Swc_Tree_Node *tn = getSwcTreeNode(index);
      if (tn != NULL) {
        nodeSet.insert(tn);
      }
    }
  }

  return nodeSet;
}