]> git.lyx.org Git - features.git/commitdiff
one more
authorAndré Pönitz <poenitz@gmx.net>
Sat, 6 Oct 2007 20:09:40 +0000 (20:09 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 6 Oct 2007 20:09:40 +0000 (20:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20799 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ControlSendto.cpp [deleted file]
src/frontends/controllers/ControlSendto.h [deleted file]
src/frontends/controllers/ControlThesaurus.cpp [deleted file]
src/frontends/controllers/ControlThesaurus.h [deleted file]
src/frontends/controllers/Makefile.am
src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/GuiSendto.cpp
src/frontends/qt4/GuiSendto.h

diff --git a/src/frontends/controllers/ControlSendto.cpp b/src/frontends/controllers/ControlSendto.cpp
deleted file mode 100644 (file)
index 95b42ec..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * \file ControlSendto.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlSendto.h"
-
-#include "Buffer.h"
-#include "Converter.h"
-#include "Format.h"
-#include "FuncRequest.h"
-#include "LyXRC.h"
-
-#include "support/filetools.h"
-#include "support/lstrings.h"
-
-using std::vector;
-using std::string;
-
-namespace lyx {
-
-using support::trim;
-
-namespace frontend {
-
-
-ControlSendto::ControlSendto(Dialog & parent)
-       : Controller(parent)
-{}
-
-
-bool ControlSendto::initialiseParams(std::string const &)
-{
-       format_ = 0;
-       command_ = lyxrc.custom_export_command;
-       return true;
-}
-
-
-void ControlSendto::dispatchParams()
-{
-       if (command_.empty() || !format_ || format_->name().empty())
-               return;
-
-       string const data = format_->name() + " " + command_;
-       dispatch(FuncRequest(getLfun(), data));
-}
-
-
-vector<Format const *> const ControlSendto::allFormats() const
-{
-       // What formats can we output natively?
-       vector<string> exports;
-       exports.push_back("lyx");
-       exports.push_back("text");
-
-       if (buffer().isLatex())
-               exports.push_back("latex");
-       else if (buffer().isDocBook())
-               exports.push_back("docbook");
-       else if (buffer().isLiterate())
-               exports.push_back("literate");
-
-       // Loop over these native formats and ascertain what formats we
-       // can convert to
-       vector<Format const *> to;
-
-       vector<string>::const_iterator ex_it  = exports.begin();
-       vector<string>::const_iterator ex_end = exports.end();
-       for (; ex_it != ex_end; ++ex_it) {
-               // Start off with the native export format.
-               // "formats" is LyX's list of recognised formats
-               to.push_back(formats.getFormat(*ex_it));
-
-               Formats::const_iterator fo_it  = formats.begin();
-               Formats::const_iterator fo_end = formats.end();
-               for (; fo_it != fo_end; ++fo_it) {
-                       // we need to hide the default graphic export formats
-                       // from the external menu, because we need them only
-                       // for the internal lyx-view and external latex run
-                       string const name = fo_it->name();
-                       if (name != "eps" && name != "xpm" && name != "png" &&
-                           theConverters().isReachable(*ex_it, name))
-                               to.push_back(&(*fo_it));
-               }
-       }
-
-       // Remove repeated formats.
-       std::sort(to.begin(), to.end());
-       to.erase(std::unique(to.begin(), to.end()), to.end());
-
-       return to;
-}
-
-
-void ControlSendto::setFormat(Format const * fmt)
-{
-       format_ = fmt;
-}
-
-
-void ControlSendto::setCommand(string const & cmd)
-{
-       command_ = trim(cmd);
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlSendto.h b/src/frontends/controllers/ControlSendto.h
deleted file mode 100644 (file)
index 8700349..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// -*- C++ -*-
-/**
- * \file ControlSendto.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef CONTROLSENDTO_H
-#define CONTROLSENDTO_H
-
-#include "Dialog.h"
-#include <vector>
-
-
-namespace lyx {
-
-class Format;
-
-namespace frontend {
-
-/** A controller for the Custom Export dialogs.
- */
-class ControlSendto : public Controller {
-public:
-       ///
-       ControlSendto(Dialog &);
-       ///
-       virtual bool initialiseParams(std::string const & data);
-       ///
-       virtual void clearParams() {}
-       ///
-       virtual void dispatchParams();
-       ///
-       virtual bool isBufferDependent() const { return true; }
-       ///
-       virtual kb_action getLfun() const { return LFUN_BUFFER_EXPORT_CUSTOM; }
-
-       /// Return a vector of those formats that can be exported from "lyx".
-       std::vector<Format const *> const allFormats() const;
-
-       /// The format to export to
-       Format const * getFormat() { return format_; }
-       void setFormat(Format const *);
-
-       /// The command to be executed
-       std::string const getCommand() const { return command_; };
-       void setCommand(std::string const &);
-private:
-       ///
-       Format const * format_;
-       ///
-       std::string command_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // CONTROLSENDTO_H
diff --git a/src/frontends/controllers/ControlThesaurus.cpp b/src/frontends/controllers/ControlThesaurus.cpp
deleted file mode 100644 (file)
index b983225..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * \file ControlThesaurus.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlThesaurus.h"
-
-#include "lyxfind.h"
-#include "FuncRequest.h"
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlThesaurus::ControlThesaurus(Dialog & parent)
-       : Controller(parent)
-{}
-
-
-bool ControlThesaurus::initialiseParams(string const & data)
-{
-       oldstr_ = from_utf8(data);
-       return true;
-}
-
-
-void ControlThesaurus::clearParams()
-{
-       oldstr_.erase();
-}
-
-
-void ControlThesaurus::replace(docstring const & newstr)
-{
-       /* FIXME: this is not suitable ! We need to have a "lock"
-        * on a particular charpos in a paragraph that is broken on
-        * deletion/change !
-        */
-       docstring const data =
-               replace2string(oldstr_, newstr,
-                                    true,  // case sensitive
-                                    true,  // match word
-                                    false, // all words
-                                    true); // forward
-       dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
-}
-
-
-Thesaurus::Meanings const & ControlThesaurus::getMeanings(docstring const & str)
-{
-       if (str != laststr_)
-               meanings_ = thesaurus.lookup(str);
-       return meanings_;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlThesaurus.h b/src/frontends/controllers/ControlThesaurus.h
deleted file mode 100644 (file)
index 9bbd936..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-// -*- C++ -*-
-/**
- * \file ControlThesaurus.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-
-#ifndef CONTROLTHESAURUS_H
-#define CONTROLTHESAURUS_H
-
-#include "Dialog.h"
-#include "Thesaurus.h"
-
-namespace lyx {
-namespace frontend {
-
-/** A controller for Thesaurus dialogs.
- */
-class ControlThesaurus : public Controller {
-public:
-       ///
-       ControlThesaurus(Dialog &);
-       ///
-       virtual bool initialiseParams(std::string const & data);
-       ///
-       virtual void clearParams();
-       ///
-       virtual void dispatchParams() {}
-       ///
-       virtual bool isBufferDependent() const { return true; }
-
-       /// replace the particular string
-       void replace(docstring const & newstr);
-
-       /// get meanings
-       Thesaurus::Meanings const & getMeanings(docstring const & str);
-
-       /// the text
-       docstring const & text() const { return oldstr_; }
-
-private:
-       /// last string looked up
-       docstring laststr_;
-
-       /// entries for last string
-       Thesaurus::Meanings meanings_;
-
-       /// original string
-       docstring oldstr_;
-
-       /// not needed.
-       virtual void apply() {}
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // CONTROLTHESAURUS_H
index ffb999b38e85417d816dfcc521bd4e4b0b28c540..4772778136e3295426e9d497f9f142025a4bee24 100644 (file)
@@ -19,8 +19,6 @@ SOURCEFILES = \
        ControlPrefs.cpp \
        ControlPrint.cpp \
        ControlSearch.cpp \
-       ControlSendto.cpp \
-       ControlThesaurus.cpp \
        ControlToc.cpp \
        frontend_helpers.cpp 
 
@@ -36,8 +34,6 @@ HEADERFILES = \
        ControlPrefs.h \
        ControlPrint.h \
        ControlSearch.h \
-       ControlSendto.h \
-       ControlThesaurus.h \
        ControlToc.h \
        frontend_helpers.h
 
index 4fde46988b0d3ad5f19552d9e8fc0a7d74fde501..ed417424603af7655073125f7dc261a7d1e22dcc 100644 (file)
@@ -28,7 +28,6 @@
 #include "GuiPrefs.h"
 #include "GuiPrint.h"
 #include "GuiSearch.h"
-#include "GuiSendto.h"
 #include "GuiShowFile.h"
 #include "GuiToc.h"
 #include "GuiView.h"
@@ -111,7 +110,7 @@ Dialog * createGuiPrefs(LyXView & lv);
 Dialog * createGuiPrint(LyXView & lv);
 Dialog * createGuiRef(LyXView & lv);
 Dialog * createGuiSearch(LyXView & lv);
-Dialog * createGuiSendto(LyXView & lv);
+Dialog * createGuiSendTo(LyXView & lv);
 Dialog * createGuiShowFile(LyXView & lv);
 Dialog * createGuiSpellchecker(LyXView & lv);
 Dialog * createGuiTabularCreate(LyXView & lv);
@@ -204,7 +203,7 @@ Dialog * Dialogs::build(string const & name)
        if (name == "ref")
                return createGuiRef(lyxview_);
        if (name == "sendto")
-               return new GuiSendtoDialog(lyxview_);
+               return createGuiSendTo(lyxview_);
        if (name == "spellchecker")
                return createGuiSpellchecker(lyxview_);
        if (name == "tabular")
index b89245b77a999a4428c516f967d20c05f5b83140..798fad0c39eb4171a65c26bf0650ee34b9fae324 100644 (file)
@@ -3,6 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
+ * \author Angus Leeming
  * \author Jürgen Spitzmüller
  *
  * Full author contact details are available in file CREDITS.
 
 #include "GuiSendto.h"
 
-#include "ControlSendto.h"
+#include "Buffer.h"
+#include "Converter.h"
+#include "Format.h"
+#include "FuncRequest.h"
+#include "LyXRC.h"
 #include "qt_helpers.h"
 
-#include "Format.h"
+#include "support/filetools.h"
+#include "support/lstrings.h"
 
 #include <QListWidget>
 #include <QPushButton>
@@ -28,12 +34,14 @@ using std::string;
 namespace lyx {
 namespace frontend {
 
-GuiSendtoDialog::GuiSendtoDialog(LyXView & lv)
-       : GuiDialog(lv, "sendto")
+using support::trim;
+
+GuiSendTo::GuiSendTo(LyXView & lv)
+       : GuiDialog(lv, "sendto"), Controller(this)
 {
        setupUi(this);
        setViewTitle(_("Send Document to Command"));
-       setController(new ControlSendto(*this));
+       setController(this, false);
 
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
@@ -45,7 +53,7 @@ GuiSendtoDialog::GuiSendtoDialog(LyXView & lv)
                this, SLOT(slotFormatSelected(QListWidgetItem *)));
        connect(formatLW, SIGNAL(itemClicked(QListWidgetItem *)),
                this, SLOT(changed_adaptor()));
-       connect(commandCO, SIGNAL(textChanged(const QString&)),
+       connect(commandCO, SIGNAL(textChanged(QString)),
                this, SLOT(changed_adaptor()));
 
        bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
@@ -55,28 +63,22 @@ GuiSendtoDialog::GuiSendtoDialog(LyXView & lv)
 }
 
 
-ControlSendto & GuiSendtoDialog::controller()
-{
-       return static_cast<ControlSendto &>(GuiDialog::controller());
-}
-
-
-void GuiSendtoDialog::changed_adaptor()
+void GuiSendTo::changed_adaptor()
 {
        changed();
 }
 
 
-void GuiSendtoDialog::closeEvent(QCloseEvent * e)
+void GuiSendTo::closeEvent(QCloseEvent * e)
 {
        slotClose();
        e->accept();
 }
 
 
-void GuiSendtoDialog::updateContents()
+void GuiSendTo::updateContents()
 {
-       all_formats_ = controller().allFormats();
+       all_formats_ = allFormats();
 
        // Check whether the current contents of the browser will be
        // changed by loading the contents of formats
@@ -97,23 +99,23 @@ void GuiSendtoDialog::updateContents()
                formatLW->addItem(toqstr(*it));
        }
 
-       commandCO->addItem(toqstr(controller().getCommand()));
+       commandCO->addItem(toqstr(command_));
 }
 
 
-void GuiSendtoDialog::applyView()
+void GuiSendTo::applyView()
 {
        int const line = formatLW->currentRow();
 
        if (line < 0 || line > int(formatLW->count()))
                return;
 
-       controller().setFormat(all_formats_[line]);
-       controller().setCommand(fromqstr(commandCO->currentText()));
+       format_ = all_formats_[line];
+       command_ = trim(fromqstr(commandCO->currentText()));
 }
 
 
-bool GuiSendtoDialog::isValid()
+bool GuiSendTo::isValid()
 {
        int const line = formatLW->currentRow();
 
@@ -124,6 +126,74 @@ bool GuiSendtoDialog::isValid()
                !commandCO->currentText().isEmpty();
 }
 
+
+bool GuiSendTo::initialiseParams(std::string const &)
+{
+       format_ = 0;
+       command_ = lyxrc.custom_export_command;
+       return true;
+}
+
+
+void GuiSendTo::dispatchParams()
+{
+       if (command_.empty() || !format_ || format_->name().empty())
+               return;
+
+       string const data = format_->name() + " " + command_;
+       dispatch(FuncRequest(getLfun(), data));
+}
+
+// FIXME: Move to Converters?
+vector<Format const *> GuiSendTo::allFormats() const
+{
+       // What formats can we output natively?
+       vector<string> exports;
+       exports.push_back("lyx");
+       exports.push_back("text");
+
+       if (buffer().isLatex())
+               exports.push_back("latex");
+       else if (buffer().isDocBook())
+               exports.push_back("docbook");
+       else if (buffer().isLiterate())
+               exports.push_back("literate");
+
+       // Loop over these native formats and ascertain what formats we
+       // can convert to
+       vector<Format const *> to;
+
+       vector<string>::const_iterator ex_it  = exports.begin();
+       vector<string>::const_iterator ex_end = exports.end();
+       for (; ex_it != ex_end; ++ex_it) {
+               // Start off with the native export format.
+               // "formats" is LyX's list of recognised formats
+               to.push_back(formats.getFormat(*ex_it));
+
+               Formats::const_iterator fo_it  = formats.begin();
+               Formats::const_iterator fo_end = formats.end();
+               for (; fo_it != fo_end; ++fo_it) {
+                       // we need to hide the default graphic export formats
+                       // from the external menu, because we need them only
+                       // for the internal lyx-view and external latex run
+                       string const name = fo_it->name();
+                       if (name != "eps" && name != "xpm" && name != "png" &&
+                           theConverters().isReachable(*ex_it, name))
+                               to.push_back(&(*fo_it));
+               }
+       }
+
+       // Remove repeated formats.
+       std::sort(to.begin(), to.end());
+       to.erase(std::unique(to.begin(), to.end()), to.end());
+
+       return to;
+}
+
+
+Dialog * createGuiSendTo(LyXView & lv) { return new GuiSendTo(lv); }
+
+
 } // namespace frontend
 } // namespace lyx
 
index d69ca02f287f8896f7642413f9a894cb38c15992..095c24914295de2c806b6a1122d3052eda9eb142 100644 (file)
@@ -4,6 +4,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
+ * \author Angus Leeming
  * \author Jürgen Spitzmüller
  *
  * Full author contact details are available in file CREDITS.
@@ -13,7 +14,6 @@
 #define GUISENDTO_H
 
 #include "GuiDialog.h"
-#include "ControlSendto.h"
 #include "ui_SendtoUi.h"
 
 #include <vector>
@@ -26,12 +26,12 @@ class Format;
 
 namespace frontend {
 
-class GuiSendtoDialog : public GuiDialog, public Ui::SendtoUi
+class GuiSendTo : public GuiDialog, public Ui::SendtoUi, public Controller
 {
        Q_OBJECT
 
 public:
-       GuiSendtoDialog(LyXView & lv);
+       GuiSendTo(LyXView & lv);
 
 private Q_SLOTS:
        void changed_adaptor();
@@ -41,7 +41,7 @@ private Q_SLOTS:
 private:
        void closeEvent(QCloseEvent * e);
        /// parent controller
-       ControlSendto & controller();
+       Controller & controller() { return *this; }
        ///
        bool isValid();
        /// Apply from dialog
@@ -51,6 +51,25 @@ private:
 
        ///
        std::vector<Format const *> all_formats_;
+       ///
+       bool initialiseParams(std::string const & data);
+       ///
+       void clearParams() {}
+       ///
+       void dispatchParams();
+       ///
+       bool isBufferDependent() const { return true; }
+       ///
+       kb_action getLfun() const { return LFUN_BUFFER_EXPORT_CUSTOM; }
+
+       /// Return a vector of those formats that can be exported from "lyx".
+       std::vector<Format const *> allFormats() const;
+
+private:
+       ///
+       Format const * format_;
+       ///
+       std::string command_;
 };
 
 } // namespace frontend