X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiShowFile.cpp;h=8dc7a98df1f3b6b4597564b3d14b19af439c745f;hb=5a46224f7311067cda747e0cae32d22dd919f179;hp=000325f8f377fd29117382d1dc5cf6412d657eb4;hpb=470aba2a0e552f27d55992372c09f15af9725fa8;p=lyx.git diff --git a/src/frontends/qt4/GuiShowFile.cpp b/src/frontends/qt4/GuiShowFile.cpp index 000325f8f3..8dc7a98df1 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() +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::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"