mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-17 21:26:16 +00:00
"Table" print is now a template, so remove the radio button. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
98 lines
2.4 KiB
C++
98 lines
2.4 KiB
C++
#include "printoptions.h"
|
|
#include "templateedit.h"
|
|
#include <QDebug>
|
|
|
|
PrintOptions::PrintOptions(QWidget *parent, struct print_options *printOpt, struct template_options *templateOpt)
|
|
{
|
|
hasSetupSlots = false;
|
|
ui.setupUi(this);
|
|
if (parent)
|
|
setParent(parent);
|
|
if (!printOpt || !templateOpt)
|
|
return;
|
|
templateOptions = templateOpt;
|
|
printOptions = printOpt;
|
|
setup();
|
|
}
|
|
|
|
void PrintOptions::setup()
|
|
{
|
|
// print type radio buttons
|
|
switch (printOptions->type) {
|
|
case print_options::DIVELIST:
|
|
ui.radioDiveListPrint->setChecked(true);
|
|
break;
|
|
case print_options::STATISTICS:
|
|
ui.radioStatisticsPrint->setChecked(true);
|
|
break;
|
|
}
|
|
|
|
// insert existing templates in the UI and select the current template
|
|
qSort(grantlee_templates);
|
|
int current_index = 0;
|
|
for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) {
|
|
if ((*i).compare(printOptions->p_template) == 0) {
|
|
break;
|
|
}
|
|
current_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);
|
|
|
|
// general print option checkboxes
|
|
if (printOptions->color_selected)
|
|
ui.printInColor->setChecked(true);
|
|
if (printOptions->print_selected)
|
|
ui.printSelected->setChecked(true);
|
|
|
|
// connect slots only once
|
|
if (hasSetupSlots)
|
|
return;
|
|
|
|
connect(ui.printInColor, SIGNAL(clicked(bool)), this, SLOT(printInColorClicked(bool)));
|
|
connect(ui.printSelected, SIGNAL(clicked(bool)), this, SLOT(printSelectedClicked(bool)));
|
|
|
|
hasSetupSlots = true;
|
|
}
|
|
|
|
// print type radio buttons
|
|
void PrintOptions::on_radioDiveListPrint_clicked(bool check)
|
|
{
|
|
if (check) {
|
|
printOptions->type = print_options::DIVELIST;
|
|
}
|
|
}
|
|
|
|
void PrintOptions::on_radioStatisticsPrint_clicked(bool check)
|
|
{
|
|
if (check) {
|
|
printOptions->type = print_options::STATISTICS;
|
|
}
|
|
}
|
|
|
|
// general print option checkboxes
|
|
void PrintOptions::printInColorClicked(bool check)
|
|
{
|
|
printOptions->color_selected = check;
|
|
}
|
|
|
|
void PrintOptions::printSelectedClicked(bool check)
|
|
{
|
|
printOptions->print_selected = check;
|
|
}
|
|
|
|
|
|
void PrintOptions::on_printTemplate_currentIndexChanged(int index)
|
|
{
|
|
printOptions->p_template = ui.printTemplate->itemData(index).toString();
|
|
}
|
|
|
|
void PrintOptions::on_editButton_clicked()
|
|
{
|
|
TemplateEdit te(this, printOptions, templateOptions);
|
|
te.exec();
|
|
setup();
|
|
}
|