]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlVCLog.C
small changes read changelog
[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
32 using SigC::slot;
33 using std::endl;
34
35 ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
36         : ControlDialog<ControlConnectBD>(lv, d)
37 {
38         d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
39 }
40
41 string const ControlVCLog::getBufferFileName() const
42 {
43         return lv_.view()->buffer()->fileName();
44 }
45
46
47 std::stringstream & ControlVCLog::getVCLogFile(std::stringstream & ss) const
48 {
49         string const name = lv_.view()->buffer()->lyxvc.getLogFile();
50
51         std::ifstream in(name.c_str());
52
53         bool found = (in.get());
54
55         if (found) {
56                 in.seekg(0, std::ios::beg); // rewind to the beginning
57
58                 ss << in.rdbuf();
59                 found = ss.good();
60         }
61         
62         if (!found)
63                 ss << "No version control log file found." << endl;
64
65         lyx::unlink(name);
66
67         return ss;
68 }