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