]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlChanges.C
Pragmatic pimpl-ing of BufferParams.
[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 namespace lyx::support;
25
26 ControlChanges::ControlChanges(Dialog & parent)
27         : Dialog::Controller(parent)
28 {}
29
30
31 bool ControlChanges::find()
32 {
33         return lyx::find::findNextChange(kernel().bufferview());
34 }
35
36
37 string const ControlChanges::getChangeDate()
38 {
39         Change c(kernel().bufferview()->getCurrentChange());
40         if (c.type == Change::UNCHANGED || !c.changetime)
41                 return string();
42
43         // ctime adds newline; trim it off!
44         string const date = rtrim(ctime(&c.changetime), "\n");
45         return date;
46 }
47
48
49 string const ControlChanges::getChangeAuthor()
50 {
51         Change c(kernel().bufferview()->getCurrentChange());
52         if (c.type == Change::UNCHANGED)
53                 return string();
54
55         Author const & a(kernel().buffer().params().authors().get(c.author));
56
57         string author(a.name());
58
59         if (!a.email().empty()) {
60                 author += " (";
61                 author += a.email() + ")";
62         }
63
64         return author;
65 }
66
67
68 void ControlChanges::accept()
69 {
70         kernel().dispatch(FuncRequest(LFUN_ACCEPT_CHANGE));
71         lyx::find::findNextChange(kernel().bufferview());
72 }
73
74
75 void ControlChanges::reject()
76 {
77         kernel().dispatch(FuncRequest(LFUN_REJECT_CHANGE));
78         lyx::find::findNextChange(kernel().bufferview());
79 }