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
14 #pragma implementation
18 #include "ControlSendto.h"
19 #include "QSendtoDialog.h"
22 #include <qcombobox.h>
25 #include <qpushbutton.h>
29 #include "converter.h"
33 typedef Qt2CB<ControlSendto, Qt2DB<QSendtoDialog> > base_class;
36 : base_class(_("Send document to command"))
41 void QSendto::build_dialog()
43 dialog_.reset(new QSendtoDialog(this));
45 // Manage the ok, apply, restore and cancel/close buttons
46 bc().setOK(dialog_->okPB);
47 bc().setApply(dialog_->applyPB);
48 bc().setCancel(dialog_->closePB);
52 void QSendto::update_contents()
54 all_formats_ = controller().allFormats();
56 // Check whether the current contents of the browser will be
57 // changed by loading the contents of formats
59 keys.resize(all_formats_.size());
61 vector<string>::iterator result = keys.begin();
62 vector<Format const *>::const_iterator it = all_formats_.begin();
63 vector<Format const *>::const_iterator end = all_formats_.end();
64 for (; it != end; ++it, ++result) {
65 *result = (*it)->prettyname();
69 dialog_->formatLB->clear();
71 for (vector<string>::const_iterator it = keys.begin();
72 it < keys.end(); ++it) {
73 dialog_->formatLB->insertItem(it->c_str());
76 dialog_->commandCO->insertItem(controller().getCommand().c_str());
81 int const line(dialog_->formatLB->currentItem());
83 if (line < 0 || line > dialog_->formatLB->count())
86 string const cmd(dialog_->commandCO->currentText().latin1());
88 controller().setFormat(all_formats_[line]);
89 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 !string(dialog_->commandCO->currentText()).empty();