File indexing completed on 2024-04-28 04:38:53
0001 /* 0002 SPDX-FileCopyrightText: 1999-2001 Bernd Gehrmann <bernd@kdevelop.org> 0003 SPDX-FileCopyrightText: 1999-2001 the KDevelop Team 0004 SPDX-FileCopyrightText: 2007 Dukju Ahn <dukjuahn@gmail.com> 0005 SPDX-FileCopyrightText: 2010 Julien Desgats <julien.desgats@gmail.com> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #ifndef KDEVPLATFORM_PLUGIN_GREPDIALOG_H 0011 #define KDEVPLATFORM_PLUGIN_GREPDIALOG_H 0012 0013 #include <QDialog> 0014 #include <QUrl> 0015 0016 #include "grepjob.h" 0017 #include "ui_grepwidget.h" 0018 0019 class GrepOutputView; 0020 class GrepViewPlugin; 0021 0022 class GrepDialog : public QDialog, private Ui::GrepWidget 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 /// Search results are displayed in: @p toolView if it is not null, 0028 /// or in a possibly created and raised GrepOutputView in the current area. 0029 explicit GrepDialog(GrepViewPlugin* plugin, GrepOutputView* toolView = nullptr, QWidget* parent = nullptr, 0030 bool show = true); 0031 ~GrepDialog() override; 0032 0033 /// Read last used settings from config. 0034 /// @pre @c show == @c false has been passed to the constructor. 0035 void setLastUsedSettings(); 0036 0037 void setPattern(const QString& pattern); 0038 0039 ///Rerun all grep jobs from a list of settings, called by GrepOutputView 0040 void historySearch(QVector<GrepJobSettings> &settingsHistory); 0041 0042 public Q_SLOTS: 0043 ///Start a new search 0044 void startSearch(); 0045 0046 ///Sets directory(ies)/files to search in. Also it can be semicolon separated list of directories/files or one of special strings: allOpenFilesString, allOpenProjectsString 0047 void setSearchLocations(const QString &dir); 0048 0049 private Q_SLOTS: 0050 void templateTypeComboActivated(int); 0051 void patternComboEditTextChanged( const QString& ); 0052 QMenu* createSyncButtonMenu(); 0053 void addUrlToMenu(QMenu* ret, const QUrl& url); 0054 void addStringToMenu(QMenu* ret, const QString& string); 0055 void synchronizeDirActionTriggered(bool); 0056 0057 ///Check if all projects have been loaded 0058 bool checkProjectsOpened(); 0059 ///Call the next element in m_jobs_history or close the dialog if all jobs are done 0060 ///\param[in] next if false, skip pending jobs 0061 void nextHistory(bool next); 0062 0063 ///Opens the dialog to select a directory to search in, and inserts it into Location(s) field. 0064 void selectDirectoryDialog(); 0065 0066 protected: 0067 ///Prevent showing the dialog if m_show is false 0068 void setVisible(bool visible) override; 0069 void closeEvent(QCloseEvent* closeEvent) override; 0070 0071 private: 0072 ///Returns whether the given url is a subfile/subdirectory of one of the chosen directories/files 0073 /// 0074 ///This is slow, so don't call it too often 0075 bool isPartOfChoice(const QUrl& url) const; 0076 ///Checks what a user has entered into the dialog and saves the data in m_settings 0077 void updateSettings(); 0078 /// Enables/disables limit-to-project UI depending on current search paths. 0079 void updateLimitToProjectEnabled(); 0080 0081 GrepViewPlugin * m_plugin; 0082 GrepOutputView* const m_toolView; 0083 ///Allow to show a dialog 0084 const bool m_show; 0085 ///Current setting 0086 GrepJobSettings m_settings; 0087 ///List of remaining grep job settings to be done 0088 QVector<GrepJobSettings> m_historyJobSettings; 0089 }; 0090 0091 0092 #endif 0093