]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlChanges.cpp
fix scrolling bug: 3320 and 3652, maybe not perfect
[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
24 #include "support/lyxtime.h"
25
26
27 namespace lyx {
28
29 namespace frontend {
30
31
32 ControlChanges::ControlChanges(Dialog & parent)
33         : Dialog::Controller(parent)
34 {}
35
36
37 void ControlChanges::next()
38 {
39         kernel().dispatch(FuncRequest(LFUN_CHANGE_NEXT));
40 }
41
42
43 docstring const ControlChanges::getChangeDate()
44 {
45         Change const & c = kernel().bufferview()->getCurrentChange();
46         if (c.type == Change::UNCHANGED)
47                 return docstring();
48
49         // FIXME UNICODE
50         return from_utf8(formatted_time(c.changetime));
51 }
52
53
54 docstring const ControlChanges::getChangeAuthor()
55 {
56         Change const & c = kernel().bufferview()->getCurrentChange();
57         if (c.type == Change::UNCHANGED)
58                 return docstring();
59
60         Author const & a = kernel().buffer().params().authors().get(c.author);
61
62         docstring author(a.name());
63
64         if (!a.email().empty()) {
65                 author += " (" + a.email() + ")";
66         }
67
68         return author;
69 }
70
71
72 void ControlChanges::accept()
73 {
74         kernel().dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
75         next();
76 }
77
78
79 void ControlChanges::reject()
80 {
81         kernel().dispatch(FuncRequest(LFUN_CHANGE_REJECT));
82         next();
83 }
84
85
86 } // namespace frontend
87 } // namespace lyx