2001-08-27 01:19:32 +00:00
|
|
|
/**
|
|
|
|
* \file QExternal.C
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2002-03-21 21:21:28 +00:00
|
|
|
#include <vector>
|
2001-08-27 01:19:32 +00:00
|
|
|
|
|
|
|
#include "ControlExternal.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
2001-08-27 01:19:32 +00:00
|
|
|
typedef Qt2CB<ControlExternal, Qt2DB<QExternalDialog> > base_class;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 01:19:32 +00:00
|
|
|
QExternal::QExternal(ControlExternal & c)
|
|
|
|
: base_class(c, _("External"))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QExternal::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QExternalDialog(this));
|
|
|
|
|
|
|
|
bc().setOK(dialog_->okPB);
|
|
|
|
bc().setApply(dialog_->applyPB);
|
|
|
|
bc().setCancel(dialog_->closePB);
|
|
|
|
bc().addReadOnly(dialog_->externalCO);
|
|
|
|
bc().addReadOnly(dialog_->fileED);
|
|
|
|
bc().addReadOnly(dialog_->browsePB);
|
|
|
|
|
|
|
|
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) {
|
|
|
|
dialog_->externalCO->insertItem(cit->c_str(), -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
dialog_->fileED->setText(params.filename.c_str());
|
|
|
|
dialog_->paramsED->setText(params.parameters.c_str());
|
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-03-21 21:21:28 +00:00
|
|
|
dialog_->externalTV->setText(controller().params().templ.helpText.c_str());
|
2001-08-27 01:19:32 +00:00
|
|
|
isValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const & QExternal::helpText()
|
|
|
|
{
|
|
|
|
controller().params().templ = controller().getTemplate(dialog_->externalCO->currentItem() + 1);
|
2002-03-21 21:21:28 +00:00
|
|
|
return controller().params().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()
|
|
|
|
{
|
|
|
|
controller().params().filename =
|
|
|
|
string(dialog_->fileED->text().latin1());
|
|
|
|
controller().params().parameters =
|
|
|
|
string(dialog_->paramsED->text().latin1());
|
|
|
|
|
|
|
|
controller().params().templ = controller().getTemplate(dialog_->externalCO->currentItem() + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QExternal::isValid()
|
|
|
|
{
|
|
|
|
bool const valid = !string(dialog_->fileED->text()).empty();
|
2002-03-21 21:21:28 +00:00
|
|
|
dialog_->viewPB->setEnabled(valid);
|
|
|
|
dialog_->editPB->setEnabled(valid);
|
|
|
|
dialog_->updatePB->setEnabled(valid);
|
2001-08-27 01:19:32 +00:00
|
|
|
return valid;
|
|
|
|
}
|