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>
28 #include "qt_helpers.h"
29 #include "converter.h"
33 typedef Qt2CB<ControlSendto, Qt2DB<QSendtoDialog> > base_class;
37 : base_class(qt_("Send document to command"))
42 void QSendto::build_dialog()
44 dialog_.reset(new QSendtoDialog(this));
46 // Manage the ok, apply, restore and cancel/close buttons
47 bc().setOK(dialog_->okPB);
48 bc().setApply(dialog_->applyPB);
49 bc().setCancel(dialog_->closePB);
53 void QSendto::update_contents()
55 all_formats_ = controller().allFormats();
57 // Check whether the current contents of the browser will be
58 // changed by loading the contents of formats
60 keys.resize(all_formats_.size());
62 vector<string>::iterator result = keys.begin();
63 vector<Format const *>::const_iterator it = all_formats_.begin();
64 vector<Format const *>::const_iterator end = all_formats_.end();
65 for (; it != end; ++it, ++result) {
66 *result = (*it)->prettyname();
70 dialog_->formatLB->clear();
72 for (vector<string>::const_iterator it = keys.begin();
73 it < keys.end(); ++it) {
74 dialog_->formatLB->insertItem(toqstr(*it));
77 dialog_->commandCO->insertItem(toqstr(controller().getCommand()));
83 int const line(dialog_->formatLB->currentItem());
85 if (line < 0 || line > dialog_->formatLB->count())
88 string const cmd(fromqstr(dialog_->commandCO->currentText()));
90 controller().setFormat(all_formats_[line]);
91 controller().setCommand(cmd);
95 bool QSendto::isValid()
97 int const line(dialog_->formatLB->currentItem());
99 if (line < 0 || line > dialog_->formatLB->count())
102 else return dialog_->formatLB->count() != 0 &&
103 !dialog_->commandCO->currentText().isEmpty();