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


C++ ProjectItem::appendRow方法代码示例

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


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

示例1: AddDocument

void Workspace::AddDocument(string projectName, QString& imageFullPath, ProcessingOptions& options)
{
    QFileInfo imageFileInfo(imageFullPath);

    // Get project.
    Project* project = m_Projects[projectName].get();
    m_ProjectsPersistentState[projectName] = false;
    QString projectDirPath = QString(project->GetDocumentsPath().c_str());
    QDir projectDir(projectDirPath);

    // Copy image to project dir.
    QString dstImageFullPath = projectDir.absoluteFilePath(imageFileInfo.fileName());
    QFile::copy(imageFullPath, dstImageFullPath);

    // Get image name.
    QString docNameQ = imageFileInfo.baseName();
    std::string docName = Utils::StringQ2W(docNameQ);

    // Add image to project.
    Document* document = project->AddDocument(
                                docName,
                                Utils::StringQ2W(dstImageFullPath),
                                options);

    // Add image to view model.
    auto projRowItem = m_ProjectsModel.findItems(Utils::StringW2Q(projectName));
    ProjectItem* projectItem = (ProjectItem*) projRowItem.first();

    ProjectItem* docItem = new ProjectItem(docName, true);
    QList<QStandardItem*> docRowItem;
    docRowItem << docItem;
    projectItem->appendRow(docItem);

    SetCurrent(project, projectItem, document, docItem);
}
开发者ID:imilos,项目名称:Application-of-pattern-recognition-algorithms-in-neutron-dosimetry,代码行数:35,代码来源:workspace.cpp

示例2: AddProject

void Workspace::AddProject(QString& projectFullPath, bool load)
{
    QFileInfo projectFileInfo(projectFullPath);

    // Extract project name from path.
    QString projectNameQ = projectFileInfo.fileName().remove(".ndtr");
    std::string projectName = Utils::StringQ2W(projectNameQ);

    // If not exists, create dir to store images.
    QDir projectDir = projectFileInfo.absoluteDir();
    // Create dir if not exist.
    if (!projectDir.exists(projectNameQ))
    {
        projectDir.mkdir(projectNameQ);
    }
    projectDir.cd(projectNameQ);

    // There can't be more projects with same name.
    if (m_Projects.count(projectName))
    {
        // "Project with the same name is already loaded."
        throw std::exception();
    }

    // Initialize project.
    m_Projects[projectName] = unique_ptr<Project>(new Project());
    m_ProjectsPersistentState[projectName] = true; // loaded or saved
    Project* project = m_Projects[projectName].get();
    project->Init(projectName,
                  projectFullPath.toStdString(),
                  projectDir.absolutePath().toStdString());

    // Load/Save project.
    if (load)
    {
        // If exists load project from file.
        if(!ProjectParser::Load(project))
        {
            // "Failed to load project file."
            throw std::exception();
        }
    }
    else
    {
        // Save project file. Serialize as XML.
        if (!ProjectParser::Save(project))
        {
            // "Failed to save project file."
            throw std::exception();
        }
    }

    // TODO: Move to method. Add images to view.
    // Add project to project model view.
    QStandardItem* rootItem = m_ProjectsModel.invisibleRootItem();
    ProjectItem* projectItem = new ProjectItem(projectName);
    QList<QStandardItem*> projectItems;
    projectItems << projectItem;
    rootItem->appendRow(projectItems);

    for (Document* doc : project->GetDocuments())
    {
        auto projRowItem = m_ProjectsModel.findItems(Utils::StringW2Q(projectName));
        ProjectItem* projectItem = (ProjectItem*) projRowItem.first();

        ProjectItem* docItem = new ProjectItem(doc->GetName(), true);
        QList<QStandardItem*> docRowItem;
        docRowItem << docItem;
        projectItem->appendRow(docItem);
    }

    // Set new project as current project.
    SetCurrent(projectName);
}
开发者ID:imilos,项目名称:Application-of-pattern-recognition-algorithms-in-neutron-dosimetry,代码行数:74,代码来源:workspace.cpp


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