2022-11-11 21:20:57 +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/>.
|
|
|
|
*/
|
|
|
|
#ifndef SEARCHINFILEDIALOG_H
|
|
|
|
#define SEARCHINFILEDIALOG_H
|
|
|
|
|
|
|
|
#include <QDialog>
|
2023-01-11 16:22:26 +08:00
|
|
|
#include <qsynedit/qsynedit.h>
|
2022-11-11 21:20:57 +08:00
|
|
|
#include "../utils.h"
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class SearchInFileDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SearchResultTreeItem;
|
|
|
|
class QTabBar;
|
|
|
|
class Editor;
|
|
|
|
class SearchInFileDialog : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit SearchInFileDialog(QWidget *parent = nullptr);
|
|
|
|
~SearchInFileDialog();
|
|
|
|
void findInFiles(const QString& text);
|
|
|
|
void findInFiles(const QString& keyword, SearchFileScope scope, QSynedit::SearchOptions options);
|
|
|
|
QSynedit::PSynSearchBase searchEngine() const;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void on_cbFind_currentTextChanged(const QString &arg1);
|
|
|
|
|
|
|
|
void on_btnCancel_clicked();
|
|
|
|
|
|
|
|
void on_btnExecute_clicked();
|
|
|
|
void on_btnReplace_clicked();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void doSearch(bool replace);
|
2023-01-11 16:22:26 +08:00
|
|
|
int execute(QSynedit::QSynEdit* editor, const QString& sSearch,
|
2022-11-11 21:20:57 +08:00
|
|
|
const QString& sReplace,
|
|
|
|
QSynedit::SearchMathedProc matchCallback = nullptr,
|
|
|
|
QSynedit::SearchConfirmAroundProc confirmAroundCallback = nullptr);
|
2023-01-11 16:22:26 +08:00
|
|
|
std::shared_ptr<SearchResultTreeItem> batchFindInEditor(QSynedit::QSynEdit * editor,const QString& filename, const QString& keyword);
|
2022-11-11 21:20:57 +08:00
|
|
|
private:
|
|
|
|
Ui::SearchInFileDialog *ui;
|
|
|
|
QSynedit::SearchOptions mSearchOptions;
|
|
|
|
QSynedit::PSynSearchBase mBasicSearchEngine;
|
|
|
|
QSynedit::PSynSearchBase mRegexSearchEngine;
|
|
|
|
|
|
|
|
// QWidget interface
|
|
|
|
protected:
|
|
|
|
void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SEARCHINFILEDIALOG_H
|