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"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
|
|
|
#include "author.h"
|
2003-02-08 19:18:01 +00:00
|
|
|
#include "buffer.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
#include "bufferparams.h"
|
2003-02-08 19:18:01 +00:00
|
|
|
#include "BufferView.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
#include "changes.h"
|
2003-02-08 19:18:01 +00:00
|
|
|
#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-09-09 22:13:45 +00:00
|
|
|
using lyx::support::rtrim;
|
|
|
|
|
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-09-09 17:00:19 +00:00
|
|
|
Author const & a(kernel().buffer().params().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
|
|
|
}
|