本文整理汇总了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);
}
}
示例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);
}
}