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


C++ IDocument::setFilePath方法代码示例

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


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

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

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


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