]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlVCLog.C
John's character.C patch (bug fix).
[lyx.git] / src / frontends / controllers / ControlVCLog.C
index acba9d795cd62ee22601049c461df307604d7f87..cc0ad7f7790f8d41d25672c7e76759a5edf4a912 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of
- * ====================================================== 
+ * ======================================================
  *
  *           LyX, The Document Processor
  *
@@ -7,62 +7,63 @@
  *
  * ======================================================
  *
- * \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;
 }