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"
|
|
|
|
|
|
|
|
#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 "lyxfind.h"
|
|
|
|
#include "LyXRC.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-25 10:25:37 +00:00
|
|
|
#include <QCloseEvent>
|
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
|
|
|
using support::bformat;
|
|
|
|
|
|
|
|
GuiChanges::GuiChanges(LyXView & lv)
|
2007-10-09 19:34:27 +00:00
|
|
|
: GuiDialog(lv, "changes")
|
2007-04-25 10:25:37 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
setViewTitle(_("Merge Changes"));
|
|
|
|
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-10-06 11:03:21 +00:00
|
|
|
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange()));
|
|
|
|
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::closeEvent(QCloseEvent *e)
|
2007-04-25 10:25:37 +00:00
|
|
|
{
|
2007-09-11 17:06:15 +00:00
|
|
|
slotClose();
|
2007-04-25 10:25:37 +00:00
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 11:03:21 +00:00
|
|
|
void GuiChanges::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-09-11 08:54:10 +00:00
|
|
|
docstring text;
|
2007-10-06 11:03:21 +00:00
|
|
|
docstring author = changeAuthor();
|
|
|
|
docstring date = changeDate();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
if (!author.empty())
|
2006-09-11 08:54:10 +00:00
|
|
|
text += bformat(_("Change by %1$s\n\n"), author);
|
2006-03-05 17:24:44 +00:00
|
|
|
if (!date.empty())
|
2006-09-11 08:54:10 +00:00
|
|
|
text += bformat(_("Change made at %1$s\n"), date);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
changeTB->setPlainText(toqstr(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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 11:03:21 +00:00
|
|
|
docstring GuiChanges::changeDate() const
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-10-06 11:03:21 +00:00
|
|
|
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));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 11:03:21 +00:00
|
|
|
docstring GuiChanges::changeAuthor() const
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-10-06 11:03:21 +00:00
|
|
|
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;
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Dialog * createGuiChanges(LyXView & lv) { return new GuiChanges(lv); }
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 10:25:37 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiChanges_moc.cpp"
|