]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/FloatPlacement.cpp
Fix the tab ordering of GuiDocument components.
[lyx.git] / src / frontends / qt4 / FloatPlacement.cpp
index 875c3c036192c78b1009483f75ca8f951db18ea1..be5cf0543ae5be78dcb9a7207c1c2b4da2e7383e 100644 (file)
 #include "FloatPlacement.h"
 #include "qt_helpers.h"
 
+#include "Buffer.h"
+#include "BufferParams.h"
+#include "FloatList.h"
+#include "TextClass.h"
+
 #include "insets/InsetFloat.h"
 #include "support/lstrings.h"
 
+#include <map>
+
 using namespace std;
 using namespace lyx::support;
 
 
 namespace lyx {
 
+namespace frontend {
+
 FloatPlacement::FloatPlacement(bool show_options, QWidget * parent)
-       : QWidget(parent)
+       : InsetParamsWidget(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()));
@@ -37,6 +47,8 @@ FloatPlacement::FloatPlacement(bool show_options, QWidget * parent)
        connect(spanCB, SIGNAL(clicked()), this, SLOT(changedSlot()));
        connect(sidewaysCB, SIGNAL(clicked()), this, SLOT(changedSlot()));
 
+       floatTypeTitle->setVisible(show_options);
+       floatTypeCO->setVisible(show_options);
        spanCB->setVisible(show_options);
        sidewaysCB->setVisible(show_options);
 }
@@ -45,7 +57,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 +118,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.floattype()));
+       }
+}
+
+
 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);
 
@@ -220,6 +251,7 @@ void FloatPlacement::checkAllowed()
        }
 }
 
+} // namespace frontend
 } // namespace lyx
 
 #include "moc_FloatPlacement.cpp"