mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 21:49:51 +00:00
77b9dbd557
* src/LaTeX.C (LaTeX::deplog): Assume that filenames in log files are stored in the file system encoding * src/frontends/qt4/qt_helpers.[Ch] (internal_path): delete * src/frontends/qt4/QGraphics.C: Adjust to change above * src/frontends/qt4/QPrefsDialog.C: ditto * src/frontends/qt4/QExternal.C: ditto * src/frontends/qt4/QInclude.C: ditto * src/support/os.h: Document the encoding of filename arguments * src/support/os_win32.h: ditto * src/support/filetools.C (findtexfile): Convert filename from file system encoding * src/support/os_win32.C: Convert filenames from utf8 to file system encoding and vice versa where needed * src/support/os_cygwin.C: ditto * src/support/getcwd.C (getcwd): Use internal_path() with correct encoding * src/support/docstring.[Ch] (from_filesystem8bit): new conversion function * src/support/environment.C (getEnv): convert environment variable from local 8bit encoding to utf8 (setEnv): convert environment variable from utf8 to local 8bit encoding * src/support/environment.h: document encoding of function arguments git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16753 a592a061-630c-0410-9148-cb99ea01b6c8
160 lines
3.5 KiB
C
160 lines
3.5 KiB
C
/**
|
|
* \file QInclude.C
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author John Levon
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "support/os.h"
|
|
|
|
#include "QIncludeDialog.h"
|
|
#include "QInclude.h"
|
|
|
|
#include "checkedwidgets.h"
|
|
#include "Qt2BC.h"
|
|
#include "qt_helpers.h"
|
|
#include "validators.h"
|
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "controllers/ControlInclude.h"
|
|
|
|
#include <qlineedit.h>
|
|
#include <qpushbutton.h>
|
|
#include <qcheckbox.h>
|
|
|
|
using std::string;
|
|
|
|
using lyx::support::os::internal_path;
|
|
|
|
namespace lyx {
|
|
namespace frontend {
|
|
|
|
typedef QController<ControlInclude, QView<QIncludeDialog> > base_class;
|
|
|
|
|
|
QInclude::QInclude(Dialog & parent)
|
|
: base_class(parent, _("Child Document"))
|
|
{}
|
|
|
|
|
|
void QInclude::build_dialog()
|
|
{
|
|
dialog_.reset(new QIncludeDialog(this));
|
|
|
|
bcview().setOK(dialog_->okPB);
|
|
bcview().setCancel(dialog_->closePB);
|
|
bcview().addReadOnly(dialog_->filenameED);
|
|
bcview().addReadOnly(dialog_->browsePB);
|
|
bcview().addReadOnly(dialog_->visiblespaceCB);
|
|
bcview().addReadOnly(dialog_->typeCO);
|
|
|
|
addCheckedLineEdit(bcview(), dialog_->filenameED, dialog_->filenameLA);
|
|
}
|
|
|
|
|
|
void QInclude::update_contents()
|
|
{
|
|
PathValidator * path_validator = getPathValidator(dialog_->filenameED);
|
|
if (path_validator)
|
|
path_validator->setChecker(kernel().docType(), lyxrc);
|
|
|
|
InsetCommandParams const & params = controller().params();
|
|
|
|
dialog_->filenameED->setText(toqstr(params["filename"]));
|
|
|
|
dialog_->visiblespaceCB->setChecked(false);
|
|
dialog_->visiblespaceCB->setEnabled(false);
|
|
dialog_->previewCB->setChecked(false);
|
|
dialog_->previewCB->setEnabled(false);
|
|
|
|
string cmdname = controller().params().getCmdName();
|
|
if (cmdname != "include" &&
|
|
cmdname != "verbatiminput" &&
|
|
cmdname != "verbatiminput*")
|
|
cmdname = "input";
|
|
|
|
if (cmdname == "input") {
|
|
dialog_->typeCO->setCurrentIndex(0);
|
|
dialog_->previewCB->setEnabled(true);
|
|
dialog_->previewCB->setChecked(params.preview());
|
|
|
|
} else if (cmdname == "include") {
|
|
dialog_->typeCO->setCurrentIndex(1);
|
|
|
|
} else if (cmdname == "verbatiminput*") {
|
|
dialog_->typeCO->setCurrentIndex(2);
|
|
dialog_->visiblespaceCB->setEnabled(true);
|
|
dialog_->visiblespaceCB->setChecked(true);
|
|
|
|
} else if (cmdname == "verbatiminput") {
|
|
dialog_->typeCO->setCurrentIndex(2);
|
|
dialog_->visiblespaceCB->setEnabled(true);
|
|
}
|
|
}
|
|
|
|
|
|
void QInclude::apply()
|
|
{
|
|
InsetCommandParams params = controller().params();
|
|
|
|
params["filename"] = from_utf8(internal_path(fromqstr(dialog_->filenameED->text())));
|
|
params.preview(dialog_->previewCB->isChecked());
|
|
|
|
int const item = dialog_->typeCO->currentIndex();
|
|
if (item == 0)
|
|
params.setCmdName("input");
|
|
else if (item == 1)
|
|
params.setCmdName("include");
|
|
else {
|
|
if (dialog_->visiblespaceCB->isChecked())
|
|
params.setCmdName("verbatiminput*");
|
|
else
|
|
params.setCmdName("verbatiminput");
|
|
}
|
|
controller().setParams(params);
|
|
}
|
|
|
|
|
|
void QInclude::browse()
|
|
{
|
|
ControlInclude::Type type;
|
|
|
|
int const item = dialog_->typeCO->currentIndex();
|
|
if (item == 0)
|
|
type = ControlInclude::INPUT;
|
|
else if (item == 1)
|
|
type = ControlInclude::INCLUDE;
|
|
else
|
|
type = ControlInclude::VERBATIM;
|
|
|
|
docstring const & name =
|
|
controller().browse(qstring_to_ucs4(dialog_->filenameED->text()), type);
|
|
if (!name.empty())
|
|
dialog_->filenameED->setText(toqstr(name));
|
|
}
|
|
|
|
|
|
void QInclude::load()
|
|
{
|
|
if (isValid()) {
|
|
string const file(fromqstr(dialog_->filenameED->text()));
|
|
slotOK();
|
|
controller().load(file);
|
|
}
|
|
}
|
|
|
|
|
|
bool QInclude::isValid()
|
|
{
|
|
return !dialog_->filenameED->text().isEmpty();
|
|
}
|
|
|
|
} // namespace frontend
|
|
} // namespace lyx
|