]> git.lyx.org Git - features.git/blob - src/frontends/qt2/QSendto.C
Remove all unnecessary #includes from header files.
[features.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 Jürgen Spitzmüller
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13
14 #include "Qt2BC.h"
15 #include "ControlSendto.h"
16 #include "QSendtoDialog.h"
17 #include "QSendto.h"
18
19 #include <qcombobox.h>
20 #include <qlistbox.h>
21 #include <qpushbutton.h>
22
23 #include "qt_helpers.h"
24 #include "format.h"
25
26 using std::vector;
27
28 typedef Qt2CB<ControlSendto, Qt2DB<QSendtoDialog> > base_class;
29
30
31 QSendto::QSendto()
32         : base_class(_("LyX: Send Document to Command"))
33 {
34 }
35
36
37 void QSendto::build_dialog()
38 {
39         dialog_.reset(new QSendtoDialog(this));
40
41         // Manage the ok, apply, restore and cancel/close buttons
42         bcview().setOK(dialog_->okPB);
43         bcview().setApply(dialog_->applyPB);
44         bcview().setCancel(dialog_->closePB);
45 }
46
47
48 void QSendto::update_contents()
49 {
50         all_formats_ = controller().allFormats();
51
52         // Check whether the current contents of the browser will be
53         // changed by loading the contents of formats
54         vector<string> keys;
55         keys.resize(all_formats_.size());
56
57         vector<string>::iterator result = keys.begin();
58         vector<Format const *>::const_iterator it  = all_formats_.begin();
59         vector<Format const *>::const_iterator end = all_formats_.end();
60         for (; it != end; ++it, ++result) {
61                 *result = (*it)->prettyname();
62         }
63
64         // Reload the browser
65         dialog_->formatLB->clear();
66
67         for (vector<string>::const_iterator it = keys.begin();
68              it < keys.end(); ++it) {
69                 dialog_->formatLB->insertItem(toqstr(*it));
70         }
71
72         dialog_->commandCO->insertItem(toqstr(controller().getCommand()));
73 }
74
75
76 void QSendto::apply()
77 {
78         int const line(dialog_->formatLB->currentItem());
79
80         if (line < 0 || line > dialog_->formatLB->count())
81                 return;
82
83         string const cmd(fromqstr(dialog_->commandCO->currentText()));
84
85         controller().setFormat(all_formats_[line]);
86         controller().setCommand(cmd);
87 }
88
89
90 bool QSendto::isValid()
91 {
92         int const line(dialog_->formatLB->currentItem());
93
94         if (line < 0 || line > dialog_->formatLB->count())
95                 return false;
96
97         else return dialog_->formatLB->count() != 0 &&
98                 !dialog_->commandCO->currentText().isEmpty();
99 }