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