]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiProgressView.cpp
00ba5ee6a00f60805f12ebdec00387e65d05bdcd
[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
28
29 GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area, 
30         Qt::WindowFlags flags) : DockView(parent, "progress", "Progress monitoring", area, flags)
31 {
32         setWindowTitle(qt_("Progress monitoring"));
33         setWidget(&text_edit);
34         text_edit.setReadOnly(true);
35
36         GuiProgress* progress = dynamic_cast<GuiProgress*>(support::ProgressInterface::instance());
37
38         if (progress) {
39                 connect(progress, SIGNAL(processStarted(QString const &)), this, SLOT(appendText(QString const &)));
40                 //connect(progress, SIGNAL(processFinished(QString const &)), this, SLOT(appendText(QString const &)));
41                 connect(progress, SIGNAL(appendMessage(QString const &)), this, SLOT(appendText(QString const &)));
42                 connect(progress, SIGNAL(appendError(QString const &)), this, SLOT(appendText(QString const &)));
43                 connect(progress, SIGNAL(clearMessages()), this, SLOT(clearText()));
44         }
45 }
46
47
48 void GuiProgressView::clearText()
49 {
50         text_edit.clear();
51 }
52
53
54 void GuiProgressView::appendText(QString const & text)
55 {
56         if (text.isEmpty())
57                 return;
58         QString time = QTime::currentTime().toString();
59         text_edit.insertPlainText(time + ": " + text.trimmed() + "\n");
60         text_edit.ensureCursorVisible();
61 }
62
63
64
65 Dialog * createGuiProgressView(GuiView & guiview)
66 {
67 #ifdef Q_WS_MACX
68         return new GuiProgressView(guiview, Qt::RightDockWidgetArea, Qt::Drawer);
69 #else
70         return new GuiProgressView(guiview, Qt::BottomDockWidgetArea);
71 #endif
72 }
73
74
75
76 } // namespace frontend
77 } // namespace lyx
78
79 #include "moc_GuiProgressView.cpp"