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
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-08-28 01:27:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ControlInclude.h"
|
|
|
|
#include "gettext.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
#include "debug.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
|
|
|
|
2001-08-28 01:27:35 +00:00
|
|
|
typedef Qt2CB<ControlInclude, Qt2DB<QIncludeDialog> > base_class;
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-08-12 14:28:43 +00:00
|
|
|
QInclude::QInclude()
|
|
|
|
: base_class(_("Include"))
|
2001-08-28 01:27:35 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QInclude::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QIncludeDialog(this));
|
|
|
|
|
|
|
|
bc().setOK(dialog_->okPB);
|
|
|
|
bc().setCancel(dialog_->closePB);
|
|
|
|
bc().addReadOnly(dialog_->filenameED);
|
|
|
|
bc().addReadOnly(dialog_->browsePB);
|
|
|
|
bc().addReadOnly(dialog_->visiblespaceCB);
|
2002-07-22 14:04:38 +00:00
|
|
|
bc().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();
|
|
|
|
|
|
|
|
dialog_->filenameED->setText(params.cparams.getContents().c_str());
|
2001-08-28 01:27:35 +00:00
|
|
|
|
|
|
|
dialog_->visiblespaceCB->setChecked(false);
|
|
|
|
dialog_->visiblespaceCB->setEnabled(false);
|
|
|
|
|
2002-11-07 22:15:53 +00:00
|
|
|
switch (params.flag) {
|
|
|
|
case InsetInclude::INPUT:
|
|
|
|
dialog_->typeCO->setCurrentItem(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case InsetInclude::INCLUDE:
|
|
|
|
dialog_->typeCO->setCurrentItem(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case InsetInclude::VERBAST:
|
|
|
|
dialog_->visiblespaceCB->setChecked(true);
|
|
|
|
/* fall through */
|
|
|
|
case InsetInclude::VERB:
|
|
|
|
dialog_->typeCO->setCurrentItem(2);
|
|
|
|
dialog_->visiblespaceCB->setEnabled(true);
|
|
|
|
break;
|
2001-08-28 01:27:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QInclude::apply()
|
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
InsetInclude::Params & params = controller().params();
|
|
|
|
|
|
|
|
params.cparams.setContents(dialog_->filenameED->text().latin1());
|
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)
|
2002-10-20 01:48:28 +00:00
|
|
|
params.flag = InsetInclude::INPUT;
|
2002-09-10 18:44:53 +00:00
|
|
|
else if (item == 1)
|
2002-10-20 01:48:28 +00:00
|
|
|
params.flag = InsetInclude::INCLUDE;
|
2001-08-28 01:27:35 +00:00
|
|
|
else {
|
|
|
|
if (dialog_->visiblespaceCB->isChecked())
|
2002-10-20 01:48:28 +00:00
|
|
|
params.flag = InsetInclude::VERBAST;
|
2001-08-28 01:27:35 +00:00
|
|
|
else
|
2002-10-20 01:48:28 +00:00
|
|
|
params.flag = InsetInclude::VERB;
|
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;
|
|
|
|
|
|
|
|
string const & name = controller().Browse(dialog_->filenameED->text().latin1(), type);
|
|
|
|
if (!name.empty())
|
2002-03-21 21:21:28 +00:00
|
|
|
dialog_->filenameED->setText(name.c_str());
|
2001-08-28 01:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QInclude::load()
|
|
|
|
{
|
|
|
|
if (isValid()) {
|
|
|
|
string const file(dialog_->filenameED->text().latin1());
|
|
|
|
slotOK();
|
|
|
|
controller().load(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QInclude::isValid()
|
|
|
|
{
|
|
|
|
return !string(dialog_->filenameED->text().latin1()).empty();
|
|
|
|
}
|