#include "qt_helpers.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/lyxtime.h"
#include "BufferView.h"
#include "Changes.h"
#include "FuncRequest.h"
-#include "lyxfind.h"
#include "LyXRC.h"
-#include <QCloseEvent>
+#include <QDateTime>
#include <QTextBrowser>
namespace lyx {
namespace frontend {
-using support::bformat;
-GuiChanges::GuiChanges(LyXView & lv)
- : GuiDialog(lv, "changes"), Controller(this)
+GuiChanges::GuiChanges(GuiView & lv)
+ : GuiDialog(lv, "changes", qt_("Merge Changes"))
{
setupUi(this);
- setController(this, false);
- setViewTitle(_("Merge Changes"));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange()));
+ connect(previousPB, SIGNAL(clicked()), this, SLOT(previousChange()));
connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectChange()));
connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptChange()));
}
-void GuiChanges::closeEvent(QCloseEvent *e)
-{
- slotClose();
- e->accept();
-}
-
-
void GuiChanges::updateContents()
{
- docstring text;
- docstring author = changeAuthor();
- docstring date = changeDate();
-
- if (!author.empty())
- text += bformat(_("Change by %1$s\n\n"), author);
- if (!date.empty())
- text += bformat(_("Change made at %1$s\n"), date);
+ bool const changesPresent = buffer().areChangesPresent();
+ nextPB->setEnabled(changesPresent);
+ previousPB->setEnabled(changesPresent);
+ changeTB->setEnabled(changesPresent);
- 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);
}
}
-docstring GuiChanges::changeDate() const
+void GuiChanges::previousChange()
{
- 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;
+ dispatch(FuncRequest(LFUN_CHANGE_PREVIOUS));
}
}
-Dialog * createGuiChanges(LyXView & lv) { return new GuiChanges(lv); }
+Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); }
} // namespace frontend
} // namespace lyx
-#include "GuiChanges_moc.cpp"
+#include "moc_GuiChanges.cpp"