mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Filter: Inherited much of Interval
This commit is contained in:
parent
1501fc2ace
commit
1bad5eb856
2 changed files with 62 additions and 0 deletions
|
@ -28,3 +28,48 @@
|
|||
#include <Filter.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Filter::empty () const
|
||||
{
|
||||
return _start.toEpoch () == 0 &&
|
||||
_end.toEpoch () == 0 &&
|
||||
_tags.size () == 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Datetime Filter::start () const
|
||||
{
|
||||
return _start;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Filter::start (Datetime value)
|
||||
{
|
||||
_start = value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Datetime Filter::end () const
|
||||
{
|
||||
return _end;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Filter::end (Datetime value)
|
||||
{
|
||||
_end = value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::set <std::string> Filter::tags () const
|
||||
{
|
||||
return _tags;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Filter::tag (const std::string& tag)
|
||||
{
|
||||
if (_tags.find (tag) == _tags.end ())
|
||||
_tags.insert (tag);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
17
src/Filter.h
17
src/Filter.h
|
@ -27,12 +27,29 @@
|
|||
#ifndef INCLUDED_FILTER
|
||||
#define INCLUDED_FILTER
|
||||
|
||||
#include <Datetime.h>
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
class Filter
|
||||
{
|
||||
public:
|
||||
Filter () = default;
|
||||
bool empty () const;
|
||||
|
||||
Datetime start () const;
|
||||
void start (Datetime);
|
||||
|
||||
Datetime end () const;
|
||||
void end (Datetime);
|
||||
|
||||
std::set <std::string> tags () const;
|
||||
void tag (const std::string&);
|
||||
|
||||
private:
|
||||
Datetime _start {0};
|
||||
Datetime _end {0};
|
||||
std::set <std::string> _tags {};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue