Commit graph

2811 commits

Author SHA1 Message Date
Lubomir I. Ivanov
adb7dc6fac Models: move the declaration of DiveItem to the header
This should allow external use of the type by
including models.h.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-11 12:40:08 +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
8fcba14753 Print: cleanup for PrintLayout::printTable()
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-10 23:03:01 +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
9dc45af915 Print: add a print preview for testing purposes
Use a QPrintPreviewDialog, while the print logic is WIP.
This way Qt will show the print output in a window instead
of exporting to a file and opending it manualy.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-10 19:27:10 +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
Lubomir I. Ivanov
74f989bc46 Print: connect all the options widgets to slots
By connecting to slots we always modify values at a previously
set 'struct options' pointer.

Also have the setup of slots and pre-set values in a
separate setup(struct options *) function.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-10 11:06:01 +03:00
Lubomir I. Ivanov
01ef9f2175 Print: correct tab order in the options widget
Tab order should begin from the topmost widget and then
descend towards the bottom end of the dialog.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-10 10:50:33 +03:00
Lubomir I. Ivanov
2c7a208bc1 Print: label update on height slider move
The PrintOptions widget has value labels next to the
horizontal sliders. Add slots to update these labels
when a slider moves.

Patch also makes a modification so that the PrintOptions
constructor requires a 'struct options' pointer. If
an options struct is not received we do not set predefined
values and do not connect signals to slots, where
options will be updated immediately.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-10 09:57:24 +03:00
Lubomir I. Ivanov
5d81eee0da Print: further adjust the print options widget UI
Makes the controls less cluterred on Ubuntu.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-09 23:13:52 +03:00
Lubomir I. Ivanov
355d8ae3d6 Print: add all controls to the print options widget
- adds missing file printoptions.ui
- adds all controls present in the GTK version of the
print dialog custom tab

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-09 22:26:30 +03:00
Lubomir I. Ivanov
52534bfb68 Print: add UI for a print dialog
PrintOptions is a QWidget class to be used as an
addition to a future print dialog (possibly based on
QPrintDialog). Currently only contains a couple of
radio buttons.

PrintDialog (printdialog.cpp/h) which is a basic QDialog
is currently added for testing only and it holds
an instance of PrintOptions.

Calling File->Print opens this test dialog for now.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-09 21:01:42 +03:00
Anton Lundin
35356e364d Calculate deco stops, TTS and NDL
Calculate TTS and NDL, and Deco stops when they don't already exist in
the samle and show them in the mouse-over.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05 22:29:36 -07:00
Lubomir I. Ivanov
f3b81ab54d Profile: prevent a bug when switching views
While in zoomed mode and when resizing the splitters or
switching views the profile tooltip can end up being at the
wrong location and also the zoom state becomes corrupt,
so perhaps the entire transformation needs to be reset.
To prevent the bug we listen for relevent to the profile
splitter resize event, view changes and clear()/plot() the
entire profile graphics.

This is an slow/expensive solution and perhaps there are
cheaper alternatives e.g. updating only the scene rectangle
and tooltip, somehow.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05 07:38:29 -07:00
Lubomir I. Ivanov
2e26de5ae6 Profile: improve tooltip animation
Remove a couple of expand() calls(?). Also store the last
expanded rectangle size in the private variable nextRectangle
and use that in collapse() animation. Patch prevents a small
jump/resize glitch if the user quickly hovers over and out
of the profile while the tooltip is still resizing.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05 07:38:27 -07:00
Lubomir I. Ivanov
3b07cd204b Profile: small tweak for tooltip separator line
Add 3px of a initial horizontal offset.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05 07:38:23 -07:00
Lubomir I. Ivanov
dfb3e2cbea Profile: collapse tooltip back to original height
When collapsing the tooltip we want it's border to become
the same height as when no tooltip info was visible - i.e. post
creation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05 07:38:19 -07:00
Linus Torvalds
98953831cd Fix Uemis Zurich downloads
Commit 48ba01b807 ("Enable downloads from the UEMIS Zurich")
mistakenly switched the meaning of the "force_download" argument when it
moved from "struct argument_block" to being a direct argument.

This fixes it right back.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 23:00:22 -07:00
Linus Torvalds
5ce5b05521 Qt: Implement trip merging logic
So during my Maui trip, I had a short hiatus in diving, causing
subsurface to start a new trip for the last day of diving.  I could have
just started the old gtk branch to fix it up, but decided that I might
as well try to implement the "merge trip" logic in the Qt branch instead.

