]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlChanges.C
Flatten the ButtonController tree by splitting it into a Controller and
[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 #include "frontends/Dialogs.h"
15 #include "frontends/LyXView.h"
16 #include "buffer.h"
17 #include "BufferView.h"
18 #include "funcrequest.h"
19 #include "lyxfind.h"
20 #include "author.h"
21 #include "support/lstrings.h"
22
23
24 ControlChanges::ControlChanges(Dialog & parent)
25         : Dialog::Controller(parent)
26 {}
27
28
29 void ControlChanges::find()
30 {
31         lyxfind::findNextChange(kernel().bufferview());
32 }
33
34
35 string const ControlChanges::getChangeDate()
36 {
37         Change c(kernel().bufferview()->getCurrentChange());
38         if (c.type == Change::UNCHANGED || !c.changetime)
39                 return string();
40         return ctime(&c.changetime);
41 }
42
43
44 string const ControlChanges::getChangeAuthor()
45 {
46         Change c(kernel().bufferview()->getCurrentChange());
47         if (c.type == Change::UNCHANGED)
48                 return string();
49
50         Author const & a(kernel().buffer()->authors().get(c.author));
51
52         string author(a.name());
53
54         if (!a.email().empty()) {
55                 author += " (";
56                 author += a.email() + ")";
57         }
58
59         return author;
60 }
61
62
63 void ControlChanges::accept()
64 {
65         kernel().dispatch(FuncRequest(LFUN_ACCEPT_CHANGE));
66         lyxfind::findNextChange(kernel().bufferview());
67 }
68
69
70 void ControlChanges::reject()
71 {
72         kernel().dispatch(FuncRequest(LFUN_REJECT_CHANGE));
73         lyxfind::findNextChange(kernel().bufferview());
74 }