Merge branch 'custom-print' of github.com:neolit123/subsurface

This commit is contained in:
Dirk Hohndel 2015-08-15 05:22:07 -07:00
commit 2455a5dec7
16 changed files with 720 additions and 201 deletions

View file

@ -1,6 +1,9 @@
#include "printer.h" #include "printer.h"
#include "templatelayout.h" #include "templatelayout.h"
#include "statistics.h"
#include "helpers.h"
#include <algorithm>
#include <QtWebKitWidgets> #include <QtWebKitWidgets>
#include <QPainter> #include <QPainter>
#include <QWebElementCollection> #include <QWebElementCollection>
@ -54,6 +57,53 @@ void Printer::putProfileImage(QRect profilePlaceholder, QRect viewPort, QPainter
} }
} }
void Printer::flowRender()
{
// render the Qwebview
QPainter painter;
QRect viewPort(0, 0, 0, 0);
painter.begin(paintDevice);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
// get all references to dontbreak divs
int start = 0, end = 0;
int fullPageResolution = webView->page()->mainFrame()->contentsSize().height();
QWebElementCollection dontbreak = webView->page()->mainFrame()->findAllElements(".dontbreak");
foreach (QWebElement dontbreakElement, dontbreak) {
if ((dontbreakElement.geometry().y() + dontbreakElement.geometry().height()) - start < pageSize.height()) {
// One more element can be placed
end = dontbreakElement.geometry().y() + dontbreakElement.geometry().height();
} else {
// fill the page with background color
QRect fullPage(0, 0, pageSize.width(), pageSize.height());
QBrush fillBrush(templateOptions->color_palette.color1);
painter.fillRect(fullPage, fillBrush);
QRegion reigon(0, 0, pageSize.width(), end - start);
viewPort.setRect(0, start, pageSize.width(), end - start);
// render the base Html template
webView->page()->mainFrame()->render(&painter, QWebFrame::ContentsLayer, reigon);
// scroll the webview to the next page
webView->page()->mainFrame()->scroll(0, dontbreakElement.geometry().y() - start);
// rendering progress is 4/5 of total work
emit(progessUpdated((end * 80.0 / fullPageResolution) + done));
static_cast<QPrinter*>(paintDevice)->newPage();
start = dontbreakElement.geometry().y();
}
}
// render the remianing page
QRect fullPage(0, 0, pageSize.width(), pageSize.height());
QBrush fillBrush(templateOptions->color_palette.color1);
painter.fillRect(fullPage, fillBrush);
QRegion reigon(0, 0, pageSize.width(), end - start);
webView->page()->mainFrame()->render(&painter, QWebFrame::ContentsLayer, reigon);
painter.end();
}
void Printer::render(int Pages = 0) void Printer::render(int Pages = 0)
{ {
// keep original preferences // keep original preferences
@ -144,9 +194,17 @@ void Printer::print()
connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int))); connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int)));
dpi = printerPtr->resolution(); dpi = printerPtr->resolution();
//rendering resolution = selected paper size in inchs * printer dpi //rendering resolution = selected paper size in inchs * printer dpi
pageSize.setHeight(printerPtr->pageLayout().paintRect(QPageLayout::Inch).height() * dpi); #if QT_VERSION >= 0x050300
pageSize.setWidth(printerPtr->pageLayout().paintRect(QPageLayout::Inch).width() * dpi); pageSize.setHeight(printerPtr->pageLayout().paintRectPixels(dpi).height());
pageSize.setWidth(printerPtr->pageLayout().paintRectPixels(dpi).width());
#else
pageSize.setHeight(printerPtr->pageRect(QPrinter::Inch).height() * dpi);
pageSize.setWidth(printerPtr->pageRect(QPrinter::Inch).width() * dpi);
#endif
webView->page()->setViewportSize(pageSize); webView->page()->setViewportSize(pageSize);
webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
// export border width with at least 1 pixel
templateOptions->border_width = std::max(1, pageSize.width() / 1000);
webView->setHtml(t.generate()); webView->setHtml(t.generate());
if (printOptions->color_selected && printerPtr->colorMode()) { if (printOptions->color_selected && printerPtr->colorMode()) {
printerPtr->setColorMode(QPrinter::Color); printerPtr->setColorMode(QPrinter::Color);
@ -165,11 +223,69 @@ void Printer::print()
} }
int Pages; int Pages;
if (divesPerPage == 0) { if (divesPerPage == 0) {
Pages = ceil(webView->page()->mainFrame()->contentsSize().height() / (float)pageSize.height()); // add extra padding at the bottom to pages with height not divisible by view port
int paddingBottom = pageSize.height() - (webView->page()->mainFrame()->contentsSize().height() % pageSize.height());
QString styleString = QString::fromUtf8("padding-bottom: ") + QString::number(paddingBottom) + "px;";
webView->page()->mainFrame()->findFirstElement("body").setAttribute("style", styleString);
flowRender();
} else { } else {
Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage); Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage);
render(Pages);
} }
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() void Printer::previewOnePage()

View file

@ -29,6 +29,7 @@ private:
int done; int done;
int dpi; int dpi;
void render(int Pages); void render(int Pages);
void flowRender();
void putProfileImage(QRect box, QRect viewPort, QPainter *painter, struct dive *dive, QPointer<ProfileWidget2> profile); void putProfileImage(QRect box, QRect viewPort, QPainter *painter, struct dive *dive, QPointer<ProfileWidget2> profile);
private slots: private slots:
@ -38,6 +39,7 @@ public:
Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode); Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode);
~Printer(); ~Printer();
void print(); void print();
void print_statistics();
void previewOnePage(); void previewOnePage();
signals: signals:

View file

