3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Juergen Spitzmueller
8 * Full author contact details are available in file CREDITS
15 #include "ControlSendto.h"
16 #include "QSendtoDialog.h"
19 #include <qcombobox.h>
22 #include <qpushbutton.h>
25 #include "qt_helpers.h"
26 #include "converter.h"
30 typedef Qt2CB<ControlSendto, Qt2DB<QSendtoDialog> > base_class;
34 : base_class(qt_("LyX: Send Document to Command"))
39 void QSendto::build_dialog()
41 dialog_.reset(new QSendtoDialog(this));
43 // Manage the ok, apply, restore and cancel/close buttons
44 bc().setOK(dialog_->okPB);
45 bc().setApply(dialog_->applyPB);
46 bc().setCancel(dialog_->closePB);
50 void QSendto::update_contents()
52 all_formats_ = controller().allFormats();
54 // Check whether the current contents of the browser will be
55 // changed by loading the contents of formats
57 keys.resize(all_formats_.size());
59 vector<string>::iterator result = keys.begin();
60 vector<Format const *>::const_iterator it = all_formats_.begin();
61 vector<Format const *>::const_iterator end = all_formats_.end();
62 for (; it != end; ++it, ++result) {
63 *result = (*it)->prettyname();
67 dialog_->formatLB->clear();
69 for (vector<string>::const_iterator it = keys.begin();
70 it < keys.end(); ++it) {
71 dialog_->formatLB->insertItem(toqstr(*it));
74 dialog_->commandCO->insertItem(toqstr(controller().getCommand()));
80 int const line(dialog_->formatLB->currentItem());
82 if (line < 0 || line > dialog_->formatLB->count())
85 string const cmd(fromqstr(dialog_->commandCO->currentText()));
87 controller().setFormat(all_formats_[line]);
88 controller().setCommand(cmd);
92 bool QSendto::isValid()
94 int const line(dialog_->formatLB->currentItem());
96 if (line < 0 || line > dialog_->formatLB->count())
99 else return dialog_->formatLB->count() != 0 &&
100 !dialog_->commandCO->currentText().isEmpty();