mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
child documents: allow inheritance of bibliography file list (#4427)
This commit is contained in:
parent
fcc139b06e
commit
8fa7e27e7e
@ -784,6 +784,10 @@ public:
|
|||||||
void registerBibfiles(docstring_list const & bf) const;
|
void registerBibfiles(docstring_list const & bf) const;
|
||||||
///
|
///
|
||||||
support::FileName getBibfilePath(docstring const & bibid) const;
|
support::FileName getBibfilePath(docstring const & bibid) const;
|
||||||
|
/// Return the list with all bibfiles in use (including bibfiles
|
||||||
|
/// of loaded child documents).
|
||||||
|
docstring_list const &
|
||||||
|
getBibfiles(UpdateScope scope = UpdateMaster) const;
|
||||||
|
|
||||||
/// routines for dealing with possible self-inclusion
|
/// routines for dealing with possible self-inclusion
|
||||||
void pushIncludedBuffer(Buffer const * buf) const;
|
void pushIncludedBuffer(Buffer const * buf) const;
|
||||||
@ -807,10 +811,6 @@ private:
|
|||||||
/// last time we loaded the cache. Note that this does NOT update the
|
/// last time we loaded the cache. Note that this does NOT update the
|
||||||
/// cached information.
|
/// cached information.
|
||||||
void checkIfBibInfoCacheIsValid() const;
|
void checkIfBibInfoCacheIsValid() const;
|
||||||
/// Return the list with all bibfiles in use (including bibfiles
|
|
||||||
/// of loaded child documents).
|
|
||||||
docstring_list const &
|
|
||||||
getBibfiles(UpdateScope scope = UpdateMaster) const;
|
|
||||||
///
|
///
|
||||||
void collectChildren(ListOfBuffers & children, bool grand_children) const;
|
void collectChildren(ListOfBuffers & children, bool grand_children) const;
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "insets/InsetBibtex.h"
|
#include "insets/InsetBibtex.h"
|
||||||
|
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
|
#include "support/docstring_list.h"
|
||||||
#include "support/ExceptionMessage.h"
|
#include "support/ExceptionMessage.h"
|
||||||
#include "support/FileName.h"
|
#include "support/FileName.h"
|
||||||
#include "support/filetools.h" // changeExtension
|
#include "support/filetools.h" // changeExtension
|
||||||
@ -88,6 +89,8 @@ GuiBibtex::GuiBibtex(GuiView & lv)
|
|||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
connect(browseBibPB, SIGNAL(clicked()),
|
connect(browseBibPB, SIGNAL(clicked()),
|
||||||
this, SLOT(browseBibPressed()));
|
this, SLOT(browseBibPressed()));
|
||||||
|
connect(inheritPB, SIGNAL(clicked()),
|
||||||
|
this, SLOT(inheritPressed()));
|
||||||
|
|
||||||
selected_model_.insertColumns(0, 1);
|
selected_model_.insertColumns(0, 1);
|
||||||
selectionManager = new GuiSelectionManager(this, availableLV, selectedLV,
|
selectionManager = new GuiSelectionManager(this, availableLV, selectedLV,
|
||||||
@ -178,6 +181,7 @@ void GuiBibtex::setButtons()
|
|||||||
int const srows = selectedLV->model()->rowCount();
|
int const srows = selectedLV->model()->rowCount();
|
||||||
buttonBox->button(QDialogButtonBox::Apply)->setEnabled(srows > 0);
|
buttonBox->button(QDialogButtonBox::Apply)->setEnabled(srows > 0);
|
||||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(srows > 0);
|
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(srows > 0);
|
||||||
|
inheritPB->setEnabled(hasInherits());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -240,6 +244,49 @@ void GuiBibtex::browseBibPressed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GuiBibtex::hasInherits()
|
||||||
|
{
|
||||||
|
if (!buffer().parent())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
docstring_list const mbibs = buffer().masterBuffer()->getBibfiles();
|
||||||
|
if (mbibs.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (auto const & f : mbibs) {
|
||||||
|
if (!selected_bibs_.contains(toqstr(f)))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiBibtex::inheritPressed()
|
||||||
|
{
|
||||||
|
docstring_list const mbibs = buffer().masterBuffer()->getBibfiles();
|
||||||
|
bool chng = false;
|
||||||
|
vector<docstring> nfe;
|
||||||
|
for (auto const & f : mbibs) {
|
||||||
|
if (!selected_bibs_.contains(toqstr(f))) {
|
||||||
|
selected_bibs_.append(toqstr(f));
|
||||||
|
setSelectedBibs(selected_bibs_);
|
||||||
|
string enc;
|
||||||
|
if (usingBiblatex()) {
|
||||||
|
string const bfe = buffer().masterParams().bibFileEncoding(to_utf8(f));
|
||||||
|
if (!bfe.empty())
|
||||||
|
nfe.push_back(f + " " + from_utf8(bfe));
|
||||||
|
}
|
||||||
|
chng = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chng) {
|
||||||
|
if (!nfe.empty())
|
||||||
|
setFileEncodings(nfe);
|
||||||
|
change_adaptor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiBibtex::on_editPB_clicked()
|
void GuiBibtex::on_editPB_clicked()
|
||||||
{
|
{
|
||||||
QModelIndexList selIdx =
|
QModelIndexList selIdx =
|
||||||
@ -351,6 +398,8 @@ void GuiBibtex::updateContents()
|
|||||||
bibtocCB->setChecked((bibtotoc() && !bibtopic) || hasbibintoc);
|
bibtocCB->setChecked((bibtotoc() && !bibtopic) || hasbibintoc);
|
||||||
bibtocCB->setEnabled(!bibtopic && !hasbibintoc);
|
bibtocCB->setEnabled(!bibtopic && !hasbibintoc);
|
||||||
|
|
||||||
|
inheritPB->setEnabled(hasInherits());
|
||||||
|
|
||||||
btPrintCO->clear();
|
btPrintCO->clear();
|
||||||
btPrintCO->addItem(qt_("all cited references"), toqstr("btPrintCited"));
|
btPrintCO->addItem(qt_("all cited references"), toqstr("btPrintCited"));
|
||||||
if (bibtopic)
|
if (bibtopic)
|
||||||
|
@ -40,6 +40,7 @@ private Q_SLOTS:
|
|||||||
void on_buttonBox_accepted();
|
void on_buttonBox_accepted();
|
||||||
void browseBstPressed();
|
void browseBstPressed();
|
||||||
void browseBibPressed();
|
void browseBibPressed();
|
||||||
|
void inheritPressed();
|
||||||
void on_editPB_clicked();
|
void on_editPB_clicked();
|
||||||
void databaseChanged();
|
void databaseChanged();
|
||||||
void rescanClicked();
|
void rescanClicked();
|
||||||
@ -99,6 +100,8 @@ private:
|
|||||||
void dispatchParams() override;
|
void dispatchParams() override;
|
||||||
///
|
///
|
||||||
bool isBufferDependent() const override { return true; }
|
bool isBufferDependent() const override { return true; }
|
||||||
|
/// Is his a child which can inherit bibs from its master?
|
||||||
|
bool hasInherits();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>523</width>
|
<width>542</width>
|
||||||
<height>617</height>
|
<height>702</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -85,6 +85,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="inheritPB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Inherit bibliography databases from the master document</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Inherit from Master</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="deletePB">
|
<widget class="QPushButton" name="deletePB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
Loading…
Reference in New Issue
Block a user