]> git.lyx.org Git - lyx.git/blob - src/frontends/kde/FormLog.C
small cleanup, doxygen, formatting changes
[lyx.git] / src / frontends / kde / FormLog.C
1 /**
2  * \file FormLog.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon
7  */
8
9 #include <config.h>
10 #include <fstream> 
11
12 #include "Dialogs.h"
13 #include "FormLog.h"
14 #include "gettext.h"
15 #include "buffer.h"
16 #include "support/lstrings.h"
17 #include "LyXView.h"
18 #include "lyxfunc.h"
19 #include "logdlg.h"
20 #include "lyxrc.h"
21
22 using std::ifstream;
23 using std::getline;
24
25 FormLog::FormLog(LyXView *v, Dialogs *d)
26         : dialog_(0), lv_(v), d_(d), h_(0), u_(0)
27 {
28         d->showLogFile.connect(slot(this, &FormLog::show));
29 }
30
31
32 FormLog::~FormLog()
33 {
34         delete dialog_;
35 }
36
37
38 void FormLog::update()
39 {
40         supdate();
41 }
42
43  
44 void FormLog::supdate(bool)
45 {
46         std::pair<Buffer::LogType, string> const logfile
47                 = lv_->view()->buffer()->getLogName();
48
49         if (logfile.first == Buffer::buildlog)
50                 dialog_->setCaption(_("Build log"));
51         else
52                 dialog_->setCaption(_("LaTeX log"));
53
54         dialog_->setLogText("");
55
56         ifstream ifstr(logfile.second.c_str());
57         if (!ifstr) {
58                 if (logfile.first == Buffer::buildlog)
59                         dialog_->setLogText(_("No build log file found"));
60                 else
61                         dialog_->setLogText(_("No LaTeX log file found"));
62                 return;
63         }
64
65         string text;
66         string line;
67
68         while (getline(ifstr, line))
69                 text += line + "\n";
70  
71         dialog_->setLogText(text);
72 }
73
74
75 void FormLog::show()
76 {
77         if (!dialog_)
78                 dialog_ = new LogDialog(this, 0, _("LyX: LaTeX Log"));
79
80         if (!dialog_->isVisible()) {
81                 h_ = d_->hideBufferDependent.connect(slot(this, &FormLog::hide));
82                 u_ = d_->updateBufferDependent.connect(slot(this, &FormLog::supdate));
83         }
84
85         dialog_->raise();
86         dialog_->setActiveWindow();
87
88         update();
89         dialog_->show();
90 }
91
92
93 void FormLog::close()
94 {
95         h_.disconnect();
96         u_.disconnect();
97 }
98
99
100 void FormLog::hide()
101 {
102         dialog_->hide();
103         close();
104 }