2002-10-16 21:26:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file QSendto.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
2003-09-07 01:45:40 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
2002-10-16 21:26:35 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-10-16 21:26:35 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
|
#include "ControlSendto.h"
|
|
|
|
|
#include "QSendtoDialog.h"
|
|
|
|
|
#include "QSendto.h"
|
|
|
|
|
|
|
|
|
|
#include <qcombobox.h>
|
|
|
|
|
#include <qlistbox.h>
|
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
|
#include "qt_helpers.h"
|
2003-02-28 09:49:49 +00:00
|
|
|
|
#include "format.h"
|
2002-10-16 21:26:35 +00:00
|
|
|
|
|
|
|
|
|
using std::vector;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2002-10-16 21:26:35 +00:00
|
|
|
|
|
2004-03-27 23:11:46 +00:00
|
|
|
|
typedef QController<ControlSendto, QView<QSendtoDialog> > base_class;
|
2002-10-16 21:26:35 +00:00
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2004-03-27 23:11:46 +00:00
|
|
|
|
QSendto::QSendto(Dialog & parent)
|
|
|
|
|
: base_class(parent, _("LyX: Send Document to Command"))
|
2002-10-16 21:26:35 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QSendto::build_dialog()
|
|
|
|
|
{
|
|
|
|
|
dialog_.reset(new QSendtoDialog(this));
|
|
|
|
|
|
|
|
|
|
// Manage the ok, apply, restore and cancel/close buttons
|
2003-03-10 03:13:28 +00:00
|
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
|
bcview().setApply(dialog_->applyPB);
|
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
2002-10-16 21:26:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
dialog_->formatLB->clear();
|
|
|
|
|
|
|
|
|
|
for (vector<string>::const_iterator it = keys.begin();
|
|
|
|
|
it < keys.end(); ++it) {
|
2002-12-17 20:37:13 +00:00
|
|
|
|
dialog_->formatLB->insertItem(toqstr(*it));
|
2002-10-16 21:26:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
|
dialog_->commandCO->insertItem(toqstr(controller().getCommand()));
|
2002-10-16 21:26:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-10-16 21:26:35 +00:00
|
|
|
|
void QSendto::apply()
|
|
|
|
|
{
|
|
|
|
|
int const line(dialog_->formatLB->currentItem());
|
|
|
|
|
|
2003-11-20 01:22:51 +00:00
|
|
|
|
if (line < 0 || line > int(dialog_->formatLB->count()))
|
2002-10-16 21:26:35 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
|
string const cmd(fromqstr(dialog_->commandCO->currentText()));
|
2002-10-16 21:26:35 +00:00
|
|
|
|
|
|
|
|
|
controller().setFormat(all_formats_[line]);
|
|
|
|
|
controller().setCommand(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-10-16 21:26:35 +00:00
|
|
|
|
bool QSendto::isValid()
|
|
|
|
|
{
|
|
|
|
|
int const line(dialog_->formatLB->currentItem());
|
|
|
|
|
|
2003-11-20 01:22:51 +00:00
|
|
|
|
if (line < 0 || line > int(dialog_->formatLB->count()))
|
2002-10-16 21:26:35 +00:00
|
|
|
|
return false;
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-10-16 21:26:35 +00:00
|
|
|
|
else return dialog_->formatLB->count() != 0 &&
|
2002-11-30 02:09:16 +00:00
|
|
|
|
!dialog_->commandCO->currentText().isEmpty();
|
2002-10-16 21:26:35 +00:00
|
|
|
|
}
|