2001-03-20 10:14:03 +00:00
|
|
|
/* This file is part of
|
2001-04-11 17:53:45 +00:00
|
|
|
* ======================================================
|
2001-03-20 10:14:03 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*
|
2001-03-21 13:27:03 +00:00
|
|
|
* \file ControlVCLog.C
|
2001-03-20 10:14:03 +00:00
|
|
|
* \author John Levon, moz@compsoc.man.ac.uk
|
|
|
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
|
|
|
*/
|
|
|
|
|
2001-04-11 17:53:45 +00:00
|
|
|
#include <fstream>
|
|
|
|
|
2001-03-20 10:14:03 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <config.h>
|
2001-04-11 17:53:45 +00:00
|
|
|
#include "Lsstream.h"
|
2001-03-20 10:14:03 +00:00
|
|
|
#include "ControlVCLog.h"
|
2001-03-21 13:27:03 +00:00
|
|
|
#include "buffer.h"
|
2001-03-20 10:14:03 +00:00
|
|
|
#include "LyXView.h"
|
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "lyxrc.h"
|
|
|
|
|
|
|
|
using SigC::slot;
|
2001-04-11 17:53:45 +00:00
|
|
|
using std::endl;
|
2001-03-20 10:14:03 +00:00
|
|
|
|
|
|
|
ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
|
2001-03-22 11:24:36 +00:00
|
|
|
: ControlDialog<ControlConnectBD>(lv, d)
|
2001-03-20 10:14:03 +00:00
|
|
|
{
|
|
|
|
d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
|
|
|
|
}
|
|
|
|
|
2001-04-11 17:53:45 +00:00
|
|
|
string const ControlVCLog::getBufferFileName() const
|
2001-03-20 10:14:03 +00:00
|
|
|
{
|
2001-04-11 17:53:45 +00:00
|
|
|
return lv_.view()->buffer()->fileName();
|
2001-03-20 10:14:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-11 17:53:45 +00:00
|
|
|
std::stringstream & ControlVCLog::getVCLogFile(std::stringstream & ss) const
|
2001-03-20 10:14:03 +00:00
|
|
|
{
|
2001-04-11 17:53:45 +00:00
|
|
|
string const name = lv_.view()->buffer()->lyxvc.getLogFile();
|
|
|
|
|
|
|
|
std::ifstream in(name.c_str());
|
|
|
|
|
|
|
|
bool found = (in.get());
|
|
|
|
|
|
|
|
if (found) {
|
|
|
|
in.seekg(0, std::ios::beg); // rewind to the beginning
|
|
|
|
|
|
|
|
ss << in.rdbuf();
|
|
|
|
found = ss.good();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
ss << "No version control log file found." << endl;
|
|
|
|
|
|
|
|
lyx::unlink(name);
|
|
|
|
|
|
|
|
return ss;
|
2001-03-20 10:14:03 +00:00
|
|
|
}
|