diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 71ac23a92866afdaff39fe51a1fe51b5c5a58bd4..983cd10f03eea7c5d6b38c52a2f7251b6bdb5ce5 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 292735c9f15fc336cca31f260fcf4ec20c2464e2..376269f98c36fb65e2ba88c068c6a1c935ed4922 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);