2001-08-27 01:19:32 +00:00
|
|
|
/**
|
|
|
|
* \file QExternal.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-08-27 01:19:32 +00:00
|
|
|
*
|
2002-10-20 01:48:28 +00:00
|
|
|
* \author John Levon
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-08-27 01:19:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2002-09-24 13:57:09 +00:00
|
|
|
|
|
|
|
|
2001-08-27 01:19:32 +00:00
|
|
|
#include "ControlExternal.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2001-08-27 01:19:32 +00:00
|
|
|
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
2002-03-21 21:21:28 +00:00
|
|
|
#include <qcombobox.h>
|
2001-08-27 01:19:32 +00:00
|
|
|
#include <qtextview.h>
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "QExternalDialog.h"
|
|
|
|
#include "QExternal.h"
|
|
|
|
#include "Qt2BC.h"
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2003-03-05 11:30:35 +00:00
|
|
|
typedef QController<ControlExternal, QView<QExternalDialog> > base_class;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-03-05 11:30:35 +00:00
|
|
|
QExternal::QExternal(Dialog & parent)
|
|
|
|
: base_class(parent, qt_("LyX: Insert External Material"))
|
2001-08-27 01:19:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QExternal::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QExternalDialog(this));
|
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
bcview().setApply(dialog_->applyPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
bcview().addReadOnly(dialog_->externalCO);
|
|
|
|
bcview().addReadOnly(dialog_->fileED);
|
|
|
|
bcview().addReadOnly(dialog_->browsePB);
|
2001-08-27 01:19:32 +00:00
|
|
|
|
|
|
|
std::vector<string> templates(controller().getTemplates());
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 01:19:32 +00:00
|
|
|
for (std::vector<string>::const_iterator cit = templates.begin();
|
|
|
|
cit != templates.end(); ++cit) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->externalCO->insertItem(toqstr(*cit), -1);
|
2001-08-27 01:19:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 01:19:32 +00:00
|
|
|
void QExternal::update_contents()
|
|
|
|
{
|
|
|
|
InsetExternal::Params const & params = controller().params();
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->fileED->setText(toqstr(params.filename));
|
|
|
|
dialog_->paramsED->setText(toqstr(params.parameters));
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 01:19:32 +00:00
|
|
|
dialog_->externalCO->setCurrentItem(controller().getTemplateNumber(params.templ.lyxName));
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->externalTV->setText(toqstr(params.templ.helpText));
|
2001-08-27 01:19:32 +00:00
|
|
|
isValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-05 11:30:35 +00:00
|
|
|
string const QExternal::helpText() const
|
2001-08-27 01:19:32 +00:00
|
|
|
{
|
2003-03-05 11:30:35 +00:00
|
|
|
ExternalTemplate templ =
|
|
|
|
controller().getTemplate(dialog_->externalCO->currentItem());
|
|
|
|
return templ.helpText;
|
2001-08-27 01:19:32 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 01:19:32 +00:00
|
|
|
void QExternal::apply()
|
|
|
|
{
|
2003-03-05 11:30:35 +00:00
|
|
|
InsetExternal::Params params = controller().params();
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
params.filename = fromqstr(dialog_->fileED->text());
|
|
|
|
params.parameters = fromqstr(dialog_->paramsED->text());
|
2001-08-27 01:19:32 +00:00
|
|
|
|
2002-10-31 20:45:57 +00:00
|
|
|
params.templ = controller().getTemplate(dialog_->externalCO->currentItem());
|
2003-03-05 11:30:35 +00:00
|
|
|
|
|
|
|
controller().setParams(params);
|
2001-08-27 01:19:32 +00:00
|
|
|
}
|