subsurface/subsurface-core
Salvador Cuñat 09c854fee0 Renumber dive list after manual dive merging
As Linus pointed out in mail list, user is forced to manually renumber
his dives after doing a merge, unless the merged dives were those at
the list tail.

This patch try to manage the more usual cases, letting the user to deal
with those more complex, based on some assumptions:

1.- We are working on an time ordered list of type:
      dive_table.nr           ... 100 -- 101 -- 102 -- 103 -- 104 ...
      dive_table.dives.number ... 234 -- 235 -- 236 -- 245 -- 246 ...
2.- It's unlikely to merge no consecutive dives, as merging is time
    based.
3.- It's unlikely (although possible) to find consecutive dives with
    no consecutive numbers.
4.- It would be rather bizarre to find that newer dive,of those to
    merge, has lower number than older.
5.- It can be found that one (or both) dives to merge are zero
    numbered.
6.- There is only need to renumber from merged dives in advance.

A variable, "factor", is fixed before reworking the dive table. This
number will be substracted from the original dive number.
If we are in point 5.- case, "factor" will be set to zero, meaning
that dive numbers will not change (if older dive is zero, merged one
will be numbered zero too and will let the user to manage this; if
newer dive is zero there won't be need of renumbering as following
dives will be correctly numbered, e.g. after splitting a dive which
is not at the tail of the table).

In most cases, "factor" *should* be set to 1.

While renumbering it can be found a dive with it's number set to zero,
this won't be changed and will remain zeroed to avoid negative
numbers. It, mostly, means that the user has pending work on his
dives.

