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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>