mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
frontends/controllers/ControlBibtex.[Ch]: new members bibtotoc(), getStylefile(),
which hold functionality that has been moved from the frontends and implement a method to use a default stylefile for new bibtex insets (bug 2322). frontends/gtk/GBibtex.C: frontends/qt2/QBibtex.C: frontends/qt4/QBibtex.C: frontends/xforms/FormBibTex.C: Move parsing of Options (stylefile, bibtotoc) to the controller (bug 2322). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13427 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0a57bcafeb
commit
4c4b3e3cff
@ -13,6 +13,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "ControlBibtex.h"
|
||||
#include "biblio.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "bufferparams.h"
|
||||
@ -24,6 +25,7 @@
|
||||
|
||||
#include "support/filefilterlist.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::pair;
|
||||
using std::string;
|
||||
@ -32,8 +34,11 @@ using std::vector;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::contains;
|
||||
using support::FileFilterList;
|
||||
using support::OnlyFilename;
|
||||
using support::prefixIs;
|
||||
using support::split;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
@ -112,7 +117,55 @@ void ControlBibtex::rescanBibStyles() const
|
||||
|
||||
bool ControlBibtex::usingBibtopic() const
|
||||
{
|
||||
return kernel().buffer().params().use_bibtopic;
|
||||
return kernel().buffer().params().use_bibtopic;
|
||||
}
|
||||
|
||||
|
||||
bool ControlBibtex::bibtotoc() const
|
||||
{
|
||||
return prefixIs(params().getOptions(), "bibtotoc");
|
||||
}
|
||||
|
||||
|
||||
string const ControlBibtex::getStylefile() const
|
||||
{
|
||||
// the different bibtex packages have (and need) their
|
||||
// own "plain" stylefiles
|
||||
biblio::CiteEngine_enum const & engine =
|
||||
biblio::getEngine(kernel().buffer());
|
||||
string defaultstyle;
|
||||
switch (engine) {
|
||||
case biblio::ENGINE_BASIC:
|
||||
defaultstyle = "plain";
|
||||
break;
|
||||
case biblio::ENGINE_NATBIB_AUTHORYEAR:
|
||||
defaultstyle = "plainnat";
|
||||
break;
|
||||
case biblio::ENGINE_NATBIB_NUMERICAL:
|
||||
defaultstyle = "plainnat";
|
||||
break;
|
||||
case biblio::ENGINE_JURABIB:
|
||||
defaultstyle = "jurabib";
|
||||
break;
|
||||
}
|
||||
|
||||
string bst = params().getOptions();
|
||||
if (bibtotoc()){
|
||||
// bibstyle exists?
|
||||
if (contains(bst,',')) {
|
||||
string bibtotoc = "bibtotoc";
|
||||
bst = split(bst, bibtotoc, ',');
|
||||
} else
|
||||
bst.erase();
|
||||
}
|
||||
|
||||
// propose default style file for new insets
|
||||
// existing insets might have (legally) no bst files
|
||||
// (if the class already provides a style)
|
||||
if (bst.empty() && params().getContents().empty())
|
||||
bst = defaultstyle;
|
||||
|
||||
return bst;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -48,6 +48,10 @@ public:
|
||||
void rescanBibStyles() const;
|
||||
/// do we use bibtopic (for sectioned bibliography)?
|
||||
bool usingBibtopic() const;
|
||||
/// should we put the bibliography to the TOC?
|
||||
bool bibtotoc() const;
|
||||
/// which stylefile do we use?
|
||||
std::string const getStylefile() const;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -28,8 +28,6 @@
|
||||
#include <libglademm.h>
|
||||
|
||||
using lyx::support::ChangeExtension;
|
||||
using lyx::support::contains;
|
||||
using lyx::support::prefixIs;
|
||||
using lyx::support::split;
|
||||
using lyx::support::trim;
|
||||
|
||||
@ -109,20 +107,10 @@ void GBibtex::update()
|
||||
}
|
||||
}
|
||||
|
||||
string bibtotoc = "bibtotoc";
|
||||
string bibstyle(controller().params().getOptions());
|
||||
|
||||
// bibtotoc exists?
|
||||
if (prefixIs(bibstyle, bibtotoc)){
|
||||
// bibstyle exists?
|
||||
if (contains(bibstyle,','))
|
||||
bibstyle = split(bibstyle, bibtotoc, ',');
|
||||
else
|
||||
bibstyle.erase();
|
||||
}
|
||||
string bibstyle(controller().getStylefile());
|
||||
|
||||
bool const bibtopic = controller().usingBibtopic();
|
||||
if (prefixIs(bibstyle, bibtotoc) && !bibtopic)
|
||||
if (controller().bibtotoc() && !bibtopic)
|
||||
toccheck_->set_active(true);
|
||||
else
|
||||
toccheck_->set_active(false);
|
||||
|
@ -33,8 +33,6 @@
|
||||
|
||||
|
||||
using lyx::support::ChangeExtension;
|
||||
using lyx::support::contains;
|
||||
using lyx::support::prefixIs;
|
||||
using lyx::support::split;
|
||||
using lyx::support::trim;
|
||||
|
||||
@ -98,23 +96,7 @@ void QBibtex::update_contents()
|
||||
dialog_->add_->bibLB->insertItem(toqstr(bibItem));
|
||||
}
|
||||
|
||||
string bibtotoc = "bibtotoc";
|
||||
string bibstyle(controller().params().getOptions());
|
||||
|
||||
// bibtotoc exists?
|
||||
if (prefixIs(bibstyle, bibtotoc)){
|
||||
// bibstyle exists?
|
||||
if (contains(bibstyle,','))
|
||||
bibstyle = split(bibstyle, bibtotoc, ',');
|
||||
else
|
||||
bibstyle.erase();
|
||||
}
|
||||
|
||||
if (prefixIs(bibstyle, bibtotoc) && !bibtopic)
|
||||
dialog_->bibtocCB->setChecked(true);
|
||||
else
|
||||
dialog_->bibtocCB->setChecked(false);
|
||||
|
||||
dialog_->bibtocCB->setChecked(controller().bibtotoc() && !bibtopic);
|
||||
dialog_->bibtocCB->setEnabled(!bibtopic);
|
||||
|
||||
string btprint(controller().params().getSecOptions());
|
||||
@ -130,6 +112,7 @@ void QBibtex::update_contents()
|
||||
dialog_->styleCB->clear();
|
||||
|
||||
int item_nr(-1);
|
||||
string bibstyle(controller().getStylefile());
|
||||
|
||||
vector<string> str;
|
||||
controller().getBibStyles(str);
|
||||
|
@ -32,8 +32,6 @@
|
||||
|
||||
|
||||
using lyx::support::ChangeExtension;
|
||||
using lyx::support::contains;
|
||||
using lyx::support::prefixIs;
|
||||
using lyx::support::split;
|
||||
using lyx::support::trim;
|
||||
|
||||
@ -97,23 +95,9 @@ void QBibtex::update_contents()
|
||||
dialog_->add_->bibLB->insertItem(toqstr(bibItem));
|
||||
}
|
||||
|
||||
string bibtotoc = "bibtotoc";
|
||||
string bibstyle(controller().params().getOptions());
|
||||
|
||||
// bibtotoc exists?
|
||||
if (prefixIs(bibstyle, bibtotoc)){
|
||||
// bibstyle exists?
|
||||
if (contains(bibstyle,','))
|
||||
bibstyle = split(bibstyle, bibtotoc, ',');
|
||||
else
|
||||
bibstyle.erase();
|
||||
}
|
||||
|
||||
if (prefixIs(bibstyle, bibtotoc) && !bibtopic)
|
||||
dialog_->bibtocCB->setChecked(true);
|
||||
else
|
||||
dialog_->bibtocCB->setChecked(false);
|
||||
string bibstyle(controller().getStylefile());
|
||||
|
||||
dialog_->bibtocCB->setChecked(controller().bibtotoc() && !bibtopic);
|
||||
dialog_->bibtocCB->setEnabled(!bibtopic);
|
||||
|
||||
string btprint(controller().params().getSecOptions());
|
||||
|
@ -34,12 +34,10 @@ namespace lyx {
|
||||
|
||||
using support::ChangeExtension;
|
||||
using support::compare;
|
||||
using support::contains;
|
||||
using support::FileFilterList;
|
||||
using support::getStringFromVector;
|
||||
using support::getVectorFromString;
|
||||
using support::OnlyFilename;
|
||||
using support::prefixIs;
|
||||
using support::split;
|
||||
|
||||
namespace frontend {
|
||||
@ -179,20 +177,13 @@ void FormBibtex::update()
|
||||
fl_set_input(dialog_->input_database,
|
||||
controller().params().getContents().c_str());
|
||||
|
||||
string bibtotoc = "bibtotoc";
|
||||
string bibstyle = controller().params().getOptions();
|
||||
string bibstyle = controller().getStylefile();
|
||||
|
||||
bool const bibtopic = controller().usingBibtopic();
|
||||
bool const bibtotoc_exists = prefixIs(bibstyle, bibtotoc);
|
||||
fl_set_button(dialog_->check_bibtotoc, bibtotoc_exists && !bibtopic);
|
||||
fl_set_button(dialog_->check_bibtotoc,
|
||||
controller().bibtotoc() && !bibtopic);
|
||||
setEnabled(dialog_->check_bibtotoc, !bibtopic);
|
||||
if (bibtotoc_exists) {
|
||||
if (contains(bibstyle, ',')) { // bibstyle exists?
|
||||
bibstyle = split(bibstyle, bibtotoc, ',');
|
||||
} else {
|
||||
bibstyle.erase();
|
||||
}
|
||||
}
|
||||
|
||||
fl_set_input(dialog_->input_style, bibstyle.c_str());
|
||||
|
||||
string btprint = controller().params().getSecOptions();
|
||||
|
Loading…
Reference in New Issue
Block a user