]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QLog.C
namespace grfx -> lyx::graphics
[lyx.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 "LyXView.h"
15 #include "qt_helpers.h"
16 #include "ControlLog.h"
17 #include "Lsstream.h"
18
19 #include <qtextview.h>
20 #include <qpushbutton.h>
21
22 #include "QLogDialog.h"
23 #include "QLog.h"
24 #include "Qt2BC.h"
25
26 #include <fstream>
27
28 using std::ifstream;
29 using std::getline;
30
31 typedef QController<ControlLog, QView<QLogDialog> > base_class;
32
33 QLog::QLog(Dialog & parent)
34         : base_class(parent, _("LyX: LaTeX Log"))
35 {
36 }
37
38
39 void QLog::build_dialog()
40 {
41         dialog_.reset(new QLogDialog(this));
42
43         bcview().setCancel(dialog_->closePB);
44 }
45
46
47 void QLog::update_contents()
48 {
49         std::pair<Buffer::LogType, string> const & logfile =
50                 controller().logfile();
51
52         if (logfile.first == Buffer::buildlog)
53                 setTitle(_("Build log"));
54         else
55                 setTitle(_("LaTeX log"));
56
57         dialog_->logTV->setText("");
58
59         ifstream ifstr(logfile.second.c_str());
60         if (!ifstr) {
61                 if (logfile.first == Buffer::buildlog)
62                         dialog_->logTV->setText(qt_("No build log file found."));
63                 else
64                         dialog_->logTV->setText(qt_("No LaTeX log file found."));
65                 return;
66         }
67
68         ostringstream ost;
69         ost << ifstr.rdbuf();
70
71         dialog_->logTV->setText(toqstr(ost.str()));
72 }