mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +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)
|
||||
{
|
||||
BufferParams const & params = buf->params();
|
||||
|
||||
try {
|
||||
|
||||
switch (cmd.action) {
|
||||
@ -148,27 +146,13 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
|
||||
case LFUN_OPTIONAL_INSERT:
|
||||
return new InsetOptArg(buf);
|
||||
|
||||
case LFUN_FLOAT_INSERT: {
|
||||
// check if the float type exists
|
||||
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_INSERT:
|
||||
return new InsetFloat(buf, to_utf8(cmd.argument()));
|
||||
|
||||
case LFUN_FLOAT_WIDE_INSERT: {
|
||||
// check if the float type exists
|
||||
string const argument = to_utf8(cmd.argument());
|
||||
if (params.documentClass().floats().typeExist(argument)) {
|
||||
auto_ptr<InsetFloat> p(new InsetFloat(buf, argument));
|
||||
p->setWide(true);
|
||||
return p.release();
|
||||
}
|
||||
lyxerr << "Non-existent float type: " << argument << endl;
|
||||
return 0;
|
||||
InsetFloat * fl = new InsetFloat(buf, to_utf8(cmd.argument()));
|
||||
fl->setWide(true);
|
||||
return fl;
|
||||
}
|
||||
|
||||
case LFUN_WRAP_INSERT: {
|
||||
@ -574,9 +558,7 @@ Inset * readInset(Lexer & lex, Buffer * buf)
|
||||
} else if (tmptok == "OptArg") {
|
||||
inset.reset(new InsetOptArg(buf));
|
||||
} else if (tmptok == "Float") {
|
||||
lex.next();
|
||||
string tmptok = lex.getString();
|
||||
inset.reset(new InsetFloat(buf, tmptok));
|
||||
inset.reset(new InsetFloat(buf, string()));
|
||||
} else if (tmptok == "Wrap") {
|
||||
lex.next();
|
||||
string tmptok = lex.getString();
|
||||
|
@ -14,6 +14,10 @@
|
||||
#include "FloatPlacement.h"
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "FloatList.h"
|
||||
|
||||
#include "insets/InsetFloat.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
@ -24,10 +28,11 @@ using namespace lyx::support;
|
||||
namespace lyx {
|
||||
|
||||
FloatPlacement::FloatPlacement(bool show_options, QWidget * parent)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent), float_list_(0)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
connect(floatTypeCO, SIGNAL(activated(int)), this, SLOT(changedSlot()));
|
||||
connect(topCB, SIGNAL(clicked()), this, SLOT(changedSlot()));
|
||||
connect(bottomCB, 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
|
||||
{
|
||||
InsetFloatParams params;
|
||||
params.type = float_type_;
|
||||
params.type = fromqstr(floatTypeCO->itemData(floatTypeCO->currentIndex()).toString());
|
||||
params.placement = get(params.wide, params.sideways);
|
||||
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)
|
||||
{
|
||||
InsetFloat const * fl = static_cast<InsetFloat const *>(inset);
|
||||
InsetFloatParams const & params = fl->params();
|
||||
|
||||
float_type_ = params.type;
|
||||
floatType->setText(toqstr(fl->floatName(float_type_)));
|
||||
BufferParams const & bp = fl->buffer().params();
|
||||
initFloatTypeCO(bp.documentClass().floats());
|
||||
|
||||
int const item = floatTypeCO->findData(toqstr(params.type));
|
||||
floatTypeCO->setCurrentIndex(item);
|
||||
|
||||
set(params.placement);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class FloatList;
|
||||
class Inset;
|
||||
class InsetFloatParams;
|
||||
|
||||
@ -54,11 +55,13 @@ private:
|
||||
void checkAllowed();
|
||||
///
|
||||
std::string const get(bool & wide, bool & sideways) const;
|
||||
///
|
||||
void initFloatTypeCO(FloatList const & floats);
|
||||
|
||||
/// one of figure or table?
|
||||
bool standardfloat_;
|
||||
///
|
||||
std::string float_type_;
|
||||
FloatList const * float_list_;
|
||||
};
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FloatPlacementUi</class>
|
||||
<widget class="QWidget" name="FloatPlacementUi">
|
||||
@ -5,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>203</width>
|
||||
<height>295</height>
|
||||
<width>207</width>
|
||||
<height>382</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -23,14 +24,12 @@
|
||||
<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">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="floatTypeCO"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -43,14 +42,14 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="defaultsCB">
|
||||
<property name="text">
|
||||
<string>Use &default placement</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="options">
|
||||
<property name="title">
|
||||
<string>Advanced Placement Options</string>
|
||||
@ -107,34 +106,34 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="3" column="2">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<width>12</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="spanCB">
|
||||
<property name="text">
|
||||
<string>&Span columns</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="sidewaysCB">
|
||||
<property name="text">
|
||||
<string>&Rotate sideways</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="6" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "frontends/Application.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace lyx::support;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
@ -111,17 +112,16 @@ namespace lyx {
|
||||
// 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(Buffer * buf, string params_str)
|
||||
: InsetCollapsable(buf)
|
||||
{
|
||||
setLabel(_("float: ") + floatName(type));
|
||||
params_.type = type;
|
||||
string2params(params_str, params_);
|
||||
}
|
||||
|
||||
|
||||
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_.sideways = params.sideways;
|
||||
}
|
||||
|
||||
setNewLabel();
|
||||
if (params_.type != params.type) {
|
||||
params_.type = params.type;
|
||||
buffer().updateLabels();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -243,6 +246,7 @@ void InsetFloatParams::write(ostream & os) const
|
||||
void InsetFloatParams::read(Lexer & lex)
|
||||
{
|
||||
lex.setContext("InsetFloatParams::read");
|
||||
lex >> type;
|
||||
if (lex.checkFor("placement"))
|
||||
lex >> placement;
|
||||
lex >> "wide" >> wide;
|
||||
@ -262,6 +266,11 @@ void InsetFloat::read(Lexer & lex)
|
||||
{
|
||||
params_.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;
|
||||
lex.setStream(data);
|
||||
lex.setContext("InsetFloat::string2params");
|
||||
lex >> params.type; // We have to read the type here!
|
||||
params.read(lex);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class InsetFloat : public InsetCollapsable
|
||||
{
|
||||
public:
|
||||
///
|
||||
InsetFloat(Buffer *, std::string const &);
|
||||
InsetFloat(Buffer * buffer, std::string params_str);
|
||||
|
||||
///
|
||||
static void string2params(std::string const &, InsetFloatParams &);
|
||||
@ -108,8 +108,6 @@ private:
|
||||
docstring getCaption(OutputParams const &) const;
|
||||
///
|
||||
InsetFloatParams params_;
|
||||
///
|
||||
docstring name_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user