2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiChanges.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
2007-02-01 20:48:43 +00:00
|
|
|
* \author Michael Gerz
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiChanges.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2008-02-05 12:43:19 +00:00
|
|
|
#include "support/gettext.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "support/lstrings.h"
|
2007-10-06 11:03:21 +00:00
|
|
|
#include "support/lyxtime.h"
|
|
|
|
|
|
|
|
#include "Author.h"
|
|
|
|
#include "Buffer.h"
|
|
|
|
#include "BufferParams.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "Changes.h"
|
|
|
|
#include "FuncRequest.h"
|
|
|
|
#include "LyXRC.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2016-05-03 19:40:28 +00:00
|
|
|
#include <QDateTime>
|
2006-05-04 07:31:46 +00:00
|
|
|
#include <QTextBrowser>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-25 10:25:37 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-10-06 11:03:21 +00:00
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiChanges::GuiChanges(GuiView & lv)
|
2008-02-05 12:43:19 +00:00
|
|
|
: GuiDialog(lv, "changes", qt_("Merge Changes"))
|
2007-04-25 10:25:37 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-10-06 11:03:21 +00:00
|
|
|
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange()));
|
2009-04-05 19:15:52 +00:00
|
|
|
connect(previousPB, SIGNAL(clicked()), this, SLOT(previousChange()));
|
2007-10-06 11:03:21 +00:00
|
|
|
connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectChange()));
|
|
|
|
connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptChange()));
|
2007-04-25 10:25:37 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
bc().addReadOnly(acceptPB);
|
|
|
|
bc().addReadOnly(rejectPB);
|
2007-04-25 10:25:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 11:03:21 +00:00
|
|
|
void GuiChanges::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2016-05-03 19:40:28 +00:00
|
|
|
bool const changesPresent = buffer().areChangesPresent();
|
|
|
|
nextPB->setEnabled(changesPresent);
|
|
|
|
previousPB->setEnabled(changesPresent);
|
|
|
|
changeTB->setEnabled(changesPresent);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2016-05-03 19:40:28 +00:00
|
|
|
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);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 11:03:21 +00:00
|
|
|
void GuiChanges::nextChange()
|
2007-02-01 20:48:43 +00:00
|
|
|
{
|
2007-10-06 11:03:21 +00:00
|
|
|
dispatch(FuncRequest(LFUN_CHANGE_NEXT));
|
2007-02-01 20:48:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 19:15:52 +00:00
|
|
|
void GuiChanges::previousChange()
|
|
|
|
{
|
|
|
|
dispatch(FuncRequest(LFUN_CHANGE_PREVIOUS));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 11:03:21 +00:00
|
|
|
void GuiChanges::acceptChange()
|
|
|
|
{
|
|
|
|
dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
|
|
|
|
nextChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiChanges::rejectChange()
|
|
|
|
{
|
|
|
|
dispatch(FuncRequest(LFUN_CHANGE_REJECT));
|
|
|
|
nextChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); }
|
2007-10-06 11:03:21 +00:00
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 10:25:37 +00:00
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiChanges.cpp"
|