diff options
author | 2021-02-13 18:58:14 +0100 | |
---|---|---|
committer | 2021-02-13 12:20:25 -0800 | |
commit | 622e9ba373f898a0d51fc009f3615d83ffd3a7fc (patch) | |
tree | 7dbddb9cd826328d745fe5086e254a93950efab3 /desktop-widgets/templatelayout.h | |
parent | 6ef4f377f0a6bc567f82fa34764c1d81cdab5a1a (diff) | |
download | subsurface-622e9ba373f898a0d51fc009f3615d83ffd3a7fc.tar.gz |
printing: "fix" progress indicator
In TemplateLayout, there was a progress indication, which reported
the progress - not of the actual rendering - but of adding the
dives to the "to render" list. Which is of course done in less than
a ms, making the whole thing completely pointless.
Instead, emit progress when actually looping over the dives or
statistics.
Nobody ever noticed the problem because even rendering is done in
fractions of a second and indeed is accounted to only one fifth
of the total progress.
The real purpose of this "fix" is to get rid of the getTotalWork()
function, which was just insane. Instead of asking the TemplateLayout
how many dives it rendered, this number was extracted from
global state. Simply store the number of dives in the TemplateLayout
object instead.
Moreover, fix two coding style issues:
- "Page" variable identifier starting with a capital
- The Printer::render() being defined (as opposed to declared) with
a default parameter. This is not how C++'s default parameters work,
sorry.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/templatelayout.h')
-rw-r--r-- | desktop-widgets/templatelayout.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/desktop-widgets/templatelayout.h b/desktop-widgets/templatelayout.h index 24dfdf278..3b5c3b9b5 100644 --- a/desktop-widgets/templatelayout.h +++ b/desktop-widgets/templatelayout.h @@ -10,7 +10,6 @@ struct print_options; struct template_options; class QTextStream; -int getTotalWork(const print_options &printOptions); void find_all_templates(); void set_bundled_templates_as_read_only(); void copy_bundled_templates(QString src, QString dst, QStringList *templateBackupList); @@ -32,6 +31,7 @@ public: QString generateStatistics(); static QString readTemplate(QString template_name); static void writeTemplate(QString template_name, QString grantlee_template); + int numDives; // valid after a call to generate() private: struct State { @@ -49,7 +49,7 @@ private: QList<token> lexer(QString input); void parser(QList<token> tokenList, int from, int to, QTextStream &out, State &state); template<typename V, typename T> - void parser_for(QList<token> tokenList, int from, int to, QTextStream &out, State &state, const V &data, const T *&act); + void parser_for(QList<token> tokenList, int from, int to, QTextStream &out, State &state, const V &data, const T *&act, bool emitProgress); QVariant getValue(QString list, QString property, const State &state); QString translate(QString s, State &state); |