summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--export-html.cpp5
-rw-r--r--git-access.c4
-rw-r--r--load-git.c9
-rw-r--r--planner.c17
-rw-r--r--pref.h1
-rw-r--r--qt-models/diveplannermodel.cpp6
-rw-r--r--qt-models/diveplannermodel.h1
-rw-r--r--qt-ui/diveplanner.cpp4
-rw-r--r--qt-ui/plannerSettings.ui30
-rw-r--r--save-git.c13
-rw-r--r--save-html.c18
-rw-r--r--subsurfacestartup.c1
-rw-r--r--theme/dive_export.html2
-rw-r--r--theme/list_lib.js9
-rw-r--r--windows.c2
15 files changed, 89 insertions, 33 deletions
diff --git a/export-html.cpp b/export-html.cpp
index 5c509d521..da570f4b0 100644
--- a/export-html.cpp
+++ b/export-html.cpp
@@ -42,8 +42,10 @@ int main(int argc, char **argv)
}
int ret = parse_file(qPrintable(source));
- if (ret)
+ if (ret) {
fprintf(stderr, "parse_file returned %d\n", ret);
+ exit(1);
+ }
// this should have set up the informational preferences - let's grab
// the units from there
@@ -58,6 +60,7 @@ int main(int argc, char **argv)
hes.selectedOnly = false;
hes.listOnly = false;
hes.yearlyStatistics = true;
+ hes.subsurfaceNumbers = true;
exportHtmlInitLogic(output, hes);
exit(0);
}
diff --git a/git-access.c b/git-access.c
index 3a99d591c..e5029f62a 100644
--- a/git-access.c
+++ b/git-access.c
@@ -362,9 +362,9 @@ static git_repository *create_local_repo(const char *localdir, const char *remot
git_repository *cloned_repo = NULL;
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
#if USE_LIBGIT23_API
- if (strncmp(remote, "ssh://", 6) == 0)
+ if (rt == RT_SSH)
opts.fetch_opts.callbacks.credentials = credential_ssh_cb;
- else if (strncmp(remote, "https://", 8) == 0)
+ else if (rt == RT_HTTPS)
opts.fetch_opts.callbacks.credentials = credential_https_cb;
opts.repository_cb = repository_create_cb;
#endif
diff --git a/load-git.c b/load-git.c
index 08eef085d..6a054e887 100644
--- a/load-git.c
+++ b/load-git.c
@@ -1129,7 +1129,8 @@ static int dive_trip_directory(const char *root, const char *name)
}
/*
- * Dive directory, name is [[yyyy-]mm-]nn-ddd-hh:mm:ss[~hex],
+ * Dive directory, name is [[yyyy-]mm-]nn-ddd-hh:mm:ss[~hex] in older git repositories
+ * but [[yyyy-]mm-]nn-ddd-hh=mm=ss[~hex] in newer repos as ':' is an illegal character for Windows files
* and 'timeoff' points to what should be the time part of
* the name (the first digit of the hour).
*
@@ -1156,8 +1157,8 @@ static int dive_directory(const char *root, const char *name, int timeoff)
if (mday_off < 0)
return GIT_WALK_SKIP;
- /* Get the time of day */
- if (sscanf(name+timeoff, "%d:%d:%d", &h, &m, &s) != 3)
+ /* Get the time of day -- parse both time formats so we can read old repos when not on Windows */
+ if (sscanf(name+timeoff, "%d:%d:%d", &h, &m, &s) != 3 && sscanf(name+timeoff, "%d=%d=%d", &h, &m, &s) != 3)
return GIT_WALK_SKIP;
if (!validate_time(h, m, s))
return GIT_WALK_SKIP;
@@ -1307,7 +1308,7 @@ static int walk_tree_directory(const char *root, const git_tree_entry *entry)
* We know the len is at least 3, because we had at least
* two digits and a dash
*/
- if (name[len-3] == ':')
+ if (name[len-3] == ':' || name[len-3] == '=')
return dive_directory(root, name, len-8);
if (digits != 2)
diff --git a/planner.c b/planner.c
index 9b2d355fa..63f1f6364 100644
--- a/planner.c
+++ b/planner.c
@@ -1040,12 +1040,21 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
previous_point_time = clock;
stopping = true;
- current_cylinder = gaschanges[gi].gasidx;
- gas = displayed_dive.cylinder[current_cylinder].gasmix;
+ /* Check we need to change cylinder.
+ * We might not if the cylinder was chosen by the user */
+ if (current_cylinder != gaschanges[gi].gasidx) {
+ current_cylinder = gaschanges[gi].gasidx;
+ gas = displayed_dive.cylinder[current_cylinder].gasmix;
#if DEBUG_PLAN & 16
- printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi].gasidx,
- (get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi].depth / 1000.0);
+ printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi].gasidx,
+ (get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi].depth / 1000.0);
#endif
+ /* Stop for the minimum duration to switch gas */
+ tissue_tolerance = add_segment(depth_to_mbar(depth, &displayed_dive) / 1000.0,
+ &displayed_dive.cylinder[current_cylinder].gasmix,
+ prefs.min_switch_duration, po2, &displayed_dive, prefs.decosac);
+ clock += prefs.min_switch_duration;
+ }
gi--;
}
diff --git a/pref.h b/pref.h
index c657cf289..ff5fd3dd8 100644
--- a/pref.h
+++ b/pref.h
@@ -84,6 +84,7 @@ struct preferences {
bool recreational_mode;
bool safetystop;
int reserve_gas;
+ int min_switch_duration; // seconds
int bottomsac;
int decosac;
int o2consumption; // ml per min
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index bace54e20..655f1bd8b 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -490,6 +490,12 @@ void DivePlannerPointsModel::setDropStoneMode(bool value)
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
+void DivePlannerPointsModel::setMinSwitchDuration(int duration)
+{
+ prefs.min_switch_duration = duration * 60;
+ emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
+}
+
void DivePlannerPointsModel::setStartDate(const QDate &date)
{
startTime.setDate(date);
diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h
index 4d1ef3227..883103f22 100644
--- a/qt-models/diveplannermodel.h
+++ b/qt-models/diveplannermodel.h
@@ -90,6 +90,7 @@ slots:
void emitDataChanged();
void setRebreatherMode(int mode);
void setReserveGas(int reserve);
+ void setMinSwitchDuration(int duration);
signals:
void planCreated();
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index e2a604b68..08ceba5db 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -254,6 +254,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
prefs.bottompo2 = s.value("bottompo2", prefs.bottompo2).toInt();
prefs.decopo2 = s.value("decopo2", prefs.decopo2).toInt();
prefs.doo2breaks = s.value("doo2breaks", prefs.doo2breaks).toBool();
+ prefs.min_switch_duration = s.value("min_switch_duration", prefs.min_switch_duration).toInt();
prefs.drop_stone_mode = s.value("drop_stone_mode", prefs.drop_stone_mode).toBool();
prefs.bottomsac = s.value("bottomsac", prefs.bottomsac).toInt();
prefs.decosac = s.value("decosac", prefs.decosac).toInt();
@@ -274,6 +275,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
ui.decopo2->setValue(prefs.decopo2 / 1000.0);
ui.backgasBreaks->setChecked(prefs.doo2breaks);
ui.drop_stone_mode->setChecked(prefs.drop_stone_mode);
+ ui.min_switch_duration->setValue(prefs.min_switch_duration / 60);
// should be the same order as in dive_comp_type!
rebreater_modes << tr("Open circuit") << tr("CCR") << tr("pSCR");
ui.rebreathermode->insertItems(0, rebreater_modes);
@@ -306,6 +308,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
connect(ui.gfhigh, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFHigh()));
connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFLow()));
connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool)));
+ connect(ui.min_switch_duration, SIGNAL(valueChanged(int)), plannerModel, SLOT(setMinSwitchDuration(int)));
connect(ui.rebreathermode, SIGNAL(currentIndexChanged(int)), plannerModel, SLOT(setRebreatherMode(int)));
connect(plannerModel, SIGNAL(recreationChanged(bool)), this, SLOT(disableDecoElements(bool)));
@@ -347,6 +350,7 @@ PlannerSettingsWidget::~PlannerSettingsWidget()
s.setValue("decopo2", prefs.decopo2);
s.setValue("doo2breaks", prefs.doo2breaks);
s.setValue("drop_stone_mode", prefs.drop_stone_mode);
+ s.setValue("min_switch_duration", prefs.min_switch_duration);
s.setValue("bottomsac", prefs.bottomsac);
s.setValue("decosac", prefs.decosac);
s.endGroup();
diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui
index 9283bcda7..9ca603b28 100644
--- a/qt-ui/plannerSettings.ui
+++ b/qt-ui/plannerSettings.ui
@@ -308,7 +308,7 @@
</property>
</widget>
</item>
- <item row="10" column="1">
+ <item row="11" column="1">
<widget class="QComboBox" name="rebreathermode">
<property name="currentText">
<string/>
@@ -338,7 +338,7 @@
</property>
</widget>
</item>
- <item row="11" column="1">
+ <item row="12" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -401,6 +401,32 @@
</property>
</widget>
</item>
+ <item row="10" column="1">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Min. switch duration</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="2">
+ <widget class="QSpinBox" name="min_switch_duration">
+ <property name="suffix">
+ <string>min</string>
+ </property>
+ <property name="prefix">
+ <string/>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>9</number>
+ </property>
+ <property name="value">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/save-git.c b/save-git.c
index 3f540eab9..e13847125 100644
--- a/save-git.c
+++ b/save-git.c
@@ -549,7 +549,8 @@ static void create_dive_name(struct dive *dive, struct membuffer *name, struct t
if (tm.tm_mon != dirtm->tm_mon)
put_format(name, "%02u-", tm.tm_mon+1);
- put_format(name, "%02u-%s-%02u:%02u:%02u",
+ /* a colon is an illegal char in a file name on Windows - use an '=' instead */
+ put_format(name, "%02u-%s-%02u=%02u=%02u",
tm.tm_mday, weekday[tm.tm_wday],
tm.tm_hour, tm.tm_min, tm.tm_sec);
}
@@ -978,19 +979,19 @@ static int update_git_checkout(git_repository *repo, git_object *parent, git_tre
static int get_authorship(git_repository *repo, git_signature **authorp)
{
#if LIBGIT2_VER_MAJOR || LIBGIT2_VER_MINOR >= 20
- return git_signature_default(authorp, repo);
-#else
+ if (git_signature_default(authorp, repo) == 0)
+ return 0;
+#endif
/* Default name information, with potential OS overrides */
struct user_info user = {
.name = "Subsurface",
- .email = "subsurace@hohndel.org"
+ .email = "subsurace@subsurface-divelog.org"
};
subsurface_user_info(&user);
/* git_signature_default() is too recent */
return git_signature_now(authorp, user.name, user.email);
-#endif
}
static void create_commit_message(struct membuffer *msg)
@@ -1052,7 +1053,7 @@ static int create_new_commit(git_repository *repo, const char *remote, const cha
const git_oid *id = git_commit_id((const git_commit *) parent);
/* if we are saving to the same git tree we got this from, let's make
* sure there is no confusion */
- if (!strcmp(existing_filename, remote) && git_oid_strcmp(id, saved_git_id))
+ if (same_string(existing_filename, remote) && git_oid_strcmp(id, saved_git_id))
return report_error("The git branch does not match the git parent of the source");
}
diff --git a/save-html.c b/save-html.c
index 5e5f931c5..6814cbc33 100644
--- a/save-html.c
+++ b/save-html.c
@@ -438,12 +438,13 @@ void export_HTML(const char *file_name, const char *photos_dir, const bool selec
export_list(&buf, photos_dir, selected_only, list_only);
f = subsurface_fopen(file_name, "w+");
- if (!f)
+ if (!f) {
report_error(translate("gettextFromC", "Can't open file %s"), file_name);
-
- flush_buffer(&buf, f); /*check for writing errors? */
+ } else {
+ flush_buffer(&buf, f); /*check for writing errors? */
+ fclose(f);
+ }
free_buffer(&buf);
- fclose(f);
}
void export_translation(const char *file_name)
@@ -521,10 +522,11 @@ void export_translation(const char *file_name)
put_format(b, "}");
f = subsurface_fopen(file_name, "w+");
- if (!f)
+ if (!f) {
report_error(translate("gettextFromC", "Can't open file %s"), file_name);
-
- flush_buffer(&buf, f); /*check for writing errors? */
+ } else {
+ flush_buffer(&buf, f); /*check for writing errors? */
+ fclose(f);
+ }
free_buffer(&buf);
- fclose(f);
}
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index a64c8175d..7130f0f59 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -47,6 +47,7 @@ struct preferences default_prefs = {
.decopo2 = 1600,
.doo2breaks = false,
.drop_stone_mode = false,
+ .min_switch_duration = 60,
.last_stop = false,
.verbatim_plan = false,
.display_runtime = true,
diff --git a/theme/dive_export.html b/theme/dive_export.html
index e27b56b62..2620ce12a 100644
--- a/theme/dive_export.html
+++ b/theme/dive_export.html
@@ -122,7 +122,7 @@ window.onload=function(){
}
set_units();
- sizeofpage=10;
+ sizeofpage=20;
showAllDives();
document.getElementById("divePanel").style.display='none';
document.getElementById("diveStat").style.display='none';
diff --git a/theme/list_lib.js b/theme/list_lib.js
index 481085049..b6ac97366 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -20,6 +20,7 @@ function showAllDives()
for (var i = 0; i < items.length; i++) {
itemsToShow.push(i);
}
+ change_sort_col('1');
olditemstoshow = itemsToShow;
start = 0;
viewInPage();
@@ -47,7 +48,7 @@ function updateView(start, end)
var divelist = document.getElementById('diveslist');
divelist.innerHTML = "";
for (var i = start; i <= end; i++) {
- divelist.innerHTML += '<ul id="' + itemsToShow[i] + '" onclick="toggleExpantion(event, this)"></ul>';
+ divelist.innerHTML += '<ul id="' + itemsToShow[i] + '" onclick="toggleExpansion(event, this)"></ul>';
expand(document.getElementById(itemsToShow[i]));
items[itemsToShow[i]].expanded = true;
};
@@ -63,7 +64,7 @@ function addHTML(indexes)
var divelist = document.getElementById('diveslist');
divelist.innerHTML = "";
for (var i = 0; i < indexes.length; i++) {
- divelist.innerHTML += '<ul id="' + indexes[i] + '" onclick="toggleExpantion(event, this)"></ul>';
+ divelist.innerHTML += '<ul id="' + indexes[i] + '" onclick="toggleExpansion(event, this)"></ul>';
expand(document.getElementById(indexes[i]));
itemsToShow[indexes[i]].expanded = true;
};
@@ -177,7 +178,7 @@ function setNumberOfDives(e)
viewInPage();
}
-function toggleExpantion(e, ul)
+function toggleExpansion(e, ul)
{
if (e.target.localName === "a" ) {
return;
@@ -794,7 +795,7 @@ function expand_trip(trip)
trips[trip].expanded = true;
var d = document.getElementById("trip_dive_list_" + trip);
for (var j in trips[trip].dives) {
- d.innerHTML += '<ul id="' + trips[trip].dives[j].number + '" onclick="toggleExpantion(event, this)" onmouseover="highlight(this)"' +
+ d.innerHTML += '<ul id="' + trips[trip].dives[j].number + '" onclick="toggleExpansion(event, this)" onmouseover="highlight(this)"' +
' onmouseout="unhighlight(this)">' + getlimited(trips[trip].dives[j]) + '</ul>';
}
}
diff --git a/windows.c b/windows.c
index 5441b39b6..7d1f1e8af 100644
--- a/windows.c
+++ b/windows.c
@@ -18,7 +18,7 @@ const char current_system_divelist_default_font[] = "Segoe UI";
const char *system_divelist_default_font = non_standard_system_divelist_default_font;
double system_divelist_default_font_size = -1;
-void subsurface_user(struct user_info *user)
+void subsurface_user_info(struct user_info *user)
{ /* Encourage use of at least libgit2-0.20 */ }
extern bool isWin7Or8();