aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/printlayout.cpp
AgeCommit message (Collapse)Author
2014-08-05Print: rename the variable 'isHeading' to 'newHeading'Gravatar Lubomir I. Ivanov
This better describes what the variable (flag) does. It's used to inform the loop that the last row goes our of the page limit and that we need to place a new heading on a new page. In that context 'newHeading' is more meaningful. The name 'isHeading' is confusing for (i == 0), since it remains 'false' yet the 0 index row is actually a heading. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05Print: add a safe guard for row heights in the table printGravatar Lubomir I. Ivanov
If a row height is more than the available height on a page (minus the height of a heading row) we have to skip this row (dive). The current profile print simply does not support that and it does not make much sense. For that to happen either the page will have to be tiny or the user must have entered a very long text for "buddy", "dive master", "location" or there must be some sort of a very-large-font-while-printing type of a problem. Technically, rows spanning on multiple pages is doable, but probably not worth the effort. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05Printing: only give up if no size is availableGravatar Dirk Hohndel
Checking for available printers appears to sometimes fail, even if there is a valid PDF or PS printer. Instead we bail if we can't get a valid size for the printer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-04Print: enable the vector table print only for Qt5.0 and newerGravatar Lubomir I. Ivanov
In #671 a user reported that the table print outputs a blank page if there are dives for one page or less to be printed. This doesn't really makes any sense. A possible bug in Qt4's QPicture is suspected, so we only enable the vector print for Qt 5.0 and newer versions. See #671 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-25PrintLayout: fix a potential bug in the recent table print updateGravatar Lubomir I. Ivanov
There is a weird QPicture dependency; we need to offset a page by headingRowHeightD2, which is half the heading height. The same doesn't make sense if we are rendering the table widget directly to the printer-painter. Moving the offset inside 'pageIndexes' is less desirable. The bug itself manifests when a top margin is set on Win32, while on Linux it's more obvious. On new page start, a fixed height from the last dive on the previous page becomes visible even if the math seems correct. Offsetting both the page index and the vertical position at which the QPicture is placed fixes that. If 'table.render(&painter...)' is used the bug also goes away and our 'pageIndexes' start to make sense again, but we want to use QPicture so that the table is in vector. I don't have a good explanation why this happens! Tested on Ubuntu 12.04 and Win7. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24PrintLayout: vectorize the table printGravatar Lubomir I. Ivanov
Use QPicture to do that. QPainter::drawPicture() requires offsetting the target QPoint's Y value by two times the headingRow height. This can be improved the hardcodding the offset when the 'pageIndexes' are calculated, but is a bit complicated. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24PrintLayout: reduce the scope of 'pic' and 'picPainter'Gravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24PrintLayout: modify the profile font size based on the #dives per pageGravatar Lubomir I. Ivanov
For the profile print, the number of dives per page is: divesPerRow * divesPerColumn If we have more 3, 0.6 seems optimal, while for less we can pretty much use the default scale of 1.0. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24PrintLayout: draw the profile to a QImage only on LinuxGravatar Lubomir I. Ivanov
The QImage fix for the recently reported "huge-vector-lines-in-PDF-printouts" bug is only needed on Linux. For Win32 and OSx we can render to vector. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24PrintLayout: fix the ProfilePrintModel fontGravatar Lubomir I. Ivanov
Fixing the font size is required, because we don't really support a dynamic row height, as the row height is set in the class constructor. 7 seems optimal for all print modes. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24PrintLayout: disable the QPainter scalingGravatar Lubomir I. Ivanov
This is wrong because we don't really need to scale. We already have the estimated page dimentions in pixels, so taking the quotient of the printer DPI and screen DPI and then scaling (probably up) our rendered widgets via the QPainter introduces blur (due to the oversampling), and a performance penalty. By rendering at the exact dimensions we ensure that the widgets are crisp at a 100% printout. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24PrintLayout: a whitespace fixGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24Printing: add 1 dive per page optionGravatar Lubomir I. Ivanov
With this option there is an exception, which makes the notes section of the profile table occupy half the page. This way dive plans can reasonably be printed. Fixes #636 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-23Animation speed is a value, not a booleanGravatar Tomaz Canabrava
This breaks compatibility with old preferences, but it's a single key and not that very important so I don't think it's a bigger issue I've renamed prefs.animation to prefs.animation_speed to denote that it's a value, and not a state. Also, fixed the places that were treating it as a state (on/off) to treat it like a correct value. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18Bypass the PDF bug by painting on a QImage and paint the image to pdfGravatar Tomaz Canabrava
well... we have a good and working printing system now. :) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18Add the HTML Delegate to printing.Gravatar Tomaz Canabrava
This patch just adds the HTML Delegate to print the text. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18Fixed memleakGravatar Tomaz Canabrava
The model was not being deleted when the table was, and thus we recreated it for every print. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18No need to delete a QPointerGravatar Tomaz Canabrava
QPointer is a smart pointer, it will delete itself when the refcount == 0. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Printing: print depth unit in tableGravatar Dirk Hohndel
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-11Printing: make table more usefulGravatar Dirk Hohndel
Tweak font size and column widths. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Printing: change the header to show depth / durationGravatar Dirk Hohndel
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-11Printing: print tags instead of max CNSGravatar Dirk Hohndel
And re-order / re-size the fields so more useful information is actually shown. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Printing: use more appropriate font sizesGravatar Dirk Hohndel
2-up and 6-up need different fonts. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Render the table print in curves.Gravatar Tomaz Canabrava
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-11Correctly disable all animationsGravatar Tomaz Canabrava
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-09Printing: scale fonts when printingGravatar Dirk Hohndel
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-09Printing: force redrawing of the profileGravatar Dirk Hohndel
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-03UI restructure: plotDive: plot current dive by default & use displayed_diveGravatar Dirk Hohndel
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-02UI restructure: plotDive should just take one diveGravatar Dirk Hohndel
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-05-22Gratuitous whitespace changesGravatar Dirk Hohndel
I keep trying to get to consistenct. Completely hopeless. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17Mark a lot of TODO's where I think it should be moved to C code.Gravatar Tomaz Canabrava
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-03-27Print: enable printing with the new profileGravatar Lubomir I. Ivanov
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 ac9a23ef3b69). 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-07Fix compile problemGravatar Dirk Hohndel
QPointer was undefined (oddly I didn't run into this when test building earlier). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07Remove a Lot of Dead Code.Gravatar Tomaz Canabrava
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-07Remove the old profile from the main screen of SubsurfaceGravatar Tomaz Canabrava
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-05Another small tweak to whitespace toolGravatar Dirk Hohndel
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-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
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-12Don't redeclare variables of the same nameGravatar Dirk Hohndel
This isn't broken, but it's confusing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12Replace mainWindow() with MainWindow::instance()Gravatar Boris Barbulovski
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-01-16Fix some memory leaks.Gravatar Boris Barbulovski
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-15Use setSectionResizeMode if we use Qt5Gravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07Get rid of pointers to dive structures in the UIGravatar Dirk Hohndel
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>
2013-12-08Silence signed vs. unsigned compare warningGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06Fix crash in table print crashGravatar Dirk Hohndel
sizeof(array) is the total size in bytes, not the number of elements... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06Print: fix issues when printing a lot of dives in table printGravatar Lubomir I. Ivanov
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-05Print: fix truncated table in "Table print" modeGravatar Lubomir I. Ivanov
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-04Cleanup some uninitialized variablesGravatar Anton Lundin
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-04Print: fix some forward declarationsGravatar Lubomir I. Ivanov
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-04PrintLayout: emit progress from printTable()Gravatar Lubomir I. Ivanov
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-04PrintLayout: emit progress from printProfileDives()Gravatar Lubomir I. Ivanov
printProfileDives() now emits a 'signalProgress' each time a dive is done processing. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>