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/xforms/FormBibTex.C: Move parsing of Options (stylefile, bibtotoc) to the 
	controller (bug 2322).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@13426 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2006-03-20 10:20:07 +00:00
parent e811433ec7
commit a4abb93f6b
10 changed files with 93 additions and 48 deletions

View File

@ -1,3 +1,10 @@
2006-03-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* 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).
2006-03-10 Martin Vermeer <martin.vermeer@hut.fi>
* ControlChanges.C: fix bug 2212: First change is skipped in

View File

@ -13,10 +13,12 @@
#include <config.h>
#include "ControlBibtex.h"
#include "biblio.h"
#include "buffer.h"
#include "bufferparams.h"
#include "debug.h"
#include "lyxrc.h"
#include "helper_funcs.h"
#include "tex_helpers.h"
@ -24,6 +26,7 @@
#include "support/filefilterlist.h"
#include "support/filetools.h"
#include "support/lstrings.h"
using std::pair;
using std::string;
@ -32,8 +35,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 +118,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

View File

@ -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

View File

@ -1,7 +1,12 @@
2006-03-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* GBibtex.C: Move parsing of Options (stylefile, bibtotoc)
to the controller (bug 2322).
2006-03-10 Martin Vermeer <martin.vermeer@hut.fi>
* GChanges.C: fix bug 2212: First change is skipped in
"Merge changes..." dialog
"Merge changes..." dialog
2006-02-20 John Spray <spray@lyx.org>
* glade/documents.glade: change "page style" to "page numbering"

View File

@ -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);

View File

@ -1,3 +1,8 @@
2006-03-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* QBibtex.C: Move parsing of Options (stylefile, bibtotoc)
to the controller (bug 2322).
2006-03-10 Martin Vermeer <martin.vermeer@hut.fi>
* QChanges.C: fix bug 2212: First change is skipped in

View File

@ -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);

View File

@ -1,3 +1,8 @@
2006-03-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* FormBibtex.C: Move parsing of Options (stylefile, bibtotoc)
to the controller (bug 2322).
2006-03-10 Martin Vermeer <martin.vermeer@hut.fi>
* FormChanges.C: fix bug 2212: First change is skipped in

View File

@ -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();

View File

@ -74,6 +74,9 @@ What's new
- Use the qt wide scroll wheel setting (bug 2175).
- Propose sensible style files for bibtex, depending on whether plain,
natbib or jurabib is used (bug 2322).
* Configuration/Installation:
- Don't use the -mms-bitfields compiler switch on mingw and cygwin, since