RedPanda-CPP/RedPandaIDE/widgets/searchdialog.h

82 lines
2.3 KiB
C
Raw Normal View History

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);
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;
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:
int execute(SynEdit* editor, const QString& sSearch,
const QString& sReplace,
SynSearchMathedProc matchCallback = nullptr,
SynSearchConfirmAroundProc confirmAroundCallback = nullptr);
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;
// QWidget interface
protected:
void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
2021-08-02 21:58:39 +08:00
};
#endif // SEARCHDIALOG_H