]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QSendto.C
partial fonts fix. Like Juergen said we really need our own dialog.
[lyx.git] / src / frontends / qt2 / QSendto.C
1 /**
2  * \file QSendto.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Juergen Spitzmueller
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "Qt2BC.h"
18 #include "ControlSendto.h"
19 #include "QSendtoDialog.h"
20 #include "QSendto.h"
21
22 #include <qcombobox.h>
23 #include <qlabel.h>
24 #include <qlistbox.h>
25 #include <qpushbutton.h>
26
27 #include "debug.h"
28 #include "gettext.h"
29 #include "converter.h"
30
31 using std::vector;
32
33 typedef Qt2CB<ControlSendto, Qt2DB<QSendtoDialog> > base_class;
34
35
36 QSendto::QSendto()
37         : base_class(_("Send document to command"))
38 {
39 }
40
41
42 void QSendto::build_dialog()
43 {
44         dialog_.reset(new QSendtoDialog(this));
45
46         // Manage the ok, apply, restore and cancel/close buttons
47         bc().setOK(dialog_->okPB);
48         bc().setApply(dialog_->applyPB);
49         bc().setCancel(dialog_->closePB);
50 }
51
52
53 void QSendto::update_contents()
54 {
55         all_formats_ = controller().allFormats();
56
57         // Check whether the current contents of the browser will be
58         // changed by loading the contents of formats
59         vector<string> keys;
60         keys.resize(all_formats_.size());
61
62         vector<string>::iterator result = keys.begin();
63         vector<Format const *>::const_iterator it  = all_formats_.begin();
64         vector<Format const *>::const_iterator end = all_formats_.end();
65         for (; it != end; ++it, ++result) {
66                 *result = (*it)->prettyname();
67         }
68
69         // Reload the browser
70         dialog_->formatLB->clear();
71
72         for (vector<string>::const_iterator it = keys.begin();
73              it < keys.end(); ++it) {
74                 dialog_->formatLB->insertItem(it->c_str());
75         }
76
77         dialog_->commandCO->insertItem(controller().getCommand().c_str());
78 }
79
80
81 void QSendto::apply()
82 {
83         int const line(dialog_->formatLB->currentItem());
84
85         if (line < 0 || line > dialog_->formatLB->count())
86                 return;
87
88         string const cmd(dialog_->commandCO->currentText().latin1());
89
90         controller().setFormat(all_formats_[line]);
91         controller().setCommand(cmd);
92 }
93
94
95 bool QSendto::isValid()
96 {
97         int const line(dialog_->formatLB->currentItem());
98
99         if (line < 0 || line > dialog_->formatLB->count())
100                 return false;
101
102         else return dialog_->formatLB->count() != 0 &&
103                 !string(dialog_->commandCO->currentText()).empty();
104 }