summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRahix <rahix@rahix.de>2020-05-12 18:41:33 +0200
committerJohn Wiegley <johnw@newartisans.com>2020-07-21 14:50:01 -0700
commitf1e8a0a42f9b0d2b11201a2b67bea6f60e37c76f (patch)
tree229cbeb40aab69a3889e479e6a8477baa495acdd /src
parent5e10e0c94aa764e3933e19bd40b7cd35ff6d37f0 (diff)
downloadfork-ledger-f1e8a0a42f9b0d2b11201a2b67bea6f60e37c76f.tar.gz
fork-ledger-f1e8a0a42f9b0d2b11201a2b67bea6f60e37c76f.tar.bz2
fork-ledger-f1e8a0a42f9b0d2b11201a2b67bea6f60e37c76f.zip
collapse_posts: Add a collapse_depth attribute
Replace the hardcoded depth of 3 with a class attribute that can later be set from a commandline argument.
Diffstat (limited to 'src')
-rw-r--r--src/filters.cc6
-rw-r--r--src/filters.h7
2 files changed, 7 insertions, 6 deletions
diff --git a/src/filters.cc b/src/filters.cc
index 6b91aab4..3e481139 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -472,12 +472,10 @@ void collapse_posts::report_subtotal()
value_t& collapse_posts::find_totals(account_t* account)
{
- unsigned short depth=3;
-
- if (depth == 0)
+ if (collapse_depth == 0)
return totals[_("<Total>")];
- if (account->depth == depth)
+ if (account->depth == collapse_depth)
return totals[account->fullname()];
//else recurse
diff --git a/src/filters.h b/src/filters.h
index 40e25ac0..be2e0e84 100644
--- a/src/filters.h
+++ b/src/filters.h
@@ -439,6 +439,7 @@ class collapse_posts : public item_handler<post_t>
temporaries_t temps;
totals_map totals;
bool only_collapse_if_zero;
+ unsigned short collapse_depth;
std::list<post_t *> component_posts;
report_t& report;
@@ -450,12 +451,14 @@ public:
expr_t& _amount_expr,
predicate_t _display_predicate,
predicate_t _only_predicate,
- bool _only_collapse_if_zero = false)
+ bool _only_collapse_if_zero = false,
+ unsigned short _collapse_depth = 0)
: item_handler<post_t>(handler), amount_expr(_amount_expr),
display_predicate(_display_predicate),
only_predicate(_only_predicate), count(0),
last_xact(NULL), last_post(NULL),
- only_collapse_if_zero(_only_collapse_if_zero), report(_report) {
+ only_collapse_if_zero(_only_collapse_if_zero),
+ collapse_depth(_collapse_depth), report(_report) {
TRACE_CTOR(collapse_posts, "post_handler_ptr, ...");
}
virtual ~collapse_posts() {