This is the end result of that.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 23:00:12 -07:00
Lubomir I. Ivanov
c7f8ada4ff Profile: attempt on better zoom and pan logic
QGraphicsView::AnchorUnderMouse does not work for
Qt 4.8.1 on Ubuntu 12.04 and if the mouseMoveEvent
overload is disabled it practically can be seen that
the anchor point is [0, 0] instead of the mouse location.

After a suggestion found on the web this patch attempts
to use the hidden scroll bars to calculate reposition
on pan and zoom *near the mouse cursor.

On the other hand QAbstactSlider (QScrollBar) class
strangly uses negative offsets for minimum scroll
position, which makes the implementation even more
ugly.

[*near] because it's not that accurate!

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 22:59:46 -07:00
Lubomir I. Ivanov
1257adfd26 Profile: use more levels of zoom
Makes it easier to see colored lines - e.g. velocity
with 20 levels of zoom.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 22:59:14 -07:00
Lubomir I. Ivanov
87dda6661c Profile: prevent a zoom glitch at maximum zoom level
The 'else if' condition in ProfileGraphicsView::wheelEvent()
is causing a zoom-in / zoom-out loop at zoomLevel = 10.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 22:58:56 -07:00
Tomaz Canabrava
249a1ac170 Added a messageBox when the planner quits with a working plan.
Added a messageBox to warn the user that he quit with a working
plan, to reduce the risk of unwanted loss of work.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 12:58:11 -03:00
Tomaz Canabrava
bb33be4117 Added the left / right shortcuts for moving the handlers around in time.
Added the left / right shortcuts for moving the handlers around in time,
this also made me wonder why we have the 'previous dc' on the menu, it
got actually to broke my code on the shortcuts for the planner because
they are active everytime - should they be active only when the profile's
visible or they serve any other purpose?

If they serve only for the profile, I'll get them out of the  menu and
put them in their proper place - the profile view.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 12:30:05 -03:00
Tomaz Canabrava
52fd769efb Added 'up' and 'down' actions on the dive planner.
Added 'up' and 'down' keyboard actions on the dive planner,
you need to select the handlers with ctrl + click, then
press up to make the handler go 1m up, or down, to make the
handler go 1m down.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 11:28:39 -03:00
Tomaz Canabrava
932ee3da94 Added a 'delete' action, with the keyboard.
Added a delete action from the keyboard, there's also
a possibility to add the same action from the menu, but
I frankly don't like much the idea. so, to delete a handler
now, you need to select it ( ctrl + click ) then press
the delete button. Multiple delection is also possible.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 11:16:42 -03:00
Tomaz Canabrava
c23dd354b9 Added a shortcut to 'esc', so it clears the selection or cancels the plan.
Added a shortcut to the esc key, so it clears the selection,
if there's no selection, it acts just like clicking on the 'cancel'
button. Next: delete selected handlers.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 11:06:28 -03:00
Tomaz Canabrava
f457415f7a Make possible to 'select' an handler by ctrl+click
Make possible to select an handler by ctrl+click on it,
this will be used in the future for the shortcut actions,
like delete, arrow keys, and such.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 11:01:59 -03:00
Tomaz Canabrava
ae08a81739 Fixed the 'hard to grab' Handler, Dive Planner now is very smooth.
So, it was on the docs, but I didn't read it before, if the
scene has items that ignores transformations, we need to
pass the view transform to the method that gets the items
in the scene. I also used IntersectsItemBoundingRect instead
of IntersectsItemsShape because it's faster, and our items
are small, so we don't need an very accurate but slower method.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 10:34:30 -03:00
Tomaz Canabrava
20ec98f2a5 Make it possible to drag a handle between handlers
Make it possible to drag a handle between handlers,
this way the configuration of the dive is more acurate
and easyer to make. I'v discovered a problem where it's
a bit hard to 'grab' the handler, investigating it now.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 10:29:28 -03:00
Tomaz Canabrava
603d2f5cb3 Make it possible to add a handler between others
Make it possible to add a handler between others,
someone asked why I didn't make like this from the
beginning, the answer is that I wanted to have something
stable before messing a bit more with the planner, but
since the planer is almost-stable, I added. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 10:06:52 -03:00
Tomaz Canabrava
55f8979160 Better positioning of buttons on dive planner
Better positioning of buttons on the dive planner. The ok / cancel
buttons are in the correct place, and the '+' sign for time will not
overlap the time string anymore.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 09:45:25 -03:00
Lubomir I. Ivanov
b68e86a141 Profile: add white outline to all text
To draw the white outline around profile text we trace a text path
using QPainterPath::addText() and then create a couple of
QGraphicsPathItem objects. One of the objects is outlined using
QPainterPathStroker and is placed at the bottom of a QGraphicsItemGroup
with a white brush. The other object holds the standard colored text
and is placed on top.

