]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlChanges.cpp
make lyx compile
[lyx.git] / src / frontends / controllers / ControlChanges.cpp
1 /**
2  * \file ControlChanges.cpp
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  * \author Michael Gerz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "ControlChanges.h"
15
16 #include "Author.h"
17 #include "Buffer.h"
18 #include "BufferParams.h"
19 #include "BufferView.h"
20 #include "Changes.h"
21 #include "FuncRequest.h"
22 #include "lyxfind.h"
23 #include "LyXRC.h"
24
25 #include "support/lyxtime.h"
26
27
28 namespace lyx {
29
30 namespace frontend {
31
32
33 ControlChanges::ControlChanges(Dialog & parent)
34         : Dialog::Controller(parent)
35 {}
36
37
38 void ControlChanges::next()
39 {
40         kernel().dispatch(FuncRequest(LFUN_CHANGE_NEXT));
41 }
42
43
44 docstring const ControlChanges::getChangeDate()
45 {
46         Change const & c = kernel().bufferview()->getCurrentChange();
47         if (c.type == Change::UNCHANGED)
48                 return docstring();
49
50         // FIXME UNICODE
51         return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
52 }
53
54
55 docstring const ControlChanges::getChangeAuthor()
56 {
57         Change const & c = kernel().bufferview()->getCurrentChange();
58         if (c.type == Change::UNCHANGED)
59                 return docstring();
60
61         Author const & a = kernel().buffer().params().authors().get(c.author);
62
63         docstring author(a.name());
64
65         if (!a.email().empty()) {
66                 author += " (" + a.email() + ")";
67         }
68
69         return author;
70 }
71
72
73 void ControlChanges::accept()
74 {
75         kernel().dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
76         next();
77 }
78
79
80 void ControlChanges::reject()
81 {
82         kernel().dispatch(FuncRequest(LFUN_CHANGE_REJECT));
83         next();
84 }
85
86
87 } // namespace frontend
88 } // namespace lyx