]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlChanges.C
The big change tracking patch. Changes from posted version :
[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 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "ViewBase.h"
18 #include "ButtonControllerBase.h"
19 #include "ControlChanges.h"
20 #include "frontends/Dialogs.h"
21 #include "frontends/LyXView.h"
22 #include "buffer.h"
23 #include "lyxfind.h"
24 #include "lyxfunc.h"
25 #include "debug.h"
26 #include "BufferView.h"
27 #include "support/lstrings.h"
28 #include "funcrequest.h"
29 #include "author.h"
30
31 ControlChanges::ControlChanges(LyXView & lv, Dialogs & d)
32         : ControlDialogBD(lv, d)
33 {
34 }
35
36
37 void ControlChanges::find()
38 {
39         lyxfind::findNextChange(bufferview());
40 }
41
42
43 string const ControlChanges::getChangeDate()
44 {
45         Change c(bufferview()->getCurrentChange());
46         if (c.type == Change::UNCHANGED || !c.changetime)
47                 return string();
48         return ctime(&c.changetime);
49 }
50
51
52 string const ControlChanges::getChangeAuthor()
53 {
54         Change c(bufferview()->getCurrentChange());
55         if (c.type == Change::UNCHANGED)
56                 return string();
57  
58         Author const & a(bufferview()->buffer()->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 void ControlChanges::accept()
72 {
73         lv_.dispatch(FuncRequest(LFUN_ACCEPT_CHANGE));
74         lyxfind::findNextChange(bufferview());
75 }
76  
77
78 void ControlChanges::reject()
79 {
80         lv_.dispatch(FuncRequest(LFUN_REJECT_CHANGE));
81         lyxfind::findNextChange(bufferview());
82 }