3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author John Levon <moz@compsoc.man.ac.uk>
7 * \author Edwin Leuven, leuven@fee.uva.nl
13 #pragma implementation
17 #include "ControlPrint.h"
18 #include "support/lstrings.h"
22 #include "QPrintDialog.h"
25 #include <qlineedit.h>
26 #include <qcheckbox.h>
27 #include <qradiobutton.h>
29 #include <qpushbutton.h>
31 // FIXME FIXME QPrintDialog is getting destructed twice !!!!
33 typedef Qt2CB<ControlPrint, Qt2DB<QPrintDialog> > base_class;
35 QPrint::QPrint(ControlPrint & c, Dialogs &)
36 : base_class(c, _("Print"))
41 void QPrint::build_dialog()
43 dialog_.reset(new QPrintDialog(this));
45 bc().setOK(dialog_->printPB);
46 bc().setCancel(dialog_->closePB);
50 void QPrint::update_contents()
52 PrinterParams & pp = controller().params();
54 dialog_->printerED->setText(pp.printer_name.c_str());
55 dialog_->fileED->setText(pp.file_name.c_str());
57 dialog_->printerRB->setChecked(true);
58 if (pp.target == PrinterParams::FILE)
59 dialog_->fileRB->setChecked(true);
61 dialog_->reverseCB->setChecked(pp.reverse_order);
63 QRadioButton * button;
64 switch (pp.which_pages) {
65 case PrinterParams::ALL: button = dialog_->allRB; break;
66 case PrinterParams::ODD: button = dialog_->oddRB; break;
67 case PrinterParams::EVEN: button = dialog_->evenRB; break;
69 button->setChecked(true);
71 // hmmm... maybe a bit weird but maybe not
72 // we might just be remembering the last
73 // time this was printed.
74 if (!pp.from_page.empty()) {
75 dialog_->fromED->setText(pp.from_page.c_str());
77 dialog_->toED->setText("");
79 dialog_->toED->setText(tostr(pp.to_page).c_str());
81 dialog_->fromED->setText("");
82 dialog_->toED->setText("");
85 dialog_->copiesSB->setValue(pp.count_copies);
91 PrinterParams::WhichPages wp;
93 if (dialog_->allRB->isChecked())
94 wp = PrinterParams::ALL;
95 else if (dialog_->oddRB->isChecked())
96 wp = PrinterParams::ODD;
98 wp = PrinterParams::EVEN;
102 if (!dialog_->fromED->text().isEmpty()) {
103 // we have at least one page requested
104 from = dialog_->fromED->text().latin1();
105 if (!dialog_->toED->text().isEmpty())
106 to = strToInt(dialog_->toED->text().latin1());
109 PrinterParams::Target t = PrinterParams::PRINTER;
110 if (dialog_->fileRB->isChecked())
111 t = PrinterParams::FILE;
113 PrinterParams const pp(t,
114 dialog_->printerED->text().latin1(),
115 dialog_->fileED->text().latin1(),
117 dialog_->reverseCB->isChecked(),
118 !dialog_->collateCB->isChecked(),
119 strToInt(dialog_->copiesSB->text().latin1()));
121 controller().params() = pp;