Merge branch 't/checkout_cleared' into next

This commit is contained in:
John Wiegley 2012-05-10 04:01:16 -05:00
commit 2bc14c3919
5 changed files with 24 additions and 12 deletions

View file

@ -309,6 +309,10 @@ namespace {
return (! account.self_details().latest_checkout.is_not_a_date_time() ?
value_t(account.self_details().latest_checkout) : NULL_VALUE);
}
value_t get_latest_checkout_cleared(account_t& account)
{
return account.self_details().latest_checkout_cleared;
}
template <value_t (*Func)(account_t&)>
value_t get_wrapper(call_scope_t& args) {
@ -405,6 +409,8 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind,
return WRAP_FUNCTOR(get_wrapper<&get_latest>);
else if (fn_name == "latest_checkout")
return WRAP_FUNCTOR(get_wrapper<&get_latest_checkout>);
else if (fn_name == "latest_checkout_cleared")
return WRAP_FUNCTOR(get_wrapper<&get_latest_checkout_cleared>);
break;
case 'n':
@ -662,8 +668,10 @@ void account_t::xdata_t::details_t::update(post_t& post,
earliest_checkin = *post.checkin;
if (post.checkout && (latest_checkout.is_not_a_date_time() ||
*post.checkout > latest_checkout))
*post.checkout > latest_checkout)) {
latest_checkout = *post.checkout;
latest_checkout_cleared = post.state() == item_t::CLEARED;
}
if (post.state() == item_t::CLEARED) {
posts_cleared_count++;

View file

@ -183,6 +183,7 @@ public:
datetime_t earliest_checkin;
datetime_t latest_checkout;
bool latest_checkout_cleared;
std::set<path> filenames;
std::set<string> accounts_referenced;

View file

@ -431,7 +431,7 @@ void instance_t::read_next_directive(bool& error_flag)
#if defined(TIMELOG_SUPPORT)
void instance_t::clock_in_directive(char * line, bool /*capitalized*/)
void instance_t::clock_in_directive(char * line, bool capitalized)
{
string datetime(line, 2, 19);
@ -452,7 +452,7 @@ void instance_t::clock_in_directive(char * line, bool /*capitalized*/)
position.end_line = context.linenum;
position.sequence = context.sequence++;
time_xact_t event(position, parse_datetime(datetime),
time_xact_t event(position, parse_datetime(datetime), capitalized,
p ? top_account()->find_account(p) : NULL,
n ? n : "",
end ? end : "");
@ -460,7 +460,7 @@ void instance_t::clock_in_directive(char * line, bool /*capitalized*/)
timelog.clock_in(event);
}
void instance_t::clock_out_directive(char * line, bool /*capitalized*/)
void instance_t::clock_out_directive(char * line, bool capitalized)
{
string datetime(line, 2, 19);
@ -481,7 +481,7 @@ void instance_t::clock_out_directive(char * line, bool /*capitalized*/)
position.end_line = context.linenum;
position.sequence = context.sequence++;
time_xact_t event(position, parse_datetime(datetime),
time_xact_t event(position, parse_datetime(datetime), capitalized,
p ? top_account()->find_account(p) : NULL,
n ? n : "",
end ? end : "");

View file

@ -62,7 +62,7 @@ namespace {
VERIFY(amt.valid());
post_t * post = new post_t(in_event.account, amt, POST_VIRTUAL);
post->set_state(item_t::CLEARED);
post->set_state(out_event.completed ? item_t::CLEARED : item_t::UNCLEARED);
post->pos = in_event.position;
post->checkin = in_event.checkin;
post->checkout = out_event.checkin;

View file

@ -56,6 +56,7 @@ class time_xact_t
{
public:
datetime_t checkin;
bool completed;
account_t * account;
string desc;
string note;
@ -66,16 +67,18 @@ public:
}
time_xact_t(const optional<position_t>& _position,
const datetime_t& _checkin,
account_t * _account = NULL,
const string& _desc = "",
const string& _note = "")
: checkin(_checkin), account(_account), desc(_desc), note(_note),
const bool _completed = false,
account_t * _account = NULL,
const string& _desc = "",
const string& _note = "")
: checkin(_checkin), completed(_completed), account(_account),
desc(_desc), note(_note),
position(_position ? *_position : position_t()) {
TRACE_CTOR(time_xact_t,
"position_t, datetime_t, account_t *, string, string");
"position_t, datetime_t, bool, account_t *, string, string");
}
time_xact_t(const time_xact_t& xact)
: checkin(xact.checkin), account(xact.account),
: checkin(xact.checkin), completed(xact.completed), account(xact.account),
desc(xact.desc), note(xact.note), position(xact.position) {
TRACE_CTOR(time_xact_t, "copy");
}