X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiShowFile.cpp;h=c2a4360b2fca7ff0b4f42ce9cb553ebaad23b297;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=821fdb67fc5df3b6d8c29dbf557321cd104af68e;hpb=34492a9d033aef3d4369d4d758b01f3969ef3af0;p=lyx.git diff --git a/src/frontends/qt4/GuiShowFile.cpp b/src/frontends/qt4/GuiShowFile.cpp index 821fdb67fc..c2a4360b2f 100644 --- a/src/frontends/qt4/GuiShowFile.cpp +++ b/src/frontends/qt4/GuiShowFile.cpp @@ -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. */ @@ -12,23 +13,23 @@ #include "GuiShowFile.h" -#include "ControlShowFile.h" #include "qt_helpers.h" +#include "support/filetools.h" #include #include -#include +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() const +void GuiShowFile::updateContents() { - return static_cast(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::update_contents() +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"