@ -15,11 +15,17 @@
font-size: {{ template_options.font_size }}vw; font-size: {{ template_options.font_size }}vw;
} }
p {
float: left;
font-size: {{ template_options.font_size }}vw;
}
table { table {
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
border:max(1px, 0.1vw); border-width: {{ template_options.borderwidth }}px;
border-style:solid; border-style:solid;
border-color: {{ template_options.color6 }};
} }
td { td {
@ -32,57 +38,59 @@
} }
.mainContainer { .mainContainer {
width: 96%; width: 100%;
margin-left: 2%; margin-left: 0%;
margin-right: 2%; margin-right: 0%;
margin-top: 0%; margin-top: 0%;
margin-bottom: 0%; margin-bottom: 2%;
overflow: hidden; overflow: hidden;
border-width: 0; border-width: 0;
page-break-inside: avoid; page-break-inside: avoid;
} }
.innerContainer { .innerContainer {
width: 98%; width: 100%;
padding: 1%; padding: 0%;
overflow: hidden; overflow: hidden;
} }
.diveDetails { .diveDetails {
width: 98%; width: 100%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border:max(1px, 0.1vw);
border-style:solid;
float: left; float: left;
} }
.dataSection { .dataSection {
width: 98%; width: 100%;
margin: 1%;
} }
.fieldTitle { .fieldTitle {
background-color: {{ template_options.color2 }}; background-color: {{ template_options.color2 }};
overflow: hidden; overflow: hidden;
color: {{ template_options.color4 }};
}
.fieldData {
color: {{ template_options.color5 }};
background-color: {{ template_options.color3 }};
} }
.table_class { .table_class {
float: left; float: left;
margin: 1%; width: 49.25%;
width: 48%; margin: 0.5%;
} }
.notes_table_class { .notes_table_class {
overflow: hidden; overflow: hidden;
width: 98%; width: 99%;
margin: 1%; margin: 0.5%;
} }
.textArea { .textArea {
line-height: {{ template_options.line_spacing }}; line-height: {{ template_options.line_spacing }};
max-height: 19vh; max-height: 19vh;
overflow: hidden; overflow: hidden;
color: {{ template_options.color4 }};
} }
</style> </style>
</head> </head>
@ -90,7 +98,7 @@
<div id="body_div"> <div id="body_div">
{% block main_rows %} {% block main_rows %}
{% for dive in dives %} {% for dive in dives %}
<div class="mainContainer"> <div class="mainContainer dontbreak">
<div class="innerContainer"> <div class="innerContainer">
<div class="diveDetails"> <div class="diveDetails">
<div class="dataSection"> <div class="dataSection">
@ -99,39 +107,40 @@
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Dive No. </h1> <h1> Dive No. </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.number }} </h1> <p> {{ dive.number }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Date </h1> <h1> Date </h1>
</td> </td>
<td><h1> {{ dive.date }} </h1> <td class="fieldData">
<p> {{ dive.date }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Location </h1> <h1> Location </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.location }} </h1> <p> {{ dive.location }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Max depth </h1> <h1> Max depth </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.depth }} </h1> <p> {{ dive.depth }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Duration </h1> <h1> Duration </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.duration }} </h1> <p> {{ dive.duration }} </p>
</td> </td>
</tr> </tr>
</tbody></table> </tbody></table>
@ -140,39 +149,40 @@
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Time. </h1> <h1> Time. </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.time }} </h1> <p> {{ dive.time }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Air Temp. </h1> <h1> Air Temp. </h1>
</td> </td>
<td><h1> {{ dive.airTemp }} </h1> <td class="fieldData">
<p> {{ dive.airTemp }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Water Temp. </h1> <h1> Water Temp. </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.waterTemp }} </h1> <p> {{ dive.waterTemp }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Buddy </h1> <h1> Buddy </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.buddy }} </h1> <p> {{ dive.buddy }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Dive Master </h1> <h1> Dive Master </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.divemaster }} </h1> <p> {{ dive.divemaster }} </p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -185,9 +195,9 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td class="fieldData">
<div class="textArea"> <div class="textArea">
<h1> {{ dive.notes }} </h1> <p> {{ dive.notes }} </p>
</div> </div>
</td> </td>
</tr> </tr>

View file

