void BondDelegate::primitiveAdded(Primitive *primitive)
 {
   if (primitive->type() != Primitive::BondType) 
     return;
     
   // add the new primitive to the end
   model()->insertRows(m_label, m_label->childCount(), 1); 
   // get the item
   ProjectTreeItem *item = m_label->child(m_label->childCount() - 1);
   item->setData(0, tr("bond %1").arg(primitive->index()));
   // set the primitive
   PrimitiveList primitives;
   primitives.append(primitive);
   item->setPrimitives(primitives);
 }
  void SelectionDelegate::initialize()
  {
    // remove any existing rows
    if (m_label->childCount())
      model()->removeRows(m_label, 0, m_label->childCount());

    QList<QString> names = m_widget->namedSelections();
    // add the selectionss...
    model()->insertRows(m_label, 0, names.size());
    for (int i = 0; i < m_label->childCount(); ++i) {
      ProjectTreeItem *item = m_label->child(i);
      item->setData(0,   names.at(i));
      item->setData(1, QString("%1").arg(i));
      // set the primitive
      PrimitiveList primitives = m_widget->namedSelectionPrimitives(i);
      item->setPrimitives(primitives);
    }

  }
  void BondDelegate::initialize()
  {
    Molecule *molecule = m_widget->molecule();

    // remove any existing rows
    if (m_label->childCount())
      model()->removeRows(m_label, 0, m_label->childCount());

    // add the bonds...  
    model()->insertRows(m_label, 0, molecule->numBonds());
    for (int i = 0; i < m_label->childCount(); ++i) {
      ProjectTreeItem *item = m_label->child(i);
      item->setData(0, tr("bond %1").arg(i));
      // set the primitive
      PrimitiveList primitives;
      primitives.append(molecule->bond(i));
      item->setPrimitives(primitives);
    }

  }