]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QLog.C
ws cleanup
[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 using std::ifstream;
28 using std::getline;
29
30 typedef Qt2CB<ControlLog, Qt2DB<QLogDialog> > base_class;
31
32 QLog::QLog(ControlLog & c)
33         : base_class(c, _("Log"))
34 {
35 }
36
37
38 void QLog::build_dialog()
39 {
40         dialog_.reset(new QLogDialog(this));
41
42         bc().setCancel(dialog_->closePB);
43 }
44
45
46 void QLog::update_contents()
47 {
48         std::pair<Buffer::LogType, string> const logfile = controller().logfile();
49
50         if (logfile.first == Buffer::buildlog)
51                 dialog_->setCaption(_("Build log"));
52         else
53                 dialog_->setCaption(_("LaTeX log"));
54
55         dialog_->logTV->setText("");
56
57         ifstream ifstr(logfile.second.c_str());
58         if (!ifstr) {
59                 if (logfile.first == Buffer::buildlog)
60                         dialog_->logTV->setText(_("No build log file found"));
61                 else
62                         dialog_->logTV->setText(_("No LaTeX log file found"));
63                 return;
64         }
65
66         string text;
67         string line;
68
69         while (getline(ifstr, line))
70                 text += line + "\n";
71
72         dialog_->logTV->setText(text.c_str());
73 }