mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
* InsetFloat:
- now accept a full parameter string at construction - LFUN_INSET_MODIFY now also interprets float type. * FloatPlacement: - The float type label is replace with a combo that can be used to change the type. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33412 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2d928ba437
commit
4c9f0eb5e6
@ -77,8 +77,6 @@ namespace Alert = frontend::Alert;
|
|||||||
|
|
||||||
Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
|
Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
|
||||||
{
|
{
|
||||||
BufferParams const & params = buf->params();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
@ -148,27 +146,13 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
|
|||||||
case LFUN_OPTIONAL_INSERT:
|
case LFUN_OPTIONAL_INSERT:
|
||||||
return new InsetOptArg(buf);
|
return new InsetOptArg(buf);
|
||||||
|
|
||||||
case LFUN_FLOAT_INSERT: {
|
case LFUN_FLOAT_INSERT:
|
||||||
// check if the float type exists
|
return new InsetFloat(buf, to_utf8(cmd.argument()));
|
||||||
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: {
|
case LFUN_FLOAT_WIDE_INSERT: {
|
||||||
// check if the float type exists
|
InsetFloat * fl = new InsetFloat(buf, to_utf8(cmd.argument()));
|
||||||
string const argument = to_utf8(cmd.argument());
|
fl->setWide(true);
|
||||||
if (params.documentClass().floats().typeExist(argument)) {
|
return fl;
|
||||||
auto_ptr<InsetFloat> p(new InsetFloat(buf, argument));
|
|
||||||
p->setWide(true);
|
|
||||||
return p.release();
|
|
||||||
}
|
|
||||||
lyxerr << "Non-existent float type: " << argument << endl;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_WRAP_INSERT: {
|
case LFUN_WRAP_INSERT: {
|
||||||
@ -574,9 +558,7 @@ Inset * readInset(Lexer & lex, Buffer * buf)
|
|||||||
} else if (tmptok == "OptArg") {
|
} else if (tmptok == "OptArg") {
|
||||||
inset.reset(new InsetOptArg(buf));
|
inset.reset(new InsetOptArg(buf));
|
||||||
} else if (tmptok == "Float") {
|
} else if (tmptok == "Float") {
|
||||||
lex.next();
|
inset.reset(new InsetFloat(buf, string()));
|
||||||
string tmptok = lex.getString();
|
|
||||||
inset.reset(new InsetFloat(buf, tmptok));
|
|
||||||
} else if (tmptok == "Wrap") {
|
} else if (tmptok == "Wrap") {
|
||||||
lex.next();
|
lex.next();
|
||||||
string tmptok = lex.getString();
|
string tmptok = lex.getString();
|
||||||
|
@ -14,6 +14,10 @@
|
|||||||
#include "FloatPlacement.h"
|
#include "FloatPlacement.h"
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
|
|
||||||
|
#include "Buffer.h"
|
||||||
|
#include "BufferParams.h"
|
||||||
|
#include "FloatList.h"
|
||||||
|
|
||||||
#include "insets/InsetFloat.h"
|
#include "insets/InsetFloat.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
@ -24,10 +28,11 @@ using namespace lyx::support;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
FloatPlacement::FloatPlacement(bool show_options, QWidget * parent)
|
FloatPlacement::FloatPlacement(bool show_options, QWidget * parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent), float_list_(0)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
connect(floatTypeCO, SIGNAL(activated(int)), this, SLOT(changedSlot()));
|
||||||
connect(topCB, SIGNAL(clicked()), this, SLOT(changedSlot()));
|
connect(topCB, SIGNAL(clicked()), this, SLOT(changedSlot()));
|
||||||
connect(bottomCB, SIGNAL(clicked()), this, SLOT(changedSlot()));
|
connect(bottomCB, SIGNAL(clicked()), this, SLOT(changedSlot()));
|
||||||
connect(pageCB, SIGNAL(clicked()), this, SLOT(changedSlot()));
|
connect(pageCB, SIGNAL(clicked()), this, SLOT(changedSlot()));
|
||||||
@ -45,7 +50,7 @@ FloatPlacement::FloatPlacement(bool show_options, QWidget * parent)
|
|||||||
docstring FloatPlacement::dialogToParams() const
|
docstring FloatPlacement::dialogToParams() const
|
||||||
{
|
{
|
||||||
InsetFloatParams params;
|
InsetFloatParams params;
|
||||||
params.type = float_type_;
|
params.type = fromqstr(floatTypeCO->itemData(floatTypeCO->currentIndex()).toString());
|
||||||
params.placement = get(params.wide, params.sideways);
|
params.placement = get(params.wide, params.sideways);
|
||||||
return from_ascii(InsetFloat::params2string(params));
|
return from_ascii(InsetFloat::params2string(params));
|
||||||
}
|
}
|
||||||
@ -106,13 +111,32 @@ void FloatPlacement::set(string const & placement)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FloatPlacement::initFloatTypeCO(FloatList const & floats)
|
||||||
|
{
|
||||||
|
if (float_list_ == &floats)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float_list_ = &floats;
|
||||||
|
floatTypeCO->clear();
|
||||||
|
FloatList::const_iterator it = floats.begin();
|
||||||
|
FloatList::const_iterator const end = floats.end();
|
||||||
|
for (; it != end; ++it) {
|
||||||
|
floatTypeCO->addItem(qt_(it->second.name()),
|
||||||
|
toqstr(it->second.type()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FloatPlacement::paramsToDialog(Inset const * inset)
|
void FloatPlacement::paramsToDialog(Inset const * inset)
|
||||||
{
|
{
|
||||||
InsetFloat const * fl = static_cast<InsetFloat const *>(inset);
|
InsetFloat const * fl = static_cast<InsetFloat const *>(inset);
|
||||||
InsetFloatParams const & params = fl->params();
|
InsetFloatParams const & params = fl->params();
|
||||||
|
|
||||||
float_type_ = params.type;
|
BufferParams const & bp = fl->buffer().params();
|
||||||
floatType->setText(toqstr(fl->floatName(float_type_)));
|
initFloatTypeCO(bp.documentClass().floats());
|
||||||
|
|
||||||
|
int const item = floatTypeCO->findData(toqstr(params.type));
|
||||||
|
floatTypeCO->setCurrentIndex(item);
|
||||||
|
|
||||||
set(params.placement);
|
set(params.placement);
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
class FloatList;
|
||||||
class Inset;
|
class Inset;
|
||||||
class InsetFloatParams;
|
class InsetFloatParams;
|
||||||
|
|
||||||
@ -54,11 +55,13 @@ private:
|
|||||||
void checkAllowed();
|
void checkAllowed();
|
||||||
///
|
///
|
||||||
std::string const get(bool & wide, bool & sideways) const;
|
std::string const get(bool & wide, bool & sideways) const;
|
||||||
|
///
|
||||||
|
void initFloatTypeCO(FloatList const & floats);
|
||||||
|
|
||||||
/// one of figure or table?
|
/// one of figure or table?
|
||||||
bool standardfloat_;
|
bool standardfloat_;
|
||||||
///
|
///
|
||||||
std::string float_type_;
|
FloatList const * float_list_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>FloatPlacementUi</class>
|
<class>FloatPlacementUi</class>
|
||||||
<widget class="QWidget" name="FloatPlacementUi">
|
<widget class="QWidget" name="FloatPlacementUi">
|
||||||
@ -5,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>203</width>
|
<width>207</width>
|
||||||
<height>295</height>
|
<height>382</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -23,14 +24,12 @@
|
|||||||
<string>Float Type:</string>
|
<string>Float Type:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="floatType">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="floatTypeCO"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
<spacer name="spacer">
|
<spacer name="spacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -43,14 +42,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="defaultsCB">
|
<widget class="QCheckBox" name="defaultsCB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Use &default placement</string>
|
<string>Use &default placement</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QGroupBox" name="options">
|
<widget class="QGroupBox" name="options">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Advanced Placement Options</string>
|
<string>Advanced Placement Options</string>
|
||||||
@ -107,34 +106,34 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="2">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>21</width>
|
<width>12</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="spanCB">
|
<widget class="QCheckBox" name="spanCB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Span columns</string>
|
<string>&Span columns</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="sidewaysCB">
|
<widget class="QCheckBox" name="sidewaysCB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Rotate sideways</string>
|
<string>&Rotate sideways</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="6" column="1">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "frontends/Application.h"
|
#include "frontends/Application.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace lyx::support;
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
@ -111,17 +112,16 @@ namespace lyx {
|
|||||||
// Lgb
|
// Lgb
|
||||||
|
|
||||||
//FIXME: why do we set in stone the type here?
|
//FIXME: why do we set in stone the type here?
|
||||||
InsetFloat::InsetFloat(Buffer * buf, string const & type)
|
InsetFloat::InsetFloat(Buffer * buf, string params_str)
|
||||||
: InsetCollapsable(buf), name_(from_utf8(type))
|
: InsetCollapsable(buf)
|
||||||
{
|
{
|
||||||
setLabel(_("float: ") + floatName(type));
|
string2params(params_str, params_);
|
||||||
params_.type = type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
docstring InsetFloat::name() const
|
docstring InsetFloat::name() const
|
||||||
{
|
{
|
||||||
return "Float:" + name_;
|
return "Float:" + from_utf8(params_.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,8 +149,11 @@ void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
params_.wide = params.wide;
|
params_.wide = params.wide;
|
||||||
params_.sideways = params.sideways;
|
params_.sideways = params.sideways;
|
||||||
}
|
}
|
||||||
|
|
||||||
setNewLabel();
|
setNewLabel();
|
||||||
|
if (params_.type != params.type) {
|
||||||
|
params_.type = params.type;
|
||||||
|
buffer().updateLabels();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +246,7 @@ void InsetFloatParams::write(ostream & os) const
|
|||||||
void InsetFloatParams::read(Lexer & lex)
|
void InsetFloatParams::read(Lexer & lex)
|
||||||
{
|
{
|
||||||
lex.setContext("InsetFloatParams::read");
|
lex.setContext("InsetFloatParams::read");
|
||||||
|
lex >> type;
|
||||||
if (lex.checkFor("placement"))
|
if (lex.checkFor("placement"))
|
||||||
lex >> placement;
|
lex >> placement;
|
||||||
lex >> "wide" >> wide;
|
lex >> "wide" >> wide;
|
||||||
@ -262,6 +266,11 @@ void InsetFloat::read(Lexer & lex)
|
|||||||
{
|
{
|
||||||
params_.read(lex);
|
params_.read(lex);
|
||||||
InsetCollapsable::read(lex);
|
InsetCollapsable::read(lex);
|
||||||
|
// check if the float type exists
|
||||||
|
if (buffer().params().documentClass().floats().typeExist(params_.type))
|
||||||
|
setLabel(_("float: ") + floatName(params_.type));
|
||||||
|
else
|
||||||
|
setLabel(bformat(_("ERROR: Unknown float type: %1$s"), from_utf8(params_.type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -497,7 +506,6 @@ void InsetFloat::string2params(string const & in, InsetFloatParams & params)
|
|||||||
Lexer lex;
|
Lexer lex;
|
||||||
lex.setStream(data);
|
lex.setStream(data);
|
||||||
lex.setContext("InsetFloat::string2params");
|
lex.setContext("InsetFloat::string2params");
|
||||||
lex >> params.type; // We have to read the type here!
|
|
||||||
params.read(lex);
|
params.read(lex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class InsetFloat : public InsetCollapsable
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetFloat(Buffer *, std::string const &);
|
InsetFloat(Buffer * buffer, std::string params_str);
|
||||||
|
|
||||||
///
|
///
|
||||||
static void string2params(std::string const &, InsetFloatParams &);
|
static void string2params(std::string const &, InsetFloatParams &);
|
||||||
@ -108,8 +108,6 @@ private:
|
|||||||
docstring getCaption(OutputParams const &) const;
|
docstring getCaption(OutputParams const &) const;
|
||||||
///
|
///
|
||||||
InsetFloatParams params_;
|
InsetFloatParams params_;
|
||||||
///
|
|
||||||
docstring name_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user