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"
14 #include "qt_helpers.h"
18 #include <QListWidget>
19 #include <QPushButton>
20 #include <QCloseEvent>
29 /////////////////////////////////////////////////////////////////////
33 /////////////////////////////////////////////////////////////////////
35 GuiSendtoDialog::GuiSendtoDialog(GuiSendto * form)
40 connect(okPB, SIGNAL(clicked()),
41 form, SLOT(slotOK()));
42 connect(applyPB, SIGNAL(clicked()),
43 form, SLOT(slotApply()));
44 connect(closePB, SIGNAL(clicked()),
45 form, SLOT(slotClose()));
47 connect( formatLW, SIGNAL( itemClicked(QListWidgetItem *) ),
48 this, SLOT( slotFormatHighlighted(QListWidgetItem *) ) );
49 connect( formatLW, SIGNAL( itemActivated(QListWidgetItem *) ),
50 this, SLOT( slotFormatSelected(QListWidgetItem *) ) );
51 connect( formatLW, SIGNAL( itemClicked(QListWidgetItem *) ),
52 this, SLOT( changed_adaptor() ) );
53 connect( commandCO, SIGNAL( textChanged(const QString&) ),
54 this, SLOT( changed_adaptor() ) );
58 void GuiSendtoDialog::changed_adaptor()
64 void GuiSendtoDialog::closeEvent(QCloseEvent * e)
71 /////////////////////////////////////////////////////////////////////
75 /////////////////////////////////////////////////////////////////////
78 GuiSendto::GuiSendto(GuiDialog & parent)
79 : GuiView<GuiSendtoDialog>(parent, _("Send Document to Command"))
84 void GuiSendto::build_dialog()
86 dialog_.reset(new GuiSendtoDialog(this));
88 // Manage the ok, apply, restore and cancel/close buttons
89 bc().setOK(dialog_->okPB);
90 bc().setApply(dialog_->applyPB);
91 bc().setCancel(dialog_->closePB);
95 void GuiSendto::update_contents()
97 all_formats_ = controller().allFormats();
99 // Check whether the current contents of the browser will be
100 // changed by loading the contents of formats
102 keys.resize(all_formats_.size());
104 vector<string>::iterator result = keys.begin();
105 vector<Format const *>::const_iterator it = all_formats_.begin();
106 vector<Format const *>::const_iterator end = all_formats_.end();
107 for (; it != end; ++it, ++result) {
108 *result = (*it)->prettyname();
111 // Reload the browser
112 dialog_->formatLW->clear();
114 for (vector<string>::const_iterator it = keys.begin();
115 it < keys.end(); ++it) {
116 dialog_->formatLW->addItem(toqstr(*it));
119 dialog_->commandCO->addItem(toqstr(controller().getCommand()));
123 void GuiSendto::apply()
125 int const line(dialog_->formatLW->currentRow());
127 if (line < 0 || line > int(dialog_->formatLW->count()))
130 string const cmd(fromqstr(dialog_->commandCO->currentText()));
132 controller().setFormat(all_formats_[line]);
133 controller().setCommand(cmd);
137 bool GuiSendto::isValid()
139 int const line(dialog_->formatLW->currentRow());
141 if (line < 0 || line > int(dialog_->formatLW->count()))
144 else return dialog_->formatLW->count() != 0 &&
145 !dialog_->commandCO->currentText().isEmpty();
148 } // namespace frontend
151 #include "GuiSendto_moc.cpp"