]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiShowFile.cpp
cosmetics
[lyx.git] / src / frontends / qt4 / GuiShowFile.cpp
1 /**
2  * \file GuiShowFile.cpp
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 #include "GuiShowFile.h"
14
15 #include "ControlShowFile.h"
16 #include "qt_helpers.h"
17
18 #include <QTextBrowser>
19 #include <QPushButton>
20 #include <QCloseEvent>
21
22
23 namespace lyx {
24 namespace frontend {
25
26 GuiShowFileDialog::GuiShowFileDialog(LyXView & lv)
27         : GuiDialog(lv, "file")
28 {
29         setupUi(this);
30         setViewTitle(_("Show File"));
31         setController(new ControlShowFile(*this));
32
33         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
34
35         bc().setPolicy(ButtonPolicy::OkCancelPolicy);
36         bc().setCancel(closePB);
37 }
38
39
40 ControlShowFile & GuiShowFileDialog::controller()
41 {
42         return static_cast<ControlShowFile &>(GuiDialog::controller());
43 }
44
45
46 void GuiShowFileDialog::closeEvent(QCloseEvent * e)
47 {
48         slotClose();
49         e->accept();
50 }
51
52
53 void GuiShowFileDialog::updateContents()
54 {
55         setWindowTitle(toqstr(controller().getFileName()));
56
57         std::string contents = controller().getFileContents();
58         if (contents.empty()) {
59                 contents = "Error -> Cannot load file!";
60         }
61
62         textTB->setPlainText(toqstr(contents));
63 }
64
65 } // namespace frontend
66 } // namespace lyx
67
68 #include "GuiShowFile_moc.cpp"