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.
15 #include "qt_helpers.h"
19 #include "controllers/ControlSendto.h"
21 #include <QListWidget>
22 #include <QPushButton>
23 #include <QCloseEvent>
32 /////////////////////////////////////////////////////////////////////
36 /////////////////////////////////////////////////////////////////////
38 QSendtoDialog::QSendtoDialog(QSendto * form)
43 connect(okPB, SIGNAL(clicked()),
44 form, SLOT(slotOK()));
45 connect(applyPB, SIGNAL(clicked()),
46 form, SLOT(slotApply()));
47 connect(closePB, SIGNAL(clicked()),
48 form, SLOT(slotClose()));
50 connect( formatLW, SIGNAL( itemClicked(QListWidgetItem *) ),
51 this, SLOT( slotFormatHighlighted(QListWidgetItem *) ) );
52 connect( formatLW, SIGNAL( itemActivated(QListWidgetItem *) ),
53 this, SLOT( slotFormatSelected(QListWidgetItem *) ) );
54 connect( formatLW, SIGNAL( itemClicked(QListWidgetItem *) ),
55 this, SLOT( changed_adaptor() ) );
56 connect( commandCO, SIGNAL( textChanged(const QString&) ),
57 this, SLOT( changed_adaptor() ) );
61 void QSendtoDialog::changed_adaptor()
67 void QSendtoDialog::closeEvent(QCloseEvent * e)
74 /////////////////////////////////////////////////////////////////////
78 /////////////////////////////////////////////////////////////////////
80 typedef QController<ControlSendto, QView<QSendtoDialog> > SendtoBase;
83 QSendto::QSendto(Dialog & parent)
84 : SendtoBase(parent, _("Send Document to Command"))
89 void QSendto::build_dialog()
91 dialog_.reset(new QSendtoDialog(this));
93 // Manage the ok, apply, restore and cancel/close buttons
94 bcview().setOK(dialog_->okPB);
95 bcview().setApply(dialog_->applyPB);
96 bcview().setCancel(dialog_->closePB);
100 void QSendto::update_contents()
102 all_formats_ = controller().allFormats();
104 // Check whether the current contents of the browser will be
105 // changed by loading the contents of formats
107 keys.resize(all_formats_.size());
109 vector<string>::iterator result = keys.begin();
110 vector<Format const *>::const_iterator it = all_formats_.begin();
111 vector<Format const *>::const_iterator end = all_formats_.end();
112 for (; it != end; ++it, ++result) {
113 *result = (*it)->prettyname();
116 // Reload the browser
117 dialog_->formatLW->clear();
119 for (vector<string>::const_iterator it = keys.begin();
120 it < keys.end(); ++it) {
121 dialog_->formatLW->addItem(toqstr(*it));
124 dialog_->commandCO->addItem(toqstr(controller().getCommand()));
128 void QSendto::apply()
130 int const line(dialog_->formatLW->currentRow());
132 if (line < 0 || line > int(dialog_->formatLW->count()))
135 string const cmd(fromqstr(dialog_->commandCO->currentText()));
137 controller().setFormat(all_formats_[line]);
138 controller().setCommand(cmd);
142 bool QSendto::isValid()
144 int const line(dialog_->formatLW->currentRow());
146 if (line < 0 || line > int(dialog_->formatLW->count()))
149 else return dialog_->formatLW->count() != 0 &&
150 !dialog_->commandCO->currentText().isEmpty();
153 } // namespace frontend
156 #include "QSendto_moc.cpp"