]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlVCLog.C
bug 183
[lyx.git] / src / frontends / controllers / ControlVCLog.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file ControlVCLog.C
11  * \author John Levon, moz@compsoc.man.ac.uk
12  * \author Angus Leeming <a.leeming@ic.ac.uk>
13  */
14
15 #include <config.h>
16 #include <fstream>
17 #include "Lsstream.h"
18
19 #ifdef __GNUG__
20 #pragma implementation
21 #endif
22
23 #include "ViewBase.h"
24 #include "ButtonControllerBase.h"
25 #include "ControlVCLog.h"
26 #include "buffer.h"
27 #include "BufferView.h"
28 #include "LyXView.h"
29 #include "Dialogs.h"
30 #include "lyxrc.h"
31 #include "support/lyxlib.h"
32 #include "gettext.h"
33
34 using SigC::slot;
35 using std::endl;
36
37 ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
38         : ControlDialog<ControlConnectBD>(lv, d)
39 {
40         d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
41 }
42
43 string const ControlVCLog::getBufferFileName() const
44 {
45         return lv_.view()->buffer()->fileName();
46 }
47
48
49 stringstream & ControlVCLog::getVCLogFile(stringstream & ss) const
50 {
51         string const name = lv_.view()->buffer()->lyxvc.getLogFile();
52
53         std::ifstream in(name.c_str());
54
55         bool found = (in.get());
56
57         if (found) {
58                 in.seekg(0, std::ios::beg); // rewind to the beginning
59
60                 ss << in.rdbuf();
61                 found = ss.good();
62         }
63         
64         if (!found)
65                 ss << _("No version control log file found.") << endl;
66
67         lyx::unlink(name);
68
69         return ss;
70 }