summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Vanek <petr@yarpen.cz>2015-01-23 13:59:55 +0100
committerOrgad Shaneh <orgads@gmail.com>2016-03-17 07:44:17 +0000
commitcdbf1f5ab33fa7a51c9e9dbc04871536922326dc (patch)
tree4c36a8603014c9eccb0aa0e16bde19e6d084785d
parenta5a4f02ced0d509f599746d0fdc70ce74d1e55a6 (diff)
downloadqt-creator-cdbf1f5ab33fa7a51c9e9dbc04871536922326dc.tar.gz
Refactor FolderNavigationWidget to use core functionality
Change-Id: Ia9ee772b8538370d3cb9378ddaf6e30f32dfaebc Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
-rw-r--r--src/plugins/projectexplorer/foldernavigationwidget.cpp44
1 files changed, 11 insertions, 33 deletions
diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp
index 4ce5498fe8..919b1ffa6d 100644
--- a/src/plugins/projectexplorer/foldernavigationwidget.cpp
+++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp
@@ -340,6 +340,15 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
const bool hasCurrentItem = current.isValid();
QAction *actionOpen = menu.addAction(actionOpenText(m_fileSystemModel, current));
actionOpen->setEnabled(hasCurrentItem);
+
+ // we need dummy DocumentModel::Entry with absolute file path in it
+ // to get EditorManager::addNativeDirAndOpenWithActions() working
+ Core::DocumentModel::Entry fakeEntry;
+ Core::IDocument document;
+ document.setFilePath(Utils::FileName::fromString(m_fileSystemModel->filePath(current)));
+ fakeEntry.document = &document;
+ Core::EditorManager::addNativeDirAndOpenWithActions(&menu, &fakeEntry);
+
const bool isDirectory = hasCurrentItem && m_fileSystemModel->isDir(current);
QAction *actionOpenDirectoryAsProject = 0;
if (isDirectory && m_fileSystemModel->fileName(current) != QLatin1String("..")) {
@@ -347,20 +356,6 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(tr("Open Project in \"%1\"")
.arg(m_fileSystemModel->fileName(current)));
}
- // Explorer & teminal
- QAction *actionExplorer = menu.addAction(Core::FileUtils::msgGraphicalShellAction());
- actionExplorer->setEnabled(hasCurrentItem);
- QAction *actionTerminal = menu.addAction(Core::FileUtils::msgTerminalAction());
- actionTerminal->setEnabled(hasCurrentItem);
-
- QAction *actionFind = menu.addAction(Core::FileUtils::msgFindInDirectory());
- actionFind->setEnabled(hasCurrentItem);
- // open with...
- if (hasCurrentItem && !isDirectory) {
- QMenu *openWith = menu.addMenu(tr("Open With"));
- Core::EditorManager::populateOpenWithMenu(openWith,
- m_fileSystemModel->filePath(current));
- }
// Open file dialog to choose a path starting from current
QAction *actionChooseFolder = menu.addAction(tr("Choose Folder..."));
@@ -372,29 +367,12 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
ev->accept();
if (action == actionOpen) { // Handle open file.
openItem(current);
- return;
- }
- if (action == actionOpenDirectoryAsProject) {
+ } else if (action == actionOpenDirectoryAsProject) {
openItem(current, true);
- return;
- }
- if (action == actionChooseFolder) { // Open file dialog
+ } else if (action == actionChooseFolder) { // Open file dialog
const QString newPath = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), currentDirectory());
if (!newPath.isEmpty())
setCurrentDirectory(newPath);
- return;
- }
- if (action == actionTerminal) {
- Core::FileUtils::openTerminal(m_fileSystemModel->filePath(current));
- return;
- }
- if (action == actionExplorer) {
- Core::FileUtils::showInGraphicalShell(this, m_fileSystemModel->filePath(current));
- return;
- }
- if (action == actionFind) {
- TextEditor::FindInFiles::findOnFileSystem(m_fileSystemModel->filePath(current));
- return;
}
}