]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QLog.C
Log and VCLog dialogs for qt2
[lyx.git] / src / frontends / qt2 / QLog.C
1 /**
2  * \file QLog.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon <moz@compsoc.man.ac.uk>
7  */
8
9 #include <config.h>
10 #include <fstream> 
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include <qtextview.h>
17 #include <qpushbutton.h>
18  
19 #include "QLogDialog.h"
20 #include "QLog.h"
21 #include "Qt2BC.h"
22 #include "gettext.h"
23  
24 #include "QtLyXView.h"
25 #include "ControlLog.h"
26
27 typedef Qt2CB<ControlLog, Qt2DB<QLogDialog> > base_class;
28
29 QLog::QLog(ControlLog & c)
30         : base_class(c, _("Log"))
31 {
32 }
33
34
35 void QLog::build_dialog()
36 {
37         dialog_.reset(new QLogDialog(this));
38
39         bc().setCancel(dialog_->closePB);
40 }
41
42
43 void QLog::update_contents()
44 {
45         std::pair<Buffer::LogType, string> const logfile = controller().logfile();
46
47         if (logfile.first == Buffer::buildlog)
48                 dialog_->setCaption(_("Build log"));
49         else
50                 dialog_->setCaption(_("LaTeX log"));
51
52         dialog_->logTV->setText("");
53
54         ifstream ifstr(logfile.second.c_str());
55         if (!ifstr) {
56                 if (logfile.first == Buffer::buildlog)
57                         dialog_->logTV->setText(_("No build log file found"));
58                 else
59                         dialog_->logTV->setText(_("No LaTeX log file found"));
60                 return;
61         }
62
63         string text;
64         string line;
65
66         while (getline(ifstr, line))
67                 text += line + "\n";
68  
69         dialog_->logTV->setText(text.c_str());
70 }