/* This file is part of
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
*
*
* ======================================================
*
- * \file ControlVCLog.h
+ * \file ControlVCLog.C
* \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
+#include <config.h>
+#include <fstream>
+#include "Lsstream.h"
+
#ifdef __GNUG__
#pragma implementation
#endif
-#include <config.h>
-#include "buffer.h"
-#include "ButtonController.h"
+#include "ViewBase.h"
+#include "ButtonControllerBase.h"
#include "ControlVCLog.h"
+#include "buffer.h"
+#include "BufferView.h"
#include "LyXView.h"
#include "Dialogs.h"
#include "lyxrc.h"
-#include "ViewBase.h"
+#include "support/lyxlib.h"
using SigC::slot;
+using std::endl;
ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
- : ControlConnectBD(lv, d)
+ : ControlDialog<ControlConnectBD>(lv, d)
{
d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
}
-
-void ControlVCLog::show()
+string const ControlVCLog::getBufferFileName() const
{
- if (!lv_.view()->available())
- return;
-
- logfile_ = lv_.view()->buffer()->lyxvc.getLogFile();
-
- bc().readOnly(isReadonly());
- view().show();
+ return lv_.view()->buffer()->fileName();
}
-void ControlVCLog::update()
+stringstream & ControlVCLog::getVCLogFile(stringstream & ss) const
{
- if (!lv_.view()->available())
- return;
+ string const name = lv_.view()->buffer()->lyxvc.getLogFile();
- logfile_ = lv_.view()->buffer()->lyxvc.getLogFile();
-
- bc().readOnly(isReadonly());
- view().update();
+ std::ifstream in(name.c_str());
- lyx::unlink(logfile_);
-}
+ bool found = (in.get());
+ if (found) {
+ in.seekg(0, std::ios::beg); // rewind to the beginning
-void ControlVCLog::hide()
-{
- logfile_.erase();
- disconnect();
- view().hide();
+ ss << in.rdbuf();
+ found = ss.good();
+ }
+
+ if (!found)
+ ss << "No version control log file found." << endl;
+
+ lyx::unlink(name);
+
+ return ss;
}