3 * Copyright 2001 LyX Team
6 * \author John Levon, moz@compsoc.man.ac.uk
7 * \author Edwin Leuven, leuven@fee.uva.nl
10 #include <qfiledialog.h>
11 #include <qcheckbox.h>
13 #include <qlineedit.h>
14 #include <qpushbutton.h>
15 #include <qradiobutton.h>
18 #include "QPrintDialog.h"
23 #include "support/filetools.h"
24 #include "support/lstrings.h"
26 #include "PrinterParams.h"
32 QPrintDialog::QPrintDialog(QPrint * f, QWidget * parent, const char * name, bool modal, WFlags fl)
33 : QPrintDialogBase(parent, name, modal, fl),
40 QPrintDialog::~QPrintDialog()
45 const char * QPrintDialog::getFrom() {
46 return fromPage->text();
50 const char * QPrintDialog::getTo() {
51 return toPage->text();
55 PrinterParams::Target QPrintDialog::getTarget() {
56 if (toPrinter->isChecked())
57 return PrinterParams::PRINTER;
59 return PrinterParams::FILE;
63 const char * QPrintDialog::getPrinter() {
64 return printerName->text();
68 const char * QPrintDialog::getFile() {
69 return fileName->text();
73 PrinterParams::WhichPages QPrintDialog::getWhichPages() {
74 if (oddPages->isChecked())
75 return PrinterParams::ODD;
76 else if (evenPages->isChecked())
77 return PrinterParams::EVEN;
79 return PrinterParams::ALL;
83 bool QPrintDialog::getReverse() {
84 return reverse->isChecked();
88 bool QPrintDialog::getSort() {
89 return collate->isChecked();
93 const char * QPrintDialog::getCount() {
94 return copies->text();
98 void QPrintDialog::setTarget(PrinterParams::Target t) {
99 toPrinter->setChecked(t==PrinterParams::PRINTER);
100 toFile->setChecked(t!=PrinterParams::PRINTER);
104 void QPrintDialog::setPrinter(const char * name) {
105 printerName->setText(name);
109 void QPrintDialog::setFile(const char * name) {
110 fileName->setText(name);
114 void QPrintDialog::setWhichPages(PrinterParams::WhichPages wp) {
116 case PrinterParams::ALL:
117 allPages->setChecked(true);
119 case PrinterParams::EVEN:
120 evenPages->setChecked(true);
122 case PrinterParams::ODD:
123 oddPages->setChecked(true);
129 void QPrintDialog::setReverse(bool on) {
130 reverse->setChecked(on);
134 void QPrintDialog::setSort(bool on) {
135 collate->setChecked(on);
139 void QPrintDialog::setCount(int num) {
140 copies->setValue(num);
141 collate->setEnabled(num > 1);
145 void QPrintDialog::setFrom(const char * text) {
146 fromPage->setText(text);
150 void QPrintDialog::setTo(const char * text) {
151 toPage->setText(text);
155 void QPrintDialog::browse_file()
157 QString d( OnlyPath(tostr(fileName->text())).c_str());
158 QString s( QFileDialog::getOpenFileName(d, "PostScript Files (*.ps)", this));
160 fileName->setText(s);
164 void QPrintDialog::print()
172 void QPrintDialog::cancel_adaptor()
179 void QPrintDialog::set_collate(int copies)
181 collate->setEnabled(copies > 1);