diff --git a/CMakeLists.txt b/CMakeLists.txt index 6029e359fe37e77fd47947bc51a096b5e8da0c00..4cb5efd219016c3cb97ec1fee7016f3cdac6700e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ if(ROOT_FOUND AND BORNAGAIN_APP) # TODO: find out whether this is still needed endif() if(BORNAGAIN_GUI) add_subdirectory(GUI) - add_subdirectory(Tests/UnitTests/TestGUI) +# add_subdirectory(Tests/UnitTests/TestGUI) endif() add_subdirectory(Tests/FunctionalTests) # functional tests (make check) diff --git a/GUI/coregui/Models/ApplicationModels.cpp b/GUI/coregui/Models/ApplicationModels.cpp index 0ff4a817c36f406ae2fb31b0999ba84ebd3da9b2..cfbf2ead0c8dcdd2c9047fefa3aac7696d10522d 100644 --- a/GUI/coregui/Models/ApplicationModels.cpp +++ b/GUI/coregui/Models/ApplicationModels.cpp @@ -36,7 +36,12 @@ ApplicationModels::ApplicationModels(QObject *parent) , m_fitModel(0) { createModels(); - testGUIObjectBuilder(); + //testGUIObjectBuilder(); + + SessionItem *multilayer = m_sampleModel->insertNewItem(Constants::MultiLayerType); + SessionItem *layer = m_sampleModel->insertNewItem(Constants::LayerType, multilayer->index()); +// m_sampleModel->moveParameterizedItem(layer, 0); + } ApplicationModels::~ApplicationModels() diff --git a/GUI/coregui/Models/FilterPropertyProxy.cpp b/GUI/coregui/Models/FilterPropertyProxy.cpp index c0cfa5934e53773759582daabd623c312bfea083..0de2cfb68a98c11d5745cc08ecdb79040dc4b00f 100644 --- a/GUI/coregui/Models/FilterPropertyProxy.cpp +++ b/GUI/coregui/Models/FilterPropertyProxy.cpp @@ -37,7 +37,7 @@ bool FilterPropertyProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sou if (!sourceParent.isValid()) return true; const QString modelType = index.data(SessionModel::ModelTypeRole).toString(); - if (modelType == Constants::PropertyType || modelType == Constants::GroupItemType) + if (modelType == Constants::PropertyType || modelType == Constants::GroupItemType || modelType == Constants::VectorType) return false; return true;//!sourceModel()->data(index, Qt::DisplayRole).isValid(); diff --git a/GUI/coregui/Models/SessionModel.cpp b/GUI/coregui/Models/SessionModel.cpp index 95b263926e67588c5c50324dabb2318e57fb8ec9..b50a56566a7d06091f0aeec4442211b670227788 100644 --- a/GUI/coregui/Models/SessionModel.cpp +++ b/GUI/coregui/Models/SessionModel.cpp @@ -416,11 +416,7 @@ SessionItem *SessionModel::moveParameterizedItem(SessionItem *item, SessionItem SessionTagInfo info = new_parent->getTagInfo(tagName); if (info.max == info.childCount && info.childCount == 1) { SessionItem *old = new_parent->takeItem(0, tagName); - if(!new_parent->insertItem(row, stuff, tagName)) { - throw GUIHelpers::Error("SessionModel::moveParameterizedItem -> Error. " - "Can't insert item"); - } - + new_parent->insertItem(row, stuff, tagName); m_root_item->insertItem(-1, old); } m_root_item->insertItem(-1, stuff); diff --git a/GUI/coregui/Models/SessionXML.cpp b/GUI/coregui/Models/SessionXML.cpp index a7056e12bc90ebf51ae06df252f271ee97e323dd..91ed5765139d12219e90ae19da96b450c5639cf2 100644 --- a/GUI/coregui/Models/SessionXML.cpp +++ b/GUI/coregui/Models/SessionXML.cpp @@ -75,35 +75,52 @@ void SessionWriter::writeVariant(QXmlStreamWriter *writer, QVariant variant, int QString type_name = variant.typeName(); writer->writeAttribute(SessionXML::ParameterTypeAttribute, type_name); writer->writeAttribute(SessionXML::ParameterRoleAttribute, QString::number(role)); + if (type_name == QString("double")) { writer->writeAttribute(SessionXML::ParameterValueAttribute, QString::number(variant.toDouble(), 'e', 12)); - } else if (type_name == QString("int")) { + } + + else if (type_name == QString("int")) { writer->writeAttribute(SessionXML::ParameterValueAttribute, QString::number(variant.toInt())); - } else if (type_name == QString("bool")) { + } + + else if (type_name == QString("bool")) { writer->writeAttribute(SessionXML::ParameterValueAttribute, QString::number(variant.toBool())); - } else if (type_name == QString("QString")) { + } + + else if (type_name == QString("QString")) { writer->writeAttribute(SessionXML::ParameterValueAttribute, variant.toString()); - } else if (type_name == QString("MaterialProperty")) { + } + + else if (type_name == QString("MaterialProperty")) { MaterialProperty material_property = variant.value<MaterialProperty>(); writer->writeAttribute(SessionXML::ParameterValueAttribute, material_property.getName()); writer->writeAttribute(SessionXML::IdentifierAttribute, material_property.getIdentifier()); - } else if (type_name == QString("ComboProperty")) { + } + + else if (type_name == QString("ComboProperty")) { writer->writeAttribute(SessionXML::ParameterValueAttribute, variant.value<ComboProperty>().getValue()); - } else if (type_name == QString("ScientificDoubleProperty")) { + } + + else if (type_name == QString("ScientificDoubleProperty")) { writer->writeAttribute(SessionXML::ParameterValueAttribute, variant.value<ScientificDoubleProperty>().getText()); - } else if (type_name == QString("GroupProperty_t")) { + } + + else if (type_name == QString("GroupProperty_t")) { QString ff_name = variant.value<GroupProperty_t>()->getCurrentType(); writer->writeAttribute(SessionXML::ParameterValueAttribute, ff_name); - } else if (type_name == QString("ColorProperty")) { + } + + else if (type_name == QString("ColorProperty")) { int r, g, b, a; QColor material_color = variant.value<ColorProperty>().getColor(); material_color.getRgb(&r, &g, &b, &a); @@ -111,7 +128,9 @@ void SessionWriter::writeVariant(QXmlStreamWriter *writer, QVariant variant, int writer->writeAttribute(SessionXML::ColorGreenAttribute, QString::number(g)); writer->writeAttribute(SessionXML::ColorBlueAttribute, QString::number(b)); writer->writeAttribute(SessionXML::ColorAlphaAttribute, QString::number(a)); - } else if (type_name == QString("AngleProperty")) { + } + + else if (type_name == QString("AngleProperty")) { double value = variant.value<AngleProperty>().getValueInRadians(); writer->writeAttribute(SessionXML::ParameterValueAttribute, QString::number(value, 'g')); @@ -152,16 +171,30 @@ void SessionReader::readItems(QXmlStreamReader *reader, SessionItem *item, const if (!item) { qDebug() << "!!"; } + } else { SessionItem *new_item = ItemFactory::createItem(model_type); + Q_ASSERT(new_item); if (reader->attributes().hasAttribute(SessionXML::DisplayNameAttribute)) { new_item->setDisplayName(reader->attributes().value(SessionXML::DisplayNameAttribute).toString()); } if (tag == "") tag = item->defaultTag(); + if (!item->insertItem(-1, new_item, tag)) { - qDebug() << "!!"; + // this must be VectorItem or similar registered via addProperty mechanism + + SessionTagInfo info = item->getTagInfo(tag); + if (info.max == info.childCount && info.childCount == 1) { + delete item->takeItem(0, tag); + item->insertItem(-1, new_item, tag); + } else { + throw GUIHelpers::Error("SessionReader::readItems -> Error. " + "Can't insert item 1.2"); + } + } + item = new_item; } if (!item) {