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"
28 typedef Qt2CB<ControlSendto, Qt2DB<QSendtoDialog> > base_class;
32 : base_class(_("LyX: Send Document to Command"))
37 void QSendto::build_dialog()
39 dialog_.reset(new QSendtoDialog(this));
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);
48 void QSendto::update_contents()
50 all_formats_ = controller().allFormats();
52 // Check whether the current contents of the browser will be
53 // changed by loading the contents of formats
55 keys.resize(all_formats_.size());
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();
65 dialog_->formatLB->clear();
67 for (vector<string>::const_iterator it = keys.begin();
68 it < keys.end(); ++it) {
69 dialog_->formatLB->insertItem(toqstr(*it));
72 dialog_->commandCO->insertItem(toqstr(controller().getCommand()));
78 int const line(dialog_->formatLB->currentItem());
80 if (line < 0 || line > dialog_->formatLB->count())
83 string const cmd(fromqstr(dialog_->commandCO->currentText()));
85 controller().setFormat(all_formats_[line]);
86 controller().setCommand(cmd);
90 bool QSendto::isValid()
92 int const line(dialog_->formatLB->currentItem());
94 if (line < 0 || line > dialog_->formatLB->count())
97 else return dialog_->formatLB->count() != 0 &&
98 !dialog_->commandCO->currentText().isEmpty();