当前位置: 首页>>代码示例>>C++>>正文


C++ ProjectTreeItem::setData方法代码示例

本文整理汇总了C++中ProjectTreeItem::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectTreeItem::setData方法的具体用法?C++ ProjectTreeItem::setData怎么用?C++ ProjectTreeItem::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectTreeItem的用法示例。


在下文中一共展示了ProjectTreeItem::setData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: commit

void ProjectModel::commit(QModelIndex &index)
{
    ProjectTreeItem *item = static_cast<ProjectTreeItem*>(index.internalPointer());
    QVariant var = item->data(0, Qt::UserRole);

    CompleteAnnotationItem *oldAnnot = var.value<CompleteAnnotationItem*>();

    AnnotationItem* oldItem = oldAnnot->getItem();

    AnnotationItem* newItem = new AnnotationItem(oldItem->getId(),
                                                 new ConllGraph(*oldItem->getOriginalParse()),
                                                 new ConllGraph(*oldItem->getEditableParse()));

    RevisionAnnotationList revisions;
    for(int i = 0; i < oldAnnot->getRevisionsCount(); i++)
        revisions << oldAnnot->getRevision(i);
    revisions << Revision<AnnotationItem*>(oldItem);

    CompleteAnnotationItem *newAnnot = new CompleteAnnotationItem(oldAnnot->id(), newItem, revisions);

    item->setData(QVariant::fromValue(newAnnot));

    //Which file the item belongs ?
    QString filename = item->parent()->data(0).toString();
    //Get the annotation and update
    int indexFile = item->project()->findFile(filename);
    item->project()->changeAnnotation( indexFile , index.row(), newAnnot );
    //item->project()->addModified( indexFile, index.row() );

}
开发者ID:Cocophotos,项目名称:DepAnnotator,代码行数:30,代码来源:projectmodel.cpp

示例2: initialize

  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);
    }

  }
开发者ID:AlbertDeFusco,项目名称:avogadro,代码行数:19,代码来源:selectiondelegate.cpp

示例3: primitiveUpdated

  void BondDelegate::primitiveUpdated(Primitive *primitive)
  {
    if (primitive->type() == Primitive::MoleculeType) {
      initialize();
      return;
    }

    if (primitive->type() != Primitive::BondType)
      return;
    
    ProjectTreeItem *item = m_label->child(primitive->index()); 
    item->setData(0, tr("bond %1").arg(primitive->index()));
  }
开发者ID:AlbertDeFusco,项目名称:avogadro,代码行数:13,代码来源:bonddelegate.cpp

示例4: setData

bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    if(!index.isValid())
        return false;

    if(role == Qt::EditRole)
    {
        ProjectTreeItem *item = static_cast<ProjectTreeItem*>(index.internalPointer());
        item->setData(value);
        return true;
    }

    return false;
}
开发者ID:Cocophotos,项目名称:DepAnnotator,代码行数:14,代码来源:projectmodel.cpp

示例5: primitiveAdded

 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);
 }
开发者ID:AlbertDeFusco,项目名称:avogadro,代码行数:15,代码来源:bonddelegate.cpp

示例6: primitiveRemoved

  void BondDelegate::primitiveRemoved(Primitive *primitive)
  {
    if (primitive->type() != Primitive::BondType)
      return;

    // remove the row
    model()->removeRows(m_label, primitive->index(), 1);

    // loop over all atoms to fix their index if needed
    if ((primitive->index() + 1) < (unsigned long) m_label->childCount()) {
      for (int i = primitive->index(); i < m_label->childCount(); ++i) {
        ProjectTreeItem *item = m_label->child(i);
        item->setData(0, tr("bond %1").arg(i));
      }
    }
  }
开发者ID:AlbertDeFusco,项目名称:avogadro,代码行数:16,代码来源:bonddelegate.cpp

示例7: initialize

  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);
    }

  }
开发者ID:AlbertDeFusco,项目名称:avogadro,代码行数:20,代码来源:bonddelegate.cpp

示例8: rollback

void ProjectModel::rollback(QModelIndex &index, int n)
{
    ProjectTreeItem *item = static_cast<ProjectTreeItem*>(index.internalPointer());
    QVariant var = item->data(0, Qt::UserRole);

    CompleteAnnotationItem *currentAnnotation = var.value<CompleteAnnotationItem*>();
    Revision<AnnotationItem*> revision = currentAnnotation->getRevision(n);

    RevisionAnnotationList revisions;

    for(int i = 0; i < n; i++){
        revisions << currentAnnotation->getRevision(i);
    }
    CompleteAnnotationItem *newAnnotation =
            new CompleteAnnotationItem(revision.getValue()->getId(),
                                       revision.getValue(), revisions);

    var.setValue<CompleteAnnotationItem*>(newAnnotation);
    item->setData(var);
}
开发者ID:Cocophotos,项目名称:DepAnnotator,代码行数:20,代码来源:projectmodel.cpp


注:本文中的ProjectTreeItem::setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。