#include "BufferParams.h"
#include "BufferView.h"
#include "Color.h"
-#include "EmbeddedFiles.h"
#include "Encoding.h"
#include "FloatPlacement.h"
#include "FuncRequest.h"
#include "support/debug.h"
#include "support/FileName.h"
+#include "support/FileFilterList.h"
#include "support/filetools.h"
#include "support/lstrings.h"
this, SLOT(classChanged()));
connect(latexModule->classCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
+ connect(latexModule->layoutPB, SIGNAL(clicked()),
+ this, SLOT(browseLayout()));
selectionManager =
new ModuleSelMan(latexModule->availableLV, latexModule->selectedLV,
// 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()));
+ this, SLOT(addExtraEmbeddedFile()));
connect(embeddedFilesModule->removePB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
+ this, SLOT(removeExtraEmbeddedFile()));
// PDF support
pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
}
+void GuiDocument::browseLayout()
+{
+ QString const label1 = qt_("Layouts|#o#O");
+ QString const dir1 = toqstr(lyxrc.document_path);
+ FileFilterList const filter(_("LyX Layout (*.layout)"));
+ QString file = browseRelFile(QString(), bufferFilepath(),
+ qt_("Local layout file"), filter, false,
+ label1, dir1);
+
+ if (!suffixIs(fromqstr(file), ".layout"))
+ return;
+
+ FileName layoutFile = makeAbsPath(fromqstr(file),
+ fromqstr(bufferFilepath()));
+
+ // load the layout file
+ LayoutFileList & bcl = LayoutFileList::get();
+ string classname = layoutFile.onlyFileName();
+ LayoutFileIndex name = bcl.addLayoutFile(
+ classname.substr(0, classname.size() - 7),
+ layoutFile.onlyPath().absFilename());
+
+ if (name.empty()) {
+ Alert::error(_("Error"),
+ _("Unable to read local layout file."));
+ return;
+ }
+
+ // do not trigger classChanged if there is no change.
+ if (latexModule->classCO->currentText() == toqstr(name))
+ return;
+
+ // add to combo box
+ int idx = latexModule->classCO->findText(toqstr(name));
+ if (idx == -1) {
+ classes_model_.insertRow(0, toqstr(name), name);
+ latexModule->classCO->setCurrentIndex(0);
+ } else
+ latexModule->classCO->setCurrentIndex(idx);
+ classChanged();
+}
+
+
void GuiDocument::classChanged()
{
int idx = latexModule->classCO->currentIndex();
}
-void GuiDocument::updateEmbeddedFileList()
+void GuiDocument::setExtraEmbeddedFileList()
{
- embeddedFilesModule->filesLW->clear();
+ embeddedFilesModule->extraLW->clear();
// add current embedded files
- EmbeddedFileList & files = buffer().embeddedFiles();
- files.update(buffer());
- EmbeddedFileList::iterator fit = files.begin();
- 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);
- }
+ vector<string> const & files = buffer().params().extraEmbeddedFiles();
+ vector<string>::const_iterator fit = files.begin();
+ vector<string>::const_iterator fit_end = files.end();
+ for (; fit != fit_end; ++fit)
+ embeddedFilesModule->extraLW->addItem(toqstr(*fit));
+}
+
+
+void GuiDocument::addExtraEmbeddedFile()
+{
+ QString const label1 = qt_("Documents|#o#O");
+ QString const dir1 = toqstr(lyxrc.document_path);
+ FileFilterList const filter(_("LyX Layout (*.layout);;LaTeX Classes (*.{cls,sty});;BibTeX Databases (*.{bib,bst})"));
+ QString file = browseRelFile(QString(), bufferFilepath(),
+ qt_("Extra embedded file"), filter, true, label1, dir1);
+
+ if (file.isEmpty())
+ return;
+
+ if (embeddedFilesModule->extraLW->findItems(file, Qt::MatchExactly).empty())
+ embeddedFilesModule->extraLW->addItem(file);
+}
+
+
+void GuiDocument::removeExtraEmbeddedFile()
+{
+ int index = embeddedFilesModule->extraLW->currentRow();
+ delete embeddedFilesModule->extraLW->takeItem(index);
}
fromqstr(pdfSupportModule->optionsLE->text()));
// Embedded files
- // FIXME
+ vector<string> & files = params.extraEmbeddedFiles();
+ files.clear();
+ for (int i = 0; i < embeddedFilesModule->extraLW->count(); ++i) {
+ QListWidgetItem * item = embeddedFilesModule->extraLW->item(i);
+ files.push_back(fromqstr(item->text()));
+ }
}
pdfSupportModule->optionsLE->setText(
toqstr(pdf.quoted_options));
-
- // embedded files
- updateEmbeddedFileList();
+
+ setExtraEmbeddedFileList();
}
{
if (applyPB->isEnabled()) {
int const ret = Alert::prompt(_("Unapplied changes"),
- _("Some changes in the dialog were not yet applied."
+ _("Some changes in the dialog were not yet applied.\n"
"If you do not apply now, they will be lost after this action."),
1, 1, _("&Apply"), _("&Dismiss"));
if (ret == 0)