2013-07-09 12:37:53 +00:00
|
|
|
#include "printoptions.h"
|
|
|
|
|
2014-11-13 22:57:42 +00:00
|
|
|
PrintOptions::PrintOptions(QWidget *parent, struct print_options *printOpt)
|
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);
|
|
|
|
if (!printOpt)
|
|
|
|
return;
|
2013-07-10 07:54:25 +00:00
|
|
|
setup(printOpt);
|
|
|
|
}
|
|
|
|
|
2014-11-13 22:57:42 +00:00
|
|
|
void PrintOptions::setup(struct print_options *printOpt)
|
2013-07-10 07:54:25 +00:00
|
|
|
{
|
2013-07-09 20:43:21 +00:00
|
|
|
printOptions = printOpt;
|
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-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
|
|
|
}
|