mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
c32e71e64d
The old surface interval calculation had fundamental issues: 1) process_all_dives(), which calculates the statistics over *all* dives was used to get the pointer to the previous dive. 2) If two dives in the table had the same time, one of those would have been considered the "previous" dive. 3) If the dive, for which the surface interval is calculated is not yet in the table, no previous dive would be determined. Fix all this by creating a get_surface_interval() function and removing the "get previous dive" functionality of process_all_dives(). Remove the process_all_dives() call from TabDiveInformation::updateData(). Reported-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
/* Dirk Hohndel, 2015 */
|
|
|
|
#include <QString>
|
|
#include <QCommandLineParser>
|
|
#include <QApplication>
|
|
#include <QDebug>
|
|
|
|
#include "core/qt-gui.h"
|
|
#include "core/qthelper.h"
|
|
#include "core/save-html.h"
|
|
#include <stdio.h>
|
|
#include "git2.h"
|
|
#include "core/subsurfacestartup.h"
|
|
#include "core/divelogexportlogic.h"
|
|
#include "core/statistics.h"
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
QApplication *application = new QApplication(argc, argv);
|
|
git_libgit2_init();
|
|
copy_prefs(&default_prefs, &prefs);
|
|
init_qt_late();
|
|
|
|
QCommandLineParser parser;
|
|
QCommandLineOption sourceDirectoryOption(QStringList() << "s" << "source",
|
|
"Read git repository from <directory>",
|
|
"directory");
|
|
parser.addOption(sourceDirectoryOption);
|
|
QCommandLineOption outputDirectoryOption(QStringList() << "u" << "output",
|
|
"Write HTML files into <directory>",
|
|
"directory");
|
|
parser.addOption(outputDirectoryOption);
|
|
|
|
parser.process(*application);
|
|
|
|
QString source = parser.value(sourceDirectoryOption);
|
|
QString output = parser.value(outputDirectoryOption);
|
|
|
|
if (source.isEmpty() || output.isEmpty()) {
|
|
qDebug() << "need --source and --output";
|
|
exit(1);
|
|
}
|
|
int ret = parse_file(qPrintable(source), &dive_table);
|
|
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
|
|
|
|
prefs.unit_system = git_prefs.unit_system;
|
|
prefs.units = git_prefs.units;
|
|
|
|
// populate the statistics
|
|
process_all_dives();
|
|
|
|
// now set up the export settings to create the HTML export
|
|
struct htmlExportSetting hes;
|
|
hes.themeFile = "sand.css";
|
|
hes.exportPhotos = true;
|
|
hes.selectedOnly = false;
|
|
hes.listOnly = false;
|
|
hes.yearlyStatistics = true;
|
|
hes.subsurfaceNumbers = true;
|
|
exportHtmlInitLogic(output, hes);
|
|
exit(0);
|
|
}
|