]> git.lyx.org Git - lyx.git/commitdiff
next one
authorAndré Pönitz <poenitz@gmx.net>
Fri, 5 Oct 2007 22:53:01 +0000 (22:53 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 5 Oct 2007 22:53:01 +0000 (22:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20765 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ControlShowFile.cpp [deleted file]
src/frontends/controllers/ControlShowFile.h [deleted file]
src/frontends/controllers/Makefile.am
src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/GuiShowFile.cpp
src/frontends/qt4/GuiShowFile.h

diff --git a/src/frontends/controllers/ControlShowFile.cpp b/src/frontends/controllers/ControlShowFile.cpp
deleted file mode 100644 (file)
index 0bd0ebe..0000000
+++ /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 <config.h>
-
-#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 (file)
index 4f160b3..0000000
+++ /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
index 2850f25bf88f3d722fd6aa15072faf7dea0698c2..82ff1ef0e3b856adbee2b3e510100980bff03b13 100644 (file)
@@ -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 \
index 280d0e075425636bae347b48138c8287d28917e0..4e550ccaba5ff06fbb37a520d21f485906ffb8e8 100644 (file)
@@ -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") {
index 000325f8f377fd29117382d1dc5cf6412d657eb4..7b1b8abae95a190d5279874f2bef9a301688f28c 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.
  */
@@ -12,8 +13,8 @@
 
 #include "GuiShowFile.h"
 
-#include "ControlShowFile.h"
 #include "qt_helpers.h"
+#include "support/filetools.h"
 
 #include <QTextBrowser>
 #include <QPushButton>
 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<ControlShowFile &>(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
 
index 44e9a781eec54d218106eb3caa0a30bb05e347b8..20ea49fc202f999dce9622222b25517e669b2220 100644 (file)
@@ -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.
  */
 #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