]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlChanges.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[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 "BufferView.h"
16 #include "funcrequest.h"
17 #include "lyxfind.h"
18 #include "author.h"
19 #include "support/lstrings.h"
20
21 using namespace lyx::support;
22
23 ControlChanges::ControlChanges(Dialog & parent)
24         : Dialog::Controller(parent)
25 {}
26
27
28 bool ControlChanges::find()
29 {
30         return lyxfind::findNextChange(kernel().bufferview());
31 }
32
33
34 string const ControlChanges::getChangeDate()
35 {
36         Change c(kernel().bufferview()->getCurrentChange());
37         if (c.type == Change::UNCHANGED || !c.changetime)
38                 return string();
39
40         // ctime adds newline; trim it off!
41         string const date = rtrim(ctime(&c.changetime), "\n");
42         return date;
43 }
44
45
46 string const ControlChanges::getChangeAuthor()
47 {
48         Change c(kernel().bufferview()->getCurrentChange());
49         if (c.type == Change::UNCHANGED)
50                 return string();
51
52         Author const & a(kernel().buffer()->authors().get(c.author));
53
54         string author(a.name());
55
56         if (!a.email().empty()) {
57                 author += " (";
58                 author += a.email() + ")";
59         }
60
61         return author;
62 }
63
64
65 void ControlChanges::accept()
66 {
67         kernel().dispatch(FuncRequest(LFUN_ACCEPT_CHANGE));
68         lyxfind::findNextChange(kernel().bufferview());
69 }
70
71
72 void ControlChanges::reject()
73 {
74         kernel().dispatch(FuncRequest(LFUN_REJECT_CHANGE));
75         lyxfind::findNextChange(kernel().bufferview());
76 }