]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiProgressView.cpp
2e1bb86d0a058ac1c80c56d77ffb7479bccf841f
[lyx.git] / src / frontends / qt4 / GuiProgressView.cpp
1 // -*- C++ -*-
2 /**
3  * \file GuiProgressView.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Peter Kümmel
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiProgressView.h"
15
16 #include "qt_helpers.h"
17
18 #include "support/debug.h"
19
20 #include <QTime>
21
22
23 namespace lyx {
24 namespace frontend {
25
26
27 ProgressViewWidget::ProgressViewWidget()
28 {
29         setupUi(this);
30
31 }
32
33
34 GuiProgressView::~GuiProgressView()
35 {
36         delete widget_;
37 }
38
39
40 GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area, 
41         Qt::WindowFlags flags) : DockView(parent, "progress", "Debug/Progress window", area, flags)
42 {
43         widget_ = new ProgressViewWidget();
44         setWidget(widget_);
45
46         GuiProgress* progress = dynamic_cast<GuiProgress*>(support::ProgressInterface::instance());
47
48         if (progress) {
49                 connect(progress, SIGNAL(processStarted(QString const &)), this, SLOT(appendText(QString const &)));
50                 //connect(progress, SIGNAL(processFinished(QString const &)), this, SLOT(appendText(QString const &)));
51                 connect(progress, SIGNAL(appendMessage(QString const &)), this, SLOT(appendText(QString const &)));
52                 connect(progress, SIGNAL(appendError(QString const &)), this, SLOT(appendText(QString const &)));
53                 connect(progress, SIGNAL(clearMessages()), this, SLOT(clearText()));
54         }
55 }
56
57
58 void GuiProgressView::clearText()
59 {
60         if (widget_->autoClearCB->isChecked())
61                 widget_->outTE->clear();
62 }
63
64
65 void GuiProgressView::appendText(QString const & text)
66 {
67         if (text.isEmpty())
68                 return;
69         QString time = QTime::currentTime().toString();
70         widget_->outTE->insertPlainText(time + ": " + text.trimmed() + "\n");
71         widget_->outTE->ensureCursorVisible();
72 }
73
74
75
76 Dialog * createGuiProgressView(GuiView & guiview)
77 {
78 #ifdef Q_WS_MACX
79         return new GuiProgressView(guiview, Qt::RightDockWidgetArea, Qt::Drawer);
80 #else
81         return new GuiProgressView(guiview, Qt::BottomDockWidgetArea);
82 #endif
83 }
84
85
86
87 } // namespace frontend
88 } // namespace lyx
89
90 #include "moc_GuiProgressView.cpp"