2006-03-05 17:24:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file QSendto.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "QSendto.h"
|
|
|
|
|
#include "QSendtoDialog.h"
|
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
|
|
#include "format.h"
|
|
|
|
|
|
|
|
|
|
#include "controllers/ControlSendto.h"
|
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
|
#include <QListWidget>
|
|
|
|
|
#include <QPushButton>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2007-03-22 23:07:24 +00:00
|
|
|
|
typedef QController<ControlSendto, QView<QSendtoDialog> > sendto_base_class;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QSendto::QSendto(Dialog & parent)
|
2007-03-22 23:07:24 +00:00
|
|
|
|
: sendto_base_class(parent, _("Send Document to Command"))
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QSendto::build_dialog()
|
|
|
|
|
{
|
|
|
|
|
dialog_.reset(new QSendtoDialog(this));
|
|
|
|
|
|
|
|
|
|
// Manage the ok, apply, restore and cancel/close buttons
|
|
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
|
bcview().setApply(dialog_->applyPB);
|
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QSendto::update_contents()
|
|
|
|
|
{
|
|
|
|
|
all_formats_ = controller().allFormats();
|
|
|
|
|
|
|
|
|
|
// Check whether the current contents of the browser will be
|
|
|
|
|
// changed by loading the contents of formats
|
|
|
|
|
vector<string> keys;
|
|
|
|
|
keys.resize(all_formats_.size());
|
|
|
|
|
|
|
|
|
|
vector<string>::iterator result = keys.begin();
|
|
|
|
|
vector<Format const *>::const_iterator it = all_formats_.begin();
|
|
|
|
|
vector<Format const *>::const_iterator end = all_formats_.end();
|
|
|
|
|
for (; it != end; ++it, ++result) {
|
|
|
|
|
*result = (*it)->prettyname();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reload the browser
|
2006-05-03 19:51:15 +00:00
|
|
|
|
dialog_->formatLW->clear();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
for (vector<string>::const_iterator it = keys.begin();
|
|
|
|
|
it < keys.end(); ++it) {
|
2006-05-03 19:51:15 +00:00
|
|
|
|
dialog_->formatLW->addItem(toqstr(*it));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-08-17 08:58:46 +00:00
|
|
|
|
dialog_->commandCO->addItem(toqstr(controller().getCommand()));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QSendto::apply()
|
|
|
|
|
{
|
2006-05-03 19:51:15 +00:00
|
|
|
|
int const line(dialog_->formatLW->currentRow());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
|
if (line < 0 || line > int(dialog_->formatLW->count()))
|
2006-03-05 17:24:44 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string const cmd(fromqstr(dialog_->commandCO->currentText()));
|
|
|
|
|
|
|
|
|
|
controller().setFormat(all_formats_[line]);
|
|
|
|
|
controller().setCommand(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool QSendto::isValid()
|
|
|
|
|
{
|
2006-05-03 19:51:15 +00:00
|
|
|
|
int const line(dialog_->formatLW->currentRow());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
|
if (line < 0 || line > int(dialog_->formatLW->count()))
|
2006-03-05 17:24:44 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
|
else return dialog_->formatLW->count() != 0 &&
|
2006-03-05 17:24:44 +00:00
|
|
|
|
!dialog_->commandCO->currentText().isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|