File indexing completed on 2024-05-12 09:55:44
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2021 Méven Car <meven.car@kdemail.net> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "katesession.h" 0010 #include "kconfiggroup.h" 0011 0012 namespace KTextEditor 0013 { 0014 class Document; 0015 } 0016 0017 class KateViewManager; 0018 0019 class KateStashManager : QObject 0020 { 0021 Q_OBJECT 0022 public: 0023 explicit KateStashManager(QObject *parent = nullptr); 0024 0025 bool stashUnsavedChanges() const 0026 { 0027 return m_stashUnsavedChanges; 0028 } 0029 0030 void setStashUnsavedChanges(bool stashUnsavedChanges) 0031 { 0032 m_stashUnsavedChanges = stashUnsavedChanges; 0033 } 0034 0035 bool stashNewUnsavedFiles() const 0036 { 0037 return m_stashNewUnsavedFiles; 0038 } 0039 0040 void setStashNewUnsavedFiles(bool stashNewUnsavedFiles) 0041 { 0042 m_stashNewUnsavedFiles = stashNewUnsavedFiles; 0043 } 0044 0045 bool canStash() const; 0046 0047 void stashDocuments(KConfig *cfg, const QList<KTextEditor::Document *> &documents) const; 0048 0049 bool willStashDoc(KTextEditor::Document *doc) const; 0050 0051 void stashDocument(KTextEditor::Document *doc, const QString &stashfileName, KConfigGroup &kconfig, const QString &path) const; 0052 static void popDocument(KTextEditor::Document *doc, const KConfigGroup &kconfig); 0053 0054 static void clearStashForSession(const KateSession::Ptr session); 0055 0056 private: 0057 bool m_stashUnsavedChanges = false; 0058 bool m_stashNewUnsavedFiles = true; 0059 };