]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlChanges.C
Pimpl Buffer.
[lyx.git] / src / frontends / controllers / ControlChanges.C
1 /**
2  * \file ControlChanges.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "ControlChanges.h"
14 #include "buffer.h"
15 #include "bufferparams.h"
16 #include "BufferView.h"
17 #include "changes.h"
18 #include "funcrequest.h"
19 #include "lyxfind.h"
20 #include "support/lstrings.h"
21
22 using namespace lyx::support;
23
24 ControlChanges::ControlChanges(Dialog & parent)
25         : Dialog::Controller(parent)
26 {}
27
28
29 bool ControlChanges::find()
30 {
31         return lyx::find::findNextChange(kernel().bufferview());
32 }
33
34
35 string const ControlChanges::getChangeDate()
36 {
37         Change c(kernel().bufferview()->getCurrentChange());
38         if (c.type == Change::UNCHANGED || !c.changetime)
39                 return string();
40
41         // ctime adds newline; trim it off!
42         string const date = rtrim(ctime(&c.changetime), "\n");
43         return date;
44 }
45
46
47 string const ControlChanges::getChangeAuthor()
48 {
49         Change c(kernel().bufferview()->getCurrentChange());
50         if (c.type == Change::UNCHANGED)
51                 return string();
52
53         Author const & a(kernel().buffer().authors().get(c.author));
54
55         string author(a.name());
56
57         if (!a.email().empty()) {
58                 author += " (";
59                 author += a.email() + ")";
60         }
61
62         return author;
63 }
64
65
66 void ControlChanges::accept()
67 {
68         kernel().dispatch(FuncRequest(LFUN_ACCEPT_CHANGE));
69         lyx::find::findNextChange(kernel().bufferview());
70 }
71
72
73 void ControlChanges::reject()
74 {
75         kernel().dispatch(FuncRequest(LFUN_REJECT_CHANGE));
76         lyx::find::findNextChange(kernel().bufferview());
77 }