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