@ -15,11 +15,17 @@
font-size: {{ template_options.font_size }}vw; font-size: {{ template_options.font_size }}vw;
} }
p {
float: left;
font-size: {{ template_options.font_size }}vw;
}
table { table {
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
border:max(1px, 0.1vw); border-width: {{ template_options.borderwidth }}px;
border-style:solid; border-style:solid;
border-color: {{ template_options.color6 }};
} }
td { td {
@ -32,10 +38,10 @@
} }
.mainContainer { .mainContainer {
width: 96%; width: 98%;
height: 100%; height: 100%;
margin-left: 2%; margin-left: 1%;
margin-right: 2%; margin-right: 1%;
margin-top: 0%; margin-top: 0%;
margin-bottom: 0%; margin-bottom: 0%;
overflow: hidden; overflow: hidden;
@ -44,53 +50,56 @@
} }
.innerContainer { .innerContainer {
width: 98%; width: 100%;
height: 98%; height: 99%;
padding: 1%; padding-top: 1%;
overflow: hidden; overflow: hidden;
} }
.diveDetails { .diveDetails {
width: 98%; width: 100%;
height: 98%; height: 98%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border:max(1px, 0.1vw);
border-style:solid;
float: left; float: left;
} }
.diveProfile { .diveProfile {
width: 96%; width: 99%;
height: 40%; height: 40%;
margin: 2%; margin: 0.5%;
} }
.dataSection { .dataSection {
width: 98%; width: 100%;
height: 40%; height: 40%;
margin: 1%; margin: 0%;
} }
.fieldTitle { .fieldTitle {
background-color: {{ template_options.color2 }}; background-color: {{ template_options.color2 }};
overflow: hidden; overflow: hidden;
color: {{ template_options.color4 }};
}
.fieldData {
background-color: {{ template_options.color3 }};
color: {{ template_options.color5 }};
} }
.table_class { .table_class {
float: left; float: left;
margin: 1%; margin: 0.5%;
width: 48%; width: 49%;
} }
.notes_table_class { .notes_table_class {
overflow: hidden; overflow: hidden;
width: 98%; width: 99%;
margin: 1%; margin: 0.5%;
} }
.textArea { .textArea {
line-height: {{ template_options.line_spacing }}; line-height: {{ template_options.line_spacing }};
color: {{ template_options.color5 }};
max-height: 19vh; max-height: 19vh;
overflow: hidden; overflow: hidden;
} }
@ -111,39 +120,40 @@
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Dive No. </h1> <h1> Dive No. </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.number }} </h1> <p> {{ dive.number }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Date </h1> <h1> Date </h1>
</td> </td>
<td><h1> {{ dive.date }} </h1> <td class="fieldData">
<p> {{ dive.date }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Location </h1> <h1> Location </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.location }} </h1> <p> {{ dive.location }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Max depth </h1> <h1> Max depth </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.depth }} </h1> <p> {{ dive.depth }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Duration </h1> <h1> Duration </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.duration }} </h1> <p> {{ dive.duration }} </p>
</td> </td>
</tr> </tr>
</tbody></table> </tbody></table>
@ -152,39 +162,40 @@
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Time. </h1> <h1> Time. </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.time }} </h1> <p> {{ dive.time }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Air Temp. </h1> <h1> Air Temp. </h1>
</td> </td>
<td><h1> {{ dive.airTemp }} </h1> <td class="fieldData">
<p> {{ dive.airTemp }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Water Temp. </h1> <h1> Water Temp. </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.waterTemp }} </h1> <p> {{ dive.waterTemp }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Buddy </h1> <h1> Buddy </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.buddy }} </h1> <p> {{ dive.buddy }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Dive Master </h1> <h1> Dive Master </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.divemaster }} </h1> <p> {{ dive.divemaster }} </p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -197,9 +208,9 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td class="fieldData">
<div class="textArea"> <div class="textArea">
<h1> {{ dive.notes }} </h1> <p> {{ dive.notes }} </p>
</div> </div>
</td> </td>
</tr> </tr>

View file

@ -0,0 +1,182 @@
<html>
<head>
<style>
body {
{{ print_options.grayscale }};
padding: 0px;
margin: 0px;
font-size: {{ template_options.font_size }}vw;
line-height: {{ template_options.line_spacing }};
font-family: {{ template_options.font }};
color: {{ template_options.color4 }};
}
h1 {
font-size: {{ template_options.font_size }}vw;
float: left;
margin: 0px;
}
p {
font-size: {{ template_options.font_size }}vw;
float: left;
margin: 0px;
}
td {
margin:0px;
}
#footer {
height: 100%;
width: 100%;
float: left;
}
#body_div {
background-color: {{ template_options.color1 }};
float: left;
}
.mainContainer {
width: 50%;
height: 33.333333%;
margin-left: 0%;
margin-right: 0%;
margin-top: 0;
margin-bottom: 0;
overflow: hidden;
page-break-inside: avoid;
float: left;
}
.innerContainer {
height: 99%;
width: 98%;
padding-left: 1%;
padding-right: 1%;
padding-top: 1%;
overflow: hidden;
}
.table_class {
overflow: hidden;
width: 100%;
margin: 0%;
float: left;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border-width: {{ template_options.borderwidth }}px;
border-style:solid;
border-color: {{ template_options.color6 }};
font-size: {{ template_options.font_size }}vw;
background-color: {{ template_options.color3 }};
color: {{ template_options.color4 }};
}
.notes_table_class {
overflow: hidden;
max-width: 100%;
min-width: 100%;
margin: 0.5%;
float: left;
}
.diveProfile {
width: 100%;
height: 95%;
margin-left: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-top: 0%;
float: right;
}
.diveDetails {
width: 100%;
float: left;
}
.dataPart {
height: 45%;
max-height: 60%;
}
.dataSection{
width: 100%;
}
.textArea {
overflow: hidden !important;
text-overflow: ellipsis;
line-height: {{ template_options.line_spacing }};
}
</style>
</head>
<body data-numberofdives = 6>
<div id="body_div">
{% block main_rows %}
{% for dive in dives %}
<div class="mainContainer">
<div class="innerContainer">
<div class="diveDetails">
<div class="dataPart">
<div class="diveProfile" id="dive_{{ dive.id }}">
</div>
<div class="dataSection">
<table style="float:left;width:100%;">
<tr>
<td>
<h1> Dive # {{ dive.number }} - {{ dive.date }} {{ dive.time }}</h1>
<p style="float:right;"> Max depth: {{ dive.depth }} </p>
</td>
</tr>
<tr>
<td>
<p> {{ dive.location }} </p>
<p style="float:right;"> Duration: {{ dive.duration }} </p>
</td>
</tr>
</table>
<table class="table_class">
<tr>
<td> Gas used: {{ dive.gas }}</td>
<td> Tags: {{ dive.tags }}</td>
<td> SAC: {{ dive.sac }}</td>
</tr>
<tr>
<td> Divemaster: {{ dive.divemaster }}</td>
<td> Buddy: {{ dive.buddy }}</td>
<td> Rating: {{ dive.rating }}/5</td>
</tr>
</table>
</div>
</div>
<div class="notesPart">
<table class="notes_table_class">
<tbody>
<tr>
<td>
<p> Notes: </p>
</td>
</tr>
<tr>
<td>
<div class="textArea">
<p> {{ dive.notes }} </p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endfor %}
{% endblock %}
<div id="footer">
</div>
</div>
</body>
</html>

