]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiShowFile.cpp
Merge QController into individual dialogs. Also various cleanup
[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 #include "Qt2BC.h"
15 #include "qt_helpers.h"
16
17 #include <QTextBrowser>
18 #include <QPushButton>
19 #include <QCloseEvent>
20
21 namespace lyx {
22 namespace frontend {
23
24 /////////////////////////////////////////////////////////////////////
25 //
26 // GuiShowFileDialog
27 //
28 /////////////////////////////////////////////////////////////////////
29
30 GuiShowFileDialog::GuiShowFileDialog(GuiShowFile * form)
31         : form_(form)
32 {
33         setupUi(this);
34         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
35 }
36
37
38 void GuiShowFileDialog::closeEvent(QCloseEvent * e)
39 {
40         form_->slotWMHide();
41         e->accept();
42 }
43
44
45 /////////////////////////////////////////////////////////////////////
46 //
47 // GuiShowFile
48 //
49 /////////////////////////////////////////////////////////////////////
50
51
52 GuiShowFile::GuiShowFile(Dialog & parent)
53         : GuiView<GuiShowFileDialog>(parent, _("Show File"))
54 {
55 }
56
57
58 void GuiShowFile::build_dialog()
59 {
60         dialog_.reset(new GuiShowFileDialog(this));
61
62         bcview().setCancel(dialog_->closePB);
63 }
64
65
66 void GuiShowFile::update_contents()
67 {
68         dialog_->setWindowTitle(toqstr(controller().getFileName()));
69
70         std::string contents = controller().getFileContents();
71         if (contents.empty()) {
72                 contents = "Error -> Cannot load file!";
73         }
74
75         dialog_->textTB->setPlainText(toqstr(contents));
76 }
77
78 } // namespace frontend
79 } // namespace lyx
80
81 #include "GuiShowFile_moc.cpp"