Commit graph

133 commits

Author SHA1 Message Date
Dirk Hohndel
46b125782e Hook up adding a dive
This gets things mostly right.

It creates a dive and uses the planner widget to create samples which are
copied into the dive. It fills in some reasonable defaults (DC model,
timestamp), but doesn't allow editing the timestamp (or the temperatures
and air pressure).

On accept the planner gets reset and the dive appears correctly in the
dive list.

Cancel still needs to be handled.

And I bet there are many subtle bugs lurking here and there. But it's a
start.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-19 22:54:00 -05:00
Dirk Hohndel
64b014aefb Don't show the planner widget when adding a dive
This looks like it might work, but since we keep recreating the dive, the
info entered in the info pane is actually lost. But it's a step in the
right direction.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-18 23:02:53 -05:00
Dirk Hohndel
882b2c146b Use Planner dialog to add dive
Right now this is just calling the same code and setting a flag whether we
are planning or adding a dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-18 22:18:10 -05:00
Anton Lundin
7d9c1e9ee4 Show sample time in the mouseover.
This is really nice to have when looking at specific coutures of a dive
or events.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-18 11:59:53 -05:00
Linus Torvalds
f8e33e171a Fix SIGSEGV after dive computer download
This fixes a crash in the current Qt subsurface code that can happen
after downloading dives from a dive computer, and the new dives merge
with old dives, causing the old dives to be re-allocated into the
merged one.

In that case, the list widgets don't get fully updated, and contain
stale pointers to old dives that no longer exists. Doing anything that
refreshes the display will hide this problem, and you do need to have
multiple dive computers on the same dive to trigger it in the first
place, so it's reasonably hard to hit, but very annoying when you do.

This patch just makes us reload all the dive UI tables, which may be
overkill. It also doesn't actually fix the fact that we seem to do
"process_dives()" within the context of the downloader thread, which
looks like a possible source of races. The "process_dives()" should
also be moved to the main thread, but needs the preferDownloaded()
information that is part of the download window, so it doesn't fit
here. Somebody else (Tomaz?) will hopefully fix that part.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-17 17:21:41 -04:00
Tomaz Canabrava
bfe1ea0cb2 Plug the Cancel action on the Dive Planner Table and start the 'ok' code.
Plug the cancel action on the dive planner ( before that, only by
hitting the 'ESC' button things worked, so now you can also click
on the Cancel box that's on the right of the planner profile window.

Also, the beginning of the 'ok' code is also at place.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-16 11:38:41 -03:00
Dirk Hohndel
e91ac60f49 Fill ws_info structure and use it when entering weight systems
The code to initialize the weight systems from the last datafile loaded
had not been brought over from the Gtk version.

We now correctly update the data structure when loading file (but not yet
when editing values).

Most likely the same needs to be done for the tanks as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-10 11:42:26 -07:00
Tomaz Canabrava
96d1cc570e Use the same code for command line and gui for file handling.
The Command line execution of Subsurface happened before the
GUI was created, this leaded to various bugs by me(tm) over
time. This patch seems to fix all of those, by reusing the
same code for GUI interaction and CommandLine interaction.

I had to rework how the main.c worked, it used to be C code
calling C++ code, and this is non desirable, since C doesn't
really understand C++.

I Moved all of C-related code to 'subsurfacestartup.c/h' and
created a tiny wrapper to call it, so all of the C code is still
C code, and the new main.cpp calls the mainwindow->loadFiles and
mainWindow->importFiles to get rid of the bugs that happened before.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-09 05:59:03 -03:00
Tomaz Canabrava
5666f6573e Code Cleanup: Merged the three TableViews shared code
Merged the shared code for the three table views into
one code, this way less code is needed if we need to
construct another tableview in the future.
I still need to clean some of the models too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-02 16:21:08 -03:00
Dirk Hohndel
db17edda65 Merge branch 'bugfixes' of github.com:danilocesar/subsurface
Fixed one conflict in qt-ui/diveplanner.cpp - please check I got this
right.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-30 20:17:20 -07:00
Tomaz Canabrava
0a043528f7 Added a new widget to control the Planner
Added a new widget to control the DivePlanner, now we
have two widgets, a graphics one and a qt sidget based one.
the Technical divers will most likely use the QtWidget one
while the hobbists will most likely use the QGraphicsView
one. there's not a option to choose one, they both will
appear at the same time.

Next step: make the screens to work.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 08:43:37 -03:00
Danilo Cesar Lemes de Paula
1e69731804 use QWebView to show the user manual
Looks like the QTextBrowser can't render the manual correctly.
Also, QWebView provides a better way to find contents on a webpage,
which is an important feature for an user manual (to be implemented).

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
2013-08-25 19:03:43 -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
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
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
Lubomir I. Ivanov
880b8394d2 Close child windows and dialogs with main window
Most child windows should be closed with the main application
window otherwise if left open and if making specific
modifictions could potentially cause a SIGSEGV.

To solve that we mark all custom windows/dialogs with
the Qt::WA_QuitOnClose attribute on instance creation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-28 20:23:59 +08:00
Tomaz Canabrava
1244438b01 Moved the DivePlanner to the MainWindow.
Now, activating the dive planner will hide the profile
and show the planner on the same place. we still need
a way to 'cancel' or 'accept' the profile created.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-27 14:48:03 -03:00
Lubomir I. Ivanov
bdd89f0e7a Coordinate some mark_divelist_changed() calls
1) Make a call mark_divelist_changed(TRUE) when the user adds new
cylinder or weight entries.

