Commit 6d7bf0f7 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

EditorManager: Add "Find in this directory..." for open files

Also add in Projects view

Change-Id: I42145c742a38f5538a4ed44574963136aa18e134
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 895caa75
......@@ -198,6 +198,7 @@ public:
QAction *m_closeAllEditorsExceptVisibleContextAction;
QAction *m_openGraphicalShellAction;
QAction *m_openTerminalAction;
QAction *m_findInDirectoryAction;
DocumentModel::Entry *m_contextMenuEntry;
Internal::OpenEditorsWindow *m_windowPopup;
......@@ -240,6 +241,7 @@ EditorManagerPrivate::EditorManagerPrivate(QWidget *parent) :
m_closeAllEditorsExceptVisibleContextAction(new QAction(EditorManager::tr("Close All Except Visible"), parent)),
m_openGraphicalShellAction(new QAction(FileUtils::msgGraphicalShellAction(), parent)),
m_openTerminalAction(new QAction(FileUtils::msgTerminalAction(), parent)),
m_findInDirectoryAction(new QAction(FileUtils::msgFindInDirectory(), parent)),
m_windowPopup(0),
m_coreListener(0),
m_reloadSetting(IDocument::AlwaysAsk),
......@@ -345,6 +347,7 @@ EditorManager::EditorManager(QWidget *parent) :
connect(d->m_openGraphicalShellAction, SIGNAL(triggered()), this, SLOT(showInGraphicalShell()));
connect(d->m_openTerminalAction, SIGNAL(triggered()), this, SLOT(openTerminal()));
connect(d->m_findInDirectoryAction, SIGNAL(triggered()), this, SLOT(findInDirectory()));
// Goto Previous In History Action
cmd = ActionManager::registerAction(d->m_gotoPreviousDocHistoryAction, Constants::GOTOPREVINHISTORY, editDesignContext);
......@@ -813,8 +816,10 @@ void EditorManager::addNativeDirActions(QMenu *contextMenu, DocumentModel::Entry
bool enabled = entry && !entry->fileName().isEmpty();
d->m_openGraphicalShellAction->setEnabled(enabled);
d->m_openTerminalAction->setEnabled(enabled);
d->m_findInDirectoryAction->setEnabled(enabled);
contextMenu->addAction(d->m_openGraphicalShellAction);
contextMenu->addAction(d->m_openTerminalAction);
contextMenu->addAction(d->m_findInDirectoryAction);
}
static void setFocusToEditorViewAndUnmaximizePanes(EditorView *view)
......@@ -958,6 +963,13 @@ void EditorManager::openTerminal()
Core::FileUtils::openTerminal(QFileInfo(d->m_contextMenuEntry->fileName()).path());
}
void EditorManager::findInDirectory()
{
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->fileName().isEmpty())
return;
emit m_instance->findOnFileSystemRequest(QFileInfo(d->m_contextMenuEntry->fileName()).path());
}
void EditorManager::rootDestroyed(QObject *root)
{
QWidget *activeWin = qApp->activeWindow();
......
......@@ -195,6 +195,7 @@ signals:
void editorOpened(Core::IEditor *editor);
void editorAboutToClose(Core::IEditor *editor);
void editorsClosed(QList<Core::IEditor *> editors);
void findOnFileSystemRequest(const QString &path);
public slots:
static bool closeAllEditors(bool askAboutModifiedEditors = true);
......@@ -229,6 +230,7 @@ private slots:
static void showInGraphicalShell();
static void openTerminal();
static void findInDirectory();
static void rootDestroyed(QObject *root);
static void setCurrentEditorFromContextChange();
......
......@@ -140,6 +140,11 @@ void FileUtils::openTerminal(const QString &path)
QProcess::startDetached(terminalEmulator, args, pwd);
}
QString FileUtils::msgFindInDirectory()
{
return QApplication::translate("Core::Internal", "Find in This Directory...");
}
QString FileUtils::msgGraphicalShellAction()
{
if (HostOsInfo::isWindowsHost())
......
......@@ -43,6 +43,7 @@ struct CORE_EXPORT FileUtils
// Helpers for common directory browser options.
static void showInGraphicalShell(QWidget *parent, const QString &path);
static void openTerminal(const QString &path);
static QString msgFindInDirectory();
// Platform-dependent action descriptions
static QString msgGraphicalShellAction();
static QString msgTerminalAction();
......
......@@ -307,7 +307,7 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
QAction *actionTerminal = menu.addAction(Core::FileUtils::msgTerminalAction());
actionTerminal->setEnabled(hasCurrentItem);
QAction *actionFind = menu.addAction(msgFindOnFileSystem());
QAction *actionFind = menu.addAction(Core::FileUtils::msgFindInDirectory());
actionFind->setEnabled(hasCurrentItem);
// open with...
if (!m_fileSystemModel->isDir(current)) {
......@@ -349,11 +349,6 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
Core::DocumentManager::executeOpenWithMenuAction(action);
}
QString FolderNavigationWidget::msgFindOnFileSystem()
{
return tr("Find in this directory...");
}
void FolderNavigationWidget::setHiddenFilesFilter(bool filter)
{
QDir::Filters filters = m_fileSystemModel->filter();
......
......@@ -60,8 +60,6 @@ public:
FolderNavigationWidget(QWidget *parent = 0);
bool autoSynchronization() const;
static QString msgFindOnFileSystem();
bool hiddenFilesFilter() const;
public slots:
......
......@@ -584,8 +584,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
projecTreeContext);
mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
d->m_searchOnFileSystem = new QAction(FolderNavigationWidget::msgFindOnFileSystem(), this);
d->m_searchOnFileSystem = new QAction(FileUtils::msgFindInDirectory(), this);
cmd = ActionManager::registerAction(d->m_searchOnFileSystem, ProjectExplorer::Constants::SEARCHONFILESYSTEM, projecTreeContext);
mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_CONFIG);
msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);
mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);
......
......@@ -53,6 +53,8 @@ FindInFiles::FindInFiles()
m_directory(0)
{
m_instance = this;
connect(Core::EditorManager::instance(), SIGNAL(findOnFileSystemRequest(QString)),
this, SLOT(findOnFileSystem(QString)));
}
FindInFiles::~FindInFiles()
......
......@@ -64,7 +64,7 @@ protected:
QString label() const;
QString toolTip() const;
public:
public slots:
static void findOnFileSystem(const QString &path);
private slots:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment