]> git.lyx.org Git - features.git/commitdiff
this (temporarily...) removes the "dock" option.
authorAndré Pönitz <poenitz@gmx.net>
Sun, 7 Oct 2007 20:00:46 +0000 (20:00 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sun, 7 Oct 2007 20:00:46 +0000 (20:00 +0000)
*sigh*

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20824 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ControlParagraph.cpp [deleted file]
src/frontends/controllers/ControlParagraph.h [deleted file]
src/frontends/controllers/Makefile.am
src/frontends/qt4/GuiParagraph.cpp
src/frontends/qt4/GuiParagraph.h

diff --git a/src/frontends/controllers/ControlParagraph.cpp b/src/frontends/controllers/ControlParagraph.cpp
deleted file mode 100644 (file)
index 0b24b60..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * \file ControlParagraph.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlParagraph.h"
-#include "Buffer.h"
-#include "BufferParams.h"
-#include "BufferView.h"
-#include "Cursor.h"
-#include "FuncRequest.h"
-#include "Lexer.h"
-#include "Paragraph.h"
-#include "ParagraphParameters.h"
-
-#include <sstream>
-
-using std::istringstream;
-using std::ostringstream;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlParagraph::ControlParagraph(Dialog & parent)
-       : Controller(parent)
-{}
-
-
-ParagraphParameters & ControlParagraph::params()
-{
-       if (haveMulitParSelection()) {
-               multiparsel_ = ParagraphParameters();
-               // FIXME: It would be nice to initialise the parameters that
-               // are common to all paragraphs.
-               return multiparsel_;
-       }
-
-       return bufferview()->cursor().innerParagraph().params();
-}
-
-
-ParagraphParameters const & ControlParagraph::params() const
-{
-       return bufferview()->cursor().innerParagraph().params();
-}
-
-
-void ControlParagraph::dispatchParams()
-{
-       if (haveMulitParSelection()) {
-               ostringstream data;
-               multiparsel_.write(data);
-               FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
-               dispatch(fr);
-               return;
-       }
-
-       bufferview()->updateMetrics(false);
-       bufferview()->buffer().changed();
-}
-
-
-bool ControlParagraph::haveMulitParSelection()
-{
-       Cursor cur = bufferview()->cursor();
-       return cur.selection() && cur.selBegin().pit() != cur.selEnd().pit();
-}
-
-       
-bool ControlParagraph::canIndent() const
-{
-       return buffer().params().paragraph_separation ==
-               BufferParams::PARSEP_INDENT;
-}
-
-
-LyXAlignment ControlParagraph::alignPossible() const
-{
-       return bufferview()->cursor().innerParagraph().layout()->alignpossible;
-}
-
-
-LyXAlignment ControlParagraph::alignDefault() const
-{
-       return bufferview()->cursor().innerParagraph().layout()->align;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlParagraph.h b/src/frontends/controllers/ControlParagraph.h
deleted file mode 100644 (file)
index 490b75f..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-// -*- C++ -*-
-/**
- * \file ControlParagraph.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef CONTROLPARAGRAPH_H
-#define CONTROLPARAGRAPH_H
-
-#include "Dialog.h"
-#include "Layout.h" // for LyXAlignment
-#include "ParagraphParameters.h"
-
-namespace lyx {
-namespace frontend {
-
-class ControlParagraph : public Controller
-{
-public:
-       ///
-       ControlParagraph(Dialog &);
-       ///
-       virtual bool initialiseParams(std::string const & /*data*/) { return true; }
-       /// clean-up on hide.
-       virtual void clearParams() {}
-       ///
-       virtual void dispatchParams();
-       ///
-       virtual bool isBufferDependent() const { return true; }
-       ///
-       ParagraphParameters & params();
-       ///
-       ParagraphParameters const & params() const;
-       ///
-       bool haveMulitParSelection();
-       ///
-       bool canIndent() const;
-       ///
-       LyXAlignment alignPossible() const;
-       ///
-       LyXAlignment alignDefault() const;
-
-private:
-       ParagraphParameters multiparsel_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // CONTROLPARAGRAPH_H
index dc0861d898d878343095ca27d1de8c6413160ade..0ead9da1337de69bb0270795b9b31557fdea1f69 100644 (file)
@@ -10,14 +10,12 @@ SOURCEFILES = \
        Dialog.cpp \
        ButtonPolicy.cpp \
        ControlMath.cpp \
-       ControlParagraph.cpp \
        frontend_helpers.cpp 
 
 HEADERFILES = \
        Dialog.h \
        ButtonPolicy.h \
        ControlMath.h \
-       ControlParagraph.h \
        frontend_helpers.h
 
 if MONOLITHIC_CONTROLLERS
index 5f6917429986932d2ee3e2f66e093cbdea6bcfff..7d812096ec6a4ec807f321f6ede2b3061b130c85 100644 (file)
@@ -6,6 +6,7 @@
  * \author Edwin Leuven
  * \author Richard Heck
  * \author Abdelrazak Younes
+ * \author Angus Leeming
  *
  * Full author contact details are available in file CREDITS.
  */
 #include <config.h>
 
 #include "GuiParagraph.h"
-#include "qt_helpers.h"
-
-#include "ControlParagraph.h"
 
+#include "Buffer.h"
+#include "BufferParams.h"
+#include "BufferView.h"
+#include "Cursor.h"
 #include "debug.h"
+#include "DialogView.h"
+#include "DockView.h"
 #include "frontend_helpers.h"
+#include "FuncRequest.h"
 #include "gettext.h"
+#include "GuiView.h"
+#include "Lexer.h"
+#include "Paragraph.h"
 #include "ParagraphParameters.h"
+#include "qt_helpers.h"
 #include "Spacing.h"
-#include "GuiView.h"
-#include "DialogView.h"
-#include "DockView.h"
 
 #include <QCheckBox>
 #include <QCloseEvent>
 
 #include <boost/current_function.hpp>
 
+#include <sstream>
+
+using std::istringstream;
+using std::ostringstream;
 using std::string;
 using std::endl;
 
 namespace lyx {
 namespace frontend {
 
-GuiParagraph::GuiParagraph(ControlParagraph & controller, QWidget * parent)
-       : QWidget(parent), controller_(controller)
+GuiParagraph::GuiParagraph(LyXView & lv)
+       : Controller(this)
 {
        setupUi(this);
        setWindowTitle(qt_("Paragraph Settings"));
 
+       //setModal(modal);
+       setLyXView(lv);
+       QGridLayout * gridLayout = new QGridLayout(this);
+       gridLayout->setMargin(0);
+       gridLayout->addWidget(this);
+
        connect(alignDefaultRB, SIGNAL(clicked()), this, SLOT(changed()));
        connect(alignJustRB, SIGNAL(clicked()), this, SLOT(changed()));
        connect(alignLeftRB, SIGNAL(clicked()), this, SLOT(changed()));
@@ -89,19 +105,18 @@ void GuiParagraph::on_linespacing_activated(int index)
 }
 
 
-void GuiParagraph::checkAlignmentRadioButtons() {
-       LyXAlignment const alignPossible = controller_.alignPossible();
-
+void GuiParagraph::checkAlignmentRadioButtons()
+{
        RadioMap::iterator it = radioMap.begin();
        for (; it != radioMap.end(); ++it) {
                LyXAlignment const align = it->first;
-               it->second->setEnabled(align & alignPossible);
+               it->second->setEnabled(align & alignPossible());
        }
-       if (controller_.haveMulitParSelection())
+       if (haveMulitParSelection())
                alignDefaultRB->setText(alignDefaultLabel);
        else
                alignDefaultRB->setText(alignDefaultLabel + " (" 
-                       + radioMap[controller_.alignDefault()]->text() + ")");
+                       + radioMap[alignDefault()]->text() + ")");
 }
 
 
@@ -149,9 +164,9 @@ void GuiParagraph::changed()
 
 void GuiParagraph::on_applyPB_clicked()
 {
-       ParagraphParameters & params = controller_.params();
+       ParagraphParameters & pp = params();
 
-       params.align(getAlignmentFromDialog());
+       pp.align(getAlignmentFromDialog());
 
        // get spacing
        Spacing::Space ls = Spacing::Default;
@@ -176,14 +191,14 @@ void GuiParagraph::on_applyPB_clicked()
        }
 
        Spacing const spacing(ls, other);
-       params.spacing(spacing);
+       pp.spacing(spacing);
 
        // label width
-       params.labelWidthString(qstring_to_ucs4(labelWidth->text()));
+       pp.labelWidthString(qstring_to_ucs4(labelWidth->text()));
        // indendation
-       params.noindent(!indentCB->isChecked());
+       pp.noindent(!indentCB->isChecked());
 
-       controller_.dispatchParams();
+       dispatchParams();
 }
 
 
@@ -197,10 +212,10 @@ void GuiParagraph::updateView()
 {
        on_synchronizedViewCB_toggled();
 
-       ParagraphParameters const & params = controller_.params();
+       ParagraphParameters const & pp = params();
 
        // label width
-       docstring const & labelwidth = params.labelWidthString();
+       docstring const & labelwidth = pp.labelWidthString();
        // FIXME We should not compare translated strings
        if (labelwidth != _("Senseless with this layout!")) {
                labelwidthGB->setEnabled(true);
@@ -212,16 +227,16 @@ void GuiParagraph::updateView()
 
        // alignment
        checkAlignmentRadioButtons();
-       alignmentToRadioButtons(params.align());
+       alignmentToRadioButtons(pp.align());
 
        //indentation
-       bool const canindent = controller_.canIndent();
+       bool const canindent = canIndent();
        indentCB->setEnabled(canindent);
-       indentCB->setChecked(canindent && !params.noindent());
+       indentCB->setChecked(canindent && !pp.noindent());
 
        // linespacing
        int ls;
-       Spacing const & space = params.spacing();
+       Spacing const & space = pp.spacing();
        switch (space.getSpace()) {
        case Spacing::Single:
                ls = 1;
@@ -250,8 +265,69 @@ void GuiParagraph::updateView()
 }
 
 
+ParagraphParameters & GuiParagraph::params()
+{
+       if (haveMulitParSelection()) {
+               multiparsel_ = ParagraphParameters();
+               // FIXME: It would be nice to initialise the parameters that
+               // are common to all paragraphs.
+               return multiparsel_;
+       }
+
+       return bufferview()->cursor().innerParagraph().params();
+}
+
+
+ParagraphParameters const & GuiParagraph::params() const
+{
+       return bufferview()->cursor().innerParagraph().params();
+}
+
+
+void GuiParagraph::dispatchParams()
+{
+       if (haveMulitParSelection()) {
+               ostringstream data;
+               multiparsel_.write(data);
+               FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
+               dispatch(fr);
+               return;
+       }
+
+       bufferview()->updateMetrics(false);
+       bufferview()->buffer().changed();
+}
+
+
+bool GuiParagraph::haveMulitParSelection()
+{
+       Cursor cur = bufferview()->cursor();
+       return cur.selection() && cur.selBegin().pit() != cur.selEnd().pit();
+}
+
+       
+bool GuiParagraph::canIndent() const
+{
+       return buffer().params().paragraph_separation ==
+               BufferParams::PARSEP_INDENT;
+}
+
+
+LyXAlignment GuiParagraph::alignPossible() const
+{
+       return bufferview()->cursor().innerParagraph().layout()->alignpossible;
+}
+
+
+LyXAlignment GuiParagraph::alignDefault() const
+{
+       return bufferview()->cursor().innerParagraph().layout()->align;
+}
+
+
 Dialog * createGuiParagraph(LyXView & lv)
 {
+#if 0
        GuiViewBase & guiview = static_cast<GuiViewBase &>(lv);
 #ifdef USE_DOCK_WIDGET
        return new DockView<ControlParagraph, GuiParagraph>(guiview, "paragraph",
@@ -259,6 +335,9 @@ Dialog * createGuiParagraph(LyXView & lv)
 #else
        return new DialogView<ControlParagraph, GuiParagraph>(guiview, "paragraph");
 #endif
+#endif
+
+       return new GuiParagraph(lv);
 }
 
 
index 9e4604c56bfeef7c3f80221bb54de1bb6753d2c6..00cb552ef1300438e95df1f521df720e0327609b 100644 (file)
@@ -6,6 +6,7 @@
  *
  * \author Edwin Leuven
  * \author John Levon
+ * \author Abdelrazak Younes
  *
  * Full author contact details are available in file CREDITS.
  */
 #ifndef GUIPARAGRAPH_H
 #define GUIPARAGRAPH_H
 
-#include "ControlParagraph.h"
 #include "Layout.h"
 #include "ui_ParagraphUi.h"
+#include "Dialog.h"
+#include "ParagraphParameters.h"
+#include "GuiView.h"
+#include "qt_helpers.h"
+#include "debug.h"
 
-#include <QWidget>
+#include <QCloseEvent>
+#include <QDialog>
+#include <QSettings>
+#include <QShowEvent>
+#include <QGridLayout>
 
 #include <map>
+#include <string>
 
 namespace lyx {
 namespace frontend {
 
-class GuiParagraph : public QWidget, public Ui::ParagraphUi
+class GuiParagraph
+       : public QDialog, public Ui::ParagraphUi, public Controller, public Dialog
 {
        Q_OBJECT
 public:
-       GuiParagraph(ControlParagraph & controller, QWidget * parent = 0);
+       GuiParagraph(LyXView & lv);
 
        /// update
        void updateView();
@@ -41,12 +52,66 @@ private:
        ///
        LyXAlignment getAlignmentFromDialog();
        ///
+       Controller & controller() { return *this; }
+       ///
        typedef std::map<LyXAlignment, QRadioButton *> RadioMap;
        RadioMap radioMap;
 
-       ControlParagraph & controller_;
-
        QString const alignDefaultLabel;
+
+       void applyView() {}
+       void hideView()
+       {
+               clearParams();
+               QDialog::hide();
+       }
+       void showData(std::string const & data)
+       {
+               initialiseParams(data);
+               showView();
+       }
+       void showView()
+       {
+               updateView();  // make sure its up-to-date
+               QDialog::show();
+               raise();
+               activateWindow();
+       }
+       bool isVisibleView() const { return QDialog::isVisible(); }
+       void checkStatus() { updateView(); }
+       void redraw() { redrawView(); }
+       void redrawView() {}
+       void updateData(std::string const & data)
+       {
+               initialiseParams(data);
+               updateView();
+       }
+       void partialUpdateView(int /*id*/) {}
+       std::string name() const { return "paragraph"; }
+
+private:
+       std::string name_;
+
+       void showEvent(QShowEvent * e)
+       {
+#if (QT_VERSION >= 0x040200)
+               QSettings settings;
+               std::string key = name_ + "/geometry";
+               QDialog::restoreGeometry(settings.value(key.c_str()).toByteArray());
+#endif
+           QDialog::showEvent(e);
+       }
+
+       void closeEvent(QCloseEvent * e)
+       {
+#if (QT_VERSION >= 0x040200)
+               QSettings settings;
+               std::string key = name_ + "/geometry";
+               settings.setValue(key.c_str(), QDialog::saveGeometry());
+#endif
+           QDialog::closeEvent(e);
+       }
+
 private Q_SLOTS:
        ///
        void changed();
@@ -58,6 +123,31 @@ private Q_SLOTS:
        void on_linespacing_activated(int);
        /// Apply changes
        void on_applyPB_clicked();
+
+private:
+       ///
+       bool initialiseParams(std::string const & /*data*/) { return true; }
+       /// clean-up on hide.
+       void clearParams() {}
+       ///
+       void dispatchParams();
+       ///
+       bool isBufferDependent() const { return true; }
+       ///
+       ParagraphParameters & params();
+       ///
+       ParagraphParameters const & params() const;
+       ///
+       bool haveMulitParSelection();
+       ///
+       bool canIndent() const;
+       ///
+       LyXAlignment alignPossible() const;
+       ///
+       LyXAlignment alignDefault() const;
+
+private:
+       ParagraphParameters multiparsel_;
 };
 
 } // namespace frontend