]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QPrintDialog.C
some small updates
[lyx.git] / src / frontends / qt2 / QPrintDialog.C
1 /**
2  * \file QPrintDialog.C
3  * Copyright 2001 LyX Team
4  * see the file COPYING
5  *
6  * \author John Levon, moz@compsoc.man.ac.uk
7  * \author Edwin Leuven, leuven@fee.uva.nl
8  */
9
10 #include <qfiledialog.h>
11 #include <qcheckbox.h>
12 #include <qlabel.h>
13 #include <qlineedit.h>
14 #include <qpushbutton.h>
15 #include <qradiobutton.h>
16 #include <qspinbox.h>
17
18 #include "QPrintDialog.h"
19 #include "QPrint.h"
20
21 #include <config.h>
22
23 #include "support/filetools.h"
24 #include "support/lstrings.h"
25 #include "lyxrc.h" 
26 #include "PrinterParams.h"
27
28 #include <gettext.h>
29 #include <cstring>
30
31
32 QPrintDialog::QPrintDialog(QPrint * f, QWidget * parent,  const char * name, bool modal, WFlags fl)
33         : QPrintDialogBase(parent, name, modal, fl), 
34         form_(f)
35 {
36         setCaption(name);
37 }
38
39  
40 QPrintDialog::~QPrintDialog()
41 {
42 }
43
44
45 const char * QPrintDialog::getFrom() {
46         return fromPage->text();
47 }
48
49
50 const char * QPrintDialog::getTo() {
51         return toPage->text();
52 }
53
54         
55 PrinterParams::Target QPrintDialog::getTarget() {
56         if (toPrinter->isChecked())
57                 return PrinterParams::PRINTER;
58         else
59                 return PrinterParams::FILE;
60 }
61
62
63 const char * QPrintDialog::getPrinter() {
64         return printerName->text();
65 }
66
67
68 const char * QPrintDialog::getFile() {
69         return fileName->text();
70 }
71
72
73 PrinterParams::WhichPages QPrintDialog::getWhichPages() {
74         if (oddPages->isChecked())
75                 return PrinterParams::ODD;
76         else if (evenPages->isChecked())
77                 return PrinterParams::EVEN;
78         else
79                 return PrinterParams::ALL;
80 }
81
82
83 bool QPrintDialog::getReverse() {
84         return reverse->isChecked();
85 }
86
87
88 bool QPrintDialog::getSort() {
89         return collate->isChecked();
90 }
91
92
93 const char * QPrintDialog::getCount() {
94         return copies->text();
95 }
96
97
98 void QPrintDialog::setTarget(PrinterParams::Target t) {
99         toPrinter->setChecked(t==PrinterParams::PRINTER);
100         toFile->setChecked(t!=PrinterParams::PRINTER);
101 }
102
103
104 void QPrintDialog::setPrinter(const char * name) {
105         printerName->setText(name);
106 }
107
108
109 void QPrintDialog::setFile(const char * name) {
110         fileName->setText(name);
111 }        
112
113
114 void QPrintDialog::setWhichPages(PrinterParams::WhichPages wp) {
115         switch (wp) {
116                 case PrinterParams::ALL:
117                         allPages->setChecked(true);
118                         break;
119                 case PrinterParams::EVEN:
120                         evenPages->setChecked(true);
121                         break;
122                 case PrinterParams::ODD:
123                         oddPages->setChecked(true);
124                         break;
125         }
126 }
127
128
129 void QPrintDialog::setReverse(bool on) {
130         reverse->setChecked(on);
131 }
132
133
134 void QPrintDialog::setSort(bool on) {
135         collate->setChecked(on);
136 }
137
138
139 void QPrintDialog::setCount(int num) {
140         copies->setValue(num);
141         collate->setEnabled(num > 1);
142 }
143
144
145 void QPrintDialog::setFrom(const char * text) {
146         fromPage->setText(text);
147 }
148
149
150 void QPrintDialog::setTo(const char * text) {
151         toPage->setText(text);
152 }
153
154  
155 void QPrintDialog::browse_file()
156 {
157         QString d( OnlyPath(tostr(fileName->text())).c_str());
158         QString s( QFileDialog::getOpenFileName(d, "PostScript Files (*.ps)", this));
159         if (!s.isNull()) 
160                 fileName->setText(s);
161 }
162
163  
164 void QPrintDialog::print()
165 {
166         form_->print();
167         form_->close();
168         hide();
169 }
170
171  
172 void QPrintDialog::cancel_adaptor()
173 {
174         form_->close();
175         hide();
176 }
177
178  
179 void QPrintDialog::set_collate(int copies)
180 {
181         collate->setEnabled(copies > 1);
182 }