case LFUN_FLOAT_INSERT: {
// check if the float type exists
- string const argument = to_utf8(cmd.argument());
- if (params.documentClass().floats().typeExist(argument))
- return new InsetFloat(buf, argument);
- lyxerr << "Non-existent float type: " << argument << endl;
+ string const type = cmd.getArg(0);
+ //FIXME: only the float type (the first argument) is transmitted
+ // because of the InsetFloat ctor.
+ if (params.documentClass().floats().typeExist(type))
+ return new InsetFloat(buf, type);
+ lyxerr << "Non-existent float type: " << type << endl;
+ return 0;
}
case LFUN_FLOAT_WIDE_INSERT: {
}
+docstring FloatPlacement::dialogToParams() const
+{
+ InsetFloatParams params;
+ params.type = fromqstr(floatType->text());
+ params.placement = get(params.wide, params.sideways);
+ return from_ascii(InsetFloat::params2string(params));
+}
+
+
void FloatPlacement::useWide()
{
spanCB->show();
}
-void FloatPlacement::set(lyx::InsetFloatParams const & params)
+void FloatPlacement::paramsToDialog(Inset const * inset)
{
+ InsetFloat const * fl = static_cast<InsetFloat const *>(inset);
+ InsetFloatParams const & params = fl->params();
+
+ floatType->setText(toqstr(params.type));
+
set(params.placement);
standardfloat_ = (params.type == "figure"
#define FLOATPLACEMENT_H
#include "ui_FloatPlacementUi.h"
-#include <QWidget>
-#include <string>
+#include <QWidget>
+#include "support/docstring.h"
namespace lyx {
+class Inset;
class InsetFloatParams;
class FloatPlacement : public QWidget, public Ui::FloatPlacementUi {
public:
FloatPlacement(QWidget * parent = 0);
+ ///
+ void paramsToDialog(Inset const *);
+ ///
+ docstring dialogToParams() const;
+ ///
void useWide();
+ ///
void useSideways();
- void set(lyx::InsetFloatParams const & params);
void set(std::string const & placement);
void checkAllowed();
#include "GuiFloat.h"
#include "FloatPlacement.h"
-#include "FuncRequest.h"
-#include "insets/InsetFloat.h"
+#include "FuncRequest.h"
#include <QPushButton>
namespace frontend {
GuiFloat::GuiFloat(GuiView & lv)
- : GuiDialog(lv, "float", qt_("Float Settings"))
+ : InsetDialog(lv, FLOAT_CODE, LFUN_FLOAT_INSERT, "float", "Float Settings")
{
setupUi(this);
- connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
- connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
-
// enable span columns checkbox
floatFP->useWide();
// enable sideways checkbox
floatFP->useSideways();
- connect(floatFP, SIGNAL(changed()), this, SLOT(change_adaptor()));
-
- bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
-
- bc().setCancel(closePB);
- bc().setApply(applyPB);
- bc().setOK(okPB);
- bc().setRestore(restorePB);
-
- bc().addReadOnly(floatFP);
-}
-
-
-void GuiFloat::change_adaptor()
-{
- changed();
-}
-
-
-void GuiFloat::updateContents()
-{
- floatFP->set(params_);
-}
-
-
-void GuiFloat::applyView()
-{
- params_.placement = floatFP->get(params_.wide, params_.sideways);
+ connect(floatFP, SIGNAL(changed()), this, SLOT(applyView()));
}
-bool GuiFloat::initialiseParams(string const & data)
+void GuiFloat::enableView(bool enable)
{
- InsetFloat::string2params(data, params_);
- return true;
+ floatFP->setEnabled(enable);
}
-void GuiFloat::clearParams()
+void GuiFloat::paramsToDialog(Inset const * inset)
{
- params_ = InsetFloatParams();
+ floatFP->paramsToDialog(inset);
}
-void GuiFloat::dispatchParams()
+docstring GuiFloat::dialogToParams() const
{
- dispatch(FuncRequest(getLfun(), InsetFloat::params2string(params_)));
+ return floatFP->dialogToParams();
}
-
Dialog * createGuiFloat(GuiView & lv) { return new GuiFloat(lv); }
-
} // namespace frontend
} // namespace lyx
#ifndef GUIFLOAT_H
#define GUIFLOAT_H
-#include "GuiDialog.h"
+#include "InsetDialog.h"
+
#include "ui_FloatUi.h"
-#include "insets/InsetFloat.h"
namespace lyx {
namespace frontend {
-class GuiFloat : public GuiDialog, public Ui::FloatUi
+class GuiFloat : public InsetDialog, public Ui::FloatUi
{
Q_OBJECT
public:
GuiFloat(GuiView & lv);
-private Q_SLOTS:
- void change_adaptor();
-
-private:
- /// Apply changes
- void applyView();
- /// update
- void updateContents();
- ///
- bool initialiseParams(std::string const & data);
- /// clean-up on hide.
- void clearParams();
- /// clean-up on hide.
- void dispatchParams();
- ///
- bool isBufferDependent() const { return true; }
-
private:
- ///
- InsetFloatParams params_;
+ /// \name Dialog inerited methods
+ //@{
+ void enableView(bool enable);
+ //@}
+
+ /// \name InsetDialog inherited methods
+ //@{
+ void paramsToDialog(Inset const *);
+ docstring dialogToParams() const;
+ //@}
};
} // namespace frontend
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>FloatPlacementUi</class>
- <widget class="QWidget" name="FloatPlacementUi" >
- <property name="geometry" >
+ <widget class="QWidget" name="FloatPlacementUi">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<height>295</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="0" column="0" colspan="2" >
- <widget class="QCheckBox" name="defaultsCB" >
- <property name="text" >
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QLabel" name="floatTypeTitle">
+ <property name="text">
+ <string>Float Type:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="floatType">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <spacer name="spacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="defaultsCB">
+ <property name="text">
<string>Use &default placement</string>
</property>
</widget>
</item>
- <item row="1" column="0" >
- <widget class="QGroupBox" name="options" >
- <property name="title" >
+ <item row="3" column="0">
+ <widget class="QGroupBox" name="options">
+ <property name="title">
<string>Advanced Placement Options</string>
</property>
- <layout class="QGridLayout" >
- <property name="margin" >
+ <layout class="QGridLayout">
+ <property name="margin">
<number>9</number>
</property>
- <property name="spacing" >
+ <property name="spacing">
<number>6</number>
</property>
- <item row="0" column="0" >
- <widget class="QCheckBox" name="topCB" >
- <property name="text" >
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="topCB">
+ <property name="text">
<string>&Top of page</string>
</property>
</widget>
</item>
- <item row="5" column="0" >
- <widget class="QCheckBox" name="ignoreCB" >
- <property name="text" >
+ <item row="5" column="0">
+ <widget class="QCheckBox" name="ignoreCB">
+ <property name="text">
<string>&Ignore LaTeX rules</string>
</property>
</widget>
</item>
- <item row="4" column="0" >
- <widget class="QCheckBox" name="heredefinitelyCB" >
- <property name="text" >
+ <item row="4" column="0">
+ <widget class="QCheckBox" name="heredefinitelyCB">
+ <property name="text">
<string>Here de&finitely</string>
</property>
</widget>
</item>
- <item row="3" column="0" >
- <widget class="QCheckBox" name="herepossiblyCB" >
- <property name="text" >
+ <item row="3" column="0">
+ <widget class="QCheckBox" name="herepossiblyCB">
+ <property name="text">
<string>&Here if possible</string>
</property>
</widget>
</item>
- <item row="2" column="0" >
- <widget class="QCheckBox" name="pageCB" >
- <property name="text" >
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="pageCB">
+ <property name="text">
<string>&Page of floats</string>
</property>
</widget>
</item>
- <item row="1" column="0" >
- <widget class="QCheckBox" name="bottomCB" >
- <property name="text" >
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="bottomCB">
+ <property name="text">
<string>&Bottom of page</string>
</property>
</widget>
</layout>
</widget>
</item>
- <item row="1" column="1" >
+ <item row="3" column="1">
<spacer>
- <property name="orientation" >
+ <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>20</height>
</property>
</spacer>
</item>
- <item row="2" column="0" colspan="2" >
- <widget class="QCheckBox" name="spanCB" >
- <property name="text" >
+ <item row="4" column="0">
+ <widget class="QCheckBox" name="spanCB">
+ <property name="text">
<string>&Span columns</string>
</property>
</widget>
</item>
- <item row="3" column="0" colspan="2" >
- <widget class="QCheckBox" name="sidewaysCB" >
- <property name="text" >
+ <item row="5" column="0">
+ <widget class="QCheckBox" name="sidewaysCB">
+ <property name="text">
<string>&Rotate sideways</string>
</property>
</widget>
</item>
- <item row="4" column="0" >
+ <item row="6" column="0">
<spacer>
- <property name="orientation" >
+ <property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</layout>
</widget>
<includes>
- <include location="local" >qt_i18n.h</include>
+ <include location="local">qt_i18n.h</include>
</includes>
<resources/>
<connections>
<receiver>options</receiver>
<slot>setDisabled(bool)</slot>
<hints>
- <hint type="sourcelabel" >
+ <hint type="sourcelabel">
<x>51</x>
<y>20</y>
</hint>
- <hint type="destinationlabel" >
+ <hint type="destinationlabel">
<x>201</x>
<y>47</y>
</hint>
-<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>FloatUi</class>
- <widget class="QDialog" name="FloatUi" >
- <property name="geometry" >
+ <widget class="QDialog" name="FloatUi">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<height>336</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string/>
</property>
- <property name="sizeGripEnabled" >
+ <property name="sizeGripEnabled">
<bool>true</bool>
</property>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>11</number>
- </property>
- <property name="spacing" >
+ <layout class="QVBoxLayout">
+ <property name="spacing">
<number>6</number>
</property>
+ <property name="margin">
+ <number>11</number>
+ </property>
<item>
- <widget class="lyx::FloatPlacement" name="floatFP" />
+ <widget class="lyx::FloatPlacement" name="floatFP" native="true"/>
</item>
<item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
+ <layout class="QHBoxLayout">
+ <property name="spacing">
<number>6</number>
</property>
- <item>
- <widget class="QPushButton" name="restorePB" >
- <property name="text" >
- <string>&Restore</string>
- </property>
- <property name="autoDefault" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
+ <property name="margin">
+ <number>0</number>
+ </property>
<item>
<spacer>
- <property name="orientation" >
+ <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeType" >
+ <property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</spacer>
</item>
<item>
- <widget class="QPushButton" name="okPB" >
- <property name="text" >
- <string>&OK</string>
+ <widget class="QPushButton" name="newPB">
+ <property name="toolTip">
+ <string/>
</property>
- <property name="default" >
- <bool>true</bool>
+ <property name="text">
+ <string>&New</string>
</property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="applyPB" >
- <property name="text" >
- <string>&Apply</string>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>false</bool>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="closePB" >
- <property name="text" >
+ <widget class="QPushButton" name="closePB">
+ <property name="text">
<string>&Close</string>
</property>
</widget>
</item>
</layout>
</widget>
- <pixmapfunction></pixmapfunction>
- <includes>
- <include location="local" >qt_i18n.h</include>
- </includes>
<customwidgets>
<customwidget>
<class>lyx::FloatPlacement</class>
<extends></extends>
<header>FloatPlacement.h</header>
<container>1</container>
- <pixmap></pixmap>
</customwidget>
</customwidgets>
<tabstops>
- <tabstop>restorePB</tabstop>
- <tabstop>okPB</tabstop>
- <tabstop>applyPB</tabstop>
<tabstop>closePB</tabstop>
</tabstops>
+ <includes>
+ <include location="local">qt_i18n.h</include>
+ </includes>
<resources/>
<connections/>
</ui>
//
// Lgb
-
+//FIXME: why do we set in stone the type here?
InsetFloat::InsetFloat(Buffer * buf, string const & type)
: InsetCollapsable(buf), name_(from_utf8(type))
{
}
-InsetFloat::~InsetFloat()
-{
- hideDialogs("float", this);
-}
-
-
docstring InsetFloat::name() const
{
return "Float:" + name_;
void InsetFloatParams::write(ostream & os) const
{
- os << "Float " << type << '\n';
+ os << type << '\n';
if (!placement.empty())
os << "placement " << placement << "\n";
void InsetFloat::write(ostream & os) const
{
+ os << "Float ";
params_.write(os);
InsetCollapsable::write(os);
}
bool InsetFloat::showInsetDialog(BufferView * bv) const
{
if (!InsetText::showInsetDialog(bv))
- bv->showDialog("float", params2string(params()),
- const_cast<InsetFloat *>(this));
+ bv->showDialog("float");
return true;
}
Lexer lex;
lex.setStream(data);
lex.setContext("InsetFloat::string2params");
- lex >> "float" >> "Float";
lex >> params.type; // We have to read the type here!
params.read(lex);
}
string InsetFloat::params2string(InsetFloatParams const & params)
{
ostringstream data;
- data << "float" << ' ';
params.write(data);
return data.str();
}