Beispiel #1
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;
}
Beispiel #2
0
QModelIndex ZObjsModel::index(int row, int column, const QModelIndex &parent)
const
{
  if (!hasIndex(row, column, parent))
    return QModelIndex();

  ZObjsItem *parentItem;

  if (!parent.isValid())
    parentItem = m_rootItem;
  else
    parentItem = static_cast<ZObjsItem*>(parent.internalPointer());

  ZObjsItem *childItem = parentItem->child(row);
  if (childItem)
    return createIndex(row, column, childItem);
  else
    return QModelIndex();
}