]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QLog.C
Lots and lots of little trivial bits.
[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 #include <fstream>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "LyXView.h"
19 #include "gettext.h"
20 #include "ControlLog.h"
21
22 #include <qtextview.h>
23 #include <qpushbutton.h>
24
25 #include "QLogDialog.h"
26 #include "QLog.h"
27 #include "Qt2BC.h"
28
29 using std::ifstream;
30 using std::getline;
31
32 typedef Qt2CB<ControlLog, Qt2DB<QLogDialog> > base_class;
33
34 QLog::QLog()
35         : base_class(_("Log"))
36 {
37 }
38
39
40 void QLog::build_dialog()
41 {
42         dialog_.reset(new QLogDialog(this));
43
44         bc().setCancel(dialog_->closePB);
45 }
46
47
48 void QLog::update_contents()
49 {
50         std::pair<Buffer::LogType, string> const logfile = controller().logfile();
51
52         if (logfile.first == Buffer::buildlog)
53                 dialog_->setCaption(_("Build log"));
54         else
55                 dialog_->setCaption(_("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(_("No build log file found"));
63                 else
64                         dialog_->logTV->setText(_("No LaTeX log file found"));
65                 return;
66         }
67
68         string text;
69         string line;
70
71         while (getline(ifstr, line))
72                 text += line + "\n";
73
74         dialog_->logTV->setText(text.c_str());
75 }