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
16 #include <qlineedit.h>
17 #include <qcheckbox.h>
18 #include <qradiobutton.h>
20 #include <qpushbutton.h>
22 #include "QPrintDialog.h"
27 #include "QtLyXView.h"
28 #include "ControlPrint.h"
30 #include "support/lstrings.h"
32 typedef Qt2CB<ControlPrint, Qt2DB<QPrintDialog> > base_class;
34 QPrint::QPrint(ControlPrint & c)
35 : base_class(c, _("Print"))
40 void QPrint::build_dialog()
42 dialog_.reset(new QPrintDialog(this));
44 bc().setOK(dialog_->printPB);
45 bc().setCancel(dialog_->closePB);
49 void QPrint::update_contents()
51 PrinterParams & pp = controller().params();
53 dialog_->printerED->setText(pp.printer_name.c_str());
54 dialog_->fileED->setText(pp.file_name.c_str());
56 dialog_->printerRB->setChecked(true);
57 if (pp.target == PrinterParams::FILE)
58 dialog_->fileRB->setChecked(true);
60 dialog_->reverseCB->setChecked(pp.reverse_order);
62 QRadioButton * button;
63 switch (pp.which_pages) {
64 case PrinterParams::ALL: button = dialog_->allRB; break;
65 case PrinterParams::ODD: button = dialog_->oddRB; break;
66 case PrinterParams::EVEN: button = dialog_->evenRB; break;
68 button->setChecked(true);
70 // hmmm... maybe a bit weird but maybe not
71 // we might just be remembering the last
72 // time this was printed.
73 if (!pp.from_page.empty()) {
74 dialog_->fromED->setText(pp.from_page.c_str());
76 dialog_->toED->setText("");
78 dialog_->toED->setText(tostr(pp.to_page).c_str());
80 dialog_->fromED->setText("");
81 dialog_->toED->setText("");
84 dialog_->copiesSB->setValue(pp.count_copies);
90 PrinterParams::WhichPages wp;
92 if (dialog_->allRB->isChecked())
93 wp = PrinterParams::ALL;
94 else if (dialog_->oddRB->isChecked())
95 wp = PrinterParams::ODD;
97 wp = PrinterParams::EVEN;
101 if (!dialog_->fromED->text().isEmpty()) {
102 // we have at least one page requested
103 from = dialog_->fromED->text().latin1();
104 if (!dialog_->toED->text().isEmpty())
105 to = strToInt(dialog_->toED->text().latin1());
108 PrinterParams::Target t = PrinterParams::PRINTER;
109 if (dialog_->fileRB->isChecked())
110 t = PrinterParams::FILE;
112 PrinterParams const pp(t,
113 dialog_->printerED->text().latin1(),
114 dialog_->fileED->text().latin1(),
116 dialog_->reverseCB->isChecked(),
117 !dialog_->collateCB->isChecked(),
118 strToInt(dialog_->copiesSB->text().latin1()));
120 controller().params() = pp;