From 34e2e491f426453a95cf09ad09a8f73b9ac56f89 Mon Sep 17 00:00:00 2001 From: dt <qtc-committer@nokia.com> Date: Mon, 1 Nov 2010 12:39:37 +0100 Subject: [PATCH] ProjectExplorer: Fix Open in graphical shell/terminal on virtual folders Use the same code that is used for figuring out a good directory for adding new files. Task-Nr: QTCREATORBUG-2682 --- .../projectexplorer/projectexplorer.cpp | 22 ++++++++++++------- src/plugins/projectexplorer/projectexplorer.h | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 71ac23a9286..983cd10f03e 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -2051,12 +2051,11 @@ void ProjectExplorerPlugin::updateContextMenuActions(Node *node) } } -void ProjectExplorerPlugin::addNewFile() +QString ProjectExplorerPlugin::directoryFor(Node *node) { - QTC_ASSERT(d->m_currentNode, return) - QString path = d->m_currentNode->path(); + QString path = node->path(); QString location; - FolderNode *folder = qobject_cast<FolderNode *>(d->m_currentNode); + FolderNode *folder = qobject_cast<FolderNode *>(node); if (path.contains("#") && folder) { // Virtual Folder case // We figure out a commonPath from the subfolders @@ -2071,6 +2070,14 @@ void ProjectExplorerPlugin::addNewFile() QFileInfo fi(path); location = (fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath()); } + return location; +} + +void ProjectExplorerPlugin::addNewFile() +{ + QTC_ASSERT(d->m_currentNode, return) + QString location = directoryFor(d->m_currentNode); + Core::ICore::instance()->showNewItemDialog(tr("New File", "Title of dialog"), Core::IWizard::wizardsOfKind(Core::IWizard::FileWizard) + Core::IWizard::wizardsOfKind(Core::IWizard::ClassWizard), @@ -2083,8 +2090,7 @@ void ProjectExplorerPlugin::addExistingFiles() ProjectNode *projectNode = qobject_cast<ProjectNode*>(d->m_currentNode->projectNode()); Core::ICore *core = Core::ICore::instance(); - QFileInfo fi(d->m_currentNode->path()); - const QString dir = (fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath()); + const QString dir = directoryFor(d->m_currentNode); QStringList fileNames = QFileDialog::getOpenFileNames(core->mainWindow(), tr("Add Existing Files"), dir); if (fileNames.isEmpty()) return; @@ -2156,13 +2162,13 @@ void ProjectExplorerPlugin::showInGraphicalShell() { QTC_ASSERT(d->m_currentNode, return) FolderNavigationWidget::showInGraphicalShell(Core::ICore::instance()->mainWindow(), - d->m_currentNode->path()); + directoryFor(d->m_currentNode)); } void ProjectExplorerPlugin::openTerminalHere() { QTC_ASSERT(d->m_currentNode, return) - FolderNavigationWidget::openTerminal(d->m_currentNode->path()); + FolderNavigationWidget::openTerminal(directoryFor(d->m_currentNode)); } void ProjectExplorerPlugin::removeFile() diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 292735c9f15..376269f98c3 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -218,6 +218,7 @@ private slots: #endif private: + QString directoryFor(Node *node); void deploy(QList<Project *>); int queue(QList<Project *>, QStringList stepIds); void updateContextMenuActions(Node *node); -- GitLab