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"
|
2003-06-11 14:30:04 +00:00
|
|
|
|
|
|
|
#include "insets/ExternalTemplate.h"
|
|
|
|
|
2003-06-04 09:16:29 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "support/tostr.h"
|
2001-08-27 01:19:32 +00:00
|
|
|
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
2003-06-04 09:16:29 +00:00
|
|
|
#include <qcheckbox.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)
|
2003-05-22 15:42:50 +00:00
|
|
|
: base_class(parent, _("LyX: 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));
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-06-11 14:30:04 +00:00
|
|
|
dialog_->externalCO->setCurrentItem(controller().getTemplateNumber(params.templatename));
|
2003-06-10 11:00:53 +00:00
|
|
|
dialog_->externalTV->setText(toqstr(helpText()));
|
2003-06-04 09:16:29 +00:00
|
|
|
|
|
|
|
int item = 0;
|
|
|
|
switch (params.display) {
|
|
|
|
case grfx::DefaultDisplay: item = 0; break;
|
|
|
|
case grfx::MonochromeDisplay: item = 1; break;
|
|
|
|
case grfx::GrayscaleDisplay: item = 2; break;
|
|
|
|
case grfx::ColorDisplay: item = 3; break;
|
|
|
|
case grfx::NoDisplay: item = 0; break;
|
|
|
|
}
|
|
|
|
dialog_->showCB->setCurrentItem(item);
|
|
|
|
dialog_->showCB->setEnabled(params.display != grfx::NoDisplay &&
|
|
|
|
!readOnly());
|
|
|
|
dialog_->displayCB->setChecked(params.display != grfx::NoDisplay);
|
|
|
|
dialog_->displayscale->setEnabled(params.display != grfx::NoDisplay &&
|
|
|
|
!readOnly());
|
|
|
|
dialog_->displayscale->setText(toqstr(tostr(params.lyxscale)));
|
|
|
|
|
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());
|
2001-08-27 01:19:32 +00:00
|
|
|
|
2003-06-11 14:30:04 +00:00
|
|
|
params.templatename =
|
|
|
|
controller().getTemplate(dialog_->externalCO->currentItem()).lyxName;
|
2003-03-05 11:30:35 +00:00
|
|
|
|
2003-06-04 09:16:29 +00:00
|
|
|
switch (dialog_->showCB->currentItem()) {
|
|
|
|
case 0: params.display = grfx::DefaultDisplay; break;
|
|
|
|
case 1: params.display = grfx::MonochromeDisplay; break;
|
|
|
|
case 2: params.display = grfx::GrayscaleDisplay; break;
|
|
|
|
case 3: params.display = grfx::ColorDisplay; break;
|
|
|
|
default:;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dialog_->displayCB->isChecked())
|
|
|
|
params.display = grfx::NoDisplay;
|
|
|
|
|
|
|
|
params.lyxscale = strToInt(fromqstr(dialog_->displayscale->text()));
|
|
|
|
|
2003-03-05 11:30:35 +00:00
|
|
|
controller().setParams(params);
|
2001-08-27 01:19:32 +00:00
|
|
|
}
|