mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Datafile: Removed exclusions
This commit is contained in:
parent
9c91cb599b
commit
db3c3fb14c
2 changed files with 6 additions and 42 deletions
|
@ -83,20 +83,6 @@ std::vector <std::string> Datafile::allLines ()
|
|||
return _lines;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Datafile::setExclusions (const std::vector <std::string>& exclusions)
|
||||
{
|
||||
// TODO Overwrite local copy
|
||||
// TODO load current exclusion set
|
||||
// TODO if local copy != exclusion set
|
||||
// TODO remove old exclusion set from _lines
|
||||
// TODO add local copy
|
||||
// TODO _dirty = true;
|
||||
|
||||
// TODO New exclusions should always be written.
|
||||
_exclusions = exclusions;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Accepted intervals; day1 <= interval.start < dayN
|
||||
void Datafile::addInterval (const Interval& interval)
|
||||
|
@ -108,9 +94,6 @@ void Datafile::addInterval (const Interval& interval)
|
|||
if (! _lines_loaded)
|
||||
load_lines ();
|
||||
|
||||
// TODO if _lines contains no exclusions
|
||||
// TODO add _exclusions
|
||||
|
||||
// TODO if interval is not a duplicate
|
||||
// TODO insert interval.serialize into _lines
|
||||
// TODO _dirty = true;
|
||||
|
@ -173,7 +156,6 @@ std::string Datafile::dump () const
|
|||
<< " dirty: " << (_dirty ? "true" : "false") << '\n'
|
||||
<< " lines: " << _lines.size () << '\n'
|
||||
<< " loaded " << (_lines_loaded ? "true" : "false") << '\n'
|
||||
<< " exclusions: " << _exclusions.size () << '\n'
|
||||
<< " range: " << _range.start.toISO () << " - "
|
||||
<< _range.end.toISO () << '\n';
|
||||
|
||||
|
@ -187,27 +169,11 @@ void Datafile::load_lines ()
|
|||
{
|
||||
_file.lock ();
|
||||
|
||||
// File::read calls read_lines.clear (), so this prevents the exclsions from
|
||||
// being discarded.
|
||||
// Load the data.
|
||||
std::vector <std::string> read_lines;
|
||||
_file.read (read_lines);
|
||||
_file.close ();
|
||||
|
||||
bool hasExclusions = false;
|
||||
for (auto& line : read_lines)
|
||||
{
|
||||
if (line[0] == 'e')
|
||||
{
|
||||
hasExclusions = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the exclusions to new files.
|
||||
if (! hasExclusions)
|
||||
for (auto& e : _exclusions)
|
||||
_lines.push_back (e);
|
||||
|
||||
// Append the lines that were read.
|
||||
for (auto& line : read_lines)
|
||||
_lines.push_back (line);
|
||||
|
|
|
@ -43,7 +43,6 @@ public:
|
|||
std::string lastLine ();
|
||||
std::vector <std::string> allLines ();
|
||||
|
||||
void setExclusions (const std::vector <std::string>&);
|
||||
void addInterval (const Interval&);
|
||||
void deleteInterval (const Interval&);
|
||||
void commit ();
|
||||
|
@ -54,12 +53,11 @@ private:
|
|||
void load_lines ();
|
||||
|
||||
private:
|
||||
File _file {};
|
||||
bool _dirty {false};
|
||||
std::vector <std::string> _lines {};
|
||||
bool _lines_loaded {false};
|
||||
std::vector <std::string> _exclusions {};
|
||||
Range _range {};
|
||||
File _file {};
|
||||
bool _dirty {false};
|
||||
std::vector <std::string> _lines {};
|
||||
bool _lines_loaded {false};
|
||||
Range _range {};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue