• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ core::IDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: updateExternalFileWarning

void ProjectTree::updateExternalFileWarning()
{
    Core::IDocument *document = qobject_cast<Core::IDocument *>(sender());
    if (!document || document->filePath().isEmpty())
        return;
    Core::InfoBar *infoBar = document->infoBar();
    Core::Id externalFileId(EXTERNAL_FILE_WARNING);
    if (!document->isModified()) {
        infoBar->removeInfo(externalFileId);
        return;
    }
    if (!infoBar->canInfoBeAdded(externalFileId))
        return;
    const FileName fileName = document->filePath();
    const QList<Project *> projects = SessionManager::projects();
    if (projects.isEmpty())
        return;
    foreach (Project *project, projects) {
        FileName projectDir = project->projectDirectory();
        if (projectDir.isEmpty())
            continue;
        if (fileName.isChildOf(projectDir))
            return;
        // External file. Test if it under the same VCS
        QString topLevel;
        if (Core::VcsManager::findVersionControlForDirectory(projectDir.toString(), &topLevel)
                && fileName.isChildOf(FileName::fromString(topLevel))) {
            return;
        }
    }
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:30,代码来源:projecttree.cpp


示例2: emitFoldersAdded

void ProjectTree::emitFoldersAdded(FolderNode *folder)
{
    if (!isInNodeHierarchy(folder))
        return;

    emit foldersAdded();

    if (Utils::anyOf(m_projectTreeWidgets, &ProjectTreeWidget::hasFocus))
        return;

    if (!m_currentNode) {
        Core::IDocument *document = Core::EditorManager::currentDocument();
        const FileName fileName = document ? document->filePath() : FileName();


        FindNodesForFileVisitor findNodes(fileName);
        foreach (FolderNode *fn, m_foldersAdded)
            fn->accept(&findNodes);

        Node *bestNode = ProjectTreeWidget::mostExpandedNode(findNodes.nodes());
        if (!bestNode)
            return;

        updateFromNode(bestNode);
    }
    m_foldersAdded.clear();
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:27,代码来源:projecttree.cpp


示例3: emitFilesAdded

void ProjectTree::emitFilesAdded(FolderNode *folder)
{
    if (!isInNodeHierarchy(folder))
        return;

    emit filesAdded();

    if (Utils::anyOf(m_projectTreeWidgets, &ProjectTreeWidget::hasFocus))
        return;

    if (!m_currentNode) {
        Core::IDocument *document = Core::EditorManager::currentDocument();
        const FileName fileName = document ? document->filePath() : FileName();

        int index = Utils::indexOf(m_filesAdded, [&fileName](FileNode *node) {
                return node->filePath() == fileName;
        });

        if (index == -1)
            return;

        updateFromNode(m_filesAdded.at(index));
    }
    m_filesAdded.clear();
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:25,代码来源:projecttree.cpp


示例4: onEditorChanged

void ExtraCompiler::onEditorChanged(Core::IEditor *editor)
{
    // Handle old editor
    if (d->lastEditor) {
        Core::IDocument *doc = d->lastEditor->document();
        disconnect(doc, &Core::IDocument::contentsChanged,
                   this, &ExtraCompiler::setDirty);

        if (d->dirty) {
            run(doc->contents());
            d->dirty = false;
        }
    }

    if (editor && editor->document()->filePath() == d->source) {
        d->lastEditor = editor;
        d->updateIssues();

        // Handle new editor
        connect(d->lastEditor->document(), &Core::IDocument::contentsChanged,
                this, &ExtraCompiler::setDirty);
    } else {
        d->lastEditor = 0;
    }
}
开发者ID:jaakristioja,项目名称:qt-creator,代码行数:25,代码来源:extracompiler.cpp


示例5: QString

static inline QString displayNameOfEditor(const QString &fileName)
{
    Core::IDocument *document = Core::EditorManager::documentModel()->documentForFilePath(fileName);
    if (document)
        return document->displayName();
    return QString();
}
开发者ID:joewan,项目名称:qt-creator,代码行数:7,代码来源:vcsbaseplugin.cpp


示例6: submitEditorAboutToClose

bool BazaarPlugin::submitEditorAboutToClose()
{
    CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor());
    QTC_ASSERT(commitEditor, return true);
    Core::IDocument *editorDocument = commitEditor->document();
    QTC_ASSERT(editorDocument, return true);

    bool dummyPrompt = false;
    const VcsBase::VcsBaseSubmitEditor::PromptSubmitResult response =
            commitEditor->promptSubmit(tr("Close Commit Editor"), tr("Do you want to commit the changes?"),
                                       tr("Message check failed. Do you want to proceed?"),
                                       &dummyPrompt, !m_submitActionTriggered);
    m_submitActionTriggered = false;

    switch (response) {
    case VcsBase::VcsBaseSubmitEditor::SubmitCanceled:
        return false;
    case VcsBase::VcsBaseSubmitEditor::SubmitDiscarded:
        return true;
    default:
        break;
    }

    QStringList files = commitEditor->checkedFiles();
    if (!files.empty()) {
        //save the commit message
        if (!Core::DocumentManager::saveDocument(editorDocument))
            return false;

        //rewrite entries of the form 'file => newfile' to 'newfile' because
        //this would mess the commit command
        for (QStringList::iterator iFile = files.begin(); iFile != files.end(); ++iFile) {
            const QStringList parts = iFile->split(QLatin1String(" => "), QString::SkipEmptyParts);
            if (!parts.isEmpty())
                *iFile = parts.last();
        }

        BazaarCommitWidget *commitWidget = commitEditor->commitWidget();
        QStringList extraOptions;
        // Author
        if (!commitWidget->committer().isEmpty())
            extraOptions.append(QLatin1String("--author=") + commitWidget->committer());
        // Fixed bugs
        foreach (const QString &fix, commitWidget->fixedBugs()) {
            if (!fix.isEmpty())
                extraOptions << QLatin1String("--fixes") << fix;
        }
        // Whether local commit or not
        if (commitWidget->isLocalOptionEnabled())
            extraOptions += QLatin1String("--local");
        m_client->commit(m_submitRepository, files, editorDocument->filePath(), extraOptions);
    }
    return true;
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:54,代码来源:bazaarplugin.cpp


示例7: setFilePath

void BarDescriptorEditorWidget::setFilePath(const QString &filePath)
{
    Core::IDocument *doc = m_xmlSourceWidget->baseTextDocument();
    if (doc) {
        doc->setFilePath(filePath);
        // setFilePath() call leads to a textChanged() signal emitted
        // and therefore having this editor-widget to become dirty
        // therefore we have to explicitly unset the dirty flag
        setDirty(false);
    }
}
开发者ID:edwardZhang,项目名称:qt-creator,代码行数:11,代码来源:bardescriptoreditorwidget.cpp


示例8: gotoLocations

void Manager::gotoLocations(const QList<QVariant> &list)
{
    QSet<SymbolLocation> locations = Utils::roleToLocations(list);

    if (locations.count() == 0)
        return;

    QString fileName;
    int line = 0;
    int column = 0;
    bool currentPositionAvailable = false;

    // what is open now?
    Core::IEditor *editor = Core::EditorManager::instance()->currentEditor();
    if (editor) {
        // get current file name
        Core::IDocument *document = editor->document();
        if (document)
            fileName = document->fileName();

        // if text file - what is current position?
        TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor);
        if (textEditor) {
            // there is open currently text editor
            int position = textEditor->position();
            textEditor->convertPosition(position, &line, &column);
            currentPositionAvailable = true;
        }
    }

    // if there is something open - try to check, is it currently activated symbol?
    if (currentPositionAvailable) {
        SymbolLocation current(fileName, line, column);
        QSet<SymbolLocation>::const_iterator it = locations.find(current);
        QSet<SymbolLocation>::const_iterator end = locations.constEnd();
        // is it known location?
        if (it != end) {
            // found - do one additional step
            ++it;
            if (it == end)
                it = locations.begin();
            const SymbolLocation &found = *it;
            gotoLocation(found.fileName(), found.line(), found.column());
            return;
        }
    }

    // no success - open first item in the list
    const SymbolLocation loc = *locations.constBegin();

    gotoLocation(loc.fileName(), loc.line(), loc.column());
}
开发者ID:gaoxiaojun,项目名称:qtcreator,代码行数:52,代码来源:classviewmanager.cpp


示例9: updateFromDocumentManager

void ProjectTree::updateFromDocumentManager(bool invalidCurrentNode)
{
    Core::IDocument *document = Core::EditorManager::currentDocument();
    const FileName fileName = document ? document->filePath() : FileName();

    Node *currentNode = 0;
    if (!invalidCurrentNode && m_currentNode && m_currentNode->filePath() == fileName)
        currentNode = m_currentNode;
    else
        currentNode = ProjectTreeWidget::nodeForFile(fileName);

    updateFromNode(currentNode);
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:13,代码来源:projecttree.cpp


示例10: onEditorAboutToClose

void ExtraCompiler::onEditorAboutToClose(Core::IEditor *editor)
{
    if (d->lastEditor != editor)
        return;

    // Oh no our editor is going to be closed
    // get the content first
    Core::IDocument *doc = d->lastEditor->document();
    disconnect(doc, &Core::IDocument::contentsChanged,
               this, &ExtraCompiler::setDirty);
    if (d->dirty) {
        run(doc->contents());
        d->dirty = false;
    }
    d->lastEditor = 0;
}
开发者ID:jaakristioja,项目名称:qt-creator,代码行数:16,代码来源:extracompiler.cpp


示例11: contextMenuEvent

void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
{
    QMenu menu;
    // Open current item
    const QModelIndex current = currentItem();
    const bool hasCurrentItem = current.isValid();
    QAction *actionOpen = menu.addAction(actionOpenText(m_fileSystemModel, current));
    actionOpen->setEnabled(hasCurrentItem);

    // we need dummy DocumentModel::Entry with absolute file path in it
    // to get EditorManager::addNativeDirAndOpenWithActions() working
    Core::DocumentModel::Entry fakeEntry;
    Core::IDocument document;
    document.setFilePath(Utils::FileName::fromString(m_fileSystemModel->filePath(current)));
    fakeEntry.document = &document;
    Core::EditorManager::addNativeDirAndOpenWithActions(&menu, &fakeEntry);

    const bool isDirectory = hasCurrentItem && m_fileSystemModel->isDir(current);
    QAction *actionOpenDirectoryAsProject = 0;
    if (isDirectory && m_fileSystemModel->fileName(current) != QLatin1String("..")) {
        actionOpenDirectoryAsProject =
            menu.addAction(tr("Open Project in \"%1\"")
                           .arg(m_fileSystemModel->fileName(current)));
    }

    // Open file dialog to choose a path starting from current
    QAction *actionChooseFolder = menu.addAction(tr("Choose Folder..."));

    QAction *action = menu.exec(ev->globalPos());
    if (!action)
        return;

    ev->accept();
    if (action == actionOpen) { // Handle open file.
        openItem(current);
    } else if (action == actionOpenDirectoryAsProject) {
        openItem(current, true);
    } else if (action == actionChooseFolder) { // Open file dialog
        const QString newPath = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), currentDirectory());
        if (!newPath.isEmpty())
            setCurrentDirectory(newPath);
    }
}
开发者ID:C-sjia,项目名称:qt-creator,代码行数:43,代码来源:foldernavigationwidget.cpp


示例12: submitEditorAboutToClose

bool MercurialPlugin::submitEditorAboutToClose()
{
    CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor());
    QTC_ASSERT(commitEditor, return true);
    Core::IDocument *editorFile = commitEditor->document();
    QTC_ASSERT(editorFile, return true);

    bool dummyPrompt = false;
    const VcsBaseSubmitEditor::PromptSubmitResult response =
            commitEditor->promptSubmit(tr("Close Commit Editor"), tr("Do you want to commit the changes?"),
                                       tr("Message check failed. Do you want to proceed?"),
                                       &dummyPrompt, !m_submitActionTriggered);
    m_submitActionTriggered = false;

    switch (response) {
    case VcsBaseSubmitEditor::SubmitCanceled:
        return false;
    case VcsBaseSubmitEditor::SubmitDiscarded:
        return true;
    default:
        break;
    }

    const QStringList files = commitEditor->checkedFiles();
    if (!files.empty()) {
        //save the commit message
        if (!Core::DocumentManager::saveDocument(editorFile))
            return false;

        QStringList extraOptions;
        if (!commitEditor->committerInfo().isEmpty())
            extraOptions << QLatin1String("-u") << commitEditor->committerInfo();
        m_client->commit(m_submitRepository, files, editorFile->filePath().toString(),
                         extraOptions);
    }
    return true;
}
开发者ID:C-sjia,项目名称:qt-creator,代码行数:37,代码来源:mercurialplugin.cpp