View file

@ -21,6 +21,11 @@
-webkit-column-break-inside: avoid; -webkit-column-break-inside: avoid;
padding-top: 1vh; padding-top: 1vh;
padding-bottom: 1vh; padding-bottom: 1vh;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border-width: {{ template_options.borderwidth }}px;
border-style:solid;
border-color: {{ template_options.color6 }};
} }
#body_div { #body_div {
@ -28,10 +33,10 @@
} }
.mainContainer { .mainContainer {
width: 96%; width: 99%;
height: 100%; height: 100%;
margin-left: 2%; margin-left: 0.5%;
margin-right: 2%; margin-right: 0.5%;
margin-top: 0%; margin-top: 0%;
margin-bottom: 0%; margin-bottom: 0%;
overflow: hidden; overflow: hidden;
@ -41,13 +46,8 @@
.table_class { .table_class {
overflow: hidden; overflow: hidden;
width: 97%; width: 100%;
margin: 1.5%; margin: 0%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border:max(0.1vw, 1px);
border-style:solid;
border-color: color: {{ template_options.color5 }};
} }
</style> </style>
@ -55,7 +55,7 @@
<body data-numberofdives = 0> <body data-numberofdives = 0>
<div id="body_div"> <div id="body_div">
<table class="table_class"> <table class="table_class">
<tr style="background-color: {{ template_options.color2 }}; color: {{ template_options.color3 }}"> <tr style="background-color: {{ template_options.color2 }}; color: {{ template_options.color4 }}">
<th>Dive #</th> <th>Dive #</th>
<th>Date</th> <th>Date</th>
<th>Time</th> <th>Time</th>
@ -66,7 +66,7 @@
</tr> </tr>
{% block main_rows %} {% block main_rows %}
{% for dive in dives %} {% for dive in dives %}
<tr style="color: {{ template_options.color4 }}"> <tr class="dontbreak" style="background-color: {{ template_options.color3 }}; color: {{ template_options.color5 }};">
<th>{{ dive.number }}</th> <th>{{ dive.number }}</th>
<th>{{ dive.date }}</th> <th>{{ dive.date }}</th>
<th>{{ dive.time }}</th> <th>{{ dive.time }}</th>

View file

@ -15,15 +15,20 @@
float: left; float: left;
} }
p {
font-size: {{ template_options.font_size }}vw;
float: left;
}
#body_div { #body_div {
background-color: {{ template_options.color1 }}; background-color: {{ template_options.color1 }};
} }
.mainContainer { .mainContainer {
width: 96%; width: 99%;
height: 50%; height: 50%;
margin-left: 2%; margin-left: 0.5%;
margin-right: 2%; margin-right: 0.5%;
margin-top: 0; margin-top: 0;
margin-bottom: 0; margin-bottom: 0;
overflow: hidden; overflow: hidden;
@ -32,68 +37,70 @@
.innerContainer { .innerContainer {
height: 85%; height: 85%;
padding: 0.5%;
margin-top: 1%; margin-top: 1%;
margin-bottom: 1%; margin-bottom: 1%;
overflow: hidden; overflow: hidden;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border:max(0.1vw, 1px);
border-style:solid;
} }
.table_class { .table_class {
overflow: hidden; overflow: hidden;
max-width: 25%; width: 25%;
min-width: 25%; height: 99%;
margin: 0.5%; margin: 0.5%;
float: left; float: left;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
border:max(0.1vw, 1px); border-width: {{ template_options.borderwidth }}px;
border-style:solid; border-style:solid;
border-color: {{ template_options.color6 }};
} }
.notes_table_class { .notes_table_class {
overflow: hidden; overflow: hidden;
max-width: 100%; width: 99%;
min-width: 100%;
margin: 0.5%; margin: 0.5%;
float: left;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
border:max(0.1vw, 1px); border-width: {{ template_options.borderwidth }}px;
border-style:solid; border-style:solid;
border-color: {{ template_options.color6 }};
} }
.fieldTitle { .fieldTitle {
background-color: {{ template_options.color2 }}; background-color: {{ template_options.color2 }};
overflow: hidden; color: {{ template_options.color4 }};
padding:0; padding-left: 2%;
}
.fieldData {
color: {{ template_options.color5 }};
background-color: {{ template_options.color3 }};
padding-left: 2%;
} }
.diveProfile { .diveProfile {
width: 48%; float: left;
height: 95%; height: 99%;
margin-left: 0%; width: 47%;
margin-right: 0%; margin: 0.5%;
margin-bottom: 0%;
margin-top: 0.5%;
float: right;
} }
.diveDetails { .diveDetails {
width: 98.5%; width: 100%;
float: left; float: left;
} }
.dataPart { .dataPart {
height: 45%; height: 64%;
max-height: 60%; padding-bottom: 1%;
width: 100%;
float: left;
} }
.notesPart { .notesPart {
height: 35%; height: 35%;
width: 100%;
float: left;
} }
.textArea { .textArea {
@ -122,39 +129,40 @@
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Dive No. </h1> <h1> Dive No. </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.number }} </h1> <p> {{ dive.number }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Date </h1> <h1> Date </h1>
</td> </td>
<td><h1> {{ dive.date }} </h1> <td class="fieldData">
<p> {{ dive.date }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Location </h1> <h1> Location </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.location }} </h1> <p> {{ dive.location }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Max depth </h1> <h1> Max depth </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.depth }} </h1> <p> {{ dive.depth }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Duration </h1> <h1> Duration </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.duration }} </h1> <p> {{ dive.duration }} </p>
</td> </td>
</tr> </tr>
</tbody></table> </tbody></table>
@ -163,39 +171,40 @@
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Time. </h1> <h1> Time. </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.time }} </h1> <p> {{ dive.time }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Air Temp. </h1> <h1> Air Temp. </h1>
</td> </td>
<td><h1> {{ dive.airTemp }} </h1> <td class="fieldData">
<p> {{ dive.airTemp }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Water Temp. </h1> <h1> Water Temp. </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.waterTemp }} </h1> <p> {{ dive.waterTemp }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Buddy </h1> <h1> Buddy </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.buddy }} </h1> <p> {{ dive.buddy }} </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="fieldTitle"> <td class="fieldTitle">
<h1> Dive Master </h1> <h1> Dive Master </h1>
</td> </td>
<td> <td class="fieldData">
<h1> {{ dive.divemaster }} </h1> <p> {{ dive.divemaster }} </p>
</td> </td>
</tr> </tr>
</tbody></table> </tbody></table>
@ -205,14 +214,14 @@
<div class="notesPart"> <div class="notesPart">
<table class="notes_table_class"> <table class="notes_table_class">
<tbody><tr> <tbody><tr>
<td class="fieldTitle"> <td style="padding-left:1%" class="fieldTitle">
<h1> Notes </h1> <h1> Notes </h1>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td class="fieldData">
<div class="textArea"> <div class="textArea">
<h1> {{ dive.notes }} </h1> <p> {{ dive.notes }} </p>
</div> </div>
</td> </td>
</tr> </tr>
@ -224,7 +233,7 @@
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}
<div id="footer"> <div id="footer">
<div> </div>
</div> </div>
</body> </body>
</html> </html>

View file

@ -17,21 +17,24 @@ template_options::color_palette_struct ssrf_colors, almond_colors, blueshades_co
PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
{ {
// initialize const colors // initialize const colors
ssrf_colors.color1 = QColor::fromRgb(0xef, 0xf7, 0xff); ssrf_colors.color1 = QColor::fromRgb(0xff, 0xff, 0xff);
ssrf_colors.color2 = QColor::fromRgb(0xa6, 0xbc, 0xd7); ssrf_colors.color2 = QColor::fromRgb(0xa6, 0xbc, 0xd7);
ssrf_colors.color3 = QColor::fromRgb(0x34, 0x65, 0xa4); ssrf_colors.color3 = QColor::fromRgb(0xef, 0xf7, 0xff);
ssrf_colors.color4 = QColor::fromRgb(0x20, 0x4a, 0x87); ssrf_colors.color4 = QColor::fromRgb(0x34, 0x65, 0xa4);
ssrf_colors.color5 = QColor::fromRgb(0x17, 0x37, 0x64); ssrf_colors.color5 = QColor::fromRgb(0x20, 0x4a, 0x87);
almond_colors.color1 = QColor::fromRgb(243, 234, 207); ssrf_colors.color6 = QColor::fromRgb(0x17, 0x37, 0x64);
almond_colors.color1 = QColor::fromRgb(255, 255, 255);
almond_colors.color2 = QColor::fromRgb(253, 204, 156); almond_colors.color2 = QColor::fromRgb(253, 204, 156);
almond_colors.color3 = QColor::fromRgb(136, 160, 150); almond_colors.color3 = QColor::fromRgb(243, 234, 207);
almond_colors.color4 = QColor::fromRgb(187, 171, 139); almond_colors.color4 = QColor::fromRgb(136, 160, 150);
almond_colors.color5 = QColor::fromRgb(239, 130, 117); almond_colors.color5 = QColor::fromRgb(187, 171, 139);
blueshades_colors.color1 = QColor::fromRgb(182, 192, 206); almond_colors.color6 = QColor::fromRgb(0, 0, 0);
blueshades_colors.color1 = QColor::fromRgb(255, 255, 255);
blueshades_colors.color2 = QColor::fromRgb(142, 152, 166); blueshades_colors.color2 = QColor::fromRgb(142, 152, 166);
blueshades_colors.color3 = QColor::fromRgb(31, 49, 75); blueshades_colors.color3 = QColor::fromRgb(182, 192, 206);
blueshades_colors.color4 = QColor::fromRgb(21, 45, 84); blueshades_colors.color4 = QColor::fromRgb(31, 49, 75);
blueshades_colors.color5 = QColor::fromRgb(5, 25, 56); blueshades_colors.color5 = QColor::fromRgb(21, 45, 84);
blueshades_colors.color6 = QColor::fromRgb(0, 0, 0);
// check if the options were previously stored in the settings; if not use some defaults. // check if the options were previously stored in the settings; if not use some defaults.
QSettings s; QSettings s;
@ -164,13 +167,6 @@ void PrintDialog::onFinished()
void PrintDialog::previewClicked(void) 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 QPrintPreviewDialog previewDialog(&qprinter, this, Qt::Window
| Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint
| Qt::WindowTitleHint); | Qt::WindowTitleHint);
@ -180,13 +176,6 @@ void PrintDialog::previewClicked(void)
void PrintDialog::printClicked(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); QPrintDialog printDialog(&qprinter, this);
if (printDialog.exec() == QDialog::Accepted) { if (printDialog.exec() == QDialog::Accepted) {
switch (printOptions.type) { switch (printOptions.type) {
@ -195,6 +184,7 @@ void PrintDialog::printClicked(void)
printer->print(); printer->print();
break; break;
case print_options::STATISTICS: case print_options::STATISTICS:
printer->print_statistics();
break; break;
} }
close(); close();
@ -204,7 +194,14 @@ void PrintDialog::printClicked(void)
void PrintDialog::onPaintRequested(QPrinter *printerPtr) void PrintDialog::onPaintRequested(QPrinter *printerPtr)
{ {
connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int))); 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); progressBar->setValue(0);
disconnect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int))); disconnect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
} }

View file

@ -64,17 +64,39 @@ void PrintOptions::setup()
} }
// print type radio buttons // print type radio buttons
void PrintOptions::on_radioDiveListPrint_clicked(bool check) void PrintOptions::on_radioDiveListPrint_toggled(bool check)
{ {
if (check) { if (check) {
printOptions->type = print_options::DIVELIST; printOptions->type = print_options::DIVELIST;
// print options
ui.printInColor->setEnabled(true);
ui.printSelected->setEnabled(true);
// print template
ui.deleteButton->setEnabled(true);
ui.editButton->setEnabled(true);
ui.exportButton->setEnabled(true);
ui.importButton->setEnabled(true);
ui.printTemplate->setEnabled(true);
} }
} }
void PrintOptions::on_radioStatisticsPrint_clicked(bool check) void PrintOptions::on_radioStatisticsPrint_toggled(bool check)
{ {
if (check) { if (check) {
printOptions->type = print_options::STATISTICS; printOptions->type = print_options::STATISTICS;
// print options
ui.printInColor->setEnabled(false);
ui.printSelected->setEnabled(false);
// print template
ui.deleteButton->setEnabled(false);
ui.editButton->setEnabled(false);
ui.exportButton->setEnabled(false);
ui.importButton->setEnabled(false);
ui.printTemplate->setEnabled(false);
} }
} }

View file

@ -19,6 +19,7 @@ struct print_options {
struct template_options { struct template_options {
int font_index; int font_index;
int color_palette_index; int color_palette_index;
int border_width;
double font_size; double font_size;
double line_spacing; double line_spacing;
struct color_palette_struct { struct color_palette_struct {
@ -27,12 +28,14 @@ struct template_options {
QColor color3; QColor color3;
QColor color4; QColor color4;
QColor color5; QColor color5;
QColor color6;
bool operator!=(const color_palette_struct &other) const { bool operator!=(const color_palette_struct &other) const {
return other.color1 != color1 return other.color1 != color1
|| other.color2 != color2 || other.color2 != color2
|| other.color3 != color3 || other.color3 != color3
|| other.color4 != color4 || other.color4 != color4
|| other.color5 != color5; || other.color5 != color5
|| other.color6 != color6;
} }
} color_palette; } color_palette;
bool operator!=(const template_options &other) const { bool operator!=(const template_options &other) const {
@ -72,8 +75,8 @@ private
slots: slots:
void printInColorClicked(bool check); void printInColorClicked(bool check);
void printSelectedClicked(bool check); void printSelectedClicked(bool check);
void on_radioStatisticsPrint_clicked(bool check); void on_radioStatisticsPrint_toggled(bool check);
void on_radioDiveListPrint_clicked(bool check); void on_radioDiveListPrint_toggled(bool check);
void on_printTemplate_currentIndexChanged(int index); void on_printTemplate_currentIndexChanged(int index);
void on_editButton_clicked(); void on_editButton_clicked();
void on_importButton_clicked(); void on_importButton_clicked();

View file

@ -627,6 +627,17 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
eventItems.clear(); eventItems.clear();
struct event *event = currentdc->events; struct event *event = currentdc->events;
while (event) { while (event) {
// if print mode is selected only draw headings, SP change, gas events or bookmark event
if (printMode) {
if (same_string(event->name, "") ||
!(strcmp(event->name, "heading") == 0 ||
(same_string(event->name, "SP change") && event->time.seconds == 0) ||
event_is_gaschange(event) ||
event->type == SAMPLE_EVENT_BOOKMARK)) {
event = event->next;
continue;
}
}
DiveEventItem *item = new DiveEventItem(); DiveEventItem *item = new DiveEventItem();
item->setHorizontalAxis(timeAxis); item->setHorizontalAxis(timeAxis);
item->setVerticalAxis(profileYAxis); item->setVerticalAxis(profileYAxis);

View file

@ -30,9 +30,11 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions,
btnGroup->addButton(ui->editButton3, 3); btnGroup->addButton(ui->editButton3, 3);
btnGroup->addButton(ui->editButton4, 4); btnGroup->addButton(ui->editButton4, 4);
btnGroup->addButton(ui->editButton5, 5); btnGroup->addButton(ui->editButton5, 5);
btnGroup->addButton(ui->editButton6, 6);
connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(colorSelect(QAbstractButton*))); connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(colorSelect(QAbstractButton*)));
ui->plainTextEdit->setPlainText(grantlee_template); ui->plainTextEdit->setPlainText(grantlee_template);
editingCustomColors = false;
updatePreview(); updatePreview();
} }
@ -59,12 +61,14 @@ void TemplateEdit::updatePreview()
ui->colorLable3->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color3.name() + "\";}"); ui->colorLable3->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color3.name() + "\";}");
ui->colorLable4->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color4.name() + "\";}"); ui->colorLable4->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color4.name() + "\";}");
ui->colorLable5->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color5.name() + "\";}"); ui->colorLable5->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color5.name() + "\";}");
ui->colorLable6->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color6.name() + "\";}");
ui->colorLable1->setText(newTemplateOptions.color_palette.color1.name()); ui->colorLable1->setText(newTemplateOptions.color_palette.color1.name());
ui->colorLable2->setText(newTemplateOptions.color_palette.color2.name()); ui->colorLable2->setText(newTemplateOptions.color_palette.color2.name());
ui->colorLable3->setText(newTemplateOptions.color_palette.color3.name()); ui->colorLable3->setText(newTemplateOptions.color_palette.color3.name());
ui->colorLable4->setText(newTemplateOptions.color_palette.color4.name()); ui->colorLable4->setText(newTemplateOptions.color_palette.color4.name());
ui->colorLable5->setText(newTemplateOptions.color_palette.color5.name()); ui->colorLable5->setText(newTemplateOptions.color_palette.color5.name());
ui->colorLable6->setText(newTemplateOptions.color_palette.color6.name());
// update critical UI elements // update critical UI elements
ui->colorpalette->setCurrentIndex(newTemplateOptions.color_palette_index); ui->colorpalette->setCurrentIndex(newTemplateOptions.color_palette_index);
@ -102,7 +106,10 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int index)
newTemplateOptions.color_palette = blueshades_colors; newTemplateOptions.color_palette = blueshades_colors;
break; break;
case CUSTOM: // custom case CUSTOM: // custom
newTemplateOptions.color_palette = custom_colors; if (!editingCustomColors)
newTemplateOptions.color_palette = custom_colors;
else
editingCustomColors = false;
break; break;
} }
updatePreview(); updatePreview();
@ -121,7 +128,7 @@ void TemplateEdit::saveSettings()
printOptions->p_template = "custom.html"; printOptions->p_template = "custom.html";
TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText()); TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText());
} }
if (templateOptions->color_palette_index == 2) { if (templateOptions->color_palette_index == CUSTOM) {
custom_colors = templateOptions->color_palette; custom_colors = templateOptions->color_palette;
} }
} }
@ -148,6 +155,7 @@ void TemplateEdit::on_buttonBox_clicked(QAbstractButton *button)
void TemplateEdit::colorSelect(QAbstractButton *button) void TemplateEdit::colorSelect(QAbstractButton *button)
{ {
editingCustomColors = true;
// reset custom colors palette // reset custom colors palette
switch (newTemplateOptions.color_palette_index) { switch (newTemplateOptions.color_palette_index) {
case SSRF_COLORS: // subsurface derived default colors case SSRF_COLORS: // subsurface derived default colors
@ -155,11 +163,11 @@ void TemplateEdit::colorSelect(QAbstractButton *button)
break; break;
case ALMOND: // almond case ALMOND: // almond
newTemplateOptions.color_palette = almond_colors; newTemplateOptions.color_palette = almond_colors;
custom_colors = newTemplateOptions.color_palette;
break; break;
case BLUESHADES: // blueshades case BLUESHADES: // blueshades
newTemplateOptions.color_palette = blueshades_colors; newTemplateOptions.color_palette = blueshades_colors;
custom_colors = newTemplateOptions.color_palette; break;
default:
break; break;
} }
@ -168,24 +176,35 @@ void TemplateEdit::colorSelect(QAbstractButton *button)
switch (btnGroup->id(button)) { switch (btnGroup->id(button)) {
case 1: case 1:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color1, this); color = QColorDialog::getColor(newTemplateOptions.color_palette.color1, this);
newTemplateOptions.color_palette.color1 = color; if (color.isValid()) {
newTemplateOptions.color_palette.color1 = color;
}
break; break;
case 2: case 2:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color2, this); color = QColorDialog::getColor(newTemplateOptions.color_palette.color2, this);
newTemplateOptions.color_palette.color2 = color; if (color.isValid()) {
break; newTemplateOptions.color_palette.color2 = color;
} break;
case 3: case 3:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color3, this); color = QColorDialog::getColor(newTemplateOptions.color_palette.color3, this);
newTemplateOptions.color_palette.color3 = color; if (color.isValid()) {
break; newTemplateOptions.color_palette.color3 = color;
} break;
case 4: case 4:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color4, this); color = QColorDialog::getColor(newTemplateOptions.color_palette.color4, this);
newTemplateOptions.color_palette.color4 = color; if (color.isValid()) {
break; newTemplateOptions.color_palette.color4 = color;
} break;
case 5: case 5:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color5, this); color = QColorDialog::getColor(newTemplateOptions.color_palette.color5, this);
newTemplateOptions.color_palette.color5 = color; if (color.isValid()) {
break; newTemplateOptions.color_palette.color5 = color;
} break;
case 6:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color6, this);
if (color.isValid()) {
newTemplateOptions.color_palette.color6 = color;
} break;
} }
newTemplateOptions.color_palette_index = CUSTOM; newTemplateOptions.color_palette_index = CUSTOM;
updatePreview(); updatePreview();

View file

@ -31,6 +31,7 @@ private slots:
private: private:
Ui::TemplateEdit *ui; Ui::TemplateEdit *ui;
QButtonGroup *btnGroup; QButtonGroup *btnGroup;
bool editingCustomColors;
struct template_options *templateOptions; struct template_options *templateOptions;
struct template_options newTemplateOptions; struct template_options newTemplateOptions;
struct print_options *printOptions; struct print_options *printOptions;

View file

@ -317,7 +317,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Table cells</string> <string>Table cells 1</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -347,9 +347,9 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QHBoxLayout" name="horizontalLayout_13">
<item> <item>
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_6">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -357,7 +357,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Text 1</string> <string>Table cells 2</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -387,9 +387,9 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_9"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<item> <item>
<widget class="QLabel" name="label_11"> <widget class="QLabel" name="label_7">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -397,7 +397,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Text 2</string> <string>Text 1</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -427,9 +427,9 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_9">
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_11">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -437,7 +437,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Borders</string> <string>Text 2</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -466,6 +466,46 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Borders</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="colorLable6">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>color6</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editButton6">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">

View file

@ -188,10 +188,30 @@ QString Dive::notes() const
return m_notes; return m_notes;
} }
QString Dive::tags() const
{
return m_tags;
}
QString Dive::gas() const
{
return m_gas;
}
QString Dive::sac() const
{
return m_sac;
}
int Dive::rating() const
{
return m_rating;
}
void Dive::put_divemaster() void Dive::put_divemaster()
{ {
if (!dive->divemaster) if (!dive->divemaster)
m_divemaster = ""; m_divemaster = "--";
else else
m_divemaster = dive->divemaster; m_divemaster = dive->divemaster;
} }
@ -207,6 +227,9 @@ void Dive::put_date_time()
void Dive::put_location() void Dive::put_location()
{ {
m_location = QString::fromUtf8(get_dive_location(dive)); m_location = QString::fromUtf8(get_dive_location(dive));
if (m_location.isEmpty()) {
m_location = "--";
}
} }
void Dive::put_depth() void Dive::put_depth()
@ -222,7 +245,7 @@ void Dive::put_duration()
void Dive::put_buddy() void Dive::put_buddy()
{ {
if (!dive->buddy) if (!dive->buddy)
m_buddy = ""; m_buddy = "--";
else else
m_buddy = dive->buddy; m_buddy = dive->buddy;
} }
@ -231,9 +254,55 @@ void Dive::put_temp()
{ {
m_airTemp = get_temperature_string(dive->airtemp, true); m_airTemp = get_temperature_string(dive->airtemp, true);
m_waterTemp = get_temperature_string(dive->watertemp, true); m_waterTemp = get_temperature_string(dive->watertemp, true);
if (m_airTemp.isEmpty()) {
m_airTemp = "--";
}
if (m_waterTemp.isEmpty()) {
m_waterTemp = "--";
}
} }
void Dive::put_notes() void Dive::put_notes()
{ {
m_notes = QString::fromUtf8(dive->notes); m_notes = QString::fromUtf8(dive->notes);
if (m_notes.isEmpty()) {
m_notes = "--";
}
}
void Dive::put_tags()
{
char buffer[256];
taglist_get_tagstring(dive->tag_list, buffer, 256);
m_tags = QString(buffer);
}
void Dive::put_gas()
{
int added = 0;
QString gas, gases;
for (int i = 0; i < MAX_CYLINDERS; i++) {
if (!is_cylinder_used(dive, i))
continue;
gas = dive->cylinder[i].type.description;
gas += QString(!gas.isEmpty() ? " " : "") + gasname(&dive->cylinder[i].gasmix);
// if has a description and if such gas is not already present
if (!gas.isEmpty() && gases.indexOf(gas) == -1) {
if (added > 0)
gases += QString(" / ");
gases += gas;
added++;
}
}
m_gas = gases;
}
void Dive::put_sac()
{
if (dive->sac) {
const char *unit;
int decimal;
double value = get_volume_units(dive->sac, &decimal, &unit);
m_sac = QString::number(value, 'f', decimal).append(unit);
}
} }

View file

@ -32,6 +32,7 @@ class Dive {
private: private:
int m_number; int m_number;
int m_id; int m_id;
int m_rating;
QString m_date; QString m_date;
QString m_time; QString m_time;
QString m_location; QString m_location;
@ -42,6 +43,9 @@ private:
QString m_airTemp; QString m_airTemp;
QString m_waterTemp; QString m_waterTemp;
QString m_notes; QString m_notes;
QString m_tags;
QString m_gas;
QString m_sac;
struct dive *dive; struct dive *dive;
void put_date_time(); void put_date_time();
void put_location(); void put_location();
@ -51,6 +55,9 @@ private:
void put_buddy(); void put_buddy();
void put_temp(); void put_temp();
void put_notes(); void put_notes();
void put_tags();
void put_gas();
void put_sac();
public: public:
Dive(struct dive *dive) Dive(struct dive *dive)
@ -58,6 +65,7 @@ public:
{ {
m_number = dive->number; m_number = dive->number;
m_id = dive->id; m_id = dive->id;
m_rating = dive->rating;
put_date_time(); put_date_time();
put_location(); put_location();
put_duration(); put_duration();
@ -66,11 +74,15 @@ public:
put_buddy(); put_buddy();
put_temp(); put_temp();
put_notes(); put_notes();
put_tags();
put_gas();
put_sac();
} }
Dive(); Dive();
~Dive(); ~Dive();
int number() const; int number() const;
int id() const; int id() const;
int rating() const;
QString date() const; QString date() const;
QString time() const; QString time() const;
QString location() const; QString location() const;
@ -81,6 +93,9 @@ public:
QString airTemp() const; QString airTemp() const;
QString waterTemp() const; QString waterTemp() const;
QString notes() const; QString notes() const;
QString tags() const;
QString gas() const;
QString sac() const;
}; };
Q_DECLARE_METATYPE(Dive) Q_DECLARE_METATYPE(Dive)
@ -112,6 +127,14 @@ else if (property == "waterTemp")
return object.waterTemp(); return object.waterTemp();
else if (property == "notes") else if (property == "notes")
return object.notes(); return object.notes();
else if (property == "rating")
return object.rating();
else if (property == "sac")
return object.sac();
else if (property == "tags")
return object.tags();
else if (property == "gas")
return object.gas();
GRANTLEE_END_LOOKUP GRANTLEE_END_LOOKUP
GRANTLEE_BEGIN_LOOKUP(template_options) GRANTLEE_BEGIN_LOOKUP(template_options)
@ -128,6 +151,8 @@ if (property == "font") {
case 4: case 4:
return "Verdana, Geneva, sans-serif"; return "Verdana, Geneva, sans-serif";
} }
} else if (property == "borderwidth") {
return object.border_width;
} else if (property == "font_size") { } else if (property == "font_size") {
return object.font_size / 9.0; return object.font_size / 9.0;
} else if (property == "line_spacing") { } else if (property == "line_spacing") {
@ -142,6 +167,8 @@ if (property == "font") {
return object.color_palette.color4.name(); return object.color_palette.color4.name();
} else if (property == "color5") { } else if (property == "color5") {
return object.color_palette.color5.name(); return object.color_palette.color5.name();
} else if (property == "color6") {
return object.color_palette.color6.name();
} }
GRANTLEE_END_LOOKUP GRANTLEE_END_LOOKUP