aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/printlayout.cpp
AgeCommit message (Collapse)Author
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>
2013-12-04PrintLayout: add estimateTotalDives()Gravatar Lubomir I. Ivanov
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-11-30Print: yet another font adjustment for the profile tableGravatar Lubomir I. Ivanov
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-30Print: give more space for the depth and duration columnGravatar Lubomir I. Ivanov
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-30Print: adjustments to font sizes and alignmentGravatar Lubomir I. Ivanov
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-30Print: setup for a new profile table layoutGravatar Lubomir I. Ivanov
- Adjust the new rows and column count - Set new row and column spans Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-10-16Prettier printingGravatar Patrick Valsecchi
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-15Random white space cleanupGravatar Dirk Hohndel
Because I can. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15printlayout.cpp: Remove convertPixmapToGrayscale()Gravatar Lubomir I. Ivanov
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-15printlayout.cpp: Increase the font size in tables bellow profileGravatar Lubomir I. Ivanov
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-14Print: remove profile border when printingGravatar Lubomir I. Ivanov
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-07Print: allow optional table on top of profileGravatar Lubomir I. Ivanov
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-03Print: small adjustments to table printingGravatar Lubomir I. Ivanov
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-03Print: provide means to print profile tablesGravatar Lubomir I. Ivanov
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-09-27Print: provide means for profile layoutingGravatar Lubomir I. Ivanov
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-08-05Print: improve table printing by using QTableViewGravatar Lubomir I. Ivanov
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-07-18Print: pass grayscale flag to setPrintMode()Gravatar Lubomir I. Ivanov
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-18Print: add method to convert profile to grayscaleGravatar Lubomir I. Ivanov
(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-18Print: add experimental code for printing profilesGravatar Lubomir I. Ivanov
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-18Print: improve new page detection in table printGravatar Lubomir I. Ivanov
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>
2013-07-18Print: support any resolution for the table printGravatar Lubomir I. Ivanov
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>
2013-07-16Clear multi-line string separator on the c++ code.Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-16Fixeda a typo that got the 'x' value where the requested one was actually y.Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-11Print: mark some functions in PrintLayout as 'const'Gravatar Lubomir I. Ivanov
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-11Print: complete columns for the table printGravatar Lubomir I. Ivanov
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>
2013-07-11Print: show column titles for table printGravatar Lubomir I. Ivanov
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-11Print: move some header includes to cpp filesGravatar Lubomir I. Ivanov
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-10Print: cleanup for PrintLayout::printTable()Gravatar Lubomir I. Ivanov
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>
2013-07-10Print: use the actual dive tableGravatar Lubomir I. Ivanov
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-10Print: initial implementation of the table printGravatar Lubomir I. Ivanov
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>