Commit 5cbfee26 authored by Eike Ziller's avatar Eike Ziller

Locator: add "create and open" functionality to 'f'

Change-Id: I0c2096020ad102a836bf06ce8db0428ccf8fb805
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent accbf545
......@@ -31,6 +31,7 @@
#include "locatorwidget.h"
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/editormanager/editormanager.h>
#include <utils/fileutils.h>
#include <QDir>
......@@ -120,6 +121,16 @@ QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Core::Lo
}
}
betterEntries.append(goodEntries);
// "create and open" functionality
const QString fullFilePath = dirInfo.filePath(name);
if (!QFileInfo(fullFilePath).exists() && dirInfo.exists()) {
LocatorFilterEntry createAndOpen(this, tr("Create and Open \"%1\"").arg(entry), fullFilePath);
createAndOpen.extraInfo = Utils::FileUtils::shortNativePath(
Utils::FileName::fromString(dirInfo.absolutePath()));
betterEntries.append(createAndOpen);
}
return betterEntries;
}
......@@ -133,6 +144,10 @@ void FileSystemFilter::accept(LocatorFilterEntry selection) const
value += QDir::toNativeSeparators(info.absoluteFilePath() + QLatin1Char('/'));
m_locatorWidget->show(value, value.length());
return;
} else if (!info.exists()) {
QFile file(selection.internalData.toString());
file.open(QFile::WriteOnly);
file.close();
}
EditorManager::openEditor(selection.internalData.toString(), Id(),
EditorManager::CanContainLineNumber);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment