]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiChanges.cpp
Disable CheckTeX while buffer is processed
[lyx.git] / src / frontends / qt4 / GuiChanges.cpp
index 63268ae24e808d3dc3f89428c7649ffd3c5455b7..c168d3591bf2f43f2e6446cbd10376705b4d3d1a 100644 (file)
 #include "FuncRequest.h"
 #include "LyXRC.h"
 
+#include <QDateTime>
 #include <QTextBrowser>
 
 
 namespace lyx {
 namespace frontend {
 
-using support::bformat;
 
 GuiChanges::GuiChanges(GuiView & lv)
        : GuiDialog(lv, "changes", qt_("Merge Changes"))
@@ -55,16 +55,29 @@ GuiChanges::GuiChanges(GuiView & lv)
 
 void GuiChanges::updateContents()
 {
-       docstring text;
-       docstring author = changeAuthor();
-       docstring date = changeDate();
+       bool const changesPresent = buffer().areChangesPresent();
+       nextPB->setEnabled(changesPresent);
+       previousPB->setEnabled(changesPresent);
+       changeTB->setEnabled(changesPresent);
 
-       if (!author.empty())
-               text += bformat(_("Change by %1$s\n\n"), author);
-       if (!date.empty())
-               text += bformat(_("Change made at %1$s\n"), date);
-
-       changeTB->setPlainText(toqstr(text));
+       Change const & c = bufferview()->getCurrentChange();
+       bool const changePresent = c.type != Change::UNCHANGED;
+       rejectPB->setEnabled(changePresent);
+       acceptPB->setEnabled(changePresent);
+
+       QString text;
+       if (changePresent) {
+               QString const author =
+                       toqstr(buffer().params().authors().get(c.author).nameAndEmail());
+               if (!author.isEmpty())
+                       text += qt_("Changed by %1\n\n").arg(author);
+
+               QString const date = QDateTime::fromTime_t(c.changetime)
+                                        .toString(Qt::DefaultLocaleLongDate);
+               if (!date.isEmpty())
+                       text += qt_("Change made on %1\n").arg(date);
+       }
+       changeTB->setPlainText(text);
 }
 
 
@@ -80,34 +93,6 @@ void GuiChanges::previousChange()
 }
 
 
-docstring GuiChanges::changeDate() const
-{
-       Change const & c = bufferview()->getCurrentChange();
-       if (c.type == Change::UNCHANGED)
-               return docstring();
-
-       // FIXME UNICODE
-       return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
-}
-
-
-docstring GuiChanges::changeAuthor() const
-{
-       Change const & c = bufferview()->getCurrentChange();
-       if (c.type == Change::UNCHANGED)
-               return docstring();
-
-       Author const & a = buffer().params().authors().get(c.author);
-
-       docstring author = a.name();
-
-       if (!a.email().empty())
-               author += " (" + a.email() + ")";
-
-       return author;
-}
-
-
 void GuiChanges::acceptChange()
 {
        dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));