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