diff options
author | saturneric <[email protected]> | 2024-01-15 09:22:32 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-15 09:22:32 +0000 |
commit | 6c632d70b391f8b317c68f7db8cfd217f9370995 (patch) | |
tree | 4136eb7164d9f910527c0392d12bd4854a2fdcff /src/ui/widgets/TextEdit.cpp | |
parent | refactor: remove boost and use QString instead of std::filesystem::path (diff) | |
download | GpgFrontend-6c632d70b391f8b317c68f7db8cfd217f9370995.tar.gz GpgFrontend-6c632d70b391f8b317c68f7db8cfd217f9370995.zip |
feat: use qt json support components in data object and infos gathering module
Diffstat (limited to 'src/ui/widgets/TextEdit.cpp')
-rw-r--r-- | src/ui/widgets/TextEdit.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp index e29184b8..0c5fb631 100644 --- a/src/ui/widgets/TextEdit.cpp +++ b/src/ui/widgets/TextEdit.cpp @@ -35,6 +35,7 @@ #include "core/GpgModel.h" #include "core/function/CacheManager.h" #include "core/function/GlobalSettingStation.h" +#include "ui/struct/CacheObject.h" namespace GpgFrontend::UI { @@ -668,26 +669,24 @@ void TextEdit::slot_save_status_to_cache_for_revovery() { } auto raw_text = document->toRawText(); - GF_UI_LOG_DEBUG("unsaved page index: {}, tab title: {} tab content: {}", i, - tab_title, raw_text.size()); + GF_UI_LOG_DEBUG("unsaved page index: {}, tab title: {}", i, tab_title); unsaved_pages.emplace_back(i, tab_title, raw_text); } - nlohmann::json unsaved_page_array = nlohmann::json::array(); + CacheObject cache("editor_unsaved_pages"); + QJsonArray unsaved_page_array; for (const auto& page : unsaved_pages) { const auto [index, title, content] = page; - nlohmann::json page_json; + QJsonObject page_json; page_json["index"] = index; - page_json["title"] = title.toStdString(); - page_json["content"] = content.toStdString(); + page_json["title"] = title; + page_json["content"] = content; unsaved_page_array.push_back(page_json); } - GF_UI_LOG_DEBUG("unsaved page json array: {}", unsaved_page_array.dump()); - CacheManager::GetInstance().SaveCache("editor_unsaved_pages", - unsaved_page_array); + cache.setArray(unsaved_page_array); } } // namespace GpgFrontend::UI |