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