this (temporarily...) removes the "dock" option.

*sigh*


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20824 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-10-07 20:00:46 +00:00
parent faafd03726
commit 175fb31dbc
5 changed files with 203 additions and 189 deletions

View File

@ -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

View File

@ -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

View 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

View 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.
*/
@ -13,18 +14,23 @@
#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 "frontend_helpers.h"
#include "gettext.h"
#include "ParagraphParameters.h"
#include "Spacing.h"
#include "GuiView.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 <QCheckBox>
#include <QCloseEvent>
@ -33,18 +39,28 @@
#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);
}

View File

@ -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 <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