2) Call mark_divelist_changed(FALSE) in
MainWindow::on_actionClose_triggered() so that each time after
a file is closed or a new one is created it does not ask immediately
the user for a save confirmation for the blank file/divelist.

3) Call mark_divelist_changed(TRUE) once a dive's geo location
has changed in GlobeGPS::changeDiveGeoPosition().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 20:57:11 +08:00
Lubomir I. Ivanov
8678e2d57c Better positioning of the plus sign icons in the Equip. tab
There are a couple of problems with said icons:
- When the Equip. tab is first seen, no relative event is monitored
so that the correct position is updated and the icons are positioned.

To solve that we connect the signal MainTab::currentChanged(int)
and call MainTab::equipmentPlusUpdate().

- When the info-profile QSplitter resizes with a snap towards/from
the edges of the main window, no resize handler is called such as
MainTab::resizeEvent().

A solution is to monitor the resize of the info-profile splitter
with MainWindow::on_infoProfileSplitter_splitterMoved() and again
call MainTab::equipmentPlusUpdate()

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 20:57:10 +08:00
Lubomir I. Ivanov
ab95da8fd2 Update main window title depending of current file state
If a file has been opened from the command line or via the File
menu the main window title becomes "Subsurface: filename.ext".
Title also updates if 'File->Save As' is called. "Subsurface" only
is displayed when no active file is present or post 'File->New'
or 'File->Close'.

To make this work a new public method is added - MainWindow::setTitle()
and also an enum type MainWindowTitleFormat, which should allow
more complicated formatting, such as showing the selected dives
or the total number of dives (e.g. MWTF_FILENAME_N_DIVES).

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 07:23:12 +08:00
Lubomir I. Ivanov
fa96ebeed7 Enable 'View->View Globe'
For viewing the Globe section (pane) we need to collapse
both the 'list' and the 'main' splitters.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 07:22:26 +08:00
Lubomir I. Ivanov
865d4953df Add action to 'File->New'
File->New in the GTK version performed the same as File->Close.
Creating a new file may also ask the user if the current file has
to be saved.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 07:22:18 +08:00
Lubomir I. Ivanov
488ff19fd9 Add the 'Import files' functionality
Similar to File->Open but for multiple files and without
calling on_actionClose_triggered().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 07:22:00 +08:00
Lubomir I. Ivanov
f3b04a88df Add an 'About' dialog for the Qt UI
The dialog is similar to the one in the GTK version

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-24 07:44:28 -07:00
Tomaz Canabrava
062515ba6f Added back the menu entry 'Dive Planner'
Added back the menu entry Dive Planner, and removed the
calee code from the Print action.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 18:48:21 -03:00
Tomaz Canabrava
beadeffaf5 Added the first scope of the visual dive planner.
Added the first files and skeleton code for the visual
dive planner. now I need to fill things. The code is
using the print action borrowed, this will need to move
to a better choice in the future.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 12:33:26 -03:00
Dirk Hohndel
106327af43 Better minimum width for yearly statistics window
The Qt default was way too small.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 10:59:48 -07:00
Dirk Hohndel
0773172f66 Merge branch 'qtHelper'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 00:33:03 -07:00
Dirk Hohndel
29b242c703 Converting the device_info list into a Qt data structure
This data structure was quite fragile and made 'undo' when editing
rather hard to implement. So instead I decided to turn this into a
QMultiMap which seemed like the ideal data structure for it.

