Add "Find in directory" to project tree context menu

And also to the filesystem view.

Task-Nr: QTCREATORBUG-5879
Change-Id: I27bfe05808182f56deafd6ceab474894631f0a26
Reviewed-on: http://codereview.qt.nokia.com/4185
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
Daniel Teske
2011-09-05 10:19:49 +02:00
committed by Eike Ziller
parent b09f527f24
commit b8b8f167b1
9 changed files with 75 additions and 4 deletions

View File

@@ -34,6 +34,8 @@
#include "projectexplorer.h"
#include "projectexplorerconstants.h"
#include <extensionsystem/pluginmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/filemanager.h>
@@ -41,6 +43,10 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/fileutils.h>
#include <find/findplugin.h>
#include <texteditor/findinfiles.h>
#include <utils/environment.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
@@ -312,6 +318,8 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
QAction *actionTerminal = menu.addAction(Core::FileUtils::msgTerminalAction());
actionTerminal->setEnabled(hasCurrentItem);
QAction *actionFind = menu.addAction(msgFindOnFileSystem());
actionFind->setEnabled(hasCurrentItem);
// open with...
if (!m_fileSystemModel->isDir(current)) {
QMenu *openWith = menu.addMenu(tr("Open with"));
@@ -345,10 +353,38 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
Core::FileUtils::showInGraphicalShell(this, m_fileSystemModel->filePath(current));
return;
}
if (action == actionFind) {
QFileInfo info = m_fileSystemModel->fileInfo(current);
if (m_fileSystemModel->isDir(current))
findOnFileSystem(info.absoluteFilePath());
else
findOnFileSystem(info.absolutePath());
return;
}
ProjectExplorerPlugin::openEditorFromAction(action,
m_fileSystemModel->filePath(current));
}
QString FolderNavigationWidget::msgFindOnFileSystem()
{
return tr("Find in this directory...");
}
void FolderNavigationWidget::findOnFileSystem(const QString &pathIn)
{
const QFileInfo fileInfo(pathIn);
const QString folder = fileInfo.isDir() ? fileInfo.absoluteFilePath() : fileInfo.absolutePath();
TextEditor::FindInFiles *fif = ExtensionSystem::PluginManager::instance()->getObject<TextEditor::FindInFiles>();
if (!fif)
return;
Find::FindPlugin *plugin = Find::FindPlugin::instance();
if (!plugin)
return;
fif->setDirectory(folder);
Find::FindPlugin::instance()->openFindDialog(fif);
}
// --------------------FolderNavigationWidgetFactory
FolderNavigationWidgetFactory::FolderNavigationWidgetFactory()
{