The current QTextDocument implementation is slow due to
HTML parsing. By using QTableView with QAbstractTableModel
we boost the performance of the table print drastically.
This patch completely replaces the old solution.
There is a hidden QTableView widget which is populated
with all data and rendered using a QPainter attached to
the printer device.
A couple of new classes are added in models.h/cpp
that handle the table print model and these are then used
in printlayout.h/cpp.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We pass the value of 'color_selected' stored in the
print options to ProfileGraphicsView::setPrintMode().
This way the profile can be printed in grayscale
internally instead of converting a QPixmap to
grayscale.
There are a couple of questions here:
1) Are all the 'if/then' checks for all individual
colors faster than the direct QPixmap/QImage grayscale
coversation.
2) The direct grayscale conversation does not give
control of individual colors, but can it look actually
better?
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
(experimental)
Add the method PrintLayout::convertPixmapToGrayscale()
to convert a rendered profile pixmap to grayscale.
It will probably be faster to have
ProfileGraphicsView render in grayscale under certain
conditions (and use a specific color table) instead -
e.g.:
ProfileGraphicsView::setPrintMode(bool printMode,
bool useGrayScale);
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
PrintLayout::printSixDives() goes trough all dives
and prints their profiles on full portrait pages.
This method is based on resizing the ProfileGraphicsView
widget, plotting each dive and then 'grabbing' it using
QPixmap::grabWidget().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
There is a potential issue when placing a heading on a new
page. If the height of a data row is larger of that of
a heading, a new heading can end up at the bottom of a page
leaving that page with two headings.
To solve that we add line breaks (<br>) until the new
page is reached and add the heading there. Algorithm
assumes that the height of a heading is larger than
a line break. Also it is now obviously even slower.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
QTextDocument uses a separate painting device,
thus we need to pass our QPrinter instance which may
have a resolution different from the screen resolution.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
It might be a good practice to declare certain class
'helper' functions as constant members. But I don't
think there are performance benefits to that other
than the readability ones.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
We use the DiveItem struct from models.h so to ease the
display of date, depth and duration. All columns present
in the GTK build are now displayed.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Patch does:
- set individual column width and name
(held in tableColumnNames, tableColumnWidths)
- reduce font size in the table
- more small tweaks in the style sheet
TODO: finish printing all dive data
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
We don't really need includes of display.h and dive.h in
printoptions.h and printlayout.h or forward declartions
of 'struct dive' and 'struct options' in there.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
also includes:
- experiment with colored background for headings
- experiment with 'left' alignment for headings
('th' tag CSS does not support 'text-align')
- whitespace fixes
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Currently only for the table print, but now we use the
actual dive table to iterate trough all dives (find only
selected if needed) and print their 'number' element
in table rows.
Also improves the new-page detection algorithm slightly.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
PrintLayout for now only handles the table print,
while the data output itself is work in progress.
For now there is a simple HTML/CSS table logic based
on QTextDocument. There is an iterative algorithm
which listens for a page increase and adds a heading
on top of the new page.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
The setup() method will be called each time to obtain the
current printer settings. Also it calculates required scalling
based on screen agains printer DPI.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
PrintLayout is a class that will handle the layouting part
of dive profiles, text, tables depending on the settings
of a QPrinter and the PrinterDialog and PrintOptions
instances.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>