This map holds all the dive computer related data indexed by the model. As
QMultiMap it allows multiple entries per key (model string) and
disambiguates between them with the deviceId.

This commit turned out much larger than I wanted. But I didn't manage to
find a clean way to break it up and make the pieces make sense.

So this brings back the Ok / Cancel button for the dive computer edit
dialog. And it makes those two buttons actually do the right thing (which
is what started this whole process). For this to work we simply copy the
map to a working copy and do all edits on that one - and then copy that
over the 'real' map when we accept the changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 00:24:28 -07:00
Tomaz Canabrava
87e380c7a2 Yearly stats are being displayed.
Yearly stats are being displayed. the code is similar to the GTK one,
but I advise the reader that it's a bit risky  ( I got an unreproducible
crash but it seems to be fixed now. ). The selection behavior is *weird*
and I have no idea why, but I'm very sleepy - will try to look at
it again tomorrow.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-17 21:05:17 -03:00
Tomaz Canabrava
a05ea5a6e8 Create a view for the Statistics Model and Fix displaying the header
This simply creates a view to show the model, while doing that
I noticed that the model header wasn't showing, so I fixed it too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-17 20:02:30 -03:00
Tomaz Canabrava
ae68ae38bb Changed a lot of code to reduce boilerplate on models in the future.
So, I changed a lot of code to reduce boilerplate on models in the
future. Currently we do not have a lot of models, but this can increase
quite rapdly. There's a second TreeModel in the works, the Yearly
Statistics, this patch will save around 250 LOC for this new model,
and more and more models will give us a greater saving.

Iwll do that for the table models in the future too - I did the tree
models now because they are the most complex case and I didn't wanted
to create a second tree model without this.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-17 18:59:50 -03:00
Dirk Hohndel
14ccbbf6e8 Merge branch 'renumberDialog' of github.com:tcanabrava/subsurface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-17 12:59:37 -07:00
Dirk Hohndel
f465230263 Merge branch '119_divecomputerManagement' of github.com:tcanabrava/subsurface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-17 11:12:10 -07:00
Tomaz Canabrava
272338875d Addes a simple 'Renumber Dialog', very similar to the GTK one.
This code adds a Renumber Dialog, that's most a copy & paste
of the GTK visual, I didn't tried to do anything fance with it,
but I still dont like how it looks like. a better management
form is needed. :)

( Well, actually my dislike is mostly because it's on a menu
and it's on a popup, I think a 'toolbox' should exist to hold
all of those widgets that don't belong to the menu - will try
that later )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-17 13:41:00 -03:00
Dirk Hohndel
e34da61362 Merge branch 'linusDiveList' of https://github.com/tcanabrava/subsurface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-13 19:56:36 +02:00
Tomaz Canabrava
7e9d6e2829 Fixed the show / hide dialog shortcuts to take the splitter into consideration
Fixed the show / hide dialog shortcuts to take the splitter into consideration,
 So, here's the deal.
 We have a few QSplitters that takes care of helping us with the
 size of a few widgets, they are ok, and we should continue using them
 to manage the visibility of them too. But the way that we did before was to
 widget->hide(); something, and if you hided something using the splitter,
 by holding it's handle and collapsing the widget, then you used the 'ctrl+number'
 shortcut to show it, it whould only show a gray panel.

 This patch makes everything behave using the splitters.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-12 15:54:55 -03:00
