Commit graph

17 commits

Author SHA1 Message Date
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 20:09:57 -08:00
Boris Barbulovski
ccb1c33d02 Put include guard to every header
* ensure include guard to every header
* comment endif guard block

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:37:01 -08:00
Tomaz Canabrava
1a933e7e19 Don't use QList if sizeof(item) > void*.
QList is optimized for storing pointer-sized items, thus
a QVector is the better choice for everything else.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:24:11 -08:00
Anton Lundin
28b8d177c3 Cleanup some uninitialized variables
I can't really see any point in passing a local loop variable around,
and copying a uninitialized pointer. Better use local variables there
and let the compiler optimize them away if it feels for doing that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-04 15:57:53 -08:00
Lubomir I. Ivanov
08cf1be212 PrintLayout: add estimateTotalDives()
estimateTotalDives() is used to calculate the total dives
to be printed, it requires a 'struct dive' pointer
and a couple of 'int' pointers for the iterator 'i' and
'total' return.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-12-04 15:13:40 +02:00
Lubomir I. Ivanov
2ec6303f50 printlayout.cpp: Remove convertPixmapToGrayscale()
Function is redundant as we should only render the profile
with a custom color table.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15 04:24:27 -07:00
Lubomir I. Ivanov
e727b899a6 Print: provide means to print profile tables
This patch adds a couple of classes and some other modifications
in PrintLayout that handle the printing of tables under a profile.

models.h : ProfilePrintModel
The class uses a 'struct *dive' to output all required data
for a certain dive at specific rows and columns. It also handles
font formatting and text alignment.

modeldelagatates.h : ProfilePrintDelegate
The class is used only for drawing a custom grid for profile tables.

PrintLayout::createProfileTable()
The function is used to create and setup the profile table object

PrintLayout::printProfileDives()
The function now has correct padding of dive profiles on a page
and also the printing of actual tables below them.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 09:38:37 -07:00
Lubomir I. Ivanov
df8107830e Print: provide means for profile layouting
printlayout.cpp(h):

This patch cleans some test code and adds the function
printProfileDives() that accepts a number of dives
per rows and columns. It can technically fit any number
of dives on a page given the page size allows it. Both
landscape and portrait layouts are supported.

It now replaces the old methods:
printTwoDives()
printSixDives()

Space is reserved for data tables that will be placed
bellow profiles on a later stage.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-27 09:29:30 -07:00
Lubomir I. Ivanov
e5b18db802 Print: improve table printing by using QTableView
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>
2013-08-05 06:59:19 +02:00
Lubomir I. Ivanov
fc84f8868d Print: add method to convert profile to grayscale
(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>
2013-07-18 12:00:12 -07:00
Lubomir I. Ivanov
3aae3ff547 Print: mark some functions in PrintLayout as 'const'
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>
2013-07-11 12:55:48 +03:00
Lubomir I. Ivanov
eab31855f5 Print: show column titles for table print
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>
2013-07-11 00:52:39 +03:00
Lubomir I. Ivanov
af1c55c29d Print: move some header includes to cpp files
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>
2013-07-11 00:45:29 +03:00
Lubomir I. Ivanov
9a99aa4c58 Print: use the actual dive table
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>
2013-07-10 22:55:40 +03:00
Lubomir I. Ivanov
eb4312c9ba Print: initial implementation of the table print
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>
2013-07-10 19:32:15 +03:00
Lubomir I. Ivanov
20804b16d3 Print: add a setup() method to PrintLayout
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>
2013-07-10 16:18:16 +03:00
Lubomir I. Ivanov
41bad7695e Print: add a class for print layouting
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>
2013-07-10 15:34:57 +03:00