]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlChanges.C
5c309caa7b0c3257aac760766d94466761a999a7
[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/lyxtime.h"
23
24 using std::string;
25
26 namespace lyx {
27
28 namespace frontend {
29
30
31 ControlChanges::ControlChanges(Dialog & parent)
32         : Dialog::Controller(parent)
33 {}
34
35
36 bool ControlChanges::find()
37 {
38         return findNextChange(kernel().bufferview());
39 }
40
41
42 bool ControlChanges::changed()
43 {
44         Change c(kernel().bufferview()->getCurrentChange());
45         return c.type != Change::UNCHANGED;
46 }
47
48
49 docstring const ControlChanges::getChangeDate()
50 {
51         Change c(kernel().bufferview()->getCurrentChange());
52         if (c.type == Change::UNCHANGED || !c.changetime)
53                 return docstring();
54
55         // FIXME UNICODE
56         return from_utf8(formatted_time(c.changetime));
57 }
58
59
60 docstring const ControlChanges::getChangeAuthor()
61 {
62         Change c(kernel().bufferview()->getCurrentChange());
63         if (c.type == Change::UNCHANGED)
64                 return docstring();
65
66         Author const & a(kernel().buffer().params().authors().get(c.author));
67
68         // FIXME UNICODE in Author class
69         docstring author(from_utf8(a.name()));
70
71         if (!a.email().empty()) {
72                 author += " (";
73                 author += from_utf8(a.email());
74                 author += ")";
75         }
76
77         return author;
78 }
79
80
81 bool ControlChanges::accept()
82 {
83         kernel().dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
84         return findNextChange(kernel().bufferview());
85 }
86
87
88 bool ControlChanges::reject()
89 {
90         kernel().dispatch(FuncRequest(LFUN_CHANGE_REJECT));
91         return findNextChange(kernel().bufferview());
92 }
93
94
95 } // namespace frontend
96 } // namespace lyx