diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/printoptions.cpp | 57 | ||||
-rw-r--r-- | qt-ui/printoptions.h | 1 |
2 files changed, 43 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(); } } diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h index 6d7ffffee..9c50b10f3 100644 --- a/qt-ui/printoptions.h +++ b/qt-ui/printoptions.h @@ -70,6 +70,7 @@ private: struct print_options *printOptions; struct template_options *templateOptions; bool hasSetupSlots; + void setupTemplates(); private slots: |