]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiShowFile.cpp
Remove the magic boolean in getChildren() from the public interface.
[lyx.git] / src / frontends / qt4 / GuiShowFile.cpp
index 306b3efd5fe8513c3dda44a6cfc3fbadc2c541eb..8dc7a98df1f3b6b4597564b3d14b19af439c745f 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 "Qt2BC.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(Dialog & parent)
-       : GuiView<GuiShowFileDialog>(parent, _("Show File"))
-{
+       textTB->setPlainText(contents);
 }
 
 
-void GuiShowFile::build_dialog()
+bool GuiShowFile::initialiseParams(string const & data)
 {
-       dialog_.reset(new GuiShowFileDialog(this));
-
-       bcview().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"