3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jürgen Spitzmüller
8 * Full author contact details are available in file CREDITS.
15 #include "ControlSendto.h"
16 #include "QSendtoDialog.h"
19 #include <qcombobox.h>
21 #include <qpushbutton.h>
23 #include "qt_helpers.h"
29 typedef Qt2CB<ControlSendto, Qt2DB<QSendtoDialog> > base_class;
33 : base_class(_("LyX: Send Document to Command"))
38 void QSendto::build_dialog()
40 dialog_.reset(new QSendtoDialog(this));
42 // Manage the ok, apply, restore and cancel/close buttons
43 bcview().setOK(dialog_->okPB);
44 bcview().setApply(dialog_->applyPB);
45 bcview().setCancel(dialog_->closePB);
49 void QSendto::update_contents()
51 all_formats_ = controller().allFormats();
53 // Check whether the current contents of the browser will be
54 // changed by loading the contents of formats
56 keys.resize(all_formats_.size());
58 vector<string>::iterator result = keys.begin();
59 vector<Format const *>::const_iterator it = all_formats_.begin();
60 vector<Format const *>::const_iterator end = all_formats_.end();
61 for (; it != end; ++it, ++result) {
62 *result = (*it)->prettyname();
66 dialog_->formatLB->clear();
68 for (vector<string>::const_iterator it = keys.begin();
69 it < keys.end(); ++it) {
70 dialog_->formatLB->insertItem(toqstr(*it));
73 dialog_->commandCO->insertItem(toqstr(controller().getCommand()));
79 int const line(dialog_->formatLB->currentItem());
81 if (line < 0 || line > dialog_->formatLB->count())
84 string const cmd(fromqstr(dialog_->commandCO->currentText()));
86 controller().setFormat(all_formats_[line]);
87 controller().setCommand(cmd);
91 bool QSendto::isValid()
93 int const line(dialog_->formatLB->currentItem());
95 if (line < 0 || line > dialog_->formatLB->count())
98 else return dialog_->formatLB->count() != 0 &&
99 !dialog_->commandCO->currentText().isEmpty();