mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Printing: add statistics print
Add statistics table print option. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
This commit is contained in:
parent
f05e9c5c79
commit
1a2f154cf4
3 changed files with 66 additions and 15 deletions
56
printer.cpp
56
printer.cpp
|
@ -1,5 +1,7 @@
|
|||
#include "printer.h"
|
||||
#include "templatelayout.h"
|
||||
#include "statistics.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QtWebKitWidgets>
|
||||
#include <QPainter>
|
||||
|
@ -172,6 +174,60 @@ void Printer::print()
|
|||
render(Pages);
|
||||
}
|
||||
|
||||
void Printer::print_statistics()
|
||||
{
|
||||
QPrinter *printerPtr;
|
||||
printerPtr = static_cast<QPrinter*>(paintDevice);
|
||||
stats_t total_stats;
|
||||
|
||||
total_stats.selection_size = 0;
|
||||
total_stats.total_time.seconds = 0;
|
||||
|
||||
QString html;
|
||||
html += "<table border=1>";
|
||||
html += "<tr>";
|
||||
html += "<td>Year</td>";
|
||||
html += "<td>Dives</td>";
|
||||
html += "<td>Total Time</td>";
|
||||
html += "<td>Avg Time</td>";
|
||||
html += "<td>Shortest Time</td>";
|
||||
html += "<td>Longest Time</td>";
|
||||
html += "<td>Avg Depth</td>";
|
||||
html += "<td>Min Depth</td>";
|
||||
html += "<td>Max Depth</td>";
|
||||
html += "<td>Avg SAC</td>";
|
||||
html += "<td>Min SAC</td>";
|
||||
html += "<td>Max SAC</td>";
|
||||
html += "<td>Min Temp</td>";
|
||||
html += "<td>Max Temp</td>";
|
||||
html += "</tr>";
|
||||
int i = 0;
|
||||
while (stats_yearly != NULL && stats_yearly[i].period) {
|
||||
html += "<tr>";
|
||||
html += "<td>" + QString::number(stats_yearly[i].period) + "</td>";
|
||||
html += "<td>" + QString::number(stats_yearly[i].selection_size) + "</td>";
|
||||
html += "<td>" + QString::fromUtf8(get_time_string(stats_yearly[i].total_time.seconds, 0)) + "</td>";
|
||||
html += "<td>" + QString::fromUtf8(get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size)) + "</td>";
|
||||
html += "<td>" + QString::fromUtf8(get_minutes(stats_yearly[i].shortest_time.seconds)) + "</td>";
|
||||
html += "<td>" + QString::fromUtf8(get_minutes(stats_yearly[i].longest_time.seconds)) + "</td>";
|
||||
html += "<td>" + get_depth_string(stats_yearly[i].avg_depth) + "</td>";
|
||||
html += "<td>" + get_depth_string(stats_yearly[i].min_depth) + "</td>";
|
||||
html += "<td>" + get_depth_string(stats_yearly[i].max_depth) + "</td>";
|
||||
html += "<td>" + get_volume_string(stats_yearly[i].avg_sac) + "</td>";
|
||||
html += "<td>" + get_volume_string(stats_yearly[i].min_sac) + "</td>";
|
||||
html += "<td>" + get_volume_string(stats_yearly[i].max_sac) + "</td>";
|
||||
html += "<td>" + QString::number(stats_yearly[i].min_temp == 0 ? 0 : get_temp_units(stats_yearly[i].min_temp, NULL)) + "</td>";
|
||||
html += "<td>" + QString::number(stats_yearly[i].max_temp == 0 ? 0 : get_temp_units(stats_yearly[i].max_temp, NULL)) + "</td>";
|
||||
html += "</tr>";
|
||||
total_stats.selection_size += stats_yearly[i].selection_size;
|
||||
total_stats.total_time.seconds += stats_yearly[i].total_time.seconds;
|
||||
i++;
|
||||
}
|
||||
html += "</table>";
|
||||
webView->setHtml(html);
|
||||
webView->print(printerPtr);
|
||||
}
|
||||
|
||||
void Printer::previewOnePage()
|
||||
{
|
||||
if (printMode == PREVIEW) {
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode);
|
||||
~Printer();
|
||||
void print();
|
||||
void print_statistics();
|
||||
void previewOnePage();
|
||||
|
||||
signals:
|
||||
|
|
|
@ -164,13 +164,6 @@ void PrintDialog::onFinished()
|
|||
|
||||
void PrintDialog::previewClicked(void)
|
||||
{
|
||||
if (printOptions.type == print_options::STATISTICS) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("This feature is not implemented yet");
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
QPrintPreviewDialog previewDialog(&qprinter, this, Qt::Window
|
||||
| Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint
|
||||
| Qt::WindowTitleHint);
|
||||
|
@ -180,13 +173,6 @@ void PrintDialog::previewClicked(void)
|
|||
|
||||
void PrintDialog::printClicked(void)
|
||||
{
|
||||
if (printOptions.type == print_options::STATISTICS) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("This feature is not implemented yet");
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
QPrintDialog printDialog(&qprinter, this);
|
||||
if (printDialog.exec() == QDialog::Accepted) {
|
||||
switch (printOptions.type) {
|
||||
|
@ -195,6 +181,7 @@ void PrintDialog::printClicked(void)
|
|||
printer->print();
|
||||
break;
|
||||
case print_options::STATISTICS:
|
||||
printer->print_statistics();
|
||||
break;
|
||||
}
|
||||
close();
|
||||
|
@ -204,7 +191,14 @@ void PrintDialog::printClicked(void)
|
|||
void PrintDialog::onPaintRequested(QPrinter *printerPtr)
|
||||
{
|
||||
connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
|
||||
printer->print();
|
||||
switch (printOptions.type) {
|
||||
case print_options::DIVELIST:
|
||||
printer->print();
|
||||
break;
|
||||
case print_options::STATISTICS:
|
||||
printer->print_statistics();
|
||||
break;
|
||||
}
|
||||
progressBar->setValue(0);
|
||||
disconnect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue