summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--printer.cpp124
-rw-r--r--printer.h2
-rw-r--r--printing_templates/Flowlayout.html88
-rw-r--r--printing_templates/One Dive.html91
-rw-r--r--printing_templates/Six Dives.html182
-rw-r--r--printing_templates/Table.html24
-rw-r--r--printing_templates/Two Dives.html107
-rw-r--r--qt-ui/printdialog.cpp51
-rw-r--r--qt-ui/printoptions.cpp26
-rw-r--r--qt-ui/printoptions.h9
-rw-r--r--qt-ui/profile/profilewidget2.cpp11
-rw-r--r--qt-ui/templateedit.cpp45
-rw-r--r--qt-ui/templateedit.h1
-rw-r--r--qt-ui/templateedit.ui60
-rw-r--r--templatelayout.cpp73
-rw-r--r--templatelayout.h27
16 files changed, 720 insertions, 201 deletions
diff --git a/printer.cpp b/printer.cpp
index fc18c9afe..b0caa0815 100644
--- a/printer.cpp
+++ b/printer.cpp
@@ -1,6 +1,9 @@
#include "printer.h"
#include "templatelayout.h"
+#include "statistics.h"
+#include "helpers.h"
+#include <algorithm>
#include <QtWebKitWidgets>
#include <QPainter>
#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)
{
// keep original preferences
@@ -144,9 +194,17 @@ void Printer::print()
connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int)));
dpi = printerPtr->resolution();
//rendering resolution = selected paper size in inchs * printer dpi
- pageSize.setHeight(printerPtr->pageLayout().paintRect(QPageLayout::Inch).height() * dpi);
- pageSize.setWidth(printerPtr->pageLayout().paintRect(QPageLayout::Inch).width() * dpi);
+#if QT_VERSION >= 0x050300
+ 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()->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());
if (printOptions->color_selected && printerPtr->colorMode()) {
printerPtr->setColorMode(QPrinter::Color);
@@ -165,11 +223,69 @@ void Printer::print()
}
int Pages;
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 {
Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage);
+ 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++;
}
- render(Pages);
+ html += "</table>";
+ webView->setHtml(html);
+ webView->print(printerPtr);
}
void Printer::previewOnePage()
diff --git a/printer.h b/printer.h
index b4cf3ac2a..5c7652a8d 100644
--- a/printer.h
+++ b/printer.h
@@ -29,6 +29,7 @@ private:
int done;
int dpi;
void render(int Pages);
+ void flowRender();
void putProfileImage(QRect box, QRect viewPort, QPainter *painter, struct dive *dive, QPointer<ProfileWidget2> profile);
private slots:
@@ -38,6 +39,7 @@ public:
Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode);
~Printer();
void print();
+ void print_statistics();
void previewOnePage();
signals:
diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html
index a3f7951d9..2615c35a8 100644
--- a/printing_templates/Flowlayout.html
+++ b/printing_templates/Flowlayout.html
@@ -15,11 +15,17 @@
font-size: {{ template_options.font_size }}vw;
}
+ p {
+ float: left;
+ font-size: {{ template_options.font_size }}vw;
+ }
+
table {
-webkit-box-sizing: border-box;
box-sizing: border-box;
- border:max(1px, 0.1vw);
+ border-width: {{ template_options.borderwidth }}px;
border-style:solid;
+ border-color: {{ template_options.color6 }};
}
td {
@@ -32,57 +38,59 @@
}
.mainContainer {
- width: 96%;
- margin-left: 2%;
- margin-right: 2%;
+ width: 100%;
+ margin-left: 0%;
+ margin-right: 0%;
margin-top: 0%;
- margin-bottom: 0%;
+ margin-bottom: 2%;
overflow: hidden;
border-width: 0;
page-break-inside: avoid;
}
.innerContainer {
- width: 98%;
- padding: 1%;
+ width: 100%;
+ padding: 0%;
overflow: hidden;
}
.diveDetails {
- width: 98%;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- border:max(1px, 0.1vw);
- border-style:solid;
+ width: 100%;
float: left;
}
.dataSection {
- width: 98%;
- margin: 1%;
+ width: 100%;
}
.fieldTitle {
background-color: {{ template_options.color2 }};
overflow: hidden;
+ color: {{ template_options.color4 }};
+ }
+
+ .fieldData {
+ color: {{ template_options.color5 }};
+ background-color: {{ template_options.color3 }};
}
.table_class {
float: left;
- margin: 1%;
- width: 48%;
+ width: 49.25%;
+ margin: 0.5%;
}
.notes_table_class {
overflow: hidden;
- width: 98%;
- margin: 1%;
+ width: 99%;
+ margin: 0.5%;
}
.textArea {
line-height: {{ template_options.line_spacing }};
max-height: 19vh;
overflow: hidden;
+ color: {{ template_options.color4 }};
}
</style>
</head>
@@ -90,7 +98,7 @@
<div id="body_div">
{% block main_rows %}
{% for dive in dives %}
- <div class="mainContainer">
+ <div class="mainContainer dontbreak">
<div class="innerContainer">
<div class="diveDetails">
<div class="dataSection">
@@ -99,39 +107,40 @@
<td class="fieldTitle">
<h1> Dive No. </h1>
</td>
- <td>
- <h1> {{ dive.number }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.number }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Date </h1>
</td>
- <td><h1> {{ dive.date }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.date }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Location </h1>
</td>
- <td>
- <h1> {{ dive.location }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.location }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Max depth </h1>
</td>
- <td>
- <h1> {{ dive.depth }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.depth }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Duration </h1>
</td>
- <td>
- <h1> {{ dive.duration }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.duration }} </p>
</td>
</tr>
</tbody></table>
@@ -140,39 +149,40 @@
<td class="fieldTitle">
<h1> Time. </h1>
</td>
- <td>
- <h1> {{ dive.time }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.time }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Air Temp. </h1>
</td>
- <td><h1> {{ dive.airTemp }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.airTemp }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Water Temp. </h1>
</td>
- <td>
- <h1> {{ dive.waterTemp }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.waterTemp }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Buddy </h1>
</td>
- <td>
- <h1> {{ dive.buddy }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.buddy }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Dive Master </h1>
</td>
- <td>
- <h1> {{ dive.divemaster }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.divemaster }} </p>
</td>
</tr>
</tbody>
@@ -185,9 +195,9 @@
</td>
</tr>
<tr>
- <td>
+ <td class="fieldData">
<div class="textArea">
- <h1> {{ dive.notes }} </h1>
+ <p> {{ dive.notes }} </p>
</div>
</td>
</tr>
diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html
index 40c02b395..020c67b30 100644
--- a/printing_templates/One Dive.html
+++ b/printing_templates/One Dive.html
@@ -15,11 +15,17 @@
font-size: {{ template_options.font_size }}vw;
}
+ p {
+ float: left;
+ font-size: {{ template_options.font_size }}vw;
+ }
+
table {
-webkit-box-sizing: border-box;
box-sizing: border-box;
- border:max(1px, 0.1vw);
+ border-width: {{ template_options.borderwidth }}px;
border-style:solid;
+ border-color: {{ template_options.color6 }};
}
td {
@@ -32,10 +38,10 @@
}
.mainContainer {
- width: 96%;
+ width: 98%;
height: 100%;
- margin-left: 2%;
- margin-right: 2%;
+ margin-left: 1%;
+ margin-right: 1%;
margin-top: 0%;
margin-bottom: 0%;
overflow: hidden;
@@ -44,53 +50,56 @@
}
.innerContainer {
- width: 98%;
- height: 98%;
- padding: 1%;
+ width: 100%;
+ height: 99%;
+ padding-top: 1%;
overflow: hidden;
}
.diveDetails {
- width: 98%;
+ width: 100%;
height: 98%;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- border:max(1px, 0.1vw);
- border-style:solid;
float: left;
}
.diveProfile {
- width: 96%;
+ width: 99%;
height: 40%;
- margin: 2%;
+ margin: 0.5%;
}
.dataSection {
- width: 98%;
+ width: 100%;
height: 40%;
- margin: 1%;
+ margin: 0%;
}
.fieldTitle {
background-color: {{ template_options.color2 }};
overflow: hidden;
+ color: {{ template_options.color4 }};
+ }
+
+ .fieldData {
+ background-color: {{ template_options.color3 }};
+ color: {{ template_options.color5 }};
}
.table_class {
float: left;
- margin: 1%;
- width: 48%;
+ margin: 0.5%;
+ width: 49%;
}
.notes_table_class {
overflow: hidden;
- width: 98%;
- margin: 1%;
+ width: 99%;
+ margin: 0.5%;
}
.textArea {
line-height: {{ template_options.line_spacing }};
+ color: {{ template_options.color5 }};
max-height: 19vh;
overflow: hidden;
}
@@ -111,39 +120,40 @@
<td class="fieldTitle">
<h1> Dive No. </h1>
</td>
- <td>
- <h1> {{ dive.number }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.number }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Date </h1>
</td>
- <td><h1> {{ dive.date }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.date }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Location </h1>
</td>
- <td>
- <h1> {{ dive.location }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.location }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Max depth </h1>
</td>
- <td>
- <h1> {{ dive.depth }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.depth }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Duration </h1>
</td>
- <td>
- <h1> {{ dive.duration }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.duration }} </p>
</td>
</tr>
</tbody></table>
@@ -152,39 +162,40 @@
<td class="fieldTitle">
<h1> Time. </h1>
</td>
- <td>
- <h1> {{ dive.time }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.time }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Air Temp. </h1>
</td>
- <td><h1> {{ dive.airTemp }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.airTemp }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Water Temp. </h1>
</td>
- <td>
- <h1> {{ dive.waterTemp }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.waterTemp }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Buddy </h1>
</td>
- <td>
- <h1> {{ dive.buddy }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.buddy }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Dive Master </h1>
</td>
- <td>
- <h1> {{ dive.divemaster }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.divemaster }} </p>
</td>
</tr>
</tbody>
@@ -197,9 +208,9 @@
</td>
</tr>
<tr>
- <td>
+ <td class="fieldData">
<div class="textArea">
- <h1> {{ dive.notes }} </h1>
+ <p> {{ dive.notes }} </p>
</div>
</td>
</tr>
diff --git a/printing_templates/Six Dives.html b/printing_templates/Six Dives.html
new file mode 100644
index 000000000..3f2c7b95e
--- /dev/null
+++ b/printing_templates/Six Dives.html
@@ -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>
diff --git a/printing_templates/Table.html b/printing_templates/Table.html
index c97267405..e4d921fae 100644
--- a/printing_templates/Table.html
+++ b/printing_templates/Table.html
@@ -21,6 +21,11 @@
-webkit-column-break-inside: avoid;
padding-top: 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 {
@@ -28,10 +33,10 @@
}
.mainContainer {
- width: 96%;
+ width: 99%;
height: 100%;
- margin-left: 2%;
- margin-right: 2%;
+ margin-left: 0.5%;
+ margin-right: 0.5%;
margin-top: 0%;
margin-bottom: 0%;
overflow: hidden;
@@ -41,13 +46,8 @@
.table_class {
overflow: hidden;
- width: 97%;
- margin: 1.5%;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- border:max(0.1vw, 1px);
- border-style:solid;
- border-color: color: {{ template_options.color5 }};
+ width: 100%;
+ margin: 0%;
}
</style>
@@ -55,7 +55,7 @@
<body data-numberofdives = 0>
<div id="body_div">
<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>Date</th>
<th>Time</th>
@@ -66,7 +66,7 @@
</tr>
{% block main_rows %}
{% 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.date }}</th>
<th>{{ dive.time }}</th>
diff --git a/printing_templates/Two Dives.html b/printing_templates/Two Dives.html
index 5dba74303..95cc9a088 100644
--- a/printing_templates/Two Dives.html
+++ b/printing_templates/Two Dives.html
@@ -15,15 +15,20 @@
float: left;
}
+ p {
+ font-size: {{ template_options.font_size }}vw;
+ float: left;
+ }
+
#body_div {
background-color: {{ template_options.color1 }};
}
.mainContainer {
- width: 96%;
+ width: 99%;
height: 50%;
- margin-left: 2%;
- margin-right: 2%;
+ margin-left: 0.5%;
+ margin-right: 0.5%;
margin-top: 0;
margin-bottom: 0;
overflow: hidden;
@@ -32,68 +37,70 @@
.innerContainer {
height: 85%;
- padding: 0.5%;
margin-top: 1%;
margin-bottom: 1%;
overflow: hidden;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- border:max(0.1vw, 1px);
- border-style:solid;
}
.table_class {
overflow: hidden;
- max-width: 25%;
- min-width: 25%;
+ width: 25%;
+ height: 99%;
margin: 0.5%;
float: left;
-webkit-box-sizing: border-box;
box-sizing: border-box;
- border:max(0.1vw, 1px);
+ border-width: {{ template_options.borderwidth }}px;
border-style:solid;
+ border-color: {{ template_options.color6 }};
}
.notes_table_class {
overflow: hidden;
- max-width: 100%;
- min-width: 100%;
+ width: 99%;
margin: 0.5%;
- float: left;
-webkit-box-sizing: border-box;
box-sizing: border-box;
- border:max(0.1vw, 1px);
+ border-width: {{ template_options.borderwidth }}px;
border-style:solid;
+ border-color: {{ template_options.color6 }};
}
.fieldTitle {
background-color: {{ template_options.color2 }};
- overflow: hidden;
- padding:0;
+ color: {{ template_options.color4 }};
+ padding-left: 2%;
+ }
+
+ .fieldData {
+ color: {{ template_options.color5 }};
+ background-color: {{ template_options.color3 }};
+ padding-left: 2%;
}
.diveProfile {
- width: 48%;
- height: 95%;
- margin-left: 0%;
- margin-right: 0%;
- margin-bottom: 0%;
- margin-top: 0.5%;
- float: right;
+ float: left;
+ height: 99%;
+ width: 47%;
+ margin: 0.5%;
}
.diveDetails {
- width: 98.5%;
+ width: 100%;
float: left;
}
.dataPart {
- height: 45%;
- max-height: 60%;
+ height: 64%;
+ padding-bottom: 1%;
+ width: 100%;
+ float: left;
}
.notesPart {
height: 35%;
+ width: 100%;
+ float: left;
}
.textArea {
@@ -122,39 +129,40 @@
<td class="fieldTitle">
<h1> Dive No. </h1>
</td>
- <td>
- <h1> {{ dive.number }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.number }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Date </h1>
</td>
- <td><h1> {{ dive.date }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.date }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Location </h1>
</td>
- <td>
- <h1> {{ dive.location }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.location }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Max depth </h1>
</td>
- <td>
- <h1> {{ dive.depth }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.depth }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Duration </h1>
</td>
- <td>
- <h1> {{ dive.duration }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.duration }} </p>
</td>
</tr>
</tbody></table>
@@ -163,39 +171,40 @@
<td class="fieldTitle">
<h1> Time. </h1>
</td>
- <td>
- <h1> {{ dive.time }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.time }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Air Temp. </h1>
</td>
- <td><h1> {{ dive.airTemp }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.airTemp }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Water Temp. </h1>
</td>
- <td>
- <h1> {{ dive.waterTemp }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.waterTemp }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Buddy </h1>
</td>
- <td>
- <h1> {{ dive.buddy }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.buddy }} </p>
</td>
</tr>
<tr>
<td class="fieldTitle">
<h1> Dive Master </h1>
</td>
- <td>
- <h1> {{ dive.divemaster }} </h1>
+ <td class="fieldData">
+ <p> {{ dive.divemaster }} </p>
</td>
</tr>
</tbody></table>
@@ -205,14 +214,14 @@
<div class="notesPart">
<table class="notes_table_class">
<tbody><tr>
- <td class="fieldTitle">
+ <td style="padding-left:1%" class="fieldTitle">
<h1> Notes </h1>
</td>
</tr>
<tr>
- <td>
+ <td class="fieldData">
<div class="textArea">
- <h1> {{ dive.notes }} </h1>
+ <p> {{ dive.notes }} </p>
</div>
</td>
</tr>
@@ -224,7 +233,7 @@
{% endfor %}
{% endblock %}
<div id="footer">
-<div>
+</div>
</div>
</body>
</html>
diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp
index 6c50ae99b..002f9b9f4 100644
--- a/qt-ui/printdialog.cpp
+++ b/qt-ui/printdialog.cpp
@@ -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)
{
// 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.color3 = QColor::fromRgb(0x34, 0x65, 0xa4);
- ssrf_colors.color4 = QColor::fromRgb(0x20, 0x4a, 0x87);
- ssrf_colors.color5 = QColor::fromRgb(0x17, 0x37, 0x64);
- almond_colors.color1 = QColor::fromRgb(243, 234, 207);
+ ssrf_colors.color3 = QColor::fromRgb(0xef, 0xf7, 0xff);
+ ssrf_colors.color4 = QColor::fromRgb(0x34, 0x65, 0xa4);
+ ssrf_colors.color5 = QColor::fromRgb(0x20, 0x4a, 0x87);
+ 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.color3 = QColor::fromRgb(136, 160, 150);
- almond_colors.color4 = QColor::fromRgb(187, 171, 139);
- almond_colors.color5 = QColor::fromRgb(239, 130, 117);
- blueshades_colors.color1 = QColor::fromRgb(182, 192, 206);
+ almond_colors.color3 = QColor::fromRgb(243, 234, 207);
+ almond_colors.color4 = QColor::fromRgb(136, 160, 150);
+ almond_colors.color5 = QColor::fromRgb(187, 171, 139);
+ 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.color3 = QColor::fromRgb(31, 49, 75);
- blueshades_colors.color4 = QColor::fromRgb(21, 45, 84);
- blueshades_colors.color5 = QColor::fromRgb(5, 25, 56);
+ blueshades_colors.color3 = QColor::fromRgb(182, 192, 206);
+ blueshades_colors.color4 = QColor::fromRgb(31, 49, 75);
+ 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.
QSettings s;
@@ -164,13 +167,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 +176,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 +184,7 @@ void PrintDialog::printClicked(void)
printer->print();
break;
case print_options::STATISTICS:
+ printer->print_statistics();
break;
}
close();
@@ -204,7 +194,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)));
}
diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp
index 1da95a94d..419098cf8 100644
--- a/qt-ui/printoptions.cpp
+++ b/qt-ui/printoptions.cpp
@@ -64,17 +64,39 @@ void PrintOptions::setup()
}
// print type radio buttons
-void PrintOptions::on_radioDiveListPrint_clicked(bool check)
+void PrintOptions::on_radioDiveListPrint_toggled(bool check)
{
if (check) {
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) {
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);
}
}
diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h
index 4903da09f..6d7ffffee 100644
--- a/qt-ui/printoptions.h
+++ b/qt-ui/printoptions.h
@@ -19,6 +19,7 @@ struct print_options {
struct template_options {
int font_index;
int color_palette_index;
+ int border_width;
double font_size;
double line_spacing;
struct color_palette_struct {
@@ -27,12 +28,14 @@ struct template_options {
QColor color3;
QColor color4;
QColor color5;
+ QColor color6;
bool operator!=(const color_palette_struct &other) const {
return other.color1 != color1
|| other.color2 != color2
|| other.color3 != color3
|| other.color4 != color4
- || other.color5 != color5;
+ || other.color5 != color5
+ || other.color6 != color6;
}
} color_palette;
bool operator!=(const template_options &other) const {
@@ -72,8 +75,8 @@ private
slots:
void printInColorClicked(bool check);
void printSelectedClicked(bool check);
- void on_radioStatisticsPrint_clicked(bool check);
- void on_radioDiveListPrint_clicked(bool check);
+ void on_radioStatisticsPrint_toggled(bool check);
+ void on_radioDiveListPrint_toggled(bool check);
void on_printTemplate_currentIndexChanged(int index);
void on_editButton_clicked();
void on_importButton_clicked();
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 400401655..c776f9fea 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -627,6 +627,17 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
eventItems.clear();
struct event *event = currentdc->events;
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();
item->setHorizontalAxis(timeAxis);
item->setVerticalAxis(profileYAxis);
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp
index 94ed276b5..e4e6453ac 100644
--- a/qt-ui/templateedit.cpp
+++ b/qt-ui/templateedit.cpp
@@ -30,9 +30,11 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions,
btnGroup->addButton(ui->editButton3, 3);
btnGroup->addButton(ui->editButton4, 4);
btnGroup->addButton(ui->editButton5, 5);
+ btnGroup->addButton(ui->editButton6, 6);
connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(colorSelect(QAbstractButton*)));
ui->plainTextEdit->setPlainText(grantlee_template);
+ editingCustomColors = false;
updatePreview();
}
@@ -59,12 +61,14 @@ void TemplateEdit::updatePreview()
ui->colorLable3->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color3.name() + "\";}");
ui->colorLable4->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color4.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->colorLable2->setText(newTemplateOptions.color_palette.color2.name());
ui->colorLable3->setText(newTemplateOptions.color_palette.color3.name());
ui->colorLable4->setText(newTemplateOptions.color_palette.color4.name());
ui->colorLable5->setText(newTemplateOptions.color_palette.color5.name());
+ ui->colorLable6->setText(newTemplateOptions.color_palette.color6.name());
// update critical UI elements
ui->colorpalette->setCurrentIndex(newTemplateOptions.color_palette_index);
@@ -102,7 +106,10 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int index)
newTemplateOptions.color_palette = blueshades_colors;
break;
case CUSTOM: // custom
- newTemplateOptions.color_palette = custom_colors;
+ if (!editingCustomColors)
+ newTemplateOptions.color_palette = custom_colors;
+ else
+ editingCustomColors = false;
break;
}
updatePreview();
@@ -121,7 +128,7 @@ void TemplateEdit::saveSettings()
printOptions->p_template = "custom.html";
TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText());
}
- if (templateOptions->color_palette_index == 2) {
+ if (templateOptions->color_palette_index == CUSTOM) {
custom_colors = templateOptions->color_palette;
}
}
@@ -148,6 +155,7 @@ void TemplateEdit::on_buttonBox_clicked(QAbstractButton *button)
void TemplateEdit::colorSelect(QAbstractButton *button)
{
+ editingCustomColors = true;
// reset custom colors palette
switch (newTemplateOptions.color_palette_index) {
case SSRF_COLORS: // subsurface derived default colors
@@ -155,11 +163,11 @@ void TemplateEdit::colorSelect(QAbstractButton *button)
break;
case ALMOND: // almond
newTemplateOptions.color_palette = almond_colors;
- custom_colors = newTemplateOptions.color_palette;
break;
case BLUESHADES: // blueshades
newTemplateOptions.color_palette = blueshades_colors;
- custom_colors = newTemplateOptions.color_palette;
+ break;
+ default:
break;
}
@@ -168,24 +176,35 @@ void TemplateEdit::colorSelect(QAbstractButton *button)
switch (btnGroup->id(button)) {
case 1:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color1, this);
- newTemplateOptions.color_palette.color1 = color;
+ if (color.isValid()) {
+ newTemplateOptions.color_palette.color1 = color;
+ }
break;
case 2:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color2, this);
- newTemplateOptions.color_palette.color2 = color;
- break;
+ if (color.isValid()) {
+ newTemplateOptions.color_palette.color2 = color;
+ } break;
case 3:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color3, this);
- newTemplateOptions.color_palette.color3 = color;
- break;
+ if (color.isValid()) {
+ newTemplateOptions.color_palette.color3 = color;
+ } break;
case 4:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color4, this);
- newTemplateOptions.color_palette.color4 = color;
- break;
+ if (color.isValid()) {
+ newTemplateOptions.color_palette.color4 = color;
+ } break;
case 5:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color5, this);
- newTemplateOptions.color_palette.color5 = color;
- break;
+ if (color.isValid()) {
+ 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;
updatePreview();
diff --git a/qt-ui/templateedit.h b/qt-ui/templateedit.h
index 15b717f78..5e548ae19 100644
--- a/qt-ui/templateedit.h
+++ b/qt-ui/templateedit.h
@@ -31,6 +31,7 @@ private slots:
private:
Ui::TemplateEdit *ui;
QButtonGroup *btnGroup;
+ bool editingCustomColors;
struct template_options *templateOptions;
struct template_options newTemplateOptions;
struct print_options *printOptions;
diff --git a/qt-ui/templateedit.ui b/qt-ui/templateedit.ui
index 238e69290..322193cc6 100644
--- a/qt-ui/templateedit.ui
+++ b/qt-ui/templateedit.ui
@@ -317,7 +317,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Table cells</string>
+ <string>Table cells 1</string>
</property>
</widget>
</item>
@@ -347,9 +347,9 @@
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
- <widget class="QLabel" name="label_7">
+ <widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -357,7 +357,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Text 1</string>
+ <string>Table cells 2</string>
</property>
</widget>
</item>
@@ -387,9 +387,9 @@
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
- <widget class="QLabel" name="label_11">
+ <widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -397,7 +397,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Text 2</string>
+ <string>Text 1</string>
</property>
</widget>
</item>
@@ -427,9 +427,9 @@
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
- <widget class="QLabel" name="label_4">
+ <widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -437,7 +437,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Borders</string>
+ <string>Text 2</string>
</property>
</widget>
</item>
@@ -467,6 +467,46 @@
</layout>
</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>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/templatelayout.cpp b/templatelayout.cpp
index 1da88249b..b0098fbd9 100644
--- a/templatelayout.cpp
+++ b/templatelayout.cpp
@@ -188,10 +188,30 @@ QString Dive::notes() const
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()
{
if (!dive->divemaster)
- m_divemaster = "";
+ m_divemaster = "--";
else
m_divemaster = dive->divemaster;
}
@@ -207,6 +227,9 @@ void Dive::put_date_time()
void Dive::put_location()
{
m_location = QString::fromUtf8(get_dive_location(dive));
+ if (m_location.isEmpty()) {
+ m_location = "--";
+ }
}
void Dive::put_depth()
@@ -222,7 +245,7 @@ void Dive::put_duration()
void Dive::put_buddy()
{
if (!dive->buddy)
- m_buddy = "";
+ m_buddy = "--";
else
m_buddy = dive->buddy;
}
@@ -231,9 +254,55 @@ void Dive::put_temp()
{
m_airTemp = get_temperature_string(dive->airtemp, 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()
{
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);
+ }
}
diff --git a/templatelayout.h b/templatelayout.h
index c545f5a05..41a3cbfa9 100644
--- a/templatelayout.h
+++ b/templatelayout.h
@@ -32,6 +32,7 @@ class Dive {
private:
int m_number;
int m_id;
+ int m_rating;
QString m_date;
QString m_time;
QString m_location;
@@ -42,6 +43,9 @@ private:
QString m_airTemp;
QString m_waterTemp;
QString m_notes;
+ QString m_tags;
+ QString m_gas;
+ QString m_sac;
struct dive *dive;
void put_date_time();
void put_location();
@@ -51,6 +55,9 @@ private:
void put_buddy();
void put_temp();
void put_notes();
+ void put_tags();
+ void put_gas();
+ void put_sac();
public:
Dive(struct dive *dive)
@@ -58,6 +65,7 @@ public:
{
m_number = dive->number;
m_id = dive->id;
+ m_rating = dive->rating;
put_date_time();
put_location();
put_duration();
@@ -66,11 +74,15 @@ public:
put_buddy();
put_temp();
put_notes();
+ put_tags();
+ put_gas();
+ put_sac();
}
Dive();
~Dive();
int number() const;
int id() const;
+ int rating() const;
QString date() const;
QString time() const;
QString location() const;
@@ -81,6 +93,9 @@ public:
QString airTemp() const;
QString waterTemp() const;
QString notes() const;
+ QString tags() const;
+ QString gas() const;
+ QString sac() const;
};
Q_DECLARE_METATYPE(Dive)
@@ -112,6 +127,14 @@ else if (property == "waterTemp")
return object.waterTemp();
else if (property == "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_BEGIN_LOOKUP(template_options)
@@ -128,6 +151,8 @@ if (property == "font") {
case 4:
return "Verdana, Geneva, sans-serif";
}
+} else if (property == "borderwidth") {
+ return object.border_width;
} else if (property == "font_size") {
return object.font_size / 9.0;
} else if (property == "line_spacing") {
@@ -142,6 +167,8 @@ if (property == "font") {
return object.color_palette.color4.name();
} else if (property == "color5") {
return object.color_palette.color5.name();
+} else if (property == "color6") {
+ return object.color_palette.color6.name();
}
GRANTLEE_END_LOOKUP