mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
filter: load filter presets from XML files
This is a bit painful: since we don't want to modify the filter presets when the user imports (as opposed to opens) a log, we have to provide a table where the parser stores the presets. Calling the parser is getting quite unwieldy, since many tables are passed. We probably should introduce a structure representing a full log-book at one point, which collects all the things that are saved to the log. Apart from that, this is simply the counterpart to saving to XML. The interpretation of the string data is performed by core functions, not the parser itself to avoid code duplication with the git parser. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
cef15c978d
commit
41cf83583d
21 changed files with 273 additions and 107 deletions
|
@ -108,7 +108,7 @@ int TestParse::parseCSV(int units, std::string file)
|
|||
params[pnr++] = intdup(-1);
|
||||
params[pnr++] = NULL;
|
||||
|
||||
return parse_manual_file(file.c_str(), params, pnr - 1, &dive_table, &trip_table, &dive_site_table);
|
||||
return parse_manual_file(file.c_str(), params, pnr - 1, &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
}
|
||||
|
||||
int TestParse::parseDivingLog()
|
||||
|
@ -129,13 +129,13 @@ int TestParse::parseDivingLog()
|
|||
int TestParse::parseV2NoQuestion()
|
||||
{
|
||||
// parsing of a V2 file should work
|
||||
return parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table);
|
||||
return parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
}
|
||||
|
||||
int TestParse::parseV3()
|
||||
{
|
||||
// parsing of a V3 files should succeed
|
||||
return parse_file(SUBSURFACE_TEST_DATA "/dives/test42.xml", &dive_table, &trip_table, &dive_site_table);
|
||||
return parse_file(SUBSURFACE_TEST_DATA "/dives/test42.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
}
|
||||
|
||||
void TestParse::testParse()
|
||||
|
@ -217,7 +217,7 @@ void TestParse::testParseHUDC()
|
|||
params[pnr++] = NULL;
|
||||
|
||||
QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearHUDC.csv",
|
||||
params, pnr - 1, "csv", &dive_table, &trip_table, &dive_site_table),
|
||||
params, pnr - 1, "csv", &dive_table, &trip_table, &dive_site_table, &filter_preset_table),
|
||||
0);
|
||||
|
||||
QCOMPARE(dive_table.nr, 1);
|
||||
|
@ -262,7 +262,7 @@ void TestParse::testParseNewFormat()
|
|||
"/dives/")
|
||||
.append(files.at(i))
|
||||
.toLatin1()
|
||||
.data(), &dive_table, &trip_table, &dive_site_table),
|
||||
.data(), &dive_table, &trip_table, &dive_site_table, &filter_preset_table),
|
||||
0);
|
||||
QCOMPARE(dive_table.nr, i + 1);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ void TestParse::testParseDLD()
|
|||
QString filename = SUBSURFACE_TEST_DATA "/dives/TestDiveDivelogsDE.DLD";
|
||||
|
||||
QVERIFY(readfile(filename.toLatin1().data(), &mem) > 0);
|
||||
QVERIFY(try_to_open_zip(filename.toLatin1().data(), &dive_table, &trip_table, &dive_site_table) > 0);
|
||||
QVERIFY(try_to_open_zip(filename.toLatin1().data(), &dive_table, &trip_table, &dive_site_table, &filter_preset_table) > 0);
|
||||
|
||||
fprintf(stderr, "number of dives from DLD: %d \n", dive_table.nr);
|
||||
|
||||
|
@ -296,8 +296,8 @@ void TestParse::testParseMerge()
|
|||
/*
|
||||
* check that we correctly merge mixed cylinder dives
|
||||
*/
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/ostc.xml", &dive_table, &trip_table, &dive_site_table), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/vyper.xml", &dive_table, &trip_table, &dive_site_table), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/ostc.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/vyper.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
|
||||
QCOMPARE(save_dives("./testmerge.ssrf"), 0);
|
||||
FILE_COMPARE("./testmerge.ssrf",
|
||||
SUBSURFACE_TEST_DATA "/dives/mergedVyperOstc.xml");
|
||||
|
@ -366,14 +366,14 @@ int TestParse::parseCSVmanual(int units, std::string file)
|
|||
params[pnr++] = intdup(units);
|
||||
params[pnr++] = NULL;
|
||||
|
||||
return parse_manual_file(file.c_str(), params, pnr - 1, &dive_table, &trip_table, &dive_site_table);
|
||||
return parse_manual_file(file.c_str(), params, pnr - 1, &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
}
|
||||
|
||||
void TestParse::exportCSVDiveDetails()
|
||||
{
|
||||
int saved_sac = 0;
|
||||
|
||||
parse_file(SUBSURFACE_TEST_DATA "/dives/test25.xml", &dive_table, &trip_table, &dive_site_table);
|
||||
parse_file(SUBSURFACE_TEST_DATA "/dives/test25.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
|
||||
export_dives_xslt("testcsvexportmanual.csv", 0, 0, "xml2manualcsv.xslt", false);
|
||||
export_dives_xslt("testcsvexportmanualimperial.csv", 0, 1, "xml2manualcsv.xslt", false);
|
||||
|
@ -409,7 +409,7 @@ void TestParse::exportSubsurfaceCSV()
|
|||
int pnr = 0;
|
||||
|
||||
/* Test SubsurfaceCSV with multiple cylinders */
|
||||
parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table);
|
||||
parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
|
||||
export_dives_xslt("testcsvexportmanual-cyl.csv", 0, 0, "xml2manualcsv.xslt", false);
|
||||
export_dives_xslt("testcsvexportmanualimperial-cyl.csv", 0, 1, "xml2manualcsv.xslt", false);
|
||||
|
@ -426,7 +426,7 @@ void TestParse::exportSubsurfaceCSV()
|
|||
params[pnr++] = strdup("units");
|
||||
params[pnr++] = intdup(1);
|
||||
params[pnr++] = 0;
|
||||
parse_csv_file("testcsvexportmanualimperial-cyl.csv", params, pnr - 1, "SubsurfaceCSV", &dive_table, &trip_table, &dive_site_table);
|
||||
parse_csv_file("testcsvexportmanualimperial-cyl.csv", params, pnr - 1, "SubsurfaceCSV", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
|
||||
// We do not currently support reading SAC, thus faking it
|
||||
if (dive_table.nr > 0) {
|
||||
|
@ -470,12 +470,12 @@ int TestParse::parseCSVprofile(int units, std::string file)
|
|||
params[pnr++] = intdup(units);
|
||||
params[pnr++] = NULL;
|
||||
|
||||
return parse_csv_file(file.c_str(), params, pnr - 1, "csv", &dive_table, &trip_table, &dive_site_table);
|
||||
return parse_csv_file(file.c_str(), params, pnr - 1, "csv", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
}
|
||||
|
||||
void TestParse::exportCSVDiveProfile()
|
||||
{
|
||||
parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table);
|
||||
parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
|
||||
export_dives_xslt("testcsvexportprofile.csv", 0, 0, "xml2csv.xslt", false);
|
||||
export_dives_xslt("testcsvexportprofileimperial.csv", 0, 1, "xml2csv.xslt", false);
|
||||
|
@ -493,13 +493,13 @@ void TestParse::exportCSVDiveProfile()
|
|||
|
||||
void TestParse::exportUDDF()
|
||||
{
|
||||
parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table);
|
||||
parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
|
||||
export_dives_xslt("testuddfexport.uddf", 0, 1, "uddf-export.xslt", false);
|
||||
|
||||
clear_dive_file_data();
|
||||
|
||||
parse_file("testuddfexport.uddf", &dive_table, &trip_table, &dive_site_table);
|
||||
parse_file("testuddfexport.uddf", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
|
||||
export_dives_xslt("testuddfexport2.uddf", 0, 1, "uddf-export.xslt", false);
|
||||
|
||||
FILE_COMPARE("testuddfexport.uddf",
|
||||
|
@ -565,7 +565,7 @@ void TestParse::parseDL7()
|
|||
|
||||
clear_dive_file_data();
|
||||
QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/DL7.zxu",
|
||||
params, pnr - 1, "DL7", &dive_table, &trip_table, &dive_site_table),
|
||||
params, pnr - 1, "DL7", &dive_table, &trip_table, &dive_site_table, &filter_preset_table),
|
||||
0);
|
||||
QCOMPARE(dive_table.nr, 3);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue