2013-07-09 12:37:53 +00:00
|
|
|
#include "printoptions.h"
|
2015-06-26 02:21:31 +00:00
|
|
|
#include "templateedit.h"
|
2015-06-11 18:13:10 +00:00
|
|
|
#include <QDebug>
|
2013-07-09 12:37:53 +00:00
|
|
|
|
2015-06-29 01:16:19 +00:00
|
|
|
PrintOptions::PrintOptions(QWidget *parent, struct print_options *printOpt, struct template_options *templateOpt)
|
2013-07-09 12:37:53 +00:00
|
|
|
{
|
2013-07-10 07:54:25 +00:00
|
|
|
hasSetupSlots = false;
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.setupUi(this);
|
2013-07-09 20:43:21 +00:00
|
|
|
if (parent)
|
|
|
|
setParent(parent);
|
2015-07-05 04:28:23 +00:00
|
|
|
if (!printOpt || !templateOpt)
|
2013-07-09 20:43:21 +00:00
|
|
|
return;
|
2015-06-29 01:16:19 +00:00
|
|
|
templateOptions = templateOpt;
|
2015-07-05 04:28:23 +00:00
|
|
|
printOptions = printOpt;
|
|
|
|
setup();
|
2013-07-10 07:54:25 +00:00
|
|
|
}
|
|
|
|
|
2015-07-05 04:28:23 +00:00
|
|
|
void PrintOptions::setup()
|
2013-07-10 07:54:25 +00:00
|
|
|
{
|
|
|
|
// print type radio buttons
|
2013-07-10 12:34:57 +00:00
|
|
|
switch (printOptions->type) {
|
2015-05-30 11:10:31 +00:00
|
|
|
case print_options::DIVELIST:
|
|
|
|
ui.radioDiveListPrint->setChecked(true);
|
2014-07-24 17:56:39 +00:00
|
|
|
break;
|
2014-11-13 22:57:42 +00:00
|
|
|
case print_options::TABLE:
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.radioTablePrint->setChecked(true);
|
2013-07-10 07:54:25 +00:00
|
|
|
break;
|
2015-05-30 11:10:31 +00:00
|
|
|
case print_options::STATISTICS:
|
|
|
|
ui.radioStatisticsPrint->setChecked(true);
|
|
|
|
break;
|
2013-07-10 07:54:25 +00:00
|
|
|
}
|
2015-06-11 18:13:10 +00:00
|
|
|
switch (printOptions->p_template) {
|
|
|
|
case print_options::ONE_DIVE:
|
|
|
|
ui.printTemplate->setCurrentIndex(0);
|
|
|
|
break;
|
|
|
|
case print_options::TWO_DIVE:
|
|
|
|
ui.printTemplate->setCurrentIndex(1);
|
|
|
|
break;
|
2015-07-04 21:02:17 +00:00
|
|
|
case print_options::CUSTOM:
|
|
|
|
ui.printTemplate->setCurrentIndex(2);
|
|
|
|
break;
|
2015-06-11 18:13:10 +00:00
|
|
|
}
|
2015-05-30 11:10:31 +00:00
|
|
|
|
2013-07-10 07:54:25 +00:00
|
|
|
// general print option checkboxes
|
|
|
|
if (printOptions->color_selected)
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.printInColor->setChecked(true);
|
2013-07-10 07:54:25 +00:00
|
|
|
if (printOptions->print_selected)
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.printSelected->setChecked(true);
|
2013-07-10 07:54:25 +00:00
|
|
|
|
|
|
|
// connect slots only once
|
|
|
|
if (hasSetupSlots)
|
|
|
|
return;
|
|
|
|
|
2013-10-03 18:54:25 +00:00
|
|
|
connect(ui.printInColor, SIGNAL(clicked(bool)), this, SLOT(printInColorClicked(bool)));
|
|
|
|
connect(ui.printSelected, SIGNAL(clicked(bool)), this, SLOT(printSelectedClicked(bool)));
|
2013-07-10 07:54:25 +00:00
|
|
|
|
|
|
|
hasSetupSlots = true;
|
2013-07-09 12:37:53 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 07:54:25 +00:00
|
|
|
// print type radio buttons
|
2015-05-30 11:10:31 +00:00
|
|
|
void PrintOptions::on_radioDiveListPrint_clicked(bool check)
|
2013-07-10 07:54:25 +00:00
|
|
|
{
|
2015-05-30 11:10:31 +00:00
|
|
|
if (check) {
|
|
|
|
printOptions->type = print_options::DIVELIST;
|
|
|
|
}
|
2013-07-10 07:54:25 +00:00
|
|
|
}
|
|
|
|
|
2015-05-30 11:10:31 +00:00
|
|
|
void PrintOptions::on_radioTablePrint_clicked(bool check)
|
2014-07-24 17:56:39 +00:00
|
|
|
{
|
2015-05-30 11:10:31 +00:00
|
|
|
if (check) {
|
|
|
|
printOptions->type = print_options::TABLE;
|
|
|
|
}
|
2014-07-24 17:56:39 +00:00
|
|
|
}
|
|
|
|
|
2015-05-30 11:10:31 +00:00
|
|
|
void PrintOptions::on_radioStatisticsPrint_clicked(bool check)
|
2013-07-10 07:54:25 +00:00
|
|
|
{
|
2015-05-30 11:10:31 +00:00
|
|
|
if (check) {
|
|
|
|
printOptions->type = print_options::STATISTICS;
|
|
|
|
}
|
2013-07-10 07:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// general print option checkboxes
|
|
|
|
void PrintOptions::printInColorClicked(bool check)
|
|
|
|
{
|
2014-11-13 22:57:42 +00:00
|
|
|
printOptions->color_selected = check;
|
2013-07-10 07:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintOptions::printSelectedClicked(bool check)
|
|
|
|
{
|
2014-11-13 22:57:42 +00:00
|
|
|
printOptions->print_selected = check;
|
2013-07-10 07:54:25 +00:00
|
|
|
}
|
2015-06-11 18:13:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
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;
|
2015-07-04 21:02:17 +00:00
|
|
|
case 2:
|
|
|
|
printOptions->p_template = print_options::CUSTOM;
|
|
|
|
break;
|
2015-06-11 18:13:10 +00:00
|
|
|
}
|
|
|
|
}
|
2015-06-26 02:21:31 +00:00
|
|
|
|
|
|
|
void PrintOptions::on_editButton_clicked()
|
|
|
|
{
|
2015-07-05 05:26:39 +00:00
|
|
|
TemplateEdit te(this, printOptions, templateOptions);
|
2015-06-26 02:21:31 +00:00
|
|
|
te.exec();
|
2015-07-05 05:29:46 +00:00
|
|
|
setup();
|
2015-06-26 02:21:31 +00:00
|
|
|
}
|