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.
14 #include "QSendtoDialog.h"
16 #include "qt_helpers.h"
20 #include "controllers/ControlSendto.h"
22 #include <QListWidget>
23 #include <QPushButton>
31 typedef QController<ControlSendto, QView<QSendtoDialog> > sendto_base_class;
34 QSendto::QSendto(Dialog & parent)
35 : sendto_base_class(parent, _("Send Document to Command"))
40 void QSendto::build_dialog()
42 dialog_.reset(new QSendtoDialog(this));
44 // Manage the ok, apply, restore and cancel/close buttons
45 bcview().setOK(dialog_->okPB);
46 bcview().setApply(dialog_->applyPB);
47 bcview().setCancel(dialog_->closePB);
51 void QSendto::update_contents()
53 all_formats_ = controller().allFormats();
55 // Check whether the current contents of the browser will be
56 // changed by loading the contents of formats
58 keys.resize(all_formats_.size());
60 vector<string>::iterator result = keys.begin();
61 vector<Format const *>::const_iterator it = all_formats_.begin();
62 vector<Format const *>::const_iterator end = all_formats_.end();
63 for (; it != end; ++it, ++result) {
64 *result = (*it)->prettyname();
68 dialog_->formatLW->clear();
70 for (vector<string>::const_iterator it = keys.begin();
71 it < keys.end(); ++it) {
72 dialog_->formatLW->addItem(toqstr(*it));
75 dialog_->commandCO->addItem(toqstr(controller().getCommand()));
81 int const line(dialog_->formatLW->currentRow());
83 if (line < 0 || line > int(dialog_->formatLW->count()))
86 string const cmd(fromqstr(dialog_->commandCO->currentText()));
88 controller().setFormat(all_formats_[line]);
89 controller().setCommand(cmd);
93 bool QSendto::isValid()
95 int const line(dialog_->formatLW->currentRow());
97 if (line < 0 || line > int(dialog_->formatLW->count()))
100 else return dialog_->formatLW->count() != 0 &&
101 !dialog_->commandCO->currentText().isEmpty();
104 } // namespace frontend