I don't know why I've written such a big explanation for such a tiny
patch :-)

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 14:11:32 -08:00
..
subsurface-qt Move Dive class from qthelper.h/cpp to it's own file 2016-01-08 08:04:44 -08:00
android.cpp Android: go back to using Qt's DataLocation 2015-11-07 10:52:19 -08:00
checkcloudconnection.cpp Switch to compile time connect syntax 2015-12-01 15:34:00 -08:00
checkcloudconnection.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
CMakeLists.txt Move Dive class from qthelper.h/cpp to it's own file 2016-01-08 08:04:44 -08:00
cochran.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
cochran.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
color.cpp Move qt-ui to desktop-widgets 2015-10-30 10:36:49 -07:00
color.h Move qt-ui to desktop-widgets 2015-10-30 10:36:49 -07:00
configuredivecomputer.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
configuredivecomputer.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
configuredivecomputerthreads.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
configuredivecomputerthreads.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
datatrak.c simple spelling changes 2015-11-15 12:10:37 -08:00
datatrak.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
deco.c Merge branch 'cmakeAndPreferences' 2015-11-02 19:54:34 -08:00
deco.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
device.c simple spelling changes 2015-11-15 12:10:37 -08:00
device.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
devicedetails.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
devicedetails.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
display.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
dive.c Assign lower number to a merged dive instead of higher one 2016-01-07 18:40:20 -08:00
dive.h Cloud storage: fix potential crash when avoiding reloading dive list 2016-01-04 17:55:37 -08:00
divecomputer.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
divecomputer.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
divelist.c Renumber dive list after manual dive merging 2016-01-10 14:11:32 -08:00
divelist.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
divelogexportlogic.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
divelogexportlogic.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
divesite.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
divesite.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
divesite.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
divesitehelpers.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
divesitehelpers.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
equipment.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
exif.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
exif.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
file.c Cloud storage: fix potential crash when avoiding reloading dive list 2016-01-04 17:55:37 -08:00
file.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
gaspressures.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
gaspressures.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
gettext.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
gettextfromc.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
gettextfromc.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
git-access.c Add option to not check the remote when loading from git storage 2015-12-27 10:06:33 -08:00
git-access.h Cloud storage: check the top commit without loading dives 2015-12-27 10:06:33 -08:00
gpslocation.cpp QML UI: partial, slow and incomplete implementation of delete GPS fix 2016-01-08 23:18:41 -08:00
gpslocation.h QML UI: partial, slow and incomplete implementation of delete GPS fix 2016-01-08 23:18:41 -08:00
helpers.h QML UI: handle editing of depth 2016-01-01 00:55:34 -08:00
imagedownloader.cpp Move ImageDownloader out of the desktop widgets 2015-11-06 11:30:11 -08:00
imagedownloader.h Move ImageDownloader out of the desktop widgets 2015-11-06 11:30:11 -08:00
isocialnetworkintegration.cpp Removed unused files 2015-11-09 18:00:56 -08:00
isocialnetworkintegration.h Remove the PluginSystem 2015-11-09 18:00:56 -08:00
libdivecomputer.c Only warn about different number of tanks and gases if there are tanks 2015-12-06 09:40:21 -08:00
libdivecomputer.h libdivecomputer.h: fix warning with DC_VERSION on Win32 2015-11-18 19:24:21 -08:00
linux.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
liquivision.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
load-git.c Cloud storage: check the top commit without loading dives 2015-12-27 10:06:33 -08:00
macos.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
membuffer.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
membuffer.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
metrics.cpp Move qt-ui to desktop-widgets 2015-10-30 10:36:49 -07:00
metrics.h Move qt-ui to desktop-widgets 2015-10-30 10:36:49 -07:00
ostctools.c simple spelling changes 2015-11-15 12:10:37 -08:00
parse-xml.c Merge branch 'cmakeAndPreferences' 2015-11-02 19:54:34 -08:00
planner.c Only close html tags if they were opened before 2015-11-24 09:20:40 -08:00
planner.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
pluginmanager.cpp Make it possible to connect to facebook again 2015-11-08 09:44:40 -08:00
pluginmanager.h Remove empty implementations 2015-11-09 18:00:56 -08:00
pref.h Add option to not check the remote when loading from git storage 2015-12-27 10:06:33 -08:00
prefs-macros.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
profile.c profile.c: remove unused variables 2015-11-07 22:26:33 -08:00
profile.h profile.h: fix incomplete type 2015-11-06 09:59:00 -08:00
qt-gui.h Missing half of the previous commit 2015-11-14 10:43:37 -08:00
qt-init.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
qthelper.cpp Move Dive class from qthelper.h/cpp to it's own file 2016-01-08 08:04:44 -08:00
qthelper.h Move Dive class from qthelper.h/cpp to it's own file 2016-01-08 08:04:44 -08:00
qthelperfromc.h Remove the non-canonical Subusrface version 2015-12-20 07:59:50 -08:00
qtserialbluetooth.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
save-git.c Remove the non-canonical Subusrface version 2015-12-20 07:59:50 -08:00
save-html.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
save-html.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
save-xml.c Interpret - as STDOUT on writing xml files 2015-11-24 09:20:03 -08:00
serial_ftdi.c ftdi: fix memory leak on error 2015-12-27 21:31:13 -08:00
sha1.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
sha1.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
statistics.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
statistics.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
strndup.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
strtod.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
subsurfacestartup.c subsurfacestartup.c: leave free_prefs() empty 2015-11-15 10:29:36 -08:00
subsurfacestartup.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
subsurfacesysinfo.cpp Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
subsurfacesysinfo.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
taxonomy.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
taxonomy.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
time.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
uemis-downloader.c Uemis downloader: handle yet another corner case 2015-12-06 13:38:38 -08:00
uemis.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
uemis.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
units.h Fix M_PI with -std=c++11 on Mingw 2015-11-03 07:19:05 -08:00
version.c Remove the non-canonical Subusrface version 2015-12-20 07:59:50 -08:00
version.h Remove the non-canonical Subusrface version 2015-12-20 07:59:50 -08:00
webservice.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
windows.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
windowtitleupdate.cpp Don't crash if we have no WindowTitleUpdater registered 2015-11-07 09:53:17 -08:00
windowtitleupdate.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
worldmap-options.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
worldmap-save.c Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00
worldmap-save.h Move all core-functionality to subsurface-core 2015-10-30 10:36:48 -07:00