GuiBibtex: add button to edit individual databases externally

This complements the inset context menu function, which only allows for
editing all databases externally
This commit is contained in:
Juergen Spitzmueller 2019-03-30 11:37:28 +01:00
parent 02974ff2a9
commit c12190b5e5
5 changed files with 53 additions and 7 deletions

View File

@ -185,6 +185,7 @@ void GuiBibtex::setButtons()
void GuiBibtex::selUpdated()
{
selectionManager->update();
editPB->setEnabled(deletePB->isEnabled());
changed();
}
@ -240,6 +241,19 @@ void GuiBibtex::browseBibPressed()
}
void GuiBibtex::on_editPB_clicked()
{
QModelIndexList selIdx =
selectedLV->selectionModel()->selectedIndexes();
if (selIdx.isEmpty())
return;
QModelIndex idx = selIdx.first();
QString sel = idx.data().toString();
FuncRequest fr(LFUN_INSET_EDIT, fromqstr(sel));
dispatch(fr);
}
void GuiBibtex::rescanClicked()
{
rescanBibStyles();
@ -297,6 +311,7 @@ void GuiBibtex::setSelectedBibs(QStringList const sl)
"encoding than specified below, set it here"));
selectedLV->setIndexWidget(selected_model_.index(i, 1), cb);
}
editPB->setEnabled(deletePB->isEnabled());
}
@ -392,6 +407,7 @@ void GuiBibtex::updateContents()
biblatexOptsLE->setText(toqstr(params_["biblatexopts"]));
setFileEncodings(getVectorFromString(params_["file_encodings"], from_ascii("\t")));
editPB->setEnabled(deletePB->isEnabled());
}
@ -399,8 +415,8 @@ void GuiBibtex::applyView()
{
docstring dbs;
unsigned int maxCount = selected_bibs_.count();
for (unsigned int i = 0; i < maxCount; i++) {
int maxCount = selected_bibs_.count();
for (int i = 0; i < maxCount; i++) {
if (i != 0)
dbs += ',';
QString item = selected_bibs_.at(i);

View File

@ -39,6 +39,7 @@ private Q_SLOTS:
void on_buttonBox_accepted();
void browseBstPressed();
void browseBibPressed();
void on_editPB_clicked();
void databaseChanged();
void rescanClicked();
void selUpdated();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>523</width>
<height>576</height>
<height>617</height>
</rect>
</property>
<property name="windowTitle">
@ -141,6 +141,33 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="editPB">
<property name="toolTip">
<string>Edit selected database externally</string>
</property>
<property name="text">
<string>&amp;Edit...</string>
</property>
<property name="icon">
<iconset>
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -85,7 +85,7 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
switch (cmd.action()) {
case LFUN_INSET_EDIT:
editDatabases();
editDatabases(cmd.argument());
break;
case LFUN_INSET_MODIFY: {
@ -132,7 +132,7 @@ bool InsetBibtex::getStatus(Cursor & cur, FuncRequest const & cmd,
}
void InsetBibtex::editDatabases() const
void InsetBibtex::editDatabases(docstring const db) const
{
vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
@ -140,7 +140,7 @@ void InsetBibtex::editDatabases() const
return;
size_t nr_databases = bibfilelist.size();
if (nr_databases > 1) {
if (nr_databases > 1 && db.empty()) {
docstring const engine = usingBiblatex() ? _("Biblatex") : _("BibTeX");
docstring message = bformat(_("The %1$s[[BibTeX/Biblatex]] inset includes %2$s databases.\n"
"If you proceed, all of them will be opened."),
@ -155,6 +155,8 @@ void InsetBibtex::editDatabases() const
vector<docstring>::const_iterator it = bibfilelist.begin();
vector<docstring>::const_iterator en = bibfilelist.end();
for (; it != en; ++it) {
if (!db.empty() && db != *it)
continue;
FileName const bibfile = buffer().getBibfilePath(*it);
theFormats().edit(buffer(), bibfile,
theFormats().getFormatFromFile(bibfile));

View File

@ -82,7 +82,7 @@ public:
private:
///
void editDatabases() const;
void editDatabases(docstring const db = docstring()) const;
///
void parseBibTeXFiles(support::FileNameList &) const;
///