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