From: André Pönitz Date: Fri, 5 Oct 2007 22:53:01 +0000 (+0000) Subject: next one X-Git-Tag: 1.6.10~8004 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f3d1cf3ca1b18e4a1645b057690e67f88bb24115;p=lyx.git next one git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20765 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/controllers/ControlShowFile.cpp b/src/frontends/controllers/ControlShowFile.cpp deleted file mode 100644 index 0bd0ebedc7..0000000000 --- a/src/frontends/controllers/ControlShowFile.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/** - * \file ControlShowFile.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Herbert Voß - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "ControlShowFile.h" - -#include "support/filetools.h" - -using std::string; - -namespace lyx { - -using support::FileName; -using support::onlyFilename; - -namespace frontend { - - -ControlShowFile::ControlShowFile(Dialog & parent) - : Controller(parent) -{} - - -bool ControlShowFile::initialiseParams(string const & data) -{ - filename_ = FileName(data); - return true; -} - - -void ControlShowFile::clearParams() -{ - filename_.erase(); -} - - -string ControlShowFile::getFileContents() -{ - return support::getFileContents(filename_); -} - - -string ControlShowFile::getFileName() -{ - return onlyFilename(filename_.absFilename()); -} - -} // namespace frontend -} // namespace lyx diff --git a/src/frontends/controllers/ControlShowFile.h b/src/frontends/controllers/ControlShowFile.h deleted file mode 100644 index 4f160b3dbc..0000000000 --- a/src/frontends/controllers/ControlShowFile.h +++ /dev/null @@ -1,49 +0,0 @@ -// -*- C++ -*- -/** - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \file ControlShowFile.h - * - * \author Herbert Voß - * - * Full author contact details are available in file CREDITS. - */ -#ifndef CONTROLSHOWFILE_H -#define CONTROLSHOWFILE_H - -#include "Dialog.h" - -#include "support/FileName.h" - -namespace lyx { -namespace frontend { - -/** A controller for the ShowFile dialog. */ - -class ControlShowFile : public Controller { -public: - /// - ControlShowFile(Dialog &); - /// - virtual bool initialiseParams(std::string const & data); - /// - virtual void clearParams(); - /// - virtual void dispatchParams() {} - /// - virtual bool isBufferDependent() const { return false; } - /// - std::string getFileContents(); - /// - std::string getFileName(); - -private: - /// - support::FileName filename_; -}; - -} // namespace frontend -} // namespace lyx - -#endif // CONTROLSHOWFILE_H diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index 2850f25bf8..82ff1ef0e3 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -31,7 +31,6 @@ SOURCEFILES = \ ControlPrint.cpp \ ControlSearch.cpp \ ControlSendto.cpp \ - ControlShowFile.cpp \ ControlSpellchecker.cpp \ ControlTabular.cpp \ ControlTabularCreate.cpp \ @@ -64,7 +63,6 @@ HEADERFILES = \ ControlPrint.h \ ControlSearch.h \ ControlSendto.h \ - ControlShowFile.h \ ControlSpellchecker.h \ ControlTabular.h \ ControlTabularCreate.h \ diff --git a/src/frontends/qt4/Dialogs.cpp b/src/frontends/qt4/Dialogs.cpp index 280d0e0754..4e550ccaba 100644 --- a/src/frontends/qt4/Dialogs.cpp +++ b/src/frontends/qt4/Dialogs.cpp @@ -185,7 +185,7 @@ Dialog * Dialogs::build(string const & name) } else if (name == "external") { dialog = new GuiExternalDialog(lyxview_); } else if (name == "file") { - dialog = new GuiShowFileDialog(lyxview_); + dialog = createGuiShowFile(lyxview_); } else if (name == "findreplace") { dialog = new GuiSearchDialog(lyxview_); } else if (name == "float") { diff --git a/src/frontends/qt4/GuiShowFile.cpp b/src/frontends/qt4/GuiShowFile.cpp index 000325f8f3..7b1b8abae9 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,8 +13,8 @@ #include "GuiShowFile.h" -#include "ControlShowFile.h" #include "qt_helpers.h" +#include "support/filetools.h" #include #include @@ -23,12 +24,15 @@ namespace lyx { namespace frontend { -GuiShowFileDialog::GuiShowFileDialog(LyXView & lv) - : GuiDialog(lv, "file") +using support::FileName; +using support::onlyFilename; + +GuiShowFile::GuiShowFile(LyXView & lv) + : GuiDialog(lv, "file"), Controller(this) { setupUi(this); setViewTitle(_("Show File")); - setController(new ControlShowFile(*this)); + setController(this, false); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); @@ -37,31 +41,41 @@ GuiShowFileDialog::GuiShowFileDialog(LyXView & lv) } -ControlShowFile & GuiShowFileDialog::controller() -{ - return static_cast(GuiDialog::controller()); -} - - -void GuiShowFileDialog::closeEvent(QCloseEvent * e) +void GuiShowFile::closeEvent(QCloseEvent * e) { slotClose(); e->accept(); } -void GuiShowFileDialog::updateContents() +void GuiShowFile::updateContents() { - setWindowTitle(toqstr(controller().getFileName())); + setWindowTitle(toqstr(onlyFilename(filename_.absFilename()))); - std::string contents = controller().getFileContents(); - if (contents.empty()) { + std::string contents = support::getFileContents(filename_); + if (contents.empty()) contents = "Error -> Cannot load file!"; - } textTB->setPlainText(toqstr(contents)); } + +bool GuiShowFile::initialiseParams(std::string const & data) +{ + filename_ = FileName(data); + return true; +} + + +void GuiShowFile::clearParams() +{ + filename_.erase(); +} + + +Dialog * createGuiShowFile(LyXView & lv) { return new GuiShowFile(lv); } + + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/GuiShowFile.h b/src/frontends/qt4/GuiShowFile.h index 44e9a781ee..20ea49fc20 100644 --- a/src/frontends/qt4/GuiShowFile.h +++ b/src/frontends/qt4/GuiShowFile.h @@ -5,6 +5,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. */ @@ -13,26 +14,38 @@ #define GUISHOWFILE_H #include "GuiDialog.h" -#include "ControlShowFile.h" #include "ui_ShowFileUi.h" +#include "support/FileName.h" + namespace lyx { namespace frontend { -class GuiShowFileDialog : public GuiDialog, public Ui::ShowFileUi +class GuiShowFile : public GuiDialog, public Ui::ShowFileUi, public Controller { Q_OBJECT public: - GuiShowFileDialog(LyXView & lv); + GuiShowFile(LyXView & lv); private: /// void closeEvent(QCloseEvent * e); /// parent controller - ControlShowFile & controller(); + Controller & controller() { return *this; } /// update void updateContents(); + /// + bool initialiseParams(std::string const & data); + /// + void clearParams(); + /// + void dispatchParams() {} + /// + bool isBufferDependent() const { return false; } + + /// + support::FileName filename_; }; } // namespace frontend