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 "ControlSendto.h"
16 #include "qt_helpers.h"
20 #include <QListWidget>
21 #include <QPushButton>
22 #include <QCloseEvent>
31 GuiSendtoDialog::GuiSendtoDialog(LyXView & lv)
32 : GuiDialog(lv, "sendto")
35 setViewTitle(_("Send Document to Command"));
36 setController(new ControlSendto(*this));
38 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
39 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
40 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
42 connect(formatLW, SIGNAL(itemClicked(QListWidgetItem *)),
43 this, SLOT(slotFormatHighlighted(QListWidgetItem *)));
44 connect(formatLW, SIGNAL(itemActivated(QListWidgetItem *)),
45 this, SLOT(slotFormatSelected(QListWidgetItem *)));
46 connect(formatLW, SIGNAL(itemClicked(QListWidgetItem *)),
47 this, SLOT(changed_adaptor()));
48 connect(commandCO, SIGNAL(textChanged(const QString&)),
49 this, SLOT(changed_adaptor()));
51 bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
53 bc().setApply(applyPB);
54 bc().setCancel(closePB);
58 ControlSendto & GuiSendtoDialog::controller() const
60 return static_cast<ControlSendto &>(GuiDialog::controller());
64 void GuiSendtoDialog::changed_adaptor()
70 void GuiSendtoDialog::closeEvent(QCloseEvent * e)
77 void GuiSendtoDialog::update_contents()
79 all_formats_ = controller().allFormats();
81 // Check whether the current contents of the browser will be
82 // changed by loading the contents of formats
84 keys.resize(all_formats_.size());
86 vector<string>::iterator result = keys.begin();
87 vector<Format const *>::const_iterator it = all_formats_.begin();
88 vector<Format const *>::const_iterator end = all_formats_.end();
89 for (; it != end; ++it, ++result)
90 *result = (*it)->prettyname();
95 for (vector<string>::const_iterator it = keys.begin();
96 it != keys.end(); ++it) {
97 formatLW->addItem(toqstr(*it));
100 commandCO->addItem(toqstr(controller().getCommand()));
104 void GuiSendtoDialog::applyView()
106 int const line = formatLW->currentRow();
108 if (line < 0 || line > int(formatLW->count()))
111 controller().setFormat(all_formats_[line]);
112 controller().setCommand(fromqstr(commandCO->currentText()));
116 bool GuiSendtoDialog::isValid()
118 int const line = formatLW->currentRow();
120 if (line < 0 || line > int(formatLW->count()))
123 return formatLW->count() != 0 &&
124 !commandCO->currentText().isEmpty();
127 } // namespace frontend
130 #include "GuiSendto_moc.cpp"