Commit graph

63 commits

Author SHA1 Message Date
Dirk Hohndel
e1ae7ebab2 Printing: print depth unit in table
When adding the method that includes the depth unit to the DiveItem class
I realized that this was yet another implementation of our depth unit
conversion. We should just call the existing helper instead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 21:59:21 -07:00
Dirk Hohndel
236ff5c89d Printing: make table more useful
Tweak font size and column widths.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 21:51:44 -07:00
Dirk Hohndel
0d9a1946fa Printing: change the header to show depth / duration
At least for my dives there wasn't enough space for depth and duration in
the header, most likely because I made the last two columns smaller to
create more space for tags and suit.

With this commit the depth and doration in the header now spans two
columns and easily fits.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 21:40:22 -07:00
Dirk Hohndel
6699dab952 Printing: print tags instead of max CNS
And re-order / re-size the fields so more useful information is actually
shown.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 21:39:44 -07:00
Dirk Hohndel
2552b027ae Printing: use more appropriate font sizes
2-up and 6-up need different fonts.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 21:30:40 -07:00
Tomaz Canabrava
8cd4a5f3d1 Render the table print in curves.
We can use QPicture to record the painting done by a QPainter and it will
be saved in vector format, then we can simply paint that.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 17:01:59 -07:00
Tomaz Canabrava
2171b981ac Correctly disable all animations
This seems to be needed for the correct print of the profile,
What was happening on the print code was that the profile even in print
mode was doing animations, and we were getting a frame of it and trying to
print it.

Also, a bit of code cleanup.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 17:00:40 -07:00
Dirk Hohndel
76a8e83a54 Printing: scale fonts when printing
This seem to work better, but it misses a couple of items at times (for
example the highest label on some of the axis).

Needs lots more testing.

See #590

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09 13:12:29 -07:00
Dirk Hohndel
2d77788cb2 Printing: force redrawing of the profile
If the first dive we end up rendering is the dive currently shown, the
info overlay would end up being printed which looks really silly.

See #590

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09 11:19:08 -07:00
Dirk Hohndel
2a55e55868 UI restructure: plotDive: plot current dive by default & use displayed_dive
No longer use the dive structure that is passed in but instead always use
the displayed_dive to display things.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 09:37:54 -07:00
Dirk Hohndel
91086d08ad UI restructure: plotDive should just take one dive
We don't have a concept of what to do when plotting multiple dives, so
let's not pretend and remove all the messing around with lists.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-02 12:03:40 -07:00
Dirk Hohndel
5ba573240f Gratuitous whitespace changes
I keep trying to get to consistenct.
Completely hopeless.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 11:40:22 -07:00
Tomaz Canabrava
f14c14c383 Mark a lot of TODO's where I think it should be moved to C code.
This marks a lot of todo's where I think there's core stuff being mangled
on the interface - we should remove this from the interface to make
testing and maintenability easier.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17 08:33:51 -07:00
Lubomir I. Ivanov
47c0ddbf30 Print: enable printing with the new profile
Some weird things happen if we use a local instance of the
ProfileWidget2 class in printProfileDives(). Once we
exit the printing dialog the profile crashes, which could
hint of singleton issues.

Instead we are going to use the already active instance of
the class which we can retrieve from MainWindow. This should
also be faster because the class is pretty heavy.

In such a case the cleanup at the end of printProfileDives()
is still relevant (removed in ac9a23ef3b). First we
resize the widget for printing purposes and then resize it
back to the original values and re-plot the current selected
dive in the dive list.

Fixes #477, #478

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-27 10:58:22 -07:00
Dirk Hohndel
18303b6f43 Fix compile problem
QPointer was undefined (oddly I didn't run into this when test building
earlier).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07 10:03:03 -08:00
Tomaz Canabrava
00c97e710f Remove a Lot of Dead Code.
This is just removal of dead code from the old profile, probably there's
still a bit more to remove, but this is a very good cleanup already.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07 08:56:06 -08:00
Tomaz Canabrava
ac9a23ef3b Remove the old profile from the main screen of Subsurface
This patch partially removes the code for the old profile from
Subsurface. It removes the use of the old profile on the mainwindow,
but keeping the code in the tree for now.

A bit of code-cleanup also entered this commit because I had to change
every instance of the code that used the old profile.

Now to the real code-cleanup

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07 08:54:20 -08:00
Dirk Hohndel
1b103c5c69 Another small tweak to whitespace tool
clang-format doesn't appear to reindent multi line #define statements
correctly - so this hopefully will clean those up.

The included whitespace corrections to the code should stay in place when
using the updated tool.

This includes cleaning up some multi-line comments that were messed up the
last time around as well as a few other minor changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-05 13:02:23 -08:00
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
Dirk Hohndel
af5ad2033d Don't redeclare variables of the same name
This isn't broken, but it's confusing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 13:24:40 -08:00
Boris Barbulovski
c86822c2f4 Replace mainWindow() with MainWindow::instance()
C++ style of accessing single instance class object.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 11:42:59 -08:00
Boris Barbulovski
6cc65f5e1c Fix some memory leaks.
Memory leaks were caused by broken parent/child relations.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 12:15:47 +07:00
Anton Lundin
5ff961b033 Use setSectionResizeMode if we use Qt5
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15 15:49:47 +07:00
Dirk Hohndel
c3fe1a9e9f Get rid of pointers to dive structures in the UI
The assumption that the pointer will keep pointing to a valid structure is
fundamentally flawed. And even if that is true today, it might change in
the future - just don't do it. Use the diveId instead.

