#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"
#include "frontends/alert.h"
-#include <boost/bind.hpp>
-
#include <QCloseEvent>
#include <QScrollBar>
#include <QTextCursor>
-#include <algorithm>
#include <sstream>
+#ifdef IN
+#undef IN
+#endif
+
+
using namespace std;
using namespace lyx::support;
namespace {
-///
-template<class Pair>
-vector<typename Pair::second_type> const
-getSecond(vector<Pair> const & pr)
-{
- vector<typename Pair::second_type> tmp(pr.size());
- transform(pr.begin(), pr.end(), tmp.begin(),
- boost::bind(&Pair::second, _1));
- return tmp;
-}
-
char const * const tex_graphics[] =
{
: GuiDialog(lv, "document", qt_("Document Settings")), current_id_(0)
{
setupUi(this);
-
- lang_ = getSecond(getLanguageData(false));
+
+ QList<LanguagePair> langs = languageData(false);
+ for (int i = 0; i != langs.size(); ++i)
+ lang_.append(langs[i].second);
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
// language & quotes
- vector<LanguagePair> const langs = getLanguageData(false);
- vector<LanguagePair>::const_iterator lit = langs.begin();
- vector<LanguagePair>::const_iterator lend = langs.end();
- for (; lit != lend; ++lit) {
- langModule->languageCO->addItem(toqstr(lit->first));
- }
+
+ QList<LanguagePair>::const_iterator lit = langs.begin();
+ QList<LanguagePair>::const_iterator lend = langs.end();
+ for (; lit != lend; ++lit)
+ langModule->languageCO->addItem(lit->first);
// Always put the default encoding in the first position.
// It is special because the displayed text is translated.
langModule->quoteStyleCO->addItem(qt_(">>text<<"));
-
numberingModule = new UiWidget<Ui::NumberingUi>;
// numbering
connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
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,
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>;
docPS->addPanel(floatModule, qt_("Float Placement"));
docPS->addPanel(bulletsModule, qt_("Bullets"));
docPS->addPanel(branchesModule, qt_("Branches"));
- docPS->addPanel(embeddedFilesModule, qt_("Embedded Files"));
docPS->addPanel(preambleModule, qt_("LaTeX Preamble"));
docPS->setCurrentPanel(qt_("Document Class"));
// FIXME: hack to work around resizing bug in Qt >= 4.2
}
+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(),
+ LayoutFileList::Local);
+
+ 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();
return;
}
}
+ // FIXME Note that by doing things this way, we load the TextClass
+ // as soon as it is selected. So, if you use the scroll wheel when
+ // sitting on the combo box, we'll load a lot of TextClass objects
+ // very quickly. This could be changed.
if (!bp_.setBaseClass(classname)) {
Alert::error(_("Error"), _("Unable to set document class."));
return;
}
-void GuiDocument::updateEmbeddedFileList()
-{
- embeddedFilesModule->filesLW->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);
- }
-}
-
-
void GuiDocument::updateNumbering()
{
DocumentClass const & tclass = bp_.documentClass();
fromqstr(langModule->encodingCO->currentText());
}
- InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
+ InsetQuotes::QuoteLanguage lga = InsetQuotes::EnglishQuotes;
switch (langModule->quoteStyleCO->currentIndex()) {
case 0:
- lga = InsetQuotes::EnglishQ;
+ lga = InsetQuotes::EnglishQuotes;
break;
case 1:
- lga = InsetQuotes::SwedishQ;
+ lga = InsetQuotes::SwedishQuotes;
break;
case 2:
- lga = InsetQuotes::GermanQ;
+ lga = InsetQuotes::GermanQuotes;
break;
case 3:
- lga = InsetQuotes::PolishQ;
+ lga = InsetQuotes::PolishQuotes;
break;
case 4:
- lga = InsetQuotes::FrenchQ;
+ lga = InsetQuotes::FrenchQuotes;
break;
case 5:
- lga = InsetQuotes::DanishQ;
+ lga = InsetQuotes::DanishQuotes;
break;
}
params.quotes_language = lga;
int const pos = langModule->languageCO->currentIndex();
- params.language = lyx::languages.getLanguage(lang_[pos]);
+ params.language = lyx::languages.getLanguage(fromqstr(lang_[pos]));
// numbering
if (params.documentClass().hasTocLevels()) {
InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
if (textLayoutModule->indentRB->isChecked())
- params.paragraph_separation = BufferParams::PARSEP_INDENT;
+ params.paragraph_separation = BufferParams::ParagraphIndentSeparation;
else
- params.paragraph_separation = BufferParams::PARSEP_SKIP;
+ params.paragraph_separation = BufferParams::ParagraphSkipSeparation;
switch (textLayoutModule->skipCO->currentIndex()) {
case 0:
params.orientation = ORIENTATION_PORTRAIT;
// margins
- params.use_geometry =
- (!marginsModule->marginCB->isChecked()
- || geom_papersize);
+ params.use_geometry = !marginsModule->marginCB->isChecked()
+ || geom_papersize;
- Ui::MarginsUi const * m(marginsModule);
+ Ui::MarginsUi const * m = marginsModule;
params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
params.topmargin = widgetsToLength(m->topLE, m->topUnit);
pdf.pagemode.clear();
pdf.quoted_options = pdf.quoted_options_check(
fromqstr(pdfSupportModule->optionsLE->text()));
-
- // Embedded files
- // FIXME
}
-/** Return the position of val in the vector if found.
- If not found, return 0.
- */
-template<class A>
-static size_t findPos(vector<A> const & vec, A const & val)
-{
- typename vector<A>::const_iterator it =
- find(vec.begin(), vec.end(), val);
- if (it == vec.end())
- return 0;
- return distance(vec.begin(), it);
+static int findPos(QStringList const & vec, QString const & val)
+{
+ for (int i = 0; i != vec.size(); ++i)
+ if (vec[i] == val)
+ return i;
+ return 0;
}
// biblio
biblioModule->citeDefaultRB->setChecked(
- params.getEngine() == biblio::ENGINE_BASIC);
+ params.citeEngine() == biblio::ENGINE_BASIC);
biblioModule->citeNatbibRB->setChecked(
- params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
- params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
+ params.citeEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
+ params.citeEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
biblioModule->citeStyleCO->setCurrentIndex(
- params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
+ params.citeEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
biblioModule->citeJurabibRB->setChecked(
- params.getEngine() == biblio::ENGINE_JURABIB);
+ params.citeEngine() == biblio::ENGINE_JURABIB);
biblioModule->bibtopicCB->setChecked(
params.use_bibtopic);
// language & quotes
- int const pos = int(findPos(lang_,
- params.language->lang()));
+ int const pos = findPos(lang_, toqstr(params.language->lang()));
langModule->languageCO->setCurrentIndex(pos);
langModule->quoteStyleCO->setCurrentIndex(
}
setLSpacing(nitem);
- if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
+ if (params.paragraph_separation == BufferParams::ParagraphIndentSeparation)
textLayoutModule->indentRB->setChecked(true);
else
textLayoutModule->skipRB->setChecked(true);
pdfSupportModule->optionsLE->setText(
toqstr(pdf.quoted_options));
-
- // embedded files
- updateEmbeddedFileList();
}
void GuiDocument::updateAvailableModules()
{
modules_av_model_.clear();
- vector<modInfoStruct> const modInfoList = getModuleInfo();
+ vector<modInfoStruct> const & modInfoList = getModuleInfo();
int const mSize = modInfoList.size();
- for (int i = 0; i < mSize; ++i) {
+ for (int i = 0; i != mSize; ++i) {
modInfoStruct const & modInfo = modInfoList[i];
- modules_av_model_.insertRow(i, qt_(modInfo.name), modInfo.id);
+ modules_av_model_.insertRow(i, modInfo.name, modInfo.id,
+ modInfo.description);
}
}
void GuiDocument::updateSelectedModules()
{
- //and selected ones, too
+ // and selected ones, too
modules_sel_model_.clear();
vector<modInfoStruct> const selModList = getSelectedModules();
int const sSize = selModList.size();
- for (int i = 0; i < sSize; ++i) {
+ for (int i = 0; i != sSize; ++i) {
modInfoStruct const & modInfo = selModList[i];
- modules_sel_model_.insertRow(i, qt_(modInfo.name), modInfo.id);
+ modules_sel_model_.insertRow(i, modInfo.name, modInfo.id,
+ modInfo.description);
}
}
{
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)
bool GuiDocument::isValid()
{
- return (validate_listings_params().empty() &&
- (textLayoutModule->skipCO->currentIndex() != 3 ||
- !textLayoutModule->skipLE->text().isEmpty()));
+ return validate_listings_params().empty()
+ && (textLayoutModule->skipCO->currentIndex() != 3
+ || !textLayoutModule->skipLE->text().isEmpty());
}
m.id = *it;
LyXModule * mod = moduleList[*it];
if (mod)
- m.name = mod->getName();
+ m.name = qt_(mod->getName());
else
- m.name = *it + " (Not Found)";
+ m.name = toqstr(*it) + toqstr(" (") + qt_("Not Found") + toqstr(")");
mInfo.push_back(m);
}
return mInfo;
static void dispatch_bufferparams(Dialog const & dialog,
- BufferParams const & bp, kb_action lfun)
+ BufferParams const & bp, FuncCode lfun)
{
ostringstream ss;
ss << "\\begin_header\n";
for (; it != end; ++it) {
modInfoStruct m;
m.id = it->getID();
- m.name = it->getName();
+ m.name = qt_(it->getName());
+ // this is supposed to give us the first sentence of the description
+ QString desc = qt_(it->getDescription());
+ int const pos = desc.indexOf(".");
+ if (pos > 0)
+ desc.truncate(pos + 1);
+ m.description = desc;
moduleNames_.push_back(m);
}
}