2001-08-28 01:27:35 +00:00
|
|
|
/**
|
|
|
|
* \file QInclude.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-28 01:27:35 +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-28 01:27:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "ControlInclude.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "QIncludeDialog.h"
|
|
|
|
#include "QInclude.h"
|
|
|
|
#include "Qt2BC.h"
|
2001-08-28 01:27:35 +00:00
|
|
|
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qcheckbox.h>
|
2002-07-22 14:04:38 +00:00
|
|
|
#include <qcombobox.h>
|
2001-08-28 01:27:35 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-03-05 14:59:37 +00:00
|
|
|
typedef QController<ControlInclude, QView<QIncludeDialog> > base_class;
|
2001-08-28 01:27:35 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-03-05 14:59:37 +00:00
|
|
|
QInclude::QInclude(Dialog & parent)
|
2003-05-22 15:42:50 +00:00
|
|
|
: base_class(parent, _("LyX: Child Document"))
|
2003-03-05 14:59:37 +00:00
|
|
|
{}
|
2001-08-28 01:27:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
void QInclude::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QIncludeDialog(this));
|
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
bcview().addReadOnly(dialog_->filenameED);
|
|
|
|
bcview().addReadOnly(dialog_->browsePB);
|
|
|
|
bcview().addReadOnly(dialog_->visiblespaceCB);
|
|
|
|
bcview().addReadOnly(dialog_->typeCO);
|
2001-08-28 01:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QInclude::update_contents()
|
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
InsetInclude::Params const & params = controller().params();
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->filenameED->setText(toqstr(params.cparams.getContents()));
|
2001-08-28 01:27:35 +00:00
|
|
|
|
|
|
|
dialog_->visiblespaceCB->setChecked(false);
|
|
|
|
dialog_->visiblespaceCB->setEnabled(false);
|
2002-12-03 05:09:50 +00:00
|
|
|
dialog_->previewCB->setChecked(false);
|
|
|
|
dialog_->previewCB->setEnabled(false);
|
2001-08-28 01:27:35 +00:00
|
|
|
|
2003-09-18 17:22:36 +00:00
|
|
|
string cmdname = controller().params().cparams.getCmdName();
|
|
|
|
if (cmdname != "include" &&
|
|
|
|
cmdname != "verbatiminput" &&
|
|
|
|
cmdname != "verbatiminput*")
|
|
|
|
cmdname = "input";
|
|
|
|
|
|
|
|
if (cmdname == "input") {
|
|
|
|
dialog_->typeCO->setCurrentItem(0);
|
|
|
|
dialog_->previewCB->setEnabled(true);
|
|
|
|
dialog_->previewCB->setChecked(params.cparams.preview());
|
|
|
|
|
|
|
|
} else if (cmdname == "include") {
|
|
|
|
dialog_->typeCO->setCurrentItem(1);
|
|
|
|
|
|
|
|
} else if (cmdname == "verbatiminput*") {
|
|
|
|
dialog_->typeCO->setCurrentItem(2);
|
|
|
|
dialog_->visiblespaceCB->setEnabled(true);
|
|
|
|
dialog_->visiblespaceCB->setChecked(true);
|
|
|
|
|
|
|
|
} else if (cmdname == "verbatiminput") {
|
|
|
|
dialog_->typeCO->setCurrentItem(2);
|
|
|
|
dialog_->visiblespaceCB->setEnabled(true);
|
2001-08-28 01:27:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QInclude::apply()
|
|
|
|
{
|
2003-03-05 14:59:37 +00:00
|
|
|
InsetInclude::Params params = controller().params();
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
params.cparams.setContents(fromqstr(dialog_->filenameED->text()));
|
2002-12-03 05:09:50 +00:00
|
|
|
params.cparams.preview(dialog_->previewCB->isChecked());
|
2001-08-28 01:27:35 +00:00
|
|
|
|
2002-07-22 14:04:38 +00:00
|
|
|
int const item = dialog_->typeCO->currentItem();
|
2002-09-10 18:44:53 +00:00
|
|
|
if (item == 0)
|
2003-09-18 17:22:36 +00:00
|
|
|
params.cparams.setCmdName("input");
|
2002-09-10 18:44:53 +00:00
|
|
|
else if (item == 1)
|
2003-09-18 17:22:36 +00:00
|
|
|
params.cparams.setCmdName("include");
|
2001-08-28 01:27:35 +00:00
|
|
|
else {
|
|
|
|
if (dialog_->visiblespaceCB->isChecked())
|
2003-09-18 17:22:36 +00:00
|
|
|
params.cparams.setCmdName("verbatiminput*");
|
2001-08-28 01:27:35 +00:00
|
|
|
else
|
2003-09-18 17:22:36 +00:00
|
|
|
params.cparams.setCmdName("verbatiminput");
|
2001-08-28 01:27:35 +00:00
|
|
|
}
|
2003-03-05 14:59:37 +00:00
|
|
|
controller().setParams(params);
|
2001-08-28 01:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QInclude::browse()
|
|
|
|
{
|
|
|
|
ControlInclude::Type type;
|
|
|
|
|
2002-07-22 14:04:38 +00:00
|
|
|
int const item = dialog_->typeCO->currentItem();
|
2002-10-20 01:48:28 +00:00
|
|
|
if (item == 0)
|
2001-08-28 01:27:35 +00:00
|
|
|
type = ControlInclude::INPUT;
|
2002-10-20 01:48:28 +00:00
|
|
|
else if (item == 1)
|
2002-09-10 18:44:53 +00:00
|
|
|
type = ControlInclude::INCLUDE;
|
2001-08-28 01:27:35 +00:00
|
|
|
else
|
|
|
|
type = ControlInclude::VERBATIM;
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
string const & name = controller().Browse(fromqstr(dialog_->filenameED->text()), type);
|
2001-08-28 01:27:35 +00:00
|
|
|
if (!name.empty())
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->filenameED->setText(toqstr(name));
|
2001-08-28 01:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QInclude::load()
|
|
|
|
{
|
|
|
|
if (isValid()) {
|
2002-12-17 20:37:13 +00:00
|
|
|
string const file(fromqstr(dialog_->filenameED->text()));
|
2001-08-28 01:27:35 +00:00
|
|
|
slotOK();
|
|
|
|
controller().load(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QInclude::isValid()
|
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
return !dialog_->filenameED->text().isEmpty();
|
2001-08-28 01:27:35 +00:00
|
|
|
}
|