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