diff options
author | Gehad elrobey <gehadelrobey@gmail.com> | 2015-07-24 09:53:07 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2015-07-28 11:37:30 +0300 |
commit | 2b2c506cb7e5e1659ad68818eca46d14d7840ecd (patch) | |
tree | 1085b0d8faa43c12818b89a4cfc7666a481457d0 /qt-ui | |
parent | c95358c4b9c39016d08c234fb7e5db4958ff381e (diff) | |
download | subsurface-2b2c506cb7e5e1659ad68818eca46d14d7840ecd.tar.gz |
Printing: use grantlee templates from the current existing template list
We use templates from the grantlee templates list created and
dynamically. So we don't need static templates anymore.
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/printdialog.cpp | 2 | ||||
-rw-r--r-- | qt-ui/printoptions.cpp | 28 | ||||
-rw-r--r-- | qt-ui/printoptions.h | 6 | ||||
-rw-r--r-- | qt-ui/templateedit.cpp | 10 |
4 files changed, 10 insertions, 36 deletions
diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 31ec354c8..bb6643b31 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -30,7 +30,6 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f printOptions.print_selected = true; printOptions.color_selected = true; printOptions.landscape = false; - printOptions.p_template = print_options::ONE_DIVE; printOptions.type = print_options::DIVELIST; templateOptions.font_index = 0; templateOptions.font_size = 9; @@ -43,7 +42,6 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f printOptions.print_selected = s.value("print_selected").toBool(); printOptions.color_selected = s.value("color_selected").toBool(); printOptions.landscape = s.value("landscape").toBool(); - printOptions.p_template = (print_options::print_template)s.value("template_selected").toInt(); qprinter.setOrientation((QPrinter::Orientation)printOptions.landscape); templateOptions.font_index = s.value("font").toInt(); templateOptions.font_size = s.value("font_size").toDouble(); diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp index 0e6a0b320..3ed3edf11 100644 --- a/qt-ui/printoptions.cpp +++ b/qt-ui/printoptions.cpp @@ -29,16 +29,12 @@ void PrintOptions::setup() ui.radioStatisticsPrint->setChecked(true); break; } - switch (printOptions->p_template) { - case print_options::ONE_DIVE: - ui.printTemplate->setCurrentIndex(0); - break; - case print_options::TWO_DIVE: - ui.printTemplate->setCurrentIndex(1); - break; - case print_options::CUSTOM: - ui.printTemplate->setCurrentIndex(2); - break; + + // insert existing templates in the UI + ui.printTemplate->clear(); + qSort(grantlee_templates); + for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { + ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i)); } // general print option checkboxes @@ -93,17 +89,7 @@ void PrintOptions::printSelectedClicked(bool check) void PrintOptions::on_printTemplate_currentIndexChanged(int index) { - switch(index){ - case 0: - printOptions->p_template = print_options::ONE_DIVE; - break; - case 1: - printOptions->p_template = print_options::TWO_DIVE; - break; - case 2: - printOptions->p_template = print_options::CUSTOM; - break; - } + printOptions->p_template = ui.printTemplate->itemData(index).toString(); } void PrintOptions::on_editButton_clicked() diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h index 3a55c6994..3ece6b64c 100644 --- a/qt-ui/printoptions.h +++ b/qt-ui/printoptions.h @@ -11,11 +11,7 @@ struct print_options { TABLE, STATISTICS } type; - enum print_template { - ONE_DIVE, - TWO_DIVE, - CUSTOM - } p_template; + QString p_template; bool print_selected; bool color_selected; bool landscape; diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 6a6328f64..de280f7a8 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -21,13 +21,7 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, ui->colorpalette->setCurrentIndex(templateOptions->color_palette_index); ui->linespacing->setValue(templateOptions->line_spacing); - if (printOptions->p_template == print_options::ONE_DIVE) { - grantlee_template = TemplateLayout::readTemplate("one_dive.html"); - } else if (printOptions->p_template == print_options::TWO_DIVE) { - grantlee_template = TemplateLayout::readTemplate("two_dives.html"); - } else if (printOptions->p_template == print_options::CUSTOM) { - grantlee_template = TemplateLayout::readTemplate("custom.html"); - } + grantlee_template = TemplateLayout::readTemplate(printOptions->p_template); // gui btnGroup = new QButtonGroup; @@ -118,7 +112,7 @@ void TemplateEdit::saveSettings() if (msgBox.exec() == QMessageBox::Save) { memcpy(templateOptions, &newTemplateOptions, sizeof(struct template_options)); if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) { - printOptions->p_template = print_options::CUSTOM; + printOptions->p_template = "custom.html"; TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText()); } if (templateOptions->color_palette_index == 1) { |