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>
d->m_findDialog->open(filter);
}
+void FindPlugin::openFindDialog(IFindFilter *filter)
+{
+ if (d->m_currentDocumentFind->candidateIsEnabled())
+ d->m_currentDocumentFind->acceptCandidate();
+ QString currentFindString = (d->m_currentDocumentFind->isEnabled() ? d->m_currentDocumentFind->currentFindString() : "");
+ if (!currentFindString.isEmpty())
+ d->m_findDialog->setFindText(currentFindString);
+ d->m_findDialog->open(filter);
+}
+
void FindPlugin::setupMenu()
{
Core::ActionManager *am = Core::ICore::instance()->actionManager();
QStringListModel *replaceCompletionModel() const;
void setUseFakeVim(bool on);
void openFindToolBar(FindDirection direction);
+ void openFindDialog(IFindFilter *filter);
public slots:
void setCaseSensitive(bool sensitive);
#include "projectexplorer.h"
#include "projectexplorerconstants.h"
+#include <extensionsystem/pluginmanager.h>
+
#include <coreplugin/icore.h>
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/filemanager.h>
#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>
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"));
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()
{
bool autoSynchronization() const;
+ static void findOnFileSystem(const QString &pathIn);
+ static QString msgFindOnFileSystem();
public slots:
void setAutoSynchronization(bool sync);
void toggleAutoSynchronization();
QAction *m_renameFileAction;
QAction *m_openFileAction;
QAction *m_projectTreeCollapseAllAction;
+ QAction *m_searchOnFileSystem;
QAction *m_showInGraphicalShell;
QAction *m_openTerminalHere;
QAction *m_setStartupProjectAction;
projecTreeContext);
mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
+ d->m_searchOnFileSystem = new QAction(FolderNavigationWidget::msgFindOnFileSystem(), this);
+ cmd = am->registerAction(d->m_searchOnFileSystem, ProjectExplorer::Constants::SEARCHONFILESYSTEM, projecTreeContext);
+ mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_CONFIG);
+ msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);
+ mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);
+
d->m_showInGraphicalShell = new QAction(Core::FileUtils::msgGraphicalShellAction(), this);
cmd = am->registerAction(d->m_showInGraphicalShell, ProjectExplorer::Constants::SHOWINGRAPHICALSHELL,
projecTreeContext);
connect(d->m_addNewSubprojectAction, SIGNAL(triggered()), this, SLOT(addNewSubproject()));
connect(d->m_removeProjectAction, SIGNAL(triggered()), this, SLOT(removeProject()));
connect(d->m_openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
+ connect(d->m_searchOnFileSystem, SIGNAL(triggered()), this, SLOT(searchOnFileSystem()));
connect(d->m_showInGraphicalShell, SIGNAL(triggered()), this, SLOT(showInGraphicalShell()));
connect(d->m_openTerminalHere, SIGNAL(triggered()), this, SLOT(openTerminalHere()));
connect(d->m_removeFileAction, SIGNAL(triggered()), this, SLOT(removeFile()));
em->openEditor(d->m_currentNode->path(), QString(), Core::EditorManager::ModeSwitch);
}
+void ProjectExplorerPlugin::searchOnFileSystem()
+{
+ QTC_ASSERT(d->m_currentNode, return)
+ FolderNavigationWidget::findOnFileSystem(pathFor(d->m_currentNode));
+}
+
void ProjectExplorerPlugin::showInGraphicalShell()
{
QTC_ASSERT(d->m_currentNode, return)
void addNewSubproject();
void removeProject();
void openFile();
+ void searchOnFileSystem();
void showInGraphicalShell();
void removeFile();
void deleteFile();
const char * const ADDNEWSUBPROJECT = "ProjectExplorer.AddNewSubproject";
const char * const REMOVEPROJECT = "ProjectExplorer.RemoveProject";
const char * const OPENFILE = "ProjectExplorer.OpenFile";
+const char * const SEARCHONFILESYSTEM = "ProjectExplorer.SearchOnFileSystem";
const char * const SHOWINGRAPHICALSHELL = "ProjectExplorer.ShowInGraphicalShell";
const char * const OPENTERMIANLHERE = "ProjectExplorer.OpenTerminalHere";
const char * const REMOVEFILE = "ProjectExplorer.RemoveFile";
#include <QtGui/QVBoxLayout>
using namespace Find;
-using namespace TextEditor::Internal;
+using namespace TextEditor;
FindInFiles::FindInFiles(SearchResultWindow *resultWindow)
: BaseFileFind(resultWindow),
settings->endGroup();
syncComboWithSettings(m_directory, m_directorySetting);
}
+
+void FindInFiles::setDirectory(const QString &directory)
+{
+ syncComboWithSettings(m_directory, directory);
+}
+
namespace TextEditor {
-namespace Internal {
-class FindInFiles : public BaseFileFind
+class TEXTEDITOR_EXPORT FindInFiles : public BaseFileFind
{
Q_OBJECT
void writeSettings(QSettings *settings);
void readSettings(QSettings *settings);
+ void setDirectory(const QString &directory);
+
protected:
Utils::FileIterator *files() const;
QPointer<QComboBox> m_directory;
};
-} // namespace Internal
} // namespace TextEditor
#endif // FINDINFILES_H