Commit aaa5218c authored by LACROIX Romain's avatar LACROIX Romain

More simple implementation : no need to instantiate WidgetsCategoryItem, this work is

done automatically by the WidgetsCategory constructor.
parent b5d19c7f
......@@ -55,29 +55,33 @@ dtkVisualizationDecoratorWithClutPrivate::dtkVisualizationDecoratorWithClutPriva
this->fields_box = new QComboBox;
this->field_components = new QComboBox;
this->field_components->setObjectName("Component");
this->field_components->addItem("Uniform");
this->field_components->addItem("Magnitude");
this->field_components->addItem("X");
this->field_components->addItem("Y");
this->field_components->addItem("W");
this->field_components->setCurrentIndex(0);
this->field_components->setObjectName("Component"); // to remove
this->fixed_range = new QCheckBox;
this->min_range = new QLineEdit;
this->max_range = new QLineEdit;
this->colormap_editor = new dtkVisualizationWidgetsColorMapEditor;
this->colormap_editor->setObjectName("Color Map");
this->show_scalar_bar = new QCheckBox;
this->show_scalar_bar->setObjectName("Scalar Bar");
QHBoxLayout *h_layout_range = new QHBoxLayout;
QWidget *range_widget = new QWidget;
range_widget->setObjectName("Fixed Range");
//////////
// Inspectors setup
show_actor_cb = new QCheckBox;
show_actor_cb->setObjectName("Display");
QDoubleValidator *double_validator = new QDoubleValidator;
double_validator->setDecimals(9);
......@@ -94,17 +98,16 @@ dtkVisualizationDecoratorWithClutPrivate::dtkVisualizationDecoratorWithClutPriva
this->show_scalar_bar->setChecked(false);
this->fields_box->setObjectName("Field");
range_widget->setObjectName("");
this->inspectors
<< this->fields_box
<< new dtkVisualizationWidgetsCategory("Elements", {
new dtkVisualizationWidgetsCategoryItem("Display", this->show_actor_cb),
new dtkVisualizationWidgetsCategoryItem("Scalar Bar", this->show_scalar_bar) } )
this->show_actor_cb,
this->show_scalar_bar } )
<< new dtkVisualizationWidgetsCategory("Colors", {
new dtkVisualizationWidgetsCategoryItem("Color Map", colormap_editor),
new dtkVisualizationWidgetsCategoryItem("Fixed Range", range_widget),
new dtkVisualizationWidgetsCategoryItem("Component", this->field_components) } );
colormap_editor,
range_widget,
this->field_components } );
}
void dtkVisualizationDecoratorWithClutPrivate::clear(void)
......
......@@ -24,7 +24,6 @@
class dtkVisualizationView2D;
class dtkVisualizationWidgetsColorMapEditor;
class dtkVisualizationWidgetsCategoryItem;
class QComboBox;
class QCheckBox;
......
......@@ -2,32 +2,24 @@
#include <QtWidgets>
dtkVisualizationWidgetsCategoryItem::dtkVisualizationWidgetsCategoryItem(const QString& name, QWidget *child, QWidget *parent) : QGroupBox(parent), c(child)
{
child->setObjectName(name);
QLayout *layout = new QHBoxLayout;
layout->setContentsMargins(0,0,0,0);
layout->addWidget(new QLabel(name));
layout->addWidget(c);
setLayout(layout);
setStyleSheet("QGroupBox { margin: 0px; padding-left: 20px }");
}
dtkVisualizationWidgetsCategoryItem::~dtkVisualizationWidgetsCategoryItem() { }
QWidget *dtkVisualizationWidgetsCategoryItem::child()
{
return c;
}
dtkVisualizationWidgetsCategory::dtkVisualizationWidgetsCategory(const QString& name, const QVector<QWidget*>& widgets, QWidget* parent) : QGroupBox(parent)
{
QLayout *layout = new QVBoxLayout;
layout->setContentsMargins(0,0,0,0);
for (auto *widget: widgets)
{
layout->addWidget(widget);
widget->setParent(this);
const QString item_name = widget->objectName();
Q_ASSERT_X(item_name.length(), Q_FUNC_INFO, "widget name must not be empty when it is a category item");
QLayout *item_layout = new QHBoxLayout;
item_layout->setContentsMargins(0,0,0,0);
item_layout->addWidget(new QLabel(item_name));
item_layout->addWidget(widget);
QGroupBox *item_box = new QGroupBox;
item_box->setLayout(item_layout);
item_box->setStyleSheet("QGroupBox { margin: 0px; padding-left: 20px }");
layout->addWidget(item_box);
item_box->setParent(this);
}
setObjectName(name);
setLayout(layout);
......
......@@ -4,18 +4,6 @@
#include <QGroupBox>
class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsCategoryItem : public QGroupBox
{
public:
dtkVisualizationWidgetsCategoryItem(const QString& name, QWidget *child, QWidget *parent = nullptr);
~dtkVisualizationWidgetsCategoryItem(void);
QWidget *child(void);
private:
QWidget *c;
};
class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsCategory : public QGroupBox
{
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment