]> 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 ab89573a434738cf32c65ddeccb51b76c3d5d7a4..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 <config.h>
 
 #include "GuiShowFile.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::GuiShowFileDialog(GuiShowFile * form)
-       : form_(form)
+GuiShowFile::GuiShowFile(GuiView & lv)
+       : GuiDialog(lv, "file", qt_("Show File"))
 {
        setupUi(this);
-       connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-}
 
+       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
 
-void GuiShowFileDialog::closeEvent(QCloseEvent * e)
-{
-       form_->slotWMHide();
-       e->accept();
+       bc().setPolicy(ButtonPolicy::OkCancelPolicy);
+       bc().setCancel(closePB);
 }
 
 
-/////////////////////////////////////////////////////////////////////
-//
-// GuiShowFile
-//
-/////////////////////////////////////////////////////////////////////
+void GuiShowFile::updateContents()
+{
+       setWindowTitle(onlyFilename(toqstr(filename_.absFilename())));
 
+       QString contents = toqstr(filename_.fileContents("UTF-8"));
+       if (contents.isEmpty())
+               contents = qt_("Error -> Cannot load file!");
 
-GuiShowFile::GuiShowFile(GuiDialog & parent)
-       : GuiView<GuiShowFileDialog>(parent, _("Show File"))
-{
+       textTB->setPlainText(contents);
 }
 
 
-void GuiShowFile::build_dialog()
+bool GuiShowFile::initialiseParams(string const & data)
 {
-       dialog_.reset(new GuiShowFileDialog(this));
-
-       bc().setCancel(dialog_->closePB);
+       filename_ = FileName(data);
+       return true;
 }
 
 
-void GuiShowFile::update_contents()
+void GuiShowFile::clearParams()
 {
-       dialog_->setWindowTitle(toqstr(controller().getFileName()));
+       filename_.erase();
+}
 
-       std::string contents = controller().getFileContents();
-       if (contents.empty()) {
-               contents = "Error -> Cannot load file!";
-       }
 
-       dialog_->textTB->setPlainText(toqstr(contents));
-}
+Dialog * createGuiShowFile(GuiView & lv) { return new GuiShowFile(lv); }
+
 
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiShowFile_moc.cpp"
+#include "moc_GuiShowFile.cpp"