X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiShowFile.cpp;h=8dc7a98df1f3b6b4597564b3d14b19af439c745f;hb=5a46224f7311067cda747e0cae32d22dd919f179;hp=306b3efd5fe8513c3dda44a6cfc3fbadc2c541eb;hpb=fc36725282df43059aee9a821f098309ccdbd523;p=lyx.git diff --git a/src/frontends/qt4/GuiShowFile.cpp b/src/frontends/qt4/GuiShowFile.cpp index 306b3efd5f..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. */ @@ -11,71 +12,61 @@ #include #include "GuiShowFile.h" -#include "Qt2BC.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::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(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"