Added date labels to the edit window
[ttodo.git] / tde.cc
blob3424982145ed2f6fb87917e8c0c97740a6203cfa
1 // tde.cc
2 //
4 #include "tde.h"
5 #include <time.h>
7 /// Default constructor.
8 CTodoEntry::CTodoEntry (void)
9 : m_Text (),
10 m_Comment (),
11 m_Created (time (NULL)),
12 m_Done (0),
13 m_Id (rand()),
14 m_SublistId (0),
15 m_Priority (priority_Medium),
16 m_Progress (0)
20 /// Reads the object from stream \p is.
21 void CTodoEntry::read (istream& is)
23 is >> m_Created >> m_Done
24 >> m_Id >> m_SublistId >> m_Priority >> m_Progress
25 >> m_Text >> m_Comment >> ios::talign<time_t>();
28 /// Writes the object to stream \p os.
29 void CTodoEntry::write (ostream& os) const
31 os << m_Created << m_Done
32 << m_Id << m_SublistId << m_Priority << m_Progress
33 << m_Text << m_Comment << ios::talign<time_t>();
36 /// Returns the size of the written object.
37 size_t CTodoEntry::stream_size (void) const
39 return (Align (stream_size_of (m_Created) +
40 stream_size_of (m_Done) +
41 stream_size_of (m_Id) +
42 stream_size_of (m_SublistId) +
43 stream_size_of (m_Priority) +
44 stream_size_of (m_Progress) +
45 stream_size_of (m_Text) +
46 stream_size_of (m_Comment), alignof(m_Created)));
49 /// Marks the item's \p progress and sets the done time if appropriate.
50 void CTodoEntry::MarkComplete (uint8_t progress)
52 assert (progress <= 100 && "Progress field is a percentage");
53 m_Progress = progress;
54 m_Done = time (NULL);
55 if (m_Progress != 100)
56 m_Done = 0;