diff --git a/src/Database.cpp b/src/Database.cpp index 1cedee2f..0ba330ad 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -60,6 +60,16 @@ void Database::initialize (const std::string& location) // TODO If there is no data file named YYYY—MM.data, then create it. } +//////////////////////////////////////////////////////////////////////////////// +void Database::commit () +{ + if (_dirty) + { + + _dirty = false; + } +} + //////////////////////////////////////////////////////////////////////////////// Interval Database::getLatestInterval () const { @@ -70,18 +80,21 @@ Interval Database::getLatestInterval () const void Database::addExclusion (const std::string& exclusion) { _files[0].addExclusion (exclusion); + _dirty = true; } //////////////////////////////////////////////////////////////////////////////// void Database::addInterval (const Interval& interval) { _files[0].addInterval (interval); + _dirty = true; } //////////////////////////////////////////////////////////////////////////////// void Database::modifyInterval (const Interval& interval) { _files[0].modifyInterval (interval); + _dirty = true; } //////////////////////////////////////////////////////////////////////////////// @@ -94,6 +107,8 @@ std::string Database::dump () const << (file.name () == _current ? " (current)" : "") << "\n"; + out << " Dirty: " << (_dirty ? "true" : "false") << "\n"; + return out.str (); } diff --git a/src/Database.h b/src/Database.h index 1f4902ae..f9cb9383 100644 --- a/src/Database.h +++ b/src/Database.h @@ -37,6 +37,7 @@ class Database public: Database () = default; void initialize (const std::string&); + void commit (); Interval getLatestInterval () const; @@ -53,6 +54,7 @@ private: std::string _location {"~/.timewarrior/data"}; std::string _current {}; std::vector _files {}; + bool _dirty {false}; }; #endif