Dirk Hohndel
863c485939 Add fifth view mode "Globe" for main window
For consistency I didn't change the meaning of Ctrl-1/2/3/4 and added
this as Ctrl-5 - but one could just as easily make the argument that
"ViewGlobe" should be Ctrl-4 and "ViewAll" should be Ctrl-5.

This ensures that only one of the four widgets is shown in the
individual modes, but it doesn't address the drawing issues with the
profile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-12 14:53:23 -04:00
Tomaz Canabrava
939246acda Added a simple "TextEditor" in the graph, for a plan mode.
Added a simple TextEditor in the graph for the 'Dive Plan' mode,
this text editor is very simple, so the user can double click on
'depth' or 'duration' to set the depth or duration of the dive.
Since this was a test, only 'duration' was done, and I'll add
duration on the next commit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 20:59:58 -07:00
Tomaz Canabrava
1baef83791 Added the option to create a new dive from the menu.
This patch adds a dive from the menu, it's the dive that will
be used to add a new dive plan. so, I also removed the option
'add imput plan' from the menu.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 15:34:57 -03:00
Dirk Hohndel
bd8470ebcf Merge branch 'fileopen' of github.com:heliocastro/subsurface 2013-06-09 21:01:04 -07:00
Helio Chissini de Castro
4b0c053e48 Ticket 127 - Repopulate context menu on preferences change
Ticket 127 mention that context menu is fixed on imperial mode, which is
partial true. Context menu only not have the changes on header model updated
when preferences are chenges during execution. Hard to note because if
program is closed and opened again, the context is initialized properly.
Since actions aren't bound to the header model, we need iteract of current
items and change the title.

Signed-off-by: Helio Chissini de Castro <helio@kde.org>
2013-06-09 20:09:39 -03:00
Helio Chissini de Castro
1262a7c0bc Keep last open dives directory
Last open dives directory is stored in settings, so no need to walk through all
subdirectories all the time.

Signed-off-by: Helio Chissini de Castro <helio@kde.org>
2013-06-08 00:03:58 -03:00
Tomaz Canabrava
ebed836ee5 Created a new dialog - Edit DiveComputer
Created a new dialog, Edit Divecomputer, it will currently only lists
the divecomputers that are used on the xml file. I used the same method
that the gtk version used, but only 2 divecomputers got visualized in the
dirk dive data. I'll assume that it's correct and will fix it in the next
couple of commits.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-07 11:43:45 -03:00
Dirk Hohndel
c774bab6e6 Merge branch '112_webservices' of https://github.com/tcanabrava/subsurface 2013-06-07 13:31:42 +09:00
Tomaz Canabrava
c1cf6c02a8 Added initial support for download dive info from the subsurface web service.
Added initial support for download dive info from subsurface web service,
the current code only downloads and output the xml downloaded in the debug
area. Now I need to parse things up and plug the unplugged stuff.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-06 10:33:15 -03:00
Dirk Hohndel
6f7e13ac70 Try to get rid of unnecessary reloads of the dive list
Don't call refreshDisplay() after preferences change. This strangely
somehow leads to a situation where I need to move the mouse over the dive
list before changes to the units are reflected.

When calling reload() do not force layout change / resort unless that is
the intention.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-06 11:28:20 +09:00
Dirk Hohndel
4d937051ca Fixing some issues with the dive selection after OK on preferences
These changes should be correct - but they still don't fix the problem
that after we click 'OK' on the preferences (regardless of whether any
changes were made), the first dive is set as current dive and shown in the
map window.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-05 17:15:32 +09:00
Dirk Hohndel
ca1c112424 Update the current dive when no dive was selected
The check to only update the dive if there were already dives selected
before seems bogus. I'm sure I put it there for a reason but it seems
flat out wrong.

This gets triggered when you select a trip by clicking on the trip
header. In that case all dives get unselected (amount_selected = 0) and
then we try to select the first dive in the trip - which fails because
of this check.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-05 09:51:40 +09:00
Dirk Hohndel
ed0f558efb Rewrite readSettings to do what it should have done from the start
This function was supposed to take the default_prefs into account but
clearly wasn't.

Now it should be much more readable and maintainable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-04 21:40:28 +09:00