| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #ifndef GUI_AUTOSAVER_H |
| #define GUI_AUTOSAVER_H |
|
|
| #include <QObject> |
|
|
| #include <map> |
| #include <set> |
| #include <string> |
| #include <fastsignals/signal.h> |
| #include <Base/Writer.h> |
|
|
| namespace App |
| { |
| class Document; |
| class DocumentObject; |
| class Property; |
| } |
|
|
| namespace Gui |
| { |
| class ViewProvider; |
|
|
| class AutoSaveProperty |
| { |
| public: |
| AutoSaveProperty(const App::Document* doc); |
| ~AutoSaveProperty(); |
| int timerId; |
| std::set<std::string> touched; |
| std::string dirName; |
| std::map<std::string, std::string> fileMap; |
|
|
| private: |
| void slotNewObject(const App::DocumentObject&); |
| void slotChangePropertyData(const App::Property&); |
| using Connection = fastsignals::connection; |
| Connection documentNew; |
| Connection documentMod; |
| }; |
|
|
| |
| |
| |
| |
| class AutoSaver: public QObject |
| { |
| Q_OBJECT |
|
|
| private: |
| static AutoSaver* self; |
| AutoSaver(QObject* parent); |
| ~AutoSaver() override; |
|
|
| public: |
| static AutoSaver* instance(); |
| |
| |
| |
| void setTimeout(int ms); |
| |
| |
| |
| void setCompressed(bool on); |
|
|
| protected: |
| void slotCreateDocument(const App::Document& Doc); |
| void slotDeleteDocument(const App::Document& Doc); |
| void timerEvent(QTimerEvent* event) override; |
| void saveDocument(const std::string&, AutoSaveProperty&); |
|
|
| public Q_SLOTS: |
| void renameFile(QString dirName, QString file, QString tmpFile); |
|
|
| private: |
| int timeout; |
| bool compressed; |
| std::map<std::string, AutoSaveProperty*> saverMap; |
| }; |
|
|
| class RecoveryWriter: public Base::FileWriter |
| { |
| public: |
| RecoveryWriter(AutoSaveProperty&); |
| ~RecoveryWriter() override; |
|
|
| |
| |
| |
| |
| |
| bool shouldWrite(const std::string&, const Base::Persistence*) const override; |
| void writeFiles() override; |
|
|
| private: |
| AutoSaveProperty& saver; |
| }; |
|
|
| } |
|
|
|
|
| #endif |
|
|