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


C++ ProjectTreeItem类代码示例

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


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

示例1: ProjectTreeItem

void ProjectModel::addProject(Project *project)
{
    //Add project and its name.
    ProjectTreeItem *childProject = new ProjectTreeItem(project, project->projectName(), rootItem);

    //Add each file in the project with its name
    for(int i = 0; i < project->filesCount(); i++)
    {
        StringAndAnnotations saa = project->file(i);
        ProjectTreeItem *childFile = new ProjectTreeItem(project, saa.first, childProject);

        //For each file add the annotations (one per row in the model)
        for(int j = 0; j < saa.second.size(); j++)
        {
            QVariant var;
            var.setValue(saa.second.at(j));

            ProjectTreeItem * childAnnotation = new ProjectTreeItem(project, var, childFile);
            childFile->appendChild(childAnnotation);
        }

        childProject->appendChild(childFile);
    }

    rootItem->appendChild(childProject);
}
开发者ID:Cocophotos,项目名称:DepAnnotator,代码行数:26,代码来源:projectmodel.cpp

示例2: QVariant

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);
}
开发者ID:Cocophotos,项目名称:DepAnnotator,代码行数:12,代码来源:projectmodel.cpp

示例3: initialize

  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: QModelIndex

/**
 * @brief ProjectManagerTreeModel::parent Get parent of item with index.
 * @param child Child where we want get parent item.
 * @return Parent of given child.
 */
QModelIndex ProjectManagerTreeModel::parent(const QModelIndex &child) const
{
    if(!child.isValid())
        return QModelIndex();

    ProjectTreeItem* cItem = static_cast<ProjectTreeItem*>(child.internalPointer());
    ProjectTreeItem* pItem = cItem->getParent();

    if(pItem == root)
        return QModelIndex();

    return createIndex(pItem->getRow(), 0, pItem);
}
开发者ID:jkonecny12,项目名称:ShaderMan,代码行数:18,代码来源:projectmanagertreemodel.cpp

示例5: rowCount

int ProjectModel::rowCount(const QModelIndex &parent) const
{
    ProjectTreeItem *parentItem;
    if (parent.column() > 0)
        return 0;

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

    return parentItem->childCount();
}
开发者ID:Cocophotos,项目名称:DepAnnotator,代码行数:13,代码来源:projectmodel.cpp

示例6: QModelIndex

QModelIndex ProjectModel::parent(const QModelIndex &index) const
{
    if (!index.isValid())
        return QModelIndex();

    ProjectTreeItem *childItem = static_cast<ProjectTreeItem*>(index.internalPointer());
    ProjectTreeItem *parentItem = childItem->parent();

    if (parentItem == rootItem)
        return QModelIndex();

    return createIndex(parentItem->row(), 0, parentItem);
}
开发者ID:Cocophotos,项目名称:DepAnnotator,代码行数:13,代码来源:projectmodel.cpp

示例7: insertExpandableItem

  ProjectTreeItem* ProjectTreeModelDelegate::insertExpandableItem(ProjectTreeItem *parent)
  {
    // insert at the end
    int position = parent->childCount();
    d->model->insertRows(parent, position, 1);
    // retrieve the item
    ProjectTreeItem *item = parent->child(position);
    // set it to non-terminal
    item->setTerminal(false);
    // store it (for hasExpandableItem & fetchMore)
    d->expandableItems.append(item);

    return item;
  }
开发者ID:AlbertDeFusco,项目名称:avogadro,代码行数:14,代码来源:projecttreemodeldelegate.cpp

示例8: 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

示例9: QDir

void ProjectTree::loadItem(QTreeWidgetItem *item)
{
    ProjectTreeItem *clickedItem = static_cast<ProjectTreeItem*>(item);
    if (!clickedItem->isLoaded()) {
        QDir* rootDir = new QDir(clickedItem->getFileInfo()->absoluteFilePath());

        clickedItem->setLoaded(true);

        for (QFileInfo fileInfo : rootDir->entryInfoList(QDir::Filter::AllEntries | QDir::Filter::NoDotAndDotDot, QDir::SortFlag::DirsFirst)) {
            ProjectTreeItem* child = new ProjectTreeItem(fileInfo);
            clickedItem->addChild(child);
        }
        resizeColumnToContents(0);
    }
}
开发者ID:sgerbino,项目名称:sol,代码行数:15,代码来源:projecttree.cpp

示例10: on_itemClicked

void ProjectTree::on_itemClicked(QTreeWidgetItem *item, int column)
{
    ProjectTreeItem *clickedItem = static_cast<ProjectTreeItem*>(item);

    if (clickedItem->getFileInfo()->isDir()) {
        if (clickedItem->isExpanded())
            clickedItem->setExpanded(false);
        else
            clickedItem->setExpanded(true);
    }
    else
        emit fileClicked(clickedItem);

    (void)column;
}
开发者ID:sgerbino,项目名称:sol,代码行数:15,代码来源:projecttree.cpp

示例11: model

 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

示例12: projectRemoved

/**
 * @brief ProjectManagerTreeModel::projectRemoved Call this method if project with given name was removed.
 * @param projName Name of the old project.
 */
void ProjectManagerTreeModel::projectRemoved(QString projName)
{
    int row = root->getRowCount();

    for(int i = 0; i < row; ++i)
    {
        ProjectTreeItem* item = root->getChild(i);
        if(item->getDataString() == projName)
        {
            insertData = projName;
            insertType = ProjectTreeItem::PROJECT;
            removeRows(i, 1);
            return;
        }
    }
}
开发者ID:jkonecny12,项目名称:ShaderMan,代码行数:20,代码来源:projectmanagertreemodel.cpp

示例13: model

  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

示例14: projectActiveChanged

/**
 * @brief ProjectManagerTreeModel::projectActiveChanged Call this method if active project was changed.
 * @param newProject New active project.
 * @param oldProject Old active project.
 */
void ProjectManagerTreeModel::projectActiveChanged(QString newProject, QString oldProject)
{    
    // new project is set

    int rowNumber = root->getRowCount();

    ProjectTreeItem* oldP = NULL;
    ProjectTreeItem* newP = NULL;

    int oldRow = 0;
    int newRow = 0;

    for(int i = 0; i < rowNumber; ++i)
    {
        ProjectTreeItem* item = root->getChild(i);

        if(item->getDataString() == newProject)
        {
            newP = item;
            newRow = i;
        }
        else if(item->getDataString() == oldProject)
        {
            oldP = item;
            oldRow = i;
        }
    }

    if(oldP != NULL)
    {
        QModelIndex index = createIndex(oldRow, 0, oldP);

        dataChanged(index,index);
    }

    if(newP != NULL)
    {
        QModelIndex indexNew = createIndex(newRow, 0, newP);

        dataChanged(indexNew,indexNew);
    }
}
开发者ID:jkonecny12,项目名称:ShaderMan,代码行数:47,代码来源:projectmanagertreemodel.cpp

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