mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Printing: retrieve number of dives per page from the template file
Add special data attribute 'data-numberofdives' in the template <body> with the number of dives per page. This is standard HTML5 specification so it won't corrupt the template file. Any template that will be used for printing must contain this attribute to assure correct output. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
6446b75b9e
commit
815072d2ae
3 changed files with 9 additions and 9 deletions
14
printer.cpp
14
printer.cpp
|
@ -34,13 +34,13 @@ void Printer::render()
|
||||||
} else {
|
} else {
|
||||||
printer->setColorMode(QPrinter::GrayScale);
|
printer->setColorMode(QPrinter::GrayScale);
|
||||||
}
|
}
|
||||||
switch (printOptions->p_template) {
|
|
||||||
case print_options::ONE_DIVE:
|
// get number of dives per page from data-numberofdives attribute in the body of the selected template
|
||||||
divesPerPage = 1;
|
bool ok;
|
||||||
break;
|
divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok);
|
||||||
case print_options::TWO_DIVE:
|
if (!ok) {
|
||||||
divesPerPage = 2;
|
divesPerPage = 1; // print each dive in a single page if the attribute is missing or malformed
|
||||||
break;
|
//TODO: show warning
|
||||||
}
|
}
|
||||||
int Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage);
|
int Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage);
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body data-numberofdives = 1>
|
||||||
{% block main_rows %}
|
{% block main_rows %}
|
||||||
{% for dive in dives %}
|
{% for dive in dives %}
|
||||||
<div class="mainContainer">
|
<div class="mainContainer">
|
||||||
|
|
|
@ -102,7 +102,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body data-numberofdives = 2>
|
||||||
{% block main_rows %}
|
{% block main_rows %}
|
||||||
{% for dive in dives %}
|
{% for dive in dives %}
|
||||||
<div class="mainContainer">
|
<div class="mainContainer">
|
||||||
|
|
Loading…
Add table
Reference in a new issue