]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiShowFile.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiShowFile.cpp
index 7b1b8abae95a190d5279874f2bef9a301688f28c..c2a4360b2fca7ff0b4f42ce9cb553ebaad23b297 100644 (file)
 
 #include <QTextBrowser>
 #include <QPushButton>
-#include <QCloseEvent>
 
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 namespace frontend {
 
-using support::FileName;
-using support::onlyFilename;
 
-GuiShowFile::GuiShowFile(LyXView & lv)
-       : GuiDialog(lv, "file"), Controller(this)
+GuiShowFile::GuiShowFile(GuiView & lv)
+       : GuiDialog(lv, "file", qt_("Show File"))
 {
        setupUi(this);
-       setViewTitle(_("Show File"));
-       setController(this, false);
 
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
 
@@ -41,26 +38,19 @@ GuiShowFile::GuiShowFile(LyXView & lv)
 }
 
 
-void GuiShowFile::closeEvent(QCloseEvent * e)
-{
-       slotClose();
-       e->accept();
-}
-
-
 void GuiShowFile::updateContents()
 {
-       setWindowTitle(toqstr(onlyFilename(filename_.absFilename())));
+       setWindowTitle(onlyFilename(toqstr(filename_.absFilename())));
 
-       std::string contents = support::getFileContents(filename_);
-       if (contents.empty())
-               contents = "Error -> Cannot load file!";
+       QString contents = toqstr(filename_.fileContents("UTF-8"));
+       if (contents.isEmpty())
+               contents = qt_("Error -> Cannot load file!");
 
-       textTB->setPlainText(toqstr(contents));
+       textTB->setPlainText(contents);
 }
 
 
-bool GuiShowFile::initialiseParams(std::string const & data)
+bool GuiShowFile::initialiseParams(string const & data)
 {
        filename_ = FileName(data);
        return true;
@@ -73,10 +63,10 @@ void GuiShowFile::clearParams()
 }
 
 
-Dialog * createGuiShowFile(LyXView & lv) { return new GuiShowFile(lv); }
+Dialog * createGuiShowFile(GuiView & lv) { return new GuiShowFile(lv); }
 
 
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiShowFile_moc.cpp"
+#include "moc_GuiShowFile.cpp"