1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef SEARCHRESULTWINDOW_H
6#define SEARCHRESULTWINDOW_H
7
8#include <QWidget>
9#include <QTreeView>
10
11typedef struct {
12 QStringList filePathList;
13 QString searchText;
14 bool sensitiveFlag;
15 bool wholeWordsFlag;
16 QStringList patternsList;
17 QStringList exPatternsList;
18 QMap<QString, QString> projectInfoMap;
19}SearchParams;
20
21typedef struct{
22 QString filePathName;
23 int lineNumber;
24 QString context;
25}FindItem;
26
27using FindItemList = QList<FindItem>;
28
29class SearchResultTreeViewPrivate;
30class SearchResultTreeView : public QTreeView
31{
32 Q_OBJECT
33public:
34 explicit SearchResultTreeView(QWidget *parent = nullptr);
35 void setData(FindItemList &itemList, QMap<QString, QString> projectInfoMap);
36 void clearData();
37
38signals:
39private:
40 SearchResultTreeViewPrivate *const d;
41};
42
43class SearchResultWindowPrivate;
44class SearchResultWindow : public QWidget
45{
46 Q_OBJECT
47public:
48 explicit SearchResultWindow(QWidget *parent = nullptr);
49 void search(SearchParams *params);
50 void setRepalceWidgtVisible(bool hide);
51 void startSearch(const QString &cmd, const QString &filePath, QMap<QString, QString> projectInfoMap);
52 void startReplace(const QStringList &options);
53 void searchAgain();
54 void showMsg(bool succeed, QString msg);
55
56signals:
57 void back();
58
59private:
60 void setupUi();
61 void clean();
62 void replace();
63
64 SearchResultWindowPrivate *const d;
65};
66
67#endif // SEARCHRESULTWINDOW_H
68