]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlChanges.C
fix crash due to invalidated iterator
[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/lyxtime.h"
23
24 using std::string;
25
26 namespace lyx {
27
28 namespace frontend {
29
30
31 ControlChanges::ControlChanges(Dialog & parent)
32         : Dialog::Controller(parent)
33 {}
34
35
36 bool ControlChanges::find()
37 {
38         return find::findNextChange(kernel().bufferview());
39 }
40
41
42 string const ControlChanges::getChangeDate()
43 {
44         Change c(kernel().bufferview()->getCurrentChange());
45         if (c.type == Change::UNCHANGED || !c.changetime)
46                 return string();
47
48         return formatted_time(c.changetime);
49 }
50
51
52 string const ControlChanges::getChangeAuthor()
53 {
54         Change c(kernel().bufferview()->getCurrentChange());
55         if (c.type == Change::UNCHANGED)
56                 return string();
57
58         Author const & a(kernel().buffer().params().authors().get(c.author));
59
60         string author(a.name());
61
62         if (!a.email().empty()) {
63                 author += " (";
64                 author += a.email() + ")";
65         }
66
67         return author;
68 }
69
70
71 bool ControlChanges::accept()
72 {
73         kernel().dispatch(FuncRequest(LFUN_ACCEPT_CHANGE));
74         return find::findNextChange(kernel().bufferview());
75 }
76
77
78 bool ControlChanges::reject()
79 {
80         kernel().dispatch(FuncRequest(LFUN_REJECT_CHANGE));
81         return find::findNextChange(kernel().bufferview());
82 }
83
84
85 } // namespace frontend
86 } // namespace lyx