本文整理汇总了C++中IDocument::filePath方法的典型用法代码示例。如果您正苦于以下问题:C++ IDocument::filePath方法的具体用法?C++ IDocument::filePath怎么用?C++ IDocument::filePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDocument
的用法示例。
在下文中一共展示了IDocument::filePath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateEnabled
void QmlProjectRunConfiguration::updateEnabled()
{
bool qmlFileFound = false;
if (mainScriptSource() == FileInEditor) {
IDocument *document = EditorManager::currentDocument();
if (document) {
m_currentFileFilename = document->filePath();
if (MimeDatabase::findByFile(mainScript()).type() == QLatin1String("application/x-qml"))
qmlFileFound = true;
}
if (!document
|| MimeDatabase::findByFile(mainScript()).type() == QLatin1String("application/x-qmlproject")) {
// find a qml file with lowercase filename. This is slow, but only done
// in initialization/other border cases.
foreach (const QString &filename, target()->project()->files(ProjectExplorer::Project::AllFiles)) {
const QFileInfo fi(filename);
if (!filename.isEmpty() && fi.baseName()[0].isLower()
&& MimeDatabase::findByFile(fi).type() == QLatin1String("application/x-qml"))
{
m_currentFileFilename = filename;
qmlFileFound = true;
break;
}
}
}
示例2: updateEnabled
void QmlProjectRunConfiguration::updateEnabled()
{
bool qmlFileFound = false;
if (mainScriptSource() == FileInEditor) {
Utils::MimeDatabase mimeDataBase;
IDocument *document = EditorManager::currentDocument();
Utils::MimeType mainScriptMimeType = mimeDataBase.mimeTypeForFile(mainScript());
if (document) {
m_currentFileFilename = document->filePath().toString();
if (mainScriptMimeType.matchesName(QLatin1String(ProjectExplorer::Constants::QML_MIMETYPE)))
qmlFileFound = true;
}
if (!document
|| mainScriptMimeType.matchesName(QLatin1String(QmlJSTools::Constants::QMLPROJECT_MIMETYPE))) {
// find a qml file with lowercase filename. This is slow, but only done
// in initialization/other border cases.
foreach (const QString &filename, target()->project()->files(Project::AllFiles)) {
const QFileInfo fi(filename);
if (!filename.isEmpty() && fi.baseName()[0].isLower()
&& mimeDataBase.mimeTypeForFile(fi).matchesName(QLatin1String(ProjectExplorer::Constants::QML_MIMETYPE)))
{
m_currentFileFilename = filename;
qmlFileFound = true;
break;
}
}
}
示例3: submitEditorAboutToClose
bool BazaarPlugin::submitEditorAboutToClose()
{
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor());
QTC_ASSERT(commitEditor, return true);
IDocument *editorDocument = commitEditor->document();
QTC_ASSERT(editorDocument, 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;
}
QStringList files = commitEditor->checkedFiles();
if (!files.empty()) {
//save the commit message
if (!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;
}
示例4: submitEditorAboutToClose
bool SubversionPlugin::submitEditorAboutToClose()
{
if (!isCommitEditorOpen())
return true;
SubversionSubmitEditor *editor = qobject_cast<SubversionSubmitEditor *>(submitEditor());
QTC_ASSERT(editor, return true);
IDocument *editorDocument = editor->document();
QTC_ASSERT(editorDocument, return true);
// Submit editor closing. Make it write out the commit message
// and retrieve files
const QFileInfo editorFile = editorDocument->filePath().toFileInfo();
const QFileInfo changeFile(m_commitMessageFileName);
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
return true; // Oops?!
// Prompt user. Force a prompt unless submit was actually invoked (that
// is, the editor was closed or shutdown).
SubversionSettings newSettings = m_settings;
const VcsBaseSubmitEditor::PromptSubmitResult answer =
editor->promptSubmit(tr("Closing Subversion Editor"),
tr("Do you want to commit the change?"),
tr("The commit message check failed. Do you want to commit the change?"),
newSettings.boolPointer(SubversionSettings::promptOnSubmitKey),
!m_submitActionTriggered);
m_submitActionTriggered = false;
switch (answer) {
case VcsBaseSubmitEditor::SubmitCanceled:
return false; // Keep editing and change file
case VcsBaseSubmitEditor::SubmitDiscarded:
cleanCommitMessageFile();
return true; // Cancel all
default:
break;
}
setSettings(newSettings); // in case someone turned prompting off
const QStringList fileList = editor->checkedFiles();
bool closeEditor = true;
if (!fileList.empty()) {
// get message & commit
closeEditor = DocumentManager::saveDocument(editorDocument);
if (closeEditor) {
VcsCommand *commitCmd = m_client->createCommitCmd(m_commitRepository,
fileList,
m_commitMessageFileName);
QObject::connect(commitCmd, &VcsCommand::finished,
this, [this]() { cleanCommitMessageFile(); });
commitCmd->execute();
}
}
return closeEditor;
}
示例5: checkCurrent
void TestProject::checkCurrent()
{
Project* project = SessionManager::startupProject ();
CustomRunConfiguration* configuration = parse (project);
if (configuration == NULL)
{
return;
}
IDocument* document = EditorManager::currentDocument ();
if (document == NULL)
{
return;
}
FileName file = document->filePath();
QStringList files = project->files (Project::ExcludeGeneratedFiles);
if (!files.contains (file.toString ()))
{
return;
}
runTestsForFiles (FileNameList () << file, configuration);
}
示例6: 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;
IDocument *currentDocument = EditorManager::currentDocument();
if (!currentDocument) {
state.currentFile.clear();
} else {
state.currentFile = currentDocument->filePath().toString();
if (state.currentFile.isEmpty() || currentDocument->isTemporary())
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
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 = VcsManager::findVersionControlForDirectory(
state.currentFileDirectory,
&state.currentFileTopLevel);
if (!fileControl)
state.clearFile();
}
// Check for project, find the control
IVersionControl *projectControl = 0;
Project *currentProject = ProjectTree::currentProject();
if (!currentProject)
currentProject = SessionManager::startupProject();
if (currentProject) {
state.currentProjectPath = currentProject->projectDirectory().toString();
state.currentProjectName = currentProject->displayName();
projectControl = 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.
IVersionControl *vc = fileControl;
if (!vc)
vc = projectControl;
if (!vc)
state.clearPatchFile(); // Need a repository to patch
if (debug)
qDebug() << state << (vc ? vc->displayName() : QLatin1String("No version control"));
EditorManager::updateWindowTitles();
emit stateChanged(state, vc);
}