Skip to content
Snippets Groups Projects
Commit 2c8ebffa authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Fixed group property is finally removed from SessionItem family

parent 06490c94
No related branches found
No related tags found
No related merge requests found
...@@ -22,16 +22,10 @@ ...@@ -22,16 +22,10 @@
GroupProperty::GroupProperty(QString group_name) GroupProperty::GroupProperty(QString group_name)
: m_group_name(std::move(group_name)) : m_group_name(std::move(group_name))
, m_group_type(UNDEFINED)
, m_groupItem(0) , m_groupItem(0)
{ {
} }
GroupProperty::EGroupType GroupProperty::type() const
{
return m_group_type;
}
SessionItem *GroupProperty::getCurrentItem() SessionItem *GroupProperty::getCurrentItem()
{ {
qDebug() << "GroupProperty::getCurrentItem()" << m_groupItem; qDebug() << "GroupProperty::getCurrentItem()" << m_groupItem;
...@@ -50,17 +44,9 @@ void GroupProperty::setGroupItem(SessionItem *groupItem) ...@@ -50,17 +44,9 @@ void GroupProperty::setGroupItem(SessionItem *groupItem)
SessionItem *GroupProperty::createCorrespondingItem() SessionItem *GroupProperty::createCorrespondingItem()
{ {
SessionItem *result = ItemFactory::createItem(getCurrentType()); SessionItem *result = ItemFactory::createItem(getCurrentType());
if(type() == FIXED) {
setCurrentLabel(result->itemLabel());
}
return result; return result;
} }
QString GroupProperty::getGroupName() const
{
return m_group_name;
}
QString GroupProperty::getCurrentType() const QString GroupProperty::getCurrentType() const
{ {
return m_current_type; return m_current_type;
...@@ -68,7 +54,6 @@ QString GroupProperty::getCurrentType() const ...@@ -68,7 +54,6 @@ QString GroupProperty::getCurrentType() const
void GroupProperty::setCurrentType(const QString &type, bool) void GroupProperty::setCurrentType(const QString &type, bool)
{ {
qDebug() << "GGG GroupProperty::setCurrentType(const QString &type)" << type;
if(type == getCurrentType()) return; if(type == getCurrentType()) return;
SessionItem *prevItem = getCurrentItem(); SessionItem *prevItem = getCurrentItem();
...@@ -97,20 +82,6 @@ QString GroupProperty::getCurrentLabel() const ...@@ -97,20 +82,6 @@ QString GroupProperty::getCurrentLabel() const
return m_type_label_map.at(m_current_type); return m_type_label_map.at(m_current_type);
} }
void GroupProperty::setCurrentLabel(const QString &label)
{
if(type() == FIXED) {
m_type_label_map[m_current_type] = label;
// if(m_groupItem) {
// m_groupItem->emitDataChanged();
// }
//// if(m_groupItem) m_groupItem->getItem(getGroupName())->emitValueChanged();
//// if(m_groupItem) {
//// qDebug() << "!!!" << m_groupItem
//// }
}
}
QStringList GroupProperty::getTypes() const QStringList GroupProperty::getTypes() const
{ {
QStringList result; QStringList result;
...@@ -154,19 +125,8 @@ QString GroupProperty::toString(int index) const ...@@ -154,19 +125,8 @@ QString GroupProperty::toString(int index) const
return name_list[index]; return name_list[index];
} }
bool GroupProperty::isFixed() const
{
return m_group_type == GroupProperty::FIXED;
}
void GroupProperty::setGroupMap(std::map<QString, QString> group_map) void GroupProperty::setGroupMap(std::map<QString, QString> group_map)
{ {
m_type_label_map = std::move(group_map); m_type_label_map = std::move(group_map);
setCurrentType(m_type_label_map.begin()->first); setCurrentType(m_type_label_map.begin()->first);
} }
void GroupProperty::setGroupType(GroupProperty::EGroupType group_type)
{
m_group_type = group_type;
}
...@@ -33,23 +33,16 @@ class SessionItem; ...@@ -33,23 +33,16 @@ class SessionItem;
class BA_CORE_API_ GroupProperty class BA_CORE_API_ GroupProperty
{ {
public: public:
enum EGroupType { UNDEFINED, FIXED, SELECTABLE };
EGroupType type() const;
void setGroupItem(SessionItem *groupItem); void setGroupItem(SessionItem *groupItem);
SessionItem *getCurrentItem(); SessionItem *getCurrentItem();
SessionItem *createCorrespondingItem(); SessionItem *createCorrespondingItem();
QString getGroupName() const;
QString getCurrentType() const; QString getCurrentType() const;
void setCurrentType(const QString &type, bool = true); void setCurrentType(const QString &type, bool = true);
QString getCurrentLabel() const; QString getCurrentLabel() const;
void setCurrentLabel(const QString &label);
QStringList getTypes() const; QStringList getTypes() const;
QStringList getLabels() const; QStringList getLabels() const;
...@@ -58,26 +51,19 @@ public: ...@@ -58,26 +51,19 @@ public:
int toIndex(const QString &type) const; int toIndex(const QString &type) const;
QString toString(int index) const; QString toString(int index) const;
bool isFixed() const;
friend class GroupPropertyRegistry; friend class GroupPropertyRegistry;
private: private:
GroupProperty(QString group_name); GroupProperty(QString group_name);
void setGroupMap(std::map<QString, QString> group_map); void setGroupMap(std::map<QString, QString> group_map);
void setGroupType(EGroupType group_type);
QString m_group_name; QString m_group_name;
EGroupType m_group_type;
SessionItem *m_groupItem; SessionItem *m_groupItem;
QString m_current_type; QString m_current_type;
std::map<QString, QString > m_type_label_map; std::map<QString, QString > m_type_label_map;
}; };
typedef QSharedPointer<GroupProperty> GroupProperty_t; typedef QSharedPointer<GroupProperty> GroupProperty_t;
Q_DECLARE_METATYPE(GroupProperty_t) Q_DECLARE_METATYPE(GroupProperty_t)
#endif #endif
...@@ -143,25 +143,8 @@ GroupPropertyRegistry::createGroupProperty(const QString &group_name, ...@@ -143,25 +143,8 @@ GroupPropertyRegistry::createGroupProperty(const QString &group_name,
const Constants::ModelType &group_type) const Constants::ModelType &group_type)
{ {
Q_ASSERT(isValidGroup(group_type)); Q_ASSERT(isValidGroup(group_type));
Constants::ModelType groupModelType = group_type;
if (groupModelType.isEmpty())
groupModelType = group_name;
GroupProperty_t result(new GroupProperty(group_name)); GroupProperty_t result(new GroupProperty(group_name));
result->setGroupMap(m_selectable_group_map[group_type]);
if (m_selectable_group_map.find(groupModelType) != m_selectable_group_map.end()) {
qDebug() << "GroupPropertyRegistry::createGroupProperty() -> creating selectable group of "
"groupModelType" << groupModelType;
result->setGroupType(GroupProperty::SELECTABLE);
result->setGroupMap(m_selectable_group_map[groupModelType]);
} else {
result->setGroupType(GroupProperty::FIXED);
// result->setValue(group_n);
std::map<QString, QString> group_map;
group_map[groupModelType] = "No label";
result->setGroupMap(group_map);
}
return result; return result;
} }
...@@ -43,13 +43,8 @@ QStringList ModelPath::getParameterTreeList(const SessionItem *item, QString pre ...@@ -43,13 +43,8 @@ QStringList ModelPath::getParameterTreeList(const SessionItem *item, QString pre
if (p_child->modelType() == Constants::GroupItemType) { if (p_child->modelType() == Constants::GroupItemType) {
if (const GroupItem *groupItem = dynamic_cast<const GroupItem*>(p_child)) { if (const GroupItem *groupItem = dynamic_cast<const GroupItem*>(p_child)) {
if (const SessionItem *subItem = groupItem->group()->getCurrentItem()) { if (const SessionItem *subItem = groupItem->group()->getCurrentItem()) {
if (groupItem->group()->isFixed()) { QString child_prefix = prefix + subItem->itemName() + QString("/");
QString child_prefix = prefix + groupItem->itemName() + QString("/"); result << getParameterTreeList(subItem, child_prefix);
result << getParameterTreeList(subItem, child_prefix);
} else {
QString child_prefix = prefix + subItem->itemName() + QString("/");
result << getParameterTreeList(subItem, child_prefix);
}
} }
} }
} else { } else {
......
...@@ -51,13 +51,11 @@ void ParameterModelBuilder::createParameterTree(JobItem *item, const QString tag ...@@ -51,13 +51,11 @@ void ParameterModelBuilder::createParameterTree(JobItem *item, const QString tag
void ParameterModelBuilder::handleItem(SessionItem *tree, SessionItem *source) void ParameterModelBuilder::handleItem(SessionItem *tree, SessionItem *source)
{ {
if (tree->modelType() == Constants::ParameterLabelType) { if (tree->modelType() == Constants::ParameterLabelType) {
GroupItem *parent = dynamic_cast<GroupItem*>(source->parent()); tree->setDisplayName(source->itemName());
if (parent && parent->group()->isFixed()) {
tree->setDisplayName(parent->itemName()); }
} else {
tree->setDisplayName(source->itemName()); else if (tree->modelType() == Constants::ParameterType) {
}
} else if (tree->modelType() == Constants::ParameterType) {
tree->setDisplayName(source->itemName()); tree->setDisplayName(source->itemName());
tree->setValue(source->value()); tree->setValue(source->value());
QString path = ModelPath::getPathFromIndex(source->index()); QString path = ModelPath::getPathFromIndex(source->index());
...@@ -66,9 +64,12 @@ void ParameterModelBuilder::handleItem(SessionItem *tree, SessionItem *source) ...@@ -66,9 +64,12 @@ void ParameterModelBuilder::handleItem(SessionItem *tree, SessionItem *source)
tree->setItemValue(ParameterItem::P_LINK, path); tree->setItemValue(ParameterItem::P_LINK, path);
tree->setItemValue(ParameterItem::P_BACKUP, source->value()); tree->setItemValue(ParameterItem::P_BACKUP, source->value());
return; return;
} else { }
else {
return; return;
} }
for (SessionItem *child : source->childItems()) { for (SessionItem *child : source->childItems()) {
if (child->isVisible() && child->isEnabled()) { if (child->isVisible() && child->isEnabled()) {
if (child->modelType() == Constants::PropertyType) { if (child->modelType() == Constants::PropertyType) {
......
...@@ -113,45 +113,26 @@ GroupPropertyEdit::~GroupPropertyEdit() ...@@ -113,45 +113,26 @@ GroupPropertyEdit::~GroupPropertyEdit()
void GroupPropertyEdit::setGroupProperty( void GroupPropertyEdit::setGroupProperty(
GroupProperty_t groupProperty) GroupProperty_t groupProperty)
{ {
qDebug() << "GroupPropertyEdit::setGroupProperty() ->" << groupProperty;
if(groupProperty) { if(groupProperty) {
m_groupProperty = groupProperty; m_groupProperty = groupProperty;
processGroup();
if(groupProperty->type() == GroupProperty::FIXED) {
processFixedGroup();
}
else if(groupProperty->type() == GroupProperty::SELECTABLE) {
processSelectableGroup();
}
else {
throw GUIHelpers::Error(" GroupPropertyEdit::setGroupProperty() -> Error. Unknown group type");
}
} }
} }
void GroupPropertyEdit::processFixedGroup() void GroupPropertyEdit::processGroup()
{
qDebug() << "GroupPropertyEdit::processFixedGroup()" << m_groupProperty->getCurrentLabel();
m_box->hide();
m_label->show();
m_label->setText(m_groupProperty->getCurrentLabel());
}
void GroupPropertyEdit::processSelectableGroup()
{ {
qDebug() << "GroupPropertyEdit::processSelectableGroup()"; qDebug() << "GroupPropertyEdit::processGroup()";
disconnect(m_box, SIGNAL(currentIndexChanged(int)), disconnect(m_box, SIGNAL(currentIndexChanged(int)),
this, SLOT(indexChanged(int))); this, SLOT(indexChanged(int)));
if(m_box->count() != m_groupProperty->getLabels().size()) { if(m_box->count() != m_groupProperty->getLabels().size()) {
m_box->clear(); m_box->clear();
qDebug() << "XXX inserting_items" << m_groupProperty->getLabels();
m_box->insertItems(0, m_groupProperty->getLabels()); m_box->insertItems(0, m_groupProperty->getLabels());
} }
m_box->setCurrentIndex(m_groupProperty->index()); m_box->setCurrentIndex(m_groupProperty->index());
connect(m_box, SIGNAL(currentIndexChanged(int)), connect(m_box, SIGNAL(currentIndexChanged(int)),
this, SLOT(indexChanged(int))); this, SLOT(indexChanged(int)), Qt::UniqueConnection);
} }
void GroupPropertyEdit::indexChanged(int index) void GroupPropertyEdit::indexChanged(int index)
...@@ -162,23 +143,23 @@ void GroupPropertyEdit::indexChanged(int index) ...@@ -162,23 +143,23 @@ void GroupPropertyEdit::indexChanged(int index)
QSize GroupPropertyEdit::sizeHint() const QSize GroupPropertyEdit::sizeHint() const
{ {
if(m_box) { if(m_box)
return m_box->sizeHint(); return m_box->sizeHint();
}
if(m_label) { if(m_label)
return m_label->sizeHint(); return m_label->sizeHint();
}
return QSize(100,10); return QSize(100,10);
} }
QSize GroupPropertyEdit::minimumSizeHint() const QSize GroupPropertyEdit::minimumSizeHint() const
{ {
if(m_box) { if(m_box)
return m_box->minimumSizeHint(); return m_box->minimumSizeHint();
}
if(m_label) { if(m_label)
return m_label->minimumSizeHint(); return m_label->minimumSizeHint();
}
return QSize(100,10); return QSize(100,10);
} }
......
...@@ -70,14 +70,14 @@ public: ...@@ -70,14 +70,14 @@ public:
GroupProperty_t group() const; GroupProperty_t group() const;
void setGroup(GroupProperty_t group); void setGroup(GroupProperty_t group);
signals: signals:
void groupPropertyChanged(const GroupProperty_t &group_property); void groupPropertyChanged(const GroupProperty_t &group_property);
private slots: private slots:
void indexChanged(int index); void indexChanged(int index);
private: private:
void processFixedGroup(); void processGroup();
void processSelectableGroup();
QComboBox *m_box; QComboBox *m_box;
QLabel *m_label; QLabel *m_label;
GroupProperty_t m_groupProperty; GroupProperty_t m_groupProperty;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment