Add ability to export only selected dives in worldmap exporter

This patch adds the ability to export selected dives only in the worldmap
exporter. After Miika added the export dialog in commit 7dc642860d
("Implementing export dialog") and exporting only selected dives became a
choice while exporting.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Gehad elrobey 2014-05-21 15:23:05 +03:00 committed by Dirk Hohndel
parent 7dc642860d
commit 19e22e1bb7
3 changed files with 13 additions and 17 deletions

View file

@ -40,13 +40,7 @@ void DiveLogExportDialog::on_buttonBox_accepted()
filename = QFileDialog::getSaveFileName(this, tr("Export World Map"), fi.absolutePath(),
tr("HTML files (*.html)"));
if (!filename.isNull() && !filename.isEmpty())
export_worldmap_HTML(filename.toUtf8().data());
return;
} else if (ui->exportWorldMap->isChecked()) {
filename = QFileDialog::getSaveFileName(this, tr("Export World Map"), fi.absolutePath(),
tr("HTML files (*.html)"));
if (!filename.isNull() && !filename.isEmpty())
export_worldmap_HTML(filename.toUtf8().data());
export_worldmap_HTML(filename.toUtf8().data(), ui->exportSelected->isChecked());
return;
}

View file

@ -83,14 +83,16 @@ void put_HTML_notes(struct membuffer *b, struct dive *dive)
}
}
void writeMarkers(struct membuffer *b)
void writeMarkers(struct membuffer *b, const bool selected_only)
{
int i, dive_no = 0;
struct dive *dive;
for_each_dive(i, dive) {
/*export selected dives only ?*/
if (selected_only) {
if (!dive->selected)
continue;
}
if (dive->latitude.udeg == 0 && dive->longitude.udeg == 0)
continue;
@ -120,7 +122,7 @@ void insert_css(struct membuffer *b)
put_format(b, "<style type=\"text/css\">%s</style>\n", css);
}
void insert_javascript(struct membuffer *b)
void insert_javascript(struct membuffer *b, const bool selected_only)
{
put_string(b, "<script type=\"text/javascript\" src=\"");
put_string(b, getGoogleApi());
@ -129,25 +131,25 @@ void insert_javascript(struct membuffer *b)
put_string(b, "rotateControl: false,\n\tstreetViewControl: false,\n\tmapTypeControl: false\n};\n");
put_string(b, "map = new google.maps.Map(document.getElementById(\"map-canvas\"),mapOptions);\nvar markers = new Array();");
put_string(b, "\nvar infowindows = new Array();\nvar temp;\nvar tempinfowindow;\n");
writeMarkers(b);
writeMarkers(b, selected_only);
put_string(b, "\nfor(var i=0;i<markers.length;i++)\n\tmarkers[i].setMap(map);\n}\n");
put_string(b, "google.maps.event.addDomListener(window, 'load', initialize);</script>\n");
}
void export(struct membuffer *b)
void export(struct membuffer *b, const bool selected_only)
{
insert_html_header(b);
insert_css(b);
insert_javascript(b);
insert_javascript(b, selected_only);
put_string(b, "\t</head>\n<body>\n<div id=\"map-canvas\"></div>\n</body>\n</html>");
}
void export_worldmap_HTML(const char *file_name)
void export_worldmap_HTML(const char *file_name, const bool selected_only)
{
FILE *f;
struct membuffer buf = { 0 };
export(&buf);
export(&buf, selected_only);
f = fopen(file_name, "w+");
if (!f)

View file

@ -5,7 +5,7 @@
extern "C" {
#endif
extern void export_worldmap_HTML(const char* x);
extern void export_worldmap_HTML(const char* file_name, const bool selected_only);
#ifdef __cplusplus