The exception is when you own the structure and use it within one UI
interaction during which any way to change the dive_table is disabled
(e.g., while adding / editing a dive).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07 12:10:19 +08:00
Anton Lundin
caf4d85d0a Silence signed vs. unsigned compare warning
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-08 09:41:42 +01:00
Dirk Hohndel
8f58faf431 Fix crash in table print crash
sizeof(array) is the total size in bytes, not the number of elements...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06 09:30:39 -08:00
Lubomir I. Ivanov
5506fa4b38 Print: fix issues when printing a lot of dives in table print
This patch improves the algorithm when estimating where
to put the new page header in the table and how we move
larger dive rows on a new page. It now performs a couple of
'passes', where the first one processes the table and the
second one is used to compensate for the lost space.

Fixes #326

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06 09:23:02 -08:00
Lubomir I. Ivanov
94f85bbef9 Print: fix truncated table in "Table print" mode
The whole procedure here is quite confusing.
Once we have our model populated, we need to estimate where
to put page headers (each page has one) and to do that we
store a list of indexes, where a page would begin (pageIndexes).

But since a row can end up being chopped at the end of a page
we move it to a new page and this particular part was lacking
compensation for the moved row's height, when storing the *last*
pageIndex.

For N number of pages we are losing N - 1 dives, or such that
were previously transferred on a new page.

See #326

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-05 08:04:48 -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
e4f35fb51a Print: fix some forward declarations
In the PrintLayout constructor we receive a pointer
of PrintDialog, but the type is incomplete, as we only
forward declare it in the class header. If we decide
to eventually call a method from PrintDialog we also
need to include printdialog.h in printlayout.cpp.

The patch also fixes a similar issue in printdialog.h.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-12-04 15:47:33 +02:00
Lubomir I. Ivanov
95e00b0acd PrintLayout: emit progress from printTable()
printTable() now emits a 'signalProgress'
to the PrintDialog's progress bar, but it has 3 stages (loops):
- pupulate a model
- process all rows
- render the table in pages

This requires that we also separate the progress in 3 stages
of 33%.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-12-04 15:35:07 +02:00
Lubomir I. Ivanov
ac7126b84a PrintLayout: emit progress from printProfileDives()
printProfileDives() now emits a 'signalProgress' each
time a dive is done processing.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-12-04 15:16:20 +02: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
d4766a8cce Print: yet another font adjustment for the profile table
We now only use a slightly large font for the "Dive #" entry.
All other font sizes remain at 9px.

Another change is that we now attempt to use 11px for
individual row height. This makes the table at least 12px bigger
(n_rows * increment), but does not cut letters like 'g',
which go slightly bellow the font baseline.

Perhaps this can be improved later by adjusting the font
and row sizes again.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30 17:37:27 +02:00
Lubomir I. Ivanov
d0dfec929f Print: give more space for the depth and duration column
There is not enough space for the last column in "6 print"
even for the english text. This gives more space extending
the row, but for some languages it will be an issue, thus
strings have to be eventually shortened by the translators.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30 15:50:47 +02:00
Lubomir I. Ivanov
a60475d336 Print: adjustments to font sizes and alignment
The new profile table requires different alignment and
different font sizes for specific cells.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30 15:41:18 +02:00
Lubomir I. Ivanov
3b7500fd33 Print: setup for a new profile table layout
- Adjust the new rows and column count
- Set new row and column spans

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30 15:32:14 +02:00
Patrick Valsecchi
4f23ff144f Prettier printing
Going through pixmaps for the profile was not needed and was making our prints
look very pixelated.

In Qt4, QWidget child classes are printed as bitmaps. So appart from
changing the code to print the tables to use a QGraphicsView instead,
there is nothing we can do, so the rest of the printing is still done as bitmaps.

Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-16 07:02:06 -07:00
Dirk Hohndel
6ccb541f1d Random white space cleanup
Because I can.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15 04:37:31 -07: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
88b1e09dee printlayout.cpp: Increase the font size in tables bellow profile
Because of varying font (screen) DPI we use pixel sized fonts
when printing. Apparently 8px does not look that good on Windows
default fonts, but kinda OK on Linux. We compensate by
increasing the font size and table rows to 9px.

Also decrease the padding between the table and profile to 5px.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15 04:23:56 -07:00
Lubomir I. Ivanov
7861103139 Print: remove profile border when printing
Custom widget frame styles such as 'Sunken' and 'Raised' which seem to
varry between OS will be captured as well:
http://harmattan-dev.nokia.com/docs/library/html/qt4/qframe.html#Shape-enum

So instead we temporarily set the profile frame to QFrame::NoFrame and
then restore it to the previous value.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-14 13:15:58 -07:00
Lubomir I. Ivanov
edd2db6886 Print: allow optional table on top of profile
Patch enables the 'Profile on top' / 'Notes on top'
functionality in the print options dialog.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-07 09:29:40 -07:00
Lubomir I. Ivanov
c79def40b1 Print: small adjustments to table printing
PrintLayout::printTable():
- hide the QTableView widget border using a stylesheet
- add a guard to fix the last column extending post the page width
due to rounding
- use 1 extra pixel instead of 2 when grabbing the page region

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 09:39:16 -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
17c97b921f Print: pass grayscale flag to setPrintMode()
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>
2013-07-18 12:00:12 -07: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
b241b7c06a Print: add experimental code for printing profiles
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>
2013-07-18 12:00:12 -07:00