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