]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiShowFile.cpp
getting rid of superfluous lyx::support:: statements.
[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  * \author Herbert Voß
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiShowFile.h"
15
16 #include "qt_helpers.h"
17 #include "support/filetools.h"
18
19 #include <QTextBrowser>
20 #include <QPushButton>
21 #include <QCloseEvent>
22
23 using namespace std;
24 using namespace lyx::support;
25
26 namespace lyx {
27 namespace frontend {
28
29
30 GuiShowFile::GuiShowFile(GuiView & lv)
31         : GuiDialog(lv, "file")
32 {
33         setupUi(this);
34         setViewTitle(_("Show File"));
35
36         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
37
38         bc().setPolicy(ButtonPolicy::OkCancelPolicy);
39         bc().setCancel(closePB);
40 }
41
42
43 void GuiShowFile::closeEvent(QCloseEvent * e)
44 {
45         slotClose();
46         e->accept();
47 }
48
49
50 void GuiShowFile::updateContents()
51 {
52         setWindowTitle(toqstr(onlyFilename(filename_.absFilename())));
53
54         docstring contents = filename_.fileContents("UTF-8");
55         if (contents.empty())
56                 contents = _("Error -> Cannot load file!");
57
58         textTB->setPlainText(toqstr(contents));
59 }
60
61
62 bool GuiShowFile::initialiseParams(string const & data)
63 {
64         filename_ = FileName(data);
65         return true;
66 }
67
68
69 void GuiShowFile::clearParams()
70 {
71         filename_.erase();
72 }
73
74
75 Dialog * createGuiShowFile(GuiView & lv) { return new GuiShowFile(lv); }
76
77
78 } // namespace frontend
79 } // namespace lyx
80
81 #include "GuiShowFile_moc.cpp"