]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QShowFile.C
Rename .C ==> .cpp for files in src/frontends/qt4, part one
[lyx.git] / src / frontends / qt4 / QShowFile.C
1 /**
2  * \file QShowFile.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 "QShowFile.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 // QShowFileDialog
28 //
29 /////////////////////////////////////////////////////////////////////
30
31 QShowFileDialog::QShowFileDialog(QShowFile * form)
32         : form_(form)
33 {
34         setupUi(this);
35         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
36 }
37
38
39 void QShowFileDialog::closeEvent(QCloseEvent * e)
40 {
41         form_->slotWMHide();
42         e->accept();
43 }
44
45
46 /////////////////////////////////////////////////////////////////////
47 //
48 // QShowFile 
49 //
50 /////////////////////////////////////////////////////////////////////
51
52 typedef QController<ControlShowFile, QView<QShowFileDialog> >
53         ShowFileBase;
54
55
56 QShowFile::QShowFile(Dialog & parent)
57         : ShowFileBase(parent, _("Show File"))
58 {
59 }
60
61
62 void QShowFile::build_dialog()
63 {
64         dialog_.reset(new QShowFileDialog(this));
65
66         bcview().setCancel(dialog_->closePB);
67 }
68
69
70 void QShowFile::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 "QShowFile_moc.cpp"