]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlChanges.C
rename getExtFromContents() to getFormatFromContents()
[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 std::string;
25
26 namespace lyx {
27
28 using support::rtrim;
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 string const ControlChanges::getChangeDate()
45 {
46         Change c(kernel().bufferview()->getCurrentChange());
47         if (c.type == Change::UNCHANGED || !c.changetime)
48                 return string();
49
50         // ctime adds newline; trim it off!
51         string const date = rtrim(ctime(&c.changetime), "\n");
52         return date;
53 }
54
55
56 string const ControlChanges::getChangeAuthor()
57 {
58         Change c(kernel().bufferview()->getCurrentChange());
59         if (c.type == Change::UNCHANGED)
60                 return string();
61
62         Author const & a(kernel().buffer().params().authors().get(c.author));
63
64         string author(a.name());
65
66         if (!a.email().empty()) {
67                 author += " (";
68                 author += a.email() + ")";
69         }
70
71         return author;
72 }
73
74
75 bool ControlChanges::accept()
76 {
77         kernel().dispatch(FuncRequest(LFUN_ACCEPT_CHANGE));
78         return find::findNextChange(kernel().bufferview());
79 }
80
81
82 bool ControlChanges::reject()
83 {
84         kernel().dispatch(FuncRequest(LFUN_REJECT_CHANGE));
85         return find::findNextChange(kernel().bufferview());
86 }
87
88
89 } // namespace frontend
90 } // namespace lyx