]> git.lyx.org Git - features.git/blob - src/frontends/qt2/QLog.C
Replace LString.h with support/std_string.h,
[features.git] / src / frontends / qt2 / QLog.C
1 /**
2  * \file QLog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13
14 #include "qt_helpers.h"
15 #include "ControlLog.h"
16 #include "support/std_sstream.h"
17
18 #include <qtextview.h>
19 #include <qpushbutton.h>
20
21 #include "QLogDialog.h"
22 #include "QLog.h"
23 #include "Qt2BC.h"
24
25 #include <fstream>
26
27 using std::ifstream;
28 using std::getline;
29
30 typedef QController<ControlLog, QView<QLogDialog> > base_class;
31
32 QLog::QLog(Dialog & parent)
33         : base_class(parent, _("LyX: LaTeX Log"))
34 {
35 }
36
37
38 void QLog::build_dialog()
39 {
40         dialog_.reset(new QLogDialog(this));
41
42         bcview().setCancel(dialog_->closePB);
43 }
44
45
46 void QLog::update_contents()
47 {
48         std::pair<Buffer::LogType, string> const & logfile =
49                 controller().logfile();
50
51         if (logfile.first == Buffer::buildlog)
52                 setTitle(_("Build log"));
53         else
54                 setTitle(_("LaTeX log"));
55
56         dialog_->logTV->setText("");
57
58         ifstream ifstr(logfile.second.c_str());
59         if (!ifstr) {
60                 if (logfile.first == Buffer::buildlog)
61                         dialog_->logTV->setText(qt_("No build log file found."));
62                 else
63                         dialog_->logTV->setText(qt_("No LaTeX log file found."));
64                 return;
65         }
66
67         ostringstream ost;
68         ost << ifstr.rdbuf();
69
70         dialog_->logTV->setText(toqstr(ost.str()));
71 }