]> 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 000325f8f377fd29117382d1dc5cf6412d657eb4..c2a4360b2fca7ff0b4f42ce9cb553ebaad23b297 100644 (file)
@@ -4,6 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author John Levon
+ * \author Herbert Voß
  *
  * Full author contact details are available in file CREDITS.
  */
 
 #include "GuiShowFile.h"
 
-#include "ControlShowFile.h"
 #include "qt_helpers.h"
+#include "support/filetools.h"
 
 #include <QTextBrowser>
 #include <QPushButton>
-#include <QCloseEvent>
 
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 namespace frontend {
 
-GuiShowFileDialog::GuiShowFileDialog(LyXView & lv)
-       : GuiDialog(lv, "file")
+
+GuiShowFile::GuiShowFile(GuiView & lv)
+       : GuiDialog(lv, "file", qt_("Show File"))
 {
        setupUi(this);
-       setViewTitle(_("Show File"));
-       setController(new ControlShowFile(*this));
 
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
 
@@ -37,32 +38,35 @@ GuiShowFileDialog::GuiShowFileDialog(LyXView & lv)
 }
 
 
-ControlShowFile & GuiShowFileDialog::controller()
+void GuiShowFile::updateContents()
 {
-       return static_cast<ControlShowFile &>(GuiDialog::controller());
+       setWindowTitle(onlyFilename(toqstr(filename_.absFilename())));
+
+       QString contents = toqstr(filename_.fileContents("UTF-8"));
+       if (contents.isEmpty())
+               contents = qt_("Error -> Cannot load file!");
+
+       textTB->setPlainText(contents);
 }
 
 
-void GuiShowFileDialog::closeEvent(QCloseEvent * e)
+bool GuiShowFile::initialiseParams(string const & data)
 {
-       slotClose();
-       e->accept();
+       filename_ = FileName(data);
+       return true;
 }
 
 
-void GuiShowFileDialog::updateContents()
+void GuiShowFile::clearParams()
 {
-       setWindowTitle(toqstr(controller().getFileName()));
+       filename_.erase();
+}
 
-       std::string contents = controller().getFileContents();
-       if (contents.empty()) {
-               contents = "Error -> Cannot load file!";
-       }
 
-       textTB->setPlainText(toqstr(contents));
-}
+Dialog * createGuiShowFile(GuiView & lv) { return new GuiShowFile(lv); }
+
 
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiShowFile_moc.cpp"
+#include "moc_GuiShowFile.cpp"