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

src/frontends/controllers/ControlPrint.cpp [deleted file]
src/frontends/controllers/ControlPrint.h [deleted file]
src/frontends/controllers/ControlSearch.cpp [deleted file]
src/frontends/controllers/ControlSearch.h [deleted file]
src/frontends/controllers/Makefile.am
src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/GuiPrint.cpp
src/frontends/qt4/GuiPrint.h

diff --git a/src/frontends/controllers/ControlPrint.cpp b/src/frontends/controllers/ControlPrint.cpp
deleted file mode 100644 (file)
index d29a946..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * \file ControlPrint.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 "ControlPrint.h"
-
-#include "frontend_helpers.h"
-
-#include "Buffer.h"
-#include "BufferParams.h"
-#include "FuncRequest.h"
-#include "gettext.h"
-
-#include "support/convert.h"
-#include "support/FileFilterList.h"
-#include "support/filetools.h"
-
-using std::string;
-
-namespace lyx {
-
-using support::changeExtension;
-using support::FileFilterList;
-
-namespace frontend {
-
-
-ControlPrint::ControlPrint(Dialog & parent)
-       : Controller(parent)
-{}
-
-
-bool ControlPrint::initialiseParams(std::string const &)
-{
-       /// get global printer parameters
-       string const name =  changeExtension(buffer().fileName(),
-                                       lyxrc.print_file_extension);
-       params_ = PrinterParams(PrinterParams::PRINTER, lyxrc.printer, name);
-
-       dialog().setButtonsValid(true); // so that the user can press Ok
-       return true;
-}
-
-
-void ControlPrint::clearParams()
-{
-       params_ = PrinterParams();
-}
-
-
-docstring const ControlPrint::browse(docstring const & in_name) const
-{
-       return browseRelFile(in_name, lyx::from_utf8(buffer().filePath()),
-                            _("Print to file"),
-                            FileFilterList(_("PostScript files (*.ps)")),
-                            true);
-}
-
-
-/// print the current buffer
-void ControlPrint::dispatchParams()
-{
-       PrinterParams const pp = params();
-       string command(lyxrc.print_command + ' ');
-
-       if (pp.target == PrinterParams::PRINTER
-           && lyxrc.print_adapt_output  // dvips wants a printer name
-           && !pp.printer_name.empty()) {// printer name given
-               command += lyxrc.print_to_printer
-                       + pp.printer_name
-                       + ' ';
-       }
-
-       if (!pp.all_pages && pp.from_page) {
-               command += lyxrc.print_pagerange_flag + ' ';
-               command += convert<string>(pp.from_page);
-               if (pp.to_page) {
-                       // we have a range "from-to"
-                       command += '-'
-                               + convert<string>(pp.to_page);
-               }
-               command += ' ';
-       }
-
-       // If both are, or both are not selected, then skip the odd/even printing
-       if (pp.odd_pages != pp.even_pages) {
-               if (pp.odd_pages) {
-                       command += lyxrc.print_oddpage_flag + ' ';
-               } else if (pp.even_pages) {
-                       command += lyxrc.print_evenpage_flag + ' ';
-               }
-       }
-
-       if (pp.count_copies > 1) {
-               if (pp.sorted_copies) {
-                       command += lyxrc.print_collcopies_flag;
-               } else {
-                       command += lyxrc.print_copies_flag;
-               }
-               command += ' '
-                       + convert<string>(pp.count_copies)
-                       + ' ';
-       }
-
-       if (pp.reverse_order) {
-               command += lyxrc.print_reverse_flag + ' ';
-       }
-
-       if (!lyxrc.print_extra_options.empty()) {
-               command += lyxrc.print_extra_options + ' ';
-       }
-
-       command += buffer().params().dvips_options();
-
-       string const target = (pp.target == PrinterParams::PRINTER) ?
-               "printer" : "file";
-
-       string const target_name = (pp.target == PrinterParams::PRINTER) ?
-               (pp.printer_name.empty() ? "default" : pp.printer_name) :
-               pp.file_name;
-
-       string const data = target + " \"" + target_name + "\" \"" + command + '"';
-       dispatch(FuncRequest(getLfun(), data));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlPrint.h b/src/frontends/controllers/ControlPrint.h
deleted file mode 100644 (file)
index 0c48504..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-// -*- C++ -*-
-/**
- * \file ControlPrint.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Allan Rae
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef CONTROLPRINT_H
-#define CONTROLPRINT_H
-
-#include "Dialog.h"
-#include "PrinterParams.h"
-#include "support/docstring.h"
-
-namespace lyx {
-namespace frontend {
-
-/** A controller for Print dialogs.
- */
-class ControlPrint : public Controller
-{
-public:
-       ///
-       ControlPrint(Dialog &);
-       ///
-       virtual bool initialiseParams(std::string const & data);
-       ///
-       virtual void clearParams();
-       ///
-       virtual void dispatchParams();
-       ///
-       virtual bool isBufferDependent() const { return true; }
-       ///
-       virtual bool canApplyToReadOnly() const { return true; }
-       ///
-       virtual kb_action getLfun() const { return LFUN_BUFFER_PRINT; }
-
-       /// Browse for a file
-       docstring const browse(docstring const &) const;
-       ///
-       PrinterParams & params() { return params_; }
-       ///
-       PrinterParams const & params() const { return params_; }
-private:
-       ///
-       PrinterParams params_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // CONTROLPRINT_H
diff --git a/src/frontends/controllers/ControlSearch.cpp b/src/frontends/controllers/ControlSearch.cpp
deleted file mode 100644 (file)
index 6a07501..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * \file ControlSearch.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 "ControlSearch.h"
-
-#include "FuncRequest.h"
-#include "lyxfind.h"
-
-namespace lyx {
-namespace frontend {
-
-ControlSearch::ControlSearch(Dialog & parent)
-       : Controller(parent)
-{}
-
-
-void ControlSearch::find(docstring const & search, bool casesensitive,
-                        bool matchword, bool forward)
-{
-       docstring const data = find2string(search, casesensitive,
-                                             matchword, forward);
-       dispatch(FuncRequest(LFUN_WORD_FIND, data));
-}
-
-
-void ControlSearch::replace(docstring const & search, docstring const & replace,
-                           bool casesensitive, bool matchword,
-                           bool forward, bool all)
-{
-       docstring const data =
-               replace2string(search, replace, casesensitive,
-                                    matchword, all, forward);
-       dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlSearch.h b/src/frontends/controllers/ControlSearch.h
deleted file mode 100644 (file)
index dffd467..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-// -*- C++ -*-
-/**
- * \file ControlSearch.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 CONTROLSEARCH_H
-#define CONTROLSEARCH_H
-
-#include "Dialog.h"
-
-namespace lyx {
-namespace frontend {
-
-/** A controller for Search dialogs.
- */
-class ControlSearch : public Controller {
-public:
-       ControlSearch(Dialog &);
-
-       virtual bool initialiseParams(std::string const &) { return true; }
-       virtual void clearParams() {}
-       virtual void dispatchParams() {}
-       virtual bool isBufferDependent() const { return true; }
-
-       /// Searches occurence of string
-       void find(docstring const & search,
-                 bool casesensitive, bool matchword, bool forward);
-
-       /// Replaces occurence of string
-       void replace(docstring const & search, docstring const & replace,
-                    bool casesensitive, bool matchword,
-                    bool forward, bool all);
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // CONTROLSEARCH_H
index 700d379976fd68bbfc47e90fe20048c8ac56669d..1efde717641717785aefeb3f50746ec36bad5ba7 100644 (file)
@@ -17,8 +17,6 @@ SOURCEFILES = \
        ControlMath.cpp \
        ControlParagraph.cpp \
        ControlPrefs.cpp \
-       ControlPrint.cpp \
-       ControlSearch.cpp \
        frontend_helpers.cpp 
 
 HEADERFILES = \
@@ -31,8 +29,6 @@ HEADERFILES = \
        ControlMath.h \
        ControlParagraph.h \
        ControlPrefs.h \
-       ControlPrint.h \
-       ControlSearch.h \
        frontend_helpers.h
 
 if MONOLITHIC_CONTROLLERS
index 1c2ee9337341a3bec7887f74a7aaac42b5cb9ac4..630b037eab623b880c888773058f1b064041514b 100644 (file)
 #include "GuiNomencl.h"
 #include "GuiParagraph.h"
 #include "GuiPrefs.h"
-#include "GuiPrint.h"
-#include "GuiShowFile.h"
 #include "GuiView.h"
-#include "TocWidget.h"
 #include "GuiURL.h"
 
 // Uncomment this if you prefer dock widget
@@ -198,7 +195,7 @@ Dialog * Dialogs::build(string const & name)
        if (name == "prefs")
                return new GuiPrefsDialog(lyxview_);
        if (name == "print")
-               return new GuiPrintDialog(lyxview_);
+               return createGuiPrint(lyxview_);
        if (name == "ref")
                return createGuiRef(lyxview_);
        if (name == "sendto")
index 49692890d4df1e115c86eca72b7fe9dab53e686c..0349fdf448f5012dc243d58befe0851637bae56e 100644 (file)
@@ -5,6 +5,7 @@
  *
  * \author John Levon
  * \author Edwin Leuven
+ * \author Angus Leeming
  *
  * Full author contact details are available in file CREDITS.
  */
 
 #include "GuiPrint.h"
 
-#include "ControlPrint.h"
 #include "qt_helpers.h"
 #include "PrinterParams.h"
 
+#include "frontend_helpers.h"
+
+#include "Buffer.h"
+#include "BufferParams.h"
+#include "FuncRequest.h"
+#include "gettext.h"
+
+#include "support/convert.h"
+#include "support/FileFilterList.h"
+#include "support/filetools.h"
 #include "support/os.h"
 
 #include <QLineEdit>
 #include <QSpinBox>
 #include <QPushButton>
 
+using std::string;
+
 
 namespace lyx {
 namespace frontend {
 
-GuiPrintDialog::GuiPrintDialog(LyXView & lv)
-       : GuiDialog(lv, "print")
+using support::FileFilterList;
+
+
+GuiPrint::GuiPrint(LyXView & lv)
+       : GuiDialog(lv, "print"), Controller(this)
 {
        setupUi(this);
-       setController(new ControlPrint(*this));
+       setController(this, false);
        setViewTitle(_("Print Document"));
 
        connect(printPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
 
        connect(copiesSB, SIGNAL(valueChanged(int)), this, SLOT(copiesChanged(int)));
-       connect(printerED, SIGNAL(textChanged(const QString&)),
+       connect(printerED, SIGNAL(textChanged(QString)),
                this, SLOT(printerChanged()));
-       connect(fileED, SIGNAL(textChanged(const QString&)),
+       connect(fileED, SIGNAL(textChanged(QString)),
                this, SLOT(fileChanged() ));
        connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked()));
        connect(allRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
@@ -67,21 +82,20 @@ GuiPrintDialog::GuiPrintDialog(LyXView & lv)
 }
 
 
-ControlPrint & GuiPrintDialog::controller()
-{
-       return static_cast<ControlPrint &>(GuiDialog::controller());
-}
-
-
-void GuiPrintDialog::change_adaptor()
+void GuiPrint::change_adaptor()
 {
        changed();
 }
 
 
-void GuiPrintDialog::browseClicked()
+void GuiPrint::browseClicked()
 {
-       QString file = toqstr(controller().browse(docstring()));
+       docstring name =
+               browseRelFile(docstring(), from_utf8(buffer().filePath()),
+                            _("Print to file"),
+                            FileFilterList(_("PostScript files (*.ps)")),
+                            true);
+       QString file = toqstr(name);
        if (!file.isNull()) {
                fileED->setText(file);
                changed();
@@ -89,7 +103,7 @@ void GuiPrintDialog::browseClicked()
 }
 
 
-void GuiPrintDialog::fileChanged()
+void GuiPrint::fileChanged()
 {
        if (!fileED->text().isEmpty())
                fileRB->setChecked(true);
@@ -97,67 +111,66 @@ void GuiPrintDialog::fileChanged()
 }
 
 
-void GuiPrintDialog::copiesChanged(int i)
+void GuiPrint::copiesChanged(int i)
 {
        collateCB->setEnabled(i != 1);
        changed();
 }
 
 
-void GuiPrintDialog::printerChanged()
+void GuiPrint::printerChanged()
 {
        printerRB->setChecked(true);
        changed();
 }
 
 
-void GuiPrintDialog::pagerangeChanged()
+void GuiPrint::pagerangeChanged()
 {
        changed();
 }
 
 
-void GuiPrintDialog::updateContents()
+void GuiPrint::updateContents()
 {
-       PrinterParams & pp = controller().params();
-
        // only reset params if a different buffer
-       if (!pp.file_name.empty() && pp.file_name == fromqstr(fileED->text()))
+       if (!params_.file_name.empty()
+                       && params_.file_name == fromqstr(fileED->text()))
                return;
 
-       printerED->setText(toqstr(pp.printer_name));
-       fileED->setText(toqstr(pp.file_name));
+       printerED->setText(toqstr(params_.printer_name));
+       fileED->setText(toqstr(params_.file_name));
 
        printerRB->setChecked(true);
-       if (pp.target == PrinterParams::FILE)
+       if (params_.target == PrinterParams::FILE)
                fileRB->setChecked(true);
 
-       reverseCB->setChecked(pp.reverse_order);
+       reverseCB->setChecked(params_.reverse_order);
 
-       copiesSB->setValue(pp.count_copies);
+       copiesSB->setValue(params_.count_copies);
 
-       oddCB->setChecked(pp.odd_pages);
-       evenCB->setChecked(pp.even_pages);
+       oddCB->setChecked(params_.odd_pages);
+       evenCB->setChecked(params_.even_pages);
 
-       collateCB->setChecked(pp.sorted_copies);
+       collateCB->setChecked(params_.sorted_copies);
 
-       if (pp.all_pages) {
+       if (params_.all_pages) {
                allRB->setChecked(true);
        } else {
                rangeRB->setChecked(true);
-               fromED->setText(QString::number(pp.from_page));
-               toED->setText(QString::number(pp.to_page));
+               fromED->setText(QString::number(params_.from_page));
+               toED->setText(QString::number(params_.to_page));
        }
 }
 
 
-void GuiPrintDialog::applyView()
+void GuiPrint::applyView()
 {
        PrinterParams::Target t = PrinterParams::PRINTER;
        if (fileRB->isChecked())
                t = PrinterParams::FILE;
 
-       PrinterParams const pp(t,
+       params_ = PrinterParams(t,
                fromqstr(printerED->text()),
                support::os::internal_path(fromqstr(fileED->text())),
                allRB->isChecked(),
@@ -167,11 +180,89 @@ void GuiPrintDialog::applyView()
                evenCB->isChecked(),
                copiesSB->text().toUInt(),
                collateCB->isChecked(),
-               reverseCB->isChecked());
+               reverseCB->isChecked()
+       );
+}
+
+
+bool GuiPrint::initialiseParams(std::string const &)
+{
+       /// get global printer parameters
+       string const name = support::changeExtension(buffer().fileName(),
+                                       lyxrc.print_file_extension);
+       params_ = PrinterParams(PrinterParams::PRINTER, lyxrc.printer, name);
+
+       dialog().setButtonsValid(true); // so that the user can press Ok
+       return true;
+}
+
 
-       controller().params() = pp;
+void GuiPrint::clearParams()
+{
+       params_ = PrinterParams();
 }
 
+
+/// print the current buffer
+void GuiPrint::dispatchParams()
+{
+       string command = lyxrc.print_command + ' ';
+
+       if (params_.target == PrinterParams::PRINTER
+           && lyxrc.print_adapt_output  // dvips wants a printer name
+           && !params_.printer_name.empty()) {// printer name given
+               command += lyxrc.print_to_printer + params_.printer_name + ' ';
+       }
+
+       if (!params_.all_pages && params_.from_page) {
+               command += lyxrc.print_pagerange_flag + ' ';
+               command += convert<string>(params_.from_page);
+               if (params_.to_page) {
+                       // we have a range "from-to"
+                       command += '-' + convert<string>(params_.to_page);
+               }
+               command += ' ';
+       }
+
+       // If both are, or both are not selected, then skip the odd/even printing
+       if (params_.odd_pages != params_.even_pages) {
+               if (params_.odd_pages)
+                       command += lyxrc.print_oddpage_flag + ' ';
+               else if (params_.even_pages)
+                       command += lyxrc.print_evenpage_flag + ' ';
+       }
+
+       if (params_.count_copies > 1) {
+               if (params_.sorted_copies)
+                       command += lyxrc.print_collcopies_flag;
+               else
+                       command += lyxrc.print_copies_flag;
+               command += ' ' + convert<string>(params_.count_copies) + ' ';
+       }
+
+       if (params_.reverse_order)
+               command += lyxrc.print_reverse_flag + ' ';
+
+       if (!lyxrc.print_extra_options.empty())
+               command += lyxrc.print_extra_options + ' ';
+
+       command += buffer().params().dvips_options();
+
+       string const target = (params_.target == PrinterParams::PRINTER) ?
+               "printer" : "file";
+
+       string const target_name = (params_.target == PrinterParams::PRINTER) ?
+               (params_.printer_name.empty() ? "default" : params_.printer_name) :
+               params_.file_name;
+
+       string const data = target + " \"" + target_name + "\" \"" + command + '"';
+       dispatch(FuncRequest(getLfun(), data));
+}
+
+
+Dialog * createGuiPrint(LyXView & lv) { return new GuiPrint(lv); }
+
+
 } // namespace frontend
 } // namespace lyx
 
index 431498896499727c72da2bc1410f3efd02284cc7..5c84ba23ed80e8bf026d6895a7c0ac1fe11b9dc1 100644 (file)
@@ -4,6 +4,8 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
+ * \author Allan Rae
+ * \author Angus Leeming
  * \author John Levon
  * \author Edwin Leuven
  *
 #define GUIPRINT_H
 
 #include "GuiDialog.h"
-#include "ControlPrint.h"
 #include "ui_PrintUi.h"
 
+#include "Dialog.h"
+#include "PrinterParams.h"
+#include "support/docstring.h"
+
 namespace lyx {
 namespace frontend {
 
-class GuiPrintDialog : public GuiDialog, public Ui::PrintUi
+class GuiPrint : public GuiDialog, public Ui::PrintUi, public Controller
 {
        Q_OBJECT
 
 public:
-       GuiPrintDialog(LyXView & lv);
+       GuiPrint(LyXView & lv);
 
 private Q_SLOTS:
        void change_adaptor();
@@ -35,13 +40,28 @@ private Q_SLOTS:
        void printerChanged();
        void pagerangeChanged();
        /// parent controller
-       ControlPrint & controller();
+       Controller & controller() { return *this; }
 
 private:
        /// Apply changes
        void applyView();
        /// update
        void updateContents();
+       ///
+       bool initialiseParams(std::string const & data);
+       ///
+       void clearParams();
+       ///
+       void dispatchParams();
+       ///
+       bool isBufferDependent() const { return true; }
+       ///
+       bool canApplyToReadOnly() const { return true; }
+       ///
+       kb_action getLfun() const { return LFUN_BUFFER_PRINT; }
+
+       ///
+       PrinterParams params_;
 };
 
 } // namespace frontend