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