X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt2%2FQDocument.C;h=13dec25629563e26985df0465fb40acabcee6702;hb=bd1f4fa8f231577c5edd181f1048fe41db877ddb;hp=1a4ad09ba43e9eda9f4cbf9e79a14a8989987e89;hpb=c5c8101ef234454d7ef148fed8b3ef541caff65d;p=lyx.git diff --git a/src/frontends/qt2/QDocument.C b/src/frontends/qt2/QDocument.C index 1a4ad09ba4..13dec25629 100644 --- a/src/frontends/qt2/QDocument.C +++ b/src/frontends/qt2/QDocument.C @@ -10,11 +10,7 @@ #include -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "gettext.h" +#include "qt_helpers.h" #include "ControlDocument.h" #include "QDocument.h" @@ -25,19 +21,23 @@ #include "helper_funcs.h" // getSecond() #include "insets/insetquotes.h" #include "frnt_lang.h" +#include "lyxrc.h" // defaultUnit #include "tex-strings.h" // tex_graphics -#include "support/lstrings.h" // tostr() +#include "support/tostr.h" #include "support/filetools.h" // LibFileSearch() +#include "support/BoostFormat.h" #include "lyxtextclasslist.h" #include "vspace.h" #include "bufferparams.h" +#include "qt_helpers.h" +#include "floatplacement.h" #include #include #include #include #include -#include +#include #include #include #include "lengthcombo.h" @@ -52,20 +52,30 @@ typedef Qt2CB > base_class; QDocument::QDocument() - : base_class(_("Document Settings")) + : base_class(_("LyX: Document Settings")) { vector const langs = frnt::getLanguageData(false); lang_ = getSecond(langs); } +namespace { + +char const * encodings[] = { "LaTeX default", "latin1", "latin2", + "latin3", "latin4", "latin5", "latin9", + "koi8-r", "koi8-u", "cp866", "cp1251", + "iso88595", "pt154", 0 +}; + +} + void QDocument::build_dialog() { dialog_.reset(new QDocumentDialog(this)); // biblio - dialog_->biblioModule->citeStyleCO->insertItem(_("Author-year")); - dialog_->biblioModule->citeStyleCO->insertItem(_("Numerical")); + dialog_->biblioModule->citeStyleCO->insertItem(qt_("Author-year")); + dialog_->biblioModule->citeStyleCO->insertItem(qt_("Numerical")); dialog_->biblioModule->citeStyleCO->setCurrentItem(0); // language & quotes @@ -74,79 +84,101 @@ void QDocument::build_dialog() vector::const_iterator lend = langs.end(); for (; lit != lend; ++lit) { dialog_->langModule->languageCO->insertItem( - lit->first.c_str()); + toqstr(lit->first)); } - dialog_->langModule->quoteStyleCO->insertItem(_("``text''")); - dialog_->langModule->quoteStyleCO->insertItem(_("''text''")); - dialog_->langModule->quoteStyleCO->insertItem(_(",,text``")); - dialog_->langModule->quoteStyleCO->insertItem(_(",,text''")); - dialog_->langModule->quoteStyleCO->insertItem(_("«text»")); - dialog_->langModule->quoteStyleCO->insertItem(_("»text«")); + int i = 0; + while (encodings[i]) { + dialog_->langModule->encodingCO->insertItem(qt_(encodings[i++])); + } - // packages - char const * items[] = {"default", "auto", "latin1", "latin2", - "latin3", "latin4", "latin5", "latin9", - "koi8-r", "koi8-u", "cp866", "cp1251", - "iso88595", "pt154", 0}; - dialog_->packagesModule->encodingCO->insertStrList(items); - - dialog_->packagesModule->lspacingCO->insertItem( - _("Single"), Spacing::Single); - dialog_->packagesModule->lspacingCO->insertItem( - _("OneHalf"), Spacing::Onehalf); - dialog_->packagesModule->lspacingCO->insertItem( - _("Double"), Spacing::Double); - dialog_->packagesModule->lspacingCO->insertItem( - _("Custom"), Spacing::Other); + dialog_->langModule->quoteStyleCO->insertItem(qt_("``text''")); + dialog_->langModule->quoteStyleCO->insertItem(qt_("''text''")); + dialog_->langModule->quoteStyleCO->insertItem(qt_(",,text``")); + dialog_->langModule->quoteStyleCO->insertItem(qt_(",,text''")); + dialog_->langModule->quoteStyleCO->insertItem(qt_("«text»")); + dialog_->langModule->quoteStyleCO->insertItem(qt_("»text«")); + // packages for (int n = 0; tex_graphics[n][0]; ++n) { QString enc = tex_graphics[n]; - dialog_->packagesModule->psdriverCO->insertItem(enc); + dialog_->latexModule->psdriverCO->insertItem(enc); } // paper - char const * sizes[] = { - _("Default") , _("Custom") , _("US letter") , _("US legal") - , _("US executive") , _("A3") , _("A4") , _("A5") - , _("B3") , _("B4") , _("B5"), 0 }; - dialog_->paperModule->papersizeCO->insertStrList(sizes); + QComboBox * cb = dialog_->pageLayoutModule->papersizeCO; + cb->insertItem(qt_("Default")); + cb->insertItem(qt_("Custom")); + cb->insertItem(qt_("US letter")); + cb->insertItem(qt_("US legal")); + cb->insertItem(qt_("US executive")); + cb->insertItem(qt_("A3")); + cb->insertItem(qt_("A4")); + cb->insertItem(qt_("A5")); + cb->insertItem(qt_("B3")); + cb->insertItem(qt_("B4")); + cb->insertItem(qt_("B5")); // layout for (LyXTextClassList::const_iterator cit = textclasslist.begin(); cit != textclasslist.end(); ++cit) { - dialog_->layoutModule->classCO->insertItem(cit->description().c_str()); + if (cit->isTeXClassAvailable()) { + dialog_->latexModule->classCO->insertItem(toqstr(cit->description())); + } else { + string item = +#if USE_BOOST_FORMAT + boost::io::str(boost::format(_("Unavailable: %1$s")) % cit->description()); +#else + _("Unavailable: ") + cit->description(); +#endif + dialog_->latexModule->classCO->insertItem(toqstr(item)); + } } for (int n = 0; tex_fonts[n][0]; ++n) { QString font = tex_fonts[n]; - dialog_->layoutModule->fontsCO->insertItem(font); + dialog_->textLayoutModule->fontsCO->insertItem(font); } - dialog_->layoutModule->fontsizeCO->insertItem(_("default")); - dialog_->layoutModule->fontsizeCO->insertItem(_("10")); - dialog_->layoutModule->fontsizeCO->insertItem(_("11")); - dialog_->layoutModule->fontsizeCO->insertItem(_("12")); - - dialog_->layoutModule->skipCO->insertItem(_("Smallskip")); - dialog_->layoutModule->skipCO->insertItem(_("Medskip")); - dialog_->layoutModule->skipCO->insertItem(_("Bigskip")); - dialog_->layoutModule->skipCO->insertItem(_("Length")); - - dialog_->layoutModule->pagestyleCO->insertItem(_("default")); - dialog_->layoutModule->pagestyleCO->insertItem(_("empty")); - dialog_->layoutModule->pagestyleCO->insertItem(_("plain")); - dialog_->layoutModule->pagestyleCO->insertItem(_("headings")); - dialog_->layoutModule->pagestyleCO->insertItem(_("fancy")); + dialog_->textLayoutModule->fontsizeCO->insertItem(qt_("default")); + dialog_->textLayoutModule->fontsizeCO->insertItem(qt_("10")); + dialog_->textLayoutModule->fontsizeCO->insertItem(qt_("11")); + dialog_->textLayoutModule->fontsizeCO->insertItem(qt_("12")); + + dialog_->textLayoutModule->skipCO->insertItem(qt_("SmallSkip")); + dialog_->textLayoutModule->skipCO->insertItem(qt_("MedSkip")); + dialog_->textLayoutModule->skipCO->insertItem(qt_("BigSkip")); + dialog_->textLayoutModule->skipCO->insertItem(qt_("Length")); + + dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("default")); + dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("empty")); + dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("plain")); + dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("headings")); + dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("fancy")); + + dialog_->textLayoutModule->lspacingCO->insertItem( + qt_("Single"), Spacing::Single); + dialog_->textLayoutModule->lspacingCO->insertItem( + qt_("OneHalf"), Spacing::Onehalf); + dialog_->textLayoutModule->lspacingCO->insertItem( + qt_("Double"), Spacing::Double); + dialog_->textLayoutModule->lspacingCO->insertItem( + qt_("Custom"), Spacing::Other); // margins dialog_->setMargins(0); // Manage the restore, ok, apply, restore and cancel/close buttons - bc().setOK(dialog_->okPB); - bc().setApply(dialog_->applyPB); - bc().setCancel(dialog_->closePB); - bc().setRestore(dialog_->restorePB); + bcview().setOK(dialog_->okPB); + bcview().setApply(dialog_->applyPB); + bcview().setCancel(dialog_->closePB); + bcview().setRestore(dialog_->restorePB); +} + + +void QDocument::showPreamble() +{ + dialog_->showPreamble(); } @@ -156,7 +188,7 @@ void QDocument::apply() // preamble params.preamble = - dialog_->preambleModule->preambleMLE->text().latin1(); + fromqstr(dialog_->preambleModule->preambleMLE->text()); // biblio params.use_natbib = @@ -170,6 +202,16 @@ void QDocument::apply() else params.quotes_times = InsetQuotes::DoubleQ; + if (dialog_->langModule->defaultencodingCB->isChecked()) { + params.inputenc = "auto"; + } else { + int i = dialog_->langModule->encodingCO->currentItem(); + if (i == 0) { + params.inputenc = "default"; + } else { + params.inputenc = encodings[i]; + } + } InsetQuotes::quote_language lga = InsetQuotes::EnglishQ; switch (dialog_->langModule->quoteStyleCO->currentItem()) { @@ -198,24 +240,42 @@ void QDocument::apply() params.language = languages.getLanguage(lang_[pos]); // numbering - params.secnumdepth = - dialog_->numberingModule->tocDepthSB->value(); - params.tocdepth = - dialog_->numberingModule->sectionnrDepthSB->value(); + params.tocdepth = dialog_->numberingModule->tocSL->value(); + params.secnumdepth = dialog_->numberingModule->depthSL->value(); // bullets - params.user_defined_bullets[0].setText(dialog_->bulletsModule->bullet1LE->text().latin1()); - params.user_defined_bullets[1].setText(dialog_->bulletsModule->bullet2LE->text().latin1()); - params.user_defined_bullets[2].setText(dialog_->bulletsModule->bullet3LE->text().latin1()); - params.user_defined_bullets[3].setText(dialog_->bulletsModule->bullet4LE->text().latin1()); - - params.user_defined_bullets[0].setSize(dialog_->bulletsModule->bulletsize1CO->currentItem()-1); - params.user_defined_bullets[1].setSize(dialog_->bulletsModule->bulletsize2CO->currentItem()-1); - params.user_defined_bullets[2].setSize(dialog_->bulletsModule->bulletsize3CO->currentItem()-1); - params.user_defined_bullets[3].setSize(dialog_->bulletsModule->bulletsize4CO->currentItem()-1); + params.user_defined_bullets[0] = dialog_->bulletsModule->getBullet(0); + params.user_defined_bullets[1] = dialog_->bulletsModule->getBullet(1); + params.user_defined_bullets[2] = dialog_->bulletsModule->getBullet(2); + params.user_defined_bullets[3] = dialog_->bulletsModule->getBullet(3); // packages - switch (dialog_->packagesModule->lspacingCO->currentItem()) { + params.graphicsDriver = + fromqstr(dialog_->latexModule->psdriverCO->currentText()); + + if (dialog_->mathsModule->amsautoCB->isChecked()) { + params.use_amsmath = BufferParams::AMS_AUTO; + } else { + if (dialog_->mathsModule->amsCB->isChecked()) + params.use_amsmath = BufferParams::AMS_ON; + else + params.use_amsmath = BufferParams::AMS_OFF; + } + + // layout + params.textclass = + dialog_->latexModule->classCO->currentItem(); + + params.fonts = + fromqstr(dialog_->textLayoutModule->fontsCO->currentText()); + + params.fontsize = + fromqstr(dialog_->textLayoutModule->fontsizeCO->currentText()); + + params.pagestyle = + fromqstr(dialog_->pageLayoutModule->pagestyleCO->currentText()); + + switch (dialog_->textLayoutModule->lspacingCO->currentItem()) { case 0: params.spacing.set(Spacing::Single); break; @@ -227,42 +287,23 @@ void QDocument::apply() break; case 3: params.spacing.set(Spacing::Other, - dialog_->packagesModule-> + dialog_->textLayoutModule-> lspacingLE->text().toFloat() ); break; } - params.graphicsDriver = - dialog_->packagesModule->psdriverCO->currentText().latin1(); - - params.use_amsmath = - dialog_->packagesModule->amsCB->isChecked(); - - params.inputenc = - dialog_->packagesModule->encodingCO->currentText().latin1(); - - // layout - params.textclass = - dialog_->layoutModule->classCO->currentItem(); - - //bool succes = controller().classApply(); - - params.fonts = - dialog_->layoutModule->fontsCO->currentText().latin1(); - - params.fontsize = - dialog_->layoutModule->fontsizeCO->currentText().latin1(); - - params.pagestyle = - dialog_->layoutModule->pagestyleCO->currentText().latin1(); + if (dialog_->textLayoutModule->twoColumnCB->isChecked()) + params.columns = 2; + else + params.columns = 1; - if (dialog_->layoutModule->indentRB->isChecked()) + if (dialog_->textLayoutModule->indentRB->isChecked()) params.paragraph_separation = BufferParams::PARSEP_INDENT; else params.paragraph_separation = BufferParams::PARSEP_SKIP; - switch (dialog_->layoutModule->skipCO->currentItem()) { + switch (dialog_->textLayoutModule->skipCO->currentItem()) { case 0: params.setDefSkip(VSpace(VSpace::SMALLSKIP)); break; @@ -275,10 +316,10 @@ void QDocument::apply() case 3: { LyXLength::UNIT unit = - dialog_->layoutModule->skipLengthCO-> + dialog_->textLayoutModule->skipLengthCO-> currentLengthItem(); double length = - dialog_->layoutModule->skipLE->text().toDouble(); + dialog_->textLayoutModule->skipLE->text().toDouble(); VSpace vs = VSpace(LyXGlueLength(LyXLength(length,unit))); params.setDefSkip(vs); break; @@ -291,36 +332,26 @@ void QDocument::apply() } params.options = - dialog_->layoutModule->optionsLE->text().latin1(); + fromqstr(dialog_->latexModule->optionsLE->text()); - params.float_placement = - dialog_->layoutModule->floatPlacementLE->text().latin1(); + params.float_placement = dialog_->floatModule->get(); // paper - params.papersize2 = - dialog_->paperModule->papersizeCO->currentItem(); - - params.paperwidth = - LyXLength(dialog_->paperModule->paperwidthLE->text().toDouble(), - dialog_->paperModule->paperwidthUnitCO->currentLengthItem() - ).asString(); + params.papersize2 = BufferParams::VMARGIN_PAPER_TYPE( + dialog_->pageLayoutModule->papersizeCO->currentItem()); - params.paperheight = - LyXLength(dialog_->paperModule->paperheightLE->text().toDouble(), - dialog_->paperModule->paperheightUnitCO->currentLengthItem() - ).asString(); + params.paperwidth = widgetsToLength(dialog_->pageLayoutModule->paperwidthLE, + dialog_->pageLayoutModule->paperwidthUnitCO); - if (dialog_->paperModule->twoColumnCB->isChecked()) - params.columns = 2; - else - params.columns = 1; + params.paperheight = widgetsToLength(dialog_->pageLayoutModule->paperheightLE, + dialog_->pageLayoutModule->paperheightUnitCO); - if (dialog_->paperModule->facingPagesCB->isChecked()) + if (dialog_->pageLayoutModule->facingPagesCB->isChecked()) params.sides = LyXTextClass::TwoSides; else params.sides = LyXTextClass::OneSide; - if (dialog_->paperModule->landscapeRB->isChecked()) + if (dialog_->pageLayoutModule->landscapeRB->isChecked()) params.orientation = BufferParams::ORIENTATION_LANDSCAPE; else params.orientation = BufferParams::ORIENTATION_PORTRAIT; @@ -333,44 +364,27 @@ void QDocument::apply() if (margin > 0) { margin = margin - 1; } - params.paperpackage = char(margin); + params.paperpackage = BufferParams::PAPER_PACKAGES(margin); + + // set params.papersize from params.papersize2 + // and params.paperpackage + params.setPaperStuff(); MarginsModuleBase const * m(dialog_->marginsModule); - - params.leftmargin = - LyXLength(m->innerLE->text().toDouble(), - m->innerUnit->currentLengthItem() - ).asString(); - - params.topmargin = - LyXLength(m->topLE->text().toDouble(), - m->topUnit->currentLengthItem() - ).asString(); - - params.rightmargin = - LyXLength(m->outerLE->text().toDouble(), - m->outerUnit->currentLengthItem() - ).asString(); - - params.bottommargin = - LyXLength(m->bottomLE->text().toDouble(), - m->bottomUnit->currentLengthItem() - ).asString(); - - params.headheight = - LyXLength(m->headheightLE->text().toDouble(), - m->headheightUnit->currentLengthItem() - ).asString(); - - params.headsep = - LyXLength(m->headsepLE->text().toDouble(), - m->headsepUnit->currentLengthItem() - ).asString(); - - params.footskip = - LyXLength(m->footskipLE->text().toDouble(), - m->footskipUnit->currentLengthItem() - ).asString(); + + params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit); + + params.topmargin = widgetsToLength(m->topLE, m->topUnit); + + params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit); + + params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit); + + params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit); + + params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit); + + params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit); } @@ -400,8 +414,28 @@ void QDocument::update_contents() BufferParams const & params = controller().params(); + // set the default unit + // FIXME: move to controller + LyXLength::UNIT defaultUnit = LyXLength::CM; + switch (lyxrc.default_papersize) { + case BufferParams::PAPER_DEFAULT: break; + + case BufferParams::PAPER_USLETTER: + case BufferParams::PAPER_LEGALPAPER: + case BufferParams::PAPER_EXECUTIVEPAPER: + defaultUnit = LyXLength::IN; + break; + + case BufferParams::PAPER_A3PAPER: + case BufferParams::PAPER_A4PAPER: + case BufferParams::PAPER_A5PAPER: + case BufferParams::PAPER_B5PAPER: + defaultUnit = LyXLength::CM; + break; + } + // preamble - QString preamble = params.preamble.c_str(); + QString preamble = toqstr(params.preamble); dialog_->preambleModule->preambleMLE->setText(preamble); // biblio @@ -423,54 +457,48 @@ void QDocument::update_contents() dialog_->langModule->quoteStyleCO->setCurrentItem( params.quotes_language); + dialog_->langModule->defaultencodingCB->setChecked(true); + + if (params.inputenc != "auto") { + dialog_->langModule->defaultencodingCB->setChecked(false); + if (params.inputenc == "default") { + dialog_->langModule->encodingCO->setCurrentItem(0); + } else { + int i = 0; + while (encodings[i]) { + if (encodings[i] == params.inputenc) + dialog_->langModule->encodingCO->setCurrentItem(i); + ++i; + } + } + } + // numbering - dialog_->numberingModule->tocDepthSB->setValue( - params.secnumdepth); - dialog_->numberingModule->sectionnrDepthSB->setValue( - params.tocdepth); + dialog_->numberingModule->tocSL->setValue(params.tocdepth); + dialog_->numberingModule->depthSL->setValue(params.secnumdepth); + dialog_->updateNumbering(); // bullets - QString s; - s = params.user_defined_bullets[0].getText().c_str(); - dialog_->bulletsModule->bullet1LE->setText(s); - s = params.user_defined_bullets[1].getText().c_str(); - dialog_->bulletsModule->bullet2LE->setText(s); - s = params.user_defined_bullets[2].getText().c_str(); - dialog_->bulletsModule->bullet3LE->setText(s); - s = params.user_defined_bullets[3].getText().c_str(); - dialog_->bulletsModule->bullet4LE->setText(s); - - dialog_->bulletsModule->bulletsize1CO->setCurrentItem( - params.user_defined_bullets[0].getSize() + 1); - dialog_->bulletsModule->bulletsize2CO->setCurrentItem( - params.user_defined_bullets[1].getSize() + 1); - dialog_->bulletsModule->bulletsize3CO->setCurrentItem( - params.user_defined_bullets[2].getSize() + 1); - dialog_->bulletsModule->bulletsize4CO->setCurrentItem( - params.user_defined_bullets[3].getSize() + 1); - - // packages - char const * enc[] = { - "default" , "auto" , "latin1" , "latin2" , "latin3" , - "latin4" , "latin5" , "latin9" , "koi8-r" , "koi8-u" , - "cp866" , "cp1251" , "iso88595" , "pt154" }; - for (size_t i = 0; i < sizeof(enc)/sizeof(char *); ++i) { - if (params.inputenc == enc[i]) - dialog_->packagesModule->encodingCO->setCurrentItem(i); - } + dialog_->bulletsModule->setBullet(0,params.user_defined_bullets[0]); + dialog_->bulletsModule->setBullet(1,params.user_defined_bullets[1]); + dialog_->bulletsModule->setBullet(2,params.user_defined_bullets[2]); + dialog_->bulletsModule->setBullet(3,params.user_defined_bullets[3]); - QString text = params.graphicsDriver.c_str(); - int nitem = dialog_->packagesModule->psdriverCO->count(); + // packages + QString text = toqstr(params.graphicsDriver); + int nitem = dialog_->latexModule->psdriverCO->count(); for (int n = 0; n < nitem ; ++n) { QString enc = tex_graphics[n]; if (enc == text) { - dialog_->packagesModule->psdriverCO->setCurrentItem(n); + dialog_->latexModule->psdriverCO->setCurrentItem(n); } } - dialog_->packagesModule->amsCB->setChecked( - params.use_amsmath); + dialog_->mathsModule->amsCB->setChecked( + params.use_amsmath == BufferParams::AMS_ON); + dialog_->mathsModule->amsautoCB->setChecked( + params.use_amsmath == BufferParams::AMS_AUTO); switch (params.spacing.getSpace()) { case Spacing::Other: nitem = 3; break; @@ -478,22 +506,10 @@ void QDocument::update_contents() case Spacing::Onehalf: nitem = 1; break; case Spacing::Default: case Spacing::Single: nitem = 0; break; } - - dialog_->packagesModule->lspacingCO->setCurrentItem(nitem); - if (params.spacing.getSpace() == Spacing::Other) { - dialog_->packagesModule->lspacingLE->setText( - tostr(params.spacing.getValue()).c_str()); - dialog_->setLSpacing(3); - } + // layout - for (int n = 0; nlayoutModule->classCO->count(); ++n) { - if (dialog_->layoutModule->classCO->text(n) == - controller().textClass().description().c_str()) { - dialog_->layoutModule->classCO->setCurrentItem(n); - break; - } - } + dialog_->latexModule->classCO->setCurrentItem(params.textclass); dialog_->updateFontsize(controller().textClass().opt_fontsize(), params.fontsize); @@ -503,16 +519,23 @@ void QDocument::update_contents() for (int n = 0; tex_fonts[n][0]; ++n) { if (tex_fonts[n] == params.fonts) { - dialog_->layoutModule->fontsCO->setCurrentItem(n); + dialog_->textLayoutModule->fontsCO->setCurrentItem(n); break; } } + dialog_->textLayoutModule->lspacingCO->setCurrentItem(nitem); + if (params.spacing.getSpace() == Spacing::Other) { + dialog_->textLayoutModule->lspacingLE->setText( + toqstr(tostr(params.spacing.getValue()))); + dialog_->setLSpacing(3); + } + if (params.paragraph_separation == BufferParams::PARSEP_INDENT) { - dialog_->layoutModule->indentRB->setChecked(true); + dialog_->textLayoutModule->indentRB->setChecked(true); } else { - dialog_->layoutModule->skipRB->setChecked(true); + dialog_->textLayoutModule->skipRB->setChecked(true); } int skip = 0; @@ -530,57 +553,55 @@ void QDocument::update_contents() { skip = 3; string const length = params.getDefSkip().asLyXCommand(); - dialog_->layoutModule->skipLengthCO->setCurrentItem(LyXLength(length).unit()); - dialog_->layoutModule->skipLE->setText(tostr(LyXLength(length).value()).c_str()); + dialog_->textLayoutModule->skipLengthCO->setCurrentItem(LyXLength(length).unit()); + dialog_->textLayoutModule->skipLE->setText(toqstr(tostr(LyXLength(length).value()))); break; } default: skip = 0; break; } - dialog_->layoutModule->skipCO->setCurrentItem(skip); + dialog_->textLayoutModule->skipCO->setCurrentItem(skip); dialog_->setSkip(skip); + dialog_->textLayoutModule->twoColumnCB->setChecked( + params.columns == 2); + if (!params.options.empty()) { - dialog_->layoutModule->optionsLE->setText( - params.options.c_str()); + dialog_->latexModule->optionsLE->setText( + toqstr(params.options)); } else { - dialog_->layoutModule->optionsLE->setText(""); + dialog_->latexModule->optionsLE->setText(""); } + dialog_->floatModule->set(params.float_placement); + // paper int const psize = params.papersize2; - dialog_->paperModule->papersizeCO->setCurrentItem(psize); + dialog_->pageLayoutModule->papersizeCO->setCurrentItem(psize); dialog_->setMargins(psize); dialog_->setCustomPapersize(psize); bool const landscape = params.orientation == BufferParams::ORIENTATION_LANDSCAPE; - dialog_->paperModule->landscapeRB->setChecked(landscape); - dialog_->paperModule->portraitRB->setChecked(!landscape); + dialog_->pageLayoutModule->landscapeRB->setChecked(landscape); + dialog_->pageLayoutModule->portraitRB->setChecked(!landscape); - dialog_->paperModule->facingPagesCB->setChecked( + dialog_->pageLayoutModule->facingPagesCB->setChecked( params.sides == LyXTextClass::TwoSides); - dialog_->paperModule->twoColumnCB->setChecked( - params.columns == 2); - - dialog_->paperModule->paperwidthUnitCO->setCurrentItem( - LyXLength(params.paperwidth).unit()); - dialog_->paperModule->paperwidthLE->setText( - tostr(LyXLength(params.paperwidth).value()).c_str()); - dialog_->paperModule->paperheightUnitCO->setCurrentItem( - LyXLength(params.paperheight).unit()); + lengthToWidgets(dialog_->pageLayoutModule->paperwidthLE, + dialog_->pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit); - dialog_->paperModule->paperheightLE->setText( - tostr(LyXLength(params.paperheight).value()).c_str()); + lengthToWidgets(dialog_->pageLayoutModule->paperheightLE, + dialog_->pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit); // margins - + MarginsModuleBase * m(dialog_->marginsModule); - + int item = params.paperpackage; if (params.use_geometry) { item = 1; @@ -590,26 +611,26 @@ void QDocument::update_contents() m->marginCO->setCurrentItem(item); dialog_->setCustomMargins(item); - m->topUnit->setCurrentItem(LyXLength(params.topmargin).unit()); - m->topLE->setText(tostr(LyXLength(params.topmargin).value()).c_str()); + lengthToWidgets(m->topLE, m->topUnit, + params.topmargin, defaultUnit); - m->bottomUnit->setCurrentItem(LyXLength(params.bottommargin).unit()); - m->bottomLE->setText(tostr(LyXLength(params.bottommargin).value()).c_str()); + lengthToWidgets(m->bottomLE, m->bottomUnit, + params.bottommargin, defaultUnit); - m->innerUnit->setCurrentItem(LyXLength(params.leftmargin).unit()); - m->innerLE->setText(tostr(LyXLength(params.leftmargin).value()).c_str()); + lengthToWidgets(m->innerLE, m->innerUnit, + params.leftmargin, defaultUnit); - m->outerUnit->setCurrentItem(LyXLength(params.rightmargin).unit()); - m->outerLE->setText(tostr(LyXLength(params.rightmargin).value()).c_str()); + lengthToWidgets(m->outerLE, m->outerUnit, + params.rightmargin, defaultUnit); - m->headheightUnit->setCurrentItem(LyXLength(params.headheight).unit()); - m->headheightLE->setText(tostr(LyXLength(params.headheight).value()).c_str()); + lengthToWidgets(m->headheightLE, m->headheightUnit, + params.headheight, defaultUnit); - m->headsepUnit->setCurrentItem(LyXLength(params.headsep).unit()); - m->headsepLE->setText(tostr(LyXLength(params.headsep).value()).c_str()); + lengthToWidgets(m->headsepLE, m->headsepUnit, + params.headsep, defaultUnit); - m->footskipUnit->setCurrentItem(LyXLength(params.footskip).unit()); - m->footskipLE->setText(tostr(LyXLength(params.footskip).value()).c_str()); + lengthToWidgets(m->footskipLE, m->footskipUnit, + params.footskip, defaultUnit); } @@ -625,7 +646,7 @@ void QDocument::useClassDefaults() { BufferParams & params = controller().params(); - params.textclass = dialog_->layoutModule->classCO->currentItem(); + params.textclass = dialog_->latexModule->classCO->currentItem(); params.useClassDefaults(); update_contents(); }