+++ /dev/null
-/**
- * \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
+++ /dev/null
-// -*- 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
* \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()));
}
-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() + ")");
}
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;
}
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();
}
{
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);
// 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;
}
+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",
#else
return new DialogView<ControlParagraph, GuiParagraph>(guiview, "paragraph");
#endif
+#endif
+
+ return new GuiParagraph(lv);
}
*
* \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();
///
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();
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