forked from qt-creator/qt-creator
ProjectTree: Fix adding files from context menu
We need to retrieve the current node before the dialog opens up. While the dialog has focus, the current node depends on what is visible in the EditorManager. Change-Id: Icdb212e8d837c9cd789e369f76d6a136d46fcaae Task-number: QTCREATORBUG-14295 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -3021,29 +3021,33 @@ void ProjectExplorerPluginPrivate::addNewSubproject()
|
||||
|
||||
void ProjectExplorerPluginPrivate::handleAddExistingFiles()
|
||||
{
|
||||
QTC_ASSERT(ProjectTree::currentNode(), return);
|
||||
Node *node = ProjectTree::currentNode();
|
||||
FolderNode *folderNode = node ? node->asFolderNode() : 0;
|
||||
|
||||
QTC_ASSERT(folderNode, return);
|
||||
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(ICore::mainWindow(),
|
||||
tr("Add Existing Files"), directoryFor(ProjectTree::currentNode()));
|
||||
if (fileNames.isEmpty())
|
||||
return;
|
||||
ProjectExplorerPlugin::addExistingFiles(fileNames);
|
||||
ProjectExplorerPlugin::addExistingFiles(fileNames, folderNode);
|
||||
}
|
||||
|
||||
void ProjectExplorerPluginPrivate::addExistingDirectory()
|
||||
{
|
||||
QTC_ASSERT(ProjectTree::currentNode(), return);
|
||||
Node *node = ProjectTree::currentNode();
|
||||
FolderNode *folderNode = node ? node->asFolderNode() : 0;
|
||||
|
||||
QTC_ASSERT(folderNode, return);
|
||||
|
||||
SelectableFilesDialogAddDirectory dialog(directoryFor(ProjectTree::currentNode()), QStringList(), ICore::mainWindow());
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
ProjectExplorerPlugin::addExistingFiles(dialog.selectedFiles());
|
||||
ProjectExplorerPlugin::addExistingFiles(dialog.selectedFiles(), folderNode);
|
||||
}
|
||||
|
||||
void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths)
|
||||
void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths, FolderNode *folderNode)
|
||||
{
|
||||
Node *node = ProjectTree::currentNode();
|
||||
FolderNode *folderNode = node ? node->asFolderNode() : 0;
|
||||
addExistingFiles(folderNode, filePaths);
|
||||
}
|
||||
|
||||
|
@@ -104,7 +104,7 @@ public:
|
||||
const bool forceSkipDeploy = false);
|
||||
|
||||
static void addExistingFiles(FolderNode *projectNode, const QStringList &filePaths);
|
||||
static void addExistingFiles(const QStringList &filePaths);
|
||||
static void addExistingFiles(const QStringList &filePaths, FolderNode *folderNode);
|
||||
|
||||
static void buildProject(Project *p);
|
||||
/// Normally there's no need to call this function.
|
||||
|
Reference in New Issue
Block a user