diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/CMakeLists.txt | 104 | ||||
-rw-r--r-- | qt-ui/printer.cpp | 273 | ||||
-rw-r--r-- | qt-ui/printer.h | 48 | ||||
-rw-r--r-- | qt-ui/templatelayout.cpp | 182 | ||||
-rw-r--r-- | qt-ui/templatelayout.h | 168 |
5 files changed, 775 insertions, 0 deletions
diff --git a/qt-ui/CMakeLists.txt b/qt-ui/CMakeLists.txt new file mode 100644 index 000000000..9def39ff3 --- /dev/null +++ b/qt-ui/CMakeLists.txt @@ -0,0 +1,104 @@ +# create the libraries +file(GLOB SUBSURFACE_UI *.ui) +qt5_wrap_ui(SUBSURFACE_UI_HDRS ${SUBSURFACE_UI}) +qt5_add_resources(SUBSURFACE_RESOURCES subsurface.qrc) +source_group("Subsurface Interface Files" FILES ${SUBSURFACE_UI}) + +# the interface, in C++ +set(SUBSURFACE_INTERFACE + updatemanager.cpp + about.cpp + divecomputermanagementdialog.cpp + divelistview.cpp + diveplanner.cpp + diveshareexportdialog.cpp + downloadfromdivecomputer.cpp + globe.cpp + graphicsview-common.cpp + kmessagewidget.cpp + maintab.cpp + mainwindow.cpp + modeldelegates.cpp + metrics.cpp + notificationwidget.cpp + preferences.cpp + simplewidgets.cpp + starwidget.cpp + subsurfacewebservices.cpp + tableview.cpp + divelogimportdialog.cpp + tagwidget.cpp + groupedlineedit.cpp + divelogexportdialog.cpp + divepicturewidget.cpp + usersurvey.cpp + configuredivecomputerdialog.cpp + undocommands.cpp + locationinformation.cpp + qtwaitingspinner.cpp +) + +if(NOT NO_USERMANUAL) + set(SUBSURFACE_INTERFACE ${SUBSURFACE_INTERFACE} + usermanual.cpp + ) +endif() + +if(NOT NO_PRINTING) + set(SUBSURFACE_INTERFACE ${SUBSURFACE_INTERFACE} + templateedit.cpp + printdialog.cpp + printoptions.cpp + printer.cpp + templatelayout.cpp + ) +endif() + +if (FBSUPPORT) + set(SUBSURFACE_INTERFACE ${SUBSURFACE_INTERFACE} + socialnetworks.cpp + ) +endif() + +if (BTSUPPORT) + set(SUBSURFACE_INTERFACE ${SUBSURFACE_INTERFACE} + btdeviceselectiondialog.cpp + ) +endif() + +source_group("Subsurface Interface" FILES ${SUBSURFACE_INTERFACE}) + +# the profile widget +set(SUBSURFACE_PROFILE_LIB_SRCS + profile/profilewidget2.cpp + profile/diverectitem.cpp + profile/divepixmapitem.cpp + profile/divelineitem.cpp + profile/divetextitem.cpp + profile/animationfunctions.cpp + profile/divecartesianaxis.cpp + profile/diveprofileitem.cpp + profile/diveeventitem.cpp + profile/divetooltipitem.cpp + profile/ruleritem.cpp + profile/tankitem.cpp +) +source_group("Subsurface Profile" FILES ${SUBSURFACE_PROFILE_LIB_SRCS}) + +# the yearly statistics widget. +set(SUBSURFACE_STATISTICS_LIB_SRCS + statistics/statisticswidget.cpp + statistics/yearstatistics.cpp + statistics/statisticsbar.cpp + statistics/monthstatistics.cpp +) +source_group("Subsurface Statistics" FILES ${SUBSURFACE_STATISTICS_LIB_SRCS}) + +add_library(subsurface_profile STATIC ${SUBSURFACE_PROFILE_LIB_SRCS}) +target_link_libraries(subsurface_profile ${QT_LIBRARIES}) +add_library(subsurface_statistics STATIC ${SUBSURFACE_STATISTICS_LIB_SRCS}) +target_link_libraries(subsurface_statistics ${QT_LIBRARIES}) +add_library(subsurface_generated_ui STATIC ${SUBSURFACE_UI_HDRS}) +target_link_libraries(subsurface_generated_ui ${QT_LIBRARIES}) +add_library(subsurface_interface STATIC ${SUBSURFACE_INTERFACE}) +target_link_libraries(subsurface_interface ${QT_LIBRARIES} ${MARBLE_LIBRARIES}) diff --git a/qt-ui/printer.cpp b/qt-ui/printer.cpp new file mode 100644 index 000000000..f0197d446 --- /dev/null +++ b/qt-ui/printer.cpp @@ -0,0 +1,273 @@ +#include "printer.h" +#include "templatelayout.h" +#include "statistics.h" +#include "helpers.h" + +#include <algorithm> +#include <QtWebKitWidgets> +#include <QPainter> +#include <QWebElementCollection> +#include <QWebElement> + +Printer::Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode) +{ + this->paintDevice = paintDevice; + this->printOptions = printOptions; + this->templateOptions = templateOptions; + this->printMode = printMode; + dpi = 0; + done = 0; + webView = new QWebView(); +} + +Printer::~Printer() +{ + delete webView; +} + +void Printer::putProfileImage(QRect profilePlaceholder, QRect viewPort, QPainter *painter, struct dive *dive, QPointer<ProfileWidget2> profile) +{ + int x = profilePlaceholder.x() - viewPort.x(); + int y = profilePlaceholder.y() - viewPort.y(); + // use the placeHolder and the viewPort position to calculate the relative position of the dive profile. + QRect pos(x, y, profilePlaceholder.width(), profilePlaceholder.height()); + profile->plotDive(dive, true); + + if (!printOptions->color_selected) { + QImage image(pos.width(), pos.height(), QImage::Format_ARGB32); + QPainter imgPainter(&image); + imgPainter.setRenderHint(QPainter::Antialiasing); + imgPainter.setRenderHint(QPainter::SmoothPixmapTransform); + profile->render(&imgPainter, QRect(0, 0, pos.width(), pos.height())); + imgPainter.end(); + + // convert QImage to grayscale before rendering + for (int i = 0; i < image.height(); i++) { + QRgb *pixel = reinterpret_cast<QRgb *>(image.scanLine(i)); + QRgb *end = pixel + image.width(); + for (; pixel != end; pixel++) { + int gray_val = qGray(*pixel); + *pixel = QColor(gray_val, gray_val, gray_val).rgb(); + } + } + + painter->drawImage(pos, image); + } else { + profile->render(painter, pos); + } +} + +void Printer::flowRender() +{ + // 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); + + // 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)); + + // add new pages only in print mode, while previewing we don't add new pages + if (printMode == Printer::PRINT) + static_cast<QPrinter*>(paintDevice)->newPage(); + else { + painter.end(); + return; + } + 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 + QPointer<ProfileWidget2> profile = MainWindow::instance()->graphics(); + int profileFrameStyle = profile->frameStyle(); + int animationOriginal = prefs.animation_speed; + double fontScale = profile->getFontPrintScale(); + double printFontScale = 1.0; + + // apply printing settings to profile + profile->setFrameStyle(QFrame::NoFrame); + profile->setPrintMode(true, !printOptions->color_selected); + profile->setToolTipVisibile(false); + prefs.animation_speed = 0; + + // render the Qwebview + QPainter painter; + QRect viewPort(0, 0, pageSize.width(), pageSize.height()); + painter.begin(paintDevice); + painter.setRenderHint(QPainter::Antialiasing); + painter.setRenderHint(QPainter::SmoothPixmapTransform); + + // get all refereces to diveprofile class in the Html template + QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile"); + + QSize originalSize = profile->size(); + if (collection.count() > 0) { + printFontScale = (double)collection.at(0).geometry().size().height() / (double)profile->size().height(); + profile->resize(collection.at(0).geometry().size()); + } + profile->setFontPrintScale(printFontScale); + + int elemNo = 0; + for (int i = 0; i < Pages; i++) { + // render the base Html template + webView->page()->mainFrame()->render(&painter, QWebFrame::ContentsLayer); + + // render all the dive profiles in the current page + while (elemNo < collection.count() && collection.at(elemNo).geometry().y() < viewPort.y() + viewPort.height()) { + // dive id field should be dive_{{dive_no}} se we remove the first 5 characters + QString diveIdString = collection.at(elemNo).attribute("id"); + int diveId = diveIdString.remove(0, 5).toInt(0, 10); + putProfileImage(collection.at(elemNo).geometry(), viewPort, &painter, get_dive_by_uniq_id(diveId), profile); + elemNo++; + } + + // scroll the webview to the next page + webView->page()->mainFrame()->scroll(0, pageSize.height()); + viewPort.adjust(0, pageSize.height(), 0, pageSize.height()); + + // rendering progress is 4/5 of total work + emit(progessUpdated((i * 80.0 / Pages) + done)); + if (i < Pages - 1 && printMode == Printer::PRINT) + static_cast<QPrinter*>(paintDevice)->newPage(); + } + painter.end(); + + // return profle settings + profile->setFrameStyle(profileFrameStyle); + profile->setPrintMode(false); + profile->setFontPrintScale(fontScale); + profile->setToolTipVisibile(true); + profile->resize(originalSize); + prefs.animation_speed = animationOriginal; + + //replot the dive after returning the settings + profile->plotDive(0, true); +} + +//value: ranges from 0 : 100 and shows the progress of the templating engine +void Printer::templateProgessUpdated(int value) +{ + done = value / 5; //template progess if 1/5 of total work + emit progessUpdated(done); +} + +void Printer::print() +{ + // we can only print if "PRINT" mode is selected + if (printMode != Printer::PRINT) { + return; + } + + + QPrinter *printerPtr; + printerPtr = static_cast<QPrinter*>(paintDevice); + + TemplateLayout t(printOptions, templateOptions); + connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int))); + dpi = printerPtr->resolution(); + //rendering resolution = selected paper size in inchs * printer dpi + pageSize.setHeight(qCeil(printerPtr->pageRect(QPrinter::Inch).height() * dpi)); + pageSize.setWidth(qCeil(printerPtr->pageRect(QPrinter::Inch).width() * dpi)); + 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); + if (printOptions->type == print_options::DIVELIST) { + webView->setHtml(t.generate()); + } else if (printOptions->type == print_options::STATISTICS ) { + webView->setHtml(t.generateStatistics()); + } + if (printOptions->color_selected && printerPtr->colorMode()) { + printerPtr->setColorMode(QPrinter::Color); + } else { + printerPtr->setColorMode(QPrinter::GrayScale); + } + // apply user settings + int divesPerPage; + + // get number of dives per page from data-numberofdives attribute in the body of the selected template + bool ok; + divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok); + if (!ok) { + divesPerPage = 1; // print each dive in a single page if the attribute is missing or malformed + //TODO: show warning + } + int Pages; + if (divesPerPage == 0) { + flowRender(); + } else { + Pages = qCeil(getTotalWork(printOptions) / (float)divesPerPage); + render(Pages); + } +} + +void Printer::previewOnePage() +{ + if (printMode == PREVIEW) { + TemplateLayout t(printOptions, templateOptions); + + pageSize.setHeight(paintDevice->height()); + pageSize.setWidth(paintDevice->width()); + webView->page()->setViewportSize(pageSize); + // initialize the border settings + templateOptions->border_width = std::max(1, pageSize.width() / 1000); + if (printOptions->type == print_options::DIVELIST) { + webView->setHtml(t.generate()); + } else if (printOptions->type == print_options::STATISTICS ) { + webView->setHtml(t.generateStatistics()); + } + + bool ok; + int divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok); + if (!ok) { + divesPerPage = 1; // print each dive in a single page if the attribute is missing or malformed + //TODO: show warning + } + if (divesPerPage == 0) { + flowRender(); + } else { + render(1); + } + } +} diff --git a/qt-ui/printer.h b/qt-ui/printer.h new file mode 100644 index 000000000..979cacd6a --- /dev/null +++ b/qt-ui/printer.h @@ -0,0 +1,48 @@ +#ifndef PRINTER_H +#define PRINTER_H + +#include <QPrinter> +#include <QWebView> +#include <QRect> +#include <QPainter> + +#include "profile/profilewidget2.h" +#include "printoptions.h" +#include "templateedit.h" + +class Printer : public QObject { + Q_OBJECT + +public: + enum PrintMode { + PRINT, + PREVIEW + }; + +private: + QPaintDevice *paintDevice; + QWebView *webView; + print_options *printOptions; + template_options *templateOptions; + QSize pageSize; + PrintMode printMode; + 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: + void templateProgessUpdated(int value); + +public: + Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode); + ~Printer(); + void print(); + void previewOnePage(); + +signals: + void progessUpdated(int value); +}; + +#endif //PRINTER_H diff --git a/qt-ui/templatelayout.cpp b/qt-ui/templatelayout.cpp new file mode 100644 index 000000000..a376459a6 --- /dev/null +++ b/qt-ui/templatelayout.cpp @@ -0,0 +1,182 @@ +#include <string> + +#include "templatelayout.h" +#include "helpers.h" +#include "display.h" + +QList<QString> grantlee_templates, grantlee_statistics_templates; + +int getTotalWork(print_options *printOptions) +{ + if (printOptions->print_selected) { + // return the correct number depending on all/selected dives + // but don't return 0 as we might divide by this number + return amount_selected ? amount_selected : 1; + } + int dives = 0, i; + struct dive *dive; + for_each_dive (i, dive) { + dives++; + } + return dives; +} + +void find_all_templates() +{ + grantlee_templates.clear(); + grantlee_statistics_templates.clear(); + QDir dir(getPrintingTemplatePathUser()); + QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot); + foreach (QFileInfo finfo, list) { + QString filename = finfo.fileName(); + if (filename.at(filename.size() - 1) != '~') { + grantlee_templates.append(finfo.fileName()); + } + } + // find statistics templates + dir.setPath(getPrintingTemplatePathUser() + QDir::separator() + "statistics"); + list = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot); + foreach (QFileInfo finfo, list) { + QString filename = finfo.fileName(); + if (filename.at(filename.size() - 1) != '~') { + grantlee_statistics_templates.append(finfo.fileName()); + } + } +} + +TemplateLayout::TemplateLayout(print_options *PrintOptions, template_options *templateOptions) : + m_engine(NULL) +{ + this->PrintOptions = PrintOptions; + this->templateOptions = templateOptions; +} + +TemplateLayout::~TemplateLayout() +{ + delete m_engine; +} + +QString TemplateLayout::generate() +{ + int progress = 0; + int totalWork = getTotalWork(PrintOptions); + + QString htmlContent; + m_engine = new Grantlee::Engine(this); + + QSharedPointer<Grantlee::FileSystemTemplateLoader> m_templateLoader = + QSharedPointer<Grantlee::FileSystemTemplateLoader>(new Grantlee::FileSystemTemplateLoader()); + m_templateLoader->setTemplateDirs(QStringList() << getPrintingTemplatePathUser()); + m_engine->addTemplateLoader(m_templateLoader); + + Grantlee::registerMetaType<Dive>(); + Grantlee::registerMetaType<template_options>(); + Grantlee::registerMetaType<print_options>(); + + QVariantList diveList; + + struct dive *dive; + int i; + for_each_dive (i, dive) { + //TODO check for exporting selected dives only + if (!dive->selected && PrintOptions->print_selected) + continue; + Dive d(dive); + diveList.append(QVariant::fromValue(d)); + progress++; + emit progressUpdated(progress * 100.0 / totalWork); + } + Grantlee::Context c; + c.insert("dives", diveList); + c.insert("template_options", QVariant::fromValue(*templateOptions)); + c.insert("print_options", QVariant::fromValue(*PrintOptions)); + + Grantlee::Template t = m_engine->loadByName(PrintOptions->p_template); + if (!t || t->error()) { + qDebug() << "Can't load template"; + return htmlContent; + } + + htmlContent = t->render(&c); + + if (t->error()) { + qDebug() << "Can't render template"; + return htmlContent; + } + return htmlContent; +} + +QString TemplateLayout::generateStatistics() +{ + QString htmlContent; + m_engine = new Grantlee::Engine(this); + + QSharedPointer<Grantlee::FileSystemTemplateLoader> m_templateLoader = + QSharedPointer<Grantlee::FileSystemTemplateLoader>(new Grantlee::FileSystemTemplateLoader()); + m_templateLoader->setTemplateDirs(QStringList() << getPrintingTemplatePathUser() + QDir::separator() + QString("statistics")); + m_engine->addTemplateLoader(m_templateLoader); + + Grantlee::registerMetaType<YearInfo>(); + Grantlee::registerMetaType<template_options>(); + Grantlee::registerMetaType<print_options>(); + + QVariantList years; + + int i = 0; + while (stats_yearly != NULL && stats_yearly[i].period) { + YearInfo year(stats_yearly[i]); + years.append(QVariant::fromValue(year)); + i++; + } + + Grantlee::Context c; + c.insert("years", years); + c.insert("template_options", QVariant::fromValue(*templateOptions)); + c.insert("print_options", QVariant::fromValue(*PrintOptions)); + + Grantlee::Template t = m_engine->loadByName(PrintOptions->p_template); + if (!t || t->error()) { + qDebug() << "Can't load template"; + return htmlContent; + } + + htmlContent = t->render(&c); + + if (t->error()) { + qDebug() << "Can't render template"; + return htmlContent; + } + + emit progressUpdated(100); + return htmlContent; +} + +QString TemplateLayout::readTemplate(QString template_name) +{ + QFile qfile(getPrintingTemplatePathUser() + QDir::separator() + template_name); + if (qfile.open(QFile::ReadOnly | QFile::Text)) { + QTextStream in(&qfile); + return in.readAll(); + } + return ""; +} + +void TemplateLayout::writeTemplate(QString template_name, QString grantlee_template) +{ + QFile qfile(getPrintingTemplatePathUser() + QDir::separator() + template_name); + if (qfile.open(QFile::ReadWrite | QFile::Text)) { + qfile.write(grantlee_template.toUtf8().data()); + qfile.resize(qfile.pos()); + qfile.close(); + } +} + +YearInfo::YearInfo() +{ + +} + +YearInfo::~YearInfo() +{ + +} diff --git a/qt-ui/templatelayout.h b/qt-ui/templatelayout.h new file mode 100644 index 000000000..a2868e7ff --- /dev/null +++ b/qt-ui/templatelayout.h @@ -0,0 +1,168 @@ +#ifndef TEMPLATELAYOUT_H +#define TEMPLATELAYOUT_H + +#include <grantlee_templates.h> +#include "mainwindow.h" +#include "printoptions.h" +#include "statistics.h" +#include "qthelper.h" +#include "helpers.h" + +int getTotalWork(print_options *printOptions); +void find_all_templates(); + +extern QList<QString> grantlee_templates, grantlee_statistics_templates; + +class TemplateLayout : public QObject { + Q_OBJECT +public: + TemplateLayout(print_options *PrintOptions, template_options *templateOptions); + ~TemplateLayout(); + QString generate(); + QString generateStatistics(); + static QString readTemplate(QString template_name); + static void writeTemplate(QString template_name, QString grantlee_template); + +private: + Grantlee::Engine *m_engine; + print_options *PrintOptions; + template_options *templateOptions; + +signals: + void progressUpdated(int value); +}; + +class YearInfo { +public: + stats_t *year; + YearInfo(stats_t& year) + :year(&year) + { + + } + YearInfo(); + ~YearInfo(); +}; + +Q_DECLARE_METATYPE(Dive) +Q_DECLARE_METATYPE(template_options) +Q_DECLARE_METATYPE(print_options) +Q_DECLARE_METATYPE(YearInfo) + +GRANTLEE_BEGIN_LOOKUP(Dive) +if (property == "number") + return object.number(); +else if (property == "id") + return object.id(); +else if (property == "date") + return object.date(); +else if (property == "time") + return object.time(); +else if (property == "location") + return object.location(); +else if (property == "duration") + return object.duration(); +else if (property == "depth") + return object.depth(); +else if (property == "divemaster") + return object.divemaster(); +else if (property == "buddy") + return object.buddy(); +else if (property == "airTemp") + return object.airTemp(); +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) +if (property == "font") { + switch (object.font_index) { + case 0: + return "Arial, Helvetica, sans-serif"; + case 1: + return "Impact, Charcoal, sans-serif"; + case 2: + return "Georgia, serif"; + case 3: + return "Courier, monospace"; + 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") { + return object.line_spacing; +} else if (property == "color1") { + return object.color_palette.color1.name(); +} else if (property == "color2") { + return object.color_palette.color2.name(); +} else if (property == "color3") { + return object.color_palette.color3.name(); +} else if (property == "color4") { + 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 + +GRANTLEE_BEGIN_LOOKUP(print_options) +if (property == "grayscale") { + if (object.color_selected) { + return ""; + } else { + return "-webkit-filter: grayscale(100%)"; + } +} +GRANTLEE_END_LOOKUP + +GRANTLEE_BEGIN_LOOKUP(YearInfo) +if (property == "year") { + return object.year->period; +} else if (property == "dives") { + return object.year->selection_size; +} else if (property == "min_temp") { + const char *unit; + double temp = get_temp_units(object.year->min_temp, &unit); + return object.year->min_temp == 0 ? "0" : QString::number(temp, 'g', 2) + unit; +} else if (property == "max_temp") { + const char *unit; + double temp = get_temp_units(object.year->max_temp, &unit); + return object.year->max_temp == 0 ? "0" : QString::number(temp, 'g', 2) + unit; +} else if (property == "total_time") { + return get_time_string(object.year->total_time.seconds, 0); +} else if (property == "avg_time") { + return get_minutes(object.year->total_time.seconds / object.year->selection_size); +} else if (property == "shortest_time") { + return get_minutes(object.year->shortest_time.seconds); +} else if (property == "longest_time") { + return get_minutes(object.year->longest_time.seconds); +} else if (property == "avg_depth") { + return get_depth_string(object.year->avg_depth); +} else if (property == "min_depth") { + return get_depth_string(object.year->min_depth); +} else if (property == "max_depth") { + return get_depth_string(object.year->max_depth); +} else if (property == "avg_sac") { + return get_volume_string(object.year->avg_sac); +} else if (property == "min_sac") { + return get_volume_string(object.year->min_sac); +} else if (property == "max_sac") { + return get_volume_string(object.year->max_sac); +} +GRANTLEE_END_LOOKUP + +#endif |