Notes:
- possibly quite expensive on older machines
- ProfileGraphicsView::plot_text() now returns a QGraphicsItemGroup
- QGraphicsSimpleTextItem uses a top-left baseline anchor
while QPainterPath::addText() uses a bottom-left baseline
which is a bit mysterious, requires the -3 offset for a match
and is possibly non-portable across fonts and sizes.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02 15:51:10 -07:00
Dirk Hohndel
9d9d516c26 Revert "Profile: add white outline to all text"
This reverts commit 44c33742c2.

I mistakenly applied the wrong version of the patch.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02 15:50:40 -07:00
Dirk Hohndel
6b08a6d428 Silence some warnings
One of them actually looks like it was a bug...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02 13:58:03 -07:00
Dirk Hohndel
be6e6638de Merge branch 'nitpicks' of github.com:tcanabrava/subsurface 2013-07-02 13:43:48 -07:00
Tomaz Canabrava
7c8bdf70d5 Make the increase time button to work.
Makes the increase time button to work, it will
increase the minimum time, not the correct time of the
dive. the total time is calculated by the deco, and
does not come from this, unless the deco is smaller
than the minimum time.

This patch also fixes the problem where a button
would only click once - I was holding the first
clicked button as the 'mouse grabber', bad tomaz.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 14:36:52 -03:00
Tomaz Canabrava
6e6a1c08c3 Make the 'increase depth' button to work.
Make the increase depth button to work, it also adds
a 'safety' stop at 150m, I know that this is deep, and
maybe we need to adjust this to a better safety stop.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 14:14:09 -03:00
Tomaz Canabrava
a7506848b3 Removed user-entered lines on the plan, keeping only deco.
Removed the user-entered lines on the plan, keeping only deco,
This way the graph looks way prettier and we don't loose any
functionality.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 13:39:54 -03:00
Tomaz Canabrava
effb7e2fac Change the color of the DepthString based on it's deepness
Change the color of the DepthString based on it's deepness
on the profile planner. The new color of the profileString
( the string that follows the mouse stating how deep you are)
is now interpolated from SAMPLE_SHALLOW and SAMPLE_DEEP -
but since those two colors were the same and I had to change
it so that could work, I want somebody to check if my choose
of colors were ok.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 13:31:25 -03:00
Tomaz Canabrava
23b29bd3cd Use the same profile colors on the planer for the Time and Depth
Use the same profile colors on the planner for the Time and Depth
rulers. this needed a new method on the rulers - setColor, that
will call the setPen method and make everything behave properly.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 12:01:47 -03:00
Tomaz Canabrava
43664d7cd5 Fixed positioning of the dive Handlers.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 11:47:26 -03:00
Tomaz Canabrava
94c2e5dc18 Correct collors for the DivePlanner background.
Use the correct colors for the Background on the Dive Plan,
same as on the Profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 11:21:28 -03:00
Tomaz Canabrava
b07429ff8b Added the last 'tick' to the rulers
The last tick to the rulers were missing, this was making
them to look odd, this make the rulers better looking,
but it caused the other-non-ported-yet-to-percent stuff
to behave in a not so good way, most visible one is the
handlers, gonna update them next.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 11:18:31 -03:00
Tomaz Canabrava
6115dc1f12 Change the rules so they work with percentages.
Changed the ruler so that they work with percentages,
also added a new method to the rules to set the size of the
ticks.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 11:12:15 -03:00
Tomaz Canabrava
c98894fd52 Added a method and a simple stub to position things using percentage.
Added a method and a simple stub to position things on the canvas
using percentage - this way I have a proper control on where I want
to put things on screen and it will make simpler for future changes,
even if the amount of code written is a bit bigger.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 10:53:08 -03:00
Tomaz Canabrava
ca517f1bf8 Shared background for profile and planner.
Share the background for profile and planner. Those are not the same
class, but they should behave somwheat the same.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 10:13:06 -03:00