#include "BufferParams.h"
#include "BufferView.h"
#include "Color.h"
+#include "EmbeddedFiles.h"
#include "Encoding.h"
#include "FloatPlacement.h"
-#include "frontend_helpers.h"
#include "FuncRequest.h"
-#include "gettext.h"
+#include "support/gettext.h"
#include "GuiBranches.h"
#include "Language.h"
#include "LaTeXFeatures.h"
#include "TextClassList.h"
#include "Validator.h"
-
-// FIXME: those two headers are needed because of the
-// WorkArea::redraw() call below.
-#include "frontends/LyXView.h"
-#include "frontends/WorkArea.h"
-
#include "insets/InsetListingsParams.h"
+#include "support/FileName.h"
+#include "support/filetools.h"
#include "support/lstrings.h"
#include <boost/bind.hpp>
#include <algorithm>
#include <sstream>
-using std::distance;
-using std::make_pair;
-using std::pair;
-using std::vector;
-using std::string;
-using std::ostringstream;
-using std::sort;
+using namespace std;
+using namespace lyx::support;
///
template<class Pair>
-std::vector<typename Pair::second_type> const
-getSecond(std::vector<Pair> const & pr)
+vector<typename Pair::second_type> const
+getSecond(vector<Pair> const & pr)
{
- std::vector<typename Pair::second_type> tmp(pr.size());
- std::transform(pr.begin(), pr.end(), tmp.begin(),
+ vector<typename Pair::second_type> tmp(pr.size());
+ transform(pr.begin(), pr.end(), tmp.begin(),
boost::bind(&Pair::second, _1));
return tmp;
}
namespace lyx {
namespace frontend {
-using support::token;
-using support::bformat;
-using support::findToken;
-using support::getVectorFromString;
-
/////////////////////////////////////////////////////////////////////
//
// PreambleModule
-GuiDocument::GuiDocument(LyXView & lv)
- : GuiDialog(lv, "document"), Controller(this)
+GuiDocument::GuiDocument(GuiView & lv)
+ : GuiDialog(lv, "document")
{
setupUi(this);
- setController(this, false);
setViewTitle(_("Document Settings"));
lang_ = getSecond(getLanguageData(false));
connect(bulletsModule, SIGNAL(changed()),
this, SLOT(change_adaptor()));
+ // embedded files
+ embeddedFilesModule = new UiWidget<Ui::EmbeddedFilesUi>;
+ connect(embeddedFilesModule->bundleCB, SIGNAL(toggled(bool)),
+ this, SLOT(change_adaptor()));
+ connect(embeddedFilesModule->addPB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(embeddedFilesModule->removePB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+
// PDF support
pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
this, SLOT(change_adaptor()));
connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor()));
+ connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)),
+ this, SLOT(change_adaptor()));
connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor()));
connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
docPS->addPanel(floatModule, _("Float Placement"));
docPS->addPanel(bulletsModule, _("Bullets"));
docPS->addPanel(branchesModule, _("Branches"));
+ docPS->addPanel(embeddedFilesModule, _("Embedded Files"));
docPS->addPanel(preambleModule, _("LaTeX Preamble"));
docPS->setCurrentPanel(_("Document Class"));
// FIXME: hack to work around resizing bug in Qt >= 4.2
void GuiDocument::classChanged()
{
textclass_type const tc = latexModule->classCO->currentIndex();
- bp_.setJustBaseClass(tc);
+ bp_.setBaseClass(tc);
if (lyxrc.auto_reset_options)
bp_.useClassDefaults();
updateContents();
}
pkgdesc += pkgList[i];
}
- if (!pkgdesc.empty())
- desc += " Requires " + pkgdesc + ".";
+ if (!pkgdesc.empty()) {
+ if (!desc.empty())
+ desc += " ";
+ desc += ("Requires " + pkgdesc + ".");
+ }
+ if (!isModuleAvailable(modName)) {
+ if (!desc.empty())
+ desc += "\n";
+ desc += "WARNING: Some packages are unavailable!";
+ }
latexModule->infoML->document()->setPlainText(toqstr(desc));
}
}
+void GuiDocument::updateEmbeddedFileList()
+{
+ embeddedFilesModule->filesLW->clear();
+ // add current embedded files
+ EmbeddedFiles & files = buffer().embeddedFiles();
+ files.update();
+ EmbeddedFiles::EmbeddedFileList::iterator fit = files.begin();
+ EmbeddedFiles::EmbeddedFileList::iterator fit_end = files.end();
+ for (; fit != fit_end; ++fit) {
+ QString label = toqstr(fit->relFilename(buffer().filePath()));
+ if (fit->refCount() > 1)
+ label += " (" + QString::number(fit->refCount()) + ")";
+ QListWidgetItem * item = new QListWidgetItem(label);
+ item->setFlags(item->flags() | Qt::ItemIsSelectable
+ | Qt::ItemIsUserCheckable);
+ if(fit->embedded())
+ item->setCheckState(Qt::Checked);
+ else
+ item->setCheckState(Qt::Unchecked);
+ // index of the currently used ParConstIterator
+ embeddedFilesModule->filesLW->addItem(item);
+ }
+}
+
+
void GuiDocument::updateNumbering()
{
TextClass const & tclass = bp_.getTextClass();
params.graphicsDriver =
tex_graphics[latexModule->psdriverCO->currentIndex()];
+ // text layout
+ params.setBaseClass(latexModule->classCO->currentIndex());
+
// Modules
params.clearLayoutModules();
QStringList const selMods = selectedModel()->stringList();
for (int i = 0; i != selMods.size(); ++i)
params.addLayoutModule(lyx::fromqstr(selMods[i]));
-
if (mathsModule->amsautoCB->isChecked()) {
params.use_amsmath = BufferParams::package_auto;
} else {
params.use_esint = BufferParams::package_off;
}
- // text layout
- params.setJustBaseClass(latexModule->classCO->currentIndex());
-
if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
params.pagestyle = "default";
else {
pageLayoutModule->paperheightUnitCO);
if (pageLayoutModule->facingPagesCB->isChecked())
- params.sides = TextClass::TwoSides;
+ params.sides = TwoSides;
else
- params.sides = TextClass::OneSide;
+ params.sides = OneSide;
if (pageLayoutModule->landscapeRB->isChecked())
params.orientation = ORIENTATION_LANDSCAPE;
pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked();
pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
+ pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked();
pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
pdf.backref = pdfSupportModule->backrefCB->isChecked();
pdf.pagebackref = pdfSupportModule->pagebackrefCB->isChecked();
else
pdf.pagemode.clear();
pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text());
- if (pdf.use_hyperref || !pdf.empty())
- pdf.store_options = true;
+
+ // Embedded files
+ // FIXME
}
If not found, return 0.
*/
template<class A>
-static size_t findPos(std::vector<A> const & vec, A const & val)
+static size_t findPos(vector<A> const & vec, A const & val)
{
- typename std::vector<A>::const_iterator it =
- std::find(vec.begin(), vec.end(), val);
+ typename vector<A>::const_iterator it =
+ find(vec.begin(), vec.end(), val);
if (it == vec.end())
return 0;
return distance(vec.begin(), it);
pageLayoutModule->portraitRB->setChecked(!landscape);
pageLayoutModule->facingPagesCB->setChecked(
- params.sides == TextClass::TwoSides);
+ params.sides == TwoSides);
lengthToWidgets(pageLayoutModule->paperwidthLE,
pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks);
pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
+ pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle);
pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
pdfSupportModule->backrefCB->setChecked(pdf.backref);
pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref);
pdfSupportModule->optionsLE->setText(
toqstr(pdf.quoted_options));
+
+ // embedded files
+ updateEmbeddedFileList();
}
void GuiDocument::useClassDefaults()
{
- bp_.setJustBaseClass(latexModule->classCO->currentIndex());
+ bp_.setBaseClass(latexModule->classCO->currentIndex());
bp_.useClassDefaults();
updateContents();
}
{
LyXModule const * const mod = moduleList[modName];
if (!mod)
- return string("Module unavailable!");
+ return string("Module not found!");
return mod->description;
}
-vector<string>
-GuiDocument::getPackageList(string const & modName) const
+vector<string> GuiDocument::getPackageList(string const & modName) const
{
LyXModule const * const mod = moduleList[modName];
if (!mod)
}
+bool GuiDocument::isModuleAvailable(string const & modName) const
+{
+ LyXModule * mod = moduleList[modName];
+ if (!mod)
+ return false;
+ return mod->isAvailable();
+}
+
+
TextClass const & GuiDocument::textClass() const
{
return textclasslist[bp_.getBaseClass()];
}
-static void dispatch_bufferparams(Controller const & controller,
+static void dispatch_bufferparams(Dialog const & dialog,
BufferParams const & bp, kb_action lfun)
{
ostringstream ss;
ss << "\\begin_header\n";
bp.writeFile(ss);
ss << "\\end_header\n";
- controller.dispatch(FuncRequest(lfun, ss.str()));
+ dialog.dispatch(FuncRequest(lfun, ss.str()));
}
// Apply the BufferParams. Note that this will set the base class
// and then update the buffer's layout.
- //FIXME Could this be done last? Then, I think, we'd get the automatic
- //update mentioned in the next FIXME...
dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
// Generate the colours requested by each new branch.
for (; it != end; ++it) {
docstring const & current_branch = it->getBranch();
Branch const * branch = branchlist.find(current_branch);
- string const x11hexname =
- lyx::X11hexname(branch->getColor());
+ string const x11hexname = X11hexname(branch->getColor());
// display the new color
docstring const str = current_branch + ' ' + from_ascii(x11hexname);
dispatch(FuncRequest(LFUN_SET_COLOR, str));
"assign branch"));
}
// FIXME: If we used an LFUN, we would not need those two lines:
- bufferview()->update();
- lyxview().currentWorkArea()->redraw();
+ bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
}
}
-Dialog * createGuiDocument(LyXView & lv) { return new GuiDocument(lv); }
+Dialog * createGuiDocument(GuiView & lv) { return new GuiDocument(lv); }
} // namespace frontend