Add ability to undo deleted dives by storing a list of the
deleted dives in a QUndoCommand.
Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Reverse all the code using the UndoBuffer class so that we can
use the QUndoStack and QUndoCommand classes. These are Qt's own
inbuild undo framework classes, offering a better undo/redo
process.
Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In the designer we set the selection type to extendedSelection
but since I removed the widget from the designer, I also had
to set it in the code.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now it's created in the mainwindow.cpp as part of the new
way to configure the interface.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Before the dive is deleted, a copy is made and passed to the
undo buffer. When edit->undo is clicked, this dive is restored
to the dive list.
Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Allow users to delete dives using the delete key.
[Dirk Hohndel: small whitespace fix; removed an unnecessary
include file]
Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Lots and lots and lots of header files were being included without being
needed. This attempts to clean some of that crud up.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Move from the Dive List context menu to the Dive Info tab, it will only
appear when connected to Facebook.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
And I had to create the Http header by hand because I couldn't
figure out how to do using HttpMultiPart from Qt.
not fun.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
All Facebook related stuff now is on SocialNetworks.h/cpp
this makes it much easier to implement things and looking
for bugs.
working:
- logging in
- getting user id
- getting album id ( or creating it )
*much* more testing is needed, of course.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We still need to do a lot of stuff on that part.
Currently when asking for sending a profile, it will just
create a private album.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We already have a bunch of filters, let's pack them together
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Try really hard to ensure there remains a valid selection. Only if none of
the dives are selectable should we give up.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we end up trying to restore the selection where the selected dive is no
longer visible (i.e., it's now filtered away), this code caused a crash by
falling first() on an empty list. Let's not do that.
Fixes#758
Oddly Qt left the trips selected (but all dives where unselected in the
UI). This got our internal state rather confused. With this change we
clean up that mess and go back to just having those dives that were
originally selected and are still visible show up as selected.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Compute the default widths for the columns in the dive trip list from
their header and (expected) content length rather than some fixed pixel
sizes.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This new version of the TagFilterSortModel actually accepts
*any* new MultiFilterInterface.
So, how to use it to create a new filter:
Implement a class that inherits from MultiFilterInterface
Implement the filterRow method
TagFilterSortModel::instance->add( myClass );
and you are done.
[Dirk Hohndel: removed some debug code and did whitespace cleanup]
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch correctly filter dives based on tags, but it will
also keep showing all the empty trips.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is an elegant way around our problem with people who have the
horrible old "100px" column width in their settings. The first time they
run Subsurface after this fix things won't get better, but the offending
keys will be deleted at exit. And the second time they run, they'll get
the much more sensible new default widths.
Thanks to Thiago for this idea.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was an interesting bug. When adding a dive that would end up in the
middle of the dive list, the newest dive in the dive list would end up
marked in the dive structure as selected - even though it wasn't
visualized as selected by Qt. Bad things happen if the user then made
changes to that dive without selecting something else first, for example
by either editing the dive or doing things to it like removing it from or
adding it to a trip. The same operation would also be applied to the
newest dive in the dive list.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The existing code seemed way complicated, made way too many assumptions
and apparently was broken in certain cases.
This code seems very simple, looks correct and should fail gracefully
(i.e. simply do nothing) if things get confused.
Fixes#706
(I hope)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The column isn't just about NITROX, there might be air and trimix in
there too.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we add a picture to the dive, this will not change anything
else, so there's no need to recalculate the profile_plot info.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This makes the screen repopulate itself after a dive change only
one time instead of the old 4. we were repopulateing when we
removed the actual selection to reset the old selection previously
stored, sigh.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Q_FOREACH will expand and already creates a copy of the
contained container, so this is just a waste of cpu cycles
and also increases a tiny bit the memory consumption.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
affects mainly capitalisation on the dive list context menu
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We need to first replot() to get displayed_dive updated, then call
refreshDisplay() so the picture model gets repopulated which triggers the
pictures to show up.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The planner used the selected dive on the dive list, and
when there's a filtering in action it can be in a state where
there's no dive selected.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The picture list is a single linked list where the pictures have a node to
their next element. When adding the same picture to two dives, things got
way way wrong and crashes were appearing.
This will replicate the information (filename, latitude and longitude) for
each dive that has the picture, BUT it still tries to save as much as
possible on the actual pixmap.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit breaks the loading of images that were done in the divelist
into smaller bits. A bit of code refactor was done in order to correct the
placement of a few methods.
ShiftTimesDialog::EpochFromExiv got moved to Exif::epoch dive_add_picture
is now used instead of add_event picture_load_exif_data got implemented
using the old listview code. dive_set_geodata_from_picture got
implemented using the old listview code.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead wait until all pictures have been set and plot that.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch removes some inconsistencies that were happening on the add
dive / cancel actions. a bit of legacy code from the old system was still
in, which made things quite... EXPLOSIVE.
This fixes restoring the selection only if we have a selection and not
deleting the temporary dive twice.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Looping over the individual dives will be very slow if there are many of
them, as the profile will try to render each of them in succession.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It's a testament to how much I mess around with things that I hadn't
noticed that saving the column width doesn't actually work. Or actually,
saving them worked, loading them back failed as it was done too early and
the setColumnWidth() calls had no effect - and so the next time we quit
subsurface, the default width of 100 was written over all the saved
values.
This seems like an incredible hack but it has the advantage of actually
working. I look forward to someone with better insides into the inner
workings of Qt to properly fix this.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We set the column width in the dive list widget when we create that
widget, based on what is in the settings. And we save the current column
width back to the settings when we destroy that widget (so if Subsurface
is shut down correctly and Qt actually gets to run the destructor but not
when someone kills the program).
That means that if we recreate the dive list at any point while Subsurface
is running (and we do that a lot when you manipulate your dive list in any
way shape or form), any changes to the column widths are lost.
DiveListView::reload() explicitly calls setupUi() which reads the column
widths back from the settings - but changes made to the columns aren't
saved to the settings until we destroy the widget...
I see no reason why reload() should call setupUi(), so I'm removing that
call. Let's hope this doesn't break anything else.
Fixes#518
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dirk's code in commit a3d300ca91 ("Correctly implement multi dive
selection") had a major flaw - it kept redrawing the selected dives
one after another. Not what we need. So this fixes this up so that it
doesn't take more than a sec to select all the dives that are on the same
part of the click on the globe. I've achieved this by creating a boolean '
dontEmitDiveChanged and sending the signal only if this flag is false.
The reason that we can't simply remove the emit from the selectionChanged
is because the selectionChanged is what we have when we click on the
diveList, if we removed this from there, nothing will happen upon
selection.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old code had several issues. It broke the synchronization between
dive->select and Qt selected status and worse, it would partially unselect
previously selected dives when called.
This patch, however, causes the selection via the map to be glacially slow
because it forces a redraw of every single selected profile.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This also fixes a couple of issues with the existing code:
- removes a memory leak
- treats null and "" the same
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
According to the documentation clearSelection() should emit
selectionChanged() - but I can verify in the debugger that sometimes this
doesn't appear to happen - consequently our notion of what's selected gets
confused.
To work around this, after calling clearSelection() we simply manuall
deselect all dives.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>