From 6a692495c024876d74145df8b67734323ec348b6 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 21 Aug 2015 18:07:30 +0200 Subject: Printing: add statistics templates to the dialog Show the existing templates based on the print type selected by the user. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/printoptions.cpp | 57 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 15 deletions(-) (limited to 'qt-ui/printoptions.cpp') diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp index 419098cf8..70cd89711 100644 --- a/qt-ui/printoptions.cpp +++ b/qt-ui/printoptions.cpp @@ -31,21 +31,7 @@ void PrintOptions::setup() break; } - // insert existing templates in the UI and select the current template - qSort(grantlee_templates); - int current_index = 0, index = 0; - for (QList::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { - if ((*i).compare(printOptions->p_template) == 0) { - current_index = index; - break; - } - index++; - } - ui.printTemplate->clear(); - for (QList::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { - ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i)); - } - ui.printTemplate->setCurrentIndex(current_index); + setupTemplates(); // general print option checkboxes if (printOptions->color_selected) @@ -63,6 +49,43 @@ void PrintOptions::setup() hasSetupSlots = true; } +void PrintOptions::setupTemplates() +{ + if (printOptions->type == print_options::DIVELIST) { + // insert dive list templates in the UI and select the current template + qSort(grantlee_templates); + int current_index = 0, index = 0; + for (QList::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { + if ((*i).compare(printOptions->p_template) == 0) { + current_index = index; + break; + } + index++; + } + ui.printTemplate->clear(); + for (QList::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { + ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i)); + } + ui.printTemplate->setCurrentIndex(current_index); + } else if (printOptions->type == print_options::STATISTICS) { + // insert statistics templates in the UI and select the current template + qSort(grantlee_statistics_templates); + int current_index = 0, index = 0; + for (QList::iterator i = grantlee_statistics_templates.begin(); i != grantlee_statistics_templates.end(); ++i) { + if ((*i).compare(printOptions->p_template) == 0) { + current_index = index; + break; + } + index++; + } + ui.printTemplate->clear(); + for (QList::iterator i = grantlee_statistics_templates.begin(); i != grantlee_statistics_templates.end(); ++i) { + ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i)); + } + ui.printTemplate->setCurrentIndex(current_index); + } +} + // print type radio buttons void PrintOptions::on_radioDiveListPrint_toggled(bool check) { @@ -79,6 +102,8 @@ void PrintOptions::on_radioDiveListPrint_toggled(bool check) ui.exportButton->setEnabled(true); ui.importButton->setEnabled(true); ui.printTemplate->setEnabled(true); + + setupTemplates(); } } @@ -97,6 +122,8 @@ void PrintOptions::on_radioStatisticsPrint_toggled(bool check) ui.exportButton->setEnabled(false); ui.importButton->setEnabled(false); ui.printTemplate->setEnabled(false); + + setupTemplates(); } } -- cgit v1.2.3-70-g09d2