+++ /dev/null
-/**
- * \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
+++ /dev/null
-// -*- 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
+++ /dev/null
-/**
- * \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
+++ /dev/null
-// -*- 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
ControlPrefs.cpp \
ControlPrint.cpp \
ControlSearch.cpp \
- ControlSendto.cpp \
- ControlThesaurus.cpp \
ControlToc.cpp \
frontend_helpers.cpp
ControlPrefs.h \
ControlPrint.h \
ControlSearch.h \
- ControlSendto.h \
- ControlThesaurus.h \
ControlToc.h \
frontend_helpers.h
#include "GuiPrefs.h"
#include "GuiPrint.h"
#include "GuiSearch.h"
-#include "GuiSendto.h"
#include "GuiShowFile.h"
#include "GuiToc.h"
#include "GuiView.h"
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);
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")
* 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>
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()));
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);
}
-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
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();
!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
* 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.
#define GUISENDTO_H
#include "GuiDialog.h"
-#include "ControlSendto.h"
#include "ui_SendtoUi.h"
#include <vector>
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();
private:
void closeEvent(QCloseEvent * e);
/// parent controller
- ControlSendto & controller();
+ Controller & controller() { return *this; }
///
bool isValid();
/// Apply from dialog
///
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