From 175fb31dbc3195e5e278a7047bf8fe7bd359525c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sun, 7 Oct 2007 20:00:46 +0000 Subject: [PATCH] this (temporarily...) removes the "dock" option. *sigh* git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20824 a592a061-630c-0410-9148-cb99ea01b6c8 --- .../controllers/ControlParagraph.cpp | 98 ------------- src/frontends/controllers/ControlParagraph.h | 55 -------- src/frontends/controllers/Makefile.am | 2 - src/frontends/qt4/GuiParagraph.cpp | 131 ++++++++++++++---- src/frontends/qt4/GuiParagraph.h | 102 +++++++++++++- 5 files changed, 201 insertions(+), 187 deletions(-) delete mode 100644 src/frontends/controllers/ControlParagraph.cpp delete mode 100644 src/frontends/controllers/ControlParagraph.h diff --git a/src/frontends/controllers/ControlParagraph.cpp b/src/frontends/controllers/ControlParagraph.cpp deleted file mode 100644 index 0b24b60308..0000000000 --- a/src/frontends/controllers/ControlParagraph.cpp +++ /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 - -#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 - -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 index 490b75fd2b..0000000000 --- a/src/frontends/controllers/ControlParagraph.h +++ /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 diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index dc0861d898..0ead9da133 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -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 diff --git a/src/frontends/qt4/GuiParagraph.cpp b/src/frontends/qt4/GuiParagraph.cpp index 5f69174299..7d812096ec 100644 --- a/src/frontends/qt4/GuiParagraph.cpp +++ b/src/frontends/qt4/GuiParagraph.cpp @@ -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. */ @@ -13,18 +14,23 @@ #include #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 #include @@ -33,18 +39,28 @@ #include +#include + +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(lv); #ifdef USE_DOCK_WIDGET return new DockView(guiview, "paragraph", @@ -259,6 +335,9 @@ Dialog * createGuiParagraph(LyXView & lv) #else return new DialogView(guiview, "paragraph"); #endif +#endif + + return new GuiParagraph(lv); } diff --git a/src/frontends/qt4/GuiParagraph.h b/src/frontends/qt4/GuiParagraph.h index 9e4604c56b..00cb552ef1 100644 --- a/src/frontends/qt4/GuiParagraph.h +++ b/src/frontends/qt4/GuiParagraph.h @@ -6,6 +6,7 @@ * * \author Edwin Leuven * \author John Levon + * \author Abdelrazak Younes * * Full author contact details are available in file CREDITS. */ @@ -13,22 +14,32 @@ #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 +#include +#include +#include +#include +#include #include +#include 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 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 -- 2.39.5