From 90ae998287623b14cef1c75f8385063023a77c00 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 26 Dec 2019 11:17:09 +0100 Subject: [PATCH] Show modified text in merge changes dialog as far as possible Fixes #1362 --- src/frontends/qt/GuiChanges.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/frontends/qt/GuiChanges.cpp b/src/frontends/qt/GuiChanges.cpp index 150d8a1c3b..c1f331feda 100644 --- a/src/frontends/qt/GuiChanges.cpp +++ b/src/frontends/qt/GuiChanges.cpp @@ -24,8 +24,10 @@ #include "BufferParams.h" #include "BufferView.h" #include "Changes.h" +#include "Cursor.h" #include "FuncRequest.h" #include "LyXRC.h" +#include "Text.h" #include #include @@ -65,26 +67,40 @@ void GuiChanges::updateContents() bool const changePresent = c.type != Change::UNCHANGED; rejectPB->setEnabled(changePresent); acceptPB->setEnabled(changePresent); + bool const inserted = c.type == Change::INSERTED; QString text; if (changePresent) { QString const author = toqstr(buffer().params().authors().get(c.author).nameAndEmail()); if (!author.isEmpty()) - text += (c.type == Change::INSERTED) ? qt_("Inserted by %1").arg(author) - : qt_("Deleted by %1").arg(author); + text += inserted ? qt_("Inserted by %1").arg(author) + : qt_("Deleted by %1").arg(author); QString const date = QDateTime::fromTime_t(c.changetime) .toString(Qt::DefaultLocaleLongDate); if (!date.isEmpty()) { if (!author.isEmpty()) - text += qt_(" on[[date]] %1\n").arg(date); + text += qt_(" on[[date]] %1").arg(date); else - text += (c.type == Change::INSERTED) ? qt_("Inserted on %1\n").arg(date) - : qt_("Deleted on %1\n").arg(date); + text += inserted ? qt_("Inserted on %1").arg(date) + : qt_("Deleted on %1").arg(date); + } + QString changedcontent = toqstr(bufferview()->cursor().selectionAsString(false)); + if (!changedcontent.isEmpty()) { + text += ":

"; + if (inserted) + text += ""; + else + text += ""; + text += changedcontent; + if (inserted) + text += ""; + else + text += ""; } } - changeTB->setPlainText(text); + changeTB->setHtml(text); } -- 2.39.5