diff --git a/src/frontends/qt/GuiBibtex.cpp b/src/frontends/qt/GuiBibtex.cpp
index 757c2c95e4..47dda81032 100644
--- a/src/frontends/qt/GuiBibtex.cpp
+++ b/src/frontends/qt/GuiBibtex.cpp
@@ -91,6 +91,8 @@ GuiBibtex::GuiBibtex(GuiView & lv)
this, SLOT(browseBibPressed()));
connect(inheritPB, SIGNAL(clicked()),
this, SLOT(inheritPressed()));
+ connect(relAbsPB, SIGNAL(clicked()),
+ this, SLOT(relAbsPressed()));
selected_model_.insertColumns(0, 1);
selectionManager = new GuiSelectionManager(this, availableLV, selectedLV,
@@ -123,6 +125,7 @@ GuiBibtex::GuiBibtex(GuiView & lv)
bc().addReadOnly(styleCB);
bc().addReadOnly(bibtocCB);
bc().addReadOnly(bibEncodingCO);
+ bc().addReadOnly(relAbsPB);
selectedLV->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
@@ -180,6 +183,7 @@ void GuiBibtex::selUpdated()
{
selectionManager->update();
editPB->setEnabled(deletePB->isEnabled());
+ updateReAbs();
changed();
}
@@ -234,6 +238,23 @@ void GuiBibtex::browseBibPressed()
}
}
+GuiBibtex::LocalPath GuiBibtex::localPathSelected()
+{
+ QModelIndexList selIdx =
+ selectedLV->selectionModel()->selectedIndexes();
+ if (selIdx.isEmpty())
+ return LP_None;
+ QModelIndex idx = selIdx.first();
+ QString sel = idx.data().toString();
+ string const texfile = support::changeExtension(fromqstr(sel), "bib");
+ if (FileName::isAbsolute(texfile))
+ return LP_Absolute;
+ FileName const file = support::makeAbsPath(texfile, buffer().filePath());
+ if (file.exists())
+ return LP_Relative;
+ return LP_None;
+}
+
bool GuiBibtex::hasInherits()
{
@@ -278,6 +299,38 @@ void GuiBibtex::inheritPressed()
}
+void GuiBibtex::relAbsPressed()
+{
+ LocalPath const p = localPathSelected();
+
+ if (p == LP_None)
+ return;
+
+ QModelIndexList selIdx =
+ selectedLV->selectionModel()->selectedIndexes();
+ QModelIndex idx = selIdx.first();
+ QString const qf = idx.data().toString();
+ string f = fromqstr(qf);
+ FileName const file = (p == LP_Absolute) ?
+ FileName(f)
+ : support::makeAbsPath(f, buffer().filePath());
+ QString const new_item = (p == LP_Absolute)
+ ? toqstr(file.relPath(buffer().filePath()))
+ : toqstr(file.absoluteFilePath());
+ QStringList sb;
+ for (QString s : selected_bibs_) {
+ if (s == qf)
+ sb << new_item;
+ else
+ sb << s;
+ }
+ selected_bibs_ = sb;
+ setSelectedBibs(selected_bibs_);
+ selectedLV->selectRow(selected_bibs_.indexOf(new_item));
+ changed();
+}
+
+
void GuiBibtex::on_editPB_clicked()
{
QModelIndexList selIdx =
@@ -305,6 +358,25 @@ void GuiBibtex::clearSelection()
}
+void GuiBibtex::updateReAbs()
+{
+ switch (localPathSelected()) {
+ case LP_Absolute:
+ relAbsPB->setText(qt_("&Make Relative"));
+ relAbsPB->setEnabled(true);
+ break;
+ case LP_Relative:
+ relAbsPB->setText(qt_("&Make Absolute"));
+ relAbsPB->setEnabled(true);
+ break;
+ case LP_None:
+ default:
+ relAbsPB->setEnabled(false);
+ break;
+ }
+}
+
+
void GuiBibtex::setSelectedBibs(QStringList const & sl)
{
selected_model_.clear();
@@ -349,6 +421,7 @@ void GuiBibtex::setSelectedBibs(QStringList const & sl)
selectedLV->setIndexWidget(selected_model_.index(i, 1), cb);
}
editPB->setEnabled(deletePB->isEnabled());
+ updateReAbs();
}
@@ -446,6 +519,7 @@ void GuiBibtex::updateContents()
setFileEncodings(getVectorFromString(params_["file_encodings"], from_ascii("\t")));
editPB->setEnabled(deletePB->isEnabled());
+ updateReAbs();
}
diff --git a/src/frontends/qt/GuiBibtex.h b/src/frontends/qt/GuiBibtex.h
index bd0a0ea536..f29d6b8260 100644
--- a/src/frontends/qt/GuiBibtex.h
+++ b/src/frontends/qt/GuiBibtex.h
@@ -40,6 +40,7 @@ private Q_SLOTS:
void on_buttonBox_accepted();
void browseBstPressed();
void browseBibPressed();
+ void relAbsPressed();
void inheritPressed();
void on_editPB_clicked();
void databaseChanged();
@@ -102,6 +103,16 @@ private:
bool isBufferDependent() const override { return true; }
/// Is his a child which can inherit bibs from its master?
bool hasInherits();
+ /// Is an item with local path selected?
+ /// returns which (none, absolute, relative)
+ enum LocalPath {
+ LP_None,
+ LP_Absolute,
+ LP_Relative
+ };
+ LocalPath localPathSelected();
+ ///
+ void updateReAbs();
private:
///
diff --git a/src/frontends/qt/ui/BibtexUi.ui b/src/frontends/qt/ui/BibtexUi.ui
index ab2769d9ac..679d7e3b8f 100644
--- a/src/frontends/qt/ui/BibtexUi.ui
+++ b/src/frontends/qt/ui/BibtexUi.ui
@@ -85,6 +85,16 @@
+ -
+
+
+ Transfer an absolute local path to a relative one or vice versa
+
+
+ &Make Relative
+
+
+
-