]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QLog.C
Some string(widget->text()) fixes. Weirdness
[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 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "LyXView.h"
18 #include "gettext.h"
19 #include "ControlLog.h"
20 #include "Lsstream.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 #include <fstream>
30
31 using std::ifstream;
32 using std::getline;
33
34 typedef Qt2CB<ControlLog, Qt2DB<QLogDialog> > base_class;
35
36 QLog::QLog()
37         : base_class(_("Log"))
38 {
39 }
40
41
42 void QLog::build_dialog()
43 {
44         dialog_.reset(new QLogDialog(this));
45
46         bc().setCancel(dialog_->closePB);
47 }
48
49
50 void QLog::update_contents()
51 {
52         std::pair<Buffer::LogType, string> const & logfile =
53                 controller().logfile();
54
55         if (logfile.first == Buffer::buildlog)
56                 dialog_->setCaption(_("Build log"));
57         else
58                 dialog_->setCaption(_("LaTeX log"));
59
60         dialog_->logTV->setText("");
61
62         ifstream ifstr(logfile.second.c_str());
63         if (!ifstr) {
64                 if (logfile.first == Buffer::buildlog)
65                         dialog_->logTV->setText(_("No build log file found"));
66                 else
67                         dialog_->logTV->setText(_("No LaTeX log file found"));
68                 return;
69         }
70
71         ostringstream ost;
72         ost << ifstr.rdbuf();
73
74         dialog_->logTV->setText(ost.str().c_str());
75 }