示例13: addEditorTab

void TabBar::addEditorTab(Core::IEditor *editor)
{
    Core::IDocument *document = editor->document();

    const int index = addTab(document->displayName());
    setTabIcon(index, Core::FileIconProvider::icon(QFileInfo(document->filePath())));
    setTabToolTip(index, document->filePath());

    m_editors.append(editor);

    connect(document, &Core::IDocument::changed, [this, editor, document]() {
        const int index = m_editors.indexOf(editor);
        if (index == -1)
            return;
        QString tabText = document->displayName();
        if (document->isModified())
            tabText += QLatin1Char('*');
        setTabText(index, tabText);
    });
}
开发者ID:stepanp,项目名称:qtcreator-tabbededitor-plugin,代码行数:20,代码来源:tabbar.cpp


示例14: slotStateChanged

void StateListener::slotStateChanged()
{
    // Get the current file. Are we on a temporary submit editor indicated by
    // temporary path prefix or does the file contains a hash, indicating a project
    // folder?
    State state;
    Core::IDocument *currentDocument = Core::EditorManager::currentDocument();
    if (!currentDocument) {
        state.currentFile.clear();
    } else {
        state.currentFile = currentDocument->filePath();
        if (state.currentFile.isEmpty()) {
            state.currentFile = VcsBasePlugin::source(currentDocument);
        }
    }
    QScopedPointer<QFileInfo> currentFileInfo; // Instantiate QFileInfo only once if required.
    if (!state.currentFile.isEmpty()) {
        const bool isTempFile = state.currentFile.startsWith(QDir::tempPath());
        // Quick check: Does it look like a patch?
        const bool isPatch = state.currentFile.endsWith(QLatin1String(".patch"))
                             || state.currentFile.endsWith(QLatin1String(".diff"));
        if (isPatch) {
            // Patch: Figure out a name to display. If it is a temp file, it could be
            // Codepaster. Use the display name of the editor.
            state.currentPatchFile = state.currentFile;
            if (isTempFile)
                state.currentPatchFileDisplayName = displayNameOfEditor(state.currentPatchFile);
            if (state.currentPatchFileDisplayName.isEmpty()) {
                currentFileInfo.reset(new QFileInfo(state.currentFile));
                state.currentPatchFileDisplayName = currentFileInfo->fileName();
            }
        }
        // For actual version control operations on it:
        // Do not show temporary files and project folders ('#')
        if (isTempFile || state.currentFile.contains(QLatin1Char('#')))
            state.currentFile.clear();
    }

    // Get the file and its control. Do not use the file unless we find one
    Core::IVersionControl *fileControl = 0;
    if (!state.currentFile.isEmpty()) {
        if (currentFileInfo.isNull())
            currentFileInfo.reset(new QFileInfo(state.currentFile));
        if (currentFileInfo->isDir()) {
            state.currentFile.clear();
            state.currentFileDirectory = currentFileInfo->absoluteFilePath();
        } else {
            state.currentFileDirectory = currentFileInfo->absolutePath();
            state.currentFileName = currentFileInfo->fileName();
        }
        fileControl = Core::VcsManager::findVersionControlForDirectory(
                    state.currentFileDirectory,
                    &state.currentFileTopLevel);
        if (!fileControl)
            state.clearFile();
    }
    // Check for project, find the control
    Core::IVersionControl *projectControl = 0;
    if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject()) {
        state.currentProjectPath = currentProject->projectDirectory().toString();
        state.currentProjectName = currentProject->displayName();
        projectControl = Core::VcsManager::findVersionControlForDirectory(state.currentProjectPath,
                                                                    &state.currentProjectTopLevel);
        if (projectControl) {
            // If we have both, let the file's one take preference
            if (fileControl && projectControl != fileControl)
                state.clearProject();
        } else {
            state.clearProject(); // No control found
        }
    }
    // Assemble state and emit signal.
    Core::IVersionControl *vc = fileControl;
    if (!vc)
        vc = projectControl;
    if (!vc) {
        state.clearPatchFile(); // Need a repository to patch
        Core::EditorManager::setWindowTitleVcsTopic(QString());
    }
    if (debug)
        qDebug() << state << (vc ? vc->displayName() : QLatin1String("No version control"));
    emit stateChanged(state, vc);
}
开发者ID:joewan,项目名称:qt-creator,代码行数:83,代码来源:vcsbaseplugin.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ core::Id类代码示例发布时间:2022-05-31
下一篇:
C++ core::ICore类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap