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.
13 #include "GuiSendto.h"
15 #include "qt_helpers.h"
19 #include <QListWidget>
20 #include <QPushButton>
21 #include <QCloseEvent>
30 /////////////////////////////////////////////////////////////////////
34 /////////////////////////////////////////////////////////////////////
36 GuiSendtoDialog::GuiSendtoDialog(GuiSendto * form)
41 connect(okPB, SIGNAL(clicked()),
42 form, SLOT(slotOK()));
43 connect(applyPB, SIGNAL(clicked()),
44 form, SLOT(slotApply()));
45 connect(closePB, SIGNAL(clicked()),
46 form, SLOT(slotClose()));
48 connect( formatLW, SIGNAL( itemClicked(QListWidgetItem *) ),
49 this, SLOT( slotFormatHighlighted(QListWidgetItem *) ) );
50 connect( formatLW, SIGNAL( itemActivated(QListWidgetItem *) ),
51 this, SLOT( slotFormatSelected(QListWidgetItem *) ) );
52 connect( formatLW, SIGNAL( itemClicked(QListWidgetItem *) ),
53 this, SLOT( changed_adaptor() ) );
54 connect( commandCO, SIGNAL( textChanged(const QString&) ),
55 this, SLOT( changed_adaptor() ) );
59 void GuiSendtoDialog::changed_adaptor()
65 void GuiSendtoDialog::closeEvent(QCloseEvent * e)
72 /////////////////////////////////////////////////////////////////////
76 /////////////////////////////////////////////////////////////////////
79 GuiSendto::GuiSendto(Dialog & parent)
80 : GuiView<GuiSendtoDialog>(parent, _("Send Document to Command"))
85 void GuiSendto::build_dialog()
87 dialog_.reset(new GuiSendtoDialog(this));
89 // Manage the ok, apply, restore and cancel/close buttons
90 bcview().setOK(dialog_->okPB);
91 bcview().setApply(dialog_->applyPB);
92 bcview().setCancel(dialog_->closePB);
96 void GuiSendto::update_contents()
98 all_formats_ = controller().allFormats();
100 // Check whether the current contents of the browser will be
101 // changed by loading the contents of formats
103 keys.resize(all_formats_.size());
105 vector<string>::iterator result = keys.begin();
106 vector<Format const *>::const_iterator it = all_formats_.begin();
107 vector<Format const *>::const_iterator end = all_formats_.end();
108 for (; it != end; ++it, ++result) {
109 *result = (*it)->prettyname();
112 // Reload the browser
113 dialog_->formatLW->clear();
115 for (vector<string>::const_iterator it = keys.begin();
116 it < keys.end(); ++it) {
117 dialog_->formatLW->addItem(toqstr(*it));
120 dialog_->commandCO->addItem(toqstr(controller().getCommand()));
124 void GuiSendto::apply()
126 int const line(dialog_->formatLW->currentRow());
128 if (line < 0 || line > int(dialog_->formatLW->count()))
131 string const cmd(fromqstr(dialog_->commandCO->currentText()));
133 controller().setFormat(all_formats_[line]);
134 controller().setCommand(cmd);
138 bool GuiSendto::isValid()
140 int const line(dialog_->formatLW->currentRow());
142 if (line < 0 || line > int(dialog_->formatLW->count()))
145 else return dialog_->formatLW->count() != 0 &&
146 !dialog_->commandCO->currentText().isEmpty();
149 } // namespace frontend
152 #include "GuiSendto_moc.cpp"