summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/output.cc29
-rw-r--r--src/output.h4
2 files changed, 19 insertions, 14 deletions
diff --git a/src/output.cc b/src/output.cc
index 76d811a3..63d8c919 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -136,14 +136,22 @@ format_accounts::format_accounts(report_t& _report,
}
}
-void format_accounts::post_account(account_t& account)
+std::size_t format_accounts::post_account(account_t& account)
{
if (account.xdata().has_flags(ACCOUNT_EXT_TO_DISPLAY)) {
+ if (account.parent &&
+ account.parent->xdata().has_flags(ACCOUNT_EXT_TO_DISPLAY) &&
+ ! account.parent->xdata().has_flags(ACCOUNT_EXT_DISPLAYED))
+ post_account(*account.parent);
+
account.xdata().add_flags(ACCOUNT_EXT_DISPLAYED);
bind_scope_t bound_scope(report, account);
account_line_format.format(report.output_stream, bound_scope);
+
+ return 1;
}
+ return 0;
}
std::pair<std::size_t, std::size_t>
@@ -167,9 +175,11 @@ format_accounts::mark_accounts(account_t& account, const bool flat)
" it has " << to_display << " children to display");
#endif
- if (account.has_flags(ACCOUNT_EXT_VISITED) || (! flat && visited > 0)) {
+ if (account.parent &&
+ (account.has_flags(ACCOUNT_EXT_VISITED) || (! flat && visited > 0))) {
bind_scope_t bound_scope(report, account);
- if (disp_pred(bound_scope) && (flat || to_display != 1)) {
+ if ((! flat && to_display > 1) ||
+ (disp_pred(bound_scope) && (flat || to_display != 1))) {
account.xdata().add_flags(ACCOUNT_EXT_TO_DISPLAY);
DEBUG("account.display", "Marking account as TO_DISPLAY");
to_display = 1;
@@ -192,17 +202,12 @@ void format_accounts::flush()
mark_accounts(*report.session.master, report.HANDLED(flat));
- std::size_t top_displayed = 0;
+ std::size_t displayed = 0;
- foreach (account_t * account, posted_accounts) {
- post_account(*account);
-
- if (account->has_flags(ACCOUNT_EXT_DISPLAYED))
- top_displayed++;
- }
+ foreach (account_t * account, posted_accounts)
+ displayed += post_account(*account);
- if (! report.HANDLED(no_total) && top_displayed > 1 &&
- report.session.master->family_total()) {
+ if (! report.HANDLED(no_total) && displayed > 1) {
bind_scope_t bound_scope(report, *report.session.master);
separator_format.format(out, bound_scope);
total_line_format.format(out, bound_scope);
diff --git a/src/output.h b/src/output.h
index 00f7d38d..a35d81cd 100644
--- a/src/output.h
+++ b/src/output.h
@@ -109,8 +109,8 @@ public:
std::pair<std::size_t, std::size_t>
mark_accounts(account_t& account, const bool flat);
- virtual void post_account(account_t& account);
- virtual void flush();
+ virtual std::size_t post_account(account_t& account);
+ virtual void flush();
virtual void operator()(account_t& account);
};