2003-02-08 19:18:01 +00:00
|
|
|
/**
|
|
|
|
* \file ControlChanges.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-08 19:18:01 +00:00
|
|
|
*/
|
|
|
|
|
2003-02-13 16:53:15 +00:00
|
|
|
#include <config.h>
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
#include "ControlChanges.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "funcrequest.h"
|
2003-03-09 21:03:43 +00:00
|
|
|
#include "lyxfind.h"
|
|
|
|
#include "support/lstrings.h"
|
2003-02-08 19:18:01 +00:00
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
using namespace lyx::support;
|
2003-03-09 21:03:43 +00:00
|
|
|
|
|
|
|
ControlChanges::ControlChanges(Dialog & parent)
|
|
|
|
: Dialog::Controller(parent)
|
|
|
|
{}
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
|
2003-03-14 11:31:07 +00:00
|
|
|
bool ControlChanges::find()
|
2003-02-08 19:18:01 +00:00
|
|
|
{
|
2003-07-27 12:02:58 +00:00
|
|
|
return lyx::find::findNextChange(kernel().bufferview());
|
2003-02-08 19:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const ControlChanges::getChangeDate()
|
|
|
|
{
|
2003-03-09 21:03:43 +00:00
|
|
|
Change c(kernel().bufferview()->getCurrentChange());
|
2003-02-08 19:18:01 +00:00
|
|
|
if (c.type == Change::UNCHANGED || !c.changetime)
|
|
|
|
return string();
|
2003-03-14 11:31:07 +00:00
|
|
|
|
|
|
|
// ctime adds newline; trim it off!
|
|
|
|
string const date = rtrim(ctime(&c.changetime), "\n");
|
|
|
|
return date;
|
2003-02-08 19:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const ControlChanges::getChangeAuthor()
|
|
|
|
{
|
2003-03-09 21:03:43 +00:00
|
|
|
Change c(kernel().bufferview()->getCurrentChange());
|
2003-02-08 19:18:01 +00:00
|
|
|
if (c.type == Change::UNCHANGED)
|
|
|
|
return string();
|
2003-02-13 16:53:15 +00:00
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
Author const & a(kernel().buffer().authors().get(c.author));
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
string author(a.name());
|
2003-02-13 16:53:15 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
if (!a.email().empty()) {
|
|
|
|
author += " (";
|
|
|
|
author += a.email() + ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
return author;
|
|
|
|
}
|
|
|
|
|
2003-02-13 16:53:15 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
void ControlChanges::accept()
|
|
|
|
{
|
2003-03-09 21:03:43 +00:00
|
|
|
kernel().dispatch(FuncRequest(LFUN_ACCEPT_CHANGE));
|
2003-07-27 12:02:58 +00:00
|
|
|
lyx::find::findNextChange(kernel().bufferview());
|
2003-02-08 19:18:01 +00:00
|
|
|
}
|
2003-02-13 16:53:15 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
void ControlChanges::reject()
|
|
|
|
{
|
2003-03-09 21:03:43 +00:00
|
|
|
kernel().dispatch(FuncRequest(LFUN_REJECT_CHANGE));
|
2003-07-27 12:02:58 +00:00
|
|
|
lyx::find::findNextChange(kernel().bufferview());
|
2003-02-08 19:18:01 +00:00
|
|
|
}
|