forked from qt-creator/qt-creator
Vcs: FilePath-ify VcsManager::promptToAdd
And adjust users a bit. Change-Id: Idb31030b208403e88c5be0171b3ca9d4d7ded35d Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -175,24 +175,21 @@ void FileSystemFilter::accept(LocatorFilterEntry selection,
|
||||
int *selectionLength) const
|
||||
{
|
||||
Q_UNUSED(selectionLength)
|
||||
QFileInfo info = selection.filePath.toFileInfo();
|
||||
if (info.isDir()) {
|
||||
if (selection.filePath.isDir()) {
|
||||
const QString value = shortcutString() + ' '
|
||||
+ QDir::toNativeSeparators(info.absoluteFilePath() + '/');
|
||||
+ selection.filePath.absoluteFilePath().toUserOutput() + '/';
|
||||
*newText = value;
|
||||
*selectionStart = value.length();
|
||||
} else {
|
||||
// Don't block locator filter execution with dialog
|
||||
QMetaObject::invokeMethod(EditorManager::instance(), [info, selection] {
|
||||
const QString targetFile = selection.internalData.toString();
|
||||
if (!info.exists()) {
|
||||
QMetaObject::invokeMethod(EditorManager::instance(), [selection] {
|
||||
const FilePath targetFile = FilePath::fromVariant(selection.internalData);
|
||||
if (!selection.filePath.exists()) {
|
||||
if (CheckableMessageBox::shouldAskAgain(ICore::settings(), kAlwaysCreate)) {
|
||||
CheckableMessageBox messageBox(ICore::dialogParent());
|
||||
messageBox.setWindowTitle(tr("Create File"));
|
||||
messageBox.setIcon(QMessageBox::Question);
|
||||
messageBox.setText(
|
||||
tr("Create \"%1\"?")
|
||||
.arg(FilePath::fromString(targetFile).shortNativePath()));
|
||||
messageBox.setText(tr("Create \"%1\"?").arg(targetFile.shortNativePath()));
|
||||
messageBox.setCheckBoxVisible(true);
|
||||
messageBox.setCheckBoxText(tr("Always create"));
|
||||
messageBox.setChecked(false);
|
||||
@@ -206,10 +203,10 @@ void FileSystemFilter::accept(LocatorFilterEntry selection,
|
||||
if (messageBox.isChecked())
|
||||
CheckableMessageBox::doNotAskAgain(ICore::settings(), kAlwaysCreate);
|
||||
}
|
||||
QFile file(targetFile);
|
||||
QFile file(targetFile.toString());
|
||||
file.open(QFile::WriteOnly);
|
||||
file.close();
|
||||
VcsManager::promptToAdd(QFileInfo(targetFile).absolutePath(), { targetFile });
|
||||
VcsManager::promptToAdd(targetFile.absolutePath(), {targetFile});
|
||||
}
|
||||
BaseFileFilter::openEditorAt(selection);
|
||||
}, Qt::QueuedConnection);
|
||||
|
@@ -431,13 +431,13 @@ QStringList VcsManager::additionalToolsPath()
|
||||
return d->m_cachedAdditionalToolsPaths;
|
||||
}
|
||||
|
||||
void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNames)
|
||||
void VcsManager::promptToAdd(const FilePath &directory, const FilePaths &filePaths)
|
||||
{
|
||||
IVersionControl *vc = findVersionControlForDirectory(FilePath::fromString(directory));
|
||||
IVersionControl *vc = findVersionControlForDirectory(directory);
|
||||
if (!vc || !vc->supportsOperation(IVersionControl::AddOperation))
|
||||
return;
|
||||
|
||||
const FilePaths unmanagedFiles = vc->unmanagedFiles(Utils::transform(fileNames, &FilePath::fromString));
|
||||
const FilePaths unmanagedFiles = vc->unmanagedFiles(filePaths);
|
||||
if (unmanagedFiles.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -446,7 +446,7 @@ void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNa
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
QStringList notAddedToVc;
|
||||
for (const FilePath &file : unmanagedFiles) {
|
||||
if (!vc->vcsAdd(FilePath::fromString(QDir(directory).filePath(file.path()))))
|
||||
if (!vc->vcsAdd(directory.resolvePath(file)))
|
||||
notAddedToVc << file.toUserOutput();
|
||||
}
|
||||
|
||||
|
@@ -80,7 +80,7 @@ public:
|
||||
|
||||
// Shows a confirmation dialog, whether the files in the list should be
|
||||
// added to revision control. Calls vcsAdd for each file.
|
||||
static void promptToAdd(const QString &directory, const QStringList &fileNames);
|
||||
static void promptToAdd(const Utils::FilePath &directory, const Utils::FilePaths &filePaths);
|
||||
|
||||
static void emitRepositoryChanged(const Utils::FilePath &repository);
|
||||
|
||||
|
@@ -3619,10 +3619,10 @@ void ProjectExplorerPluginPrivate::addExistingProjects()
|
||||
if (subProjectFilePaths.empty())
|
||||
return;
|
||||
FilePaths failedProjects;
|
||||
QStringList addedProjects;
|
||||
FilePaths addedProjects;
|
||||
for (const FilePath &filePath : qAsConst(subProjectFilePaths)) {
|
||||
if (projectNode->addSubProject(filePath))
|
||||
addedProjects << filePath.toString();
|
||||
addedProjects << filePath;
|
||||
else
|
||||
failedProjects << filePath;
|
||||
}
|
||||
@@ -3633,7 +3633,7 @@ void ProjectExplorerPluginPrivate::addExistingProjects()
|
||||
message + "\n " + FilePath::formatFilePaths(failedProjects, "\n "));
|
||||
return;
|
||||
}
|
||||
VcsManager::promptToAdd(dir.toString(), addedProjects);
|
||||
VcsManager::promptToAdd(dir, addedProjects);
|
||||
}
|
||||
|
||||
void ProjectExplorerPluginPrivate::handleAddExistingFiles()
|
||||
@@ -3685,7 +3685,7 @@ void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const FileP
|
||||
[¬Added](const FilePath &f) { return !notAdded.contains(f); });
|
||||
}
|
||||
|
||||
VcsManager::promptToAdd(dir.toString(), Utils::transform(fileNames, &FilePath::toString));
|
||||
VcsManager::promptToAdd(dir, fileNames);
|
||||
}
|
||||
|
||||
void ProjectExplorerPluginPrivate::removeProject()
|
||||
|
@@ -30,7 +30,9 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/removefiledialog.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
@@ -995,7 +997,8 @@ void ResourceModel::addFiles(int prefixIndex, const QStringList &fileNames, int
|
||||
firstFile = cnt;
|
||||
lastFile = cnt + unique_list.count() - 1;
|
||||
|
||||
Core::VcsManager::promptToAdd(m_resource_file.filePath().absolutePath().toString(), fileNames);
|
||||
Core::VcsManager::promptToAdd(m_resource_file.filePath().absolutePath(),
|
||||
Utils::transform(fileNames, &FilePath::fromString));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user