diff options
author | Gehad elrobey <gehadelrobey@gmail.com> | 2015-08-21 18:07:30 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2015-08-22 18:34:34 +0300 |
commit | 6a692495c024876d74145df8b67734323ec348b6 (patch) | |
tree | 2df90776afd63442c340d57200aff32db750e550 /qt-ui/printoptions.cpp | |
parent | 77c81b299bf376d67435e61cf172d49a3177f680 (diff) | |
download | subsurface-6a692495c024876d74145df8b67734323ec348b6.tar.gz |
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 <neolit123@gmail.com>
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Diffstat (limited to 'qt-ui/printoptions.cpp')
-rw-r--r-- | qt-ui/printoptions.cpp | 57 |
1 files changed, 42 insertions, 15 deletions
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<QString>::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<QString>::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<QString>::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<QString>::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<QString>::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<QString>::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(); } } |