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 | |
11 | typedef 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 | |
21 | typedef struct{ |
22 | QString filePathName; |
23 | int lineNumber; |
24 | QString context; |
25 | }FindItem; |
26 | |
27 | using FindItemList = QList<FindItem>; |
28 | |
29 | class SearchResultTreeViewPrivate; |
30 | class SearchResultTreeView : public QTreeView |
31 | { |
32 | Q_OBJECT |
33 | public: |
34 | explicit SearchResultTreeView(QWidget *parent = nullptr); |
35 | void setData(FindItemList &itemList, QMap<QString, QString> projectInfoMap); |
36 | void clearData(); |
37 | |
38 | signals: |
39 | private: |
40 | SearchResultTreeViewPrivate *const d; |
41 | }; |
42 | |
43 | class SearchResultWindowPrivate; |
44 | class SearchResultWindow : public QWidget |
45 | { |
46 | Q_OBJECT |
47 | public: |
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 | |
56 | signals: |
57 | void back(); |
58 | |
59 | private: |
60 | void setupUi(); |
61 | void clean(); |
62 | void replace(); |
63 | |
64 | SearchResultWindowPrivate *const d; |
65 | }; |
66 | |
67 | #endif // SEARCHRESULTWINDOW_H |
68 | |