2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-08-02 21:58:39 +08:00
|
|
|
#ifndef SEARCHDIALOG_H
|
|
|
|
#define SEARCHDIALOG_H
|
|
|
|
|
|
|
|
#include <QDialog>
|
2021-08-04 09:13:41 +08:00
|
|
|
#include "../qsynedit/SynEdit.h"
|
2021-08-05 19:58:32 +08:00
|
|
|
#include "../utils.h"
|
2021-08-02 21:58:39 +08:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class SearchDialog;
|
|
|
|
}
|
|
|
|
|
2021-08-05 12:31:53 +08:00
|
|
|
struct SearchResultTreeItem;
|
2021-08-02 23:42:10 +08:00
|
|
|
class QTabBar;
|
2021-08-03 23:55:57 +08:00
|
|
|
class Editor;
|
2021-08-02 21:58:39 +08:00
|
|
|
class SearchDialog : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2021-08-03 23:55:57 +08:00
|
|
|
enum class SearchAction {
|
|
|
|
Find,
|
|
|
|
FindFiles,
|
|
|
|
Replace,
|
|
|
|
ReplaceFiles
|
|
|
|
};
|
|
|
|
|
2021-08-02 21:58:39 +08:00
|
|
|
public:
|
|
|
|
explicit SearchDialog(QWidget *parent = nullptr);
|
|
|
|
~SearchDialog();
|
2021-08-02 23:42:10 +08:00
|
|
|
void find(const QString& text);
|
2021-08-04 00:17:38 +08:00
|
|
|
void findNext();
|
|
|
|
void findPrevious();
|
2021-08-02 23:42:10 +08:00
|
|
|
void findInFiles(const QString& text);
|
2021-08-05 19:58:32 +08:00
|
|
|
void findInFiles(const QString& keyword, SearchFileScope scope, SynSearchOptions options);
|
2021-08-02 23:42:10 +08:00
|
|
|
void replace(const QString& sFind, const QString& sReplace);
|
2021-08-03 23:55:57 +08:00
|
|
|
PSynSearchBase searchEngine() const;
|
|
|
|
|
2021-08-04 00:17:38 +08:00
|
|
|
QTabBar *tabBar() const;
|
|
|
|
|
2021-08-02 23:42:10 +08:00
|
|
|
private slots:
|
2021-08-03 23:55:57 +08:00
|
|
|
void onTabChanged();
|
2021-08-02 23:42:10 +08:00
|
|
|
void on_cbFind_currentTextChanged(const QString &arg1);
|
|
|
|
|
|
|
|
void on_btnCancel_clicked();
|
|
|
|
|
|
|
|
void on_btnExecute_clicked();
|
2021-08-03 23:55:57 +08:00
|
|
|
private:
|
2021-11-02 13:12:36 +08:00
|
|
|
int execute(SynEdit* editor, const QString& sSearch,
|
2022-01-24 18:03:35 +08:00
|
|
|
const QString& sReplace,
|
|
|
|
SynSearchMathedProc matchCallback = nullptr,
|
|
|
|
SynSearchConfirmAroundProc confirmAroundCallback = nullptr);
|
2021-11-02 13:12:36 +08:00
|
|
|
std::shared_ptr<SearchResultTreeItem> batchFindInEditor(SynEdit * editor,const QString& filename, const QString& keyword);
|
2021-08-02 21:58:39 +08:00
|
|
|
private:
|
|
|
|
Ui::SearchDialog *ui;
|
2021-08-02 23:42:10 +08:00
|
|
|
QTabBar *mTabBar;
|
2021-08-03 23:55:57 +08:00
|
|
|
SynSearchOptions mSearchOptions;
|
|
|
|
PSynSearchBase mSearchEngine;
|
|
|
|
PSynSearchBase mBasicSearchEngine;
|
|
|
|
PSynSearchBase mRegexSearchEngine;
|
2021-08-02 21:58:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SEARCHDIALOG_H
|