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
|
|
|
*
|
2003-08-23 00:17:00 +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
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
using lyx::support::strToInt;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
|
2003-03-05 11:30:35 +00:00
|
|
|
typedef QController<ControlExternal, QView<QExternalDialog> > base_class;
|
2002-03-21 21:21: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();
|
|
|
|
|
2003-07-23 09:17:04 +00:00
|
|
|
string const name =
|
|
|
|
params.filename.outputFilename(kernel().bufferFilepath());
|
|
|
|
dialog_->fileED->setText(toqstr(name));
|
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) {
|
2003-07-21 21:30:57 +00:00
|
|
|
case lyx::graphics::DefaultDisplay: item = 0; break;
|
|
|
|
case lyx::graphics::MonochromeDisplay: item = 1; break;
|
|
|
|
case lyx::graphics::GrayscaleDisplay: item = 2; break;
|
|
|
|
case lyx::graphics::ColorDisplay: item = 3; break;
|
|
|
|
case lyx::graphics::NoDisplay: item = 0; break;
|
2003-06-04 09:16:29 +00:00
|
|
|
}
|
|
|
|
dialog_->showCB->setCurrentItem(item);
|
2003-07-21 21:30:57 +00:00
|
|
|
dialog_->showCB->setEnabled(params.display != lyx::graphics::NoDisplay &&
|
2003-06-04 09:16:29 +00:00
|
|
|
!readOnly());
|
2003-07-21 21:30:57 +00:00
|
|
|
dialog_->displayCB->setChecked(params.display != lyx::graphics::NoDisplay);
|
|
|
|
dialog_->displayscale->setEnabled(params.display != lyx::graphics::NoDisplay &&
|
2003-06-04 09:16:29 +00:00
|
|
|
!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
|
|
|
|
2003-07-23 09:17:04 +00:00
|
|
|
params.filename.set(fromqstr(dialog_->fileED->text()),
|
|
|
|
kernel().bufferFilepath());
|
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()) {
|
2003-07-21 21:30:57 +00:00
|
|
|
case 0: params.display = lyx::graphics::DefaultDisplay; break;
|
|
|
|
case 1: params.display = lyx::graphics::MonochromeDisplay; break;
|
|
|
|
case 2: params.display = lyx::graphics::GrayscaleDisplay; break;
|
|
|
|
case 3: params.display = lyx::graphics::ColorDisplay; break;
|
2003-06-04 09:16:29 +00:00
|
|
|
default:;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dialog_->displayCB->isChecked())
|
2003-07-21 21:30:57 +00:00
|
|
|
params.display = lyx::graphics::NoDisplay;
|
2003-06-04 09:16:29 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|