2017-04-27 18:27:59 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-06-16 13:58:22 +00:00
|
|
|
/* Dirk Hohndel, 2015 */
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QCommandLineParser>
|
2017-02-05 20:44:11 +00:00
|
|
|
#include <QApplication>
|
2015-06-16 13:58:22 +00:00
|
|
|
|
2017-02-05 20:44:11 +00:00
|
|
|
#include "core/qt-gui.h"
|
|
|
|
#include "core/qthelper.h"
|
2019-03-03 21:29:40 +00:00
|
|
|
#include "core/file.h"
|
2020-10-17 10:32:22 +00:00
|
|
|
#include "core/device.h"
|
core: introduce divelog structure
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.
Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).
The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.
To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.
The whole commit is large, but was mostly an automatic
conversion.
One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-08 20:31:08 +00:00
|
|
|
#include "core/divelog.h"
|
2019-03-03 21:29:40 +00:00
|
|
|
#include "core/divesite.h"
|
2019-05-31 14:09:14 +00:00
|
|
|
#include "core/trip.h"
|
2017-02-05 20:44:11 +00:00
|
|
|
#include "core/save-html.h"
|
|
|
|
#include <stdio.h>
|
2015-06-16 13:58:22 +00:00
|
|
|
#include "git2.h"
|
2017-02-05 20:44:11 +00:00
|
|
|
#include "core/subsurfacestartup.h"
|
|
|
|
#include "core/divelogexportlogic.h"
|
|
|
|
#include "core/statistics.h"
|
2015-06-16 13:58:22 +00:00
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2015-06-17 13:27:33 +00:00
|
|
|
QApplication *application = new QApplication(argc, argv);
|
2015-06-16 13:58:22 +00:00
|
|
|
git_libgit2_init();
|
2024-06-13 20:59:32 +00:00
|
|
|
prefs = default_prefs;
|
2015-06-16 13:58:22 +00:00
|
|
|
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()) {
|
2024-03-25 19:33:30 +00:00
|
|
|
report_info("need --source and --output");
|
2015-06-16 13:58:22 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
core: introduce divelog structure
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.
Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).
The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.
To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.
The whole commit is large, but was mostly an automatic
conversion.
One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-08 20:31:08 +00:00
|
|
|
int ret = parse_file(qPrintable(source), &divelog);
|
2015-06-18 19:22:14 +00:00
|
|
|
if (ret) {
|
2024-03-25 19:33:30 +00:00
|
|
|
report_info("parse_file returned %d", ret);
|
2015-06-18 19:22:14 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2015-06-17 13:27:33 +00:00
|
|
|
|
|
|
|
// this should have set up the informational preferences - let's grab
|
|
|
|
// the units from there
|
2017-02-05 20:44:11 +00:00
|
|
|
prefs.unit_system = git_prefs.unit_system;
|
|
|
|
prefs.units = git_prefs.units;
|
2015-06-17 13:27:33 +00:00
|
|
|
|
|
|
|
// now set up the export settings to create the HTML export
|
2015-06-16 13:58:22 +00:00
|
|
|
struct htmlExportSetting hes;
|
|
|
|
hes.themeFile = "sand.css";
|
|
|
|
hes.exportPhotos = true;
|
|
|
|
hes.selectedOnly = false;
|
|
|
|
hes.listOnly = false;
|
|
|
|
hes.yearlyStatistics = true;
|
2015-06-18 19:23:30 +00:00
|
|
|
hes.subsurfaceNumbers = true;
|
2015-06-17 13:27:33 +00:00
|
|
|
exportHtmlInitLogic(output, hes);
|
2015-06-16 13:58:22 +00:00
|
|
|
exit(0);
|
|
|
|
}
|