1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef TEXTEDITTABWIDGET_H |
6 | #define TEXTEDITTABWIDGET_H |
7 | |
8 | #include "common/common.h" |
9 | |
10 | #include <QWidget> |
11 | |
12 | class TextEdit; |
13 | class TextEditTabWidgetPrivate; |
14 | class TextEditTabWidget : public QWidget |
15 | { |
16 | Q_OBJECT |
17 | friend class TextEditTabWidgetPrivate; |
18 | TextEditTabWidgetPrivate *const d; |
19 | public: |
20 | explicit TextEditTabWidget(QWidget *parent = nullptr); |
21 | explicit TextEditTabWidget(TextEditTabWidget &text); |
22 | virtual ~TextEditTabWidget(); |
23 | static TextEditTabWidget *instance(); |
24 | void setCloseButtonVisible(bool flag); |
25 | void setSplitButtonVisible(bool flag); |
26 | |
27 | protected: |
28 | virtual void keyPressEvent(QKeyEvent *event) override; |
29 | virtual void focusInEvent(QFocusEvent *event) override; |
30 | virtual void focusOutEvent(QFocusEvent *event) override; |
31 | void paintEvent(QPaintEvent *event = nullptr) override; |
32 | void dragEnterEvent(QDragEnterEvent *event) override; |
33 | void dropEvent(QDropEvent *event) override; |
34 | |
35 | signals: |
36 | void closed(); |
37 | void splitClicked(Qt::Orientation, const newlsp::ProjectKey &, const QString &); |
38 | void selected(bool state); |
39 | void closeWidget(); |
40 | void sigOpenFile(); |
41 | |
42 | public slots: |
43 | void openFile(const QString &filePath); |
44 | void closeFile(const QString &filePath); |
45 | void jumpToLine(const QString &filePath, int line); |
46 | void jumpToRange(const QString &filePath, const newlsp::Range &range); |
47 | void runningToLine(const QString &filePath, int line); |
48 | void openFileWithKey(const newlsp::ProjectKey &key, const QString &filePath); |
49 | void jumpToLineWithKey(const newlsp::ProjectKey &key, const QString &filePath, int line); |
50 | void runningToLineWithKey(const newlsp::ProjectKey &key, const QString &filePath, int line); |
51 | void runningEnd(); |
52 | void addDebugPoint(const QString &filePath, int line); |
53 | void removeDebugPoint(const QString &filePath, int line); |
54 | void debugPointClean(); |
55 | void replaceRange(const QString &filePath, const newlsp::Range &range,const QString &text); |
56 | void setLineBackground(const QString &filePath, int line, const QColor &color); |
57 | void delLineBackground(const QString &filePath, int line); |
58 | void cleanLineBackground(const QString &filePath); |
59 | void setAnnotation(const QString &filePath, int line, const QString &title, const AnnotationInfo &info); |
60 | void cleanAnnotation(const QString &filePath, const QString &title); |
61 | void cleanAllAnnotation(const QString &title); |
62 | void selectSelf(bool state); |
63 | void setModifiedAutoReload(const QString &filePath, bool flag); |
64 | |
65 | private slots: |
66 | void setDefaultFileEdit(); |
67 | void hideFileEdit(const QString &file); |
68 | void showFileEdit(const QString &file); |
69 | void hideFileStatusBar(const QString &file); |
70 | void showFileStatusBar(const QString &file); |
71 | void removeFileStatusBar(const QString &file); |
72 | void removeFileEdit(const QString &file); |
73 | void removeFileTab(const QString &file); |
74 | void fileModifyed(const QString &file); |
75 | void fileDeleted(const QString &file); |
76 | void fileMoved(const QString &file); |
77 | void doRenameReplace(const newlsp::WorkspaceEdit &renameResult); |
78 | TextEdit *switchFileAndToOpen(const newlsp::ProjectKey &key, const QString &filePath); |
79 | TextEdit *switchFileAndToOpen(const QString &filePath); |
80 | void saveEditFile(const QString &file); |
81 | |
82 | private: |
83 | void handleDeletedFile(const QString &file); |
84 | void detectFile(const QString &file); |
85 | }; |
86 | |
87 | #endif // TEXTEDITTABWIDGET_H |
88 | |