]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/printdlgimpl.C
Qt2 compilation + LColor cleanup from John
[lyx.git] / src / frontends / qt2 / printdlgimpl.C
1 /**
2  * \file printdlgimpl.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 "printdlgimpl.h"
19 #include "FormPrint.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 PrintDlgImpl::PrintDlgImpl( FormPrint *f, QWidget* parent,  const char* name, bool modal, WFlags fl )
33         : PrintDlg( parent, name, modal, fl ), form_(f)
34 {
35         setCaption(name);
36 }
37
38  
39 PrintDlgImpl::~PrintDlgImpl()
40 {
41          // no need to delete child widgets, Qt does it all for us
42 }
43
44
45 const char * PrintDlgImpl::getFrom() {
46         return fromPage->text();
47 }
48
49
50 const char * PrintDlgImpl::getTo() {
51         return toPage->text();
52 }
53
54         
55 PrinterParams::Target PrintDlgImpl::getTarget() {
56         if (toPrinter->isChecked())
57                 return PrinterParams::PRINTER;
58         else
59                 return PrinterParams::FILE;
60 }
61
62         
63 const char * PrintDlgImpl::getPrinter() {
64         return printerName->text();
65 }
66
67 const char * PrintDlgImpl::getFile() {
68         return fileName->text();
69 }
70
71 PrinterParams::WhichPages PrintDlgImpl::getWhichPages() {
72         if (oddPages->isChecked())
73                 return PrinterParams::ODD;
74         else if (evenPages->isChecked())
75                 return PrinterParams::EVEN;
76         else
77                 return PrinterParams::ALL;
78 }
79
80 bool PrintDlgImpl::getReverse() {
81         return reverse->isChecked();
82 }
83
84 bool PrintDlgImpl::getSort() {
85         return collate->isChecked();
86 }
87
88 const char * PrintDlgImpl::getCount() {
89         return copies->text();
90 }
91
92 void PrintDlgImpl::setTarget(PrinterParams::Target t) {
93         toPrinter->setChecked(t==PrinterParams::PRINTER);
94         toFile->setChecked(t!=PrinterParams::PRINTER);
95 }
96
97 void PrintDlgImpl::setPrinter(const char * name) {
98         printerName->setText(name);
99 }
100
101 void PrintDlgImpl::setFile(const char * name) {
102         fileName->setText(name);
103 }        
104
105 void PrintDlgImpl::setWhichPages(PrinterParams::WhichPages wp) {
106         switch (wp) {
107                 case PrinterParams::ALL:
108                         allPages->setChecked(true);
109                         break;
110                 case PrinterParams::EVEN:
111                         evenPages->setChecked(true);
112                         break;
113                 case PrinterParams::ODD:
114                         oddPages->setChecked(true);
115                         break;
116         }
117 }
118
119
120 void PrintDlgImpl::setReverse(bool on) {
121         reverse->setChecked(on);
122 }
123
124
125 void PrintDlgImpl::setSort(bool on) {
126         collate->setChecked(on);
127 }
128
129
130 void PrintDlgImpl::setCount(int num) {
131         copies->setValue(num);
132         collate->setEnabled(num > 1);
133 }
134
135
136 void PrintDlgImpl::setFrom(const char * text) {
137         fromPage->setText(text);
138 }
139
140
141 void PrintDlgImpl::setTo(const char * text) {
142         toPage->setText(text);
143 }
144
145  
146 void PrintDlgImpl::browse_file()
147 {
148         QString d( OnlyPath(tostr(fileName->text())).c_str() );
149         QString s( QFileDialog::getOpenFileName( d, "PostScript Files (*.ps)", this ) );
150         if (!s.isNull()) 
151                 fileName->setText(s);
152 }
153
154  
155 void PrintDlgImpl::print()
156 {
157         form_->print();
158         form_->close();
159         hide();
160 }
161
162  
163 void PrintDlgImpl::cancel_adaptor()
164 {
165         form_->close();
166         hide();
167 }
168
169  
170 void PrintDlgImpl::set_collate(int copies)
171 {
172         collate->setEnabled(copies > 1);
173 }