| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
|---|---|
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #ifndef TEXTEDITKEEPER_H |
| 6 | #define TEXTEDITKEEPER_H |
| 7 | |
| 8 | #include "textedittabwidget/textedit.h" |
| 9 | #include "services/project/projectinfo.h" |
| 10 | #include <framework/service/qtclassfactory.h> |
| 11 | #include <framework/service/qtclassmanager.h> |
| 12 | |
| 13 | class TextEditKeeper final |
| 14 | { |
| 15 | dpf::QtClassFactory<TextEdit> editFactory; |
| 16 | QString analysedLanguage; |
| 17 | QString analysedWorkspace; |
| 18 | QString analysedStorage; |
| 19 | AnalysedData data; |
| 20 | dpfservice::ProjectInfo proInfo; |
| 21 | TextEditKeeper(){} |
| 22 | |
| 23 | inline static TextEditKeeper *instance(){ |
| 24 | static TextEditKeeper ins; |
| 25 | return &ins; |
| 26 | } |
| 27 | |
| 28 | public: |
| 29 | |
| 30 | template<class Edit> |
| 31 | static bool impl(const QString &language = Edit::implLanguage(), QString *err = nullptr) { |
| 32 | bool result = true; |
| 33 | result &= instance()->editFactory.regClass<Edit>(language, err); |
| 34 | return result; |
| 35 | } |
| 36 | |
| 37 | static TextEdit *create(const QString &language, QString *err = nullptr); |
| 38 | |
| 39 | static void setAnalysedLanguage(const QString &lang); |
| 40 | static QString getAnalysedLanguage(); |
| 41 | |
| 42 | static void setAnalysedWorkspace(const QString &workspace); |
| 43 | static QString getAnalysedWorkspace(); |
| 44 | |
| 45 | static void setAnalysedStorage(const QString &storage); |
| 46 | static QString getAnalysedStorage(); |
| 47 | |
| 48 | static void setAnalysedData(const AnalysedData &data); |
| 49 | static AnalysedData analysedData(); |
| 50 | static void cleanAnalysedData(); |
| 51 | |
| 52 | static QString userActionAnalyseTitle(); |
| 53 | static QString getTokenTypeAnnLine(const QString &tokenType, const QString &displayText); |
| 54 | |
| 55 | static dpfservice::ProjectInfo projectInfo(); |
| 56 | static void saveProjectInfo(const dpfservice::ProjectInfo &info); |
| 57 | static void removeProjectInfo(const dpfservice::ProjectInfo &info); |
| 58 | }; |
| 59 | |
| 60 | #endif // TEXTEDITKEEPER_H |
| 61 |