本文整理汇总了C++中ProjectTreeItem::data方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectTreeItem::data方法的具体用法?C++ ProjectTreeItem::data怎么用?C++ ProjectTreeItem::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectTreeItem
的用法示例。
在下文中一共展示了ProjectTreeItem::data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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() );
}
示例2: data
QVariant ProjectModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole && role != Qt::UserRole)
return QVariant();
ProjectTreeItem *item = static_cast<ProjectTreeItem*>(index.internalPointer());
return item->data(index.column(), role);
}
示例3: 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);
}